“第二课--OpenWRT 固件定制”的版本间的差异
小 (Customize firmware - build option) |
|||
| (未显示2个用户的7个中间版本) | |||
| 第2行: | 第2行: | ||
|- | |- | ||
| | | | ||
| + | microWRT已经被openwrt官方支持,使用最新的官方代码(trunk45331),并根据'''https://www.microduino.cc/wiki/index.php?title=第四课--OpenWRT_下载编译''',就可以很容易的编译出自己的针对microWRT的固件。 | ||
| − | + | 下面我们也给出了详细的定制过程。 | |
| − | |||
| − | |||
| − | |||
=== 加入 MicroWRT 硬件描述 === | === 加入 MicroWRT 硬件描述 === | ||
| 第145行: | 第143行: | ||
即可在编译时自动生成 MicroWRT 固件。 | 即可在编译时自动生成 MicroWRT 固件。 | ||
| + | |||
| + | |||
| + | === Machine Name 定制 === | ||
| + | |||
| + | 在 运行 ''' cat /pro/cpuinfo''' 查看开发板 CPU 信息时, 可以通过定制使其显示正确的板卡名称。 修改 '''target/linux/ramips/base-files/lib/ramips.sh''' 找到 | ||
| + | |||
| + | case "$machine" in | ||
| + | |||
| + | 在下面加入 MicroWRT 的信息 | ||
| + | |||
| + | case "$machine" in | ||
| + | *"MicroWRT") | ||
| + | name="microwrt" | ||
| + | ;; | ||
| + | |||
| + | ?即可 | ||
| + | |||
=== 网络接口定制(VLAN) === | === 网络接口定制(VLAN) === | ||
| 第172行: | 第187行: | ||
ucidef_add_switch_vlan "switch0" "2" "4 6t" | ucidef_add_switch_vlan "switch0" "2" "4 6t" | ||
;; | ;; | ||
| + | |||
| + | === 默认 IP 定制 === | ||
| + | |||
| + | 很多人家里的路由器默认 IP 都是 192.168.1.1. 如果直接把 MicroWRT 接入,可能会引起 IP 冲突导致其他电脑无法上网。一劳永逸的解决办法就是修改 MicroWRT 的默认 IP | ||
| + | 找到 '''package/base-files/files/bin/config_generate''', | ||
| + | |||
| + | set network.$1.ipaddr='192.168.1.1' | ||
| + | |||
| + | 修改为 | ||
| + | |||
| + | set network.$1.ipaddr='192.168.233.1' | ||
| + | |||
| + | 即可 | ||
| + | |||
| + | |||
| + | === Profile 定制 & 加快编译 === | ||
| + | |||
| + | OpenWRT 编译固件时,会把同一 CPU 的所有型号固件统统编译一遍,可能需要花掉几个小时。如果只需要 MicroWRT 固件,我们可以单独编译它。将以下文件保存为 '''target/linux/ramips/mt7620/profiles/microwrt.mk''' | ||
| + | |||
| + | define Profile/MicroWRT | ||
| + | NAME:=MicroWRT | ||
| + | PACKAGES:=\ | ||
| + | kmod-usb-core kmod-usb-dwc2 kmod-usb2 kmod-usb-ohci \ | ||
| + | kmod-mt76 | ||
| + | endef | ||
| + | |||
| + | define Profile/MicroWRT/Description | ||
| + | Support for MicroWRT | ||
| + | endef | ||
| + | $(eval $(call Profile,MicroWRT)) | ||
| + | |||
| + | 然后 '''删除固件源码下的 /tmp''', 重新 '''make menuconfig''' 就可以看到,选择 MT7620 之后,Target Profile 中出现了 MicroWRT. 选择之后,即可单独为 MicroWRT 编译固件。 | ||
| + | |} | ||
| + | |||
| + | |||
| + | === OpenWRT 版本、软件源定制 === | ||
| + | |||
| + | '''make menuconfig''' 进入配置菜单, 选择 '''Image configuration''' - '''Version configuration options'''. 这里可以定制软件的版本、制造商、产品名称和软件源。 | ||
| + | |||
| + | [[File:Version configuration options.png|700px|center]] | ||
| + | |||
| + | 注意:软件源需要设置为 | ||
| + | |||
| + | http://downloads.openwrt.org/snapshots/trunk/ramips/mt7620/packages | ||
| + | |||
| + | 然后退到上一层, 选中 '''Separate feed repositories'''. 此时,编译好的 OpenWRT 固件才能够找到对应的软件包。 | ||
|} | |} | ||
2015年6月14日 (日) 11:56的最新版本
|
microWRT已经被openwrt官方支持,使用最新的官方代码(trunk45331),并根据https://www.microduino.cc/wiki/index.php?title=第四课--OpenWRT_下载编译,就可以很容易的编译出自己的针对microWRT的固件。 下面我们也给出了详细的定制过程。 目录加入 MicroWRT 硬件描述DTS 是对每一块板上硬件的描述。对于 MicroWRT ,我们需要定制的内容主要包括板卡名称、串口波特率、Flash分区、GPIO、按键、SPI、PCI-E、I2C、网口等硬件接口。将以下内容保存为 target/linux/ramips/dts/MicroWRT.dts /dts-v1/;
/include/ "mt7620a.dtsi"
/ {
compatible = "microwrt", "ralink,mt7620a-soc";
model = "MicroWRT";
chosen {
bootargs = "console=ttyS0,115200";
};
palmbus@10000000 {
gpio2: gpio@660 {
status = "okay";
};
gpio3: gpio@688 {
status = "okay";
};
spi@b00 {
status = "okay";
m25p80@0 {
#address-cells = <1>;
#size-cells = <1>;
compatible = "w25q128";
reg = <0 0>;
linux,modalias = "m25p80", "w25q128";
spi-max-frequency = <10000000>;
partition@0 {
label = "u-boot";
reg = <0x0 0x30000>;
read-only;
};
partition@30000 {
label = "u-boot-env";
reg = <0x30000 0x10000>;
read-only;
};
factory: partition@40000 {
label = "factory";
reg = <0x40000 0x10000>;
read-only;
};
partition@50000 {
label = "firmware";
reg = <0x50000 0xfb0000>;
};
};
};
};
ehci@101c0000 {
status = "okay";
};
ohci@101c1000 {
status = "okay";
};
pcie@10140000 {
status = "okay";
pcie-bridge {
mt76@0,0 {
reg = <0x0000 0 0 0 0>;
device_type = "pci";
mediatek,mtd-eeprom = <&factory 0x8000>;
mediatek,2ghz = <0>;
};
};
};
ethernet@10100000 {
pinctrl-names = "default";
pinctrl-0 = <&ephy_pins>;
mtd-mac-address = <&factory 0x4>;
ralink,port-map = "llllw";
};
wmac@10180000 {
ralink,mtd-eeprom = <&factory 0>;
};
pinctrl {
state_default: pinctrl0 {
default {
ralink,group = "wled", "i2c", "wdt", "uartf";
ralink,function = "gpio";
};
};
};
gpio-keys-polled {
compatible = "gpio-keys-polled";
#address-cells = <1>;
#size-cells = <0>;
poll-interval = <20>;
reset {
label = "reset";
gpios = <&gpio0 1 1>;
linux,code = <0x198>;
};
wps {
label = "wps";
gpios = <&gpio0 2 1>;
linux,code = <0x211>;
};
};
};
加入 MicroWRT 编译选项有了 MicroWRT 的硬件描述,我们只需要通知 OpenWRT 编译工具进行编译,就可以生成适合 MicroWRT 的固件了。修改 target/linux/ramips/image/Makefile 找到 ifeq ($(SUBTARGET),mt7620) define Image/Build/Profile/Default 在下面加入 $(call Image/Build/Profile/MicroWRT,$(1)) 然后在这个函数上面加入 Image/Build/Profile/MicroWRT=$(call BuildFirmware/Default16M/$(1),$(1),microwrt,MicroWRT) 即可在编译时自动生成 MicroWRT 固件。
Machine Name 定制在 运行 cat /pro/cpuinfo 查看开发板 CPU 信息时, 可以通过定制使其显示正确的板卡名称。 修改 target/linux/ramips/base-files/lib/ramips.sh 找到 case "$machine" in 在下面加入 MicroWRT 的信息 case "$machine" in
*"MicroWRT")
name="microwrt"
;;
?即可
网络接口定制(VLAN)MT7620 内置了支持 VLAN 的交换机,通过划分不同的 VLAN 就可以实现内外网的切换。MicroWRT 扩展板提供了一个一以太网口,连接到 Port 4。通常我们会使用这个网口连接外网。此时需要修改固件源码中的 /target/linux/ramips/base-files/etc/board.d/02_network。 找到如下段落: wt1520 | \
xiaomi-miwifi-mini |\
y1)
ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
ucidef_add_switch "switch0" "1" "1"
ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 6t"
ucidef_add_switch_vlan "switch0" "2" "4 6t"
;;
这一段就是将 Port 4 配置到 VLAN 2 的代码。 只要把 microwrt 也加进去就好了。 wt1520 | \
xiaomi-miwifi-mini | \
microwrt | \
y1)
ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
ucidef_add_switch "switch0" "1" "1"
ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 6t"
ucidef_add_switch_vlan "switch0" "2" "4 6t"
;;
默认 IP 定制很多人家里的路由器默认 IP 都是 192.168.1.1. 如果直接把 MicroWRT 接入,可能会引起 IP 冲突导致其他电脑无法上网。一劳永逸的解决办法就是修改 MicroWRT 的默认 IP 找到 package/base-files/files/bin/config_generate, set network.$1.ipaddr='192.168.1.1' 修改为 set network.$1.ipaddr='192.168.233.1' 即可
Profile 定制 & 加快编译OpenWRT 编译固件时,会把同一 CPU 的所有型号固件统统编译一遍,可能需要花掉几个小时。如果只需要 MicroWRT 固件,我们可以单独编译它。将以下文件保存为 target/linux/ramips/mt7620/profiles/microwrt.mk define Profile/MicroWRT
NAME:=MicroWRT
PACKAGES:=\
kmod-usb-core kmod-usb-dwc2 kmod-usb2 kmod-usb-ohci \
kmod-mt76
endef
define Profile/MicroWRT/Description
Support for MicroWRT
endef
$(eval $(call Profile,MicroWRT))
然后 删除固件源码下的 /tmp, 重新 make menuconfig 就可以看到,选择 MT7620 之后,Target Profile 中出现了 MicroWRT. 选择之后,即可单独为 MicroWRT 编译固件。 |
OpenWRT 版本、软件源定制
make menuconfig 进入配置菜单, 选择 Image configuration - Version configuration options. 这里可以定制软件的版本、制造商、产品名称和软件源。
注意:软件源需要设置为
http://downloads.openwrt.org/snapshots/trunk/ramips/mt7620/packages
然后退到上一层, 选中 Separate feed repositories. 此时,编译好的 OpenWRT 固件才能够找到对应的软件包。 |}