Debugging code starting at 0xC000

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Debugging code starting at 0xC000

Jump to solution
1,399 Views
Teckna
Contributor V

Hi all,

I'm using CW 10.2, MQX 3.8.1 and Kinetis K60 target.


I placed my code at address 0xC000 but i am not able to debug it.

When i try to debug my code, CW makes code downloading accurately but entry point is not my main but 0xfffffffe.


This is my memory layout in linker file:


MEMORY

{

   vectorrom   (RX): ORIGIN = 0x0000C000, LENGTH = 0x00000400

   cfmprotrom  (R): ORIGIN = 0x0000C400, LENGTH = 0x00000020

   rom         (RX): ORIGIN = 0x0000C420, LENGTH = 0x00073BE0  # Code + Const data 

   ram         (RW): ORIGIN = 0x1FFF0000,LENGTH =  0x00020000  # SRAM - RW data

   # kernel space starts after RAM variables (Location of MQX Kernel data + MQX heap)

   end_of_kd   (RW): ORIGIN = 0x2000FFF0, LENGTH = 0x00000000

 

   # Boot stack reused by MQX Kernel data

   bstack      (RW): ORIGIN = 0x2000FA00, LENGTH = 0x00000200  # Boot stack

   end_bstack  (RW): ORIGIN = 0x2000FBFF, LENGTH = 0x00000000

   # extdatavar  (RW): ORIGIN = 0x60000000, LENGTH = 0x0005C000  # external SRAM - RW data

   exttpnvar   (RW): ORIGIN = 0x6005C000, LENGTH = 0x00004000  # external SRAM - RW data

   extramdisk  (RW): ORIGIN = 0x60060000, LENGTH = 0x00020000  # external SRAM - RW data

}

Can you help me?

1 Solution
750 Views
ndavies
Contributor V

Also if you are using a bootloader, you will need to tell CW not to overwrite the bootloader when you load your app into memory using the debugger. There is a comment on here somewhere that explains how to do that.

View solution in original post

0 Kudos
5 Replies
750 Views
ndavies
Contributor V

Do you have a valid start address loaded in memory location 0x04? When the ARM core starts it loads the initial stack pointer from address 0x0000 and the initial program counter from address 0x0004.

Since you want to start from address 0xc000, I'm assuming you are using a bootloader. The bootloader usually has its interupt vector table starting at location 0x0000 filling the need to have the stack pointer and program counter loaded from address 0x0000 on startup. After the bootloader is finished doing it's work, it would then load in the starting address of your app into the program counter.

Do you have your bootloader loaded into memory? You'll either need the bootloader loaded or the stack and intial program counter addresses loaded into addresses 0x0000 and 0x0004 respectively.

0 Kudos
750 Views
Teckna
Contributor V

Hi Norm,

what you say is correct but is not my problem.

When i use bootloader placed at 0x0000 and code placed at 0xC000 it works but i'm in real time mode.

My problem is referred to the debug mode by PE-micro Multilink Universal. I am not able to make a debug of my code placed at 0xC000.

I would like to know if there is a debug configuration in CW that emulate a real bootloader and generally if it's possible to make a debug of a code starting at address different from 0x0000.

Regards

0 Kudos
750 Views
ndavies
Contributor V

Sorry, from your description this is your problem. There isn't a bootloader emulator. You need to load the bootloader, load your app. Place a break point at 0xc000. Hit run. Your app will then stop at 0xc000. You can debug from there.

Without the bootloader, the Kinetis core doesn't know where to go to start running the application. It pulls the code start address from the address location 0x0004. If you haven't loaded the bootloader, the data at address 0x0004 will be 0xFFFFFFFF. The kinetis will jump to address 0xFFFFFFFE. (It knows address oxFFFFFFFF is an invalid address from instructions. so it sets the program counter to oxFFFFFFFe.) So you either need to load the bootlaoder or put the data 0x0000C000 at address 0x00000004.

0 Kudos
751 Views
ndavies
Contributor V

Also if you are using a bootloader, you will need to tell CW not to overwrite the bootloader when you load your app into memory using the debugger. There is a comment on here somewhere that explains how to do that.

0 Kudos
750 Views
Teckna
Contributor V

Many Thanks Norm :smileywink:,

my problem was erase of bootloader loading application placed at 0xC000.

In Debug configuration it's possible to preserve a Memory range when you make a memory programming as indicated in next screenshot.

Immagine.png

Regards!