You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nuttx.apache.org by Mark Stevens <ma...@thepcsite.co.uk> on 2023/06/10 20:45:24 UTC
STM32 and GDB - How do I generate the ELF file?
So I’m admitting defeat on this problem and I need some help please.
I’m trying to work out the magic incantations I need to weave to create a NuttX ELF file that I can use with GDB. To be clear this is the OS ELF file that I can use on the host computer.
I am currently targeting the Pico boards but I have also had this problem with the STM32F767 Discovery board as well. I have opened connect to the boards in both cases and I am now trying to debug the OS on the board.
Can anyone point me in the right direction - I’m sure it is going to be simple, I just need pointing in the right direction.
Thanks in advance,
Mark
_____________________________
Blog: blog.thepcsite.co.uk
Twitter: @nevynuk
Re: STM32 and GDB - How do I generate the ELF file?
Posted by "Alan C. Assis" <ac...@gmail.com>.
We have a more detailed documentation here:
https://nuttx.apache.org/docs/latest/quickstart/debugging.html#debugging-with-openocd-and-gdb
Any issue, please let us to know.
BR,
Alan
On 6/10/23, Alan C. Assis <ac...@gmail.com> wrote:
> Hi Mark,
>
> Could you please try these magical steps:
>
> $ make distclean
>
> $ ./tools/configure.sh stm32f777zit6-meadow:nsh
>
> $ make menuconfig
>
> Build Setup --->
> Debug Options --->
> [*] Generate Debug Symbols
>
> $ make -j
>
> Flash nuttx.bin
>
> Connect to the board using OpenOCD + STLink-V2:
>
> $ sudo openocd -f interface/stlink-v2.cfg -f target/stm32f7x.cfg
>
> In another terminal:
>
> $ gdb nuttx
> (gdb) target remote localhost:3333
> (gdb) monitor reset
> (gdb) load nuttx
> (gdb) b nx_start
> (gdb) c
>
> BR,
>
> Alan
>
> On 6/10/23, Mark Stevens <ma...@thepcsite.co.uk> wrote:
>> So I’m admitting defeat on this problem and I need some help please.
>>
>> I’m trying to work out the magic incantations I need to weave to create a
>> NuttX ELF file that I can use with GDB. To be clear this is the OS ELF
>> file
>> that I can use on the host computer.
>>
>> I am currently targeting the Pico boards but I have also had this problem
>> with the STM32F767 Discovery board as well. I have opened connect to the
>> boards in both cases and I am now trying to debug the OS on the board.
>>
>> Can anyone point me in the right direction - I’m sure it is going to be
>> simple, I just need pointing in the right direction.
>>
>> Thanks in advance,
>> Mark
>> _____________________________
>> Blog: blog.thepcsite.co.uk
>> Twitter: @nevynuk
>>
>>
>>
>>
>>
>>
>
Re: STM32 and GDB - How do I generate the ELF file?
Posted by Mark Stevens <ma...@thepcsite.co.uk>.
Personally I think debug symbols should be off by default. The default position for any OS should always be small, fast and most importantly, secure.
Different modes are a great way of solving this. Visual Studio has had this for as long as I have been using it.
Regards,
Mark
_____________________________
Blog: blog.thepcsite.co.uk
Twitter: @nevynuk
> On 11 Jun 2023, at 14:49, Alan C. Assis <ac...@gmail.com> wrote:
>
> You are welcome Mark!
>
> There is a PR proposing to enabling it by default:
> https://github.com/apache/nuttx/pull/9499
>
> To be honest I don't know if it will be a good idea.
>
> Probably some company will forget to disable it and will ship the
> firmware with debug symbols enabled.
>
> Sometime ago a company released their firmware with nsh and the memory
> read/write tools enabled and then came his complaining that it was a
> security fail (a user used the memory tool to dump their proprietary
> firmware) and forced us to disable that memory tool features by
> default.
>
> Some building systems solve like that of Android solve it creating
> different compilation modes: Debug, Release, etc.
>
> BR,
>
> Alan
>
> On 6/11/23, Mark Stevens <ma...@thepcsite.co.uk> wrote:
>> I think the missing piece of information is that the nuttx file contains the
>> debug symbols.
>>
>> Thanks for your time and help.
>>
>> Regards,
>> Mark
>> _____________________________
>> Blog: blog.thepcsite.co.uk
>> Twitter: @nevynuk
>>
>>
>>
>>
>>
>>> On 10 Jun 2023, at 22:10, Alan C. Assis <ac...@gmail.com> wrote:
>>>
>>> Hi Mark,
>>>
>>> Could you please try these magical steps:
>>>
>>> $ make distclean
>>>
>>> $ ./tools/configure.sh stm32f777zit6-meadow:nsh
>>>
>>> $ make menuconfig
>>>
>>> Build Setup --->
>>> Debug Options --->
>>> [*] Generate Debug Symbols
>>>
>>> $ make -j
>>>
>>> Flash nuttx.bin
>>>
>>> Connect to the board using OpenOCD + STLink-V2:
>>>
>>> $ sudo openocd -f interface/stlink-v2.cfg -f target/stm32f7x.cfg
>>>
>>> In another terminal:
>>>
>>> $ gdb nuttx
>>> (gdb) target remote localhost:3333
>>> (gdb) monitor reset
>>> (gdb) load nuttx
>>> (gdb) b nx_start
>>> (gdb) c
>>>
>>> BR,
>>>
>>> Alan
>>>
>>> On 6/10/23, Mark Stevens <ma...@thepcsite.co.uk> wrote:
>>>> So I’m admitting defeat on this problem and I need some help please.
>>>>
>>>> I’m trying to work out the magic incantations I need to weave to create
>>>> a
>>>> NuttX ELF file that I can use with GDB. To be clear this is the OS ELF
>>>> file
>>>> that I can use on the host computer.
>>>>
>>>> I am currently targeting the Pico boards but I have also had this
>>>> problem
>>>> with the STM32F767 Discovery board as well. I have opened connect to
>>>> the
>>>> boards in both cases and I am now trying to debug the OS on the board.
>>>>
>>>> Can anyone point me in the right direction - I’m sure it is going to be
>>>> simple, I just need pointing in the right direction.
>>>>
>>>> Thanks in advance,
>>>> Mark
>>>> _____________________________
>>>> Blog: blog.thepcsite.co.uk
>>>> Twitter: @nevynuk
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>
>>
Re: STM32 and GDB - How do I generate the ELF file?
Posted by "Alan C. Assis" <ac...@gmail.com>.
You are welcome Mark!
There is a PR proposing to enabling it by default:
https://github.com/apache/nuttx/pull/9499
To be honest I don't know if it will be a good idea.
Probably some company will forget to disable it and will ship the
firmware with debug symbols enabled.
Sometime ago a company released their firmware with nsh and the memory
read/write tools enabled and then came his complaining that it was a
security fail (a user used the memory tool to dump their proprietary
firmware) and forced us to disable that memory tool features by
default.
Some building systems solve like that of Android solve it creating
different compilation modes: Debug, Release, etc.
BR,
Alan
On 6/11/23, Mark Stevens <ma...@thepcsite.co.uk> wrote:
> I think the missing piece of information is that the nuttx file contains the
> debug symbols.
>
> Thanks for your time and help.
>
> Regards,
> Mark
> _____________________________
> Blog: blog.thepcsite.co.uk
> Twitter: @nevynuk
>
>
>
>
>
>> On 10 Jun 2023, at 22:10, Alan C. Assis <ac...@gmail.com> wrote:
>>
>> Hi Mark,
>>
>> Could you please try these magical steps:
>>
>> $ make distclean
>>
>> $ ./tools/configure.sh stm32f777zit6-meadow:nsh
>>
>> $ make menuconfig
>>
>> Build Setup --->
>> Debug Options --->
>> [*] Generate Debug Symbols
>>
>> $ make -j
>>
>> Flash nuttx.bin
>>
>> Connect to the board using OpenOCD + STLink-V2:
>>
>> $ sudo openocd -f interface/stlink-v2.cfg -f target/stm32f7x.cfg
>>
>> In another terminal:
>>
>> $ gdb nuttx
>> (gdb) target remote localhost:3333
>> (gdb) monitor reset
>> (gdb) load nuttx
>> (gdb) b nx_start
>> (gdb) c
>>
>> BR,
>>
>> Alan
>>
>> On 6/10/23, Mark Stevens <ma...@thepcsite.co.uk> wrote:
>>> So I’m admitting defeat on this problem and I need some help please.
>>>
>>> I’m trying to work out the magic incantations I need to weave to create
>>> a
>>> NuttX ELF file that I can use with GDB. To be clear this is the OS ELF
>>> file
>>> that I can use on the host computer.
>>>
>>> I am currently targeting the Pico boards but I have also had this
>>> problem
>>> with the STM32F767 Discovery board as well. I have opened connect to
>>> the
>>> boards in both cases and I am now trying to debug the OS on the board.
>>>
>>> Can anyone point me in the right direction - I’m sure it is going to be
>>> simple, I just need pointing in the right direction.
>>>
>>> Thanks in advance,
>>> Mark
>>> _____________________________
>>> Blog: blog.thepcsite.co.uk
>>> Twitter: @nevynuk
>>>
>>>
>>>
>>>
>>>
>>>
>
>
Re: STM32 and GDB - How do I generate the ELF file?
Posted by Gregory Nutt <sp...@gmail.com>.
On 6/11/2023 11:42 AM, Tim Hardisty wrote:
> Where should that be in the (current) documentation? I’ll go and add it as I didn’t know this.
I am not very familiar with the new documentation. There should be a
document about creating board support and that document should discuss
the content of the Make.defs file.
Candidates would be
* Documentation/guides/customapps.rst
* Documentation/quickstart/organization.rst
Perhaps people that work with the new documentation know more about this.
Re: STM32 and GDB - How do I generate the ELF file?
Posted by Tim Hardisty <ti...@hardisty.co.uk>.
Where should that be in the (current) documentation? I’ll go and add it as I didn’t know this.
From: Gregory Nutt <sp...@gmail.com>
Reply to: "dev@nuttx.apache.org" <de...@nuttx.apache.org>
Date: Sunday, 11 June 2023 at 18:16
To: "dev@nuttx.apache.org" <de...@nuttx.apache.org>
Subject: Re: STM32 and GDB - How do I generate the ELF file?
On 6/11/2023 11:07 AM, Mark Stevens wrote:
Is there any reason for not having the extension?
To me the extension adds information about the file.
The name is actually BIN = nuttx$(EXEEXT) but EXEEXT is not normally
defined.
Different toolchains generate executable images in different formats and
that format is not known at that level. If you want nuttx.elf just
define EXEEXT to be .elf in your Make.defs file.
Re: STM32 and GDB - How do I generate the ELF file?
Posted by Gregory Nutt <sp...@gmail.com>.
On 6/11/2023 11:16 AM, Gregory Nutt wrote:
> On 6/11/2023 11:07 AM, Mark Stevens wrote:
>> Is there any reason for not having the extension?
>>
>> To me the extension adds information about the file.
>
> The name is actually BIN = nuttx$(EXEEXT) but EXEEXT is not normally
> defined.
>
> Different toolchains generate executable images in different formats
> and that format is not known at that level. If you want nuttx.elf
> just define EXEEXT to be .elf in your Make.defs file.
>
There are a few examples:
$ find boards -name Make.defs | xargs grep EXEEXT
boards/arm/gd32f4/gd32f450zk-eval/scripts/Make.defs:EXEEXT = .elf
boards/arm/lpc43xx/bambino-200e/scripts/Make.defs:EXEEXT = .elf
boards/avr/atmega/arduino-mega2560/scripts/Make.defs:EXEEXT = .elf
boards/x86/qemu/qemu-i486/scripts/Make.defs:EXEEXT = .elf
boards/x86_64/intel64/qemu-intel64/scripts/Make.defs:EXEEXT = .elf
Re: STM32 and GDB - How do I generate the ELF file?
Posted by Gregory Nutt <sp...@gmail.com>.
On 6/11/2023 11:07 AM, Mark Stevens wrote:
> Is there any reason for not having the extension?
>
> To me the extension adds information about the file.
The name is actually BIN = nuttx$(EXEEXT) but EXEEXT is not normally
defined.
Different toolchains generate executable images in different formats and
that format is not known at that level. If you want nuttx.elf just
define EXEEXT to be .elf in your Make.defs file.
Re: STM32 and GDB - How do I generate the ELF file?
Posted by Mark Stevens <ma...@thepcsite.co.uk>.
Is there any reason for not having the extension?
To me the extension adds information about the file.
Regards,
Mark
_____________________________
Blog: blog.thepcsite.co.uk
Twitter: @nevynuk
> On 11 Jun 2023, at 17:19, Petro Karashchenko <pe...@gmail.com> wrote:
>
> The nuttx file is actually an ELF file, but without .elf extension.
>
> BR,
> Petro
>
> On Sun, Jun 11, 2023, 10:39 AM Mark Stevens <ma...@thepcsite.co.uk> wrote:
>
>> I think the missing piece of information is that the nuttx file contains
>> the debug symbols.
>>
>> Thanks for your time and help.
>>
>> Regards,
>> Mark
>> _____________________________
>> Blog: blog.thepcsite.co.uk
>> Twitter: @nevynuk
>>
>>
>>
>>
>>
>>> On 10 Jun 2023, at 22:10, Alan C. Assis <ac...@gmail.com> wrote:
>>>
>>> Hi Mark,
>>>
>>> Could you please try these magical steps:
>>>
>>> $ make distclean
>>>
>>> $ ./tools/configure.sh stm32f777zit6-meadow:nsh
>>>
>>> $ make menuconfig
>>>
>>> Build Setup --->
>>> Debug Options --->
>>> [*] Generate Debug Symbols
>>>
>>> $ make -j
>>>
>>> Flash nuttx.bin
>>>
>>> Connect to the board using OpenOCD + STLink-V2:
>>>
>>> $ sudo openocd -f interface/stlink-v2.cfg -f target/stm32f7x.cfg
>>>
>>> In another terminal:
>>>
>>> $ gdb nuttx
>>> (gdb) target remote localhost:3333
>>> (gdb) monitor reset
>>> (gdb) load nuttx
>>> (gdb) b nx_start
>>> (gdb) c
>>>
>>> BR,
>>>
>>> Alan
>>>
>>> On 6/10/23, Mark Stevens <ma...@thepcsite.co.uk> wrote:
>>>> So I’m admitting defeat on this problem and I need some help please.
>>>>
>>>> I’m trying to work out the magic incantations I need to weave to create
>> a
>>>> NuttX ELF file that I can use with GDB. To be clear this is the OS ELF
>> file
>>>> that I can use on the host computer.
>>>>
>>>> I am currently targeting the Pico boards but I have also had this
>> problem
>>>> with the STM32F767 Discovery board as well. I have opened connect to
>> the
>>>> boards in both cases and I am now trying to debug the OS on the board.
>>>>
>>>> Can anyone point me in the right direction - I’m sure it is going to be
>>>> simple, I just need pointing in the right direction.
>>>>
>>>> Thanks in advance,
>>>> Mark
>>>> _____________________________
>>>> Blog: blog.thepcsite.co.uk
>>>> Twitter: @nevynuk
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>
>>
Re: STM32 and GDB - How do I generate the ELF file?
Posted by Petro Karashchenko <pe...@gmail.com>.
The nuttx file is actually an ELF file, but without .elf extension.
BR,
Petro
On Sun, Jun 11, 2023, 10:39 AM Mark Stevens <ma...@thepcsite.co.uk> wrote:
> I think the missing piece of information is that the nuttx file contains
> the debug symbols.
>
> Thanks for your time and help.
>
> Regards,
> Mark
> _____________________________
> Blog: blog.thepcsite.co.uk
> Twitter: @nevynuk
>
>
>
>
>
> > On 10 Jun 2023, at 22:10, Alan C. Assis <ac...@gmail.com> wrote:
> >
> > Hi Mark,
> >
> > Could you please try these magical steps:
> >
> > $ make distclean
> >
> > $ ./tools/configure.sh stm32f777zit6-meadow:nsh
> >
> > $ make menuconfig
> >
> > Build Setup --->
> > Debug Options --->
> > [*] Generate Debug Symbols
> >
> > $ make -j
> >
> > Flash nuttx.bin
> >
> > Connect to the board using OpenOCD + STLink-V2:
> >
> > $ sudo openocd -f interface/stlink-v2.cfg -f target/stm32f7x.cfg
> >
> > In another terminal:
> >
> > $ gdb nuttx
> > (gdb) target remote localhost:3333
> > (gdb) monitor reset
> > (gdb) load nuttx
> > (gdb) b nx_start
> > (gdb) c
> >
> > BR,
> >
> > Alan
> >
> > On 6/10/23, Mark Stevens <ma...@thepcsite.co.uk> wrote:
> >> So I’m admitting defeat on this problem and I need some help please.
> >>
> >> I’m trying to work out the magic incantations I need to weave to create
> a
> >> NuttX ELF file that I can use with GDB. To be clear this is the OS ELF
> file
> >> that I can use on the host computer.
> >>
> >> I am currently targeting the Pico boards but I have also had this
> problem
> >> with the STM32F767 Discovery board as well. I have opened connect to
> the
> >> boards in both cases and I am now trying to debug the OS on the board.
> >>
> >> Can anyone point me in the right direction - I’m sure it is going to be
> >> simple, I just need pointing in the right direction.
> >>
> >> Thanks in advance,
> >> Mark
> >> _____________________________
> >> Blog: blog.thepcsite.co.uk
> >> Twitter: @nevynuk
> >>
> >>
> >>
> >>
> >>
> >>
>
>
Re: STM32 and GDB - How do I generate the ELF file?
Posted by Mark Stevens <ma...@thepcsite.co.uk>.
I think the missing piece of information is that the nuttx file contains the debug symbols.
Thanks for your time and help.
Regards,
Mark
_____________________________
Blog: blog.thepcsite.co.uk
Twitter: @nevynuk
> On 10 Jun 2023, at 22:10, Alan C. Assis <ac...@gmail.com> wrote:
>
> Hi Mark,
>
> Could you please try these magical steps:
>
> $ make distclean
>
> $ ./tools/configure.sh stm32f777zit6-meadow:nsh
>
> $ make menuconfig
>
> Build Setup --->
> Debug Options --->
> [*] Generate Debug Symbols
>
> $ make -j
>
> Flash nuttx.bin
>
> Connect to the board using OpenOCD + STLink-V2:
>
> $ sudo openocd -f interface/stlink-v2.cfg -f target/stm32f7x.cfg
>
> In another terminal:
>
> $ gdb nuttx
> (gdb) target remote localhost:3333
> (gdb) monitor reset
> (gdb) load nuttx
> (gdb) b nx_start
> (gdb) c
>
> BR,
>
> Alan
>
> On 6/10/23, Mark Stevens <ma...@thepcsite.co.uk> wrote:
>> So I’m admitting defeat on this problem and I need some help please.
>>
>> I’m trying to work out the magic incantations I need to weave to create a
>> NuttX ELF file that I can use with GDB. To be clear this is the OS ELF file
>> that I can use on the host computer.
>>
>> I am currently targeting the Pico boards but I have also had this problem
>> with the STM32F767 Discovery board as well. I have opened connect to the
>> boards in both cases and I am now trying to debug the OS on the board.
>>
>> Can anyone point me in the right direction - I’m sure it is going to be
>> simple, I just need pointing in the right direction.
>>
>> Thanks in advance,
>> Mark
>> _____________________________
>> Blog: blog.thepcsite.co.uk
>> Twitter: @nevynuk
>>
>>
>>
>>
>>
>>
Re: STM32 and GDB - How do I generate the ELF file?
Posted by "Alan C. Assis" <ac...@gmail.com>.
Hi Mark,
Could you please try these magical steps:
$ make distclean
$ ./tools/configure.sh stm32f777zit6-meadow:nsh
$ make menuconfig
Build Setup --->
Debug Options --->
[*] Generate Debug Symbols
$ make -j
Flash nuttx.bin
Connect to the board using OpenOCD + STLink-V2:
$ sudo openocd -f interface/stlink-v2.cfg -f target/stm32f7x.cfg
In another terminal:
$ gdb nuttx
(gdb) target remote localhost:3333
(gdb) monitor reset
(gdb) load nuttx
(gdb) b nx_start
(gdb) c
BR,
Alan
On 6/10/23, Mark Stevens <ma...@thepcsite.co.uk> wrote:
> So I’m admitting defeat on this problem and I need some help please.
>
> I’m trying to work out the magic incantations I need to weave to create a
> NuttX ELF file that I can use with GDB. To be clear this is the OS ELF file
> that I can use on the host computer.
>
> I am currently targeting the Pico boards but I have also had this problem
> with the STM32F767 Discovery board as well. I have opened connect to the
> boards in both cases and I am now trying to debug the OS on the board.
>
> Can anyone point me in the right direction - I’m sure it is going to be
> simple, I just need pointing in the right direction.
>
> Thanks in advance,
> Mark
> _____________________________
> Blog: blog.thepcsite.co.uk
> Twitter: @nevynuk
>
>
>
>
>
>