.1、新建 cc.h 文件
SDK 包里面会用到很多数据类型,所以我们需要在 cc.h 里面定义一些常用的数据类型。
#define _I volatile
#define_O volatile
#define _IO volatile
typedef signed char
typedef Bigned short
typedef signed int
typedef unsigned char
typedef unsigned short
typedef unsigned int
typedef unsigned long long
int8_t;
int16_t;
int32_t;
uint8_t;
uint16_t;
uint32_t;
uint64_t;
typedef signed char s8;
typedef signed short s16;
typedef signed int s32;
typedef signed long long s64;
typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned int u32;
typedef unsigned long long u64;
#endif
2、移植文件.
需要移植的文件 fs.common.h、fsl.iomuxc.h、MCIMX6Y2.h。
将这三个文件与资料中的文件进行比较,删去不必要的一些代码段。
复制之前模仿stm32的代码。
3、编写链接脚本
SECTIONS{
.=0X87808000;
.text :{
start.o
*(.text)
}
.rodata ALIGN(4):{*(.rodata*))
.data ALIGN(4):*(.data)
_bss_start=.;
.bss ALIGN(4):{*(.bss)*(COMMON)}
bss_end=.;
}
4、编写Makefile
CROSS_COMPILE ?= arm-Linux-gnueabihf-
NAME?= ledc
cc :=$(CROSS_COMPILE)
gcc :=$(CROSS_COMPILE)1d
0BJCOPY :=$(CROSS_COMPILE)objcopy
OBJDUMP :=$(CROSS_COMPILE)objdump
OBJS := start.o main.o
$(NAME).bin : $(OBJS)
$(LD)-Timx6u.lds -o $(NAME).elf $^
$(OBJCOPY)-O binary -S $(NAME).elf se
$(OBJDUMP)-D -m arm $(NAME).elf > $(NAME).dis
%.o:%.c
$(CC)-Wall -nostdlib -c -02 -o $@ $<
%. o :%.S
$(CC)-Wall -nostdlib -c -02 .o $@ $<
clean:
rm -rf *.o $(NAME).bin $(NAME).elf $(NAME).dis