关闭

u-boot在华恒S3C2410EDU板子上的移植(转载出处--华恒论坛; 作者:合工大超女)

标签: clinuxflashapplicationcmdparameters
2152人阅读 评论(0) 收藏 举报
呵呵。今天终于把这个uboot搞定啦。居然拖拖拉拉做了好久:(。感觉做底层的东西不懂那些硬件的东西真困难,还有那些汇编,看的头都大。幸好有光盘里有现成的ppcboot2.0的源码可以参考,哈哈。当然啦,还要多亏hn和winter的耐心帮助啦。3q。现就将我的移植步骤详细说一遍喽!(说明:我是在hharm-edu上移植的哦)

1.到sourceforge.net中下载uboot源码,我用的版本是1.1.4.(和1.1.3没太多区别,修改的地方基本一样)。
2.解压后,修改Makefile中的交叉编译路径。
ifeq ($(ARCH),arm)
CROSS_COMPILE = /opt/host/armv4l/bin/armv4l-unknown-linux-
endif
3.make smdk2410_config ;make 后出现错误,根据提示修改:
(1)将cpu/arm920t/config.mk中的PLATform_CPPFLAGS +=$( -mapcs-32,$(call cc-option,-mabi=apcs-gnu)改为PLATform_CPPFLAGS +=$(call cc-option,-mapcs-32,$(call cc-option,-mabi=apcs-gnu),)
(2)将/include/asm-arm/processor.h中的
union debug_insn {
u32arm;
u16thumb;
};改为
union debug_insn {
u32arm_mode;
u16thumb_mode;
};
4.再make后即可编译通过啦。因为uboot中的2410板子里没有edu上用的那种flash,所以就把ppcboot中的flash文件直接拷过来啦。哈哈。方便。将/ppcboot-2.0.0/board/smdk2410/flash.c和flash-define.h拷到u-boot-1.1.4/board/smdk2410下,再将/ppcboot-2.0.0/include/flash.h拷到u-boot-1.1.4/nclude/下。hoho。flash驱动算是搞定。
5.修改include/configs/smdk2410.h,
去掉#define CONFIG_DRIVER_CS8900 1
#define CS8900_BASE 0x8000300
#define CS8900_BUS16 1

加上#define CONFIG_DRIVER_DM9000 1
#define CONFIG_DM9000_BASE 0x8000300
#define DM9000_IO CONFIG_DM9000_BASE
#define DM9000_DATA (CONFIG_DM9000_BASE+4)
#define CONFIG_DM9000_USE_16BIT
#define COMMAND_LINE "initrd=0x30800000,0x440000 mem=64M root=/dev/ram init=/linuxrc console=ttyS0"
 再修改其它一些配置,不具体写了,修改后如下:
#define CONFIG_COMMANDS /
(CONFIG_CMD_DFL | /
CFG_CMD_CACHE | /
CFG_CMD_PING | /     //加上PING哦,否则不能下载
CFG_CMD_REGINFO  | /
CFG_CMD_DATE | /
CFG_CMD_ELF)

#define CONFIG_ETHADDR08:00:3e:26:0a:5b
#define CONFIG_NETMASK          255.255.255.0
#define CONFIG_IPADDR192.168.2.110
#define CONFIG_SERVERIP192.168.2.111

#define CFG_MAX_FLASH_BANKS1/* max number of memory banks */
#define CONFIG_INTEL_E28F128 1
#ifdef CONFIG_INTEL_E28F128
#define PHYS_FLASH_SIZE0x01000000 /* 16MB */
#define CFG_FLASH_SIZEPHYS_FLASH_SIZE /* 16MB */
#define CFG_MAX_FLASH_SECT(128)/* max number of sectors on one chip */
#define CFG_ENV_ADDR(CFG_FLASH_BASE + 0x020000) /* addr of environment */
#endif

6.Ok。make编译后,生成uboot.bin文件,下载到ram中,go 30008000,出现
#Starting application at 0x30008000…
Start linux..
Setup linux parameters at 0x3000100 然后就不动了:(
我的解决方法是到cpu/arm920t/start.S中
#ifndef CONFIG_SKIP_LOWLEVEL_INIT
//blcpu_init_crit
#endif
注释掉blcpu_init_crit。哈哈,重新编译后就可以在ram中调试啦。看了这段子程序,是调用board/smdk2410/lowlevel_init.S文件,这个文件是用来初始化ram的,估计是在ram中运行,就不能初始化了吧?(恳请大虾解惑)。
一切调试成功后,就可以烧进去了。注意现在就要把blcpu_init_crit前的注释去掉喽。烧到flash中就必须初始化ram,否则烧写后什么显示都没。

下面是我uboot工作状态:
PPCBoot 2.0.0 (Dec 15 2005 - 20:00:18)
                                                                               
PPCBoot code: 33F00000 -> 33F15D5C  BSS: -> 33F191F0
DRAM Configuration:
Bank #0: 30000000 64 MB
Flash Memory Start 0x0
Device ID of the Flash is 18
intel E28F128J3A150 init finished!!!
Flash: 16 MB
Write 18 to Watchdog and it is 18 now
start linux now(y/n):
                                                                               
SMDK2410 # tftp 30008000 u-boot.bin
<DM9000> I/O: 8000300, VID: 90000a46
NetOurIP =c0a802de
NetServerIP = c0a8026f
NetOurGatewayIP = c0a80201
NetOurSubnetMask = ffffff00
ARP broadcast 1
ARP broadcast 2
TFTP from server 192.168.2.111; our IP address is 192.168.2.222
Filename 'u-boot.bin'.
Load address: 0x0
Loading: #####################
done
Bytes transferred = 103676 (194fc hex)
SMDK2410 # go 30008000
## Starting application at 0x30008000 ...
Start linux ..
Setup linux parameters at 0x30000100
                                                                               
                                                                               
U-Boot 1.1.4 (Dec 27 2006 - 13:56:04)
                                                                               
U-Boot code: 33F80000 -> 33F994FC  BSS: -> 33F9D8DC
RAM Configuration:
Bank #0: 30000000 64 MB
Flash Memory Start 0x0
Device ID of the Flash is 18
intel E28F128J3A150 init finished!!!
Flash: 16 MB
*** Warning - bad CRC, using default environment
                                                                               
In:    serial
Out:   serial
Err:   serial
DAILY2410 #
DAILY2410 #
DAILY2410 # printenv
bootdelay=3
baudrate=115200
ethaddr=08:00:3e:26:0a:5b
ipaddr=192.168.2.110
serverip=192.168.2.111
netmask=255.255.255.0
stdin=serial
stdout=serial
stderr=serial
                                                                               
Environment size: 161/65532 bytes
DAILY2410 #

Environment size: 161/65532 bytes
DAILY2410 # bdinfo
arch_number = 0x000000C1
env_t       = 0x00000000
boot_params = 0x30000100
DRAM bank   = 0x00000000
-> start    = 0x30000000
-> size     = 0x04000000
ethaddr     = 08:00:3E:26:0A:5B
ip_addr     = 192.168.2.110
baudrate    = 115200 bps
DAILY2410 #


DAILY2410 # flinfo
                                                                               
Bank # 1: intel E28F128J3A150
   00000000 (RO)  00020000       00040000       00060000       00080000
   000A0000       000C0000       000E0000       00100000       00120000
   00140000       00160000       00180000       001A0000       001C0000
   001E0000       00200000       00220000       00240000       00260000
   00280000       002A0000       002C0000       002E0000       00300000
   00320000       00340000       00360000       00380000       003A0000
   003C0000       003E0000       00400000       00420000       00440000
   00460000       00480000       004A0000       004C0000       004E0000
   00500000       00520000       00540000       00560000       00580000
   005A0000       005C0000       005E0000       00600000       00620000
   00640000       00660000       00680000       006A0000       006C0000
   006E0000       00700000       00720000       00740000       00760000
   00780000       007A0000       007C0000       007E0000       00800000
   00820000       00840000       00860000       00880000       008A0000
   008C0000       008E0000       00900000       00920000       00940000
   00960000       00980000       009A0000       009C0000       009E0000
   00A00000       00A20000       00A40000       00A60000       00A80000
   00AA0000       00AC0000       00AE0000       00B00000       00B20000
   00B40000       00B60000       00B80000       00BA0000       00BC0000
   00BE0000       00C00000       00C20000       00C40000       00C60000
   00C80000       00CA0000       00CC0000       00CE0000       00D00000
   00D20000       00D40000       00D60000       00D80000       00DA0000
   00DC0000       00DE0000       00E00000       00E20000       00E40000
   00E60000       00E80000       00EA0000       00EC0000       00EE0000
   00F00000       00F20000       00F40000       00F60000       00F80000
   00FA0000       00FC0000       00FE0000
DAILY2410 #


DAILY2410 # protect off 1:0
Un-Protect Flash Sectors 0-0 in Bank # 1
. done
DAILY2410 #

DAILY2410 # erase 1:0
Erase Flash Sectors 0-0 in Bank # 1     [XXXXX]
DAILY2410 #


DAILY2410 # tftp 30008000 u-boot.bin
dm9000 i/o: 0x8000300, id: 0x90000a46
MAC: 00:80:00:80:00:80
operating at unknown: 15 mode
TFTP from server 192.168.2.111; our IP address is 192.168.2.110
Filename 'u-boot.bin'.
Load address: 0x30008000
Loading: T #####################
done
Bytes transferred = 103704 (19518 hex)


DAILY2410 # cp.b 30008000 0 20000
Copy to Flash...        *******************************************************
       #
done


7.出现新的问题,用这个uboot虽然能下载内核,说明网卡驱动正常,但是无法go,也不能正常bootm。
如果用go命令出现:
## Starting application at 0x30008000 ...
Uncompressing Linux.............................................................                                                                                
Error: unrecognized/unsupported machine ID (r1 = 0x33f4fc88).
                                                                               
Available machine support:
                                                                               
ID (hex)        NAME
000000c1        SMDK2410
                                                                               
Please check your kernel config and/or bootloader.
或者大多数时候就停在
## Starting application at 0x30008000 ...
Uncompressing Linux.............................................................     不动了。。
这是uboot传递给内核的参数发生错误。
解决方法是参照ppcboot源码中的go指令的运行方式修改。
只要修改两个文件即可:lib_arm/armlinux.c和common/cmd_boot.c。                                                                           在armlinux.c中加入
static inline void cpu_arm920_cache_clean_invalidate_all(void)

{
__asm__(
"movr1, #0/n"
"movr1, #7 << 5/n"  /* 8 segments */
"1:orrr3, r1, #63 << 26/n"  /* 64 entries */
"2:mcrp15, 0, r3, c7, c14, 2/n" /* clean & invalidate D index */
"subsr3, r3, #1 << 26/n"
"bcs2b/n"  /* entries 64 to 0 */
"subsr1, r1, #1 << 5/n"
"bcs1b/n"  /* segments 7 to 0 */
"mcrp15, 0, r1, c7, c5, 0/n"  /* invalidate I cache */
"mcrp15, 0, r1, c7, c10, 4/n" /* drain WB */
);
}

static inline void cpu_arm920_tlb_invalidate_all(void)
{
__asm__(
"movr0, #0/n"
"mcrp15, 0, r0, c7, c10, 4/n"/* drain WB */
"mcrp15, 0, r0, c8, c7, 0/n"/* invalidate I & D TLBs */
);
}

 

void  call_linux(long a0, long a1, long a2)
{
__asm__(
"movr0, %0/n"
"movr1, %1/n"
"movr2, %2/n"
"movip, #0/n"
"mcrp15, 0, ip, c13, c0, 0/n"/* zero PID */
"mcrp15, 0, ip, c7, c7, 0/n"/* invalidate I,D caches */
"mcrp15, 0, ip, c7, c10, 4/n"/* drain write buffer */
"mcrp15, 0, ip, c8, c7, 0/n"/* invalidate I,D TLBs */
"mrcp15, 0, ip, c1, c0, 0/n"/* get control register */
"bicip, ip, #0x0001/n"/* disable MMU */
"mcrp15, 0, ip, c1, c0, 0/n"/* write control register */
"movpc, r2/n"
"nop/n"
"nop/n"
: /* no outpus */
: "r" (a0), "r" (a1), "r" (a2)
);
#define RAMDISK 1
/*static*/ void setup_linux_param(ulong param_base)
{
struct param_struct *params = (struct param_struct *)param_base;
#ifdef RAMDISK
char linux_cmd[] = "initrd=0x30800000,0x440000 mem=64M  root=/dev/ram init=/linuxrc console=ttyS0";
#endif
#ifdef CRAMFS
char linux_cmd[] = "root=/dev/mtdblock/2 rw mem=32M";
#endif
printf("Setup linux parameters at 0x%08lx/n", param_base);
memset(params, 0, sizeof(struct param_struct));

params->u1.s.page_size = LINUX_PAGE_SIZE;
params->u1.s.nr_pages = (DRAM_SIZE >> LINUX_PAGE_SHIFT);
#if 0
params->u1.s.page_size = LINUX_PAGE_SIZE;
params->u1.s.nr_pages = (dram_size >> LINUX_PAGE_SHIFT);
params->u1.s.ramdisk_size = 0;
params->u1.s.rootdev = rootdev;
params->u1.s.flags = 0;

#endif
/* If use ramdisk */
params->u1.s.initrd_start = 0xC0800000 ;
params->u1.s.initrd_size = 0x440000;
params->u1.s.rd_start = 0;

/* set linux command line */
if (linux_cmd == NULL) {
printf("Wrong magic: could not found linux command line/n");
} else {
memcpy(params->commandline, linux_cmd, strlen(linux_cmd) + 1);
}
}
以及几个宏变量的定义。
在cmd_boot.c中将do_go函数改为
int do_go (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
ulongaddr, rc;
int     rcode = 0;

if (argc < 2) {
printf ("Usage:/n%s/n", cmdtp->usage);
return 1;
}

addr = simple_strtoul(argv[1], NULL, 16);

printf ("## Starting application at 0x%08lx .../n", addr);

printf("Start linux ../n");
setup_linux_param(/*boot_mem_base*/0x30000000 + 0x100);
call_linux(0, 0xc1, addr);
printf("End/n");
rc = ((ulong (*)(int, char *[]))addr) (--argc, &argv[1]);
if (rc != 0) rcode = 1;

printf ("## Application terminated, rc = 0x%lx/n", rc);
return rcode;
}
就ok啦。
重新编译后,我的linux和ramdisk.image.gz就可以欢快的跑起来啦。
哈,不过这是2.4的内核,把armlinux.c中的ttyS0改为ttySAC0,在用论坛上下的zImage.2410.2.6测试一下,哈,2.6也能跑啦。
不过bootm的问题我无法解决。
做了一个uImage。Tftp 30008000后,出现:
## Booting image at 30008000 ...
  Image Name:
  Created:      2007-01-01  12:18:08 UTC
  Image Type:   ARM Linux Kernel Image (gzip compressed)
  Data Size:    893780 Bytes = 872.8 kB
  Load Address: 30008000
  Entry Point:  30008000
  Verifying Checksum ... OK
  Uncompressing Kernel Image ... Error: inflate() returned -3
GUNZIP ERROR - must RESET board to recover

看了论坛上的旧帖,说是地址覆盖了。故改为31000000 .tftp后,bootm 31000000,呵,内核也能跑以来,可是莫名奇妙的是那些打印信息不在console上显示,怎么全都跑到lcd上显示去了。。。我晕。。就是把原来的zImage做成的uImage,解压后两个应该是一样的啊。
晕。。。不搞了。。还是先用go继续做吧。


 
0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:31532次
    • 积分:283
    • 等级:
    • 排名:千里之外
    • 原创:1篇
    • 转载:4篇
    • 译文:0篇
    • 评论:3条
    文章分类
    文章存档
    最新评论