Skip to content

Commit

Permalink
Batter handle image which included V2X containter
Browse files Browse the repository at this point in the history
Check second container, if it is v2x containter
means image have 3 container, otherwise 2 containter

Signed-off-by: Frank Li <[email protected]>
  • Loading branch information
nxpfrankli committed Feb 19, 2020
1 parent 0b47f4d commit 1ecc47f
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 10 deletions.
2 changes: 1 addition & 1 deletion libuuu/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Config::Config()
{
push_back(ConfigItem("SDPS:", "MX8QXP", NULL, NXP_VID, 0x012F, 0x0002));
push_back(ConfigItem("SDPS:", "MX8QM", "MX8QXP", NXP_VID, 0x0129, 0x0002));
push_back(ConfigItem("SDPS:", "MX8DXL", "MX8DXL", NXP_VID, 0x0147));
push_back(ConfigItem("SDPS:", "MX8DXL", "MX8QXP", NXP_VID, 0x0147));
push_back(ConfigItem("SDPS:", "MX28", NULL, FSL_VID, 0x004f));
push_back(ConfigItem("SDPS:", "MX815", NULL, NXP_VID, 0x013E));
push_back(ConfigItem("SDPS:", "MX865", "MX815", NXP_VID, 0x0146));
Expand Down
24 changes: 19 additions & 5 deletions libuuu/rominfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ ROM_INFO g_RomInfo[] =
{ "MX7ULP", 0x2f018000, ROM_INFO_HID | ROM_INFO_HID_MX6 | ROM_INFO_HID_SKIP_DCD },
{ "MXRT106X", 0x1000, ROM_INFO_HID | ROM_INFO_HID_MX6 | ROM_INFO_HID_SKIP_DCD },
{ "MX8QXP", 0x0, ROM_INFO_HID | ROM_INFO_HID_NO_CMD | ROM_INFO_HID_UID_STRING },
{ "MX8DXL", 0x0, ROM_INFO_HID | ROM_INFO_HID_NO_CMD | ROM_INFO_HID_UID_STRING | ROM_INFO_3CONTAINER },
{ "MX28", 0x0, ROM_INFO_HID},
{ "MX815", 0x0, ROM_INFO_HID | ROM_INFO_HID_NO_CMD | ROM_INFO_HID_UID_STRING | ROM_INFO_HID_EP1 | ROM_INFO_HID_PACK_SIZE_1020 },
{ "SPL", 0x0, ROM_INFO_HID | ROM_INFO_HID_MX6 | ROM_INFO_SPL_JUMP | ROM_INFO_HID_SDP_NO_MAX_PER_TRANS},
Expand Down Expand Up @@ -115,6 +114,9 @@ struct rom_bootimg {
uint8_t iv[IV_MAX_LEN];
};


#define IMG_V2X 0x0B

#pragma pack ()

inline uint32_t round_up(uint32_t x, uint32_t align)
Expand All @@ -123,17 +125,29 @@ inline uint32_t round_up(uint32_t x, uint32_t align)
return (x + mask) & ~mask;
}

size_t GetContainerActualSize(shared_ptr<FileBuffer> p, size_t offset, int numofcontainer)
size_t GetContainerActualSize(shared_ptr<FileBuffer> p, size_t offset)
{
struct rom_container *hdr;
int cindex = 1;

int cindex = numofcontainer - 1;

hdr = (struct rom_container *)(p->data() + offset + cindex * CONTAINER_HDR_ALIGNMENT);
hdr = (struct rom_container *)(p->data() + offset + CONTAINER_HDR_ALIGNMENT);
if (hdr->tag != CONTAINER_TAG)
return p->size() - offset;

struct rom_bootimg *image;

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

if ((image->flags & 0xF) == IMG_V2X)
{
cindex = 2;
hdr = (struct rom_container *)(p->data() + offset + cindex * CONTAINER_HDR_ALIGNMENT);
if (hdr->tag != CONTAINER_TAG)
return p->size() - offset;
}

image = (struct rom_bootimg *)(p->data() + offset + cindex * CONTAINER_HDR_ALIGNMENT
+ sizeof(struct rom_container)
+ sizeof(struct rom_bootimg) * (hdr->num_images - 1));
Expand Down
3 changes: 1 addition & 2 deletions libuuu/rominfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
#define ROM_INFO_HID_PACK_SIZE_1020 0x2000
#define ROM_INFO_HID_SDP_NO_MAX_PER_TRANS 0x4000
#define ROM_INFO_AUTO_SCAN_UBOOT_POS 0x8000
#define ROM_INFO_3CONTAINER 0x10000

#include <stdint.h>
#include <stddef.h>
Expand All @@ -61,5 +60,5 @@ struct ROM_INFO
ROM_INFO * search_rom_info(const char *s);
ROM_INFO * search_rom_info(ConfigItem *item);

size_t GetContainerActualSize(shared_ptr<FileBuffer> p, size_t offset, int numofcontainer );
size_t GetContainerActualSize(shared_ptr<FileBuffer> p, size_t offset);
size_t GetFlashHeaderSize(shared_ptr<FileBuffer> p, size_t offset = 0);
2 changes: 1 addition & 1 deletion libuuu/sdp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ int SDPWriteCmd::run(CmdCtx*ctx)
}
else
{
offset += GetContainerActualSize(fbuff, offset, rom->flags & ROM_INFO_3CONTAINER? 3: 2);
offset += GetContainerActualSize(fbuff, offset);
}

if (offset >= fbuff->size())
Expand Down
2 changes: 1 addition & 1 deletion libuuu/sdps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ int SDPSCmd::run(CmdCtx *pro)
return -1;
}

size_t sz = GetContainerActualSize(p, offset, rom->flags & ROM_INFO_3CONTAINER ? 3 : 2);
size_t sz = GetContainerActualSize(p, offset);

if (!(rom->flags & ROM_INFO_HID_NO_CMD))
{
Expand Down

0 comments on commit 1ecc47f

Please sign in to comment.