< !-- /* Font Definitions */ @font-face {font-family:宋體; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:SimSun; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:黑體; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:SimHei; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:1 135135232 16 0 262144 0;} @font-face {font-family:Calibri; mso-font-alt:Arial; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:0 0 0 0 0 0;} @font-face {font-family:"/@宋體"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"/@黑體"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:1 135135232 16 0 262144 0;} @font-face {font-family:Fixedsys; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-alt:方正舒體; mso-font-charset:134; mso-generic-font-family:auto; mso-font-format:other; mso-font-pitch:fixed; mso-font-signature:1 135135232 16 0 262144 0;} @font-face {font-family:"/@Fixedsys"; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:134; mso-generic-font-family:auto; mso-font-format:other; mso-font-pitch:fixed; mso-font-signature:1 135135232 16 0 262144 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin-top:0cm; margin-right:0cm; margin-bottom:10.0pt; margin-left:0cm; line-height:120%; mso-pagination:none; mso-hyphenate:none; font-size:10.0pt; font-family:Calibri; mso-fareast-font-family:宋體; mso-bidi-font-family:"Times New Roman"; mso-fareast-language:EN-US; mso-bidi-language:EN-US; font-style:italic;} /* Page Definitions */ @page {mso-page-border-surround-header:no; mso-page-border-surround-footer:no;} @page Section1 {size:595.3pt 841.9pt; margin:72.0pt 90.0pt 72.0pt 90.0pt; mso-header-margin:36.0pt; mso-footer-margin:36.0pt; mso-paper-source:0; layout-grid:15.6pt;} div.Section1 {page:Section1;}--> uboot-2010.03移植到2410(從nand啟動(dòng)) 【環(huán)境】 <a> Ubuntu 10.04 LTS <b> u-boot-2010.03 <c> FS2410 主板,,SAMSUNG S3C2410A 微處理器 <d> 交叉編譯器 arm-linux-gcc-4.3.2 <e> Nand: Samsung K9F1208U0B,, 64M
【步驟】 Step1: 創(chuàng)建板級源碼 <1> 解壓 furtherchan@further:~/work$ tar -jxvf u-boot-2010.03.tar.bz2 <2>進(jìn)入板極源碼目錄 furtherchan@further:~/work/u-boot-2010.03/board/samsung$ ls smdk2400 smdk2410 smdk6400 smdkc100
<3>拷貝一份最相似的平臺代碼: furtherchan@further:~/work/u-boot-2010.03/board/samsung$ cp -av smdk2410/ fs2410 `smdk2410/' -> `fs2410' `smdk2410/Makefile' -> `fs2410/Makefile' `smdk2410/config.mk' -> `fs2410/config.mk' `smdk2410/flash.c' -> `fs2410/flash.c' `smdk2410/smdk2410.c' -> `fs2410/smdk2410.c' `smdk2410/lowlevel_init.S' -> `fs2410/lowlevel_init.S'
furtherchan@further:~/work/u-boot-2010.03/board/samsung$ ls fs2410 smdk2400 smdk2410 smdk6400 smdkc100 furtherchan@further:~/work/u-boot-2010.03/board/samsung$ cd fs2410/
修改文件名 furtherchan@further:~/work/u-boot-2010.03/board/samsung/fs2410$ mv smdk2410.c fs2410.c
修改Makefile furtherchan@further:~/work/u-boot-2010.03/board/samsung/fs2410$ vim Makefile COBJS := smdk2410.o flash.o → COBJS := fs2410.o flash.o 拷貝頭文件 furtherchan@further:~/work/u-boot-2010.03/board/samsung/fs2410$ cd ../../../include/configs/ furtherchan@further:~/work/u-boot-2010.03/include/configs$ cp -v smdk2410.h fs2410.h `smdk2410.h' -> `fs2410.h'
退回U-Boot根目錄 furtherchan@further:~/work/u-boot-2010.03/include/configs$ cd ../.. furtherchan@further:~/work/u-boot-2010.03$
<4>修改頂級Makefile furtherchan@further:~/work/u-boot-2010.03$ vim Makefile smdk2410_config : unconfig @$(MKCONFIG) $(@:_config=) arm arm920t smdk2410 samsung s3c24x0
在3045和3046行(即以上兩句)下加入以下兩句: fs2410_config : unconfig @$(MKCONFIG) $(@:_config=) arm arm920t fs2410 samsung s3c24x0
<5>編譯 furtherchan@further:~/work/u-boot-2010.03$make fs2410_config furtherchan@further:~/work/u-boot-2010.03$make …... arm-linux-objcopy-O srec u-boot u-boot.srec arm-linux-objcopy--gap-fill=0xff -O binary u-boot u-boot.bin furtherchan@further:~/work/u-boot-2010.03$ ll -h u-boot.bin -rwxr-xr-x 1 furtherchan furtherchan 99K 2010-07-05 20:25 u-boot.bin 此時(shí)編譯生成的u-boot.bin文件還無法運(yùn)行在fs2410開發(fā)板上,需要做以下修改.
Step2: 修改平臺相關(guān)信息
<1>修改中斷禁止部分 furtherchan@further:~/work/u-boot-2010.03$ cd cpu/arm920t/ furtherchan@further:~/work/u-boot-2010.03/cpu/arm920t$ vim start.S # if defined(CONFIG_S3C2410) ldr r1, =0x3ff ldr r0, =INTSUBMSK str r1, [r0]
修改成如下: # if defined(CONFIG_S3C2410) ldr r1, =0x7ff ldr r0, =INTSUBMSK str r1, [r0]
<2>修改SDRAM刷新周期:board/samsung/fs2410/lowlevel_init.S #define REFCNT 1113 /* period=15.6us, HCLK=60Mhz, (2048+1-15.6*60) */ 改成: #define REFCNT 1268 /* period=7.8125us, HCLK=100Mhz, (2048+1-7.8125*100) */
Step3: U-BOOT增加NAND啟動(dòng)支持 <1>修改命令提示符,,在include/configs/fs2410.h中修改如下代碼: #define CONFIG_SYS_PROMPT "SMDK2410 # " 改成: #define CONFIG_SYS_PROMPT "fs2410 # " <2>修改默認(rèn)載入地址 #define CONFIG_SYS_LOAD_ADDR 0x33000000 改成: #define CONFIG_SYS_LOAD_ADDR 0x30008000
<3>加入支持nand寫 #define CONFIG_ENV_IS_IN_FLASH 1 改成: #define CONFIG_ENV_IS_IN_NAND 1 /* common/env_nand.c */
并增加一句: #define CONFIG_ENV_OFFSET 0x30000
<4>調(diào)試過程 U-Boot第一階段完成后,,跳轉(zhuǎn)到第二階段的主函數(shù)lib_arm/board.c中271行: void start_armboot (void) ,在該函數(shù)中有如下定義: #if defined(CONFIG_CMD_NAND) puts ("NAND: "); nand_init(); /* go init the NAND */ #endif 為了支持NAND,,在include/configs/fs2410.h中添加如下代碼: #define CONFIG_CMD_NAND
添加完先編譯一下: furtherchan@further:~/work/u-boot-2010.03$ make distclean Generating include/autoconf.mk furtherchan@further:~/work/u-boot-2010.03$ make fs2410_config Configuring for fs2410 board... furtherchan@further:~/work/u-boot-2010.03$ arm-linux-gcc -v Using built-in specs. Target: arm-none-linux-gnueabi …... gcc version 4.3.2 (Sourcery G++ Lite 2008q3-72)
編譯,,出現(xiàn)錯(cuò)誤: furtherchan@further:~/work/u-boot-2010.03$ make CROSS_COMPILE=arm-linux- make[1]: Entering directory `/home/furtherchan/work/u-boot-2010.03/drivers/mtd/nand' …... -o nand.o nand.c -c nand.c:29: error: 'CONFIG_SYS_MAX_NAND_DEVICE' undeclared here (not in a function) nand.c:32: error: 'CONFIG_SYS_NAND_BASE' undeclared here (not in a function) make[1]: *** [nand.o] Error 1 make[1]: Leaving directory `/home/furtherchan/work/u-boot-2010.03/drivers/mtd/nand' make: *** [drivers/mtd/nand/libnand.a] Error 2
在include/configs/fs2410.h中繼續(xù)添加代碼: #define CONFIG_SYS_MAX_NAND_DEVICE 1 #define CONFIG_SYS_NAND_BASE 0x4E000000
繼續(xù)編譯,,出現(xiàn)錯(cuò)誤: furtherchan@further:~/work/u-boot-2010.03$ make CROSS_COMPILE=arm-linux- make[1]: Leaving directory `/home/furtherchan/work/u-boot-2010.03/cpu/arm920t' …... drivers/mtd/nand/libnand.a(nand.o): In function `nand_init_chip': /home/furtherchan/work/u-boot-2010.03/drivers/mtd/nand/nand.c:48: undefined reference to `board_nand_init' make: *** [u-boot] Error 1 板級nand初始化函數(shù)找不到,,在drivers/mtd/nand/目錄下有個(gè)s3c2410_nand.c文件,一直不知道是什么時(shí)候用的,,估計(jì)是需要調(diào)用該文件中的board_nand_init(),。 查看drivers/mtd/nand/nand.c,其中nand_init_chip調(diào)用了board_nand_init(),,同時(shí)在/drivers/mtd/nand/s3c2410_nand.c中有board_nand_init()函數(shù),,下面就要考慮如何把s3c2410_nand.c的board_nand_init()整到 nand.c中。 分析該目錄下的Makefile,,用s3c2410關(guān)鍵字查詢到如下內(nèi)容: COBJS-$( CONFIG_NAND_S3C2410 ) += s3c2410_nand.o
要使該行編譯進(jìn)工程,,需定義CONFIG_NAND_S3C2410,同樣,,在include/configs/fs2410.h中繼續(xù)添加代碼: #define CONFIG_NAND_S3C2410
繼續(xù)編譯: furtherchan@further:~/work/u-boot-2010.03$ make CROSS_COMPILE=arm-linux-
編譯成功,,燒寫板子,輸出如下信息: fs2410 #
U-Boot 2010.03 (Jul 06 2010 - 13:22:17) DRAM: 64 MB Flash: 512 kB NAND: 64 MiB *** Warning - bad CRC or NAND, using default environment In: serial Out: serial Err: serial Net: CS8900-0
fs2410 # nand info Device 0: NAND 64MiB 3,3V 8-bit, sector size 16 KiB fs2410 # saveenv Saving Environment to NAND... Erasing Nand... Erasing at 0x3c00000000001 -- 0% complete. Writing to Nand... done fs2410 #
可見nand讀寫成功,。 設(shè)好環(huán)境參數(shù)后啟動(dòng),,出現(xiàn)如下錯(cuò)誤: fs2410 # boot NAND read: device 0 offset 0x40000, size 0x200000 2097152 bytes read: OK ## Starting application at 0x30008000 ... Uncompressing Linux................................................................................................................. done, booting the kernel. Error: unrecognized/unsupported machine ID (r1 = 0x33f4fb6c). Available machine support: ID (hex) NAME 000000c1 SMDK2410 0000015b IPAQ-H1940 00000290 Acer-N30 0000014b Simtec-BAST 000002a8 Nex Vision - Otom 1.1 00000400 AML_M5900 000001db Thorcom-VR1000 00000454 QT2410 000003fe SMDK2413 000003f1 SMDK2412 00000377 S3C2413 00000474 VSTMS 000002de Simtec-Anubis 0000034a Simtec-OSIRIS 00000250 IPAQ-RX3715 0000016a SMDK2440 000002a9 NexVision - Nexcoder 2440 0000043c SMDK2443
Please check your kernel config and/or bootloader. 以上信息可見,,machine Id不匹配,由于本人的zImage之前在板子上跑是正確的,,基本可斷定u-boot平臺ID傳遞錯(cuò)誤: fs2410 # bdinfo arch_number = 0x000000C1 env_t = 0x00000000 boot_params = 0x30000100 DRAM bank = 0x00000000 -> start = 0x30000000 -> size = 0x04000000 ethaddr = aa:2c:33:44:55:66 ip_addr = 192.168.1.212 baudrate = 115200 bps 以上arch_number轉(zhuǎn)換成10進(jìn)制即193,,在內(nèi)核源碼文件include/asm-arm/mach-types.h 中有相應(yīng)定義,在u-boot文件include/asm-arm/mach-types.h 存在相同定義: #define MACH_TYPE_SMDK2410 193 在board/samsung/fs2410/fs2410.c中有如下定義: /* arch number of SMDK2410-Board */ gd->bd->bi_arch_number = MACH_TYPE_SMDK2410; /* adress of boot parameters */ gd->bd->bi_boot_params = 0x30000100;
看來的確是uboot沒有把參數(shù)傳遞給內(nèi)核,。
board/samsung/fs2410/fs2410.c : #include< asm/arch/s3c24x0_cpu.h> include/asm-arm/arch-s3c24x0/s3c24x0_cpu.h s3c24x0_cpu.h 內(nèi)容如下: #ifdef CONFIG_S3C2400 #include <asm/arch/s3c2400.h> #elif defined CONFIG_S3C2410 #include < asm/arch/s3c2410.h> #else #error Please define the s3c24x0 cpu type #endif
需要定義:CONFIG_S3C2410,,在fs2410.h中已有該定義
解決:在common/cmd_boot.c中do_go()函數(shù)修改如下: int do_go (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) { ulong addr, rc; int rcode = 0; /************* Add by FurtherChan ************/ char*commandline = getenv ("bootargs" ); struct param_struct *my_params = (struct param_struct *) 0x30000100; memset (my_params, 0, sizeof (struct param_struct)); my_params->u1.s.page_size = 4096; my_params->u1.s.nr_pages = 0x4000000>> 12; memcpy (my_params->commandline, commandline, strlen (commandline) + 1); /***************** Add end *******************/ if (argc < 2) { cmd_usage (cmdtp); return 1; } addr = simple_strtoul (argv[1], NULL, 16); printf ("## Starting application at 0x%08lX .../n", addr); /* * pass address parameter as argv[0] (aka command name), * and all remaining args */ /*************** Add by FurtherChan *************/ __asm__ ("mov r1, #193/n" "mov ip, #0/n" "mcr p15, 0, ip, c13, c0, 0/n" "mcr p15, 0, ip, c7, c7, 0/n" "mcr p15, 0, ip, c7, c10, 4/n" "mcr p15, 0, ip, c8, c7, 0/n" "mrc p15, 0, ip, c1, c0, 0/n" "bic ip, ip, #0x0001/n" "mov pc, %0/n""nop/n" : :"r" (addr) ); /***************** Add end ********************/ rc = do_go_exec ((void *) addr, argc - 1, argv + 1); if (rc != 0) rcode = 1; printf ("## Application terminated, rc = 0x%lX/n", rc); return rcode; }
重新編譯后,燒寫,,啟動(dòng)板子: fs2410 # boot
NAND read: device 0 offset 0x40000, size 0x200000 2097152 bytes read: OK ## Starting application at 0x30008000 ... Uncompressing Linux................................................................................................................. done, booting the kernel. Linux version 2.6.22.6 (furtherchan@further) (gcc version 4.3.2 (Sourcery G++ Lite 2008q3-72) ) #25 Thu Jul 1 16:25:29 CST 2010 CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=00007177 Machine: SMDK2410 ATAG_INITRD is deprecated; please update your bootloader. Memory policy: ECC disabled, Data cache writeback CPU S3C2410A (id 0x32410002) S3C2410: core 202.800 MHz, memory 101.400 MHz, peripheral 50.700 MHz …...
啟動(dòng)成功,! |
|