The openWrt series of articles are based on work practice records, openWrt version 19.07, hardware LS1046A platform.
This article records the path and method of openWRT-related parameter configuration files; relevant parameters are often needed in R&D projects, and special notes are recorded.
(1). Wifi's default opening method, ssid, encryption method and other configurations
# cat package/kernel/mac80211/files/lib/wifi/mac80211.sh
......
uci -q batch <<-EOF
set wireless.radio${
devidx}=wifi-device
set wireless.radio${
devidx}.type=mac80211
set wireless.radio${
devidx}.channel=${
channel}
set wireless.radio${
devidx}.hwmode=11${
mode_band}
${
dev_id}
${
ht_capab}
set wireless.radio${
devidx}.disabled=1
set wireless.default_radio${
devidx}=wifi-iface
set wireless.default_radio${
devidx}.device=radio${
devidx}
set wireless.default_radio${
devidx}.network=lan
set wireless.default_radio${
devidx}.mode=ap
set wireless.default_radio${
devidx}.ssid=OpenWrt
set wireless.default_radio${
devidx}.encryption=none
EOF
uci -q commit wireless
(2). Hardware platform device tree file
Linux kernel source code decompression path:
build_dir/target-aarch64_generic_glibc/linux-layerscape_armv8_64b/linux-4.14.200/arch/arm64/boot/dts$
The storage path of the device tree path is arch/arm64/boot/dts/ related device tree files of each platform; you can choose to revise the device tree file by your own hardware platform.
To modify the method, please refer to this link and use the patch method to modify.
https://blog.csdn.net/weixin_38387929/article/details/113039372
(3). System image generation configuration file
The path rules of the system mirror configuration file are as follows:
# 源码目录
package/base-files/files/$
$ls
bin etc lib rom sbin usr
Need to customize the relevant content, you can go to the etc/ folder to modify.
eg: modify the display characters of the command line
$vi etc/init.d/system
system_config() {
[ "$2" = 0 ] || {
echo "validation failed"
return 1
}
#echo "$hostname" > /proc/sys/kernel/hostname
echo "host" > /proc/sys/kernel/hostname # 修改主机名称
[ -z "$conloglevel" -a -z "$buffersize" ] || dmesg ${
conloglevel:+-n $conloglevel} ${
buffersize:+-s $buffersize}
echo "$timezone" > /tmp/TZ
[ -n "$zonename" ] && [ -f "/usr/share/zoneinfo/$zonename" ] && \
ln -sf "/usr/share/zoneinfo/$zonename" /tmp/localtime && rm -f /tmp/TZ
# apply timezone to kernel
date -k
}
eg: display banner
$ vi etc/banner
#自行修改 banner 内容。
(4). Upgrade image detection script parameters
(5). Status light, network default parameter configuration
# ls target/linux/layerscape/base-files/etc/board.d/
01_led 02_network 03_gpio_switches
(6). Ethernet network parameter configuration
root@OpenWrt:/etc/config# cat network
config interface 'loopback'
option ifname 'lo'
option proto 'static'
option ipaddr '127.0.0.1'
option netmask '255.0.0.0'
config globals 'globals'
option ula_prefix 'fd06:7893:cd7f::/48'
config interface 'lan'
option type 'bridge'
option ifname 'eth0 eth1 eth2 eth4'
option proto 'static'
option ipaddr '192.168.155.1'
option netmask '255.255.255.0'
option ip6assign '60'
config interface 'wan'
option ifname 'eth3'
option proto 'dhcp'
config interface 'wan6'
option ifname 'eth3'
option proto 'dhcpv6'
(7). uboot partition and entry parameter configuration
uboot partition
#cat package/boot/uboot-envtools/files/layerscape
#!/bin/sh
#
# Copyright (C) 2016 LEDE
#
[ -f /etc/config/ubootenv ] && exit 0
touch /etc/config/ubootenv
. /lib/uboot-envtools.sh
. /lib/functions.sh
board=$(board_name)
case "$board" in
traverse,ls1043v | \
traverse,ls1043s)
ubootenv_add_uci_config "/dev/mtd1" "0x40000" "0x2000" "0x20000"
;;
esac
config_load ubootenv
config_foreach ubootenv_add_app_config ubootenv
exit 0
uboot entry parameters
#cat package/boot/uboot-layerscape/files/ls1046ardb-sdboot-uEnv.txt
fdtaddr=0x8f000000
loadaddr=0x81000000
fdt_high=0xffffffffffffffff
initrd_high=0xffffffffffffffff
hwconfig=fsl_ddr:bank_intlv=auto
sd_boot=mmc read $fdtaddr 7800 800;mmc read $loadaddr 8000 8000;bootm $loadaddr - $fdtaddr
bootargs=root=/dev/mmcblk0p1 rw rootwait rootfstype=ext4 noinitrd earlycon=uart8250,mmio,0x21c0500 console=ttyS0,115200
bootcmd=echo starting openwrt ...;run sd_boot
bootdelay=3
laoli@ubuntu:~/openwrt-19.7.5/openwrt$ cat package/boot/uboot-layerscape/files/ls1046ardb--uEnv.txt
ls1046ardb-sdboot-uEnv.txt ls1046ardb-uEnv.txt
laoli@ubuntu:~/openwrt-19.7.5/openwrt$ cat package/boot/uboot-layerscape/files/ls1046ardb--uEnv.txt
ls1046ardb-sdboot-uEnv.txt ls1046ardb-uEnv.txt
laoli@ubuntu:~/openwrt-19.7.5/openwrt$ cat package/boot/uboot-layerscape/files/ls1046ardb-uEnv.txt
fdtaddr=0x8f000000
loadaddr=0x81000000
fdt_high=0xffffffffffffffff
initrd_high=0xffffffffffffffff
hwconfig=fsl_ddr:bank_intlv=auto
qspi_boot=sf probe 0:0;sf read $fdtaddr f00000 100000;sf read $loadaddr 1000000 1000000;bootm $loadaddr - $fdtaddr
bootargs=ubi.mtd=9 root=ubi0:rootfs rw rootfstype=ubifs noinitrd earlycon=uart8250,mmio,0x21c0500 console=ttyS0,115200 mtdparts=1550000.quadspi:1m(bl2),4m(fip),1m(u-boot-env),3m(reserved-1),256k(fman),5888k(reserved-2),1m(dtb),16m(kernel),32m(ubifs)
bootcmd=echo starting openwrt ...;run qspi_boot
bootdelay=3
(8). Web page parameter configuration
The relevant content of the modified web interface is under the package/feeds/luci/ folder, this folder is the storage path of luci-app, and the modified content can be packaged into the mirror after recompiling.
The basic configuration content is under the luci-base folder.
package/feeds/luci$ ls luci-base
htdocs luasrc Makefile po root src
(9). vtysh control console parameter configuration method
Refer to this link for command line revision
http://www.blog.chinaunix.net/uid-8877552-id-5130702.html