Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2013-03

Free-pascal question

21 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Chavoux Luyt

Hi all

This might be slightly off-topic... I have some fpc -related questions:
1. How good is Lazarus/fpc for embedded programming (compared to C)? It will probably be on a (custom-made) device with ARM/Atmel-based chipset (with or without an OS - will this make a difference?).
2. I remember that the original Turbo Pascal (and Delphi) could use in-line (i386) assembler. Is this still possible with Lazarus/free-pascal and for other chipsets like Atmel/ARM?

Thanks
Chavoux
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20130307/4a7d4b7f/attachment.html>

Reply by email

Sven Barth
to Chavoux Luyt
Chavoux Luyt wrote
1. How good is Lazarus/fpc for embedded programming (compared to C)? It will probably be on a (custom-made) device with ARM/Atmel-based chipset (with or without an OS - will this make a difference?).

I can't tell you how good or bad it is, but there are quite some boards supported already by FPC. You can take a look here for the current list: http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/rtl/embedded/arm/

2. I remember that the original Turbo Pascal (and Delphi) could use in-line (i386) assembler. Is this still possible with Lazarus/free-pascal and for other chipsets like Atmel/ARM?

FPC supports inline assembly for each supported target except the JVM ones. Of course you need to write in the correct assembly language for each CPU (and maybe differentiate with {$ifdef CPUXYZ} if you want to support multiple processors).

As a sidenote: For pure Pascal development (and I consider embedded development part of this) I suggest you to use the fpc-pascal list in the future.

Regards,
Sven

Reply by email

Graeme Geldenhuys
to Chavoux Luyt: Hi all This might be slightly off-topic... I have some fpc -related questions: 1. How…
Chavoux Luyt wrote
This might be slightly off-topic... I have some fpc -related questions: 1. How good is Lazarus/fpc for embedded programming (compared to C)?

FPC works just fine for embedded programming. I haven't tried LCL for such tasks, simply because LCL is to "fat" for my taste. Rather large executables, even for a "hello world" application.

Paul Breneman has some excellent information about embedded work with FPC in combination with fpGUI toolkit. A simple 2.5MB download and you have a compiler, fpGUI toolkit, Visual Forms Designer and the experimental Maximus IDE. Due to the usage of fpGUI, executables are nice and small too.

I've tested his downloads with a Garmin iQue M5 (WinCE device), and with a Raspberry Pi (ARM Linux). Paul uses different devices.

http://www.turbocontrol.com/easyfpgui.htm

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Reply by email

Michael Schnell
to Chavoux Luyt: Hi all This might be slightly off-topic... I have some fpc -related questions: 1. How…
Chavoux Luyt wrote
1. How good is Lazarus/fpc for embedded programming (compared to C)? It will probably be on a (custom-made) device with ARM/Atmel-based chipset (with or without an OS - will this make a difference?).

What exactly do you mean by embedded ?

Possible definitions include:

- (hard) real-time
- direct hardware access
- interrupt programming
- code in Flash memory (for "diskless" low-cost hardware)
- no OS
- no GUI (for "headless" low-cost hardware)
- memory space efficiency (for low-cost hardware)
- speed efficiency (for low-cost hardware)
- cross compiling
- remote debugging

Some people (especially in the German Lazarus forum) currently are experimenting with cross compiling and remote debugging using a QNAP NAS (headless ARM Linux device using an embedded "diskless" Linux distribution)

Others are experimenting with Android (on ARM-Linux) or devices like "Raspberry Pi" (extremely cheap ARM-Linux device constructed for educational use).

-Michael

Reply by email

Sven Barth
to Michael Schnell
Michael Schnell wrote
Others are experimenting with Android (on ARM-Linux) or devices like "Raspberry Pi" (extremely cheap ARM-Linux device constructed for educational use).

Note: for Android the new native android target in 2.7.1 should be used (currently supports arm-android and i386-android, but AFAIK not yet mips-android).

Regards,
Sven

Reply by email

Sven Barth
to Michael Schnell
Michael Schnell wrote
On 03/07/2013 11:28 AM, Sven Barth wrote: > Note: for Android the new native android target in 2.7.1 should be used I understand this is the JVM compiler. Correct ?

No, you're wrong. Since a few weeks native android support was merged to trunk. When I write arm-android, i386-android and mips-android I mean these the native platforms. If I talk about the JVM one that is jvm-android.

Regards,
Sven

Reply by email

Chavoux Luyt
to Michael Schnell: What exactly do you mean by embedded ? Possible definitions include: - (hard) real-time -…

Hi Michael

Michael Schnell wrote 8 lines
On 03/07/2013 10:45 AM, Chavoux Luyt wrote: > 1. How good is Lazarus/fpc for embedded programming (compared to C)? It > will probably be on a (custom-made) device with ARM/Atmel-based chipset > (with or without an OS - will this make a difference?). > > What exactly do you mean by embedded ?

I am not going to build the hardware myself, but will probably (help to) program the device. It will be a programmable GPS collar, so I am not sure what the engineers are going to include. But to answer your questions:

Show quoted text 5 lines
Possible definitions include: - (hard) real-time

Probably not necessary. It will need a real-time clock, though.

- direct hardware access

Yes, this will be needed.

- interrupt programming

Yes, probably. I want to include an accelerator meter and it should send a hardware interrupt to tell the device to take a GPS reading.

- code in Flash memory (for "diskless" low-cost hardware)

Definitely diskless to fit in a GPS collar.

- no OS

Although an OS will probably make things easier, low power consumption will be the most (?) important requirement. An OS that runs all the time (or use too much power to boot up every time it receives a hardware interrupt) will probably not work (even if an open-source OS exists for a specific chipset).

- no GUI (for "headless" low-cost hardware)

Yes! (If there is an OS, it might be possible to have a web interface and embedded web server for settings etc., though).

- memory space efficiency (for low-cost hardware)

Yes! It needs to store at least 2160 GPS data points (in addition to the main program itself and any configuration settings).

- speed efficiency (for low-cost hardware)

Yes!

- cross compiling

Yes, the development will be done on Linux (either fpc or c cross-compiler) and written to the device using whatever pins/connectors are available (probably USB and possibly wireless/UHF - this will depend on hardware design)

- remote debugging

Will depend on the chipset and hardware design... can this be done using fpc?

.Thanks
Chavoux
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20130307/0c7f3325/attachment-0001.html>

Reply by email

Reinier Olislagers
to Chavoux Luyt
Chavoux Luyt wrote
Will depend on the chipset and hardware design... can this be done using fpc?

fpc list please.

I'm sure having this kind of information there would be helpful both to current subscribers and people searching the fpc list later.

Having it in the Laz list makes it awkward to search and pollutes the dicussions.

Thanks,
Reinier

Reply by email

Sven Barth
to Chavoux Luyt
Chavoux Luyt wrote 10 lines
Hi Reinier On 7 March 2013 13:18, Reinier Olislagers wrote: > On 7-3-2013 11:57, Chavoux Luyt wrote: >> Will depend on the chipset and hardware design... can this be done using >> fpc? > fpc list please. I am not currently a member of that list. Should I join fpc-Pascal or fpc-devel to ask this? (I assume it is one of the lists found on this page: http://www.freepascal.org/maillist.var)?

As you want to use FPC (or at least research whether you should) the correct list would be fpc-pascal. And the link is correct.

Regards,
Sven

Reply by email

Michael Schnell
to Chavoux Luyt: Hi Michael I am not going to build the hardware myself, but will probably (help to)…
Chavoux Luyt wrote
Although an OS will probably make things easier, low power consumption will be the most (?) important requirement.

If power consumption is a very major issue, the best possible arch that somewhere is in reach is the PIC32 which in fact is a MIPS variant. I know that a MIPS implementation for the fpc compiler is being worked on.

- no GUI (for "headless" low-cost hardware) Yes! (If there is an OS, it might be possible to have a web interface and embedded web server for settings etc., though).

While no-GUI projects are not too hard a problem, you need to consider, that the normal Delphi like "event driven" programming paradigm is not possible with the current Lazarus library (it is possible with the "mse" library, that is similar on other accounts.)

Show quoted text 7 lines
- cross compiling Yes, the development will be done on Linux (either fpc or c cross-compiler) and written to the device using whatever pins/connectors are available (probably USB and possibly wireless/UHF - this will depend on hardware design)

While fpc officially does support Cross compiling, it is no especially easy to get it working (see the appropriate Wiki articles)

Show quoted text 6 lines
- remote debugging Will depend on the chipset and hardware design... can this be done using fpc?

Lazarus uses gdb for debugging. If you don't use an OS (such as Linux) on the target, you can't use the GNU created gdb "receiver" (either gdb or gdbserver). I seem to remember that in this forum I read something about a standard protocol that allows to attach hardware debugger devices, that someone might be willing to implement into Lazarus.

-Michael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20130307/127e5863/attachment.html>

Reply by email

Graeme Geldenhuys
to Michael Schnell
Michael Schnell wrote
While fpc officially does support Cross compiling, it is no especially easy to get it working (see the appropriate Wiki articles)

All it takes is a bit of practice with the installation.

Alternatively, use CodeTyphon
[http://www.pilotlogic.com/sitejoom/index.php/codetyphon]. CodeTyphon is a repackaged FPC & Lazarus with lots of cross-compiling options all built-in, plus every component you could ever wish for. It is like the "Studio version" of Lazarus. :) Quite impressive actually.

Lazarus uses gdb for debugging. If you don't use an OS (such as Linux) on the target, you can't use the GNU created gdb "receiver" (either gdb or gdbserver).

You could also debug using a debugserver and the dbugintf unit included with FPC. Making it communicate over TCP shouldn't be too hard, and is on my todo list. FPC includes a rudimentary console debug server, and LCL and fpGUI versions also exist, which are much better.

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Reply by email

Chavoux Luyt
to Graeme Geldenhuys

Hi

Graeme Geldenhuys wrote 12 lines
On 2013-03-07 12:33, Michael Schnell wrote: > While fpc officially does support Cross compiling, it is no especially > easy to get it working (see the appropriate Wiki articles) All it takes is a bit of practice with the installation. Alternatively, use CodeTyphon [http://www.pilotlogic.com/sitejoom/index.php/codetyphon]. CodeTyphon is a repackaged FPC & Lazarus with lots of cross-compiling options all built-in, plus every component you could ever wish for. It is like the "Studio version" of Lazarus. :) Quite impressive actually.

Thanks Graeme, I'll have a look.

Show quoted text 8 lines
> Lazarus uses gdb for debugging. If you don't use an OS (such as Linux) > on the target, you can't use the GNU created gdb "receiver" (either gdb > or gdbserver). You could also debug using a debugserver and the dbugintf unit included with FPC. Making it communicate over TCP shouldn't be too hard, and is on my todo list. FPC includes a rudimentary console debug server, and LCL and fpGUI versions also exist, which are much better.

Or use a well-placed oscilloscope. ;-)
I have done a few embedded projects in the past (using C/assembler) where that was my only debugging tool...
not so much fun for a programmer, but a good learning experience. Unfortunately, I don't have my own oscilloscope (they are really expensive), but I hope one of the engineers will have one.

Cheers
Chavoux

Reply by email

Michael Schnell
to Graeme Geldenhuys: All it takes is a bit of practice with the installation. Alternatively, use CodeTyphon…
Graeme Geldenhuys wrote
All it takes is a bit of practice with the installation.

I just tried unsuccessfully (but of course not hard enough) to get cross-compiling for ARM going. (Result: unspecific error messages from "make crossinstall": when doing it as a normal user: "timeout", when doing it as root: "memory overflow". This happens when the cross compiler tries to create the RTL (already with the first file: system,.pp)

OTOH the crosscompiler created by "make crossinstall" before, does seem to work: it issues a correct command line message and it can compile a workable "writeln ('hello world');" .

The problem might be, that I tried it on Debian 64 bit with a 64 bit version of fpc to compile the crosscompiler. So I suppose the cross compiler is a 64 bit program.

Andy from the German forum could build this cross compiler and RTL on a 32 bit Debian.

-Michael

Reply by email

Reinier Olislagers
to Michael Schnell: I just tried unsuccessfully (but of course not hard enough) to get cross-compiling for…
Michael Schnell wrote 6 lines
On 03/07/2013 02:20 PM, Graeme Geldenhuys wrote: > All it takes is a bit of practice with the installation. I just tried unsuccessfully (but of course not hard enough) to get cross-compiling for ARM going. (Result: unspecific error messages from "make crossinstall": when doing it as a normal user: "timeout", when

<snip>

Sorry, what does all of this have to do with Lazarus? The OP has meanwhile continued the discussion on the fpc list...

Reply by email

Michael Schnell
to Chavoux Luyt: Hi Thanks Graeme, I'll have a look. Or use a well-placed oscilloscope. ;-) I have done a…
Chavoux Luyt wrote
I have done a few embedded projects in the past (using C/assembler) where that was my only debugging tool..

Poor boy. :-(

I would not do any decent work without a debugger (Right now I mostly use an JTAG/USB adapter and Eclipse to do C/ASM code with an (68K) "Fido" processor. Hopefully I might get fpc support for this chip in the future. The chip also features four 8-bit coprocessors that don't have any debugger support, so with same I need to do "scope-debugging" (in fact using an "USB-Adapter" Logic-analyzer with display on the PC), as well. But here it's only ASM with a very limited amount of code.)

-Michael

Reply by email

Graeme Geldenhuys
to Michael Schnell: Only if the target runs an OS that gdbserver can run on. Chavoux seems to prefer a system…
Michael Schnell wrote
Only if the target runs an OS that gdbserver can run on.

Please note, I said "debugserver", not "gdbserver". Lazarus and fpGUI includes GUI debug server applications. For example, take a look at <laz>/tools/debugserver/debugserver.lpi
You use this with the dbugintf unit - which comes with FPC.

Chavoux seems to prefer a system without a "big" OS.

Yes, I noticed this afterwards, so my suggestion will probably not fit his needs.

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Reply by email

Michael Schnell
to Graeme Geldenhuys
Graeme Geldenhuys wrote
Lazarus and fpGUI includes GUI debug server applications. For example, take a look at <laz>/tools/debugserver/debugserver.lpi You use this with the dbugintf unit - which comes with FPC.

I see. Do you know of any hardware debug interfaces that might work with this ?

-Michael

Reply by email