Skip to content

Commit ee85785

Browse files
author
Ilya Dmitrichenko
committed
cortex-m3-qemu: refactor the port.
Switch from CodeSourcery to ARM GCC and clean-up some stale files, also copy `main.c` and `mpconfigport.h` from bare-arm.
1 parent 5130b81 commit ee85785

11 files changed

Lines changed: 50 additions & 1514 deletions

File tree

cortex-m3-qemu/Makefile

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ include ../py/py.mk
1010
CROSS_COMPILE = arm-none-eabi-
1111

1212
CFLAGS_CORTEX_M3 = -mthumb -mcpu=cortex-m3
13-
CFLAGS = -I. -I$(PY_SRC) -Wall -ansi -std=gnu99 $(CFLAGS_CORTEX_M3) $(COPT)
13+
CFLAGS = -I. -I$(PY_SRC) -Wall -ansi -std=gnu99 $(CFLAGS_CORTEX_M3) $(COPT) \
14+
-flto -ffunction-sections -fdata-sections
1415

1516
#Debugging/Optimization
1617
ifeq ($(DEBUG), 1)
@@ -20,35 +21,33 @@ else
2021
COPT += -Os -DNDEBUG
2122
endif
2223

23-
#LDFLAGS = --nostdlib -T stm32f405.ld -Map=$(@:.elf=.map) --cref
24-
LDFLAGS = -lm -T generic-m-hosted.ld # -Map=$(@:.elf=.map) --cref
25-
LIBS =
26-
27-
# uncomment this if you want libgcc
28-
#LIBS += $(shell $(CC) -print-libgcc-file-name)
24+
## With CoudeSourcery it's actually a little different, you just need `-T generic-m-hosted.ld`.
25+
## Although for some reason `$(LD)` will not find that linker script, it works with `$(CC)`.
26+
## It turns out that this is specific to CoudeSourcery, and ARM version of GCC ships something
27+
## else instead and according to the following files, this is what we need to pass to `$(CC).
28+
## - gcc-arm-none-eabi-4_8-2014q1/share/gcc-arm-none-eabi/samples/src/makefile.conf
29+
## - gcc-arm-none-eabi-4_8-2014q1/share/gcc-arm-none-eabi/samples/src/qemu/Makefile
30+
LDFLAGS= --specs=nano.specs --specs=rdimon.specs -Wl,--gc-sections -Wl,-Map=$(@:.elf=.map)
2931

3032
SRC_C = \
31-
help.c \
32-
math.c \
33-
34-
#gccollect.c \
35-
#pyexec.c \
33+
main.c \
3634

3735
SRC_S = \
38-
gchelper.s \
3936

4037
OBJ =
4138
OBJ += $(PY_O)
4239
OBJ += $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
4340
OBJ += $(addprefix $(BUILD)/, $(SRC_S:.s=.o))
4441

45-
all: $(BUILD)/flash.elf
42+
all: run
43+
44+
run: $(BUILD)/flash.elf
4645

47-
run:
4846
qemu-system-arm -cpu cortex-m3 -nographic -monitor null -serial null -semihosting -kernel $(BUILD)/flash.elf
4947

48+
## `$(LD)` doesn't seem to like `--specs` for some reason, but we can just use `$(CC)` here.
5049
$(BUILD)/flash.elf: $(OBJ)
51-
$(Q)$(CC) $(CFLAGS) $(LDFLAGS) main.c -o $@ $(OBJ) $(LIBS)
50+
$(Q)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJ) $(LIBS)
5251
$(Q)$(SIZE) $@
5352

5453
include ../py/mkrules.mk

cortex-m3-qemu/gccollect.c

Lines changed: 0 additions & 56 deletions
This file was deleted.

cortex-m3-qemu/gccollect.h

Lines changed: 0 additions & 17 deletions
This file was deleted.

cortex-m3-qemu/gchelper.s

Lines changed: 0 additions & 62 deletions
This file was deleted.

cortex-m3-qemu/help.c

Lines changed: 0 additions & 95 deletions
This file was deleted.

0 commit comments

Comments
 (0)