一、克隆openwrt代码
在openwrt官方git仓库中clone openwrt源码:
git clone https://www.github.com/openwrt/openwrt
或者想得到固定版本的openwrt源码:
git clone https://www.github.com/openwrt/openwrt -b chaos_calmer
使用GIT更新源码:
git pull
更新源:
./scripts/feeds update -a
安装下载好的包:
./scripts/feeds install -a (或者 'install <PACKAGENAME>' )
二、新增BL-WP02G配置文件
在openwrt目录中创建BL-WP02G的dts文件:
touch ./target/linux/ramips/dts/BL-WP02G.dts
编辑BL-WP02G.dts文件
/dts-v1/; #include "rt3050.dtsi" #include <dt-bindings/gpio/gpio.h> #include <dt-bindings/input/input.h> / { compatible = "lb-link,bl-wp02g", "ralink,rt3052-soc"; model = "LB-LINK BL-WP02G"; gpio-keys-polled { compatible = "gpio-keys-polled"; poll-interval = <20>; reset { label = "reset"; gpios = <&gpio0 0 GPIO_ACTIVE_LOW>; linux,code = <KEY_RESTART>; }; }; }; &spi0 { status = "okay"; m25p80@0 { compatible = "jedec,spi-nor"; reg = <0>; spi-max-frequency = <10000000>; partitions { compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; partition@0 { label = "u-boot"; reg = <0x0 0x30000>; read-only; }; partition@30000 { label = "devdata"; reg = <0x30000 0x10000>; read-only; }; devconf: partition@40000 { label = "devconf"; reg = <0x40000 0x10000>; read-only; }; partition@50000 { compatible = "denx,uimage"; label = "firmware"; reg = <0x50000 0xfb0000>; }; }; }; }; &pinctrl { state_default: pinctrl0 { gpio { ralink,group = "i2c", "jtag", "rgmii", "mdio", "uartf"; ralink,function = "gpio"; }; }; }; ðernet { mtd-mac-address = <&devconf 0x4>; }; &esw { mediatek,portmap = <0x2f>; }; &wmac { ralink,mtd-eeprom = <&devconf 0>; };
三、修改配置文件
编辑./target/linux/ramips/base-files/lib/ramips.sh文件,添加:
*"BL-WP02G") name="bl-wp02g" ;;
编辑./target/linux/ramips/base-files/etc/board.d/02_network文件,添加:
bl-wp02g|) ucidef_add_switch "switch0" \ "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "0:wan" "6@eth0" ;;
编辑./target/linux/ramips/image/rt305x.mk文件,添加:
define Device/bl-wp02g DTS := BL-WP02G IMAGE_SIZE := $(ralink_default_fw_size_16M) DEVICE_TITLE := LB-LINK BL-WP02G endef TARGET_DEVICES += bl-wp02g
编辑./target/linux/ramips/base-files/lib/upgrade/platform.sh文件,添加
bl-wp02g|\
编辑./target/linux/ramips/base-files/etc/diag.sh文件,添加:
bl-wp02g|\
四、编译固件
make defconfig make menuconfig
选择想要的平台及软件包,保存并退出
make V=99
编译固件。