HOWTO: Cross compile LPC Firmware on Gentoo

Since I had to cross-compile the LPC firmware on Gentoo today, I wanted to share my findings, in case anyone else runs into the same issues:

  • You can use Gentoo’s “crossdev” script to set up the toolchain.
    • Check the page from the Gentoo Wiki for instructions how to install crossdev.
    • The target needed for the LPC firmware is arm-none-eabi.
    • You’ll need gcc, so don’t use the --llvm flag when installing the toolchain.
  • Before you can compile the actual firmware binary, you need to compile lpcrc in the tools/lpcrc folder.
    • Just change into that folder and run make
  • At the time I’m writing this (2024-02-22) the toolchain installed by crossdev has _FORTIFY_SOURCE defined. The LPC firmware does not compile if this feature is enabled (with rather confusing error messages).
    • You can disable it in the main Makefile of the LPC firmware. I added the following two lines, but I’m not certain if the second one is actually needed:
      GCFLAGS += -U_FORTIFY_SOURCE
      GCFLAGS += -D_FORTIFY_SOURCE=0
      
    • Since I already had parts of the project compiled before I made those changes to the makefile, I got weird linker errors. If you get errors like undefined reference to '_exit', you might want to do a make clean and try again. At least for me that fixed those.
1 Like