diff options
author | Jack Rosenthal <jrosenth@chromium.org> | 2021-06-29 18:01:00 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-06-30 15:38:04 +0000 |
commit | 9ff5d3c2286c7d9c1c1219f5cc51546998847861 (patch) | |
tree | ab3170e26386924bee21d36b28fd9b03f5ba9b3f | |
parent | 4ceafce3bcd0ab0592f1de227e660b6d4d7f1b75 (diff) | |
download | chrome-ec-9ff5d3c2286c7d9c1c1219f5cc51546998847861.tar.gz |
zephyr: implement ro/rw packing for hayato
The "npcx" packer in zmake was hard-coded for Nuvoton devices.
Restructure into a new packer, BinmanPacker, which makes no Nuvoton
assumptions, and subclass it for the NpcxPacker.
Note: there's some file size check here which was coded for Nuvoton
only. I think it's not actually necessary since binman already checks
to see if the region overflowed, and will error if it did. The best
thing to do here is to keep the existing behavior and evaluate if that
Nuvoton-only size check can just be removed from zmake.
BUG=b:192401039
BRANCH=none
TEST=zmake testall
TEST=inspected fmap of hayato image, note I don't have a device to
test on right now
Signed-off-by: Jack Rosenthal <jrosenth@chromium.org>
Change-Id: Ic45a030d0dd02451834161305f048487f7b273e4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2995602
Reviewed-by: Denis Brockus <dbrockus@chromium.org>
-rw-r--r-- | zephyr/include/cros/ite/it8xxx2.dtsi | 12 | ||||
-rw-r--r-- | zephyr/projects/asurada/hayato/zmake.yaml | 2 | ||||
-rw-r--r-- | zephyr/zmake/zmake/output_packers.py | 46 |
3 files changed, 48 insertions, 12 deletions
diff --git a/zephyr/include/cros/ite/it8xxx2.dtsi b/zephyr/include/cros/ite/it8xxx2.dtsi index 12ba51388d..2e7b17106e 100644 --- a/zephyr/include/cros/ite/it8xxx2.dtsi +++ b/zephyr/include/cros/ite/it8xxx2.dtsi @@ -64,4 +64,16 @@ label = "FLASH"; }; }; + + /* it8xxx2 has 1MB of flash */ + binman { + wp-ro { + offset = <0x0>; + size = <0x80000>; + }; + ec-rw { + offset = <0x80000>; + size = <0x80000>; + }; + }; }; diff --git a/zephyr/projects/asurada/hayato/zmake.yaml b/zephyr/projects/asurada/hayato/zmake.yaml index 133c622527..cbe856ae4c 100644 --- a/zephyr/projects/asurada/hayato/zmake.yaml +++ b/zephyr/projects/asurada/hayato/zmake.yaml @@ -10,4 +10,4 @@ dts-overlays: supported-zephyr-versions: - v2.5 toolchain: coreboot-sdk -output-type: raw +output-type: binman diff --git a/zephyr/zmake/zmake/output_packers.py b/zephyr/zmake/zmake/output_packers.py index 478eb4c24d..a4c1dbd759 100644 --- a/zephyr/zmake/zmake/output_packers.py +++ b/zephyr/zmake/zmake/output_packers.py @@ -100,13 +100,11 @@ class RawBinPacker(BasePacker): yield singleimage / 'zephyr' / 'zephyr.bin', 'zephyr.bin' -class NpcxPacker(BasePacker): - """Packer for RO/RW image to generate a .bin build using FMAP. +class BinmanPacker(BasePacker): + """Packer for RO/RW image to generate a .bin build using FMAP.""" + ro_file = 'zephyr.bin' + rw_file = 'zephyr.bin' - This expects that the build is setup to generate a - zephyr.npcx.bin for the RO image, which should be packed using - Nuvoton's loader format. - """ def __init__(self, project): self.logger = logging.getLogger(self.__class__.__name__) super().__init__(project) @@ -137,9 +135,8 @@ class NpcxPacker(BasePacker): # Copy the inputs into the work directory so that Binman can # find them under a hard-coded name. - shutil.copy2(ro / 'zephyr' / 'zephyr.npcx.bin', - work_dir / 'zephyr_ro.bin') - shutil.copy2(rw / 'zephyr' / 'zephyr.bin', work_dir / 'zephyr_rw.bin') + shutil.copy2(ro / 'zephyr' / self.ro_file, work_dir / 'zephyr_ro.bin') + shutil.copy2(rw / 'zephyr' / self.rw_file, work_dir / 'zephyr_rw.bin') # Version in FRID/FWID can be at most 31 bytes long (32, minus # one for null character). @@ -160,11 +157,23 @@ class NpcxPacker(BasePacker): if proc.wait(timeout=60): raise OSError('Failed to run binman') - yield self._check_packed_file_size(work_dir / 'zephyr.bin', - {'ro': ro, 'rw': rw}), 'zephyr.bin' + yield work_dir / 'zephyr.bin', 'zephyr.bin' yield ro / 'zephyr' / 'zephyr.elf', 'zephyr.ro.elf' yield rw / 'zephyr' / 'zephyr.elf', 'zephyr.rw.elf' + +class NpcxPacker(BinmanPacker): + """Packer for RO/RW image to generate a .bin build using FMAP. + + This expects that the build is setup to generate a + zephyr.npcx.bin for the RO image, which should be packed using + Nuvoton's loader format. + """ + ro_file = 'zephyr.npcx.bin' + + # TODO(b/192401039): CONFIG_FLASH_SIZE is nuvoton-only. Since + # binman already checks sizes, perhaps we can just remove this + # code? def _get_max_image_bytes(self, ro, rw): ro_size = util.read_kconfig_autoconf_value( ro / 'zephyr' / 'include' / 'generated', @@ -174,9 +183,24 @@ class NpcxPacker(BasePacker): 'CONFIG_FLASH_SIZE') return max(int(ro_size, 0), int(rw_size, 0)) * 1024 + # This can probably be removed too and just rely on binman to + # check the sizes... see the comment above. + def pack_firmware(self, work_dir, jobclient, ro, rw, version_string=""): + for path, output_file in super().pack_firmware( + work_dir, jobclient, ro, rw, version_string=version_string, + ): + if output_file == 'zephyr.bin': + yield ( + self._check_packed_file_size(path, {'ro': ro, 'rw': rw}), + 'zephyr.bin', + ) + else: + yield path, output_file + # A dictionary mapping packer config names to classes. packer_registry = { + 'binman': BinmanPacker, 'elf': ElfPacker, 'npcx': NpcxPacker, 'raw': RawBinPacker, |