blue-pill: convert blinky to startup.s boot.
This commit is contained in:
parent
244153679d
commit
524f860331
|
@ -1,5 +1,5 @@
|
||||||
# configurables
|
# configurables
|
||||||
OBJS :=
|
OBJS := startup.o
|
||||||
TARGET := blinky
|
TARGET := blinky
|
||||||
OBJS += $(TARGET).o
|
OBJS += $(TARGET).o
|
||||||
|
|
||||||
|
@ -9,9 +9,9 @@ BIN := $(TARGET).bin
|
||||||
|
|
||||||
# toolchain setup
|
# toolchain setup
|
||||||
ARMTC := arm-none-eabi
|
ARMTC := arm-none-eabi
|
||||||
ARMCC := $(ARMTC)-gcc
|
CC := $(ARMTC)-gcc
|
||||||
CC := $(ARMCC)
|
LD := $(ARMTC)-gcc
|
||||||
LD := $(ARMCC)
|
AS := $(ARMTC)-as
|
||||||
ARMSIZE := $(ARMTC)-size
|
ARMSIZE := $(ARMTC)-size
|
||||||
OBJCOPY := $(ARMTC)-objcopy
|
OBJCOPY := $(ARMTC)-objcopy
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ STARTMEM := 0x8000000
|
||||||
all: $(BIN)
|
all: $(BIN)
|
||||||
|
|
||||||
$(ELF): $(OBJS)
|
$(ELF): $(OBJS)
|
||||||
$(ARMCC) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS)
|
$(CC) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS)
|
||||||
$(ARMSIZE) $@
|
$(ARMSIZE) $@
|
||||||
|
|
||||||
.PHONY: strip
|
.PHONY: strip
|
||||||
|
|
|
@ -19,7 +19,9 @@ led_on() {
|
||||||
set_pin(GPIO_C, LED_PIN);
|
set_pin(GPIO_C, LED_PIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
void __attribute__ ((weak, naked)) reset_handler(void) {
|
int
|
||||||
|
main(void)
|
||||||
|
{
|
||||||
*RCC |= (1 << 4); /* enable port C clock */
|
*RCC |= (1 << 4); /* enable port C clock */
|
||||||
output_mode(GPIO_C, LED_PIN, OUTPUT_GPP, OUTPUT_MAX_2MHZ);
|
output_mode(GPIO_C, LED_PIN, OUTPUT_GPP, OUTPUT_MAX_2MHZ);
|
||||||
|
|
||||||
|
@ -35,22 +37,3 @@ void __attribute__ ((weak, naked)) reset_handler(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__ ((section(".vectors")))
|
|
||||||
struct {
|
|
||||||
unsigned int *initial_sp_value;
|
|
||||||
void (*reset)(void);
|
|
||||||
void (*nmi)(void);
|
|
||||||
void (*hard_fault)(void);
|
|
||||||
void (*memory_manage_fault)(void);
|
|
||||||
void (*bus_fault)(void);
|
|
||||||
void (*usage_fault)(void);
|
|
||||||
void (*reserved_x001c[4])(void);
|
|
||||||
void (*sv_call)(void);
|
|
||||||
void (*debug_monitor)(void);
|
|
||||||
void (*reserved_x0034)(void);
|
|
||||||
void (*pend_sv)(void);
|
|
||||||
void (*systick)(void);
|
|
||||||
void (*irq[68])(void);
|
|
||||||
} vector_table = {
|
|
||||||
.reset = reset_handler,
|
|
||||||
};
|
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
/*
|
||||||
|
* Startup code for the STM32F103-based blue pill board.
|
||||||
|
*
|
||||||
|
* TODO: revisit stack pointer
|
||||||
|
* TODO: is the IRQv buffer actually needed right now?
|
||||||
|
*/
|
||||||
|
|
||||||
|
.globl vectors
|
||||||
|
vectors:
|
||||||
|
.align 2
|
||||||
|
.long 0x100 /* best guess at stack pointer */
|
||||||
|
.long reset_handler /* reset handler */
|
||||||
|
.long 0 /* NMI handler */
|
||||||
|
.long 0 /* hard_fault_handler */
|
||||||
|
.long 0 /* memory management handler */
|
||||||
|
.long 0 /* bus fault handler */
|
||||||
|
.long 0 /* usage fault handler */
|
||||||
|
.skip 0x20 /* reserved */
|
||||||
|
.long 0 /* svcall handler */
|
||||||
|
.long 0 /* debug handler */
|
||||||
|
.skip 4 /* reserved */
|
||||||
|
.long 0 /* pendsv handler */
|
||||||
|
.long 0 /* systick handler */
|
||||||
|
.skip 0xf4 /* remaining / IRQ vectors */
|
||||||
|
|
||||||
|
.globl reset_handler
|
||||||
|
reset_handler:
|
||||||
|
bl main
|
Loading…
Reference in New Issue