Not a long time ago, I’ve updated my home computer with fresh Xubintu 24.04 LTS, so I need to reinstall/resetup my develop enviroment for STM32
If you had an experience with installation of ARM GNU Toolchain on Linux, I guess you also had a painfull experience with ancient and non-working installation instruction for Linux provided by ARM. In general, installtion procedure is quite simple: just unpack an archive, than add «bin» directory into PATH variable.
But! The main issue is a GDB binary with python-based TUI (terminal user interface). It is linked with the old Python 3.8 library, and legacy (plus removed in fresh distros) libncurses5 library.
On the previous Xubuntu 22.04, I’ve used a solution with a custom repository, but for the current Xubintu 24.04 Python 3.8 doesn’t exist, and libncurses5 package has been removed from repositories. How can we solve this problem?
After a litte search, I’ve found a suitable solution on StackOverflow. Just build your own GDB with actual Python for you system! It is quite simple!
I’ve checked this instruction, and did a small change in the tutorial: replaced final «make install» command on a deb-file generation, because simple «make install» just copies compiled binary and other files into your system directories without any control. Please, DON’T DO IT on modern repository-based Linux systems! All software MUST BE installed using a system package manger.
OK. Let’s installation begin! I’m going to do all my action in «/storage/Temp» directory.
Part I. GDB compilation
At first, let’s install all required packages for a compilation
| 1 | $ sudo apt-get install -y build-essential libz-dev libexpat1-dev libncurses-dev libgmp-dev libmpfr-dev libisl-dev libreadline-dev libpython3-dev texinfo texlive | 
Then, fetch fresh sources for GDB
| 1 | $ wget https://ftp.gnu.org/gnu/gdb/gdb-14.2.tar.xz | 
Unpack it
| 1 | $ tar Jxf gdb-14.2.tar.xz | 
Create a directory for compilation
| 1 | $ mkdir gdb-build | 
And the directories for a future package’s tree
| 1 | $ mkdir arm-none-eabi-gdb | 
| 1 | $ mkdir arm-none-eabi-gdb/usr | 
Move to the build directory
| 1 | $ cd gdb-build | 
And run pre-configuration. Please mention «—prefix» option. It points on our «package’s tree» dir
| 1 | $ ../gdb-14.2/configure --with-expat --target=arm-none-eabi --program-prefix=arm-none-eabi- --with-source-highlight --with-python=$(which python3) --enable-tui --prefix=/storage/Temp/arm-none-eabi-gdb/usr | 
Run compilation process
| 1 | $ make -j8 all | 
And finally, make an «installation»
| 1 | $ make install | 
Well, let’s check what we have in our installation dir
| 1 | $ cd /storage/Temp/arm-none-eabi-gdb/usr/bin/ | 
| 1 2 3 | $ ls arm-none-eabi-gdb  arm-none-eabi-gdb-add-index  arm-none-eabi-run | 
Great! We have «arm-none-eabi-gdb» binary. But we have to check, which kind of libraries linked to our binary.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | $ ldd arm-none-eabi-gdb 	linux-vdso.so.1 (0x00007ffff49cd000) 	libncursesw.so.6 => /lib/x86_64-linux-gnu/libncursesw.so.6 (0x0000796ab03c4000) 	libtinfo.so.6 => /lib/x86_64-linux-gnu/libtinfo.so.6 (0x0000796ab0390000) 	libpython3.12.so.1.0 => /lib/x86_64-linux-gnu/libpython3.12.so.1.0 (0x0000796aafa00000) 	libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x0000796ab0365000) 	libmpfr.so.6 => /lib/x86_64-linux-gnu/libmpfr.so.6 (0x0000796ab02aa000) 	libgmp.so.10 => /lib/x86_64-linux-gnu/libgmp.so.10 (0x0000796aaf97c000) 	libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x0000796aaf600000) 	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x0000796aaf893000) 	libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x0000796aaf5d3000) 	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x0000796aaf200000) 	libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x0000796aaf5b7000) 	/lib64/ld-linux-x86-64.so.2 (0x0000796ab0e0e000) | 
Success! Our custom GDB binary linked with the fresh system Python, and libncurses libraries! Save this command output, it will be usefull for future steps.
Part II. Build custom «deb» package file
Now we can build our custom «deb» package for the installation.
| 1 | $ cd /storage/Temp/arm-none-eabi-gdb/ | 
| 1 | $ mkdir DEBIAN && cd DEBIAN | 
| 1 | $ nano control | 
Add follwing text into «control» file
| 1 2 3 4 5 6 | Package: arm-none-eabi-gdb Version: 4.12 Maintainer: Igor Volodin Architecture: amd64 Depends: libc6, zlib1g, libgcc-s1, libstdc++6, libgmp10, libmpfr6, libexpat1, libpython3-stdlib, libtinfo6, libncurses6, libncursesw6           Description: GDB for ARM with Python TUI | 
Also, I have to mention, how to collect a list of packages for the «Depends» option. Look at the output of «ldd» command. It contains list of required shared libraries. Just get the library name from the output (for example, I will use «libexpat»), and find similar in the installed packages.
| 1 2 3 4 5 | $ dpkg -l | grep libexpat ii  libexpat1:amd64                                2.6.1-2build1                             amd64        XML parsing C library - runtime library ii  libexpat1-dev:amd64                            2.6.1-2build1                             amd64        XML parsing C library - development kit | 
OK, we have «libexpat1» and «libexpat1-dev». The second is just for compilation from sources, and not needed for the our binary package. Re-check our choice, by listing all files, related to the «libexpat1» package. Yes, it includes /usr/lib/x86_64-linux-gnu/libexpat.so.1 file, so we can add «libexpat1» into «Depends» section.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | $ dpkg -L libexpat1 /. /usr /usr/lib /usr/lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu/libexpat.so.1.9.1 /usr/lib/x86_64-linux-gnu/libexpatw.so.1.9.1 /usr/share /usr/share/doc /usr/share/doc/libexpat1 /usr/share/doc/libexpat1/AUTHORS /usr/share/doc/libexpat1/changelog.Debian.gz /usr/share/doc/libexpat1/copyright /usr/lib/x86_64-linux-gnu/libexpat.so.1 /usr/lib/x86_64-linux-gnu/libexpatw.so.1 | 
Right now we have a «package installation tree» in «/storage/Temp/arm-none-eabi-gdb» directory. And on this step, better to check, have we intersections with already installed files in our system, or not. Our package tree has «gdb» directory in /storage/Temp/arm-none-eabi-gdb/usr/share/. And it contains something.
| 1 2 3 4 | $ ls /storage/Temp/arm-none-eabi-gdb/usr/share/gdb python  syscalls  system-gdbinit | 
But our current system directory also has same directory and files in /usr/share/!
| 1 2 3 | $  ls /usr/share/gdb/ auto-load  python  syscalls  system-gdbinit | 
Unfortunallty, I don’t know, how package mainteiner have to resolve similar issues. I’ve removed confilcting directories and files form «package installation tree»
| 1 | $ rm -rf /storage/Temp/arm-none-eabi-gdb/usr/share/gdb /storage/Temp/arm-none-eabi-gdb/usr/include/gdb | 
Well, it is time to build the package. Move to the top directory
| 1 | $ cd /storage/Temp/ | 
And build the package
| 1 2 3 | $ dpkg-deb --build arm-none-eabi-gdb dpkg-deb: building package 'arm-none-eabi-gdb' in 'arm-none-eabi-gdb.deb'. | 
Recheck what the package contains
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | $ dpkg -c arm-none-eabi-gdb.deb drwxrwxr-x igor/igor         0 2024-06-19 21:25 ./ drwxrwxr-x igor/igor         0 2024-06-19 21:16 ./usr/ drwxrwxr-x igor/igor         0 2024-06-19 21:16 ./usr/bin/ -rwxr-xr-x igor/igor 163716584 2024-06-19 21:16 ./usr/bin/arm-none-eabi-gdb -rwxr-xr-x igor/igor      4627 2024-06-19 21:16 ./usr/bin/arm-none-eabi-gdb-add-index -rwxr-xr-x igor/igor   8545496 2024-06-19 21:16 ./usr/bin/arm-none-eabi-run drwxrwxr-x igor/igor         0 2024-06-19 23:19 ./usr/include/ drwxrwxr-x igor/igor         0 2024-06-19 21:16 ./usr/include/sim/ -rw-r--r-- igor/igor     12471 2024-06-19 21:16 ./usr/include/sim/callback.h -rw-r--r-- igor/igor      9969 2024-06-19 21:16 ./usr/include/sim/sim.h drwxrwxr-x igor/igor         0 2024-06-19 21:16 ./usr/lib/ -rw-r--r-- igor/igor   9277172 2024-06-19 21:16 ./usr/lib/libarm-none-eabi-sim.a drwxrwxr-x igor/igor         0 2024-06-19 21:46 ./usr/share/ drwxrwxr-x igor/igor         0 2024-06-19 21:16 ./usr/share/doc/ drwxrwxr-x igor/igor         0 2024-06-19 21:16 ./usr/share/doc/arm/ -rw-r--r-- igor/igor       779 2024-06-19 21:16 ./usr/share/doc/arm/README drwxrwxr-x igor/igor         0 2024-06-19 21:16 ./usr/share/info/ -rw-r--r-- igor/igor     48920 2024-06-19 21:16 ./usr/share/info/annotate.info -rw-r--r-- igor/igor    698473 2024-06-19 21:16 ./usr/share/info/bfd.info -rw-r--r-- igor/igor     90873 2024-06-19 21:16 ./usr/share/info/ctf-spec.info -rw-rw-r-- igor/igor       990 2024-06-19 21:16 ./usr/share/info/dir -rw-r--r-- igor/igor     29050 2024-06-19 21:16 ./usr/share/info/gdb.info -rw-r--r-- igor/igor    301325 2024-06-19 21:16 ./usr/share/info/gdb.info-1 -rw-r--r-- igor/igor    300368 2024-06-19 21:16 ./usr/share/info/gdb.info-2 -rw-r--r-- igor/igor    302491 2024-06-19 21:16 ./usr/share/info/gdb.info-3 -rw-r--r-- igor/igor    308967 2024-06-19 21:16 ./usr/share/info/gdb.info-4 -rw-r--r-- igor/igor    287286 2024-06-19 21:16 ./usr/share/info/gdb.info-5 -rw-r--r-- igor/igor    299564 2024-06-19 21:16 ./usr/share/info/gdb.info-6 -rw-r--r-- igor/igor    302126 2024-06-19 21:16 ./usr/share/info/gdb.info-7 -rw-r--r-- igor/igor    384849 2024-06-19 21:16 ./usr/share/info/gdb.info-8 -rw-r--r-- igor/igor    249330 2024-06-19 21:16 ./usr/share/info/gdb.info-9 -rw-r--r-- igor/igor     29825 2024-06-19 21:16 ./usr/share/info/sframe-spec.info -rw-r--r-- igor/igor    184719 2024-06-19 21:16 ./usr/share/info/stabs.info drwxrwxr-x igor/igor         0 2024-06-19 21:16 ./usr/share/locale/ drwxrwxr-x igor/igor         0 2024-06-19 21:16 ./usr/share/locale/da/ drwxrwxr-x igor/igor         0 2024-06-19 21:16 ./usr/share/locale/da/LC_MESSAGES/ -rw-r--r-- igor/igor    153602 2024-06-19 21:16 ./usr/share/locale/da/LC_MESSAGES/bfd.mo -rw-r--r-- igor/igor     17551 2024-06-19 21:16 ./usr/share/locale/da/LC_MESSAGES/opcodes.mo drwxrwxr-x igor/igor         0 2024-06-19 21:16 ./usr/share/locale/de/ drwxrwxr-x igor/igor         0 2024-06-19 21:16 ./usr/share/locale/de/LC_MESSAGES/ -rw-r--r-- igor/igor     54340 2024-06-19 21:16 ./usr/share/locale/de/LC_MESSAGES/opcodes.mo drwxrwxr-x igor/igor         0 2024-06-19 21:16 ./usr/share/locale/es/ drwxrwxr-x igor/igor         0 2024-06-19 21:16 ./usr/share/locale/es/LC_MESSAGES/ -rw-r--r-- igor/igor    208584 2024-06-19 21:16 ./usr/share/locale/es/LC_MESSAGES/bfd.mo -rw-r--r-- igor/igor     39868 2024-06-19 21:16 ./usr/share/locale/es/LC_MESSAGES/opcodes.mo drwxrwxr-x igor/igor         0 2024-06-19 21:16 ./usr/share/locale/fi/ drwxrwxr-x igor/igor         0 2024-06-19 21:16 ./usr/share/locale/fi/LC_MESSAGES/ -rw-r--r-- igor/igor    162673 2024-06-19 21:16 ./usr/share/locale/fi/LC_MESSAGES/bfd.mo -rw-r--r-- igor/igor     31220 2024-06-19 21:16 ./usr/share/locale/fi/LC_MESSAGES/opcodes.mo drwxrwxr-x igor/igor         0 2024-06-19 21:16 ./usr/share/locale/fr/ drwxrwxr-x igor/igor         0 2024-06-19 21:16 ./usr/share/locale/fr/LC_MESSAGES/ -rw-r--r-- igor/igor    239357 2024-06-19 21:16 ./usr/share/locale/fr/LC_MESSAGES/bfd.mo -rw-r--r-- igor/igor     57025 2024-06-19 21:16 ./usr/share/locale/fr/LC_MESSAGES/opcodes.mo drwxrwxr-x igor/igor         0 2024-06-19 21:16 ./usr/share/locale/ga/ drwxrwxr-x igor/igor         0 2024-06-19 21:16 ./usr/share/locale/ga/LC_MESSAGES/ -rw-r--r-- igor/igor     30700 2024-06-19 21:16 ./usr/share/locale/ga/LC_MESSAGES/opcodes.mo drwxrwxr-x igor/igor         0 2024-06-19 21:16 ./usr/share/locale/hr/ drwxrwxr-x igor/igor         0 2024-06-19 21:16 ./usr/share/locale/hr/LC_MESSAGES/ -rw-r--r-- igor/igor      5144 2024-06-19 21:16 ./usr/share/locale/hr/LC_MESSAGES/bfd.mo drwxrwxr-x igor/igor         0 2024-06-19 21:16 ./usr/share/locale/id/ drwxrwxr-x igor/igor         0 2024-06-19 21:16 ./usr/share/locale/id/LC_MESSAGES/ -rw-r--r-- igor/igor    144237 2024-06-19 21:16 ./usr/share/locale/id/LC_MESSAGES/bfd.mo -rw-r--r-- igor/igor     30272 2024-06-19 21:16 ./usr/share/locale/id/LC_MESSAGES/opcodes.mo drwxrwxr-x igor/igor         0 2024-06-19 21:16 ./usr/share/locale/it/ drwxrwxr-x igor/igor         0 2024-06-19 21:16 ./usr/share/locale/it/LC_MESSAGES/ -rw-r--r-- igor/igor     26349 2024-06-19 21:16 ./usr/share/locale/it/LC_MESSAGES/opcodes.mo drwxrwxr-x igor/igor         0 2024-06-19 21:16 ./usr/share/locale/ja/ drwxrwxr-x igor/igor         0 2024-06-19 21:16 ./usr/share/locale/ja/LC_MESSAGES/ -rw-r--r-- igor/igor    134646 2024-06-19 21:16 ./usr/share/locale/ja/LC_MESSAGES/bfd.mo drwxrwxr-x igor/igor         0 2024-06-19 21:16 ./usr/share/locale/ka/ drwxrwxr-x igor/igor         0 2024-06-19 21:16 ./usr/share/locale/ka/LC_MESSAGES/ -rw-r--r-- igor/igor      4993 2024-06-19 21:16 ./usr/share/locale/ka/LC_MESSAGES/bfd.mo drwxrwxr-x igor/igor         0 2024-06-19 21:16 ./usr/share/locale/nl/ drwxrwxr-x igor/igor         0 2024-06-19 21:16 ./usr/share/locale/nl/LC_MESSAGES/ -rw-r--r-- igor/igor     25259 2024-06-19 21:16 ./usr/share/locale/nl/LC_MESSAGES/opcodes.mo drwxrwxr-x igor/igor         0 2024-06-19 21:16 ./usr/share/locale/pt/ drwxrwxr-x igor/igor         0 2024-06-19 21:16 ./usr/share/locale/pt/LC_MESSAGES/ -rw-r--r-- igor/igor    218318 2024-06-19 21:16 ./usr/share/locale/pt/LC_MESSAGES/bfd.mo drwxrwxr-x igor/igor         0 2024-06-19 21:16 ./usr/share/locale/pt_BR/ drwxrwxr-x igor/igor         0 2024-06-19 21:16 ./usr/share/locale/pt_BR/LC_MESSAGES/ -rw-r--r-- igor/igor     56398 2024-06-19 21:16 ./usr/share/locale/pt_BR/LC_MESSAGES/opcodes.mo drwxrwxr-x igor/igor         0 2024-06-19 21:16 ./usr/share/locale/ro/ drwxrwxr-x igor/igor         0 2024-06-19 21:16 ./usr/share/locale/ro/LC_MESSAGES/ -rw-r--r-- igor/igor    238628 2024-06-19 21:16 ./usr/share/locale/ro/LC_MESSAGES/bfd.mo -rw-r--r-- igor/igor     56150 2024-06-19 21:16 ./usr/share/locale/ro/LC_MESSAGES/opcodes.mo drwxrwxr-x igor/igor         0 2024-06-19 21:16 ./usr/share/locale/ru/ drwxrwxr-x igor/igor         0 2024-06-19 21:16 ./usr/share/locale/ru/LC_MESSAGES/ -rw-r--r-- igor/igor    292997 2024-06-19 21:16 ./usr/share/locale/ru/LC_MESSAGES/bfd.mo drwxrwxr-x igor/igor         0 2024-06-19 21:16 ./usr/share/locale/rw/ drwxrwxr-x igor/igor         0 2024-06-19 21:16 ./usr/share/locale/rw/LC_MESSAGES/ -rw-r--r-- igor/igor       388 2024-06-19 21:16 ./usr/share/locale/rw/LC_MESSAGES/bfd.mo drwxrwxr-x igor/igor         0 2024-06-19 21:16 ./usr/share/locale/sr/ drwxrwxr-x igor/igor         0 2024-06-19 21:16 ./usr/share/locale/sr/LC_MESSAGES/ -rw-r--r-- igor/igor    292730 2024-06-19 21:16 ./usr/share/locale/sr/LC_MESSAGES/bfd.mo -rw-r--r-- igor/igor     67410 2024-06-19 21:16 ./usr/share/locale/sr/LC_MESSAGES/opcodes.mo drwxrwxr-x igor/igor         0 2024-06-19 21:16 ./usr/share/locale/sv/ drwxrwxr-x igor/igor         0 2024-06-19 21:16 ./usr/share/locale/sv/LC_MESSAGES/ -rw-r--r-- igor/igor    155219 2024-06-19 21:16 ./usr/share/locale/sv/LC_MESSAGES/bfd.mo -rw-r--r-- igor/igor     55522 2024-06-19 21:16 ./usr/share/locale/sv/LC_MESSAGES/opcodes.mo drwxrwxr-x igor/igor         0 2024-06-19 21:16 ./usr/share/locale/tr/ drwxrwxr-x igor/igor         0 2024-06-19 21:16 ./usr/share/locale/tr/LC_MESSAGES/ -rw-r--r-- igor/igor     69552 2024-06-19 21:16 ./usr/share/locale/tr/LC_MESSAGES/bfd.mo -rw-r--r-- igor/igor     16117 2024-06-19 21:16 ./usr/share/locale/tr/LC_MESSAGES/opcodes.mo drwxrwxr-x igor/igor         0 2024-06-19 21:16 ./usr/share/locale/uk/ drwxrwxr-x igor/igor         0 2024-06-19 21:16 ./usr/share/locale/uk/LC_MESSAGES/ -rw-r--r-- igor/igor    299719 2024-06-19 21:16 ./usr/share/locale/uk/LC_MESSAGES/bfd.mo -rw-r--r-- igor/igor     70903 2024-06-19 21:16 ./usr/share/locale/uk/LC_MESSAGES/opcodes.mo drwxrwxr-x igor/igor         0 2024-06-19 21:16 ./usr/share/locale/vi/ drwxrwxr-x igor/igor         0 2024-06-19 21:16 ./usr/share/locale/vi/LC_MESSAGES/ -rw-r--r-- igor/igor    160341 2024-06-19 21:16 ./usr/share/locale/vi/LC_MESSAGES/bfd.mo -rw-r--r-- igor/igor     33633 2024-06-19 21:16 ./usr/share/locale/vi/LC_MESSAGES/opcodes.mo drwxrwxr-x igor/igor         0 2024-06-19 21:16 ./usr/share/locale/zh_CN/ drwxrwxr-x igor/igor         0 2024-06-19 21:16 ./usr/share/locale/zh_CN/LC_MESSAGES/ -rw-r--r-- igor/igor     17866 2024-06-19 21:16 ./usr/share/locale/zh_CN/LC_MESSAGES/bfd.mo -rw-r--r-- igor/igor     20533 2024-06-19 21:16 ./usr/share/locale/zh_CN/LC_MESSAGES/opcodes.mo drwxrwxr-x igor/igor         0 2024-06-19 21:16 ./usr/share/man/ drwxrwxr-x igor/igor         0 2024-06-19 21:16 ./usr/share/man/man1/ -rw-r--r-- igor/igor      6536 2024-06-19 21:16 ./usr/share/man/man1/arm-none-eabi-gdb-add-index.1 -rw-r--r-- igor/igor     16840 2024-06-19 21:16 ./usr/share/man/man1/arm-none-eabi-gdb.1 -rw-r--r-- igor/igor     14121 2024-06-19 21:16 ./usr/share/man/man1/arm-none-eabi-gdbserver.1 drwxrwxr-x igor/igor         0 2024-06-19 21:16 ./usr/share/man/man5/ -rw-r--r-- igor/igor      7873 2024-06-19 21:16 ./usr/share/man/man5/arm-none-eabi-gdbinit.5 | 
Now, we can install it using dpkg
| 1 | $ sudo dpkg -i arm-none-eabi-gdb.deb | 
Check it
| 1 2 3 4 5 6 7 | $ sudo dpkg -l | grep arm-none ii  arm-none-eabi-gdb  4.12     amd64        GDB for ARM with Python TUI $ which arm-none-eabi-gdb /usr/bin/arm-none-eabi-gdb | 
 
					