Merge pull request #557 from antmicro/mor1kx_linux_booting

bios: boot: Boot linux on mor1kx with external device tree and rootfs
This commit is contained in:
enjoy-digital 2020-06-02 15:45:52 +02:00 committed by GitHub
commit 47bb3d7990
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 40 additions and 1 deletions

View File

@ -233,7 +233,7 @@ int serialboot(void)
return 1; return 1;
} }
#if defined(CONFIG_CPU_TYPE_VEXRISCV) && defined(CONFIG_CPU_VARIANT_LINUX) #if defined(CONFIG_CPU_VARIANT_LINUX)
#ifndef KERNEL_IMAGE_RAM_OFFSET #ifndef KERNEL_IMAGE_RAM_OFFSET
#define KERNEL_IMAGE_RAM_OFFSET 0x00000000 #define KERNEL_IMAGE_RAM_OFFSET 0x00000000
@ -286,6 +286,35 @@ const char *filename, char *buffer)
static const unsigned char macadr[6] = {0x10, 0xe2, 0xd5, 0x00, 0x00, 0x00}; static const unsigned char macadr[6] = {0x10, 0xe2, 0xd5, 0x00, 0x00, 0x00};
#if defined(CONFIG_CPU_TYPE_MOR1KX) && defined(CONFIG_CPU_VARIANT_LINUX)
static int try_get_kernel_rootfs_dtb(unsigned int ip, unsigned short tftp_port)
{
unsigned long tftp_dst_addr;
int size;
tftp_dst_addr = MAIN_RAM_BASE + KERNEL_IMAGE_RAM_OFFSET;
size = tftp_get_v(ip, tftp_port, "Image", (void *)tftp_dst_addr);
if (size <= 0) {
printf("Network boot failed\n");
return 0;
}
tftp_dst_addr = MAIN_RAM_BASE + DEVICE_TREE_IMAGE_RAM_OFFSET;
size = tftp_get_v(ip, tftp_port, "mor1kx.dtb", (void *)tftp_dst_addr);
if(size <= 0) {
printf("No mor1kx.dtb found\n");
return 0;
}
tftp_dst_addr = MAIN_RAM_BASE + ROOTFS_IMAGE_RAM_OFFSET;
size = tftp_get_v(ip, tftp_port, "rootfs.cpio", (void *)tftp_dst_addr);
if(size <= 0) {
printf("No rootfs.cpio found (optional)\n");
}
return 1;
}
#endif
#if defined(CONFIG_CPU_TYPE_VEXRISCV) && defined(CONFIG_CPU_VARIANT_LINUX) #if defined(CONFIG_CPU_TYPE_VEXRISCV) && defined(CONFIG_CPU_VARIANT_LINUX)
static int try_get_kernel_rootfs_dtb_emulator(unsigned int ip, unsigned short tftp_port) static int try_get_kernel_rootfs_dtb_emulator(unsigned int ip, unsigned short tftp_port)
@ -351,6 +380,16 @@ void netboot(void)
} }
printf("Unable to download Linux images, falling back to boot.bin\n"); printf("Unable to download Linux images, falling back to boot.bin\n");
#endif #endif
#if defined(CONFIG_CPU_TYPE_MOR1KX) && defined(CONFIG_CPU_VARIANT_LINUX)
if(try_get_kernel_rootfs_dtb(ip, tftp_port))
{
boot(MAIN_RAM_BASE + DEVICE_TREE_IMAGE_RAM_OFFSET, 0, 0, MAIN_RAM_BASE);
return;
}
printf("Unable to download Linux images, falling back to boot.bin\n");
#endif
tftp_dst_addr = MAIN_RAM_BASE; tftp_dst_addr = MAIN_RAM_BASE;
size = tftp_get_v(ip, tftp_port, "boot.bin", (void *)tftp_dst_addr); size = tftp_get_v(ip, tftp_port, "boot.bin", (void *)tftp_dst_addr);
if (size <= 0) { if (size <= 0) {