Hi,
I have been using kinetis design tool to debug my code on microcontroller KL04z. Is there a way to run image with starting address at 0x1000 instead of 0x0 in KL04z on PEMicro debugger on KDS.
I have done the followings but in vain:
1. Change the following in MemoryMap-mkl04z32m4.ld to
rom (rx) : ORIGIN = 0x1000, LENGTH = 0x7000
2. build the image
3a. On KDS, run PEMicro debugger => Not work. Stuck at 0xfffffffe
3b. On KDS, run PEMicro debugger, on runtime options setting PC to 0x1000 => not work. Stuck at 0xfffffffe.
Please see attached result.
Thanks a lot.
With regards,
Mario
已解决! 转到解答。
Hello Mario:
I had no problems to debug from 0x1000 offset. Your description however mentions a section with name rom in the linker file. Is this an example project taken from some place? or did you create that project with KDS new project wizard?
For your reference I attach to this response the project I created moving code to 0x1000 address.
About the Flash Configuration Field, such information can be found in the Reference Manual in chapter 27.3.1 Flash Configuration Field Description and throughout other sections of the manual regarding security and booting options. You can also refer to AN4507 and AN4835.
Regards!,
Jorge Gonzalez
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Mario,
Do you have a bootloader or other application to run at address 0x0?
Kinetis by default has the interrupt vector table at address 0x0 on Power On Reset (POR).
The address 0x00000000 has the stack address. Initial Stack address points to internal SRAM (volatile memory).
The address 0x00000004 has the PC (Program Counter) address. Initial PC points to flash (nonvolatile code) memory.
Also at address 0x400-0x410 are flash configuration fields that upon POR are read to determine the system permissions, security, boot methods, etc... If these fields are not programmed correctly the device can be "bricked" (i.e. made inaccessible and must be replaced). The most important field is the FSEC[SEC] field that should be binary 10 to keep the device in unsecure state to allow the debugger interface to operate.
In summary, code doesn't start at address 0x0. That space is part of the vector table and the vector table addresses 0x0 and 0x4 have the stack and PC addresses that are fetched by the core on POR/reset to know where to start executing code.
Hope this helps.
Regards,
David
Hi David,
Thanks for your reply. I did not have a bootloader to run at address 0x0. I thought that PEMicro Multilink FX debugger could force KL04 to start from 0x1000 by setting start PC at 0x1000.
Previously, when using FRDM-KL05z as usbdm debugger, the image could run properly from 0x1000 even without bootloader at 0x0:
So, I thought I could do the same on PEMicro Multilink FX debugger. Probably, I am wrong.
BTW, I am new to KL04z. Where could I find the following information (such as application note) besides KL04 reference manual
"Also at address 0x400-0x410 are flash configuration fields that upon POR are read to determine the system permissions, security, boot methods, etc... If these fields are not programmed correctly the device can be "bricked" (i.e. made inaccessible and must be replaced). The most important field is the FSEC[SEC] field that should be binary 10 to keep the device in unsecure state to allow the debugger interface to operate."
Thank you so much
With regards,
Mario
Hello Mario:
I had no problems to debug from 0x1000 offset. Your description however mentions a section with name rom in the linker file. Is this an example project taken from some place? or did you create that project with KDS new project wizard?
For your reference I attach to this response the project I created moving code to 0x1000 address.
About the Flash Configuration Field, such information can be found in the Reference Manual in chapter 27.3.1 Flash Configuration Field Description and throughout other sections of the manual regarding security and booting options. You can also refer to AN4507 and AN4835.
Regards!,
Jorge Gonzalez
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Jorge,
I do not find the attachment in your reply. Where can I get it? I am running into a similar issue where I want to debug code starting at 0x4000 instead of 0x0000 using PE Micro Universal Debugger. I am using a Kinetis K20 series of microcontroller.
Thanks and regards,
Suman
Hi Jorge,
Sorry for delay. I have been pulled off to work on something else.
I have just tested your project. It works.
My project was created using USBDM tab on KDS. The structure as well as startup code in my usbdm-created project is quite different from yours.
Finally, the memory map is defined in ..\Project_Settings\Linker_Files\MemoryMap-mkl05z32m4.ld
The original setting is
MKL05Z32M4
*/
MEMORY
{
ram (rwx) : ORIGIN = 0x1FFFFC00, LENGTH = 0x00001000
rom (rx) : ORIGIN = 0x00000000, LENGTH = 0x00008000
io (rwx) : ORIGIN = 0x40000000, LENGTH = 0x00080000
io_1 (rwx) : ORIGIN = 0x400FF000, LENGTH = 0x00001000
io_2 (rwx) : ORIGIN = 0x44000000, LENGTH = 0x1C000000
io_3 (rwx) : ORIGIN = 0xE0000000, LENGTH = 0x00100000
io_4 (rwx) : ORIGIN = 0xF0000000, LENGTH = 0x00001000
io_5 (rwx) : ORIGIN = 0xF0001000, LENGTH = 0x00001000
io_6 (rwx) : ORIGIN = 0xF0002000, LENGTH = 0x00001000
io_7 (rwx) : ORIGIN = 0xF0003000, LENGTH = 0x00001000
io_8 (rwx) : ORIGIN = 0xF8000000, LENGTH = 0x08000000
};
I have modified it into
MKL05Z32M4
*/
MEMORY
{
ram (rwx) : ORIGIN = 0x1FFFFC00, LENGTH = 0x00001000
rom (rx) : ORIGIN = 0x00001000, LENGTH = 0x00007000 <= change
io (rwx) : ORIGIN = 0x40000000, LENGTH = 0x00080000
io_1 (rwx) : ORIGIN = 0x400FF000, LENGTH = 0x00001000
io_2 (rwx) : ORIGIN = 0x44000000, LENGTH = 0x1C000000
io_3 (rwx) : ORIGIN = 0xE0000000, LENGTH = 0x00100000
io_4 (rwx) : ORIGIN = 0xF0000000, LENGTH = 0x00001000
io_5 (rwx) : ORIGIN = 0xF0001000, LENGTH = 0x00001000
io_6 (rwx) : ORIGIN = 0xF0002000, LENGTH = 0x00001000
io_7 (rwx) : ORIGIN = 0xF0003000, LENGTH = 0x00001000
io_8 (rwx) : ORIGIN = 0xF8000000, LENGTH = 0x08000000
};
With regards
Mario