{"id":12,"date":"2019-12-08T01:37:57","date_gmt":"2019-12-08T00:37:57","guid":{"rendered":"http:\/\/pmortensen.eu\/2\/?p=12"},"modified":"2023-11-08T15:11:18","modified_gmt":"2023-11-08T14:11:18","slug":"arm-toolchain-ubuntu-19-04-black-magic-probe","status":"publish","type":"post","link":"https:\/\/pmortensen.eu\/world2\/2019\/12\/08\/arm-toolchain-ubuntu-19-04-black-magic-probe\/","title":{"rendered":"Getting the ARM toolchain to work on Ubuntu 19.04 and later (including for Black Magic Probe (BMP))"},"content":{"rendered":"<p>The short version is: Download the tar ball from arm.com, extract, add the \/bin folder in the extracted to the path, and make <a href=\"https:\/\/en.wikipedia.org\/wiki\/GNU_Debugger\">GDB<\/a> work by adding symbolic links in \/usr\/lib\/x86_64-linux-gnu for the expected version 5 of the libraries &#8220;libncurses&#8221; and &#8220;libtinfo&#8221; (to point to the existing\/newest versions of those libraries).<\/p>\n<h2>Introduction<\/h2>\n<p>This post contains complete instructions to set up the GCC cross-compiler from scratch on a newly installed <a href=\"https:\/\/en.wikipedia.org\/wiki\/Ubuntu_version_history#Ubuntu_19.04_(Disco_Dingo)\">Ubuntu&nbsp;19.04<\/a> (Disco Dingo) or later (no extra packages assumed to be installed), compiling a &#8220;Hello, World!&#8221; (LED blink) program for an ARM board (<a href=\"https:\/\/1bitsy.org\/\">1Bitsy<\/a>), flashing it to the board using GDB and the <a href=\"https:\/\/1bitsquared.com\/products\/black-magic-probe\">Black Magic Probe<\/a>, and interactively single-stepping the program in GDB.<\/p>\n<p>The installation part is completely general and the LED blink part only requires specifying another processor (as the used library works on multiple ARM processors). The flash and debugging part in GDB is dependent on an adapter that implements the GDB debugging protocol (Black Magic Probe is used as an example here).<\/p>\n<p>Only the last part is specific for Black Magic Probe.<\/p>\n<h2>The problem<\/h2>\n<p>A <a href=\"http:\/\/pvm-professionalengineering.blogspot.com\/2017\/06\/getting-started-with-1bitsy-and-black.html\">previous blog post<\/a> covered using apt-get to install the GCC cross-compiler for ARM:<\/p>\n<pre class=\"brush: plain; gutter: false; title: ; notranslate\" title=\"\">\r\nsudo add-apt-repository ppa:team-gcc-arm-embedded\/ppa\r\nsudo apt-get update\r\nsudo apt-get install gcc-arm-embedded\r\n<\/pre>\n<p>While this still works on Ubuntu 18.04 (32 bit) and Ubuntu 16.04 (64 bit), it no longer works on Ubuntu 19.04 and later:<\/p>\n<pre class=\"brush: plain; gutter: false; title: ; notranslate\" title=\"\">\r\nE: Unable to locate package gcc-arm-embedded\r\n<\/pre>\n<p>Even when using the new procedure to get the compiler to run, there are also problems getting GDB to run. For further details, see Appendix A.<\/p>\n<h2>Step-by-step procedure<\/h2>\n<p>The following can be blindly applied. It has been tested on a 64-bit <a href=\"https:\/\/en.wikipedia.org\/wiki\/Ubuntu_MATE#Releases\">Ubuntu&nbsp;MATE&nbsp;20.04<\/a> (Focal Fossa) system and a 64-bit Ubuntu&nbsp;19.10 (Eoan Ermine) system and is likely to also work on a 64-bit Ubuntu&nbsp;19.04 (Disco Dingo) system.<\/p>\n<h3>Setting up the cross compiler<\/h3>\n<p>Before starting, uninstall any already-installed ARM GCC cross compiler (this command can be used unconditionally &#8211; if it is not installed, it will report &#8220;Package &#8216;gcc-arm-none-eabi&#8217; is not installed, so not removed&#8221;):<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\nsudo apt remove gcc-arm-embedded\r\n<\/pre>\n<p>Instead of using apt-get, we get the toolchain directly from arm.com as a tar ball. This is actually much simpler than it sounds: Download it, extract it, and add the location of the \/bin folder in the extracted folder to the path (environment variable &#8220;PATH&#8221;). That&#8217;s it. In detail:<\/p>\n<p>In the following, the sample path &#8220;\/temp2\/2019-12-05&#8221; under the current user is used to download and extract into. You may want some other folder(s) &#8211; adjust as needed.<\/p>\n<p>Go to <a href=\"https:\/\/developer.arm.com\/tools-and-software\/open-source-software\/developer-tools\/gnu-toolchain\/gnu-rm\/downloads\">arm.com<\/a> and find &#8220;Linux x86_64 Tarball&#8221;. Download &#8220;gcc-arm-none-eabi-9-2019-q4-major-x86_64-linux.tar.bz2&#8221; to ~\/temp2\/2019-12-05 (<a href=\"https:\/\/developer.arm.com\/-\/media\/Files\/downloads\/gnu-rm\/9-2019q4\/RC2.1\/gcc-arm-none-eabi-9-2019-q4-major-x86_64-linux.tar.bz2?revision=6e63531f-8cb1-40b9-bbfc-8a57cdfc01b4&#038;la=en&#038;hash=F761343D43A0587E8AC0925B723C04DBFB848339\">direct download URL<\/a> (valid as of 2019-12-07)), MD5 FE0029DE4F4EC43CF7008944E34FF8CC. It is about 110 MB.<\/p>\n<p>Extract it. For example, in Nautilus (the default file manager in Ubuntu), right click on the .bz2 file, select &#8220;Open with Archive Manager&#8221;, select the single folder, right click on it, select &#8220;Extract&#8221;, press button &#8220;Extract&#8221;, wait for it to finish, &#8220;Close&#8221;, and close Archive Manager.<\/p>\n<p>Alternatively, on the command line:<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\ncd ~\/temp2\/2019-12-05\r\ntar xvzf gcc-arm-none-eabi-9-2019-q4-major-x86_64-linux.tar.bz2\r\n<\/pre>\n<p>Install other required packages:<\/p>\n<pre class=\"brush: plain; gutter: false; title: ; notranslate\" title=\"\">\r\nsudo apt-get update\r\nsudo apt-get install ncurses-dev\r\nsudo apt-get install git\r\nsudo apt-get install make\r\nsudo apt-get install python-minimal\r\n<\/pre>\n<p>For initial testing (in the same session), this suffices:<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\ncd ~\r\nexport PATH=$PATH:~\/temp2\/2019-12-05\/gcc-arm-none-eabi-9-2019-q4-major\/bin\r\narm-none-eabi-c++  --version\r\n<\/pre>\n<p>The output should look something like this:<\/p>\n<pre class=\"brush: plain; gutter: false; title: ; notranslate\" title=\"\">\r\narm-none-eabi-c++ (GNU Tools for Arm Embedded Processors 9-2019-q4-major) 9.2.1 20191025 (release) [ARM\/arm-9-branch revision 277599]\r\nCopyright (C) 2019 Free Software Foundation, Inc.\r\nThis is free software; see the source for copying conditions.  There is NO\r\nwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\r\n<\/pre>\n<p>For more permanent use, put this into the .profile file, near the end, in the user top folder, using some text editor (<a href=\"https:\/\/en.wikipedia.org\/wiki\/Vim_%28text_editor%29\">Vim<\/a>\/<a href=\"https:\/\/en.wikipedia.org\/wiki\/Vi\">vi<\/a> in this example &#8211; but you need to be proficient in using Vim\/vi. Otherwise, use another editor, like <a href=\"https:\/\/en.wikipedia.org\/wiki\/GNU_nano\">nano<\/a> or <a href=\"https:\/\/pmortensen.eu\/world2\/2020\/03\/29\/using-geany\/\">Geany<\/a>):<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\nvi ~\/.profile\r\n<\/pre>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\nPATH=$PATH:~\/temp2\/2019-12-05\/gcc-arm-none-eabi-9-2019-q4-major\/bin\r\n<\/pre>\n<p>After the change, it may be necessary to login\/logout or <strong><em>restart the computer<\/em><\/strong> to make the change take effect (it may not be enough to open a new terminal window).<\/p>\n<h3>Compiling the blink program<\/h3>\n<p>Get source code for a <em>Hello, World!<\/em> (blink) example program:<\/p>\n<pre class=\"brush: plain; gutter: false; title: ; notranslate\" title=\"\">\r\ncd ~\r\ngit clone https:\/\/github.com\/1bitsy\/1bitsy-examples.git\r\ncd 1bitsy-examples\r\ngit submodule init\r\ngit submodule update\r\n<\/pre>\n<div id=\"Python_blues_on_Ubuntu\"><\/div>\n<p>On Ubuntu 20.04 and later, change \u201cpython\u201d in the very first line of file &#8220;irq2nvic_h&#8221; to \u201cpython3\u201d (see the appendix for details):<\/p>\n<pre class=\"brush: plain; gutter: false; title: ; notranslate\" title=\"\">\r\nvi ~\/1bitsy-examples\/libopencm3\/scripts\/irq2nvic_h\r\n<\/pre>\n<p>Compile:<\/p>\n<pre class=\"brush: plain; gutter: false; title: ; notranslate\" title=\"\">\r\nmake\r\n<\/pre>\n<p>Check that it produced the executable:<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\nls -ls ~\/1bitsy-examples\/examples\/1bitsy\/fancyblink\/*.elf\r\n<\/pre>\n<p>The result should be something like (broken up in two lines here):<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\n112 -rwxrwxr-x 1 embo embo 234364 Jan 19 19:19 \r\n\/home\/embo\/1bitsy-examples\/examples\/1bitsy\/fancyblink\/fancyblink.elf\r\n<\/pre>\n<h3>Getting GDB to work<\/h3>\n<p>This presumes the current version of &#8220;libncurses&#8221; and &#8220;libtinfo&#8221; is 6.2 (&#8220;libncurses.so.6.2&#8221; (160 KB) and &#8220;libtinfo.so.6.2&#8221; (190 KB) exist in folder &#8220;\/usr\/lib\/x86_64-linux-gnu&#8221;). If not, adjust the version numbers accordingly (in Ubuntu 19.10, the version is 6.1 instead of 6.2.)<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\ncd \/usr\/lib\/x86_64-linux-gnu\r\nsudo ln -s libncurses.so.6.2 libncurses.so.5\r\nsudo ln -s libtinfo.so.6.2   libtinfo.so.5\r\n<\/pre>\n<p>This puts in symbolic links for the libraries GDB is expecting (version 5).<\/p>\n<p>Verify:<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\nls -ls \/usr\/lib\/x86_64-linux-gnu | grep libncurses.so.5\r\nls -ls \/usr\/lib\/x86_64-linux-gnu | grep libtinfo.so.5\r\n<\/pre>\n<p>The output should look like:<\/p>\n<pre class=\"brush: plain; gutter: false; title: ; notranslate\" title=\"\">\r\n0 lrwxrwxrwx  1 root root 17 Jan 19 15:38 libncurses.so.5 -&gt; libncurses.so.6.2\r\n0 lrwxrwxrwx  1 root root 15 Jan 19 15:38 libtinfo.so.5 -&gt; libtinfo.so.6.2\r\n<\/pre>\n<p>Check that GDB works:<\/p>\n<pre class=\"brush: plain; gutter: false; title: ; notranslate\" title=\"\">\r\narm-none-eabi-gdb --version\r\n<\/pre>\n<p>The output should be something like:<\/p>\n<pre class=\"brush: plain; gutter: false; title: ; notranslate\" title=\"\">\r\nGNU gdb (GNU Tools for Arm Embedded Processors 9-2019-q4-major) 8.3.0.20190709-git\r\nCopyright (C) 2019 Free Software Foundation, Inc.\r\nLicense GPLv3+: GNU GPL version 3 or later &lt;http:\/\/gnu.org\/licenses\/gpl.html&gt;\r\nThis is free software: you are free to change and redistribute it.\r\nThere is NO WARRANTY, to the extent permitted by law.\r\n<\/pre>\n<h3>Setting up for hardware<\/h3>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\nid\r\nsudo adduser $USER dialout\r\nid\r\n<\/pre>\n<p><sub>(<a href=\"https:\/\/askubuntu.com\/questions\/133235\">Related Ask Ubuntu question<\/a>. The reason <a href=\"https:\/\/askubuntu.com\/a\/26221\">why it is <em>&#8220;dialout&#8221;<\/em><\/a>.)<\/sub><\/p>\n<p>The output should include &#8220;(dialout)&#8221; in the &#8220;groups=&#8221; part. In that case, log out and log in. If it is not in the output, a restart of the computer is required (if a restart is not done the result is &#8220;Permission denied&#8221; in the &#8220;target extended-remote \/dev\/ttyACM0&#8221; line below).<\/p>\n<p>Connect the Black Magic Probe with a microUSB cable.<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\nclear ; dmesg | tail -n 15\r\n<\/pre>\n<p>Output includes: &#8220;ttyACM0&#8221; and &#8220;ttyACM1&#8221;. &#8220;ttyACM0&#8221; is the <a href=\"https:\/\/en.wikipedia.org\/wiki\/COM_%28hardware_interface%29\">COM port<\/a> that GDB uses to communicate with the Black Magic Probe and &#8220;ttyACM1&#8221; is the auxiliary COM port that can be used to connect to the target board&#8217;s serial port (so it is not necessary to use a separate USB-to-serial adapter).<\/p>\n<p>Note that if some device with a serial port, for example, an Arduino, was already connected, the numbers <em>may<\/em> be shifted (it all depends), &#8220;ttyACM1&#8221; and &#8220;ttyACM2&#8221;. An example could be a macro keyboard based on Arduino Leonardo or a keyboard based on <a href=\"https:\/\/docs.qmk.fm\/#\/hardware_avr\">QMK<\/a> (also macro capable).<\/p>\n<p>Connect the 1Bitsy with a microUSB cable.<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\nclear ; dmesg | tail -n 15\r\n<\/pre>\n<p>Output includes: &#8220;ttyACM2&#8221; &#8211; but <em>only<\/em> if there is already firmware on it that makes it appear as a serial device. This is <em>not<\/em> the case for <a href=\"http:\/\/pvm-professionalengineering.blogspot.com\/2017\/06\/getting-started-with-1bitsy-and-black.html\">the Kickstarter one<\/a>&#8230; <\/p>\n<p>Connect 1Bitsy and Black Magic Probe using the JTAG cable. Note: the ribbon cable is to come from the <em>same direction<\/em> as the USB cable. That is, the ribbon cable should <em><strong>not<\/strong><\/em> cover the main chip\/IC of the 1Bitsy.<\/p>\n<h3 id=\"flashing\">Flashing the blink program<\/h3>\n<pre class=\"brush: plain; gutter: false; title: ; notranslate\" title=\"\">\r\ncd ~\/1bitsy-examples\/examples\/1bitsy\/fancyblink\r\narm-none-eabi-gdb fancyblink.elf\r\ntarget extended-remote \/dev\/ttyACM0\r\nmonitor version\r\nmonitor help\r\nmonitor jtag_scan\r\nattach 1\r\nload\r\n<\/pre>\n<h3>Debugging with GDB<\/h3>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\nrun\r\ny\r\n&lt;Ctrl + C&gt;\r\nlist\r\n<\/pre>\n<p>Note: &#8216;run&#8217; (or &#8216;start&#8217; or repowering) is required if updating\/changing the source code. The changes do not take effect before restarting, that is, flashing (&#8216;load&#8217; in the previous step) will not actually make it start execute the newly flashed program (the old one is still RAM and is still executing).<\/p>\n<h3>Debugging in full-screen mode<\/h3>\n<p>Using a line debugger is like being trapped in the 1970s. However, GDB can also do full-screen debugging.<\/p>\n<p>It can also be put into a mode when <kbd>Enter<\/kbd> does not have to be pressed for each command. Thus it can come close to an experience of what is expected of a debugger.<\/p>\n<p>Enable full-screen mode:<\/p>\n<pre class=\"brush: plain; gutter: false; title: ; notranslate\" title=\"\">\r\ntui enable\r\n<\/pre>\n<p>It immediately shows a screen with about 10 lines on each side of the current line:<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/pmortensen.eu\/world2\/wp-content\/uploads\/2019\/12\/FancyBlink_TUI-300x208.png\" alt=\"Screen of cross GDB in TUI mode connected to ARM board 1-bitsy through Black Magic Prove\" width=\"600\" height=\"416\" class=\"alignnone size-medium wp-image-46\" srcset=\"https:\/\/pmortensen.eu\/world2\/wp-content\/uploads\/2019\/12\/FancyBlink_TUI-300x208.png 300w, https:\/\/pmortensen.eu\/world2\/wp-content\/uploads\/2019\/12\/FancyBlink_TUI-1024x711.png 1024w, https:\/\/pmortensen.eu\/world2\/wp-content\/uploads\/2019\/12\/FancyBlink_TUI-768x533.png 768w, https:\/\/pmortensen.eu\/world2\/wp-content\/uploads\/2019\/12\/FancyBlink_TUI-100x69.png 100w, https:\/\/pmortensen.eu\/world2\/wp-content\/uploads\/2019\/12\/FancyBlink_TUI-150x104.png 150w, https:\/\/pmortensen.eu\/world2\/wp-content\/uploads\/2019\/12\/FancyBlink_TUI-200x139.png 200w, https:\/\/pmortensen.eu\/world2\/wp-content\/uploads\/2019\/12\/FancyBlink_TUI-450x312.png 450w, https:\/\/pmortensen.eu\/world2\/wp-content\/uploads\/2019\/12\/FancyBlink_TUI-600x416.png 600w, https:\/\/pmortensen.eu\/world2\/wp-content\/uploads\/2019\/12\/FancyBlink_TUI-900x625.png 900w, https:\/\/pmortensen.eu\/world2\/wp-content\/uploads\/2019\/12\/FancyBlink_TUI.png 1059w\" sizes=\"(max-width: 600px) 100vw, 600px\" \/><\/p>\n<p>Enable single key mode: <kbd>Ctrl<\/kbd> + <kbd>X<\/kbd>, <kbd>C<\/kbd><\/p>\n<p>Exit single key mode: <kbd>Q<\/kbd><\/p>\n<p>Continue, break into the running program (on the 1Bitsy), and do some step over and step in operations:<\/p>\n<pre class=\"brush: plain; gutter: false; title: ; notranslate\" title=\"\">\r\ncont\r\n&lt;Ctrl + C&gt;\r\nstep\r\nstart\r\ny\r\nnext\r\nstep\r\nnext\r\nnext\r\nnext\r\ncont\r\n<\/pre>\n<p>In GDB, <\/p>\n<ul>\n<li>&#8216;next&#8217; (short &#8216;n&#8217;) is <strong><em>step over<\/em><\/strong> (like <em>F10<\/em> in <a href=\"https:\/\/en.wikipedia.org\/wiki\/Visual_Studio\">Visual&nbsp;Studio<\/a>)<\/li>\n<li>&#8216;step&#8217; (short &#8216;s&#8217;) is <strong><em>step in<\/em><\/strong> (like <em>F11<\/em> in Visual Studio)<\/li>\n<li>&#8216;finish&#8217; (short &#8216;fin&#8217;) is <strong><em>step out<\/em><\/strong> (like <em>Shift<\/em> + <em>F11<\/em> in Visual Studio).\n<\/ul>\n<p>Quit debugging:<\/p>\n<pre class=\"brush: plain; gutter: false; title: ; notranslate\" title=\"\">\r\n&lt;Ctrl + C&gt;\r\nquit\r\ny\r\n<\/pre>\n<h3>Testing<\/h3>\n<p>This procedure was tested on Ubuntu 19.04 and Ubuntu 20.04 MATE with standard AMD PC hardware (64-bit, 8 GB RAM, etc.). For previous blog posts, it was tested on Ubuntu 16.04, Ubuntu 17.10, and Ubuntu 18.04 (some in 32-bit editions).<\/p>\n<p>This blog post will continue to be updated as new versions of Ubuntu (and some other Linux distributions), the ARM cross compiler, Python, libopencm3, etc. becomes available (though possibly with some delay &#8211; express interest in comments to speed it up).<\/p>\n<h2>Appendix A Error messages and troubleshooting<\/h2>\n<p>While the main part of this post is focused on getting the toolchain installed as quickly as possible and up and running when debugging on ARM, this appendix documents the error messages that you may run into, the troubleshooting, and the background information on why the instructions are as they are.<\/p>\n<h3>&#8216;apt-get&#8217; blues<\/h3>\n<p>On Ubuntu 19.04 and later, this does not work:<\/p>\n<p>We get this error:<\/p>\n<pre class=\"brush: plain; gutter: false; title: ; notranslate\" title=\"\">\r\nE: Unable to locate package gcc-arm-embedded\r\n<\/pre>\n<h3>tar blues<\/h3>\n<p>Using &#8216;tar&#8217; on the command line to extract the GCC cross-compiler tar ball may lead to this output:<\/p>\n<pre class=\"brush: plain; gutter: false; title: ; notranslate\" title=\"\">\r\ngzip: stdin: not in gzip format\r\ntar: Child returned status 1\r\ntar: Error is not recoverable: exiting now\r\n<\/pre>\n<p>The current resolution is to use the file manager instead (as described in the main part of this blog post).<\/p>\n<h3>PATH setup blues &#8211; using Vim<\/h3>\n<p>When using Vim\/vi to edit file &#8216;.profile&#8217; this may be the result when pasting in the path line (the error message includes the quote at the end):<\/p>\n<pre class=\"brush: plain; gutter: false; title: ; notranslate\" title=\"\">\r\nE353: Nothing in register &quot;\r\n<\/pre>\n<p>The reason is that Vim\/vi is not in insert mode. The first character in the clipboard, &#8220;P&#8221; in &#8220;PATH=$PATH:~\/temp2\/2019-12-05\/gcc-arm-none-eabi-9-2019-q4-major\/bin&#8221;, is seen as a command, not something to paste. A direct paste actually sometimes works if using a command-line window on Ubuntu, but it may not always work, e.g., if using SSH to connect to another computer, etc.<\/p>\n<p>The resolution is to enter insert mode <em>explicitly<\/em> by pressing &#8220;i&#8221; first.<\/p>\n<h3>Python blues<\/h3>\n<p>Using &#8216;make&#8217; (when the PATH environment variable has been correctly set up), may result in this error:<\/p>\n<pre class=\"brush: plain; gutter: false; title: ; notranslate\" title=\"\">\r\n  GENHDR  include\/libopencm3\/lpc17xx\/irq.json\r\n\/usr\/bin\/env: \u2018python\u2019: No such file or directory\r\nmake[1]: *** [Makefile:55: include\/libopencm3\/lpc17xx\/irq.json.genhdr] Error 127\r\nmake: *** [Makefile:54: lib] Error 2\r\n<\/pre>\n<p>The reason is that with Ubuntu 20.04 and later, the executable for the Python interpreter is no longer &#8216;python&#8217;, but &#8216;python3&#8217; &#8211; the executable \u2018python\u2019 (for Python 2) was removed. And the library \u201clibopencm3\u201d used by the example code has not yet been updated to reflect this fact (even though there was <a href=\"https:\/\/github.com\/libopencm3\/libopencm3\/issues\/1265\">some discussion in November 2020<\/a>).<\/p>\n<p>The resolution is to change \u201cpython\u201d in the very first line of file &#8220;irq2nvic_h&#8221; to \u201cpython3\u201d (in our example, the file is at &#8220;~\/1bitsy-examples\/libopencm3\/scripts\/irq2nvic_h&#8221;). The result should be \u201c#!\/usr\/bin\/env python3\u201d.<\/p>\n<h3>GDB blues<\/h3>\n<p>If GDB is launched after the tar ball has been installed (so the compiler can be invoked from anywhere),<\/p>\n<pre class=\"brush: plain; gutter: false; title: ; notranslate\" title=\"\">\r\narm-none-eabi-gdb --version\r\n<\/pre>\n<p>this is the likely result:<\/p>\n<pre class=\"brush: plain; gutter: false; title: ; notranslate\" title=\"\">\r\narm-none-eabi-gdb: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory\r\n<\/pre>\n<p>We will add some symbolic links, but first, to be confident we are making the changes in the right folder (for 32 bit or 64 bit libraries), find out the bitness of GDB (32 bit or 64 bit):<\/p>\n<pre class=\"brush: plain; gutter: false; title: ; notranslate\" title=\"\">\r\nfile ~\/temp2\/2019-12-05\/gcc-arm-none-eabi-9-2019-q4-major\/bin\/arm-none-eabi-gdb\r\n<\/pre>\n<p>For 64 bit, the result includes &#8220;arm-none-eabi-gdb: ELF 64-bit LSB executable, x86-64&#8221;.<\/p>\n<p>For 64 bit, the &#8220;libncurses&#8221; library lives in &#8220;\/usr\/lib\/x86_64-linux-gnu&#8221;:<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\ncd \/usr\/lib\/x86_64-linux-gnu\r\nls -ls | grep libncurses\r\n<\/pre>\n<p>The output includes:<\/p>\n<pre class=\"brush: plain; gutter: false; title: ; notranslate\" title=\"\">\r\n    4 -rw-r--r-- 1 root root     31 Aug  9 12:18 libncurses.so\r\n    0 lrwxrwxrwx 1 root root     17 Aug  9 12:18 libncurses.so.6 -&gt; libncurses.so.6.1\r\n  160 -rw-r--r-- 1 root root 162024 Aug  9 12:18 libncurses.so.6.1\r\n<\/pre>\n<p>There is the symbolic link &#8220;libncurses.so.6&#8221;, but not &#8220;libncurses.so.5&#8221; that GDB expects.<\/p>\n<p>Add it by:<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\ncd \/usr\/lib\/x86_64-linux-gnu\r\nsudo ln -s libncurses.so.6.1 libncurses.so.5\r\n<\/pre>\n<p>If we try starting GDB again we get (a different error message):<\/p>\n<pre class=\"brush: plain; gutter: false; title: ; notranslate\" title=\"\">\r\narm-none-eabi-gdb: error while loading shared libraries:\r\nlibtinfo.so.5: cannot open shared object file: No such file or directory\r\n<\/pre>\n<p>As for libncurses, so for &#8220;libtinfo&#8221; from the error message:<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\ncd \/usr\/lib\/x86_64-linux-gnu\r\nls -ls | grep libtinfo\r\n<\/pre>\n<p>The output includes:<\/p>\n<pre class=\"brush: plain; gutter: false; title: ; notranslate\" title=\"\">\r\n  0 lrwxrwxrwx 1 root root     35 Aug 9 12:18 libtinfo.so -&gt; \/lib\/x86_64-linux-gnu\/libtinfo.so.6\r\n  0 lrwxrwxrwx 1 root root     15 Aug 9 12:18 libtinfo.so.6 -&gt; libtinfo.so.6.1\r\n188 -rw-r--r-- 1 root root 192032 Aug 9 12:18 libtinfo.so.6.1\r\n<\/pre>\n<p>Like for libncurses, there is the symbolic link &#8220;libtinfo.so.6&#8221;, but not &#8220;libtinfo.so.5&#8221; that GDB expects.<\/p>\n<p>Add it by:<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\ncd \/usr\/lib\/x86_64-linux-gnu\r\nsudo ln -s libtinfo.so.6.1   libtinfo.so.5\r\n<\/pre>\n<p>After this, GDB finally works:<\/p>\n<pre class=\"brush: plain; gutter: false; title: ; notranslate\" title=\"\">\r\narm-none-eabi-gdb --version\r\n<\/pre>\n<p>The output includes:<\/p>\n<pre class=\"brush: plain; gutter: false; title: ; notranslate\" title=\"\">\r\nGNU gdb (GNU Tools for Arm Embedded Processors 9-2019-q4-major) 8.3.0.20190709-git\r\n<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The short version is: Download the tar ball from arm.com, extract, add the \/bin folder in the extracted to the path, and make GDB work by adding symbolic links in \/usr\/lib\/x86_64-linux-gnu for the expected version 5 of the libraries &#8220;libncurses&#8221; &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"more-link\" href=\"https:\/\/pmortensen.eu\/world2\/2019\/12\/08\/arm-toolchain-ubuntu-19-04-black-magic-probe\/\"> <span class=\"screen-reader-text\">Getting the ARM toolchain to work on Ubuntu 19.04 and later (including for Black Magic Probe (BMP))<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[4,23,16],"tags":[5,6,9,8,7,10,11,12],"_links":{"self":[{"href":"https:\/\/pmortensen.eu\/world2\/wp-json\/wp\/v2\/posts\/12"}],"collection":[{"href":"https:\/\/pmortensen.eu\/world2\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pmortensen.eu\/world2\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pmortensen.eu\/world2\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pmortensen.eu\/world2\/wp-json\/wp\/v2\/comments?post=12"}],"version-history":[{"count":150,"href":"https:\/\/pmortensen.eu\/world2\/wp-json\/wp\/v2\/posts\/12\/revisions"}],"predecessor-version":[{"id":4734,"href":"https:\/\/pmortensen.eu\/world2\/wp-json\/wp\/v2\/posts\/12\/revisions\/4734"}],"wp:attachment":[{"href":"https:\/\/pmortensen.eu\/world2\/wp-json\/wp\/v2\/media?parent=12"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pmortensen.eu\/world2\/wp-json\/wp\/v2\/categories?post=12"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pmortensen.eu\/world2\/wp-json\/wp\/v2\/tags?post=12"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}