TQ2440第一个裸板程序led
2013-04-22 22:48
267 查看
开发环境
系统:ubuntu 10.04.4
单板:tq2440
编译器:arm-linux-gcc-4.3.2
搭建开发环境详见ubuntu 10.04.4开发环境配置。
目标:实现tq2440单板上4个led灯闪烁
第一个程序很简单,用汇编实现。硬件如下:
nLED_1——>GPB5
nLED_2——>GPB6
nLED_3——>GPB7
nLED_4——>GPB8
根据s3c2440手册编写代码,包括2个文件1_led.s和Makefile.
一、编写源码
文件·1_led.s:
文件Makefile:
二、编译
change@change:~$ cd /home/change/Si/tq2440/1_led/
change@change:~/Si/tq2440/1_led$ make
arm-linux-gcc -g -c -o 1_led.o 1_led.s
arm-linux-ld -Ttext 0x00000000 -g 1_led.o -o 1_led_elf
arm-linux-objcopy -O binary -S 1_led_elf 1_led.bin
arm-linux-objdump -D 1_led_elf > 1_led.dis
change@change:~/Si/tq2440/1_led$ ls
1_led.bin 1_led.dis 1_led_elf 1_led.o 1_led.s Makefile
三、烧写、测试:
很多人电脑都没有并口或者openjtag编程器,这里介绍直接用u-boot烧写。前提是单板已有u-boot并且支持网卡。
我用NOR Flash里的u-boot烧写程序到NAND Flash,过程如下:
单板NOR Flash启动上电:
其中上面网卡参数设置根据自己的网关设定。
tq2440单板断电,拨到NAND Flash启动,上电4个LED灯即开始闪烁。
系统:ubuntu 10.04.4
单板:tq2440
编译器:arm-linux-gcc-4.3.2
搭建开发环境详见ubuntu 10.04.4开发环境配置。
目标:实现tq2440单板上4个led灯闪烁
第一个程序很简单,用汇编实现。硬件如下:
nLED_1——>GPB5
nLED_2——>GPB6
nLED_3——>GPB7
nLED_4——>GPB8
根据s3c2440手册编写代码,包括2个文件1_led.s和Makefile.
一、编写源码
文件·1_led.s:
.text .global _start _start: ldr r0,=0x56000010 mov r1,#0x00015400 str r1,[r0] ldr r0,=0x56000014 loop: mov r1,#0x00000000 str r1,[r0] bl delay mov r1,#0x00000ff0 str r1,[r0] bl delay b loop delay: mov r4,#100 del1: mov r5,#1000 del2: sub r5,r5,#1 nop cmp r5,#1 bne del2 sub r4,r4,#1 nop cmp r4,#1 bne del1 mov pc,lr
文件Makefile:
1_led.bin:1_led.s arm-linux-gcc -g -c -o 1_led.o 1_led.s arm-linux-ld -Ttext 0x00000000 -g 1_led.o -o 1_led_elf arm-linux-objcopy -O binary -S 1_led_elf 1_led.bin arm-linux-objdump -D 1_led_elf > 1_led.dis clean: rm -f 1_led.bin *.o 1_led_elf 1_led.dis
二、编译
change@change:~$ cd /home/change/Si/tq2440/1_led/
change@change:~/Si/tq2440/1_led$ make
arm-linux-gcc -g -c -o 1_led.o 1_led.s
arm-linux-ld -Ttext 0x00000000 -g 1_led.o -o 1_led_elf
arm-linux-objcopy -O binary -S 1_led_elf 1_led.bin
arm-linux-objdump -D 1_led_elf > 1_led.dis
change@change:~/Si/tq2440/1_led$ ls
1_led.bin 1_led.dis 1_led_elf 1_led.o 1_led.s Makefile
三、烧写、测试:
很多人电脑都没有并口或者openjtag编程器,这里介绍直接用u-boot烧写。前提是单板已有u-boot并且支持网卡。
我用NOR Flash里的u-boot烧写程序到NAND Flash,过程如下:
单板NOR Flash启动上电:
U-Boot 1.1.6 (Mar 24 2012 - 03:44:51) DRAM: 64 MB Flash: 2 MB NAND: 256 MiB In: serial Out: serial Err: serial Hit any key to stop autoboot: 0 TQ2440 # printenv bootargs=noinitrd root=/dev/mtdblock2 init=/linuxrc console=ttySAC0 bootdelay=3 baudrate=115200 ethaddr=08:00:3e:26:0a:5b ipaddr=192.168.1.111 serverip=192.168.1.110 netmask=255.255.255.0 bootcmd=nboot 0x30000000 0 0;bootm 0x30000000 tdin=serial stdout=serial stderr=serial Environment size: 477/131068 bytes TQ2440 # set ipaddr 172.16.1.133 TQ2440 # set gatewayip 172.16.1.1 TQ2440 # set serverip 172.16.1.135 TQ2440 # ping 172.16.1.135 dm9000 i/o: 0x20000000, id: 0x90000a46 MAC: 00:80:00:80:00:80 could not establish link host 172.16.1.135 is alive TQ2440 # tftp 0x30000000 1_led.bin dm9000 i/o: 0x20000000, id: 0x90000a46 MAC: 00:80:00:80:00:80 could not establish link TFTP from server 172.16.1.135; our IP address is 172.16.1.133 Filename '1_led.bin'. Load address: 0x30000000 Loading: # done Bytes transferred = 96 (60 hex) TQ2440 # nand erase 0 0x40000 NAND erase: device 0 offset 0x0, size 0x40000 Erasing at 0x20000 -- 100% complete. OK TQ2440 # nand write 0x30000000 0 0x40000 NAND write: device 0 offset 0x0, size 0x40000 262144 bytes written: OK TQ2440 #
其中上面网卡参数设置根据自己的网关设定。
tq2440单板断电,拨到NAND Flash启动,上电4个LED灯即开始闪烁。
相关文章推荐
- s5pc100第一个裸板程序led
- ok6410第一个裸板程序led
- micro2440第一个裸板程序led
- 飞凌OK6410开发板(裸板) 第一个点亮LED灯程序
- 友善之臂第一个裸板驱动LED程序的详细分析(新手向)
- STM32学习第一个程序,LED灯
- STM32学习之第一个程序(点亮LED)
- Zigbee之旅(二):第一个CC2430程序——LED灯闪烁实验(转)
- 我的第一个汇编程序,led流水灯
- TQ2440裸板更新程序_update
- 【菜鸟入门】stm32的第一个程序--LED
- 第008课 第1个ARM裸板程序及引申(点亮LED灯)
- 【tiny6410】led裸板程序
- cortex-A8的第一个裸跑程序——点亮LED灯
- mini2440(6) 我的第一个ARM汇编程序---LED灯裸机硬件控制程序(2)
- 嵌入式Linux开发——裸板程序点亮开发板上的LED灯
- 起航,第一个程序——还是LED灯
- 用Keil-MDK开发TQ2440裸机程序入门教程——LED流水灯实现
- 单片机小白学步系列(十四) 点亮第一个LED的程序分析
- 第一个包含头文件的led程序