[PATCH v7 00/11] Integrate EFI capsule tasks into u-boot's build flow

This patchset aims to bring two capsule related tasks under the u-boot build flow.
One is the embedding of the public key into the platform's dtb. The public key is in the form of an EFI Signature List(ESL) file and is used for capsule authentication. This is being achieved by adding the signature node containing the capsule public key in the architecture's u-boot.dtsi file. Currently, the u-boot.dtsi file has been added for the sandbox and arm architectures. The path to the ESL file is being provided through a Kconfig symbol(CONFIG_EFI_CAPSULE_ESL_FILE).
Changes have also been made to the test flow so that the keys used for signing the capsule, and the ESL file, are generated prior to invoking the u-boot's build, which enables embedding the ESL file into the dtb as part of the u-boot build.
The other task is related to generation of capsules. The capsules can be generated as part of u-boot build, and this is being achieved through binman, by adding a capsule entry type. The capsules can be generated by specifying the capsule parameters as properties under the capsule entry node.
Changes have also been made to the efi capsule update feature testing setup on the sandbox variants. Currently, the capsule files and the public key ESL file are generated after u-boot has been built. This logic has been changed so that the capsule input files along with the keys needed for capsule signing and authentication are generated prior to initiation of the u-boot build. The placement of all the keys and public key certificates needed for signing and authenticating capsules is under the board/sandbox/ directory. The other input files needed for testing the EFI capsule update feature are being generated through binman for the sandbox platform.
The document has been updated to reflect the above changes.
Changes since V6:
After discussing with Simon and Tom over irc, this series puts only the keys and cert files under the board/sandbox/ directory. The other set of capsule input files needed for capsule update feature testing are being generated through binman.
The other patch specific changes are as under.
* New patch that puts the keys and cert files under board/sandbox/ directory as suggested Simon Glass. * Populate the CONFIG_EFI_CAPSULE_ESL_FILE symbol for sandbox and sandbox_flattree which enable capsule authentication. * New patch which has been split up from the binman capsule entry support patch from earlier version, as suggested by Simon Glass. * Enables mkeficapsule tool for all sandbox variants, instead of only for sandbox_spl variant. * Split the changes for mkeficapsule btool into a separate patch, as suggested by Simon Glass. * Use the word commandline consistently, as suggested by Simon Glass. * Add macros for the GUID strings in sandbox_efi_capsule.h * Highlight that the private and public keys are mandatory for capsule signing. * Add a URL link to the UEFI spec, as used in the rst files. * Use local vars for private and public keys in BuildSectionData() * Use local vars for input payload and capsule filenames in BuildSectionData(). * Drop the ProcessContents() and SetImagePos() as the superclass functions suffice. * Use GUID macro names in the capsule test dts files. * Rename efi_capsule_payload.bin to capsule_input.bin. * Use macros defined in sandbox_efi_capsule for GUIDs and capsule input filenames. * Generate the capsule input files through binman text entries. * New patch for fixing CI trace test failure.
Sughosh Ganu (11): binman: bintool: Build a tool from a list of commands nuvoton: npcm845-evb: Add a newline at the end of file sandbox: capsule: Add keys and certificates needed for capsule update testing capsule: authenticate: Add capsule public key in platform's dtb doc: capsule: Document the new mechanism to embed ESL file into dtb sandbox: Build the mkeficapsule tool for the sandbox variants btool: mkeficapsule: Add a bintool for EFI capsule generation binman: capsule: Add support for generating EFI capsules sandbox: capsule: Generate capsule related files through binman doc: Add documentation to highlight capsule generation related updates sandbox: trace: Increase trace buffer size
.azure-pipelines.yml | 2 +- .gitlab-ci.yml | 2 +- arch/arm/dts/nuvoton-npcm845-evb.dts | 2 +- arch/arm/dts/u-boot.dtsi | 14 + arch/sandbox/dts/u-boot.dtsi | 380 ++++++++++++++++++ board/sandbox/SIGNER.crt | 19 + board/sandbox/SIGNER.esl | Bin 0 -> 831 bytes board/sandbox/SIGNER.key | 28 ++ board/sandbox/SIGNER2.crt | 19 + board/sandbox/SIGNER2.key | 28 ++ configs/sandbox_defconfig | 1 + configs/sandbox_flattree_defconfig | 1 + doc/develop/uefi/uefi.rst | 40 +- include/sandbox_efi_capsule.h | 25 ++ lib/efi_loader/Kconfig | 9 + test/py/tests/test_efi_capsule/conftest.py | 168 +------- test/py/tests/test_efi_capsule/signature.dts | 10 - .../tests/test_efi_capsule/uboot_bin_env.its | 36 -- test/py/tests/test_trace.py | 2 +- tools/Kconfig | 6 +- tools/binman/bintool.py | 19 +- tools/binman/btool/mkeficapsule.py | 101 +++++ tools/binman/entries.rst | 62 +++ tools/binman/etype/efi_capsule.py | 143 +++++++ tools/binman/ftest.py | 121 ++++++ tools/binman/test/307_capsule.dts | 23 ++ tools/binman/test/308_capsule_signed.dts | 25 ++ tools/binman/test/309_capsule_version.dts | 24 ++ tools/binman/test/310_capsule_signed_ver.dts | 26 ++ tools/binman/test/311_capsule_oemflags.dts | 24 ++ tools/binman/test/312_capsule_missing_key.dts | 24 ++ .../binman/test/313_capsule_missing_index.dts | 22 + .../binman/test/314_capsule_missing_guid.dts | 19 + .../test/315_capsule_missing_payload.dts | 19 + 34 files changed, 1213 insertions(+), 231 deletions(-) create mode 100644 arch/arm/dts/u-boot.dtsi create mode 100644 arch/sandbox/dts/u-boot.dtsi create mode 100644 board/sandbox/SIGNER.crt create mode 100644 board/sandbox/SIGNER.esl create mode 100644 board/sandbox/SIGNER.key create mode 100644 board/sandbox/SIGNER2.crt create mode 100644 board/sandbox/SIGNER2.key create mode 100644 include/sandbox_efi_capsule.h delete mode 100644 test/py/tests/test_efi_capsule/signature.dts delete mode 100644 test/py/tests/test_efi_capsule/uboot_bin_env.its create mode 100644 tools/binman/btool/mkeficapsule.py create mode 100644 tools/binman/etype/efi_capsule.py create mode 100644 tools/binman/test/307_capsule.dts create mode 100644 tools/binman/test/308_capsule_signed.dts create mode 100644 tools/binman/test/309_capsule_version.dts create mode 100644 tools/binman/test/310_capsule_signed_ver.dts create mode 100644 tools/binman/test/311_capsule_oemflags.dts create mode 100644 tools/binman/test/312_capsule_missing_key.dts create mode 100644 tools/binman/test/313_capsule_missing_index.dts create mode 100644 tools/binman/test/314_capsule_missing_guid.dts create mode 100644 tools/binman/test/315_capsule_missing_payload.dts

Add support to build a tool from source with a list of commands. This is useful when a tool can be built with multiple commands instead of a single command.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org Reviewed-by: Simon Glass sjg@chromium.org --- Changes since V6: None
tools/binman/bintool.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/tools/binman/bintool.py b/tools/binman/bintool.py index 0b0f56dbbb..3c4ad1adbb 100644 --- a/tools/binman/bintool.py +++ b/tools/binman/bintool.py @@ -328,7 +328,7 @@ class Bintool: return result.stdout
@classmethod - def build_from_git(cls, git_repo, make_target, bintool_path, flags=None): + def build_from_git(cls, git_repo, make_targets, bintool_path, flags=None): """Build a bintool from a git repo
This clones the repo in a temporary directory, builds it with 'make', @@ -336,7 +336,8 @@ class Bintool:
Args: git_repo (str): URL of git repo - make_target (str): Target to pass to 'make' to build the tool + make_targets (list of str): List of targets to pass to 'make' to build + the tool bintool_path (str): Relative path of the tool in the repo, after build is complete flags (list of str): Flags or variables to pass to make, or None @@ -350,12 +351,14 @@ class Bintool: tmpdir = tempfile.mkdtemp(prefix='binmanf.') print(f"- clone git repo '{git_repo}' to '{tmpdir}'") tools.run('git', 'clone', '--depth', '1', git_repo, tmpdir) - print(f"- build target '{make_target}'") - cmd = ['make', '-C', tmpdir, '-j', f'{multiprocessing.cpu_count()}', - make_target] - if flags: - cmd += flags - tools.run(*cmd) + for target in make_targets: + print(f"- build target '{target}'") + cmd = ['make', '-C', tmpdir, '-j', f'{multiprocessing.cpu_count()}', + target] + if flags: + cmd += flags + tools.run(*cmd) + fname = os.path.join(tmpdir, bintool_path) if not os.path.exists(fname): print(f"- File '{fname}' was not produced")

Add a newline at the end of the dts, without which the build fails when including the u-boot.dtsi file.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org Reviewed-by: Simon Glass sjg@chromium.org Reviewed-by: Ilias Apalodimas ilias.apalodimas@linaro.org --- Changes since V6: None
arch/arm/dts/nuvoton-npcm845-evb.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm/dts/nuvoton-npcm845-evb.dts b/arch/arm/dts/nuvoton-npcm845-evb.dts index 3cab7807e3..a93666cb41 100644 --- a/arch/arm/dts/nuvoton-npcm845-evb.dts +++ b/arch/arm/dts/nuvoton-npcm845-evb.dts @@ -354,4 +354,4 @@ &r1en_pins &r1oen_pins >; -}; \ No newline at end of file +};

Add the private keys and public key certificates which are to be used for capsule authentication while testing the EFI capsule update functionality. There are two pairs of private and public keys. The SIGNER.{key,crt} pair will be used for signing capsules, whilst the SIGNER2.{key,crt} pair is to be used as malicious keys for testing authentication failure cases. The SIGNER.crt is also converted to an EFI Signature List(ESL) file, SIGNER.esl, which is embedded in the platform's device-tree for capsule authentication.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org --- Changes since V6: * New patch that puts the keys and cert files under board/sandbox/ directory as suggested Simon Glass.
board/sandbox/SIGNER.crt | 19 +++++++++++++++++++ board/sandbox/SIGNER.esl | Bin 0 -> 831 bytes board/sandbox/SIGNER.key | 28 ++++++++++++++++++++++++++++ board/sandbox/SIGNER2.crt | 19 +++++++++++++++++++ board/sandbox/SIGNER2.key | 28 ++++++++++++++++++++++++++++ 5 files changed, 94 insertions(+) create mode 100644 board/sandbox/SIGNER.crt create mode 100644 board/sandbox/SIGNER.esl create mode 100644 board/sandbox/SIGNER.key create mode 100644 board/sandbox/SIGNER2.crt create mode 100644 board/sandbox/SIGNER2.key
diff --git a/board/sandbox/SIGNER.crt b/board/sandbox/SIGNER.crt new file mode 100644 index 0000000000..82d8576a64 --- /dev/null +++ b/board/sandbox/SIGNER.crt @@ -0,0 +1,19 @@ +-----BEGIN CERTIFICATE----- +MIIDDzCCAfegAwIBAgIUUzrWhMi7oPFshQP6eFlccqf7exswDQYJKoZIhvcNAQEL +BQAwFjEUMBIGA1UEAwwLVEVTVF9TSUdORVIwIBcNMjMwODA0MTgwNzQyWhgPMzAw +MzEwMDYxODA3NDJaMBYxFDASBgNVBAMMC1RFU1RfU0lHTkVSMIIBIjANBgkqhkiG +9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsAX2ldD9Y0c0utd1NU/uFW7jFbMRV4cByWOc ++Rcer/nFgX9yta7ivu3BJ1ueWR17zRNiQpIzLyEipoSPwyyViD5wLrPLRXVP0dru +aCWyiPm+hm7mpjvwhvR7F2efJTguq9nJI4scaL7APUhbIXHHSL9mK8IlbFnshaR/ +qwd//nBW64HVqWlHNd+uxpFP2Qp0kQwb1b80USNWuMtjaIBam2R1xxDac1jSd001 +4X/XcDORxRpJl+0gONw7Ws2nuggeBGlCsy2Fo9/mngEG3bwa7qSmUM9T1Cp+1+vg +Rmi7ox7Yb4m2KaTXoD76mydcQW7+fQkCvpUVC8AtOTWMOfrCMQIDAQABo1MwUTAd +BgNVHQ4EFgQUHvG7Xchqzwdggky+oyzlpNem8UowHwYDVR0jBBgwFoAUHvG7Xchq +zwdggky+oyzlpNem8UowDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOC +AQEAUn1ncSqeXbQAHNrVOFldLwu70hNlMxf2z4EfH2M7vJgrpwkRuIFw7PXNITBh +CImd/ghm5NGFysrK7BwdHkFvUXZV3rE93BhcLC9leWfky33kW9olIzpE14i5FfBn +ABmaokPhOrzAneGzU35sZHNotlqOrzgpKVkpOWrykhYZ5Qjk8Sz0xvzuG8TJc20s +2og+W8Rm2u/xI9xPxtFbq9vUjvFS35o1pm+vkzpgNdo4YS1PG37BW/aopsooLSk7 +9Rxv5vzNXtQqeZ5qBdKbAVh3OsgqwigTmXVvOX3xpy9r9qiimhaISxCt83RZ7wQW +I19t9pXyxAi6u7MRhJZlAeH/3w== +-----END CERTIFICATE----- diff --git a/board/sandbox/SIGNER.esl b/board/sandbox/SIGNER.esl new file mode 100644 index 0000000000000000000000000000000000000000..f8cc272309b2f80113c29e22bc9fdd5c767b4667 GIT binary patch literal 831 zcmZ1&d0^?2Da*aux2_hA(f&|m&&&V@%1|1@gOCPI%=`vTjNcb9GchtTi3D3+YdNud z!N;6d=3f<&F-6ONS4$i4vT<s)d9;1!Wn|=LWiSvk6fqEDV-96u=HU);4GxJ9_H_4i z4Kh#==QT1murM$&v@kF?F^ZDlH#RUZHZ(9Wg9_l(*~F-XYzZSP19KB2KLgNRTue=j zj0_uCzfHaHH`(1}*Y#3U|97H!k3}~NhPN}GOrG;oTyFi(qmA`NTh~3>_x7NA^t?#f z>a)U0PLquF6_u8?^dHul+F@6qxB0YdssF`W?=n<3b^P4dmiKI#^@p}E)#B;%RW0;Z z-#n?@Et9eDfUQTgV&QR*{b|~VRC6NVv@WS%&0hbnAnbMH)s>m<ruWw!o9KU&t7IaN z^ws?)fy!Y!PA6wHM9oeqJuYyoIO0;duj#}3>jlOWk4kw?f2&||$2#il@?9KqESXN5 zbz2wTe>RVi?d~3_cT1K9oDaUDRd@aM1GkLbi{)<QcW%>Ma(#i_ui5G`j(PuTIhpoN z73DslYiZhJ`RkA&6Eh<N<Kke0Km%D|xXbdfh_Q&secT;;BI`VRLX*$F#X3)yTwnIl z%Rn9^t;`}}Al86g0Y6BAFeBrC7FGjhAcY+4z_<klJ0n9-ZF-^Byx1)aGPkZ;M8@iK z@4h6QYApWke51U4vh|)B+RHfwcQh8f`Fd8-Ad#bU?mv#SCl^~!ojUbKMpn)-Kd>zH z-bULy5-~dZsg>zZPS-w(zNM;c<#N4ar|5@t2FY2AoF7{4IWYI(=HR-Vl;VtSQGM$z zG&LhNEwesN5|ez&@#Le<mt%k4Ngp{`oU3!I!!G(r+O78=mGAf;yBNLt_LaVmLHB2w zF3Vp(*($;GmPMkjzjWQf=x-~Qozl?NwEilS|Lo7%xGP$f^Riek&1Q@!w>qJ9NJDsL xX})Fc$L0Fj-&QP|CD!3Bu=aCF<a-t|<@nrhQ$HQy*tL7JV9T^r#)tp!0|2#rO&9<G
literal 0 HcmV?d00001
diff --git a/board/sandbox/SIGNER.key b/board/sandbox/SIGNER.key new file mode 100644 index 0000000000..9a37f59796 --- /dev/null +++ b/board/sandbox/SIGNER.key @@ -0,0 +1,28 @@ +-----BEGIN PRIVATE KEY----- +MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCwBfaV0P1jRzS6 +13U1T+4VbuMVsxFXhwHJY5z5Fx6v+cWBf3K1ruK+7cEnW55ZHXvNE2JCkjMvISKm +hI/DLJWIPnAus8tFdU/R2u5oJbKI+b6GbuamO/CG9HsXZ58lOC6r2ckjixxovsA9 +SFshccdIv2YrwiVsWeyFpH+rB3/+cFbrgdWpaUc1367GkU/ZCnSRDBvVvzRRI1a4 +y2NogFqbZHXHENpzWNJ3TTXhf9dwM5HFGkmX7SA43Dtazae6CB4EaUKzLYWj3+ae +AQbdvBrupKZQz1PUKn7X6+BGaLujHthvibYppNegPvqbJ1xBbv59CQK+lRULwC05 +NYw5+sIxAgMBAAECggEAHn8h/knjpMAw/BAZP//VrYP1Nwy7u/Dpl9U43JUrXWzG +Uc3dd2nR4id6GBIRCLqJePnbQ9JlqMwyXyxHZhbC34SF1imTVbjh9+dY99VULdQr +NMphDrsCzLbt3pu24HFv8Jk+dniDFwi5cMSo+U3nq4xxrLIp3rBjwLHD5sNZYyEU +9xZnj7ziTn5X8da8iRxNpyzz2kQeVemJ0ahr/IkX718bkakSFMesGkln06vH7rAs +069SeqOPrFEbWYXI5iMktLugl3JZpzasRE48j0M42PuProgvT7jb8B35ZF7kn0jT +MqTIHglsJRWcSY0fAb2lHSAvd2vLLVunxr9PDWZvGQKBgQDVzVTuvo1CrVrQLy+B +tpy2k5mjR3qxAOcoWTnKcMErLe8imWWaxukODenP4XqQIX4Sl+X3BXxOqun0Klap +FEsI7TWSHf0eULFtFj0SCgqfRR+V/nblP05eO2nFXgr5YdNa1bWf/aMHplBo4q9e +bbAr4InUB7IGWL2cWjhOhWuJbQKBgQDSw81cBM+vGPUYH/wlxlTVgZCo2Dg2NHjt +LUBqvOZNr21j2F+w8t1vKmqwhkqpc5HIi3pHjEA5gZLTRtmf4GQyo973I6MGn4bS +eayOd6/+FkAi9DUD+WaF7yctJqeevav6KF2UCiz78OtCAU5Y9jFFJpuOANIztI7m +t7ZCUpMFVQKBgFnAsP7oj3SGQbFTnaXeeztKCx04TJExx9hwXIpXe0AdMF5d9wFa +r0tvG9Bg34rSBJLZoXhpnR2JMl2FyIuCMV219t84J6IqTdF1nH2OKZdi9TeKc28Z +fFSirGxmZkT6hDeFr5FScLYtY2QkhWomseY5hKK1+E4hwrd4SFruN46hAoGBAJgh +nzTBgEtqH1enlrCJhSiLmihV0dVGcNb559pjuXTvoG0GfKPT2gPowRPkCzZe5ia0 +jrHgSWd44MtCA8nEBW8MG9+VyJH6Si3Yh7ZaLB2iX+8bCL1yow8f/c44bZtGW0F5 +K3q1EZ1VW+rL2IqcQhog8P1CGHgb514f0x3yTo71AoGACGdb+Nb6lg8OSJPUcuuH +xsWk6RhkJl9bldTleS+QT3R9zO3FvbTwnCCYJboh5Cq/jVmiA7T+fcVAyEJNHSdm +hxbHdScuiJdNWL9+FczOkylnKH3VEdG3RS5lGdyi6r+miTMs3h8WfzGp4JINysjg +PUFskK36qGjASfkRUn0hizQ= +-----END PRIVATE KEY----- diff --git a/board/sandbox/SIGNER2.crt b/board/sandbox/SIGNER2.crt new file mode 100644 index 0000000000..2e8e5d5828 --- /dev/null +++ b/board/sandbox/SIGNER2.crt @@ -0,0 +1,19 @@ +-----BEGIN CERTIFICATE----- +MIIDDzCCAfegAwIBAgIUWw3vHYnrjoHUXytxSm2eYWzbYVAwDQYJKoZIhvcNAQEL +BQAwFjEUMBIGA1UEAwwLVEVTVF9TSUdORVIwIBcNMjMwODA0MTgwODEyWhgPMzAw +MzEwMDYxODA4MTJaMBYxFDASBgNVBAMMC1RFU1RfU0lHTkVSMIIBIjANBgkqhkiG +9w0BAQEFAAOCAQ8AMIIBCgKCAQEApj8NaRndsTVtKZXrEV5JHpN7sFAdOjbetbZ2 +b6TJASreCKJKhls9bWZbPmdgqr8Dn3LD2du3D0WErsUZzN2HS+DBuknj1e4v2Ejc +N66vAj/MyxrQmzSH7H7DXz0BLTwacOvu6TCSoY6qVdlNlEM2RIl+KpZ4S6cr9iTS +WoNu8n9H3i3SYux5yfcXb3F6QNQ0hpuMvgw4YGHiPAxLXhLurNE2EH5zmUkDniYv +tf0M9EufeLhSQd+zMhof5gdeSC2/IL2uJwN2shzgStHXfh0olAhmKy2Du2o/p380 +I/Tdak5cwpwtetN2zHM1OaZMHDg4OsT9Ep9dSekWMstHNKsySwIDAQABo1MwUTAd +BgNVHQ4EFgQUm9b8SnF811nweXSfGisfpzUHGwgwHwYDVR0jBBgwFoAUm9b8SnF8 +11nweXSfGisfpzUHGwgwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOC +AQEAaOZFOcQzF1MRekcBmIZMaHSWYxOUrVLzBNSNhFD8muYiUAAufrkyTUq0Mmat +w5hAnJ34VGpU1wxQlr/uwH7wpZZnGuj10rAp3tqES0g24AeH1bC9wmRs+rD6dcZR +YmZq6FxtV7Cv3pQX7lhDYbcBj2za3YT6I1+yczskAHR6KYYuJzKJ7XRVCL7ZlYRX +pUMZBQq2eAVWlW/c5iDT3KoGZUD9Of71F7qyUAqMMYafeDxguDz7gKstoXVCklQ+ +I4C7JKmRbrRvMgXx6O1clGhAsRZ0nNAtzi7XT5tD27qFwIPgwv48RWgsmPtzE03S +YGQ5WhYMdHOOjWmcV6MDkCpiSA== +-----END CERTIFICATE----- diff --git a/board/sandbox/SIGNER2.key b/board/sandbox/SIGNER2.key new file mode 100644 index 0000000000..2324f69ebd --- /dev/null +++ b/board/sandbox/SIGNER2.key @@ -0,0 +1,28 @@ +-----BEGIN PRIVATE KEY----- +MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCmPw1pGd2xNW0p +lesRXkkek3uwUB06Nt61tnZvpMkBKt4IokqGWz1tZls+Z2CqvwOfcsPZ27cPRYSu +xRnM3YdL4MG6SePV7i/YSNw3rq8CP8zLGtCbNIfsfsNfPQEtPBpw6+7pMJKhjqpV +2U2UQzZEiX4qlnhLpyv2JNJag27yf0feLdJi7HnJ9xdvcXpA1DSGm4y+DDhgYeI8 +DEteEu6s0TYQfnOZSQOeJi+1/Qz0S594uFJB37MyGh/mB15ILb8gva4nA3ayHOBK +0dd+HSiUCGYrLYO7aj+nfzQj9N1qTlzCnC1603bMczU5pkwcODg6xP0Sn11J6RYy +y0c0qzJLAgMBAAECggEABDY2MLoew3IkBltrParAWAUUcFLi95jw92q6BkOHEJg8 +2qia1yCitPUtPodMLmOKF5x4EdgXg5sv2O8MGbWP1VtUKXGh3QJcnRnNmsZ1hXJC +RBcrei2aVLsqf0V2Mg3+GuG8PW3vLWHyZ/Sd6afeuXEYm2Bzrw9J5rfd3dBVKm7f +HBvIyy1ATO/2cbUaEaCLOyhxLhssTI2TIK5SjlsjFLxiQXEi6RyGfBxUCriKZykS +krMdvYh7Tf0uYcv0STmQ5s5Rd+RhRIGCVAdsNBxxJjgBAgqqa/B+kWbcc6o2D41n +yWjErUaBBx3t0A7oT4K4DSTYwMNDVY3fhdd+szsocQKBgQDjnm8LG4UO6OQDm6iX +0vTQTItoAz5TU6GEjHTCfVEqiupD4LKfHhSXwp2hRyzxXO5oNTU9MQCzYd7Npes0 +oVk4Tjo3YDacNPgxqKjODu/Q+tkTH15ydzGr674+YXHfCA1uT5GKOiiF0H1FZgMa +Dk0s+3uWX34vbL4QCu97bUhBewKBgQC6+Z0J9sClgWvvjkglJN3XhRnAacp+WgX7 +bkpgSboXIIsqeqhd1WCLeV7L1pcZgifYBMPojf5LTBqBedL1q3RuqiqQWD/bSIYN +Oc9KCdTjksS8Zo+w+s5zDObDhW9y13H2mKwDqilYBrT4fiA62wPMf1SjEF+RSC6K +ZrQzHO1xcQKBgAILsXnLFIYOx8XUh05eAf9BQNt9c/jxvnjffkklMS6Nsw9LHK/b +aFn40MvbROcia64aFFFpeFUkYwk8HYIKlS+xXEqVHciHnVds6Z94eOVK69qFJKco +tRSTeNE8tPZJLz23j1pLrYOOXSHbidmZGU53MCQo1Yx9kLO6NW7Ji6WzAoGBALP4 +lEoE80Xbn3NEdvkZ1VcfzLvCmKCqMlvjuz+Xd8HPF2VaDznSq01VFAQMmAB7obJy +U8hC9OSxakn6Yy8JS9dBgBrUdxKxaibM4FQZxosOuMPHzMPDhniDkJPemnnmGtIL +/nbAkW8jdYpCjO9Z5PwwC92xYuvKmNGrLgSM8ZhhAoGAfgSZTpASXubM18E3ecfw +5z333wf9qEQgZj7i9MzByFZudyHUhv/FPW1ocUJf36Wu1dfofZg3noSL6oakrm2v +dFDo4PoyCStuF0w9SSzpIld01ZG0t7XqphY0DmshCXIXsqr7Vb4WrbBI7KX+b3Um +BzmROfaSud97NjQ/RA26OZk= +-----END PRIVATE KEY-----

Hi Sughosh,
On Sat, 5 Aug 2023 at 05:35, Sughosh Ganu sughosh.ganu@linaro.org wrote:
Add the private keys and public key certificates which are to be used for capsule authentication while testing the EFI capsule update functionality. There are two pairs of private and public keys. The SIGNER.{key,crt} pair will be used for signing capsules, whilst the SIGNER2.{key,crt} pair is to be used as malicious keys for testing authentication failure cases. The SIGNER.crt is also converted to an EFI Signature List(ESL) file, SIGNER.esl, which is embedded in the platform's device-tree for capsule authentication.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
Changes since V6:
- New patch that puts the keys and cert files under board/sandbox/ directory as suggested Simon Glass.
board/sandbox/SIGNER.crt | 19 +++++++++++++++++++ board/sandbox/SIGNER.esl | Bin 0 -> 831 bytes board/sandbox/SIGNER.key | 28 ++++++++++++++++++++++++++++ board/sandbox/SIGNER2.crt | 19 +++++++++++++++++++ board/sandbox/SIGNER2.key | 28 ++++++++++++++++++++++++++++ 5 files changed, 94 insertions(+) create mode 100644 board/sandbox/SIGNER.crt create mode 100644 board/sandbox/SIGNER.esl create mode 100644 board/sandbox/SIGNER.key create mode 100644 board/sandbox/SIGNER2.crt create mode 100644 board/sandbox/SIGNER2.key
Can we call these good.* and bad.* so it is clear what they are for? Also, please avoid capital letters in filenames.
Regards, Simon

hi Simon,
On Sat, 5 Aug 2023 at 20:34, Simon Glass sjg@chromium.org wrote:
Hi Sughosh,
On Sat, 5 Aug 2023 at 05:35, Sughosh Ganu sughosh.ganu@linaro.org wrote:
Add the private keys and public key certificates which are to be used for capsule authentication while testing the EFI capsule update functionality. There are two pairs of private and public keys. The SIGNER.{key,crt} pair will be used for signing capsules, whilst the SIGNER2.{key,crt} pair is to be used as malicious keys for testing authentication failure cases. The SIGNER.crt is also converted to an EFI Signature List(ESL) file, SIGNER.esl, which is embedded in the platform's device-tree for capsule authentication.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
Changes since V6:
- New patch that puts the keys and cert files under board/sandbox/ directory as suggested Simon Glass.
board/sandbox/SIGNER.crt | 19 +++++++++++++++++++ board/sandbox/SIGNER.esl | Bin 0 -> 831 bytes board/sandbox/SIGNER.key | 28 ++++++++++++++++++++++++++++ board/sandbox/SIGNER2.crt | 19 +++++++++++++++++++ board/sandbox/SIGNER2.key | 28 ++++++++++++++++++++++++++++ 5 files changed, 94 insertions(+) create mode 100644 board/sandbox/SIGNER.crt create mode 100644 board/sandbox/SIGNER.esl create mode 100644 board/sandbox/SIGNER.key create mode 100644 board/sandbox/SIGNER2.crt create mode 100644 board/sandbox/SIGNER2.key
Can we call these good.* and bad.* so it is clear what they are for? Also, please avoid capital letters in filenames.
I was using the same nomenclature that was being used currently by the efi capsule update tests. But I guess I can change this.
-sughosh

Hi Sughosh,
On Sat, 5 Aug 2023 at 11:50, Sughosh Ganu sughosh.ganu@linaro.org wrote:
hi Simon,
On Sat, 5 Aug 2023 at 20:34, Simon Glass sjg@chromium.org wrote:
Hi Sughosh,
On Sat, 5 Aug 2023 at 05:35, Sughosh Ganu sughosh.ganu@linaro.org wrote:
Add the private keys and public key certificates which are to be used for capsule authentication while testing the EFI capsule update functionality. There are two pairs of private and public keys. The SIGNER.{key,crt} pair will be used for signing capsules, whilst the SIGNER2.{key,crt} pair is to be used as malicious keys for testing authentication failure cases. The SIGNER.crt is also converted to an EFI Signature List(ESL) file, SIGNER.esl, which is embedded in the platform's device-tree for capsule authentication.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
Changes since V6:
- New patch that puts the keys and cert files under board/sandbox/ directory as suggested Simon Glass.
board/sandbox/SIGNER.crt | 19 +++++++++++++++++++ board/sandbox/SIGNER.esl | Bin 0 -> 831 bytes board/sandbox/SIGNER.key | 28 ++++++++++++++++++++++++++++ board/sandbox/SIGNER2.crt | 19 +++++++++++++++++++ board/sandbox/SIGNER2.key | 28 ++++++++++++++++++++++++++++ 5 files changed, 94 insertions(+) create mode 100644 board/sandbox/SIGNER.crt create mode 100644 board/sandbox/SIGNER.esl create mode 100644 board/sandbox/SIGNER.key create mode 100644 board/sandbox/SIGNER2.crt create mode 100644 board/sandbox/SIGNER2.key
Can we call these good.* and bad.* so it is clear what they are for? Also, please avoid capital letters in filenames.
I was using the same nomenclature that was being used currently by the efi capsule update tests. But I guess I can change this.
Yes please. You could use a patch at the start of your series, perhaps?
Regards, Simon

hi Simon,
On Sun, 6 Aug 2023 at 00:06, Simon Glass sjg@chromium.org wrote:
Hi Sughosh,
On Sat, 5 Aug 2023 at 11:50, Sughosh Ganu sughosh.ganu@linaro.org wrote:
hi Simon,
On Sat, 5 Aug 2023 at 20:34, Simon Glass sjg@chromium.org wrote:
Hi Sughosh,
On Sat, 5 Aug 2023 at 05:35, Sughosh Ganu sughosh.ganu@linaro.org wrote:
Add the private keys and public key certificates which are to be used for capsule authentication while testing the EFI capsule update functionality. There are two pairs of private and public keys. The SIGNER.{key,crt} pair will be used for signing capsules, whilst the SIGNER2.{key,crt} pair is to be used as malicious keys for testing authentication failure cases. The SIGNER.crt is also converted to an EFI Signature List(ESL) file, SIGNER.esl, which is embedded in the platform's device-tree for capsule authentication.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
Changes since V6:
- New patch that puts the keys and cert files under board/sandbox/ directory as suggested Simon Glass.
board/sandbox/SIGNER.crt | 19 +++++++++++++++++++ board/sandbox/SIGNER.esl | Bin 0 -> 831 bytes board/sandbox/SIGNER.key | 28 ++++++++++++++++++++++++++++ board/sandbox/SIGNER2.crt | 19 +++++++++++++++++++ board/sandbox/SIGNER2.key | 28 ++++++++++++++++++++++++++++ 5 files changed, 94 insertions(+) create mode 100644 board/sandbox/SIGNER.crt create mode 100644 board/sandbox/SIGNER.esl create mode 100644 board/sandbox/SIGNER.key create mode 100644 board/sandbox/SIGNER2.crt create mode 100644 board/sandbox/SIGNER2.key
Can we call these good.* and bad.* so it is clear what they are for? Also, please avoid capital letters in filenames.
I was using the same nomenclature that was being used currently by the efi capsule update tests. But I guess I can change this.
Yes please. You could use a patch at the start of your series, perhaps?
Er, this is actually at the start of the series, isn't it. Well, at least before we start adding relevant stuff like the ESL file incbin logic in the u-boot.dtsi file -- this patch precedes patch 4 which is adding the incbin logic to u-boot.dtsi.
-sughosh

Hi Sughosh,
On Sat, 5 Aug 2023 at 12:50, Sughosh Ganu sughosh.ganu@linaro.org wrote:
hi Simon,
On Sun, 6 Aug 2023 at 00:06, Simon Glass sjg@chromium.org wrote:
Hi Sughosh,
On Sat, 5 Aug 2023 at 11:50, Sughosh Ganu sughosh.ganu@linaro.org wrote:
hi Simon,
On Sat, 5 Aug 2023 at 20:34, Simon Glass sjg@chromium.org wrote:
Hi Sughosh,
On Sat, 5 Aug 2023 at 05:35, Sughosh Ganu sughosh.ganu@linaro.org wrote:
Add the private keys and public key certificates which are to be used for capsule authentication while testing the EFI capsule update functionality. There are two pairs of private and public keys. The SIGNER.{key,crt} pair will be used for signing capsules, whilst the SIGNER2.{key,crt} pair is to be used as malicious keys for testing authentication failure cases. The SIGNER.crt is also converted to an EFI Signature List(ESL) file, SIGNER.esl, which is embedded in the platform's device-tree for capsule authentication.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
Changes since V6:
- New patch that puts the keys and cert files under board/sandbox/ directory as suggested Simon Glass.
board/sandbox/SIGNER.crt | 19 +++++++++++++++++++ board/sandbox/SIGNER.esl | Bin 0 -> 831 bytes board/sandbox/SIGNER.key | 28 ++++++++++++++++++++++++++++ board/sandbox/SIGNER2.crt | 19 +++++++++++++++++++ board/sandbox/SIGNER2.key | 28 ++++++++++++++++++++++++++++ 5 files changed, 94 insertions(+) create mode 100644 board/sandbox/SIGNER.crt create mode 100644 board/sandbox/SIGNER.esl create mode 100644 board/sandbox/SIGNER.key create mode 100644 board/sandbox/SIGNER2.crt create mode 100644 board/sandbox/SIGNER2.key
Can we call these good.* and bad.* so it is clear what they are for? Also, please avoid capital letters in filenames.
I was using the same nomenclature that was being used currently by the efi capsule update tests. But I guess I can change this.
Yes please. You could use a patch at the start of your series, perhaps?
Er, this is actually at the start of the series, isn't it. Well, at least before we start adding relevant stuff like the ESL file incbin logic in the u-boot.dtsi file -- this patch precedes patch 4 which is adding the incbin logic to u-boot.dtsi.
OK, well anyway if you can rename them to be more meaningful that would help.
Regards, Simon

The EFI capsule authentication logic in u-boot expects the public key in the form of an EFI Signature List(ESL) to be provided as part of the platform's dtb. Currently, the embedding of the ESL file into the dtb needs to be done manually.
Add a signature node in the u-boot dtsi file and include the public key through the capsule-key property. This file is per architecture, and is currently being added for sandbox and arm architectures. It will have to be added for other architectures which need to enable capsule authentication support.
The path to the ESL file is specified through the CONFIG_EFI_CAPSULE_ESL_FILE symbol.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org --- Changes since V6: * Populate the CONFIG_EFI_CAPSULE_ESL_FILE symbol for sandbox and sandbox_flattree which enable capsule authentication.
Note: Simon Glass had asked me to rid of the CONFIG_EFI_HAVE_CAPSULE_SUPPORT ifdef used in the sandbox' u-boot.dtsi file. However, that results in the sandbox_vpl test failing in CI. Hence that check has been kept.
arch/arm/dts/u-boot.dtsi | 14 ++++++++++++++ arch/sandbox/dts/u-boot.dtsi | 17 +++++++++++++++++ configs/sandbox_defconfig | 1 + configs/sandbox_flattree_defconfig | 1 + lib/efi_loader/Kconfig | 9 +++++++++ 5 files changed, 42 insertions(+) create mode 100644 arch/arm/dts/u-boot.dtsi create mode 100644 arch/sandbox/dts/u-boot.dtsi
diff --git a/arch/arm/dts/u-boot.dtsi b/arch/arm/dts/u-boot.dtsi new file mode 100644 index 0000000000..4f31da4521 --- /dev/null +++ b/arch/arm/dts/u-boot.dtsi @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: GPL-2.0+ +/** + * Devicetree file with miscellaneous nodes that will be included + * at build time into the DTB. Currently being used for including + * capsule related information. + */ + +#ifdef CONFIG_EFI_CAPSULE_AUTHENTICATE +/ { + signature { + capsule-key = /incbin/(CONFIG_EFI_CAPSULE_ESL_FILE); + }; +}; +#endif /* CONFIG_EFI_CAPSULE_AUTHENTICATE */ diff --git a/arch/sandbox/dts/u-boot.dtsi b/arch/sandbox/dts/u-boot.dtsi new file mode 100644 index 0000000000..60bd004937 --- /dev/null +++ b/arch/sandbox/dts/u-boot.dtsi @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Devicetree file with miscellaneous nodes that will be included + * at build time into the DTB. Currently being used for including + * capsule related information. + * + */ + +#ifdef CONFIG_EFI_HAVE_CAPSULE_SUPPORT +/ { +#ifdef CONFIG_EFI_CAPSULE_AUTHENTICATE + signature { + capsule-key = /incbin/(CONFIG_EFI_CAPSULE_ESL_FILE); + }; +#endif +}; +#endif /* CONFIG_EFI_HAVE_CAPSULE_SUPPORT */ diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig index b6c4f735f2..779af4abc8 100644 --- a/configs/sandbox_defconfig +++ b/configs/sandbox_defconfig @@ -341,6 +341,7 @@ CONFIG_EFI_RUNTIME_UPDATE_CAPSULE=y CONFIG_EFI_CAPSULE_ON_DISK=y CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y CONFIG_EFI_CAPSULE_AUTHENTICATE=y +CONFIG_EFI_CAPSULE_ESL_FILE="../../../board/sandbox/SIGNER.esl" CONFIG_EFI_SECURE_BOOT=y CONFIG_TEST_FDTDEC=y CONFIG_UNIT_TEST=y diff --git a/configs/sandbox_flattree_defconfig b/configs/sandbox_flattree_defconfig index 8aa295686d..0ca2e4a5ae 100644 --- a/configs/sandbox_flattree_defconfig +++ b/configs/sandbox_flattree_defconfig @@ -227,6 +227,7 @@ CONFIG_EFI_RUNTIME_UPDATE_CAPSULE=y CONFIG_EFI_CAPSULE_ON_DISK=y CONFIG_EFI_CAPSULE_FIRMWARE_FIT=y CONFIG_EFI_CAPSULE_AUTHENTICATE=y +CONFIG_EFI_CAPSULE_ESL_FILE="../../../board/sandbox/SIGNER.esl" CONFIG_UNIT_TEST=y CONFIG_UT_TIME=y CONFIG_UT_DM=y diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig index a22e47616f..0d559ff3a1 100644 --- a/lib/efi_loader/Kconfig +++ b/lib/efi_loader/Kconfig @@ -235,6 +235,15 @@ config EFI_CAPSULE_MAX Select the max capsule index value used for capsule report variables. This value is used to create CapsuleMax variable.
+config EFI_CAPSULE_ESL_FILE + string "Path to the EFI Signature List File" + default "" + depends on EFI_CAPSULE_AUTHENTICATE + help + Provides the absolute path to the EFI Signature List file which + will be embedded in the platform's device tree and used for + capsule authentication at the time of capsule update. + config EFI_DEVICE_PATH_TO_TEXT bool "Device path to text protocol" default y

Hi Sughosh,
On Sat, 5 Aug 2023 at 05:35, Sughosh Ganu sughosh.ganu@linaro.org wrote:
The EFI capsule authentication logic in u-boot expects the public key in the form of an EFI Signature List(ESL) to be provided as part of the platform's dtb. Currently, the embedding of the ESL file into the dtb needs to be done manually.
Add a signature node in the u-boot dtsi file and include the public key through the capsule-key property. This file is per architecture, and is currently being added for sandbox and arm architectures. It will have to be added for other architectures which need to enable capsule authentication support.
The path to the ESL file is specified through the CONFIG_EFI_CAPSULE_ESL_FILE symbol.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
Changes since V6:
- Populate the CONFIG_EFI_CAPSULE_ESL_FILE symbol for sandbox and sandbox_flattree which enable capsule authentication.
Note: Simon Glass had asked me to rid of the CONFIG_EFI_HAVE_CAPSULE_SUPPORT ifdef used in the sandbox' u-boot.dtsi file. However, that results in the sandbox_vpl test failing in CI. Hence that check has been kept.
arch/arm/dts/u-boot.dtsi | 14 ++++++++++++++ arch/sandbox/dts/u-boot.dtsi | 17 +++++++++++++++++ configs/sandbox_defconfig | 1 + configs/sandbox_flattree_defconfig | 1 + lib/efi_loader/Kconfig | 9 +++++++++ 5 files changed, 42 insertions(+) create mode 100644 arch/arm/dts/u-boot.dtsi create mode 100644 arch/sandbox/dts/u-boot.dtsi
diff --git a/arch/arm/dts/u-boot.dtsi b/arch/arm/dts/u-boot.dtsi new file mode 100644 index 0000000000..4f31da4521 --- /dev/null +++ b/arch/arm/dts/u-boot.dtsi @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: GPL-2.0+ +/**
- Devicetree file with miscellaneous nodes that will be included
- at build time into the DTB. Currently being used for including
- capsule related information.
- */
+#ifdef CONFIG_EFI_CAPSULE_AUTHENTICATE +/ {
signature {
capsule-key = /incbin/(CONFIG_EFI_CAPSULE_ESL_FILE);
};
+}; +#endif /* CONFIG_EFI_CAPSULE_AUTHENTICATE */ diff --git a/arch/sandbox/dts/u-boot.dtsi b/arch/sandbox/dts/u-boot.dtsi new file mode 100644 index 0000000000..60bd004937 --- /dev/null +++ b/arch/sandbox/dts/u-boot.dtsi @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0+ +/*
- Devicetree file with miscellaneous nodes that will be included
- at build time into the DTB. Currently being used for including
- capsule related information.
- */
+#ifdef CONFIG_EFI_HAVE_CAPSULE_SUPPORT +/ { +#ifdef CONFIG_EFI_CAPSULE_AUTHENTICATE
signature {
capsule-key = /incbin/(CONFIG_EFI_CAPSULE_ESL_FILE);
};
+#endif +}; +#endif /* CONFIG_EFI_HAVE_CAPSULE_SUPPORT */ diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig index b6c4f735f2..779af4abc8 100644 --- a/configs/sandbox_defconfig +++ b/configs/sandbox_defconfig @@ -341,6 +341,7 @@ CONFIG_EFI_RUNTIME_UPDATE_CAPSULE=y CONFIG_EFI_CAPSULE_ON_DISK=y CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y CONFIG_EFI_CAPSULE_AUTHENTICATE=y +CONFIG_EFI_CAPSULE_ESL_FILE="../../../board/sandbox/SIGNER.esl"
Can we avoid the path here, and just use e.g. good.esl ?
Perhaps this could be fixed up later, e.g. by adding the board directory as an include dir when building the DT?
CONFIG_EFI_SECURE_BOOT=y CONFIG_TEST_FDTDEC=y CONFIG_UNIT_TEST=y diff --git a/configs/sandbox_flattree_defconfig b/configs/sandbox_flattree_defconfig index 8aa295686d..0ca2e4a5ae 100644 --- a/configs/sandbox_flattree_defconfig +++ b/configs/sandbox_flattree_defconfig @@ -227,6 +227,7 @@ CONFIG_EFI_RUNTIME_UPDATE_CAPSULE=y CONFIG_EFI_CAPSULE_ON_DISK=y CONFIG_EFI_CAPSULE_FIRMWARE_FIT=y CONFIG_EFI_CAPSULE_AUTHENTICATE=y +CONFIG_EFI_CAPSULE_ESL_FILE="../../../board/sandbox/SIGNER.esl" CONFIG_UNIT_TEST=y CONFIG_UT_TIME=y CONFIG_UT_DM=y diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig index a22e47616f..0d559ff3a1 100644 --- a/lib/efi_loader/Kconfig +++ b/lib/efi_loader/Kconfig @@ -235,6 +235,15 @@ config EFI_CAPSULE_MAX Select the max capsule index value used for capsule report variables. This value is used to create CapsuleMax variable.
+config EFI_CAPSULE_ESL_FILE
string "Path to the EFI Signature List File"
default ""
depends on EFI_CAPSULE_AUTHENTICATE
help
Provides the absolute path to the EFI Signature List file which
It isn't really an absolute path as it doesn't start with /
You really can't/shouldn't use absolute paths in a U-Boot build.
will be embedded in the platform's device tree and used for
capsule authentication at the time of capsule update.
config EFI_DEVICE_PATH_TO_TEXT bool "Device path to text protocol" default y -- 2.34.1
Regards, Simon

hi Simon,
On Sat, 5 Aug 2023 at 20:34, Simon Glass sjg@chromium.org wrote:
Hi Sughosh,
On Sat, 5 Aug 2023 at 05:35, Sughosh Ganu sughosh.ganu@linaro.org wrote:
The EFI capsule authentication logic in u-boot expects the public key in the form of an EFI Signature List(ESL) to be provided as part of the platform's dtb. Currently, the embedding of the ESL file into the dtb needs to be done manually.
Add a signature node in the u-boot dtsi file and include the public key through the capsule-key property. This file is per architecture, and is currently being added for sandbox and arm architectures. It will have to be added for other architectures which need to enable capsule authentication support.
The path to the ESL file is specified through the CONFIG_EFI_CAPSULE_ESL_FILE symbol.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
Changes since V6:
- Populate the CONFIG_EFI_CAPSULE_ESL_FILE symbol for sandbox and sandbox_flattree which enable capsule authentication.
Note: Simon Glass had asked me to rid of the CONFIG_EFI_HAVE_CAPSULE_SUPPORT ifdef used in the sandbox' u-boot.dtsi file. However, that results in the sandbox_vpl test failing in CI. Hence that check has been kept.
arch/arm/dts/u-boot.dtsi | 14 ++++++++++++++ arch/sandbox/dts/u-boot.dtsi | 17 +++++++++++++++++ configs/sandbox_defconfig | 1 + configs/sandbox_flattree_defconfig | 1 + lib/efi_loader/Kconfig | 9 +++++++++ 5 files changed, 42 insertions(+) create mode 100644 arch/arm/dts/u-boot.dtsi create mode 100644 arch/sandbox/dts/u-boot.dtsi
diff --git a/arch/arm/dts/u-boot.dtsi b/arch/arm/dts/u-boot.dtsi new file mode 100644 index 0000000000..4f31da4521 --- /dev/null +++ b/arch/arm/dts/u-boot.dtsi @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: GPL-2.0+ +/**
- Devicetree file with miscellaneous nodes that will be included
- at build time into the DTB. Currently being used for including
- capsule related information.
- */
+#ifdef CONFIG_EFI_CAPSULE_AUTHENTICATE +/ {
signature {
capsule-key = /incbin/(CONFIG_EFI_CAPSULE_ESL_FILE);
};
+}; +#endif /* CONFIG_EFI_CAPSULE_AUTHENTICATE */ diff --git a/arch/sandbox/dts/u-boot.dtsi b/arch/sandbox/dts/u-boot.dtsi new file mode 100644 index 0000000000..60bd004937 --- /dev/null +++ b/arch/sandbox/dts/u-boot.dtsi @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0+ +/*
- Devicetree file with miscellaneous nodes that will be included
- at build time into the DTB. Currently being used for including
- capsule related information.
- */
+#ifdef CONFIG_EFI_HAVE_CAPSULE_SUPPORT +/ { +#ifdef CONFIG_EFI_CAPSULE_AUTHENTICATE
signature {
capsule-key = /incbin/(CONFIG_EFI_CAPSULE_ESL_FILE);
};
+#endif +}; +#endif /* CONFIG_EFI_HAVE_CAPSULE_SUPPORT */ diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig index b6c4f735f2..779af4abc8 100644 --- a/configs/sandbox_defconfig +++ b/configs/sandbox_defconfig @@ -341,6 +341,7 @@ CONFIG_EFI_RUNTIME_UPDATE_CAPSULE=y CONFIG_EFI_CAPSULE_ON_DISK=y CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y CONFIG_EFI_CAPSULE_AUTHENTICATE=y +CONFIG_EFI_CAPSULE_ESL_FILE="../../../board/sandbox/SIGNER.esl"
Can we avoid the path here, and just use e.g. good.esl ?
Unfortunately no. I believe the way incbin works in dts is that it looks for the binary to be included in the same directory as the dts. Which is why I have to point it to the location of the esl relative to the dts.
Perhaps this could be fixed up later, e.g. by adding the board directory as an include dir when building the DT?
Again, this is not how incbin seems to work in dts. I tried putting the esl in one of the existing include directory locations, but it does not pick the file from those dirs. It works with the assumption that the bin file is to be in the same dir as the dts.
CONFIG_EFI_SECURE_BOOT=y CONFIG_TEST_FDTDEC=y CONFIG_UNIT_TEST=y diff --git a/configs/sandbox_flattree_defconfig b/configs/sandbox_flattree_defconfig index 8aa295686d..0ca2e4a5ae 100644 --- a/configs/sandbox_flattree_defconfig +++ b/configs/sandbox_flattree_defconfig @@ -227,6 +227,7 @@ CONFIG_EFI_RUNTIME_UPDATE_CAPSULE=y CONFIG_EFI_CAPSULE_ON_DISK=y CONFIG_EFI_CAPSULE_FIRMWARE_FIT=y CONFIG_EFI_CAPSULE_AUTHENTICATE=y +CONFIG_EFI_CAPSULE_ESL_FILE="../../../board/sandbox/SIGNER.esl" CONFIG_UNIT_TEST=y CONFIG_UT_TIME=y CONFIG_UT_DM=y diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig index a22e47616f..0d559ff3a1 100644 --- a/lib/efi_loader/Kconfig +++ b/lib/efi_loader/Kconfig @@ -235,6 +235,15 @@ config EFI_CAPSULE_MAX Select the max capsule index value used for capsule report variables. This value is used to create CapsuleMax variable.
+config EFI_CAPSULE_ESL_FILE
string "Path to the EFI Signature List File"
default ""
depends on EFI_CAPSULE_AUTHENTICATE
help
Provides the absolute path to the EFI Signature List file which
It isn't really an absolute path as it doesn't start with /
Will change
You really can't/shouldn't use absolute paths in a U-Boot build.
Okay
-sughosh
will be embedded in the platform's device tree and used for
capsule authentication at the time of capsule update.
config EFI_DEVICE_PATH_TO_TEXT bool "Device path to text protocol" default y -- 2.34.1
Regards, Simon

Hi Sughosh,
On Sat, 5 Aug 2023 at 11:54, Sughosh Ganu sughosh.ganu@linaro.org wrote:
hi Simon,
On Sat, 5 Aug 2023 at 20:34, Simon Glass sjg@chromium.org wrote:
Hi Sughosh,
On Sat, 5 Aug 2023 at 05:35, Sughosh Ganu sughosh.ganu@linaro.org wrote:
The EFI capsule authentication logic in u-boot expects the public key in the form of an EFI Signature List(ESL) to be provided as part of the platform's dtb. Currently, the embedding of the ESL file into the dtb needs to be done manually.
Add a signature node in the u-boot dtsi file and include the public key through the capsule-key property. This file is per architecture, and is currently being added for sandbox and arm architectures. It will have to be added for other architectures which need to enable capsule authentication support.
The path to the ESL file is specified through the CONFIG_EFI_CAPSULE_ESL_FILE symbol.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
Changes since V6:
- Populate the CONFIG_EFI_CAPSULE_ESL_FILE symbol for sandbox and sandbox_flattree which enable capsule authentication.
Note: Simon Glass had asked me to rid of the CONFIG_EFI_HAVE_CAPSULE_SUPPORT ifdef used in the sandbox' u-boot.dtsi file. However, that results in the sandbox_vpl test failing in CI. Hence that check has been kept.
arch/arm/dts/u-boot.dtsi | 14 ++++++++++++++ arch/sandbox/dts/u-boot.dtsi | 17 +++++++++++++++++ configs/sandbox_defconfig | 1 + configs/sandbox_flattree_defconfig | 1 + lib/efi_loader/Kconfig | 9 +++++++++ 5 files changed, 42 insertions(+) create mode 100644 arch/arm/dts/u-boot.dtsi create mode 100644 arch/sandbox/dts/u-boot.dtsi
diff --git a/arch/arm/dts/u-boot.dtsi b/arch/arm/dts/u-boot.dtsi new file mode 100644 index 0000000000..4f31da4521 --- /dev/null +++ b/arch/arm/dts/u-boot.dtsi @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: GPL-2.0+ +/**
- Devicetree file with miscellaneous nodes that will be included
- at build time into the DTB. Currently being used for including
- capsule related information.
- */
+#ifdef CONFIG_EFI_CAPSULE_AUTHENTICATE +/ {
signature {
capsule-key = /incbin/(CONFIG_EFI_CAPSULE_ESL_FILE);
};
+}; +#endif /* CONFIG_EFI_CAPSULE_AUTHENTICATE */ diff --git a/arch/sandbox/dts/u-boot.dtsi b/arch/sandbox/dts/u-boot.dtsi new file mode 100644 index 0000000000..60bd004937 --- /dev/null +++ b/arch/sandbox/dts/u-boot.dtsi @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0+ +/*
- Devicetree file with miscellaneous nodes that will be included
- at build time into the DTB. Currently being used for including
- capsule related information.
- */
+#ifdef CONFIG_EFI_HAVE_CAPSULE_SUPPORT +/ { +#ifdef CONFIG_EFI_CAPSULE_AUTHENTICATE
signature {
capsule-key = /incbin/(CONFIG_EFI_CAPSULE_ESL_FILE);
};
+#endif +}; +#endif /* CONFIG_EFI_HAVE_CAPSULE_SUPPORT */ diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig index b6c4f735f2..779af4abc8 100644 --- a/configs/sandbox_defconfig +++ b/configs/sandbox_defconfig @@ -341,6 +341,7 @@ CONFIG_EFI_RUNTIME_UPDATE_CAPSULE=y CONFIG_EFI_CAPSULE_ON_DISK=y CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y CONFIG_EFI_CAPSULE_AUTHENTICATE=y +CONFIG_EFI_CAPSULE_ESL_FILE="../../../board/sandbox/SIGNER.esl"
Can we avoid the path here, and just use e.g. good.esl ?
Unfortunately no. I believe the way incbin works in dts is that it looks for the binary to be included in the same directory as the dts. Which is why I have to point it to the location of the esl relative to the dts.
Perhaps this could be fixed up later, e.g. by adding the board directory as an include dir when building the DT?
Again, this is not how incbin seems to work in dts. I tried putting the esl in one of the existing include directory locations, but it does not pick the file from those dirs. It works with the assumption that the bin file is to be in the same dir as the dts.
Yes but you can change that. Try adding to the cmd_dtc rule in Makefile.lib:
-i $(srctree)/board/$(BOARDDIR) \
[..]
Regards, Simon

hi Simon,
On Sun, 6 Aug 2023 at 00:06, Simon Glass sjg@chromium.org wrote:
Hi Sughosh,
On Sat, 5 Aug 2023 at 11:54, Sughosh Ganu sughosh.ganu@linaro.org wrote:
hi Simon,
On Sat, 5 Aug 2023 at 20:34, Simon Glass sjg@chromium.org wrote:
Hi Sughosh,
On Sat, 5 Aug 2023 at 05:35, Sughosh Ganu sughosh.ganu@linaro.org wrote:
The EFI capsule authentication logic in u-boot expects the public key in the form of an EFI Signature List(ESL) to be provided as part of the platform's dtb. Currently, the embedding of the ESL file into the dtb needs to be done manually.
Add a signature node in the u-boot dtsi file and include the public key through the capsule-key property. This file is per architecture, and is currently being added for sandbox and arm architectures. It will have to be added for other architectures which need to enable capsule authentication support.
The path to the ESL file is specified through the CONFIG_EFI_CAPSULE_ESL_FILE symbol.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
Changes since V6:
- Populate the CONFIG_EFI_CAPSULE_ESL_FILE symbol for sandbox and sandbox_flattree which enable capsule authentication.
Note: Simon Glass had asked me to rid of the CONFIG_EFI_HAVE_CAPSULE_SUPPORT ifdef used in the sandbox' u-boot.dtsi file. However, that results in the sandbox_vpl test failing in CI. Hence that check has been kept.
arch/arm/dts/u-boot.dtsi | 14 ++++++++++++++ arch/sandbox/dts/u-boot.dtsi | 17 +++++++++++++++++ configs/sandbox_defconfig | 1 + configs/sandbox_flattree_defconfig | 1 + lib/efi_loader/Kconfig | 9 +++++++++ 5 files changed, 42 insertions(+) create mode 100644 arch/arm/dts/u-boot.dtsi create mode 100644 arch/sandbox/dts/u-boot.dtsi
diff --git a/arch/arm/dts/u-boot.dtsi b/arch/arm/dts/u-boot.dtsi new file mode 100644 index 0000000000..4f31da4521 --- /dev/null +++ b/arch/arm/dts/u-boot.dtsi @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: GPL-2.0+ +/**
- Devicetree file with miscellaneous nodes that will be included
- at build time into the DTB. Currently being used for including
- capsule related information.
- */
+#ifdef CONFIG_EFI_CAPSULE_AUTHENTICATE +/ {
signature {
capsule-key = /incbin/(CONFIG_EFI_CAPSULE_ESL_FILE);
};
+}; +#endif /* CONFIG_EFI_CAPSULE_AUTHENTICATE */ diff --git a/arch/sandbox/dts/u-boot.dtsi b/arch/sandbox/dts/u-boot.dtsi new file mode 100644 index 0000000000..60bd004937 --- /dev/null +++ b/arch/sandbox/dts/u-boot.dtsi @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0+ +/*
- Devicetree file with miscellaneous nodes that will be included
- at build time into the DTB. Currently being used for including
- capsule related information.
- */
+#ifdef CONFIG_EFI_HAVE_CAPSULE_SUPPORT +/ { +#ifdef CONFIG_EFI_CAPSULE_AUTHENTICATE
signature {
capsule-key = /incbin/(CONFIG_EFI_CAPSULE_ESL_FILE);
};
+#endif +}; +#endif /* CONFIG_EFI_HAVE_CAPSULE_SUPPORT */ diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig index b6c4f735f2..779af4abc8 100644 --- a/configs/sandbox_defconfig +++ b/configs/sandbox_defconfig @@ -341,6 +341,7 @@ CONFIG_EFI_RUNTIME_UPDATE_CAPSULE=y CONFIG_EFI_CAPSULE_ON_DISK=y CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y CONFIG_EFI_CAPSULE_AUTHENTICATE=y +CONFIG_EFI_CAPSULE_ESL_FILE="../../../board/sandbox/SIGNER.esl"
Can we avoid the path here, and just use e.g. good.esl ?
Unfortunately no. I believe the way incbin works in dts is that it looks for the binary to be included in the same directory as the dts. Which is why I have to point it to the location of the esl relative to the dts.
Perhaps this could be fixed up later, e.g. by adding the board directory as an include dir when building the DT?
Again, this is not how incbin seems to work in dts. I tried putting the esl in one of the existing include directory locations, but it does not pick the file from those dirs. It works with the assumption that the bin file is to be in the same dir as the dts.
Yes but you can change that. Try adding to the cmd_dtc rule in Makefile.lib:
-i $(srctree)/board/$(BOARDDIR) \
We already have the
-I$(srctree)/include
and I had tried putting the esl under the include directory, but it was not found.
-sughosh
[..]
Regards, Simon

Hi Sughosh,
On Sat, 5 Aug 2023 at 12:47, Sughosh Ganu sughosh.ganu@linaro.org wrote:
hi Simon,
On Sun, 6 Aug 2023 at 00:06, Simon Glass sjg@chromium.org wrote:
Hi Sughosh,
On Sat, 5 Aug 2023 at 11:54, Sughosh Ganu sughosh.ganu@linaro.org wrote:
hi Simon,
On Sat, 5 Aug 2023 at 20:34, Simon Glass sjg@chromium.org wrote:
Hi Sughosh,
On Sat, 5 Aug 2023 at 05:35, Sughosh Ganu sughosh.ganu@linaro.org wrote:
The EFI capsule authentication logic in u-boot expects the public key in the form of an EFI Signature List(ESL) to be provided as part of the platform's dtb. Currently, the embedding of the ESL file into the dtb needs to be done manually.
Add a signature node in the u-boot dtsi file and include the public key through the capsule-key property. This file is per architecture, and is currently being added for sandbox and arm architectures. It will have to be added for other architectures which need to enable capsule authentication support.
The path to the ESL file is specified through the CONFIG_EFI_CAPSULE_ESL_FILE symbol.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
Changes since V6:
- Populate the CONFIG_EFI_CAPSULE_ESL_FILE symbol for sandbox and sandbox_flattree which enable capsule authentication.
Note: Simon Glass had asked me to rid of the CONFIG_EFI_HAVE_CAPSULE_SUPPORT ifdef used in the sandbox' u-boot.dtsi file. However, that results in the sandbox_vpl test failing in CI. Hence that check has been kept.
arch/arm/dts/u-boot.dtsi | 14 ++++++++++++++ arch/sandbox/dts/u-boot.dtsi | 17 +++++++++++++++++ configs/sandbox_defconfig | 1 + configs/sandbox_flattree_defconfig | 1 + lib/efi_loader/Kconfig | 9 +++++++++ 5 files changed, 42 insertions(+) create mode 100644 arch/arm/dts/u-boot.dtsi create mode 100644 arch/sandbox/dts/u-boot.dtsi
diff --git a/arch/arm/dts/u-boot.dtsi b/arch/arm/dts/u-boot.dtsi new file mode 100644 index 0000000000..4f31da4521 --- /dev/null +++ b/arch/arm/dts/u-boot.dtsi @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: GPL-2.0+ +/**
- Devicetree file with miscellaneous nodes that will be included
- at build time into the DTB. Currently being used for including
- capsule related information.
- */
+#ifdef CONFIG_EFI_CAPSULE_AUTHENTICATE +/ {
signature {
capsule-key = /incbin/(CONFIG_EFI_CAPSULE_ESL_FILE);
};
+}; +#endif /* CONFIG_EFI_CAPSULE_AUTHENTICATE */ diff --git a/arch/sandbox/dts/u-boot.dtsi b/arch/sandbox/dts/u-boot.dtsi new file mode 100644 index 0000000000..60bd004937 --- /dev/null +++ b/arch/sandbox/dts/u-boot.dtsi @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0+ +/*
- Devicetree file with miscellaneous nodes that will be included
- at build time into the DTB. Currently being used for including
- capsule related information.
- */
+#ifdef CONFIG_EFI_HAVE_CAPSULE_SUPPORT +/ { +#ifdef CONFIG_EFI_CAPSULE_AUTHENTICATE
signature {
capsule-key = /incbin/(CONFIG_EFI_CAPSULE_ESL_FILE);
};
+#endif +}; +#endif /* CONFIG_EFI_HAVE_CAPSULE_SUPPORT */ diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig index b6c4f735f2..779af4abc8 100644 --- a/configs/sandbox_defconfig +++ b/configs/sandbox_defconfig @@ -341,6 +341,7 @@ CONFIG_EFI_RUNTIME_UPDATE_CAPSULE=y CONFIG_EFI_CAPSULE_ON_DISK=y CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y CONFIG_EFI_CAPSULE_AUTHENTICATE=y +CONFIG_EFI_CAPSULE_ESL_FILE="../../../board/sandbox/SIGNER.esl"
Can we avoid the path here, and just use e.g. good.esl ?
Unfortunately no. I believe the way incbin works in dts is that it looks for the binary to be included in the same directory as the dts. Which is why I have to point it to the location of the esl relative to the dts.
Perhaps this could be fixed up later, e.g. by adding the board directory as an include dir when building the DT?
Again, this is not how incbin seems to work in dts. I tried putting the esl in one of the existing include directory locations, but it does not pick the file from those dirs. It works with the assumption that the bin file is to be in the same dir as the dts.
Yes but you can change that. Try adding to the cmd_dtc rule in Makefile.lib:
-i $(srctree)/board/$(BOARDDIR) \
We already have the
-I$(srctree)/include
and I had tried putting the esl under the include directory, but it was not found.
I think the board directory is better, though. It isn't really an include.
Regards, Simon

hi Simon,
On Sun, 6 Aug 2023 at 00:35, Simon Glass sjg@chromium.org wrote:
Hi Sughosh,
On Sat, 5 Aug 2023 at 12:47, Sughosh Ganu sughosh.ganu@linaro.org wrote:
hi Simon,
On Sun, 6 Aug 2023 at 00:06, Simon Glass sjg@chromium.org wrote:
Hi Sughosh,
On Sat, 5 Aug 2023 at 11:54, Sughosh Ganu sughosh.ganu@linaro.org wrote:
hi Simon,
On Sat, 5 Aug 2023 at 20:34, Simon Glass sjg@chromium.org wrote:
Hi Sughosh,
On Sat, 5 Aug 2023 at 05:35, Sughosh Ganu sughosh.ganu@linaro.org wrote:
The EFI capsule authentication logic in u-boot expects the public key in the form of an EFI Signature List(ESL) to be provided as part of the platform's dtb. Currently, the embedding of the ESL file into the dtb needs to be done manually.
Add a signature node in the u-boot dtsi file and include the public key through the capsule-key property. This file is per architecture, and is currently being added for sandbox and arm architectures. It will have to be added for other architectures which need to enable capsule authentication support.
The path to the ESL file is specified through the CONFIG_EFI_CAPSULE_ESL_FILE symbol.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
Changes since V6:
- Populate the CONFIG_EFI_CAPSULE_ESL_FILE symbol for sandbox and sandbox_flattree which enable capsule authentication.
Note: Simon Glass had asked me to rid of the CONFIG_EFI_HAVE_CAPSULE_SUPPORT ifdef used in the sandbox' u-boot.dtsi file. However, that results in the sandbox_vpl test failing in CI. Hence that check has been kept.
arch/arm/dts/u-boot.dtsi | 14 ++++++++++++++ arch/sandbox/dts/u-boot.dtsi | 17 +++++++++++++++++ configs/sandbox_defconfig | 1 + configs/sandbox_flattree_defconfig | 1 + lib/efi_loader/Kconfig | 9 +++++++++ 5 files changed, 42 insertions(+) create mode 100644 arch/arm/dts/u-boot.dtsi create mode 100644 arch/sandbox/dts/u-boot.dtsi
diff --git a/arch/arm/dts/u-boot.dtsi b/arch/arm/dts/u-boot.dtsi new file mode 100644 index 0000000000..4f31da4521 --- /dev/null +++ b/arch/arm/dts/u-boot.dtsi @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: GPL-2.0+ +/**
- Devicetree file with miscellaneous nodes that will be included
- at build time into the DTB. Currently being used for including
- capsule related information.
- */
+#ifdef CONFIG_EFI_CAPSULE_AUTHENTICATE +/ {
signature {
capsule-key = /incbin/(CONFIG_EFI_CAPSULE_ESL_FILE);
};
+}; +#endif /* CONFIG_EFI_CAPSULE_AUTHENTICATE */ diff --git a/arch/sandbox/dts/u-boot.dtsi b/arch/sandbox/dts/u-boot.dtsi new file mode 100644 index 0000000000..60bd004937 --- /dev/null +++ b/arch/sandbox/dts/u-boot.dtsi @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0+ +/*
- Devicetree file with miscellaneous nodes that will be included
- at build time into the DTB. Currently being used for including
- capsule related information.
- */
+#ifdef CONFIG_EFI_HAVE_CAPSULE_SUPPORT +/ { +#ifdef CONFIG_EFI_CAPSULE_AUTHENTICATE
signature {
capsule-key = /incbin/(CONFIG_EFI_CAPSULE_ESL_FILE);
};
+#endif +}; +#endif /* CONFIG_EFI_HAVE_CAPSULE_SUPPORT */ diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig index b6c4f735f2..779af4abc8 100644 --- a/configs/sandbox_defconfig +++ b/configs/sandbox_defconfig @@ -341,6 +341,7 @@ CONFIG_EFI_RUNTIME_UPDATE_CAPSULE=y CONFIG_EFI_CAPSULE_ON_DISK=y CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y CONFIG_EFI_CAPSULE_AUTHENTICATE=y +CONFIG_EFI_CAPSULE_ESL_FILE="../../../board/sandbox/SIGNER.esl"
Can we avoid the path here, and just use e.g. good.esl ?
Unfortunately no. I believe the way incbin works in dts is that it looks for the binary to be included in the same directory as the dts. Which is why I have to point it to the location of the esl relative to the dts.
Perhaps this could be fixed up later, e.g. by adding the board directory as an include dir when building the DT?
Again, this is not how incbin seems to work in dts. I tried putting the esl in one of the existing include directory locations, but it does not pick the file from those dirs. It works with the assumption that the bin file is to be in the same dir as the dts.
Yes but you can change that. Try adding to the cmd_dtc rule in Makefile.lib:
-i $(srctree)/board/$(BOARDDIR) \
We already have the
-I$(srctree)/include
and I had tried putting the esl under the include directory, but it was not found.
I think the board directory is better, though. It isn't really an include.
What I was trying to say is that putting the esl file under an include directory does not work, in that the dtc is not able to locate the esl file from the include directories. The incbin file has to be in a directory relative to that of the dts file.
I just put the SIGNER.esl under the include/ directory to check if dtc is able to locate the file from an include directory, and it does not.
-sughosh
Regards, Simon

On Sat, Aug 05, 2023 at 09:03:53AM -0600, Simon Glass wrote:
Hi Sughosh,
On Sat, 5 Aug 2023 at 05:35, Sughosh Ganu sughosh.ganu@linaro.org wrote:
The EFI capsule authentication logic in u-boot expects the public key in the form of an EFI Signature List(ESL) to be provided as part of the platform's dtb. Currently, the embedding of the ESL file into the dtb needs to be done manually.
Add a signature node in the u-boot dtsi file and include the public key through the capsule-key property. This file is per architecture, and is currently being added for sandbox and arm architectures. It will have to be added for other architectures which need to enable capsule authentication support.
The path to the ESL file is specified through the CONFIG_EFI_CAPSULE_ESL_FILE symbol.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
Changes since V6:
- Populate the CONFIG_EFI_CAPSULE_ESL_FILE symbol for sandbox and sandbox_flattree which enable capsule authentication.
Note: Simon Glass had asked me to rid of the CONFIG_EFI_HAVE_CAPSULE_SUPPORT ifdef used in the sandbox' u-boot.dtsi file. However, that results in the sandbox_vpl test failing in CI. Hence that check has been kept.
arch/arm/dts/u-boot.dtsi | 14 ++++++++++++++ arch/sandbox/dts/u-boot.dtsi | 17 +++++++++++++++++
We've already had some go-round as to why this basically identical file can't be in like lib/efi_loader/ or something, yes?
configs/sandbox_defconfig | 1 + configs/sandbox_flattree_defconfig | 1 + lib/efi_loader/Kconfig | 9 +++++++++ 5 files changed, 42 insertions(+) create mode 100644 arch/arm/dts/u-boot.dtsi create mode 100644 arch/sandbox/dts/u-boot.dtsi
diff --git a/arch/arm/dts/u-boot.dtsi b/arch/arm/dts/u-boot.dtsi new file mode 100644 index 0000000000..4f31da4521 --- /dev/null +++ b/arch/arm/dts/u-boot.dtsi @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: GPL-2.0+ +/**
- Devicetree file with miscellaneous nodes that will be included
- at build time into the DTB. Currently being used for including
- capsule related information.
- */
+#ifdef CONFIG_EFI_CAPSULE_AUTHENTICATE +/ {
signature {
capsule-key = /incbin/(CONFIG_EFI_CAPSULE_ESL_FILE);
};
+}; +#endif /* CONFIG_EFI_CAPSULE_AUTHENTICATE */ diff --git a/arch/sandbox/dts/u-boot.dtsi b/arch/sandbox/dts/u-boot.dtsi new file mode 100644 index 0000000000..60bd004937 --- /dev/null +++ b/arch/sandbox/dts/u-boot.dtsi @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0+ +/*
- Devicetree file with miscellaneous nodes that will be included
- at build time into the DTB. Currently being used for including
- capsule related information.
- */
+#ifdef CONFIG_EFI_HAVE_CAPSULE_SUPPORT +/ { +#ifdef CONFIG_EFI_CAPSULE_AUTHENTICATE
signature {
capsule-key = /incbin/(CONFIG_EFI_CAPSULE_ESL_FILE);
};
+#endif +}; +#endif /* CONFIG_EFI_HAVE_CAPSULE_SUPPORT */
And why are these two different?
diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig index a22e47616f..0d559ff3a1 100644 --- a/lib/efi_loader/Kconfig +++ b/lib/efi_loader/Kconfig @@ -235,6 +235,15 @@ config EFI_CAPSULE_MAX Select the max capsule index value used for capsule report variables. This value is used to create CapsuleMax variable.
+config EFI_CAPSULE_ESL_FILE
string "Path to the EFI Signature List File"
default ""
No default.
depends on EFI_CAPSULE_AUTHENTICATE
help
Provides the absolute path to the EFI Signature List file which
It isn't really an absolute path as it doesn't start with /
You really can't/shouldn't use absolute paths in a U-Boot build.
You can't as it will break reproducible builds (or make them harder than required).

On Sun, 6 Aug 2023 at 03:42, Tom Rini trini@konsulko.com wrote:
On Sat, Aug 05, 2023 at 09:03:53AM -0600, Simon Glass wrote:
Hi Sughosh,
On Sat, 5 Aug 2023 at 05:35, Sughosh Ganu sughosh.ganu@linaro.org wrote:
The EFI capsule authentication logic in u-boot expects the public key in the form of an EFI Signature List(ESL) to be provided as part of the platform's dtb. Currently, the embedding of the ESL file into the dtb needs to be done manually.
Add a signature node in the u-boot dtsi file and include the public key through the capsule-key property. This file is per architecture, and is currently being added for sandbox and arm architectures. It will have to be added for other architectures which need to enable capsule authentication support.
The path to the ESL file is specified through the CONFIG_EFI_CAPSULE_ESL_FILE symbol.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
Changes since V6:
- Populate the CONFIG_EFI_CAPSULE_ESL_FILE symbol for sandbox and sandbox_flattree which enable capsule authentication.
Note: Simon Glass had asked me to rid of the CONFIG_EFI_HAVE_CAPSULE_SUPPORT ifdef used in the sandbox' u-boot.dtsi file. However, that results in the sandbox_vpl test failing in CI. Hence that check has been kept.
arch/arm/dts/u-boot.dtsi | 14 ++++++++++++++ arch/sandbox/dts/u-boot.dtsi | 17 +++++++++++++++++
We've already had some go-round as to why this basically identical file can't be in like lib/efi_loader/ or something, yes?
Yes, these need to be under the arch/$(ARCH)/dts/ directory for the dtc to include them as part of the platform's dts.
configs/sandbox_defconfig | 1 + configs/sandbox_flattree_defconfig | 1 + lib/efi_loader/Kconfig | 9 +++++++++ 5 files changed, 42 insertions(+) create mode 100644 arch/arm/dts/u-boot.dtsi create mode 100644 arch/sandbox/dts/u-boot.dtsi
diff --git a/arch/arm/dts/u-boot.dtsi b/arch/arm/dts/u-boot.dtsi new file mode 100644 index 0000000000..4f31da4521 --- /dev/null +++ b/arch/arm/dts/u-boot.dtsi @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: GPL-2.0+ +/**
- Devicetree file with miscellaneous nodes that will be included
- at build time into the DTB. Currently being used for including
- capsule related information.
- */
+#ifdef CONFIG_EFI_CAPSULE_AUTHENTICATE +/ {
signature {
capsule-key = /incbin/(CONFIG_EFI_CAPSULE_ESL_FILE);
};
+}; +#endif /* CONFIG_EFI_CAPSULE_AUTHENTICATE */ diff --git a/arch/sandbox/dts/u-boot.dtsi b/arch/sandbox/dts/u-boot.dtsi new file mode 100644 index 0000000000..60bd004937 --- /dev/null +++ b/arch/sandbox/dts/u-boot.dtsi @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0+ +/*
- Devicetree file with miscellaneous nodes that will be included
- at build time into the DTB. Currently being used for including
- capsule related information.
- */
+#ifdef CONFIG_EFI_HAVE_CAPSULE_SUPPORT +/ { +#ifdef CONFIG_EFI_CAPSULE_AUTHENTICATE
signature {
capsule-key = /incbin/(CONFIG_EFI_CAPSULE_ESL_FILE);
};
+#endif +}; +#endif /* CONFIG_EFI_HAVE_CAPSULE_SUPPORT */
And why are these two different?
For the sandbox's u-boot.dtsi, we need CONFIG_EFI_CAPSULE_AUTHENTICATE so that the ESL file is looked for only when capsule authentication is enabled. The outer CONFIG_EFI_HAVE_CAPSULE_SUPPORT is to not include stuff from this file unless capsule support is enabled. Simon had asked me to rid of the outer ifdef, but the sandbox_vpl test fails without it.
diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig index a22e47616f..0d559ff3a1 100644 --- a/lib/efi_loader/Kconfig +++ b/lib/efi_loader/Kconfig @@ -235,6 +235,15 @@ config EFI_CAPSULE_MAX Select the max capsule index value used for capsule report variables. This value is used to create CapsuleMax variable.
+config EFI_CAPSULE_ESL_FILE
string "Path to the EFI Signature List File"
default ""
No default.
Okay
depends on EFI_CAPSULE_AUTHENTICATE
help
Provides the absolute path to the EFI Signature List file which
It isn't really an absolute path as it doesn't start with /
You really can't/shouldn't use absolute paths in a U-Boot build.
You can't as it will break reproducible builds (or make them harder than required).
Okay
-sughosh

Hi Sughosh,
On Sun, 6 Aug 2023 at 05:18, Sughosh Ganu sughosh.ganu@linaro.org wrote:
On Sun, 6 Aug 2023 at 03:42, Tom Rini trini@konsulko.com wrote:
On Sat, Aug 05, 2023 at 09:03:53AM -0600, Simon Glass wrote:
Hi Sughosh,
On Sat, 5 Aug 2023 at 05:35, Sughosh Ganu sughosh.ganu@linaro.org wrote:
The EFI capsule authentication logic in u-boot expects the public key in the form of an EFI Signature List(ESL) to be provided as part of the platform's dtb. Currently, the embedding of the ESL file into the dtb needs to be done manually.
Add a signature node in the u-boot dtsi file and include the public key through the capsule-key property. This file is per architecture, and is currently being added for sandbox and arm architectures. It will have to be added for other architectures which need to enable capsule authentication support.
The path to the ESL file is specified through the CONFIG_EFI_CAPSULE_ESL_FILE symbol.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
Changes since V6:
- Populate the CONFIG_EFI_CAPSULE_ESL_FILE symbol for sandbox and sandbox_flattree which enable capsule authentication.
Note: Simon Glass had asked me to rid of the CONFIG_EFI_HAVE_CAPSULE_SUPPORT ifdef used in the sandbox' u-boot.dtsi file. However, that results in the sandbox_vpl test failing in CI. Hence that check has been kept.
arch/arm/dts/u-boot.dtsi | 14 ++++++++++++++ arch/sandbox/dts/u-boot.dtsi | 17 +++++++++++++++++
We've already had some go-round as to why this basically identical file can't be in like lib/efi_loader/ or something, yes?
Yes, these need to be under the arch/$(ARCH)/dts/ directory for the dtc to include them as part of the platform's dts.
configs/sandbox_defconfig | 1 + configs/sandbox_flattree_defconfig | 1 + lib/efi_loader/Kconfig | 9 +++++++++ 5 files changed, 42 insertions(+) create mode 100644 arch/arm/dts/u-boot.dtsi create mode 100644 arch/sandbox/dts/u-boot.dtsi
diff --git a/arch/arm/dts/u-boot.dtsi b/arch/arm/dts/u-boot.dtsi new file mode 100644 index 0000000000..4f31da4521 --- /dev/null +++ b/arch/arm/dts/u-boot.dtsi @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: GPL-2.0+ +/**
- Devicetree file with miscellaneous nodes that will be included
- at build time into the DTB. Currently being used for including
- capsule related information.
- */
+#ifdef CONFIG_EFI_CAPSULE_AUTHENTICATE +/ {
signature {
capsule-key = /incbin/(CONFIG_EFI_CAPSULE_ESL_FILE);
};
+}; +#endif /* CONFIG_EFI_CAPSULE_AUTHENTICATE */ diff --git a/arch/sandbox/dts/u-boot.dtsi b/arch/sandbox/dts/u-boot.dtsi new file mode 100644 index 0000000000..60bd004937 --- /dev/null +++ b/arch/sandbox/dts/u-boot.dtsi @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0+ +/*
- Devicetree file with miscellaneous nodes that will be included
- at build time into the DTB. Currently being used for including
- capsule related information.
- */
+#ifdef CONFIG_EFI_HAVE_CAPSULE_SUPPORT +/ { +#ifdef CONFIG_EFI_CAPSULE_AUTHENTICATE
signature {
capsule-key = /incbin/(CONFIG_EFI_CAPSULE_ESL_FILE);
};
+#endif +}; +#endif /* CONFIG_EFI_HAVE_CAPSULE_SUPPORT */
And why are these two different?
For the sandbox's u-boot.dtsi, we need CONFIG_EFI_CAPSULE_AUTHENTICATE so that the ESL file is looked for only when capsule authentication is enabled. The outer CONFIG_EFI_HAVE_CAPSULE_SUPPORT is to not include stuff from this file unless capsule support is enabled. Simon had asked me to rid of the outer ifdef, but the sandbox_vpl test fails without it.
Did you look at why? From what I can see, it is because you are adding the multiple-images tag in binman but not updating VPL. This patch seems to fix it:
Signed-off-by: Simon Glass sjg@chromium.org ---
arch/sandbox/dts/sandbox_vpl.dtsi | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/arch/sandbox/dts/sandbox_vpl.dtsi b/arch/sandbox/dts/sandbox_vpl.dtsi index c7dc00a8d2d..83e7657d5db 100644 --- a/arch/sandbox/dts/sandbox_vpl.dtsi +++ b/arch/sandbox/dts/sandbox_vpl.dtsi @@ -4,6 +4,11 @@ */
&binman { + image: image { + }; +}; + +&image { u-boot-tpl-elf { no-expanded; };
-- 2.34.1
I think it makes sense to generate the capsule definition for all sandbox builds so you can drop the #ifdefs. Once the tests are tidied up, it won't have that much impact...if it annoys us we can drop it later. The EFI_CAPSULE_ESL_FILE Kconfig needs to be present always (no 'depends on'), default to "", otherwise you need an annoying #ifdef in the .dtsi file.
Regards, Simon

On Sun, Aug 06, 2023 at 04:48:11PM +0530, Sughosh Ganu wrote:
On Sun, 6 Aug 2023 at 03:42, Tom Rini trini@konsulko.com wrote:
On Sat, Aug 05, 2023 at 09:03:53AM -0600, Simon Glass wrote:
Hi Sughosh,
On Sat, 5 Aug 2023 at 05:35, Sughosh Ganu sughosh.ganu@linaro.org wrote:
The EFI capsule authentication logic in u-boot expects the public key in the form of an EFI Signature List(ESL) to be provided as part of the platform's dtb. Currently, the embedding of the ESL file into the dtb needs to be done manually.
Add a signature node in the u-boot dtsi file and include the public key through the capsule-key property. This file is per architecture, and is currently being added for sandbox and arm architectures. It will have to be added for other architectures which need to enable capsule authentication support.
The path to the ESL file is specified through the CONFIG_EFI_CAPSULE_ESL_FILE symbol.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
Changes since V6:
- Populate the CONFIG_EFI_CAPSULE_ESL_FILE symbol for sandbox and sandbox_flattree which enable capsule authentication.
Note: Simon Glass had asked me to rid of the CONFIG_EFI_HAVE_CAPSULE_SUPPORT ifdef used in the sandbox' u-boot.dtsi file. However, that results in the sandbox_vpl test failing in CI. Hence that check has been kept.
arch/arm/dts/u-boot.dtsi | 14 ++++++++++++++ arch/sandbox/dts/u-boot.dtsi | 17 +++++++++++++++++
We've already had some go-round as to why this basically identical file can't be in like lib/efi_loader/ or something, yes?
Yes, these need to be under the arch/$(ARCH)/dts/ directory for the dtc to include them as part of the platform's dts.
That logic is just in scripts/ somewhere and can be extended. We can add flags to specific files when needed.
configs/sandbox_defconfig | 1 + configs/sandbox_flattree_defconfig | 1 + lib/efi_loader/Kconfig | 9 +++++++++ 5 files changed, 42 insertions(+) create mode 100644 arch/arm/dts/u-boot.dtsi create mode 100644 arch/sandbox/dts/u-boot.dtsi
diff --git a/arch/arm/dts/u-boot.dtsi b/arch/arm/dts/u-boot.dtsi new file mode 100644 index 0000000000..4f31da4521 --- /dev/null +++ b/arch/arm/dts/u-boot.dtsi @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: GPL-2.0+ +/**
- Devicetree file with miscellaneous nodes that will be included
- at build time into the DTB. Currently being used for including
- capsule related information.
- */
+#ifdef CONFIG_EFI_CAPSULE_AUTHENTICATE +/ {
signature {
capsule-key = /incbin/(CONFIG_EFI_CAPSULE_ESL_FILE);
};
+}; +#endif /* CONFIG_EFI_CAPSULE_AUTHENTICATE */ diff --git a/arch/sandbox/dts/u-boot.dtsi b/arch/sandbox/dts/u-boot.dtsi new file mode 100644 index 0000000000..60bd004937 --- /dev/null +++ b/arch/sandbox/dts/u-boot.dtsi @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0+ +/*
- Devicetree file with miscellaneous nodes that will be included
- at build time into the DTB. Currently being used for including
- capsule related information.
- */
+#ifdef CONFIG_EFI_HAVE_CAPSULE_SUPPORT +/ { +#ifdef CONFIG_EFI_CAPSULE_AUTHENTICATE
signature {
capsule-key = /incbin/(CONFIG_EFI_CAPSULE_ESL_FILE);
};
+#endif +}; +#endif /* CONFIG_EFI_HAVE_CAPSULE_SUPPORT */
And why are these two different?
For the sandbox's u-boot.dtsi, we need CONFIG_EFI_CAPSULE_AUTHENTICATE so that the ESL file is looked for only when capsule authentication is enabled. The outer CONFIG_EFI_HAVE_CAPSULE_SUPPORT is to not include stuff from this file unless capsule support is enabled. Simon had asked me to rid of the outer ifdef, but the sandbox_vpl test fails without it.
Sounds like this needs more re-working all around then, as we should only have one of these fragments, and it probably shouldn't be included when not needed.

Hi,
On Sun, 6 Aug 2023 at 11:25, Tom Rini trini@konsulko.com wrote:
On Sun, Aug 06, 2023 at 04:48:11PM +0530, Sughosh Ganu wrote:
On Sun, 6 Aug 2023 at 03:42, Tom Rini trini@konsulko.com wrote:
On Sat, Aug 05, 2023 at 09:03:53AM -0600, Simon Glass wrote:
Hi Sughosh,
On Sat, 5 Aug 2023 at 05:35, Sughosh Ganu sughosh.ganu@linaro.org wrote:
The EFI capsule authentication logic in u-boot expects the public key in the form of an EFI Signature List(ESL) to be provided as part of the platform's dtb. Currently, the embedding of the ESL file into the dtb needs to be done manually.
Add a signature node in the u-boot dtsi file and include the public key through the capsule-key property. This file is per architecture, and is currently being added for sandbox and arm architectures. It will have to be added for other architectures which need to enable capsule authentication support.
The path to the ESL file is specified through the CONFIG_EFI_CAPSULE_ESL_FILE symbol.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
Changes since V6:
- Populate the CONFIG_EFI_CAPSULE_ESL_FILE symbol for sandbox and sandbox_flattree which enable capsule authentication.
Note: Simon Glass had asked me to rid of the CONFIG_EFI_HAVE_CAPSULE_SUPPORT ifdef used in the sandbox' u-boot.dtsi file. However, that results in the sandbox_vpl test failing in CI. Hence that check has been kept.
arch/arm/dts/u-boot.dtsi | 14 ++++++++++++++ arch/sandbox/dts/u-boot.dtsi | 17 +++++++++++++++++
We've already had some go-round as to why this basically identical file can't be in like lib/efi_loader/ or something, yes?
Yes, these need to be under the arch/$(ARCH)/dts/ directory for the dtc to include them as part of the platform's dts.
That logic is just in scripts/ somewhere and can be extended. We can add flags to specific files when needed.
configs/sandbox_defconfig | 1 + configs/sandbox_flattree_defconfig | 1 + lib/efi_loader/Kconfig | 9 +++++++++ 5 files changed, 42 insertions(+) create mode 100644 arch/arm/dts/u-boot.dtsi create mode 100644 arch/sandbox/dts/u-boot.dtsi
diff --git a/arch/arm/dts/u-boot.dtsi b/arch/arm/dts/u-boot.dtsi new file mode 100644 index 0000000000..4f31da4521 --- /dev/null +++ b/arch/arm/dts/u-boot.dtsi @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: GPL-2.0+ +/**
- Devicetree file with miscellaneous nodes that will be included
- at build time into the DTB. Currently being used for including
- capsule related information.
- */
+#ifdef CONFIG_EFI_CAPSULE_AUTHENTICATE +/ {
signature {
capsule-key = /incbin/(CONFIG_EFI_CAPSULE_ESL_FILE);
};
+}; +#endif /* CONFIG_EFI_CAPSULE_AUTHENTICATE */ diff --git a/arch/sandbox/dts/u-boot.dtsi b/arch/sandbox/dts/u-boot.dtsi new file mode 100644 index 0000000000..60bd004937 --- /dev/null +++ b/arch/sandbox/dts/u-boot.dtsi @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0+ +/*
- Devicetree file with miscellaneous nodes that will be included
- at build time into the DTB. Currently being used for including
- capsule related information.
- */
+#ifdef CONFIG_EFI_HAVE_CAPSULE_SUPPORT +/ { +#ifdef CONFIG_EFI_CAPSULE_AUTHENTICATE
signature {
capsule-key = /incbin/(CONFIG_EFI_CAPSULE_ESL_FILE);
};
+#endif +}; +#endif /* CONFIG_EFI_HAVE_CAPSULE_SUPPORT */
And why are these two different?
For the sandbox's u-boot.dtsi, we need CONFIG_EFI_CAPSULE_AUTHENTICATE so that the ESL file is looked for only when capsule authentication is enabled. The outer CONFIG_EFI_HAVE_CAPSULE_SUPPORT is to not include stuff from this file unless capsule support is enabled. Simon had asked me to rid of the outer ifdef, but the sandbox_vpl test fails without it.
Sounds like this needs more re-working all around then, as we should only have one of these fragments, and it probably shouldn't be included when not needed.
Another option is to include the actual file (or even the data!) in the capsule-key property for sandbox, rather than the CONFIG.
Regards, Simon

hi Simon,
On Mon, 7 Aug 2023 at 00:16, Simon Glass sjg@chromium.org wrote:
Hi,
On Sun, 6 Aug 2023 at 11:25, Tom Rini trini@konsulko.com wrote:
On Sun, Aug 06, 2023 at 04:48:11PM +0530, Sughosh Ganu wrote:
On Sun, 6 Aug 2023 at 03:42, Tom Rini trini@konsulko.com wrote:
On Sat, Aug 05, 2023 at 09:03:53AM -0600, Simon Glass wrote:
Hi Sughosh,
On Sat, 5 Aug 2023 at 05:35, Sughosh Ganu sughosh.ganu@linaro.org wrote:
The EFI capsule authentication logic in u-boot expects the public key in the form of an EFI Signature List(ESL) to be provided as part of the platform's dtb. Currently, the embedding of the ESL file into the dtb needs to be done manually.
Add a signature node in the u-boot dtsi file and include the public key through the capsule-key property. This file is per architecture, and is currently being added for sandbox and arm architectures. It will have to be added for other architectures which need to enable capsule authentication support.
The path to the ESL file is specified through the CONFIG_EFI_CAPSULE_ESL_FILE symbol.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
Changes since V6:
- Populate the CONFIG_EFI_CAPSULE_ESL_FILE symbol for sandbox and sandbox_flattree which enable capsule authentication.
Note: Simon Glass had asked me to rid of the CONFIG_EFI_HAVE_CAPSULE_SUPPORT ifdef used in the sandbox' u-boot.dtsi file. However, that results in the sandbox_vpl test failing in CI. Hence that check has been kept.
arch/arm/dts/u-boot.dtsi | 14 ++++++++++++++ arch/sandbox/dts/u-boot.dtsi | 17 +++++++++++++++++
We've already had some go-round as to why this basically identical file can't be in like lib/efi_loader/ or something, yes?
Yes, these need to be under the arch/$(ARCH)/dts/ directory for the dtc to include them as part of the platform's dts.
That logic is just in scripts/ somewhere and can be extended. We can add flags to specific files when needed.
configs/sandbox_defconfig | 1 + configs/sandbox_flattree_defconfig | 1 + lib/efi_loader/Kconfig | 9 +++++++++ 5 files changed, 42 insertions(+) create mode 100644 arch/arm/dts/u-boot.dtsi create mode 100644 arch/sandbox/dts/u-boot.dtsi
diff --git a/arch/arm/dts/u-boot.dtsi b/arch/arm/dts/u-boot.dtsi new file mode 100644 index 0000000000..4f31da4521 --- /dev/null +++ b/arch/arm/dts/u-boot.dtsi @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: GPL-2.0+ +/**
- Devicetree file with miscellaneous nodes that will be included
- at build time into the DTB. Currently being used for including
- capsule related information.
- */
+#ifdef CONFIG_EFI_CAPSULE_AUTHENTICATE +/ {
signature {
capsule-key = /incbin/(CONFIG_EFI_CAPSULE_ESL_FILE);
};
+}; +#endif /* CONFIG_EFI_CAPSULE_AUTHENTICATE */ diff --git a/arch/sandbox/dts/u-boot.dtsi b/arch/sandbox/dts/u-boot.dtsi new file mode 100644 index 0000000000..60bd004937 --- /dev/null +++ b/arch/sandbox/dts/u-boot.dtsi @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0+ +/*
- Devicetree file with miscellaneous nodes that will be included
- at build time into the DTB. Currently being used for including
- capsule related information.
- */
+#ifdef CONFIG_EFI_HAVE_CAPSULE_SUPPORT +/ { +#ifdef CONFIG_EFI_CAPSULE_AUTHENTICATE
signature {
capsule-key = /incbin/(CONFIG_EFI_CAPSULE_ESL_FILE);
};
+#endif +}; +#endif /* CONFIG_EFI_HAVE_CAPSULE_SUPPORT */
And why are these two different?
For the sandbox's u-boot.dtsi, we need CONFIG_EFI_CAPSULE_AUTHENTICATE so that the ESL file is looked for only when capsule authentication is enabled. The outer CONFIG_EFI_HAVE_CAPSULE_SUPPORT is to not include stuff from this file unless capsule support is enabled. Simon had asked me to rid of the outer ifdef, but the sandbox_vpl test fails without it.
Sounds like this needs more re-working all around then, as we should only have one of these fragments, and it probably shouldn't be included when not needed.
Another option is to include the actual file (or even the data!) in the capsule-key property for sandbox, rather than the CONFIG.
Will this not mean that the dtsi file will have to be included explicitly for all the files which want to include the public key? I think it will be easier if the dtsi file can get included automatically, similar to u-boot.dtsi. I will check if we can put a dtsi file under lib/efi_loader/ and get that included automatically with capsule auth enabled, similar to how u-boot.dtsi gets included.
-sughosh

Hi Sughosh,
On Sun, 6 Aug 2023 at 13:34, Sughosh Ganu sughosh.ganu@linaro.org wrote:
hi Simon,
On Mon, 7 Aug 2023 at 00:16, Simon Glass sjg@chromium.org wrote:
Hi,
On Sun, 6 Aug 2023 at 11:25, Tom Rini trini@konsulko.com wrote:
On Sun, Aug 06, 2023 at 04:48:11PM +0530, Sughosh Ganu wrote:
On Sun, 6 Aug 2023 at 03:42, Tom Rini trini@konsulko.com wrote:
On Sat, Aug 05, 2023 at 09:03:53AM -0600, Simon Glass wrote:
Hi Sughosh,
On Sat, 5 Aug 2023 at 05:35, Sughosh Ganu sughosh.ganu@linaro.org wrote: > > The EFI capsule authentication logic in u-boot expects the public key > in the form of an EFI Signature List(ESL) to be provided as part of > the platform's dtb. Currently, the embedding of the ESL file into the > dtb needs to be done manually. > > Add a signature node in the u-boot dtsi file and include the public > key through the capsule-key property. This file is per architecture, > and is currently being added for sandbox and arm architectures. It > will have to be added for other architectures which need to enable > capsule authentication support. > > The path to the ESL file is specified through the > CONFIG_EFI_CAPSULE_ESL_FILE symbol. > > Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org > --- > Changes since V6: > * Populate the CONFIG_EFI_CAPSULE_ESL_FILE symbol for sandbox and > sandbox_flattree which enable capsule authentication. > > Note: > Simon Glass had asked me to rid of the CONFIG_EFI_HAVE_CAPSULE_SUPPORT > ifdef used in the sandbox' u-boot.dtsi file. However, that results in > the sandbox_vpl test failing in CI. Hence that check has been kept. > > > arch/arm/dts/u-boot.dtsi | 14 ++++++++++++++ > arch/sandbox/dts/u-boot.dtsi | 17 +++++++++++++++++
We've already had some go-round as to why this basically identical file can't be in like lib/efi_loader/ or something, yes?
Yes, these need to be under the arch/$(ARCH)/dts/ directory for the dtc to include them as part of the platform's dts.
That logic is just in scripts/ somewhere and can be extended. We can add flags to specific files when needed.
> configs/sandbox_defconfig | 1 + > configs/sandbox_flattree_defconfig | 1 + > lib/efi_loader/Kconfig | 9 +++++++++ > 5 files changed, 42 insertions(+) > create mode 100644 arch/arm/dts/u-boot.dtsi > create mode 100644 arch/sandbox/dts/u-boot.dtsi > > diff --git a/arch/arm/dts/u-boot.dtsi b/arch/arm/dts/u-boot.dtsi > new file mode 100644 > index 0000000000..4f31da4521 > --- /dev/null > +++ b/arch/arm/dts/u-boot.dtsi > @@ -0,0 +1,14 @@ > +// SPDX-License-Identifier: GPL-2.0+ > +/** > + * Devicetree file with miscellaneous nodes that will be included > + * at build time into the DTB. Currently being used for including > + * capsule related information. > + */ > + > +#ifdef CONFIG_EFI_CAPSULE_AUTHENTICATE > +/ { > + signature { > + capsule-key = /incbin/(CONFIG_EFI_CAPSULE_ESL_FILE); > + }; > +}; > +#endif /* CONFIG_EFI_CAPSULE_AUTHENTICATE */ > diff --git a/arch/sandbox/dts/u-boot.dtsi b/arch/sandbox/dts/u-boot.dtsi > new file mode 100644 > index 0000000000..60bd004937 > --- /dev/null > +++ b/arch/sandbox/dts/u-boot.dtsi > @@ -0,0 +1,17 @@ > +// SPDX-License-Identifier: GPL-2.0+ > +/* > + * Devicetree file with miscellaneous nodes that will be included > + * at build time into the DTB. Currently being used for including > + * capsule related information. > + * > + */ > + > +#ifdef CONFIG_EFI_HAVE_CAPSULE_SUPPORT > +/ { > +#ifdef CONFIG_EFI_CAPSULE_AUTHENTICATE > + signature { > + capsule-key = /incbin/(CONFIG_EFI_CAPSULE_ESL_FILE); > + }; > +#endif > +}; > +#endif /* CONFIG_EFI_HAVE_CAPSULE_SUPPORT */
And why are these two different?
For the sandbox's u-boot.dtsi, we need CONFIG_EFI_CAPSULE_AUTHENTICATE so that the ESL file is looked for only when capsule authentication is enabled. The outer CONFIG_EFI_HAVE_CAPSULE_SUPPORT is to not include stuff from this file unless capsule support is enabled. Simon had asked me to rid of the outer ifdef, but the sandbox_vpl test fails without it.
Sounds like this needs more re-working all around then, as we should only have one of these fragments, and it probably shouldn't be included when not needed.
Another option is to include the actual file (or even the data!) in the capsule-key property for sandbox, rather than the CONFIG.
Will this not mean that the dtsi file will have to be included explicitly for all the files which want to include the public key? I think it will be easier if the dtsi file can get included automatically, similar to u-boot.dtsi. I will check if we can put a dtsi file under lib/efi_loader/ and get that included automatically with capsule auth enabled, similar to how u-boot.dtsi gets included.
Well I feel that the CONFIG is a bit silly in a way, at least for sandbox, since we know the file being used. It just makes it harder.
Regards, Simon

Update the document to specify how the EFI Signature List(ESL) file can be embedded into the platform's dtb as part of the u-boot build.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org Reviewed-by: Simon Glass sjg@chromium.org --- Changes since V6: None
doc/develop/uefi/uefi.rst | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-)
diff --git a/doc/develop/uefi/uefi.rst b/doc/develop/uefi/uefi.rst index a7a41f2fac..b2854b52a6 100644 --- a/doc/develop/uefi/uefi.rst +++ b/doc/develop/uefi/uefi.rst @@ -522,20 +522,16 @@ and used by the steps highlighted below. ... }
-You can do step-4 manually with +You can perform step-4 by defining the Kconfig symbol +CONFIG_EFI_CAPSULE_ESL_FILE. Once this has been done, the signature +node can be added to the u-boot.dtsi file. For reference, check the +u-boot.dtsi file for the sandbox architecture. If this node has not +been added to the architecture's u-boot.dtsi file, this needs to be +done. The node has currently been added for the sandbox and arm +architectures' in the u-boot.dtsi file. Once the u-boot.dtsi file has +been added with the signature node, the esl file will automatically +get embedded into the platform's dtb as part of u-boot build.
-.. code-block:: console - - $ dtc -@ -I dts -O dtb -o signature.dtbo signature.dts - $ fdtoverlay -i orig.dtb -o new.dtb -v signature.dtbo - -where signature.dts looks like:: - - &{/} { - signature { - capsule-key = /incbin/("CRT.esl"); - }; - };
Anti-rollback Protection ************************

Build the mkeficapsule tool for all the sandbox variants. This tool will be used subsequently for testing capsule generation in binman.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org --- Changes since V6: * New patch which has been split up from the binman capsule entry support patch from earlier version, as suggested by Simon Glass. * Enables mkeficapsule tool for all sandbox variants, instead of only for sandbox_spl variant.
tools/Kconfig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/Kconfig b/tools/Kconfig index 6e23f44d55..353a855243 100644 --- a/tools/Kconfig +++ b/tools/Kconfig @@ -91,10 +91,10 @@ config TOOLS_SHA512 Enable SHA512 support in the tools builds
config TOOLS_MKEFICAPSULE - bool "Build efimkcapsule command" - default y if EFI_CAPSULE_ON_DISK + bool "Build mkeficapsule tool" + default y if EFI_CAPSULE_ON_DISK || SANDBOX help - This command allows users to create a UEFI capsule file and, + This tool allows users to create a UEFI capsule file and, optionally sign that file. If you want to enable UEFI capsule update feature on your target, you certainly need this.

On Sat, 5 Aug 2023 at 05:35, Sughosh Ganu sughosh.ganu@linaro.org wrote:
Build the mkeficapsule tool for all the sandbox variants. This tool will be used subsequently for testing capsule generation in binman.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
Changes since V6:
- New patch which has been split up from the binman capsule entry support patch from earlier version, as suggested by Simon Glass.
- Enables mkeficapsule tool for all sandbox variants, instead of only for sandbox_spl variant.
tools/Kconfig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org
At some point after this series is in, please take a look at why this tool isn't enabled for all builds.

On Sat, Aug 05, 2023 at 09:03:49AM -0600, Simon Glass wrote:
On Sat, 5 Aug 2023 at 05:35, Sughosh Ganu sughosh.ganu@linaro.org wrote:
Build the mkeficapsule tool for all the sandbox variants. This tool will be used subsequently for testing capsule generation in binman.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
Changes since V6:
- New patch which has been split up from the binman capsule entry support patch from earlier version, as suggested by Simon Glass.
- Enables mkeficapsule tool for all sandbox variants, instead of only for sandbox_spl variant.
tools/Kconfig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org
At some point after this series is in, please take a look at why this tool isn't enabled for all builds.
The tool requires a bunch of stuff (see the rules in tools/Makefile).

Hi Tom,
On Sat, 5 Aug 2023 at 16:15, Tom Rini trini@konsulko.com wrote:
On Sat, Aug 05, 2023 at 09:03:49AM -0600, Simon Glass wrote:
On Sat, 5 Aug 2023 at 05:35, Sughosh Ganu sughosh.ganu@linaro.org wrote:
Build the mkeficapsule tool for all the sandbox variants. This tool will be used subsequently for testing capsule generation in binman.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
Changes since V6:
- New patch which has been split up from the binman capsule entry support patch from earlier version, as suggested by Simon Glass.
- Enables mkeficapsule tool for all sandbox variants, instead of only for sandbox_spl variant.
tools/Kconfig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org
At some point after this series is in, please take a look at why this tool isn't enabled for all builds.
The tool requires a bunch of stuff (see the rules in tools/Makefile).
Oh, I see. It requires uuid and gnutils
Even so, would it be too bad to require those packages for building U-Boot?
Regards, Simon

On Sat, Aug 05, 2023 at 08:04:43PM -0600, Simon Glass wrote:
Hi Tom,
On Sat, 5 Aug 2023 at 16:15, Tom Rini trini@konsulko.com wrote:
On Sat, Aug 05, 2023 at 09:03:49AM -0600, Simon Glass wrote:
On Sat, 5 Aug 2023 at 05:35, Sughosh Ganu sughosh.ganu@linaro.org wrote:
Build the mkeficapsule tool for all the sandbox variants. This tool will be used subsequently for testing capsule generation in binman.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
Changes since V6:
- New patch which has been split up from the binman capsule entry support patch from earlier version, as suggested by Simon Glass.
- Enables mkeficapsule tool for all sandbox variants, instead of only for sandbox_spl variant.
tools/Kconfig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org
At some point after this series is in, please take a look at why this tool isn't enabled for all builds.
The tool requires a bunch of stuff (see the rules in tools/Makefile).
Oh, I see. It requires uuid and gnutils
Even so, would it be too bad to require those packages for building U-Boot?
We can always re-evaluate this later depending on the uptake of capsules. On the other hand we have a config for host tools only, for distros to use, and this isn't the only "sometimes" tool.

Add a bintool for generating EFI capsules. This calls the mkeficapsule tool which generates the capsules.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org --- Changes since V6: * Split the changes for mkeficapsule btool into a separate patch, as suggested by Simon Glass. * Use the word commandline consistently, as suggested by Simon Glass.
tools/binman/btool/mkeficapsule.py | 101 +++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 tools/binman/btool/mkeficapsule.py
diff --git a/tools/binman/btool/mkeficapsule.py b/tools/binman/btool/mkeficapsule.py new file mode 100644 index 0000000000..61179747ff --- /dev/null +++ b/tools/binman/btool/mkeficapsule.py @@ -0,0 +1,101 @@ +# SPDX-License-Identifier: GPL-2.0+ +# Copyright 2023 Linaro Limited +# +"""Bintool implementation for mkeficapsule tool + +mkeficapsule is a tool used for generating EFI capsules. + +The following are the commandline options to be provided +to the tool +Usage: mkeficapsule [options] <image blob> <output file> +Options: + -g, --guid <guid string> guid for image blob type + -i, --index <index> update image index + -I, --instance <instance> update hardware instance + -v, --fw-version <version> firmware version + -p, --private-key <privkey file> private key file + -c, --certificate <cert file> signer's certificate file + -m, --monotonic-count <count> monotonic count + -d, --dump_sig dump signature (*.p7) + -A, --fw-accept firmware accept capsule, requires GUID, no image blob + -R, --fw-revert firmware revert capsule, takes no GUID, no image blob + -o, --capoemflag Capsule OEM Flag, an integer between 0x0000 and 0xffff + -h, --help print a help message +""" + +from binman import bintool + +class Bintoolmkeficapsule(bintool.Bintool): + """Handles the 'mkeficapsule' tool + + This bintool is used for generating the EFI capsules. The + capsule generation parameters can either be specified through + commandline, or through a config file. + """ + def __init__(self, name): + super().__init__(name, 'mkeficapsule tool for generating capsules') + + def generate_capsule(self, image_index, image_guid, hardware_instance, + payload, output_fname, priv_key, pub_key, + monotonic_count=0, version=0, oemflags=0): + """Generate a capsule through commandline-provided parameters + + Args: + image_index (int): Unique number for identifying payload image + image_guid (str): GUID used for identifying the image + hardware_instance (int): Optional unique hardware instance of + a device in the system. 0 if not being used + payload (str): Path to the input payload image + output_fname (str): Path to the output capsule file + priv_key (str): Path to the private key + pub_key(str): Path to the public key + monotonic_count (int): Count used when signing an image + version (int): Image version (Optional) + oemflags (int): Optional 16 bit OEM flags + + Returns: + str: Tool output + """ + args = [ + f'--index={image_index}', + f'--guid={image_guid}', + f'--instance={hardware_instance}' + ] + + if version: + args += [f'--fw-version={version}'] + if oemflags: + args += [f'--capoemflag={oemflags}'] + if priv_key and pub_key: + args += [ + f'--monotonic-count={monotonic_count}', + f'--private-key={priv_key}', + f'--certificate={pub_key}' + ] + + args += [ + payload, + output_fname + ] + + return self.run_cmd(*args) + + def fetch(self, method): + """Fetch handler for mkeficapsule + + This builds the tool from source + + Returns: + tuple: + str: Filename of fetched file to copy to a suitable directory + str: Name of temp directory to remove, or None + """ + if method != bintool.FETCH_BUILD: + return None + + cmd = ['tools-only_defconfig', 'tools'] + result = self.build_from_git( + 'https://source.denx.de/u-boot/u-boot.git', + cmd, + 'tools/mkeficapsule') + return result

Hi Sughosh,
On Sat, 5 Aug 2023 at 05:35, Sughosh Ganu sughosh.ganu@linaro.org wrote:
Add a bintool for generating EFI capsules. This calls the mkeficapsule tool which generates the capsules.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
Changes since V6:
- Split the changes for mkeficapsule btool into a separate patch, as suggested by Simon Glass.
- Use the word commandline consistently, as suggested by Simon Glass.
tools/binman/btool/mkeficapsule.py | 101 +++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 tools/binman/btool/mkeficapsule.py
Reviewed-by: Simon Glass sjg@chromium.org
diff --git a/tools/binman/btool/mkeficapsule.py b/tools/binman/btool/mkeficapsule.py new file mode 100644 index 0000000000..61179747ff --- /dev/null +++ b/tools/binman/btool/mkeficapsule.py @@ -0,0 +1,101 @@ +# SPDX-License-Identifier: GPL-2.0+ +# Copyright 2023 Linaro Limited +# +"""Bintool implementation for mkeficapsule tool
+mkeficapsule is a tool used for generating EFI capsules.
+The following are the commandline options to be provided +to the tool +Usage: mkeficapsule [options] <image blob> <output file> +Options:
-g, --guid <guid string> guid for image blob type
-i, --index <index> update image index
-I, --instance <instance> update hardware instance
-v, --fw-version <version> firmware version
-p, --private-key <privkey file> private key file
-c, --certificate <cert file> signer's certificate file
-m, --monotonic-count <count> monotonic count
-d, --dump_sig dump signature (*.p7)
-A, --fw-accept firmware accept capsule, requires GUID, no image blob
-R, --fw-revert firmware revert capsule, takes no GUID, no image blob
-o, --capoemflag Capsule OEM Flag, an integer between 0x0000 and 0xffff
-h, --help print a help message
+"""
+from binman import bintool
+class Bintoolmkeficapsule(bintool.Bintool):
- """Handles the 'mkeficapsule' tool
- This bintool is used for generating the EFI capsules. The
- capsule generation parameters can either be specified through
- commandline, or through a config file.
- """
- def __init__(self, name):
super().__init__(name, 'mkeficapsule tool for generating capsules')
- def generate_capsule(self, image_index, image_guid, hardware_instance,
payload, output_fname, priv_key, pub_key,
monotonic_count=0, version=0, oemflags=0):
"""Generate a capsule through commandline-provided parameters
Args:
image_index (int): Unique number for identifying payload image
image_guid (str): GUID used for identifying the image
I wonder what we can do about this, so that we don't have to speak in GUIDs? Is there a registry somewhere of what all these things are? It would be nice if you could provide a string like 'u-boot-sandbox' and the capsule tool would know what that means.
hardware_instance (int): Optional unique hardware instance of
a device in the system. 0 if not being used
payload (str): Path to the input payload image
output_fname (str): Path to the output capsule file
priv_key (str): Path to the private key
pub_key(str): Path to the public key
monotonic_count (int): Count used when signing an image
version (int): Image version (Optional)
oemflags (int): Optional 16 bit OEM flags
Returns:
str: Tool output
"""
args = [
f'--index={image_index}',
f'--guid={image_guid}',
f'--instance={hardware_instance}'
]
if version:
args += [f'--fw-version={version}']
if oemflags:
args += [f'--capoemflag={oemflags}']
if priv_key and pub_key:
args += [
f'--monotonic-count={monotonic_count}',
f'--private-key={priv_key}',
f'--certificate={pub_key}'
]
It almost seems worth adding two methods in this class, one to build with keys and one to not. Anyway, we can leave it for now.
args += [
payload,
output_fname
]
return self.run_cmd(*args)
- def fetch(self, method):
"""Fetch handler for mkeficapsule
This builds the tool from source
Returns:
tuple:
str: Filename of fetched file to copy to a suitable directory
str: Name of temp directory to remove, or None
"""
if method != bintool.FETCH_BUILD:
return None
cmd = ['tools-only_defconfig', 'tools']
result = self.build_from_git(
'https://source.denx.de/u-boot/u-boot.git',
cmd,
'tools/mkeficapsule')
return result
-- 2.34.1
Regards, Simon

hi Simon,
On Sat, 5 Aug 2023 at 20:34, Simon Glass sjg@chromium.org wrote:
Hi Sughosh,
On Sat, 5 Aug 2023 at 05:35, Sughosh Ganu sughosh.ganu@linaro.org wrote:
Add a bintool for generating EFI capsules. This calls the mkeficapsule tool which generates the capsules.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
Changes since V6:
- Split the changes for mkeficapsule btool into a separate patch, as suggested by Simon Glass.
- Use the word commandline consistently, as suggested by Simon Glass.
tools/binman/btool/mkeficapsule.py | 101 +++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 tools/binman/btool/mkeficapsule.py
Reviewed-by: Simon Glass sjg@chromium.org
diff --git a/tools/binman/btool/mkeficapsule.py b/tools/binman/btool/mkeficapsule.py new file mode 100644 index 0000000000..61179747ff --- /dev/null +++ b/tools/binman/btool/mkeficapsule.py @@ -0,0 +1,101 @@ +# SPDX-License-Identifier: GPL-2.0+ +# Copyright 2023 Linaro Limited +# +"""Bintool implementation for mkeficapsule tool
+mkeficapsule is a tool used for generating EFI capsules.
+The following are the commandline options to be provided +to the tool +Usage: mkeficapsule [options] <image blob> <output file> +Options:
-g, --guid <guid string> guid for image blob type
-i, --index <index> update image index
-I, --instance <instance> update hardware instance
-v, --fw-version <version> firmware version
-p, --private-key <privkey file> private key file
-c, --certificate <cert file> signer's certificate file
-m, --monotonic-count <count> monotonic count
-d, --dump_sig dump signature (*.p7)
-A, --fw-accept firmware accept capsule, requires GUID, no image blob
-R, --fw-revert firmware revert capsule, takes no GUID, no image blob
-o, --capoemflag Capsule OEM Flag, an integer between 0x0000 and 0xffff
-h, --help print a help message
+"""
+from binman import bintool
+class Bintoolmkeficapsule(bintool.Bintool):
- """Handles the 'mkeficapsule' tool
- This bintool is used for generating the EFI capsules. The
- capsule generation parameters can either be specified through
- commandline, or through a config file.
- """
- def __init__(self, name):
super().__init__(name, 'mkeficapsule tool for generating capsules')
- def generate_capsule(self, image_index, image_guid, hardware_instance,
payload, output_fname, priv_key, pub_key,
monotonic_count=0, version=0, oemflags=0):
"""Generate a capsule through commandline-provided parameters
Args:
image_index (int): Unique number for identifying payload image
image_guid (str): GUID used for identifying the image
I wonder what we can do about this, so that we don't have to speak in GUIDs? Is there a registry somewhere of what all these things are? It would be nice if you could provide a string like 'u-boot-sandbox' and the capsule tool would know what that means.
In the EFI world GUIDs are just identifiers used for uniquely identifying resources, in this case, images on a given board. There is no registry of these values, however there are certain resources which do have truly unique value, e.g. EFI protocols, or standard disk partitions -- these values are then defined in a specification, like UEFI.
In this context though, these GUIDs simply serve in identifying an image for a given board. Typically, the platform code would then "declare" the images that are supported on that platform using their associated GUID values. And these GUIDs which are part of the capsule are then used for checking if the input image on the capsule is indeed intended for that platform at the time of performing the update.
hardware_instance (int): Optional unique hardware instance of
a device in the system. 0 if not being used
payload (str): Path to the input payload image
output_fname (str): Path to the output capsule file
priv_key (str): Path to the private key
pub_key(str): Path to the public key
monotonic_count (int): Count used when signing an image
version (int): Image version (Optional)
oemflags (int): Optional 16 bit OEM flags
Returns:
str: Tool output
"""
args = [
f'--index={image_index}',
f'--guid={image_guid}',
f'--instance={hardware_instance}'
]
if version:
args += [f'--fw-version={version}']
if oemflags:
args += [f'--capoemflag={oemflags}']
if priv_key and pub_key:
args += [
f'--monotonic-count={monotonic_count}',
f'--private-key={priv_key}',
f'--certificate={pub_key}'
]
It almost seems worth adding two methods in this class, one to build with keys and one to not. Anyway, we can leave it for now.
I had them separate in my earlier versions, but clubbed them together. I personally don't find this confusing.
-sughosh
args += [
payload,
output_fname
]
return self.run_cmd(*args)
- def fetch(self, method):
"""Fetch handler for mkeficapsule
This builds the tool from source
Returns:
tuple:
str: Filename of fetched file to copy to a suitable directory
str: Name of temp directory to remove, or None
"""
if method != bintool.FETCH_BUILD:
return None
cmd = ['tools-only_defconfig', 'tools']
result = self.build_from_git(
'https://source.denx.de/u-boot/u-boot.git',
cmd,
'tools/mkeficapsule')
return result
-- 2.34.1
Regards, Simon

Add support in binman for generating EFI capsules. The capsule parameters can be specified through the capsule binman entry. Also add test cases in binman for testing capsule generation.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org --- Changes since V6: * Add macros for the GUID strings in sandbox_efi_capsule.h * Highlight that the private and public keys are mandatory for capsule signing. * Add a URL link to the UEFI spec, as used in the rst files. * Use local vars for private and public keys in BuildSectionData() * Use local vars for input payload and capsule filenames in BuildSectionData(). * Drop the ProcessContents() and SetImagePos() as the superclass functions suffice. * Use GUID macro names in the capsule test dts files. * Rename efi_capsule_payload.bin to capsule_input.bin.
include/sandbox_efi_capsule.h | 14 ++ tools/binman/entries.rst | 62 ++++++++ tools/binman/etype/efi_capsule.py | 143 ++++++++++++++++++ tools/binman/ftest.py | 121 +++++++++++++++ tools/binman/test/307_capsule.dts | 23 +++ tools/binman/test/308_capsule_signed.dts | 25 +++ tools/binman/test/309_capsule_version.dts | 24 +++ tools/binman/test/310_capsule_signed_ver.dts | 26 ++++ tools/binman/test/311_capsule_oemflags.dts | 24 +++ tools/binman/test/312_capsule_missing_key.dts | 24 +++ .../binman/test/313_capsule_missing_index.dts | 22 +++ .../binman/test/314_capsule_missing_guid.dts | 19 +++ .../test/315_capsule_missing_payload.dts | 19 +++ 13 files changed, 546 insertions(+) create mode 100644 include/sandbox_efi_capsule.h create mode 100644 tools/binman/etype/efi_capsule.py create mode 100644 tools/binman/test/307_capsule.dts create mode 100644 tools/binman/test/308_capsule_signed.dts create mode 100644 tools/binman/test/309_capsule_version.dts create mode 100644 tools/binman/test/310_capsule_signed_ver.dts create mode 100644 tools/binman/test/311_capsule_oemflags.dts create mode 100644 tools/binman/test/312_capsule_missing_key.dts create mode 100644 tools/binman/test/313_capsule_missing_index.dts create mode 100644 tools/binman/test/314_capsule_missing_guid.dts create mode 100644 tools/binman/test/315_capsule_missing_payload.dts
diff --git a/include/sandbox_efi_capsule.h b/include/sandbox_efi_capsule.h new file mode 100644 index 0000000000..da71b87a18 --- /dev/null +++ b/include/sandbox_efi_capsule.h @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (c) 2023, Linaro Limited + */ + +#if !defined(_SANDBOX_EFI_CAPSULE_H_) +#define _SANDBOX_EFI_CAPSULE_H_ + +#define SANDBOX_UBOOT_IMAGE_GUID "09d7cf52-0720-4710-91d1-08469b7fe9c8" +#define SANDBOX_UBOOT_ENV_IMAGE_GUID "5a7021f5-fef2-48b4-aaba-832e777418c0" +#define SANDBOX_FIT_IMAGE_GUID "3673b45d-6a7c-46f3-9e60-adabb03f7937" +#define SANDBOX_INCORRECT_GUID "058b7d83-50d5-4c47-a195-60d86ad341c4" + +#endif /* _SANDBOX_EFI_CAPSULE_H_ */ diff --git a/tools/binman/entries.rst b/tools/binman/entries.rst index f2376932be..fc094b9c08 100644 --- a/tools/binman/entries.rst +++ b/tools/binman/entries.rst @@ -468,6 +468,68 @@ updating the EC on startup via software sync.
+.. _etype_efi_capsule: + +Entry: capsule: Entry for generating EFI Capsule files +------------------------------------------------------ + +The parameters needed for generation of the capsules can +be provided as properties in the entry. + +Properties / Entry arguments: + - image-index: Unique number for identifying corresponding + payload image. Number between 1 and descriptor count, i.e. + the total number of firmware images that can be updated. + - image-type-id: Image GUID which will be used for identifying the + updatable image on the board. + - hardware-instance: Optional number for identifying unique + hardware instance of a device in the system. Default value of 0 + for images where value is not to be used. + - fw-version: Optional value of image version that can be put on + the capsule through the Firmware Management Protocol(FMP) header. + - monotonic-count: Count used when signing an image. + - private-key: Path to PEM formatted .key private key file. This property + is mandatory for generating signed capsules. + - public-key-cert: Path to PEM formatted .crt public key certificate + file. This property is mandatory for generating signed capsules. + - oem-flags - Optional OEM flags to be passed through capsule header. + + Since this is a subclass of Entry_section, all properties of the parent + class also apply here. + +For more details on the description of the capsule format, and the capsule +update functionality, refer Section 8.5 and Chapter 23 in the `UEFI +specification`_. + +The capsule parameters like image index and image GUID are passed as +properties in the entry. The payload to be used in the capsule is to be +provided as a subnode of the capsule entry. + +A typical capsule entry node would then look something like this:: + + capsule { + type = "efi-capsule"; + image-index = <0x1>; + /* Image GUID for testing capsule update */ + image-type-id = SANDBOX_UBOOT_IMAGE_GUID; + hardware-instance = <0x0>; + private-key = "path/to/the/private/key"; + public-key-cert = "path/to/the/public-key-cert"; + oem-flags = <0x8000>; + + u-boot { + }; + }; + +In the above example, the capsule payload is the U-Boot image. The +capsule entry would read the contents of the payload and put them +into the capsule. Any external file can also be specified as the +payload using the blob-ext subnode. + +.. _`UEFI specification`: https://uefi.org/sites/default/files/resources/UEFI_Spec_2_10_Aug29.pdf + + + .. _etype_encrypted:
Entry: encrypted: Externally built encrypted binary blob diff --git a/tools/binman/etype/efi_capsule.py b/tools/binman/etype/efi_capsule.py new file mode 100644 index 0000000000..bfdca94e26 --- /dev/null +++ b/tools/binman/etype/efi_capsule.py @@ -0,0 +1,143 @@ +# SPDX-License-Identifier: GPL-2.0+ +# Copyright (c) 2023 Linaro Limited +# +# Entry-type module for producing a EFI capsule +# + +import os + +from binman.entry import Entry +from binman.etype.section import Entry_section +from dtoc import fdt_util +from u_boot_pylib import tools + +class Entry_efi_capsule(Entry_section): + """Generate EFI capsules + + The parameters needed for generation of the capsules can + be provided as properties in the entry. + + Properties / Entry arguments: + - image-index: Unique number for identifying corresponding + payload image. Number between 1 and descriptor count, i.e. + the total number of firmware images that can be updated. + - image-type-id: Image GUID which will be used for identifying the + updatable image on the board. + - hardware-instance: Optional number for identifying unique + hardware instance of a device in the system. Default value of 0 + for images where value is not to be used. + - fw-version: Optional value of image version that can be put on + the capsule through the Firmware Management Protocol(FMP) header. + - monotonic-count: Count used when signing an image. + - private-key: Path to PEM formatted .key private key file. This property + is mandatory for generating signed capsules. + - public-key-cert: Path to PEM formatted .crt public key certificate + file. This property is mandatory for generating signed capsules. + - oem-flags - Optional OEM flags to be passed through capsule header. + + Since this is a subclass of Entry_section, all properties of the parent + class also apply here. + + For more details on the description of the capsule format, and the capsule + update functionality, refer Section 8.5 and Chapter 23 in the `UEFI + specification`_. + + The capsule parameters like image index and image GUID are passed as + properties in the entry. The payload to be used in the capsule is to be + provided as a subnode of the capsule entry. + + A typical capsule entry node would then look something like this + + capsule { + type = "efi-capsule"; + image-index = <0x1>; + /* Image GUID for testing capsule update */ + image-type-id = SANDBOX_UBOOT_IMAGE_GUID; + hardware-instance = <0x0>; + private-key = "path/to/the/private/key"; + public-key-cert = "path/to/the/public-key-cert"; + oem-flags = <0x8000>; + + u-boot { + }; + }; + + In the above example, the capsule payload is the U-Boot image. The + capsule entry would read the contents of the payload and put them + into the capsule. Any external file can also be specified as the + payload using the blob-ext subnode. + + .. _`UEFI specification`: https://uefi.org/sites/default/files/resources/UEFI_Spec_2_10_Aug29.pdf + """ + def __init__(self, section, etype, node): + super().__init__(section, etype, node) + self.required_props = ['image-index', 'image-type-id'] + self.image_index = 0 + self.image_guid = '' + self.hardware_instance = 0 + self.monotonic_count = 0 + self.fw_version = 0 + self.oem_flags = 0 + self.private_key = '' + self.public_key_cert = '' + self.auth = 0 + + def ReadNode(self): + self.ReadEntries() + super().ReadNode() + + self.image_index = fdt_util.GetInt(self._node, 'image-index') + self.image_guid = fdt_util.GetString(self._node, 'image-type-id') + self.fw_version = fdt_util.GetInt(self._node, 'fw-version') + self.hardware_instance = fdt_util.GetInt(self._node, 'hardware-instance') + self.monotonic_count = fdt_util.GetInt(self._node, 'monotonic-count') + self.oem_flags = fdt_util.GetInt(self._node, 'oem-flags') + + self.private_key = fdt_util.GetString(self._node, 'private-key') + self.public_key_cert = fdt_util.GetString(self._node, 'public-key-cert') + if ((self.private_key and not self.public_key_cert) or (self.public_key_cert and not self.private_key)): + self.Raise('Both private key and public key certificate need to be provided') + elif not (self.private_key and self.public_key_cert): + self.auth = 0 + else: + self.auth = 1 + + def ReadEntries(self): + """Read the subnode to get the payload for this capsule""" + # We can have a single payload per capsule + if len(self._node.subnodes) == 0: + self.Raise('The capsule entry expects at least one subnode for payload') + + for node in self._node.subnodes: + entry = Entry.Create(self, node) + entry.ReadNode() + self._entries[entry.name] = entry + + def BuildSectionData(self, required): + private_key = '' + public_key_cert = '' + if self.auth: + if not os.path.isabs(self.private_key): + private_key = tools.get_input_filename(self.private_key) + if not os.path.isabs(self.public_key_cert): + public_key_cert = tools.get_input_filename(self.public_key_cert) + data, payload, _ = self.collect_contents_to_file( + self._entries.values(), 'capsule_payload') + outfile = self._filename if self._filename else self._node.name + capsule_fname = tools.get_output_filename(outfile) + ret = self.mkeficapsule.generate_capsule(self.image_index, + self.image_guid, + self.hardware_instance, + payload, + capsule_fname, + private_key, + public_key_cert, + self.monotonic_count, + self.fw_version, + self.oem_flags) + if ret is not None: + os.remove(payload) + return tools.read_file(capsule_fname) + + def AddBintools(self, btools): + self.mkeficapsule = self.AddBintool(btools, 'mkeficapsule') diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index 36428ec343..9bda0157f7 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -48,6 +48,7 @@ U_BOOT_VPL_DATA = b'vpl76543210fedcbazywxyz_' BLOB_DATA = b'89' ME_DATA = b'0abcd' VGA_DATA = b'vga' +EFI_CAPSULE_DATA = b'efi' U_BOOT_DTB_DATA = b'udtb' U_BOOT_SPL_DTB_DATA = b'spldtb' U_BOOT_TPL_DTB_DATA = b'tpldtb' @@ -119,6 +120,11 @@ COMP_BINTOOLS = ['bzip2', 'gzip', 'lz4', 'lzma_alone', 'lzop', 'xz', 'zstd']
TEE_ADDR = 0x5678
+# Firmware Management Protocol(FMP) GUID +FW_MGMT_GUID = 'edd5cb6d2de8444cbda17194199ad92a' +# Image GUID specified in the DTS +CAPSULE_IMAGE_GUID = '52cfd7092007104791d108469b7fe9c8' + class TestFunctional(unittest.TestCase): """Functional tests for binman
@@ -215,6 +221,7 @@ class TestFunctional(unittest.TestCase): TestFunctional._MakeInputFile('scp.bin', SCP_DATA) TestFunctional._MakeInputFile('rockchip-tpl.bin', ROCKCHIP_TPL_DATA) TestFunctional._MakeInputFile('ti_unsecure.bin', TI_UNSECURE_DATA) + TestFunctional._MakeInputFile('capsule_input.bin', EFI_CAPSULE_DATA)
# Add a few .dtb files for testing TestFunctional._MakeInputFile('%s/test-fdt1.dtb' % TEST_FDT_SUBDIR, @@ -7139,5 +7146,119 @@ fdt fdtmap Extract the devicetree blob from the fdtmap self.assertEqual(fdt_util.GetString(key_node, "key-name-hint"), "key")
+ def _CheckCapsule(self, data, signed_capsule=False, version_check=False, + capoemflags=False): + fmp_signature = "4d535331" # 'M', 'S', 'S', '1' + fmp_size = "10" + fmp_fw_version = "02" + oemflag = "0080" + + payload_data = EFI_CAPSULE_DATA + + # Firmware Management Protocol(FMP) GUID - offset(0 - 32) + self.assertEqual(FW_MGMT_GUID, data.hex()[:32]) + # Image GUID - offset(96 - 128) + self.assertEqual(CAPSULE_IMAGE_GUID, data.hex()[96:128]) + + if capoemflags: + # OEM Flags - offset(40 - 44) + self.assertEqual(oemflag, data.hex()[40:44]) + if signed_capsule and version_check: + # FMP header signature - offset(4770 - 4778) + self.assertEqual(fmp_signature, data.hex()[4770:4778]) + # FMP header size - offset(4778 - 4780) + self.assertEqual(fmp_size, data.hex()[4778:4780]) + # firmware version - offset(4786 - 4788) + self.assertEqual(fmp_fw_version, data.hex()[4786:4788]) + # payload offset signed capsule(4802 - 4808) + self.assertEqual(payload_data.hex(), data.hex()[4802:4808]) + elif signed_capsule: + # payload offset signed capsule(4770 - 4776) + self.assertEqual(payload_data.hex(), data.hex()[4770:4776]) + elif version_check: + # FMP header signature - offset(184 - 192) + self.assertEqual(fmp_signature, data.hex()[184:192]) + # FMP header size - offset(192 - 194) + self.assertEqual(fmp_size, data.hex()[192:194]) + # firmware version - offset(200 - 202) + self.assertEqual(fmp_fw_version, data.hex()[200:202]) + # payload offset for non-signed capsule with version header(216 - 222) + self.assertEqual(payload_data.hex(), data.hex()[216:222]) + else: + # payload offset for non-signed capsule with no version header(184 - 190) + self.assertEqual(payload_data.hex(), data.hex()[184:190]) + + def testCapsuleGen(self): + """Test generation of EFI capsule""" + data = self._DoReadFile('307_capsule.dts') + + self._CheckCapsule(data) + + def testSignedCapsuleGen(self): + """Test generation of EFI capsule""" + data = tools.read_file(self.TestFile("key.key")) + self._MakeInputFile("key.key", data) + data = tools.read_file(self.TestFile("key.pem")) + self._MakeInputFile("key.crt", data) + + data = self._DoReadFile('308_capsule_signed.dts') + + self._CheckCapsule(data, signed_capsule=True) + + def testCapsuleGenVersionSupport(self): + """Test generation of EFI capsule with version support""" + data = self._DoReadFile('309_capsule_version.dts') + + self._CheckCapsule(data, version_check=True) + + def testCapsuleGenSignedVer(self): + """Test generation of signed EFI capsule with version information""" + data = tools.read_file(self.TestFile("key.key")) + self._MakeInputFile("key.key", data) + data = tools.read_file(self.TestFile("key.pem")) + self._MakeInputFile("key.crt", data) + + data = self._DoReadFile('310_capsule_signed_ver.dts') + + self._CheckCapsule(data, signed_capsule=True, version_check=True) + + def testCapsuleGenCapOemFlags(self): + """Test generation of EFI capsule with OEM Flags set""" + data = self._DoReadFile('311_capsule_oemflags.dts') + + self._CheckCapsule(data, capoemflags=True) + + def testCapsuleGenKeyMissing(self): + """Test that binman errors out on missing key""" + with self.assertRaises(ValueError) as e: + self._DoReadFile('312_capsule_missing_key.dts') + + self.assertIn("Both private key and public key certificate need to be provided", + str(e.exception)) + + def testCapsuleGenIndexMissing(self): + """Test that binman errors out on missing image index""" + with self.assertRaises(ValueError) as e: + self._DoReadFile('313_capsule_missing_index.dts') + + self.assertIn("entry is missing properties: image-index", + str(e.exception)) + + def testCapsuleGenGuidMissing(self): + """Test that binman errors out on missing image GUID""" + with self.assertRaises(ValueError) as e: + self._DoReadFile('314_capsule_missing_guid.dts') + + self.assertIn("entry is missing properties: image-type-id", + str(e.exception)) + + def testCapsuleGenPayloadMissing(self): + """Test that binman errors out on missing input(payload)image""" + with self.assertRaises(ValueError) as e: + self._DoReadFile('315_capsule_missing_payload.dts') + + self.assertIn("The capsule entry expects at least one subnode for payload", + str(e.exception)) + if __name__ == "__main__": unittest.main() diff --git a/tools/binman/test/307_capsule.dts b/tools/binman/test/307_capsule.dts new file mode 100644 index 0000000000..86552ff83f --- /dev/null +++ b/tools/binman/test/307_capsule.dts @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: GPL-2.0+ + +/dts-v1/; + +#include <sandbox_efi_capsule.h> + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + efi-capsule { + image-index = <0x1>; + /* Image GUID for testing capsule update */ + image-type-id = SANDBOX_UBOOT_IMAGE_GUID; + hardware-instance = <0x0>; + + blob { + filename = "capsule_input.bin"; + }; + }; + }; +}; diff --git a/tools/binman/test/308_capsule_signed.dts b/tools/binman/test/308_capsule_signed.dts new file mode 100644 index 0000000000..37d2f35e71 --- /dev/null +++ b/tools/binman/test/308_capsule_signed.dts @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: GPL-2.0+ + +/dts-v1/; + +#include <sandbox_efi_capsule.h> + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + efi-capsule { + image-index = <0x1>; + /* Image GUID for testing capsule update */ + image-type-id = SANDBOX_UBOOT_IMAGE_GUID; + hardware-instance = <0x0>; + private-key = "key.key"; + public-key-cert = "key.crt"; + + blob { + filename = "capsule_input.bin"; + }; + }; + }; +}; diff --git a/tools/binman/test/309_capsule_version.dts b/tools/binman/test/309_capsule_version.dts new file mode 100644 index 0000000000..a3d2f96f5c --- /dev/null +++ b/tools/binman/test/309_capsule_version.dts @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: GPL-2.0+ + +/dts-v1/; + +#include <sandbox_efi_capsule.h> + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + efi-capsule { + image-index = <0x1>; + fw-version = <0x2>; + /* Image GUID for testing capsule update */ + image-type-id = SANDBOX_UBOOT_IMAGE_GUID; + hardware-instance = <0x0>; + + blob { + filename = "capsule_input.bin"; + }; + }; + }; +}; diff --git a/tools/binman/test/310_capsule_signed_ver.dts b/tools/binman/test/310_capsule_signed_ver.dts new file mode 100644 index 0000000000..01c9c01222 --- /dev/null +++ b/tools/binman/test/310_capsule_signed_ver.dts @@ -0,0 +1,26 @@ +// SPDX-License-Identifier: GPL-2.0+ + +/dts-v1/; + +#include <sandbox_efi_capsule.h> + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + efi-capsule { + image-index = <0x1>; + fw-version = <0x2>; + /* Image GUID for testing capsule update */ + image-type-id = SANDBOX_UBOOT_IMAGE_GUID; + hardware-instance = <0x0>; + private-key = "key.key"; + public-key-cert = "key.crt"; + + blob { + filename = "capsule_input.bin"; + }; + }; + }; +}; diff --git a/tools/binman/test/311_capsule_oemflags.dts b/tools/binman/test/311_capsule_oemflags.dts new file mode 100644 index 0000000000..cfc41c7b55 --- /dev/null +++ b/tools/binman/test/311_capsule_oemflags.dts @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: GPL-2.0+ + +/dts-v1/; + +#include <sandbox_efi_capsule.h> + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + efi-capsule { + image-index = <0x1>; + /* Image GUID for testing capsule update */ + image-type-id = SANDBOX_UBOOT_IMAGE_GUID; + hardware-instance = <0x0>; + oem-flags = <0x8000>; + + blob { + filename = "capsule_input.bin"; + }; + }; + }; +}; diff --git a/tools/binman/test/312_capsule_missing_key.dts b/tools/binman/test/312_capsule_missing_key.dts new file mode 100644 index 0000000000..1a08d0e991 --- /dev/null +++ b/tools/binman/test/312_capsule_missing_key.dts @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: GPL-2.0+ + +/dts-v1/; + +#include <sandbox_efi_capsule.h> + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + efi-capsule { + image-index = <0x1>; + /* Image GUID for testing capsule update */ + image-type-id = SANDBOX_UBOOT_IMAGE_GUID; + hardware-instance = <0x0>; + private-key = "tools/binman/test/key.key"; + + blob { + filename = "capsule_input.bin"; + }; + }; + }; +}; diff --git a/tools/binman/test/313_capsule_missing_index.dts b/tools/binman/test/313_capsule_missing_index.dts new file mode 100644 index 0000000000..c6aa899211 --- /dev/null +++ b/tools/binman/test/313_capsule_missing_index.dts @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: GPL-2.0+ + +/dts-v1/; + +#include <sandbox_efi_capsule.h> + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + efi-capsule { + /* Image GUID for testing capsule update */ + image-type-id = SANDBOX_UBOOT_IMAGE_GUID; + hardware-instance = <0x0>; + + blob { + filename = "capsule_input.bin"; + }; + }; + }; +}; diff --git a/tools/binman/test/314_capsule_missing_guid.dts b/tools/binman/test/314_capsule_missing_guid.dts new file mode 100644 index 0000000000..d76afba853 --- /dev/null +++ b/tools/binman/test/314_capsule_missing_guid.dts @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: GPL-2.0+ + +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + efi-capsule { + image-index = <0x1>; + hardware-instance = <0x0>; + + blob { + filename = "capsule_input.bin"; + }; + }; + }; +}; diff --git a/tools/binman/test/315_capsule_missing_payload.dts b/tools/binman/test/315_capsule_missing_payload.dts new file mode 100644 index 0000000000..7d7b9e2ea0 --- /dev/null +++ b/tools/binman/test/315_capsule_missing_payload.dts @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: GPL-2.0+ + +/dts-v1/; + +#include <sandbox_efi_capsule.h> + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + efi-capsule { + image-index = <0x1>; + /* Image GUID for testing capsule update */ + image-type-id = SANDBOX_UBOOT_IMAGE_GUID; + hardware-instance = <0x0>; + }; + }; +};

Hi Sughosh,
On Sat, 5 Aug 2023 at 05:35, Sughosh Ganu sughosh.ganu@linaro.org wrote:
Add support in binman for generating EFI capsules. The capsule parameters can be specified through the capsule binman entry. Also add test cases in binman for testing capsule generation.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
Changes since V6:
- Add macros for the GUID strings in sandbox_efi_capsule.h
- Highlight that the private and public keys are mandatory for capsule signing.
- Add a URL link to the UEFI spec, as used in the rst files.
- Use local vars for private and public keys in BuildSectionData()
- Use local vars for input payload and capsule filenames in BuildSectionData().
- Drop the ProcessContents() and SetImagePos() as the superclass functions suffice.
- Use GUID macro names in the capsule test dts files.
- Rename efi_capsule_payload.bin to capsule_input.bin.
include/sandbox_efi_capsule.h | 14 ++
Please move this file to a later patch - see below.
Could we have a single header file with all the GUIDs, i.e. sandbox, ARM, etc.
tools/binman/entries.rst | 62 ++++++++ tools/binman/etype/efi_capsule.py | 143 ++++++++++++++++++ tools/binman/ftest.py | 121 +++++++++++++++ tools/binman/test/307_capsule.dts | 23 +++ tools/binman/test/308_capsule_signed.dts | 25 +++ tools/binman/test/309_capsule_version.dts | 24 +++ tools/binman/test/310_capsule_signed_ver.dts | 26 ++++ tools/binman/test/311_capsule_oemflags.dts | 24 +++ tools/binman/test/312_capsule_missing_key.dts | 24 +++ .../binman/test/313_capsule_missing_index.dts | 22 +++ .../binman/test/314_capsule_missing_guid.dts | 19 +++ .../test/315_capsule_missing_payload.dts | 19 +++ 13 files changed, 546 insertions(+) create mode 100644 include/sandbox_efi_capsule.h create mode 100644 tools/binman/etype/efi_capsule.py create mode 100644 tools/binman/test/307_capsule.dts create mode 100644 tools/binman/test/308_capsule_signed.dts create mode 100644 tools/binman/test/309_capsule_version.dts create mode 100644 tools/binman/test/310_capsule_signed_ver.dts create mode 100644 tools/binman/test/311_capsule_oemflags.dts create mode 100644 tools/binman/test/312_capsule_missing_key.dts create mode 100644 tools/binman/test/313_capsule_missing_index.dts create mode 100644 tools/binman/test/314_capsule_missing_guid.dts create mode 100644 tools/binman/test/315_capsule_missing_payload.dts
diff --git a/include/sandbox_efi_capsule.h b/include/sandbox_efi_capsule.h new file mode 100644 index 0000000000..da71b87a18 --- /dev/null +++ b/include/sandbox_efi_capsule.h @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: GPL-2.0+ +/*
- Copyright (c) 2023, Linaro Limited
- */
+#if !defined(_SANDBOX_EFI_CAPSULE_H_) +#define _SANDBOX_EFI_CAPSULE_H_
+#define SANDBOX_UBOOT_IMAGE_GUID "09d7cf52-0720-4710-91d1-08469b7fe9c8" +#define SANDBOX_UBOOT_ENV_IMAGE_GUID "5a7021f5-fef2-48b4-aaba-832e777418c0" +#define SANDBOX_FIT_IMAGE_GUID "3673b45d-6a7c-46f3-9e60-adabb03f7937" +#define SANDBOX_INCORRECT_GUID "058b7d83-50d5-4c47-a195-60d86ad341c4"
These should not be needed in binman tests.
+#endif /* _SANDBOX_EFI_CAPSULE_H_ */ diff --git a/tools/binman/entries.rst b/tools/binman/entries.rst index f2376932be..fc094b9c08 100644 --- a/tools/binman/entries.rst +++ b/tools/binman/entries.rst @@ -468,6 +468,68 @@ updating the EC on startup via software sync.
+.. _etype_efi_capsule:
+Entry: capsule: Entry for generating EFI Capsule files +------------------------------------------------------
+The parameters needed for generation of the capsules can +be provided as properties in the entry.
+Properties / Entry arguments:
- image-index: Unique number for identifying corresponding
payload image. Number between 1 and descriptor count, i.e.
the total number of firmware images that can be updated.
- image-type-id: Image GUID which will be used for identifying the
updatable image on the board.
- hardware-instance: Optional number for identifying unique
hardware instance of a device in the system. Default value of 0
for images where value is not to be used.
- fw-version: Optional value of image version that can be put on
the capsule through the Firmware Management Protocol(FMP) header.
- monotonic-count: Count used when signing an image.
- private-key: Path to PEM formatted .key private key file. This property
is mandatory for generating signed capsules.
- public-key-cert: Path to PEM formatted .crt public key certificate
file. This property is mandatory for generating signed capsules.
- oem-flags - Optional OEM flags to be passed through capsule header.
- Since this is a subclass of Entry_section, all properties of the parent
- class also apply here.
+For more details on the description of the capsule format, and the capsule +update functionality, refer Section 8.5 and Chapter 23 in the `UEFI +specification`_.
+The capsule parameters like image index and image GUID are passed as +properties in the entry. The payload to be used in the capsule is to be +provided as a subnode of the capsule entry.
+A typical capsule entry node would then look something like this::
- capsule {
type = "efi-capsule";
image-index = <0x1>;
/* Image GUID for testing capsule update */
image-type-id = SANDBOX_UBOOT_IMAGE_GUID;
hardware-instance = <0x0>;
private-key = "path/to/the/private/key";
public-key-cert = "path/to/the/public-key-cert";
oem-flags = <0x8000>;
u-boot {
};
- };
+In the above example, the capsule payload is the U-Boot image. The +capsule entry would read the contents of the payload and put them +into the capsule. Any external file can also be specified as the +payload using the blob-ext subnode.
+.. _`UEFI specification`: https://uefi.org/sites/default/files/resources/UEFI_Spec_2_10_Aug29.pdf
.. _etype_encrypted:
Entry: encrypted: Externally built encrypted binary blob diff --git a/tools/binman/etype/efi_capsule.py b/tools/binman/etype/efi_capsule.py new file mode 100644 index 0000000000..bfdca94e26 --- /dev/null +++ b/tools/binman/etype/efi_capsule.py @@ -0,0 +1,143 @@ +# SPDX-License-Identifier: GPL-2.0+ +# Copyright (c) 2023 Linaro Limited +# +# Entry-type module for producing a EFI capsule +#
+import os
+from binman.entry import Entry +from binman.etype.section import Entry_section +from dtoc import fdt_util +from u_boot_pylib import tools
+class Entry_efi_capsule(Entry_section):
- """Generate EFI capsules
- The parameters needed for generation of the capsules can
- be provided as properties in the entry.
- Properties / Entry arguments:
- image-index: Unique number for identifying corresponding
payload image. Number between 1 and descriptor count, i.e.
the total number of firmware images that can be updated.
- image-type-id: Image GUID which will be used for identifying the
updatable image on the board.
- hardware-instance: Optional number for identifying unique
hardware instance of a device in the system. Default value of 0
for images where value is not to be used.
- fw-version: Optional value of image version that can be put on
the capsule through the Firmware Management Protocol(FMP) header.
- monotonic-count: Count used when signing an image.
- private-key: Path to PEM formatted .key private key file. This property
is mandatory for generating signed capsules.
- public-key-cert: Path to PEM formatted .crt public key certificate
file. This property is mandatory for generating signed capsules.
- oem-flags - Optional OEM flags to be passed through capsule header.
- Since this is a subclass of Entry_section, all properties of the parent
- class also apply here.
- For more details on the description of the capsule format, and the capsule
- update functionality, refer Section 8.5 and Chapter 23 in the `UEFI
- specification`_.
- The capsule parameters like image index and image GUID are passed as
- properties in the entry. The payload to be used in the capsule is to be
- provided as a subnode of the capsule entry.
- A typical capsule entry node would then look something like this
- capsule {
type = "efi-capsule";
image-index = <0x1>;
/* Image GUID for testing capsule update */
image-type-id = SANDBOX_UBOOT_IMAGE_GUID;
hardware-instance = <0x0>;
private-key = "path/to/the/private/key";
public-key-cert = "path/to/the/public-key-cert";
oem-flags = <0x8000>;
u-boot {
};
- };
- In the above example, the capsule payload is the U-Boot image. The
- capsule entry would read the contents of the payload and put them
- into the capsule. Any external file can also be specified as the
- payload using the blob-ext subnode.
- .. _`UEFI specification`: https://uefi.org/sites/default/files/resources/UEFI_Spec_2_10_Aug29.pdf
- """
- def __init__(self, section, etype, node):
super().__init__(section, etype, node)
self.required_props = ['image-index', 'image-type-id']
self.image_index = 0
self.image_guid = ''
self.hardware_instance = 0
self.monotonic_count = 0
self.fw_version = 0
self.oem_flags = 0
self.private_key = ''
self.public_key_cert = ''
self.auth = 0
- def ReadNode(self):
self.ReadEntries()
super().ReadNode()
I believe those two lines should be swapped.
self.image_index = fdt_util.GetInt(self._node, 'image-index')
self.image_guid = fdt_util.GetString(self._node, 'image-type-id')
self.fw_version = fdt_util.GetInt(self._node, 'fw-version')
self.hardware_instance = fdt_util.GetInt(self._node, 'hardware-instance')
self.monotonic_count = fdt_util.GetInt(self._node, 'monotonic-count')
self.oem_flags = fdt_util.GetInt(self._node, 'oem-flags')
self.private_key = fdt_util.GetString(self._node, 'private-key')
self.public_key_cert = fdt_util.GetString(self._node, 'public-key-cert')
if ((self.private_key and not self.public_key_cert) or (self.public_key_cert and not self.private_key)):
self.Raise('Both private key and public key certificate need to be provided')
elif not (self.private_key and self.public_key_cert):
self.auth = 0
else:
self.auth = 1
- def ReadEntries(self):
"""Read the subnode to get the payload for this capsule"""
# We can have a single payload per capsule
if len(self._node.subnodes) == 0:
self.Raise('The capsule entry expects at least one subnode for payload')
Still need to drop this
for node in self._node.subnodes:
entry = Entry.Create(self, node)
entry.ReadNode()
self._entries[entry.name] = entry
I think you can drop this method, since it should be the same as entry_Sectoin ?
- def BuildSectionData(self, required):
private_key = ''
public_key_cert = ''
if self.auth:
if not os.path.isabs(self.private_key):
private_key = tools.get_input_filename(self.private_key)
if not os.path.isabs(self.public_key_cert):
public_key_cert = tools.get_input_filename(self.public_key_cert)
data, payload, _ = self.collect_contents_to_file(
s/_/uniq/ since you need this below
self._entries.values(), 'capsule_payload')
'capsule_in' is better as it is an input to this entry type
outfile = self._filename if self._filename else self._node.name
You need a unique filename so cannot use self._node.name since it is not guaranteed to be unique.
See how mkimage does this, using uniq
capsule_fname = tools.get_output_filename(outfile)
ret = self.mkeficapsule.generate_capsule(self.image_index,
self.image_guid,
self.hardware_instance,
payload,
capsule_fname,
private_key,
public_key_cert,
self.monotonic_count,
self.fw_version,
self.oem_flags)
if ret is not None:
os.remove(payload)
return tools.read_file(capsule_fname)
- def AddBintools(self, btools):
self.mkeficapsule = self.AddBintool(btools, 'mkeficapsule')
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index 36428ec343..9bda0157f7 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -48,6 +48,7 @@ U_BOOT_VPL_DATA = b'vpl76543210fedcbazywxyz_' BLOB_DATA = b'89' ME_DATA = b'0abcd' VGA_DATA = b'vga' +EFI_CAPSULE_DATA = b'efi' U_BOOT_DTB_DATA = b'udtb' U_BOOT_SPL_DTB_DATA = b'spldtb' U_BOOT_TPL_DTB_DATA = b'tpldtb' @@ -119,6 +120,11 @@ COMP_BINTOOLS = ['bzip2', 'gzip', 'lz4', 'lzma_alone', 'lzop', 'xz', 'zstd']
TEE_ADDR = 0x5678
+# Firmware Management Protocol(FMP) GUID +FW_MGMT_GUID = 'edd5cb6d2de8444cbda17194199ad92a' +# Image GUID specified in the DTS +CAPSULE_IMAGE_GUID = '52cfd7092007104791d108469b7fe9c8'
class TestFunctional(unittest.TestCase): """Functional tests for binman
@@ -215,6 +221,7 @@ class TestFunctional(unittest.TestCase): TestFunctional._MakeInputFile('scp.bin', SCP_DATA) TestFunctional._MakeInputFile('rockchip-tpl.bin', ROCKCHIP_TPL_DATA) TestFunctional._MakeInputFile('ti_unsecure.bin', TI_UNSECURE_DATA)
TestFunctional._MakeInputFile('capsule_input.bin', EFI_CAPSULE_DATA) # Add a few .dtb files for testing TestFunctional._MakeInputFile('%s/test-fdt1.dtb' % TEST_FDT_SUBDIR,
@@ -7139,5 +7146,119 @@ fdt fdtmap Extract the devicetree blob from the fdtmap self.assertEqual(fdt_util.GetString(key_node, "key-name-hint"), "key")
- def _CheckCapsule(self, data, signed_capsule=False, version_check=False,
capoemflags=False):
fmp_signature = "4d535331" # 'M', 'S', 'S', '1'
fmp_size = "10"
fmp_fw_version = "02"
oemflag = "0080"
payload_data = EFI_CAPSULE_DATA
# Firmware Management Protocol(FMP) GUID - offset(0 - 32)
self.assertEqual(FW_MGMT_GUID, data.hex()[:32])
# Image GUID - offset(96 - 128)
self.assertEqual(CAPSULE_IMAGE_GUID, data.hex()[96:128])
As discussed please add a TODO here, so it is clear that you are planning to write a decoder tool like dump_image.
if capoemflags:
# OEM Flags - offset(40 - 44)
self.assertEqual(oemflag, data.hex()[40:44])
if signed_capsule and version_check:
# FMP header signature - offset(4770 - 4778)
self.assertEqual(fmp_signature, data.hex()[4770:4778])
# FMP header size - offset(4778 - 4780)
self.assertEqual(fmp_size, data.hex()[4778:4780])
# firmware version - offset(4786 - 4788)
self.assertEqual(fmp_fw_version, data.hex()[4786:4788])
# payload offset signed capsule(4802 - 4808)
self.assertEqual(payload_data.hex(), data.hex()[4802:4808])
elif signed_capsule:
# payload offset signed capsule(4770 - 4776)
self.assertEqual(payload_data.hex(), data.hex()[4770:4776])
elif version_check:
# FMP header signature - offset(184 - 192)
self.assertEqual(fmp_signature, data.hex()[184:192])
# FMP header size - offset(192 - 194)
self.assertEqual(fmp_size, data.hex()[192:194])
# firmware version - offset(200 - 202)
self.assertEqual(fmp_fw_version, data.hex()[200:202])
# payload offset for non-signed capsule with version header(216 - 222)
self.assertEqual(payload_data.hex(), data.hex()[216:222])
else:
# payload offset for non-signed capsule with no version header(184 - 190)
self.assertEqual(payload_data.hex(), data.hex()[184:190])
- def testCapsuleGen(self):
"""Test generation of EFI capsule"""
data = self._DoReadFile('307_capsule.dts')
self._CheckCapsule(data)
- def testSignedCapsuleGen(self):
"""Test generation of EFI capsule"""
data = tools.read_file(self.TestFile("key.key"))
self._MakeInputFile("key.key", data)
data = tools.read_file(self.TestFile("key.pem"))
self._MakeInputFile("key.crt", data)
data = self._DoReadFile('308_capsule_signed.dts')
self._CheckCapsule(data, signed_capsule=True)
- def testCapsuleGenVersionSupport(self):
"""Test generation of EFI capsule with version support"""
data = self._DoReadFile('309_capsule_version.dts')
self._CheckCapsule(data, version_check=True)
- def testCapsuleGenSignedVer(self):
"""Test generation of signed EFI capsule with version information"""
data = tools.read_file(self.TestFile("key.key"))
self._MakeInputFile("key.key", data)
data = tools.read_file(self.TestFile("key.pem"))
self._MakeInputFile("key.crt", data)
data = self._DoReadFile('310_capsule_signed_ver.dts')
self._CheckCapsule(data, signed_capsule=True, version_check=True)
- def testCapsuleGenCapOemFlags(self):
"""Test generation of EFI capsule with OEM Flags set"""
data = self._DoReadFile('311_capsule_oemflags.dts')
self._CheckCapsule(data, capoemflags=True)
- def testCapsuleGenKeyMissing(self):
"""Test that binman errors out on missing key"""
with self.assertRaises(ValueError) as e:
self._DoReadFile('312_capsule_missing_key.dts')
self.assertIn("Both private key and public key certificate need to be provided",
str(e.exception))
- def testCapsuleGenIndexMissing(self):
"""Test that binman errors out on missing image index"""
with self.assertRaises(ValueError) as e:
self._DoReadFile('313_capsule_missing_index.dts')
self.assertIn("entry is missing properties: image-index",
str(e.exception))
- def testCapsuleGenGuidMissing(self):
"""Test that binman errors out on missing image GUID"""
with self.assertRaises(ValueError) as e:
self._DoReadFile('314_capsule_missing_guid.dts')
self.assertIn("entry is missing properties: image-type-id",
str(e.exception))
- def testCapsuleGenPayloadMissing(self):
"""Test that binman errors out on missing input(payload)image"""
with self.assertRaises(ValueError) as e:
self._DoReadFile('315_capsule_missing_payload.dts')
self.assertIn("The capsule entry expects at least one subnode for payload",
str(e.exception))
if __name__ == "__main__": unittest.main() diff --git a/tools/binman/test/307_capsule.dts b/tools/binman/test/307_capsule.dts new file mode 100644 index 0000000000..86552ff83f --- /dev/null +++ b/tools/binman/test/307_capsule.dts @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: GPL-2.0+
+/dts-v1/;
+#include <sandbox_efi_capsule.h>
We can't include sandbox files in binman! I Does it actually matter what the GUID value is? Can they all be the same? For now I think it is best to have
#define BINMAN_TEST_GUID "xxx"
repeated at the top of each .dts file. Hopefully at some point we can figure out a sensible way to provide a decoder ring for this mess, so we can use actually names in the binman definition instead of GUIDs.
+/ {
#address-cells = <1>;
#size-cells = <1>;
binman {
efi-capsule {
image-index = <0x1>;
/* Image GUID for testing capsule update */
image-type-id = SANDBOX_UBOOT_IMAGE_GUID;
hardware-instance = <0x0>;
blob {
filename = "capsule_input.bin";
};
};
};
+};
Regards, Simon

Hi Sughosh,
On Sat, 5 Aug 2023 at 09:03, Simon Glass sjg@chromium.org wrote:
Hi Sughosh,
On Sat, 5 Aug 2023 at 05:35, Sughosh Ganu sughosh.ganu@linaro.org wrote:
Add support in binman for generating EFI capsules. The capsule parameters can be specified through the capsule binman entry. Also add test cases in binman for testing capsule generation.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
Changes since V6:
- Add macros for the GUID strings in sandbox_efi_capsule.h
- Highlight that the private and public keys are mandatory for capsule signing.
- Add a URL link to the UEFI spec, as used in the rst files.
- Use local vars for private and public keys in BuildSectionData()
- Use local vars for input payload and capsule filenames in BuildSectionData().
- Drop the ProcessContents() and SetImagePos() as the superclass functions suffice.
- Use GUID macro names in the capsule test dts files.
- Rename efi_capsule_payload.bin to capsule_input.bin.
include/sandbox_efi_capsule.h | 14 ++
Please move this file to a later patch - see below.
Could we have a single header file with all the GUIDs, i.e. sandbox, ARM, etc.
tools/binman/entries.rst | 62 ++++++++ tools/binman/etype/efi_capsule.py | 143 ++++++++++++++++++ tools/binman/ftest.py | 121 +++++++++++++++ tools/binman/test/307_capsule.dts | 23 +++ tools/binman/test/308_capsule_signed.dts | 25 +++ tools/binman/test/309_capsule_version.dts | 24 +++ tools/binman/test/310_capsule_signed_ver.dts | 26 ++++ tools/binman/test/311_capsule_oemflags.dts | 24 +++ tools/binman/test/312_capsule_missing_key.dts | 24 +++ .../binman/test/313_capsule_missing_index.dts | 22 +++ .../binman/test/314_capsule_missing_guid.dts | 19 +++ .../test/315_capsule_missing_payload.dts | 19 +++ 13 files changed, 546 insertions(+) create mode 100644 include/sandbox_efi_capsule.h create mode 100644 tools/binman/etype/efi_capsule.py create mode 100644 tools/binman/test/307_capsule.dts create mode 100644 tools/binman/test/308_capsule_signed.dts create mode 100644 tools/binman/test/309_capsule_version.dts create mode 100644 tools/binman/test/310_capsule_signed_ver.dts create mode 100644 tools/binman/test/311_capsule_oemflags.dts create mode 100644 tools/binman/test/312_capsule_missing_key.dts create mode 100644 tools/binman/test/313_capsule_missing_index.dts create mode 100644 tools/binman/test/314_capsule_missing_guid.dts create mode 100644 tools/binman/test/315_capsule_missing_payload.dts
[..]
diff --git a/tools/binman/test/307_capsule.dts b/tools/binman/test/307_capsule.dts new file mode 100644 index 0000000000..86552ff83f --- /dev/null +++ b/tools/binman/test/307_capsule.dts @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: GPL-2.0+
+/dts-v1/;
+#include <sandbox_efi_capsule.h>
We can't include sandbox files in binman! I Does it actually matter what the GUID value is? Can they all be the same? For now I think it is best to have
#define BINMAN_TEST_GUID "xxx"
repeated at the top of each .dts file. Hopefully at some point we can figure out a sensible way to provide a decoder ring for this mess, so we can use actually names in the binman definition instead of GUIDs.
Oh, having thought about this a bit more, there is a much better way.
In the entry type, allow the image_guid to be a string, like 'binman-test' or 'sandbox-test'. Then binman can have a conversion function to figure out the GUID to pass to the tool, e.g. in efi_capsule.py:
TYPE_TO_GUID = { 'binman-test': '09123987987f98712', 'sandbox-test':, '98123987123123987123987', }
def get_guid(type_str): 'Get the GUID to use for a particular purpose""" return TYPE_TO_GUID.get(type_str, type_str)
Then you can use these same strings in the sandbox tests, without needing to include anything.
+/ {
#address-cells = <1>;
#size-cells = <1>;
binman {
efi-capsule {
image-index = <0x1>;
/* Image GUID for testing capsule update */
image-type-id = SANDBOX_UBOOT_IMAGE_GUID;
hardware-instance = <0x0>;
blob {
filename = "capsule_input.bin";
};
};
};
+};
Regards, Simon

hi Simon,
On Sat, 5 Aug 2023 at 22:50, Simon Glass sjg@chromium.org wrote:
Hi Sughosh,
On Sat, 5 Aug 2023 at 09:03, Simon Glass sjg@chromium.org wrote:
Hi Sughosh,
On Sat, 5 Aug 2023 at 05:35, Sughosh Ganu sughosh.ganu@linaro.org wrote:
Add support in binman for generating EFI capsules. The capsule parameters can be specified through the capsule binman entry. Also add test cases in binman for testing capsule generation.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
Changes since V6:
- Add macros for the GUID strings in sandbox_efi_capsule.h
- Highlight that the private and public keys are mandatory for capsule signing.
- Add a URL link to the UEFI spec, as used in the rst files.
- Use local vars for private and public keys in BuildSectionData()
- Use local vars for input payload and capsule filenames in BuildSectionData().
- Drop the ProcessContents() and SetImagePos() as the superclass functions suffice.
- Use GUID macro names in the capsule test dts files.
- Rename efi_capsule_payload.bin to capsule_input.bin.
include/sandbox_efi_capsule.h | 14 ++
Please move this file to a later patch - see below.
Could we have a single header file with all the GUIDs, i.e. sandbox, ARM, etc.
tools/binman/entries.rst | 62 ++++++++ tools/binman/etype/efi_capsule.py | 143 ++++++++++++++++++ tools/binman/ftest.py | 121 +++++++++++++++ tools/binman/test/307_capsule.dts | 23 +++ tools/binman/test/308_capsule_signed.dts | 25 +++ tools/binman/test/309_capsule_version.dts | 24 +++ tools/binman/test/310_capsule_signed_ver.dts | 26 ++++ tools/binman/test/311_capsule_oemflags.dts | 24 +++ tools/binman/test/312_capsule_missing_key.dts | 24 +++ .../binman/test/313_capsule_missing_index.dts | 22 +++ .../binman/test/314_capsule_missing_guid.dts | 19 +++ .../test/315_capsule_missing_payload.dts | 19 +++ 13 files changed, 546 insertions(+) create mode 100644 include/sandbox_efi_capsule.h create mode 100644 tools/binman/etype/efi_capsule.py create mode 100644 tools/binman/test/307_capsule.dts create mode 100644 tools/binman/test/308_capsule_signed.dts create mode 100644 tools/binman/test/309_capsule_version.dts create mode 100644 tools/binman/test/310_capsule_signed_ver.dts create mode 100644 tools/binman/test/311_capsule_oemflags.dts create mode 100644 tools/binman/test/312_capsule_missing_key.dts create mode 100644 tools/binman/test/313_capsule_missing_index.dts create mode 100644 tools/binman/test/314_capsule_missing_guid.dts create mode 100644 tools/binman/test/315_capsule_missing_payload.dts
[..]
diff --git a/tools/binman/test/307_capsule.dts b/tools/binman/test/307_capsule.dts new file mode 100644 index 0000000000..86552ff83f --- /dev/null +++ b/tools/binman/test/307_capsule.dts @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: GPL-2.0+
+/dts-v1/;
+#include <sandbox_efi_capsule.h>
We can't include sandbox files in binman! I Does it actually matter what the GUID value is? Can they all be the same? For now I think it is best to have
#define BINMAN_TEST_GUID "xxx"
repeated at the top of each .dts file. Hopefully at some point we can figure out a sensible way to provide a decoder ring for this mess, so we can use actually names in the binman definition instead of GUIDs.
Oh, having thought about this a bit more, there is a much better way.
In the entry type, allow the image_guid to be a string, like 'binman-test' or 'sandbox-test'. Then binman can have a conversion function to figure out the GUID to pass to the tool, e.g. in efi_capsule.py:
TYPE_TO_GUID = { 'binman-test': '09123987987f98712', 'sandbox-test':, '98123987123123987123987', }
def get_guid(type_str): 'Get the GUID to use for a particular purpose""" return TYPE_TO_GUID.get(type_str, type_str)
Then you can use these same strings in the sandbox tests, without needing to include anything.
Okay, will try this out. Thanks for the suggestion.
-sughosh
+/ {
#address-cells = <1>;
#size-cells = <1>;
binman {
efi-capsule {
image-index = <0x1>;
/* Image GUID for testing capsule update */
image-type-id = SANDBOX_UBOOT_IMAGE_GUID;
hardware-instance = <0x0>;
blob {
filename = "capsule_input.bin";
};
};
};
+};
Regards, Simon

hi Simon,
On Sat, 5 Aug 2023 at 22:50, Simon Glass sjg@chromium.org wrote:
Hi Sughosh,
On Sat, 5 Aug 2023 at 09:03, Simon Glass sjg@chromium.org wrote:
Hi Sughosh,
On Sat, 5 Aug 2023 at 05:35, Sughosh Ganu sughosh.ganu@linaro.org wrote:
Add support in binman for generating EFI capsules. The capsule parameters can be specified through the capsule binman entry. Also add test cases in binman for testing capsule generation.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
Changes since V6:
- Add macros for the GUID strings in sandbox_efi_capsule.h
- Highlight that the private and public keys are mandatory for capsule signing.
- Add a URL link to the UEFI spec, as used in the rst files.
- Use local vars for private and public keys in BuildSectionData()
- Use local vars for input payload and capsule filenames in BuildSectionData().
- Drop the ProcessContents() and SetImagePos() as the superclass functions suffice.
- Use GUID macro names in the capsule test dts files.
- Rename efi_capsule_payload.bin to capsule_input.bin.
include/sandbox_efi_capsule.h | 14 ++
Please move this file to a later patch - see below.
Could we have a single header file with all the GUIDs, i.e. sandbox, ARM, etc.
tools/binman/entries.rst | 62 ++++++++ tools/binman/etype/efi_capsule.py | 143 ++++++++++++++++++ tools/binman/ftest.py | 121 +++++++++++++++ tools/binman/test/307_capsule.dts | 23 +++ tools/binman/test/308_capsule_signed.dts | 25 +++ tools/binman/test/309_capsule_version.dts | 24 +++ tools/binman/test/310_capsule_signed_ver.dts | 26 ++++ tools/binman/test/311_capsule_oemflags.dts | 24 +++ tools/binman/test/312_capsule_missing_key.dts | 24 +++ .../binman/test/313_capsule_missing_index.dts | 22 +++ .../binman/test/314_capsule_missing_guid.dts | 19 +++ .../test/315_capsule_missing_payload.dts | 19 +++ 13 files changed, 546 insertions(+) create mode 100644 include/sandbox_efi_capsule.h create mode 100644 tools/binman/etype/efi_capsule.py create mode 100644 tools/binman/test/307_capsule.dts create mode 100644 tools/binman/test/308_capsule_signed.dts create mode 100644 tools/binman/test/309_capsule_version.dts create mode 100644 tools/binman/test/310_capsule_signed_ver.dts create mode 100644 tools/binman/test/311_capsule_oemflags.dts create mode 100644 tools/binman/test/312_capsule_missing_key.dts create mode 100644 tools/binman/test/313_capsule_missing_index.dts create mode 100644 tools/binman/test/314_capsule_missing_guid.dts create mode 100644 tools/binman/test/315_capsule_missing_payload.dts
[..]
diff --git a/tools/binman/test/307_capsule.dts b/tools/binman/test/307_capsule.dts new file mode 100644 index 0000000000..86552ff83f --- /dev/null +++ b/tools/binman/test/307_capsule.dts @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: GPL-2.0+
+/dts-v1/;
+#include <sandbox_efi_capsule.h>
We can't include sandbox files in binman! I Does it actually matter what the GUID value is? Can they all be the same? For now I think it is best to have
#define BINMAN_TEST_GUID "xxx"
repeated at the top of each .dts file. Hopefully at some point we can figure out a sensible way to provide a decoder ring for this mess, so we can use actually names in the binman definition instead of GUIDs.
Oh, having thought about this a bit more, there is a much better way.
In the entry type, allow the image_guid to be a string, like 'binman-test' or 'sandbox-test'. Then binman can have a conversion function to figure out the GUID to pass to the tool, e.g. in efi_capsule.py:
TYPE_TO_GUID = { 'binman-test': '09123987987f98712', 'sandbox-test':, '98123987123123987123987', }
def get_guid(type_str): 'Get the GUID to use for a particular purpose""" return TYPE_TO_GUID.get(type_str, type_str)
Then you can use these same strings in the sandbox tests, without needing to include anything.
While we can use this method for both sandbox and binman tests, I would prefer using the actual GUID strings for the sandbox tests. This will serve as an illustrative example to the user for how to pass the image GUID value for generating the capsule. For the binman tests, I can use this logic to avoid including the header file.
-sughosh
+/ {
#address-cells = <1>;
#size-cells = <1>;
binman {
efi-capsule {
image-index = <0x1>;
/* Image GUID for testing capsule update */
image-type-id = SANDBOX_UBOOT_IMAGE_GUID;
hardware-instance = <0x0>;
blob {
filename = "capsule_input.bin";
};
};
};
+};
Regards, Simon

Hi Sughosh,
On Sun, 6 Aug 2023 at 09:35, Sughosh Ganu sughosh.ganu@linaro.org wrote:
hi Simon,
On Sat, 5 Aug 2023 at 22:50, Simon Glass sjg@chromium.org wrote:
Hi Sughosh,
On Sat, 5 Aug 2023 at 09:03, Simon Glass sjg@chromium.org wrote:
Hi Sughosh,
On Sat, 5 Aug 2023 at 05:35, Sughosh Ganu sughosh.ganu@linaro.org wrote:
Add support in binman for generating EFI capsules. The capsule parameters can be specified through the capsule binman entry. Also add test cases in binman for testing capsule generation.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
Changes since V6:
- Add macros for the GUID strings in sandbox_efi_capsule.h
- Highlight that the private and public keys are mandatory for capsule signing.
- Add a URL link to the UEFI spec, as used in the rst files.
- Use local vars for private and public keys in BuildSectionData()
- Use local vars for input payload and capsule filenames in BuildSectionData().
- Drop the ProcessContents() and SetImagePos() as the superclass functions suffice.
- Use GUID macro names in the capsule test dts files.
- Rename efi_capsule_payload.bin to capsule_input.bin.
include/sandbox_efi_capsule.h | 14 ++
Please move this file to a later patch - see below.
Could we have a single header file with all the GUIDs, i.e. sandbox, ARM, etc.
tools/binman/entries.rst | 62 ++++++++ tools/binman/etype/efi_capsule.py | 143 ++++++++++++++++++ tools/binman/ftest.py | 121 +++++++++++++++ tools/binman/test/307_capsule.dts | 23 +++ tools/binman/test/308_capsule_signed.dts | 25 +++ tools/binman/test/309_capsule_version.dts | 24 +++ tools/binman/test/310_capsule_signed_ver.dts | 26 ++++ tools/binman/test/311_capsule_oemflags.dts | 24 +++ tools/binman/test/312_capsule_missing_key.dts | 24 +++ .../binman/test/313_capsule_missing_index.dts | 22 +++ .../binman/test/314_capsule_missing_guid.dts | 19 +++ .../test/315_capsule_missing_payload.dts | 19 +++ 13 files changed, 546 insertions(+) create mode 100644 include/sandbox_efi_capsule.h create mode 100644 tools/binman/etype/efi_capsule.py create mode 100644 tools/binman/test/307_capsule.dts create mode 100644 tools/binman/test/308_capsule_signed.dts create mode 100644 tools/binman/test/309_capsule_version.dts create mode 100644 tools/binman/test/310_capsule_signed_ver.dts create mode 100644 tools/binman/test/311_capsule_oemflags.dts create mode 100644 tools/binman/test/312_capsule_missing_key.dts create mode 100644 tools/binman/test/313_capsule_missing_index.dts create mode 100644 tools/binman/test/314_capsule_missing_guid.dts create mode 100644 tools/binman/test/315_capsule_missing_payload.dts
[..]
diff --git a/tools/binman/test/307_capsule.dts b/tools/binman/test/307_capsule.dts new file mode 100644 index 0000000000..86552ff83f --- /dev/null +++ b/tools/binman/test/307_capsule.dts @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: GPL-2.0+
+/dts-v1/;
+#include <sandbox_efi_capsule.h>
We can't include sandbox files in binman! I Does it actually matter what the GUID value is? Can they all be the same? For now I think it is best to have
#define BINMAN_TEST_GUID "xxx"
repeated at the top of each .dts file. Hopefully at some point we can figure out a sensible way to provide a decoder ring for this mess, so we can use actually names in the binman definition instead of GUIDs.
Oh, having thought about this a bit more, there is a much better way.
In the entry type, allow the image_guid to be a string, like 'binman-test' or 'sandbox-test'. Then binman can have a conversion function to figure out the GUID to pass to the tool, e.g. in efi_capsule.py:
TYPE_TO_GUID = { 'binman-test': '09123987987f98712', 'sandbox-test':, '98123987123123987123987', }
def get_guid(type_str): 'Get the GUID to use for a particular purpose""" return TYPE_TO_GUID.get(type_str, type_str)
Then you can use these same strings in the sandbox tests, without needing to include anything.
While we can use this method for both sandbox and binman tests, I would prefer using the actual GUID strings for the sandbox tests. This will serve as an illustrative example to the user for how to pass the image GUID value for generating the capsule. For the binman tests, I can use this logic to avoid including the header file.
So long as it is easy, that's OK. But how does the user know which GUID to use?
Regards, Simon

hi Simon,
On Mon, 7 Aug 2023 at 00:16, Simon Glass sjg@chromium.org wrote:
Hi Sughosh,
On Sun, 6 Aug 2023 at 09:35, Sughosh Ganu sughosh.ganu@linaro.org wrote:
hi Simon,
On Sat, 5 Aug 2023 at 22:50, Simon Glass sjg@chromium.org wrote:
Hi Sughosh,
On Sat, 5 Aug 2023 at 09:03, Simon Glass sjg@chromium.org wrote:
Hi Sughosh,
On Sat, 5 Aug 2023 at 05:35, Sughosh Ganu sughosh.ganu@linaro.org wrote:
Add support in binman for generating EFI capsules. The capsule parameters can be specified through the capsule binman entry. Also add test cases in binman for testing capsule generation.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
Changes since V6:
- Add macros for the GUID strings in sandbox_efi_capsule.h
- Highlight that the private and public keys are mandatory for capsule signing.
- Add a URL link to the UEFI spec, as used in the rst files.
- Use local vars for private and public keys in BuildSectionData()
- Use local vars for input payload and capsule filenames in BuildSectionData().
- Drop the ProcessContents() and SetImagePos() as the superclass functions suffice.
- Use GUID macro names in the capsule test dts files.
- Rename efi_capsule_payload.bin to capsule_input.bin.
include/sandbox_efi_capsule.h | 14 ++
Please move this file to a later patch - see below.
Could we have a single header file with all the GUIDs, i.e. sandbox, ARM, etc.
tools/binman/entries.rst | 62 ++++++++ tools/binman/etype/efi_capsule.py | 143 ++++++++++++++++++ tools/binman/ftest.py | 121 +++++++++++++++ tools/binman/test/307_capsule.dts | 23 +++ tools/binman/test/308_capsule_signed.dts | 25 +++ tools/binman/test/309_capsule_version.dts | 24 +++ tools/binman/test/310_capsule_signed_ver.dts | 26 ++++ tools/binman/test/311_capsule_oemflags.dts | 24 +++ tools/binman/test/312_capsule_missing_key.dts | 24 +++ .../binman/test/313_capsule_missing_index.dts | 22 +++ .../binman/test/314_capsule_missing_guid.dts | 19 +++ .../test/315_capsule_missing_payload.dts | 19 +++ 13 files changed, 546 insertions(+) create mode 100644 include/sandbox_efi_capsule.h create mode 100644 tools/binman/etype/efi_capsule.py create mode 100644 tools/binman/test/307_capsule.dts create mode 100644 tools/binman/test/308_capsule_signed.dts create mode 100644 tools/binman/test/309_capsule_version.dts create mode 100644 tools/binman/test/310_capsule_signed_ver.dts create mode 100644 tools/binman/test/311_capsule_oemflags.dts create mode 100644 tools/binman/test/312_capsule_missing_key.dts create mode 100644 tools/binman/test/313_capsule_missing_index.dts create mode 100644 tools/binman/test/314_capsule_missing_guid.dts create mode 100644 tools/binman/test/315_capsule_missing_payload.dts
[..]
diff --git a/tools/binman/test/307_capsule.dts b/tools/binman/test/307_capsule.dts new file mode 100644 index 0000000000..86552ff83f --- /dev/null +++ b/tools/binman/test/307_capsule.dts @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: GPL-2.0+
+/dts-v1/;
+#include <sandbox_efi_capsule.h>
We can't include sandbox files in binman! I Does it actually matter what the GUID value is? Can they all be the same? For now I think it is best to have
#define BINMAN_TEST_GUID "xxx"
repeated at the top of each .dts file. Hopefully at some point we can figure out a sensible way to provide a decoder ring for this mess, so we can use actually names in the binman definition instead of GUIDs.
Oh, having thought about this a bit more, there is a much better way.
In the entry type, allow the image_guid to be a string, like 'binman-test' or 'sandbox-test'. Then binman can have a conversion function to figure out the GUID to pass to the tool, e.g. in efi_capsule.py:
TYPE_TO_GUID = { 'binman-test': '09123987987f98712', 'sandbox-test':, '98123987123123987123987', }
def get_guid(type_str): 'Get the GUID to use for a particular purpose""" return TYPE_TO_GUID.get(type_str, type_str)
Then you can use these same strings in the sandbox tests, without needing to include anything.
While we can use this method for both sandbox and binman tests, I would prefer using the actual GUID strings for the sandbox tests. This will serve as an illustrative example to the user for how to pass the image GUID value for generating the capsule. For the binman tests, I can use this logic to avoid including the header file.
So long as it is easy, that's OK. But how does the user know which GUID to use?
I think you got me wrong here. What I meant was that passing the GUID value in the capsule entry like how it is currently done in the u-boot.dtsi file would give the user an idea of how to specify the GUID value for an image. If we use the string that you suggest above for both binman tests as well as sandbox, the user might get confused as to how the GUID value is to be passed in the normal scenario. I want the sandbox capsule entries to also be kind of illustrative of how a capsule entry would look like.
-sughosh
Regards, Simon

Hi Sughosh,
On Sun, 6 Aug 2023 at 13:27, Sughosh Ganu sughosh.ganu@linaro.org wrote:
hi Simon,
On Mon, 7 Aug 2023 at 00:16, Simon Glass sjg@chromium.org wrote:
Hi Sughosh,
On Sun, 6 Aug 2023 at 09:35, Sughosh Ganu sughosh.ganu@linaro.org wrote:
hi Simon,
On Sat, 5 Aug 2023 at 22:50, Simon Glass sjg@chromium.org wrote:
Hi Sughosh,
On Sat, 5 Aug 2023 at 09:03, Simon Glass sjg@chromium.org wrote:
Hi Sughosh,
On Sat, 5 Aug 2023 at 05:35, Sughosh Ganu sughosh.ganu@linaro.org wrote:
Add support in binman for generating EFI capsules. The capsule parameters can be specified through the capsule binman entry. Also add test cases in binman for testing capsule generation.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
Changes since V6:
- Add macros for the GUID strings in sandbox_efi_capsule.h
- Highlight that the private and public keys are mandatory for capsule signing.
- Add a URL link to the UEFI spec, as used in the rst files.
- Use local vars for private and public keys in BuildSectionData()
- Use local vars for input payload and capsule filenames in BuildSectionData().
- Drop the ProcessContents() and SetImagePos() as the superclass functions suffice.
- Use GUID macro names in the capsule test dts files.
- Rename efi_capsule_payload.bin to capsule_input.bin.
include/sandbox_efi_capsule.h | 14 ++
Please move this file to a later patch - see below.
Could we have a single header file with all the GUIDs, i.e. sandbox, ARM, etc.
tools/binman/entries.rst | 62 ++++++++ tools/binman/etype/efi_capsule.py | 143 ++++++++++++++++++ tools/binman/ftest.py | 121 +++++++++++++++ tools/binman/test/307_capsule.dts | 23 +++ tools/binman/test/308_capsule_signed.dts | 25 +++ tools/binman/test/309_capsule_version.dts | 24 +++ tools/binman/test/310_capsule_signed_ver.dts | 26 ++++ tools/binman/test/311_capsule_oemflags.dts | 24 +++ tools/binman/test/312_capsule_missing_key.dts | 24 +++ .../binman/test/313_capsule_missing_index.dts | 22 +++ .../binman/test/314_capsule_missing_guid.dts | 19 +++ .../test/315_capsule_missing_payload.dts | 19 +++ 13 files changed, 546 insertions(+) create mode 100644 include/sandbox_efi_capsule.h create mode 100644 tools/binman/etype/efi_capsule.py create mode 100644 tools/binman/test/307_capsule.dts create mode 100644 tools/binman/test/308_capsule_signed.dts create mode 100644 tools/binman/test/309_capsule_version.dts create mode 100644 tools/binman/test/310_capsule_signed_ver.dts create mode 100644 tools/binman/test/311_capsule_oemflags.dts create mode 100644 tools/binman/test/312_capsule_missing_key.dts create mode 100644 tools/binman/test/313_capsule_missing_index.dts create mode 100644 tools/binman/test/314_capsule_missing_guid.dts create mode 100644 tools/binman/test/315_capsule_missing_payload.dts
[..]
diff --git a/tools/binman/test/307_capsule.dts b/tools/binman/test/307_capsule.dts new file mode 100644 index 0000000000..86552ff83f --- /dev/null +++ b/tools/binman/test/307_capsule.dts @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: GPL-2.0+
+/dts-v1/;
+#include <sandbox_efi_capsule.h>
We can't include sandbox files in binman! I Does it actually matter what the GUID value is? Can they all be the same? For now I think it is best to have
#define BINMAN_TEST_GUID "xxx"
repeated at the top of each .dts file. Hopefully at some point we can figure out a sensible way to provide a decoder ring for this mess, so we can use actually names in the binman definition instead of GUIDs.
Oh, having thought about this a bit more, there is a much better way.
In the entry type, allow the image_guid to be a string, like 'binman-test' or 'sandbox-test'. Then binman can have a conversion function to figure out the GUID to pass to the tool, e.g. in efi_capsule.py:
TYPE_TO_GUID = { 'binman-test': '09123987987f98712', 'sandbox-test':, '98123987123123987123987', }
def get_guid(type_str): 'Get the GUID to use for a particular purpose""" return TYPE_TO_GUID.get(type_str, type_str)
Then you can use these same strings in the sandbox tests, without needing to include anything.
While we can use this method for both sandbox and binman tests, I would prefer using the actual GUID strings for the sandbox tests. This will serve as an illustrative example to the user for how to pass the image GUID value for generating the capsule. For the binman tests, I can use this logic to avoid including the header file.
So long as it is easy, that's OK. But how does the user know which GUID to use?
I think you got me wrong here. What I meant was that passing the GUID value in the capsule entry like how it is currently done in the u-boot.dtsi file would give the user an idea of how to specify the GUID value for an image. If we use the string that you suggest above for both binman tests as well as sandbox, the user might get confused as to how the GUID value is to be passed in the normal scenario. I want the sandbox capsule entries to also be kind of illustrative of how a capsule entry would look like.
OK I see.
Of course, I would like to see a decoder ring for GUIDs somewhere. Perhaps Binman is a good place for that, or a file it can read?
Regards, Simon

hi Simon,
On Mon, 7 Aug 2023 at 07:04, Simon Glass sjg@chromium.org wrote:
Hi Sughosh,
On Sun, 6 Aug 2023 at 13:27, Sughosh Ganu sughosh.ganu@linaro.org wrote:
hi Simon,
On Mon, 7 Aug 2023 at 00:16, Simon Glass sjg@chromium.org wrote:
Hi Sughosh,
On Sun, 6 Aug 2023 at 09:35, Sughosh Ganu sughosh.ganu@linaro.org wrote:
hi Simon,
On Sat, 5 Aug 2023 at 22:50, Simon Glass sjg@chromium.org wrote:
Hi Sughosh,
On Sat, 5 Aug 2023 at 09:03, Simon Glass sjg@chromium.org wrote:
Hi Sughosh,
On Sat, 5 Aug 2023 at 05:35, Sughosh Ganu sughosh.ganu@linaro.org wrote: > > Add support in binman for generating EFI capsules. The capsule > parameters can be specified through the capsule binman entry. Also add > test cases in binman for testing capsule generation. > > Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org > --- > Changes since V6: > * Add macros for the GUID strings in sandbox_efi_capsule.h > * Highlight that the private and public keys are mandatory for capsule > signing. > * Add a URL link to the UEFI spec, as used in the rst files. > * Use local vars for private and public keys in BuildSectionData() > * Use local vars for input payload and capsule filenames in > BuildSectionData(). > * Drop the ProcessContents() and SetImagePos() as the superclass > functions suffice. > * Use GUID macro names in the capsule test dts files. > * Rename efi_capsule_payload.bin to capsule_input.bin. > > > include/sandbox_efi_capsule.h | 14 ++
Please move this file to a later patch - see below.
Could we have a single header file with all the GUIDs, i.e. sandbox, ARM, etc.
> tools/binman/entries.rst | 62 ++++++++ > tools/binman/etype/efi_capsule.py | 143 ++++++++++++++++++ > tools/binman/ftest.py | 121 +++++++++++++++ > tools/binman/test/307_capsule.dts | 23 +++ > tools/binman/test/308_capsule_signed.dts | 25 +++ > tools/binman/test/309_capsule_version.dts | 24 +++ > tools/binman/test/310_capsule_signed_ver.dts | 26 ++++ > tools/binman/test/311_capsule_oemflags.dts | 24 +++ > tools/binman/test/312_capsule_missing_key.dts | 24 +++ > .../binman/test/313_capsule_missing_index.dts | 22 +++ > .../binman/test/314_capsule_missing_guid.dts | 19 +++ > .../test/315_capsule_missing_payload.dts | 19 +++ > 13 files changed, 546 insertions(+) > create mode 100644 include/sandbox_efi_capsule.h > create mode 100644 tools/binman/etype/efi_capsule.py > create mode 100644 tools/binman/test/307_capsule.dts > create mode 100644 tools/binman/test/308_capsule_signed.dts > create mode 100644 tools/binman/test/309_capsule_version.dts > create mode 100644 tools/binman/test/310_capsule_signed_ver.dts > create mode 100644 tools/binman/test/311_capsule_oemflags.dts > create mode 100644 tools/binman/test/312_capsule_missing_key.dts > create mode 100644 tools/binman/test/313_capsule_missing_index.dts > create mode 100644 tools/binman/test/314_capsule_missing_guid.dts > create mode 100644 tools/binman/test/315_capsule_missing_payload.dts >
[..]
> diff --git a/tools/binman/test/307_capsule.dts b/tools/binman/test/307_capsule.dts > new file mode 100644 > index 0000000000..86552ff83f > --- /dev/null > +++ b/tools/binman/test/307_capsule.dts > @@ -0,0 +1,23 @@ > +// SPDX-License-Identifier: GPL-2.0+ > + > +/dts-v1/; > + > +#include <sandbox_efi_capsule.h>
We can't include sandbox files in binman! I Does it actually matter what the GUID value is? Can they all be the same? For now I think it is best to have
#define BINMAN_TEST_GUID "xxx"
repeated at the top of each .dts file. Hopefully at some point we can figure out a sensible way to provide a decoder ring for this mess, so we can use actually names in the binman definition instead of GUIDs.
Oh, having thought about this a bit more, there is a much better way.
In the entry type, allow the image_guid to be a string, like 'binman-test' or 'sandbox-test'. Then binman can have a conversion function to figure out the GUID to pass to the tool, e.g. in efi_capsule.py:
TYPE_TO_GUID = { 'binman-test': '09123987987f98712', 'sandbox-test':, '98123987123123987123987', }
def get_guid(type_str): 'Get the GUID to use for a particular purpose""" return TYPE_TO_GUID.get(type_str, type_str)
Then you can use these same strings in the sandbox tests, without needing to include anything.
While we can use this method for both sandbox and binman tests, I would prefer using the actual GUID strings for the sandbox tests. This will serve as an illustrative example to the user for how to pass the image GUID value for generating the capsule. For the binman tests, I can use this logic to avoid including the header file.
So long as it is easy, that's OK. But how does the user know which GUID to use?
I think you got me wrong here. What I meant was that passing the GUID value in the capsule entry like how it is currently done in the u-boot.dtsi file would give the user an idea of how to specify the GUID value for an image. If we use the string that you suggest above for both binman tests as well as sandbox, the user might get confused as to how the GUID value is to be passed in the normal scenario. I want the sandbox capsule entries to also be kind of illustrative of how a capsule entry would look like.
OK I see.
Of course, I would like to see a decoder ring for GUIDs somewhere. Perhaps Binman is a good place for that, or a file it can read?
I'd suggest we start with your above solution for the binman tests. If we get consensus amongst the folks who work on EFI to have such a GUID decoder file, it can be worked upon later. I think these are things which are part of a larger point that you have about specifying GUIDs in a particular way, and that should be tackled separately, and not through this series, especially at this stage in the series. My 2 cents.
-sughosh

Hi Sughosh,
On Mon, 7 Aug 2023 at 00:40, Sughosh Ganu sughosh.ganu@linaro.org wrote:
hi Simon,
On Mon, 7 Aug 2023 at 07:04, Simon Glass sjg@chromium.org wrote:
Hi Sughosh,
On Sun, 6 Aug 2023 at 13:27, Sughosh Ganu sughosh.ganu@linaro.org wrote:
hi Simon,
On Mon, 7 Aug 2023 at 00:16, Simon Glass sjg@chromium.org wrote:
Hi Sughosh,
On Sun, 6 Aug 2023 at 09:35, Sughosh Ganu sughosh.ganu@linaro.org wrote:
hi Simon,
On Sat, 5 Aug 2023 at 22:50, Simon Glass sjg@chromium.org wrote:
Hi Sughosh,
On Sat, 5 Aug 2023 at 09:03, Simon Glass sjg@chromium.org wrote: > > Hi Sughosh, > > On Sat, 5 Aug 2023 at 05:35, Sughosh Ganu sughosh.ganu@linaro.org wrote: > > > > Add support in binman for generating EFI capsules. The capsule > > parameters can be specified through the capsule binman entry. Also add > > test cases in binman for testing capsule generation. > > > > Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org > > --- > > Changes since V6: > > * Add macros for the GUID strings in sandbox_efi_capsule.h > > * Highlight that the private and public keys are mandatory for capsule > > signing. > > * Add a URL link to the UEFI spec, as used in the rst files. > > * Use local vars for private and public keys in BuildSectionData() > > * Use local vars for input payload and capsule filenames in > > BuildSectionData(). > > * Drop the ProcessContents() and SetImagePos() as the superclass > > functions suffice. > > * Use GUID macro names in the capsule test dts files. > > * Rename efi_capsule_payload.bin to capsule_input.bin. > > > > > > include/sandbox_efi_capsule.h | 14 ++ > > Please move this file to a later patch - see below. > > Could we have a single header file with all the GUIDs, i.e. sandbox, ARM, etc. > > > tools/binman/entries.rst | 62 ++++++++ > > tools/binman/etype/efi_capsule.py | 143 ++++++++++++++++++ > > tools/binman/ftest.py | 121 +++++++++++++++ > > tools/binman/test/307_capsule.dts | 23 +++ > > tools/binman/test/308_capsule_signed.dts | 25 +++ > > tools/binman/test/309_capsule_version.dts | 24 +++ > > tools/binman/test/310_capsule_signed_ver.dts | 26 ++++ > > tools/binman/test/311_capsule_oemflags.dts | 24 +++ > > tools/binman/test/312_capsule_missing_key.dts | 24 +++ > > .../binman/test/313_capsule_missing_index.dts | 22 +++ > > .../binman/test/314_capsule_missing_guid.dts | 19 +++ > > .../test/315_capsule_missing_payload.dts | 19 +++ > > 13 files changed, 546 insertions(+) > > create mode 100644 include/sandbox_efi_capsule.h > > create mode 100644 tools/binman/etype/efi_capsule.py > > create mode 100644 tools/binman/test/307_capsule.dts > > create mode 100644 tools/binman/test/308_capsule_signed.dts > > create mode 100644 tools/binman/test/309_capsule_version.dts > > create mode 100644 tools/binman/test/310_capsule_signed_ver.dts > > create mode 100644 tools/binman/test/311_capsule_oemflags.dts > > create mode 100644 tools/binman/test/312_capsule_missing_key.dts > > create mode 100644 tools/binman/test/313_capsule_missing_index.dts > > create mode 100644 tools/binman/test/314_capsule_missing_guid.dts > > create mode 100644 tools/binman/test/315_capsule_missing_payload.dts > >
[..]
> > diff --git a/tools/binman/test/307_capsule.dts b/tools/binman/test/307_capsule.dts > > new file mode 100644 > > index 0000000000..86552ff83f > > --- /dev/null > > +++ b/tools/binman/test/307_capsule.dts > > @@ -0,0 +1,23 @@ > > +// SPDX-License-Identifier: GPL-2.0+ > > + > > +/dts-v1/; > > + > > +#include <sandbox_efi_capsule.h> > > We can't include sandbox files in binman! I Does it actually matter > what the GUID value is? Can they all be the same? For now I think it > is best to have > > #define BINMAN_TEST_GUID "xxx" > > repeated at the top of each .dts file. Hopefully at some point we can > figure out a sensible way to provide a decoder ring for this mess, so > we can use actually names in the binman definition instead of GUIDs.
Oh, having thought about this a bit more, there is a much better way.
In the entry type, allow the image_guid to be a string, like 'binman-test' or 'sandbox-test'. Then binman can have a conversion function to figure out the GUID to pass to the tool, e.g. in efi_capsule.py:
TYPE_TO_GUID = { 'binman-test': '09123987987f98712', 'sandbox-test':, '98123987123123987123987', }
def get_guid(type_str): 'Get the GUID to use for a particular purpose""" return TYPE_TO_GUID.get(type_str, type_str)
Then you can use these same strings in the sandbox tests, without needing to include anything.
While we can use this method for both sandbox and binman tests, I would prefer using the actual GUID strings for the sandbox tests. This will serve as an illustrative example to the user for how to pass the image GUID value for generating the capsule. For the binman tests, I can use this logic to avoid including the header file.
So long as it is easy, that's OK. But how does the user know which GUID to use?
I think you got me wrong here. What I meant was that passing the GUID value in the capsule entry like how it is currently done in the u-boot.dtsi file would give the user an idea of how to specify the GUID value for an image. If we use the string that you suggest above for both binman tests as well as sandbox, the user might get confused as to how the GUID value is to be passed in the normal scenario. I want the sandbox capsule entries to also be kind of illustrative of how a capsule entry would look like.
OK I see.
Of course, I would like to see a decoder ring for GUIDs somewhere. Perhaps Binman is a good place for that, or a file it can read?
I'd suggest we start with your above solution for the binman tests. If we get consensus amongst the folks who work on EFI to have such a GUID decoder file, it can be worked upon later. I think these are things which are part of a larger point that you have about specifying GUIDs in a particular way, and that should be tackled separately, and not through this series, especially at this stage in the series. My 2 cents.
That sounds OK to me. When we get to it, I think we should create a database of GUIDs, with a name for each, and perhaps an ID number, so we can allocate them.
Regards, Simon

hi Simon,
On Sat, 5 Aug 2023 at 20:34, Simon Glass sjg@chromium.org wrote:
Hi Sughosh,
On Sat, 5 Aug 2023 at 05:35, Sughosh Ganu sughosh.ganu@linaro.org wrote:
Add support in binman for generating EFI capsules. The capsule parameters can be specified through the capsule binman entry. Also add test cases in binman for testing capsule generation.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
Changes since V6:
- Add macros for the GUID strings in sandbox_efi_capsule.h
- Highlight that the private and public keys are mandatory for capsule signing.
- Add a URL link to the UEFI spec, as used in the rst files.
- Use local vars for private and public keys in BuildSectionData()
- Use local vars for input payload and capsule filenames in BuildSectionData().
- Drop the ProcessContents() and SetImagePos() as the superclass functions suffice.
- Use GUID macro names in the capsule test dts files.
- Rename efi_capsule_payload.bin to capsule_input.bin.
include/sandbox_efi_capsule.h | 14 ++
Please move this file to a later patch - see below.
The idea was to also be able to run the binman capsule tests once this patch was applied. If we are to move this to a separate patch, it should be the one before this patch. But I guess based on your other reply, this might not be needed after all.
Could we have a single header file with all the GUIDs, i.e. sandbox, ARM, etc.
Umm, I am not too sure. Maybe we can take a call at a later point if there are too many files that start cropping up.
tools/binman/entries.rst | 62 ++++++++ tools/binman/etype/efi_capsule.py | 143 ++++++++++++++++++ tools/binman/ftest.py | 121 +++++++++++++++ tools/binman/test/307_capsule.dts | 23 +++ tools/binman/test/308_capsule_signed.dts | 25 +++ tools/binman/test/309_capsule_version.dts | 24 +++ tools/binman/test/310_capsule_signed_ver.dts | 26 ++++ tools/binman/test/311_capsule_oemflags.dts | 24 +++ tools/binman/test/312_capsule_missing_key.dts | 24 +++ .../binman/test/313_capsule_missing_index.dts | 22 +++ .../binman/test/314_capsule_missing_guid.dts | 19 +++ .../test/315_capsule_missing_payload.dts | 19 +++ 13 files changed, 546 insertions(+) create mode 100644 include/sandbox_efi_capsule.h create mode 100644 tools/binman/etype/efi_capsule.py create mode 100644 tools/binman/test/307_capsule.dts create mode 100644 tools/binman/test/308_capsule_signed.dts create mode 100644 tools/binman/test/309_capsule_version.dts create mode 100644 tools/binman/test/310_capsule_signed_ver.dts create mode 100644 tools/binman/test/311_capsule_oemflags.dts create mode 100644 tools/binman/test/312_capsule_missing_key.dts create mode 100644 tools/binman/test/313_capsule_missing_index.dts create mode 100644 tools/binman/test/314_capsule_missing_guid.dts create mode 100644 tools/binman/test/315_capsule_missing_payload.dts
diff --git a/include/sandbox_efi_capsule.h b/include/sandbox_efi_capsule.h new file mode 100644 index 0000000000..da71b87a18 --- /dev/null +++ b/include/sandbox_efi_capsule.h @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: GPL-2.0+ +/*
- Copyright (c) 2023, Linaro Limited
- */
+#if !defined(_SANDBOX_EFI_CAPSULE_H_) +#define _SANDBOX_EFI_CAPSULE_H_
+#define SANDBOX_UBOOT_IMAGE_GUID "09d7cf52-0720-4710-91d1-08469b7fe9c8" +#define SANDBOX_UBOOT_ENV_IMAGE_GUID "5a7021f5-fef2-48b4-aaba-832e777418c0" +#define SANDBOX_FIT_IMAGE_GUID "3673b45d-6a7c-46f3-9e60-adabb03f7937" +#define SANDBOX_INCORRECT_GUID "058b7d83-50d5-4c47-a195-60d86ad341c4"
These should not be needed in binman tests.
+#endif /* _SANDBOX_EFI_CAPSULE_H_ */ diff --git a/tools/binman/entries.rst b/tools/binman/entries.rst index f2376932be..fc094b9c08 100644 --- a/tools/binman/entries.rst +++ b/tools/binman/entries.rst @@ -468,6 +468,68 @@ updating the EC on startup via software sync.
+.. _etype_efi_capsule:
+Entry: capsule: Entry for generating EFI Capsule files +------------------------------------------------------
+The parameters needed for generation of the capsules can +be provided as properties in the entry.
+Properties / Entry arguments:
- image-index: Unique number for identifying corresponding
payload image. Number between 1 and descriptor count, i.e.
the total number of firmware images that can be updated.
- image-type-id: Image GUID which will be used for identifying the
updatable image on the board.
- hardware-instance: Optional number for identifying unique
hardware instance of a device in the system. Default value of 0
for images where value is not to be used.
- fw-version: Optional value of image version that can be put on
the capsule through the Firmware Management Protocol(FMP) header.
- monotonic-count: Count used when signing an image.
- private-key: Path to PEM formatted .key private key file. This property
is mandatory for generating signed capsules.
- public-key-cert: Path to PEM formatted .crt public key certificate
file. This property is mandatory for generating signed capsules.
- oem-flags - Optional OEM flags to be passed through capsule header.
- Since this is a subclass of Entry_section, all properties of the parent
- class also apply here.
+For more details on the description of the capsule format, and the capsule +update functionality, refer Section 8.5 and Chapter 23 in the `UEFI +specification`_.
+The capsule parameters like image index and image GUID are passed as +properties in the entry. The payload to be used in the capsule is to be +provided as a subnode of the capsule entry.
+A typical capsule entry node would then look something like this::
- capsule {
type = "efi-capsule";
image-index = <0x1>;
/* Image GUID for testing capsule update */
image-type-id = SANDBOX_UBOOT_IMAGE_GUID;
hardware-instance = <0x0>;
private-key = "path/to/the/private/key";
public-key-cert = "path/to/the/public-key-cert";
oem-flags = <0x8000>;
u-boot {
};
- };
+In the above example, the capsule payload is the U-Boot image. The +capsule entry would read the contents of the payload and put them +into the capsule. Any external file can also be specified as the +payload using the blob-ext subnode.
+.. _`UEFI specification`: https://uefi.org/sites/default/files/resources/UEFI_Spec_2_10_Aug29.pdf
.. _etype_encrypted:
Entry: encrypted: Externally built encrypted binary blob diff --git a/tools/binman/etype/efi_capsule.py b/tools/binman/etype/efi_capsule.py new file mode 100644 index 0000000000..bfdca94e26 --- /dev/null +++ b/tools/binman/etype/efi_capsule.py @@ -0,0 +1,143 @@ +# SPDX-License-Identifier: GPL-2.0+ +# Copyright (c) 2023 Linaro Limited +# +# Entry-type module for producing a EFI capsule +#
+import os
+from binman.entry import Entry +from binman.etype.section import Entry_section +from dtoc import fdt_util +from u_boot_pylib import tools
+class Entry_efi_capsule(Entry_section):
- """Generate EFI capsules
- The parameters needed for generation of the capsules can
- be provided as properties in the entry.
- Properties / Entry arguments:
- image-index: Unique number for identifying corresponding
payload image. Number between 1 and descriptor count, i.e.
the total number of firmware images that can be updated.
- image-type-id: Image GUID which will be used for identifying the
updatable image on the board.
- hardware-instance: Optional number for identifying unique
hardware instance of a device in the system. Default value of 0
for images where value is not to be used.
- fw-version: Optional value of image version that can be put on
the capsule through the Firmware Management Protocol(FMP) header.
- monotonic-count: Count used when signing an image.
- private-key: Path to PEM formatted .key private key file. This property
is mandatory for generating signed capsules.
- public-key-cert: Path to PEM formatted .crt public key certificate
file. This property is mandatory for generating signed capsules.
- oem-flags - Optional OEM flags to be passed through capsule header.
- Since this is a subclass of Entry_section, all properties of the parent
- class also apply here.
- For more details on the description of the capsule format, and the capsule
- update functionality, refer Section 8.5 and Chapter 23 in the `UEFI
- specification`_.
- The capsule parameters like image index and image GUID are passed as
- properties in the entry. The payload to be used in the capsule is to be
- provided as a subnode of the capsule entry.
- A typical capsule entry node would then look something like this
- capsule {
type = "efi-capsule";
image-index = <0x1>;
/* Image GUID for testing capsule update */
image-type-id = SANDBOX_UBOOT_IMAGE_GUID;
hardware-instance = <0x0>;
private-key = "path/to/the/private/key";
public-key-cert = "path/to/the/public-key-cert";
oem-flags = <0x8000>;
u-boot {
};
- };
- In the above example, the capsule payload is the U-Boot image. The
- capsule entry would read the contents of the payload and put them
- into the capsule. Any external file can also be specified as the
- payload using the blob-ext subnode.
- .. _`UEFI specification`: https://uefi.org/sites/default/files/resources/UEFI_Spec_2_10_Aug29.pdf
- """
- def __init__(self, section, etype, node):
super().__init__(section, etype, node)
self.required_props = ['image-index', 'image-type-id']
self.image_index = 0
self.image_guid = ''
self.hardware_instance = 0
self.monotonic_count = 0
self.fw_version = 0
self.oem_flags = 0
self.private_key = ''
self.public_key_cert = ''
self.auth = 0
- def ReadNode(self):
self.ReadEntries()
super().ReadNode()
I believe those two lines should be swapped.
Again, like my earlier code for ProcessContents() and SetImagePos(), which was taken from mkimage.py as reference, this code is on similar lines to what is in intel_ifwi.py. Both these files are authored by you, so I took this as reference, especially mkimage.py.
self.image_index = fdt_util.GetInt(self._node, 'image-index')
self.image_guid = fdt_util.GetString(self._node, 'image-type-id')
self.fw_version = fdt_util.GetInt(self._node, 'fw-version')
self.hardware_instance = fdt_util.GetInt(self._node, 'hardware-instance')
self.monotonic_count = fdt_util.GetInt(self._node, 'monotonic-count')
self.oem_flags = fdt_util.GetInt(self._node, 'oem-flags')
self.private_key = fdt_util.GetString(self._node, 'private-key')
self.public_key_cert = fdt_util.GetString(self._node, 'public-key-cert')
if ((self.private_key and not self.public_key_cert) or (self.public_key_cert and not self.private_key)):
self.Raise('Both private key and public key certificate need to be provided')
elif not (self.private_key and self.public_key_cert):
self.auth = 0
else:
self.auth = 1
- def ReadEntries(self):
"""Read the subnode to get the payload for this capsule"""
# We can have a single payload per capsule
if len(self._node.subnodes) == 0:
self.Raise('The capsule entry expects at least one subnode for payload')
Still need to drop this
? Should we not check if the input payload is missing? We cannot call the mkeficapsule tool without an input image(binary).
for node in self._node.subnodes:
entry = Entry.Create(self, node)
entry.ReadNode()
self._entries[entry.name] = entry
I think you can drop this method, since it should be the same as entry_Sectoin ?
Will check, but again, referenced from mkimage.py.
- def BuildSectionData(self, required):
private_key = ''
public_key_cert = ''
if self.auth:
if not os.path.isabs(self.private_key):
private_key = tools.get_input_filename(self.private_key)
if not os.path.isabs(self.public_key_cert):
public_key_cert = tools.get_input_filename(self.public_key_cert)
data, payload, _ = self.collect_contents_to_file(
s/_/uniq/ since you need this below
self._entries.values(), 'capsule_payload')
'capsule_in' is better as it is an input to this entry type
outfile = self._filename if self._filename else self._node.name
You need a unique filename so cannot use self._node.name since it is not guaranteed to be unique.
See how mkimage does this, using uniq
Okay
capsule_fname = tools.get_output_filename(outfile)
ret = self.mkeficapsule.generate_capsule(self.image_index,
self.image_guid,
self.hardware_instance,
payload,
capsule_fname,
private_key,
public_key_cert,
self.monotonic_count,
self.fw_version,
self.oem_flags)
if ret is not None:
os.remove(payload)
return tools.read_file(capsule_fname)
- def AddBintools(self, btools):
self.mkeficapsule = self.AddBintool(btools, 'mkeficapsule')
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index 36428ec343..9bda0157f7 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -48,6 +48,7 @@ U_BOOT_VPL_DATA = b'vpl76543210fedcbazywxyz_' BLOB_DATA = b'89' ME_DATA = b'0abcd' VGA_DATA = b'vga' +EFI_CAPSULE_DATA = b'efi' U_BOOT_DTB_DATA = b'udtb' U_BOOT_SPL_DTB_DATA = b'spldtb' U_BOOT_TPL_DTB_DATA = b'tpldtb' @@ -119,6 +120,11 @@ COMP_BINTOOLS = ['bzip2', 'gzip', 'lz4', 'lzma_alone', 'lzop', 'xz', 'zstd']
TEE_ADDR = 0x5678
+# Firmware Management Protocol(FMP) GUID +FW_MGMT_GUID = 'edd5cb6d2de8444cbda17194199ad92a' +# Image GUID specified in the DTS +CAPSULE_IMAGE_GUID = '52cfd7092007104791d108469b7fe9c8'
class TestFunctional(unittest.TestCase): """Functional tests for binman
@@ -215,6 +221,7 @@ class TestFunctional(unittest.TestCase): TestFunctional._MakeInputFile('scp.bin', SCP_DATA) TestFunctional._MakeInputFile('rockchip-tpl.bin', ROCKCHIP_TPL_DATA) TestFunctional._MakeInputFile('ti_unsecure.bin', TI_UNSECURE_DATA)
TestFunctional._MakeInputFile('capsule_input.bin', EFI_CAPSULE_DATA) # Add a few .dtb files for testing TestFunctional._MakeInputFile('%s/test-fdt1.dtb' % TEST_FDT_SUBDIR,
@@ -7139,5 +7146,119 @@ fdt fdtmap Extract the devicetree blob from the fdtmap self.assertEqual(fdt_util.GetString(key_node, "key-name-hint"), "key")
- def _CheckCapsule(self, data, signed_capsule=False, version_check=False,
capoemflags=False):
fmp_signature = "4d535331" # 'M', 'S', 'S', '1'
fmp_size = "10"
fmp_fw_version = "02"
oemflag = "0080"
payload_data = EFI_CAPSULE_DATA
# Firmware Management Protocol(FMP) GUID - offset(0 - 32)
self.assertEqual(FW_MGMT_GUID, data.hex()[:32])
# Image GUID - offset(96 - 128)
self.assertEqual(CAPSULE_IMAGE_GUID, data.hex()[96:128])
As discussed please add a TODO here, so it is clear that you are planning to write a decoder tool like dump_image.
Okay
-sughosh
if capoemflags:
# OEM Flags - offset(40 - 44)
self.assertEqual(oemflag, data.hex()[40:44])
if signed_capsule and version_check:
# FMP header signature - offset(4770 - 4778)
self.assertEqual(fmp_signature, data.hex()[4770:4778])
# FMP header size - offset(4778 - 4780)
self.assertEqual(fmp_size, data.hex()[4778:4780])
# firmware version - offset(4786 - 4788)
self.assertEqual(fmp_fw_version, data.hex()[4786:4788])
# payload offset signed capsule(4802 - 4808)
self.assertEqual(payload_data.hex(), data.hex()[4802:4808])
elif signed_capsule:
# payload offset signed capsule(4770 - 4776)
self.assertEqual(payload_data.hex(), data.hex()[4770:4776])
elif version_check:
# FMP header signature - offset(184 - 192)
self.assertEqual(fmp_signature, data.hex()[184:192])
# FMP header size - offset(192 - 194)
self.assertEqual(fmp_size, data.hex()[192:194])
# firmware version - offset(200 - 202)
self.assertEqual(fmp_fw_version, data.hex()[200:202])
# payload offset for non-signed capsule with version header(216 - 222)
self.assertEqual(payload_data.hex(), data.hex()[216:222])
else:
# payload offset for non-signed capsule with no version header(184 - 190)
self.assertEqual(payload_data.hex(), data.hex()[184:190])
- def testCapsuleGen(self):
"""Test generation of EFI capsule"""
data = self._DoReadFile('307_capsule.dts')
self._CheckCapsule(data)
- def testSignedCapsuleGen(self):
"""Test generation of EFI capsule"""
data = tools.read_file(self.TestFile("key.key"))
self._MakeInputFile("key.key", data)
data = tools.read_file(self.TestFile("key.pem"))
self._MakeInputFile("key.crt", data)
data = self._DoReadFile('308_capsule_signed.dts')
self._CheckCapsule(data, signed_capsule=True)
- def testCapsuleGenVersionSupport(self):
"""Test generation of EFI capsule with version support"""
data = self._DoReadFile('309_capsule_version.dts')
self._CheckCapsule(data, version_check=True)
- def testCapsuleGenSignedVer(self):
"""Test generation of signed EFI capsule with version information"""
data = tools.read_file(self.TestFile("key.key"))
self._MakeInputFile("key.key", data)
data = tools.read_file(self.TestFile("key.pem"))
self._MakeInputFile("key.crt", data)
data = self._DoReadFile('310_capsule_signed_ver.dts')
self._CheckCapsule(data, signed_capsule=True, version_check=True)
- def testCapsuleGenCapOemFlags(self):
"""Test generation of EFI capsule with OEM Flags set"""
data = self._DoReadFile('311_capsule_oemflags.dts')
self._CheckCapsule(data, capoemflags=True)
- def testCapsuleGenKeyMissing(self):
"""Test that binman errors out on missing key"""
with self.assertRaises(ValueError) as e:
self._DoReadFile('312_capsule_missing_key.dts')
self.assertIn("Both private key and public key certificate need to be provided",
str(e.exception))
- def testCapsuleGenIndexMissing(self):
"""Test that binman errors out on missing image index"""
with self.assertRaises(ValueError) as e:
self._DoReadFile('313_capsule_missing_index.dts')
self.assertIn("entry is missing properties: image-index",
str(e.exception))
- def testCapsuleGenGuidMissing(self):
"""Test that binman errors out on missing image GUID"""
with self.assertRaises(ValueError) as e:
self._DoReadFile('314_capsule_missing_guid.dts')
self.assertIn("entry is missing properties: image-type-id",
str(e.exception))
- def testCapsuleGenPayloadMissing(self):
"""Test that binman errors out on missing input(payload)image"""
with self.assertRaises(ValueError) as e:
self._DoReadFile('315_capsule_missing_payload.dts')
self.assertIn("The capsule entry expects at least one subnode for payload",
str(e.exception))
if __name__ == "__main__": unittest.main() diff --git a/tools/binman/test/307_capsule.dts b/tools/binman/test/307_capsule.dts new file mode 100644 index 0000000000..86552ff83f --- /dev/null +++ b/tools/binman/test/307_capsule.dts @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: GPL-2.0+
+/dts-v1/;
+#include <sandbox_efi_capsule.h>
We can't include sandbox files in binman! I Does it actually matter what the GUID value is? Can they all be the same? For now I think it is best to have
#define BINMAN_TEST_GUID "xxx"
repeated at the top of each .dts file. Hopefully at some point we can figure out a sensible way to provide a decoder ring for this mess, so we can use actually names in the binman definition instead of GUIDs.
+/ {
#address-cells = <1>;
#size-cells = <1>;
binman {
efi-capsule {
image-index = <0x1>;
/* Image GUID for testing capsule update */
image-type-id = SANDBOX_UBOOT_IMAGE_GUID;
hardware-instance = <0x0>;
blob {
filename = "capsule_input.bin";
};
};
};
+};
Regards, Simon

Hi Sughosh,
On Sat, 5 Aug 2023 at 12:42, Sughosh Ganu sughosh.ganu@linaro.org wrote:
hi Simon,
On Sat, 5 Aug 2023 at 20:34, Simon Glass sjg@chromium.org wrote:
Hi Sughosh,
On Sat, 5 Aug 2023 at 05:35, Sughosh Ganu sughosh.ganu@linaro.org wrote:
Add support in binman for generating EFI capsules. The capsule parameters can be specified through the capsule binman entry. Also add test cases in binman for testing capsule generation.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
Changes since V6:
- Add macros for the GUID strings in sandbox_efi_capsule.h
- Highlight that the private and public keys are mandatory for capsule signing.
- Add a URL link to the UEFI spec, as used in the rst files.
- Use local vars for private and public keys in BuildSectionData()
- Use local vars for input payload and capsule filenames in BuildSectionData().
- Drop the ProcessContents() and SetImagePos() as the superclass functions suffice.
- Use GUID macro names in the capsule test dts files.
- Rename efi_capsule_payload.bin to capsule_input.bin.
include/sandbox_efi_capsule.h | 14 ++
Please move this file to a later patch - see below.
The idea was to also be able to run the binman capsule tests once this patch was applied. If we are to move this to a separate patch, it should be the one before this patch. But I guess based on your other reply, this might not be needed after all.
Yes, it should not be needed if we name the test GUIDs. Remember that binman is a standalone tool so cannot reference files outside tools/...although there is no test for that so some things may have crept in.
Could we have a single header file with all the GUIDs, i.e. sandbox, ARM, etc.
Umm, I am not too sure. Maybe we can take a call at a later point if there are too many files that start cropping up.
OK
tools/binman/entries.rst | 62 ++++++++ tools/binman/etype/efi_capsule.py | 143 ++++++++++++++++++ tools/binman/ftest.py | 121 +++++++++++++++ tools/binman/test/307_capsule.dts | 23 +++ tools/binman/test/308_capsule_signed.dts | 25 +++ tools/binman/test/309_capsule_version.dts | 24 +++ tools/binman/test/310_capsule_signed_ver.dts | 26 ++++ tools/binman/test/311_capsule_oemflags.dts | 24 +++ tools/binman/test/312_capsule_missing_key.dts | 24 +++ .../binman/test/313_capsule_missing_index.dts | 22 +++ .../binman/test/314_capsule_missing_guid.dts | 19 +++ .../test/315_capsule_missing_payload.dts | 19 +++ 13 files changed, 546 insertions(+) create mode 100644 include/sandbox_efi_capsule.h create mode 100644 tools/binman/etype/efi_capsule.py create mode 100644 tools/binman/test/307_capsule.dts create mode 100644 tools/binman/test/308_capsule_signed.dts create mode 100644 tools/binman/test/309_capsule_version.dts create mode 100644 tools/binman/test/310_capsule_signed_ver.dts create mode 100644 tools/binman/test/311_capsule_oemflags.dts create mode 100644 tools/binman/test/312_capsule_missing_key.dts create mode 100644 tools/binman/test/313_capsule_missing_index.dts create mode 100644 tools/binman/test/314_capsule_missing_guid.dts create mode 100644 tools/binman/test/315_capsule_missing_payload.dts
[..]
- def ReadNode(self):
self.ReadEntries()
super().ReadNode()
I believe those two lines should be swapped.
Again, like my earlier code for ProcessContents() and SetImagePos(), which was taken from mkimage.py as reference, this code is on similar lines to what is in intel_ifwi.py. Both these files are authored by you, so I took this as reference, especially mkimage.py.
OK, then take a look at mkimage.py and follow that. Yes intel_ifwi is around the wrong way. Although these days ReadEntries() is called automatically from entry_Section so you don't need to call it here.
self.image_index = fdt_util.GetInt(self._node, 'image-index')
self.image_guid = fdt_util.GetString(self._node, 'image-type-id')
self.fw_version = fdt_util.GetInt(self._node, 'fw-version')
self.hardware_instance = fdt_util.GetInt(self._node, 'hardware-instance')
self.monotonic_count = fdt_util.GetInt(self._node, 'monotonic-count')
self.oem_flags = fdt_util.GetInt(self._node, 'oem-flags')
self.private_key = fdt_util.GetString(self._node, 'private-key')
self.public_key_cert = fdt_util.GetString(self._node, 'public-key-cert')
if ((self.private_key and not self.public_key_cert) or (self.public_key_cert and not self.private_key)):
self.Raise('Both private key and public key certificate need to be provided')
elif not (self.private_key and self.public_key_cert):
self.auth = 0
else:
self.auth = 1
- def ReadEntries(self):
"""Read the subnode to get the payload for this capsule"""
# We can have a single payload per capsule
if len(self._node.subnodes) == 0:
self.Raise('The capsule entry expects at least one subnode for payload')
Still need to drop this
? Should we not check if the input payload is missing? We cannot call the mkeficapsule tool without an input image(binary).
Why not?
for node in self._node.subnodes:
entry = Entry.Create(self, node)
entry.ReadNode()
self._entries[entry.name] = entry
I think you can drop this method, since it should be the same as entry_Sectoin ?
Will check, but again, referenced from mkimage.py.
That one is special since it has to deal with a special 'imagename' node.
Regards, Simon

hi Simon,
On Sun, 6 Aug 2023 at 00:35, Simon Glass sjg@chromium.org wrote:
Hi Sughosh,
On Sat, 5 Aug 2023 at 12:42, Sughosh Ganu sughosh.ganu@linaro.org wrote:
hi Simon,
On Sat, 5 Aug 2023 at 20:34, Simon Glass sjg@chromium.org wrote:
Hi Sughosh,
On Sat, 5 Aug 2023 at 05:35, Sughosh Ganu sughosh.ganu@linaro.org wrote:
Add support in binman for generating EFI capsules. The capsule parameters can be specified through the capsule binman entry. Also add test cases in binman for testing capsule generation.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
Changes since V6:
- Add macros for the GUID strings in sandbox_efi_capsule.h
- Highlight that the private and public keys are mandatory for capsule signing.
- Add a URL link to the UEFI spec, as used in the rst files.
- Use local vars for private and public keys in BuildSectionData()
- Use local vars for input payload and capsule filenames in BuildSectionData().
- Drop the ProcessContents() and SetImagePos() as the superclass functions suffice.
- Use GUID macro names in the capsule test dts files.
- Rename efi_capsule_payload.bin to capsule_input.bin.
include/sandbox_efi_capsule.h | 14 ++
Please move this file to a later patch - see below.
The idea was to also be able to run the binman capsule tests once this patch was applied. If we are to move this to a separate patch, it should be the one before this patch. But I guess based on your other reply, this might not be needed after all.
Yes, it should not be needed if we name the test GUIDs. Remember that binman is a standalone tool so cannot reference files outside tools/...although there is no test for that so some things may have crept in.
Could we have a single header file with all the GUIDs, i.e. sandbox, ARM, etc.
Umm, I am not too sure. Maybe we can take a call at a later point if there are too many files that start cropping up.
OK
tools/binman/entries.rst | 62 ++++++++ tools/binman/etype/efi_capsule.py | 143 ++++++++++++++++++ tools/binman/ftest.py | 121 +++++++++++++++ tools/binman/test/307_capsule.dts | 23 +++ tools/binman/test/308_capsule_signed.dts | 25 +++ tools/binman/test/309_capsule_version.dts | 24 +++ tools/binman/test/310_capsule_signed_ver.dts | 26 ++++ tools/binman/test/311_capsule_oemflags.dts | 24 +++ tools/binman/test/312_capsule_missing_key.dts | 24 +++ .../binman/test/313_capsule_missing_index.dts | 22 +++ .../binman/test/314_capsule_missing_guid.dts | 19 +++ .../test/315_capsule_missing_payload.dts | 19 +++ 13 files changed, 546 insertions(+) create mode 100644 include/sandbox_efi_capsule.h create mode 100644 tools/binman/etype/efi_capsule.py create mode 100644 tools/binman/test/307_capsule.dts create mode 100644 tools/binman/test/308_capsule_signed.dts create mode 100644 tools/binman/test/309_capsule_version.dts create mode 100644 tools/binman/test/310_capsule_signed_ver.dts create mode 100644 tools/binman/test/311_capsule_oemflags.dts create mode 100644 tools/binman/test/312_capsule_missing_key.dts create mode 100644 tools/binman/test/313_capsule_missing_index.dts create mode 100644 tools/binman/test/314_capsule_missing_guid.dts create mode 100644 tools/binman/test/315_capsule_missing_payload.dts
[..]
- def ReadNode(self):
self.ReadEntries()
super().ReadNode()
I believe those two lines should be swapped.
Again, like my earlier code for ProcessContents() and SetImagePos(), which was taken from mkimage.py as reference, this code is on similar lines to what is in intel_ifwi.py. Both these files are authored by you, so I took this as reference, especially mkimage.py.
OK, then take a look at mkimage.py and follow that. Yes intel_ifwi is around the wrong way. Although these days ReadEntries() is called automatically from entry_Section so you don't need to call it here.
self.image_index = fdt_util.GetInt(self._node, 'image-index')
self.image_guid = fdt_util.GetString(self._node, 'image-type-id')
self.fw_version = fdt_util.GetInt(self._node, 'fw-version')
self.hardware_instance = fdt_util.GetInt(self._node, 'hardware-instance')
self.monotonic_count = fdt_util.GetInt(self._node, 'monotonic-count')
self.oem_flags = fdt_util.GetInt(self._node, 'oem-flags')
self.private_key = fdt_util.GetString(self._node, 'private-key')
self.public_key_cert = fdt_util.GetString(self._node, 'public-key-cert')
if ((self.private_key and not self.public_key_cert) or (self.public_key_cert and not self.private_key)):
self.Raise('Both private key and public key certificate need to be provided')
elif not (self.private_key and self.public_key_cert):
self.auth = 0
else:
self.auth = 1
- def ReadEntries(self):
"""Read the subnode to get the payload for this capsule"""
# We can have a single payload per capsule
if len(self._node.subnodes) == 0:
self.Raise('The capsule entry expects at least one subnode for payload')
Still need to drop this
? Should we not check if the input payload is missing? We cannot call the mkeficapsule tool without an input image(binary).
Why not?
The mkeficapsule tool expects a input binary(image blob as it calls it) for generation of a normal capsule. Not passing the input image and the capsule filename to the tool results in the help being printed. For e.g. the below command is not passing one filename.
$ ./tools/mkeficapsule -i 0x1 -g 09d7cf52-0720-4710-91d1-08469b7fe9c8 foo.capsule Usage: mkeficapsule [options] <image blob> <output file> Options: -g, --guid <guid string> guid for image blob type -i, --index <index> update image index -I, --instance <instance> update hardware instance -v, --fw-version <version> firmware version -p, --private-key <privkey file> private key file -c, --certificate <cert file> signer's certificate file -m, --monotonic-count <count> monotonic count -d, --dump_sig dump signature (*.p7) -A, --fw-accept firmware accept capsule, requires GUID, no image blob -R, --fw-revert firmware revert capsule, takes no GUID, no image blob -o, --capoemflag Capsule OEM Flag, an integer between 0x0000 and 0xffff -h, --help print a help message
So we need an input binary for a normal capsule.
-sughosh
for node in self._node.subnodes:
entry = Entry.Create(self, node)
entry.ReadNode()
self._entries[entry.name] = entry
I think you can drop this method, since it should be the same as entry_Sectoin ?
Will check, but again, referenced from mkimage.py.
That one is special since it has to deal with a special 'imagename' node.
Regards, Simon

Hi Sughosh,
On Sat, 5 Aug 2023 at 13:35, Sughosh Ganu sughosh.ganu@linaro.org wrote:
hi Simon,
On Sun, 6 Aug 2023 at 00:35, Simon Glass sjg@chromium.org wrote:
Hi Sughosh,
On Sat, 5 Aug 2023 at 12:42, Sughosh Ganu sughosh.ganu@linaro.org wrote:
hi Simon,
On Sat, 5 Aug 2023 at 20:34, Simon Glass sjg@chromium.org wrote:
Hi Sughosh,
On Sat, 5 Aug 2023 at 05:35, Sughosh Ganu sughosh.ganu@linaro.org wrote:
Add support in binman for generating EFI capsules. The capsule parameters can be specified through the capsule binman entry. Also add test cases in binman for testing capsule generation.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
Changes since V6:
- Add macros for the GUID strings in sandbox_efi_capsule.h
- Highlight that the private and public keys are mandatory for capsule signing.
- Add a URL link to the UEFI spec, as used in the rst files.
- Use local vars for private and public keys in BuildSectionData()
- Use local vars for input payload and capsule filenames in BuildSectionData().
- Drop the ProcessContents() and SetImagePos() as the superclass functions suffice.
- Use GUID macro names in the capsule test dts files.
- Rename efi_capsule_payload.bin to capsule_input.bin.
include/sandbox_efi_capsule.h | 14 ++
Please move this file to a later patch - see below.
The idea was to also be able to run the binman capsule tests once this patch was applied. If we are to move this to a separate patch, it should be the one before this patch. But I guess based on your other reply, this might not be needed after all.
Yes, it should not be needed if we name the test GUIDs. Remember that binman is a standalone tool so cannot reference files outside tools/...although there is no test for that so some things may have crept in.
Could we have a single header file with all the GUIDs, i.e. sandbox, ARM, etc.
Umm, I am not too sure. Maybe we can take a call at a later point if there are too many files that start cropping up.
OK
tools/binman/entries.rst | 62 ++++++++ tools/binman/etype/efi_capsule.py | 143 ++++++++++++++++++ tools/binman/ftest.py | 121 +++++++++++++++ tools/binman/test/307_capsule.dts | 23 +++ tools/binman/test/308_capsule_signed.dts | 25 +++ tools/binman/test/309_capsule_version.dts | 24 +++ tools/binman/test/310_capsule_signed_ver.dts | 26 ++++ tools/binman/test/311_capsule_oemflags.dts | 24 +++ tools/binman/test/312_capsule_missing_key.dts | 24 +++ .../binman/test/313_capsule_missing_index.dts | 22 +++ .../binman/test/314_capsule_missing_guid.dts | 19 +++ .../test/315_capsule_missing_payload.dts | 19 +++ 13 files changed, 546 insertions(+) create mode 100644 include/sandbox_efi_capsule.h create mode 100644 tools/binman/etype/efi_capsule.py create mode 100644 tools/binman/test/307_capsule.dts create mode 100644 tools/binman/test/308_capsule_signed.dts create mode 100644 tools/binman/test/309_capsule_version.dts create mode 100644 tools/binman/test/310_capsule_signed_ver.dts create mode 100644 tools/binman/test/311_capsule_oemflags.dts create mode 100644 tools/binman/test/312_capsule_missing_key.dts create mode 100644 tools/binman/test/313_capsule_missing_index.dts create mode 100644 tools/binman/test/314_capsule_missing_guid.dts create mode 100644 tools/binman/test/315_capsule_missing_payload.dts
[..]
- def ReadNode(self):
self.ReadEntries()
super().ReadNode()
I believe those two lines should be swapped.
Again, like my earlier code for ProcessContents() and SetImagePos(), which was taken from mkimage.py as reference, this code is on similar lines to what is in intel_ifwi.py. Both these files are authored by you, so I took this as reference, especially mkimage.py.
OK, then take a look at mkimage.py and follow that. Yes intel_ifwi is around the wrong way. Although these days ReadEntries() is called automatically from entry_Section so you don't need to call it here.
self.image_index = fdt_util.GetInt(self._node, 'image-index')
self.image_guid = fdt_util.GetString(self._node, 'image-type-id')
self.fw_version = fdt_util.GetInt(self._node, 'fw-version')
self.hardware_instance = fdt_util.GetInt(self._node, 'hardware-instance')
self.monotonic_count = fdt_util.GetInt(self._node, 'monotonic-count')
self.oem_flags = fdt_util.GetInt(self._node, 'oem-flags')
self.private_key = fdt_util.GetString(self._node, 'private-key')
self.public_key_cert = fdt_util.GetString(self._node, 'public-key-cert')
if ((self.private_key and not self.public_key_cert) or (self.public_key_cert and not self.private_key)):
self.Raise('Both private key and public key certificate need to be provided')
elif not (self.private_key and self.public_key_cert):
self.auth = 0
else:
self.auth = 1
- def ReadEntries(self):
"""Read the subnode to get the payload for this capsule"""
# We can have a single payload per capsule
if len(self._node.subnodes) == 0:
self.Raise('The capsule entry expects at least one subnode for payload')
Still need to drop this
? Should we not check if the input payload is missing? We cannot call the mkeficapsule tool without an input image(binary).
Why not?
The mkeficapsule tool expects a input binary(image blob as it calls it) for generation of a normal capsule. Not passing the input image and the capsule filename to the tool results in the help being printed. For e.g. the below command is not passing one filename.
$ ./tools/mkeficapsule -i 0x1 -g 09d7cf52-0720-4710-91d1-08469b7fe9c8 foo.capsule Usage: mkeficapsule [options] <image blob> <output file> Options: -g, --guid <guid string> guid for image blob type -i, --index <index> update image index -I, --instance <instance> update hardware instance -v, --fw-version <version> firmware version -p, --private-key <privkey file> private key file -c, --certificate <cert file> signer's certificate file -m, --monotonic-count <count> monotonic count -d, --dump_sig dump signature (*.p7) -A, --fw-accept firmware accept capsule, requires GUID, no image blob -R, --fw-revert firmware revert capsule, takes no GUID, no image blob -o, --capoemflag Capsule OEM Flag, an integer between 0x0000 and 0xffff -h, --help print a help message
So we need an input binary for a normal capsule.
Yes of course I understand that, but it can be empty, I expect. If you don't have any entries, then your etype implementation should use an empty file, as written.
No other etype has this sort of restriction so I don't think we should add it now.
Regards, Simon

The EFI capsule files can now be generated as part of u-boot build through binman. Add capsule entry nodes in the u-boot.dtsi for the sandbox architecture for generating the capsules. These capsules are then used for testing the EFI capsule update functionality on the sandbox platforms. Also add binman nodes for generating the input files used for these capsules.
Remove the corresponding logic which was used for generation of these input files which is now superfluous.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org --- Changes since V6: * Use macros defined in sandbox_efi_capsule for GUIDs and capsule input filenames. * Generate the capsule input files through binman text entries.
arch/sandbox/dts/u-boot.dtsi | 363 ++++++++++++++++++ include/sandbox_efi_capsule.h | 11 + test/py/tests/test_efi_capsule/conftest.py | 168 +------- test/py/tests/test_efi_capsule/signature.dts | 10 - .../tests/test_efi_capsule/uboot_bin_env.its | 36 -- 5 files changed, 385 insertions(+), 203 deletions(-) delete mode 100644 test/py/tests/test_efi_capsule/signature.dts delete mode 100644 test/py/tests/test_efi_capsule/uboot_bin_env.its
diff --git a/arch/sandbox/dts/u-boot.dtsi b/arch/sandbox/dts/u-boot.dtsi index 60bd004937..f1b16b41c2 100644 --- a/arch/sandbox/dts/u-boot.dtsi +++ b/arch/sandbox/dts/u-boot.dtsi @@ -7,11 +7,374 @@ */
#ifdef CONFIG_EFI_HAVE_CAPSULE_SUPPORT + +#include <sandbox_efi_capsule.h> + / { #ifdef CONFIG_EFI_CAPSULE_AUTHENTICATE signature { capsule-key = /incbin/(CONFIG_EFI_CAPSULE_ESL_FILE); }; #endif + + binman: binman { + multiple-images; + }; +}; + +&binman { + input1 { + filename = UBOOT_BIN_IMAGE_OLD; + text { + text = "u-boot:Old"; + }; + }; + + input2 { + filename = UBOOT_BIN_IMAGE_NEW; + text { + text = "u-boot:New"; + }; + }; + + input3 { + filename = UBOOT_ENV_IMAGE_OLD; + text { + text = "u-boot-env:Old"; + }; + }; + + input4 { + filename = UBOOT_ENV_IMAGE_NEW; + text { + text = "u-boot-env:New"; + }; + }; + + itb { + filename = UBOOT_FIT_IMAGE; + + fit { + description = "Automatic U-Boot environment update"; + #address-cells = <2>; + + images { + u-boot-bin { + description = "U-Boot binary on SPI Flash"; + compression = "none"; + type = "firmware"; + arch = "sandbox"; + load = <0>; + blob { + filename = UBOOT_BIN_IMAGE_NEW; + }; + + hash-1 { + algo = "sha1"; + }; + }; + u-boot-env { + description = "U-Boot environment on SPI Flash"; + compression = "none"; + type = "firmware"; + arch = "sandbox"; + load = <0>; + blob { + filename = UBOOT_ENV_IMAGE_NEW; + }; + + hash-1 { + algo = "sha1"; + }; + }; + }; + }; + }; + + capsule1 { + filename = "Test01"; + capsule { + type = "efi-capsule"; + image-index = <0x1>; + image-type-id = SANDBOX_UBOOT_IMAGE_GUID; + + blob { + filename = UBOOT_BIN_IMAGE_NEW; + }; + }; + }; + + capsule2 { + filename = "Test02"; + capsule { + type = "efi-capsule"; + image-index = <0x2>; + image-type-id = SANDBOX_UBOOT_ENV_IMAGE_GUID; + + blob { + filename = UBOOT_ENV_IMAGE_NEW; + }; + }; + }; + + capsule3 { + filename = "Test03"; + capsule { + type = "efi-capsule"; + image-index = <0x1>; + image-type-id = SANDBOX_INCORRECT_GUID; + + blob { + filename = UBOOT_BIN_IMAGE_NEW; + }; + }; + }; + + capsule4 { + filename = "Test04"; + capsule { + type = "efi-capsule"; + image-index = <0x1>; + image-type-id = SANDBOX_FIT_IMAGE_GUID; + + blob { + filename = UBOOT_FIT_IMAGE; + }; + }; + }; + + capsule5 { + filename = "Test05"; + capsule { + type = "efi-capsule"; + image-index = <0x1>; + image-type-id = SANDBOX_INCORRECT_GUID; + + blob { + filename = UBOOT_FIT_IMAGE; + }; + }; + }; + + capsule6 { + filename = "Test101"; + capsule { + type = "efi-capsule"; + image-index = <0x1>; + fw-version = <0x5>; + image-type-id = SANDBOX_UBOOT_IMAGE_GUID; + + blob { + filename = UBOOT_BIN_IMAGE_NEW; + }; + }; + }; + + capsule7 { + filename = "Test102"; + capsule { + type = "efi-capsule"; + image-index = <0x2>; + fw-version = <0xa>; + image-type-id = SANDBOX_UBOOT_ENV_IMAGE_GUID; + + blob { + filename = UBOOT_ENV_IMAGE_NEW; + }; + }; + }; + + capsule8 { + filename = "Test103"; + capsule { + type = "efi-capsule"; + image-index = <0x1>; + fw-version = <0x2>; + image-type-id = SANDBOX_UBOOT_IMAGE_GUID; + + blob { + filename = UBOOT_BIN_IMAGE_NEW; + }; + }; + }; + + capsule9 { + filename = "Test104"; + capsule { + type = "efi-capsule"; + image-index = <0x1>; + fw-version = <0x5>; + image-type-id = SANDBOX_FIT_IMAGE_GUID; + + blob { + filename = UBOOT_FIT_IMAGE; + }; + }; + }; + + capsule10 { + filename = "Test105"; + capsule { + type = "efi-capsule"; + image-index = <0x1>; + fw-version = <0x2>; + image-type-id = SANDBOX_FIT_IMAGE_GUID; + + blob { + filename = UBOOT_FIT_IMAGE; + }; + }; + }; + +#ifdef CONFIG_EFI_CAPSULE_AUTHENTICATE + capsule11 { + filename = "Test11"; + capsule { + type = "efi-capsule"; + image-index = <0x1>; + image-type-id = SANDBOX_UBOOT_IMAGE_GUID; + private-key = CAPSULE_PRIV_KEY; + public-key-cert = CAPSULE_PUB_KEY; + monotonic-count = <0x1>; + + blob { + filename = UBOOT_BIN_IMAGE_NEW; + }; + }; + }; + + capsule12 { + filename = "Test12"; + capsule { + type = "efi-capsule"; + image-index = <0x1>; + image-type-id = SANDBOX_UBOOT_IMAGE_GUID; + private-key = CAPSULE_INVAL_KEY; + public-key-cert = CAPSULE_INVAL_PUB_KEY; + monotonic-count = <0x1>; + + blob { + filename = UBOOT_BIN_IMAGE_NEW; + }; + }; + }; + + capsule13 { + filename = "Test13"; + capsule { + type = "efi-capsule"; + image-index = <0x1>; + image-type-id = SANDBOX_FIT_IMAGE_GUID; + private-key = CAPSULE_PRIV_KEY; + public-key-cert = CAPSULE_PUB_KEY; + monotonic-count = <0x1>; + + blob { + filename = UBOOT_FIT_IMAGE; + }; + }; + }; + + capsule14 { + filename = "Test14"; + capsule { + type = "efi-capsule"; + image-index = <0x1>; + image-type-id = SANDBOX_FIT_IMAGE_GUID; + private-key = CAPSULE_INVAL_KEY; + public-key-cert = CAPSULE_INVAL_PUB_KEY; + monotonic-count = <0x1>; + + blob { + filename = UBOOT_FIT_IMAGE; + }; + }; + }; + + capsule15 { + filename = "Test111"; + capsule { + type = "efi-capsule"; + image-index = <0x1>; + fw-version = <0x5>; + image-type-id = SANDBOX_UBOOT_IMAGE_GUID; + private-key = CAPSULE_PRIV_KEY; + public-key-cert = CAPSULE_PUB_KEY; + monotonic-count = <0x1>; + + blob { + filename = UBOOT_BIN_IMAGE_NEW; + }; + }; + }; + + capsule16 { + filename = "Test112"; + capsule { + type = "efi-capsule"; + image-index = <0x2>; + fw-version = <0xa>; + image-type-id = SANDBOX_UBOOT_ENV_IMAGE_GUID; + private-key = CAPSULE_PRIV_KEY; + public-key-cert = CAPSULE_PUB_KEY; + monotonic-count = <0x1>; + + blob { + filename = UBOOT_ENV_IMAGE_NEW; + }; + }; + }; + + capsule17 { + filename = "Test113"; + capsule { + type = "efi-capsule"; + image-index = <0x1>; + fw-version = <0x2>; + image-type-id = SANDBOX_UBOOT_IMAGE_GUID; + private-key = CAPSULE_PRIV_KEY; + public-key-cert = CAPSULE_PUB_KEY; + monotonic-count = <0x1>; + + blob { + filename = UBOOT_BIN_IMAGE_NEW; + }; + }; + }; + + capsule18 { + filename = "Test114"; + capsule { + type = "efi-capsule"; + image-index = <0x1>; + fw-version = <0x5>; + image-type-id = SANDBOX_FIT_IMAGE_GUID; + private-key = CAPSULE_PRIV_KEY; + public-key-cert = CAPSULE_PUB_KEY; + monotonic-count = <0x1>; + + blob { + filename = UBOOT_FIT_IMAGE; + }; + }; + }; + + capsule19 { + filename = "Test115"; + capsule { + type = "efi-capsule"; + image-index = <0x1>; + fw-version = <0x2>; + image-type-id = SANDBOX_FIT_IMAGE_GUID; + private-key = CAPSULE_PRIV_KEY; + public-key-cert = CAPSULE_PUB_KEY; + monotonic-count = <0x1>; + + blob { + filename = UBOOT_FIT_IMAGE; + }; + }; + }; +#endif /* CONFIG_EFI_CAPSULE_AUTHENTICATE */ }; #endif /* CONFIG_EFI_HAVE_CAPSULE_SUPPORT */ diff --git a/include/sandbox_efi_capsule.h b/include/sandbox_efi_capsule.h index da71b87a18..8e6128de41 100644 --- a/include/sandbox_efi_capsule.h +++ b/include/sandbox_efi_capsule.h @@ -11,4 +11,15 @@ #define SANDBOX_FIT_IMAGE_GUID "3673b45d-6a7c-46f3-9e60-adabb03f7937" #define SANDBOX_INCORRECT_GUID "058b7d83-50d5-4c47-a195-60d86ad341c4"
+#define UBOOT_BIN_IMAGE_NEW "u-boot.bin.new" +#define UBOOT_ENV_IMAGE_NEW "u-boot.env.new" +#define UBOOT_BIN_IMAGE_OLD "u-boot.bin.old" +#define UBOOT_ENV_IMAGE_OLD "u-boot.env.old" +#define UBOOT_FIT_IMAGE "u-boot_bin_env.itb" + +#define CAPSULE_PRIV_KEY "SIGNER.key" +#define CAPSULE_PUB_KEY "SIGNER.crt" +#define CAPSULE_INVAL_KEY "SIGNER2.key" +#define CAPSULE_INVAL_PUB_KEY "SIGNER2.crt" + #endif /* _SANDBOX_EFI_CAPSULE_H_ */ diff --git a/test/py/tests/test_efi_capsule/conftest.py b/test/py/tests/test_efi_capsule/conftest.py index 054be1ee97..d5dc80f5ff 100644 --- a/test/py/tests/test_efi_capsule/conftest.py +++ b/test/py/tests/test_efi_capsule/conftest.py @@ -32,41 +32,22 @@ def efi_capsule_data(request, u_boot_config): check_call('mkdir -p %s' % data_dir, shell=True) check_call('mkdir -p %s' % install_dir, shell=True)
- capsule_auth_enabled = u_boot_config.buildconfig.get( - 'config_efi_capsule_authenticate') - if capsule_auth_enabled: - # Create private key (SIGNER.key) and certificate (SIGNER.crt) - check_call('cd %s; ' - 'openssl req -x509 -sha256 -newkey rsa:2048 ' - '-subj /CN=TEST_SIGNER/ -keyout SIGNER.key ' - '-out SIGNER.crt -nodes -days 365' - % data_dir, shell=True) - check_call('cd %s; %scert-to-efi-sig-list SIGNER.crt SIGNER.esl' - % (data_dir, EFITOOLS_PATH), shell=True) - - # Update dtb adding capsule certificate - check_call('cd %s; ' - 'cp %s/test/py/tests/test_efi_capsule/signature.dts .' - % (data_dir, u_boot_config.source_dir), shell=True) - check_call('cd %s; ' - 'dtc -@ -I dts -O dtb -o signature.dtbo signature.dts; ' - 'fdtoverlay -i %s/arch/sandbox/dts/test.dtb ' - '-o test_sig.dtb signature.dtbo' - % (data_dir, u_boot_config.build_dir), shell=True) - - # Create *malicious* private key (SIGNER2.key) and certificate - # (SIGNER2.crt) - check_call('cd %s; ' - 'openssl req -x509 -sha256 -newkey rsa:2048 ' - '-subj /CN=TEST_SIGNER/ -keyout SIGNER2.key ' - '-out SIGNER2.crt -nodes -days 365' - % data_dir, shell=True) - + check_call('cp %s/u-boot.bin.* %s' + % (u_boot_config.build_dir, data_dir), shell=True) + check_call('cp %s/u-boot.env.* %s' + % (u_boot_config.build_dir, data_dir), shell=True) + check_call('cp %s/u-boot_bin_env.itb %s ' % (u_boot_config.build_dir, data_dir), shell=True) + check_call('cp %s/Test* %s ' % (u_boot_config.build_dir, data_dir), shell=True) # Update dtb to add the version information check_call('cd %s; ' 'cp %s/test/py/tests/test_efi_capsule/version.dts .' % (data_dir, u_boot_config.source_dir), shell=True) + + capsule_auth_enabled = u_boot_config.buildconfig.get( + 'config_efi_capsule_authenticate') if capsule_auth_enabled: + check_call('cp %s/arch/sandbox/dts/test.dtb %s/test_sig.dtb' % + (u_boot_config.build_dir, data_dir), shell=True) check_call('cd %s; ' 'dtc -@ -I dts -O dtb -o version.dtbo version.dts; ' 'fdtoverlay -i test_sig.dtb ' @@ -79,133 +60,6 @@ def efi_capsule_data(request, u_boot_config): '-o test_ver.dtb version.dtbo' % (data_dir, u_boot_config.build_dir), shell=True)
- # Create capsule files - # two regions: one for u-boot.bin and the other for u-boot.env - check_call('cd %s; echo -n u-boot:Old > u-boot.bin.old; echo -n u-boot:New > u-boot.bin.new; echo -n u-boot-env:Old > u-boot.env.old; echo -n u-boot-env:New > u-boot.env.new' % data_dir, - shell=True) - check_call('sed -e "s?BINFILE1?u-boot.bin.new?" -e "s?BINFILE2?u-boot.env.new?" %s/test/py/tests/test_efi_capsule/uboot_bin_env.its > %s/uboot_bin_env.its' % - (u_boot_config.source_dir, data_dir), - shell=True) - check_call('cd %s; %s/tools/mkimage -f uboot_bin_env.its uboot_bin_env.itb' % - (data_dir, u_boot_config.build_dir), - shell=True) - check_call('cd %s; %s/tools/mkeficapsule --index 1 --guid 09D7CF52-0720-4710-91D1-08469B7FE9C8 u-boot.bin.new Test01' % - (data_dir, u_boot_config.build_dir), - shell=True) - check_call('cd %s; %s/tools/mkeficapsule --index 2 --guid 5A7021F5-FEF2-48B4-AABA-832E777418C0 u-boot.env.new Test02' % - (data_dir, u_boot_config.build_dir), - shell=True) - check_call('cd %s; %s/tools/mkeficapsule --index 1 --guid 058B7D83-50D5-4C47-A195-60D86AD341C4 u-boot.bin.new Test03' % - (data_dir, u_boot_config.build_dir), - shell=True) - check_call('cd %s; %s/tools/mkeficapsule --index 1 --guid 3673B45D-6A7C-46F3-9E60-ADABB03F7937 uboot_bin_env.itb Test04' % - (data_dir, u_boot_config.build_dir), - shell=True) - check_call('cd %s; %s/tools/mkeficapsule --index 1 --guid 058B7D83-50D5-4C47-A195-60D86AD341C4 uboot_bin_env.itb Test05' % - (data_dir, u_boot_config.build_dir), - shell=True) - check_call('cd %s; %s/tools/mkeficapsule --index 1 --fw-version 5 ' - '--guid 09D7CF52-0720-4710-91D1-08469B7FE9C8 u-boot.bin.new Test101' % - (data_dir, u_boot_config.build_dir), - shell=True) - check_call('cd %s; %s/tools/mkeficapsule --index 2 --fw-version 10 ' - '--guid 5A7021F5-FEF2-48B4-AABA-832E777418C0 u-boot.env.new Test102' % - (data_dir, u_boot_config.build_dir), - shell=True) - check_call('cd %s; %s/tools/mkeficapsule --index 1 --fw-version 2 ' - '--guid 09D7CF52-0720-4710-91D1-08469B7FE9C8 u-boot.bin.new Test103' % - (data_dir, u_boot_config.build_dir), - shell=True) - check_call('cd %s; %s/tools/mkeficapsule --index 1 --fw-version 5 ' - '--guid 3673B45D-6A7C-46F3-9E60-ADABB03F7937 uboot_bin_env.itb Test104' % - (data_dir, u_boot_config.build_dir), - shell=True) - check_call('cd %s; %s/tools/mkeficapsule --index 1 --fw-version 2 ' - '--guid 3673B45D-6A7C-46F3-9E60-ADABB03F7937 uboot_bin_env.itb Test105' % - (data_dir, u_boot_config.build_dir), - shell=True) - - if capsule_auth_enabled: - # raw firmware signed with proper key - check_call('cd %s; ' - '%s/tools/mkeficapsule --index 1 --monotonic-count 1 ' - '--private-key SIGNER.key --certificate SIGNER.crt ' - '--guid 09D7CF52-0720-4710-91D1-08469B7FE9C8 ' - 'u-boot.bin.new Test11' - % (data_dir, u_boot_config.build_dir), - shell=True) - # raw firmware signed with *mal* key - check_call('cd %s; ' - '%s/tools/mkeficapsule --index 1 --monotonic-count 1 ' - '--private-key SIGNER2.key ' - '--certificate SIGNER2.crt ' - '--guid 09D7CF52-0720-4710-91D1-08469B7FE9C8 ' - 'u-boot.bin.new Test12' - % (data_dir, u_boot_config.build_dir), - shell=True) - # FIT firmware signed with proper key - check_call('cd %s; ' - '%s/tools/mkeficapsule --index 1 --monotonic-count 1 ' - '--private-key SIGNER.key --certificate SIGNER.crt ' - '--guid 3673B45D-6A7C-46F3-9E60-ADABB03F7937 ' - 'uboot_bin_env.itb Test13' - % (data_dir, u_boot_config.build_dir), - shell=True) - # FIT firmware signed with *mal* key - check_call('cd %s; ' - '%s/tools/mkeficapsule --index 1 --monotonic-count 1 ' - '--private-key SIGNER2.key ' - '--certificate SIGNER2.crt ' - '--guid 3673B45D-6A7C-46F3-9E60-ADABB03F7937 ' - 'uboot_bin_env.itb Test14' - % (data_dir, u_boot_config.build_dir), - shell=True) - # raw firmware signed with proper key with version information - check_call('cd %s; ' - '%s/tools/mkeficapsule --index 1 --monotonic-count 1 ' - '--fw-version 5 ' - '--private-key SIGNER.key --certificate SIGNER.crt ' - '--guid 09D7CF52-0720-4710-91D1-08469B7FE9C8 ' - 'u-boot.bin.new Test111' - % (data_dir, u_boot_config.build_dir), - shell=True) - # raw firmware signed with proper key with version information - check_call('cd %s; ' - '%s/tools/mkeficapsule --index 2 --monotonic-count 1 ' - '--fw-version 10 ' - '--private-key SIGNER.key --certificate SIGNER.crt ' - '--guid 5A7021F5-FEF2-48B4-AABA-832E777418C0 ' - 'u-boot.env.new Test112' - % (data_dir, u_boot_config.build_dir), - shell=True) - # raw firmware signed with proper key with lower version information - check_call('cd %s; ' - '%s/tools/mkeficapsule --index 1 --monotonic-count 1 ' - '--fw-version 2 ' - '--private-key SIGNER.key --certificate SIGNER.crt ' - '--guid 09D7CF52-0720-4710-91D1-08469B7FE9C8 ' - 'u-boot.bin.new Test113' - % (data_dir, u_boot_config.build_dir), - shell=True) - # FIT firmware signed with proper key with version information - check_call('cd %s; ' - '%s/tools/mkeficapsule --index 1 --monotonic-count 1 ' - '--fw-version 5 ' - '--private-key SIGNER.key --certificate SIGNER.crt ' - '--guid 3673B45D-6A7C-46F3-9E60-ADABB03F7937 ' - 'uboot_bin_env.itb Test114' - % (data_dir, u_boot_config.build_dir), - shell=True) - # FIT firmware signed with proper key with lower version information - check_call('cd %s; ' - '%s/tools/mkeficapsule --index 1 --monotonic-count 1 ' - '--fw-version 2 ' - '--private-key SIGNER.key --certificate SIGNER.crt ' - '--guid 3673B45D-6A7C-46F3-9E60-ADABB03F7937 ' - 'uboot_bin_env.itb Test115' - % (data_dir, u_boot_config.build_dir), - shell=True) - # Create a disk image with EFI system partition check_call('virt-make-fs --partition=gpt --size=+1M --type=vfat %s %s' % (mnt_point, image_path), shell=True) diff --git a/test/py/tests/test_efi_capsule/signature.dts b/test/py/tests/test_efi_capsule/signature.dts deleted file mode 100644 index 078cfc76c9..0000000000 --- a/test/py/tests/test_efi_capsule/signature.dts +++ /dev/null @@ -1,10 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ - -/dts-v1/; -/plugin/; - -&{/} { - signature { - capsule-key = /incbin/("SIGNER.esl"); - }; -}; diff --git a/test/py/tests/test_efi_capsule/uboot_bin_env.its b/test/py/tests/test_efi_capsule/uboot_bin_env.its deleted file mode 100644 index fc65907481..0000000000 --- a/test/py/tests/test_efi_capsule/uboot_bin_env.its +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Automatic software update for U-Boot - * Make sure the flashing addresses ('load' prop) is correct for your board! - */ - -/dts-v1/; - -/ { - description = "Automatic U-Boot environment update"; - #address-cells = <2>; - - images { - u-boot-bin { - description = "U-Boot binary on SPI Flash"; - data = /incbin/("BINFILE1"); - compression = "none"; - type = "firmware"; - arch = "sandbox"; - load = <0>; - hash-1 { - algo = "sha1"; - }; - }; - u-boot-env { - description = "U-Boot environment on SPI Flash"; - data = /incbin/("BINFILE2"); - compression = "none"; - type = "firmware"; - arch = "sandbox"; - load = <0>; - hash-1 { - algo = "sha1"; - }; - }; - }; -};

Hi Sughosh,
On Sat, 5 Aug 2023 at 05:35, Sughosh Ganu sughosh.ganu@linaro.org wrote:
The EFI capsule files can now be generated as part of u-boot build through binman. Add capsule entry nodes in the u-boot.dtsi for the sandbox architecture for generating the capsules. These capsules are then used for testing the EFI capsule update functionality on the sandbox platforms. Also add binman nodes for generating the input files used for these capsules.
Remove the corresponding logic which was used for generation of these input files which is now superfluous.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
Changes since V6:
- Use macros defined in sandbox_efi_capsule for GUIDs and capsule input filenames.
- Generate the capsule input files through binman text entries.
arch/sandbox/dts/u-boot.dtsi | 363 ++++++++++++++++++ include/sandbox_efi_capsule.h | 11 + test/py/tests/test_efi_capsule/conftest.py | 168 +------- test/py/tests/test_efi_capsule/signature.dts | 10 - .../tests/test_efi_capsule/uboot_bin_env.its | 36 -- 5 files changed, 385 insertions(+), 203 deletions(-) delete mode 100644 test/py/tests/test_efi_capsule/signature.dts delete mode 100644 test/py/tests/test_efi_capsule/uboot_bin_env.its
I think you are still getting confused with using filenames when you don't need to. See below...
diff --git a/arch/sandbox/dts/u-boot.dtsi b/arch/sandbox/dts/u-boot.dtsi index 60bd004937..f1b16b41c2 100644 --- a/arch/sandbox/dts/u-boot.dtsi +++ b/arch/sandbox/dts/u-boot.dtsi @@ -7,11 +7,374 @@ */
#ifdef CONFIG_EFI_HAVE_CAPSULE_SUPPORT
+#include <sandbox_efi_capsule.h>
/ { #ifdef CONFIG_EFI_CAPSULE_AUTHENTICATE signature { capsule-key = /incbin/(CONFIG_EFI_CAPSULE_ESL_FILE); }; #endif
binman: binman {
multiple-images;
};
+};
+&binman {
input1 {
filename = UBOOT_BIN_IMAGE_OLD;
text {
text = "u-boot:Old";
};
};
input2 {
filename = UBOOT_BIN_IMAGE_NEW;
text {
text = "u-boot:New";
};
};
input3 {
filename = UBOOT_ENV_IMAGE_OLD;
text {
text = "u-boot-env:Old";
};
};
input4 {
filename = UBOOT_ENV_IMAGE_NEW;
text {
text = "u-boot-env:New";
};
};
All of those nodes can be removed
itb {
filename = UBOOT_FIT_IMAGE;
fit {
description = "Automatic U-Boot environment update";
#address-cells = <2>;
images {
u-boot-bin {
description = "U-Boot binary on SPI Flash";
compression = "none";
type = "firmware";
arch = "sandbox";
load = <0>;
blob {
filename = UBOOT_BIN_IMAGE_NEW;
};
instead of this blob node, you should be able to write:
text { text = "u-boot:Old"; };
There is no need to provide filenames in every node.
hash-1 {
algo = "sha1";
};
};
u-boot-env {
description = "U-Boot environment on SPI Flash";
compression = "none";
type = "firmware";
arch = "sandbox";
load = <0>;
blob {
filename = UBOOT_ENV_IMAGE_NEW;
};
same here and below
hash-1 {
algo = "sha1";
};
};
};
};
};
capsule1 {
filename = "Test01";
capsule {
type = "efi-capsule";
image-index = <0x1>;
image-type-id = SANDBOX_UBOOT_IMAGE_GUID;
blob {
filename = UBOOT_BIN_IMAGE_NEW;
};
again this should be a text node
same below
};
};
capsule2 {
filename = "Test02";
capsule {
type = "efi-capsule";
image-index = <0x2>;
image-type-id = SANDBOX_UBOOT_ENV_IMAGE_GUID;
blob {
filename = UBOOT_ENV_IMAGE_NEW;
};
};
};
capsule3 {
filename = "Test03";
capsule {
type = "efi-capsule";
image-index = <0x1>;
image-type-id = SANDBOX_INCORRECT_GUID;
blob {
filename = UBOOT_BIN_IMAGE_NEW;
};
};
};
capsule4 {
filename = "Test04";
capsule {
type = "efi-capsule";
image-index = <0x1>;
image-type-id = SANDBOX_FIT_IMAGE_GUID;
blob {
filename =
[..]
capsule19 {
filename = "Test115";
[..]
We really need to talk about these tests. So many cases! Can you not reduce this?
Regards, Simon

hi Simon,
On Sat, 5 Aug 2023 at 20:34, Simon Glass sjg@chromium.org wrote:
Hi Sughosh,
On Sat, 5 Aug 2023 at 05:35, Sughosh Ganu sughosh.ganu@linaro.org wrote:
The EFI capsule files can now be generated as part of u-boot build through binman. Add capsule entry nodes in the u-boot.dtsi for the sandbox architecture for generating the capsules. These capsules are then used for testing the EFI capsule update functionality on the sandbox platforms. Also add binman nodes for generating the input files used for these capsules.
Remove the corresponding logic which was used for generation of these input files which is now superfluous.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
Changes since V6:
- Use macros defined in sandbox_efi_capsule for GUIDs and capsule input filenames.
- Generate the capsule input files through binman text entries.
arch/sandbox/dts/u-boot.dtsi | 363 ++++++++++++++++++ include/sandbox_efi_capsule.h | 11 + test/py/tests/test_efi_capsule/conftest.py | 168 +------- test/py/tests/test_efi_capsule/signature.dts | 10 - .../tests/test_efi_capsule/uboot_bin_env.its | 36 -- 5 files changed, 385 insertions(+), 203 deletions(-) delete mode 100644 test/py/tests/test_efi_capsule/signature.dts delete mode 100644 test/py/tests/test_efi_capsule/uboot_bin_env.its
I think you are still getting confused with using filenames when you don't need to. See below...
No, I don't think so. This is being done on purpose, since I want these files to be created. These are then copied to the efi capsule update tests' data directory, and are then used in testing the feature. Maybe if you want, I can put a comment to that effect.
diff --git a/arch/sandbox/dts/u-boot.dtsi b/arch/sandbox/dts/u-boot.dtsi index 60bd004937..f1b16b41c2 100644 --- a/arch/sandbox/dts/u-boot.dtsi +++ b/arch/sandbox/dts/u-boot.dtsi @@ -7,11 +7,374 @@ */
#ifdef CONFIG_EFI_HAVE_CAPSULE_SUPPORT
+#include <sandbox_efi_capsule.h>
/ { #ifdef CONFIG_EFI_CAPSULE_AUTHENTICATE signature { capsule-key = /incbin/(CONFIG_EFI_CAPSULE_ESL_FILE); }; #endif
binman: binman {
multiple-images;
};
+};
+&binman {
input1 {
filename = UBOOT_BIN_IMAGE_OLD;
text {
text = "u-boot:Old";
};
};
input2 {
filename = UBOOT_BIN_IMAGE_NEW;
text {
text = "u-boot:New";
};
};
input3 {
filename = UBOOT_ENV_IMAGE_OLD;
text {
text = "u-boot-env:Old";
};
};
input4 {
filename = UBOOT_ENV_IMAGE_NEW;
text {
text = "u-boot-env:New";
};
};
All of those nodes can be removed
itb {
filename = UBOOT_FIT_IMAGE;
fit {
description = "Automatic U-Boot environment update";
#address-cells = <2>;
images {
u-boot-bin {
description = "U-Boot binary on SPI Flash";
compression = "none";
type = "firmware";
arch = "sandbox";
load = <0>;
blob {
filename = UBOOT_BIN_IMAGE_NEW;
};
instead of this blob node, you should be able to write:
text { text = "u-boot:Old"; };
There is no need to provide filenames in every node.
I know, please check above.
hash-1 {
algo = "sha1";
};
};
u-boot-env {
description = "U-Boot environment on SPI Flash";
compression = "none";
type = "firmware";
arch = "sandbox";
load = <0>;
blob {
filename = UBOOT_ENV_IMAGE_NEW;
};
same here and below
hash-1 {
algo = "sha1";
};
};
};
};
};
capsule1 {
filename = "Test01";
capsule {
type = "efi-capsule";
image-index = <0x1>;
image-type-id = SANDBOX_UBOOT_IMAGE_GUID;
blob {
filename = UBOOT_BIN_IMAGE_NEW;
};
again this should be a text node
same below
};
};
capsule2 {
filename = "Test02";
capsule {
type = "efi-capsule";
image-index = <0x2>;
image-type-id = SANDBOX_UBOOT_ENV_IMAGE_GUID;
blob {
filename = UBOOT_ENV_IMAGE_NEW;
};
};
};
capsule3 {
filename = "Test03";
capsule {
type = "efi-capsule";
image-index = <0x1>;
image-type-id = SANDBOX_INCORRECT_GUID;
blob {
filename = UBOOT_BIN_IMAGE_NEW;
};
};
};
capsule4 {
filename = "Test04";
capsule {
type = "efi-capsule";
image-index = <0x1>;
image-type-id = SANDBOX_FIT_IMAGE_GUID;
blob {
filename =
[..]
capsule19 {
filename = "Test115";
[..]
We really need to talk about these tests. So many cases! Can you not reduce this?
Unfortunately no. These capsules are all needed for the feature testing. Which is why I was asking yesterday if you wanted these generated for normal builds as well, or only for CI runs.
-sughosh

Hi Sughosh,
On Sat, 5 Aug 2023 at 12:01, Sughosh Ganu sughosh.ganu@linaro.org wrote:
hi Simon,
On Sat, 5 Aug 2023 at 20:34, Simon Glass sjg@chromium.org wrote:
Hi Sughosh,
On Sat, 5 Aug 2023 at 05:35, Sughosh Ganu sughosh.ganu@linaro.org wrote:
The EFI capsule files can now be generated as part of u-boot build through binman. Add capsule entry nodes in the u-boot.dtsi for the sandbox architecture for generating the capsules. These capsules are then used for testing the EFI capsule update functionality on the sandbox platforms. Also add binman nodes for generating the input files used for these capsules.
Remove the corresponding logic which was used for generation of these input files which is now superfluous.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
Changes since V6:
- Use macros defined in sandbox_efi_capsule for GUIDs and capsule input filenames.
- Generate the capsule input files through binman text entries.
arch/sandbox/dts/u-boot.dtsi | 363 ++++++++++++++++++ include/sandbox_efi_capsule.h | 11 + test/py/tests/test_efi_capsule/conftest.py | 168 +------- test/py/tests/test_efi_capsule/signature.dts | 10 - .../tests/test_efi_capsule/uboot_bin_env.its | 36 -- 5 files changed, 385 insertions(+), 203 deletions(-) delete mode 100644 test/py/tests/test_efi_capsule/signature.dts delete mode 100644 test/py/tests/test_efi_capsule/uboot_bin_env.its
I think you are still getting confused with using filenames when you don't need to. See below...
No, I don't think so. This is being done on purpose, since I want these files to be created. These are then copied to the efi capsule update tests' data directory, and are then used in testing the feature. Maybe if you want, I can put a comment to that effect.
I just traced through this code. I really think this needs to be simplified. You can do it in a patch at the end if you like.
But you have the 'u-boot.bin.old' and 'Old' strings in test_efi_capsule_auth2, for example.
In the binman world you define UBOOT_BIN_IMAGE_OLD as "u-boot.bin.old", then use that in the sandbox.dtsi
Then binman creates the u-boot.bin.old file (unnecessarily in my view) Then in efi_capsule_data() you copy the file to the test directory.
So for the last step, you could just create the file again, rather than copying it from the U-Boot build directory. After all, you know the contents. If you like you could put the different contents as binary strings in capsule_defs.py
Then you don't need to create the files.
There is a lot more I can say about the EFI capsule tests. For now I think we'll have to live with it creating 19 different binman images on sandbox. I think we could put them in an efi_capsules subdir, but that would need to be created somewhere, since binman doesn't do it. I suppose we could make binman automatically create a directory if an entry filename needs it?
Anyway, for tests, primarily we need to split things up, so we have, for example:
process_capsule_file()
which processes the capsule in U-Boot, e.g. using an 'efi' command, then outputs what it did. Then the test can plant the capsule, run that function and check that the output is as expected. This can actually be a unit test, i.e. written in C.
Most of the tests can do this. Then we can have one test that checks the whole flow, but it doesn't need to be done for every case, as now.
Regards, Simon

hi Simon,
On Sun, 6 Aug 2023 at 00:06, Simon Glass sjg@chromium.org wrote:
Hi Sughosh,
On Sat, 5 Aug 2023 at 12:01, Sughosh Ganu sughosh.ganu@linaro.org wrote:
hi Simon,
On Sat, 5 Aug 2023 at 20:34, Simon Glass sjg@chromium.org wrote:
Hi Sughosh,
On Sat, 5 Aug 2023 at 05:35, Sughosh Ganu sughosh.ganu@linaro.org wrote:
The EFI capsule files can now be generated as part of u-boot build through binman. Add capsule entry nodes in the u-boot.dtsi for the sandbox architecture for generating the capsules. These capsules are then used for testing the EFI capsule update functionality on the sandbox platforms. Also add binman nodes for generating the input files used for these capsules.
Remove the corresponding logic which was used for generation of these input files which is now superfluous.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
Changes since V6:
- Use macros defined in sandbox_efi_capsule for GUIDs and capsule input filenames.
- Generate the capsule input files through binman text entries.
arch/sandbox/dts/u-boot.dtsi | 363 ++++++++++++++++++ include/sandbox_efi_capsule.h | 11 + test/py/tests/test_efi_capsule/conftest.py | 168 +------- test/py/tests/test_efi_capsule/signature.dts | 10 - .../tests/test_efi_capsule/uboot_bin_env.its | 36 -- 5 files changed, 385 insertions(+), 203 deletions(-) delete mode 100644 test/py/tests/test_efi_capsule/signature.dts delete mode 100644 test/py/tests/test_efi_capsule/uboot_bin_env.its
I think you are still getting confused with using filenames when you don't need to. See below...
No, I don't think so. This is being done on purpose, since I want these files to be created. These are then copied to the efi capsule update tests' data directory, and are then used in testing the feature. Maybe if you want, I can put a comment to that effect.
I just traced through this code. I really think this needs to be simplified. You can do it in a patch at the end if you like.
But you have the 'u-boot.bin.old' and 'Old' strings in test_efi_capsule_auth2, for example.
In the binman world you define UBOOT_BIN_IMAGE_OLD as "u-boot.bin.old", then use that in the sandbox.dtsi
Then binman creates the u-boot.bin.old file (unnecessarily in my view) Then in efi_capsule_data() you copy the file to the test directory.
So for the last step, you could just create the file again, rather than copying it from the U-Boot build directory. After all, you know the contents. If you like you could put the different contents as binary strings in capsule_defs.py
Then you don't need to create the files.
Okay. TBH, I thought you would ask me to reuse the files created in binman for the tests as well, which is why I put this logic. I will create these files as part of the tests then.
There is a lot more I can say about the EFI capsule tests. For now I think we'll have to live with it creating 19 different binman images on sandbox. I think we could put them in an efi_capsules subdir, but that would need to be created somewhere, since binman doesn't do it. I suppose we could make binman automatically create a directory if an entry filename needs it?
I think this can be taken up as a follow-up. I also was thinking of adding a flag/property to not generate all the map files. I don't think such a property exists currently. The map files really are not needed for the capsules.
Anyway, for tests, primarily we need to split things up, so we have, for example:
process_capsule_file()
which processes the capsule in U-Boot, e.g. using an 'efi' command, then outputs what it did. Then the test can plant the capsule, run that function and check that the output is as expected. This can actually be a unit test, i.e. written in C.
Most of the tests can do this. Then we can have one test that checks the whole flow, but it doesn't need to be done for every case, as now.
I believe even Ilias thinks that these tests should be in C. But this is a separate effort, not related to this series. I also have doubts about your observation on not using so many capsule files for tests, but that can be investigated separately. For now, I want to focus on getting these changes in, followed by the generation of capsules through the config file. And FWIW, I am able to use relative paths in the binman tests for generating and testing the capsules generated through the config file -- so that takes care of your objection to using absolute paths. I will send that series once this gets merged.
-sughosh
Regards, Simon

Hi Sughosh,
On Sat, 5 Aug 2023 at 13:12, Sughosh Ganu sughosh.ganu@linaro.org wrote:
hi Simon,
On Sun, 6 Aug 2023 at 00:06, Simon Glass sjg@chromium.org wrote:
Hi Sughosh,
On Sat, 5 Aug 2023 at 12:01, Sughosh Ganu sughosh.ganu@linaro.org wrote:
hi Simon,
On Sat, 5 Aug 2023 at 20:34, Simon Glass sjg@chromium.org wrote:
Hi Sughosh,
On Sat, 5 Aug 2023 at 05:35, Sughosh Ganu sughosh.ganu@linaro.org wrote:
The EFI capsule files can now be generated as part of u-boot build through binman. Add capsule entry nodes in the u-boot.dtsi for the sandbox architecture for generating the capsules. These capsules are then used for testing the EFI capsule update functionality on the sandbox platforms. Also add binman nodes for generating the input files used for these capsules.
Remove the corresponding logic which was used for generation of these input files which is now superfluous.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
Changes since V6:
- Use macros defined in sandbox_efi_capsule for GUIDs and capsule input filenames.
- Generate the capsule input files through binman text entries.
arch/sandbox/dts/u-boot.dtsi | 363 ++++++++++++++++++ include/sandbox_efi_capsule.h | 11 + test/py/tests/test_efi_capsule/conftest.py | 168 +------- test/py/tests/test_efi_capsule/signature.dts | 10 - .../tests/test_efi_capsule/uboot_bin_env.its | 36 -- 5 files changed, 385 insertions(+), 203 deletions(-) delete mode 100644 test/py/tests/test_efi_capsule/signature.dts delete mode 100644 test/py/tests/test_efi_capsule/uboot_bin_env.its
I think you are still getting confused with using filenames when you don't need to. See below...
No, I don't think so. This is being done on purpose, since I want these files to be created. These are then copied to the efi capsule update tests' data directory, and are then used in testing the feature. Maybe if you want, I can put a comment to that effect.
I just traced through this code. I really think this needs to be simplified. You can do it in a patch at the end if you like.
But you have the 'u-boot.bin.old' and 'Old' strings in test_efi_capsule_auth2, for example.
In the binman world you define UBOOT_BIN_IMAGE_OLD as "u-boot.bin.old", then use that in the sandbox.dtsi
Then binman creates the u-boot.bin.old file (unnecessarily in my view) Then in efi_capsule_data() you copy the file to the test directory.
So for the last step, you could just create the file again, rather than copying it from the U-Boot build directory. After all, you know the contents. If you like you could put the different contents as binary strings in capsule_defs.py
Then you don't need to create the files.
Okay. TBH, I thought you would ask me to reuse the files created in binman for the tests as well, which is why I put this logic. I will create these files as part of the tests then.
There is a lot more I can say about the EFI capsule tests. For now I think we'll have to live with it creating 19 different binman images on sandbox. I think we could put them in an efi_capsules subdir, but that would need to be created somewhere, since binman doesn't do it. I suppose we could make binman automatically create a directory if an entry filename needs it?
I think this can be taken up as a follow-up. I also was thinking of adding a flag/property to not generate all the map files. I don't think such a property exists currently. The map files really are not needed for the capsules.
Sure, but if you implemented SetImagePos() then it would work. Something to think about when you create the tool to dump capsules.
Anyway, for tests, primarily we need to split things up, so we have, for example:
process_capsule_file()
which processes the capsule in U-Boot, e.g. using an 'efi' command, then outputs what it did. Then the test can plant the capsule, run that function and check that the output is as expected. This can actually be a unit test, i.e. written in C.
Most of the tests can do this. Then we can have one test that checks the whole flow, but it doesn't need to be done for every case, as now.
I believe even Ilias thinks that these tests should be in C. But this is a separate effort, not related to this series. I also have doubts about your observation on not using so many capsule files for tests, but that can be investigated separately. For now, I want to focus on getting these changes in, followed by the generation of capsules through the config file. And FWIW, I am able to use relative paths in the binman tests for generating and testing the capsules generated through the config file -- so that takes care of your objection to using absolute paths. I will send that series once this gets merged.
OK, yes it is best to get this series in and worry about tdy-ups after that.
Regards, Simon

On Sat, Aug 05, 2023 at 09:04:00AM -0600, Simon Glass wrote:
Hi Sughosh,
On Sat, 5 Aug 2023 at 05:35, Sughosh Ganu sughosh.ganu@linaro.org wrote:
The EFI capsule files can now be generated as part of u-boot build through binman. Add capsule entry nodes in the u-boot.dtsi for the sandbox architecture for generating the capsules. These capsules are then used for testing the EFI capsule update functionality on the sandbox platforms. Also add binman nodes for generating the input files used for these capsules.
Remove the corresponding logic which was used for generation of these input files which is now superfluous.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
Changes since V6:
- Use macros defined in sandbox_efi_capsule for GUIDs and capsule input filenames.
- Generate the capsule input files through binman text entries.
arch/sandbox/dts/u-boot.dtsi | 363 ++++++++++++++++++ include/sandbox_efi_capsule.h | 11 + test/py/tests/test_efi_capsule/conftest.py | 168 +------- test/py/tests/test_efi_capsule/signature.dts | 10 - .../tests/test_efi_capsule/uboot_bin_env.its | 36 -- 5 files changed, 385 insertions(+), 203 deletions(-) delete mode 100644 test/py/tests/test_efi_capsule/signature.dts delete mode 100644 test/py/tests/test_efi_capsule/uboot_bin_env.its
I think you are still getting confused with using filenames when you don't need to. See below...
diff --git a/arch/sandbox/dts/u-boot.dtsi b/arch/sandbox/dts/u-boot.dtsi index 60bd004937..f1b16b41c2 100644 --- a/arch/sandbox/dts/u-boot.dtsi +++ b/arch/sandbox/dts/u-boot.dtsi @@ -7,11 +7,374 @@ */
#ifdef CONFIG_EFI_HAVE_CAPSULE_SUPPORT
+#include <sandbox_efi_capsule.h>
/ { #ifdef CONFIG_EFI_CAPSULE_AUTHENTICATE signature { capsule-key = /incbin/(CONFIG_EFI_CAPSULE_ESL_FILE); }; #endif
binman: binman {
multiple-images;
};
+};
+&binman {
input1 {
filename = UBOOT_BIN_IMAGE_OLD;
text {
text = "u-boot:Old";
};
};
input2 {
filename = UBOOT_BIN_IMAGE_NEW;
text {
text = "u-boot:New";
};
};
input3 {
filename = UBOOT_ENV_IMAGE_OLD;
text {
text = "u-boot-env:Old";
};
};
input4 {
filename = UBOOT_ENV_IMAGE_NEW;
text {
text = "u-boot-env:New";
};
};
All of those nodes can be removed
itb {
filename = UBOOT_FIT_IMAGE;
fit {
description = "Automatic U-Boot environment update";
#address-cells = <2>;
images {
u-boot-bin {
description = "U-Boot binary on SPI Flash";
compression = "none";
type = "firmware";
arch = "sandbox";
load = <0>;
blob {
filename = UBOOT_BIN_IMAGE_NEW;
};
instead of this blob node, you should be able to write:
text { text = "u-boot:Old"; };
There is no need to provide filenames in every node.
hash-1 {
algo = "sha1";
};
};
u-boot-env {
description = "U-Boot environment on SPI Flash";
compression = "none";
type = "firmware";
arch = "sandbox";
load = <0>;
blob {
filename = UBOOT_ENV_IMAGE_NEW;
};
same here and below
hash-1 {
algo = "sha1";
};
};
};
};
};
capsule1 {
filename = "Test01";
capsule {
type = "efi-capsule";
image-index = <0x1>;
image-type-id = SANDBOX_UBOOT_IMAGE_GUID;
blob {
filename = UBOOT_BIN_IMAGE_NEW;
};
again this should be a text node
same below
};
};
capsule2 {
filename = "Test02";
capsule {
type = "efi-capsule";
image-index = <0x2>;
image-type-id = SANDBOX_UBOOT_ENV_IMAGE_GUID;
blob {
filename = UBOOT_ENV_IMAGE_NEW;
};
};
};
capsule3 {
filename = "Test03";
capsule {
type = "efi-capsule";
image-index = <0x1>;
image-type-id = SANDBOX_INCORRECT_GUID;
blob {
filename = UBOOT_BIN_IMAGE_NEW;
};
};
};
capsule4 {
filename = "Test04";
capsule {
type = "efi-capsule";
image-index = <0x1>;
image-type-id = SANDBOX_FIT_IMAGE_GUID;
blob {
filename =
[..]
capsule19 {
filename = "Test115";
[..]
We really need to talk about these tests. So many cases! Can you not reduce this?
And why are these tests in the generic looking file and not one of the test dts files? This looks like something that would make implementation in real life confusing and non-obvious.

On Sun, 6 Aug 2023 at 03:48, Tom Rini trini@konsulko.com wrote:
On Sat, Aug 05, 2023 at 09:04:00AM -0600, Simon Glass wrote:
Hi Sughosh,
On Sat, 5 Aug 2023 at 05:35, Sughosh Ganu sughosh.ganu@linaro.org wrote:
The EFI capsule files can now be generated as part of u-boot build through binman. Add capsule entry nodes in the u-boot.dtsi for the sandbox architecture for generating the capsules. These capsules are then used for testing the EFI capsule update functionality on the sandbox platforms. Also add binman nodes for generating the input files used for these capsules.
Remove the corresponding logic which was used for generation of these input files which is now superfluous.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
Changes since V6:
- Use macros defined in sandbox_efi_capsule for GUIDs and capsule input filenames.
- Generate the capsule input files through binman text entries.
arch/sandbox/dts/u-boot.dtsi | 363 ++++++++++++++++++ include/sandbox_efi_capsule.h | 11 + test/py/tests/test_efi_capsule/conftest.py | 168 +------- test/py/tests/test_efi_capsule/signature.dts | 10 - .../tests/test_efi_capsule/uboot_bin_env.its | 36 -- 5 files changed, 385 insertions(+), 203 deletions(-) delete mode 100644 test/py/tests/test_efi_capsule/signature.dts delete mode 100644 test/py/tests/test_efi_capsule/uboot_bin_env.its
I think you are still getting confused with using filenames when you don't need to. See below...
diff --git a/arch/sandbox/dts/u-boot.dtsi b/arch/sandbox/dts/u-boot.dtsi index 60bd004937..f1b16b41c2 100644 --- a/arch/sandbox/dts/u-boot.dtsi +++ b/arch/sandbox/dts/u-boot.dtsi
<snip>
};
};
capsule2 {
filename = "Test02";
capsule {
type = "efi-capsule";
image-index = <0x2>;
image-type-id = SANDBOX_UBOOT_ENV_IMAGE_GUID;
blob {
filename = UBOOT_ENV_IMAGE_NEW;
};
};
};
capsule3 {
filename = "Test03";
capsule {
type = "efi-capsule";
image-index = <0x1>;
image-type-id = SANDBOX_INCORRECT_GUID;
blob {
filename = UBOOT_BIN_IMAGE_NEW;
};
};
};
capsule4 {
filename = "Test04";
capsule {
type = "efi-capsule";
image-index = <0x1>;
image-type-id = SANDBOX_FIT_IMAGE_GUID;
blob {
filename =
[..]
capsule19 {
filename = "Test115";
[..]
We really need to talk about these tests. So many cases! Can you not reduce this?
And why are these tests in the generic looking file and not one of the test dts files? This looks like something that would make implementation in real life confusing and non-obvious.
These are not capsules that are being generated for binman tests. Those dts files are indeed under tools/binman/test/. These capsules are the ones used for testing the capsule update feature in the CI run. The idea of having these capsule nodes defined in this file is to have them generated as part of the standard build.
-sughosh

On Sun, Aug 06, 2023 at 04:43:06PM +0530, Sughosh Ganu wrote:
On Sun, 6 Aug 2023 at 03:48, Tom Rini trini@konsulko.com wrote:
On Sat, Aug 05, 2023 at 09:04:00AM -0600, Simon Glass wrote:
Hi Sughosh,
On Sat, 5 Aug 2023 at 05:35, Sughosh Ganu sughosh.ganu@linaro.org wrote:
The EFI capsule files can now be generated as part of u-boot build through binman. Add capsule entry nodes in the u-boot.dtsi for the sandbox architecture for generating the capsules. These capsules are then used for testing the EFI capsule update functionality on the sandbox platforms. Also add binman nodes for generating the input files used for these capsules.
Remove the corresponding logic which was used for generation of these input files which is now superfluous.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
Changes since V6:
- Use macros defined in sandbox_efi_capsule for GUIDs and capsule input filenames.
- Generate the capsule input files through binman text entries.
arch/sandbox/dts/u-boot.dtsi | 363 ++++++++++++++++++ include/sandbox_efi_capsule.h | 11 + test/py/tests/test_efi_capsule/conftest.py | 168 +------- test/py/tests/test_efi_capsule/signature.dts | 10 - .../tests/test_efi_capsule/uboot_bin_env.its | 36 -- 5 files changed, 385 insertions(+), 203 deletions(-) delete mode 100644 test/py/tests/test_efi_capsule/signature.dts delete mode 100644 test/py/tests/test_efi_capsule/uboot_bin_env.its
I think you are still getting confused with using filenames when you don't need to. See below...
diff --git a/arch/sandbox/dts/u-boot.dtsi b/arch/sandbox/dts/u-boot.dtsi index 60bd004937..f1b16b41c2 100644 --- a/arch/sandbox/dts/u-boot.dtsi +++ b/arch/sandbox/dts/u-boot.dtsi
<snip>
};
};
capsule2 {
filename = "Test02";
capsule {
type = "efi-capsule";
image-index = <0x2>;
image-type-id = SANDBOX_UBOOT_ENV_IMAGE_GUID;
blob {
filename = UBOOT_ENV_IMAGE_NEW;
};
};
};
capsule3 {
filename = "Test03";
capsule {
type = "efi-capsule";
image-index = <0x1>;
image-type-id = SANDBOX_INCORRECT_GUID;
blob {
filename = UBOOT_BIN_IMAGE_NEW;
};
};
};
capsule4 {
filename = "Test04";
capsule {
type = "efi-capsule";
image-index = <0x1>;
image-type-id = SANDBOX_FIT_IMAGE_GUID;
blob {
filename =
[..]
capsule19 {
filename = "Test115";
[..]
We really need to talk about these tests. So many cases! Can you not reduce this?
And why are these tests in the generic looking file and not one of the test dts files? This looks like something that would make implementation in real life confusing and non-obvious.
These are not capsules that are being generated for binman tests. Those dts files are indeed under tools/binman/test/. These capsules are the ones used for testing the capsule update feature in the CI run. The idea of having these capsule nodes defined in this file is to have them generated as part of the standard build.
The high level concern I have (so it applies to a few of these patches) is that it's not going to be clear and straightforward on how to use this regularly (for example, if I follow all of this right, I should be able to do a capsule update to push a build to one of my boards, and then run our pytest suite on it, instead of playing games with SD mux boards and so forth) or production (configure product-board so that we can deliver an updated firmware via $mechanism).

Hi Tom,
On Mon, 7 Aug 2023 at 12:08, Tom Rini trini@konsulko.com wrote:
On Sun, Aug 06, 2023 at 04:43:06PM +0530, Sughosh Ganu wrote:
On Sun, 6 Aug 2023 at 03:48, Tom Rini trini@konsulko.com wrote:
On Sat, Aug 05, 2023 at 09:04:00AM -0600, Simon Glass wrote:
Hi Sughosh,
On Sat, 5 Aug 2023 at 05:35, Sughosh Ganu sughosh.ganu@linaro.org wrote:
The EFI capsule files can now be generated as part of u-boot build through binman. Add capsule entry nodes in the u-boot.dtsi for the sandbox architecture for generating the capsules. These capsules are then used for testing the EFI capsule update functionality on the sandbox platforms. Also add binman nodes for generating the input files used for these capsules.
Remove the corresponding logic which was used for generation of these input files which is now superfluous.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
Changes since V6:
- Use macros defined in sandbox_efi_capsule for GUIDs and capsule input filenames.
- Generate the capsule input files through binman text entries.
arch/sandbox/dts/u-boot.dtsi | 363 ++++++++++++++++++ include/sandbox_efi_capsule.h | 11 + test/py/tests/test_efi_capsule/conftest.py | 168 +------- test/py/tests/test_efi_capsule/signature.dts | 10 - .../tests/test_efi_capsule/uboot_bin_env.its | 36 -- 5 files changed, 385 insertions(+), 203 deletions(-) delete mode 100644 test/py/tests/test_efi_capsule/signature.dts delete mode 100644 test/py/tests/test_efi_capsule/uboot_bin_env.its
I think you are still getting confused with using filenames when you don't need to. See below...
diff --git a/arch/sandbox/dts/u-boot.dtsi b/arch/sandbox/dts/u-boot.dtsi index 60bd004937..f1b16b41c2 100644 --- a/arch/sandbox/dts/u-boot.dtsi +++ b/arch/sandbox/dts/u-boot.dtsi
<snip>
};
};
capsule2 {
filename = "Test02";
capsule {
type = "efi-capsule";
image-index = <0x2>;
image-type-id = SANDBOX_UBOOT_ENV_IMAGE_GUID;
blob {
filename = UBOOT_ENV_IMAGE_NEW;
};
};
};
capsule3 {
filename = "Test03";
capsule {
type = "efi-capsule";
image-index = <0x1>;
image-type-id = SANDBOX_INCORRECT_GUID;
blob {
filename = UBOOT_BIN_IMAGE_NEW;
};
};
};
capsule4 {
filename = "Test04";
capsule {
type = "efi-capsule";
image-index = <0x1>;
image-type-id = SANDBOX_FIT_IMAGE_GUID;
blob {
filename =
[..]
capsule19 {
filename = "Test115";
[..]
We really need to talk about these tests. So many cases! Can you not reduce this?
And why are these tests in the generic looking file and not one of the test dts files? This looks like something that would make implementation in real life confusing and non-obvious.
These are not capsules that are being generated for binman tests. Those dts files are indeed under tools/binman/test/. These capsules are the ones used for testing the capsule update feature in the CI run. The idea of having these capsule nodes defined in this file is to have them generated as part of the standard build.
The high level concern I have (so it applies to a few of these patches) is that it's not going to be clear and straightforward on how to use this regularly (for example, if I follow all of this right, I should be able to do a capsule update to push a build to one of my boards, and then run our pytest suite on it, instead of playing games with SD mux boards and so forth) or production (configure product-board so that we can deliver an updated firmware via $mechanism).
Well you can do that today with VBE...
Regards, Simon

The EFI capsules can now be generated as part of u-boot build, through binman. Highlight these changes in the documentation.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org --- Changes since V6: None
doc/develop/uefi/uefi.rst | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
diff --git a/doc/develop/uefi/uefi.rst b/doc/develop/uefi/uefi.rst index b2854b52a6..3150d6fb9c 100644 --- a/doc/develop/uefi/uefi.rst +++ b/doc/develop/uefi/uefi.rst @@ -318,6 +318,9 @@ Run the following command --guid <image GUID> \ <capsule_file_name>
+Capsule with firmware version +***************************** + The UEFI specification does not define the firmware versioning mechanism. EDK II reference implementation inserts the FMP Payload Header right before the payload. It coutains the fw_version and lowest supported version, @@ -345,6 +348,21 @@ add --fw-version option in mkeficapsule tool. If the --fw-version option is not set, FMP Payload Header is not inserted and fw_version is set as 0.
+ +Capsule Generation through binman +********************************* + +Support has also been added to generate capsules during u-boot build +through binman. This requires the platform's DTB to be populated with +the capsule entry nodes for binman. The capsules then can be generated +by specifying the capsule parameters either through a config file, or +by specifying them as properties in the capsule entry node. + +Check the arch/sandbox/dts/u-boot.dtsi file for the sandbox platform +as reference for how to generate capsules through binman as part of +u-boot build. + + Performing the update *********************

Hi Sughosh,
On Sat, 5 Aug 2023 at 05:35, Sughosh Ganu sughosh.ganu@linaro.org wrote:
The EFI capsules can now be generated as part of u-boot build, through
Please check your patches for 'U-Boot' throughout.
binman. Highlight these changes in the documentation.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
Changes since V6: None
doc/develop/uefi/uefi.rst | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
diff --git a/doc/develop/uefi/uefi.rst b/doc/develop/uefi/uefi.rst index b2854b52a6..3150d6fb9c 100644 --- a/doc/develop/uefi/uefi.rst +++ b/doc/develop/uefi/uefi.rst @@ -318,6 +318,9 @@ Run the following command --guid <image GUID> \ <capsule_file_name>
+Capsule with firmware version +*****************************
The UEFI specification does not define the firmware versioning mechanism. EDK II reference implementation inserts the FMP Payload Header right before the payload. It coutains the fw_version and lowest supported version, @@ -345,6 +348,21 @@ add --fw-version option in mkeficapsule tool. If the --fw-version option is not set, FMP Payload Header is not inserted and fw_version is set as 0.
+Capsule Generation through binman +*********************************
+Support has also been added to generate capsules during u-boot build +through binman. This requires the platform's DTB to be populated with +the capsule entry nodes for binman. The capsules then can be generated +by specifying the capsule parameters either through a config file, or
not a config file at present
+by specifying them as properties in the capsule entry node.
+Check the arch/sandbox/dts/u-boot.dtsi file for the sandbox platform +as reference for how to generate capsules through binman as part of +u-boot build.
Performing the update
-- 2.34.1
Regards, Simon

hi Simon,
On Sat, 5 Aug 2023 at 20:34, Simon Glass sjg@chromium.org wrote:
Hi Sughosh,
On Sat, 5 Aug 2023 at 05:35, Sughosh Ganu sughosh.ganu@linaro.org wrote:
The EFI capsules can now be generated as part of u-boot build, through
Please check your patches for 'U-Boot' throughout.
Okay
binman. Highlight these changes in the documentation.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
Changes since V6: None
doc/develop/uefi/uefi.rst | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
diff --git a/doc/develop/uefi/uefi.rst b/doc/develop/uefi/uefi.rst index b2854b52a6..3150d6fb9c 100644 --- a/doc/develop/uefi/uefi.rst +++ b/doc/develop/uefi/uefi.rst @@ -318,6 +318,9 @@ Run the following command --guid <image GUID> \ <capsule_file_name>
+Capsule with firmware version +*****************************
The UEFI specification does not define the firmware versioning mechanism. EDK II reference implementation inserts the FMP Payload Header right before the payload. It coutains the fw_version and lowest supported version, @@ -345,6 +348,21 @@ add --fw-version option in mkeficapsule tool. If the --fw-version option is not set, FMP Payload Header is not inserted and fw_version is set as 0.
+Capsule Generation through binman +*********************************
+Support has also been added to generate capsules during u-boot build +through binman. This requires the platform's DTB to be populated with +the capsule entry nodes for binman. The capsules then can be generated +by specifying the capsule parameters either through a config file, or
not a config file at present
Yes, will remove the reference.
-sughosh
+by specifying them as properties in the capsule entry node.
+Check the arch/sandbox/dts/u-boot.dtsi file for the sandbox platform +as reference for how to generate capsules through binman as part of +u-boot build.
Performing the update
-- 2.34.1
Regards, Simon

When running the trace test on the sandbox platform, the current size of 16MiB is no longer large enough for capturing the entire trace history, and results in truncation. Use a size of 32MiB for the trace buffer on the sandbox platform while running the trace test.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org --- Changes since V6: * New patch for fixing CI trace test failure.
.azure-pipelines.yml | 2 +- .gitlab-ci.yml | 2 +- test/py/tests/test_trace.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml index 2678e5ae05..2ef4db5318 100644 --- a/.azure-pipelines.yml +++ b/.azure-pipelines.yml @@ -275,7 +275,7 @@ stages: TEST_PY_BD: "sandbox" BUILD_ENV: "FTRACE=1 NO_LTO=1" TEST_PY_TEST_SPEC: "trace" - OVERRIDE: "-a CONFIG_TRACE=y -a CONFIG_TRACE_EARLY=y -a CONFIG_TRACE_EARLY_SIZE=0x01000000" + OVERRIDE: "-a CONFIG_TRACE=y -a CONFIG_TRACE_EARLY=y -a CONFIG_TRACE_EARLY_SIZE=0x01000000 -a CONFIG_TRACE_BUFFER_SIZE=0x02000000" coreboot: TEST_PY_BD: "coreboot" TEST_PY_ID: "--id qemu" diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8010afae95..3e41299658 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -315,7 +315,7 @@ sandbox trace_test.py: TEST_PY_BD: "sandbox" BUILD_ENV: "FTRACE=1 NO_LTO=1" TEST_PY_TEST_SPEC: "trace" - OVERRIDE: "-a CONFIG_TRACE=y -a CONFIG_TRACE_EARLY=y -a CONFIG_TRACE_EARLY_SIZE=0x01000000" + OVERRIDE: "-a CONFIG_TRACE=y -a CONFIG_TRACE_EARLY=y -a CONFIG_TRACE_EARLY_SIZE=0x01000000 -a CONFIG_TRACE_BUFFER_SIZE=0x02000000" <<: *buildman_and_testpy_dfn
evb-ast2500 test.py: diff --git a/test/py/tests/test_trace.py b/test/py/tests/test_trace.py index ac3e95925e..ad2250920d 100644 --- a/test/py/tests/test_trace.py +++ b/test/py/tests/test_trace.py @@ -61,7 +61,7 @@ def collect_trace(cons):
# Read out the trace data addr = 0x02000000 - size = 0x01000000 + size = 0x02000000 out = cons.run_command(f'trace calls {addr:x} {size:x}') print(out) fname = os.path.join(TMPDIR, 'trace')

Hi Sughosh,
On Sat, 5 Aug 2023 at 05:36, Sughosh Ganu sughosh.ganu@linaro.org wrote:
When running the trace test on the sandbox platform, the current size of 16MiB is no longer large enough for capturing the entire trace history, and results in truncation. Use a size of 32MiB for the trace buffer on the sandbox platform while running the trace test.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
Changes since V6:
- New patch for fixing CI trace test failure.
.azure-pipelines.yml | 2 +- .gitlab-ci.yml | 2 +- test/py/tests/test_trace.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org
Do you know what has made it jump up?
diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml index 2678e5ae05..2ef4db5318 100644 --- a/.azure-pipelines.yml +++ b/.azure-pipelines.yml @@ -275,7 +275,7 @@ stages: TEST_PY_BD: "sandbox" BUILD_ENV: "FTRACE=1 NO_LTO=1" TEST_PY_TEST_SPEC: "trace"
OVERRIDE: "-a CONFIG_TRACE=y -a CONFIG_TRACE_EARLY=y -a CONFIG_TRACE_EARLY_SIZE=0x01000000"
OVERRIDE: "-a CONFIG_TRACE=y -a CONFIG_TRACE_EARLY=y -a CONFIG_TRACE_EARLY_SIZE=0x01000000 -a CONFIG_TRACE_BUFFER_SIZE=0x02000000" coreboot: TEST_PY_BD: "coreboot" TEST_PY_ID: "--id qemu"
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8010afae95..3e41299658 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -315,7 +315,7 @@ sandbox trace_test.py: TEST_PY_BD: "sandbox" BUILD_ENV: "FTRACE=1 NO_LTO=1" TEST_PY_TEST_SPEC: "trace"
- OVERRIDE: "-a CONFIG_TRACE=y -a CONFIG_TRACE_EARLY=y -a CONFIG_TRACE_EARLY_SIZE=0x01000000"
- OVERRIDE: "-a CONFIG_TRACE=y -a CONFIG_TRACE_EARLY=y -a CONFIG_TRACE_EARLY_SIZE=0x01000000 -a CONFIG_TRACE_BUFFER_SIZE=0x02000000" <<: *buildman_and_testpy_dfn
evb-ast2500 test.py: diff --git a/test/py/tests/test_trace.py b/test/py/tests/test_trace.py index ac3e95925e..ad2250920d 100644 --- a/test/py/tests/test_trace.py +++ b/test/py/tests/test_trace.py @@ -61,7 +61,7 @@ def collect_trace(cons):
# Read out the trace data addr = 0x02000000
- size = 0x01000000
- size = 0x02000000 out = cons.run_command(f'trace calls {addr:x} {size:x}') print(out) fname = os.path.join(TMPDIR, 'trace')
-- 2.34.1
Regards, Simon

hi Simon,
On Sat, 5 Aug 2023 at 20:34, Simon Glass sjg@chromium.org wrote:
Hi Sughosh,
On Sat, 5 Aug 2023 at 05:36, Sughosh Ganu sughosh.ganu@linaro.org wrote:
When running the trace test on the sandbox platform, the current size of 16MiB is no longer large enough for capturing the entire trace history, and results in truncation. Use a size of 32MiB for the trace buffer on the sandbox platform while running the trace test.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
Changes since V6:
- New patch for fixing CI trace test failure.
.azure-pipelines.yml | 2 +- .gitlab-ci.yml | 2 +- test/py/tests/test_trace.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org
Do you know what has made it jump up?
I suspect this is due to the increase in the size of the dtb with all the additional binman nodes. It starts failing with the last capsule node being added under the binman node.
-sughosh
diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml index 2678e5ae05..2ef4db5318 100644 --- a/.azure-pipelines.yml +++ b/.azure-pipelines.yml @@ -275,7 +275,7 @@ stages: TEST_PY_BD: "sandbox" BUILD_ENV: "FTRACE=1 NO_LTO=1" TEST_PY_TEST_SPEC: "trace"
OVERRIDE: "-a CONFIG_TRACE=y -a CONFIG_TRACE_EARLY=y -a CONFIG_TRACE_EARLY_SIZE=0x01000000"
OVERRIDE: "-a CONFIG_TRACE=y -a CONFIG_TRACE_EARLY=y -a CONFIG_TRACE_EARLY_SIZE=0x01000000 -a CONFIG_TRACE_BUFFER_SIZE=0x02000000" coreboot: TEST_PY_BD: "coreboot" TEST_PY_ID: "--id qemu"
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8010afae95..3e41299658 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -315,7 +315,7 @@ sandbox trace_test.py: TEST_PY_BD: "sandbox" BUILD_ENV: "FTRACE=1 NO_LTO=1" TEST_PY_TEST_SPEC: "trace"
- OVERRIDE: "-a CONFIG_TRACE=y -a CONFIG_TRACE_EARLY=y -a CONFIG_TRACE_EARLY_SIZE=0x01000000"
- OVERRIDE: "-a CONFIG_TRACE=y -a CONFIG_TRACE_EARLY=y -a CONFIG_TRACE_EARLY_SIZE=0x01000000 -a CONFIG_TRACE_BUFFER_SIZE=0x02000000" <<: *buildman_and_testpy_dfn
evb-ast2500 test.py: diff --git a/test/py/tests/test_trace.py b/test/py/tests/test_trace.py index ac3e95925e..ad2250920d 100644 --- a/test/py/tests/test_trace.py +++ b/test/py/tests/test_trace.py @@ -61,7 +61,7 @@ def collect_trace(cons):
# Read out the trace data addr = 0x02000000
- size = 0x01000000
- size = 0x02000000 out = cons.run_command(f'trace calls {addr:x} {size:x}') print(out) fname = os.path.join(TMPDIR, 'trace')
-- 2.34.1
Regards, Simon
participants (3)
-
Simon Glass
-
Sughosh Ganu
-
Tom Rini