Enable split mode in binman
v2 cover Enable split mode in binman
This series extends the functionality of ti-secure-rom entry type in binman to support enabling of split mode vs. the default lockstep mode via changing the field in the x509 certificate. A DONOTMERGE patch is added to give an example of how this can be done via the binman.dtsi
Changes since v2:
- Udit:
- included TRM link in commit message
- added DONOTMERGE patch showing example
Neha Malcom Francis (2):
binman: openssl: x509: ti_secure_rom: Add support for bootcore_opts
DONOTMERGE: arm: dts: k3-j7200-binman: Enable split mode for MCU R5
arch/arm/dts/k3-j7200-binman.dtsi | 3 +++ tools/binman/btool/openssl.py | 6 ++++-- tools/binman/etype/ti_secure_rom.py | 12 ++++++++++-- tools/binman/etype/x509_cert.py | 3 ++- tools/binman/test/297_ti_secure_rom.dts | 1 + 5 files changed, 20 insertions(+), 5 deletions(-)
Signature · 1 line
2.34.1
PATCH v2 1/2 binman: openssl: x509: ti_secure_rom: Add support for bootcore_opts
According to the TRMs of K3 platform of devices, the ROM boot image format specifies a "Core Options Field" that provides the capability to set the boot core in lockstep when set to 0 or to split mode when set to 2. Add support for providing the same from the binman DTS. Also modify existing test case for ensuring future coverage.
---
Link to J721E TRM: https://www.ti.com/lit/zip/spruil1
Section 4.5.4.1 Boot Info
tools/binman/btool/openssl.py | 6 ++++-- tools/binman/etype/ti_secure_rom.py | 12 ++++++++++-- tools/binman/etype/x509_cert.py | 3 ++- tools/binman/test/297_ti_secure_rom.dts | 1 + 4 files changed, 17 insertions(+), 5 deletions(-)
tools/binman/btool/openssl.py +4 -2
@@ -155,6 +155,7 @@ authInPlace = INTEGER:2 C, ST, L, O, OU, CN and emailAddress cert_type (int): Certification type bootcore (int): Booting core + bootcore_opts(int): Booting core option (split/lockstep mode) load_addr (int): Load address of image sha (int): Hash function
@@ -225,7 +226,7 @@ emailAddress = {req_dist_name_dict['emailAddress']} imagesize_sbl, hashval_sbl, load_addr_sysfw, imagesize_sysfw, hashval_sysfw, load_addr_sysfw_data, imagesize_sysfw_data, hashval_sysfw_data, sysfw_inner_cert_ext_boot_block, - dm_data_ext_boot_block): + dm_data_ext_boot_block, bootcore_opts): """Create a certificate Args:
@@ -241,6 +242,7 @@ emailAddress = {req_dist_name_dict['emailAddress']} bootcore (int): Booting core load_addr (int): Load address of image sha (int): Hash function + bootcore_opts (int): Boot core option (split/lockstep mode) Returns: str: Tool output
@@ -285,7 +287,7 @@ sysfw_data=SEQUENCE:sysfw_data [sbl] compType = INTEGER:1 bootCore = INTEGER:16 -compOpts = INTEGER:0 +compOpts = INTEGER:{bootcore_opts} destAddr = FORMAT:HEX,OCT:{load_addr:08x} compSize = INTEGER:{imagesize_sbl} shaType = OID:{sha_type}
tools/binman/etype/ti_secure_rom.py +10 -2
@@ -32,6 +32,7 @@ class Entry_ti_secure_rom(Entry_x509_cert): - core: core on which bootloader runs, valid cores are 'secure' and 'public' - content: phandle of SPL in case of legacy bootflow or phandles of component binaries in case of combined bootflow + - bootcore_opts (optional): split-mode (0) or lockstep mode (1) set to 0 by default The following properties are only for generating a combined bootflow binary: - sysfw-inner-cert: boolean if binary contains sysfw inner certificate
@@ -69,6 +70,7 @@ class Entry_ti_secure_rom(Entry_x509_cert): self.sw_rev = fdt_util.GetInt(self._node, 'sw-rev', 1) self.sha = fdt_util.GetInt(self._node, 'sha', 512) self.core = fdt_util.GetString(self._node, 'core', 'secure') + self.bootcore_opts = fdt_util.GetInt(self._node, 'core-opts') self.key_fname = self.GetEntryArgsOrProps([ EntryArg('keyfile', str)], required=True)[0] if self.combined:
@@ -103,11 +105,14 @@ class Entry_ti_secure_rom(Entry_x509_cert): else: self.cert_type = 2 self.bootcore = 0 - self.bootcore_opts = 32 + if self.bootcore_opts is None: + self.bootcore_opts = 32 else: self.cert_type = 1 self.bootcore = 16 - self.bootcore_opts = 0 + if self.bootcore_opts is None: + self.bootcore_opts = 0 + return super().GetCertificate(required=required, type='rom') def CombinedGetCertificate(self, required):
@@ -126,6 +131,9 @@ class Entry_ti_secure_rom(Entry_x509_cert): self.num_comps = 3 self.sha_type = SHA_OIDS[self.sha] + if self.bootcore_opts is None: + self.bootcore_opts = 0 + # sbl self.content = fdt_util.GetPhandleList(self._node, 'content-sbl') input_data_sbl = self.GetContents(required)
tools/binman/etype/x509_cert.py +2 -1
@@ -136,7 +136,8 @@ class Entry_x509_cert(Entry_collection): imagesize_sysfw_data=self.imagesize_sysfw_data, hashval_sysfw_data=self.hashval_sysfw_data, sysfw_inner_cert_ext_boot_block=self.sysfw_inner_cert_ext_boot_block, - dm_data_ext_boot_block=self.dm_data_ext_boot_block + dm_data_ext_boot_block=self.dm_data_ext_boot_block, + bootcore_opts=self.bootcore_opts ) if stdout is not None: data = tools.read_file(output_fname)
tools/binman/test/297_ti_secure_rom.dts +1 -0
@@ -9,6 +9,7 @@ binman { ti-secure-rom { content = <&unsecure_binary>; + core-opts = <2>; }; unsecure_binary: blob-ext { filename = "ti_unsecure.bin";
Signature · 1 line
2.34.1
Re: [PATCH v2 1/2] binman: openssl: x509: ti_secure_rom: Add support for bootcore_opts
Hi Neha,
Quoted 61 lines · Neha Malcom Francis
According to the TRMs of K3 platform of devices, the ROM boot image format specifies a "Core Options Field" that provides the capability to set the boot core in lockstep when set to 0 or to split mode when set to 2. Add support for providing the same from the binman DTS. Also modify existing test case for ensuring future coverage.
Signed-off-by Neha Malcom Francis <[email protected]>---
Link to J721E TRM: https://www.ti.com/lit/zip/spruil1
Section 4.5.4.1 Boot Infotools/binman/btool/openssl.py | 6 ++++-- tools/binman/etype/ti_secure_rom.py | 12 ++++++++++-- tools/binman/etype/x509_cert.py | 3 ++- tools/binman/test/297_ti_secure_rom.dts | 1 + 4 files changed, 17 insertions(+), 5 deletions(-)tools/binman/btool/openssl.py +4
-2@@ -155,6 +155,7 @@ authInPlace = INTEGER:2 C, ST, L, O, OU, CN and emailAddress cert_type (int): Certification type bootcore (int): Booting core + bootcore_opts(int): Booting core option (split/lockstep mode) load_addr (int): Load address of image sha (int): Hash function@@ -225,7 +226,7 @@ emailAddress = {req_dist_name_dict['emailAddress']} imagesize_sbl, hashval_sbl, load_addr_sysfw, imagesize_sysfw, hashval_sysfw, load_addr_sysfw_data, imagesize_sysfw_data, hashval_sysfw_data, sysfw_inner_cert_ext_boot_block, - dm_data_ext_boot_block): + dm_data_ext_boot_block, bootcore_opts): """Create a certificate Args:@@ -241,6 +242,7 @@ emailAddress = {req_dist_name_dict['emailAddress']} bootcore (int): Booting core load_addr (int): Load address of image sha (int): Hash function + bootcore_opts (int): Boot core option (split/lockstep mode) Returns: str: Tool output@@ -285,7 +287,7 @@ sysfw_data=SEQUENCE:sysfw_data [sbl] compType = INTEGER:1 bootCore = INTEGER:16 -compOpts = INTEGER:0 +compOpts = INTEGER:{bootcore_opts} destAddr = FORMAT:HEX,OCT:{load_addr:08x} compSize = INTEGER:{imagesize_sbl} shaType = OID:{sha_type}tools/binman/etype/ti_secure_rom.py +0
-0
tools/binman/etype/ti_secure_rom.py class Entry_ti_secure_rom(Entry_x509_cert): · line 35
Quoted 4 lines
tools/binman/etype/ti_secure_rom.py +1
-0@@ -32,6 +32,7 @@ class Entry_ti_secure_rom(Entry_x509_cert): - core: core on which bootloader runs, valid cores are 'secure' and 'public' - content: phandle of SPL in case of legacy bootflow or phandles of component binaries in case of combined bootflow + - bootcore_opts (optional): split-mode (0) or lockstep mode (1) set to 0 by default
core-opts is what it is called in your .dts so you should use the same name here. Please also regen the entries.rst file
Quoted 13 lines
tools/binman/etype/ti_secure_rom.py +1
-0The following properties are only for generating a combined bootflow binary: - sysfw-inner-cert: boolean if binary contains sysfw inner certificate@@ -69,6 +70,7 @@ class Entry_ti_secure_rom(Entry_x509_cert): self.sw_rev = fdt_util.GetInt(self._node, 'sw-rev', 1) self.sha = fdt_util.GetInt(self._node, 'sha', 512) self.core = fdt_util.GetString(self._node, 'core', 'secure') + self.bootcore_opts = fdt_util.GetInt(self._node, 'core-opts') self.key_fname = self.GetEntryArgsOrProps([ EntryArg('keyfile', str)], required=True)[0]if self.combined:
tools/binman/etype/ti_secure_rom.py class Entry_ti_secure_rom(Entry_x509_cert): · line 109
Quoted 6 lines
tools/binman/etype/ti_secure_rom.py +2
-1@@ -103,11 +105,14 @@ class Entry_ti_secure_rom(Entry_x509_cert): else: self.cert_type = 2 self.bootcore = 0 - self.bootcore_opts = 32 + if self.bootcore_opts is None: + self.bootcore_opts = 32
How come it is 32? I thought it was 0 or 1 (as documented above)? Please add docs to explain this.
Quoted 25 lines
tools/binman/etype/ti_secure_rom.py +6
-1else: self.cert_type = 1 self.bootcore = 16 - self.bootcore_opts = 0 + if self.bootcore_opts is None: + self.bootcore_opts = 0 + return super().GetCertificate(required=required, type='rom') def CombinedGetCertificate(self, required):@@ -126,6 +131,9 @@ class Entry_ti_secure_rom(Entry_x509_cert): self.num_comps = 3 self.sha_type = SHA_OIDS[self.sha] + if self.bootcore_opts is None: + self.bootcore_opts = 0 + # sbl self.content = fdt_util.GetPhandleList(self._node, 'content-sbl') input_data_sbl = self.GetContents(required)tools/binman/etype/x509_cert.py +0
-0
tools/binman/etype/x509_cert.py class Entry_x509_cert(Entry_collection): · line 140
Quoted 6 lines
tools/binman/etype/x509_cert.py +2
-1@@ -136,7 +136,8 @@ class Entry_x509_cert(Entry_collection): imagesize_sysfw_data=self.imagesize_sysfw_data, hashval_sysfw_data=self.hashval_sysfw_data, sysfw_inner_cert_ext_boot_block=self.sysfw_inner_cert_ext_boot_block, - dm_data_ext_boot_block=self.dm_data_ext_boot_block + dm_data_ext_boot_block=self.dm_data_ext_boot_block, + bootcore_opts=self.bootcore_opts
When you add args to a function, please update the function comment.
Quoted 16 lines
tools/binman/etype/x509_cert.py +0
-0) if stdout is not None: data = tools.read_file(output_fname)tools/binman/test/297_ti_secure_rom.dts +1
-1@@ -9,6 +9,7 @@ binman { ti-secure-rom { content = <&unsecure_binary>; + core-opts = <2>; }; unsecure_binary: blob-ext { filename = "ti_unsecure.bin"; --
Quoted 2 lines
2.34.1
Regards,
Simonm
Re: [PATCH v2 1/2] binman: openssl: x509: ti_secure_rom: Add support for bootcore_opts
Hi Simon
Quoted 142 lines · Simon Glass
Hi Neha,
Quoted 61 lines · Neha Malcom Francis
According to the TRMs of K3 platform of devices, the ROM boot image format specifies a "Core Options Field" that provides the capability to set the boot core in lockstep when set to 0 or to split mode when set to 2. Add support for providing the same from the binman DTS. Also modify existing test case for ensuring future coverage.
Signed-off-by Neha Malcom Francis <[email protected]>---
Link to J721E TRM: https://www.ti.com/lit/zip/spruil1
Section 4.5.4.1 Boot Infotools/binman/btool/openssl.py | 6 ++++-- tools/binman/etype/ti_secure_rom.py | 12 ++++++++++-- tools/binman/etype/x509_cert.py | 3 ++- tools/binman/test/297_ti_secure_rom.dts | 1 + 4 files changed, 17 insertions(+), 5 deletions(-)tools/binman/btool/openssl.py +4
-2@@ -155,6 +155,7 @@ authInPlace = INTEGER:2 C, ST, L, O, OU, CN and emailAddress cert_type (int): Certification type bootcore (int): Booting core + bootcore_opts(int): Booting core option (split/lockstep mode) load_addr (int): Load address of image sha (int): Hash function@@ -225,7 +226,7 @@ emailAddress = {req_dist_name_dict['emailAddress']} imagesize_sbl, hashval_sbl, load_addr_sysfw, imagesize_sysfw, hashval_sysfw, load_addr_sysfw_data, imagesize_sysfw_data, hashval_sysfw_data, sysfw_inner_cert_ext_boot_block, - dm_data_ext_boot_block): + dm_data_ext_boot_block, bootcore_opts): """Create a certificate Args:@@ -241,6 +242,7 @@ emailAddress = {req_dist_name_dict['emailAddress']} bootcore (int): Booting core load_addr (int): Load address of image sha (int): Hash function + bootcore_opts (int): Boot core option (split/lockstep mode) Returns: str: Tool output@@ -285,7 +287,7 @@ sysfw_data=SEQUENCE:sysfw_data [sbl] compType = INTEGER:1 bootCore = INTEGER:16 -compOpts = INTEGER:0 +compOpts = INTEGER:{bootcore_opts} destAddr = FORMAT:HEX,OCT:{load_addr:08x} compSize = INTEGER:{imagesize_sbl} shaType = OID:{sha_type}tools/binman/etype/ti_secure_rom.py +0
-0tools/binman/etype/ti_secure_rom.py class Entry_ti_secure_rom(Entry_x509_cert): · line 35
Quoted 4 lines
tools/binman/etype/ti_secure_rom.py +1
-0@@ -32,6 +32,7 @@ class Entry_ti_secure_rom(Entry_x509_cert): - core: core on which bootloader runs, valid cores are 'secure' and 'public' - content: phandle of SPL in case of legacy bootflow or phandles of component binaries in case of combined bootflow + - bootcore_opts (optional): split-mode (0) or lockstep mode (1) set to 0 by defaultcore-opts is what it is called in your .dts so you should use the same name here. Please also regen the
entries.rstfileQuoted 13 lines
tools/binman/etype/ti_secure_rom.py +1
-0The following properties are only for generating a combined bootflow binary: - sysfw-inner-cert: boolean if binary contains sysfw inner certificate@@ -69,6 +70,7 @@ class Entry_ti_secure_rom(Entry_x509_cert): self.sw_rev = fdt_util.GetInt(self._node, 'sw-rev', 1) self.sha = fdt_util.GetInt(self._node, 'sha', 512) self.core = fdt_util.GetString(self._node, 'core', 'secure') + self.bootcore_opts = fdt_util.GetInt(self._node, 'core-opts') self.key_fname = self.GetEntryArgsOrProps([ EntryArg('keyfile', str)], required=True)[0]if self.combined:
tools/binman/etype/ti_secure_rom.py class Entry_ti_secure_rom(Entry_x509_cert): · line 109
Quoted 6 lines
tools/binman/etype/ti_secure_rom.py +2
-1@@ -103,11 +105,14 @@ class Entry_ti_secure_rom(Entry_x509_cert): else: self.cert_type = 2 self.bootcore = 0 - self.bootcore_opts = 32 + if self.bootcore_opts is None: + self.bootcore_opts = 32How come it is 32? I thought it was 0 or 1 (as documented above)? Please add docs to explain this.
Quoted 25 lines
tools/binman/etype/ti_secure_rom.py +6
-1else: self.cert_type = 1 self.bootcore = 16 - self.bootcore_opts = 0 + if self.bootcore_opts is None: + self.bootcore_opts = 0 + return super().GetCertificate(required=required, type='rom') def CombinedGetCertificate(self, required):@@ -126,6 +131,9 @@ class Entry_ti_secure_rom(Entry_x509_cert): self.num_comps = 3 self.sha_type = SHA_OIDS[self.sha] + if self.bootcore_opts is None: + self.bootcore_opts = 0 + # sbl self.content = fdt_util.GetPhandleList(self._node, 'content-sbl') input_data_sbl = self.GetContents(required)tools/binman/etype/x509_cert.py +0
-0tools/binman/etype/x509_cert.py class Entry_x509_cert(Entry_collection): · line 140
Quoted 6 lines
tools/binman/etype/x509_cert.py +2
-1@@ -136,7 +136,8 @@ class Entry_x509_cert(Entry_collection): imagesize_sysfw_data=self.imagesize_sysfw_data, hashval_sysfw_data=self.hashval_sysfw_data, sysfw_inner_cert_ext_boot_block=self.sysfw_inner_cert_ext_boot_block, - dm_data_ext_boot_block=self.dm_data_ext_boot_block + dm_data_ext_boot_block=self.dm_data_ext_boot_block, + bootcore_opts=self.bootcore_optsWhen you add args to a function, please update the function comment.
Quoted 13 lines
tools/binman/etype/x509_cert.py +0
-0) if stdout is not None: data = tools.read_file(output_fname)tools/binman/test/297_ti_secure_rom.dts +1
-0@@ -9,6 +9,7 @@ binman { ti-secure-rom { content = <&unsecure_binary>; + core-opts = <2>; };
Quoted 8 lines
Quoted 5 lines
tools/binman/test/297_ti_secure_rom.dts +0
-1unsecure_binary: blob-ext { filename = "ti_unsecure.bin"; --2.34.1
Regards,
Simonm
Thanks for the review comments! Will send out v3.
Signature · 2 lines
Thanking You Neha Malcom Francis
Re: [PATCH v2 1/2] binman: openssl: x509: ti_secure_rom: Add support for bootcore_opts
In reply to Simon GlassHi Simon
Quoted 8 lines · Simon Glass
Hi Neha,
Quoted 5 lines · Neha Malcom Francis
According to the TRMs of K3 platform of devices, the ROM boot image format specifies a "Core Options Field" that provides the capability to set the boot core in lockstep when set to 0 or to split mode when set to 2. Add support for providing the same from the binman DTS. Also
[...]
Quoted 7 lines
Quoted 7 lines
self.content =
fdt_util.GetPhandleList(self._node, 'content-sbl')input_data_sbl=self.GetContents(required)tools/binman/etype/x509_cert.py +0
-0@@ -136,7 +136,8 @@ class Entry_x509_cert(Entry_collection):
Quoted 9 lines
tools/binman/etype/x509_cert.py class Entry_x509_cert(Entry_collection): · line 140
Quoted 6 lines
tools/binman/etype/x509_cert.py +2
-1imagesize_sysfw_data=self.imagesize_sysfw_data, hashval_sysfw_data=self.hashval_sysfw_data, sysfw_inner_cert_ext_boot_block=self.sysfw_inner_cert_ext_boot_block, - dm_data_ext_boot_block=self.dm_data_ext_boot_block + dm_data_ext_boot_block=self.dm_data_ext_boot_block, + bootcore_opts=self.bootcore_optsWhen you add args to a function, please update the function comment.
Before sending out the next version, just wanted to mention that this was a function call, the function comment has already been updated in tools/binman/btool/openssl.py
Signature · 2 lines
Thanking You Neha Malcom Francis
PATCH v2 2/2 DONOTMERGE: arm: dts: k3-j7200-binman: Enable split mode for MCU R5
In reply to Neha Malcom FrancisSet boot core-opts to enable split mode for MCU R5 cluster by default. This patch serves to demonstrate how this can be done.
--- arch/arm/dts/k3-j7200-binman.dtsi | 3 +++ 1 file changed, 3 insertions(+)
arch/arm/dts/k3-j7200-binman.dtsi +3 -0
@@ -55,6 +55,7 @@ <&combined_dm_cfg>, <&sysfw_inner_cert>; combined; dm-data; + core-opts = <2>; sysfw-inner-cert; keyfile = "custMpk.pem"; sw-rev = <1>;
@@ -100,6 +101,7 @@ <&combined_dm_cfg_fs>, <&sysfw_inner_cert_fs>; combined; dm-data; + core-opts = <2>; sysfw-inner-cert; keyfile = "custMpk.pem"; sw-rev = <1>;
@@ -146,6 +148,7 @@ <&combined_tifs_cfg_gp>, <&combined_dm_cfg_gp>; combined; dm-data; + core-opts = <2>; content-sbl = <&u_boot_spl_unsigned>; load = <0x41c00000>; content-sysfw = <&ti_fs_gp>;
Signature · 1 line
2.34.1