blob: d36fb2f643f6d71ccc219cda556a4748252d0aa2 [file] [log] [blame]
// Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
#include "bootstrap.h"
#include "common.h"
#include "flash_ctrl.h"
#include "gpio.h"
#include "spi_device.h"
#include "uart.h"
// Choose a "standard" baud rate to make it possible to use stty/screen directly
#if defined(SIMULATION)
const unsigned long UART_BAUD_RATE = 9600;
#else
const unsigned long UART_BAUD_RATE = 230400;
#endif
static inline void try_launch(void) {
__asm__ volatile(
"la a0, _flash_start;"
"la sp, _stack_start;"
"jr a0;"
:
:
:);
}
int main(int argc, char **argv) {
uart_init(UART_BAUD_RATE);
int rv = bootstrap();
if (rv) {
uart_send_str("Bootstrap failed with status code: ");
uart_send_uint(rv, 32);
uart_send_str("\r\n");
// Currently the only way to recover is by a hard reset.
return rv;
}
uart_send_str("Jump!\r\n");
while (!uart_tx_empty()) {
}
try_launch();
}