Forum > Embedded

Running a minimal fpc on a microcontroller

<< < (2/4) > >>

A tough challenge.  Some ideas:

* remove compiler messages and help (~ 80kB)
* drop debug info support (this will probably shave off a few kB)
* remove unicode support in compiler[\li]

* remove multiple dialect support (macpas/fpc/delphi/objfpc/iso) and only support a single dialect (probably complicated, I think these dialect checks are sprinkled over several units)I'll speculate that this will drop the compiler size closer to 2 MB in size.

In embedded you have to provide build-in file system support of some kind and memory management. At least there is a lightweight heap manager in RTL.  Then (as marcov mentioned) you need binutlis such an assembler and linker.  Not sure this is available, so one may have to include an embedded linker in the compiler.


--- Quote from: mischi on May 28, 2019, 01:47:00 pm ---If you could get along with old style iso pascal without objects, the p5 pascal compiler might do a job.

--- End quote ---

A p5 compiler that can be compiled by FPC is available from

8 MB RAM is too small for modern compilers. Maybe it's better to use some other small Pascal compilers or create one new. It will depends on what features you want to support in the compiler. OOP compilers are complex but classic Pascal compilers are smaller.

(I can remember my first attempt at porting pre 1.0 FPC to FreeBSD. The year was 1998, and the idea was to just make cycle with a target linux, but then on a FreeBSD system). The non production FreeBSD system was an old 486 with 8MB, and a 32MB swap.

After 6 hours compiling it bombed out with a linking error, sigh. Slow porting it is :)

I knew I would find it in the end. You can take a look for inspiration at this a p-code Pascal running on AVR MEGA163:

You might also examine these p-code related links:


[0] Message Index

[#] Next page

[*] Previous page

Go to full version