[SOLVED] Ozone, correct way to do multi-image project?

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • [SOLVED] Ozone, correct way to do multi-image project?

    I tried to follow the example given in the Ozone user manual for setting up a multi-image download, but I am having some problems.
    The project consists of 3 ELF files: bootloader, flash area used as NVM, and then the main program. I have all 3 as both elf and bin files.

    The main program elf is selected as the elf file to load in the new project creator.
    Following "6.2.3.1 Writing a Multi-Image Download Routine" in the manual, I added the section to my project file:

    C Source Code

    1. void TargetDownload (void) {
    2. Util.Log("Downloading Program.");
    3. /* 1. Download the application program */
    4. Debug.Download();
    5. /* 2. Download the additional program image */
    6. Target.LoadMemory("bootloader.bin", 0x08000000);
    7. Target.LoadMemory("NVM.bin",0x08004000);
    8. }


    And the auto-created project already has this in place:

    C Source Code

    1. void OnProjectLoad (void) {
    2. //
    3. // Dialog-generated settings
    4. // ... chip settings here, omitted
    5. // User settings
    6. File.Open ("main_program.elf");
    7. }


    However, with that setup, Ozone appears to recursively call the TargetDownload() function!
    The console shows: "Error executing script function "TargetDownload": maximum call level reached."

    If I remove the Debug.Download() from the TargetDownload() implementation, then it seems that the main program ELF is not loaded.
    What is the right way to set this up?
  • Hello Andrew,

    Thank you for your inquiry.
    The correct sequence would be to first load and execute the bootloader image.
    void OnProjectLoad (void) {
    [...]
    File.Open ("bootloader.elf");
    }

    Then after bootloader has executed load the main image with File.Load and any additional images with Target.LoadMemory.
    After that you need to set the correct PC and SP values.
    Example:
    void AfterTargetHalt() {

    unsigned int PC;
    unsigned int SP;

    PC = Target.GetReg("PC");

    if (PC == <BOOTLOADER_END_PC>) {

    Target.LoadMemory("NVM.bin",<NVM_BASE_ADDR>);
    File.Load("main_image.elf", "");

    PC = <MAIN_IMAGE_ENTRY_PC>;
    SP = <MAIN_IMAGE_ENTRY_SP>;

    Target.SetReg("PC", PC);
    Target.SetReg("SP", SP);
    }
    }


    Currently the ozone manual is a bit unclear in that matter so the descriptions will be extended in future iterations.

    Best regards,
    Nino
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Interesting ... that's a little more complicated than I thought.

    The intent really was just to, on connect: loader bootloader & NVM bin's, then reset the chip and run as normal.
    I even have an ELF for the bootloader, although I expect to never do any debugging inside it.
  • Hello Andrew,

    If you only want to debug your "main" application you can use our Software J-Flash to flash the bootloader and NVM bins and then simply debug the mainapp.elf in Ozone.
    Would that be a option for you?

    Best regards,
    Nino
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Yeah, that is an OK option.
    There are occasional changes to the NVM that have to be reflashed ...

    This seems to work, though:

    C Source Code

    1. void AfterTargetConnect (void) {
    2. Target.LoadMemory("bootloader.bin",0x08000000);
    3. Target.LoadMemory("NVM.bin",0x08004000);
    4. }



    C Source Code

    1. void OnProjectLoad (void) {
    2. //
    3. // ...
    4. //
    5. // User settings
    6. File.Open ("main.elf");
    7. }



    so then the NVM/bootloader loads will be trivial loads (only change if needed), and then the device will reset and run as normal? Understanding that you need to disconnect and reconnect to reflect any changes into the flash.

    The post was edited 1 time, last by apullin ().

  • Hello Andrew,


    so then the NVM/bootloader loads will be trivial loads (only change if needed), and then the device will reset and run as normal? Understanding that you need to disconnect and reconnect to reflect any changes into the flash.


    The way you use it is also an alternative option.
    More information about these functions can be found in the Ozone user manual (simply press F1 while Ozone is open) in section 6.1.

    Best regards,
    Nino
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.