Skip to content

Commit

Permalink
Create gcc branch. Makefile is added. xShell is not working.
Browse files Browse the repository at this point in the history
  • Loading branch information
Xuxingliang committed Nov 4, 2018
1 parent 8dfde8d commit ba4943e
Show file tree
Hide file tree
Showing 752 changed files with 970 additions and 1,382 deletions.
695 changes: 0 additions & 695 deletions MDK/AD5791Ref.uvoptx

This file was deleted.

581 changes: 0 additions & 581 deletions MDK/AD5791Ref.uvprojx

This file was deleted.

9 changes: 0 additions & 9 deletions MDK/EventRecorderStub.scvd

This file was deleted.

38 changes: 0 additions & 38 deletions USR/app/CBuff.C

This file was deleted.

26 changes: 0 additions & 26 deletions USR/app/CBuff.h

This file was deleted.

109 changes: 109 additions & 0 deletions src/Makefile
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"
154 changes: 154 additions & 0 deletions src/STM32F030F4.ld
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.
36 changes: 3 additions & 33 deletions USR/app/xShell.C → src/app/xShell.c
Original file line number Diff line number Diff line change
@@ -1,34 +1,4 @@
/************xShell*******************************************************
* used on stm32f103ze,compiler:arm_cc;not support IAR
*
* ver 0.1,2013-12-22,by 徐兴良 in xjtu,xi'an,shanxi,CHINA
**************************************************************************
* ver 0.2,2015-3-25,by 徐兴良 in xjtu,xi'an,shanxi,CHINA,
* made it more easier to use
**************************************************************************
* how to use it:
* 1. set flag USE_XSHELL to 1,
* you can simple turn it off by set it to 0
* 2. add "--keep *.o(xShellTab)" to misc control in linker page(without "")
* 3. complete function xShell_printf(const char*str,...),
* if you dont want any output, just write a empty function
* you can use this to simply it
* #define xShell_print printf
* this is much easier to realize the printf function
* 4. register your function use the macro xShell_FUN_REG(name, desc)
* 5. register your variable use the macro xShell_VAR_REG(name, desc)
* the variable can be list to the terminal
* 6. when you received a character, execute
* xShell_InputChar(xShell_st *xShell,char c);
* fistly, you should first define the struct (xShell),this is
* the workspace of xshell, pass its pointer to this function,
* parameter 'c' is the charater you received
* 7. enjoy it.
*
****************************************************************************/


#include <string.h>
#include "string.h"
#include "xShell.H"
#include "xprintf.h"

Expand Down Expand Up @@ -216,7 +186,7 @@ static unsigned int xShell_Str2Num(char*Str,unsigned long *Res)
while(1)
{
if((*p<='9'&&*p>='0')||(*p<='f'&&*p>='a')||(*p=='x'&&Num==1))
{//字母开头或' 'x开头的则认为16进制,统计合法的字符个数
{//
if(*p>='a')HexDec=16;
Num++;
}else if(*p=='\0')break;
Expand All @@ -227,7 +197,7 @@ static unsigned int xShell_Str2Num(char*Str,unsigned long *Res)
if(HexDec==16)
{
if(Num<3)return 2;
if(*p=='0' && (*(p+1)=='x'))//剔除没有加0x前缀的16进制数
if(*p=='0' && (*(p+1)=='x'))//
{
p+=2;
Num-=2;
Expand Down
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.
Loading

0 comments on commit ba4943e

Please sign in to comment.