Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2252081
  • 博文数量: 218
  • 博客积分: 5767
  • 博客等级: 大校
  • 技术积分: 5883
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-01 14:44
文章存档

2012年(53)

2011年(131)

2009年(1)

2008年(33)

分类: 嵌入式

2011-10-27 17:21:51

u-boot-2011.09ST2410上的移植之在RAM中运行

作者:mutes


u-boot版本:u-boot-2011.09

运行环境:Window7  Vmware workstation7.1   CentOS6.0
交叉编译环境:Arm-linux-gcc-4.3.2 with EABI

硬件环境:

ST2410X开发板(CPUS3C2410X64M SDRAM: 2HY57V561620FTP-H2M norflash: 39VF160164M nandflash:K9F1208U0M,网卡:cs8900a

移植时间:2011.10.27
源码下载地址:

参考文献:
http://blog.csdn.net/csuwzc/article/details/6453623
使用JLink间接烧写S3C2410S3C2440开发板NorNand Flash的方法:http://www.ourdev.cn/bbs/bbs_content_all.jsp?bbs_sn=3228953

一、创建板子文件夹和配置文件

1、解压源码包并进入源码目录

[just@just study]$ tar jxvf u-boot-2011.09.tar.bz2

[just@just study]$ cd u-boot-2011.09

[just@just u-boot-2011.09]$

 

2、在boards.cfg中的smdk2410后加入

[just@just u-boot-2011.09]$ vim boards.cfg //在旧版本中是直接在当前目录下Makefile文件中添加的

smdk2410               arm         arm920t     -                   samsung        s3c24x0

后增加一行

mutes2410                 arm         arm920t     -                   samsung        s3c24x0

st2410_config :       unconfig

        @$(MKCONFIG) $(@:_config=) arm arm920t st2410 NULL s3c24x0我把我的板子起名叫st2410,可以依自己的喜好修改,注意@前用tab键空格。

各项的意思如下:

mutes2410:    开发板的目标板型号(BOARD),对应于board/samsung/mutes2410目录。

arm:        CPU的架构(ARCH)

arm920t:    CPU的类型(CPU),其对应于cpu/arm920t子目录。

:开发板名称,没有就用‘-’表示

samsung:       开发者/或经销商(vender)

s3c24x0:    片上系统(SOC)

最后为Options项,也可不填写

3、建立board/samsung/mutes2410目录,拷贝board/samsung/smdk2410下的文件到board/samsung/mutes2410目录,将smdk2410.c更名为mutes2410.c  //这里比版本多了一级目录samsung

[just@just u-boot-2011.09]$ cp -ar board/samsung/smdk2410 board/samsung/mutes2410

mv board/samsung/mutes2410/smdk2410.c board/samsung/mutes2410/mutes2410.c

 

4board/samsung/mutes2410/Makefile中,如下修改(因为前面将smdk2410.c文件改名为mutes2410.c)

COBJS:= smdk2410.o   //在新版本中没有flash.o

改为:

COBJS:= mutes2410.o

 

5cp include/configs/smdk2410.h include/configs/mutes2410.h

首先将mutes2410.h中的

131 #define CONFIG_SYS_PROMPT       "SMDK2410 # "  //早期版本为CFG_PROMPT

修改为

131 #define CONFIG_SYS_PROMPT       "MUTES2410 # "

6测试编译能否成功:

[just@just u-boot-2011.09]$ make mutes2410_config
awk '(NF && $1 !~ /^#/) { print $1 ": " $1 "_config; $(MAKE)" }' boards.cfg > .boards.depend
Configuring for mutes2410 board...

[just@just u-boot-2011.09]$ make
Generating include/autoconf.mk
Generating include/autoconf.mk.dep
arm-linux-gcc -DDO_DEPS_ONLY \

。。。。。。。。。。。。。。。
然后会生成二进制文件u-boot.bin 这个时候把程序放到开发板上是运行不了的,因为通过tftp下载的程序,它会指定下载地址,然后从指定下载位置运行,而u-boot默认代码地址为0

下面修改相关文件,开启调试配置

1)、修改u-boot默认代码地址为0x33e00000st2410SDRAM空间是0x30000000~0x34000000,共64M),然后修改mutes2410.h

vim include/configs/mutes2410.h

#define CONFIG_SYS_TEXT_BASE    0x0

修改为

#define CONFIG_SYS_TEXT_BASE    0x33e00000

 

2)、在mutes2410.h文件最后#endif前一行添加下面一行

#define CONFIG_SKIP_LOWLEVEL_INIT

CONFIG_SKIP_LOWLEVEL_INIT这个宏用于cpu/arm920t/start.S里,主要是对CPU和存储控制器的初始化,因为我要在RAM中运行,所以调试阶段跳过初始化。

然后重新生成u-boot.bin,通过tftpuboot.bin下载到开发板运行了,当然运行会出错的。

ST2410 # tftp 0x32000000 u-boot.bin
TFTP from server 192.168.1.91; our IP address is 192.168.1.200
Filename 'u-boot.bin'.
Load address: 0x32000000
Loading: #################################################################
         ###########################
done
Bytes transferred = 468028 (7243c hex)
ST2410 # go 0x32000000
## Starting application at 0x32000000 ...
??

U-Boot 2011.09 (Oct 27 2011 - 18:42:31)

DRAM:  64 MiB
WARNING: Caches not enabled
Flash: *** failed ***
### ERROR ### Please RESET the board ###

运行到这里死了。从串口输出信息可以看到u-boot-2011.09默认是不支持39VF1601norflash,在后面我们先去掉对norflash的支持,先让它只在内存运行。

3)、去掉对norflash、网卡的支持

include/configs/mutes2410.h文件中可以看到

 54 /*
 55  * Hardware drivers
 56  */
 57 #define CONFIG_NET_MULTI
 58 #define CONFIG_CS8900           /* we have a CS8900 on-board */
 59 #define CONFIG_CS8900_BASE      0x19000300
 60 #define CONFIG_CS8900_BUS16     /* the Linux driver does accesses as shorts */

我们注释掉第58

include/configs/mutes2410.h文件中找到“FLASH and environment organization”项,可以看到

179 /*-----------------------------------------------------------------------
180  * FLASH and environment organization
181  */
182
183 #define CONFIG_SYS_FLASH_CFI
184 #define CONFIG_FLASH_CFI_DRIVER
185 #define CONFIG_FLASH_CFI_LEGACY
186 #define CONFIG_SYS_FLASH_LEGACY_512Kx16
187 #define CONFIG_FLASH_SHOW_PROGRESS      45
188
189 #define CONFIG_SYS_MAX_FLASH_BANKS      1
190 #define CONFIG_SYS_FLASH_BANKS_LIST     { CONFIG_SYS_FLASH_BASE }
191 #define CONFIG_SYS_MAX_FLASH_SECT       (19)
192
193 #define CONFIG_ENV_ADDR                 (CONFIG_SYS_FLASH_BASE + 0x070000)
194 #define CONFIG_ENV_IS_IN_FLASH
195 #define CONFIG_ENV_SIZE                 0x10000
196 /* allow to overwrite serial and ethaddr */
197 #define CONFIG_ENV_OVERWRITE

 

我们注释掉第183194行,在后面添加宏定义#define CONFIG_SYS_NO_FLASH
及加上宏定义#undef CONFIG_CMD_IMLS

CONFIG_CMD_IMLS是在include/config_cmd_all.h中定义的,这里要把它取消掉,否则将出现如下错误:

In file included from cmd_bootm.c:35:
/home/just/study/u-boot-2011.09/include/environment.h:152: error: 'CONFIG_ENV_SIZE' undeclared here (not in a function)
In file included from cmd_bootm.c:80:
/home/just/study/u-boot-2011.09/include/mtd/cfi_flash.h:174: error: expected ')' before '*' token
cmd_bootm.c:81: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'flash_info'
cmd_bootm.c: In function 'do_imls':
cmd_bootm.c:1164: error: 'flash_info_t' undeclared (first use in this function)
cmd_bootm.c:1164: error: (Each undeclared identifier is reported only once
cmd_bootm.c:1164: error: for each function it appears in.)
cmd_bootm.c:1164: error: 'info' undeclared (first use in this function)
cmd_bootm.c:1168: error: 'flash_info' undeclared (first use in this function)
cmd_bootm.c:1169: error: 'CONFIG_SYS_MAX_FLASH_BANKS' undeclared (first use in this function)
cmd_bootm.c:1171: error: 'FLASH_UNKNOWN' undeclared (first use in this function)
make[1]: *** [cmd_bootm.o]
错误 1
make[1]: Leaving directory `/home/just/study/u-boot-2011.09/common'
make: *** [common/libcommon.o]
错误 2

取消宏定义后就不会出现了

修改后如下: 

183 /*#define CONFIG_SYS_FLASH_CFI
184 #define CONFIG_FLASH_CFI_DRIVER
185 #define CONFIG_FLASH_CFI_LEGACY
186 #define CONFIG_SYS_FLASH_LEGACY_512Kx16
187 #define CONFIG_FLASH_SHOW_PROGRESS      45
188
189 #define CONFIG_SYS_MAX_FLASH_BANKS      1
190 #define CONFIG_SYS_FLASH_BANKS_LIST     { CONFIG_SYS_FLASH_BASE }
191 #define CONFIG_SYS_MAX_FLASH_SECT       (19)
192
193 #define CONFIG_ENV_ADDR                 (CONFIG_SYS_FLASH_BASE + 0x070000)
194 #define CONFIG_ENV_IS_IN_FLASH*/
195
196 #define CONFIG_SYS_NO_FLASH
197 #undef CONFIG_CMD_IMLS
198 #define CONFIG_ENV_ADDR                 (PHYS_SDRAM_1)
199 #define CONFIG_ENV_IS_IN_NVRAM
200 #define CONFIG_ENV_SIZE                 0x10000
201 /* allow to overwrite serial and ethaddr */
202 #define CONFIG_ENV_OVERWRITE

因为在RAM中运行,环境参数也要做相应修改,如198,199行。默认环境参数是在flash中的。

修改后编译出错如下:

mutes2410.c:149: error: expected declaration specifiers or '...' before 'flash_info_t'
mutes2410.c: In function 'board_flash_get_legacy':
mutes2410.c:151: error: 'info' undeclared (first use in this function)
mutes2410.c:151: error: (Each undeclared identifier is reported only once
mutes2410.c:151: error: for each function it appears in.)
mutes2410.c:151: error: 'FLASH_CFI_16BIT' undeclared (first use in this function)
mutes2410.c:152: error: 'FLASH_CFI_BY16' undeclared (first use in this function)
mutes2410.c:153: error: 'FLASH_CFI_X16' undeclared (first use in this function)

mutes2410.h中我已经添加了CONFIG_SYS_NO_FLASH并取消了CONFIG_SYS_FLASH_CFI的宏定义不知道为什么新版u-bootboard/samsung/mutes2410/mutes2410.c文件中对board_flash_get_legacy函数没加宏开关,在这里我们在对'board_flash_get_legacy'函数添加一个宏开关如下:(添加第149157行)

149 #ifdef CONFIG_SYS_FLASH_CFI
150 ulong board_flash_get_legacy(ulong base, int banknum, flash_info_t *info)
151 {
152         info->portwidth = FLASH_CFI_16BIT;
153         info->chipwidth = FLASH_CFI_BY16;
154         info->interface = FLASH_CFI_X16;
155         return 1;
156 }
157 #endif

 

编译下载运行如下:

ST2410 # tftp 0x32000000 u-boot.bin
TFTP from server 192.168.1.91; our IP address is 192.168.1.200
Filename 'u-boot.bin'.
Load address: 0x32000000
Loading: #################################################################
         ########################
done
Bytes transferred = 451816 (6e4e8 hex)
ST2410 # go 0x32000000
## Starting application at 0x32000000 ...
??

U-Boot 2011.09 (Oct 28 2011 - 06:51:39)

DRAM:  64 MiB
WARNING: Caches not enabled

到这里然后自动重启了。

4)、开启u-boot打印调试信息的功能

为了查找原因,在这里我又开启了u-boot打印调试信息的功能

mutes2410.h文件最后#endif前一行再添加“#define DEBUG  1
”添加后的结果如下:

244 #define CONFIG_SKIP_LOWLEVEL_INIT
245 #define DEBUG  1
246 #endif /* __CONFIG_H */

 

为什么添加这个宏定义,我们在include/common.h文件中可以看到以下代码

119 #ifdef  DEBUG
120 #define debug(fmt,args...)      printf (fmt ,##args)
121 #define debugX(level,fmt,args...) if (DEBUG>=level) printf(fmt,##args);
122 #else
123 #define debug(fmt,args...)
124 #define debugX(level,fmt,args...)
125 #endif  /* DEBUG */
126
127 #ifdef DEBUG
128 # define _DEBUG 1
129 #else
130 # define _DEBUG 0
131 #endif

显然需要我们开启DEBUG宏定义,源码中的debug函数才生效,而要debugX函数生效,这里我定义了DEBUG1
保存编译下载运行如下:

ST2410 # tftp 0x32000000 u-boot.bin
TFTP from server 192.168.1.91; our IP address is 192.168.1.200
Filename 'u-boot.bin'.
Load address: 0x32000000
Loading: #################################################################
         ############################
done
Bytes transferred = 474184 (73c48 hex)
ST2410 # go 0x32000000
## Starting application at 0x32000000 ...
??

U-Boot 2011.09 (Oct 28 2011 - 06:54:53)

U-Boot code: 32000000 -> 3206B4E0  BSS: -> 320AEBE4
monitor len: 000AEBE4
ramsize: 04000000
TLB table at: 33ff0000
Top of RAM usable for U-Boot at: 33ff0000
Reserving 698k for U-Boot at: 33f41000
Reserving 4160k for malloc() at: 33b31000
Reserving 24 Bytes for Board Info at: 33b30fe8
Reserving 120 Bytes for Global Data at: 33b30f70
New Stack Pointer is: 33b30f60
RAM Configuration:
Bank #0: 30000000 64 MiB
relocation Offset is: 01f41000
WARNING: Caches not enabled
monitor flash len: 00073C48
dram_bank_mmu_setup: bank: 0
Now running in RAM - U-Boot at: 33f41000
NAND:  board_nand_init()
end of nand_init
hwcontrol(): 0xff 0x83
hwcontrol(): 0xffffffff 0x81
raise: Signal # 8 caught
raise: Signal # 8 caught
dev_ready
hwcontrol(): 0x90 0x83
hwcontrol(): 0x00 0x85
hwcontrol(): 0xffffffff 0x81
raise: Signal # 8 caught
raise: Signal # 8 caught
dev_ready
hwcontrol(): 0x90 0x83
hwcontrol(): 0x00 0x85
hwcontrol(): 0xffffffff 0x81
raise: Signal # 8 caught
raise: Signal # 8 caught
dev_ready
hwcontrol(): 0xffffffff 0x80
64 MiB
*** Warning - bad CRC, using default environment

Destroy Hash Table: 33fae068 table = (null)
Create Hash Table: N=75
INSERT: table 33fae068, filled 1/79 rv 33b32418 ==> name="bootdelay" value="5"
INSERT: table 33fae068, filled 2/79 rv 33b32358 ==> name="baudrate" value="115200"
INSERT: table 33fae068, filled 3/79 rv 33b32328 ==> name="ipaddr" value="10.0.0.110"
INSERT: table 33fae068, filled 4/79 rv 33b32430 ==> name="serverip" value="10.0.0.1"
INSERT: table 33fae068, filled 5/79 rv 33b325bc ==> name="netmask" value="255.255.255.0"
INSERT: free(data = 33b322a0)
INSERT: done
In:    serial
Out:   serial
Err:   serial
Net:   raise: Signal # 8 caught
CS8900-0Warning: failed to set MAC address
原来在启动网卡时出现了问题,这个问题我们留到实现CS8900网卡时再来解决,在这里我们先去掉对CS8900网卡的支持,在include/configs/mutes2410.h 文件中去掉第58CONFIG_CS8900宏定义
58 //#define CONFIG_CS8900
编译运行OK

ST2410 # tftp 0x32000000 u-boot.bin
TFTP from server 192.168.1.91; our IP address is 192.168.1.200
Filename 'u-boot.bin'.
Load address: 0x32000000
Loading: #################################################################
         ############################
done
Bytes transferred = 474176 (73c40 hex)
ST2410 # go 0x32000000
## Starting application at 0x32000000 ...
??

U-Boot 2011.09 (Oct 28 2011 - 06:59:50)

U-Boot code: 32000000 -> 3206B4D8  BSS: -> 320AEBE4
monitor len: 000AEBE4
ramsize: 04000000
TLB table at: 33ff0000
Top of RAM usable for U-Boot at: 33ff0000
Reserving 698k for U-Boot at: 33f41000
Reserving 4160k for malloc() at: 33b31000
Reserving 24 Bytes for Board Info at: 33b30fe8
Reserving 120 Bytes for Global Data at: 33b30f70
New Stack Pointer is: 33b30f60
RAM Configuration:
Bank #0: 30000000 64 MiB
relocation Offset is: 01f41000
WARNING: Caches not enabled
monitor flash len: 00073C40
dram_bank_mmu_setup: bank: 0
Now running in RAM - U-Boot at: 33f41000
NAND:  board_nand_init()
end of nand_init
hwcontrol(): 0xff 0x83
hwcontrol(): 0xffffffff 0x81
raise: Signal # 8 caught
raise: Signal # 8 caught
dev_ready
hwcontrol(): 0x90 0x83
hwcontrol(): 0x00 0x85
hwcontrol(): 0xffffffff 0x81
raise: Signal # 8 caught
raise: Signal # 8 caught
dev_ready
hwcontrol(): 0x90 0x83
hwcontrol(): 0x00 0x85
hwcontrol(): 0xffffffff 0x81
raise: Signal # 8 caught
raise: Signal # 8 caught
dev_ready
hwcontrol(): 0xffffffff 0x80
64 MiB
*** Warning - bad CRC, using default environment

Destroy Hash Table: 33fae068 table = (null)
Create Hash Table: N=75
INSERT: table 33fae068, filled 1/79 rv 33b32418 ==> name="bootdelay" value="5"
INSERT: table 33fae068, filled 2/79 rv 33b32358 ==> name="baudrate" value="115200"
INSERT: table 33fae068, filled 3/79 rv 33b32328 ==> name="ipaddr" value="10.0.0.110"
INSERT: table 33fae068, filled 4/79 rv 33b32430 ==> name="serverip" value="10.0.0.1"
INSERT: table 33fae068, filled 5/79 rv 33b325bc ==> name="netmask" value="255.255.255.0"
INSERT: free(data = 33b322a0)
INSERT: done
In:    serial
Out:   serial
Err:   serial
Net:   No ethernet found.
### main_loop entered: bootdelay=5

### main_loop: bootcmd=""
MUTES2410 #

 

 

 

 

阅读(3197) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~