diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8344189 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.axf +*.map diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..f395b04 --- /dev/null +++ b/Makefile @@ -0,0 +1,19 @@ +CC=arm-none-eabi-gcc +ARCH_FLAGS=-mthumb -mcpu=cortex-m0plus +CFLAGS=$(ARCH_FLAGS) -Os -flto -ffunction-sections -fdata-sections -D__STARTUP_COPY_MULTIPLE -D__STARTUP_CLEAR_BSS_MULTIPLE +USE_NANO=--specs=nano.specs +USE_NOHOST=--specs=nosys.specs + +# Link for code size +GC=-Wl,--gc-sections + +# Create map file +MAP=-Wl,-Map=main.map + +LDSCRIPTS=-L. -T multi-ram.ld + +main.axf: main.c sysinit.c startup_ARMCM0.s + $(CC) $^ $(CFLAGS) -fno-exceptions $(USE_NANO) $(USE_NOHOST) $(LDSCRIPTS) $(GC) $(MAP) -o $@ + +clean: + rm -f *.axf *.map diff --git a/main.c b/main.c new file mode 100644 index 0000000..9edf026 --- /dev/null +++ b/main.c @@ -0,0 +1,7 @@ + +void main() +{ + for (;;); + + return; +} diff --git a/multi-ram.ld b/multi-ram.ld index 41872f1..1f25ff6 100644 --- a/multi-ram.ld +++ b/multi-ram.ld @@ -184,6 +184,7 @@ SECTIONS __bss2_end__ = .; } > RAM2 + /* .heap (COPY): { __end__ = .; @@ -191,6 +192,7 @@ SECTIONS *(.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 @@ -202,7 +204,7 @@ SECTIONS /* Set stack top to end of RAM, and stack limit move down by * size of stack_dummy section */ - __StackTop = ORIGIN(RAM) + LENGTH(RAM); + __StackTop = ORIGIN(RAM) + 0xFF; __StackLimit = __StackTop - SIZEOF(.stack_dummy); PROVIDE(__stack = __StackTop); diff --git a/startup_ARMCM0.s b/startup_ARMCM0.s index 7358e9e..35324f5 100644 --- a/startup_ARMCM0.s +++ b/startup_ARMCM0.s @@ -30,11 +30,6 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------*/ - -/* CHANGING DEFINES */ -#define __STARTUP_COPY_MULTIPLE -#define __STARTUP_CLEAR_BSS_MULTIPLE - .syntax unified .arch armv6-m @@ -237,7 +232,7 @@ Reset_Handler: #ifndef __START #define __START _start #endif - bl __START + bl _start .pool .size Reset_Handler, . - Reset_Handler