最小固件:
3604643
openwrt-ramips-mt76x8-mt7628-squashfs-sysupgrade.bin
带LUCI:
./scripts/feeds update -a
./scripts/feeds install -a
make defconfig
make check
make download
make menuconfig
make V=s
1.修改固件大小限制和flash分区
在target中主要是针对各个平台对应的makefile和编译规则等,
当然也有通用的部分
openwrt-master/target/linux/ramips/image/mt76x8.mk
可以查看到当前平台所对应的各种路由器固件配置
这是当前的目标板
define Device/mt7628
DTS := MT7628
BLOCKSIZE := 64k
IMAGE_SIZE := $(ralink_default_fw_size_4M)
DEVICE_TITLE := MediaTek MT7628 EVB
DEVICE_PACKAGES := kmod-usb2 kmod-usb-ohci kmod-usb-ledtrig-usbport
endef
TARGET_DEVICES += mt7628
由于固件大小被限制为4m,所以当固件超过4M的时候就会出现编译错误
partition@50000 {
label = "firmware";
reg = <0x50000 0x7b0000>;
};
这里默认是7m多一点,根据flash大小设置
partition@50000 {
label = "firmware";
// reg = <0x50000 0x7b0000>; //8MB flash
// reg = <0x50000 0xfb0000>; //16MB flash
reg = <0x50000 0x1fb0000>; //32MB flash
};
2.修改内存大小
MT7628.dts文件有
memory@0 {
device_type = “memory”;
reg = <0x0 0x10000000>; //256MB RAM
// reg = <0x0 0x8000000>; //128MB RAM
// reg = <0x0 0x4000000>; //64MB RAM
};
但是据说lede很多在修改dts后不生效的。
//在menuconfig(make kenerl_menuconfig)的时候搜索Machine selection --> DRAM Size
3.修改波特率
target/linux/ramips/dts/mt7628an.dtsi
chosen {
bootargs = “console=ttyS0,115200”;
};
4.修改主机名、时区等,
package/base-files/files/bin/config_generate
generate_static_system() {
224 uci -q batch <<-EOF
225 delete system.@system[0]
226 add system system
227 set system.@system[-1].hostname=‘Jiamu’
228 set system.@system[-1].timezone=‘CTS-8’
229 set system.@system[-1].zonename=‘Asia/Shanghai’
230 set system.@system[-1].ttylogin=‘0’
231 set system.@system[-1].log_size=‘64’
232 set system.@system[-1].urandom_seed=‘0’
233
234 delete system.ntp
235 set system.ntp=‘timeserver’
236 set system.ntp.enabled=‘1’
237 set system.ntp.enable_server=‘0’
238 add_list system.ntp.server=‘0.openwrt.pool.ntp.org’
239 add_list system.ntp.server=‘1.openwrt.pool.ntp.org’
240 add_list system.ntp.server=‘2.openwrt.pool.ntp.org’
241 add_list system.ntp.server=‘3.openwrt.pool.ntp.org’
242 EOF
5.默认启动wifi,修改wifi名字
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=0 //使能
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=jiamu //ssid名
set wireless.default_radio${devidx}.encryption=psk //wifi加密方式
set wireless.default_radio${devidx}.key=12345678
EOF
6.自定义busybox
Base system
打开ftpget/ftpput tftp等功能
7.设置串口登录密码
在inittab中添加
::respawn:/sbin/getty -L ttyS0 115200 vt100
主要配置busybox支持gettty
文件系统挂载:
启动流程:
kernel_init -->内核启动
try_to_run_init_process("/sbin/init") --> 启动init程序,似乎和cc不同的是没有直接从/etc/preinit启动
这个init是procd中的init.c的init编译的
early挂载proc等节点,所以在文件系统中不需要fatab了,初始化环境变量(init: Console is alive)
cmdline();解析传递过来的init_debug参数
watchdog_init();初始化看门狗,怎么用这个看门狗???(init: - watchdog -)
execvp(kmod[0], kmod);开始加载/etc/modu