arm: working bootloader, example app
'make' will produce two outputs: - bootloader.elf to be loaded into the bitstream - app.bin to be loaded through the programmer Loading app.bin is as simple as: - reset the board - `python3 prog.py app.bin`
This commit is contained in:
23
arm/app_init.cc
Normal file
23
arm/app_init.cc
Normal file
@@ -0,0 +1,23 @@
|
||||
#include <cstdint>
|
||||
|
||||
extern "C" int main();
|
||||
extern uint32_t _bss_begin, _bss_end, _initial_stack_pointer;
|
||||
|
||||
__attribute__((section(".app_init")))
|
||||
void AppInit() {
|
||||
*(uint32_t*)(0x40000000) = 0;
|
||||
asm ("mov sp, %0"
|
||||
:
|
||||
: "r" (&_initial_stack_pointer)
|
||||
:
|
||||
);
|
||||
|
||||
// clear .bss
|
||||
for (uint32_t* ptr = &_bss_begin; ptr < &_bss_end; ptr++) {
|
||||
*ptr = 0;
|
||||
}
|
||||
|
||||
main();
|
||||
|
||||
while(true) {}
|
||||
}
|
||||
Reference in New Issue
Block a user