2017-03-09 05:30 AM
Hello everyone,
I am working with SPC56EL60L3 and SPC5STUDIO v5.0.
I have two different applications:
- a bootloader application
- the main application
The idea is to have the bootloader application loaded starting from flash sector 0 (flash address 0x00000000) and the main application loaded starting from flash sector 3 (flash address 0x0001C000).
I made some changes to the .ld script to adjust flash settings.
For the bootloader I have:
MEMORY
{ flash : org = 0x00000000, len = 112k ram : org = 0x40000000, len = 128K}I could think of reducing the size...
For the application, I have:
MEMORY
{ flash : org = 0x0001C000, len = 1M - 0x0001C000 ram : org = 0x40000000, len = 128K}I flashed both applications and it looks like the microcontroller starts running the bootloader.
I have the following questions:
- is this procedure right? Just developing two separate applications and flash to different sectors chnaging the linkers script settings?
- how do I do to jump to the main application from the bootloader?
Thank you.
Regards
Alessandro
2017-03-21 01:42 AM
Hi Alessandro,
in attachment you can find 2 test applications (SPC56ELxx_RLA Boot and SPC56ELxx_RLA SERIAL Test Application for DiscoveryPlus) that I have modified in order to show you how to jump from a boot test application (SPC56ELxx_RLA Boot) to a main test application (SPC56ELxx_RLA SERIAL Test Application for DiscoveryPlus). Please, note that these 2 test applications have been developed under SPC5Studio 5.2.3 (at the moment, the last released version) and tested on a Leopard Discovery board (SPC56EL70L5). In the archive file you can also find 2 application.ld files: application_boot.ld and application_serial.ld. Since SPC5Studio regenerate the application.ld files every time you run a code generation, please, make sure to replace the generated application.ld files with the ones present in the archive file before to compile the 2 test applications.
As you can see surfing in the code, the boot test application makes only a jump to a fixed position (0x1C000). Instead, the main test application has to be compiled to start from 0x1C000 and has to contain the interrupt initialization code in order to correctly support the interrupt managment. Please, let me suggest you to program in the core flash memory firstly the main test application and secondly the boot test application (in this way the program counter will be positioned directly at the begin of the boot test application and you can start the execution simply by running the core).Please, feel free to contact me for any other informtation or support.
Best regards,
Luigi
________________ Attachments : SPC5Studio5.2.3_Boot_Example.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HymK&d=%2Fa%2F0X0000000bCL%2FXOUQabnp4B5uTCLm0cuTaq11HiuQg4AM6KWwm7ScQZ0&asPdf=false2017-03-21 05:55 AM
Hi Luigi Zambrano,
I too have similar query.
I am using SPC560B54L5 Discovery Board(768k Flash and 64k RAM) with SPC5studio v5.2.3
I written individual test application for Boot loader and main application. I am trying to use first 2 sectors for Boot loader and from the third sector (0x0000C000) I am trying to load the main application.
I have done the same as your suggestion but still the jump to the main application is not getting branched.I also referred to your test applications but I am not clear with which instruction causes jump from boot loader to main application. Kindly clarify on jump instruction in your code.
I am attaching my test application for your reference.
Looking forward for your valuable guidance,
Thanks in Advance,
Regards,
R.Santhamurthy
________________ Attachments : Bootloader_test.rar : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006Hyll&d=%2Fa%2F0X0000000bCH%2F1.UDqtHbzhzUY3P1UGiHjTCGk_06tfycphDAMRkDK_c&asPdf=false2017-03-21 08:32 AM
Hi R.Santhamurty, the branch is in the file crt0.s of the boot test application
/* Branch to the main application */
e_lis %r3, HI(0x0001C000) e_or2i %r3, LO(0x0001C000) mtctr %r3 se_bctrlRegards,
Luigi
2017-03-21 09:47 AM
Hi R.Santhamurty, in attachment you can find an example with a boot test application (0x00000) that branches to a main test application (0x10000) for Bolero B Discovery (SPC560B54L5) developed under SPC5Studio 5.2.3.
Please, feel free to contact me for any other question or support.
Regards,
Luigi
________________ Attachments : SPC5Studio5.2.3_BoleroB_Boot_Example.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006Hylb&d=%2Fa%2F0X0000000bCG%2F74bcva28FNXyec8xjeGM9KUl3q.jphpbTGR2FrNw67Y&asPdf=false2017-03-21 12:28 PM
Hi Luigi,
thank you for providing an example.
Looking at the code I've seen you changed the crt0.s file adding the following piece of code, before the call to the main function:
/* Branch to the main application */
e_lis %r3, HI(0x0001C000) e_or2i %r3, LO(0x0001C000) mtctr %r3 se_bctrlOk, understood how to do it in assembly.
For my application I need to to the same thing in C. The booloader is launched at microcontroller startup, it needs to do some stuff (listening to the CAN bus for incoming messages, etcc...) and then, once finished, it needs to call the main application (which is flashed starting from 0x00010000).
In other words I need to jump to the application from the bootloader main function.How can I do this in C?Thank you.RegardsAlessandro2017-03-22 03:00 AM
Hi Alessandro,
it is enought to move the branch instructions in the main function. In attachment you can find a new version of the boot test application in which I have moved the branch instrunctions in the main. Please, use with this test application the same application.ld file that I have shared with the old boot test application version.
Regards,
Luigi
________________ Attachments : SPC56ELxx_RLA Boot 2.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006Hxx3&d=%2Fa%2F0X0000000bCI%2FEivdvFl.xZZwlWqaWSIOw.B4TBiqBHkOyCDw_eluHoM&asPdf=false2017-03-24 02:22 AM
Hi Luigi Zambrano,
The attached example for boot loader is working as you explained. However I need to include GPIO and serial output operations in Boot loader section.
I updated the example with all the necessary components but neither the LED nor serial write is getting executed. From the boot loader it directly jumps to main application. Even I tried to increase the Boot loader size and modified the jump address to modified address, but still the issue repeats.
I am attaching the edited projects with this, kindly through it and share your suggestions in resolving the issue explained.
________________ Attachments : SPC5Studio5.2.3_BoleroB_Boot_Example.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006Hyen&d=%2Fa%2F0X0000000bC5%2FyLiiyy4PyzTPEa2fWKYPZBM2pRWORy6.WkxyuB_dbDA&asPdf=false2017-03-24 04:21 AM
Hi R.Santhamurty,
in order to execute some code in the main of the boot test application, obviously you have to move the jump to the main test application in the main of the boot test application. Moreover, before the jump, you have to move the core in DRUN mode because the clocktree init function (that will be re-executed by the main test application) has it as requirement. In attachment you can find the boot test application with the required modifications. Please, note this new boot test application use the same application.ld file that I shared you last time.
Regards,
Luigi ________________ Attachments : SPC560Bxx_RLA Boot 2.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006Hykx&d=%2Fa%2F0X0000000bC3%2FWCSa47jAuP8nCd9L0gFf9fzwvkR3dsoMJCmMQL3VRgE&asPdf=false