0019-ar71xx-check-both-HWID-and-HWREV-on-upgrades-of-TP-LINK-devices.patch 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. From: Matthias Schiffer <mschiffer@universe-factory.net>
  2. Date: Fri, 1 Apr 2016 23:16:13 +0200
  3. Subject: ar71xx: check both HWID and HWREV on upgrades of TP-LINK devices
  4. There's no reason for us to be more lenient than the stock firmware, so
  5. better check the HWREV as well to avoid bricked devices.
  6. Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
  7. Backport of r49105
  8. diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
  9. index 762cd76..024e493 100755
  10. --- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
  11. +++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
  12. @@ -66,6 +66,10 @@ tplink_get_image_hwid() {
  13. get_image "$@" | dd bs=4 count=1 skip=16 2>/dev/null | hexdump -v -n 4 -e '1/1 "%02x"'
  14. }
  15. +tplink_get_image_mid() {
  16. + get_image "$@" | dd bs=4 count=1 skip=17 2>/dev/null | hexdump -v -n 4 -e '1/1 "%02x"'
  17. +}
  18. +
  19. tplink_get_image_boot_size() {
  20. get_image "$@" | dd bs=4 count=1 skip=37 2>/dev/null | hexdump -v -n 4 -e '1/1 "%02x"'
  21. }
  22. @@ -373,13 +377,17 @@ platform_check_image() {
  23. }
  24. local hwid
  25. - local imageid
  26. + local mid
  27. + local imagehwid
  28. + local imagemid
  29. hwid=$(tplink_get_hwid)
  30. - imageid=$(tplink_get_image_hwid "$1")
  31. + mid=$(tplink_get_mid)
  32. + imagehwid=$(tplink_get_image_hwid "$1")
  33. + imagemid=$(tplink_get_image_mid "$1")
  34. - [ "$hwid" != "$imageid" ] && {
  35. - echo "Invalid image, hardware ID mismatch, hw:$hwid image:$imageid."
  36. + [ "$hwid" != "$imagehwid" -o "$mid" != "$imagemid" ] && {
  37. + echo "Invalid image, hardware ID mismatch, hw:$hwid $mid image:$imagehwid $imagemid."
  38. return 1
  39. }