Wednesday, December 13th 2017, 9:38pm UTC+1

You are not logged in.

  • Login
  • Register

Dear visitor, welcome to SEGGER Forum. If this is your first visit here, please read the Help. It explains how this page works. You must be registered before you can use all the page's features. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

apullin

Beginner

Date of registration: Mar 31st 2010

Posts: 13

1

Sunday, September 10th 2017, 7:35pm

[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/C++ Source code

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


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

C/C++ Source code

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


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?

SEGGER - Nino

Super Moderator

Date of registration: Jan 2nd 2017

Posts: 454

2

Monday, September 11th 2017, 12:00pm

Hello Andrew,

Thank you for your inquiry.
The correct sequence would be to first load and execute the bootloader image.

Quoted

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:

Quoted

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

apullin

Beginner

Date of registration: Mar 31st 2010

Posts: 13

3

Tuesday, September 12th 2017, 7:48pm

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.

SEGGER - Nino

Super Moderator

Date of registration: Jan 2nd 2017

Posts: 454

4

Wednesday, September 13th 2017, 8:53am

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

apullin

Beginner

Date of registration: Mar 31st 2010

Posts: 13

5

Wednesday, September 13th 2017, 8:20pm

Yeah, that is an OK option.
There are occasional changes to the NVM that have to be reflashed ...

This seems to work, though:

C/C++ Source code

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



C/C++ Source code

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



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.

This post has been edited 1 times, last edit by "apullin" (Sep 13th 2017, 8:23pm)


SEGGER - Nino

Super Moderator

Date of registration: Jan 2nd 2017

Posts: 454

6

Thursday, September 14th 2017, 11:48am

Hello Andrew,

Quoted


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