mirror of https://github.com/wolfSSL/wolfBoot.git
fsp: remove WOLFBOOT_FIXED_PARTITIONS (and hardcoded size limit)
now the size of the image is limited by the available memory only. The image is loaded in RAM just after wolfboot.pull/365/head
parent
d88315c801
commit
e24c372777
|
@ -6,8 +6,7 @@ HASH=SHA384
|
||||||
DEBUG=1
|
DEBUG=1
|
||||||
SPMATH=1
|
SPMATH=1
|
||||||
ENCRYPTION=0
|
ENCRYPTION=0
|
||||||
WOLFBOOT_FIXED_PARTITIONS=1
|
WOLFBOOT_NO_PARTITIONS=1
|
||||||
WOLFBOOT_PARTITION_SIZE=0x4000000
|
|
||||||
FORCE_32BIT=1
|
FORCE_32BIT=1
|
||||||
|
|
||||||
# 4gb - 12mb (BIOS Region size)
|
# 4gb - 12mb (BIOS Region size)
|
||||||
|
|
|
@ -7,8 +7,7 @@ DEBUG=1
|
||||||
SPMATH=1
|
SPMATH=1
|
||||||
FORCE_32BIT=1
|
FORCE_32BIT=1
|
||||||
ENCRYPTION=0
|
ENCRYPTION=0
|
||||||
WOLFBOOT_FIXED_PARTITIONS=1
|
WOLFBOOT_NO_PARTITIONS=1
|
||||||
WOLFBOOT_PARTITION_SIZE=0x8000000
|
|
||||||
WOLFTPM=0
|
WOLFTPM=0
|
||||||
|
|
||||||
# TPM Keystore options
|
# TPM Keystore options
|
||||||
|
|
|
@ -7,8 +7,7 @@ DEBUG=1
|
||||||
SPMATH=1
|
SPMATH=1
|
||||||
FORCE_32BIT=1
|
FORCE_32BIT=1
|
||||||
ENCRYPTION=0
|
ENCRYPTION=0
|
||||||
WOLFBOOT_FIXED_PARTITIONS=1
|
WOLFBOOT_NO_PARTITIONS=1
|
||||||
WOLFBOOT_PARTITION_SIZE=0x8000000
|
|
||||||
WOLFTPM=0
|
WOLFTPM=0
|
||||||
|
|
||||||
# TPM Keystore options
|
# TPM Keystore options
|
||||||
|
|
|
@ -7,8 +7,7 @@ DEBUG=1
|
||||||
SPMATH=1
|
SPMATH=1
|
||||||
FORCE_32BIT=1
|
FORCE_32BIT=1
|
||||||
ENCRYPTION=0
|
ENCRYPTION=0
|
||||||
WOLFBOOT_FIXED_PARTITIONS=1
|
WOLFBOOT_NO_PARTITIONS=1
|
||||||
WOLFBOOT_PARTITION_SIZE=0x8000000
|
|
||||||
WOLFTPM=1
|
WOLFTPM=1
|
||||||
|
|
||||||
# TPM Keystore options
|
# TPM Keystore options
|
||||||
|
|
|
@ -7,8 +7,7 @@ DEBUG=1
|
||||||
SPMATH=1
|
SPMATH=1
|
||||||
FORCE_32BIT=1
|
FORCE_32BIT=1
|
||||||
ENCRYPTION=0
|
ENCRYPTION=0
|
||||||
WOLFBOOT_FIXED_PARTITIONS=1
|
WOLFBOOT_NO_PARTITIONS=1
|
||||||
WOLFBOOT_PARTITION_SIZE=0x800000
|
|
||||||
WOLFTPM=1
|
WOLFTPM=1
|
||||||
|
|
||||||
# TPM Keystore options
|
# TPM Keystore options
|
||||||
|
|
|
@ -27,6 +27,7 @@ struct stage2_parameter {
|
||||||
#if WOLFBOOT_FSP
|
#if WOLFBOOT_FSP
|
||||||
uint32_t hobList;
|
uint32_t hobList;
|
||||||
uint32_t page_table;
|
uint32_t page_table;
|
||||||
|
uint32_t tolum;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -546,12 +546,17 @@ void start(uint32_t stack_base, uint32_t stack_top, uint64_t timestamp,
|
||||||
stage2_params->hobList = (uint32_t)hobList;
|
stage2_params->hobList = (uint32_t)hobList;
|
||||||
|
|
||||||
#ifdef WOLFBOOT_64BIT
|
#ifdef WOLFBOOT_64BIT
|
||||||
stage2_params->page_table = ((uint32_t)(stage2_params) -
|
stage2_params->page_table = ((uint32_t)(top_address) -
|
||||||
x86_paging_get_page_table_size());
|
x86_paging_get_page_table_size());
|
||||||
stage2_params->page_table = (((uint32_t)stage2_params->page_table) & ~((1 << 12) - 1));
|
stage2_params->page_table = (((uint32_t)stage2_params->page_table) & ~((1 << 12) - 1));
|
||||||
memset((uint8_t*)stage2_params->page_table, 0, x86_paging_get_page_table_size());
|
memset((uint8_t*)stage2_params->page_table, 0, x86_paging_get_page_table_size());
|
||||||
|
wolfBoot_printf("page table @ 0x%x [length: %x]" ENDLINE, (uint32_t)stage2_params->page_table, x86_paging_get_page_table_size());
|
||||||
|
top_address = stage2_params->page_table;
|
||||||
#endif /* WOLFBOOT_64BIT */
|
#endif /* WOLFBOOT_64BIT */
|
||||||
|
|
||||||
|
stage2_params->tolum = top_address;
|
||||||
|
|
||||||
|
|
||||||
/* change_stack_and_invoke() never returns.
|
/* change_stack_and_invoke() never returns.
|
||||||
*
|
*
|
||||||
* Execution here is eventually transferred to memory_ready_entry
|
* Execution here is eventually transferred to memory_ready_entry
|
||||||
|
|
|
@ -41,7 +41,9 @@
|
||||||
#include "hal.h"
|
#include "hal.h"
|
||||||
#include "spi_flash.h"
|
#include "spi_flash.h"
|
||||||
#include "printf.h"
|
#include "printf.h"
|
||||||
|
#include "stage1.h"
|
||||||
#include "wolfboot/wolfboot.h"
|
#include "wolfboot/wolfboot.h"
|
||||||
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <x86/common.h>
|
#include <x86/common.h>
|
||||||
#include <x86/ahci.h>
|
#include <x86/ahci.h>
|
||||||
|
@ -62,7 +64,9 @@
|
||||||
|
|
||||||
#define MAX_FAILURES 4
|
#define MAX_FAILURES 4
|
||||||
|
|
||||||
#define IMAGE_PRELOAD_ADDRESS 0x5000100
|
/* from the linker, where wolfBoot ends */
|
||||||
|
extern uint8_t _end_wb[];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief function for starting the boot process.
|
* @brief function for starting the boot process.
|
||||||
*
|
*
|
||||||
|
@ -72,6 +76,7 @@
|
||||||
*/
|
*/
|
||||||
void RAMFUNCTION wolfBoot_start(void)
|
void RAMFUNCTION wolfBoot_start(void)
|
||||||
{
|
{
|
||||||
|
struct stage2_parameter *stage2_params;
|
||||||
struct wolfBoot_image os_image;
|
struct wolfBoot_image os_image;
|
||||||
uint8_t p_hdr[IMAGE_HEADER_SIZE];
|
uint8_t p_hdr[IMAGE_HEADER_SIZE];
|
||||||
int pA_ver = 0, pB_ver = 0;
|
int pA_ver = 0, pB_ver = 0;
|
||||||
|
@ -110,14 +115,15 @@ void RAMFUNCTION wolfBoot_start(void)
|
||||||
|
|
||||||
wolfBoot_printf("Versions, A:%u B:%u\r\n", pA_ver, pB_ver);
|
wolfBoot_printf("Versions, A:%u B:%u\r\n", pA_ver, pB_ver);
|
||||||
|
|
||||||
|
|
||||||
if (pB_ver > pA_ver)
|
if (pB_ver > pA_ver)
|
||||||
selected = 1;
|
selected = 1;
|
||||||
else
|
else
|
||||||
selected = 0;
|
selected = 0;
|
||||||
|
|
||||||
load_address = (uint32_t *)(IMAGE_PRELOAD_ADDRESS - IMAGE_HEADER_SIZE);
|
stage2_params = stage2_get_parameters();
|
||||||
|
/* load the image just after wolfboot */
|
||||||
|
load_address = (uint32_t *)(_end_wb);
|
||||||
|
wolfBoot_printf("Load address %x\r\n", load_address);
|
||||||
do {
|
do {
|
||||||
failures++;
|
failures++;
|
||||||
if (selected)
|
if (selected)
|
||||||
|
@ -139,7 +145,14 @@ void RAMFUNCTION wolfBoot_start(void)
|
||||||
/* Dereference img_size from header */
|
/* Dereference img_size from header */
|
||||||
img_size = *( ((uint32_t *)p_hdr) + 1);
|
img_size = *( ((uint32_t *)p_hdr) + 1);
|
||||||
|
|
||||||
|
if (img_size >
|
||||||
|
((uint32_t)(stage2_params->tolum) - (uint32_t)(uintptr_t)load_address)) {
|
||||||
|
wolfBoot_printf("Image size %d doesn't fit in low memory\r\n", img_size);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/* Read the image into RAM */
|
/* Read the image into RAM */
|
||||||
|
wolfBoot_printf("Loading image from disk...");
|
||||||
load_off = 0;
|
load_off = 0;
|
||||||
do {
|
do {
|
||||||
ret = disk_read(BOOT_DISK, cur_part, load_off, 512,
|
ret = disk_read(BOOT_DISK, cur_part, load_off, 512,
|
||||||
|
@ -155,25 +168,30 @@ void RAMFUNCTION wolfBoot_start(void)
|
||||||
selected ^= 1;
|
selected ^= 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
wolfBoot_printf("done.\r\n");
|
||||||
ret = wolfBoot_open_image_address(&os_image, (void *)load_address);
|
ret = wolfBoot_open_image_address(&os_image, (void *)load_address);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
wolfBoot_printf("Error parsing loaded image\r\n");
|
wolfBoot_printf("Error parsing loaded image\r\n");
|
||||||
selected ^= 1;
|
selected ^= 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wolfBoot_printf("Checking image integrity...");
|
||||||
if (wolfBoot_verify_integrity(&os_image) != 0) {
|
if (wolfBoot_verify_integrity(&os_image) != 0) {
|
||||||
wolfBoot_printf("Error validating integrity for partition %c\r\n",
|
wolfBoot_printf("Error validating integrity for partition %c\r\n",
|
||||||
'A' + selected);
|
'A' + selected);
|
||||||
selected ^= 1;
|
selected ^= 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
wolfBoot_printf("done.\r\n");
|
||||||
|
wolfBoot_printf("Verifying image signature...");
|
||||||
if (wolfBoot_verify_authenticity(&os_image) != 0) {
|
if (wolfBoot_verify_authenticity(&os_image) != 0) {
|
||||||
wolfBoot_printf("Error validating authenticity for partition %c\r\n",
|
wolfBoot_printf("Error validating authenticity for partition %c\r\n",
|
||||||
'A' + selected);
|
'A' + selected);
|
||||||
selected ^= 1;
|
selected ^= 1;
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
|
wolfBoot_printf("done.\r\n");
|
||||||
failures = 0;
|
failures = 0;
|
||||||
break; /* Success case */
|
break; /* Success case */
|
||||||
}
|
}
|
||||||
|
@ -183,8 +201,8 @@ void RAMFUNCTION wolfBoot_start(void)
|
||||||
panic();
|
panic();
|
||||||
}
|
}
|
||||||
|
|
||||||
wolfBoot_printf("Firmware Valid\n");
|
wolfBoot_printf("Firmware Valid.\r\n");
|
||||||
wolfBoot_printf("Booting at %08lx\n", IMAGE_PRELOAD_ADDRESS);
|
wolfBoot_printf("Booting at %08lx\r\n", os_image.fw_base);
|
||||||
hal_prepare_boot();
|
hal_prepare_boot();
|
||||||
do_boot((uint32_t*)os_image.fw_base);
|
do_boot((uint32_t*)os_image.fw_base);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue