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 <rickleaf.wu@gmail.com> 2011-03-01 15:38:16
- Committer: Ricky Wu <rickleaf.wu@gmail.com> 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>
