I am making a USB bootloader. The goal is to stream a SB21 file via USB in 512Byte chunks and stream them to the Bootloader API. But when I stream the SB file, only the ERASE section works, no data in the load section actually gets loaded into flash. I know the SB file is good because I can send the same SB file via blhost directly to the bootloader and it works. Attached to this forum post is my C source code that streams the data to the boot ROM. Is there anything incorrect that might help solve this issue?
My bootloader code uses the NXP kb_init, kb_deinit and kb_execute API to stream a SB file.
My sb21 config yaml:
# Description: Secure Binary v2.1 section blocks
sections:
# --------------------------------------===== SB2.1 Commands [Optional] =====---------------------------------------
# Description: Secure Binary v2.1 commands block, list of all possible options - Modify it according to your
# application
- commands:
# Erase Application space. Keep bottom reserved area for persistent data
- erase:
address: 0x10000
length: 0x6BC00
mem_opt: 0
flags: 0
# Load the signed application MBI to flash
- load:
address: 0x10000
load_opt: 0
# File path is replaced with the generated device-specific MBI.
file: C:\code\Application_SECURE_MBI.bin
Notes:
1. I am able to use blhost to send the same exact SB21 file to the Boot ROM and everything works. So I know the SBI is good
2. When I use my bootloader to stream the SB21 file, it does the erase section command, but the load section of the MBI file seems to fail, but I get no error code at all from kb_execute or the init/deinit calls. They all say success.
3. the final SB21 file is 155,568 Bytes total. I am able to stream every byte to the bootloader, all with status_t = 0x00 as a result.
4. My CMPA has SECURE_BOOT disabled, SWD access is enabled, CMPA is not sealed. CFPA also have everything enabled and open. ISP is enabled