openWrt 系列文章是以工作实践记录为主,openWrt版本19.07,硬件LS1046A平台。
本篇文章记录openWRT相关参数配置文件路径和方法;在研发工程中经常需要相关相关参数,特记录备忘。
(1). wifi的默认开启方式、ssid、加密方式等配置
# 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). 硬件平台 设备树文件
linux内核源码解压路径:
build_dir/target-aarch64_generic_glibc/linux-layerscape_armv8_64b/linux-4.14.200/arch/arm64/boot/dts$
设备树路径存放路径为 arch/arm64/boot/dts/ 各平台相关设备树文件;更加硬件平台自行选择修订设备树文件即可。
修改方法、请参考此链接,使用patch 方法修订。
https://blog.csdn.net/weixin_38387929/article/details/113039372
(3). 系统镜像生成配置文件
系统镜像配置文件路径规则如下:
# 源码目录
package/base-files/files/$
$ls
bin etc lib rom sbin usr
需要定制化相关内容,可以到etc/文件夹下修改。
eg:修改命令行的显示字符
$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:显示banner
$ vi etc/banner
#自行修改 banner 内容。
(4). 升级镜像检测脚本参数
(5). 状态灯、网络缺省参数配置
# ls target/linux/layerscape/base-files/etc/board.d/
01_led 02_network 03_gpio_switches
(6). 以太网网络参数配置
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分区及入口参数配置
uboot分区
#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 入口参数
#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页面参数配置
修改 Web 界面相关内容在package/feeds/luci/luci-base/文件夹下,此文件夹是luci-app存储路径,修改内容重新编译可打包到镜像中。
基础配置内容在luci-base文件夹下。
package/feeds/luci$ ls luci-base
htdocs luasrc Makefile po root src
原文件基础文档位置,修改图标相关内容
/home/robot/OpenWrt/x86-openWrt-19.07/feeds/luci/luci-base/htdocs/luci-static/resources
修改web页面的标题、header、footer 相关内容文件路径:
robot@ubuntu:~/OpenWrt/mtk7621-19.07/package/feeds/luci$ ls luci-theme-*
luci-theme-bootstrap:
htdocs luasrc Makefile root
luci-theme-material:
htdocs luasrc Makefile root
luci-theme-openwrt:
htdocs luasrc Makefile root
luci-theme-rosy:
htdocs luasrc Makefile root
- header、footer 相关内容
robot@ubuntu:~/OpenWrt/mtk7621-19.07/package/feeds/luci$ ls luci-theme-material/luasrc/view/themes/material/
footer.htm header.htm
- header 中使用的图标路径
/home/robot/OpenWrt/mtk7621-19.07/feeds/luci/themes/luci-theme-material/htdocs/luci-static/material
//图标文件brand.png 和 favicon.ico 替换掉即可。
robot@ubuntu:~/OpenWrt/mtk7621-19.07/package/feeds/luci/luci-theme-material/htdocs/luci-static/material$ ls
brand.png cascade.css custom.css favicon.ico icons js
无线图标位置:
/home/robot/OpenWrt/x86-openWrt-19.07/build_dir/target-x86_64_glibc/root-x86/www/luci-static/material/brand.png
修改 ping、trace 域名
/home/robot/OpenWrt/x86-openWrt-19.07/feeds/luci/modules/luci-mod-network/htdocs/luci-static/resources/view/network/diagnostics.js
(9). vtysh 控制console参数配置方法
参考此链接进行命令行修订
http://www.blog.chinaunix.net/uid-8877552-id-5130702.html
(10). 修改 x86 镜像开机名称
修改 x86 镜像开机名称,通过make menuconfig 中的 target Images 的 Title for the menu entry in GRUB 名称。
(11) OPKG包管理工具参数配置
(12) 修改DNS 和 system 参数
参考链接
https://blog.csdn.net/weixin_38387929/article/details/119573051
(13) 增加 interface 接口的参数
参考链接
https://blog.csdn.net/weixin_38387929/article/details/117088345
(14)、增加开机自启动项
(15)、增加用户软件包
参考链接
https://blog.csdn.net/weixin_38387929/article/details/112524279