embeddedelfbootloaderzephyr-rtosrenode

Loading two .elf files in Renode (bootloader and application)


I'm trying to simulate a bootloader and an application in Renode. Both are built in separate .elf files, see https://docs.zephyrproject.org/latest/develop/west/sign.html . Can somebody help me writting the correct .resc script? I also swapped the loadELF commands, mentioned in https://github.com/renode/renode/issues/411

My current .resc file only loads the bootloader elf (adding "sysbus LoadELF $ORIGIN/signed_zephyr.elf" doesn´t work):

logFile $ORIGIN/nucleo_f429zi-hello_world-renode.log False
using sysbus
$name?="nucleo_f429zi"
mach create $name

machine LoadPlatformDescription $ORIGIN/nucleo_f429zi-hello_world.repl

showAnalyzer usart3
usart3 RecordToAsciinema $ORIGIN/nucleo_f429zi-hello_world-asciinema

macro reset
"""
    sysbus LoadELF $ORIGIN/mcuboot_zephyr.elf
    cpu0 VectorTableOffset `sysbus GetSymbolAddress "_vector_table"`
    cpu0 EnableProfilerCollapsedStack $ORIGIN/nucleo_f429zi-hello_world-profile true
    sysbus LoadELF $ORIGIN/signed_zephyr.elf
"""

runMacro $reset

Output: Renode Terminal + usart3

I found a similar macro in the demo files but I don´t know how to use it for my case:

macro reset  
"""
    # Set the WAIT_FOR_JTAG GPIO pin. The bootloader stalls if it's set to low.
    gpio OnGPIO 15 true

    # Load the bootloader. The address has to be specified as the binary files do not contain
    # any addressing information.
    sysbus LoadELF $boot 0xffffe000

    # The ELF files already contain information on where to load each part. They also provide symbols, which
    # can be used for execution tracing.
    sysbus LoadELF $bin

    # By default, the initial PC is set to the ELF entry point. Since the bootloader has to be started before the target application,
    # the PC needs to be set manually to the correct value.
    sysbus.cpu PC 0xfffffff0
"""

runMacro $reset

Solution

  • You might want to reverse the order of loading the elf files, i.e. load the app first, then the bootloader, or your stuff will start at the wrong address / the vector table address "guessed" by Renode will be wrong.

    I opened an issue about that in Renode's github, where it was confirmed that what I stumbled upon was right & they added this to their documentation (alas he does not link to it there):

    When loading more than one .elf file ...

    Quoting from there:

    I notice that if, in my .resc file, I load my bootloader ELF first, then the app ELF with sysbus LoadELF, the settings for that seem to be overwritten by the last load, and it guesses the VTOR of the app - so I swapped the order of ELF loading in my .resc script and it guesses the bootloader one, which needs to start.