Recent

Author Topic: Micro:Bit tutorial on wiki does not seem to work  (Read 5434 times)

kveroneau

  • Full Member
  • ***
  • Posts: 119
Micro:Bit tutorial on wiki does not seem to work
« on: December 21, 2019, 09:35:45 pm »
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:bit

I 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:

Code: Text  [Select][+][-]
  1. root@6828c28f1661:~# fpc -Parm -Tembedded -Wpnrf51822_xxaa test -Cparmv6m
  2. Error: ppcarm can't be executed, error message: Failed to execute "ppcarm", error code: 127
  3.  

Okay, so I thought that perhaps the make command didn't put the needed binary into place, so I did the following:

Code: Text  [Select][+][-]
  1. ln -s /usr/lib/fpc/3.0.4/ppcrossarm /usr/bin/ppcarm
  2.  

I once again tried the compile command, and received another error:

Code: Text  [Select][+][-]
  1. root@6828c28f1661:~# fpc -Parm -Tembedded -Wpnrf51822_xxaa test -Cparmv6m
  2. Error: Illegal parameter: -Wpnrf51822_xxaa
  3. Error: /usr/bin/ppcarm returned an error exitcode
  4.  

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):

Code: Text  [Select][+][-]
  1. FROM kveroneau/fpc:3.0.4-amd64
  2.  
  3. RUN apt-get update && apt-get -y install wget build-essential
  4.  
  5. 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
  6.  
  7. 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
  8.  
  9. RUN cd /usr/src/binutils-2.28.1 && ./configure --target=arm-linux --prefix=/opt/binutils --program-prefix=arm-embedded- --disable-werror && make && make install
  10.  
  11. ENV PATH /opt/binutils/bin:/usr/sbin:/usr/bin:/sbin:/bin
  12.  
  13. 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
  14.  

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.  :D

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
« Last Edit: December 21, 2019, 09:42:25 pm by kveroneau »

MiR

  • Sr. Member
  • ****
  • Posts: 250
Re: Micro:Bit tutorial on wiki does not seem to work
« Reply #1 on: December 22, 2019, 12:07:56 am »
When I am not mistaken the unit files for the nrf chips are only in trunk.

So you will need to compile a cross compiler based on trunk and then use that one to compile your sample code

Michael

julkas

  • Guest
Re: Micro:Bit tutorial on wiki does not seem to work
« Reply #2 on: December 22, 2019, 04:07:36 pm »
When I am not mistaken the unit files for the nrf chips are only in trunk.

So you will need to compile a cross compiler based on trunk and then use that one to compile your sample code

Michael
Yes, you must build cross compiler for your target from trunk.
BTW - Good idea - small Docker image for FPC embedded dev.

 

TinyPortal © 2005-2018