From ede9bee7f22fd5d0e1bacb7689f1cac23992b70b Mon Sep 17 00:00:00 2001 From: Josh Rahm Date: Fri, 15 Nov 2024 02:48:27 -0700 Subject: UART is working. --- src/init.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/init.c') diff --git a/src/init.c b/src/init.c index 30e2c6d..5753a13 100644 --- a/src/init.c +++ b/src/init.c @@ -5,7 +5,7 @@ void on_reset(void); -void __attribute__((weak, interrupt, __section__(".isr_vector"))) +void __attribute__((weak, interrupt, __section__(".isr_vector.routines"))) default_irq_handler(void) { return; @@ -13,7 +13,7 @@ default_irq_handler(void) #define WEAK_IRQ(irq) \ void __attribute__(( \ - weak, alias("default_irq_handler"), __section__(".isr_vector"))) \ + weak, alias("default_irq_handler"), __section__(".isr_vector.routines"))) \ irq(void) WEAK_IRQ(irq_on_reset); @@ -60,7 +60,9 @@ extern uint32_t BSS_STOP; static inline void set_mtvec(void* vector_table) { - asm volatile("csrw mtvec, %0" : : "r"(vector_table)); + uint32_t mtvec = (uint32_t) vector_table; + mtvec |= 1; // Set interrupt table mode to "VECTORED" + asm volatile("csrw mtvec, %0" : : "r"(mtvec)); } /* @@ -99,7 +101,7 @@ extern void main(void); /* Start function. Responsible for initializing the system and jumping to the * main function. */ -static void start(void) +static __attribute((__section__(".sinit.1"))) void start(void) { /* Initialize the data segments. */ init_data_segments(); @@ -113,7 +115,7 @@ static void start(void) * The reset callback.This has to be a naked function because the stack pointer * may not be initialized!!. */ -__attribute((naked, __section__(".isr_routines.on_reset"))) void on_reset(void) +__attribute((naked, __section__(".sinit"))) void _begin(void) { // Set up the stack pointer to point to the end of SRAM. asm volatile( -- cgit