micro2440 first bare board program LED

Publisher:tau29Latest update time:2024-07-02 Source: elecfansKeywords:micro2440 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Development Environment:

System: Ubuntu 10.04.4

Board: micro2440

Compiler: arm-linux-gcc-4.3.2

For details on setting up the development environment, see Ubuntu 10.04.4 development environment configuration. http://www.linuxidc.com/Linux/2013-04/83609.htm

Objective: Make 4 LEDs on the micro2440 board flash

The first program is very simple and is implemented in assembly. The hardware is as follows:

nLED_1——>GPB5

nLED_2——>GPB6

nLED_3——>GPB7

nLED_4——>GPB8

Write the code according to the s3c2440 manual, including 2 files 1_led.s and Makefile.

File 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

linuxidc@linuxidc:~$ cd /home/linuxidc/Si/micro2440/1_led/

linuxidc@linuxidc:~/Si/micro2440/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
linuxidc@linuxidc:~/Si/micro2440/ 1_led$ ls
1_led.bin 1_led.dis 1_led_elf 1_led.o 1_led.s Makefile


Burning and testing:

Many people do not have parallel ports or openjtag programmers on their computers. Here we introduce burning directly with u-boot. The premise is that the board already has u-boot and supports network cards.

I use u-boot in NOR Flash to burn the program to NAND Flash. The process is as follows:

Start the board NOR Flash and power on:

U-Boot 2012.04.01 (Oct 25 2012 - 22:47:25)

CPUID: 32440001
FCLK: 400 MHz
HCLK: 100 MHz
PCLK: 50 MHz
DRAM: 64 MiB
WARNING: Caches not enabled
Flash: 2 MiB
NAND: 256 MiB
In: serial
Out: serial
Err: serial
Net: dm9000
Warning: dm9000 MAC addresses don 't match: Address in SROM is ff
:ff:ff:ff:ff:ff Address in environment is 00
:0c:29:4d:e4:f4

Hit any key to stop autoboot: 0
SMDK2410 # printenv
baudrate=115200
bootargs=console=ttySAC0 root=/dev/mtdblock3
bootcmd=nand read 30000000 kernel;bootm 30000000
bootdelay=5
ethact=dm9000
ethaddr=00:0c:29:4d: e4:f4
gatewayip=172.16.1.1
ipaddr=172.16.1.133
mtddevname=u-boot
mtddevnum=0
mtdids=nand0=micro2440-0
mtdparts=mtdparts=micro2440-0:256k(u-boot),128k(params),2M( kernel),-(rootfs)
netmask=255.255.255.0
partition=nand0,0
serverip=172.16.1.135
stderr=serial
stdin=serial
stdout=serial

Environment size: 476/131068 bytes
SMDK2410 # tftp 0x30000000 1_led.bin
dm9000 i/o: 0x20000000, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 00:0c:29:4d:e4:f4
could not establish link
Using d m9000 device
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)
SMDK2410 # nand erase 0 0x40000

NAND erase: device 0 offset 0x0, size 0x40000
Erasing at 0x20000 -- 100% complete.
OK
SMDK2410 # nand write 0x30000000 0 0x40000

NAND write: device 0 offset 0x0, size 0x40000
262144 bytes written: OK
SMDK2410 # 

Note that printenv found that the network card parameters are incorrect and need to be set as follows:

SMDK2410 # set ipaddr 172.16.1.133
SMDK2410 # set gatewayip 172.16.1.1
SMDK2410 # set serverip 172.16.1.135
SMDK2410 # save

Then power off the board, switch to NAND Flash startup, power on, and the four LED lights start flashing.


Keywords:micro2440 Reference address:micro2440 first bare board program LED

Previous article:Porting madplay to mini2440 under Ubuntu 8.10
Next article:Hardware time setting of Embedded Linux under Friendly Arm Micro2440

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号