Okay, so I had a
Micro:bit for awhile, and decided I wanted to take it to the next level and try using FreePascal to build programs for it. I followed the following Wiki page:
https://wiki.lazarus.freepascal.org/micro:bitI followed the wiki to generate the following Dockerfile, which gives me a working
binutils, and appears to compile FreePascal with no issues. The first problem I had was that when I went to execute the compile command to build the example from the wiki, I got the following error:
root@6828c28f1661:~# fpc -Parm -Tembedded -Wpnrf51822_xxaa test -Cparmv6m
Error: ppcarm can't be executed, error message: Failed to execute "ppcarm", error code: 127
Okay, so I thought that perhaps the make command didn't put the needed binary into place, so I did the following:
ln -s /usr/lib/fpc/3.0.4/ppcrossarm /usr/bin/ppcarm
I once again tried the compile command, and received another error:
root@6828c28f1661:~# fpc -Parm -Tembedded -Wpnrf51822_xxaa test -Cparmv6m
Error: Illegal parameter: -Wpnrf51822_xxaa
Error: /usr/bin/ppcarm returned an error exitcode
At first I swapped out
-Wpnrf51822_xxaa with
-WPnrf51822_xxaa thinking that -WP needed to be capitalized, the same error occurred. I then went and ran
fpc -i and in the list of
Supported Microcontroller types, I do not see it there. I am currently using FPC 3.0.4, as I thought it would be in a stable FPC source release, as the wiki article dates back to 2017, so surely the microcontroller would be in the latest version of FPC now. Is this microcontroller still only available in FPC trunk?
Here's my current Dockerfile(will change before I make it available to anyone who might want it):
FROM kveroneau/fpc:3.0.4-amd64
RUN apt-get update && apt-get -y install wget build-essential
RUN wget -O /tmp/fpc-source.tgz ftp://mirror.freemirror.org/pub/fpc/dist/3.0.4/source/fpc-3.0.4.source.tar.gz && cd /usr/src && tar -xzvf /tmp/fpc-source.tgz && rm -rf /tmp/fpc-source.tgz
RUN wget -O /tmp/binutils.tgz https://gnu.freemirror.org/gnu/binutils/binutils-2.28.1.tar.gz && cd /usr/src && tar -xzvf /tmp/binutils.tgz && rm -rf /tmp/binutils.tgz
RUN cd /usr/src/binutils-2.28.1 && ./configure --target=arm-linux --prefix=/opt/binutils --program-prefix=arm-embedded- --disable-werror && make && make install
ENV PATH /opt/binutils/bin:/usr/sbin:/usr/bin:/sbin:/bin
RUN cd /usr/src/fpc-3.0.4 && make clean buildbase installbase CROSSINSTALL=1 OS_TARGET=embedded CPU_TARGET=arm SUBARCH=armv6m INSTALL_PREFIX=/usr
Great part about Docker here is that I can 100% create a reproducible build for anyone in these forums to try out and see the problem firsthand.

I committed my current Dockerfile here, if anyone wants to play around and potentially get it working,
https://github.com/kveroneau/fpc-docker/tree/master/Builder/fpc-microbit