Relative paths in prj.conf (custom bootloader)

I am building an application using VSCode on Windows 11 Pro and I would like to specify a bootloader file (.hex) to be included in the final image generated by the build process.

I do so by giving a value to CONFIG_B0_HEX_FILE in my prj.conf file. My problem is that this only works if I give the absolute path to my bootloader's .hex file. If I try to specify the path in a relative way, it complains that it cannot find the .hex file.

Imagine my application is under "C:\project\ble_firmware", my prj.conf is "C:\project\ble_firmware\prj.conf", and the bootloader is under "C:\project\ble_firmware\bootloader\binary\my_bootloader.hex", then the only way I have found is to use following line in my prj.conf:

CONFIG_B0_HEX_FILE="C:\\project\\ble_firmware\\bootloader\\binary\\my_bootloader.hex"

I would have expected that something like:

CONFIG_B0_HEX_FILE=".\\bootloader\\binary\\my_bootloader.hex"

should also work, but it doesn't. I have tried many different syntaxes and assumed different starting directories for the relative path, but I don't seem to find the proper one. I read on another ticket that the "application directory" should be used a reference instead of the "prj.conf" directory, but I either do not understand what is referred to by "application directory" or it is the same directory where my prj.conf is, so unfortunately that did not help.

Could you please tell me how to specify the relative path?

Many thanks!

Parents
  • Hi,

    The relative path fails due to it being incorrect when running mergehex:

    FileNotFoundError: [Errno 2] No such file or directory: '.\\\\bootloader\\\\binary\\\\my_bootloader.hex'

    One option is to set it in CMakeLists.txt instead. If you do this, you must also set CONFIG_B0_BUILD_STRATEGY_USE_HEX_FILE in CMakeLists.txt, as if not, CONFIG_B0_HEX_FILE will be overwritten with an empty path. This must be set before find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}).

    Here is an example:

    cmake_minimum_required(VERSION 3.20.0)
    
    set(CONFIG_B0_BUILD_STRATEGY_USE_HEX_FILE y)
    set(CONFIG_B0_HEX_FILE ${CMAKE_CURRENT_SOURCE_DIR}/bootloader/binary/my_bootloader.hex)
    
    find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
    project(hello_world)
    
    target_sources(app PRIVATE src/main.c)
    

    Best regards,
    Marte

Reply Children
No Data
Related