close

廠商 : company

Model name : rt5350f

 

希望功能 : wan port , wifi 則是lan

wan port ip : 192.168.100.88  (dhcp client)

wlan0 ip : 192.168.50.1   (dhcp server)

 

要改的檔案列表

target/linux/ramips/base-files/etc/uci-defaults/02_network

target/linux/ramips/base-files/lib/ramips.sh

target/linux/ramips/base-files/lib/upgrade/platform.sh

target/linux/ramips/dts/RT5350_EVB.dts

target/linux/ramips/image/Makefile

target/linux/ramips/rt305x/profiles/company.mk

 

 

接下來,依關係來說明 

1. profiles/company.mk 

        新增產品和公司的資訊,最重要是 Profile/RT5350_EVB (後面的名字不可以重複)

 


 

define Profile/RT5350_EVB
    NAME:=RT5350 module
    PACKAGES:=kmod-usb-core kmod-usb-ohci kmod-usb2 kmod-ledtrig-usbdev \
        kmod-i2c-core kmod-i2c-gpio
endef

define Profile/RT5350_EVB/Description
    Package set for RT5350 Wifi Evaluation Board
endef


$(eval $(call Profile,RT5350_EVB))


 

最後 這一行如果沒有加入,OpenWrt會無法編譯,加入之後就可以在make menuconfig看到我們新增進去的產品

接下來對source code加入檔案

 

2. target/linux/ramips/dts/RT5350_EVB.dts

    在編譯過程中,會到 target/linux/ramips/dts/  中, 找要編譯的target對應的dts檔案,

    裡面有定義 model ,這個定義會在init過程中被使用到

   在這個例子中, 就是會去找 RT5350_EVB.dts  ,  model 定義成 RT5350F

  (待釐清 : 這邊可以定義GPIO)

 

 


 

/dts-v1/;

/include/ "rt5350.dtsi"

/ {
    compatible = "RT5350_EVB", "ralink,rt5350-soc";
    model = "RT5350F";

    palmbus@10000000 {
    
        spi@b00 {
            status = "okay";
    
            m25p80@0 {
                #address-cells = <1>;
                #size-cells = <1>;
                reg = <0 0>;
                spi-max-frequency = <10000000>;
                compatible = "mx25l6405d";
                linux,modalias = "m25p80", "mx25l6405d";
    
    
                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 0x1fb0000>;
                };
            };
        };
    };
    
    ethernet@10100000 {
        mtd-mac-address = <&factory 0x28>;
    };

    wmac@10180000 {
        ralink,mtd-eeprom = <&factory 0>;
};
};

 


 

 

3.target/linux/ramips/base-files/lib/ramips.sh

(待釐清 : 誰CALL的)

ramips_board_detect ()中,會依照/proc/cpuinfo的machine 來做判斷

 * 將 dts定義的model 轉換成 board_name  , 並且利用兩個變數將資料儲存起來

 * 在/tmp/sysinfo/ 建立兩個檔案

        "$RAMIPS_BOARD_NAME" > /tmp/sysinfo/board_name   ,這是小寫

         "$RAMIPS_MODEL" > /tmp/sysinfo/model                      ,這是大寫,從/proc/cpuinfo取得, 字串則是在dts中定義的model


 

machine=$(awk 'BEGIN{FS="[ \t]+:[ \t]"} /machine/ {print $2}' /proc/cpuinfo)

    case "$machine" in

    *"RT5350F")
        name="rt5350f" 

        ;;
    esac
    
    [ -z "$RAMIPS_BOARD_NAME" ] && RAMIPS_BOARD_NAME="$name"
    [ -z "$RAMIPS_MODEL" ] && RAMIPS_MODEL="$machine"

    [ -e "/tmp/sysinfo/" ] || mkdir -p "/tmp/sysinfo/"

    echo "$RAMIPS_BOARD_NAME" > /tmp/sysinfo/board_name
    echo "$RAMIPS_MODEL" > /tmp/sysinfo/model


 

 

4. target/linux/ramips/base-files/etc/uci-defaults/02_network

這裡是將定義產品的網路介面,在ramips_setup_interfaces() 中 ,需要加入model的判斷和介面卡設定

用來判斷 board 則是ramips.sh中 被轉換的字串 "$RAMIPS_BOARD_NAME"   (rt5350f)

 


 

ramips_setup_interfaces()
{
    local board="$1"

    ucidef_set_interface_loopback

    case $board in

    rt5350f)
        ucidef_set_interface_lan "eth0.2"
        ucidef_set_interface_wan "eth0.1"
        ucidef_add_switch "switch0" "1" "1"
        ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 6t"
        ucidef_add_switch_vlan "switch0" "2" "0 6t"
        ;;

        ;;
    esac
}

 


 5. target/linux/ramips/image/Makefile

 加入image的規則,這樣OpenWrt才知道要怎麼打包 , 打包規則以及 加入Default

 Image/Build/Profile/RT5350_EVB 要跟前面相同

 

(待釐清 : 後面兩個規則)

 


 

Image/Build/Profile/RT5350_EVB=$(call BuildFirmware/Default8M/$(1),$(1),rt5350f,RT5350_EVB)

ifeq ($(SUBTARGET),rt305x)
define Image/Build/Profile/Default

    $(call Image/Build/Profile/RT5350_EVB,$(1))

endef
endif


 

 

 

 

 

 

target/linux/ramips/base-files/lib/upgrade/platform.sh

 

 

 


 

 

 

 

   

 

 

 

 

 

arrow
arrow
    全站熱搜

    橘 發表在 痞客邦 留言(0) 人氣()