Hello,
I am using the MC9S12XDT256 microcontroller.
I am trying to develop bootloader software. The program structure is designed to receive S-record type data via CAN and write it to the appropriate addresses in the flash memory.
The program flow should be as follows:
1- The bootloader software will run and check for an update request.
1.1- If there is an update request, the bootloader software will update the application software.
1.2- If there is no update request, the application software will be executed.
2-The system must be restarted and should operate with the existing application software.
I use "asm JMP 0xC000" to switch from the bootloader software to the application software. (0xC000 is the address of the _Startup function in the application software.)
When I merge the bootloader and application software and program them using Cyclone, the program works without any issues. Similarly, when I reload the same application software using the bootloader program, it also works fine.
However, when I make a small change in the application software and try to load it via the bootloader, the application software does not work. The program goes to the _Startup function of the new application software but fails to proceed to the main function. During debugging, I noticed that it enters the _Startup function but cannot proceed beyond the Init() function within _Startup.
Could you please help me? Thank you!
Hi,
"1)Registers should be in their reset state because I power-cycle the system to restart it."
- Yes, but when do you jump to the application? Directly after the reset before initialization made by bootloader? Or do you jump to the application somewhere from main function of the bootloader? In second case, you need to deinitialize all the resources which have been initialized by the bootloader. Especially it's necessary to disable interrupts on all levels.
Best regards,
Ladislav
Hi,
There is an AN4258 that can be used as a development platform. It uses UART, but the principle is the same.
Possible problems I see:
1) It is important that all registers are in a reset state when you go into the application. Any remaining settings from the previous process can affect the execution of the application code.
2) It would be a good idea to dump the code and check that everything is loaded in the correct address space.
AN4258: Serial Bootloader for S12(X) Microcontrollers Based on 180 nm Technology – Application Note
https://www.nxp.com/docs/en/application-note-software/AN4258SW.zip
Best regards,
Ladislav
Thank you for your response.
1)Registers should be in their reset state because I power-cycle the system to restart it.
2)I have checked the flash addresses, and the written data seems to match the S-record data.
I still haven’t resolved the issue. Do you have any other suggestions?
Best regards.
I tested with a simpler application code and did not encounter the previous issue. In the test application, I toggle the state of a single LED. In the version loaded via the bootloader, I toggle the states of two LEDs. Both scenarios work without any problems.
Compared to the test code, the application code where I encountered the problem includes:
-Timer interrupts
-CAN interrupts
-XGATE usage
I suspect that these factors might be triggering the issue. Could the problem be related to these interrupts or the XGATE usage? Has anyone experienced a similar situation?