imxtools: rework sb file production

The old code had some annoying way of dealing with padding by adding explicit
instructions to the stream, which is 1) ugly 2) not in par with freescale
tools. The trick, which this new version implements, is to put the useful length
of the section in the section header, and the actual (with padding) length in
the boot tag. This way the tools can just ignore padding instruction by
reading the section header, and the bootloader can still load the image because
it uses the boot tags.
Also correctly handle the case where the first section does not start right
after the header (there is a bug in freescale tools for this case by the way).
There is an ambiguity in the way the padding instructions should be encrypted:
the bootloader should logically treat them as regular instruction of the section
stream, but it appears the freescale tools do not generate them as part of the
stream and instead encrypt them like boot tags, which is stupid because there
is no way the bootloader could decrypt them, and anyway we don't care because
the bootloader doesn't decrypt them at all.

Change-Id: Iabdc1d1f9f82d374779bf03efb75c2c3998f5b5d
This commit is contained in:
Amaury Pouly 2017-01-01 20:46:16 +01:00
parent 4f7fea2add
commit 2df6b1fc43
2 changed files with 82 additions and 73 deletions

View file

@ -195,7 +195,8 @@ struct sb_section_t
struct sb_inst_t *insts;
/* for production use */
uint32_t file_offset; /* in blocks */
uint32_t sec_size; /* in blocks */
uint32_t sec_size; /* in blocks, without padding */
uint32_t pad_size; /* padding size after the section until next section */
};
struct sb_file_t
@ -217,6 +218,7 @@ struct sb_file_t
struct sb_version_t product_ver;
struct sb_version_t component_ver;
/* for production use */
int first_boot_sec; /* index in sections[] */
uint32_t image_size; /* in blocks */
};