Free Pascal on Ultibo?

General discussion about anything related to Ultibo.
minus56bits
Posts: 4
Joined: Wed Dec 12, 2018 11:43 am

Free Pascal on Ultibo?

Postby minus56bits » Fri Dec 14, 2018 6:41 pm

Hello Ultibo community!

I have bumped into Ultibo just the other week and have only touched the surface of this project so far, but this is an awesome piece of work, Garry, that's for sure! Hats off!

I wonder if it would be possible to run the Free Pascal compiler itself on Ultibo? An Ultibo development system independent of any big PC and OS? Granted, it's a moot point. Lazarus on PC is definitely more convenient for development than a basic text editor on Ultibo, but just to satisfy my curiosity...

Anyway, thanks for Ultibo!

Frank
User avatar
Ultibo
Site Admin
Posts: 2185
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Re: Free Pascal on Ultibo?

Postby Ultibo » Fri Dec 14, 2018 11:16 pm

Hello Frank, welcome to Ultibo!

minus56bits wrote:I wonder if it would be possible to run the Free Pascal compiler itself on Ultibo? An Ultibo development system independent of any big PC and OS? Granted, it's a moot point. Lazarus on PC is definitely more convenient for development than a basic text editor on Ultibo, but just to satisfy my curiosity...

As far as we know (and we haven't tried) it should be technically possible to build the FPC compiler itself into an Ultibo application. It would require a bit of modification since it is normally designed to be run from the command line but there are no features the compiler code requires that are not available under Ultibo.

The bigger challenge is to deal with the GNU utils that FPC normally uses to do the actual work of compiling and linking an application, in order to compile even a minimal project you need both as (the assembler) and ld (the linker) to be available and while it might be possible to build those as static libraries, link them into an Ultibo application and then modify FPC to call them internally instead of from the command line it gets to be quite a bit of work overall.

Right now it is outside the scope of what we are focusing on but that shouldn't stop anyone from experimenting if they are keen to explore these things. We should point out that a number of people are finding using the Ultibo version of Lazarus and FPC on Raspbian (running on a Pi) to be a successful development environment that doesn't need a full sized PC, if you haven't seen it there are links to our Linux installer script in the Forum Quick Reference.

Hope you enjoy using Ultibo, feel free to ask any questions as you explore what it can do.
Ultibo.org | Make something amazing
https://ultibo.org
minus56bits
Posts: 4
Joined: Wed Dec 12, 2018 11:43 am

Re: Free Pascal on Ultibo?

Postby minus56bits » Sat Dec 15, 2018 10:22 am

Thank you for your detailed answer!

I wasn't aware of the fact that FPC doesn't consist of pure Pascal code from reading the source to storing the executable but uses external tools while compiling.

Right now it is outside the scope of what we are focusing on

No suggestion here, just curiosity. I totally understand how important focusing is. You are already working on a wide range of topics.

Hope you enjoy using Ultibo, feel free to ask any questions as you explore what it can do.

Thank you! I'm going to read most of Wiki and forum content first to get a better picture of the potential.
Gavinmc42
Posts: 1555
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: Free Pascal on Ultibo?

Postby Gavinmc42 » Sat Dec 15, 2018 12:08 pm

Language Compilers and Interpreters, it one of the things you need to know the difference.

Generally Ultibo is Cross Compiled on a x86 CPU for a 32bit Armhf CPU.
The exception is when you install Ultibo via the install script on to a Pi.
Then the Pi's Arm CPU compiles for itself.

Ultibo consists of two parts the Free Pascal Compiler FPC and Lazarus the IDE/Editor.

An Interpreter for Languages like Basic, Java and Python exists on the machine the code runs on.
Here the code is not (generally) compiled but Interpreted by a Run Time Engine, the program tells this run time engine what to do.

C, C++, Pascal is compiled into the run time engine with the program built into it.
Ultibo has a RTL, Run Time Library that is added to your code, it does all the magic and has lots of libraries of useful stuff.

Normally you then take this compiled program and copy it to the Pi's SDcard along with the Raspberry Pi's Boot programs.
These extra files are the boot loader etc in the firmware folder.
These are made by the Raspberry Pi Foundation just for the purpose of booting the Videocore cpu and then starting the Arm cpu.
Ultibo compiles to a new kernel.img that is loaded and run by start.elf

The Free Pascal Compiler comes with lots of useful stuff too.
One advantage of Lazarus/FPC is these libraries comes standard and you can do a lot stuff without using extra libraries.
C is very simple but you need extra libraries to do anything useful, these are called dependencies.
There is a an expression called "Dependency hell", where your program does not work because of a missing/faulty library.
Normally C dependencies are easy to get, if you have Internet they just download and install, most of the time.

Ultibo once installed, has everything. That everything is around 600MB.
The Laz IDE, FPC Compiler and all the very useful libraries can be trimmed.
So to compile itself Ultibo needs some of those files, but which ones?

pik33 has a dos bios/grub like program that swaps his SDcard between Raspbian and Ultibo kernels.
Most on my recent coding is for Zero's and I load via the USB boot mode without SDcard.
Others use Ethernet to upgrade Ultibo kernels.

One of the first things I tested was a Ultibo server on a Pi upgrading other Ultibo Pi's.
This Ultibo server can even run in QEMU, could it run a compiler to upgrade other Ultibo Pi's?
Over the last 2 years i sort of have my own library of useful units (library), so my main application can be very short.
Some sort on mini compiler/interpreter could run that, sort of a shell or bash script?

So many ways to do things with Ultibo, limited only by time and skill?
hansotten
Posts: 54
Joined: Thu Feb 04, 2016 7:07 am

Re: Free Pascal on Ultibo?

Postby hansotten » Sat Dec 15, 2018 3:16 pm

minus56bits wrote:Thank you for your detailed answer!

I wasn't aware of the fact that FPC doesn't consist of pure Pascal code from reading the source to storing the executable but uses external tools while compiling.


Ultibo core is pure Pascal with inline assembler in e.g boot procedures.
The Freepascal compiler generates ARM code, and that needs assembly and building, therefore the use of the GNU utils Assembler and Loader. As does any Freepascal program.
minus56bits
Posts: 4
Joined: Wed Dec 12, 2018 11:43 am

Re: Free Pascal on Ultibo?

Postby minus56bits » Sat Dec 15, 2018 7:09 pm

Thank you. I really appreciate your comments.

Ultibo once installed, has everything. That everything is around 600MB.

Wow! The demo kernel was about 2 or 3 MB if I remember correctly, so if we don't talk about some kind of mysterious bit explosion here there must be a lot more stuff to explore in Ultibo than I expected! :o

pik33 has a dos bios/grub like program that swaps his SDcard between Raspbian and Ultibo kernels.

Thanks, that will surely simplify development and preserve the SDcard.

So many ways to do things with Ultibo, limited only by time and skill?

Usually its time. Skills can be acquired if time permits. ;)

The Freepascal compiler generates ARM code, and that needs assembly and building, therefore the use of the GNU utils Assembler and Loader.

Makes sense to use well tested and matured tools here than to write from scratch in Pascal. Didn't know that, though.

Return to “Discussion”

Who is online

Users browsing this forum: No registered users and 1 guest