[fpc-devel] Embedded Strings on nRF51-DK

Paul Michell Paul at michellcomputing.co.uk
Thu Apr 16 12:49:49 CEST 2015


I'm using FPC to build embedded binaries for the Nordic Semiconductor nRF51-DK 
development board:


I have been able to adapt the sample gcc make scripts to replace C units with 
equivalent pascal units after partially translating the header files from the 
SDK.  This has enabled me to build test applications to use the board's 
buttons, LEDs, UART and timers.

However, when I try to use pascal string variables (short or long) the 
compiler fails.  For example the following works:

Function Main: Integer; Cdecl; Alias: 'main';
  UARTConfigure(11, 9, 10, 8, True);
  UARTPutString('Hello World');

But this fails:

Function Main: Integer; Cdecl; Alias: 'main';
  Text: String;
  Text := 'Hello World';
  UARTConfigure(11, 9, 10, 8, True);

With the following errors:

Main.pas:(.text.n_main_$$_main$$smallint+0xe): undefined reference to 
Main.pas:(.text.n_main_$$_main$$smallint+0x12): undefined reference to 
Main.pas:(.text.n_main_$$_main$$smallint+0x26): undefined reference to 
Main.pas:(.text.n_main_$$_main$$smallint+0x42): undefined reference to 
Main.pas:(.text.n_main_$$_main$$smallint+0x4e): undefined reference to 
Main.pas:(.text.n_main_$$_main$$smallint+0x54): undefined reference to 
Main.pas:(.text.n_main_$$_main$$smallint+0x64): undefined reference to 

I assume this is because string handling support is not included in the 
embedded RTL generated with the compiler, or that I am not linking the right 
object files if I need to do this by hand?  What would be the best way to 
enable string handling? Even short string handling would make FPC far more 
preferable to C for me for embedded work.


Paul Michell

More information about the fpc-devel mailing list