Skip to content

Commit

Permalink
support v2x container for imx943
Browse files Browse the repository at this point in the history
V2X container use difference tag at imx943.
Update code to get correct SPL size for imx943's boot image.

Signed-off-by: Frank Li <frank.li@nxp.com>
  • Loading branch information
nxpfrankli committed Jan 9, 2025
1 parent 03f16e5 commit e926f83
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions libuuu/rominfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ const ROM_INFO * search_rom_info(const ConfigItem *item)
#define CONTAINER_HDR_ALIGNMENT 0x400
#define CONTAINER_HDR_ALIGNMENT_V2 0x4000
static constexpr uint8_t CONTAINER_TAG = 0x87;
static constexpr uint8_t V2X_TAG = 0x82; // After imx943

#pragma pack (1)
struct rom_container {
Expand Down Expand Up @@ -130,6 +131,7 @@ static constexpr uint32_t IMG_V2X = 0x0B;
size_t GetContainerActualSize(shared_ptr<DataBuffer> p, size_t offset, bool bROMAPI, bool skipspl)
{
uint32_t align = CONTAINER_HDR_ALIGNMENT;
unsigned int cindex = 1;

if(bROMAPI)
return p->size() - offset;
Expand All @@ -142,30 +144,33 @@ size_t GetContainerActualSize(shared_ptr<DataBuffer> p, size_t offset, bool bROM
else if (hdr->version >= 2)
{ /* after imx943 align change to 0x4000 from 0x400 */
align = CONTAINER_HDR_ALIGNMENT_V2;
hdr = reinterpret_cast<struct rom_container*>(p->data() + offset + align);
if (hdr->tag == V2X_TAG)
cindex++;
}

hdr = reinterpret_cast<struct rom_container *>(p->data() + offset + align);
if (hdr->tag != CONTAINER_TAG)
{
return p->size() - offset;
}

/* Check if include V2X container*/
auto image = reinterpret_cast<struct rom_bootimg *>(p->data() + offset + align
+ sizeof(struct rom_container));

unsigned int cindex = 1;
if ((image->flags & 0xF) == IMG_V2X)
else
{
cindex = 2;
hdr = reinterpret_cast<struct rom_container *>(p->data() + offset + cindex * align);
hdr = reinterpret_cast<struct rom_container*>(p->data() + offset + align);
if (hdr->tag != CONTAINER_TAG)
{
{
return p->size() - offset;
}

/* Check if include V2X container*/
auto image = reinterpret_cast<struct rom_bootimg*>(p->data() + offset + align
+ sizeof(struct rom_container));

if ((image->flags & 0xF) == IMG_V2X)
cindex++;
}

hdr = reinterpret_cast<struct rom_container*>(p->data() + offset + cindex * align);
if (hdr->tag != CONTAINER_TAG)
{
return p->size() - offset;
}

image = reinterpret_cast<struct rom_bootimg *>(p->data() + offset + cindex * align
auto image = reinterpret_cast<struct rom_bootimg *>(p->data() + offset + cindex * align
+ sizeof(struct rom_container)
+ sizeof(struct rom_bootimg) * (hdr->num_images - 1));

Expand Down

0 comments on commit e926f83

Please sign in to comment.