synth/arm/main.cc
Paul Mathieu b8b0d94065 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`
2022-05-10 11:20:02 -07:00

33 lines
515 B
C++

#include "gpio.h"
namespace {
[[maybe_unused]]
void sleep(int ms) {
for (int i = 0; i < ms; i++) {
// sleep for 1 ms
for (int j = 0; j < 22000; j++) {
asm("");
}
}
}
} // namespace
extern "C" int main() {
uint8_t cnt = 0;
for (int i = 0; i < 256; i++) {
gpio0->data = cnt;
cnt++;
sleep(125);
}
auto* airc = reinterpret_cast<volatile uint32_t*>(0xe000ed0c);
uint32_t a = *airc;
*airc = a | 0x04;
while (1) {}
}