1. 程式人生 > >移植命令和庫到海思相關芯片

移植命令和庫到海思相關芯片

iptables

  • 編譯fw_printenv工具:

  • make ARCH=arm CROSS_COMPILE=arm-hisiv300-linux- hi3521a_config

    make ARCH=arm CROSS_COMPILE=arm-hisiv300-linux-

    make ARCH=arm CROSS_COMPILE=arm-hisiv300-linux- env

    編譯會出現問題:只需進入u-boot目錄

    vi include/linux/types.h +154

    //typedef u_int32_t uintmax_t;

    //typedef int32_t intmax_t;

    因為在arm-hisiv300-linux/target/usr/include/stdint.h 已經定已過了


    2.安裝fw_printenv工具

    到/tools/env目錄中,將編譯好的fw_printenv拷貝到目標機的文件系統中,並通過"ln -s fw_printenv fw_setenv",創建一個fw_setenv到fw_printenv的軟鏈。


    註意可以用:

    arm-hisiv300-linux-strip fw_printenv

    來去掉相應的符號來減少空間的浪費

    3.這個工具還需要一個配置文件,以獲取uboot的ENV區域的位置信息。默認狀態下,請將fw_env.config文件拷貝到目標機的文件系統的/etc目錄下。然後結合uboot配置中定義的ENV區和Linux下mtd分區的情況修改配置文件。具體的修改方法見fw_env.config文件中的說明及/tools/env/README文件。



    移植ppp相關:

    1: 配置編譯內核

    在內核原代碼主目錄下make menuconfig內核加入了ppp,socket 等選項

    Device Drivers -> Network device support -> <*> PPP (point-to-point protocol)中,選中所有ppp選項:

    Device Drivers ->

    Network Device Support->

    <*> PPP (point-to-point protocol) support

    [*] PPP multilink support

    <*> PPP support for async serial ports

    <*> PPP support for sync tty ports

    <*> SLIP (serial line) support

    [*] CSLIP compressed headers

    Device Drivers -> Network device support -> <*> Universal TUN/TAP device driver support

    退出,保存配置,重新執行make ARCH=arm CROSS_COMPILE=arm-hisiv300-linux- uImage .

    將arch/arm/boot/下的uImage下載到開發板上重啟系統。

    我的內核設置為:

    Device Drivers -> Network device support -> <*> PPP (point-to-point protocol)中,選中所有ppp選項:

    Device Drivers ->

    Network Device Support->

    <M> PPP (point-to-point protocol) support

    [*] PPP multilink support

    <M> PPP support for async serial ports

    <M> PPP support for sync tty ports

    <M> SLIP (serial line) support

    [*] CSLIP compressed headers

    Device Drivers -> Network device support -> <M> Universal TUN/TAP device driver support

    需要將未安裝的模塊使用insmod命令加載.ko。 也可以直接向上面那樣,編譯出具有這些功能的內核(推薦)




    2、配置

    進入ppp/ppp-2.4.5/

    有兩個目錄etc.ppp scripts

    2.1 修改源代碼scripts目錄下的ppp-on ppp-on-dialer ppp-off

    之後復制到/etc/ppp目錄下

    並修改執行權限,chmod +x ppp-on ppp-off ppp-on-dialer

    2.2 pppd提供認證信息時,可能協商使用PAP或者CHAP認證方式,所以需要修改源代碼etc.ppp目錄下的pap-secrets和chap-secrets,

    在pap-secrets添加需要的用戶名和密碼

    card * card *

    在chap-secrets添加需要的用戶名和口令

    card * card *


    之後將它們復制到/etc/ppp目錄下


    相應的maefile如下:

    TOOLS_TOP_DIR ?= $(shell pwd)

    TOOL_TAR_BALL := ppp-2.4.5.tar.gz

    TOOL_NAME :=ppp-2.4.5

    TOOL_BIN := bin

    OSDRV_CROSS ?= arm-hisiv300-linux

    OSDRV_CROSS_CFLAGS ?= -mcpu=cortex-a7 -mfloat-abi=softfp -mfpu=neon-vfpv4

    subdir := pppd pppdump pppstats chat

    all:

    -rm $(TOOLS_TOP_DIR)/$(TOOL_NAME) -rf;

    tar -xvf $(TOOL_TAR_BALL);

    mkdir -p $(TOOLS_TOP_DIR)/$(TOOL_NAME)/$(TOOL_BIN)/;

    mkdir -p $(TOOLS_TOP_DIR)/$(TOOL_BIN)/;

    pushd $(TOOLS_TOP_DIR)/$(TOOL_NAME)/; \

    ./configure > /dev/null; \

    make CC=arm-hisiv300-linux-gcc -j 20 > /dev/null; \

    for d in $(subdir); do(arm-hisiv300-linux-strip $$d/$$d;cp $$d/$$d $(TOOLS_TOP_DIR)/$(TOOL_BIN) -rf); done

    popd

    .PHONY: clean


    -pushd $(TOOLS_TOP_DIR)/$(TOOL_NAME)/ &&\

    make -C $(TOOLS_TOP_DIR)/$(TOOL_NAME)/ clean && \

    popd


    .PHONY: distclean

    distclean:

    -rm $(TOOLS_TOP_DIR)/$(TOOL_NAME) -rf;

    -rm $(TOOLS_TOP_DIR)/$(TOOL_BIN) -rf;


    iptables的配置:

    一、配置內核並編譯,支持netfilter

    cd linux-3.10.y

    make ARCH=arm CROSS_COMPILE=arm-hisiv300-linux- menuconfig

    [*] Networking support --->

    Networking options --->

    [*] Network packet filtering framework (Netfilter) --->

    Core Netfilter Configuration --->(全部選上)

    IP: Netfilter Configuration ---> (全部選上)


    註意:這裏的所有選項一定選為built-in [*],而不能選為Module [M],如果選為Module,重新燒制的系統內核裏用modprobe ip_tables 命令將不能找到iptables模塊。上一步還有一點要註意的是IP: Netfilter configuration中的FULL NAT選項一定要選中,否則將不能使用 iptables -t nat命令


    makefile修改入下:

    TOOLS_TOP_DIR ?= $(shell pwd)

    TOOL_TAR_BALL := iptables-1.6.1.tar.bz2

    TOOL_NAME :=iptables-1.6.1

    TOOL_BIN := install

    OSDRV_CROSS ?= arm-hisiv300-linux

    OSDRV_CROSS_CFLAGS ?= -mcpu=cortex-a7 -mfloat-abi=softfp -mfpu=neon-vfpv4

    all:

    -rm $(TOOLS_TOP_DIR)/$(TOOL_NAME) -rf;

    tar -xvf $(TOOL_TAR_BALL);

    mkdir -p $(TOOLS_TOP_DIR)/$(TOOL_BIN)/;

    pushd $(TOOLS_TOP_DIR)/$(TOOL_NAME)/; \

    ./configure --host=$(OSDRV_CROSS) --prefix=$(TOOLS_TOP_DIR)/$(TOOL_BIN) \

    --enable-static --disable-shared --disable-ipv6 --disable-nftables \

    --disable-largefile > /dev/null; \

    make -j 20 > /dev/null; \

    make install > /dev/null; \

    arm-hisiv300-linux-strip $(TOOLS_TOP_DIR)/$(TOOL_BIN)/sbin/xtables-multi

    rm -rf $(TOOLS_TOP_DIR)/$(TOOL_BIN)/sbin/iptables*

    mv $(TOOLS_TOP_DIR)/$(TOOL_BIN)/sbin/xtables-multi $(TOOLS_TOP_DIR)/$(TOOL_BIN)/sbin/iptables

    popd

    .PHONY: clean

    clean:

    -pushd $(TOOLS_TOP_DIR)/$(TOOL_NAME)/ &&\

    make -C $(TOOLS_TOP_DIR)/$(TOOL_NAME)/ clean && \

    popd

    .PHONY: distclean

    distclean:

    -rm $(TOOLS_TOP_DIR)/$(TOOL_NAME) -rf;

    -rm $(TOOLS_TOP_DIR)/$(TOOL_BIN) -rf;

    移植e2fsprogs相關

    TOOLS_TOP_DIR ?= $(shell pwd)

    TOOL_TAR_BALL := e2fsprogs-1.41.11.tar.gz

    TOOL_NAME := e2fsprogs-1.41.11

    TOOL_BIN := bin

    OSDRV_CROSS ?= arm-hisiv300-linux

    OSDRV_CROSS_CFLAGS ?= -mcpu=cortex-a7 -mfloat-abi=softfp -mfpu=neon-vfpv4

    all:

    -rm $(TOOLS_TOP_DIR)/$(TOOL_NAME) -rf;

    tar -xzf $(TOOL_TAR_BALL);

    mkdir -p $(TOOLS_TOP_DIR)/$(TOOL_NAME)/$(TOOL_BIN)/;

    mkdir -p $(TOOLS_TOP_DIR)/$(TOOL_BIN)/;

    pushd $(TOOLS_TOP_DIR)/$(TOOL_NAME)/; \

    ./configure --host=$(OSDRV_CROSS) CFLAGS="$(OSDRV_CROSS_CFLAGS)" \

    LDFLAGS="$(OSDRV_CROSS_CFLAGS)" --prefix=$(TOOLS_TOP_DIR)/$(TOOL_NAME)/$(TOOL_BIN) \

    --disable-tls > /dev/null; \

    make -j 20 > /dev/null; \

    make install > /dev/null; \

    cp $(TOOL_BIN)/sbin/mkfs.ext2 $(TOOLS_TOP_DIR)/$(TOOL_BIN) -rf; \

    cp $(TOOL_BIN)/sbin/mkfs.ext3 $(TOOLS_TOP_DIR)/$(TOOL_BIN) -rf; \

    cp $(TOOL_BIN)/sbin/mkfs.ext4 $(TOOLS_TOP_DIR)/$(TOOL_BIN) -rf; \

    cp $(TOOL_BIN)/sbin/mke2fs $(TOOLS_TOP_DIR)/$(TOOL_BIN) -rf; \

    popd

    .PHONY: clean

    -pushd $(TOOLS_TOP_DIR)/$(TOOL_NAME)/ &&\

    make -C $(TOOLS_TOP_DIR)/$(TOOL_NAME)/ clean && \

    popd

    .PHONY: distclean

    distclean:

    -rm $(TOOLS_TOP_DIR)/$(TOOL_NAME) -rf;

    -rm $(TOOLS_TOP_DIR)/$(TOOL_BIN) -rf;

    頂層makefile如下:

    subdir:=ppp iptables e2fsprogs udev reg-tools bftpd

    TOP_DIR:=$(shell pwd)

    TOP_BIN:=bin

    TOP_ETC:=etc

    all:

    mkdir -p $(TOP_DIR)/$(TOP_BIN)

    mkdir -p $(TOP_DIR)/$(TOP_ETC)

    for d in $(subdir); do (make -C $$d); done

    cp creat_softlink.sh $(TOP_DIR)/$(TOP_BIN) && chmod a+x $(TOP_DIR)/$(TOP_BIN)/creat_softlink.sh

    for d in $(subdir); do (cp $$d/$(TOP_BIN)/* $(TOP_DIR)/$(TOP_BIN) -rf); done

    for d in $(subdir); do (cp $$d/$(TOP_ETC)/* $(TOP_DIR)/$(TOP_ETC) -rf); done

    .PHONY:clean distclean

    clean:

    for d in $(subdir); do (make clean -C $$d); done

    distclean:

    -rm $(shell pwd)/bin -rf;

    -rm $(shell pwd)/etc -rf;

    for d in $(subdir); do (make distclean -C $$d); done


    移植命令和庫到海思相關芯片