Recent

Author Topic: Tutorial: Install Lazarus to Raspberry Pi  (Read 11799 times)

jcdammeyer

  • Jr. Member
  • **
  • Posts: 60
Re: Tutorial: Install Lazarus to Raspberry Pi
« Reply #75 on: July 14, 2020, 10:27:41 am »
The attached photo shows the same source code on Stretch Pi3.  Although the Lazarus 1.6 won't run the installed component due to missing files the screenshot does show that the fonts, buttons etc match the Windows versions unlike the latest Pi OS.

So the three year cycle of OS upgrades results in more man hours of useless work with what appears to be very little benefit.  The MakeLazarus script that ran on the Pi4 with Buster does not finish on the Pi3.  So I guess I might as well trash the 16GB MicroSD with Stretch and rebuild with Buster so that I can load the newest Lazarus.  What a colossal waste of time for no apparent benefit. 

Perhaps someone can explain why Buster is better than Stretch?  My first OS on a Pi was Wheezy on a Pi2B.  That one also bit me in the backside when Octoprint did and automatic upgrade that wouldn't run on Wheezy. It could have checked first and refused to upgrade.  But not.   I had to upgrade the OS to do the exact same thing it was doing the previous day.  The 'new' features of Octoprint were for hardware I didn't have on my 3D printer.  That cost a couple of days of screwing around I'll never get back.

 IMHO I think a 3 year life cycle on an OS is way too short.  Fine if we were still using vacuum tubes and paper oil filled capacitors that had a life of 2 years but the hardware now has a life of 10 to 20.  It's time the software reflected that.

« Last Edit: July 14, 2020, 10:29:46 am by jcdammeyer »

rvk

  • Hero Member
  • *****
  • Posts: 4227
Re: Tutorial: Install Lazarus to Raspberry Pi
« Reply #76 on: July 14, 2020, 11:44:03 am »
1. The last script rvk posted works well as long as it's captured and pasted without leading spaces.
Argh... Yes. There should be no leading spaces. I think the browser you used, inserted them during copy. Chrome does it correctly. This is since the code-tags also have advanced formatting (unlike before).

2. The ICON installed on the desktop is the usual piece of crap that tells me it's a script and asks if I want to edit or run it.  I want to run it.  Always.  Never figured out how to fix that.  It also restarts the config dialog each time rather than directly to Lazarus.  Perhaps because of the fppkg issue.?
I'm not sure I had that too? I can't test it right now because I don't have a spare PI.
But to remove the prompt you can do the following:
Open File Manager, Select Edit - Preferences - General, Tick the option "Don't ask options on launch executable file"

3. The identical Lazarus program compiled by 2.0.8 or 2.0.10 on WIN-XP, WIN-7, WIN-10 also compiles with 2.1.0 on the Pi4.  However the size of fonts and spacing of components on the form is incorrect.  Both development environments are using 1080 screens.

With respect to point 3, one shouldn't have to re-edit all the forms so there's perhaps some Lazarus defaults that are different on the Windows 32/64 bit targets.  Line ends are also handled slightly differently but that's to be expected given CRLF for Windows and LF for Linux.
Isn't the font-size taken from the desktop-font? Look at the size of the font of the form. If it's 0 it will take a default. I think the font-size on the RPI desktop is larger than it should be. So you should take different font-size into consideration OR specify exactly what font-size you want.

dbannon

  • Hero Member
  • *****
  • Posts: 1111
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Tutorial: Install Lazarus to Raspberry Pi
« Reply #77 on: July 14, 2020, 03:03:44 pm »
Mind if I suggest another, quite different approach ?

I have just had a quick play with building my tomboy-ng on a Pi. I installed FPC from a tar then downloaded Lazarus source and built just lazbuild and lcl.  That way, i could build an existing project quite easily, from the command line (as computer are meant to be used) without building Lazarus the IDE at all.

I write the code on a more suitable machine than a Pi, all I want to do is build it. Sounds like you have some legacy code, might work for you too ! 

Now, obviously I am using Buster but the same process should work with any viable OS. Stretch is old but still pretty widely used on larger systems. If its a new stretch install, you will probably need to install libgtk2.0-0-dev first ....

And if this is a silly solution, sorry about that !

Davo

Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng

jcdammeyer

  • Jr. Member
  • **
  • Posts: 60
Re: Tutorial: Install Lazarus to Raspberry Pi
« Reply #78 on: July 14, 2020, 06:58:42 pm »
Mind if I suggest another, quite different approach ?

I have just had a quick play with building my tomboy-ng on a Pi. I installed FPC from a tar then downloaded Lazarus source and built just lazbuild and lcl.  That way, i could build an existing project quite easily, from the command line (as computer are meant to be used) without building Lazarus the IDE at all.
Davo

Your suggestion might work.  However, I did my share of command line stuff on PDP-10s and Unix.  I detest (with a passion) doing anything from the command line.  There wouldn't be a need for Delphi or Lazarus if we were back in the 70's with punch cards writing ALOGOL-W programs on IBM-370s.  (Been there, done that).   So although the socketCAN (https://github.com/linux-can/can-utils) library is useful at the command line for dumping and sending CAN messages it's not really all that useful at the command line. 

As shown in the second photo the second tab, and there are a few more to come, for interacting and simulating a CANopen Master or Slave are much better done with a graphical user interface.  And that philosophy is probably best supported by probably 99.99999...% of PCs, laptops, tablets and even now phones not using a command line interface.  One can use one for a lifetime and never have to use a command line interface.  My two cents.

I'll have to check what OS is available on the Beaglebone Black.  My goal for this project, and the reason for using Lazarus rather than RAD Studio is to make the code available to everyone.  RAD Studio with either C++ or Delphi can compile for Microsoft, Apple and now Linux but not for ARMs like Pi and Beagle.  Not only that Delphi can do multi-platform user interface design so the components on the desktop or tablet surface have the look and feel of that particular environment.  iPad and iPhone buttons look like what you get from Apple.  Android buttons are different as are the ones for PCs and MACs.  All on one development environment. 

Different from Lazarus with Write once, Compile many times, Distribute executable.   In C++ or Delphi or a mix.  But next year when my RAD Studio support license expires I'm not sure I'll have the funds to renew.  And for this project I want to reach a hobby small business market with source code.
John
« Last Edit: July 14, 2020, 07:00:30 pm by jcdammeyer »

jcdammeyer

  • Jr. Member
  • **
  • Posts: 60
Re: Tutorial: Install Lazarus to Raspberry Pi
« Reply #79 on: July 14, 2020, 07:14:14 pm »
Oh and I'm also using Lazarus under LinuxCNC to create the equivalent of MACH3 (WIN-XP) wizards that take away the tedium of writing long G-Code applications to do simple things like instruct a milling machine to bore a hole at a specific location.

Even this program could be designed to run from a command line with a whole bunch of parameters.  And some LinuxCNC users have done exactly that.  But not me.

The PC for my mill is dual boot and runs both LinuxCNC and MACH3 but I don't think I've booted WIN-XP up now for several months so I think I've made my decision to stay with LinuxCNC.  That and to use MACH3 properly it really needs an Ethernet SmoothStepper for $150US or so.  The LinuxCNC is now using a MESA 7i92 Ethernet to Parallel module ($89US).  So a bit of apples and oranges there too.  And MACH4 costs too much and requires either the discontinued WIN-7 or WIN-10 and WIN-10 will never end up running machines in my shop.

I am trying really hard to become a Lazarus user.  MachineKit (a derivation of LinuxCNC) runs on a BeagleBone Black taking advantage of the built in dual hardware processors.  There are others now using a Raspberry Pi for LinuxCNC along with the MESA 7i92.  So once again, Lazarus applications with full source code released are the best way to develop these wizards without ever touching the command line.

dbannon

  • Hero Member
  • *****
  • Posts: 1111
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Tutorial: Install Lazarus to Raspberry Pi
« Reply #80 on: July 15, 2020, 02:07:06 am »
.....
Your suggestion might work.  However, I did my share of command line stuff on PDP-10s and Unix.  I detest (with a passion) doing anything from the command line.  There wouldn't be a need for Delphi or Lazarus if we were back in the 70's with punch cards writing ALOGOL-W programs on IBM-370s.  (Been there, done that).   So although the socketCAN (https://github.com/linux-can/can-utils) library is useful at the command line for dumping and sending CAN messages it's not really all that useful at the command line. 
....
I was not suggesting you build a command line app, my suggestion was that you can build any app (GUI or otherwise) from the command line and so avoid having to build Lazarus.  If you already have the code for your app, or are developing it on a bigger machine, its a way to get it built on the raspberry pi.   I might be wrong but developing any sort of substantial app on the raspberry Pi might be a bit tedious.

Good luck with your project !

Davo
Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng

jcdammeyer

  • Jr. Member
  • **
  • Posts: 60
Re: Tutorial: Install Lazarus to Raspberry Pi
« Reply #81 on: July 15, 2020, 03:10:19 am »
I see your point but as my previous screen shots show, what looks great on Stretch, WIN-XP, WIN-7 and WIN-10 looks terrible on Buster. I've tried changing screen fonts with no luck.  And things like rounded corners on buttons that are square on the Buster version along with positioning out of whack. 

So the Lazurus IDE really has to be there to get around a useless/broken Buster version of the OS.  And again, other than because they have this schedule of upgrading every 3 years I still don't see anything better in Buster.  I've just created a new 16GB SD card for the Pi3.  I'll see what happens there. 

I think overall my better solution might be to move backwards and since I've already had to make changes to LazSerial to get it to work right fixing it so it compiles with Lazarus 1.6 would mean no issues with either the Pi or the Beaglebone.

jcdammeyer

  • Jr. Member
  • **
  • Posts: 60
Re: Tutorial: Install Lazarus to Raspberry Pi
« Reply #82 on: July 15, 2020, 03:11:47 am »
Oh and downloaded your Tomboy-ng to give it a try.  Neat!

jcdammeyer

  • Jr. Member
  • **
  • Posts: 60
Re: Tutorial: Install Lazarus to Raspberry Pi
« Reply #83 on: July 15, 2020, 09:08:51 pm »
Brand new 16GB MicroSD card for Pi3.  Install Buster.
The script poisted by rvk fails every time.  This is just one of the failures.  Initially it was failing with me not being allowed access to /root.  And so on.  So I can install 2.0.0 but the moment I try and install a component package I get this type of error.

https://forum.lazarus.freepascal.org/index.php/topic,46612.0.html

I wasn't getting it with the Pi4 and Buster after running the script from rvk. 

I cannot believe how badly installing the newest lazarus IDE and Free Pascal is broken.  Don't even know where to start looking next.


Code: Text  [Select][+][-]
  1. echo ""pi@raspberrypi:~/lazarus $ ./MakeLazarus
  2.  
  3. ==============================================================
  4. Running on: Raspberry Pi 3 Model B Rev 1.2
  5. ==============================================================
  6.  
  7. Updating package list to latest version (sudo needed)
  8.  
  9. ==============================================================
  10.  
  11. Installing required packages (sudo used)
  12.  
  13. Compiling for ARMv7 Processor (Pi2 and Pi3 only)
  14. ==============================================================
  15.  
  16. Downloading FPC sources
  17.  
  18. Now: Last Changed Rev: 45792
  19.  
  20. Downloading Lazarus sources
  21.  
  22. svn: E120106: ra_serf: The server sent a truncated HTTP response body.
  23. Now:
  24.  
  25. ==============================================================
  26.  
  27. Now compiling FPC, this will take some time
  28.  
  29. /usr/bin/ld.bfd: warning: ./link.res contains output sections; did you forget -T?
  30. /usr/bin/ld.bfd: warning: arm/bin/arm-linux/link.res contains output sections; did you forget -T?    ]
  31. 2.52k [                             <=>                                                              ]
  32.  
  33. Doing some extra configuration
  34.  
  35. ==============================================================
  36.  
  37. Now compiling Lazarus, this will take some time
  38.  
  39. Makefile:2956: warning: overriding recipe for target '.'                                             ]
  40. Makefile:2954: warning: ignoring old recipe for target '.'
  41. Makefile:2956: warning: overriding recipe for target '.'
  42. Makefile:2954: warning: ignoring old recipe for target '.'
  43. Makefile:2956: warning: overriding recipe for target '.'                                             ]
  44. Makefile:2954: warning: ignoring old recipe for target '.'
  45. Makefile:2956: warning: overriding recipe for target '.'                                             ]
  46. Makefile:2954: warning: ignoring old recipe for target '.'
  47. Makefile:2956: warning: overriding recipe for target '.'                                             ]
  48. Makefile:2954: warning: ignoring old recipe for target '.'
  49. make[2]: *** [Makefile:4667: lazarus] Error 1                             <=>                        ]
  50. make[1]: *** [Makefile:5108: bigide] Error 2
  51. make: *** [Makefile:3610: idebig] Error 2
  52.  132  [                                                                 <=>                          ]
  53. Something went wrong compiling Lazarus. Aborting.
  54.  

rvk

  • Hero Member
  • *****
  • Posts: 4227
Re: Tutorial: Install Lazarus to Raspberry Pi
« Reply #84 on: July 15, 2020, 09:51:16 pm »
Downloading Lazarus sources
svn: E120106: ra_serf: The server sent a truncated HTTP response body.
Yikes. Looks like the Lazarus sources are not completely downloaded. I had this too last week. With a second try the error went away.

The script doesn't check if the checkout on svn is successful.
(Maybe I should build that in)

If you keep getting the error you could do
svn cleanup /home/pi/dev/lazarus

And if that doesn't work, you can remove the complete /home/pi/dev directory (including subdirs) and /home/pi/.fpc.cfg

BTW. The script doesn't need root. I run it as pi. But pi has sudo root privileges by default (which are used for the apt-get command).
Nowhere in the script is /root accessed. So what error message did you get for that???

Are you on WiFi or cable? If on WiFi, the svn has a timeout which might get hit (due to WiFi of svn server problems)
see https://stackoverflow.com/questions/27267742/why-do-i-get-svn-e120106-ra-serf-the-server-sent-a-truncated-http-response-b

(I think I also had massive problems with the default integrated WiFi in the RPI3. I used a separate usb-dongle to fix that)

Edit: The lazarus svn seems to be having some problems.
For me:
Quote
==============================================================
Running on: Raspberry Pi 3 Model B Rev 1.2
==============================================================

Updating package list to latest version (sudo needed)

==============================================================

Installing required packages (sudo used)

Compiling for ARMv7 Processor (Pi2 and Pi3 only)
Downloading package fp-compiler-3.0.4

Get:1 http://mirror.serverius.net/raspbian/raspbian buster/main armhf fp-compiler-3.0.4 armhf 3.0.4+dfsg-22+rpi1 [1,789 kB]
Fetched 1,789 kB in 1s (1,600 kB/s)
==============================================================

Downloading FPC sources

Now: Last Changed Rev: 45793

Downloading Lazarus sources

svn: E120108: Error running context: The server unexpectedly closed the connection.
Download of fpc failed. Aborting.
« Last Edit: July 15, 2020, 10:03:42 pm by rvk »

jcdammeyer

  • Jr. Member
  • **
  • Posts: 60
Re: Tutorial: Install Lazarus to Raspberry Pi
« Reply #85 on: July 15, 2020, 10:06:17 pm »
I'm going to start over and reflash the SD card.  Too much of try this and then try that.  I thought I got rid of everything.
Direct.  not WiFi.
And here's an interesting point.  Put Stretch SD card back into Pi3.  The one with Lazarus 1.6.  Seems now for some reason the gdb is not failing and the component is installed and the LazSerial appears to work.  The Beaglebone black only has a command line version of Buster and the newest graphical one is still Stretch and Lazarus is 1.6.  Haven't been able to install anything newer on the BBB.

I think for this project, which is for a series of articles on CANopen, I may see if I can install Lazarus 1.6 on the Windows machines since I now have the LazSerial component (access to USB based Serial ports) working.

The Buster SD card already has the CAN-utils installed and I've been logging CAN messages via the CAN HAT that uses the MCP2515.  The object of the Pi and BBB versions of this application was to select either the USB CAN dongle or select the MCP2515 (CAN0 device) and have identical operation.  Then the Lazarus Pascal code can show how to write CAN bus applications for either a serial port USB to CAN dongle or the SocketCAN Library.  The SocketCAN should be portable to the BBB with it's internal CAN hardware inside the processor.

So I don't really want to reprogram the Buster SD but it may be the best way to start over and not install anything else until I have a newer Lazarus.  But, OTOH, if 1.6 works...

avra

  • Hero Member
  • *****
  • Posts: 1945
    • Additional info
Re: Tutorial: Install Lazarus to Raspberry Pi
« Reply #86 on: July 15, 2020, 11:28:16 pm »
Don't even know where to start looking next.
If other ways do not work for you, then you can take a look at fpcupdeluxe:
https://wiki.lazarus.freepascal.org/fpcupdeluxe

It can be used to install any imaginable Lazarus+FPC combo (official, fixes, trunks...) native on Pi, or for easy install of cross compiler targeting Pi.
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

jcdammeyer

  • Jr. Member
  • **
  • Posts: 60
Re: Tutorial: Install Lazarus to Raspberry Pi
« Reply #87 on: July 15, 2020, 11:52:15 pm »
If other ways do not work for you, then you can take a look at fpcupdeluxe:
https://wiki.lazarus.freepascal.org/fpcupdeluxe
It can be used to install any imaginable Lazarus+FPC combo (official, fixes, trunks...) native on Pi, or for easy install of cross compiler targeting Pi.

That looks really interesting.  Do we just use the fpcupdeluxe-arm-linux link or what needs to be done to install this on a pi (or BBB)?

My eyes are sore from staring at the screen and trying to figure out what to do next.  So I went and played in the shop for a bit.  Just finished changing over a single phase 2HP motor on my mill to a 1.8kW AC Servo controlled by LinuxCNC.
https://youtu.be/VvXMoC917O0

jcdammeyer

  • Jr. Member
  • **
  • Posts: 60
Re: Tutorial: Install Lazarus to Raspberry Pi
« Reply #88 on: July 16, 2020, 12:12:56 am »
BTW, mucking with the font size directly and resizing a few things results in a more presentable display.  I still need to find out what to do to prevent the extra LF that is needed on the WIN systems but not on the Linux.   But considering the LazSerial component had a comment that it wasn't working with Linux ports I've had success here. 

What also doesn't work the same is the ON Change event when the first item in the list is selected from the drop box. Select the 2nd or 3rd and the event is called.  But select the first and it's not.  The WIN version of Lazarus does not have that problem.

The attached screen shot is a grab from real time on Stretch, Lazarus 1.6, Lawicel CANUSB attached v/ttyUSB0.  The screen on the right is a CAN RS485 HAT using an MCP2515 and ifconfig shows it as can0:  They are both on a larger network generating a number of CAN messages.

The next step with either Lazarus 1.6.0 or 2.1.0 is to add those devices into the COM Port selection list and from there chose either the LazSerial connection or the socketCAN connection.

jcdammeyer

  • Jr. Member
  • **
  • Posts: 60
Re: Tutorial: Install Lazarus to Raspberry Pi
« Reply #89 on: July 16, 2020, 12:33:19 am »
OK.  Did a quick download of the WIN32 version.  Wow!   Downloaded the ARM one onto the Pi.  It appears to be installing...2.0.10 which is what I have on the WIN PCs.  I wonder if this will run on the BBB...

Update on Pi3 (Stretch Version 9):  Had a bunch of warnings with SVN client return Error Code 256
and in pink unexpectedly closed connection.
Then after a while.. restarted.  May take some time...

Downloaded same ARM package to BBB (Stretch Version 9).  Had to use terminal to chmod +x and then run ./fpcupdeluxe.
It's poor little single core is usage bar is pinned at 100%.  May take some time...
« Last Edit: July 16, 2020, 12:52:20 am by jcdammeyer »

 

TinyPortal © 2005-2018