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.
Previous article:Porting madplay to mini2440 under Ubuntu 8.10
Next article:Hardware time setting of Embedded Linux under Friendly Arm Micro2440
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
- Brief Analysis of Automotive Ethernet Test Content and Test Methods
- How haptic technology can enhance driving safety
- What is the concept of nano power supply?
- loto instrument_How to simulate the output of camshaft and crankshaft waveforms_using arbitrary waveform signal source SIG852?
- About CAN communication rate setting
- ADC and DAC special study
- MicroPython drives Weixue 2.13-inch ink screen (electronic paper)
- IC1B logic probe circuit diagram
- ESP32-S2-Saola-1 running circuitpython(1)
- [2022 Digi-Key Innovation Design Competition] Multi-platform IoT Hazardous Gas Detection System Based on STM32F7508-DK
- "Recommended Chinese chips" + domestic high-precision ADC and ultrasonic measurement circuit
- [Hua Diao Experience] 18-line empty board lights up WS2812B's 256-bit LED hard screen