修改配置文件,新增自定义板卡信息
适用openwrt 版本 19.07.04
- 默认板卡配置,当前选择的是板卡为【MediaTek LinkIt Smart 7688】
.config - OpenWrt Configuration
──────────────────────────────────────────────────────────────────────────────────
┌─────────────────────── Target Profile ────────────────────────┐
│ Use the arrow keys to navigate this window or press the │
│ hotkey of the item you wish to select followed by the <SPACE │
│ BAR>. Press <?> for additional information about this │
│ ┌─────────────^(-)──────────────────────────────────────────┐ │
│ │ ( ) HILINK HLK7628N │ │
│ │ ( ) HiWiFi HC5661A │ │
│ │ ( ) HiWiFi HC5861B │ │
│ │ (X) MediaTek LinkIt Smart 7688 │ │
│ │ ( ) MediaTek MT7628 EVB │ │
│ │ ( ) Mercury MAC1200R v2.0 │ │
│ └─────────────v(+)──────────────────────────────────────────┘ │
├───────────────────────────────────────────────────────────────┤
│ <Select> < Help > │
└───────────────────────────────────────────────────────────────┘
- 修改target/linux/ramips/image/mt76x8.mk文件,参考【LinkIt7688】配置文件,新增自定义板卡信息【LinkIt7688-eric】
define Device/LinkIt7688
DTS := LINKIT7688
IMAGE_SIZE := $(ralink_default_fw_size_32M)
SUPPORTED_DEVICES := linkits7688 linkits7688d
DEVICE_TITLE := MediaTek LinkIt Smart 7688
DEVICE_PACKAGES:= kmod-usb2 kmod-usb-ohci uboot-envtools
endef
TARGET_DEVICES += LinkIt7688
# eric++ 新增自定义板卡配置
define Device/LinkIt7688-eric
DTS := LINKIT7688-eric
IMAGE_SIZE := $(ralink_default_fw_size_32M)
SUPPORTED_DEVICES := linkits7688-eric linkits7688d
DEVICE_TITLE := MediaTek LinkIt Smart 7688 eric
DEVICE_PACKAGES:= kmod-usb2 kmod-usb-ohci uboot-envtools
endef
TARGET_DEVICES += LinkIt7688-eric
该配置选项,默认对应的设备树文件:LINKIT7688-eric.dts
(SUPPORTED_DEVICES :=LinkIt7688-eric,名字不对,会影响到luci升级模块固件检测机制)
- 此时menuconfig中可以选择新增的板卡设备
.config - OpenWrt Configuration
──────────────────────────────────────────────────────────────────────────────────
┌─────────────────────── Target Profile ────────────────────────┐
│ Use the arrow keys to navigate this window or press the │
│ hotkey of the item you wish to select followed by the <SPACE │
│ BAR>. Press <?> for additional information about this │
│ ┌─────────────^(-)──────────────────────────────────────────┐ │
│ │ ( ) HiWiFi HC5661A │ │
│ │ ( ) HiWiFi HC5861B │ │
│ │ ( ) MediaTek LinkIt Smart 7688 │ │
│ │ (X) MediaTek LinkIt Smart 7688 eric │ │
│ │ ( ) MediaTek MT7628 EVB │ │
│ │ ( ) Mercury MAC1200R v2.0 │ │
│ └─────────────v(+)──────────────────────────────────────────┘ │
├───────────────────────────────────────────────────────────────┤
│ <Select> < Help > │
└───────────────────────────────────────────────────────────────┘
- 新增设备树文件,复制target/linux/ramips/dts/LINKIT7688.dts,新建LINKIT7688-eric.dts
eric@eric-PC:~/Documents/work/openwrt_1907/target/linux/ramips/dts$ ls *7688*
LINKIT7688.dts
eric@eric-PC:~/Documents/work/openwrt_1907/target/linux/ramips/dts$ cp LINKIT7688.dts LINKIT7688-eric.dts
eric@eric-PC:~/Documents/work/openwrt_1907/target/linux/ramips/dts$ ls *7688*
LINKIT7688.dts LINKIT7688-eric.dts
eric@eric-PC:~/Documents/work/openwrt_1907/target/linux/ramips/dts$
- 对应的target/linux/ramips/base-files/etc/board.d/01_leds和02_network、package/boot/uboot-envtools/files/ramips等文件,可以不修改。因为其中判断分支是以标签【board_name=linkits7688】为准
target/linux/ramips/base-files/etc/board.d/01_leds:
linkits7688)
ucidef_set_led_wlan "wifi" "wifi" "linkit-smart-7688:orange:wifi" "phy0tpt"
;;
target/linux/ramips/base-files/etc/board.d/02_network:
linkits7688)
wan_mac=$(mtd_get_mac_binary factory 4)
lan_mac=$(mtd_get_mac_binary factory 46)
package/boot/uboot-envtools/files/ramips:
linkits7688|\
miwifi-nano|\
sk-wb8|\
wsr-1166|\
wsr-600|\
zbt-wg2626)
ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x1000" "0x10000"
;;
- 标签linkits7688,原自target/linux/ramips/base-files/lib/ramips.sh中,判断依据"MediaTek LinkIt Smart 7688,由设备树决定
target/linux/ramips/base-files/lib/ramips.sh:
machine=$(awk 'BEGIN{FS="[ \t]+:[ \t]"} /machine/ {print $2}' /proc/cpuinfo)
*"MediaTek LinkIt Smart 7688")
name="linkits7688"
;;
echo "$name" > /tmp/sysinfo/board_name
echo "$machine" > /tmp/sysinfo/model
查看cpuinfo:
root@OpenWrt:/# cat /proc/cpuinfo
system type : MediaTek MT7688 ver:1 eco:2
machine : MediaTek LinkIt Smart 7688
processor : 0
cpu model : MIPS 24KEc V5.5
BogoMIPS : 380.92
wait instruction : yes
microsecond timers : yes
tlb_entries : 32
extra interrupt vector : yes
hardware watchpoint : yes, count: 4, address/irw mask: [0x0ffc, 0x0ffc, 0x0ffb, 0x0ffb]
isa : mips1 mips2 mips32r1 mips32r2
ASEs implemented : mips16 dsp
Options implemented : tlb 4kex 4k_cache prefetch mcheck ejtag llsc pindexed_dcache userlocal vint perf_cntr_intr_bit nan_legacy nan_2008 perf
shadow register sets : 1
kscratch registers : 0
package : 0
core : 0
VCED exceptions : not available
VCEI exceptions : not available
- machine : MediaTek LinkIt Smart 7688,由设备树决定
model = "MediaTek LinkIt Smart 7688";
- 由以上逻辑可以看出,board_name = linkits7688
如果需要重新定义标签分支,则修改 ramips.sh 和设树mode,添加自己的标签分支即可,需要注意的是:对应的01_leds、02_network、ramips等依赖文件,需要同步添加标签分支。
target/linux/ramips/dts/LINKIT7688-eric.dts:
model = "Eric board V3.0";
target/linux/ramips/base-files/lib/ramips.sh:
*"MediaTek LinkIt Smart 7688")
name="linkits7688"
;;
*"Eric board V3.0")
name="linkits7688-eric"
;;
target/linux/ramips/base-files/etc/board.d/01_leds:
linkits7688)
ucidef_set_led_wlan "wifi" "wifi" "linkit-smart-7688:orange:wifi" "phy0tpt"
;;
linkits7688-eric)
# eric++
# ucidef_set_led_wlan "wifi" "wifi" "led-wifi" "phy0tpt"
ucidef_set_led_netdev "wifi" "wifi" "linkit-smart-7688:orange:wifi" "wlan0"
ucidef_set_led_netdev "lan" "lan" "linkit-smart-7688:orange:usb" "eth0"
;;
target/linux/ramips/base-files/etc/board.d/02_network:
linkits7688 | \
....此处省略n行
zte-q7)
ucidef_add_switch "switch0"
ucidef_add_switch_attr "switch0" "enable" "false"
ucidef_set_interface_lan "eth0"
;;
linkits7688-eric)
# 单网口
# ucidef_add_switch "switch0"
# ucidef_add_switch_attr "switch0" "enable" "false"
# ucidef_set_interface_lan "eth0"
# usb网卡
# ucidef_set_interface_wan "eth1"
# 多网口
ucidef_add_switch "switch0" \
"0:lan" "1:lan" "6t@eth0"
ucidef_set_interface_wan "eth1"
;;
linkits7688-eric|\
linkits7688)
wan_mac=$(mtd_get_mac_binary factory 4)
lan_mac=$(mtd_get_mac_binary factory 46)
;;
package/boot/uboot-envtools/files/ramips:
linkits7688|\
linkits7688-eric|\
miwifi-nano|\
sk-wb8|\
wsr-1166|\
wsr-600|\
zbt-wg2626)
ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x1000" "0x10000"
;;