[Lazarus] Cross-compiling for Raspberry Pi2

classic Classic list List threaded Threaded
112 messages Options
1234 ... 6
Reply | Threaded
Open this post in threaded view
|

[Lazarus] Cross-compiling for Raspberry Pi2

Bo Berglund
I have a need to port a Delphi console program written for Windows to
be used on Raspberry Pi2.
Apparently it is possible to use Freepascal to get programs running on
the Pi2 platform, but can it be done in Windows so I don't have to
install the complete IDE on a Pi and set it up with a monitor,
keyboard and mouse just for running the compile?

The program is a communication module that talks over TCP/IP sockets
to a data collection device connected via WiFi.
I use the Indy10 TCP/IP components (created in code) to communicate
and the data is decoded and stored on disk.

What are the steps needed to port to Pi2?

Any experience with a similar project would be good to read about!

--
Bo Berglund
Developer in Sweden


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Cross-compiling for Raspberry Pi2

leledumbo
Administrator
> What are the steps needed to port to Pi2?

Standard cross compiling rules apply. Nothing is fancy, pi is just another arm-linux system. Probably only SoftFP vs hard float that's problematic, but simply installing the latest raspbian and compile using hardfloat enabled FPC for arm should suffice.
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Cross-compiling for Raspberry Pi2

David Taylor
In reply to this post by Bo Berglund
On 18/09/2015 00:28, Bo Berglund wrote:

> I have a need to port a Delphi console program written for Windows to
> be used on Raspberry Pi2.
> Apparently it is possible to use Freepascal to get programs running on
> the Pi2 platform, but can it be done in Windows so I don't have to
> install the complete IDE on a Pi and set it up with a monitor,
> keyboard and mouse just for running the compile?
>
> The program is a communication module that talks over TCP/IP sockets
> to a data collection device connected via WiFi.
> I use the Indy10 TCP/IP components (created in code) to communicate
> and the data is decoded and stored on disk.
>
> What are the steps needed to port to Pi2?
>
> Any experience with a similar project would be good to read about!

You might be able to compile on the RPi as I did.  See the section
"Compiling..." at:

   http://www.satsignal.eu/raspberry-pi/DigitalClock.html

I, too, would be interested in cross-compiling....
--
David
Web: http://www.satsignal.eu


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Cross-compiling for Raspberry Pi2

Martin Schreiber
In reply to this post by Bo Berglund
On Friday 18 September 2015 01:28:16 Bo Berglund wrote:
> I have a need to port a Delphi console program written for Windows to
> be used on Raspberry Pi2.
> Apparently it is possible to use Freepascal to get programs running on
> the Pi2 platform, but can it be done in Windows so I don't have to
> install the complete IDE on a Pi and set it up with a monitor,
> keyboard and mouse just for running the compile?
>
On Linux X86 you could use MSEide and the FPC cross compiling environment from
here:
http://mseide-msegui.sourceforge.net/pics/crossarm.png
http://sourceforge.net/projects/mseide-msegui/files/fpcrossarm/

I assume it is possible to make something similar for Lazarus and Windows, I
don't know if it already exists.

For integrated development with FPC 3.0.1 MSEide+MSEgui git master version is
necessary:

https://gitlab.com/mseide-msegui/mseide-msegui

>From MSEide+MSEgui README.TXT:
"
Crosscompiling and remote debugging i386-linux -> arm-linux
***********************************************************
For Raspberry Pi:
- Establish a ssh login without password (public key authentication).

- On the i386-linux host install the scp program
- download and extract
 
http://sourceforge.net/projects/mseide-msegui/files/fpcrossarm/crossfpc-i386_linux-eabihf_3_0_1.tar.gz
  to <your crossfpc directory>.

- Start MSEide, in 'Settings'-'Configure MSEide'-'Global Macros' add:

Name          Value

CROSSMSEDIR   <MSEide+MSEgui directory>
CROSSFPCDIR   <your crossfpc directory>
HOSTIP        <the IP of the host>
REMOTEIP      <the IP of the remote target>
REMOTEPORT    <the remote port, ex: 2345>
REMOTEUSER    pi

- 'Project'-'New'-'From Template', select "crossarmdefault.prj" or
  "crossarmconsole.prj".
- Create the new project.
- 'Project'-'Options'-'Macros', set the TARGETPROJECTDIR value to the project
  path in remote target, ex: "/home/pi/proj/testcase".
- Check the TARGETENV macro.
- If your application needs additional libraries copy them from Raspberry Pi
  /lib/arm-linux-gnueabihf or /usr/lib/arm-linux-gnueabihf to
  <your crossfpc directory>/eabihf/lib

Press F9 and hope the best. ;-)
"
MSEide+MSEgui also runs amazingly fast natively on the Raspberry Pi, the
limiting factor is FPC compiling speed and memory consumption especially for
smart linking.

Martin

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Cross-compiling for Raspberry Pi2

Bo Berglund
In reply to this post by Bo Berglund

I found a guide t o install FPC-Lazarus directly on the Pi2 itself
here:
http://www.tweaking4all.com/hardware/raspberry-pi/install-lazarus-pascal-on-raspberry-pi-2/

It seems like an easier way to build directly on the end hardware than
crosscompiling. But the CPU power might be a limiting factor of
course. I will make an attempt at doing this first and see how it
goes.
I can always try cross-compilation later.

--
Bo Berglund
Developer in Sweden


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Cross-compiling for Raspberry Pi2

Michael Schnell
In reply to this post by Bo Berglund
On 09/18/2015 01:28 AM, Bo Berglund wrote:
> I have a need to port a Delphi console program written for Windows to
> be used on Raspberry Pi2.
>
>
> What are the steps needed to port to Pi2?

I would use a Linux desktop to do the port to Linux in the most
comfortable way, before considering the port to ARM.

Especially with "console programs" Delphi/Windows is rather different
from Lazarus/Linux, as in Lazarus console programs don't feature an
Event queue.

-Michael

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Cross-compiling for Raspberry Pi2

Michael Schnell
In reply to this post by Martin Schreiber
On 09/18/2015 07:00 AM, Martin Schreiber wrote:
>
> On Linux X86 you could use MSEide and the FPC cross compiling environment from
> here:
> http://mseide-msegui.sourceforge.net/pics/crossarm.png
> http://sourceforge.net/projects/mseide-msegui/files/fpcrossarm/

Maybe MSE is more suitable in this case, as (AFAIK) here console
programs with an event queue is supported in Linux.

-Michael

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Cross-compiling for Raspberry Pi2

Michael Van Canneyt
In reply to this post by Michael Schnell


On Fri, 18 Sep 2015, Michael Schnell wrote:

> On 09/18/2015 01:28 AM, Bo Berglund wrote:
>> I have a need to port a Delphi console program written for Windows to
>> be used on Raspberry Pi2.
>>
>>
>> What are the steps needed to port to Pi2?
>
> I would use a Linux desktop to do the port to Linux in the most comfortable
> way, before considering the port to ARM.
>
> Especially with "console programs" Delphi/Windows is rather different from
> Lazarus/Linux, as in Lazarus console programs don't feature an Event queue.

To the best of my knowledge, Delphi itself does not offer an event queue either in console programs.

If you are talking about thread queues: the mechanisms in Delphi and Lazarus are exactly the same.
If you are talking about the windows 'event system': this is a windows concept, not a linux concept.
Linux has different mechanisms entirely. This is unrelated to Delphi/Lazarus/FPC whatever.

I really do not appreciate this kind of derogatory comments.

Michael.

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Cross-compiling for Raspberry Pi2

Michael Schnell
On 09/18/2015 10:42 AM, Michael Van Canneyt wrote:
>
> To the best of my knowledge, Delphi itself does not offer an event
> queue either in console programs.

In fact I doubt that the OP really intends to do a pure "console
program" that is called by e.g. bash and runs through without waiting
for anything and then exits.

AFAIK, with Delphi a "console program" is just a normal application that
only does not show a Windows, but that can use e.g. TTimer in the normal
Delphi-way.

>
> If you are talking about thread queues: the mechanisms in Delphi and
> Lazarus are exactly the same.
AS the OP did not mention threads, I was mainly thinking of TTimer (I
should have better written "TTimer" instead of "Event-Queue", even
though under the hood this means the same in that issue) .

> If you are talking about the windows 'event system': this is a windows
> concept, not a linux concept. Linux has different mechanisms entirely.
> This is unrelated to Delphi/Lazarus/FPC whatever.
With Lazarus the User does not need to be aware that under the hood the
Event Queue in the Windows and Linux brand of the LCL is implemented in
a different way. Lazarus rather perfectly hides this. (But not with
"Console Applications").

>
> I really do not appreciate this kind of derogatory comments.

I did not mean to sound derogatory at all. I am very happy that the
maintainers of the FPC and Lazarus Project do this great work.

I was just trying to be helpful to the OP, and I think - not only
because of the potential issue I described - it is a good idea to split
the porting task in porting from Delphi/ Windows to Lazarus/Linux and
then form PC to ARM. (Been there, learned my lesson.)  With a complex
Project, it even could be viable to do a port from Delphi to Lazarus on
Windows first).

-Michael


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Cross-compiling for Raspberry Pi2

Mark Morgan Lloyd
In reply to this post by Bo Berglund
Bo Berglund wrote:
> I found a guide t o install FPC-Lazarus directly on the Pi2 itself
> here:
> http://www.tweaking4all.com/hardware/raspberry-pi/install-lazarus-pascal-on-raspberry-pi-2/
>
> It seems like an easier way to build directly on the end hardware than
> crosscompiling. But the CPU power might be a limiting factor of
> course. I will make an attempt at doing this first and see how it
> goes.
> I can always try cross-compilation later.

Bo, I did that on the original RPi at the end of last month. You'll need
a couple of the Debian -dev packages (yell if you want me to check my
notes) but the important things are (a) you'll need at least 512Mb of
RAM+swap available and (b) remember that you can run the IDE etc. over
SSH- you don't need a local screen and keyboard.

--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Cross-compiling for Raspberry Pi2

Michael Van Canneyt
In reply to this post by Michael Schnell


On Fri, 18 Sep 2015, Michael Schnell wrote:

> On 09/18/2015 10:42 AM, Michael Van Canneyt wrote:
>>
>> To the best of my knowledge, Delphi itself does not offer an event queue
>> either in console programs.
>
> In fact I doubt that the OP really intends to do a pure "console program"
> that is called by e.g. bash and runs through without waiting for anything and
> then exits.
>
> AFAIK, with Delphi a "console program" is just a normal application that only
> does not show a Windows, but that can use e.g. TTimer in the normal
> Delphi-way.

So, we are talking about the windows event queue.

The way your post was constructed, you made it sound as if lazarus fails to offer what Delphi offers.
It has nothing to do with Lazarus. Linux does not have an event queue as windows has it.
One is emulated in e.g. X11 applications, and Lazarus uses that for it's GUI, and for TTimer.

Glad we straightened that out.

I'm still waiting for your patch to create a basic TEventApplication class descending from TCustomApplication.
When you do, I'll be glad to include it in FPC, and as a bonus I'll even throw in an item for it under
"new project" in File|New in the lazarus IDE...

It will then hopefully put an end to this years long bickering about event queues :)

Michael.

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Cross-compiling for Raspberry Pi2

Michael Schnell
On 09/18/2015 11:28 AM, Michael Van Canneyt wrote:
>
> The way your post was constructed, you made it sound as if lazarus
> fails to offer what Delphi offers.

Sorry for being unclear !! (This obviously is just an issue of the word
"Console Application".)

The contrary is true. Lazarus (at least in Linux) is able to compile
real "pure run through" command line tools, while Delphi (AFAIK) just
does normal "Applications" that don't show the main Windows and calls
this a "Console Program".

In Linux, a Lazarus Console application can be used on hardware with no
GUI system installed.

So Bo supposedly is save if he selects "Application" and not "Console
Application" when setting up his project. In fact on a PI a GUI system
is active by default.

Other than MSE, a Lazarus "Console Application" can't use TTimer, this
might not be relevant for Bo on Pi.

-Michael

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Cross-compiling for Raspberry Pi2

Marco van de Voort
In reply to this post by Michael Schnell
On Fri, Sep 18, 2015 at 11:02:23AM +0200, Michael Schnell wrote:
> AFAIK, with Delphi a "console program" is just a normal application that
> only does not show a Windows, but that can use e.g. TTimer in the normal
> Delphi-way.

Could you please post your Delphi test for that? Thanks.

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Cross-compiling for Raspberry Pi2

Sven Barth
In reply to this post by Michael Schnell

Am 18.09.2015 11:41 schrieb "Michael Schnell" <[hidden email]>:
> The contrary is true. Lazarus (at least in Linux) is able to compile real "pure run through" command line tools, while Delphi (AFAIK) just does normal "Applications" that don't show the main Windows and calls this a "Console Program".

Creating a new Console Application in Delphi creates a nearly empty project file that contains an empty "begin...end." block with a "{$apptype console}", so exactly what is needed for a console application that does not show any GUI by default (the Lazarus analog is "Simple Program" or so).

Regards,
Sven


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Cross-compiling for Raspberry Pi2

Graeme Geldenhuys-3
In reply to this post by Bo Berglund
On 2015-09-18 at 00:43, Bo Berglund wrote:

> It seems like an easier way to build directly on the end hardware than
> crosscompiling.

Yeah, that's what I've been doing for years, and it works very well. I
have an original RPi, so even less memory and CPU power, so I opted not
to use Lazarus IDE or LCL. Maximus or MSEide only use 15-25MB of RAM
(compared to Lazarus's 100+MB for the same project).

You can obviously compile from the command line too and use any
lightweight text editor if you want.


Regards,
  - Graeme -

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Cross-compiling for Raspberry Pi2

Bo Berglund
In reply to this post by Michael Schnell
On Fri, 18 Sep 2015 11:02:23 +0200, Michael Schnell
<[hidden email]> wrote:

>On 09/18/2015 10:42 AM, Michael Van Canneyt wrote:
>>
>> To the best of my knowledge, Delphi itself does not offer an event
>> queue either in console programs.
>
>In fact I doubt that the OP really intends to do a pure "console
>program" that is called by e.g. bash and runs through without waiting
>for anything and then exits.
>
...
>
>I was just trying to be helpful to the OP, and I think - not only
>because of the potential issue I described - it is a good idea to split
>the porting task in porting from Delphi/ Windows to Lazarus/Linux and
>then form PC to ARM. (Been there, learned my lesson.)  With a complex
>Project, it even could be viable to do a port from Delphi to Lazarus on
>Windows first).

Thanks for your suggestions!
I think I need to explain more what I am after....

What I want to do is the following:

I want to create an automation function running on the RPi2 for
managing a data monitoring system to collect data for detecting
imminent risk of failure of dams.
The system would work as follows:
- An instrument collects data from a number of sensors on the dam
- The instrument is essentially designed to be manually operated so
the Pi is there to automate it
- It has a communications channel via a WiFi adapter hooked to its
serial port and there are commands to do whatever needed
- Via this channel it is possible to command a measure cycle and to
download the resulting data
- So a schedule needs to be set up to tell the instrument to do two
different measure cycles at certain times
- The data will be downloaded to the RPi2 when the cycle finishes in
order to free memory on the instrument
- Access to the data will be provided on the RPi2 via a mobile network
router also connected to the RPi2
- The whole system will be deployed unattended for long periods
(months-years)

I have previously built systems like this using a Windows PC to
automate the instrument and using serial communications. The software
was written using Delphi 7 as a Windows service controlled via
settings in the Registry.

Now we need to shrink and ruggedize the system and I wanted to use an
RPi2 to implement the controller. It would be dual homed with a wired
connection to the router and a WiFi connection to the instrument which
emulates the serial link.

Yesterday I realized that it would be a large task to re-invent the
software on the Pi using for example python since I am not at all
familiar with that language.
Then it dawned on me that freepascal is multi-platform and I colud
possibly port existing Delphi code over to the Pi, thus reducing the
amount of work needed. I have used a serial comm component in the
existing code but I figured I could replace that by an Indy TCP client
component instead. Apart from that there are only standard functions
used and no user interface.

So that is why I am here now. I have used RPi units for a lot of
things at home (I run media centers, printer servers, VPN servers and
such things using 4 different Pi:s). So it is a natural to try this
road...

I am still looking for the proper way to go. Possibly first starting
from my existing Delphi software and creating the cut down unattended
software on Windows and then porting over to the Pi. Windows services
is not possible of course so I figured I could make a console program
started by cron instead.

What would be the best way in your view?


--
Bo Berglund
Developer in Sweden


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Cross-compiling for Raspberry Pi2

Martin Schreiber
On Friday 18 September 2015 15:44:40 Bo Berglund wrote:
> On Fri, 18 Sep 2015 11:02:23 +0200, Michael Schnell

>
> What would be the best way in your view?

1. Port the Delphi 7 application to FPC Windows X86 on a Windows X86 PC.
2. Port the FPC Windows to FPC Linux X86 on a Linux X86 PC.
3. Cross compile and cross debug the Linux application to RaspberryPi on the
Linux X86 PC.

Martin


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Cross-compiling for Raspberry Pi2

Martin Schreiber
On Friday 18 September 2015 16:08:20 Martin Schreiber wrote:
> 2. Port the FPC Windows to FPC Linux X86 on a Linux X86 PC.
2. Port the FPC Windows application to FPC Linux X86 on a Linux X86 PC.

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Cross-compiling for Raspberry Pi2

Bo Berglund
In reply to this post by Martin Schreiber
On Fri, 18 Sep 2015 16:08:20 +0200, Martin Schreiber
<[hidden email]> wrote:

>On Friday 18 September 2015 15:44:40 Bo Berglund wrote:
>> On Fri, 18 Sep 2015 11:02:23 +0200, Michael Schnell
>
>>
>> What would be the best way in your view?
>
>1. Port the Delphi 7 application to FPC Windows X86 on a Windows X86 PC.
>2. Port the FPC Windows to FPC Linux X86 on a Linux X86 PC.
>3. Cross compile and cross debug the Linux application to RaspberryPi on the
>Linux X86 PC.
>
Thanks!
I have Lazarus installed on my laptop so I guess I can start right
away to cut and paste code from my existing project and create the
console app on Windows but in Lazarus then.
I have not really used Lazarus except for some hello world tests and
for checking how to port a Sentinel dongle function to FPC.

I'll probably ask some more, but how does one go about getting Indy10
onto Lazarus/FPC?


--
Bo Berglund
Developer in Sweden


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Cross-compiling for Raspberry Pi2

Martin Schreiber
On Friday 18 September 2015 16:14:35 Bo Berglund wrote:

> I have not really used Lazarus except for some hello world tests and
> for checking how to port a Sentinel dongle function to FPC.
>
Now that is a chance to use MSEide instead. ;-)
MSEide runs amazingly fast on Raspberry Pi and has very good suport for
development of embedded and microprocessor projects written in Pascal or C,
cross development with MSEide is very comfortable. I use it daily for
different ARM and AVR32 projects.
With MSEgui you also have a state of the art cross platform GUI toolkit with
excellent database options at your fingertips. MSEgui probably is the most
versatile GUI toolkit on the market.

Martin

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
1234 ... 6