Skip to content
This repository was archived by the owner on Dec 27, 2018. It is now read-only.

Commit 3bf072d

Browse files
author
firecrafty
committed
PROS Project Template
1 parent b40df79 commit 3bf072d

File tree

17 files changed

+3043
-0
lines changed

17 files changed

+3043
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/bin
2+
project.pros

LICENSE.MD

Lines changed: 595 additions & 0 deletions
Large diffs are not rendered by default.

Makefile

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Universal C Makefile for MCU targets
2+
3+
# Path to project root (for top-level, so the project is in ./; first-level, ../; etc.)
4+
ROOT=.
5+
# Binary output directory
6+
BINDIR=$(ROOT)/bin
7+
# Subdirectories to include in the build
8+
SUBDIRS=src
9+
10+
# Nothing below here needs to be modified by typical users
11+
12+
# Include common aspects of this project
13+
-include $(ROOT)/common.mk
14+
15+
ASMSRC:=$(wildcard *.$(ASMEXT))
16+
ASMOBJ:=$(patsubst %.o,$(BINDIR)/%.o,$(ASMSRC:.$(ASMEXT)=.o))
17+
HEADERS:=$(wildcard *.$(HEXT))
18+
CSRC=$(wildcard *.$(CEXT))
19+
COBJ:=$(patsubst %.o,$(BINDIR)/%.o,$(CSRC:.$(CEXT)=.o))
20+
CPPSRC:=$(wildcard *.$(CPPEXT))
21+
CPPOBJ:=$(patsubst %.o,$(BINDIR)/%.o,$(CPPSRC:.$(CPPEXT)=.o))
22+
OUT:=$(BINDIR)/$(OUTNAME)
23+
24+
.PHONY: all clean upload _force_look
25+
26+
# By default, compile program
27+
all: $(BINDIR) $(OUT)
28+
29+
# Remove all intermediate object files (remove the binary directory)
30+
clean:
31+
-rm -f $(OUT)
32+
-rm -rf $(BINDIR)
33+
34+
# Uploads program to device
35+
upload: all
36+
$(UPLOAD)
37+
38+
# Phony force-look target
39+
_force_look:
40+
@true
41+
42+
# Looks in subdirectories for things to make
43+
$(SUBDIRS): %: _force_look
44+
@$(MAKE) --no-print-directory -C $@
45+
46+
# Ensure binary directory exists
47+
$(BINDIR):
48+
-@mkdir -p $(BINDIR)
49+
50+
# Compile program
51+
$(OUT): $(SUBDIRS) $(ASMOBJ) $(COBJ) $(CPPOBJ)
52+
@echo LN $(BINDIR)/*.o $(LIBRARIES) to $@
53+
@$(CC) $(LDFLAGS) $(BINDIR)/*.o $(LIBRARIES) -o $@
54+
@$(MCUPREFIX)size $(SIZEFLAGS) $(OUT)
55+
$(MCUPREPARE)
56+
57+
# Assembly source file management
58+
$(ASMOBJ): $(BINDIR)/%.o: %.$(ASMEXT) $(HEADERS)
59+
@echo AS $<
60+
@$(AS) $(AFLAGS) -o $@ $<
61+
62+
# Object management
63+
$(COBJ): $(BINDIR)/%.o: %.$(CEXT) $(HEADERS)
64+
@echo CC $(INCLUDE) $<
65+
$(CC) $(INCLUDE) $(CFLAGS) -o $@ $<
66+
67+
$(CPPOBJ): $(BINDIR)/%.o: %.$(CPPEXT) $(HEADERS)
68+
@echo CPC $(INCLUDE) $<
69+
@$(CPPCC) $(INCLUDE) $(CPPFLAGS) -o $@ $<

common.mk

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Universal C Makefile for MCU targets
2+
# Top-level template file to configure build
3+
4+
MAKE_COMMAND=make
5+
6+
# Makefile for IFI VeX Cortex Microcontroller (STM32F103VD series)
7+
DEVICE=VexCortex
8+
# Libraries to include in the link (use -L and -l) e.g. -lm, -lmyLib
9+
LIBRARIES=$(wildcard $(ROOT)/firmware/*.a) -lgcc -lm
10+
# Prefix for ARM tools (must be on the path)
11+
MCUPREFIX=arm-none-eabi-
12+
# Flags for the assembler
13+
MCUAFLAGS=-mthumb -mcpu=cortex-m3 -mlittle-endian
14+
# Flags for the compiler
15+
MCUCFLAGS=-mthumb -mcpu=cortex-m3 -mlittle-endian -mfloat-abi=soft
16+
# Flags for the linker
17+
MCULFLAGS=-nostartfiles -Wl,-static -Bfirmware -Wl,-u,VectorTable -Wl,-T -Xlinker firmware/cortex.ld
18+
# Prepares the elf file by converting it to a binary that java can write
19+
MCUPREPARE=$(OBJCOPY) $(OUT) -O binary $(BINDIR)/$(OUTBIN)
20+
# Advanced sizing flags
21+
SIZEFLAGS=
22+
# Uploads program using java
23+
UPLOAD=@java -jar firmware/uniflash.jar vex $(BINDIR)/$(OUTBIN)
24+
25+
# Advanced options
26+
ASMEXT=s
27+
CEXT=c
28+
CPPEXT=cpp
29+
HEXT=h
30+
INCLUDE=-I$(ROOT)/include -I$(ROOT)/src
31+
OUTBIN=output.bin
32+
OUTNAME=output.elf
33+
34+
# Flags for programs
35+
AFLAGS:=$(MCUAFLAGS)
36+
ARFLAGS:=$(MCUCFLAGS)
37+
CCFLAGS:=-c -Wall $(MCUCFLAGS) -Os -ffunction-sections -fsigned-char -fomit-frame-pointer -fsingle-precision-constant
38+
CFLAGS:=$(CCFLAGS) -std=gnu99 -Werror=implicit-function-declaration
39+
CPPFLAGS:=$(CCFLAGS) -fno-exceptions -fno-rtti -felide-constructors
40+
LDFLAGS:=-Wall $(MCUCFLAGS) $(MCULFLAGS) -Wl,--gc-sections
41+
42+
# Tools used in program
43+
AR:=$(MCUPREFIX)ar
44+
AS:=$(MCUPREFIX)as
45+
CC:=$(MCUPREFIX)gcc
46+
CPPCC:=$(MCUPREFIX)g++
47+
OBJCOPY:=$(MCUPREFIX)objcopy

firmware/STM32F10x.ld

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
/* Memory space definitions */
2+
MEMORY {
3+
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 64K
4+
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 384K
5+
}
6+
7+
/* Higher address of the user mode stack */
8+
EXTERN ( _estack );
9+
PROVIDE ( _estack = ORIGIN(RAM) + LENGTH(RAM) );
10+
11+
/* This sends all unreferenced IRQHandlers to reset. */
12+
PROVIDE ( ISR_SWI = 0 );
13+
PROVIDE ( ISR_IRQ = 0 );
14+
PROVIDE ( ISR_Prefetch = 0 );
15+
PROVIDE ( ISR_Abort = 0 );
16+
PROVIDE ( ISR_FIQ = 0 );
17+
18+
PROVIDE ( ISR_NMI = 0 );
19+
PROVIDE ( ISR_HardFault = 0 );
20+
PROVIDE ( ISR_MemManage = 0 );
21+
PROVIDE ( ISR_BusFault = 0 );
22+
PROVIDE ( ISR_UsageFault = 0 );
23+
24+
PROVIDE ( ISR_SVC = 0 );
25+
PROVIDE ( ISR_DebugMon = 0 );
26+
PROVIDE ( ISR_PendSV = 0 );
27+
PROVIDE ( ISR_SysTick = 0 );
28+
29+
PROVIDE ( ISR_WWDG = 0 );
30+
PROVIDE ( ISR_PVD = 0 );
31+
PROVIDE ( ISR_TAMPER = 0 );
32+
PROVIDE ( ISR_RTC = 0 );
33+
PROVIDE ( ISR_FLASH = 0 );
34+
PROVIDE ( ISR_RCC = 0 );
35+
PROVIDE ( ISR_EXTI0 = 0 );
36+
PROVIDE ( ISR_EXTI1 = 0 );
37+
PROVIDE ( ISR_EXTI2 = 0 );
38+
PROVIDE ( ISR_EXTI3 = 0 );
39+
PROVIDE ( ISR_EXTI4 = 0 );
40+
PROVIDE ( ISR_DMAChannel1 = 0 );
41+
PROVIDE ( ISR_DMAChannel2 = 0 );
42+
PROVIDE ( ISR_DMAChannel3 = 0 );
43+
PROVIDE ( ISR_DMAChannel4 = 0 );
44+
PROVIDE ( ISR_DMAChannel5 = 0 );
45+
PROVIDE ( ISR_DMAChannel6 = 0 );
46+
PROVIDE ( ISR_DMAChannel7 = 0 );
47+
PROVIDE ( ISR_DMA1_Channel1 = 0 );
48+
PROVIDE ( ISR_DMA1_Channel2 = 0 );
49+
PROVIDE ( ISR_DMA1_Channel3 = 0 );
50+
PROVIDE ( ISR_DMA1_Channel4 = 0 );
51+
PROVIDE ( ISR_DMA1_Channel5 = 0 );
52+
PROVIDE ( ISR_DMA1_Channel6 = 0 );
53+
PROVIDE ( ISR_DMA1_Channel7 = 0 );
54+
PROVIDE ( ISR_ADC = 0 );
55+
PROVIDE ( ISR_ADC1_2 = 0 );
56+
PROVIDE ( ISR_USB_HP_CAN_TX = 0 );
57+
PROVIDE ( ISR_USB_HP_CAN1_TX = 0 );
58+
PROVIDE ( ISR_USB_LP_CAN_RX0 = 0 );
59+
PROVIDE ( ISR_USB_LP_CAN1_RX0 = 0 );
60+
PROVIDE ( ISR_CAN_RX1 = 0 );
61+
PROVIDE ( ISR_CAN1_RX1 = 0 );
62+
PROVIDE ( ISR_CAN_SCE = 0 );
63+
PROVIDE ( ISR_CAN1_SCE = 0 );
64+
PROVIDE ( ISR_EXTI9_5 = 0 );
65+
PROVIDE ( ISR_TIM1_BRK = 0 );
66+
PROVIDE ( ISR_TIM1_UP = 0 );
67+
PROVIDE ( ISR_TIM1_TRG_COM = 0 );
68+
PROVIDE ( ISR_TIM1_CC = 0 );
69+
PROVIDE ( ISR_TIM2 = 0 );
70+
PROVIDE ( ISR_TIM3 = 0 );
71+
PROVIDE ( ISR_TIM4 = 0 );
72+
PROVIDE ( ISR_I2C1_EV = 0 );
73+
PROVIDE ( ISR_I2C1_ER = 0 );
74+
PROVIDE ( ISR_I2C2_EV = 0 );
75+
PROVIDE ( ISR_I2C2_ER = 0 );
76+
PROVIDE ( ISR_SPI1 = 0 );
77+
PROVIDE ( ISR_SPI2 = 0 );
78+
PROVIDE ( ISR_USART1 = 0 );
79+
PROVIDE ( ISR_USART2 = 0 );
80+
PROVIDE ( ISR_USART3 = 0 );
81+
PROVIDE ( ISR_EXTI15_10 = 0 );
82+
PROVIDE ( ISR_RTCAlarm = 0 );
83+
PROVIDE ( ISR_USBWakeUp = 0 );
84+
PROVIDE ( ISR_TIM8_BRK = 0 );
85+
PROVIDE ( ISR_TIM8_UP = 0 );
86+
PROVIDE ( ISR_TIM8_TRG_COM = 0 );
87+
PROVIDE ( ISR_TIM8_CC = 0 );
88+
PROVIDE ( ISR_ADC3 = 0 );
89+
PROVIDE ( ISR_FSMC = 0 );
90+
PROVIDE ( ISR_SDIO = 0 );
91+
PROVIDE ( ISR_TIM5 = 0 );
92+
PROVIDE ( ISR_SPI3 = 0 );
93+
PROVIDE ( ISR_UART4 = 0 );
94+
PROVIDE ( ISR_UART5 = 0 );
95+
PROVIDE ( ISR_TIM6 = 0 );
96+
PROVIDE ( ISR_TIM7 = 0 );
97+
PROVIDE ( ISR_DMA2_Channel1 = 0 );
98+
PROVIDE ( ISR_DMA2_Channel2 = 0 );
99+
PROVIDE ( ISR_DMA2_Channel3 = 0 );
100+
PROVIDE ( ISR_DMA2_Channel4_5 = 0 );

firmware/cortex.ld

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
/* Include STM32F10X linker scripts */
2+
INCLUDE "STM32F10x.ld"
3+
4+
EXTERN ( _heapbegin );
5+
6+
/* Section definitions for Cortex firmware flashing */
7+
SECTIONS {
8+
.isr_vector : {
9+
/* startup code, prevents garbage collection from eating everything */
10+
KEEP(*(.isr_vector))
11+
. = ALIGN(4);
12+
} >FLASH
13+
.text : {
14+
. = ALIGN(4);
15+
*(.text)
16+
*(.text.*)
17+
/* Preinit array of functions */
18+
__preinit_array_start = .;
19+
KEEP (*(.preinit_array))
20+
__preinit_array_end = .;
21+
. = ALIGN(4);
22+
/* Init array of functions */
23+
KEEP(*(.init))
24+
. = ALIGN(4);
25+
__init_array_start = .;
26+
KEEP (*(SORT(.init_array.*)))
27+
KEEP (*(.init_array))
28+
__init_array_end = .;
29+
. = ALIGN(4);
30+
/* C++ constructors */
31+
KEEP (*crtbegin.o(.ctors))
32+
KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
33+
KEEP (*(SORT(.ctors.*)))
34+
KEEP (*crtend.o(.ctors))
35+
. = ALIGN(4);
36+
/* Finalizer array of functions */
37+
KEEP(*(.fini))
38+
. = ALIGN(4);
39+
__fini_array_start = .;
40+
KEEP (*(.fini_array))
41+
KEEP (*(SORT(.fini_array.*)))
42+
__fini_array_end = .;
43+
. = ALIGN(4);
44+
/* C++ destructors */
45+
KEEP (*crtbegin.o(.dtors))
46+
KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
47+
KEEP (*(SORT(.dtors.*)))
48+
KEEP (*crtend.o(.dtors))
49+
_etext = .;
50+
_srdata = .;
51+
. = ALIGN(4);
52+
*(.rodata)
53+
*(.rodata*)
54+
*(.glue_7)
55+
*(.glue_7t)
56+
. = ALIGN(4);
57+
_erdata = .;
58+
_sidata = .;
59+
} >FLASH
60+
/* The program executes knowing that the data is in the RAM, but the loader puts the
61+
* initial values in the FLASH (inidata). The startup copies the initial values over */
62+
.data : AT ( _sidata ) {
63+
. = ALIGN(4);
64+
_sdata = .;
65+
*(.data)
66+
*(.data.*)
67+
*(.RAMtext)
68+
. = ALIGN(4);
69+
_edata = .;
70+
} >RAM
71+
/* Uninitialized data (zero-fill) section */
72+
.bss : {
73+
. = ALIGN(4);
74+
_sbss = .;
75+
*(.bss)
76+
*(COMMON)
77+
. = ALIGN(4);
78+
_ebss = .;
79+
. = ALIGN(8);
80+
_heapbegin = .;
81+
} >RAM
82+
83+
/DISCARD/ : {
84+
libc.a ( * )
85+
libg.a ( * )
86+
libm.a ( * )
87+
libgcc.a ( * )
88+
libstdc++.a ( * )
89+
libsupc++.a ( * )
90+
}
91+
/* ARM exception unwinding, mandated by ARM EABI C++ standard (with -fno-exceptions?) */
92+
.ARM.exidx 0 : { *(.ARM.exidx*) }
93+
/* Stabs debugging sections */
94+
.stab 0 : { *(.stab) }
95+
.stabstr 0 : { *(.stabstr) }
96+
.stab.excl 0 : { *(.stab.excl) }
97+
.stab.exclstr 0 : { *(.stab.exclstr) }
98+
.stab.index 0 : { *(.stab.index) }
99+
.stab.indexstr 0 : { *(.stab.indexstr) }
100+
.comment 0 : { *(.comment) }
101+
/* DWARF 1 */
102+
.debug 0 : { *(.debug) }
103+
.line 0 : { *(.line) }
104+
/* GNU DWARF 1 extensions */
105+
.debug_srcinfo 0 : { *(.debug_srcinfo) }
106+
.debug_sfnames 0 : { *(.debug_sfnames) }
107+
/* DWARF 1.1 and DWARF 2 */
108+
.debug_aranges 0 : { *(.debug_aranges) }
109+
.debug_pubnames 0 : { *(.debug_pubnames) }
110+
/* DWARF 2 */
111+
.debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
112+
.debug_abbrev 0 : { *(.debug_abbrev) }
113+
.debug_line 0 : { *(.debug_line) }
114+
.debug_frame 0 : { *(.debug_frame) }
115+
.debug_str 0 : { *(.debug_str) }
116+
.debug_loc 0 : { *(.debug_loc) }
117+
.debug_macinfo 0 : { *(.debug_macinfo) }
118+
/* SGI/MIPS DWARF 2 extensions */
119+
.debug_weaknames 0 : { *(.debug_weaknames) }
120+
.debug_funcnames 0 : { *(.debug_funcnames) }
121+
.debug_typenames 0 : { *(.debug_typenames) }
122+
.debug_varnames 0 : { *(.debug_varnames) }
123+
}

0 commit comments

Comments
 (0)