mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-09 13:12:37 -05:00
multiboot: Add v1 boot protocol
v1 passes the drive and partition number of the boot volume instead of using the volume number. The volume number isn't reliable because the same filesystem might get a different volume number once the firmware is loaded, which will cause the firmware to use the wrong root volume and fail to locate the correct .rockbox directory. Using drive and partition numbers avoids this issue because drive numbering is fixed and determined by the target. Change-Id: I7e68b892d9424a1f686197a6122e139b438e5f7e
This commit is contained in:
parent
6ffd42548b
commit
dc9d354ed2
6 changed files with 99 additions and 12 deletions
|
|
@ -42,6 +42,20 @@ static bool verify_boot_data_v0(void)
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool verify_boot_data_v1(void) INIT_ATTR;
|
||||
static bool verify_boot_data_v1(void)
|
||||
{
|
||||
/* validate protocol version */
|
||||
if (boot_data.version != 1)
|
||||
return false;
|
||||
|
||||
/* validate length */
|
||||
if (boot_data.length != 4)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
struct verify_bd_entry
|
||||
{
|
||||
int version;
|
||||
|
|
@ -50,6 +64,7 @@ struct verify_bd_entry
|
|||
|
||||
static const struct verify_bd_entry verify_bd[] INITDATA_ATTR = {
|
||||
{ 0, verify_boot_data_v0 },
|
||||
{ 1, verify_boot_data_v1 },
|
||||
};
|
||||
|
||||
void verify_boot_data(void)
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
#include "crc32.h"
|
||||
#include "loader_strerror.h"
|
||||
#include "file.h"
|
||||
#include "disk.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
|
@ -30,10 +31,20 @@ static void write_bootdata_v0(struct boot_data_t *data, unsigned int boot_volume
|
|||
{
|
||||
memset(data->payload, data->length, 0);
|
||||
|
||||
data->boot_volume = boot_volume;
|
||||
data->_boot_volume = boot_volume;
|
||||
data->version = 0;
|
||||
}
|
||||
|
||||
static void write_bootdata_v1(struct boot_data_t *data, unsigned int boot_volume)
|
||||
{
|
||||
memset(data->payload, data->length, 0);
|
||||
|
||||
data->_boot_volume = 0xff;
|
||||
data->version = 1;
|
||||
data->boot_drive = volume_drive(boot_volume);
|
||||
data->boot_partition = volume_partition(boot_volume);
|
||||
}
|
||||
|
||||
/* Write bootdata into location in FIRMWARE marked by magic header
|
||||
* Assumes buffer is already loaded with the firmware image
|
||||
* We just need to find the location and write data into the
|
||||
|
|
@ -68,6 +79,8 @@ bool write_bootdata(unsigned char* buf, int len, unsigned int boot_volume)
|
|||
/* Write boot data according to the selected protocol */
|
||||
if (proto_version == 0)
|
||||
write_bootdata_v0(data, boot_volume);
|
||||
else if (proto_version == 1)
|
||||
write_bootdata_v1(data, boot_volume);
|
||||
else
|
||||
break;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue