From 712a543c9dcc1716cc4bc4f35803b78a58f43707 Mon Sep 17 00:00:00 2001 From: David Garske Date: Wed, 9 Aug 2023 11:21:39 -0700 Subject: [PATCH] Fixes and improvements for iMXRT1050 QSPI. --- IDE/CCS/TMS570LC43xx/README.md | 6 ++--- IDE/IAR/README.md | 6 ++--- config/examples/imx-rt1050.config | 2 +- docs/Targets.md | 25 +++++++++++++++++++ .../scripts/prepare_encrypted_delta_update.sh | 2 +- tools/scripts/prepare_update.sh | 2 +- tools/scripts/prepare_update_l5.sh | 2 +- tools/scripts/prepare_update_l5_dualbank.sh | 2 +- 8 files changed, 36 insertions(+), 11 deletions(-) diff --git a/IDE/CCS/TMS570LC43xx/README.md b/IDE/CCS/TMS570LC43xx/README.md index c2eb0c3b..2ba330ac 100644 --- a/IDE/CCS/TMS570LC43xx/README.md +++ b/IDE/CCS/TMS570LC43xx/README.md @@ -97,7 +97,7 @@ MEMORY In order to generate a signed image, the application is copied to a binary format and signed with the following commands ``` "c:\ti\ccs1031\ccs\tools\compiler\ti-cgt-arm_20.2.4.LTS\bin\armobjcopy.exe" -O binary application.out application.bin -".\tools\keytools\sign.exe" --ecc256 --sha256 application.bin ecc256.der 1 +".\tools\keytools\sign.exe" --ecc256 --sha256 application.bin wolfboot_signing_private_key.der 1 ``` Output should resemble: @@ -106,7 +106,7 @@ Update type: Firmware Input image: application.bin Selected cipher: ECC256 Selected hash : SHA256 -Public key: ecc256.der +Public key: wolfboot_signing_private_key.der Output image: application_v1_signed.bin Calculating SHA256 digest... Signing the firmware... @@ -116,7 +116,7 @@ Output image(s) successfully created. To flash the signed image the following command can be used. ``` -"c:\ti\ccs1031\ccs\ccs_base\scripting\examples\uniflash\cmdLine\uniflash.bat" -ccxml "IDE\CCS\TMS570LC43xx\flashHercules.ccxml" -setOptions FlashEraseSelection="Necessary Sectors Only (for Program Load)" -programBin application_v1_signed.bin 0x20000 +"c:\ti\ccs1031\ccs\ccs_base\scripting\examples\uniflash\cmdLine\uniflash.bat" -ccxml "IDE\CCS\TMS570LC43xx\flashHercules.ccxml" -setOptions FlashEraseSelection="Necessary Sectors Only (for Program Load)" -programBin application_v1_signed.bin 0x20000 ``` # Implementation notes diff --git a/IDE/IAR/README.md b/IDE/IAR/README.md index aeef72b5..0e3e09f8 100644 --- a/IDE/IAR/README.md +++ b/IDE/IAR/README.md @@ -40,14 +40,14 @@ generate_key.bat ``` -The script will generate a keypair. The file `ecc256.der` in the root of the repository contains the private key that will be used -to sign valid firmware images. The file `src/ecc256_pub_key.c` now contains the public key that the bootloader embeds in its codebase +The script will generate a keypair. The file `wolfboot_signing_private_key.der` in the root of the repository contains the private key that will be used +to sign valid firmware images. The file `src/keystore.c` now contains the public key that the bootloader embeds in its codebase to use it later to verify the image. ### Compiling and linking the images -Now both projects (wolfboot and wolfboot-test-app) can be compiled and linked. +Now both projects (wolfboot and wolfboot-test-app) can be compiled and linked. The two resulting images will be placed in the output directory `Debug/Exe`: - wolfboot.bin - wolfboot-test-app.bin diff --git a/config/examples/imx-rt1050.config b/config/examples/imx-rt1050.config index beb5a22c..66ad2195 100644 --- a/config/examples/imx-rt1050.config +++ b/config/examples/imx-rt1050.config @@ -2,7 +2,7 @@ ARCH?=ARM TARGET?=imx_rt SIGN?=ECC256 HASH?=SHA256 -MCUXPRESSO?=$(PWD)/../SDK_2_11_0_EVKB-IMXRT1050 +MCUXPRESSO?=$(PWD)/../SDK_2_14_0_EVKB-IMXRT1050 MCUXPRESSO_CPU?=MIMXRT1052DVJ6B MCUXPRESSO_DRIVERS?=$(MCUXPRESSO)/devices/MIMXRT1052 MCUXPRESSO_CMSIS?=$(MCUXPRESSO)/CMSIS diff --git a/docs/Targets.md b/docs/Targets.md index 28bfb176..19e403e6 100644 --- a/docs/Targets.md +++ b/docs/Targets.md @@ -1053,6 +1053,31 @@ DCP support (hardware acceleration for SHA256 operations) can be enabled by usin Firmware can be directly uploaded to the target by copying `factory.bin` to the virtual USB drive associated to the device, or by loading the image directly into flash using a JTAG/SWD debugger. +### Testing Update + +```sh +tools/scripts/prepare_update.sh + +# HyperFlash +JLinkExe -if swd -speed 5000 -Device "MIMXRT1052XXX6A" +# QSPI +JLinkExe -if swd -speed 5000 -Device "MIMXRT1052XXX6A?BankAddr=0x60000000&Loader=QSPI" + +loadbin factory.bin 0x60000000 +loadbin update.bin 0x60030000 +``` + +### NXP iMX-RT Debugging JTAG / JLINK + +```sh +JLinkGDBServer -Device MIMXRT1052xxx6A -speed 5000 -if swd -port 3333 +arm-none-eabi-gdb +add-symbol-file test-app/image.elf 0x60010000 +mon reset init +b main +c +``` + ## NXP Kinetis diff --git a/tools/scripts/prepare_encrypted_delta_update.sh b/tools/scripts/prepare_encrypted_delta_update.sh index 64b3afc2..655aaa22 100755 --- a/tools/scripts/prepare_encrypted_delta_update.sh +++ b/tools/scripts/prepare_encrypted_delta_update.sh @@ -16,7 +16,7 @@ echo -n "0123456789abcdef0123456789abcdef0123456789ab" > enc_key.der $SIGN_TOOL --ecc256 \ --encrypt enc_key.der \ --delta test-app/image_v1_signed.bin \ - test-app/image.bin ecc256.der $VERSION + test-app/image.bin wolfboot_signing_private_key.der $VERSION dd if=/dev/zero bs=$SIZE count=1 2>/dev/null | tr "\000" "\377" > update.bin dd if=$APP of=update.bin bs=1 conv=notrunc printf "pBOOT" >> update.bin diff --git a/tools/scripts/prepare_update.sh b/tools/scripts/prepare_update.sh index 438e4922..576690f9 100755 --- a/tools/scripts/prepare_update.sh +++ b/tools/scripts/prepare_update.sh @@ -9,7 +9,7 @@ fi SIZE=131067 VERSION=8 APP=test-app/image_v"$VERSION"_signed.bin -$SIGN_TOOL --ecc256 test-app/image.bin ecc256.der $VERSION +$SIGN_TOOL --ecc256 test-app/image.bin wolfboot_signing_private_key.der $VERSION dd if=/dev/zero bs=$SIZE count=1 2>/dev/null | tr "\000" "\377" > update.bin dd if=$APP of=update.bin bs=1 conv=notrunc printf "pBOOT" >> update.bin diff --git a/tools/scripts/prepare_update_l5.sh b/tools/scripts/prepare_update_l5.sh index a8b0e432..2ab7c39b 100755 --- a/tools/scripts/prepare_update_l5.sh +++ b/tools/scripts/prepare_update_l5.sh @@ -9,7 +9,7 @@ fi SIZE=129019 VERSION=8 APP=test-app/image_v"$VERSION"_signed.bin -$SIGN_TOOL --sha256 --ecc256 test-app/image.bin ecc256.der $VERSION +$SIGN_TOOL --sha256 --ecc256 test-app/image.bin wolfboot_signing_private_key.der $VERSION dd if=/dev/zero bs=$SIZE count=1 2>/dev/null | tr "\000" "\377" > update.bin dd if=$APP of=update.bin bs=1 conv=notrunc printf "pBOOT" >> update.bin diff --git a/tools/scripts/prepare_update_l5_dualbank.sh b/tools/scripts/prepare_update_l5_dualbank.sh index a0601675..e7a3ef2e 100755 --- a/tools/scripts/prepare_update_l5_dualbank.sh +++ b/tools/scripts/prepare_update_l5_dualbank.sh @@ -9,7 +9,7 @@ fi SIZE=229371 VERSION=8 APP=test-app/image_v"$VERSION"_signed.bin -$SIGN_TOOL --ecc256 test-app/image.bin ecc256.der $VERSION +$SIGN_TOOL --ecc256 test-app/image.bin wolfboot_signing_private_key.der $VERSION dd if=/dev/zero bs=$SIZE count=1 2>/dev/null | tr "\000" "\377" > update.bin dd if=$APP of=update.bin bs=1 conv=notrunc printf "pBOOT" >> update.bin