Skip to content

ARM GNU Toolchain GDB problem

I decided to upgrade my bare metal ARM GNU toolchain to the latest version from ARM because that seemed to be a good idea at the time. Only, it wasn't.

I downloaded both the 12.2.Rel1 version and the 11.3.Rel1 version from ARM's website and both showed the following problem on my Ubuntu 22.04 system when trying to run arm-none-eabi-gdb:

Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Python path configuration:
  PYTHONHOME = (not set)
  PYTHONPATH = (not set)
  program name = '/usr/local/bld-tools/bld-tools-virtual-env/bin/python'
  isolated = 0
  environment = 1
  user site = 1
  import site = 1
  sys._base_executable = '/usr/local/bld-tools/bld-tools-virtual-env/bin/python'
  sys.base_prefix = '/usr'
  sys.base_exec_prefix = '/usr'
  sys.executable = '/usr/local/bld-tools/bld-tools-virtual-env/bin/python'
  sys.prefix = '/usr'
  sys.exec_prefix = '/usr'
  sys.path = [
    '/usr/lib/python38.zip',
    '/usr/lib/python3.8',
    '/usr/lib/lib-dynload',
  ]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00007f3bbbbfdc00 (most recent call first):
<no Python frame>

I don't seem to be the only one who has this problem, I saw a couple of posts on the ARM forum and other places showing the same issue, but no response whatsoever from ARM on how to fix it. Other places had a bunch of complicated suggestions that seemed to involve having to downgrade the system Python installation. I'm really not eager to break my system that bad.

It looks to me like this toolchain was built with a configuration tied to a particular Python virtualenv instead of the standard system environment. In case you wonder, yes I did try to set $PYTHONHOME and $PYTHONPATH environment variables but they seemed to not have any effect.

Makes you wonder about ARM's QA, to release at least two versions of the toolchain that have this issue.

I decided to forego the scary, potentially system breaking stuff to make the ARM version work, and instead installed the xPack GNU ARM Embedded GCC toolchain. That one works just fine out of the box.

Another suggestion I received was to use the GDB from Ubuntu's gdb-multiarch package instead and ignore the broken GDB.