hominlinx 发表于 2015-11-1 21:25:56

led 从sd卡启动

我的目的是将led的bin烧写到sd里面, 然后插入sd卡,上电,就能看到led,这些全部在linux完成。

首先是代码和makefile:
代码:
```
1 .text                                                                                                                                                               
2 .code 32                                                                                                                                                            
3 .global _start                                                                                                                                                      
4 _start:                                                                                                                                                               
5   ldr r0,=0x7F008820                                                                                                                                                
6   ldr r1,=0x11111111                                                                                                                                                
7   str r1,                                                                                                                                                      
8   ldr r0,=0x7F008824                                                                                                                                                
9   ldr r2,=0xff000000                                                                                                                                                
10   str r2,                                                                                                                                                      
11 loop:                                                                                                                                                               
12   b loop   
```
makefile:
```
TARGET := led.bin
BUILD:= led

COBJS += led.o
#COBJS += main.o

CROSS_COMPILE := arm-linux-

CC                                := $(CROSS_COMPILE)gcc
LD                                := $(CROSS_COMPILE)ld
OBJCOPY                        := $(CROSS_COMPILE)objcopy

CFLAGS                         += -Wall
CFLAGS                        += -I./include

LDFLAGS                        += -e _start -Ttext 0x0c000000

#way
all: $(TARGET)
$(TARGET):$(BUILD)
        $(OBJCOPY) -O binary $^ $@

$(BUILD):$(COBJS)
        $(LD) $(LDFLAGS) -o $@ $^

%.o:%.c
        $(CC) $(CFLAGS) -c -o $@ $^

clean:
        rm -rf *.o $(TARGET) $(BUILD)
```
我使用的是2G 的sd卡,总大小是2041053184 bytes, 根据手册,我需要写入的地址为 2041053184 - 18 * 512 = 2041043968
`sudo dd if=./led.bin of=/dev/sdb seek=2041043968 bs=1`, 这样将bin写道sd里面。
然后上电,结果没反应。
求教。。。

hominlinx 发表于 2015-11-6 20:09:52

支持下,请大家帮我回答下 谢谢了

lyle 发表于 2018-12-19 14:36:57

遇到相同问题,楼主解决没?
页: [1]
查看完整版本: led 从sd卡启动