eclipse软件仿真操作
1.编写程序代码(以SDRAM为例)
1.1 编写head.s汇编文件
.equ SDRAM_BASE, 0x30000000 .equ MEM_CTL_BASE, 0x48000000 .text .global _start _start: bl disable_watch_dog bl memsetup bl copy_steppingstone_to_sdram ldr pc,=on_sdram on_sdram: ldr sp,=0x34000000 bl main halt_loop: b halt_loop disable_watch_dog: mov r1,#0x53000000 mov r2,#0x00 str r2,[r1] mov pc,lr copy_steppingstone_to_sdram: mov r1,#0x00 ldr r2,=SDRAM_BASE mov r3,#4*1024 1: ldr r4,[r1],#4 str r4,[r2],#4 cmp r1,r3 bne 1b mov pc,lr memsetup: mov r1,#MEM_CTL_BASE adrl r2,mem_cfg_val add r3,r1,#52 1: ldr r4,[r2],#4 ldr r4,[r1],#4 cmp r1,r3 bne 1b mov pc,lr .align 4 mem_cfg_val: .long 0x22011110 @BWSCON .long 0x00000700 @BANKCON0 .long 0x00000700 @BANKCON1 .long 0x00000700 @BANKCON2 .long 0x00000700 @BANKCON3 .long 0x00000700 @BANKCON4 .long 0x00000700 @BANKCON5 .long 0x00018005 @BANKCON6 .long 0x00018005 @BANKCON7 .long 0x008C07A3 @REFRESH .long 0x000000B1 @BANKSIZE .long 0x00000030 @MRSRB6 .long 0x00000030 @MRSRB7
1.2 编写led.c C程序文件
#define GPBCON *((volatile unsigned long*)0x56000010) #define GPBDAT *((volatile unsigned long*)0x56000014) int main() { GPBCON=0x00000400; GPBDAT=0x00000000; return 0; }
1.3 编写makefile文件
all:head.o led.o arm-linux-ld -Ttext 0x30000000 led.o head.o -o sdram.elf arm-linux-objcopy -O binary -S sdram.elf sdram.bin arm-linux-objdump -D -m arm sdram.elf > sdram.dis head.o:head.s arm-linux-gcc -g -c head.s led.o:led.c arm-linux-gcc -g -c led.c clean: rm -f sdram.dis sdram.bin sdram.elf *.o
注:必须用all否则编译会报错
2.编译
打开eclipse->project->build all 没有错误可以进行下一步
3.连接JLink
dongry@d-linux:~$ cd arm-tools dongry@d-linux:~/arm-tools$ ls ARM-tools dongry@d-linux:~/arm-tools$ cd ARM-tools dongry@d-linux:~/arm-tools/ARM-tools$ ls arm-linux-gcc-4.3.2.tgz eclipse-cpp-helios-SR2-linux-gtk.tar.gz arm-linux-gdb-7.5 JLink_Linux_V434a dnw JLink_Linux_V434a.tgz dnw_usb.ko dongry@d-linux:~/arm-tools/ARM-tools$ cd JLink_Linux_V434a dongry@d-linux:~/arm-tools/ARM-tools/JLink_Linux_V434a$ ls 45-jlink.rules JLinkGDBServer libjlinkarm.so.4.34.1 start JLinkExe libjlinkarm.so.4 README dongry@d-linux:~/arm-tools/ARM-tools/JLink_Linux_V434a$ ./JLinkGDBServer //运行JLink SEGGER J-Link GDB Server V4.34a JLinkARM.dll V4.34a (DLL compiled Aug 31 2011 11:51:40)
4.配置eclipse
虫子->debug configureation->双击Zylin Embedded debug(Native)->单击New_configuration
配置1:main(添加.elf文件)
配置2:debugger
配置3:command(复制粘贴初始化脚本)