MCUBoot: adding custom serial flash driver as secondary partition

We use spi flash with custom driver and goal is to set it to act as secondary partition for MCUBoot.

The question is how to adapt driver to be accepted by MCUBoot, maybe there is an example on how driver should look like?

As far as I understand Nordic supports mx25r64, what files have to be produced and where to place them to enable custom driver to be accepted by MCUBoot?

Parents Reply Children
  • Is it possible to run debugger in bootloader (using VS Code) ?

    I managed to build the project, however get the following error from the bootloader:

    *** Booting Zephyr OS build v2.7.0-ncs1  ***
    00> I: Starting bootloader
    00> W: Failed reading sectors; BOOT_MAX_IMG_SECTORS=128 - too small?
    00> E: ***** MPU FAULT *****
    00> E:   Instruction Access Violation
    00> E: r0/a1:  0x00000000  r1/a2:  0x00000000  r2/a3:  0x20000284
    00> E: r3/a4:  0x00000020 r12/ip:  0xe6f7fbb5 r14/lr:  0x00000e4f
    00> E:  xpsr:  0x61000000
    00> E: Faulting instruction address (r15/pc): 0xe6f7fbb4
    00> E: >>> ZEPHYR FATAL ERROR 0: CPU exception on CPU 0
    00> E: Current thread: 0x20000128 (unknown)
    00> E: Resetting system

    And this is my pm_static.yml:

    external_flash:
      address: 0x0
      region: external_flash
      size: 0x800000
    app:
      address: 0xc200
      end_address: 0x6DC80
      region: flash_primary
      size: 0x61A80
    mcuboot:
      address: 0x0
      end_address: 0xc000
      placement:
        before:
        - mcuboot_primary
      region: flash_primary
      size: 0xc000
    mcuboot_pad:
      address: 0xc000
      end_address: 0xc200
      placement:
        align:
          start: 0x1000
        before:
        - mcuboot_primary_app
      region: flash_primary
      size: 0x200
    mcuboot_primary:
      address: 0xc000
      end_address: 0x6DC80
      orig_span: &id001
      - mcuboot_pad
      - app
      region: flash_primary
      sharers: 0x1
      size: 0x6DE80
      span: *id001
    mcuboot_primary_app:
      address: 0xc200
      end_address: 0x6DC80
      orig_span: &id002
      - app
      region: flash_primary
      size: 0x61A80
      span: *id002
    mcuboot_secondary:
      address: 0x0
      device: at25xe081
      end_address: 0x6DE80
      region: external_flash
      size: 0x6DE80
    settings_storage:
      address: 0x7e000
      end_address: 0x80000
      placement:
        before:
        - end
      region: flash_primary
      size: 0x2000
    sram_primary:
      address: 0x20000000
      end_address: 0x20010000
      region: sram_primary
      size: 0x10000

  • I just talked to a colleague familiar with this stuff, and asked if at25xe081 was supported by the spi_nor driver. He said as far as he knew, most of the NOR chips should be supported by the spi_nor driver, and most of the commands from the data sheets seems to be generic, so it should not be a problem as far as he knew.

    To get more details, and a more certain answer, try to ask the Zephyr experts on Zephyr Discord, if at25xe081 is supported by the spi_nor driver (Maybe add a link to the data sheet). If that is the case, you may save a lot of time.

    Best regards,

    Simon

  • Thank you for information, Simon.

    Maybe you can also provide a hint on how to debug the bootloader?

  • mesh777 said:
    Maybe you can also provide a hint on how to debug the bootloader?

    Ah, yes. Of course. If you debug through VS Code GDB it should be quite straightforward. See the following video: https://youtu.be/MGsZJpdLtco?list=PLx_tBuQ_KSqEt7NK-H7Lu78lT2OijwIMl&t=30 

    Then set a break point in <ncs location>/bootloader/mcuboot/boot/zephyr/main.c-->main() and you can start to debug.

    Let me know if you don't get it to work.

  • I use VS Code and GDB.

    Can you share working launch.json, as I am not able to manage to reach that breakpoint.

    EDIT: I enabled debugging by unchecking Debug Options in build configuration.

    Now I have problem with device_get_binding, it returns Null for my driver. Although MCUBoot uses the same dts file when building. What else could be possibly wrong?

Related