openwrt adds custom board information

Modify the configuration file and add custom board information.
Applicable to openwrt version 19.07.04

  • The default board configuration, the currently selected board is [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 >                     │          
         └───────────────────────────────────────────────────────────────┘          

  • Modify target/linux/ramips/image/mt76x8.mk file, refer to [LinkIt7688] configuration file, and add custom board information [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

This configuration option, the default corresponding device tree file: LINKIT7688-eric.dts
(SUPPORTED_DEVICES :=LinkIt7688-eric, the name is wrong, it will affect the luci upgrade module firmware detection mechanism)

  • At this time, the newly added board device can be selected in 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 >                     │          
         └───────────────────────────────────────────────────────────────┘                                                                  
  • Add device tree file, copy target/linux/ramips/dts/LINKIT7688.dts, create new 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$ 

  • The corresponding target/linux/ramips/base-files/etc/board.d/01_leds and 02_network, package/boot/uboot-envtools/files/ramips and other files can be left unmodified. Because the judgment branch is based on the label [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"
	;;
  • The label linkits7688, originally from target/linux/ramips/base-files/lib/ramips.sh, is based on "MediaTek LinkIt Smart 7688, determined by the device tree"

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

View 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, determined by the device tree
model = "MediaTek LinkIt Smart 7688";
  • It can be seen from the above logic that board_name = linkits7688
    If you need to redefine the label branch, modify ramips.sh and set the tree mode, and add your own label branch. Note that: the corresponding 01_leds, 02_network, ramips and other dependent files , Need to add tag branches synchronously.

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"
	;;

Guess you like

Origin blog.csdn.net/pyt1234567890/article/details/109352936