查看: 4373|回复: 0

添加openwrt新设备支持

[复制链接]
  • TA的每日心情
    开心
    2016-8-15 09:30
  • 签到天数: 162 天

    连续签到: 1 天

    [LV.7]常住居民III

    发表于 2017-7-24 14:12:58 | 显示全部楼层 |阅读模式
    分享到:
    添加openwrt新设备支持

    转自互联网
    代码修改步骤
    step 1. 通过修改target/linux/ar71xx/image/Makefile 来添加新机器镜像,例如AP152-QTSA820
    1. diff --git a/target/linux/ar71xx/image/Makefile b/target/linux/ar71xx/image/Makefile
    2. index 4f02be9..9371ebf 100644
    3. --- a/target/linux/ar71xx/image/Makefile
    4. +++ b/target/linux/ar71xx/image/Makefile
    5. @@ -848,6 +848,9 @@ $(eval $(call SingleProfile,AthLzma,$(fs_64k),AP151_8M,ap151-8M,AP151,ttyS0,1152
    6. $(eval $(call SingleProfile,AthLzma,$(fs_64k),AP151_16M,ap151-16M,AP151,ttyS0,115200,$(ap151_mtdlayout_16M),1507328,$(AR71XX_16M_ROOTFS_SIZE),RKuImage))
    7. $(eval $(call SingleProfile,AthLzma,$(fs_64k),AP152_8M,ap152-8M,AP152,ttyS0,115200,$(ap152_mtdlayout_8M),1507328,$(AR71XX_8M_ROOTFS_SIZE),RKuImage))
    8. $(eval $(call SingleProfile,AthLzma,$(fs_64k),AP152_16M,ap152-16M,AP152,ttyS0,115200,$(ap152_mtdlayout_16M),1507328,$(AR71XX_16M_ROOTFS_SIZE),RKuImage))
    9. +$(eval $(call SingleProfile,AthLzma,$(fs_64k),AP152_QTSA820,ap152-QTSA820,AP152-QTSA820,ttyS0,115200,$(ap152_mtdlayout_16M),1507328,$(AR71XX_16M_ROOTFS_SIZE),RKuImage))
    10. +$(eval $(call SingleProfile,AthLzma,$(fs_64k),AP152_8200T2,ap152-8200T2,AP152-8200T2,ttyS0,115200,$(ap152_mtdlayout_16M),1507328,$(AR71XX_16M_ROOTFS_SIZE),RKuImage))
    11. +$(eval $(call SingleProfile,AthLzma,$(fs_64k),AP152_8200R2,ap152-8200R2,AP152-8200R2,ttyS0,115200,$(ap152_mtdlayout_16M),1507328,$(AR71XX_16M_ROOTFS_SIZE),RKuImage))
    12. $(eval $(call SingleProfile,AthLzma,$(fs_64k),CUS531_16M,cus531-16M,CUS531,ttyS0,115200,$(cus531_mtdlayout_16M),1507328,14876672,RKuImage))
    13. $(eval $(call SingleProfile,AthLzma,$(fs_64k),CUS531_32M,cus531-32M,CUS531,ttyS0,115200,$(cus531_mtdlayout_32M),1507328,14876672,RKuImage))
    14. $(eval $(call SingleProfile,AthLzma,$(fs_64k),CUS531_32M_DUAL,cus531-32M-dual,CUS531,ttyS0,115200,,1507328,14876672,RKuImage))
    15. @@ -983,7 +986,7 @@ $(eval $(call MultiProfile,AP121,AP121_2M AP121_4M))
    16. $(eval $(call MultiProfile,AP143,AP143_8M AP143_16M AP143_32M AP143_32M_DUAL))
    17. $(eval $(call MultiProfile,AP147,AP147_16M AP147_8M))
    18. $(eval $(call MultiProfile,AP151,AP151_16M AP151_8M))
    19. -$(eval $(call MultiProfile,AP152,AP152_16M AP152_8M))
    20. +$(eval $(call MultiProfile,AP152,AP152_QTSA820 AP152_8200T2 AP152_8200R2 AP152_16M AP152_8M))
    21. $(eval $(call MultiProfile,CUS531,CUS531_16M CUS531_32M CUS531DUAL CUS531NAND CUS531_32M_DUAL CUS531DUAL_DUAL CUS531NAND_DUAL))
    22. $(eval $(call MultiProfile,EWDORIN, EWDORINAP EWDORINRT))
    23. $(eval $(call MultiProfile,TEW652BRP,TEW652BRP_FW TEW652BRP_RECOVERY))
    24. @@ -1076,6 +1079,9 @@ define Image/Build/Profile/QSDK_Premium_Beeliner_Router
    25.         $(call Image/Build/Profile/AP135DUAL,$(1))
    26.         $(call Image/Build/Profile/AP135NAND,$(1))
    27.         $(call Image/Build/Profile/AP152_16M,$(1))
    28. +       $(call Image/Build/Profile/AP152_QTSA820,$(1))
    29. +       $(call Image/Build/Profile/AP152_8200T2,$(1))
    30. +       $(call Image/Build/Profile/AP152_8200R2,$(1))
    31.         $(call Image/Build/Profile/AP151_16M,$(1))
    32.         $(call Image/Build/Profile/AP147_16M,$(1))
    33.         $(call Image/Build/Profile/DB120_16M,$(1))   
    复制代码
    step 2. 创建新机器文件代码在kernel_repos/arch/mips/ath79/mach-ap152-qtsa820.c
    在这里需改GPIO, Port Layout, Flash memory config, wifi, usb, watchdog timer, 等开发板特有的东西
    1. diff --git a/arch/mips/ath79/mach-ap152-8200r2.c b/arch/mips/ath79/mach-ap152-8200r2.c
    2. new file mode 100644
    3. index 0000000..3a6c604
    4. --- /dev/null
    5. +++ b/arch/mips/ath79/mach-ap152-8200r2.c
    6. @@ -0,0 +1,206 @@
    7. +MIPS_MACHINE(ATH79_MACH_AP152_8200R2, "AP152-8200R2", "Qualcomm Atheros AP152-8200R2 board",
    8. +            ap152_setup);
    9. diff --git a/arch/mips/ath79/mach-ap152-8200t2.c b/arch/mips/ath79/mach-ap152-8200t2.c
    10. new file mode 100644
    11. index 0000000..323b35a
    12. --- /dev/null
    13. +++ b/arch/mips/ath79/mach-ap152-8200t2.c
    14. @@ -0,0 +1,206 @@
    15. +MIPS_MACHINE(ATH79_MACH_AP152_8200T2, "AP152-8200T2", "Qualcomm Atheros AP152-8200T2 board",
    16. +            ap152_setup);
    17. diff --git a/arch/mips/ath79/mach-ap152-qtsa820.c b/arch/mips/ath79/mach-ap152-qtsa820.c
    18. new file mode 100644
    19. index 0000000..4b64fa1
    20. --- /dev/null
    21. +++ b/arch/mips/ath79/mach-ap152-qtsa820.c
    22. +MIPS_MACHINE(ATH79_MACH_AP152_QTSA820, "AP152-QTSA820", "Qualcomm Atheros AP152-QTSA820 board",
    23. +            ap152_setup);
    复制代码
    step 3. 添加新机器索引到头文件kernel_repos/arch/mips/ath79/machtypes.h

    1. diff --git a/arch/mips/ath79/machtypes.h b/arch/mips/ath79/machtypes.h
    2. index b5417a7..3712dee 100644
    3. --- a/arch/mips/ath79/machtypes.h
    4. +++ b/arch/mips/ath79/machtypes.h
    5. @@ -33,6 +33,9 @@ enum ath79_mach_type {
    6.         ATH79_MACH_AP147,               /* Atheros AP147 reference board */
    7.         ATH79_MACH_AP151,               /* Atheros AP151 reference board */
    8.         ATH79_MACH_AP152,               /* Atheros AP152 reference board */
    9. +       ATH79_MACH_AP152_QTSA820,/* Atheros AP152-QTSA820 board */
    10. +       ATH79_MACH_AP152_8200T2,/* Atheros AP152-8200T2 board */
    11. +       ATH79_MACH_AP152_8200R2,/* Atheros AP152-8200R2 board */
    12.         ATH79_MACH_AP81,                /* Atheros AP81 reference board */
    13.         ATH79_MACH_AP83,                /* Atheros AP83 */
    14.         ATH79_MACH_AP96,                /* Atheros AP96 */
    复制代码
    step 4. 添加新机器的索引到kernel_repos/arch/mips/ath79/{Kconfig,Makefile}
    1. diff --git a/arch/mips/ath79/Kconfig b/arch/mips/ath79/Kconfig
    2. index d092806..52e5202 100644
    3. --- a/arch/mips/ath79/Kconfig
    4. +++ b/arch/mips/ath79/Kconfig
    5. @@ -176,6 +176,49 @@ config ATH79_MACH_AP152
    6.           Say 'Y' here if you want your kernel to support the
    7.           Atheros AP152 reference board.
    8.   
    9. +config ATH79_MACH_AP152_QTSA820
    10. +       bool "Atheros AP152-QTSA820 board"
    11. +       select SOC_QCA956X
    12. +       select ATH79_DEV_GPIO_BUTTONS
    13. +       select ATH79_DEV_LEDS_GPIO
    14. +       select ATH79_DEV_SPI
    15. +       select ATH79_DEV_USB
    16. +       select ATH79_DEV_WMAC
    17. +       select ATH79_DEV_ETH
    18. +       select ATH79_DEV_M25P80
    19. +       help
    20. +         Say 'Y' here if you want your kernel to support the
    21. +         Atheros AP152-QTSA820 board.
    22. +
    23. +config ATH79_MACH_AP152_8200T2
    24. +       bool "Atheros AP152-8200T2 board"
    25. +       select SOC_QCA956X
    26. +       select ATH79_DEV_GPIO_BUTTONS
    27. +       select ATH79_DEV_LEDS_GPIO
    28. +       select ATH79_DEV_SPI
    29. +       select ATH79_DEV_USB
    30. +       select ATH79_DEV_WMAC
    31. +       select ATH79_DEV_ETH
    32. +       select ATH79_DEV_M25P80
    33. +       help
    34. +         Say 'Y' here if you want your kernel to support the
    35. +         Atheros AP152-8200T2 board.
    36. +
    37. +config ATH79_MACH_AP152_8200R2
    38. +       bool "Atheros AP152-8200R2 board"
    39. +       select SOC_QCA956X
    40. +       select ATH79_DEV_GPIO_BUTTONS
    41. +       select ATH79_DEV_LEDS_GPIO
    42. +       select ATH79_DEV_SPI
    43. +       select ATH79_DEV_USB
    44. +       select ATH79_DEV_WMAC
    45. +       select ATH79_DEV_ETH
    46. +       select ATH79_DEV_M25P80
    47. +       help
    48. +         Say 'Y' here if you want your kernel to support the
    49. +         Atheros AP152-8200R2 board.
    50. +
    51. +
    52. config ATH79_MACH_AP81
    53.         bool "Atheros AP81 reference board"
    54.         select SOC_AR913X
    55. diff --git a/arch/mips/ath79/Makefile b/arch/mips/ath79/Makefile
    56. index 695e51c..806b46f 100644
    57. --- a/arch/mips/ath79/Makefile
    58. +++ b/arch/mips/ath79/Makefile
    59. @@ -57,6 +57,9 @@ obj-$(CONFIG_ATH79_MACH_AP143)                += mach-ap143.o
    60. obj-$(CONFIG_ATH79_MACH_AP147)         += mach-ap147.o
    61. obj-$(CONFIG_ATH79_MACH_AP151)         += mach-ap151.o
    62. obj-$(CONFIG_ATH79_MACH_AP152)         += mach-ap152.o
    63. +obj-$(CONFIG_ATH79_MACH_AP152_8200R2)          += mach-ap152-8200r2.o
    64. +obj-$(CONFIG_ATH79_MACH_AP152_8200T2)          += mach-ap152-8200t2.o
    65. +obj-$(CONFIG_ATH79_MACH_AP152_QTSA820)         += mach-ap152-qtsa820.o
    66. obj-$(CONFIG_ATH79_MACH_AP81)          += mach-ap81.o
    67. obj-$(CONFIG_ATH79_MACH_AP83)          += mach-ap83.o
    68. obj-$(CONFIG_ATH79_MACH_AP96)          += mach-ap96.o
    复制代码
    step 5. 用户态脚本package_repos/ok_base-files/lib/ar71xx.sh,通过解析/proc/cpuinfo来初始化board_name,model,放到/tmp/sysinfo/之后的用户态脚本通过它来区分板子
    1. diff --git a/ok_base-files/lib/ar71xx.sh b/ok_base-files/lib/ar71xx.sh
    2. index 91abca1..dedf81a 100755
    3. --- a/ok_base-files/lib/ar71xx.sh
    4. +++ b/ok_base-files/lib/ar71xx.sh
    5. @@ -205,6 +205,12 @@ ar71xx_board_detect() {
    6. +       *"AP152-QTSA820 board")
    7. +               name="ap152"
    8. +               ;;
    9. +       *"AP152-8200T2 board")
    10. +               name="ap152"
    11. +               ;;
    12. +       *"AP152-8200R2 board")
    13. +               name="ap152"
    14. +               ;;
    15.         *AP81)
    16.                 name="ap81"
    17.                 ;;
    复制代码
    1. root@oakridge:/tmp/sysinfo# cat /tmp/sysinfo/board_name
    2. ap152
    3. root@oakridge:/tmp/sysinfo# cat /tmp/sysinfo/model
    4. Qualcomm Atheros AP152-QTSA820 board
    复制代码
    setp 6. 修改各个用户态脚本来支持新的
    1. llwang@VM2~/repos/osdk_repos/package_repos/ok_base-files $ grep -rin ap152 *
    2. etc/uci-defaults/network:112:ap152)
    3. etc/diag.sh:50: ap152)
    4. etc/diag.sh:51:         status_led="ap152:green:status"
    5. lib/wifi/qcawifi.sh:356:                ap152 | ap147 | ap151 | ap135 | ap137)
    6. lib/upgrade/ap135.sh:77:        "ap152" |\
    7. lib/upgrade/ap135.sh:126:       "ap152" |\
    8. lib/upgrade/platform.sh:110:    ap152 |\
    9. lib/upgrade/platform.sh:329:    ap152 |\
    10. lib/ar71xx.sh:202:      *"AP152 reference board")
    11. lib/ar71xx.sh:203:              name="ap152"
    12. lib/ar71xx.sh:205:      *"AP152-QTSA820 board")
    13. lib/ar71xx.sh:206:              name="ap152"
    14. lib/preinit/81_load_wifi_board_bin:16:         ap152)
    复制代码
    step 7. 使用make kernel_menuconfig选中新加入的machine type,保存到targe/linux/config-3.3然后编译
    1. $ make kenerl_menuconfig
    2. Machine selection ---> Atheros AR71xx/AR724xx/AR913X machine selection ---> Atheros AP52-QTSA820 board
    复制代码
    1. diff --git a/target/linux/ar71xx/config-3.3 b/target/linux/ar71xx/config-3.3
    2. index 95a892c..e158692 100644
    3. --- a/target/linux/ar71xx/config-3.3
    4. +++ b/target/linux/ar71xx/config-3.3
    5. @@ -38,6 +38,8 @@ CONFIG_ATH79_DEV_WMAC=y
    6. # CONFIG_ATH79_MACH_AP147 is not set
    7. # CONFIG_ATH79_MACH_AP151 is not set
    8. CONFIG_ATH79_MACH_AP152=y
    9. +CONFIG_ATH79_MACH_AP152_8200R2=y
    10. +CONFIG_ATH79_MACH_AP152_8200T2=y
    11. +CONFIG_ATH79_MACH_AP152_QTSA820=y
    12. # CONFIG_ATH79_MACH_AP81 is not set
    13. # CONFIG_ATH79_MACH_AP83 is not set
    复制代码
    程序流程
    • Image Generator将board identifier放到内核的command line
    • 内核命令行通过BOARD=MY_BOARD来执行
    • 内核代码查找板子类型和机器类型相关代码
    • /lib/ar71xx.sh从/proc/cpuinfo中读取板子名称放入/tmp/sysinfo/{board_name,model}
    • 一些脚本使用这个名字来区分板子
    通用步骤
    • 详细的列出设备上的芯片,关注processor,flash,ethernet,wireless。
    • 确定串口和uboot能访问
    • 准备和安装固件,查看bootlog的问题和错误
    • 核实flash分区,LED和buttons
    GPIO
    GPIO LED Testing
    1. #!/bin/sh
    2. GPIOCHIP=0
    3. BASE=$(cat /sys/class/gpio/gpiochip${GPIOCHIP}/base)
    4. NGPIO=$(cat /sys/class/gpio/gpiochip${GPIOCHIP}/ngpio)
    5. max=$(($BASE+$NGPIO))
    6. gpio=$BASE
    7. while [ $gpio -lt $max ] ; do
    8.         echo $gpio > /sys/class/gpio/export
    9.         [ -d /sys/class/gpio/gpio${gpio} ] && {
    10.                 echo out > /sys/class/gpio/gpio$gpio/direction

    11.                 echo "[GPIO$gpio] Trying value 0"
    12.                 echo 0 > /sys/class/gpio/gpio$gpio/value
    13.                 sleep 3s

    14.                 echo "[GPIO$gpio] Trying value 1"
    15.                 echo 1 > /sys/class/gpio/gpio$gpio/value
    16.                 sleep 3s

    17.                 echo $gpio > /sys/class/gpio/unexport
    18.         }
    19.         gpio=$((gpio+1))
    20. done
    复制代码
    GPIO Button Testing
    1. #!/bin/sh
    2. GPIOCHIP=0
    3. BASE=$(cat /sys/class/gpio/gpiochip${GPIOCHIP}/base)
    4. NGPIO=$(cat /sys/class/gpio/gpiochip${GPIOCHIP}/ngpio)
    5. max=$(($BASE+$NGPIO))
    6. gpio=$BASE
    7. while [ $gpio -lt $max ] ; do
    8.         echo $gpio > /sys/class/gpio/export
    9.         [ -d /sys/class/gpio/gpio${gpio} ] && {
    10.                 echo in > /sys/class/gpio/gpio${gpio}/direction
    11.                 echo "[GPIO${gpio}] value $(cat /sys/class/gpio/gpio${gpio}/value)"
    12.                 echo ${gpio} > /sys/class/gpio/unexport
    13.         }
    14.         gpio=$((gpio+1))
    15. done
    复制代码
    回复

    使用道具 举报

    您需要登录后才可以回帖 注册/登录

    本版积分规则

    关闭

    站长推荐上一条 /2 下一条

    手机版|小黑屋|与非网

    GMT+8, 2024-3-29 09:39 , Processed in 0.133098 second(s), 17 queries , MemCache On.

    ICP经营许可证 苏B2-20140176  苏ICP备14012660号-2   苏州灵动帧格网络科技有限公司 版权所有.

    苏公网安备 32059002001037号

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.