Ok,
Why it does not work? Is jumping address 0x00FA4000 wrong? Yes. There is only 005A there, not the programs code.
The Bootloader elf file you have in the pic is the project name. It even says "Project".
That being said...
There is a couple of ways to add the Bootloader to the main project. (Lauterbach, etc..)
Compiling multiple projects in S32DS IDE?
Create a .bin from the bootloader. (Almost the same way you create an .srec, except you create a .bin file) (Search for how to create an Srecord)
Then add the following line(s) to the linker file
MEMORY
{
flash_rchw : org = 0x00FC0000, len = 0x4
cpu0_reset_vec : org = 0x00FC0000+0x10, len = 0x4
cpu2_reset_vec : org = 0x00FC0000+0x04, len = 0x4
m_bootloader : org = 0x00FC8000, len = 0x224K /* Bootloader additions */
m_text : org = 0x01000000, len = 1280K
m_data : org = 0x40000000, len = 192K
}
/* Bootloader additions */
TARGET(binary)
INPUT(Serial_Bootloader.bin)
OUTPUT_FORMAT(default)
SECTIONS
{
/* Bootloader additions */
.my_boot :
{
KEEP(Serial_Bootloader.bin (.data))
} > m_bootloader
Of course you will have to copy the .bin to the Apps debug directory, or optionally add search paths to the project.
That will load both the App and bootloader as 1 project.
Now, you need to change the bootheader Jump address location in the App.
(The app will jump to the Apps code, so you have to change it to jump to the Bootloaders Program code)
const uint32_t __attribute__ ((section(".rchw"))) RCHW1 = RCHW_VAL;
#if defined(MPC574xP) || defined(MPC5777C) || defined(MPC577xK)
const uint32_t __attribute__ ((section(".cpu0_reset_vector"))) RCHW2 = (uint32_t)ENTRY_POINT;
#else
#if defined(TURN_ON_CPU0)
const uint32_t __attribute__ ((section(".cpu0_reset_vector"))) RCHW2_0 = (uint32_t)0xFC8000; <-- Change This To jump to bootloader instead of the App
#endif
Ok, so now the boot header will jump to the Bootloader instead of the App.
Now, you want the bootloader to be able to jump to the App.
I am having a bit of trouble with this. It's where I am currently at.
You can look at the registers to see what's going on.
/*********************************************/
/* Run function at address */
//typedef void func(void);
//func* fnPtr = (func*)0x01000000;
//fnPtr();
/*********************************************/
/* Load Address of Reset Vector (Directly) */
__asm__(" e_lis %r3, 0x0100");
__asm__(" e_ori %r3,%r3,0x0000");
__asm__(" se_mtlr %r3");
__asm__(" se_blr");
/*********************************************/
/* Load Address of Reset Vector (Indirectly)
asm("e_lis %r12,0x00FC");
asm("e_or2i %r12,0x0010");
asm("e_lwz %r0,0(%r12) ");
asm("mtlr %r0");
asm("se_blrl");
*/
The Indirect loads the address at offset 0x10.
The direct loads the address directly.
If you look at the memory, you should see something like the following
**********************************************
FLASH BOOT HEADER
[00FC0000] 005A0002 FFFFFFFF FFFFFFFF FFFFFFFF
[00FC0010] 00FC8000 FFFFFFFF FFFFFFFF FFFFFFFF (Jumps to Bootloader code)
[00FC8000] 709FE405 7080C000 70780520 54640010 (Bootloader code)
[01000000] 709FE405 7080C000 70780520 54640010 (Application code)
**********************************************