cancel
Showing results for 
Search instead for 
Did you mean: 

Porting mcuboot to stm32 image unset?

suads
Associate III

Hi I have ported mcuboot to stm32 without os, following the https://interrupt.memfault.com/blog/mcuboot-overview. But I'm having problems and some things are not clear to me, hope someone can help me.
By following the guide I implemented everything, added the internal flash read/write erase functionality. Configured the Application size and start addresses

size.png

Used the command to create boot.bin and upload it to 0x8000000:

 

arm-none-eabi-objcopy build/stm32g4.elf stm32g4-app-no-header.bin -O binary && python mcuboot/scripts/imgtool.py sign --header-size 0x200 --align 4 --slot-size 0xa000 --version 1.0.0 --key mcuboot/root-rsa-2048.pem --pad-header stm32g4-app-no-header.bin boot.bin

 

Used the command to create app1.bin and upload it to 0x800a000:

arm-none-eabi-objcopy build/stm32g4.elf stm32g4-app-no-header.bin -O binary && python mcuboot/scripts/imgtool.py sign --header-size 0x200 --align 4 --slot-size 0xa000 --version 3.0.0 --key mcuboot/root-rsa-2048.pem --pad-header stm32g4-app-no-header.bin app1.bin.

And also for app2 on address 0x8014000, and uploaded the .bin files on the using Stm32cubeprogrammer.

Using semi hosting and  openocd for debugging I get this output:

bootloader2.png

I ' m not sure if I done everything correctly ! I think Something is wrong with the image and header of the file, that I create with the previous commands?

And also there are some question I want to ask:

Must be the linker script(.ld) and startup script (.s) changed, or will this mcuboot handle this?, and what about the stm32 boot pins?

1 REPLY 1
VladP
Associate

Do you have any progress on this ? I have a similar STM32 board, and I don`t want to use Zephyr or any other OS. MCUBoot would need the implementation for the flash read/write as well as a crypto library.

Can you share the code implementation for :

/*< Opens the area for use. id is one of the `fa_id`s */
int     flash_area_open(uint8_t id, const struct flash_area **);
void    flash_area_close(const struct flash_area *);
/*< Reads `len` bytes of flash memory at `off` to the buffer at `dst` */
int     flash_area_read(const struct flash_area *, uint32_t off, void *dst,
                     uint32_t len);
/*< Writes `len` bytes of flash memory at `off` from the buffer at `src` */
int     flash_area_write(const struct flash_area *, uint32_t off,
                     const void *src, uint32_t len);
/*< Erases `len` bytes of flash memory at `off` */
int     flash_area_erase(const struct flash_area *, uint32_t off, uint32_t len);
/*< Returns this `flash_area`s alignment */
uint8_t flash_area_align(const struct flash_area *);
/*< What is value is read from erased flash bytes. */
uint8_t flash_area_erased_val(const struct flash_area *);
/*< Given flash area ID, return info about sectors within the area. */
int     flash_area_get_sectors(int fa_id, uint32_t *count,
                     struct flash_sector *sectors);
/*< Returns the `fa_id` for slot, where slot is 0 (primary) or 1 (secondary).
    `image_index` (0 or 1) is the index of the image. Image index is
    relevant only when multi-image support support is enabled */
int     flash_area_id_from_multi_image_slot(int image_index, int slot);
/*< Returns the slot (0 for primary or 1 for secondary), for the supplied
    `image_index` and `area_id`. `area_id` is unique and is represented by
    `fa_id` in the `flash_area` struct. */
int     flash_area_id_to_multi_image_slot(int image_index, int area_id);

Thanks