Recent

Author Topic: Lazarus Embedded GUI  (Read 6422 times)

Mathias

  • Jr. Member
  • **
  • Posts: 88
Lazarus Embedded GUI
« on: September 21, 2022, 04:31:06 pm »
Lazarus Embedded GUI

I've been developing a GUI for a long time, with which you can easily create programs for embedded systems.
The advantage of the package, almost all settings for compilers and programmers are taken care of.

The AVRs are already very well supported, especially the ordinary Arduinos.
There are quite a few examples for the Arduino UNO.
There are more and more, even for non-Arduino.
STM-32, Arduino DUO, ESPxxx and Rasberry Pico also work, only the examples are (still) missing.
A serial monitor similar to the Arduino IDE is also built in.

Downloads:
https://github.com/sechshelme/Lazarus-Embedded

Installation:
At Lazarus at "Open Package/Package File (.lpi) .../"
Then open this file, compile and install it. ./Lazarus_Embedded_GUI_Package/embedded_gui_package.lpk

Example for an Arduino:
Via "File --> New... --> Project --> [Embedded] Embedded-Project --> Templates... --> Arduino UNO --> Blink Pin 13 --> Ok --> Ok"
an Arduino UNO Project can then be created.
If you want to change something at runtime, you can edit the values ​​via "Project --> [Embedded] Options".

Final word:
The package is developed under Linux, so it may still have bugs under Windows.
A functional embedded cross compiler is required.
I'm always grateful for feedback, whether it's posted directly in the forum or in the Issus ;)
« Last Edit: September 26, 2022, 05:47:31 pm by Mathias »

Handoko

  • Hero Member
  • *****
  • Posts: 5150
  • My goal: build my own game engine using Lazarus
Re: Lazarus Embedded GUI
« Reply #1 on: September 21, 2022, 04:42:52 pm »
That looks great.

I have an Arduino but I am busy currently, will try your Lazarus Embedded GUI when I have time.

Thank you for sharing it.

ccrause

  • Hero Member
  • *****
  • Posts: 856
Re: Lazarus Embedded GUI
« Reply #2 on: September 21, 2022, 09:07:24 pm »
Thank you for sharing this Mathias, it has great potential to help getting new users started in the embedded Pascal world.

A couple of observations on the GUI:
  • I expect a selection (say AVR) to hide non-relevant options elsewhere, for example only show AVRDude as programmer option, the other programmers are not relevant (maybe UF2 too).
  • Currently the CPU info window does not show the controllers for the selected architecture on the main window.  As an additional feature, when selecting a controller, the OK button can copy the controller back to the main window (this will then also require a Cancel button)
  • The AVRDude panel does not show the bottom setting on my small laptop screen - scroll bars should be enabled so that users with smaller screens can navigate to out of view areas
  • Changing the architecture should clear the previously selected example template (could be an empty program skeleton), else one ends up with an example that isn't compatible with the new architecture
  • I think the Programmer selection should only happen in one place, either as radiobuttons or maybe a dropdown list. Then only show the configuration for the selected programmer.

Of course these observations are just my expectation of the work flow of using the interface.

MarkMLl

  • Hero Member
  • *****
  • Posts: 6683
Re: Lazarus Embedded GUI
« Reply #3 on: September 21, 2022, 09:14:21 pm »
I'll try and take a look at this, possibly when I'm next looking at a Pico, but as a question:

A functional embedded cross compiler is required.

Assuming that the FPC sources were available, could it build a cross compiler as needed?

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

ccrause

  • Hero Member
  • *****
  • Posts: 856
Re: Lazarus Embedded GUI
« Reply #4 on: September 22, 2022, 06:48:02 am »
A functional embedded cross compiler is required.

Assuming that the FPC sources were available, could it build a cross compiler as needed?
This would be great in principle, but requires quite a bit of work to ensure a working cross compiler with bin tools ready to use. Fpcupdeluxe already do this well, so perhaps this tool could scan for available cross compiler's and give a warning or note if it is missing.

d.ioannidis

  • Full Member
  • ***
  • Posts: 221
    • Nephelae
Re: Lazarus Embedded GUI
« Reply #5 on: September 22, 2022, 09:57:42 am »
    Assuming that the FPC sources were available, could it build a cross compiler as needed?
    MarkMLl

    This would be great in principle, but requires quite a bit of work to ensure a working cross compiler with bin tools ready to use. Fpcupdeluxe already do this well, so perhaps this tool could scan for available cross compiler's and give a warning or note if it is missing.

    It's easy, IMHO, to add an AVR cross compiler in an official Lazarus/FPC installation on Windows. The easiest way ( for me ) is the following which does not require to change compiler binaries, sources dir, etc in the start "Configure Lazarus IDE" popup window but it will not use have the latest changes/fixes from main.

    It's a ~10 minute work with two 2 clones, 1 copy 2 copies, 1 build and 1 edit process :

    Lets assume that you're installed the lazarus-2.2.2-fpc-3.2.2-win32.

    ( I installed Lazarus to "G:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2" directory, replace it with your Lazarus installation directory )



    1st step, getting the sources and binaries



    You need to add use the same version fpc sources for the AVR cross compiler as your lazarus fpc installation has. In this example you'll need the fpc sources with tag release_3_2_2 .

    Open a command prompt, go to "G:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\3.2.2\" directory and clone the fpc release_3_2_2 tag  :
    [/list]
    Code: Pascal  [Select][+][-]
    1. G:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\3.2.2>git clone --depth 1 --branch release_3_2_2 https://gitlab.com/freepascal.org/fpc/source.git release_3_2_2

    Also clone the fpc binaries to get the windows avr binutils ( I choose to clone it inside the lazarus installation but you can clone it everywhere you want .) :
    Code: Pascal  [Select][+][-]
    1. G:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\3.2.2>git clone https://gitlab.com/freepascal.org/fpc/binaries.git fpc_binaries

    Copy the avr-embedded-* ( ar, as, ld, nm, objcopy, objdump, strip ) binaries from the "<WhereYouCloneTheFPCBinaries>\fpc_binaries\i386-win32\" directory to "G:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\3.2.2\bin\i386-win32" directory.



    2nd step, build the cross compiler and supported AVR mcu's rtl



    Go to the "G:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\3.2.2\release_3_2_2\" direcvtory and build the AVR cross compiler with the following command for i.e. atmega328p the subarch is avr5 ( list of subarchitectures  ) ( again this is my preferred way ) :

    ( I installed Lazarus to "G:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2" directory, replace it with your Lazarus installation directory )

    Code: Pascal  [Select][+][-]
    1. G:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\3.2.2\bin\i386-win32\make.exe clean crossall crossinstall CPU_TARGET=avr OS_TARGET=embedded SUBARCH=avr5 INSTALL_PREFIX=G:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\3.2.2 CROSSOPT="-g- -O3 -CX -XX -Xs" CROSSBINDIR=G:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\3.2.2\bin\i386-win32 BINUTILSPREFIX=avr-embedded- STRIP=1


    ( Addition after Mathias post )


    AFAIU, the fpc 3.2.2 AVR cross compiler doesn't support the avr1, avr2, avrtiny and avrxmega3 subarchs so build everything else using this command ( executed in the same directory as above ) :

    ( I installed Lazarus to "G:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2" directory, replace it with your Lazarus installation directory )

    Code: Pascal  [Select][+][-]
    1. FOR %I IN (avr25 avr35 avr4 avr5 avr51 avr6) DO rmdir /s /q G:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\3.2.2\units\avr-embedded\%I & mkdir G:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\3.2.2\units\avr-embedded\%I & G:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\3.2.2\bin\i386-win32\make.exe crossall crossinstall CPU_TARGET=avr OS_TARGET=embedded SUBARCH=%I INSTALL_PREFIX=G:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\3.2.2 CROSSOPT="-g- -O3 -CX -XX -Xs" CROSSBINDIR=G:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\3.2.2\bin\i386-win32 BINUTILSPREFIX=avr-embedded- STRIP=1 & move G:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\3.2.2\units\avr-embedded\rtl G:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\3.2.2\units\avr-embedded\%I & move G:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\3.2.2\units\avr-embedded\rtl-extra G:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\3.2.2\units\avr-embedded\%I



    3rd step, configure the paths



    ( Removed after Mathias post )

    ( I installed Lazarus to "G:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2" directory, replace it with your Lazarus installation directory )

    Final, edit the G:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\3.2.2\bin\i386-win32\fpc.cfg and change the units searchpath part from :

    Code: Pascal  [Select][+][-]
    1. # searchpath for units and other system dependent things
    2. -FuG:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\3.2.2/units/$fpctarget
    3. -FuG:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\3.2.2/units/$fpctarget/*
    4. -FuG:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\3.2.2/units/$fpctarget/rtl

    to :

    Code: Pascal  [Select][+][-]
    1. #ifdef embedded
    2. -FuG:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\$FPCVERSION/units/$fpctarget/$fpcsubarch
    3. -FuG:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\$FPCVERSION/units/$fpctarget/$fpcsubarch/*
    4. -FuG:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\$FPCVERSION/units/$fpctarget/$fpcsubarch/rtl
    5. #else
    6. # searchpath for units and other system dependent things
    7. -FuG:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\$FPCVERSION/units/$fpctarget
    8. -FuG:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\$FPCVERSION/units/$fpctarget/*
    9. -FuG:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\$FPCVERSION/units/$fpctarget/rtl
    10. #endif
    11.  

    All and all, a 10 minute process to add an AVR cross compiler to an official Lazarus installation on Windows.
    As I mentioned, a drawback of this process is that a lot of fixes, newer functionality etc, sometimes they don't go in the releases but they're remain in main.

    PS: I'm leaving more advanced installation / setups ( debug units, release stripped units, build for smaller or for fastest units ) for other time or to anyone who wants to do it ...... ;)

    regards,
    « Last Edit: September 22, 2022, 05:19:00 pm by Dimitrios Chr. Ioannidis »

    Mathias

    • Jr. Member
    • **
    • Posts: 88
    Re: Lazarus Embedded GUI
    « Reply #6 on: September 22, 2022, 02:00:19 pm »
    Quote
    It's easy, IMHO, to add an AVR cross compiler in an official Lazarus/FPC installation on Windows. The easiest way ( for me ) is the following which doesn't not require to change compiler binaries, sources dir, etc in the start "Configure Lazarus IDE" popup window but it will not use the latest changes/fixes from main.

    It's a ~10 minute work with two 2 clones, 1 copy 2 copies, 1 build and 1 edit process :[
    .....
    It seems that the problem with the SubArch has already been solved.
    Don Alfredo has already done the work for us with fpcupdeluxe.
    I just tested my latest build Lazarus with AVR 25/5/6.
    All now run in parallel without me having to rebuild the cross compiler.

    Now I just have to see if this is also possible with ARM and ESPxx.
    « Last Edit: September 22, 2022, 04:37:57 pm by Mathias »

    d.ioannidis

    • Full Member
    • ***
    • Posts: 221
      • Nephelae
    Re: Lazarus Embedded GUI
    « Reply #7 on: September 22, 2022, 04:19:38 pm »
    I just tested my latest build Lazarus with AVR 25/5/6.

    The whole point of my post was NOT to use the latest main of fpc and/or lazarus ....

    I want to use the releases so I can use ifdef's for the various fpc versions and, IMHO, the development versions ( for both fpc and lazarus ) is a moving target that I don't want to chase during project development. Better the devil you know than the devil you don't .... ;)

    In my post I tried to keep it simple for the people to follow but you can automate all the supported subarch builds with something like the following. On windows open a command prompt go to the release_3_2_2 directory ( look at my previous post ) and run after you build the avr cross compiler :

    Code: Pascal  [Select][+][-]
    1. FOR %I IN (avr25 avr35 avr4 avr5 avr51) DO rmdir /s /q G:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\3.2.2\units\avr-embedded\%I & mkdir G:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\3.2.2\units\avr-embedded\%I & G:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\3.2.2\bin\i386-win32\make.exe crossall crossinstall CPU_TARGET=avr OS_TARGET=embedded SUBARCH=%I INSTALL_PREFIX=G:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\3.2.2 CROSSOPT="-g- -O3 -CX -XX -Xs" CROSSBINDIR=G:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\3.2.2\bin\i386-win32 BINUTILSPREFIX=avr-embedded- STRIP=1 & move G:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\3.2.2\units\avr-embedded\rtl G:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\3.2.2\units\avr-embedded\%I & move G:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\3.2.2\units\avr-embedded\rtl-extra G:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\3.2.2\units\avr-embedded\%I

    All now run in parallel without me having to rebuild the cross compiler.

    The above command doesn't call make with the clean parameter so it doesn't rebuild the ppcrossavr compiler, only the relevant mcu rtl is builded ( all the subarchs in the IN () range/set in the above example ).

    Also notice that the avr fpc 3.2.2 doesn't support the avr1, avr2, avrtiny and avrxmega3 subarchs but I can live with that. I'm testing the fixes_3_2 from time to time to see what AVR bugfixes and/or new functionality are added to prepare my projects for the next version ....

    regards,
    « Last Edit: September 22, 2022, 05:08:24 pm by Dimitrios Chr. Ioannidis »

    MarkMLl

    • Hero Member
    • *****
    • Posts: 6683
    Re: Lazarus Embedded GUI
    « Reply #8 on: September 22, 2022, 04:36:11 pm »
    The whole point of my post was NOT to use the latest main of fpc and/or lazarus ....

    Which sounds entirely reasonable to me. Start off with what's currently installed, ask the user for the location of the compiler sources and where he'd like a cross-compiler to be put (which might not be the same as the location of the existing fpc binary, on e.g. a Linux system), and tell him what else he needs in terms of target linker etc.

    MarkMLl
    MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
    Pet hate: people who boast about the size and sophistication of their computer.
    GitHub repositories: https://github.com/MarkMLl?tab=repositories

    Mathias

    • Jr. Member
    • **
    • Posts: 88
    Re: Lazarus Embedded GUI
    « Reply #9 on: September 22, 2022, 05:02:23 pm »
    Thank you for sharing this Mathias, it has great potential to help getting new users started in the embedded Pascal world.

    A couple of observations on the GUI:
    • I expect a selection (say AVR) to hide non-relevant options elsewhere, for example only show AVRDude as programmer option, the other programmers are not relevant (maybe UF2 too).
    • Currently the CPU info window does not show the controllers for the selected architecture on the main window.  As an additional feature, when selecting a controller, the OK button can copy the controller back to the main window (this will then also require a Cancel button)
    • The AVRDude panel does not show the bottom setting on my small laptop screen - scroll bars should be enabled so that users with smaller screens can navigate to out of view areas
    • Changing the architecture should clear the previously selected example template (could be an empty program skeleton), else one ends up with an example that isn't compatible with the new architecture
    • I think the Programmer selection should only happen in one place, either as radiobuttons or maybe a dropdown list. Then only show the configuration for the selected programmer.

    Of course these observations are just my expectation of the work flow of using the interface.
    Thanks for the feedback

    1. I've already thought of that, with the AVRs it would still be possible. But with the ARM there are the same SubArchs, which different programmers need. What I personally don't like is the combination of RadioButtons and TabPageControls. I've already thought of frames, which adapt to the radio buttons.

    2. This is a bit ugly, so I wanted to adjust it myself.

    3. I could possibly go more broadly. What is your screen resolution?

    4. This bothers me too, this is one of the next steps. If you change the board, there is no longer a need for examples, this only gets in the way.

    5. The same as point 1.

    AlanTheBeast

    • Sr. Member
    • ****
    • Posts: 348
    • My software never cras....
    Re: Lazarus Embedded GUI
    « Reply #10 on: September 23, 2022, 07:59:41 pm »
    The package is developed under Linux, so it may still have bugs under Windows.

    What's the word for Mac OS?

    or Ubuntu in a VM under Mac OS?

    I may do an Arduino or Pico sometime later this year (or early next year ).
    Everyone talks about the weather but nobody does anything about it.
    ..Samuel Clemens.

    Mathias

    • Jr. Member
    • **
    • Posts: 88
    Re: Lazarus Embedded GUI
    « Reply #11 on: September 24, 2022, 04:44:17 pm »
    The package is developed under Linux, so it may still have bugs under Windows.

    What's the word for Mac OS?

    or Ubuntu in a VM under Mac OS?

    I may do an Arduino or Pico sometime later this year (or early next year ).
    If you have a Mac, you are welcome to test it.
    It should work in the VM if you manage to loop through the USB devices.

    Mongkey

    • Sr. Member
    • ****
    • Posts: 430
    Re: Lazarus Embedded GUI
    « Reply #12 on: September 25, 2022, 04:13:05 am »
    i already tested on ubuntu, avr work very good the other not working.

    thank you.

    Mathias

    • Jr. Member
    • **
    • Posts: 88
    Re: Lazarus Embedded GUI
    « Reply #13 on: September 25, 2022, 08:33:10 am »
    i already tested on ubuntu, avr work very good the other not working.

    thank you.
    Unfortunately you cut off the AVR when trying to prevent images, but I assume it's the Atmega328.
    Did you also install the SubArchs with the ARMs and ESPxx?
    Or did you just use the default setting?
    Did you use the latest fpcudeluxe?

    kupferstecher

    • Hero Member
    • *****
    • Posts: 583
    Re: Lazarus Embedded GUI
    « Reply #14 on: September 25, 2022, 02:43:27 pm »
    Hi,

    the name Lazarus Embedded GUI I still think is quite missleading. When I read it I expect a GUI framework for target embedded (forms and controls for an embedded display).

    I'd prefere something like the following:
     Lazarus Embedded Plugin
     Lazarus Embedded Wizard
     Lazarus Embedded Package
     Lazarus Embedded Dialog
    or similar.

     

    TinyPortal © 2005-2018