258820 views|0 replies

6818

Posts

11

Resources
The OP
 

[Zhengdian Atom Alpha IMX6ULL Linux Development Board] Assembly program writing, compiling, and burning firmware - lighting up the LED [Copy link]

Today I started to learn how to write LED assembly for the Zhengdian Atom Alpha development board.
1. Open vscode and create a new led.s
code as follows:

```
/***************************************************************
Copyright lugl.
File name: led.s
Author: Liu Jianhua
Version: V1.0
Description: Bare metal experiment 1 Assembly lighting
Use assembly to light up the LED on the development board, learn and master how to use assembly language to
complete the GPIO initialization and control of the i.MX6U processor.
Others: None
Log: First version V1.0 2023.5.1 Learn from Zuo Zhongkai teacher's routine
****************************************************************/
.global _start /* Global label*/

/*
*Description: _start function, the program starts from this function, execute this function to complete the clock enable,
* GPIO initialization, and finally control the GPIO to output a low level to light up the LED light
*/
_start:
ldr r0, = 0x020c4068 @register CCGR0
ldr r1, = 0xFFFFFFFF
str r1, [r0] @write to CCGR0 register

ldr r0, =0x020C406C @register CCGR1
str r1, [r0]

ldr r0, =0x020C4070 @register CCGR2
str r1, [r0]

ldr r0, =0x020C4074 @register CCGR3
str r1, [r0]

ldr r0, =0x020C4078 @register CCGR4
str r1, [r0]

ldr r0, =0x020C407C @register CCGR5
str r1, [r0]

ldr r0, =0x020C4080 @register CCGR6
str r1, [r0]

/* Initialization clock ends */

/* Start setting IO properties of GPIO1_IO03
*bit 16: 0 HYS off
*bit [15:14]: 00 Default pull-down
*bit [13]: 0 kepper function
*bit [12]: 1 pull/kepper enable
*bit [11]: 0 Close open-circuit output
*bit [7:6]: 10 Speed 100 MHz
*bit [5:3]: 110 R0/6 drive capability
*bit [0]: 0 Low slew rate
0b0 0001 0000 1011 0000
0x00 00 10 B0
*/

ldr r0, = 0x020e02f4 @ register SW_PAD_GPIO1_IO03_BASE
ldr r1, = 0x000010b0 @ configuration register value
str r1, [r0] @ write GPIO configuration value

/* Set GPIO1——IO03 to output*/
ldr r0, = 0x0209c004 @ Register GPIO1——GDIR
ldr r1, = 0x00000008
str r1, [r0]

/* Turn on LED0 */
ldr r0, = 0x0209c000 @ register GPIO1_DR
ldr r1, = 0
str r1, [r0]

loop:
b loop
```

2. After saving, write makfile

```
led.bin:led.s
arm-linux-gnueabihf-gcc -g -c led.s -o led.o
arm-linux-gnueabihf-ld -Ttext 0X87800000 led.o -o led.elf
arm-linux -gnueabihf-objcopy -O binary -S -g led.elf led.bin
arm-linux-gnueabihf-objdump -D led.elf > led.dis
clean:
rm -rf *.o led.bin led.elf led.dis
```

3. Then copy these two files to the newly created linux-tool of the virtual machine

4. Copy in a dedicated burning tool imxdownload from Zhengdian Atom, and modify its execution permission: `chmod 777 imxdownload`
5. Insert an SD. I use the "CS Genesis SD NAND provided by Leilong Development" here. Use ls /dev/sd* to check whether it is loaded:


Because I use Nflash card, it is not like the SDD card mentioned in the tutorial. I use sdb here.


6. Execute the flash

```
lugl@lugl-virtual-machine:~/linux/tool$ ./imxdownload led.bin /dev/sdb
I.MX6ULL bin download software
Edit by:zuozhongkai
Date:2019/6/10
Version:V1.1
log:V1.0 initial version,just support 512MB DDR3
V1.1 and support 256MB DDR3
file led.bin size = 144Bytes
Board DDR SIZE: 512MB
Delete Old load.imx
Create New load.imx
Download load.imx to /dev/sdb ......
Recorded 6+1 reads
Recorded 6+1 writes
3216 bytes (3.2 kB, 3.1 KiB) copied, 0.0111069 s, 290 kB/s
```

7.
Insert the card into the development board, power on, and wait for a while, then you will see the DS0 light on the development board.

At this point, the first program written in assembly language has run successfully.

This post is from ARM Technology
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list