当前位置: 代码迷 >> 综合 >> openwrt新增自定义板卡信息
  详细解决方案

openwrt新增自定义板卡信息

热度:4   发布时间:2024-03-10 02:09:20.0

修改配置文件,新增自定义板卡信息
适用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/LinkIt7688DTS := LINKIT7688IMAGE_SIZE := $(ralink_default_fw_size_32M)SUPPORTED_DEVICES := linkits7688 linkits7688dDEVICE_TITLE := MediaTek LinkIt Smart 7688DEVICE_PACKAGES:= kmod-usb2 kmod-usb-ohci uboot-envtools
endef
TARGET_DEVICES += LinkIt7688# eric++ 新增自定义板卡配置
define Device/LinkIt7688-ericDTS := LINKIT7688-ericIMAGE_SIZE := $(ralink_default_fw_size_32M)SUPPORTED_DEVICES := linkits7688 linkits7688dDEVICE_TITLE := MediaTek LinkIt Smart 7688 ericDEVICE_PACKAGES:= kmod-usb2 kmod-usb-ohci uboot-envtools
endef
TARGET_DEVICES += LinkIt7688-eric

该配置选项,默认对应的设备树文件:LINKIT7688-eric.dts

  • 此时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$ 
  • 对应的01_leds和02_network等文件,无需修改。其中判断分支是以【board_name=linkits7688】为准

01_leds:

linkits7688)ucidef_set_led_wlan "wifi" "wifi" "linkit-smart-7688:orange:wifi" "phy0tpt";;

02_network:

	linkits7688)wan_mac=$(mtd_get_mac_binary factory 4)lan_mac=$(mtd_get_mac_binary factory 46)

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

其中:

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