redboot on QEMU for mini2440

(原创文章,欢迎转载,请注明出处,谢谢。)

最近有空呼吸新鲜空气,重新拿起来了eCos,做点东西共享给大家。

 

rt-thread最近很火,在mini2440的qemu平台上发表了测试和代码,这无疑给更多的爱好者以新的学习机会。

 

这段时间一直在研究ecos,所以有了把ecos移植到mini2440的qemu平台的想法。经过几天的折腾,终于可以在qemu的上面看到redboot的命令了。

 

先看看成果,然后进入枯燥的coding历程

 

redboot on QEMU for mini2440_第1张图片
现在开始看代码,:-)

 

 

1. 获得代码

 

git clone git://repo.or.cz/qemu/mini2440.git  qemu

 

修改启动部分为ram的最小地址直接启动

 

ricky@ricky-laptop:~/ecos/projects/mini2440-qemu/mini2440$ git diff diff --git a/hw/mini2440.c b/hw/mini2440.c index 5decf4b..7a70aae 100644 --- a/hw/mini2440.c +++ b/hw/mini2440.c @@ -258,46 +258,15 @@ static void mini2440_reset(void *opaque) struct mini2440_board_s *s = (struct mini2440_board_s *) opaque; uint32_t image_size; - /* - * Normally we would load 4 KB of nand to SRAM and jump there, but - * it is not working perfectly as expected, so we cheat and load - * it from nand directly relocated to 0x33f80000 and jump there - */ - if (mini2440_load_from_nand(s->nand, 0, S3C_RAM_BASE | 0x03f80000, 256*1 - mini2440_printf("loaded default u-boot from NAND/n"); - s->cpu->env->regs[15] = S3C_RAM_BASE | 0x03f80000; /* start addr - } -#if 0 && defined(LATER) - if (mini2440_load_from_nand(s->nand, 0, S3C_SRAM_BASE_NANDBOOT, S3C_SRAM - s->cpu->env->regs[15] = S3C_SRAM_BASE_NANDBOOT; /* start address - mini2440_printf("4KB SteppingStone loaded from NAND/n"); - } -#endif : diff --git a/hw/mini2440.c b/hw/mini2440.c index 5decf4b..7a70aae 100644 --- a/hw/mini2440.c +++ b/hw/mini2440.c @@ -258,46 +258,15 @@ static void mini2440_reset(void *opaque) struct mini2440_board_s *s = (struct mini2440_board_s *) opaque; uint32_t image_size; - /* - * Normally we would load 4 KB of nand to SRAM and jump there, but - * it is not working perfectly as expected, so we cheat and load - * it from nand directly relocated to 0x33f80000 and jump there - */ - if (mini2440_load_from_nand(s->nand, 0, S3C_RAM_BASE | 0x03f80000, 256*10 - mini2440_printf("loaded default u-boot from NAND/n"); - s->cpu->env->regs[15] = S3C_RAM_BASE | 0x03f80000; /* start addre - } -#if 0 && defined(LATER) - if (mini2440_load_from_nand(s->nand, 0, S3C_SRAM_BASE_NANDBOOT, S3C_SRAM_ - s->cpu->env->regs[15] = S3C_SRAM_BASE_NANDBOOT; /* start address, - mini2440_printf("4KB SteppingStone loaded from NAND/n"); - } -#endif - /* : diff --git a/hw/mini2440.c b/hw/mini2440.c index 5decf4b..7a70aae 100644 --- a/hw/mini2440.c +++ b/hw/mini2440.c @@ -258,46 +258,15 @@ static void mini2440_reset(void *opaque) struct mini2440_board_s *s = (struct mini2440_board_s *) opaque; uint32_t image_size; - /* - * Normally we would load 4 KB of nand to SRAM and jump there, but - * it is not working perfectly as expected, so we cheat and load - * it from nand directly relocated to 0x33f80000 and jump there - */ - if (mini2440_load_from_nand(s->nand, 0, S3C_RAM_BASE | 0x03f80000, 256*102 - mini2440_printf("loaded default u-boot from NAND/n"); - s->cpu->env->regs[15] = S3C_RAM_BASE | 0x03f80000; /* start addres - } -#if 0 && defined(LATER) - if (mini2440_load_from_nand(s->nand, 0, S3C_SRAM_BASE_NANDBOOT, S3C_SRAM_S - s->cpu->env->regs[15] = S3C_SRAM_BASE_NANDBOOT; /* start address, - mini2440_printf("4KB SteppingStone loaded from NAND/n"); - } -#endif - /* - * if a u--boot is available as a file, we always use it : diff --git a/hw/mini2440.c b/hw/mini2440.c index 5decf4b..7a70aae 100644 --- a/hw/mini2440.c +++ b/hw/mini2440.c @@ -258,46 +258,15 @@ static void mini2440_reset(void *opaque) struct mini2440_board_s *s = (struct mini2440_board_s *) opaque; uint32_t image_size; - /* - * Normally we would load 4 KB of nand to SRAM and jump there, but - * it is not working perfectly as expected, so we cheat and load - * it from nand directly relocated to 0x33f80000 and jump there - */ - if (mini2440_load_from_nand(s->nand, 0, S3C_RAM_BASE | 0x03f80000, 256*1024)> - mini2440_printf("loaded default u-boot from NAND/n"); - s->cpu->env->regs[15] = S3C_RAM_BASE | 0x03f80000; /* start address, - } -#if 0 && defined(LATER) - if (mini2440_load_from_nand(s->nand, 0, S3C_SRAM_BASE_NANDBOOT, S3C_SRAM_SIZE - s->cpu->env->regs[15] = S3C_SRAM_BASE_NANDBOOT; /* start address, u-b - mini2440_printf("4KB SteppingStone loaded from NAND/n"); - } -#endif - /* - * if a u--boot is available as a file, we always use it - */ - { - image_size = load_image("mini2440/u-boot.bin", qemu_get_ram_ptr(0x03f8000 : diff --git a/hw/mini2440.c b/hw/mini2440.c index 5decf4b..7a70aae 100644 --- a/hw/mini2440.c +++ b/hw/mini2440.c @@ -258,46 +258,15 @@ static void mini2440_reset(void *opaque) struct mini2440_board_s *s = (struct mini2440_board_s *) opaque; uint32_t image_size; - /* - * Normally we would load 4 KB of nand to SRAM and jump there, but - * it is not working perfectly as expected, so we cheat and load - * it from nand directly relocated to 0x33f80000 and jump there - */ - if (mini2440_load_from_nand(s->nand, 0, S3C_RAM_BASE | 0x03f80000, 256*1024)> 0) - mini2440_printf("loaded default u-boot from NAND/n"); - s->cpu->env->regs[15] = S3C_RAM_BASE | 0x03f80000; /* start address, u-b - } -#if 0 && defined(LATER) - if (mini2440_load_from_nand(s->nand, 0, S3C_SRAM_BASE_NANDBOOT, S3C_SRAM_SIZE) > - s->cpu->env->regs[15] = S3C_SRAM_BASE_NANDBOOT; /* start address, u-boot - mini2440_printf("4KB SteppingStone loaded from NAND/n"); - } -#endif - /* - * if a u--boot is available as a file, we always use it - */ - { - image_size = load_image("mini2440/u-boot.bin", qemu_get_ram_ptr(0x03f80000)) - if (image_size < 0) - image_size = load_image("u-boot.bin", qemu_get_ram_ptr(0x03f80000)); - if (image_size > 0) { : diff --git a/hw/mini2440.c b/hw/mini2440.c index 5decf4b..7a70aae 100644 --- a/hw/mini2440.c +++ b/hw/mini2440.c @@ -258,46 +258,15 @@ static void mini2440_reset(void *opaque) struct mini2440_board_s *s = (struct mini2440_board_s *) opaque; uint32_t image_size; - /* - * Normally we would load 4 KB of nand to SRAM and jump there, but - * it is not working perfectly as expected, so we cheat and load - * it from nand directly relocated to 0x33f80000 and jump there - */ - if (mini2440_load_from_nand(s->nand, 0, S3C_RAM_BASE | 0x03f80000, 256*1024)> 0) { - mini2440_printf("loaded default u-boot from NAND/n"); - s->cpu->env->regs[15] = S3C_RAM_BASE | 0x03f80000; /* start address, u-boot - } -#if 0 && defined(LATER) - if (mini2440_load_from_nand(s->nand, 0, S3C_SRAM_BASE_NANDBOOT, S3C_SRAM_SIZE) > 0) - s->cpu->env->regs[15] = S3C_SRAM_BASE_NANDBOOT; /* start address, u-boot rel - mini2440_printf("4KB SteppingStone loaded from NAND/n"); - } -#endif - /* - * if a u--boot is available as a file, we always use it - */ - { - image_size = load_image("mini2440/u-boot.bin", qemu_get_ram_ptr(0x03f80000)); - if (image_size < 0) - image_size = load_image("u-boot.bin", qemu_get_ram_ptr(0x03f80000)); - if (image_size > 0) { - if (image_size & (512 -1)) /* round size to a NAND block size * - image_size = (image_size + 512) & ~(512-1); - mini2440_printf("loaded override u-boot (size %x)/n", image_size); : diff --git a/hw/mini2440.c b/hw/mini2440.c index 5decf4b..7a70aae 100644 --- a/hw/mini2440.c +++ b/hw/mini2440.c @@ -258,46 +258,15 @@ static void mini2440_reset(void *opaque) struct mini2440_board_s *s = (struct mini2440_board_s *) opaque; uint32_t image_size; - /* - * Normally we would load 4 KB of nand to SRAM and jump there, but - * it is not working perfectly as expected, so we cheat and load - * it from nand directly relocated to 0x33f80000 and jump there - */ - if (mini2440_load_from_nand(s->nand, 0, S3C_RAM_BASE | 0x03f80000, 256*1024)> 0) { - mini2440_printf("loaded default u-boot from NAND/n"); - s->cpu->env->regs[15] = S3C_RAM_BASE | 0x03f80000; /* start address, u-boot alrea - } -#if 0 && defined(LATER) - if (mini2440_load_from_nand(s->nand, 0, S3C_SRAM_BASE_NANDBOOT, S3C_SRAM_SIZE) > 0) { - s->cpu->env->regs[15] = S3C_SRAM_BASE_NANDBOOT; /* start address, u-boot relocati - mini2440_printf("4KB SteppingStone loaded from NAND/n"); - } -#endif - /* - * if a u--boot is available as a file, we always use it - */ - { - image_size = load_image("mini2440/u-boot.bin", qemu_get_ram_ptr(0x03f80000)); - if (image_size < 0) - image_size = load_image("u-boot.bin", qemu_get_ram_ptr(0x03f80000)); - if (image_size > 0) { - if (image_size & (512 -1)) /* round size to a NAND block size */ - image_size = (image_size + 512) & ~(512-1); - mini2440_printf("loaded override u-boot (size %x)/n", image_size); - s->cpu->env->regs[15] = S3C_RAM_BASE | 0x03f80000; /* start address, u-boot - } - } : diff --git a/hw/mini2440.c b/hw/mini2440.c index 5decf4b..7a70aae 100644 --- a/hw/mini2440.c +++ b/hw/mini2440.c @@ -258,46 +258,15 @@ static void mini2440_reset(void *opaque) struct mini2440_board_s *s = (struct mini2440_board_s *) opaque; uint32_t image_size; - /* - * Normally we would load 4 KB of nand to SRAM and jump there, but - * it is not working perfectly as expected, so we cheat and load - * it from nand directly relocated to 0x33f80000 and jump there - */ - if (mini2440_load_from_nand(s->nand, 0, S3C_RAM_BASE | 0x03f80000, 256*1024)> 0) { - mini2440_printf("loaded default u-boot from NAND/n"); - s->cpu->env->regs[15] = S3C_RAM_BASE | 0x03f80000; /* start address, u-boot already relo - } -#if 0 && defined(LATER) - if (mini2440_load_from_nand(s->nand, 0, S3C_SRAM_BASE_NANDBOOT, S3C_SRAM_SIZE) > 0) { - s->cpu->env->regs[15] = S3C_SRAM_BASE_NANDBOOT; /* start address, u-boot relocating code - mini2440_printf("4KB SteppingStone loaded from NAND/n"); - } -#endif - /* - * if a u--boot is available as a file, we always use it - */ - { - image_size = load_image("mini2440/u-boot.bin", qemu_get_ram_ptr(0x03f80000)); - if (image_size < 0) - image_size = load_image("u-boot.bin", qemu_get_ram_ptr(0x03f80000)); - if (image_size > 0) { - if (image_size & (512 -1)) /* round size to a NAND block size */ - image_size = (image_size + 512) & ~(512-1); - mini2440_printf("loaded override u-boot (size %x)/n", image_size); - s->cpu->env->regs[15] = S3C_RAM_BASE | 0x03f80000; /* start address, u-boot already - } - } - /* - * if a kernel was explicitly specified, we load it too - */ - if (s->kernel) { - image_size = load_image(s->kernel, qemu_get_ram_ptr(0x02000000)); : diff --git a/hw/mini2440.c b/hw/mini2440.c index 5decf4b..7a70aae 100644 --- a/hw/mini2440.c +++ b/hw/mini2440.c @@ -258,46 +258,15 @@ static void mini2440_reset(void *opaque) struct mini2440_board_s *s = (struct mini2440_board_s *) opaque; uint32_t image_size; - /* - * Normally we would load 4 KB of nand to SRAM and jump there, but - * it is not working perfectly as expected, so we cheat and load - * it from nand directly relocated to 0x33f80000 and jump there - */ - if (mini2440_load_from_nand(s->nand, 0, S3C_RAM_BASE | 0x03f80000, 256*1024)> 0) { - mini2440_printf("loaded default u-boot from NAND/n"); - s->cpu->env->regs[15] = S3C_RAM_BASE | 0x03f80000; /* start address, u-boot already relocated - } -#if 0 && defined(LATER) - if (mini2440_load_from_nand(s->nand, 0, S3C_SRAM_BASE_NANDBOOT, S3C_SRAM_SIZE) > 0) { - s->cpu->env->regs[15] = S3C_SRAM_BASE_NANDBOOT; /* start address, u-boot relocating code */ - mini2440_printf("4KB SteppingStone loaded from NAND/n"); - } -#endif - /* - * if a u--boot is available as a file, we always use it - */ - { - image_size = load_image("mini2440/u-boot.bin", qemu_get_ram_ptr(0x03f80000)); - if (image_size < 0) - image_size = load_image("u-boot.bin", qemu_get_ram_ptr(0x03f80000)); - if (image_size > 0) { - if (image_size & (512 -1)) /* round size to a NAND block size */ - image_size = (image_size + 512) & ~(512-1); - mini2440_printf("loaded override u-boot (size %x)/n", image_size); - s->cpu->env->regs[15] = S3C_RAM_BASE | 0x03f80000; /* start address, u-boot already reloc - } - } - /* - * if a kernel was explicitly specified, we load it too - */ - if (s->kernel) { - image_size = load_image(s->kernel, qemu_get_ram_ptr(0x02000000)); - if (image_size > 0) { - if (image_size & (512 -1)) /* round size to a NAND block size */ : diff --git a/hw/mini2440.c b/hw/mini2440.c index 5decf4b..7a70aae 100644 --- a/hw/mini2440.c +++ b/hw/mini2440.c @@ -258,46 +258,15 @@ static void mini2440_reset(void *opaque) struct mini2440_board_s *s = (struct mini2440_board_s *) opaque; uint32_t image_size; - /* - * Normally we would load 4 KB of nand to SRAM and jump there, but - * it is not working perfectly as expected, so we cheat and load - * it from nand directly relocated to 0x33f80000 and jump there - */ - if (mini2440_load_from_nand(s->nand, 0, S3C_RAM_BASE | 0x03f80000, 256*1024)> 0) { - mini2440_printf("loaded default u-boot from NAND/n"); - s->cpu->env->regs[15] = S3C_RAM_BASE | 0x03f80000; /* start address, u-boot already relocated * - } -#if 0 && defined(LATER) - if (mini2440_load_from_nand(s->nand, 0, S3C_SRAM_BASE_NANDBOOT, S3C_SRAM_SIZE) > 0) { - s->cpu->env->regs[15] = S3C_SRAM_BASE_NANDBOOT; /* start address, u-boot relocating code */ - mini2440_printf("4KB SteppingStone loaded from NAND/n"); - } -#endif - /* - * if a u--boot is available as a file, we always use it - */ - { - image_size = load_image("mini2440/u-boot.bin", qemu_get_ram_ptr(0x03f80000)); - if (image_size < 0) - image_size = load_image("u-boot.bin", qemu_get_ram_ptr(0x03f80000)); - if (image_size > 0) { - if (image_size & (512 -1)) /* round size to a NAND block size */ - image_size = (image_size + 512) & ~(512-1); - mini2440_printf("loaded override u-boot (size %x)/n", image_size); - s->cpu->env->regs[15] = S3C_RAM_BASE | 0x03f80000; /* start address, u-boot already reloca - } - } - /* - * if a kernel was explicitly specified, we load it too - */ - if (s->kernel) { - image_size = load_image(s->kernel, qemu_get_ram_ptr(0x02000000)); - if (image_size > 0) { - if (image_size & (512 -1)) /* round size to a NAND block size */ - image_size = (image_size + 512) & ~(512-1); : diff --git a/hw/mini2440.c b/hw/mini2440.c index 5decf4b..7a70aae 100644 --- a/hw/mini2440.c +++ b/hw/mini2440.c @@ -258,46 +258,15 @@ static void mini2440_reset(void *opaque) struct mini2440_board_s *s = (struct mini2440_board_s *) opaque; uint32_t image_size; - /* - * Normally we would load 4 KB of nand to SRAM and jump there, but - * it is not working perfectly as expected, so we cheat and load - * it from nand directly relocated to 0x33f80000 and jump there - */ - if (mini2440_load_from_nand(s->nand, 0, S3C_RAM_BASE | 0x03f80000, 256*1024)> 0) { - mini2440_printf("loaded default u-boot from NAND/n"); - s->cpu->env->regs[15] = S3C_RAM_BASE | 0x03f80000; /* start address, u-boot already relocated * - } -#if 0 && defined(LATER) - if (mini2440_load_from_nand(s->nand, 0, S3C_SRAM_BASE_NANDBOOT, S3C_SRAM_SIZE) > 0) { - s->cpu->env->regs[15] = S3C_SRAM_BASE_NANDBOOT; /* start address, u-boot relocating code */ - mini2440_printf("4KB SteppingStone loaded from NAND/n"); - } -#endif - /* - * if a u--boot is available as a file, we always use it - */ - { - image_size = load_image("mini2440/u-boot.bin", qemu_get_ram_ptr(0x03f80000)); - if (image_size < 0) - image_size = load_image("u-boot.bin", qemu_get_ram_ptr(0x03f80000)); - if (image_size > 0) { - if (image_size & (512 -1)) /* round size to a NAND block size */ - image_size = (image_size + 512) & ~(512-1); - mini2440_printf("loaded override u-boot (size %x)/n", image_size); - s->cpu->env->regs[15] = S3C_RAM_BASE | 0x03f80000; /* start address, u-boot already reloca - } - } - /* - * if a kernel was explicitly specified, we load it too - */ - if (s->kernel) { - image_size = load_image(s->kernel, qemu_get_ram_ptr(0x02000000)); - if (image_size > 0) { - if (image_size & (512 -1)) /* round size to a NAND block size */ - image_size = (image_size + 512) & ~(512-1); - mini2440_printf("loaded %s (size %x)/n", s->kernel, image_size); - } - } + if (s->kernel) { + image_size = load_image(s->kernel, qemu_get_ram_ptr(0)); + if (image_size > 0) { + if (image_size & (512 -1)) + image_size = (image_size + 512) & ~(512-1); + s->cpu->env->regs[15] = S3C_RAM_BASE ; + mini2440_printf("loaded kernel %s at %p/n", s->kernel, s->cpu->env->regs[15]); + } + } } /* Typical touchscreen calibration values */ @@ -353,6 +322,11 @@ static struct mini2440_board_s *mini2440_init_common(int ram_size, return s; } static void mini2440_init(ram_addr_t ram_size, const char *boot_device, @@ -371,9 +345,18 @@ static void mini2440_init(ram_addr_t ram_size, mini = mini2440_init_common(ram_size, kernel_filename, cpu_model, sd); mini->nand = nand_init(NAND_MFR_SAMSUNG, 0x76); mini->cpu->nand->reg(mini->cpu->nand, mini->nand); mini2440_reset(mini); }  

 

 

编译qemu for mini2440
./configure --target-list=arm-softmmu --disable-linux-user;make

 

安装,或者直接copy arm-softmmu里面的可执行文件也可以。

 

2. 让ecos增加对mini2440的支持

 

http://code.google.com/p/redboot-mini2440/ 这个project里面有全部的代码,不过可能用于各种原因并没有完善。

 

我们获得他的源代码基于ecos 3.0,然后我们根据smdk2410重新创建mini2440的hal 模块

ricky@ricky-laptop:/opt/ecos/ecos-hg/packages/hal/arm/arm9$ ls mini2440/current/ cdl ChangeLog include misc src ricky@ricky-laptop:/opt/ecos/ecos-hg/packages/hal/arm/arm9$ ls mini2440/current/src/ hal_diag.c mini2440_misc.c ricky@ricky-laptop:/opt/ecos/ecos-hg/packages/hal/arm/arm9$ ls mini2440/current/cdl/ hal_arm_arm9_mini2440.cdl ricky@ricky-laptop:/opt/ecos/ecos-hg/packages/hal/arm/arm9$ ls mini2440/current/include/ hal_diag.h hal_platform_setup.h pkgconf plf_stub.h hal_platform_ints.h memcfg.h plf_io.h s3c2440x.h ricky@ricky-laptop:/opt/ecos/ecos-hg/packages/hal/arm/arm9$ ls mini2440/current/misc/ mini2440_redboot_RAM.ecm mini2440_redboot_ROMRAM.ecm ricky@ricky-laptop:/opt/ecos/ecos-hg/packages/hal/arm/arm9$  

3. 针对QEMU的修改

 

为了能让redboot顺利的运行在qemu上面,我们需要让程序直接跑在sdram上面,但是需要对硬件做必要的初始化。

所以,目前的RAM,ROM,ROMRAM都不太合适,我们加入一个新的启动方式QEMU,相当于ROMRAM方式下面禁用mmu的跳转

 

Revision: 3047 Branch: default Author: Ricky Wu <[email protected]> 2011-03-01 15:38:16 Committer: Ricky Wu <[email protected]> 2011-03-01 15:38:16 Tags: tip Parent: 3046:e7902e8a3e20 (1. remove QEMU start method. 2. add simple nand read funtion) mini2440 redboot can be run on qemu for mini2440 ----- packages/hal/arm/arm9/mini2440/current/cdl/hal_arm_arm9_mini2440.cdl ----- @@ -78,8 +78,8 @@ cdl_component CYG_HAL_STARTUP { display "Startup type" flavor data - legal_values { "RAM" "ROM" "ROMRAM" "NAND" } - default_value { "NAND" } + legal_values { "RAM" "ROM" "ROMRAM" "NAND" "QEMU" } + default_value { "QEMU" } no_define define -file system.h CYG_HAL_STARTUP description " @@ -328,7 +328,8 @@ no_define calculated { CYG_HAL_STARTUP == "RAM" ? "arm_arm9_mini2440_ram" : / CYG_HAL_STARTUP == "ROM" ? "arm_arm9_mini2440_rom" : / - "arm_arm9_mini2440_romram" } + CYG_HAL_STARTUP == "ROMRAM" ? "arm_arm9_mini2440_romram" : / + "arm_arm9_mini2440_qemu" } cdl_option CYGHWR_MEMORY_LAYOUT_LDI { display "Memory layout linker script fragment" @@ -337,7 +338,8 @@ define -file system.h CYGHWR_MEMORY_LAYOUT_LDI calculated {CYG_HAL_STARTUP == "RAM" ? "<pkgconf/mlt_arm_arm9_mini2440_ram.ldi>" : / CYG_HAL_STARTUP == "ROM" ? "<pkgconf/mlt_arm_arm9_mini2440_rom.ldi>" : / - "<pkgconf/mlt_arm_arm9_mini2440_romram.ldi>" } + CYG_HAL_STARTUP == "ROMRAM" ? "<pkgconf/mlt_arm_arm9_mini2440_romram.ldi>" : / + "<pkgconf/mlt_arm_arm9_mini2440_qemu.ldi>" } } cdl_option CYGHWR_MEMORY_LAYOUT_H { @@ -347,7 +349,8 @@ define -file system.h CYGHWR_MEMORY_LAYOUT_H calculated { CYG_HAL_STARTUP == "RAM" ? "<pkgconf/mlt_arm_arm9_mini2440_ram.h>" : / CYG_HAL_STARTUP == "ROM" ? "<pkgconf/mlt_arm_arm9_mini2440_rom.h>" : / - "<pkgconf/mlt_arm_arm9_mini2440_romram.h>" } + CYG_HAL_STARTUP == "ROMRAM" ? "<pkgconf/mlt_arm_arm9_mini2440_romram.h>" : / + "<pkgconf/mlt_arm_arm9_mini2440_qemu.h>" } } } @@ -356,7 +359,7 @@ flavor bool default_value 0 parent CYGPKG_HAL_ROM_MONITOR - requires { (CYG_HAL_STARTUP == "ROM") || (CYG_HAL_STARTUP == "ROMRAM") } + requires { (CYG_HAL_STARTUP == "ROM") || (CYG_HAL_STARTUP == "ROMRAM") || (CYG_HAL_STARTUP == "QEMU") } description " Enable this option if this program is to be used as a ROM monitor, i.e. applications will be loaded into RAM on the board, and this ----- packages/hal/arm/arm9/mini2440/current/include/hal_platform_setup.h ----- @@ -91,7 +91,7 @@ #endif -#if defined(CYG_HAL_STARTUP_ROM) || defined(CYG_HAL_STARTUP_ROMRAM) +#if defined(CYG_HAL_STARTUP_ROM) || defined(CYG_HAL_STARTUP_ROMRAM) || defined(CYG_HAL_STARTUP_QEMU) #define PLATFORM_SETUP1 _platform_setup1 #define CYGHWR_HAL_ARM_HAS_MMU #define CYGSEM_HAL_ROM_RESET_USES_JUMP @@ -160,7 +160,7 @@ // To reduce PLL lock time, adjust the LOCKTIME register. ldr r0,=LOCKTIME - ldr r1,=0xffffff + ldr r1,=0xffffffff str r1,[r0] // We must set ratios, set memctl, then change FCLK. packages/hal/arm/arm9/mini2440/current/include/pkgconf/mlt_arm_arm9_mini2440_qemu.h new file mode 100644 @@ -0,0 +1,20 @@ +// eCos memory layout - Fri Oct 20 05:43:59 2000 + +// This is a generated file - do not edit + +#ifndef __ASSEMBLER__ +#include <cyg/infra/cyg_type.h> +#include <stddef.h> + +#endif +#define CYGMEM_REGION_ram (0) +#define CYGMEM_REGION_ram_SIZE (0x4000000) +#define CYGMEM_REGION_ram_ATTR (CYGMEM_REGION_ATTR_R | CYGMEM_REGION_ATTR_W) +#define CYGMEM_REGION_sram (0x40000000) +#define CYGMEM_REGION_sram_SIZE (0x1000) +#define CYGMEM_REGION_sram_ATTR (CYGMEM_REGION_ATTR_R | CYGMEM_REGION_ATTR_W) +#ifndef __ASSEMBLER__ +extern char CYG_LABEL_NAME (__heap1) []; +#endif +#define CYGMEM_SECTION_heap1 (CYG_LABEL_NAME (__heap1)) +#define CYGMEM_SECTION_heap1_SIZE (0x4000000 - (size_t) CYG_LABEL_NAME (__heap1)) packages/hal/arm/arm9/mini2440/current/include/pkgconf/mlt_arm_arm9_mini2440_qemu.ldi new file mode 100644 @@ -0,0 +1,30 @@ +// eCos memory layout - Fri Oct 20 05:43:59 2000 + +// This is a generated file - do not edit + +#include <cyg/infra/cyg_type.inc> + +MEMORY +{ + ram : ORIGIN = 0, LENGTH = 0x4000000 + sram : ORIGIN = 0x40000000, LENGTH = 0x1000 +} + +SECTIONS +{ + SECTIONS_BEGIN + SECTION_fixed_vectors (ram, 0x20, LMA_EQ_VMA) + SECTION_rom_vectors (ram, 0x8000, LMA_EQ_VMA) + SECTION_RELOCS (ram, ALIGN (0x1), LMA_EQ_VMA) + SECTION_text (ram, ALIGN (0x4), LMA_EQ_VMA) + SECTION_fini (ram, ALIGN (0x4), LMA_EQ_VMA) + SECTION_rodata (ram, ALIGN (0x4), LMA_EQ_VMA) + SECTION_rodata1 (ram, ALIGN (0x4), LMA_EQ_VMA) + SECTION_got (ram, ALIGN (0x4), LMA_EQ_VMA) + SECTION_fixup (ram, ALIGN (0x4), LMA_EQ_VMA) + SECTION_gcc_except_table (ram, ALIGN (0x4), LMA_EQ_VMA) + SECTION_data (ram, ALIGN (0x4), LMA_EQ_VMA) + SECTION_bss (ram, ALIGN (0x4), LMA_EQ_VMA) + CYG_LABEL_DEFN(__heap1) = ALIGN (0x8); + SECTIONS_END +}

4. 如何在QEMU中运行

 

注意一下,需要用我们自己编译出来的qemu-system-arm

 

qemu-system-arm  -M mini2440 -m 128M -kernel install/bin/redboot.elf  -show-cursor -serial stdio

ricky@ricky-laptop:~/ecos/projects/mini2440-redboot$ sh qemu.sh 
S3C: CLK=240 HCLK=240 PCLK=240 UCLK=57
QEMU: ee24c08_init
DM9000: INIT QEMU MAC : 52:54:00:12:34:56
QEMU mini2440_reset: loaded kernel install/bin/redboot.elf at 0x30000000
S3C: CLK=240 HCLK=60 PCLK=30 UCLK=57
S3C: CLK=400 HCLK=100 PCLK=50 UCLK=57
+
RedBoot(tm) bootstrap and debug environment [QEMU]
Non-certified release, version UNKNOWN - built 15:39:35, Mar  1 2011
Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
Free Software Foundation, Inc.
RedBoot is free software, covered by the eCos license, derived from the
GNU General Public License. You are welcome to change it and/or distribute
copies of it under certain conditions. Under the license terms, RedBoot's
source code and full license terms must have been made available to you.
Redboot comes with ABSOLUTELY NO WARRANTY.
Platform: MINI2440 system (ARM9) 
RAM: 0x00000000-0x04000000 [0x0001aab0-0x04000000 available]
RedBoot> help
Manage machine caches
   cache [ON | OFF]
Display/switch console channel
   channel [-1|<channel number>]
Compute a 32bit checksum [POSIX algorithm] for a range of memory
   cksum -b <location> -l <length>
Display (hex dump) a range of memory
   dump -b <location> [-l <length>] [-s] [-1|-2|-4]
Execute an image - with MMU off
   exec [-w timeout] [-b <load addr> [-l <length>]]
        [-r <ramdisk addr> [-s <ramdisk length>]]
        [-c "kernel command line"] [-t <target> ] [<entry_point>]
Execute code at a location
   go [-w <timeout>] [-c] [entry]
Help about help?
   help [<topic>]
Display command history
   history 
Load a file
   load [-r] [-v] [-m <varies>] [-c <channel_number>] 
        [-b <base_address>] <file_name>
Compare two blocks of memory
   mcmp -s <location> -d <location> -l <length> [-1|-2|-4]
Copy memory from one address to another
   mcopy -s <location> -d <location> -l <length> [-1|-2|-4]
Fill a block of memory with a pattern
   mfill -b <location> -l <length> -p <pattern> [-1|-2|-4]
Reset the system
   reset 
Display RedBoot version information
   version 
Display (hex dump) a range of memory
   x -b <location> [-l <length>] [-s] [-1|-2|-4]
RedBoot> 

 

你可能感兴趣的:(c,image,struct,command,File,layout)