The RVDS CodeWarrior configuration is as follows:
Linker (link) settings
RealView Linker->output:
Linkertype Select Simple;simple image in the RO base fill 0x50200000, RW base fill 0x50203000.
RealView linker->options:
Image entry point fill 0x50200000.
RealView linker->layout:
Object/symbol fill in the Startup.o;section and fill in the start.
Other settings are no longer described.
One, the assembly code segment completes the work (primarily is the initialization stack)
Ro set to 0x5020 0138//ro segment, Code snippet end address (starting 0x5020 0000)
R1 set to 0x5020 0478//zi segment, uninitialized global variable segment end address
R2 set to 0x0000 0000//Initialize global variable
R3 set to 0x5020 0138//zi segment, uninitialized global variable segment start address
1.startup.s
; Start the file. Initialize the C program's operating environment, and then enter the C program code.; Import connector three-segment variable in a previously defined run domain; Arm executable image file by the Ro, RW, zi three sections; Ro for code snippets, RW for initialized global variables, Zi for uninitialized global variables Preserve8 IMPORT | image$ $RO $ $Limit | ; RO segment End Address IMPORT | image$ $RW $ $Base | ; RW section start Address IMPORT | image$ $ZI $ $Base | ; Zi section start Address IMPORT | image$ $ZI $ $Limit | ; Zi segment End Address IMPORT main; Declares the main () function area start,code,readonly in a C program; Declares the code snippet start ENTRY; Identification Program Entry CODE32; Statement 32-bit ARM instruction Usr_stack_legth EQU 128; Initialize the operating environment of the C program LDR r0,=|
image$ $RO $ $Limit | LDR r1,=|
image$ $RW $ $Base | LDR r3,=|
image$ $ZI $ $Base | CMP r0,r1 BEQ LOOP1 LOOP0 cmp r1,r3 LDRCC r2,[r0], #4 STRCC r2,[r1], #4 BCC LOOP0 LOOP1 LDR
mage$ $ZI $ $Limit | MOV R2, #0 LOOP2 CMP r3,r1 STRCC r2,[r3], #4 BCC LOOP2, set system mode stack, SP/R13 register; MSR cpsr_c, #0xdf LDR SP, stackusr BL main; Jump to C program code main () function stackusr DCD usrstackspace + (usr_stack_legth-1) *4 area mystacks, DATA, Noinit, AL ign=2 Usrstackspace Space Usr_Stack_legth * 4; User (System) pattern stack space End
2.main.c
#define LED1_ON ~ (1<<4)//1111 1111 1111 1111 1111 1111 1110 1111 gpkdat31~gpkdat0 #define LED2_ON ~ (1<< 5) #define LED3_ON ~ (1<<6) #define LED4_ON ~ (1<<7) #define Led1_off (1<<4)//0000 0000 0000 00 0000 0000 0001 0000 #define LED2_OFF (1<<5) #define LED3_OFF (1<<6) #define Led4_off (1<<7) #de
Fine Ledall_off (0xf<<4)//0000 0000 0000 0000-0000-0000-1111 typedef 0000 long unsigned;
typedef unsigned short U16;
typedef unsigned char U8;
#define RGPIOKCON0 (* (volatile u32 *) 0x7f008800) #define RGPIOKDAT (* volatile u32 *) 0x7f008808) void delay (int times);
int main (void) {u32 uconvalue;
Uconvalue = rGPIOKCON0; Uconvalue &= ~ (0xffff<<16); 0000 0000 0000 0000 1111 1111 1111 1111 gpkcon7~gpkcon0 uconvalue |= 0x1111<<16;
0001 0001 0001 0001 0000 0000 0000 = 0000 rGPIOKCON0;
Rgpiokdat |= Ledall_off;
while (1) {Rgpiokdat &= led1_on;
Delay (1000); Rgpiokdat |= Ledall_off;
Rgpiokdat &= led2_on;
Delay (1000);
Rgpiokdat |= Ledall_off;
Rgpiokdat &= led3_on;
Delay (1000);
Rgpiokdat |= Ledall_off;
Rgpiokdat &= led4_on;
Delay (1000);
Rgpiokdat |= Ledall_off;
} void delay (int times) {int i;
for (; times>0;times--) for (i=0;i<3000;i++); }
=============================================================================================================== =====================
3. If you do not need to RVDS integrated compilation environment, the following is based on the window platform ARMCC compiler in DOS makefile
All:
armasm-o startup.o startup.s--debug--keep--cpu=arm1176jzf-s armcc-c main.o main.c--debug--cpu=ARM1176
Jzf-s-o0
armlink-o myled.axf startup.o main.o--ro_base=0x50200000--rw_base=0x50203000---FIRST=STARTUP.O (start) --entry=0x50200000
fromelf-o myled.bin--bin myled.axf clean: del *.o *.axf *.bin
#armasm-
o STARTUP.O Startup.s--debug--keep--cpu=arm1176jzf-s #armcc-C main.o main.c--debug--cpu=arm1176jzf-s-O0
#armlink-O in CLC.AXF STARTUP.O main.o--entry main--ro_base=0x50200000--first=startup.o (start)
#fromelf-O inclc.bin--bin Inclc.axf
4. After the above, directly pull Axd can be.