Hello, I have a question on how the code downloading works on LPC1820 (a flashless part). In my configuration, I used a 512KB external boot prom to host the firmware for this processor, and I am using Keil IDE to debug it. My question is where on the processor my code gets downloaded to when I debug it? Usually the code will be downloaded to the internal flash of the MCU and MCU resets after the download to execute the code from the flash, since LPC1820 has no internal flash, where doe my code go and how its debugging work??
My speculation is that the code is downloaded to SRAM within LPC1820, then the debugger is modifying the shadow register so that the above SRAM can be remapped to the address 0x00000000, can you confirm? How can I read the Shadow register for this purpose?
Thanks
Richard
For a debug session this means the following:
Concretely for the LPC1820 this means, that you create a program which is linked to the SPIFI memory region, you program it into the flash (or call it downloading into flash) and then you start the debugger.
Alternatively you can also create a program linked to the internal SRAM region and start the debugger. The debugger downloads the binary part of the ELF file into the SRAM (no need to read it back) and then you can debug.
A "bare metal debug session" would be, if you have code in the flash which the debugger doesn't know, so it does not have the relation to an ELF file with its debug information. Then you just start the debugger without loading such an ELF file into the debugger and you set the program counter to the beginning of this flash image. The debugger will read the binary image from the flash memory, disassembles it and then you can make steps in the code, but just on assembler level and without any support through debug symbols.
You can do this for example for the ROM code inside the LPC1820 (Boot ROM), where you don't have source code and also no ELF file.
Maybe the above described steps vary in one or the other area depending on the debugger implementation, but in principle this is the flow. Hope this help a little bit.
Regards,
Bernhard.
Bernhard, thanks for the great insights on how downloading and debugging work, which is very helpful. One more step though, for LPC1820 (which is a flashless part), will my binary gets downloaded to SRAM within the MCI?
Thanks
Richard
When you have an external ROM (Quad SPI flash or parallel NOR flash) with your program binary in it and you debug this code, then nothing gets downloaded to the MCU.
The MCU executes the program binary, the debugger software on the PC knows the program binary and its structure, and under control of JTAG these two instances run in parallel.
If you don't have an outside memory, then of course you need to bring your program binary into the internal SRAM. And then it's just the same as it would be in another memory, it is simply there, available for the ARM for execution.
Regards,
Bernhard.
Thank you Bernhard for the great information! I do have an external QSPI flash on my target board, however it contains a different image from what to be debugged, will the new image be downloaded to SRAM in that case? Will the debugger detect that the image in external QSPI flash is different so it won't use it?
PS: Can you please point me to some reading/links on how Debugger works internally?
Thanks again,
Richard
Hello Richard CHEN,
You can use external flash through SPIFI, there is software driver library support under LPCopen.
About detail please refer to User Manual->Chapter 21: LPC18xx SPI Flash Interface (SPIFI).
It support execute-in-place (direct code execution from the SPI Flash memory) and
general read/write/erase operations.
There is a SPIFI introduction: LPC key feature_SPIFI
Have a great day,
TIC
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------
Thanks Alice, what I try to understand is where my code is downloaded to with MCU during debugging process.
Richard