新聞中心

        EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > ARM開(kāi)發(fā)板上uClinux內(nèi)核移植

        ARM開(kāi)發(fā)板上uClinux內(nèi)核移植

        作者: 時(shí)間:2010-02-01 來(lái)源:網(wǎng)絡(luò) 收藏

        4.項(xiàng)目及說(shuō)明

        4.1壓縮代碼起始地址修改

        修改文件:-dist/linux-2.4.x/arch/armnommu/boot/Makefile

        修改內(nèi)容:

        ifeq

        ($(CONFIG_BOARD_MBA44),y)

        ZTEXTADDR = 0x0c100000

        ZRELADDR =

        0x0c008000

        endif

        說(shuō)明:

        ZTEXTADDR:自解壓代碼的起始地址。

        ZRELADDR:解壓后代碼輸出起始地址。

        4.2處理器配置選項(xiàng)的修改

        修改文件:-dist/linux-2.4.x/arch/armnommu/config.in

        修改內(nèi)容:

        define_bool

        CONFIG_NO_PGT_CACHE y

        define_bool CONFIG_CPU_WITH_CACHE y

        define_bool

        CONFIG_CPU_WITH_MCR_INSTRUCTION n

        - define_int CONFIG__CLK 60000000

        -

        define_bool CONFIG_SERIAL_S3C44B0X y

        - define_int CONFIG_FORCE_MAX_ZONEORDER

        5

        + define_int CONFIG__CLK 64000000 #72000000

        +# define_bool

        CONFIG_SERIAL_S3C44B0X y

        +# define_int CONFIG_FORCE_MAX_ZONEORDER 5

        if [

        $CONFIG_SET_MEM_PARAM = n ]; then

        - define_hex DRAM_BASE 0x00000000

        +

        define_hex DRAM_BASE 0x0C000000

        define_hex DRAM_SIZE 0x00800000

        -

        define_hex FLASH_MEM_BASE 0x01000000

        + define_hex FLASH_MEM_BASE

        0x00000000

        define_hex FLASH_SIZE

        0x00200000

        fi

        fi

        ……

        說(shuō)明:

        修改了對(duì)處理器主頻的定義:

        define_int

        CONFIG_ARM_CLK 64000000

        修改了存儲(chǔ)器大小和起始地址的定義:

        define_hex DRAM_BASE

        0x0C000000;SDRAM的起始地址

        define_hex DRAM_SIZE 0x00800000;SDRAM的大小

        define_hex

        FLASH_MEM_BASE 0x00000000;flash的起始地址

        define_hex FLASH_SIZE

        0x00200000;flash的大小

        4.3起始地址的修改

        修改文件:-dist/linux-2.4.x/arch/armnommu/Makefile

        修改內(nèi)容:

        ifeq

        ($(CONFIG_BOARD_MBA44),y)

        -TEXTADDR = 0x0c000000

        +TEXTADDR =

        0x0c008000

        MACHINE = S3C44B0X

        INCDIR = $(MACHINE)

        -CORE_FILES :=

        $(CORE_FILES) romfs.o

        +CORE_FILES := $(CORE_FILES)

        #romfs.o

        endif

        說(shuō)明:

        TEXTADDR:內(nèi)核的起始地址,通常取值:DRAM_BASE+0x8000。

        4.4ROM文件系統(tǒng)的定位修改

        修改文件:uClinux-dist/linux-2.4.x/drivers/block/blkmem.c

        修改內(nèi)容:

        +#ifdef

        CONFIG_BOARD_MBA44

        + {0, 0xc700000, -1},/*{0, 0x100000,

        -1},*/

        #endif

        說(shuō)明:將ROM file system在SDRAM中的地址定位在0xc700000。

        4.5修改存儲(chǔ)空間配置

        修改文件:uClinux-dist/linux-2.4.x/include/asm-armnommu/arch-S3C44B0X/memory.h

        修改內(nèi)容:

        -#define

        PHYS_OFFSET (DRAM_BASE + 2*1024*1024)

        +#define PHYS_OFFSET

        (DRAM_BASE)//(DRAM_BASE + 2*1024*1024)

        #define PAGE_OFFSET

        (PHYS_OFFSET)

        -#define END_MEM (DRAM_BASE + DRAM_SIZE -

        2*1024*1024)

        +#define END_MEM (DRAM_BASE+DRAM_SIZE)//(DRAM_BASE + DRAM_SIZE -

        2*1024*1024)

        說(shuō)明:PHYS_OFFSET:RAM第一個(gè)bank的起始地址。

        4.6初始化節(jié)拍定時(shí)器

        修改文件:uClinux-dist/linux-2.4.x/include/asm-armnommu/arch-S3C44B0X/time.h

        修改內(nèi)容:

        -extern

        void s3c44b0x_timer_interrupt(int irq, void *dev_id, struct pt_regs

        *regs);

        +//extern void s3c44b0x_timer_interrupt(int irq, void *dev_id, struct

        pt_regs *regs);

        +static inline void s3c44b0x_timer_interrupt(int irq, void

        *dev_id, struct pt_regs *regs)

        +{

        + do_leds();

        +

        do_timer(regs);

        +}//modified by hzh

        /* TODO: THE, 2003-08-13, do timer setup like in eCos */

        -#define

        S3C44B0X_TIMER5_PRESCALER 16

        +#define S3C44B0X_TIMER5_PRESCALER 32

        extern __inline__ void setup_timer (void)

        {

        u_int32_t

        tmod;

        u_int32_t period;

        + __u32 rw_tmp;

        period = (CONFIG_ARM_CLK/S3C44B0X_TIMER5_PRESCALER)/HZ;

        outl(period,

        S3C44B0X_TCNTB5);

        @@ -36,8 +42,14 @@

        outl(tmod, S3C44B0X_TCON);

        /* initialize the timer period and prescaler */

        - outl((5-1) 16,

        S3C44B0X_TCFG0);

        - outl( (0x3 20), S3C44B0X_TCFG1); /* prescaler

        */

        + rw_tmp = inl(S3C44B0X_TCFG0);

        + rw_tmp = ~(0xff16);

        +

        rw_tmp |= (16-1)16;

        + outl(rw_tmp, S3C44B0X_TCFG0); // prescaler =

        1/16

        + rw_tmp = inl(S3C44B0X_TCFG1);

        + rw_tmp =

        ~(0xf20);

        + rw_tmp |= 020;

        + outl(rw_tmp, S3C44B0X_TCFG1);

        // mux = 1/2

        說(shuō)明:這里,uClinux使用了S3C44B0X的內(nèi)部定時(shí)器5,并利用定時(shí)器5的中斷來(lái)產(chǎn)生節(jié)拍。

        4.7定義二級(jí)異常中斷矢量表的起始地址

        修改文件:uClinux-dist/linux-2.4.x/include/asm-armnommu/proc/system.h

        修改內(nèi)容:

        +#ifdef

        CONFIG_BOARD_MBA44

        +#undef vectors_base()

        +#define vectors_base()

        (DRAM_BASE)

        +#endif

        說(shuō)明:vectors_base()定義了二級(jí)異常中斷矢量表的起始地址,這個(gè)地址與Bootloader中的_IRQ_BASEADDRESS相對(duì)應(yīng)。

        4.8定義CPU體系結(jié)構(gòu)和交叉編譯器

        修改文件:uClinux-dist/linux-2.4.x/Makefile

        修改內(nèi)容:

        -# ARCH :=

        armnommu

        +ARCH := armnommu

        # ARCH := m68knommu

        # ARCH := h8300

        #

        ARCH := niosnommu

        ……

        HOSTCFLAGS = -Wall -Wstrict-prototypes -O2

        -fomit-frame-pointer

        # CROSS_COMPILE = m68k-elf-

        -# CROSS_COMPILE = arm-elf-

        +CROSS_COMPILE

        = arm-elf-

        # CROSS_COMPILE = h8300-elf-

        # CROSS_COMPILE = nios-elf-

        #

        CROSS_COMPILE = e1-coff-

        說(shuō)明:這里定義了CPU體系結(jié)構(gòu):ARCH :=

        armnommu和對(duì)應(yīng)的交叉編譯器名稱(chēng):CROSS_COMPILE = arm-elf-。

        4.9以太網(wǎng)卡寄存器地址的偏移量修改

        這里針對(duì)ARMSYS的硬件結(jié)構(gòu),要做兩處特殊的修改:

        修改文件:uClinux-dist/linux-2.4.x/driver/net/8390.h

        修改內(nèi)容:#define

        ETH_ADDR_SFT 8

        說(shuō)明:訪(fǎng)問(wèn)RTL8019內(nèi)部寄存器地址的偏移量。

        4.10以太網(wǎng)設(shè)備基地址修改

        修改文件:uClinux-dist/linux-2.4.x/driver/net/ne.c

        修改內(nèi)容:dev->base_addr =

        base_addr = 0x08000000;

        說(shuō)明:修改了以太網(wǎng)設(shè)備的基地址。

        5.的步驟

        5.1解壓uClinux-dist發(fā)行包

        到以下地址下載uClinux-dist-20040408.tar.gz源代碼包:

        http://www.uclinux.org/pub/uClinux/dist/uClinux-dist-20040408.tar.gz

        該版本在很多方面比早先的20030522版本要完善很多,這也使我們的工作變得方便很多。其中使用的內(nèi)核版本是Linux

        2.4.24。

        以下工作在裝有Linux操作系統(tǒng)(例如RedHat9.0)的PC機(jī)上進(jìn)行。

        將uClinux-dist-20040408.tar.gz拷貝到/home/下(或者其它目錄都可以),運(yùn)行解壓命令:

        tar xvzf uClinux-ARMSYS-20040801.tar.gz

        解壓結(jié)束后會(huì)在/home/下生成uClinux-dist目錄。

        5.2安裝補(bǔ)丁

        到以下地址下載補(bǔ)丁文件:

        http://www.hzlitai.com.cn/download/uClinux-20040408-ARMSYS.rar

        解壓后產(chǎn)生patch文件,安裝patch文件:

        patch Cp1 uClinux-20040408-ARMSYS.patch

        安裝過(guò)程中可能會(huì)出現(xiàn)一些錯(cuò)誤信息,可以手動(dòng)地按照patch文件的內(nèi)容在指定的文件處進(jìn)行修改一下。

        6.配置與編譯

        6.1安裝編譯環(huán)境

        到以下地址下載arm-elf工具鏈:

        http://www.uclinux.org/pub/uClinux/m68k-elf-tools/arm-elf-tools-20030314.sh

        將arm-elf-tools-20030314.sh拷貝到根目錄,運(yùn)行安裝:

        sh arm-elf-tools-20030314.sh

        6.2內(nèi)核配置

        下面就可以開(kāi)始配置uClinux的內(nèi)核和用戶(hù)選項(xiàng)了。打開(kāi)終端。

        # cd /home/uClinux-dist

        # make

        menuconfig

        進(jìn)入uClinux配置(uClinux v3.1.0 Configuration),選中“Kernel/Library/Defaults

        Selectionà”敲空格進(jìn)入。其中有兩個(gè)選項(xiàng):定制內(nèi)核設(shè)置和定制用戶(hù)選項(xiàng)設(shè)置:

        [*] Customize Kernel Settings

        [

        ] Customize Vendor/User Settings

        選中定制內(nèi)核設(shè)置選項(xiàng),按下ESC鍵退出,在詢(xún)問(wèn)是否保存時(shí),選擇Yes并回車(chē)。

        終端將首先進(jìn)入內(nèi)核配置選單。我們?cè)谂渲胾Clinux內(nèi)核時(shí),就可以通過(guò)對(duì)這些選項(xiàng)的選擇和取消選擇來(lái)設(shè)定內(nèi)核所具有的功能項(xiàng)。這也是裁減uClinux內(nèi)核的基本方法。

        每個(gè)選項(xiàng)都對(duì)應(yīng)著一個(gè)宏定義,make

        menuconfig執(zhí)行結(jié)束后,自動(dòng)將配置結(jié)果保存為.config文件,將前一次的配置結(jié)果備份為.config.old文件。

        讀者可到http://www.hzlitai.com.cn/download/linux/8019/kernelconfig_eth

        處下載內(nèi)核配置文件(其中包括對(duì)網(wǎng)卡驅(qū)動(dòng)的配置),讀者可對(duì)照進(jìn)行配置。

        6.3交叉編譯

        按下面的步驟對(duì)uClinux源碼包進(jìn)行編譯:

        # make dep

        # make clean (非必要)

        # make

        lib_only

        # make user_only

        # make romfs

        # make image

        #

        make

        初次移植時(shí),在make

        lib_only到make這5步編譯過(guò)程中很可能產(chǎn)生錯(cuò)誤,無(wú)法繼續(xù)下去。如果產(chǎn)生了錯(cuò)誤,可以嘗試根據(jù)報(bào)告的錯(cuò)誤內(nèi)容修改一下源程序,這一過(guò)程將有助于你熟悉uClinux內(nèi)核源程序的結(jié)構(gòu),或者可以跟我們聯(lián)系

        Support@hzlitai.com.cn

        交叉編譯成功后,在 uClinux-dist/目錄下產(chǎn)生images目錄,其中包含的3個(gè)文件:image.ram,

        image.rom和romfs.img就是我們可以使用的二進(jìn)制文件。參考《uClinux的移植包在ARMSYS上的使用說(shuō)明》的方法,下載或燒錄這些二進(jìn)制文件,并啟動(dòng)運(yùn)行uClinux。

        7.啟動(dòng)信息

        正確啟動(dòng)信息的例子如下:

        Linux version 2.4.24-uc0 (root@localhost) (gcc

        version 2.95.3 20010315

        (release)(ColdFire patches - 20010318 from http://fiddes

        .net/coldfire/)(uClinux XIP and shared

        lib patches from http://www.snapgear.com/

        )) #165 五 10月 8

        20:04:10 CST 2004

        Processor: Samsung S3C44B0X revision 0

        Architecture:

        S3C44B0X

        On node 0 totalpages: 2048

        zone(0): 0 pages.

        zone(1): 2048

        pages.

        zone(2): 0 pages.

        Kernel command line: root=/dev/rom0

        init=/linuxrc

        Calibrating delay loop... 31.84 BogoMIPS

        Memory: 8MB = 8MB

        total

        Memory: 6592KB available (1270K code, 155K data, 40K init)

        Dentry

        cache hash table entries: 1024 (order: 1, 8192 bytes)

        Inode cache hash table

        entries: 512 (order: 0, 4096 bytes)

        Mount cache hash table entries: 512

        (order: 0, 4096 bytes)

        Buffer cache hash table entries: 1024 (order: 0, 4096

        bytes)

        Page-cache hash table entries: 2048 (order: 1, 8192 bytes)

        POSIX

        conformance testing by UNIFIX

        Linux NET4.0 for Linux 2.4

        Based upon

        Swansea University Computer Society NET3.039

        Initializing RT netlink

        socket

        Starting kswapd

        ttyS0 at I/O 0x1d00000 (irq = 3) is a

        S3C44B0

        ttyS1 at I/O 0x1d04000 (irq = 2) is a S3C44B0

        ne.c:v1.10 9/23/94

        Donald Becker (becker@scyld.com)

        Last

        modified Nov 1, 2000 by Paul Gortmaker

        NE*000 ethercard probe at 0x8000000:

        00 00 e8 12 34 56

        eth0: NE1000 found at 0x8000000, using IRQ 22

        Blkmem

        copyright 1998,1999 D. Jeff Dionne

        Blkmem copyright 1998 Kenneth

        Albanowski

        Blkmem 1 disk images:

        0: C400000-C47CBFF [VIRTUAL

        C400000-C47CBFF] (RO)

        RAMDISK driver initialized: 16 RAM disks of 1024K size

        1024 blocksize

        NET4: Linux TCP/IP 1.0 for NET4.0

        IP Protocols: IC

        IP:

        routing cache hash table of 512 buckets, 4Kbytes

        TCP: Hash tables configured

        (established 512 bind 512)

        VFS: Mounted root (romfs filesystem)

        readonly.

        Freeing init memory: 40K

        Shell invoked to run file:

        /etc/rc

        Command: hostname Samsung

        Command: /bin/expand /etc/ramfs.img

        /dev/ram0

        Command: mount -t proc proc /proc

        Command: mount -t ext2

        /dev/ram0 /var

        Command: mkdir /var/config

        Command: mkdir

        /var/tmp

        Command: mkdir /var/log

        Command: mkdir /var/run

        Command: mkdir

        /var/lock

        Command: cat /etc/motd

        Welcome to

        ____ _ _

        / __| ||_|

        _

        _| | | | _ ____ _ _ _ _

        | | | | | | || | _ | | | | / /

        | |_| | |__| ||

        | | | | |_| |/

        | _______|_||_|_| |_|____|_/_/

        | |

        |_|

        For further information check:

        http://www.uclinux.org/

        Command: ifconfig lo 127.0.0.1

        Command: route add -net 127.0.0.0 netmask

        255.255.255.0 lo

        Command: ifconfig eth0 192.168.253.2 netmask 255.255.255.0

        up

        Execution Finished, Exiting

        Sash command shell (version

        1.1.1)

        />

        出現(xiàn)以上信息后,可以嘗試從鍵盤(pán)輸入ls、ping命令,來(lái)查看系統(tǒng)的運(yùn)行情況。我們還建議讀者按照uClinux-dist

        Documentation下的Adding-User-Apps-HOWTO文檔編寫(xiě)一個(gè)簡(jiǎn)單的Helloworld應(yīng)用程序,看是否能夠正確運(yùn)行。


        上一頁(yè) 1 2 下一頁(yè)

        評(píng)論


        相關(guān)推薦

        技術(shù)專(zhuān)區(qū)

        關(guān)閉
        主站蜘蛛池模板: 古交市| 丹江口市| 盐亭县| 土默特右旗| 扶沟县| 台前县| 赣榆县| 麟游县| 永春县| 宽甸| 铜鼓县| 河北省| 兴城市| 武鸣县| 固原市| 根河市| 新昌县| 炎陵县| 渝北区| 海南省| 绥德县| 富宁县| 马尔康县| 永登县| 老河口市| 化州市| 无锡市| 黔东| 资阳市| 榕江县| 花垣县| 罗源县| 塔城市| 临桂县| 普兰店市| 蕉岭县| 永登县| 翼城县| 辰溪县| 阜康市| 和龙市|