Cortex-M debugging doesn't work

I followed the steps on how to load and debug application on Cortex-M.
On my Ubuntu 22.04 VM I downloaded exactly the same toolchain gcc-arm-11.2-2022.02-x86_64-arm-none-eabi.tar.xz but the problem is that
./arm-none-eabi-gdb --version
./arm-none-eabi-gdb: error while loading shared libraries: cannot open shared object file: No such file or directory

I searched on the web and I found someone suggesting to install

Can you verify, please?

Hi @vix,

“ncurses” is required by GDB to use the TUI (terminal user interface) mode. So you need to install it in your system by running:

$ sudo apt-get install libncurses5 libncurses5-dev

Please check if that solves your issue. You might need to install more dependencies if more errors appear in your system.

Best Regards,

The situation is not so easy.
It seems that the GDB included in the toolchain gcc-arm-11.2-2022.02-x86_64-arm-none-eabi.tar.xz cannot work on Ubuntu 22.04 and maybe 20.04 (see this topic on ARM community).

Following that topic you can find the “solution”

Thank you for pointing out the issues around python incompatibility.
For Ubuntu 20.04, Python 3.6 could be installed through the PPA route as mentioned in 5842 – arm-none-eabi-gdb 11.2 doesn't start on Ubuntu 20.04 host, however, this might not work for Ubuntu 22.04.
For the next release, we are working on updating the version of Python that is used in GDB, so that there will be better compatibility for the newer linux distros. Following on from that, we do want to take a look at other approaches, such as the two binary approach or static linking approach, to improve on the compatibility.

I can confirm that this workaround doesn’t work on Ubuntu 22.04.
I read that hfranco user were able to use Docker Container with Ubuntu 20.04.
Are you that user @hfranco.tx?
If this is the case, I suggest to add some info to Toradex documentation, advising the developer to use Ubuntu 20.04 (and not 22.04)

And I can add that the gdb incliuded with the new toolchain arm-gnu-toolchain-12.2.rel1-x86_64-arm-none-eabi.tar.xz doesn’t work on Ubuntu 22.04.
I’ve just opened a ticket on ARM Community.

Hi @vix,

Yes, it was me. This issue is related to a python library unavailable on Ubuntu 22.04. So instead we need to compile this library ourselves and point out to GDB where it’s located. The steps that I’ve done are described in this article: Cortex-M JTAG Debugging | Toradex Developer Center, on this part:

Apparently, the ARM GDB developers didn’t update their python libraries yet, so instead, we need to do this workaround. Can you please check if that solves your issue?

Best Regards,

Hi @hfranco.tx
if I follow the steps and try to compile Python-3.6 make install -j$(nproc) I get this error :scream:

	./python -E -m lib2to3.pgen2.driver /home/ubuntu/python3.6/lib/python3.6/lib2to3/PatternGrammar.txt
Generating grammar tables from /home/ubuntu/python3.6/lib/python3.6/lib2to3/PatternGrammar.txt
Writing grammar tables to /home/ubuntu/python3.6/lib/python3.6/lib2to3/
if test "xupgrade" != "xno"  ; then \
	case upgrade in \
		upgrade) ensurepip="--upgrade" ;; \
		install|*) ensurepip="" ;; \
	esac; \
	LD_LIBRARY_PATH=/home/ubuntu/python3.6 ./python -E -m ensurepip \
		$ensurepip --root=/ ; \
Segmentation fault (core dumped)
make: *** [Makefile:1102: install] Error 139

Moreover there is typo in the steps Cortex-M JTAG Debugging | Toradex Developer Center

Hi @vix,

I followed the exact same steps and it compiled successfully. I’m not sure where this error is coming from, but regardless of this error, are you able to run the GDB with the LD_LIBRARY_PATH now?

export LD_LIBRARY_PATH=/home/$USER/python3.6_lib/lib 

Thanks! I will fix the article.

Best Regards,

Even if the compilation fails with segmentation fault, I verified that

find . -name



as expected (and as in the article Cortex-M JTAG Debugging | Toradex Developer Center).

So I exported the path

export LD_LIBRARY_PATH=/home/$USER/python3.6/lib

(please notice another typo - the right export should be /home/$USER/python3.6/lib and not /home/$USER/python3.6_lib/lib)
and I can run gdb

Hi @vix,

Great! I believe I will remove the part

$ make install -j$(nproc)

since it’s not necessary.

Thanks! I will fix this one as well. Thanks for reporting.

Best Regards,

I would suggest addig the same necessary steps for Ubuntu 22.04 to the section Download the GCC Toolchain

1 Like

Hello @hfranco.tx
I tried to sertup a fresh environment and I discovered that:

  • after make -j$(nproc), find . -name returns ONLY ./
  • it’s only AFTER make install -j$(nproc) (that on my PC fails as I described above), that find . -name returns ./ AND .lib//

And without ./lib/, I can’t run GDB, even if I tried to export

export LD_LIBRARY_PATH=/home/$USER/python3.6

(without the final lib/)

You have to re-add the step
$ make install -j$(nproc)
that is necessary, even if it fails.

I confrim one more time that only the toolchain gcc-arm-11.2-2022.02-x86_64-arm-none-eabi.tar.xz can be used.
The new arm-gnu-toolchain-12.2.rel1-x86_64-arm-none-eabi.tar.xz doesn’t work at the moment.

Hi @vix,

Thanks for letting me know. I have a fresh install of a new OS on my computer, I will also reproduce the steps and update the article.

Good to know! Thanks for sharing that as well. I personally always use the 11.2-2022.02 version and haven’t tried anything new yet.


Best Regards,

In case someone is interested, this is the topic on ARM community where I’ve been discussing why the new toolchain arm-gnu-toolchain-12.2.rel1-x86_64-arm-none-eabi.tar.xz doesn’t work on Ubuntu 22.04.

1 Like

Hello @hfranco.tx
I’ve just found another issue while trying to setup my new development machine iwht Ubuntu 22.04.
The same steps described here and that worked some weeks ago, now don’t work anymore because

$ sudo apt-get install libncursesw5 libpython3.6-dev


Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package libpython3.6-dev
E: Couldn't find any package by glob 'libpython3.6-dev'
E: Couldn't find any package by regex 'libpython3.6-dev'

Is it possible that Python 3.6 has been removed by Ubuntu 22.04 upstream?
Or something like that?

Hi @vix,

for libpython3.6, you will need to compile them manually, as we previously discussed in this article:

After compiling it manually, you can run

$ export LD_LIBRARY_PATH=/home/$USER/python3.6/lib

to tell GDB where this library is. Have you tried that already?

Yes, they were removed from 22.04, but that’s still a dependency from the GDB ARM. I’m not sure if they released a new version and fixed this problem, but the last time I tried it was still a problem.

Best Regards,

Hi @hfranco.tx
yes, I remember that I have to manually compile libpython3.6 (and I did it on my new machine too).

The problem is that some weeks ago the first command

sudo apt-get install libncursesw5 libpython3.6-dev

worked on Ubuntu-22.04.
Now it fails, and even if I follow all the other steps, compiling successfully Python3.6, gdb server doesn’t work.

Now (March 30th, 2023) It works on Ubuntu 22.04 only if the first command is

sudo apt-get install libncursesw5

without trying to apt-getting libpython3.6-dev.
Then, all the other steps to compile Python3.6.

Feel free to improve the documentation, if you like.

Hi @vix,

I got it now, ok, thanks for the recommendation, I will report to our marketing team.

Thanks for pointing this out. Probably this library as removed from the feeds.

Best Regards,