嵌入式学习:裸机开发_L5_BSP工程管理LED实验
程序员文章站
2022-06-09 08:28:49
...
裸机开发_L5_BSP工程管理LED实验
0. 本节目标
- Makefile的编写:函数使用
- BSP分门别类
1. 目录结构
2. 硬件层电路
2.1 正点原子 i.MX6ULL ALPHA V2.2 开发板
查看底板原理图可知:
功能管脚 | 芯片引脚 |
---|---|
LED0 | GPIO1_IO03 |
2.2 飞凌i.MX6UL-C开发板
3. 软件编写
Makefile
CROSS_COMPILE ?= arm-linux-gnueabihf-
TARGET ?= ledc
CC := $(CROSS_COMPILE)gcc
LD := $(CROSS_COMPILE)ld
OBJCOPY := $(CROSS_COMPILE)objcopy
OBJDUMP := $(CROSS_COMPILE)objdump
INCUDIRS := imx6ull \
bsp/clk \
bsp/led \
bsp/delay
SRCDIRS := project \
bsp/clk \
bsp/led \
bsp/delay
INCLUDE := $(patsubst %, -I %, $(INCUDIRS))
SFILES := $(foreach dir, $(SRCDIRS), $(wildcard $(dir)/*.S))
CFILES := $(foreach dir, $(SRCDIRS), $(wildcard $(dir)/*.c))
SFILENDIR := $(notdir $(SFILES))
CFILENDIR := $(notdir $(CFILES))
SOBJS := $(patsubst %, obj/%, $(SFILENDIR:.S=.o))
COBJS := $(patsubst %, obj/%, $(CFILENDIR:.c=.o))
OBJS := $(SOBJS)$(COBJS)
VPATH := $(SRCDIRS)
.PHONY: clean
$(TARGET).bin : $(OBJS)
$(LD) -Timx6ull.lds -o $(TARGET).elf $^
$(OBJCOPY) -O binary -S $(TARGET).elf aaa@qq.com
$(OBJDUMP) -D -m arm $(TARGET).elf > $(TARGET).dis
$(SOBJS) : obj/%.o : %.S
$(CC) -Wall -nostdlib -c -O2 $(INCLUDE) -o aaa@qq.com $<
$(COBJS) : obj/%.o : %.c
$(CC) -Wall -nostdlib -c -O2 $(INCLUDE) -o aaa@qq.com $<
clean:
rm -rf $(TARGET).elf $(TARGET).bin $(TARGET).dis $(OBJS)
print:
@echo INCLUDE = $(INCLUDE)
@echo SFILES = $(SFILES)
@echo CFILES = $(CFILES)
@echo SFILENDIR = $(SFILENDIR)
@echo CFILENDIR = $(CFILENDIR)
@echo SOBJS = $(SOBJS)
@echo COBJS = $(COBJS)
@echo OBJS = $(OBJS)
$(NAME).bin : $(OBJS)
$(LD) -Timx6ull.lds -o $(NAME).elf $^
$(OBJCOPY) -O binary -S $(NAME).elf aaa@qq.com
$(OBJDUMP) -D -m arm $(NAME).elf > $(NAME).dis
%.o : %.c
$(CC) -Wall -nostdlib -c -O2 -o aaa@qq.com $<
%.o : %.S
$(CC) -Wall -nostdlib -c -O2 -o aaa@qq.com $<