diff --git a/.vscode/settings.json b/.vscode/settings.json index 0ab8f97..8d5cb57 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -16,6 +16,7 @@ "stdexcept": "cpp", "streambuf": "cpp", "system_error": "cpp", - "tuple": "cpp" + "tuple": "cpp", + "main.h": "c" } } \ No newline at end of file diff --git a/numworks_port/build/main.bin b/numworks_port/build/main.bin index ff6161c..5f5d8c7 100755 Binary files a/numworks_port/build/main.bin and b/numworks_port/build/main.bin differ diff --git a/numworks_port/build/main.elf b/numworks_port/build/main.elf index 056273f..3e81d59 100755 Binary files a/numworks_port/build/main.elf and b/numworks_port/build/main.elf differ diff --git a/numworks_port/build/rt0.o b/numworks_port/build/rt0.o index 298d4c8..86c4d35 100644 Binary files a/numworks_port/build/rt0.o and b/numworks_port/build/rt0.o differ diff --git a/numworks_port/build/vector_table.o b/numworks_port/build/vector_table.o index b635bd6..95f70db 100644 Binary files a/numworks_port/build/vector_table.o and b/numworks_port/build/vector_table.o differ diff --git a/numworks_port/src/linker.ld b/numworks_port/src/linker.ld index c083a1a..b2e3544 100644 --- a/numworks_port/src/linker.ld +++ b/numworks_port/src/linker.ld @@ -2,7 +2,6 @@ /*ENTRY(reset_handler)*/ /* End of RAM / Start of stack */ /* (4KB SRAM) */ -_estack = 0x20262144; /* epsilon stuff */ STACK_SIZE = 32K; @@ -85,6 +84,13 @@ SECTIONS *(.rodata.*) } >FLASH + .init_array : { + . = ALIGN(4); + _init_array_start = .; + KEEP (*(.init_array*)) + _init_array_end = .; + } >FLASH + /* The 'data' section is space set aside in RAM for * things like variables, which can change. */ .data : { diff --git a/numworks_port/src/rt0.cpp b/numworks_port/src/rt0.cpp index 948a356..2d3ffee 100644 --- a/numworks_port/src/rt0.cpp +++ b/numworks_port/src/rt0.cpp @@ -1,5 +1,9 @@ #include "vector_table.h" #include +#include +#include "device/stm32f730xx.h" + +#define LED_PIN (4) // PC0 typedef void (*cxx_constructor)(); @@ -52,8 +56,19 @@ void __attribute__((noinline)) start() { size_t bssSectionLength = (&_bss_section_end_ram - &_bss_section_start_ram); memset_custom(&_bss_section_start_ram, 0, bssSectionLength); + // Enable the GPIOa and GPIOC peripheral in RCC. + RCC->AHB1ENR |= RCC_AHB1ENR_GPIOBEN ; + + // C0 is connected to the LED. + // It should be set to push-pull low-speed output. + GPIOB->MODER &= ~(0x3 << (LED_PIN*2)); + GPIOB->MODER |= (0x1 << (LED_PIN*2)); + GPIOB->OTYPER &= ~(1 << LED_PIN); + + GPIOB->ODR = (1 << LED_PIN); + while (0) { - /* code */ + GPIOB->ODR = (1 << LED_PIN); } } \ No newline at end of file diff --git a/numworks_port/src/vector_table.cpp b/numworks_port/src/vector_table.cpp index 8b875a9..948a363 100644 --- a/numworks_port/src/vector_table.cpp +++ b/numworks_port/src/vector_table.cpp @@ -1,5 +1,5 @@ #include "vector_table.h" -extern const void * _estack; +extern const void * _stack_start; /* Interrupt Service Routines are void->void functions */ typedef void(*ISR)(void); @@ -16,7 +16,7 @@ ISR InitialisationVector[INITIALISATION_VECTOR_SIZE] __attribute__((section(".isr_vector_table"))) __attribute__((used)) = { - (ISR)&_estack, // Stack start + (ISR)&_stack_start, // Stack start start, // Reset service routine, 0, // NMI service routine, 0, // HardFault service routine,