2011-06-17 11:50:24     using u-boot for debugging bare metal elf

Document created by Aaronwu Employee on Aug 27, 2013
Version 1Show Document
  • View in full screen mode

2011-06-17 11:50:24     using u-boot for debugging bare metal elf

Prasanth Rajagopal (INDIA)

Message: 101388   


I could run a bare metal elf image via bootelf, but how do I use u-boot for a debugging the same? I could execute bfin-elf-gdb from Eclipse, but I dont know how to have something like a gdbserver on u-boot (doesnt it required a software that talks to gdb commands).






2011-06-17 11:57:17     Re: using u-boot for debugging bare metal elf

Mike Frysinger (UNITED STATES)

Message: 101389   


debugging bare metal generally requires jtag.  gdbproxy provides the stub for you to connect to.


although you might be able to use the kgdb interface with u-boot over the serial port ...




2011-06-17 14:29:11     Re: using u-boot for debugging bare metal elf

Prasanth Rajagopal (INDIA)

Message: 101391   


[ didn't mean to write to wrong forum ]


How exactly do I do that? Did I miss in Docs? They mostly refer to preparing the Linux Kernel for debugging with kgdb. I could find one discussion here.   comments.gmane.org/gmane.linux.hardware.blackfin.u-boot.devel/226


If it is something useful (say, one could debug fully without buying a JTAG) I could put that in ELF Docs with an example...




2011-06-17 14:54:48     Re: using u-boot for debugging bare metal elf

Mike Frysinger (UNITED STATES)

Message: 101392   


yeah, i'm not sure if there are any real docs on using kgdb with u-boot.  yes, it can be pretty confusing if you try searching as the term "kgdb" will come up with the linux-kernel rather than u-boot.  it's basically the same thing ... a remote gdb stub in the system you can connect to over serial.


i think the process is something like:

- connect to u-boot via serial terminal

- type "kgdb" to break in

- disconnect serial terminal

- connect with gdb


i'd have to play with it a bit though to see how it'd actually work, and talk to the guy who did the majority of the work.




2011-06-17 15:05:13     Re: using u-boot for debugging bare metal elf

Prasanth Rajagopal (INDIA)

Message: 101393   




While trying to search similar feature for other products, I can came across the micromonitor boot loader for Blackin itself!

Includes Gdb server for application loads and post-mortem analysis


10.11 GDB Interface

MicroMonitor can be configured with a gdb server running on Ethernet (a preliminary serial interface is also available, but untested as of this writing). The gdb stubs in uMon1.0 allow the user to connect to the target via the gdb command: target remote udp:


It also says in Docs that:


The BF537 port of uMon can be built to run launched by other bootloaders or it can be built to run standalone. There is a procedure included in the BF537 port (refer to that port's makefile) that walks the user through the steps to install uMon over top of u-boot, resident in flash (mode-0 boot),


Wondering if this means I could launch uMon from u-boot, and then in turn I can run gdbserver to debug any elf image via gdb?    Does it make sense to try?




2011-06-17 15:06:55     Re: using u-boot for debugging bare metal elf

Prasanth Rajagopal (INDIA)

Message: 101394   


I found that here:   www.umonfw.com/docs/umon_user_manual.pdf




2011-06-17 15:50:53     Re: using u-boot for debugging bare metal elf

Mike Frysinger (UNITED STATES)

Message: 101395   


it sounds like it could work, but ive never used uMon to be able to say ...


ethernet would certainly be easier than messing with the uart ...




2011-06-20 06:29:38     Re: using u-boot for debugging bare metal elf

Prasanth Rajagopal (INDIA)

Message: 101472   


I could find only BF537 port...


On BF537 Kit, I built uMon, loaded as ELF in to u-boot, commands work like u-boot - all fine till there..but barely any documetation for using gdb - looks like files are missing for gdb, or they never tested for BF537. Have contact mailling list, will update if I find something useful.




2011-06-21 12:19:28     Re: using u-boot for debugging bare metal elf

Mike Frysinger (UNITED STATES)

Message: 101525   


i guess the method for using u-boot isnt as robust yet as it should be.  so the steps would be something like:

- switch to netconsole

   - set ncip to your desktop system

   - run `set stdin nc;set stdout nc`

   - run tools/netconsole in u-boot source to connect

- disconnect serial console

- type `kgdb` into the netconsole

- run gdb

   - `set remotebaud 57600`

   - `target remote /dev/ttyS0`

   - wait for it to connect

   - set some breakpoints

   - type "continue"

- launch your bare metal app

- hit breakpoints with gdb and debug away


i dont think you can break in to the system though (via CTRL+C), so dont bother


there does seem to be some timeouts in the communication between kgdb and gdb that we'll have to look into




2011-06-21 13:12:29     Re: using u-boot for debugging bare metal elf

Prasanth Rajagopal (INDIA)

Message: 101526   


I guess that will require more testing then...?


Past few days I tried my hand on uMon. I can run an ELF app now and return back to the uMon with Ed Sutter's help. The gdb server in uMon helps in static /symbolic debugging that it can talk to gdb for the ELF application that was executed from its command line. Is that possible with u-boot?


Here is what he had to say on my questions:


uMon is in no way being as actively  developed as u-boot is.  The primary reason is that u-boot is closely tied to the linux tree; hence, it inherits features from the linux dev community.  That is somewhat of a goodnews/badnews issue IMHO; but there's not doubt that this linkage has its advantages. I use uMon regularly as a bootloader and as a simple OS for small projects because it just works.  As I need features I add them and make them available for folks to use. I also try to add the "simple" stuff that folks request  just to support it; however, that's as much as I have room for at    this point.  The big need at this point is support for NAND and USB;   neither  of which are trivial.


I have a BF518 eval board under my desk just "waiting" for a port.  With the onslaught of new devices like these and the  ARM-Cortex-M3-ish devices, my plan was to rework uMon to be a very small  footprint bootloader for these types of devices.  This has just not happened because I unfortunately have a day job just like everyone else.


The capability of the gdb server in uMon is to provide basic download and then post-mortem analysis.  There's no support for using gdb as a runtime debugger.


The idea of "post-mortem-analysis" was simply to provide the ability to do similar things that would be done with a unix coredump. Since uMon would typically be "beneath" the application, it would be similar to a unix shell after a core dump.  If there was a crash or exit, the "core" would still be in memory and gdb could be connected to uMon to symbolically look at state (assuming of course that the crash did not corrupt memory).




2011-06-21 14:23:08     Re: using u-boot for debugging bare metal elf

Mike Frysinger (UNITED STATES)

Message: 101528   


symbol management isnt handled by the gdb stub.  it's handled by the gdb client you run on your system.  thus symbolic debugging should work fine with u-boot and kgdb and any other gdb stub.




2011-06-22 11:24:15     Re: using u-boot for debugging bare metal elf

Prasanth Rajagopal (INDIA)

Message: 101570   


I am giving a try with the method you explained:


switch to netconsole

   - set ncip to your desktop system

   - run `set stdin nc;set stdout nc`

   - run tools/netconsole in u-boot source to connect

- disconnect serial console

- type `kgdb` into the netconsole

- run gdb

   - `set remotebaud 57600`

   - `target remote /dev/ttyS0`

   - wait for it to connect

   - set some breakpoints

   - type "continue"

- launch your bare metal app

- hit breakpoints with gdb and debug away


I set the stdio for nc via Cygwin running on Windows. netconsole gets connected with input and output working properly. I disconnected console Putty on WIndows.Then I ran kgdb, but it crashes as below (tried setting kgdboc=ttyBF0,57600n8, but not sure if that made sense). I am using u-boot 2010R1.


bfin> bdinfo

U-Boot      = U-Boot 2010.06 (ADI-2010R1-RC2) (Jun 23 2011 - 00:55:38)

CPU         = bf537-0.2

Board       = bf537-stamp

VCO         =    500 MHz

CCLK        =    500 MHz

SCLK        =    125 MHz

boot_params = 0x00000000

memstart    = 0x00000000

memsize     = 0x04000000

flashstart  = 0x20000000

flashsize   = 0x00400000

flashoffset = 0x00000000

ethaddr     = 32:e1:cf:8e:88:f5

ip_addr     =

baudrate    = 57600 bps

bfin> kgdb

Entering KGDB mode via exception handler...


Ack! Something bad happened to the Blackfin!



SEQSTAT: 00000001  IPEND: 0032  SYSCFG: 3ef8c

  HWERRCAUSE: 0x0: undef

  EXCAUSE   : 0x1: custom exception

RETE: <0xffa11e56> { __etext_l1 + 0x11e2e }

RETN: <0x03f1f240> /* unknown address */

RETX: <0x03f96c4a> { _kgdb_breakpoint + 0xa }

RETS: <0x03f8f406> { _do_kgdb + 0x22 }

RETI: <0x03f800d6> { _start + 0xd6 }

DCPLB_FAULT_ADDR: <0x03f1f23c> /* unknown address */

ICPLB_FAULT_ADDR: <0x03f96c4a> { _kgdb_breakpoint + 0xa }



R0 : 00000000    R1 : 03f1fe78    R2 : 00000000    R3 : 00000000

R4 : 00000000    R5 : 00000000    R6 : 03f1fe78    R7 : 00000000

P0 : ff800085    P1 : 00000428    P2 : 03f22148    P3 : 03f1ff80

P4 : 000003fc    P5 : 03fab200    FP : 03f1f678    SP : ffb00f18

LB0: 03f8142a    LT0: 03f81428    LC0: 00000000

LB1: 03f925b4    LT1: 03f925ae    LC1: 00000000

B0 : 0000001b    L0 : 00000000    M0 : ffffffbc    I0 : 03f1ecee

B1 : 00000000    L1 : 00000000    M1 : 00000000    I1 : 03f1ff80

B2 : 5b559ff7    L2 : 00000000    M2 : ff807ffc    I2 : 00000000

B3 : 4c3dedd3    L3 : 00000000    M3 : 00000000    I3 : 03f9d264

A0.w: 03200000   A0.x: 00000000   A1.w: 00002b53   A1.x: 00000000

USP : ff804414  ASTAT: 00000000


Hardware Trace:

   0 Target : <0x03f811d4> { _trap_c + 0x0 }

     Source : <0x03f80a50> { _trap + 0x6c }

   1 Target : <0x03f809e4> { _trap + 0x0 }

     Source : <0x03f96c48> { _kgdb_breakpoint + 0x8 }

   2 Target : <0x03f96c40> { _kgdb_breakpoint + 0x0 }

     Source : <0x03f8f402> { _do_kgdb + 0x1e }

   3 Target : <0x03f8f3fe> { _do_kgdb + 0x1a }

     Source : <0x03f8dd22> { _printf + 0x42 }

   4 Target : <0x03f8dd18> { _printf + 0x38 }

     Source : <0x03f87076> { _nc_puts + 0x36 }

   5 Target : <0x03f8706e> { _nc_puts + 0x2e }

     Source : <0x03f81dde> { _eth_halt + 0x26 }

   6 Target : <0x03f81dd2> { _eth_halt + 0x1a }

     Source : <0x03f9c1fc> { _bfin_EMAC_halt + 0x20 }

   7 Target : <0x03f9c1dc> { _bfin_EMAC_halt + 0x0 }

     Source : <0x03f81dd0> { _eth_halt + 0x18 }

   8 Target : <0x03f81db8> { _eth_halt + 0x0 }

     Source : <0x03f87034> { _nc_send_packet + 0xec }

   9 Target : <0x03f8702e> { _nc_send_packet + 0xe6 }

     Source : <0x03f83136> { _NetSendUDPPacket + 0x10e }

  10 Target : <0x03f8312c> { _NetSendUDPPacket + 0x104 }

     Source : <0x03f9c444> { _bfin_EMAC_send + 0xfc }

  11 Target : <0x03f9c43c> { _bfin_EMAC_send + 0xf4 }

     Source : <0x03f9c422> { _bfin_EMAC_send + 0xda }

  12 Target : <0x03f9c3fe> { _bfin_EMAC_send + 0xb6 }

     Source : <0x03f9c410> { _bfin_EMAC_send + 0xc8 }

  13 Target : <0x03f9c3fe> { _bfin_EMAC_send + 0xb6 }

     Source : <0x03f9c410> { _bfin_EMAC_send + 0xc8 }

  14 Target : <0x03f9c3fe> { _bfin_EMAC_send + 0xb6 }

     Source : <0x03f9c410> { _bfin_EMAC_send + 0xc8 }

  15 Target : <0x03f9c3fe> { _bfin_EMAC_send + 0xb6 }

     Source : <0x03f9c410> { _bfin_EMAC_send + 0xc8 }


kgdb: handle_exception; trap [0x5]




2011-06-22 12:20:38     Re: using u-boot for debugging bare metal elf

Mike Frysinger (UNITED STATES)

Message: 101571   


it didnt crash.  that's expected behavior.




2011-06-23 07:29:25     Re: using u-boot for debugging bare metal elf

Prasanth Rajagopal (INDIA)

Message: 101610   


The first line in output was obvious, but second made me confusing, as it's something new to me. But I could now debug with eclipse via gdb (bare metal via windows), except that I have issues with excecution stop and break points.


I click on debug, it goes to debug mode and upon resume I can see LEDs blinking. If I insert breakpoints, it never halts there - and after LED blinks are done, the disaassembler shows the pointer at start of main, and I lose control over - I need to terminate the bfin-elf-gdb manually, and then I need to reset board.


I had a feeling that I cannot use default startup as that will reset the stack - so I just had -nostartfiles. But that didnt fix anything.


Here is the gcc verbose:


**** Build of configuration Debug for project led_blink_bf537 ****


make all

'Building file: ../src/led_blink_bf537.c'

'Invoking: Blackfin ELF C Compiler'

bfin-elf-gcc -O0 -g3 -Wall -c -fmessage-length=0 -g -mcpu=bf537-any -MMD -MP -MF"src/led_blink_bf537.d" \

-MT"src/led_blink_bf537.d" -o"src/led_blink_bf537.o" "../src/led_blink_bf537.c"

'Finished building: ../src/led_blink_bf537.c'

' '

'Building target: led_blink_bf537'

'Invoking: Blackfin ELF C Linker'

bfin-elf-gcc -nostartfiles -g -Wl,-Map,led.map -mcpu=bf537-any -o"led_blink_bf537"  ./src/led_blink_bf537.o 

'Finished building target: led_blink_bf537'

' '



Here is the code:


Note:       0xffa00000                _start

                 0xffa00010                main


#include <cdefBF537.h>

int i,j;

int main();


void _start()





int main(void)


//are we in start?

*pPORTF_FER   = 0x0000;  // Setup for LEDs

*pPORTFIO_DIR  = 0x0FC0;  // Setup port for output

*pPORTFIO_SET  = 0x0FC0;  // Turn all LEDs on




  *pPORTFIO_CLEAR  = 0x01C0;





  *pPORTFIO_SET  = 0x01C0;







*pPORTFIO_SET  = 0x0FC0;  // Turn all LEDs on


return 0;




Here is the gdb output from eclipse. The last one shows it is running, and then I am out of control.


1442-gdb-set confirm off





1443-gdb-set width 0




1444-gdb-set height 0




1445-interpreter-exec console echo




1446-gdb-show prompt

1446^done,value="(gdb) "



1447-gdb-set new-console on

No symbol "new" in current context.

&"No symbol \"new\" in current context.\n"

1447^error,msg="No symbol \"new\" in current context."



1448 target remote COM1

target remote COM1

&"target remote COM1\n"

~"0x03f96c4a in ?? ()\n"

0x03f96c4a in ?? ()

set remotetimeout 300





1449 set remotetimeout 300

&"set remotetimeout 300\n"




1450 load


~"Loading section .text, size 0x11c lma 0xffa00000\n"

Loading section .text, size 0x11c lma 0xffa00000


~"Start address 0xffa00000, load size 284\n"

Start address 0xffa00000, load size 284

~"Transfer rate: 2272 bits in <1 sec, 142 bytes/write.\n"

Transfer rate: 2272 bits in <1 sec, 142 bytes/write.




1451-environment-directory "C:/Program Files/Analog Devices/GNU Toolchain/2010R1/temp/led_blink_bf537" "C:/Program Files/Analog Devices/GNU Toolchain/2010R1/temp/led_blink_bf537/Debug" "C:/Program Files/Analog Devices/GNU Toolchain/2010R1/temp/led_blink_bf537/Debug/src" "C:/Program Files/Analog Devices/GNU Toolchain/2010R1/temp/led_blink_bf537/src"

1451^done,source-path="C:/Program Files/Analog Devices/GNU Toolchain/2010R1/temp/led_blink_bf537;C:/Program Files/Analog Devices/GNU Toolchain/2010R1/temp/led_blink_bf537/Debug;C:/Program Files/Analog Devices/GNU Toolchain/2010R1/temp/led_blink_bf537/Debug/src;C:/Program Files/Analog Devices/GNU Toolchain/2010R1/temp/led_blink_bf537/src;$cdir;$cwd"



1452 info threads

&"info threads\n"

&"warning: RMT ERROR : failed to get remote thread list.\n"










1454-break-insert *4288676790




1455-break-disable 1




1456-break-insert *4288675840

1456^done,bkpt={number="2",type="breakpoint",disp="keep",enabled="y",addr="0xffa00000",func="_start",file="../src/led_blink_bf537.c",fullname="C:/Program Files/Analog Devices/GNU Toolchain/2010R1/temp/led_blink_bf537/Debug/../src/led_blink_bf537.c",line="17",times="0"}



1457-break-disable 2




1458-break-insert *4288677208




1459-break-disable 3




1460-break-insert *4288675930

1460^done,bkpt={number="4",type="breakpoint",disp="keep",enabled="y",addr="0xffa0005a",func="main",file="../src/led_blink_bf537.c",fullname="C:/Program Files/Analog Devices/GNU Toolchain/2010R1/temp/led_blink_bf537/Debug/../src/led_blink_bf537.c",line="34",times="0"}



1461-break-disable 4




1462-break-insert *4288677628




1463-break-disable 5




1464-break-insert *4288676092

1464^done,bkpt={number="6",type="breakpoint",disp="keep",enabled="y",addr="0xffa000fc",func="main",file="../src/led_blink_bf537.c",fullname="C:/Program Files/Analog Devices/GNU Toolchain/2010R1/temp/led_blink_bf537/Debug/../src/led_blink_bf537.c",line="30",times="0"}



1465-break-disable 6




1466-break-insert *4288676104

1466^done,bkpt={number="7",type="breakpoint",disp="keep",enabled="y",addr="0xffa00108",func="main",file="../src/led_blink_bf537.c",fullname="C:/Program Files/Analog Devices/GNU Toolchain/2010R1/temp/led_blink_bf537/Debug/../src/led_blink_bf537.c",line="44",times="0"}



1467-break-disable 7




1468-break-insert *4288677618




1469-break-disable 8






1470-break-insert *4288677634






1471-break-disable 9






1472-break-insert *4288677520






1473-break-disable 10






1474-break-insert *4288677218






1475-break-disable 11






1476-break-insert *4288677226






1477-break-disable 12






1478-break-insert *4288677302






1479-break-disable 13






1480-break-insert *4288677306






1481-break-disable 14






1482-break-insert *4288677328






1483-break-disable 15






1484-break-insert *4288677330






1485-break-disable 16






1486-break-insert *4288677322






1487-break-disable 17






1488-break-insert *4288677326






1489-break-disable 18






1490-break-insert *4288676118


1490^done,bkpt={number="19",type="breakpoint",disp="keep",enabled="y",addr="0xffa00116",func="main",file="../src/led_blink_bf537.c",fullname="C:/Program Files/Analog Devices/GNU Toolchain/2010R1/temp/led_blink_bf537/Debug/../src/led_blink_bf537.c",line="47",times="0"}




1491-break-disable 19






1492-break-insert *4288677320






1493-break-disable 20






1494-break-insert *4288677654






1495-break-disable 21






1496-break-insert *4288677204






1497-break-disable 22






1498-break-insert *4288677214






1499-break-disable 23






1500-break-insert *4288677318






1501-break-disable 24






1502-break-insert *4288677222






1503-break-disable 25






1504-break-insert *4288676792






1505-break-disable 26






1506-break-insert *4288677386






1507-break-disable 27






1508-break-insert *4288677244






1509-break-disable 28






1510-break-insert *4288677644






1511-break-disable 29






1512-break-insert *4288677526






1513-break-disable 30






1514-break-insert *4288677646






1515-break-disable 31






1516-break-insert *4288675856


1516^done,bkpt={number="32",type="breakpoint",disp="keep",enabled="y",addr="0xffa00010",func="main",file="../src/led_blink_bf537.c",fullname="C:/Program Files/Analog Devices/GNU Toolchain/2010R1/temp/led_blink_bf537/Debug/../src/led_blink_bf537.c",line="23",times="0"}




1517-break-disable 32






1518 tbreak main


tbreak main


&"tbreak main\n"


~"Breakpoint 33 at 0xffa00014: file ../src/led_blink_bf537.c, line 25.\n"


Breakpoint 33 at 0xffa00014: file ../src/led_blink_bf537.c, line 25.






1519 continue






~"main () at ../src/led_blink_bf537.c:25\n"


main () at ../src/led_blink_bf537.c:25


~"25\t\t*pPORTF_FER \t\t= 0x0000;\t\t// Setup for LEDs\n"


25 *pPORTF_FER = 0x0000; // Setup for LEDs








1520^done,BreakpointTable={nr_rows="32",nr_cols="6",hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},{width="14",alignment="-1",col_name="type",colhdr="Type"},{width="4",alignment="-1",col_name="disp",colhdr="Disp"},{width="3",alignment="-1",col_name="enabled",colhdr="Enb"},{width="10",alignment="-1",col_name="addr",colhdr="Address"},{width="40",alignment="2",col_name="what",colhdr="What"}],body=[bkpt={number="1",type="breakpoint",disp="keep",enabled="n",addr="0xffa003b6",at="",times="0"},bkpt={number="2",type="breakpoint",disp="keep",enabled="n",addr="0xffa00000",func="_start",file="../src/led_blink_bf537.c",fullname="C:/Program Files/Analog Devices/GNU Toolchain/2010R1/temp/led_blink_bf537/Debug/../src/led_blink_bf537.c",line="17",times="0"},bkpt={number="3",type="breakpoint",disp="keep",enabled="n",addr="0xffa00558",at="",times="0"},bkpt={number="4",type="breakpoint",disp="keep",enabled="n",addr="0xffa0005a",func="main",file="../src/led_blink_bf537.c",fullname="C:/Program Files/Analog Devices/GNU Toolchain/2010R1/temp/led_blink_bf537/Debug/../src/led_blink_bf537.c",line="34",times="0"},bkpt={number="5",type="breakpoint",disp="keep",enabled="n",addr="0xffa006fc",at="",times="0"},bkpt={number="6",type="breakpoint",disp="keep",enabled="n",addr="0xffa000fc",func="main",file="../src/led_blink_bf537.c",fullname="C:/Program Files/Analog Devices/GNU Toolchain/2010R1/temp/led_blink_bf537/Debug/../src/led_blink_bf537.c",line="30",times="0"},bkpt={number="7",type="breakpoint",disp="keep",enabled="n",addr="0xffa00108",func="main",file="../src/led_blink_bf537.c",fullname="C:/Program Files/Analog Devices/GNU Toolchain/2010R1/temp/led_blink_bf537/Debug/../src/led_blink_bf537.c",line="44",times="0"},bkpt={number="8",type="breakpoint",disp="keep",enabled="n",addr="0xffa006f2",at="",times="0"},bkpt={number="9",type="breakpoint",disp="keep",enabled="n",addr="0xffa00702",at="",times="0"},bkpt={number="10",type="breakpoint",disp="keep",enabled="n",addr="0xffa00690",at="",times="0"},bkpt={number="11",type="breakpoint",disp="keep",enabled="n",addr="0xffa00562",at="",times="0"},bkpt={number="12",type="breakpoint",disp="keep",enabled="n",addr="0xffa0056a",at="",times="0"},bkpt={number="13",type="breakpoint",disp="keep",enabled="n",addr="0xffa005b6",at="",times="0"},bkpt={number="14",type="breakpoint",disp="keep",enabled="n",addr="0xffa005ba",at="",times="0"},bkpt={number="15",type="breakpoint",disp="keep",enabled="n",addr="0xffa005d0",at="",times="0"},bkpt={number="16",type="breakpoint",disp="keep",enabled="n",addr="0xffa005d2",at="",times="0"},bkpt={number="17",type="breakpoint",disp="keep",enabled="n",addr="0xffa005ca",at="",times="0"},bkpt={number="18",type="breakpoint",disp="keep",enabled="n",addr="0xffa005ce",at="",times="0"},bkpt={number="19",type="breakpoint",disp="keep",enabled="n",addr="0xffa00116",func="main",file="../src/led_blink_bf537.c",fullname="C:/Program Files/Analog Devices/GNU Toolchain/2010R1/temp/led_blink_bf537/Debug/../src/led_blink_bf537.c",line="47",times="0"},bkpt={number="20",type="breakpoint",disp="keep",enabled="n",addr="0xffa005c8",at="",times="0"},bkpt={number="21",type="breakpoint",disp="keep",enabled="n",addr="0xffa00716",at="",times="0"},bkpt={number="22",type="breakpoint",disp="keep",enabled="n",addr="0xffa00554",at="",times="0"},bkpt={number="23",type="breakpoint",disp="keep",enabled="n",addr="0xffa0055e",at="",times="0"},bkpt={number="24",type="breakpoint",disp="keep",enabled="n",addr="0xffa005c6",at="",times="0"},bkpt={number="25",type="breakpoint",disp="keep",enabled="n",addr="0xffa00566",at="",times="0"},bkpt={number="26",type="breakpoint",disp="keep",enabled="n",addr="0xffa003b8",at="",times="0"},bkpt={number="27",type="breakpoint",disp="keep",enabled="n",addr="0xffa0060a",at="",times="0"},bkpt={number="28",type="breakpoint",disp="keep",enabled="n",addr="0xffa0057c",at="",times="0"},bkpt={number="29",type="breakpoint",disp="keep",enabled="n",addr="0xffa0070c",at="",times="0"},bkpt={number="30",type="breakpoint",disp="keep",enabled="n",addr="0xffa00696",at="",times="0"},bkpt={number="31",type="breakpoint",disp="keep",enabled="n",addr="0xffa0070e",at="",times="0"},bkpt={number="32",type="breakpoint",disp="keep",enabled="n",addr="0xffa00010",func="main",file="../src/led_blink_bf537.c",fullname="C:/Program Files/Analog Devices/GNU Toolchain/2010R1/temp/led_blink_bf537/Debug/../src/led_blink_bf537.c",line="23",times="0"}]}




1521 info proc


&"info proc\n"


&"Undefined info command: \"proc\". Try \"help info\".\n"


1521^error,msg="Undefined info command: \"proc\". Try \"help info\"."




1522 info program


&"info program\n"


~"Debugging a target over a serial line.\n"


~"Program stopped at 0xffa00014.\n"


~"It stopped at a breakpoint that has since been deleted.\n"


~"Type \"info stack\" or \"info registers\" for more information.\n"






1523 info threads


&"info threads\n"


&"warning: RMT ERROR : failed to get remote thread list.\n"












1525-stack-list-frames 0 1


1525^done,stack=[frame={level="0",addr="0xffa00014",func="main",file="../src/led_blink_bf537.c",fullname="C:/Program Files/Analog Devices/GNU Toolchain/2010R1/temp/led_blink_bf537/Debug/../src/led_blink_bf537.c",line="25"}]










1527 info sharedlibrary


&"info sharedlibrary\n"


~"No shared libraries loaded at this time.\n"






1528-stack-list-arguments 0 0 0






1529-stack-list-locals 0






1530-data-disassemble -s 0xffa00014 -e 0xffa000a4 -- 1


1530^done,asm_insns=[src_and_asm_line={line="25",file="../src/led_blink_bf537.c",line_asm_insn=[{address="0xffa00014",func-name="main",offset="4",inst="P2.H = 0xffc0;\t\t/* (-64)\tP2=0x0xffc00000(-4194304) */"},{address="0xffa00018",func-name="main",offset="8",inst="P2.L = 0x3200;\t\t/* (12800)\tP2=0x0xffc03200(-4181504) */"},{address="0xffa0001c",func-name="main",offset="12",inst="R0 = 0x0 (X);\t\t/*\t\tR0=0x0( 0) */"},{address="0xffa0001e",func-name="main",offset="14",inst="W[P2] = R0;"}]},src_and_asm_line={line="26",file="../src/led_blink_bf537.c",line_asm_insn=[{address="0xffa00020",func-name="main",offset="16",inst="P2.H = 0xffc0;\t\t/* (-64)\tP2=0x0xffc03200(-4181504) */"},{address="0xffa00024",func-name="main",offset="20",inst="P2.L = 0x730;\t\t/* (1840)\tP2=0x0xffc00730(-4192464) */"},{address="0xffa00028",func-name="main",offset="24",inst="R0 = 0xfc0 (X);\t\t/*\t\tR0=0x0xfc0(4032) */"},{address="0xffa0002c",func-name="main",offset="28",inst="W[P2] = R0;"}]},src_and_asm_line={line="27",file="../src/led_blink_bf537.c",line_asm_insn=[{address="0xffa0002e",func-name="main",offset="30",inst="P2.H = 0xffc0;\t\t/* (-64)\tP2=0x0xffc00730(-4192464) */"},{address="0xffa00032",func-name="main",offset="34",inst="P2.L = 0x708;\t\t/* (1800)\tP2=0x0xffc00708(-4192504) */"},{address="0xffa00036",func-name="main",offset="38",inst="R0 = 0xfc0 (X);\t\t/*\t\tR0=0x0xfc0(4032) */"},{address="0xffa0003a",func-name="main",offset="42",inst="W[P2] = R0;"}]},src_and_asm_line={line="28",file="../src/led_blink_bf537.c",line_asm_insn=[]},src_and_asm_line={line="29",file="../src/led_blink_bf537.c",line_asm_insn=[]},src_and_asm_line={line="30",file="../src/led_blink_bf537.c",line_asm_insn=[{address="0xffa0003c",func-name="main",offset="44",inst="P2.H = 0xff80;\t\t/* (-128)\tP2=0x0xff800708 */"},{address="0xffa00040",func-name="main",offset="48",inst="P2.L = 0x0;\t\t/* ( 0)\tP2=0x0xff800000 <j> */"},{address="0xffa00044",func-name="main",offset="52",inst="R0 = 0x0 (X);\t\t/*\t\tR0=0x0( 0) */"},{address="0xffa00046",func-name="main",offset="54",inst="[P2] = R0;"},{address="0xffa00048",func-name="main",offset="56",inst="JUMP.S 0x0xffa000f4 <main+228>;"}]},src_and_asm_line={line="31",file="../src/led_blink_bf537.c",line_asm_insn=[]},src_and_asm_line={line="32",file="../src/led_blink_bf537.c",line_asm_insn=[{address="0xffa0004a",func-name="main",offset="58",inst="P2.H = 0xffc0;\t\t/* (-64)\tP2=0x0xffc00000(-4194304) */"},{address="0xffa0004e",func-name="main",offset="62",inst="P2.L = 0x704;\t\t/* (1796)\tP2=0x0xffc00704(-4192508) */"},{address="0xffa00052",func-name="main",offset="66",inst="R0 = 0x1c0 (X);\t\t/*\t\tR0=0x0x1c0(448) */"},{address="0xffa00056",func-name="main",offset="70",inst="W[P2] = R0;"}]},src_and_asm_line={line="33",file="../src/led_blink_bf537.c",line_asm_insn=[]},src_and_asm_line={line="34",file="../src/led_blink_bf537.c",line_asm_insn=[{address="0xffa00058",func-name="main",offset="72",inst="P2.H = 0xff80;\t\t/* (-128)\tP2=0x0xff800704 */"},{address="0xffa0005c",func-name="main",offset="76",inst="P2.L = 0x4;\t\t/* ( 4)\tP2=0x0xff800004 <i> */"},{address="0xffa00060",func-name="main",offset="80",inst="R0 = 0x0 (X);\t\t/*\t\tR0=0x0( 0) */"},{address="0xffa00062",func-name="main",offset="82",inst="[P2] = R0;"},{address="0xffa00064",func-name="main",offset="84",inst="JUMP.S 0x0xffa0007e <main+110>;"},{address="0xffa00068",func-name="main",offset="88",inst="P2.H = 0xff80;\t\t/* (-128)\tP2=0x0xff800004 <i> */"},{address="0xffa0006c",func-name="main",offset="92",inst="P2.L = 0x4;\t\t/* ( 4)\tP2=0x0xff800004 <i> */"},{address="0xffa00070",func-name="main",offset="96",inst="R0 = [P2];"},{address="0xffa00072",func-name="main",offset="98",inst="R0 += 0x1;\t\t/* ( 1) */"},{address="0xffa00074",func-name="main",offset="100",inst="P2.H = 0xff80;\t\t/* (-128)\tP2=0x0xff800004 <i> */"},{address="0xffa00078",func-name="main",offset="104",inst="P2.L = 0x4;\t\t/* ( 4)\tP2=0x0xff800004 <i> */"},{address="0xffa0007c",func-name="main",offset="108",inst="[P2] = R0;"},{address="0xffa0007e",func-name="main",offset="110",inst="P2.H = 0xff80;\t\t/* (-128)\tP2=0x0xff800004 <i> */"},{address="0xffa00082",func-name="main",offset="114",inst="P2.L = 0x4;\t\t/* ( 4)\tP2=0x0xff800004 <i> */"},{address="0xffa00086",func-name="main",offset="118",inst="R0 = [P2];"},{address="0xffa00088",func-name="main",offset="120",inst="R1.H = 0x7a;\t\t/* (122)\tR1=0x0x7a0000(7995392) */"},{address="0xffa0008c",func-name="main",offset="124",inst="R1.L = 0x11ff;\t\t/* (4607)\tR1=0x0x7a11ff(7999999) */"},{address="0xffa00090",func-name="main",offset="128",inst="CC = R0 <= R1;"},{address="0xffa00092",func-name="main",offset="130",inst="IF CC JUMP 0x0xffa00066 <main+86>;"}]},src_and_asm_line={line="35",file="../src/led_blink_bf537.c",line_asm_insn=[{address="0xffa00066",func-name="main",offset="86",inst="NOP;"}]},src_and_asm_line={line="36",file="../src/led_blink_bf537.c",line_asm_insn=[]},src_and_asm_line={line="37",file="../src/led_blink_bf537.c",line_asm_insn=[{address="0xffa00094",func-name="main",offset="132",inst="P2.H = 0xffc0;\t\t/* (-64)\tP2=0x0xffc00004(-4194300) */"},{address="0xffa00098",func-name="main",offset="136",inst="P2.L = 0x708;\t\t/* (1800)\tP2=0x0xffc00708(-4192504) */"},{address="0xffa0009c",func-name="main",offset="140",inst="R0 = 0x1c0 (X);\t\t/*\t\tR0=0x0x1c0(448) */"},{address="0xffa000a0",func-name="main",offset="144",inst="W[P2] = R0;"}]},src_and_asm_line={line="38",file="../src/led_blink_bf537.c",line_asm_insn=[]},src_and_asm_line={line="39",file="../src/led_blink_bf537.c",line_asm_insn=[{address="0xffa000a2",func-name="main",offset="146",inst="P2.H = 0xff80;\t\t/* (-128)\tP2=0x0xff800708 */"},{address="0xffa000a6",func-name="main",offset="150",inst="P2.L = 0x4;\t\t/* ( 4)\tP2=0x0xff800004 <i> */"},{address="0xffa000aa",func-name="main",offset="154",inst="R0 = 0x0 (X);\t\t/*\t\tR0=0x0( 0) */"},{address="0xffa000ac",func-name="main",offset="156",inst="[P2] = R0;"},{address="0xffa000ae",func-name="main",offset="158",inst="JUMP.S 0x0xffa000c8 <main+184>;"}]}]




1531-data-disassemble -s 0xffa00064 -e 0xffa00084 -- 1


1531^done,asm_insns=[src_and_asm_line={line="34",file="../src/led_blink_bf537.c",line_asm_insn=[{address="0xffa00068",func-name="main",offset="88",inst="P2.H = 0xff80;\t\t/* (-128)\tP2=0x0xff800004 <i> */"},{address="0xffa0006c",func-name="main",offset="92",inst="P2.L = 0x4;\t\t/* ( 4)\tP2=0x0xff800004 <i> */"},{address="0xffa00070",func-name="main",offset="96",inst="R0 = [P2];"},{address="0xffa00072",func-name="main",offset="98",inst="R0 += 0x1;\t\t/* ( 1) */"},{address="0xffa00074",func-name="main",offset="100",inst="P2.H = 0xff80;\t\t/* (-128)\tP2=0x0xff800004 <i> */"},{address="0xffa00078",func-name="main",offset="104",inst="P2.L = 0x4;\t\t/* ( 4)\tP2=0x0xff800004 <i> */"},{address="0xffa0007c",func-name="main",offset="108",inst="[P2] = R0;"},{address="0xffa0007e",func-name="main",offset="110",inst="P2.H = 0xff80;\t\t/* (-128)\tP2=0x0xff800004 <i> */"},{address="0xffa00082",func-name="main",offset="114",inst="P2.L = 0x4;\t\t/* ( 4)\tP2=0x0xff800004 <i> */"},{address="0xffa00086",func-name="main",offset="118",inst="R0 = [P2];"},{address="0xffa00088",func-name="main",offset="120",inst="R1.H = 0x7a;\t\t/* (122)\tR1=0x0x7a11ff(7999999) */"},{address="0xffa0008c",func-name="main",offset="124",inst="R1.L = 0x11ff;\t\t/* (4607)\tR1=0x0x7a11ff(7999999) */"},{address="0xffa00090",func-name="main",offset="128",inst="CC = R0 <= R1;"},{address="0xffa00092",func-name="main",offset="130",inst="IF CC JUMP 0x0xffa00066 <main+86>;"}]},src_and_asm_line={line="35",file="../src/led_blink_bf537.c",line_asm_insn=[{address="0xffa00066",func-name="main",offset="86",inst="NOP;"}]}]




1532-data-disassemble -s 0xffa00064 -e 0xffa00084 -- 0


1532^done,asm_insns=[{address="0xffa00064",func-name="main",offset="84",inst="JUMP.S 0x0xffa0007e <main+110>;"},{address="0xffa00066",func-name="main",offset="86",inst="NOP;"},{address="0xffa00068",func-name="main",offset="88",inst="P2.H = 0xff80;\t\t/* (-128)\tP2=0x0xff800004 <i> */"},{address="0xffa0006c",func-name="main",offset="92",inst="P2.L = 0x4;\t\t/* ( 4)\tP2=0x0xff800004 <i> */"},{address="0xffa00070",func-name="main",offset="96",inst="R0 = [P2];"},{address="0xffa00072",func-name="main",offset="98",inst="R0 += 0x1;\t\t/* ( 1) */"},{address="0xffa00074",func-name="main",offset="100",inst="P2.H = 0xff80;\t\t/* (-128)\tP2=0x0xff800004 <i> */"},{address="0xffa00078",func-name="main",offset="104",inst="P2.L = 0x4;\t\t/* ( 4)\tP2=0x0xff800004 <i> */"},{address="0xffa0007c",func-name="main",offset="108",inst="[P2] = R0;"},{address="0xffa0007e",func-name="main",offset="110",inst="P2.H = 0xff80;\t\t/* (-128)\tP2=0x0xff800004 <i> */"},{address="0xffa00082",func-name="main",offset="114",inst="P2.L = 0x4;\t\t/* ( 4)\tP2=0x0xff800004 <i> */"}]




1533-break-insert led_blink_bf537.c:44


1533^done,bkpt={number="34",type="breakpoint",disp="keep",enabled="y",addr="0xffa00104",func="main",file="../src/led_blink_bf537.c",fullname="C:/Program Files/Analog Devices/GNU Toolchain/2010R1/temp/led_blink_bf537/Debug/../src/led_blink_bf537.c",line="44",times="0"}












2011-06-23 07:30:53     Re: using u-boot for debugging bare metal elf

Prasanth Rajagopal (INDIA)

Message: 101611   


Sorry if I screwed the page!




2011-06-23 13:09:47     Re: using u-boot for debugging bare metal elf

Prasanth Rajagopal (INDIA)

Message: 101624   


Perhaps I should rely on gdb commands first, instead of eclipse, but any ideas on latter is also welcome. Here is the command line output - I am not sure what 0x03f96c4a() represents - but I dont have SDRAM, I am not using startup files also. But I am run the ELF Image via bootelf.


C:\Program Files\Analog Devices\GNU Toolchain\2010R1\elf\bin>bfin-elf-gdb.exe led_blink_bf537

GNU gdb 6.6

Copyright (C) 2006 Free Software Foundation, Inc.

GDB is free software, covered by the GNU General Public License, and you are

welcome to change it and/or distribute copies of it under certain conditions.

Type "show copying" to see the conditions.

There is absolutely no warranty for GDB.  Type "show warranty" for details.

This GDB was configured as "--host=i386-mingw32msvc --target=bfin-elf"...

(gdb) set remotebaud 57600

(gdb) target remote COM1

Remote debugging using COM1

0x03f96c4a in ?? ()

(gdb) break main

Breakpoint 1 at 0xffa0002e: file ../src/led_blink_bf537.c, line 27.

(gdb) break led_blink_bf537.c:44

Breakpoint 2 at 0xffa00104: file ../src/led_blink_bf537.c, line 44.

(gdb) step

Cannot find bounds of current function

(gdb) continue



>>> Even when I had two breakpoints, the code never runs further, and instead performs a return to kgdb, waking up the u-boot prompt. I had -g in the compiler option.


At the same time, I can do static operations such as


(gdb) info functions

All defined functions:


File ../src/led_blink_bf537.c:

void _start();

int main(void);





2011-06-23 13:25:50     Re: using u-boot for debugging bare metal elf

Steve Strobel (UNITED STATES)

Message: 101625   


> ...except that I have issues with excecution stop and break points.


Unless I am mistaken (Ed Sutter could say for sure), uMON doesn't have a full GDB server implementation like the one used in Linux apps.  So to debug a bare metal app, you would need to build a gdb server into the app itself or enhance the uMON version.  I think that uMON by design stays out of the way once it starts your application;  unless you leave it in memory and make calls to it from your application, it isn't going to do anything until your application exits.  In other words, I would not expect to be able to use its GDB stub to stop a running application.  It might not be too hard to enhance it to set a breakpoint before starting the application, but giving it the ability to set a new breakpoint while the application was running would require a background tread for the gdb server, something uMON (AFAIK) doesn't currently do.






2011-06-23 14:02:40     Re: using u-boot for debugging bare metal elf

Prasanth Rajagopal (INDIA)

Message: 101630   




Actually all my replies are completely on the u-boot mechanism MIke mentioned about (starting from the one: I am giving a try with the method you explained:....)


It was out of curiousity I went to uMon and Ed has really helped on that. He clarified that gdbserver on uMon can only be used for symbolic debugging. This gdbserver wasn't available on Blackfin (and to note they only have BF537 port), but past few days he fixed that as well.


I found that uMon file system is quite easy to use, and through APIs applications can talk to the bootloader directly, (I havent explored u-boot a lot to compare...but I was more concerned about how bare metal ELF can be dealt, to help debugging such as below) :


"tftp -F app -fE get app_file" - stores as an ELF file to memory. Since it is a ELF file supported file system, so you can retrieve, run and debug ELF files any time.


"tfs -v ld app" - load the application ELF into ram as a pure stripped out binary.  You can control it as a function.


As far as I understood now, u-boot is far superior on its debugging capabilites (though I dont know how it can maintain multiple ELF files though, as i read only about jffs2 file system)


I will post the uMon output captured shortly in the Docs.


- Prasanth.




2011-06-28 07:46:49     Re: using u-boot for debugging bare metal elf

Prasanth Rajagopal (INDIA)

Message: 101790   




Maybe I am doing something obviously wrong here, as you only said - there does seem to be some timeouts in the communication between kgdb and gdb that we'll have to look into.