blue-pill: cleaning some stuff up

This commit is contained in:
Kyle Isom 2018-03-08 11:31:00 -08:00
parent 5734a63997
commit ca7eaec903
3 changed files with 29 additions and 12 deletions

View File

@ -15,6 +15,8 @@ CXX := $(ARMTC)-g++
LD := $(ARMTC)-ld LD := $(ARMTC)-ld
ARMSIZE := $(ARMTC)-size ARMSIZE := $(ARMTC)-size
OBJCOPY := $(ARMTC)-objcopy OBJCOPY := $(ARMTC)-objcopy
PAGER ?= less
OPENOCD ?= /usr/share/openocd
# compiler options # compiler options
CPUFLAGS := -mcpu=cortex-m3 -mthumb CPUFLAGS := -mcpu=cortex-m3 -mthumb
@ -26,8 +28,7 @@ LDLIBS := -lc -lnosys
# programmer options # programmer options
STARTMEM := 0x8000000 STARTMEM := 0x8000000
# targets ### build targets ###
.PHONY: all .PHONY: all
all: $(BIN) all: $(BIN)
@ -38,6 +39,11 @@ $(ELF): $(OBJS)
$(BIN): $(ELF) $(BIN): $(ELF)
$(OBJCOPY) -O binary $< $@ $(OBJCOPY) -O binary $< $@
.PHONY: clean
clean:
rm -f *.o *.bin *.elf *.d *.map
### programming targets ###
.PHONY: flash .PHONY: flash
flash: $(BIN) flash: $(BIN)
st-flash write $(BIN) $(STARTMEM) st-flash write $(BIN) $(STARTMEM)
@ -46,10 +52,22 @@ flash: $(BIN)
erase: erase:
st-flash erase st-flash erase
.PHONY: reset
reset:
st-flash reset
.PHONY: install .PHONY: install
install: erase flash install: erase flash reset
.PHONY: clean ### miscellaneous targets ###
clean: .PHONY: disass
rm -f *.o *.bin *.elf *.d *.map disass: $(ELF)
$(ARMTC)-objdump -D $(ELF) | $(PAGER)
.PHONY: dump
dump: $(ELF)
$(ARMTC)-objdump -D $(ELF) > $(TARGET).dump
.PHONY: ocd
ocd:
openocd -f $(OPENOCD)/scripts/interface/stlink-v2.cfg -f $(OPENOCD)/scripts/target/stm32f1x.cfg

View File

@ -10,7 +10,7 @@ main() {
GPIO_C->enable_clock(); GPIO_C->enable_clock();
GPIO_C->pin_mode(LED, true, OUTPUT_GPP, OUTPUT_MAX_2MHZ); GPIO_C->pin_mode(LED, true, OUTPUT_GPP, OUTPUT_MAX_2MHZ);
while(1) { while (true) {
GPIO_C->pin_clear(LED); GPIO_C->pin_clear(LED);
delay(LDELAY); delay(LDELAY);
GPIO_C->pin_set(LED); GPIO_C->pin_set(LED);

View File

@ -1,17 +1,17 @@
/* /*
* Startup code for the STM32F103-based blue pill board. * Startup code for the STM32F103-based blue pill board.
* *
* TODO: revisit stack pointer * The stack pointer is initialised to the top of the stack (which
* TODO: is the IRQv buffer actually needed right now? * grows downward), so I pointed it to the end of the SRAM (where the
* stack should be).
*/ */
.cpu cortex-m3 .cpu cortex-m3
.thumb .thumb
.globl vectors
vectors: vectors:
.align 2 .align 2
.long 0x20002000 /* best guess at stack pointer */ .long 0x20005000 /* stack pointer points to top of SRAM */
.long reset_handler /* reset handler */ .long reset_handler /* reset handler */
.long hang /* NMI handler */ .long hang /* NMI handler */
.long hang /* hard_fault_handler */ .long hang /* hard_fault_handler */
@ -30,7 +30,6 @@ vectors:
.thumb_func .thumb_func
hang: b . hang: b .
.thumb_func .thumb_func
reset_handler: reset_handler:
bl main bl main