Solved! Go to Solution.
Let me try to explain: If you take a look at S32K344_Basic_SecureBoot example, it's just configuration project. It's not bootloader, it's not application, it's just configuration project. It's supposed to be executed only first time. Once BOOT_SEQ is set, this project is never executed again.
S32K344_SecureBootBlinky is protected application. If you take a look at its linker file, it starts at 0x005040C0:
There's app boot header at this address:
And then there's the application - correctly aligned as mentioned in my last post.
Small difference (I was wrong in my previous post) - BOOT_SEQ is already set in boot header in S32K344_Basic_SecureBoot project:
So, you can simply load the project by debugger, debugger will manually set the program counter to entry point, secure boot is configured and, because BOOT_SEQ is already set, secure boot is active after first reset. Then the S32K344_SecureBootBlinky is started.
But you can reprogram the BOOT_SEQ by your software once the configuration is completed. It's up to you.
To implement this approach to your use-case, you should have configuration project like S32K344_Basic_SecureBoot, then you should have your bootloader which will be protected by basic secure boot (this is equal to S32K344_SecureBootBlinky) and then you should have your application.
How to start application from bootloader: just deinitialize everything and jump to entry point of application. It was discussed here many times, for example here:
https://community.nxp.com/t5/S32K/S32K312-bootloader-jump-to-application-issue/td-p/1795729
Regards,
Lukas
Hi
I don't think this approach is correct. I can see that bootloader and application is used but you are signing application only while bootloader is supposed to be run after each reset. This sounds as security risk. And when talking about security risk, our recommendation is to use advanced secure boot mode, not just simple basic secure boot mode.
First thing I can see in your description is that you placed app_boot_header at 0x500000. This is not correct. We provide Secure Boot application note including demo projects. It can be downloaded from:
https://www.nxp.com/products/S32K3
Application note can be found here:
Documentation -> Secure Files -> Secure Boot Application note v0.1.1.0 (AN744511)
Associated demo project can be downloaded here:
Design Resources -> Software -> Secure Files -> SecureBootAppNoteDemo (SW745310)
Take a look at section "5.2 Configuration". This section says that start address of the application must be aligned to 128 bytes, so app header should start at "app_start_adress - 64bytes".
My recommendation is to study following example:
c:\NXP\S32K3_HSE_DemoExamples_1_0_0\S32K3_HSE_DemoExamples\Secure_Boot\S32K344_Basic_SecureBoot\
from:
https://www.nxp.com/webapp/Download?colCode=S32K3_HSE_DemoExamples
It's minimalist example which shows the right procedure. Just notice that BOOT_SEQ is not programmed for some reasons at the end, it's up to user to modify the BOOT_SEQ at the end. And once the BOOT_SEQ is '1', be aware that application is started after next reset after verification. The configuration project won't be started anymore unless you modify BOOT_SEQ back to zero. You can try to run original example and test how it works.
So, if you want to use basic secure boot mode, it makes sense to protect bootloader only, not the application. And then bootloader should verify the application. Personally, I would use advanced secure boot mode for this.
Regards,
Lukas
Dear Lukas.
Thank u for your answer.
I am trying to understand what you are talking about.
I am trying to implement basic secure boot to protect only the bootloader.
Question)
When our configuration have two part( bootloader(int_flash) + application),
When the image sign & verification is completed in the bootloader and BOOT_SEQ is set to 1,
After reset, the only application can be executed by the application's ivt.
Is that right?
Let me try to explain: If you take a look at S32K344_Basic_SecureBoot example, it's just configuration project. It's not bootloader, it's not application, it's just configuration project. It's supposed to be executed only first time. Once BOOT_SEQ is set, this project is never executed again.
S32K344_SecureBootBlinky is protected application. If you take a look at its linker file, it starts at 0x005040C0:
There's app boot header at this address:
And then there's the application - correctly aligned as mentioned in my last post.
Small difference (I was wrong in my previous post) - BOOT_SEQ is already set in boot header in S32K344_Basic_SecureBoot project:
So, you can simply load the project by debugger, debugger will manually set the program counter to entry point, secure boot is configured and, because BOOT_SEQ is already set, secure boot is active after first reset. Then the S32K344_SecureBootBlinky is started.
But you can reprogram the BOOT_SEQ by your software once the configuration is completed. It's up to you.
To implement this approach to your use-case, you should have configuration project like S32K344_Basic_SecureBoot, then you should have your bootloader which will be protected by basic secure boot (this is equal to S32K344_SecureBootBlinky) and then you should have your application.
How to start application from bootloader: just deinitialize everything and jump to entry point of application. It was discussed here many times, for example here:
https://community.nxp.com/t5/S32K/S32K312-bootloader-jump-to-application-issue/td-p/1795729
Regards,
Lukas