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