How to load code to HC12 RAM with gdb?

Marek Peca marek@tynska.cuni.cz
Fri May 14 12:23:00 GMT 2004


Hello,

I'm trying to get some very primitive code run in MC912D60A MCU. I
tried to load it either to external RAM or internal 2K RAM using gdb
and target bdm12 and haven't succeeded.

Gdb gives me an error "Memory access error while loading section
.text.", but when I tell in command 'target bdm12', that FLASH is in
target location (see below), gdb tries to upload the code. Also if I
try to load it in other RAM location, eg. 0x0 or some other low
address, it proceeds.

However, the code cannot be run.

Please, can anybody tell me, where I am doing bad?
Is target bdm12 able to running a code from RAM?

Regards, Marek P.

------

One of my memory.x files I used is:
MEMORY
{
    page0 (rwx) : ORIGIN = 0x0, LENGTH = 256
    text  (rwx) : ORIGIN = 0x00200, LENGTH = 0x0300
    data        : ORIGIN = 0x00500, LENGTH = 0x0300
    eeprom      : ORIGIN = 0xb600, LENGTH = 512
}
PROVIDE (_stack = 0x0500 + 0x0300 - 1);
/*
after some experiments I also added
SECTIONS {
  .text : { *(.text) } >text
  .data : { *(.data) } >data
  .bss :  { *(.bss)  *(COMMON) } >data
}*/

I'm compiling using
 m68hc12-gcc -g -Wl,-m,m68hc12elfb -o neco.exe neco.c
and running
 m68hc11-elf-gdb neco.exe
commands:
(gdb) target bdm12 ttyS1 8 0x0 0x800 0xd00 0x8000
Connected to the bdm12 interface.
(gdb) load neco.exe
Loading section .text, size 0xc7 lma 0x200
Memory access error while loading section .text.
(gdb) target bdm12 ttyS1 8 0x0 0x800 0xd00 0x0  
Connected to the bdm12 interface.
(gdb) load neco.exe
Loading section .text, size 0xc7 lma 0x200
Unable to erase flash
(gdb) load neco.o 0x1ff
Loading section .text, size 0x5e lma 0x1ff
Start address 0x0, load size 94
Transfer rate: 752 bits/sec, 94 bytes/write.

neco.c is here:
main() {
  unsigned short pole[256];
  int sragor;

  for (;;) {
    for (sragor = 0; sragor < 256; sragor++)
      pole[sragor]++;
  }
}



More information about the Gdb mailing list