-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create gcc branch. Makefile is added. xShell is not working.
- Loading branch information
Xuxingliang
committed
Nov 4, 2018
1 parent
8dfde8d
commit ba4943e
Showing
752 changed files
with
970 additions
and
1,382 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
#STM32 makefile template | ||
# 生成的文件名<项目名> | ||
PROJECT = ad5791ref_stm32f030 | ||
|
||
# 定义文件格式和文件名 | ||
TARGET := $(PROJECT) | ||
TARGET_ELF := $(TARGET).elf | ||
TARGET_BIN := $(TARGET).bin | ||
TARGET_HEX := $(TARGET).hex | ||
OBJCPFLAGS_ELF_TO_BIN = -Obinary | ||
OBJCPFLAGS_ELF_TO_HEX = -Oihex | ||
OBJCPFLAGS_BIN_TO_HEX = -Ibinary -Oihex | ||
VPATH = .. | ||
# 定义路径 | ||
TOP_DIR = . | ||
INC_DIR := -I./ | ||
INC_DIR += -I../src | ||
INC_DIR += -I../stm32f0xxlib/CMSIS/Include | ||
INC_DIR += -I../stm32f0xxlib/CMSIS/Device/ST/STM32F0xx/Include | ||
INC_DIR += -I../stm32f0xxlib/STM32F0xx_StdPeriph_Driver/inc | ||
INC_DIR += -I./app | ||
INC_DIR += -I./bsp | ||
INC_DIR += --include ./stm32f0xx_conf.h | ||
|
||
# 设置ld链接脚本文件 | ||
LDSCRIPT := ./STM32F030F4.ld | ||
|
||
# 定义编译工具 | ||
CC = arm-none-eabi-gcc | ||
AS = arm-none-eabi-as | ||
LD = arm-none-eabi-ld | ||
AR = arm-none-eabi-ar | ||
OBJCP = arm-none-eabi-objcopy | ||
|
||
# 定义编译标志 | ||
CCFLAGS += -Wall -mcpu=cortex-m0 -mthumb -g -mfloat-abi=soft '-std=gnu99' | ||
# -march=armv7-m | ||
ASFLAGS += -Wall -mcpu=cortex-m0 -mthumb | ||
LDFLAGS += -T $(LDSCRIPT) -L'C:\Program Files (x86)\GNU Tools Arm Embedded\7 2018-q2-update\lib\gcc\arm-none-eabi\7.3.1' -L'C:\Program Files (x86)\GNU Tools Arm Embedded\7 2018-q2-update\arm-none-eabi\lib' -lgcc -lc -lnosys | ||
#-A armv7-m | ||
#LDFLAGS += -L /Users/ch-yanghl/gcc-arm-none-eabi/lib/gcc/arm-none-eabi/5.4.1 | ||
#LDFLAGS += -L /Users/ch-yanghl/gcc-arm-none-eabi/arm-none-eabi/lib/thumb | ||
|
||
# .c文件中的头文件引用查找路径 | ||
CCFLAGS += $(INC_DIR) | ||
|
||
# .s文件的flags | ||
#ASFLAGS += | ||
|
||
# .c文件编译时定义宏 | ||
CCFLAGS += -D STM32F030 -D USE_STDPERIPH_DRIVER | ||
VPATH = .. | ||
SOURCE := $(wildcard ./*.c) | ||
SOURCE += $(wildcard ./bsp/*.c) | ||
SOURCE += $(wildcard ./app/*.c) | ||
SOURCE += $(wildcard ../stm32f0xxlib/STM32F0xx_StdPeriph_Driver/src/*.c) | ||
|
||
# 添加启动文件 | ||
#SOURCE += $(SCRIPT_DIR)/startup_stm32f10x_md.c | ||
SOURCE_ASM := ../src/startup_stm32f030.s | ||
|
||
# 展开工作 子目录中的inc文件(inc文件中添加需要编译链接的.c,.s等文件) | ||
#-include $(TOP_DIR)/src/make.inc | ||
#-include $(TOP_DIR)/third_party/make.inc | ||
|
||
# 替换文件后缀 | ||
C_OBJS := $(SOURCE:%.c=%.o) | ||
ASM_OBJS := $(SOURCE_ASM:%.s=%.o) | ||
|
||
# 编译命令的定义 | ||
COMPILE = $(CC) $(CCFLAGS) -c $< -o $@ | ||
ASSEMBLE = $(AS) $(ASFLAGS) -c $< -o $@ | ||
LINK = $(LD) $+ $(LDFLAGS) $(LDLIBS) -o $@ | ||
ELF_TO_BIN = $(OBJCP) $(OBJCPFLAGS_ELF_TO_BIN) $< $@ | ||
BIN_TO_HEX = $(OBJCP) $(OBJCPFLAGS_BIN_TO_HEX) $< $@ | ||
|
||
# 定义伪目标 | ||
.PHONY: all clean printf | ||
|
||
# 定义规则 | ||
all: $(TARGET_HEX) | ||
@echo "build done" | ||
|
||
$(TARGET_HEX): $(TARGET_BIN) | ||
$(BIN_TO_HEX) | ||
|
||
$(TARGET_BIN): $(TARGET_ELF) | ||
$(ELF_TO_BIN) | ||
|
||
$(TARGET_ELF): $(C_OBJS) $(ASM_OBJS) | ||
$(LINK) | ||
|
||
$(C_OBJS):%.o:%.c | ||
$(COMPILE) | ||
|
||
$(ASM_OBJS):%.o:%.s | ||
$(ASSEMBLE) | ||
|
||
printf: | ||
@echo $(ASM_OBJS) | ||
@echo $(ASSEMBLE) | ||
|
||
# 清理项 | ||
clean: | ||
rm -f $(TARGET_HEX) | ||
rm -f $(TARGET_BIN) | ||
rm -f $(TARGET_ELF) | ||
rm -f $(C_OBJS) $(ASM_OBJS) | ||
@echo "clean done" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
/* Linker script to configure memory regions. */ | ||
MEMORY | ||
{ | ||
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 64k | ||
RAM (xrw) : ORIGIN = 0x200000C0, LENGTH = 8k - 0x0C0 | ||
} | ||
|
||
/* Linker script to place sections and symbol values. Should be used together | ||
* with other linker script that defines memory regions FLASH and RAM. | ||
* It references following symbols, which must be defined in code: | ||
* Reset_Handler : Entry of reset handler | ||
* | ||
* It defines following symbols, which code can use without definition: | ||
* __exidx_start | ||
* __exidx_end | ||
* __etext | ||
* __data_start__ | ||
* __preinit_array_start | ||
* __preinit_array_end | ||
* __init_array_start | ||
* __init_array_end | ||
* __fini_array_start | ||
* __fini_array_end | ||
* __data_end__ | ||
* __bss_start__ | ||
* __bss_end__ | ||
* __end__ | ||
* end | ||
* __HeapLimit | ||
* __StackLimit | ||
* __StackTop | ||
* __stack | ||
* _estack | ||
*/ | ||
ENTRY(Reset_Handler) | ||
|
||
SECTIONS | ||
{ | ||
.text : | ||
{ | ||
KEEP(*(.isr_vector)) | ||
*(.text*) | ||
KEEP(*(.init)) | ||
KEEP(*(.fini)) | ||
KEEP(*.o(xShellTab)) | ||
|
||
/* .ctors */ | ||
*crtbegin.o(.ctors) | ||
*crtbegin?.o(.ctors) | ||
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors) | ||
*(SORT(.ctors.*)) | ||
*(.ctors) | ||
|
||
/* .dtors */ | ||
*crtbegin.o(.dtors) | ||
*crtbegin?.o(.dtors) | ||
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors) | ||
*(SORT(.dtors.*)) | ||
*(.dtors) | ||
|
||
*(.rodata*) | ||
|
||
KEEP(*(.eh_frame*)) | ||
} > FLASH | ||
|
||
.ARM.extab : | ||
{ | ||
*(.ARM.extab* .gnu.linkonce.armextab.*) | ||
} > FLASH | ||
|
||
__exidx_start = .; | ||
.ARM.exidx : | ||
{ | ||
*(.ARM.exidx* .gnu.linkonce.armexidx.*) | ||
} > FLASH | ||
__exidx_end = .; | ||
|
||
__etext = .; | ||
_sidata = .; | ||
|
||
.data : AT (__etext) | ||
{ | ||
__data_start__ = .; | ||
_sdata = .; | ||
*(vtable) | ||
*(.data*) | ||
|
||
. = ALIGN(4); | ||
/* preinit data */ | ||
PROVIDE_HIDDEN (__preinit_array_start = .); | ||
KEEP(*(.preinit_array)) | ||
PROVIDE_HIDDEN (__preinit_array_end = .); | ||
|
||
. = ALIGN(4); | ||
/* init data */ | ||
PROVIDE_HIDDEN (__init_array_start = .); | ||
KEEP(*(SORT(.init_array.*))) | ||
KEEP(*(.init_array)) | ||
PROVIDE_HIDDEN (__init_array_end = .); | ||
|
||
|
||
. = ALIGN(4); | ||
/* finit data */ | ||
PROVIDE_HIDDEN (__fini_array_start = .); | ||
KEEP(*(SORT(.fini_array.*))) | ||
KEEP(*(.fini_array)) | ||
PROVIDE_HIDDEN (__fini_array_end = .); | ||
|
||
KEEP(*(.jcr*)) | ||
. = ALIGN(4); | ||
/* All data end */ | ||
__data_end__ = .; | ||
_edata = .; | ||
|
||
} > RAM | ||
|
||
.bss : | ||
{ | ||
. = ALIGN(4); | ||
__bss_start__ = .; | ||
_sbss = .; | ||
*(.bss*) | ||
*(COMMON) | ||
. = ALIGN(4); | ||
__bss_end__ = .; | ||
_ebss = .; | ||
} > RAM | ||
|
||
.heap (COPY): | ||
{ | ||
__end__ = .; | ||
end = __end__; | ||
*(.heap*) | ||
__HeapLimit = .; | ||
} > RAM | ||
|
||
/* .stack_dummy section doesn't contains any symbols. It is only | ||
* used for linker to calculate size of stack sections, and assign | ||
* values to stack symbols later */ | ||
.stack_dummy (COPY): | ||
{ | ||
*(.stack*) | ||
} > RAM | ||
|
||
/* Set stack top to end of RAM, and stack limit move down by | ||
* size of stack_dummy section */ | ||
__StackTop = ORIGIN(RAM) + LENGTH(RAM); | ||
_estack = __StackTop; | ||
__StackLimit = __StackTop - SIZEOF(.stack_dummy); | ||
PROVIDE(__stack = __StackTop); | ||
|
||
/* Check if data + heap + stack exceeds RAM limit */ | ||
ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack") | ||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.