Forum > Embedded

Lazarus Embedded GUI

<< < (2/5) > >>

d.ioannidis:

--- Quote from: MarkMLl on September 21, 2022, 09:14:21 pm ---Assuming that the FPC sources were available, could it build a cross compiler as needed?
MarkMLl

--- End quote ---


--- Quote from: ccrause on September 22, 2022, 06:48:02 am ---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.

--- End 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 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  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---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  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---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  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---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  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---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  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---# searchpath for units and other system dependent things-FuG:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\3.2.2/units/$fpctarget-FuG:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\3.2.2/units/$fpctarget/*-FuG:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\3.2.2/units/$fpctarget/rtl
to :


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---#ifdef embedded-FuG:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\$FPCVERSION/units/$fpctarget/$fpcsubarch-FuG:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\$FPCVERSION/units/$fpctarget/$fpcsubarch/*-FuG:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\$FPCVERSION/units/$fpctarget/$fpcsubarch/rtl#else# searchpath for units and other system dependent things-FuG:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\$FPCVERSION/units/$fpctarget-FuG:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\$FPCVERSION/units/$fpctarget/*-FuG:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\$FPCVERSION/units/$fpctarget/rtl#endif 
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,

Mathias:

--- 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 :[
.....
--- End quote ---
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.

d.ioannidis:

--- Quote from: Mathias on September 22, 2022, 02:00:19 pm ---I just tested my latest build Lazarus with AVR 25/5/6.

--- End quote ---

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  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---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

--- Quote from: Mathias on September 22, 2022, 02:00:19 pm ---All now run in parallel without me having to rebuild the cross compiler.

--- End quote ---

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,

MarkMLl:

--- Quote from: Dimitrios Chr. Ioannidis on September 22, 2022, 04:19:38 pm ---The whole point of my post was NOT to use the latest main of fpc and/or lazarus ....

--- End quote ---

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

Mathias:

--- Quote from: ccrause 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.

--- End quote ---
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.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version