Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2014-05

Gdb and openocd via lazarus

16 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Justin Smyth

Hi folks

I can get lazarus to compile my project ok then I can openocd to flash my board , I can gdb connecting on port 3333 OK but I can't get it stop on any break points..

Also should I see once it connects with gdb something change in openocd ?

With the LPC1343 chipset do I need to do anything special before running my own code ? I am just doing a loop with some break points in it to see I can see it working.

Kind Regards

Justin

Earlier message 19 lines
From: Justin Smyth [mailto:] Sent: Saturday, 17 May 2014 10:02 AM To: Subject: [Lazarus] Gdb and openocd via lazarus Hi folks I remember a while ago Michael ring had someway of modified version of Lazarus to connect to gdb spawned from a openocd session , is this still possible? I am using fpc 2.6.5 and latest Lazarus from the svn ( fpc is from svn fixes2_6 branch) -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20140522/6e7ff036/attachment.html>

Reply by email

Martin Schreiber
to Justin Smyth
Justin Smyth wrote 5 lines
I can get lazarus to compile my project ok then I can openocd to flash my board , I can gdb connecting on port 3333 OK but I can't get it stop on any break points..

I don't know openocd, connection with gdb is described here: http://openocd.sourceforge.net/doc/html/GDB-and-OpenOCD.html#GDB-and-OpenOCD

In MSEide the procedure is as follows - I assume same as in Lazarus: In 'Start gdb server command run target' write the command or script which starts the OpenOCD gdb proxy server (I don't know the command). Set 'Wait before connect' to the GDB server startup time + some reserve. 'Target connection' = remote localhost:3333

Activate 'gdb download' then MSEide will use the gdb "load" command for program download.

I suggest to make first a minimal C-program with the gcc toolchain of your target. If that works the FPC adventure can start. ;-)

Martin

Reply by email

Koenraad Lelong
to Martin Schreiber
Martin Schreiber wrote 15 lines
In MSEide the procedure is as follows - I assume same as in Lazarus: In 'Start gdb server command run target' write the command or script which starts the OpenOCD gdb proxy server (I don't know the command). Set 'Wait before connect' to the GDB server startup time + some reserve. 'Target connection' = remote localhost:3333 Activate 'gdb download' then MSEide will use the gdb "load" command for program download. I suggest to make first a minimal C-program with the gcc toolchain of your target. If that works the FPC adventure can start. ;-) Martin

Hi,

I tried to debug my arm-board with MSEide.
I manually started openocd (I need to be root). I configured MSEide debugger : Target connection : extended-remote localhost:3333. I configured debug-target to the elf-file of my project. Is there a macro to add an extention to the "make-output-file" ? I compiled the project and manually flashed it, and I left it in reset halt. I then can attach to the target, I see gdb connecting to openocd. I get the proper source in the source window. I can start the project, but since there seems still a problem with the compile-fase (the resulting binary does not work properly) I tried to reset the board. There gdb drops the connection to the target.

When I set a breakpoint, the target halts, but MSEide does not indicate in the source where it stops. I can step, but again MSEide does not follow in the source.

I can "continue" the target and stop it. But when I stop it, no indication where in the source it stopped.

So progress, but not there yet. Or maybe I'm doing things wrong ?

I still need to find why the binary is not good. When I compile the project via cli, it's working. From within MSEide, it does not work, although the command-line is the same as my manual command-line. I will add -va again and compare the outputs.

Koenraad.

Reply by email

Martin Schreiber
to Koenraad Lelong
Koenraad Lelong wrote
I tried to debug my arm-board with MSEide. I manually started openocd (I need to be root).

Maybe it could be done by a root script with setuser flag in 'Project'-'Options'-'Debugger'-'Target'-'Start gdb server command run target'.

I configured MSEide debugger : Target connection : extended-remote localhost:3333.

Up to now I used "remote" only.

I configured debug-target to the elf-file of my project. Is there a macro to add an extention to the "make-output-file" ?

The gdb target file can be defined in 'Project'-'Options'-'Debugger'-'Debug Target' (as you did). There is a predefined macro ${EXEEXT} in 'Settings' for global access or define your own project specific macros in 'Project'-'Options'-'Macros'. It is possible to save such a customized project as template for future. MSEide project templates are normal project (*.prj)-files.

Show quoted text 14 lines
I compiled the project and manually flashed it, and I left it in reset halt. I then can attach to the target, I see gdb connecting to openocd. I get the proper source in the source window. I can start the project, but since there seems still a problem with the compile-fase (the resulting binary does not work properly) I tried to reset the board. There gdb drops the connection to the target. When I set a breakpoint, the target halts, but MSEide does not indicate in the source where it stops. I can step, but again MSEide does not follow in the source. I can "continue" the target and stop it. But when I stop it, no indication where in the source it stopped.

The searched source directories must be listed
in 'Project'-'Options'-'Debugger'-'Source directories'. What shows the status line below the MSEide main menu?

BTW, the MSEide+MSEgui mailinglist is here:
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk Archive and NNTP gateway:
http://news.gmane.org/gmane.comp.ide.mseide.user
I don't think the theme is appropriate for this list. ;-)

Martin

Reply by email

Koenraad Lelong
to Martin Schreiber
Martin Schreiber wrote
I don't think the theme is appropriate for this list. ;-)

I hesitated to post in the Lazarus-list, because it's indeed not lazarus-related anymore.
I find the theme is appopriate : gdb-debugging of pascal-source.

I'll subscribe to yet another list, and contunue there.

Koenraad

Reply by email

Michael Ring
to Koenraad Lelong: I tried to debug my arm-board with MSEide. I manually started openocd (I need to be…

If I were you I would try to start as low-level as possible.

To do so, please check if your gdb is configured with textui enabled ( try starting it with arm-none-eabi-gdb --tui )

if only commandline shows up then download gdb and recompile it:

cd gdb
./configure--target=arm-none-eabi--prefix=/usr/local --program-prefix=arm-none-eabi---disable-werror --enable-tui

This Text UI is very nice for finding out if the problem is related to gdb or to the integration of gdb into the ide.

Here's how I call gdb:

arm-none-eabi-gdb hello.elf --tui --eval-command="target extended :3333" --eval-command="monitor reset halt" --eval-command="set mem inaccessible-by-default off" --eval-command="load"

This loads the binary, you should end up with the debugger showing you your source code.

Now try stepping through the code, if all is fine then great, problem is in the integration of gdb.

Stept I use:
break main
cont

step

When stepping does not work you can go deeper:

add

--eval-command="layout asm" --eval-command="layout regs"

to the commandline and start over, now you can single step through the assembler code with

stepi

This should help you to track down your problems (I hope)

Michael

Koenraad Lelong wrote 55 lines
op 21-05-14 20:17, Martin Schreiber schreef: > > In MSEide the procedure is as follows - I assume same as in Lazarus: > In 'Start gdb server command run target' write the command or script > which > starts the OpenOCD gdb proxy server (I don't know the command). > Set 'Wait before connect' to the GDB server startup time + some reserve. > 'Target connection' = remote localhost:3333 > > Activate 'gdb download' then MSEide will use the gdb "load" command for > program download. > > I suggest to make first a minimal C-program with the gcc toolchain of > your > target. If that works the FPC adventure can start. ;-) > > Martin > Hi, I tried to debug my arm-board with MSEide. I manually started openocd (I need to be root). I configured MSEide debugger : Target connection : extended-remote localhost:3333. I configured debug-target to the elf-file of my project. Is there a macro to add an extention to the "make-output-file" ? I compiled the project and manually flashed it, and I left it in reset halt. I then can attach to the target, I see gdb connecting to openocd. I get the proper source in the source window. I can start the project, but since there seems still a problem with the compile-fase (the resulting binary does not work properly) I tried to reset the board. There gdb drops the connection to the target. When I set a breakpoint, the target halts, but MSEide does not indicate in the source where it stops. I can step, but again MSEide does not follow in the source. I can "continue" the target and stop it. But when I stop it, no indication where in the source it stopped. So progress, but not there yet. Or maybe I'm doing things wrong ? I still need to find why the binary is not good. When I compile the project via cli, it's working. From within MSEide, it does not work, although the command-line is the same as my manual command-line. I will add -va again and compare the outputs. Koenraad. -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20140528/64ccbd26/attachment.html>

Reply by email

Martin Schreiber
to Koenraad Lelong: I tried to debug my arm-board with MSEide. I manually started openocd (I need to be…
Koenraad Lelong wrote
I tried to debug my arm-board with MSEide. I manually started openocd (I need to be root).

Is the debug interface connected by USB? Then it is possible to setup an udev rule in order to allow non-root access. Copy a file to /etc/udev/rules.d, for the J-Link for example I named it 99-jlink_mse.rules, the content: "
ACTION!="add", SUBSYSTEM!=="usb_device", GOTO="jlink_rules_end" ATTR{idProduct}=="0101", ATTR{idVendor}=="1366", MODE="664", GROUP="users" ATTR{idProduct}=="0102", ATTR{idVendor}=="1366", MODE="664", GROUP="users" ATTR{idProduct}=="0103", ATTR{idVendor}=="1366", MODE="664", GROUP="users" ATTR{idProduct}=="0104", ATTR{idVendor}=="1366", MODE="664", GROUP="users" ATTR{idProduct}=="0105", ATTR{idVendor}=="1366", MODE="664", GROUP="users" LABEL="jlink_rules_end"
"
"lsusb -v" lists the connected USB-devices with their device descriptor. The file provided by Segger did not work because of an unknown BUS variable and SYSFS instead of ATTR.

I tried to connect an EFM32 board by openocd->J-Link->SWD->Chip, sadly the openocd J-Link driver supports JTAG only. :-(

Martin

Reply by email

Koenraad Lelong
to Martin Schreiber
Martin Schreiber wrote 8 lines
On Wednesday 28 May 2014 12:36:57 Koenraad Lelong wrote: > > I tried to debug my arm-board with MSEide. > I manually started openocd (I need to be root). Is the debug interface connected by USB? Then it is possible to setup an udev rule in order to allow non-root access. Copy a file to /etc/udev/rules.d, for the J-Link for example I named it 99-jlink_mse.rules, the content:

I don't know why, but now it works. I use a board with an stlink-v2 interface, via USB.

Koenraad

Reply by email

Koenraad Lelong
to Michael Ring: If I were you I would try to start as low-level as possible. To do so, please check if…
Michael Ring wrote 20 lines
Here's how I call gdb: arm-none-eabi-gdb hello.elf --tui --eval-command="target extended :3333" --eval-command="monitor reset halt" --eval-command="set mem inaccessible-by-default off" --eval-command="load" This loads the binary, you should end up with the debugger showing you your source code. Now try stepping through the code, if all is fine then great, problem is in the integration of gdb. Stept I use: break main cont step

This all works. Tomorrow I will try to send those commands with mseide.

Many thanks.

Koenraad

Reply by email

Justin Smyth
to Koenraad Lelong

Michael

A few questions for you , I am back now able to proceeded with my arm project using lazarus ( laptop has been dead 3 weeks needed a replacement motherboard off ebay from the USA).

The arm GDB I am using I got from code sorcery ( arm-none-eabi )

C:\LazarusExtras\gdb\bin>arm-none-eabi-gdb.exe
GNU gdb (Sourcery G++ Lite 2010.09-51) 7.2.50.20100908-cvs Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details.
This GDB was configured as "--host=i686-mingw32 --target=arm-none-eabi". For bug reporting instructions, please see:
<https://support.codesourcery.com/GNUToolchain/>.

Is this the best version to use ?

Could I compile the latest version of gdb from there svn ? would that work out of the box - I've been able to compile fpc ok for arm from svn.

I just want to make sure the copy of gdb for arm I using can stop on breakpoints etc.

Justin Smyth

Earlier message 36 lines
-----Original Message----- From: Koenraad Lelong [mailto:] Sent: Friday, 30 May 2014 6:06 AM To: Subject: Re: [Lazarus] Gdb and openocd via lazarus op 28-05-14 13:57, Michael Ring schreef: > > Here's how I call gdb: > > arm-none-eabi-gdb hello.elf --tui --eval-command="target extended :3333" > --eval-command="monitor reset halt" --eval-command="set mem > inaccessible-by-default off" --eval-command="load" > > > This loads the binary, you should end up with the debugger showing you > your source code. > > Now try stepping through the code, if all is fine then great, problem > is in the integration of gdb. > > Stept I use: > break main > cont > > step > This all works. Tomorrow I will try to send those commands with mseide. Many thanks. Koenraad --

Reply by email

Michael Ring
to Justin Smyth

There's an excellent Page on using gdb with freepascal on the wiki:

http://wiki.lazarus.freepascal.org/GDB_Debugger_Tips,

when you scroll down there's a list of recommended gdb versions.

Rebuilding gdb from source is peace of cake on linux and mac, I never really tried it on a windows machine , but this link should help:

http://dev.zhourenjian.com/blog/2009/03/11/compiling-gdb-debugger-in-windows.html

or have a look at the linaro toolchain, they also have a lot of different precompiled versions for windows, their builds:

https://releases.linaro.org/14.05/components/toolchain/binaries

When you start at https://releases.linaro.org/ you can see all the different versions available.

Michael

Justin Smyth wrote 84 lines
Michael A few questions for you , I am back now able to proceeded with my arm project using lazarus ( laptop has been dead 3 weeks needed a replacement motherboard off ebay from the USA). The arm GDB I am using I got from code sorcery ( arm-none-eabi ) C:\LazarusExtras\gdb\bin>arm-none-eabi-gdb.exe GNU gdb (Sourcery G++ Lite 2010.09-51) 7.2.50.20100908-cvs Copyright (C) 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "--host=i686-mingw32 --target=arm-none-eabi". For bug reporting instructions, please see: <https://support.codesourcery.com/GNUToolchain/>. Is this the best version to use ? Could I compile the latest version of gdb from there svn ? would that work out of the box - I've been able to compile fpc ok for arm from svn. I just want to make sure the copy of gdb for arm I using can stop on breakpoints etc. Justin Smyth -----Original Message----- From: Koenraad Lelong [mailto:] Sent: Friday, 30 May 2014 6:06 AM To: Subject: Re: [Lazarus] Gdb and openocd via lazarus op 28-05-14 13:57, Michael Ring schreef: > Here's how I call gdb: > > arm-none-eabi-gdb hello.elf --tui --eval-command="target extended :3333" > --eval-command="monitor reset halt" --eval-command="set mem > inaccessible-by-default off" --eval-command="load" > > > This loads the binary, you should end up with the debugger showing you > your source code. > > Now try stepping through the code, if all is fine then great, problem > is in the integration of gdb. > > Stept I use: > break main > cont > > step > This all works. Tomorrow I will try to send those commands with mseide. Many thanks. Koenraad -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Justin Smyth
to Michael Ring

Thanks Michael

I got better results from using the GDB from the tool chain binaries from linaro.

Is it normal for TUI not to be supported in the arm eabi version ?

I can now start openocd8 , and start gdb and I see both of them talk to each other ( I want to see gdb connect correctly then I will move onto getting lazarus to connect once I have it working in two dos prompts on my windows vm )

My open ocd configuration file looks like this ( does this look right ? anything missing or do I need to change anything ? )

source [find interface/stlink-v2.cfg]
set CHIPSERIES lpc1300
set TRANSPORT hla_swd
set CPUROMSIZE 0x8000
set CPURAMSIZE 0x2000
source [find target/lpc1343.cfg]

init
reset init

flash write_image erase unlock myprogram.elf 0 elf

reset run
reset init

Kind Regards

Justin

Earlier message 116 lines
-----Original Message----- From: Michael Ring [mailto:] Sent: Monday, 16 June 2014 6:33 PM To: Lazarus mailing list Subject: Re: [Lazarus] Gdb and openocd via lazarus There's an excellent Page on using gdb with freepascal on the wiki: http://wiki.lazarus.freepascal.org/GDB_Debugger_Tips, when you scroll down there's a list of recommended gdb versions. Rebuilding gdb from source is peace of cake on linux and mac, I never really tried it on a windows machine , but this link should help: http://dev.zhourenjian.com/blog/2009/03/11/compiling-gdb-debugger-in-windows .html or have a look at the linaro toolchain, they also have a lot of different precompiled versions for windows, their builds: https://releases.linaro.org/14.05/components/toolchain/binaries When you start at https://releases.linaro.org/ you can see all the different versions available. Michael Am 14.06.14 17:42, schrieb Justin Smyth: > Michael > > A few questions for you , I am back now able to proceeded with my arm > project using lazarus ( laptop has been dead 3 weeks needed a replacement > motherboard off ebay from the USA). > > > The arm GDB I am using I got from code sorcery ( arm-none-eabi ) > > > C:\LazarusExtras\gdb\bin>arm-none-eabi-gdb.exe > GNU gdb (Sourcery G++ Lite 2010.09-51) 7.2.50.20100908-cvs > Copyright (C) 2010 Free Software Foundation, Inc. > License GPLv3+: GNU GPL version 3 or later > <http://gnu.org/licenses/gpl.html> > This is free software: you are free to change and redistribute it. > There is NO WARRANTY, to the extent permitted by law. Type "show copying" > and "show warranty" for details. > This GDB was configured as "--host=i686-mingw32 --target=arm-none-eabi". > For bug reporting instructions, please see: > <https://support.codesourcery.com/GNUToolchain/>. > > > > Is this the best version to use ? > > Could I compile the latest version of gdb from there svn ? would that work > out of the box - I've been able to compile fpc ok for arm from svn. > > > I just want to make sure the copy of gdb for arm I using can stop on > breakpoints etc. > > > Justin Smyth > > > > -----Original Message----- > From: Koenraad Lelong [mailto:] > Sent: Friday, 30 May 2014 6:06 AM > To: > Subject: Re: [Lazarus] Gdb and openocd via lazarus > > op 28-05-14 13:57, Michael Ring schreef: >> Here's how I call gdb: >> >> arm-none-eabi-gdb hello.elf --tui --eval-command="target extended :3333" >> --eval-command="monitor reset halt" --eval-command="set mem >> inaccessible-by-default off" --eval-command="load" >> >> >> This loads the binary, you should end up with the debugger showing you >> your source code. >> >> Now try stepping through the code, if all is fine then great, problem >> is in the integration of gdb. >> >> Stept I use: >> break main >> cont >> >> step >> > This all works. Tomorrow I will try to send those commands with mseide. > > Many thanks. > > Koenraad > > > -- > _______________________________________________ > Lazarus mailing list > > http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus > > > > -- > _______________________________________________ > Lazarus mailing list > > http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus --

Reply by email

Michael Ring
to Justin Smyth

TUI is a rather seldomly used option, I also saw that some linux distros do not support it. If you want it you will perhaps really need to build a version of gdb for yourself.

Your openocd file looks fine on first glance, I would propably not do the flash command manually and instead use gdb's command to do the flashing, but in the end the result should be pretty much the same. Using gdb for flashing is perhaps a little better because you do not need to change your openocd config file when you binary file changes. If I find the time tonight I will see if this works, but I will not promise anything ;-)

So what is your status right now, can you already single step through your code and does entering
break main
cont

work ?

Michael

Justin Smyth wrote 165 lines
Thanks Michael I got better results from using the GDB from the tool chain binaries from linaro. Is it normal for TUI not to be supported in the arm eabi version ? I can now start openocd8 , and start gdb and I see both of them talk to each other ( I want to see gdb connect correctly then I will move onto getting lazarus to connect once I have it working in two dos prompts on my windows vm ) My open ocd configuration file looks like this ( does this look right ? anything missing or do I need to change anything ? ) source [find interface/stlink-v2.cfg] set CHIPSERIES lpc1300 set TRANSPORT hla_swd set CPUROMSIZE 0x8000 set CPURAMSIZE 0x2000 source [find target/lpc1343.cfg] init reset init flash write_image erase unlock myprogram.elf 0 elf reset run reset init Kind Regards Justin -----Original Message----- From: Michael Ring [mailto:] Sent: Monday, 16 June 2014 6:33 PM To: Lazarus mailing list Subject: Re: [Lazarus] Gdb and openocd via lazarus There's an excellent Page on using gdb with freepascal on the wiki: http://wiki.lazarus.freepascal.org/GDB_Debugger_Tips, when you scroll down there's a list of recommended gdb versions. Rebuilding gdb from source is peace of cake on linux and mac, I never really tried it on a windows machine , but this link should help: http://dev.zhourenjian.com/blog/2009/03/11/compiling-gdb-debugger-in-windows .html or have a look at the linaro toolchain, they also have a lot of different precompiled versions for windows, their builds: https://releases.linaro.org/14.05/components/toolchain/binaries When you start at https://releases.linaro.org/ you can see all the different versions available. Michael Am 14.06.14 17:42, schrieb Justin Smyth: > Michael > > A few questions for you , I am back now able to proceeded with my arm > project using lazarus ( laptop has been dead 3 weeks needed a replacement > motherboard off ebay from the USA). > > > The arm GDB I am using I got from code sorcery ( arm-none-eabi ) > > > C:\LazarusExtras\gdb\bin>arm-none-eabi-gdb.exe > GNU gdb (Sourcery G++ Lite 2010.09-51) 7.2.50.20100908-cvs > Copyright (C) 2010 Free Software Foundation, Inc. > License GPLv3+: GNU GPL version 3 or later > <http://gnu.org/licenses/gpl.html> > This is free software: you are free to change and redistribute it. > There is NO WARRANTY, to the extent permitted by law. Type "show copying" > and "show warranty" for details. > This GDB was configured as "--host=i686-mingw32 --target=arm-none-eabi". > For bug reporting instructions, please see: > <https://support.codesourcery.com/GNUToolchain/>. > > > > Is this the best version to use ? > > Could I compile the latest version of gdb from there svn ? would that work > out of the box - I've been able to compile fpc ok for arm from svn. > > > I just want to make sure the copy of gdb for arm I using can stop on > breakpoints etc. > > > Justin Smyth > > > > -----Original Message----- > From: Koenraad Lelong [mailto:] > Sent: Friday, 30 May 2014 6:06 AM > To: > Subject: Re: [Lazarus] Gdb and openocd via lazarus > > op 28-05-14 13:57, Michael Ring schreef: >> Here's how I call gdb: >> >> arm-none-eabi-gdb hello.elf --tui --eval-command="target extended :3333" >> --eval-command="monitor reset halt" --eval-command="set mem >> inaccessible-by-default off" --eval-command="load" >> >> >> This loads the binary, you should end up with the debugger showing you >> your source code. >> >> Now try stepping through the code, if all is fine then great, problem >> is in the integration of gdb. >> >> Stept I use: >> break main >> cont >> >> step >> > This all works. Tomorrow I will try to send those commands with mseide. > > Many thanks. > > Koenraad > > > -- > _______________________________________________ > Lazarus mailing list > > http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus > > > > -- > _______________________________________________ > Lazarus mailing list > > http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Justin Smyth
to Michael Ring

Thanks

My status right now I about to move into getting it working when lazarus calls GDB. I didn't know about GDB doing the flash instead

I just wanted to make sure both gdb and openocd were talking correctly and I had that stage correct. ( it seems to work except openocd bitches about the checksum of 0x00000000 not matching the calculated value of the file)

Heres the output in question - from when open up openocd with a configuration file that I deleted the bit from Flash on wards

Two questions LPC Vector can I ignore this , and the time out for gdb ( I tried to add --eval-command="set remotetimeout 60" and it didn't make any difference )

C:\LazarusExtras\OpenOCD>openocd.exe -f ocd.cfg
Open On-Chip Debugger 0.8.0 (2014-04-28-08:42)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.sourceforge.net/doc/doxygen/bugs.html adapter speed: 10 kHz
adapter_nsrst_delay: 200
Info : This adapter doesn't support configurable speed Info : STLINK v2 JTAG v14 API v2 SWIM v3 VID 0x0483 PID 0x3748 Info : using stlink api v2
Info : Target voltage: 3.191053
Info : lpc1343.cpu: hardware has 6 breakpoints, 4 watchpoints target state: halted
target halted due to debug-request, current mode: Thread xPSR: 0x01000000 pc: 0x1fff0104 msp: 0x10000ffc

-----> now I start gdb in a separate dos cmd

C:\LazarusExtras\gdb\bin>arm-none-eabi-gdb myprogram.elf --eval-command="target
extended :3333" --eval-command="monitor reset halt" --eval-command="set mem in
accessible-by-default off" --eval-command="load"
GNU gdb (crosstool-NG linaro-1.13.1-4.9-2014.05 - Linaro GCC 4.9-2014.05) 7.6.1-
2013.10
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details.
This GDB was configured as "--host=i586-host_pc-mingw32msvc --target=arm-none-ea
bi".
For bug reporting instructions, please see:
<https://bugs.launchpad.net/gcc-linaro>...
Reading symbols from C:\LazarusExtras\gdb\bin\myprogram.elf...done. Remote debugging using :3333
0x1fff0104 in ?? ()
target state: halted
target halted due to debug-request, current mode: Thread xPSR: 0x01000000 pc: 0x1fff0104 msp: 0x10000ffc
Loading section .text, size 0x7cc lma 0x0
Loading section .data, size 0x98 lma 0x7cc
Start address 0x784, load size 2148
Transfer rate: 740 bytes/sec, 1074 bytes/write.
(gdb)

Now the openocd windows comes up with

Info : accepting 'gdb' connection from 3333
target state: halted
target halted due to debug-request, current mode: Thread xPSR: 0x01000000 pc: 0x1fff0104 msp: 0x10000ffc
target state: halted
target halted due to debug-request, current mode: Thread xPSR: 0x01000000 pc: 0x1fff0104 msp: 0x10000ffc
target state: halted
target halted due to breakpoint, current mode: Thread xPSR: 0x61000000 pc: 0x10000004 msp: 0x100000b4
---> Warn : Verification will fail since checksum in image (0x00000000) to be written to flash is different from calculated vector checksum (0xefffba67). <---
----> Warn : To remove this warning modify build tools on developer PC to inject correct LPC vector checksum. <----
*** Warn : keep_alive() was not invoked in the 1000ms timelimit. GDB alive packet not sent! (1785). Workaround: increase "set remotetimeout" in GDB *** target state: halted
target halted due to debug-request, current mode: Thread xPSR: 0x01000000 pc: 0x1fff0104 msp: 0x10000ffc

Earlier message 192 lines
-----Original Message----- From: Michael Ring [mailto:] Sent: Tuesday, 17 June 2014 7:39 PM To: ; Lazarus mailing list Subject: Re: [Lazarus] Gdb and openocd via lazarus TUI is a rather seldomly used option, I also saw that some linux distros do not support it. If you want it you will perhaps really need to build a version of gdb for yourself. Your openocd file looks fine on first glance, I would propably not do the flash command manually and instead use gdb's command to do the flashing, but in the end the result should be pretty much the same. Using gdb for flashing is perhaps a little better because you do not need to change your openocd config file when you binary file changes. If I find the time tonight I will see if this works, but I will not promise anything ;-) So what is your status right now, can you already single step through your code and does entering break main cont work ? Michael Am 16.06.14 16:03, schrieb Justin Smyth: > Thanks Michael > > > I got better results from using the GDB from the tool chain binaries > from linaro. > > Is it normal for TUI not to be supported in the arm eabi version ? > > I can now start openocd8 , and start gdb and I see both of them talk > to each other ( I want to see gdb connect correctly then I will move > onto getting lazarus to connect once I have it working in two dos > prompts on my windows vm ) > > My open ocd configuration file looks like this ( does this look right ? > anything missing or do I need to change anything ? ) > > > source [find interface/stlink-v2.cfg] > set CHIPSERIES lpc1300 > set TRANSPORT hla_swd > set CPUROMSIZE 0x8000 > set CPURAMSIZE 0x2000 > source [find target/lpc1343.cfg] > > init > reset init > > flash write_image erase unlock myprogram.elf 0 elf > > reset run > reset init > > > Kind Regards > > > Justin > > -----Original Message----- > From: Michael Ring [mailto:] > Sent: Monday, 16 June 2014 6:33 PM > To: Lazarus mailing list > Subject: Re: [Lazarus] Gdb and openocd via lazarus > > There's an excellent Page on using gdb with freepascal on the wiki: > > http://wiki.lazarus.freepascal.org/GDB_Debugger_Tips, > > when you scroll down there's a list of recommended gdb versions. > > Rebuilding gdb from source is peace of cake on linux and mac, I never > really tried it on a windows machine , but this link should help: > > http://dev.zhourenjian.com/blog/2009/03/11/compiling-gdb-debugger-in-w > indows > .html > > or have a look at the linaro toolchain, they also have a lot of > different precompiled versions for windows, their builds: > > https://releases.linaro.org/14.05/components/toolchain/binaries > > When you start at https://releases.linaro.org/ you can see all the > different versions available. > > Michael > > Am 14.06.14 17:42, schrieb Justin Smyth: >> Michael >> >> A few questions for you , I am back now able to proceeded with my arm >> project using lazarus ( laptop has been dead 3 weeks needed a >> replacement motherboard off ebay from the USA). >> >> >> The arm GDB I am using I got from code sorcery ( arm-none-eabi ) >> >> >> C:\LazarusExtras\gdb\bin>arm-none-eabi-gdb.exe >> GNU gdb (Sourcery G++ Lite 2010.09-51) 7.2.50.20100908-cvs Copyright >> (C) 2010 Free Software Foundation, Inc. >> License GPLv3+: GNU GPL version 3 or later >> <http://gnu.org/licenses/gpl.html> >> This is free software: you are free to change and redistribute it. >> There is NO WARRANTY, to the extent permitted by law. Type "show copying" >> and "show warranty" for details. >> This GDB was configured as "--host=i686-mingw32 --target=arm-none-eabi". >> For bug reporting instructions, please see: >> <https://support.codesourcery.com/GNUToolchain/>. >> >> >> >> Is this the best version to use ? >> >> Could I compile the latest version of gdb from there svn ? would that >> work out of the box - I've been able to compile fpc ok for arm from svn. >> >> >> I just want to make sure the copy of gdb for arm I using can stop on >> breakpoints etc. >> >> >> Justin Smyth >> >> >> >> -----Original Message----- >> From: Koenraad Lelong [mailto:] >> Sent: Friday, 30 May 2014 6:06 AM >> To: >> Subject: Re: [Lazarus] Gdb and openocd via lazarus >> >> op 28-05-14 13:57, Michael Ring schreef: >>> Here's how I call gdb: >>> >>> arm-none-eabi-gdb hello.elf --tui --eval-command="target extended :3333" >>> --eval-command="monitor reset halt" --eval-command="set mem >>> inaccessible-by-default off" --eval-command="load" >>> >>> >>> This loads the binary, you should end up with the debugger showing >>> you your source code. >>> >>> Now try stepping through the code, if all is fine then great, >>> problem is in the integration of gdb. >>> >>> Stept I use: >>> break main >>> cont >>> >>> step >>> >> This all works. Tomorrow I will try to send those commands with mseide. >> >> Many thanks. >> >> Koenraad >> >> >> -- >> _______________________________________________ >> Lazarus mailing list >> >> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus >> >> >> >> -- >> _______________________________________________ >> Lazarus mailing list >> >> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus > > -- > _______________________________________________ > Lazarus mailing list > > http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus > > > > -- > _______________________________________________ > Lazarus mailing list > > http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Justin Smyth

I've updated lpc13xx.pp to add the Checksum under neath "UsageFault_interrupt"

What I'm not sure is what is the linker script. Where do I find it ?

Justin

Earlier message 363 lines
-----Original Message----- From: Michael Ring [mailto:] Sent: Tuesday, 17 June 2014 9:16 PM To: Subject: Re: [Lazarus] Gdb and openocd via lazarus About flashing: You can remove your flashing code from openocd, you have the load command in your gdb commandline and this does the flashing. Those lines: Loading section .text, size 0x7cc lma 0x0 Loading section .data, size 0x98 lma 0x7cc Start address 0x784, load size 2148 Transfer rate: 740 bytes/sec, 1074 bytes/write. tell me that flasing was done via gdb 'load' command. The openocd warning shows a still open issue in fpc. The binary you built will work fine if you run it in the debugger, it will however not work on a standalone chip not connected to a debugger because lpc chip rom first verifies a checksum and when it is correct the boot rom starts the app, if the checksum is wrong then the serial bootloader process is initiated. simple rule is that the sum of the data stored in the first 8 interrupt vectors must be 0 This link shows the details: http://www.lpcware.com/content/forum/lpc1788-flash-signature-generation the important line is this one: a) in the linker script: /* Calculate NXP Cortex-M3 valid user code checksum. This is 0-(sum of first 7 entries in vector table), * Note that we must add 1 to each code space vector (LSB = marker for thumb code). */ __valid_user_code_checksum = 0 - (__cs3_stack + __cs3_reset + 1 + NMI_Handler + 1 + HardFault_Handler + 1 + MemManage_Handler + 1 + BusFault_Handler + 1 + UsageFault_Handler + 1); Attention: these statements must be outside any output section, because linker variables inside output sections are relative to the start of the section. something like this must get added to the linker script for lpc-chips. code should be something like (but needs testing): __valid_user_code_checksum = 0 - (_stack_top + Startup + 1 + NonMaskableInt_interrupt + 1 + 1 + MemoryManagement_interrupt + 1 + BusFault_interrupt + 1 + UsageFault_interrupt + 1); This value must the be written into the 'Checksum' vector. I always wanted to do this a long time ago, but I never actually needed it because I still have plenty of stm32 chips to burn and those do not need to have this trick applied..... .long _stack_top .long Startup .long NonMaskableInt_interrupt .long 0 .long MemoryManagement_interrupt .long BusFault_interrupt .long UsageFault_interrupt .long Checksum .long 0 Am 17.06.14 12:49, schrieb Justin Smyth: > Thanks > > > My status right now I about to move into getting it working when > lazarus calls GDB. I didn't know about GDB doing the flash instead > > > I just wanted to make sure both gdb and openocd were talking correctly > and I had that stage correct. ( it seems to work except openocd > bitches about the checksum of 0x00000000 not matching the calculated > value of the file) > > Heres the output in question - from when open up openocd with a > configuration file that I deleted the bit from Flash on wards > > Two questions LPC Vector can I ignore this , and the time out for gdb > ( I tried to add --eval-command="set remotetimeout 60" and it didn't > make any difference ) > > > C:\LazarusExtras\OpenOCD>openocd.exe -f ocd.cfg Open On-Chip Debugger > 0.8.0 (2014-04-28-08:42) Licensed under GNU GPL v2 For bug reports, > read > http://openocd.sourceforge.net/doc/doxygen/bugs.html > adapter speed: 10 kHz > adapter_nsrst_delay: 200 > Info : This adapter doesn't support configurable speed Info : STLINK > v2 JTAG v14 API v2 SWIM v3 VID 0x0483 PID 0x3748 Info : using stlink > api v2 Info : Target voltage: 3.191053 Info : lpc1343.cpu: hardware > has 6 breakpoints, 4 watchpoints target state: halted target halted > due to debug-request, current mode: Thread > xPSR: 0x01000000 pc: 0x1fff0104 msp: 0x10000ffc > > -----> now I start gdb in a separate dos cmd > > > C:\LazarusExtras\gdb\bin>arm-none-eabi-gdb myprogram.elf > --eval-command="target extended :3333" --eval-command="monitor reset > halt" --eval-command="set mem in accessible-by-default off" > --eval-command="load" > GNU gdb (crosstool-NG linaro-1.13.1-4.9-2014.05 - Linaro GCC > 4.9-2014.05) > 7.6.1- > 2013.10 > Copyright (C) 2013 Free Software Foundation, Inc. > License GPLv3+: GNU GPL version 3 or later > <http://gnu.org/licenses/gpl.html> > This is free software: you are free to change and redistribute it. > There is NO WARRANTY, to the extent permitted by law. Type "show copying" > and "show warranty" for details. > This GDB was configured as "--host=i586-host_pc-mingw32msvc > --target=arm-none-ea bi". > For bug reporting instructions, please see: > <https://bugs.launchpad.net/gcc-linaro>... > Reading symbols from C:\LazarusExtras\gdb\bin\myprogram.elf...done. > Remote debugging using :3333 > 0x1fff0104 in ?? () > target state: halted > target halted due to debug-request, current mode: Thread > xPSR: 0x01000000 pc: 0x1fff0104 msp: 0x10000ffc Loading section .text, > size 0x7cc lma 0x0 Loading section .data, size 0x98 lma 0x7cc Start > address 0x784, load size 2148 Transfer rate: 740 bytes/sec, 1074 > bytes/write. > (gdb) > > > Now the openocd windows comes up with > > Info : accepting 'gdb' connection from 3333 target state: halted > target halted due to debug-request, current mode: Thread > xPSR: 0x01000000 pc: 0x1fff0104 msp: 0x10000ffc target state: halted > target halted due to debug-request, current mode: Thread > xPSR: 0x01000000 pc: 0x1fff0104 msp: 0x10000ffc target state: halted > target halted due to breakpoint, current mode: Thread > xPSR: 0x61000000 pc: 0x10000004 msp: 0x100000b4 > ---> Warn : Verification will fail since checksum in image > ---> (0x00000000) to > be written to flash is different from calculated vector checksum > (0xefffba67). <--- > ----> Warn : To remove this warning modify build tools on developer PC > ----> to > inject correct LPC vector checksum. <---- > *** Warn : keep_alive() was not invoked in the 1000ms timelimit. GDB > alive packet not sent! (1785). Workaround: increase "set > remotetimeout" in GDB *** target state: halted target halted due to > debug-request, current mode: Thread > xPSR: 0x01000000 pc: 0x1fff0104 msp: 0x10000ffc > > > > > > > -----Original Message----- > From: Michael Ring [mailto:] > Sent: Tuesday, 17 June 2014 7:39 PM > To: ; Lazarus mailing list > Subject: Re: [Lazarus] Gdb and openocd via lazarus > > TUI is a rather seldomly used option, I also saw that some linux > distros do not support it. If you want it you will perhaps really need > to build a version of gdb for yourself. > > Your openocd file looks fine on first glance, I would propably not do > the flash command manually and instead use gdb's command to do the > flashing, but in the end the result should be pretty much the same. > Using gdb for flashing is perhaps a little better because you do not > need to change your openocd config file when you binary file changes. > If I find the time tonight I will see if this works, but I will not > promise anything ;-) > > So what is your status right now, can you already single step through > your code and does entering break main cont > > work ? > > Michael > > Am 16.06.14 16:03, schrieb Justin Smyth: >> Thanks Michael >> >> >> I got better results from using the GDB from the tool chain binaries >> from linaro. >> >> Is it normal for TUI not to be supported in the arm eabi version ? >> >> I can now start openocd8 , and start gdb and I see both of them talk >> to each other ( I want to see gdb connect correctly then I will move >> onto getting lazarus to connect once I have it working in two dos >> prompts on my windows vm ) >> >> My open ocd configuration file looks like this ( does this look right ? >> anything missing or do I need to change anything ? ) >> >> >> source [find interface/stlink-v2.cfg] set CHIPSERIES lpc1300 set >> TRANSPORT hla_swd set CPUROMSIZE 0x8000 set CPURAMSIZE 0x2000 source >> [find target/lpc1343.cfg] >> >> init >> reset init >> >> flash write_image erase unlock myprogram.elf 0 elf >> >> reset run >> reset init >> >> >> Kind Regards >> >> >> Justin >> >> -----Original Message----- >> From: Michael Ring [mailto:] >> Sent: Monday, 16 June 2014 6:33 PM >> To: Lazarus mailing list >> Subject: Re: [Lazarus] Gdb and openocd via lazarus >> >> There's an excellent Page on using gdb with freepascal on the wiki: >> >> http://wiki.lazarus.freepascal.org/GDB_Debugger_Tips, >> >> when you scroll down there's a list of recommended gdb versions. >> >> Rebuilding gdb from source is peace of cake on linux and mac, I never >> really tried it on a windows machine , but this link should help: >> >> http://dev.zhourenjian.com/blog/2009/03/11/compiling-gdb-debugger-in- >> w >> indows >> .html >> >> or have a look at the linaro toolchain, they also have a lot of >> different precompiled versions for windows, their builds: >> >> https://releases.linaro.org/14.05/components/toolchain/binaries >> >> When you start at https://releases.linaro.org/ you can see all the >> different versions available. >> >> Michael >> >> Am 14.06.14 17:42, schrieb Justin Smyth: >>> Michael >>> >>> A few questions for you , I am back now able to proceeded with my >>> arm project using lazarus ( laptop has been dead 3 weeks needed a >>> replacement motherboard off ebay from the USA). >>> >>> >>> The arm GDB I am using I got from code sorcery ( arm-none-eabi ) >>> >>> >>> C:\LazarusExtras\gdb\bin>arm-none-eabi-gdb.exe >>> GNU gdb (Sourcery G++ Lite 2010.09-51) 7.2.50.20100908-cvs Copyright >>> (C) 2010 Free Software Foundation, Inc. >>> License GPLv3+: GNU GPL version 3 or later >>> <http://gnu.org/licenses/gpl.html> >>> This is free software: you are free to change and redistribute it. >>> There is NO WARRANTY, to the extent permitted by law. Type "show > copying" >>> and "show warranty" for details. >>> This GDB was configured as "--host=i686-mingw32 --target=arm-none-eabi". >>> For bug reporting instructions, please see: >>> <https://support.codesourcery.com/GNUToolchain/>. >>> >>> >>> >>> Is this the best version to use ? >>> >>> Could I compile the latest version of gdb from there svn ? would >>> that work out of the box - I've been able to compile fpc ok for arm from svn. >>> >>> >>> I just want to make sure the copy of gdb for arm I using can stop on >>> breakpoints etc. >>> >>> >>> Justin Smyth >>> >>> >>> >>> -----Original Message----- >>> From: Koenraad Lelong [mailto:] >>> Sent: Friday, 30 May 2014 6:06 AM >>> To: >>> Subject: Re: [Lazarus] Gdb and openocd via lazarus >>> >>> op 28-05-14 13:57, Michael Ring schreef: >>>> Here's how I call gdb: >>>> >>>> arm-none-eabi-gdb hello.elf --tui --eval-command="target extended :3333" >>>> --eval-command="monitor reset halt" --eval-command="set mem >>>> inaccessible-by-default off" --eval-command="load" >>>> >>>> >>>> This loads the binary, you should end up with the debugger showing >>>> you your source code. >>>> >>>> Now try stepping through the code, if all is fine then great, >>>> problem is in the integration of gdb. >>>> >>>> Stept I use: >>>> break main >>>> cont >>>> >>>> step >>>> >>> This all works. Tomorrow I will try to send those commands with mseide. >>> >>> Many thanks. >>> >>> Koenraad >>> >>> >>> -- >>> _______________________________________________ >>> Lazarus mailing list >>> >>> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus >>> >>> >>> >>> -- >>> _______________________________________________ >>> Lazarus mailing list >>> >>> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus >> -- >> _______________________________________________ >> Lazarus mailing list >> >> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus >> >> >> >> -- >> _______________________________________________ >> Lazarus mailing list >> >> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus > >

Reply by email