Recent

Author Topic: RaspberryPi Zero2W  (Read 6691 times)

Mark20

  • New Member
  • *
  • Posts: 36
RaspberryPi Zero2W
« on: December 16, 2023, 08:52:57 pm »
Hi,
is it possible develop with Lazarus some console program that can use SPI and I2C interfaces on PiZero ?
Somebody have developed anything on this board and have experiences to share ?

Regards,
Marco

cdbc

  • Hero Member
  • *****
  • Posts: 1655
    • http://www.cdbc.dk
Re: RaspberryPi Zero2W
« Reply #1 on: December 17, 2023, 12:11:45 am »
Hi
Maybe search for posts by @ccrause & @PascalByThree in this forum.
They have been discussing something like this...
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 2.2.6 up until Jan 2024 from then on it's: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 3.0

dbannon

  • Hero Member
  • *****
  • Posts: 3156
    • tomboy-ng, a rewrite of the classic Tomboy
Re: RaspberryPi Zero2W
« Reply #2 on: December 17, 2023, 05:12:39 am »
yes, should work fine. I have a app that uses 1-wire temp sensors, same general sort of thing, works perfectly.

Have you looked at the lazarus wiki page on the RasPi ?

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

ccrause

  • Hero Member
  • *****
  • Posts: 970
Re: RaspberryPi Zero2W
« Reply #3 on: December 17, 2023, 06:07:30 am »
Will this be an embedded program (no OS), or run in Linux? The sub forum suggests embedded?

Mark20

  • New Member
  • *
  • Posts: 36
Re: RaspberryPi Zero2W
« Reply #4 on: December 17, 2023, 09:44:03 am »
yes, should work fine. I have a app that uses 1-wire temp sensors, same general sort of thing, works perfectly.

Have you looked at the lazarus wiki page on the RasPi ?

thank you Davo,
can you give me some links on wiki ? 
I asked because the RpiZero2W is smaller than classic Rpi, so I don't know if enough Ram to run a Freepascal application...
I have to use an MQTTclient and some DigI/O for data collection.

@ccrause
for "No OS" do you mean direct hw programming, in C like with microcontrollers ?
I don't know how do this on this board (did a lot on ATmega256), but I'd like  much know where get information to develop on RpiZero in this way.
Can you help ?

Regards,
Marco

ccrause

  • Hero Member
  • *****
  • Posts: 970
Re: RaspberryPi Zero2W
« Reply #5 on: December 17, 2023, 10:43:59 am »
@ccrause
for "No OS" do you mean direct hw programming, in C like with microcontrollers ?
Yes, this is what I meant. I ask because you posted your question under the Embedded forum.  If you want to go the embedded route on the Pi Zero, consider the Ultibo project.  Raw embedded on an ARM processor is a bit more challenging than on an 8 bit AVR.  Ultibo provides a bunch of libraries and low level support to simplify the work you have to do for an embedded program.

From your other questions it seems that you really want to run a Free pascal program on top of Linux. The link that Davo referred to is for use in Linux: https://wiki.freepascal.org/Lazarus_on_Raspberry_Pi#Accessing_external_hardware

Mark20

  • New Member
  • *
  • Posts: 36
Re: RaspberryPi Zero2W
« Reply #6 on: December 17, 2023, 11:29:57 am »
Thank you !
have to study now :-)

hansotten

  • Full Member
  • ***
  • Posts: 101
    • The School of Wirth
Re: RaspberryPi Zero2W
« Reply #7 on: December 17, 2023, 12:15:00 pm »
Hi,
is it possible develop with Lazarus some console program that can use SPI and I2C interfaces on PiZero ?
Somebody have developed anything on this board and have experiences to share ?

Regards,
Marco
Yes, that will work. Use the fpcupdeluxe-armv6hf-linux variant. If you want to run on the Pi and not cross compile, enlarge the swapfile.
There are nice libraries available, see the wiki. I have good results with rpihal but there is more.
https://wiki.lazarus.freepascal.org/Lazarus_on_Raspberry_Pi will help.

Lazarus is a bit heavy for a Pi Zero. Freepascal apps  runs fine.
 
http://pascal.hansotten.com/ Pascal for Small Machines. The School of Wirth, sources of old Pascal compilers,

MarkMLl

  • Hero Member
  • *****
  • Posts: 8027
Re: RaspberryPi Zero2W
« Reply #8 on: December 17, 2023, 12:22:40 pm »
Lazarus is a bit heavy for a Pi Zero. Freepascal apps  runs fine.

The bottom line however is that the amount of swap is probably the most important thing. Also try to move that off the SD-Card if possible, since that type of medium has little-to-no wear levelling and it won't last long in that role.

A couple of thoughts on terminology: hopefully everybody appreciates that the Pi Zero family usually runs Linux, as distinct from the Pi Pico (RP2040) family which doesn't. And of course these days, it's common to consider Linux as a candidate OS for an embedded system, even if by historical standards it is vastly overweight and insufficiently reliable.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

Mark20

  • New Member
  • *
  • Posts: 36
Re: RaspberryPi Zero2W
« Reply #9 on: December 17, 2023, 07:12:33 pm »
@hansotten
if Freepascal apps run fine, for me is enough.
I can develop on Rpi or even PC with cross compile.
Thank you !

@MarkMLl
I need understand if for my app is necessary an OS (Rpi Zero2) or not (Rpi Pico), but now I have the paths to follow. Thank you,
Marco

dbannon

  • Hero Member
  • *****
  • Posts: 3156
    • tomboy-ng, a rewrite of the classic Tomboy
Re: RaspberryPi Zero2W
« Reply #10 on: December 18, 2023, 11:40:52 pm »
Yes Mark20, you probably would be disappointed running Lazarus on a Pi Zero, or even a Linux Desktop but for command line driven, no GUI, absolutely fine.

Depending on what I am doing, I generally edit using Lazarus, because the IDE is really useful, and cross compile from my laptop. Then use sshfs from the Pi to mount that directory from my laptop on the Pi so its easy to run and test the compiled executable.

Alternatively, you may be able to compile on the PI  zero but do keep in mind, as MarkMLI said, the SDcards and not made for repeated rewrites, and compiling does a lot of repeated rewrites.

If you have a 'bigger' PI, at least a 3 with 2G ram, running Lazarus is practicable, just, (must increase swap to initially build Lazarus at least) and the (32bit ?) binary can be used, when perfected, in the zero.

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

MarkMLl

  • Hero Member
  • *****
  • Posts: 8027
Re: RaspberryPi Zero2W
« Reply #11 on: December 19, 2023, 09:14:04 am »
Alternatively, you may be able to compile on the PI  zero but do keep in mind, as MarkMLI said, the SDcards and not made for repeated rewrites, and compiling does a lot of repeated rewrites.

It's specifically swap that causes problems, not rewrites per se.

It would be easy enough to have a script- a few lines or Perl or whatever- which detected that a .lpi file had been changed and ran lazbuild on it.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

dbannon

  • Hero Member
  • *****
  • Posts: 3156
    • tomboy-ng, a rewrite of the classic Tomboy
Re: RaspberryPi Zero2W
« Reply #12 on: December 19, 2023, 10:23:54 am »
I think you do need to consider just the i/o on the SDcard too. Its just the total number of times a particular part of the card is written to. The SDCards do not have the load leveling circuitry that a SSD has to even out those writes over the whole thing. So, you can easily write repeatably to the same spot and they have a limited number of times each spot is written to.

Yep, a particular problem with swap files but I always ensure, for example, my Lazarus Source is on a USB disk before I compile Lazarus.  (Its actually a conventional hard disk connected over USB, slower but the RasPi is no ball of fire anyway).

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

Thaddy

  • Hero Member
  • *****
  • Posts: 16174
  • Censorship about opinions does not belong here.
Re: RaspberryPi Zero2W
« Reply #13 on: December 19, 2023, 10:45:16 am »
The swap is only necessary during compilation annd you can revert it  when your software is running properly. When compiling with FPC on the zero itself I change the swap from 128 to 512, when compiling with Lazarus too I use either 1024 or 2048 depending on components needed. Nowadays I merely use cross-compiling, though.
It also helps if you use at least a class 10 card although a class 4 should still work.
If I smell bad code it usually is bad code and that includes my own code.

dbannon

  • Hero Member
  • *****
  • Posts: 3156
    • tomboy-ng, a rewrite of the classic Tomboy
Re: RaspberryPi Zero2W
« Reply #14 on: December 19, 2023, 11:06:16 am »
I recently found, using Debian Bookworm on a PasPi4 with only 2G ram that I needed to increase swap to 1G when compiling Lazarus. The same hardware a year (?) ago running Debian Bullseye based Raspi OS worked 'out of the box', so I don't know if its because Lazarus has got bigger or the OS has got bigger, both true of course.

But I did not reverse the increase, no point really, if it does not need that extra swap, it won't use it, if it does need it, its there. Using swap is always undesirable but preferable to crashing the system.

There was a large HPC facility in this Nations capital where a good friend of mine would always kill any long running job that went into swap, I got a lot of credit at my facility by just sending a polite email.

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

 

TinyPortal © 2005-2018