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
ARMSIZE := $(ARMTC)-size
OBJCOPY := $(ARMTC)-objcopy
PAGER ?= less
OPENOCD ?= /usr/share/openocd
# compiler options
CPUFLAGS := -mcpu=cortex-m3 -mthumb
@ -26,8 +28,7 @@ LDLIBS := -lc -lnosys
# programmer options
STARTMEM := 0x8000000
# targets
### build targets ###
.PHONY: all
all: $(BIN)
@ -38,6 +39,11 @@ $(ELF): $(OBJS)
$(BIN): $(ELF)
$(OBJCOPY) -O binary $< $@
.PHONY: clean
clean:
rm -f *.o *.bin *.elf *.d *.map
### programming targets ###
.PHONY: flash
flash: $(BIN)
st-flash write $(BIN) $(STARTMEM)
@ -46,10 +52,22 @@ flash: $(BIN)
erase:
st-flash erase
.PHONY: reset
reset:
st-flash reset
.PHONY: install
install: erase flash
install: erase flash reset
.PHONY: clean
clean:
rm -f *.o *.bin *.elf *.d *.map
### miscellaneous targets ###
.PHONY: disass
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->pin_mode(LED, true, OUTPUT_GPP, OUTPUT_MAX_2MHZ);
while(1) {
while (true) {
GPIO_C->pin_clear(LED);
delay(LDELAY);
GPIO_C->pin_set(LED);

View File

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