A core-dump implementation for PIC18 devices with on-chip Ethernet controller

by Isaac Marino Bavaresco

These routines are an useful tool for debugging complex systems based on Microchip's Ethernet-enabled PIC18 micro-controllers.

They take advantage of the large Ethernet packet buffer to save all the registers, hardware stack and RAM, immediately after an abnormal reset, before they get corrupted by the firmware.

NOTE: In the given sample the core-dump is saved to a file in a file-system. If your board doesn't have a file system, it would be possible to transmit the core-dump by any available interface (serial, for instance) even by the Ehternet controller if you are careful enough for not corrupting the core-dump image in the Ethernet packet buffer.

In the C library startup file (one of the following, depending on your configuration: c018_e.c, c018i_e.c or c018iz_e.c), replace the sequence:

"
...
#pragma code _entry_scn=0x000000
void
_entry (void)
{
_asm goto _startup _endasm}
...
"
With:
"
...
extern void __init0 (void);
#pragma code _entry_scn=0x000000
void
_entry (void)
{
_asm goto __init0 _endasm}
...
"

Probably you will need to add explicitly a linker-script file to your project, and comment the reference to the original "C018*.c".

Code: