Recent

Author Topic: LazPackageEmbeddedAVR: Project Wizard for Target AVR  (Read 10644 times)

kupferstecher

  • Hero Member
  • *****
  • Posts: 583
LazPackageEmbeddedAVR: Project Wizard for Target AVR
« on: January 19, 2017, 01:28:08 pm »
Using FPC on AVR worked quite well for me, but the installation procedure and the project setup is a bit tricky. I'd like to simplify things in order to make the FPC more popular on the target embedded.

Therefore I created a Project Wizard for AVR.

In the Project Wizard the user can choose from a list of devices, a project name, the project path and programmer settings. The Project Wizard creates an empty project accordingly with all neccessary settings for the device, instrustion set and so on. The created project can be opened in Lazarus and is directly compilable by Strg+F9. With correct programmer settings it will be written on the target in the same rush.

A special feature is the creation of a file containing all interrupt routines available on the device.

If the compiler is installed correctly than this is a "three-clicks-to-run"-solution.

This project wizard and the AVRFPC compiler and linker should be provided as binaries from official side, then programming with FPC on AVR microcontrollers would be really beginner friendly.

Of course the Wizard - as simple as it is - is not ready yet, especially the programmer command lines have to be defined.

Please have a look and give your suggestions!

--
Edit: Link deleted

Current version as Lazarus IDE Plugin, sources and instructions:
https://github.com/kupferstecher/LazPackageEmbeddedAVR
--
Regards~
« Last Edit: February 24, 2019, 01:19:10 pm by kupferstecher »

turronet

  • New Member
  • *
  • Posts: 19
Re: LazWizardAVR: Project Wizard for Target AVR
« Reply #1 on: January 20, 2017, 12:42:42 am »
Hello,

another approach could be the template.
Here You can find what I did for stm32f103 devices
https://github.com/Turro75/stm32lazarustemplate

Valerio

jmpessoa

  • Hero Member
  • *****
  • Posts: 2297
Re: LazWizardAVR: Project Wizard for Target AVR
« Reply #2 on: January 20, 2017, 01:10:15 am »
Hi there!

Here is my initial work targeting Arduino:

[Lamwino: Lazarus Arduino Module Wizard]

https://github.com/jmpessoa/lazarduinomodulewizard

Maybe some of us can put everything together .....

Greetings!
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

kupferstecher

  • Hero Member
  • *****
  • Posts: 583
Re: LazWizardAVR: Project Wizard for Target AVR
« Reply #3 on: January 20, 2017, 06:27:59 pm »
Jmpessoa, I really like the plugin-sytle of your wizard, so that it can be used within Lazarus. While I don't understand how that is accomplished, yet.

Also that the FPC can be compiled from within the IDE is quite a solution, but wouldn't it be easier to just provide the binaries? The binutils (linker, assembler) are provided by the Arduinu IDE, are they? What else is the purpose of the Arduino installation? As I prefere a more general approach covering the common AVR devices (and ARM seperately) instead of focusing on the arduino boards.

Turronet, Templates like yours are also possible, but you'd need a seperate template for each device. And programmer settings have to be handled seperately then. But still its a good starting point.


Does anyone know the dependency of the instruction sets? For compiling the FPC the instruction set has to be defined (right?) and while compilation again. Is a compilation of two devices with different instruction set with the same FPC installation possible?

PS: Forgot to attach screenshots, here they are now.

djzepi

  • New Member
  • *
  • Posts: 36
Re: LazWizardAVR: Project Wizard for Target AVR
« Reply #4 on: February 10, 2017, 08:49:08 am »
Hello

Could you add to check
if it support Lazarus / FPC embedded system
See the error message (attach file)

kupferstecher

  • Hero Member
  • *****
  • Posts: 583
Re: LazWizardAVR: Project Wizard for Target AVR
« Reply #5 on: February 10, 2017, 10:57:08 am »
Hello djzepi,

to check within the Wizard if the proper cross compiler is available is not so easy, because the Lazarus installation path may vary between different installations.

I'd say if there is an instruction that the crosscompiler has to be installed first, then a check wouldn't be neccessary.
On the other hand I'm not so sure how to provide the crosscompiler in the best way. In Jmpessoa's wizard there is the functionality of compiling the cross compiler. I'd prefere to just provide the binries, but I don't know how to do that in a good way. If everybody has to do the compilation of the cross compiler from sources, then probably only advanced users will do that.

ccrause

  • Hero Member
  • *****
  • Posts: 845
Re: LazWizardAVR: Project Wizard for Target AVR
« Reply #6 on: March 19, 2017, 04:28:43 pm »
Good start! I would like to make some suggestions so that this idea can become more useful:

1. Sort list of devices, this makes it easier to find a device (Combobox.Sorted := true )

2. On my installation it is necessary to change the binutils prefix to avr- by passing the -XPavr- switch to the compiler. May be useful to make this option visible somewhere in the wizard.  Would be convenient if an automatic check can be done to identify the correct prefix, 2nd best would be to check if current configuration can call avr as (on my machine this is avr-as, could be avr-embedded-as on other machines)

3. I prefer it if the programmer action is only added to the "execute after run" option. I compile often as I write code to check for errors and would not want to program the device every time.

4. If a user selects a programmer that requires a serial port parameter then it would be useful if a list of available ports can be presented a la Arduino IDE.  Synapse and PascalSCADA have some code to scan for ports on various OS's.

5. Other popular programmers that can be added to the list of programmers: "avrispv2",  "arduino" and "usbasp".  USBasp doesn't require a port parameter since it runs over USB.

kupferstecher

  • Hero Member
  • *****
  • Posts: 583
Re: LazWizardAVR: Project Wizard for Target AVR
« Reply #7 on: March 19, 2017, 09:44:06 pm »
Hello,

I know that it is not very useful as it is now. The problem is, that I like the plugin-style like jmpessoa made. But I don't know how to do it and I didn't manage to take a closer look in his sources, yet. The same with distributing the compiler, providing binaries would be easier I guess. What I don't understand so far, is the target instruction set, e.g. AVR5, it seems it has to be defined twice, once when compiling the avr-compiler and once when compiling the programm. Does it need a seperate avr-compiler for each target instruction set? And what instruction sets are even supported?

About your suggestions:
1. Sort list of devices, this makes it easier to find a device (Combobox.Sorted := true )
Good point!

2. On my installation it is necessary to change the binutils prefix to avr- by passing the -XPavr- switch to the compiler. May be useful to make this option visible somewhere in the wizard.  Would be convenient if an automatic check can be done to identify the correct prefix, 2nd best would be to check if current configuration can call avr as (on my machine this is avr-as, could be avr-embedded-as on other machines)
Here I'd rather provide suitable binaries. About the prefix, I think an optional one makes things unnecessarily complicated. As you can name the binaries while compilation as you wish. But it might be useful to always use the 'avr' prefix and make that as standard.

3. I prefer it if the programmer action is only added to the "execute after run" option. I compile often as I write code to check for errors and would not want to program the device every time.
I wanted to do that, especially for embedded devices a compilation without a combined program upload is quite useful. But I don't know how to tell Lazarus not to search for an executable when pushing "run". Any idea?

4. If a user selects a programmer that requires a serial port parameter then it would be useful if a list of available ports can be presented a la Arduino IDE.  Synapse and PascalSCADA have some code to scan for ports on various OS's.
Good idea, and with the libs quite easy.

5. Other popular programmers that can be added to the list of programmers: "avrispv2",  "arduino" and "usbasp".  USBasp doesn't require a port parameter since it runs over USB.
Programmers can actually be added very easy, just place a file in the subfolder 'Programmer' and subsubfolder 'AVRDude' or 'Others'. The file name (no file extension) is the programmers name, listet in the dropdown 'programmer'. As content you can write the command line using wildcards. The port parameter by the way is only shown when the corresponding wildcard is used in the file. The files are loaded on programm start.
Of course the programmer command lines should be collected and distributed with the Wizard, but also your own custom command line is as easy to add without reinstallation.

As summary the critical topics for me are now:
- Wizard as stand-alone or as Lazarus plugin?
- How to provide the compiler/binutils, as binaries or as build script? In case of binaries how to host?
- How to compile the avr-compiler for all different instruction sets?

ccrause

  • Hero Member
  • *****
  • Posts: 845
Re: LazWizardAVR: Project Wizard for Target AVR
« Reply #8 on: March 21, 2017, 08:14:51 am »
As summary the critical topics for me are now:
- Wizard as stand-alone or as Lazarus plugin?
Definitely a plugin for creating a new project like jmpessoa's wizard in my opinion.  Perhaps preparation/download of cross compiler, binutils etc can be handled in a stand-alone tool.

- How to provide the compiler/binutils, as binaries or as build script? In case of binaries how to host?
A difficult question. Building from scratch is a bit tricky (I did that) but a build script should make it a whole lot easier. If you bundle everything required as compiled binaries like Arduino then it can become a very large install.  If you go this route someone needs to maintain platform specific collections of fpc, avrdude and avr bin utils.

- How to compile the avr-compiler for all different instruction sets?
h

I'm not sure it is possible at the moment to build a single compiler that supports all the different AVR instruction sets.  The work-around could be to build a compiler per instruction set, the compiler is small enough to make this a non-issue.  Separating the different compiled units (e.g. RTL) in a logical way may require a bit of thinking.  The following issue touches on this: http://bugs.freepascal.org/view.php?id=30294

Perhaps jmpessoa is willing to merge your code with his wizard?  Although I would prefer a name that is not Arduino specific but refers to the more generic AVR processor.  I could create a project on sourceforge of github for this, but I would prefer if different efforts in the same space is concentrated into one project, not split into different projects.

kupferstecher

  • Hero Member
  • *****
  • Posts: 583
Re: LazWizardAVR -> LazPackageEmbeddedAVR
« Reply #9 on: February 24, 2019, 01:07:41 pm »
Lately I remodelled the AVR project wizard to a Lazarus IDE plugin, so that it is integrated in the New Project dialog.

Sources and instruction:
https://github.com/kupferstecher/LazPackageEmbeddedAVR

Please test and give feedback.

What is missing/ incomplete:
- The programmer commands, there are only two as examples now.
- A dialog to change the programmer port after the project is created.
« Last Edit: February 24, 2019, 01:14:28 pm by kupferstecher »

Laksen

  • Hero Member
  • *****
  • Posts: 724
    • J-Software
Re: LazPackageEmbeddedAVR: Project Wizard for Target AVR
« Reply #10 on: February 24, 2019, 01:35:06 pm »
Only the RTL has to be compiled for each subarch. I don't know if there's a neat way of doing that without recompiling the compiler, but either way. The compiler is only dependent on the overall architecture and one ppcrossavr binary will work with all subarch's (instruction sets)

Nice project btw :)

ccrause

  • Hero Member
  • *****
  • Posts: 845
Re: LazPackageEmbeddedAVR: Project Wizard for Target AVR
« Reply #11 on: February 24, 2019, 07:47:14 pm »
Only the RTL has to be compiled for each subarch. I don't know if there's a neat way of doing that without recompiling the compiler, but either way.
Indeed, after the initial cross compiler build it is sufficient to build the RTL from the rtl folder for a different subarchitecture:
Code: Bash  [Select][+][-]
  1. make all FPC=~/fpc/3.3.1/compiler/ppcrossavr FPCFPMAKE=~/fpc/3.3.1/compiler/ppc RELEASE=1 SUBARCH=avr5 BINUTILSPREFIX=avr-
Adjust paths and prefixes and compiler options as required. Of course one still needs to manually rename the rtl folders to something like avr-embedded-avr5 and update the unit search path (in e.g. fpc.cfg) accordingly to keep the different subarch files in separate folders.

kupferstecher

  • Hero Member
  • *****
  • Posts: 583
Re: LazPackageEmbeddedAVR: Project Wizard for Target AVR
« Reply #12 on: February 25, 2019, 10:18:25 am »
It's good to know that the different sub-arches do work parallelly.

I think the LazPackageEmbeddedAVR could also be a good place to add some standard procedures, like delay routines, routines for flash and eeprom access etc.

EDIT:

2. On my installation it is necessary to change the binutils prefix to avr- by passing the -XPavr- switch to the compiler. May be useful to make this option visible somewhere in the wizard.
I didn't implement such an option now and I think it's not useful. There should be one standard and I'd stick to the way FPCUpDeluxe is doing it. I think it's -XPavr-embedded- by now.
« Last Edit: February 25, 2019, 10:22:38 am by kupferstecher »

 

TinyPortal © 2005-2018