bios: Add boot command to be able to boot directly from system memory.

This is useful for un-usual boot sequences where the binaries are not
loaded directly by the BIOS but externally (over a bridge for example).

Example of use:
$litex_sim
$litex_bare_metal_demo --build-path=build/sim
$litex_sim --ram-init=demo.bin

Press Esc during the LiteX boot.

litex> help

LiteX BIOS, available commands:

flush_cpu_dcache         - Flush CPU data cache
crc                      - Compute CRC32 of a part of the address space
ident                    - Identifier of the system
help                     - Print this help

serialboot               - Boot from Serial (SFL)
romboot                  - Boot from ROM
reboot                   - Reboot
boot                     - Boot from Memory

mem_speed                - Test memory speed
mem_test                 - Test memory access
mem_copy                 - Copy address space
mem_write                - Write address space
mem_read                 - Read address space
mem_list                 - List available memory regions


litex>
litex> mem_list
Available memory regions:
ROM       0x00000000 0x8000
SRAM      0x01000000 0x2000
MAIN_RAM  0x40000000 0x10000000
CSR       0x82000000 0x10000

litex>
litex> boot 0x40000000
Executing booted program at 0x40000000

--============= Liftoff! ===============--

LiteX minimal demo app built Feb 24 2021 11:30:05

Available commands:
help               - Show this command
reboot             - Reboot CPU
donut              - Spinning Donut demo
litex-demo-app>
This commit is contained in:
Florent Kermarrec 2021-02-24 11:40:40 +01:00
parent c18ea700cc
commit 80bd4ac4ec
3 changed files with 55 additions and 1 deletions

View file

@ -48,7 +48,7 @@
extern void boot_helper(unsigned long r1, unsigned long r2, unsigned long r3, unsigned long addr);
static void __attribute__((noreturn)) boot(unsigned long r1, unsigned long r2, unsigned long r3, unsigned long addr)
void __attribute__((noreturn)) boot(unsigned long r1, unsigned long r2, unsigned long r3, unsigned long addr)
{
printf("Executing booted program at 0x%08lx\n\n", addr);
printf("--============= \e[1mLiftoff!\e[0m ===============--\n");

View file

@ -4,6 +4,8 @@
void set_local_ip(const char * ip_address);
void set_remote_ip(const char * ip_address);
void set_mac_addr(const char * mac_address);
void __attribute__((noreturn)) boot(unsigned long r1, unsigned long r2, unsigned long r3, unsigned long addr);
int serialboot(void);
void netboot(void);
void flashboot(void);

View file

@ -9,6 +9,58 @@
#include "../helpers.h"
#include "../boot.h"
/**
* Command "boot"
*
* Boot software from system memory
*
*/
static void boot_handler(int nb_params, char **params)
{
char *c;
unsigned long addr;
unsigned long r1;
unsigned long r2;
unsigned long r3;
if (nb_params < 1) {
printf("boot <address> [r1] [r2] [r3]");
return;
}
addr = strtoul(params[0], &c, 0);
if (*c != 0) {
printf("Incorrect address");
return;
}
r1 = 0;
if (nb_params > 1) {
r1 = strtoul(params[1], &c, 0);
if (*c != 0) {
printf("Incorrect r1");
return;
}
}
r2 = 0;
if (nb_params > 2) {
r2 = strtoul(params[2], &c, 0);
if (*c != 0) {
printf("Incorrect r2");
return;
}
}
r3 = 0;
if (nb_params > 3) {
r2 = strtoul(params[3], &c, 0);
if (*c != 0) {
printf("Incorrect r3");
return;
}
}
boot(r1, r2, r3, addr);
}
define_command(boot, boot_handler, "Boot from Memory", BOOT_CMDS);
/**
* Command "reboot"
*