使用汇编代码点亮一个LED灯

这篇博客详细介绍了如何使用汇编代码点亮S3C2410开发板上的LED灯。通过提供的Makefile,将汇编代码编译成bin文件,然后通过DNW工具下载到开发板的NANDFLASH中。文中还展示了开发板启动过程以及如何通过串口下载和执行bin文件,最后成功控制LED灯亮起。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

汇编代码:

.text

.global _start

_start:

           LDR  R0,=0x56000010

           MOV  R1,# 0x00001000

           STR  R1, [R0]

           LDR  R0,=0x56000014

           MOV  R1,#0x00000000

           STR  R1, [R0]

 MAIN_LOOP:

          B MAIN_LOOP

 

 

相应的Makefile如下:

led_on.bin:led_on.S

        arm-softfloat-linux-gnu-gcc -g -c -o led_on.o led_on.S
        arm-softfloat-linux-gnu-ld -Ttext 0x0000000 -g led_on.o -o led_on_elf
        arm-softfloat-linux-gnu-objcopy -O binary -S led_on_elf led_on.bin
clean:
        rm -f led_on.bin led_on_elf *.o

 

用到的是S3C2410开发板,在开发板上用DNW工具下在led_on.bin文件。开发板是从NANDFLASH启动,使用DNW显示过程如下:

 

 

Power on reset
Env.Os_Auto_Flag=ff
<*******************************************>
<*                                         *>
<*             S3C2410 Board BIOS          *>
<*                                         *>
<*         http://www.farsight.com.cn      *>
<*                                         *>
<*                                         *>
<*******************************************>
NOR Flash Boot, Read ID is : 0x234b00bf
SST39VF1601 found

Please select function :
0 : USB download file
1 : Uart download file
2 : Write Nand flash with download file
3 : Load Pragram from Nand flash and run
4 : Erase Nand flash regions
5 : Write NOR flash with download file
6 : Set boot params
7 : Set AutoBoot parameter,1:linux 2:wince

选7

Please Input Number:9
.


Please select function :
0 : USB download file
1 : Uart download file
2 : Write Nand flash with download file
3 : Load Pragram from Nand flash and run
4 : Erase Nand flash regions
5 : Write NOR flash with download file
6 : Set boot params
7 : Set AutoBoot parameter,1:linux 2:wince

选4擦除NANDFALSH

 


Please select which region to erase : Esc to abort
0 : offset 0x0       , size 0x40000    [bootloader]
1 : offset 0x40000   , size 0x1c0000   [zImage]
2 : offset 0x200000  , size 0x1e00000  [cramfs]
3 : offset 0x2000000 , size 0x2000000  [WinCE]
Are you sure to erase nand flash from page 0x0, block count 0x10 ? [y/n]
................Erase Nand partition completed success

Please select function :
0 : USB download file
1 : Uart download file
2 : Write Nand flash with download file
3 : Load Pragram from Nand flash and run
4 : Erase Nand flash regions
5 : Write NOR flash with download file
6 : Set boot params
7 : Set AutoBoot parameter,1:linux 2:wince

选择1通过串口下载bin文件。

 

Now download file from uart0...
Download File Size = 42
Are you sure to run? [y/n]

Please select function :
0 : USB download file
1 : Uart download file
2 : Write Nand flash with download file
3 : Load Pragram from Nand flash and run
4 : Erase Nand flash regions
5 : Write NOR flash with download file
6 : Set boot params
7 : Set AutoBoot parameter,1:linux 2:wince
现在2

将.bin下载到NANDFLASH


Please select which region to write : Esc to abort
0 : offset 0x0       , size 0x40000    [bootloader]
1 : offset 0x40000   , size 0x1c0000   [zImage]
2 : offset 0x200000  , size 0x1e00000  [cramfs]
3 : offset 0x2000000 , size 0x2000000  [WinCE]
Now write nand flash page 0x0 from ram address 0x30400000, filesize = 36
Are you sure? [y/n]
.Program nand flash partition success

下载成功

 

 

Please select function :
0 : USB download file
1 : Uart download file
2 : Write Nand flash with download file
3 : Load Pragram from Nand flash and run
4 : Erase Nand flash regions
5 : Write NOR flash with download file
6 : Set boot params
7 : Set AutoBoot parameter,1:linux 2:wince

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值