Skip to content

Commit

Permalink
WIP: mkimage: rkspi: skip padding for socs no longer needing
Browse files Browse the repository at this point in the history
Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
  • Loading branch information
Kwiboo committed May 19, 2023
1 parent 8ee515a commit 7b42660
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tools/rkcommon.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,13 @@ bool rkcommon_is_header_v2(struct image_tool_params *params)
return (info->header_ver == RK_HEADER_V2);
}

bool rkcommon_need_spi_padding(struct image_tool_params *params)
{
struct spl_info *info = rkcommon_get_spl_info(params->imagename);

return (info->header_ver == RK_HEADER_V1);
}

static void do_sha256_hash(uint8_t *buf, uint32_t size, uint8_t *out)
{
sha256_context ctx;
Expand Down
8 changes: 8 additions & 0 deletions tools/rkcommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,12 @@ void rkcommon_rc4_encode_spl(void *buf, unsigned int offset, unsigned int size);
int rkcommon_vrec_header(struct image_tool_params *params,
struct image_type_params *tparams);

/**
* rkcommon_need_spi_padding() - check if spi padding is required
*
* Some socs bootrom only read the first 2KB of each 4KB page of spi flash.
* Return: true or false depending on spi padding being required.
*/
bool rkcommon_need_spi_padding(struct image_tool_params *params);

#endif
6 changes: 6 additions & 0 deletions tools/rkspi.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ static void rkspi_set_header(void *buf, struct stat *sbuf, int ifd,

rkcommon_set_header(buf, sbuf, ifd, params);

if (!rkcommon_need_spi_padding(params))
return;

/*
* Spread the image out so we only use the first 2KB of each 4KB
* region. This is a feature of the SPI format required by the Rockchip
Expand Down Expand Up @@ -62,6 +65,9 @@ static int rkspi_vrec_header(struct image_tool_params *params,
{
rkcommon_vrec_header(params, tparams);

if (!rkcommon_need_spi_padding(params))
return 0;

/*
* Converting to the SPI format (i.e. splitting each 4K page into two
* 2K subpages and then padding these 2K pages up to take a complete
Expand Down

0 comments on commit 7b42660

Please sign in to comment.