0027-ar71xx-fix-model-string-detection-on-NETGEAR-WNDR3700-3800-WNDRMAC.patch 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. From: Matthias Schiffer <mschiffer@universe-factory.net>
  2. Date: Sun, 15 Mar 2015 19:51:15 +0100
  3. Subject: ar71xx: fix model string detection on NETGEAR WNDR3700/3800/WNDRMAC
  4. There were a few issues with the existing code to detect the model string:
  5. * Always using the string starting with byte 56 would cut off the W of WNDR when
  6. the ID starts with 29763654+16+128 instead of 29763654+16+64
  7. * The string contained garbage after the zero byte instead of cutting it off
  8. after the zero (which wasn't always visible using busybox tools, but could
  9. confuse other scripts)
  10. diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh
  11. index ac7f787..f50a236 100755
  12. --- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
  13. +++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
  14. @@ -37,16 +37,28 @@ wndr3700_board_detect() {
  15. machine="NETGEAR WNDR3700"
  16. ;;
  17. "33373031")
  18. - local model
  19. - model=$(ar71xx_get_mtd_offset_size_format art 56 10 %c)
  20. - if [ -z "$model" ] || [ "$model" = $'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff' ]; then
  21. + case "$(ar71xx_get_mtd_offset_size_format art 56 10 %c)" in
  22. + $'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff')
  23. machine="NETGEAR WNDR3700v2"
  24. - elif [ -z "$model" ] || [ "$model" = $'\xff\xff\xff\xff\xff\xff\xff\xff\xffN' ]; then
  25. + ;;
  26. + $'\xff\xff\xff\xff\xff\xff\xff\xff\xffN')
  27. machine="NETGEAR WNDRMAC"
  28. - else
  29. - machine="NETGEAR $model"
  30. - fi
  31. - ;;
  32. + ;;
  33. + *)
  34. + # Use awk to remove everything after the first zero byte
  35. + model="$(ar71xx_get_mtd_offset_size_format art 41 32 %c | awk 'BEGIN{FS="[[:cntrl:]]"} {print $1; exit}')"
  36. + case $model in
  37. + '29763654+16+64'*)
  38. + machine="NETGEAR ${model:14}"
  39. + ;;
  40. + '29763654+16+128'*)
  41. + machine="NETGEAR ${model:15}"
  42. + ;;
  43. + *)
  44. + # Unknown ID
  45. + machine="NETGEAR $model"
  46. + esac
  47. + esac
  48. esac
  49. AR71XX_BOARD_NAME="$name"