Gpio (2) C program
@*************************************** ***************************************
@ File: crt0.s
@ Function: transfer it to the C program
@*************************************** ***************************************
. Text
. Global _ start
_ Start:
LDR r0, = 0x53000000 @ watchdog Register address
MoV R1, #0x0
STR R1, [R0] @ write 0, prohibit watchdog, otherwise the CPU will continue to restart
LDR sp, = 1024*4 @ set the stack. Note: it cannot be greater than 4 kb, because the available memory is only 4 kb.
@ The code in NAND Flash will be moved to the internal RAM after the reset. This Ram only has 4 K
BL main @ calls the main function in the C program
Halt_loop:
B halt_loop
# Define gpbcon (* (volatile unsigned long *) 0x56000010)
# Define gpbdat (* (volatile unsigned long *) 0x56000014)
Int main ()
{
Gpbcon = 0x00015400; // set the GPB5-8 to the output port
// [11: 10] = 0b01, [13: 12] = 0b01,
// [15: 14] = 0b01, [17: 16] = 0b01,
Gpbdat = 0x00000000; // GPB5-8 output 0, led1 light
Return 0;
}
Use the following command to compile and connect
Arm-Linux-gcc-g-c-o crt0.o crt0.s
Arm-Linux-gcc-g-C-nostdlib-O led_on_c.o led_on_c.c
Arm-Linux-LD-ttext 0x0000000-G crt0.o led_on_c.o-O led_on_c_elf
Arm-Linux-objcopy-O Binary-s led_on_c_elf led_on_c.bin