首页 > 代码库 > The first No OS program (Mini2440)
The first No OS program (Mini2440)
In Mini2440:
First we need a Assembly program to call C program.
crt0.S
@switch to C program.text.global _start_start: ldr r0,=0x53000000 mov r1,#0x0 str r1,[r0] ldr sp,=1024*4 bl main @using C mainhalt_loop: b halt_loop
Next the main().
led_on_c.c
#define GPBCON (*(volatile unsigned long *)0x56000010)#define GPBDAT (*(volatile unsigned long *)0x56000014)#define LED1 (1<<(10)) //LED1-GPB5int main(){ GPBCON = LED1; GPBDAT &= ~(1<<5); //LED1 ON return 0;}
Next the Makefile.
Makefile
led_on_c.bin: crt0.S led_on_c.c arm-linux-gcc -g -c -o crt0.o crt0.S arm-linux-gcc -g -c -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 arm-linux-objdump -D -m arm led_on_c_elf > led_on_c.disclean: rm -f led_on_c.dis led_on_c.bin led_on_c_elf *.o
Finally,we just need to execute the make command.And the bin are created.
The first No OS program (Mini2440)
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。