向openwrt 源码添加ap143支持
借鉴地址:http://www.pppei.net/blog/post/536
1、向文件 \target\linux\ar71xx\generic\profiles\atheros.mk 中添加ap143类型
define Profile/AP143
NAME:=Atheros AP143 reference board // 对应make menuconfig中单板类型选择处的显示
PACKAGES:=kmod-usb-core kmod-usb2 kmod-usb-storage
endef
define Profile/AP143/Description
Package set optimized for the Atheros AP143 reference board.
endef
$(eval $(call Profile,AP143))
修改完后保存文件,然后删除tmp目录。
命令: rm -rf tmp
重新进入单板类型后,就会存在ap143单板类型。
2、
这步我提供了patch,下载后放入 target/linux/ar71xx/patches-3.18/ 下即可。
文件名称为:730-MIPS-ath79-add-ap143-support.patch
手动修改比较麻烦,于是做了patch自动完成,只修改了三个文件内核源码目录中的arch/mips/ath79/machtypes.h 和Makefile 以及Kconfig,具体修改的内容打开patch一看便知。
3、这一步要修改的这些脚本都是在刷机后,固件启动过程中用到的,也要添加对AP143单板的识别。
打开 target/linux/ar71xx/base-files/lib/ar71xx.sh 找到 ar71xx_board_detect 函数,加入单板类型:
*"AP143 reference board")
name="ap143"
;;
注:这里引号内的ap143和下面其它脚本中要修改的内容一致
target/linux/ar71xx/base-files/lib/upgrade/platform.sh
文件中函数 platform_check_image 添加“ap143”
ap136-010 | \
ap136-020 | \
ap135-020 | \
ap143 | \
ap96 | \
bxu2000n-2-a1 | \
db120 | \
注:不修改这个文件web页面刷机会提示固件不正确。
target/linux/ar71xx/base-files/etc/uci-defaults/leds
找到:
ap113)
ucidef_set_led_usbdev "usb" "USB" "ap113:green:usb" "1-1"
;;
在下面添加
ap143)
ucidef_set_led_default "wan" "WAN" "ap143:green:wan" "1"
ucidef_set_led_switch "lan1" "LAN1" "ap143:green:lan1" "switch0" "0x1"
ucidef_set_led_wlan "wlan" "WLAN" "ap143:green:wlan" "phy0tpt"
;;
target/linux/ar71xx/base-files/etc/uci-defaults/network
找到:
tl-wr841n-v9 |\
ap143 | \ // 添加了ap143
whr-g301n |\
whr-hp-g300n |\
whr-hp-gn |\
wzr-hp-ag300h)
ucidef_set_interfaces_lan_wan "eth0" "eth1"
ucidef_add_switch "switch0" "1" "1"
ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 4"
;;
注:不修改此文件无法初始化网络
target/linux/ar71xx/base-files/etc/diag.sh 中修改指示灯的工作状态。
4、
target/linux/ar71xx/image/Makefile
中添加
1)分区相关:
ap143_mtdlayout_16M=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,14528k(rootfs),1344k(kernel),64k(factory),64k(art),15872k@0x50000(firmware)
2)
$(eval $(call SingleProfile,AthLzma,64k,AP143_16M,ap143-16M,AP143,ttyS0,115200,$$(ap143_mtdlayout_16M),RKuImage))
3)
$(eval $(call MultiProfile,AP143,AP143_16M))
然后要重编译tools,清空之前编译的内容,重新编译固件生效
命令: make tools/clean
至此,板类型ap143的支持工作已经基本完成,可以编译固件了。
make menuconfig // 选中单板类型AP143
make V=99
遗留问题:编译的时候,每次都需要确认单板类型为ap143的是否编译?
* Atheros AR71XX/AR724X/AR913X machine selection
*
ALFA Network AP96 board support (ATH79_MACH_ALFA_AP96) [Y/n] y
ALFA Network Hornet-UB board support (ATH79_MACH_HORNET_UB) [Y/n] y
ALFA Network N2/N5 board support (ATH79_MACH_ALFA_NX) [Y/n] y
ALFA Network Tube2H board support (ATH79_MACH_TUBE2H) [Y/n] y
Allnet ALL0258N support (ATH79_MACH_ALL0258N) [Y/n] y
Allnet ALL0315N support (ATH79_MACH_ALL0315N) [Y/n] y
Bitmain Antminer S1 support (ATH79_MACH_ANTMINER_S1) [Y/n] y
Atheros AP113 board support (ATH79_MACH_AP113) [Y/n] y
Atheros AP121 reference board (ATH79_MACH_AP121) [Y/n/?] y
Atheros AP132 reference board (ATH79_MACH_AP132) [Y/n/?] y
Atheros AP136/AP135 reference board (ATH79_MACH_AP136) [Y/n/?] y
Atheros AP143 refernece board (ATH79_MACH_AP143) [N/y/?] (NEW)