Re: [fpc-pascal] MQTT package for freepascal/lazarus?

2022-10-21 Thread Koenraad Lelong via fpc-pascal

Hi,

FWIW,
I'm using MQTT via cmd-line. I.e. I call
 ExecuteProcess(MQTTExec,MQTTStrArr);
while MQTTExec is /usr/bin/mosquitto_pub

That's on a linux-server.


Op 20/10/2022 om 15:57 schreef Bo Berglund via fpc-pascal:

On Thu, 20 Oct 2022 11:11:17 +0200, Bo Berglund via fpc-pascal
 wrote:


On Tue, 11 Oct 2022 19:42:26 +0200 (CEST), Karoly Balogh via fpc-pascal
 wrote:


Hi,

On Tue, 11 Oct 2022, Bo Berglund via fpc-pascal wrote:


I am looking for a pascal implementation of the MQTT protocol.
I could not find anything inside Lazarus' OnLinePackageManager.

Is there something like that available?


I made a front-end Pascal library, and and Object Pascal wrapper for
libmosquitto a couple of years ago. It's available here. It's know to work
on Linux, Windows and macOS at least. It's against libmosquitto 1.x. Not
sure if 2.x got released meanwhile. I can update things if needed. (Pull
requests are welcomed.)

It's available here:
https://github.com/chainq/mosquitto-p


Well, the version of the mosquitto broker server that gets installed on my
RaspberryPi4 is:

$ mosquitto --version
Error: Unknown option '--version'.
mosquitto version 2.0.11
mosquitto is an MQTT v5.0/v3.1.1/v3.1 broker.

So this is what I have to communicate with as a client.

I need to be able to publish as well as subscribe to topics.

In the Lazarus forum I have seen people having problems with this when they use
various FPC packages while the native command line works OK (on Linux), probably
because they are using old packages not updated for the changes made in MQTT in
recent years.

So this is why I am asking if there is some MQTT client package available for
FPC/Lazarus that complies to the updated protocols?


I found this on the Lazarus forum:
https://forum.lazarus.freepascal.org/index.php/topic,54397.msg435050.html#msg435050

Not a poackage, but rather advice on how to utilize binary "drivers" installed
on the system via translated header files. Not optimal, but might be doable
anyway.

I will try that path going forward, just now dealing with the MQTT source
devices.



___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] ExecuteProcess problem

2020-08-25 Thread Koenraad Lelong via fpc-pascal

FWIW,

That array did the trick. Thanks again.
But I'll study the wrapper in the near future.

Op 25/08/2020 om 18:18 schreef Koenraad Lelong via fpc-pascal:

Hi,
Thanks for the suggestion I will try that array.

Why I did it like that : I thought it an easy and fast way to enhance my 
project. I added the same value to rrd, the same way, i.e. a 
ExecuteProcess with a bunch of parameters. There it works, but no double 
quotes needed.


LAter I will try your wrapper.

Op 25/08/2020 om 15:52 schreef Karoly Balogh (Charlie/SGR) via fpc-pascal:


Just a guess, but I think you need to do:

MQTTStr[0]:='-h';
MQTTStr[1]:=MQTTBroker;
MQTTStr[2]:='-t';
MQTTStr[3]:=MQTTTopic;

... etc.
MQTTStr[n]:='-m';
MQTTStr[n+1]:=MQTTMessage;


...


BTW, shameless plug, but this is a very very hacky way to talk to an MQTT
broker I think, I've made a raw C header conversion, and a Pascal-style
multithreaded OOP wrapper for libmosquitto, so you can properly integrate
MQTT communication in your Free Pascal app (tested on Linux, MacOS and
Windows):

https://github.com/chainq/mosquitto-p


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] ExecuteProcess problem

2020-08-25 Thread Koenraad Lelong via fpc-pascal

Hi,

Thanks for the reply, I did know of that project. The thing is, at the 
moment I don't know how to implement that in my project. I'm still 
studying this.


Op 25/08/2020 om 15:55 schreef Luca Olivetti via fpc-pascal:


Not what you're asking, but did you try to send the messages yourself 
instead of using mosquitto_pub?

I didn't try it, but there's

https://github.com/heX16/mqtt-free-pascal

Bye

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] ExecuteProcess problem

2020-08-25 Thread Koenraad Lelong via fpc-pascal

Hi,
Thanks for the suggestion I will try that array.

Why I did it like that : I thought it an easy and fast way to enhance my 
project. I added the same value to rrd, the same way, i.e. a 
ExecuteProcess with a bunch of parameters. There it works, but no double 
quotes needed.


LAter I will try your wrapper.

Op 25/08/2020 om 15:52 schreef Karoly Balogh (Charlie/SGR) via fpc-pascal:


Just a guess, but I think you need to do:

MQTTStr[0]:='-h';
MQTTStr[1]:=MQTTBroker;
MQTTStr[2]:='-t';
MQTTStr[3]:=MQTTTopic;

... etc.
MQTTStr[n]:='-m';
MQTTStr[n+1]:=MQTTMessage;


...


BTW, shameless plug, but this is a very very hacky way to talk to an MQTT
broker I think, I've made a raw C header conversion, and a Pascal-style
multithreaded OOP wrapper for libmosquitto, so you can properly integrate
MQTT communication in your Free Pascal app (tested on Linux, MacOS and
Windows):

https://github.com/chainq/mosquitto-p


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] ExecuteProcess problem

2020-08-25 Thread Koenraad Lelong via fpc-pascal

Hi,
I'm extending an old daemon so it writes the data to MQTT, using 
mosquitto_pub.
To have a correct message (-m ...) I need to include double-quotes. But 
it seems ExecuteProcess(exec,cmdline) splits the cmdline according some 
rules if it's a single string.

When I tried to do it in a single string :
-h 127.0.0.1 -t solartopic -u user -P secret -i clientid -m "{\"Pac\": 
458.00}"

I got :
Error: Unknown option 'Pac\":'.
So I need to make cmdline an array. How I do that ?
I tried :
 MQTTStr : array [0..5] of ansistring;
...
 MQTTStr[0]:='-h '+MQTTBroker;
 MQTTStr[1]:='-t '+MQTTTopic;
 MQTTStr[2]:='-u '+MQTTUser;
 MQTTStr[3]:='-P '+MQTTPassw;
 MQTTStr[4]:='-i '+MQTTClientID;
 MQTTStr[5]:='-m "{\"'+ChanName+'\": '+TextValue+'}"';
 ExecuteProcess(MQTTExec,MQTTStr));
But then :
Error: Unknown option '-h 127.0.0.1'.
Use 'mosquitto_pub --help' to see usage.

Thanks in advance

Koenraad
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Serial to TCP gateway in FPC?

2017-06-29 Thread Koenraad Lelong

Op 29-06-17 om 10:25 schreef Bo Berglund:

On Sun, 18 Jun 2017 20:36:11 +0200, Koenraad Lelong
<fpasc...@de-brouwerij.be> wrote:


Do you know the SDPO-package ? That has a serial component (SDPOSerial).
This has a OnRxData event.


Do you mean SDPO or 5DPO (letter S or number 5 at the start)?
I googled for SDPO but the hits were for 5DPO...



It's the same project. Sometimes it's called 5dpo sometimes sdpo.
In the component-list there is a tab 5dpo, but the component itself is 
called TSdpoSerial. If you want to install it, you have to install 
SdpoSerialLaz.


HTH,
Koenraad

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Serial to TCP gateway in FPC?

2017-06-18 Thread Koenraad Lelong

Op 18-06-17 om 18:16 schreef Bo Berglund:

Hi,

Do you know the SDPO-package ? That has a serial component (SDPOSerial). 
This has a OnRxData event.


Just a thought. I used it in the past without problems.

HTH

Koenraad.


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] GPIO for pi

2016-07-28 Thread Koenraad Lelong

Op 28-07-16 om 21:53 schreef Bo Berglund:

On Thu, 28 Jul 2016 09:12:53 +0200, Koenraad Lelong
<fpasc...@de-brouwerij.be> wrote:


I'll ammend the application so users should input the address and port
on the form, and give a warning to remove any IO from the pi.


Thanks,
I received the updated project with the explanation for each test
added.
I put this into a separate directory and opened it and it
compiled/built fine without errors.
But when I hit the Green run button in Lazarus I get an error box
saying that the debugger entered the error state.
More info is:

The GDB command:
"-gdb-set confirm off"
did not return any result.

This did not happen last time I tested after doing a dist-upgrade to
get the GPIO service installed. Now I have also rebooted the Pi and
now both the previous and this new version exhibit this error.
So it seems like the Raspbian upgrade has hosed my Lazarus
environment.

Did you see this too?



No, I can run the application from within lazarus.
Could you try to run the application 'stand-alone' ?
FWIW, I have two different lazarus-versions on that pi, both from fcpup, 
but different versions of both fpc and lazarus. Both work.

From the about-boxes :
First :
Lazarus 1.5 (2015-11-06)
fpc 3.1.1
Second
Lazarus 1.6RC1 (2015-12-17)
fpc 3.0.0

Koenraad.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Test for valid ip address

2016-07-28 Thread Koenraad Lelong

Op 28-07-16 om 10:38 schreef Christo:


The in_addr IP address type is a packed record of byte, so if an IP
address part larger than 255 is encountered in a string it will be
truncated when copied to the byte record using StrToHostAddr.  This
probably means you have to use some other means of detecting an invalid
address, or add a check for (tmpAddress <> IPAddressStr) to cater for
your situation.


Thanks,

I used the check :
(tmpAddress <> IPAddressStr)
in stead of
(tmpAddress='0.0.0.0')

Koenraad

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] Test for valid ip address

2016-07-28 Thread Koenraad Lelong

Hi,

I need a way to test if an string containing an ipv4-address is really 
an ipv4-address.

I tried
tmpAddress:=HostAddrToStr(StrToHostAddr(IPAddressStr));
writeln(tmpAddress);
 if (tmpAddress='0.0.0.0') then
  begin
   writeln('Error in IP-address');
   IPAddressStr:=tmpAddress;
  end;
When I enter 192.168.185.297 (i.e. not a valid ipv4 address) in 
IPAddressStr I get

192.168.185.41
not the expected error-message.

According to the rtl-manual :

function StrToHostAddr(IP: AnsiString) : in_addr
Description: StrToHostAddr converts the string representation in IP to a 
host address and returns the host

address.
Errors: On error, the host address is filled with zeroes.

I would think that converting those zeroes to a host-address would yield 
0.0.0.0.


Am I missing something ?
Is there a better way, without using some other network-library ?

Koenraad.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] GPIO for pi

2016-07-28 Thread Koenraad Lelong

Op 28-07-16 om 00:59 schreef Bo Berglund:

On Wed, 27 Jul 2016 21:43:10 +0200, Bo Berglund
 wrote:





Now done updating Raspbian to latest version.
And the project compiles!

If it works is another story because I do not understand what to do
with a form with a long list of checkboxes without explanation...


The program is a demo/test program. It's the gui-fied version of 
x_pigpiod_if2.c.

Remove any IO from the pi, and then just press the Test-button.
The program then tests all functions (tests a through c are not 
implemented yet, because I don't have the extra hardware, like SPI or 
I2C devices). All tests should display 'PASS', there are sub-tests.

Output is like this :
Connected to pigpio daemon 0
Testing pigpiod C I/F 2
pigpio version 54
Hardware revision 10489921
Mode/PUD/read/write tests
TEST 1.1 PASS (set mode, get mode: 0)
TEST 1.2 PASS (set pull up down, read: 1)
TEST 1.3 PASS (set pull up down, read: 0)
TEST 1.4 PASS (write, get mode: 1)
TEST 1.5 PASS (read: 0)
TEST 1.6 PASS (write, read: 1)
PWM dutycycle/range/frequency tests.
...

Remember to program the IP-address of your pi at the start of the 
Test-button OnClick event, in the parameters of the pigpio_start call. 
That has to be the x.x.x.x form. 127.0.0.1 should work if you run the 
application on the pi itself.


The c-version uses pigpio_start(0, 0) where those 0's mean 'default 
values', which are ip-address 127.0.0.1 and port .

I tried to replace those by
 pigpio_start(PChar(#0), PChar(#0)) or
 pigpio_start(PChar(''), PChar(''))
Both didn't work, so I hardcoded these values.

I'll ammend the application so users should input the address and port 
on the form, and give a warning to remove any IO from the pi.


Koenraad
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] GPIO for pi

2016-07-27 Thread Koenraad Lelong

Op 27-07-16 om 15:52 schreef Bo Berglund:

Thanks,
I unpacked the zip in my Projects dir on a Raspberry Pi3 running Raspbian.
Did nothing else to the files.

Then opened the project in Lazarus 1.6 (with FPC 3.0) and executed a compile 
command.
I received an error message so I repeated it again and the same error appeared:

Compile Project, Target: x_pigpiod_if2: Exit code 256, Errors: 1
/usr/bin/ld: warning: link.res contains output sections; did you forget -T?
/usr/bin/ld: cannot find -lpigpiod_if2
x_pigpiod_if2.lpr(21,0) Error: Error while linking

Is this a project that requires the presence of some other binary packages or 
libraries?
Like pigpiod_if2

Best Regards,

Bo Berglund

Bo,

I have following files on the pi :
/usr/lib/libpigpio.so
/usr/lib/libpigpiod_if2.so

Do you have these ? I'm running the latest raspbian-image 
(2016-05-27-raspbian-jessie.img).
You could also download the library from 
http://abyz.co.uk/rpi/pigpio/index.html and compile and install that.


To use the library, you need of course enable the gpio-server 
(raspi-config/advanced options). Or manually start it when you have an 
older (or different ?) OS-version.


HTH

Koenraad.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Parallel Port Access with Free Pascal - windows

2016-07-26 Thread Koenraad Lelong

Op 24-07-16 om 16:29 schreef James Richters:

Bo,
I also have a raspberry pi project..  I got a hifi-berry card for it and it
is streaming audio to a central audio system, I'm using VLC media player and
an app on my cell phone to control it,  I have not made use of the GPIO on
them yet, but I would really like to learn how this can be accomplished with
FPC, since I am more familiar with pascal than any other language, it would
be great to learn how to do this!  I have a particular application in mind.
I have a relay board that will turn relays on and off with TTL level
signals, what I wish to do is have a remote way to turn certain amplifiers
on and off.   There are 24 amplifiers going to 44 speakers (4 are
subwoffers) in and around my house, sometimes I'll want just downstairs and
outside amps on, other times I'll want just one room on, or all amps on
etc.The amps are all in my crawlspace under the first floor, and that's
where the raspberry pi is.  I also have some volume control chips that are
controlled by clocking data into them, I could chain them all together and
be able to control all of them with just one clock and one data bit.
Any advice on how to get started on controlling GPIO with a raspberry pi
with FPC would be greatly appreciated!

-Original Message-
From: fpc-pascal-boun...@lists.freepascal.org
[mailto:fpc-pascal-boun...@lists.freepascal.org] On Behalf Of Bo Berglund
Sent: Sunday, July 24, 2016 2:22 AM
To: fpc-pascal@lists.freepascal.org
Subject: Re: [fpc-pascal] Parallel Port Access with Free Pascal - windows

On Fri, 22 Jul 2016 14:19:20 +, Mark Morgan Lloyd
 wrote:


Or go the whole hog and
port the program onto a Raspberry Pi: Bo's doing something like you're
asking.


Yes, indeed! I now have something like 7-8 operational RPi units for
different purposes and in several places I have used the GPIO pins to
control and read back digital stuff from FPC programs. Very convenient.

Last I did was to attach a 4-way relay board to a RPi and put a smapp FPC
command line program on it, which gets called from a PHP script on the
Apache webserver on the Pi.
Now I have a webpage, with which I can switch on/off the relays with in
order to control the operational state of some measuring equipment sitting
half way across the workd!

You could do a LOT with FPC and a Raspberry Pi!

Examples:
The Pi also runs an OpenVPN server so I can access it with PuTTY and/or
TightVNC to program it if I need to.

My Pi also has a port mapping utility which makes it possible for me to
remotely access a WiFi network device on a WiFi access point close to the
RPi again from a long distance away. THis was created with FPC and Indy10 on
the RPi.


While Bo's contribution is valid, I have the impression that the 
raspberry is going to the pigpiod. Newer raspbian images have a switch 
(in raspi-config/advanced options) to enable a gpio-server. Using that 
it is possible to access all gpio-functions (gpio, serial, spi, pwm, 
...) as a normal user. See http://abyz.co.uk/rpi/pigpio/index.html. 
There is a snag : the communication with the server happens via the 
network, so it could be that your pi will be hijacked, unless you take 
precautions.


FWIW, I ported the library to fpc, together with the test/demo software 
(x_pigpiod_if2).
The fact that the communication goes via the network opens possibilities 
though. I tested my port on my laptop, connected to the pi. So 
applications running on a remote PC could control the pi's IO.


I have no public place to publish this software, so if anyone is 
interested, please ask.


Koenraad.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] ARM-embedded Interrupt numbers

2015-08-24 Thread Koenraad Lelong

Op 14-08-15 om 14:18 schreef Jeppe Johansen:

Hi Koenraad,

For simplicity I think it would be best to just add them to each unit
without too many macros.

There's not a clear line for what to include in the RTL units at the
moment, but with CMSIS growing more relevant I think it makes sense to
have that table of IRQn numbers in there for all Cortex-M devices.

You can either just use SVN to create a patch (there's info here:
http://wiki.freepascal.org/Creating_A_Patch), or just send the files to
me and I'll fix it up.

Best Regards,
Jeppe

Hi,

Sorry it's been a while, but here are the modifications I did and the 
include file.
That include file is a Pascal version of the stm32f10x.h file from CMSIS 
3.5.0.


I hope this will appear in some future FPC-version.

Koenraad.

Index: fpc-31290/rtl/embedded/arm/stm32f10x_hd.pp
===
--- fpc-31290/rtl/embedded/arm/stm32f10x_hd.pp	(revision 31290)
+++ fpc-31290/rtl/embedded/arm/stm32f10x_hd.pp	(working copy)
@@ -39,6 +39,8 @@
 
  FSMCBank4PCCARD	= FSMCBase+$3000;
 
+ {$i stm32f10x_intr.inc}
+
 type
  TTimerRegisters = record
   CR1, res1,
Index: fpc-31290/rtl/embedded/arm/stm32f10x_ld.pp
===
--- fpc-31290/rtl/embedded/arm/stm32f10x_ld.pp	(revision 31290)
+++ fpc-31290/rtl/embedded/arm/stm32f10x_ld.pp	(working copy)
@@ -39,6 +39,8 @@
 
  FSMCBank4PCCARD	= FSMCBase+$3000;
 
+ {$i stm32f10x_intr.inc}
+
 type
  TTimerRegisters = record
   CR1, res1,
Index: fpc-31290/rtl/embedded/arm/stm32f10x_md.pp
===
--- fpc-31290/rtl/embedded/arm/stm32f10x_md.pp	(revision 31290)
+++ fpc-31290/rtl/embedded/arm/stm32f10x_md.pp	(working copy)
@@ -39,6 +39,8 @@
 
  FSMCBank4PCCARD	= FSMCBase+$3000;
 
+ {$i stm32f10x_intr.inc}
+ 
 type
  TTimerRegisters = record
   CR1, res1,
Index: fpc-31290/rtl/embedded/arm/stm32f10x_xl.pp
===
--- fpc-31290/rtl/embedded/arm/stm32f10x_xl.pp	(revision 31290)
+++ fpc-31290/rtl/embedded/arm/stm32f10x_xl.pp	(working copy)
@@ -39,6 +39,8 @@
 
  FSMCBank4PCCARD	= FSMCBase+$3000;
 
+ {$i stm32f10x_intr.inc}
+
 type
  TTimerRegisters = record
   CR1, res1,
const
  NonMaskableInt_IRQn= -14; //  2 Non Maskable // interrupt 
   
  HardFault_IRQn = -13;  //  4 Cortex-M3 Memory Management // 
interrupt  
  MemoryManagement_IRQn  = -12; //  4 Cortex-M3 Memory Management // 
interrupt  
  BusFault_IRQn  = -11; //  5 Cortex-M3 Bus Fault // interrupt  

  UsageFault_IRQn= -10; //  6 Cortex-M3 Usage Fault // interrupt

  SVCall_IRQn= -5;  // 11 Cortex-M3 SV Call // interrupt
  
  DebugMonitor_IRQn  = -4;  // 12 Cortex-M3 Debug Monitor // interrupt  
  
  PendSV_IRQn= -2;  // 14 Cortex-M3 Pend SV // interrupt
  
  SysTick_IRQn   = -1;  // 15 Cortex-M3 System Tick // interrupt
  
  WWDG_IRQn  = 0;   //  Window WatchDog // interrupt

  PVD_IRQn   = 1;   //  PVD through EXTI Line detection // 
interrupt
  TAMPER_IRQn= 2;   //  Tamper // interrupt 
   
  RTC_IRQn   = 3;   //  RTC global // interrupt 
   
  FLASH_IRQn = 4;   //  FLASH global // interrupt   
   
  RCC_IRQn   = 5;   //  RCC global // interrupt 
   
  EXTI0_IRQn = 6;   //  EXTI Line0 // interrupt 
   
  EXTI1_IRQn = 7;   //  EXTI Line1 // interrupt 
   
  EXTI2_IRQn = 8;   //  EXTI Line2 // interrupt 
   
  EXTI3_IRQn = 9;   //  EXTI Line3 // interrupt 
   
  EXTI4_IRQn = 10;  // EXTI Line4 // interrupt  
  
  DMA1_Channel1_IRQn = 11;  // DMA1 Channel 1 global // interrupt   
   
  DMA1_Channel2_IRQn = 12;  // DMA1 Channel 2 global // interrupt   
   
  DMA1_Channel3_IRQn = 13;  // DMA1 Channel 3 global // interrupt   
   
  DMA1_Channel4_IRQn = 14;  // DMA1 Channel 4 global // interrupt   
   
  DMA1_Channel5_IRQn = 15;  // DMA1 Channel 5 global // interrupt   
   
  DMA1_Channel6_IRQn = 16;  // DMA1 Channel 6 global // interrupt   
   
  DMA1_Channel7_IRQn = 17;  // DMA1 Channel 7 global // interrupt 

  {$ifdef stm32f10x_ld}
  ADC1_2_IRQn= 18;  // ADC1 et ADC2 global 

[fpc-pascal] ARM-embedded Interrupt numbers

2015-08-14 Thread Koenraad Lelong

Hi,

I'm trying to restart my arm-embedded project.
A few years ago I had a working compiler, with some utility-files.

I made a new cross-compiler (fpc svn 31290). But I don't find where the 
interrupt-numbers of an STM32F103xx processor are defined.
So I made an inc-file and added that to e.g. 
rtl/embedded/arm/stm32f10x_md.pp, because that's the processor I'm 
working with.
The inc-file does contain ifdef's for the different STM32F10x processors 
though, so all stm32F10x files could contain that inc-file.


Is this the way to do it ? Or is there  better way ? Or does this exist 
already ?


Comments please.

If that's a proper way to do this, how could this be included in a next 
version of fpc ? Do I make a bug-report including the new file, with 
diffs for the modified files ?

How do I make a proper diff ?

Thanks,

Koenraad.

Code snippet of the interrupt-numbers :

const
  NonMaskableInt_IRQn= -14; //  2 Non Maskable // interrupt 

  HardFault_IRQn  = -13;  //  4 Cortex-M3 Memory Management 
// interrupt
  MemoryManagement_IRQn  = -12; //  4 Cortex-M3 Memory Management 
// interrupt
  BusFault_IRQn  = -11; //  5 Cortex-M3 Bus Fault // 
interrupt
  UsageFault_IRQn= -10; //  6 Cortex-M3 Usage Fault // 
interrupt
  SVCall_IRQn= -5;   // 11 Cortex-M3 SV Call // 
interrupt
  DebugMonitor_IRQn  = -4;   // 12 Cortex-M3 Debug Monitor // 
interrupt
  PendSV_IRQn= -2;   // 14 Cortex-M3 Pend SV // 
interrupt
  SysTick_IRQn= -1;  // 15 Cortex-M3 System Tick // 
interrupt
  WWDG_IRQn  = 0;   //  Window WatchDog // interrupt 

  PVD_IRQn= 1;//  PVD through EXTI Line 
detection // interrupt
  TAMPER_IRQn= 2;   //  Tamper // interrupt 

  RTC_IRQn= 3;//  RTC global // interrupt 

  FLASH_IRQn  = 4;//  FLASH global // interrupt 

  RCC_IRQn= 5;//  RCC global // interrupt 

  EXTI0_IRQn  = 6;//  EXTI Line0 // interrupt 

  EXTI1_IRQn  = 7;//  EXTI Line1 // interrupt 

  EXTI2_IRQn  = 8;//  EXTI Line2 // interrupt 

  EXTI3_IRQn  = 9;//  EXTI Line3 // interrupt 

  EXTI4_IRQn  = 10;  // EXTI Line4 // interrupt 

  DMA1_Channel1_IRQn  = 11;  // DMA1 Channel 1 global // 
interrupt
  DMA1_Channel2_IRQn  = 12;  // DMA1 Channel 2 global // 
interrupt
  DMA1_Channel3_IRQn  = 13;  // DMA1 Channel 3 global // 
interrupt
  DMA1_Channel4_IRQn  = 14;  // DMA1 Channel 4 global // 
interrupt
  DMA1_Channel5_IRQn  = 15;  // DMA1 Channel 5 global // 
interrupt
  DMA1_Channel6_IRQn  = 16;  // DMA1 Channel 6 global // 
interrupt

  DMA1_Channel7_IRQn  = 17;  // DMA1 Channel 7 global // interrupt

  {$ifdef stm32f10x_ld}
  ADC1_2_IRQn= 18;   // ADC1 et ADC2 global // 
interrupt
  USB_HP_CAN1_TX_IRQn= 19;   // USB High Priority or CAN1 TX 
Interrupts
  USB_LP_CAN1_RX0_IRQn= 20;  // USB Low Priority or CAN1 RX0 
Interrupts
  CAN1_RX1_IRQn  = 21;   // CAN1 RX1 // interrupt 

  CAN1_SCE_IRQn  = 22;   // CAN1 SCE // interrupt 

  EXTI9_5_IRQn= 23;  // External Line[9:5] Interrupts 

  TIM1_BRK_IRQn  = 24;   // TIM1 Break // interrupt 

  TIM1_UP_IRQn= 25;  // TIM1 Update // interrupt 

  TIM1_TRG_COM_IRQn  = 26;   // TIM1 Trigger and Commutation // 
interrupt
  TIM1_CC_IRQn= 27;  // TIM1 Capture Compare // 
interrupt
  TIM2_IRQn  = 28;   // TIM2 global // interrupt 

  TIM3_IRQn  = 29;   // TIM3 global // interrupt 

  I2C1_EV_IRQn= 31;  // I2C1 Event // interrupt 

  I2C1_ER_IRQn= 32;  // I2C1 Error // interrupt 

  SPI1_IRQn  = 35;   // SPI1 global // interrupt 

  USART1_IRQn= 37;   // USART1 global // interrupt 

  USART2_IRQn= 38;   // USART2 global // interrupt 

  EXTI15_10_IRQn  = 40;  // External Line[15:10] Interrupts 

  RTCAlarm_IRQn  = 41;   // RTC Alarm through EXTI Line // 
interrupt
  USBWakeUp_IRQn  = 42;  // USB WakeUp from suspend through 
EXTI Line // interrupt

  {$endif}

  {$ifdef STM32F10X_LD_VL}
  ADC1_2_IRQn= 18;   // ADC1 et ADC2 global // 
interrupt
  EXTI9_5_IRQn= 23;  // External Line[9:5] Interrupts 

  TIM1_BRK_IRQn  = 24;   // TIM1 Break // interrupt 

  TIM1_UP_IRQn= 25;  // TIM1 Update // interrupt 



___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] linux ACL

2015-01-23 Thread Koenraad Lelong

Hi,

I need to set ACL's on files on Linux. Is there something ready-made in 
fpc ? Or should I use a TProcess and execute a setfacl that way ?


TIA

Koenraad
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] ARM Linux cross development

2014-01-15 Thread Koenraad Lelong

op 15-01-14 11:42, Michael Schnell schreef:

  - We only could get fpc, gdb, and gdbserver compiled after installing
the complete Code Source C cross development suite (including
Eclipse). We did not find any smaller and more handy package that did
work for that purpose. We did not thinks that it is worth (or even
legal) to recommend this in the Wiki.


Just curious : are you sure ? When I started cross-compiling I thought 
also I needed a whole tool-chain. Now I'm using just binutils, comiled 
for my processor. But in my case I'm just working with arm-embedded, so 
no real OS envolved. That works fine.


Koenraad.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] ARM Linux cross development

2014-01-15 Thread Koenraad Lelong

op 15-01-14 13:31, Michael Schnell schreef:


Did you try to create the  PC-ARM cross gdb and ARM cross-compile the
ARM gdbserver ? It might be that this in fact was why he needed the huge
libraries.


I did create a cross-gdb, I think. But no server. I'm using JTAG, with 
openocd. I use Insight compiled for arm-embedded. Insight is a GUI for 
GDB, and maybe gdb is compiled in, I don't know.
I connect the JTAG-dongle to the PC via USB. Then I start openocd. Then 
I can telnet to openocd to erase and program the flash. Then I use 
Insight that connects to openocd via a network-interface to debug.


FWIW

Koenraad.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] arm-embedded and interrupts

2013-12-11 Thread Koenraad Lelong

op 11-12-13 19:36, Jeppe Græsdal Johansen schreef:


What am I doing wrong ?

Thanks for any pointers.

Koenraad Lelong

The Cortex-M RTL units were changed some time ago to favour a more
flexible way of doing interrupt handling for embedded devices, by
implementing assembler support for weak references and scrapping the old
compiler integrated interrupt vector system.

Now to declare an interrupt routine you would do:

procedure SysTick_interrupt; [public, alias: 'SysTick_interrupt'];
begin
end;

You can check the source code of the RTL unit you are using to find the
names of the interrupt handler functions.


Thanks,

That works. I already found the names, but I didn't know how to declare 
the interrupts, so now I do.

I hope to do some real work in the next few weeks.

Regards,

Koenraad Lelong

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Using arm-embedded-fpc

2013-10-26 Thread Koenraad Lelong

op 24-10-13 13:41, Koenraad Lelong schreef:

But I'm unable to locate where that '--build-id' is generated for the
linker-commandline. If that is removed (only for arm-embedded ?), the
build-id will not be generated, so no wasted memory.


Hi,

I found where the '--build-id' is defined : /etc/fpc.cfg
Is this standard ? Or is this something the OpenSuse packager of fpc added ?
I modified it to :
# --
# Use BuildId by default
# --
#IFNDEF EMBEDDED
-k--build-id
#ENDIF

Then is works. Could fpcmkcfg do this, as I understand that this is what 
generates a standard fpc.cfg when installing fpc ?


Koenraad

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Using arm-embedded-fpc

2013-10-24 Thread Koenraad Lelong

op 23-10-13 21:51, Florian Klämpfl schreef:

Am 23.10.2013 20:01, schrieb Michael Ring:

This article describes what build-id does:

https://fedoraproject.org/wiki/Releases/FeatureBuildId

your fix should get applied to trunk, the gnu-build section should end
up somewhere, best place is flash, it will not get used anyway.


Well, the best would be if it ended up nowhere because it eats only
flash memory.


Hi,

I modified t_embed.pas to not include that line in link.res :
.note.gnu.build-id : { *(.note.gnu.build-id) } flash

But I'm unable to locate where that '--build-id' is generated for the 
linker-commandline. If that is removed (only for arm-embedded ?), the 
build-id will not be generated, so no wasted memory.


Regards,

Koenraad.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Using arm-embedded-fpc

2013-10-23 Thread Koenraad Lelong

op 23-10-13 11:33, Tomas Hajny schreef:

On Wed, October 23, 2013 11:23, Koenraad Lelong wrote:

...


Are you aware of compiler option -s (or -sh, but that is the default for
-s if I remember correctly)?

Tomas


Hi Tomas,

fpc@linux:~/src-arm-fpc fpc -Parm -Tembedded -Wplpc2124 -sh tled1.pp
Free Pascal Compiler version 2.7.1 [2013/10/23] for arm
Copyright (c) 1993-2013 by Florian Klaempfl and others
Target OS: Embedded
Compiling tled1.pp
tled1.pp(54,4) Fatal: Can't open executable tled1.elf
Fatal: Compilation aborted
Error: /usr/bin/ppcrossarm returned an error exitcode (normal if you did 
not specify a source file to be compiled)


fpc@linux:~/src-arm-fpc ls -l
total 16
-rw-r--r-- 1 fpc users  867 okt 23 11:55 link.res
-rw-r--r-- 1 fpc users 1187 okt 23 10:33 tled1.pp
-rw-r--r-- 1 fpc users 4710 okt 23 11:55 tled1.s

tled1.s seems the assembly-file of the source. link.res is the same as 
the one I get when I don't use -sh.


Thanks anyway.

Koenraad Lelong
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Using arm-embedded-fpc

2013-10-23 Thread Koenraad Lelong

op 23-10-13 12:09, Carsten Bager schreef:

Have a look at this file
http://freepascal.dk/files/fpcarm7.tgz
This is a 2.05 compiler, but I am still using it in produktion.
This is an old package that uses LPC2138 as target.
Now a days we use LPC2368 and LPC 2387 as target.
The compiler produce good code.
Regards
Carsten


Hi Carsten,

Unfortunately, my target will be STM32. I used the lpc to follow the 
wiki. Once I get that working I hope the STM32 will be working also. And 
I would like to use fpc 2.7.1 because I know that this version has 
enhanced interrupt-handling. I mean, it's easy to use interrupts, at 
least, I think, reading the sources of the cross-compiler. I once had a 
working STM32 cross-compiler but there you had to be very carefull when 
you defined interrupt-routines.


Thanks anyway.

Koenraad Lelong.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Using arm-embedded-fpc

2013-10-23 Thread Koenraad Lelong

op 23-10-13 13:54, Jonas Maebe schreef:


On 23 Oct 2013, at 12:05, Koenraad Lelong wrote:


fpc@linux:~/src-arm-fpc fpc -Parm -Tembedded -Wplpc2124 -sh tled1.pp
Free Pascal Compiler version 2.7.1 [2013/10/23] for arm
Copyright (c) 1993-2013 by Florian Klaempfl and others
Target OS: Embedded
Compiling tled1.pp
tled1.pp(54,4) Fatal: Can't open executable tled1.elf
Fatal: Compilation aborted
Error: /usr/bin/ppcrossarm returned an error exitcode (normal if you
did not specify a source file to be compiled)


Can you try again after applying the attached patch?


Jonas


Thanks Jonas,

Now I can use -sh. The resulting ppas.sh :

#!/bin/sh
DoExitAsm ()
{ echo An error occurred while assembling $1; exit 1; }
DoExitLink ()
{ echo An error occurred while linking $1; exit 1; }
echo Assembling program
/usr/bin/arm-embedded-as -mfpu=softvfp -o tled1.o tled1.s
if [ $? != 0 ]; then DoExitAsm program; fi
rm tled1.s
echo Linking tled1
OFS=$IFS
IFS=

/usr/bin/arm-embedded-ld -g  --build-id   --gc-sections  -L. -o 
tled1.elf -T link.res

if [ $? != 0 ]; then DoExitLink tled1; fi
IFS=$OFS
echo Linking tled1
OFS=$IFS
IFS=

/usr/bin/arm-embedded-objcopy -O ihex tled1.elf tled1.hex
if [ $? != 0 ]; then DoExitLink tled1; fi
IFS=$OFS

Tinkering with it I found --build-id gives my problem. If that is 
removed, there are no errors.

But I also analyzed link.res :
SEARCH_DIR(/usr/lib/fpc/2.7.1/units/arm-embedded/rtl/)
SEARCH_DIR(/usr/lib/fpc/2.7.1/)
INPUT (
tled1.o
/usr/lib/fpc/2.7.1/units/arm-embedded/rtl/system.o
/usr/lib/fpc/2.7.1/units/arm-embedded/rtl/lpc21x4.o
)
ENTRY(_START)
MEMORY
{
flash : ORIGIN = 0x, LENGTH = 0x0004
ram : ORIGIN = 0x4000, LENGTH = 0x4000
}
_stack_top = 0x40004000;
SECTIONS
{
 .text :
{
_text_start = .;
KEEP(*(.init, .init.*))
*(.text, .text.*)
*(.strings)
*(.rodata, .rodata.*)
*(.comment)
_etext = .;
} flash
.note.gnu.build-id : { *(.note.gnu.build-id) }
.data :
{
_data = .;
*(.data, .data.*)
KEEP (*(.fpc .fpc.n_version .fpc.n_links))
_edata = .;
} ram AT flash
.bss :
{
_bss_start = .;
*(.bss, .bss.*)
*(COMMON)
} ram
. = ALIGN(4);
_bss_end = . ;
}
_end = .;


Deducing from the error-message :
/usr/bin/arm-embedded-ld: error: no memory region specified for loadable 
section `.note.gnu.build-id'


in ppas.sh I modified the line
.note.gnu.build-id : { *(.note.gnu.build-id) }
to
.note.gnu.build-id : { *(.note.gnu.build-id) } flash

Then ppas.sh reports no errors.

I modified compiler/systems/t_embed.pas to have that line, and then the 
compilation of tled1 without -sh produces a tled1.elf. And the 
disassembled tled1.elf seems to be the program when comparing with a 
saved tled1.s.


So, is it safe to include that 'flash' to the linking script via the 
compiler ? Did I find a bug, or am I doing something wrong ?


Thanks for your support.

Koenraad

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Using arm-embedded-fpc

2013-10-23 Thread Koenraad Lelong

op 23-10-13 19:33, Michael Ring schreef:

I think I remember that we had a discussion on build-id before, it did
not work on linux but I thought that Florian has created a fix and I
think I have verified that it works after that on my linux system.

Are you on Linux? And using trunk compiler? If you do not use trunk then
please try to use it, hopefully the fix is in there.

Michael


Michael,

I downloaded it this morning, svn trunk. And I'm working on linux.
There was indeed a discussion (started jan 23, by me), but I never could 
compile an application, actually link the application, it was the same 
error. Today I looked into it again, and I hope I found a solution.


Regards,

Koenraad.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] ipv6 address convertion

2013-08-01 Thread Koenraad Lelong

Hi,
I need to manipulate an ipv6 address. I need to add some value to the 
netaddress and replace the hostaddress with another value. E.g. add 2 to 
the netaddress and replace the hostaddress by ::1

2001:db8:8500:11f8:6631:50ff:fe9a:640b/62 - 2001:db8:8500:11fa::1/62

Is there a function in fpc that converts a 'short' ipv6 address to its 
full length ? I.e. convert :: to the required number of 0's to get a 
'full' address ? E.g.

2001:DB8:8500:11f8::1 - 2001:0DB8:8500:11f8::::0001

And what are the NetAddrToStr6 and HostAddrToStr6 and their counterparts 
supposed to do ? Same for the ipv4 functions.


If I try following program (compiled with fpc 2.6.0) with this :
./project1 6 2001:DB8:8500:11f8::1/62
I get strange results :
netadr  : ::0033:3DBB:1000::0034:5296:1000
hostadr : ::
netadr  : 2001:0DB8:8500:11F8::0001
hostadr : 2001:0DB8:8500:11F8::0001

Note the first netaddress.

program project1;

{$mode objfpc}{$H+}

uses
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  Classes, sockets;

var
  inparam : string;
  address : string;

begin

if not ((paramstr(1)='6') or (paramstr(1)='4')) then
 writeln('only 4 or 6 allowed as first parameter')
else
 if paramstr(1)='6' then
  begin
   inparam:=paramstr(2);
   writeln(inparam);
   address:=copy(inparam,1,pos('/',inparam)-1);
   writeln('netadr  : ',NetAddrToStr6(StrToNetAddr6(inparam)));
   writeln('hostadr : ',HostAddrToStr6(StrToHostAddr6(inparam)));
   writeln('netadr  : ',NetAddrToStr6(StrToNetAddr6(address)));
   writeln('hostadr : ',HostAddrToStr6(StrToHostAddr6(address)));
  end
else
 begin
   inparam:=paramstr(2);
   writeln(inparam);
   address:=copy(inparam,1,pos('/',inparam)-1);
   writeln('netadr  : ',NetAddrToStr(StrToNetAddr(inparam)));
   writeln('hostadr : ',HostAddrToStr(StrToHostAddr(inparam)));
   writeln('netadr  : ',NetAddrToStr(StrToNetAddr(address)));
   writeln('hostadr : ',HostAddrToStr(StrToHostAddr(address)));
 end;
end.


Thanks,

Koenraad Lelong
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Program not running

2013-05-29 Thread Koenraad Lelong

Op 27-05-13 21:20, Koenraad Lelong schreef:

Hi,


..

A suggestion on the hardkernel-forum said it might be an armhf problem.
Is it prossible to compile fpc from armhf ? Should I do this native ? 
I mean, I have an fpc running on the hardware, but it's an armel, at 
least I think it is. My ppcarm says Compiler CPU target arm. Then : 
supported targets : linux for ARMEL.


Thanks,

Koenraad Lelong
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Program not running

2013-05-29 Thread Koenraad Lelong

Op 29-05-13 18:16, Thomas Schatzl schreef:


There's snapshot on the ftp.

Downloaded ftp://ftp.freepascal.org/pub/fpc/snapshot/v27/arm-linux-armhf/




Should I do this native ?



Copied the contents to /usr
Tried fpc -i, shows fpc 2.6.2, for armel.

Is there some mistake ?

Since it seems possible, I'll have to investigate how to make my own armhf.

Koenraad.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Program not running

2013-05-27 Thread Koenraad Lelong

Hi,

Does anyone have an idea why a program made with fpc will not run ?
I have an odroid X2 module, with xubuntu armhf. I installed the 
fpc/fpgui-package from Paul Breneman on it. Then I compiled the demo's 
which went fine. But when I tried to start those executables I get an 
error :

./helloworld
-bash: ./helloworld: No such file or directory

When I file the executables I get :

file helloworld
helloworld: ELF 32-bit LSB executable, ARM, version 1 (SYSV), 
dynamically linked (uses shared libs), for GNU/Linux 2.0.0, not stripped


ldd gives :
ldd helloworld
not a dynamic executable

A bare fpc-program gives the same results.

program test;

begin

writeln('tfpc-test');
end.

Commandline to compile this :
./ppcarm test -Sc -FEbin -FUdcu -Fufpcunits -Iufpcunits

Running those same executables on a Raspberry Pi works OK.

Thanks for any idea's.

Koenraad Lelong
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Not working download-link

2013-05-26 Thread Koenraad Lelong

Hi,

I just tried to download fpc for arm-linux. The links on the website are 
broken.

Now it is :
ftp://freepascal.stack.nl/pub/fpc/dist/arm-linux-2.6.2/fpc-2.6.2.arm-linux.tar
It should be
ftp://freepascal.stack.nl/pub/fpc/dist/2.6.2/arm-linux/fpc-2.6.2.arm-linux.tar

It appears every mirror is affected (I tried a few).

Regards,

Koenraad Lelong


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Compiling arm-embedded fpc

2013-03-03 Thread Koenraad Lelong

Op 14-02-13 20:08, Michael Ring schreef:

I might have found a hack to solve your linking problem for arm-embedded
on linux, unfortunately I am not an expert on gnu ld, but perhaps this
here gives a hint to somebody that knows how to properly solve your
problem:

First, create a script names arm-embedded-ld with the following content:

#!/bin/sh
sed --in-place s^*(.comment)^*(.comment)\n*(.note, .note.*)^g
link.res
/usr/local/bin/arm-embedded-ld $*



Hi,

When I install that script my test-program compiles and links (fpc 
r23627) with an own compiled binutils 2.23.1. Without it I still get the 
linker-error.
I tried to make a crosscompiler today with r23680, but that fails. Is it 
still necessary to use that arm-embedded-ld hack ?


Thanks,

Koenraad Lelong
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Place of elements in record

2013-02-28 Thread Koenraad Lelong

Hi,

I'm developping a arm-embedded project. I need to store some variables 
to EEPROM. What I'm doing now is manually give each variable an address 
and then I use that address to store the variable in EEPROM. 
Unfortunately, that's not easy. Yesterday I spent some hours trying to 
see why the code I wrote does not work. This morning I thought of a 
possible reason, and I think I'm right : I was overlapping some variables.


So I'm trying to find a simpler way to have the relative position of 
variables to use as an address in an EEPROM.
I'm tinking about using a record. Is there a way to get the relative 
position of a record-element ?

Some psuedo-code :

EEPROM_Content : record of
 Var1 : byte;
 Var2 : word;
 Var3 : byte;
end{EEPROM_Content};

EEPROM_WriteByte(position of Var1 in EEPROM_Content,EEPROM_Content.Var1);
//position of Var1 in EEPROM_Content should be 0
EEPROM_WriteWord(position of Var2 in EEPROM_Content,EEPROM_Content.Var2);
//position of Var2 in EEPROM_Content should be 1
EEPROM_WriteByte(position of Var3 in EEPROM_Content,EEPROM_Content.Var3);
//position of Var3 in EEPROM_Content should be 4

I think I could use
@EEPROM_Content.Var1-@EEPROM_Content.Var1
@EEPROM_Content.Var2-@EEPROM_Content.Var1
@EEPROM_Content.Var3-@EEPROM_Content.Var1
as those positions, but is this computed at compile-time, or at run-time 
? Am I right if I assume EEPROM_Content.Var1 is at relative position 0 
in the record ?
I prefer to have the individual variables written to EEPROM, but maybe 
writing the whole record in one go would be possible also. Then I don't 
need to hassle with the positions. I mean, it _is_ possible to do that 
but if it's suited for the project I don't know yet.


Other solutions ?

Mmm, writing things out clears the mind. I think it would be better to 
write the whole record.


Thanks for your input.

Regards,

Koenraad Lelong
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Place of elements in record

2013-02-28 Thread Koenraad Lelong

On 28-02-13 09:41, Mark Morgan Lloyd wrote:


I'd suggest that this depends in part on the semiconductor technology.
You might be best transferring individual fields for old-fashioned
EEPROMs, or defining a larger block with a magic number for more
RAM-like devices particularly if they have load-levelling.


Hi,

I'm using old-fashioned EEPROM (1 kilobyte). In the device every 
write-cycle takes about 3ms. So writing individual variables each takes 
3ms. But writing the whole record would also take 3ms (I think, I have 
to verify this). So it's tempting to do that. But a whole record could 
cross memory-pages, then the record needs to be split in two (or more) 
cycles. But at the moment I'm saving less than 20 variables, so 
splitting will be for later.


Thanks for your input, same for you Ludo.

Regards,

Koenraad Lelong.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] pascal compiler for ardurino

2013-02-27 Thread Koenraad Lelong

On 26-02-13 20:07, ik wrote:

Hello,

Is there a Pascal compiler for Ardurino (instead of the existed build
in language or C) ?

Thanks,
Ido


Hi,

Does it have to be Arduino ? Or just the formfactor ? I'm using an 
Olimexino. That has an STM32 cortex-m3 processor in the same formfactor. 
And I'm developping an embedded project with FPC.

There is also the maple, arduino form-factor but also a cortex-m3 processor.

Just my 2 cents ;-)

Koenraad Lelong


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Compiling arm-embedded fpc

2013-02-18 Thread Koenraad Lelong

On 17-02-13 20:27, Michael Ring wrote:

I did a quick check on Mac  Linux, on both platforms compiling 
loading resulting .elf file into gdb works fine.

Thank you very much,

Michael



Hi,

I'm very confused. I must be doing something wrong, but I can't find out 
what.
I tried this on a virgin virtual machine based on Opensuse 12.2. I 
installed a binutils 2.23.1 for it. I did as -v, and I get it's 
version : 2.23.1. Then I compiled fpc r23627 with fpc 2.6.0. Then I 
compiled the tled1.pp program with the new crosscompiler and I get the 
error :


/home/fpc/bin/arm-none-eabi-ld: error: no memory region specified for 
loadable section `.note.gnu.build-id'

tled1.pp(54,4) Error: Error while linking
tled1.pp(54,4) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
Error: /usr/bin/ppcrossarm returned an error exitcode (normal if you did 
not specify a source file to be compiled)


I'll make the new virtual machine available on dropbox.

Regards,

Koenraad Lelong.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Compiling arm-embedded fpc

2013-02-18 Thread Koenraad Lelong

Op 18-02-13 16:22, Michael Ring schreef:

My guess is that you use an old version of ppcrossarm:

Looking at your error message ppcrossarm is located in:
/usr/bin/ppcrossarm

which is a quite unusual place for it when you install it from trunk.

Michael


Hi Micheal,

I don't think it's that. I started from scratch, only an fpc 2.6.0. for 
x386 is installed. This is my script to make the cross-compiler :


#!/bin/bash -e
cd $1
#SUBTYPE=armv7m
SUBTYPE=armv4
make clean
make buildbase CROSSINSTALL=1 OS_TARGET=embedded CPU_TARGET=arm 
SUBARCH=$SUBTYPE BINUTILSPREFIX=arm-none-eabi- CROSSOPT=-CfSoft 
PREFIX=/usr
sudo make installbase CROSSINSTALL=1 OS_TARGET=embedded CPU_TARGET=arm 
SUBARCH=$SUBTYPE BINUTILSPREFIX=arm-none-eabi- CROSSOPT=-CfSoft 
PREFIX=/usr

#make clean
echo $SUBTYPE
echo ---
echo 'As root, once do : make-link.sh'
echo ---

Like you can see : prefix is /usr. I also tried with the make-lines on 
one line, as root. This does not help.


This in make-link.sh :

#!/bin/bash -e
cd /usr/bin
ln -s ../lib/fpc/2.7.1/ppcrossarm ppcrossarm

To compile an embedded project I use this :

#!/bin/bash
PROCESSOR=lpc2124
fpc -Parm -Tembedded -Wp$PROCESSOR -XParm-none-eabi- $1

I'm putting a new version of my VM on dropbox.

Regards,

Koenraad Lelong
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Compiling arm-embedded fpc

2013-02-15 Thread Koenraad Lelong

On 14-02-13 21:34, Michael Ring wrote:

I did a grep through the fpc sourcecode and found a reference in
./compiler/systems/t_linux.pas in an arm related ifdef section

add('  .note.gnu.build-id : { *(.note.gnu.build-id) }');

so perhaps this is really missing in arm-embedded target.


The patch for for fpc/compiler/systems/t_embed.pas seems to be pretty
 straightforward, I will create the patch and test if debugging still
works.

Michael

by the way:

I used binutils-2.23.1 to create the cross-tools, configure script
was:

./configure --target=arm-none-eabi --program-prefix=arm-embedded-

compiled under Fedora-18.


...

Sounds to me like a broken binutils. I have never heard about the
.note section, except for some warnings now and then on obscure
platforms


Hi guys,

Thanks for taking the time to investigate this.
As far as I know binutils is the collection of programs to create
executables, so the gcc-compiler, assembler, linker, etc. Another name 
is toolchain, right ?
I recently searched for a toolchain, and I found one : 
gcc-arm-none-eabi-4_7-2012q4-20121208-linux.tar.bz2. I got this in the 
release.txt :

GNU Tools for ARM Embedded Processors 4.7
   - Dec 2012
I think I tried it also with an older toolchain from Codewarriors (now
Mentor). I'll have to verify this, though.
There's nothing to compile, just unpack and use it.
I don't know what you are using as toolchain, did you have the same 
problem ?


Like I said before, I made a virtual machine that's set up to have a
development environment for embedded-arm and fpc, including openocd. I 
made some scripts to do the compilation (to get a crosscompiler and the 
embedded-arm projects). The only thing I should do is make some document 
explaining how to use those scripts, although they're rather 
straighforward.
That could be used to investigate this case. The downside is it's size, 
about 900MB. It's on susestudio.com and on dropbox 
(https://www.dropbox.com/sh/dbsxi81jx2cb73n/h6ro62_XsD).
I'm going to use this when this problem is solved, but anyone can use 
it. I'm going to try to maintain this, so all comments are welcome. 
Users/passwords : fpc/fpc and root/linux.


Thanks again,

Koenraad Lelong.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Arm Embedded Question

2013-01-30 Thread Koenraad Lelong

Op 30-01-13 13:38, delph...@smythconsulting.net schreef:

I've been following the wiki and have successfully created fpc for my
arm processor ( Cortex M3 - using a LPC 1343 board) ( as per the wiki's
intructions)

once i have written my sample program is there anyway to debug it on the
MCU ? ( ie like doing in Lazarus for win32/64 projects)

any help would be of much benefit


Kind Regards


Justin Smyth


Hi,

Mostly you debug via gdb. Depending on the board us can use jtag (e.g. 
openocd) or another hardware-interface. Some STM32 boards have an 
ST-link interface.


P.S. what version of fpc did you use (svn-revision) ? I'm asking because 
I'm having troubles with my cross-compilers. At the moment I'm making a 
virtual appliance with fpc 2.6.0 for 386 and some revisions of trunk. I 
made some scripts to compile the crosscompiler.

This way interested people can look into the problems.

And when there is a usable compiler, I can make the appliance to share 
it with interested users.


Regards,

Koenraad Lelong
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Compiling arm-embedded fpc

2013-01-30 Thread Koenraad Lelong

Hi Michael,

I downloaded svn version 23457, and now I can compile the crosscompiler.
Unfortunately, I can't compile a project with that crosscompiler. More
precisely, the project can't be linked. I have to redo some things to
note what I am doing and what the results are, but the linking stage
seems to go wrong.
I'll report more when I have my notes.

Regards,

Koenraad Lelong



Hi,

I made a virtual appliance with opensuse 12.2, x386. To be able to 
download it you must create an account on http://susestudio.com. Search 
for freepascal, then you'll find it : Freepascal for arm-embedded.


While making and testing it I discovered that the last revision (at this 
time 23542) does create a compiler, but when I try to compile the 
application from the wiki, I get a linking error :


fpc -Parm -Tembedded -Wplpc2124 -XParm-none-eabi- tled1.pp

Free Pascal Compiler version 2.7.1 [2013/01/30] for arm
Copyright (c) 1993-2012 by Florian Klaempfl and others
Target OS: Embedded
Compiling tled1.pp
Assembling program
Linking tled1
/home/fpc/bin/arm-none-eabi-ld: error: no memory region specified for 
loadable section `.note.gnu.build-id'

tled1.pp(54,4) Error: Error while linking
tled1.pp(54,4) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
Error: /usr/bin/ppcrossarm returned an error exitcode (normal if you did 
not specify a source file to be compiled)

fpc@linux-ogvy:~/src-arm-fpc

This is the same error I reported about some days ago. Is it me, doing 
something wrong, or is there something wrong with the crosscompiler ?


Regards,

Koenraad Lelong.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Compiling arm-embedded fpc

2013-01-30 Thread Koenraad Lelong

Hi,

An update. I tried to make a crosscompiler with the new sources on my 
old developing machine. There I still get the segmentation fault. The 
difference is that that machine is 64 bit, while the appliance is 32 bit.


Actually, that was why I made the appliance. To see if there were 
differences.


Regards,

Koenraad
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Compiling arm-embedded fpc

2013-01-27 Thread Koenraad Lelong

Op 24-01-13 22:05, Michael Ring schreef:

I could reproduce the problem on Fedora 18 x86_64. The error shows up in
revision 23457, the only file changed in this revision is
compiler/arm/aoptcpu.pas.

Checkin comment for file was:

Revision *23457*
http://svn.freepascal.org/cgi-bin/viewvc.cgi?view=revisionrevision=23457
- (view
http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/compiler/arm/aoptcpu.pas?revision=23457view=markup)
(annotate
http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/compiler/arm/aoptcpu.pas?annotate=23457)
- [select for diffs]
http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/compiler/arm/aoptcpu.pas?r1=23457view=log


Hi Michael,

I downloaded svn version 23457, and now I can compile the crosscompiler. 
Unfortunately, I can't compile a project with that crosscompiler. More 
precisely, the project can't be linked. I have to redo some things to 
note what I am doing and what the results are, but the linking stage 
seems to go wrong.

I'll report more when I have my notes.

Regards,

Koenraad Lelong

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Embeded ARM Examples.

2013-01-24 Thread Koenraad Lelong

On 22-01-13 13:36, delph...@smythconsulting.net wrote:

Hi All,
I’ve been a user of Lazarus for years now and will soon want to write
some code to run on Embedded ARM ( specifically an ARM Cortex M3 ) using
an LPC1343.
I’m new to this so i would appreciate someone pointing me in the right
direction , some examples and or some wiki regarding this matter would
help alot.
Kind Regards
Justin Smyth


Hi,

I'm tinkering with a cortex-m3 board (STM32) so I could help somewhat. 
Unfortunately, I downloaded and made my crosscompiler some months ago.
In the mean time there are many changes in the arm-embedded FPC that I 
would like to use, mainly interrupt-handling. Yesterday I downloaded 
fpc-trunk but I was unable to make an arm-crosscompiler. Actually, it's 
the RTL that does not compile. See my posts of yesterday.


What exactly are you looking for ? There are a number of postings (also 
from me) in this list about arm-embedded, did you read those ?

Did you read http://wiki.freepascal.org/TARGET_Embedded ?

Regards,

Koenraad Lelong

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Compiling arm-embedded fpc

2013-01-24 Thread Koenraad Lelong

On 24-01-13 11:24, Jeppe Græsdal Johansen wrote:

Looks like a memory corruption problem. I just tried to compile trunk
with 2.6.0 as a starting compiler on win32 and had no problems(apart
from the broken RTL).

What starting compiler and what os/cpu are you on?



Hi,

What do you mean with memory corruption ? Is the memory of my PC broken, 
or is the compiler messing with the memory and then corrupts it ?
As far as I see it's not possible to compile the RTL. That's my problem. 
The crosscompiler seems OK, when I run ppcrossarm -i I see the output 
I expect.
I'm trying to be as clear as possible, but sometimes I presume too much 
and the reader does not understand what I want to say :-(
What I was trying to do is pinpointing where it goes wrong. So I manualy 
tried running the last line before the compilation (how to do that : see 
the wiki) stopped with the segmentation fault. And I did this with gdb 
to get a backtrace. That's what I sent to the list.


You say you can't compile the RTL, what error do you get ?

I'm compiling this with FPC 2.6.0, on Opensuse 12.1 64 bit.

Anyway, thanks for your reply.

Regards,

Koenraad Lelong.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Compiling arm-embedded fpc

2013-01-23 Thread Koenraad Lelong

Hi,

I was looking into the latest fpc to see if there were updates about 
arm-embedded since my last version. Indeed there are !
So I downloaded it (svn 23505) and tried to compile it, following the 
wiki (http://wiki.freepascal.org/TARGET_Embedded). It crashes at 
'ppcrossarm system.pp', message : segmentation-fault. Just that.
I tried running the last line, and adding -vv. In the fpcdebug.txt I 
can't see much, but I don't know what I'm looking for. I could show 
that, but it's big, about 240k.


Any suggestions how to try to resolve this ? How do you keep debugging 
symbols in the compiler ?


 gdb --args ../../compiler/ppcrossarm -Cparmv7m @rtl.cfg -Ur 
-Tembedded -Parm -XParm-embedded- -Xr -Ur -Xs -O2 -n -Fi../inc -Fi../arm 
-FE. -FU/home/koenraad/Documenten/fpc-20130123/rtl/units/arm-embedded 
-darm -dRELEASE  -Us -Sg system.pp

GNU gdb (GDB) SUSE (7.3-41.1.2)
...
Reading symbols from 
/home/koenraad/Documenten/fpc-20130123/compiler/ppcrossarm...(no 
debugging symbols found)...done.

(gdb) run
Starting program: 
/home/koenraad/Documenten/fpc-20130123/compiler/ppcrossarm -Cparmv7m 
@rtl.cfg -Ur -Tembedded -Parm -XParm-embedded- -Xr -Ur -Xs -O2 -n 
-Fi../inc -Fi../arm -FE. 
-FU/home/koenraad/Documenten/fpc-20130123/rtl/units/arm-embedded -darm 
-dRELEASE -Us -Sg system.pp


Program received signal SIGSEGV, Segmentation fault.
0x00416a66 in ?? ()
(gdb) bt
#0  0x00416a66 in ?? ()
#1  0x0020 in ?? ()
#2  0x0020 in ?? ()
#3  0x008dcb90 in ?? ()
#4  0x0009 in ?? ()
#5  0x77b161c0 in ?? ()
#6  0x77415c80 in ?? ()
#7  0x77b161c0 in ?? ()
#8  0x00416ca0 in ?? ()
#9  0x7fffca40 in ?? ()
#10 0x008dcb90 in ?? ()
#11 0x001800010115 in ?? ()
#12 0x00415bc7 in ?? ()
#13 0x008dcb90 in ?? ()
#14 0x0040ff5a in ?? ()
#15 0x774521c0 in ?? ()
#16 0x in ?? ()
(gdb)

Regards,

Koenraad Lelong
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Compiling arm-embedded fpc

2013-01-23 Thread Koenraad Lelong

On 23-01-13 17:20, Tomas Hajny wrote:

OPT=-gl -Xs-


Thanks, I comiled this way :

make clean buildbase installbase OPT=-gl -Xs- -O- CROSSINSTALL=1 
OS_TARGET=embedded CPU_TARGET=arm SUBARCH=armv7


That gives this :

 gdb --args ../../compiler/ppcrossarm -Cparmv7m @rtl.cfg -Ur 
-Tembedded -Parm -XParm-embedded- -Xr -Ur -Xs -O2 -n -Fi../inc -Fi../arm 
-FE. -FU/home/koenraad/Documenten/fpc-20130123/rtl/units/arm-embedded 
-darm -dRELEASE  -Us -Sg system.pp

...
Reading symbols from 
/home/koenraad/Documenten/fpc-20130123/compiler/ppcrossarm...done.

(gdb) run
Starting program: 
/home/koenraad/Documenten/fpc-20130123/compiler/ppcrossarm -Cparmv7m 
@rtl.cfg -Ur -Tembedded -Parm -XParm-embedded- -Xr -Ur -Xs -O2 -n 
-Fi../inc -Fi../arm -FE. 
-FU/home/koenraad/Documenten/fpc-20130123/rtl/units/arm-embedded -darm 
-dRELEASE -Us -Sg system.pp


Program received signal SIGSEGV, Segmentation fault.
0x00419bb0 in SYSGETMEM_FIXED (CHUNKSIZE=32) at ../inc/heap.inc:977
977 pmc_next^.prev_fixed := nil;
(gdb) bt
#0  0x00419bb0 in SYSGETMEM_FIXED (CHUNKSIZE=32) at 
../inc/heap.inc:977

#1  0x00419e38 in SYSGETMEM (SIZE=32) at ../inc/heap.inc:1072
#2  0x0041877d in GETMEM (P=0x774521c0, SIZE=24) at 
../inc/heap.inc:276
#3  0x00411f1c in NEWINSTANCE (self=0x900180) at 
../inc/objpas.inc:355

warning: Range for type (null) has invalid bounds 0..-107
warning: Range for type (null) has invalid bounds 0..-2
warning: Range for type (null) has invalid bounds 1..-127
#4  0x0045f9da in CREATE (this=0x0, vmt=0x900180, INITSIZE=9) at 
cclasses.pas:2985
#5  0x004daf33 in SET_LIVE_RANGE_DIRECTION (this=0x7755d300, 
DIR=RAD_BACKWARDS) at rgobj.pas:723
#6  0x004d3fa3 in SET_REGALLOC_LIVE_RANGE_DIRECTION 
(this=0x7741a000, DIR=RAD_BACKWARDS) at cgobj.pas:775
#7  0x0056d830 in GENERATE_CODE (this=0x77b161c0) at 
psub.pas:1325
#8  0x0056cc95 in GENERATE_CODE_TREE (this=0x77b161c0) at 
psub.pas:1023
#9  0x0056ed82 in READ_PROC_BODY 
(OLD_CURRENT_PROCINFO=0x77b16040, PD=0x77fcedb0) at psub.pas:1865
#10 0x0056f297 in READ_PROC (ISCLASSMETHOD=false, USEFWPD=0x0) 
at psub.pas:1996
#11 0x0056f79d in READ_DECLARATIONS (ISLIBRARY=false) at 
psub.pas:2120

#12 0x0056a6b5 in BLOCK (ISLIBRARY=false) at psub.pas:279
#13 0x0056e6c7 in PARSE_BODY (this=0x77b16040) at psub.pas:1693
#14 0x005e477b in PROC_UNIT () at pmodules.pas:944
#15 0x005c8cf9 in COMPILE (FILENAME=...) at parser.pas:347
#16 0x0042a3d8 in COMPILE (CMD=0x0) at compiler.pas:255
#17 0x0040041a in main () at pp.pas:239
(gdb)

Anyone can help ?

Regards,

Koenraad Lelong

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] fcl-db components missing from 2.6.0 (Lazarus winx64 bin inst)

2012-10-29 Thread Koenraad Lelong

Op 29-10-12 17:14, Andrew Brunner schreef:

Hi,

I'm trying to setup a build box on Win8 x64.  I can't get Lazarus to
compile my project.  It fails because it uses postgresql, mysql and
oracle units.

The postgresql compiles units are missing from compiled units folder.
The actual source is listed in the source.  Their code-tools system does
find the unit when I hot-click the unit.

I'm going to FPC/Laz build from svn/source but I just wanted to post
here to see what was the cause...



Hi,

When I have this on linux, it's mostly because the devel-packages are 
not installed. And they need the drivers themselves installed. Maybe on 
Win it's the same ? Or maybe the 32bit drivers are installed and 64bit 
is needed ?


HTH.

Regards,

Koenraad Lelong
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Smartcard Pascal

2012-08-20 Thread Koenraad Lelong

Hi,

I'm gathering information for a possible project using a smartcard. I 
would like to have it running on linux, so I will be using pcsc-lite.


In september 2010 there was a thread about pc/sc and I was wondering if 
someone could give an update. Micheal  Van Canneyt mentioned a heavily 
improved version of a component. Is that new component publicly 
available ? Does it work on linux ?


 I am using this component (heavily improved) but it's geared towards
 the microsoft API. The Linux API (openSC) has not been translated as
 far as I know.

 I'm using PCSC-Lite (http://pcsclite.alioth.debian.org/) which is AFAIK
 a Linux version of the M§ API. At least its API
 http://pcsclite.alioth.debian.org/api/group__API.html looks quite
 similar to what I've seen in this component.


TIA

Koenraad Lelong
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Compiling on Raspberry Pi

2012-08-07 Thread Koenraad Lelong

Hi,

I recently recieved my Raspberry PI. That's an arm-linux device.
I downloaded the easyfpgui-package from 
http://www.turbocontrol.com/easyfpgui.htm.
I can't compile the dbgterm, I get errors on baudrates that seem 
undefined. In the sources these baudrates are enclosed in IFDEF's. How 
can I know what constants are defined, is there an easy way ? Of course 
I could write a pascal-program with just writeln's enclosed in an IFDEF 
of each possible constant. But where does fpc get the values of these 
constants from ?


The rest of the apps compile fine although I had no possibility to test 
them since I don't yet have a suitable video-cable.


TIA,

Koenraad Lelong.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


RE : [fpc-pascal] Variable alignment in arm-embedded

2012-06-26 Thread Koenraad Lelong

On 13-06-12 07:01, alrieckert wrote:
...

Just to report back.

I'm making progress with my embedded application. Learning to use the 
processor is not easy compared to 8 bit processors.


I found a bug in Anton's library though:
in stm32f1xx_systick.pas
  if NewState = DISABLED then
is wrong and should be
  if NewState  DISABLED then

That's compared to the c-sources, and now it's working for me.

Maybe the comments of the c-sources of what the functions do and need as 
parameters should be included.


The LCD-unit seems not to specify for which LCD the software is written, 
and contains a unit which is not there (defPSPlcd - PlayStationP LCD ?).
If someone is interested in my LCD driver (for the Nokia 6610 display 
with non-Philips chip, MOD-NOKIA6610 from Olimex) I can post it. I think 
it should be usable on other cortex-m3 boards than mine.


Anyway, thanks for all help.

Koenraad Lelong.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] fpc arm-embedded suitable for cortex-m4 ?

2012-06-26 Thread Koenraad Lelong

Hi,

Last week I attended a seminar regarding cortex-m4. I was wondering if 
fpc works for that processor. AFAIK, the processor is compatible with a 
cortex-m3, but has a hardware floating point processor and DSP-related 
instructions. So if fpc would be able to use the floating point 
processor that would be great. I wouldn't know how to use the 
dsp-instructions, yet.


Thanks for any pointers,

Koenraad lelong.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: RE : [fpc-pascal] Variable alignment in arm-embedded

2012-06-26 Thread Koenraad Lelong

On 26-06-12 09:38, alrieckert wrote:

Thank you for the feedback, does this mean you got the interrupt working
with my patches??

Hi Anton,

Yes, I got interrupts working now.
It took some experimenting though. Or maybe I'm missing something. To 
get the interrupt procedure on the right place in the vector table you 
need to add an offset to the constant :


procedure Exti0_Proc; interrupt EXTI0_IRQn + 15;

But to enable the interrupt you have to use the constant itself :

NVIC_EnableIRQ(EXTI0_IRQn); // enable interrupt from rot.sensor

Maybe adding some constants for the place in the vector table would be 
better ?


P.S. Did you work already with interrupts ? I found I needed to clear 
the Pending bit of the interrupt at the end of the interrupt-routine. 
Otherwise I never left the interrupt-routine, or so it seemed. I tried 
with event-mode but that seemed no solution.


GPIO_EXTILineConfig(GPIO_PortSourceGPIOA, GPIO_PinSource0);
EXTI_StructInit(EXTI_InitStructure);
EXTI_InitStructure.EXTI_Trigger:=EXTI_Trigger_Rising_Falling;
EXTI_InitStructure.EXTI_Line:=EXTI_Line0;
EXTI_InitStructure.EXTI_LineCmd:=ENABLED;
//EXTI_InitStructure.EXTI_Mode:=EXTI_Mode_Event;
EXTI_Init(EXTI_InitStructure);

Regards,

Koen.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] fpc arm-embedded suitable for cortex-m4 ?

2012-06-26 Thread Koenraad Lelong

On 26-06-12 09:45, Jeppe Græsdal Johansen wrote:

The FPU is single precision only, as far as I remember. That made it a
little hard to work with in fpc, and last I took a stab at it there
weren't any affordable chips around with support even.


Hi Jeppe,

Would this be a good candidate to port fpc to cortex-m4 :
http://be.farnell.com/stmicroelectronics/stm32f4discovery/board-eval-stm32f4-discovery/dp/2009276
I could sponsor one if you like ;-)
And there is no hurry. I need to finish my cortex-m3 project first and 
see if that processor is fast enough.


Regards,

Koenraad Lelong
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


RE : [fpc-pascal] Variable alignment in arm-embedded

2012-06-13 Thread Koenraad Lelong

On 13-06-12 07:37, alrieckert wrote:


alrieckert wrote


Please just make sure about your starting address for the flash. I'm using
the STM32F103CBT6 and the start address is 0x0800 and not 0x080


I've just verified it. The starting address for the flash should be
0x0800. The reason for mine being 0x08003000 is that I'm making use of a
USB DFU bootloader to load my program onto the device.

Would be nice if we could specify the flash start offset at compile (link)
time and not to hard code this into the compiler?

Regards
Anton


Thanks Anton,

I will try this right away. And good spotting that start-address. I 
think I removed the 3 and somehow didn't replace it with a 0. I would 
have had a hard time debugging that I think. I'm using an STM32F103RB 
b.t.w. (Olimexino-STM board).


About that DFU-loader, do you have to do anything special to be able to 
use fpc, besides modifying your start-address ? Any links to read more 
about it ?

Now I'm using jtag to flash and debug my software.

Regards,

Koenraad.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: RE : RE : [fpc-pascal] Variable alignment in arm-embedded

2012-06-12 Thread Koenraad Lelong

On 08-06-12 14:37, Jeppe Græsdal Johansen wrote:

Den 08-06-2012 14:28, Ludo Brands skrev:

Thanks Ludo,

I'll take that as a starting point. I hope I will not need the lost
256 bytes in the future.

I could be wrong but AFAIK if the compiler would do the alignment, the
loss
can also be up to 255 bytes. Here you lose 256 bytes in all cases.

Yes, but this would allow the linker to place other stuff there which
fits in less than 255 bytes.

Wasting 255 bytes is a lot on systems that only has a few kilobytes of
RAM. I wonder if the restriction of 32 bytes on the align directive
could just be removed, or will we need some sort of linker script changes?


Hi,

I'm still struggling to get interrupts (or even inputs) work but I 
wanted to comment on the size of the table. Reading the manuals I found 
it's actually on a 512 byte boundery. The VTOR (Vector Table Offset 
Register) masks off the last 9 bits (8..0).
If I need that space I will modify the start of RAM location and use the 
first bytes of RAM for the vector-table.
It would be nice to have external linker scripts. That way you could 
more easily add processors, or use custom bootloaders.


Regards,

Koenraad Lelong.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


RE : [fpc-pascal] Variable alignment in arm-embedded

2012-06-12 Thread Koenraad Lelong

On 11-06-12 13:46, alrieckert wrote:

Hi Jeppe,

I've been using the actual ROM based interrupt table for the past month now
in freepascal ad it seems to work great. No need to declare a block of RAM
and pointing the interrupt table to it.


...


Please let me know if you have any questions.

--
Anton


Hi Anton,

I just tried something, but it seems that the vector table is not 
updated. I enclose my project.
This afternoon I downloaded your whole git-repo following your links. I 
compiled my crosscompiler. Then I tried a bare project. First I found 
that the flash-start was wrong. I corrected that and recompiled the 
compiler. Then I compiled the bare-program again. I didn't find my 
systick-handler (optimized away !?). Then I tried to use the handler 
and now I see the systick-handler in the disassembly (bare.dis). 
Unfortunately, I don't see the address of the systick-handler in the 
vector-table.


What am I doing wrong ?

Koenraad.


Bare.tar.bz
Description: application/bzip
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: RE : [fpc-pascal] Variable alignment in arm-embedded

2012-06-08 Thread Koenraad Lelong

On 08-06-12 06:45, Ludo Brands wrote:


Handcrafted alignment:

var
   ReservedBlock:array[0..$1FF] of byte;
   IntVectors:pointer;
begin
   IntVectors:=pointer((ptruint(@ReservedBlock[0])+$100) and not $ff);
End;

Or dynamic:

Var
   pReservedBlock,IntVectors:pointer;
begin
   Getmem(pReservedBlock,$200);
   IntVectors:=pointer((ptruint(pReservedBlock)+$100) and not $ff);
End;


Thanks Ludo,

I'll take that as a starting point. I hope I will not need the lost 
256 bytes in the future.
I can replace the IntVectors-pointer with a pointer to a record of 
pointers, isn't it ? That way I have a clearer view of what vectors I'm 
working with.


TIntVectorTable = record of
NMI_Handler,
HardFault_Handler,
MemManage_Handler,
BusFault_Handler,
UsageFault_Handler,
SWI_Handler,
DebugMonitor_Handler,
PendingSV_Handler,
Systick_Handler,
(* STM32 specific Interrupt Numbers *)
WWDG_Handler,
PVD_Handler,
...
USBWakeUp_Handler : pointer;
end {TIntVectors};

var
 IntVectors : ^TIntVectorTable;
 ReservedBlock:array[0..$FF+SizeOf(TIntVectorTable)] of byte;

procedure SystickProc; interrupt;

begin
...
end;

begin
  IntVectors:=pointer((ptruint(@ReservedBlock[0])+$100) and not $ff);
  IntVectors^.SystickHandler:=@SystickProc;
...
end.

Koenraad
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Variable alignment in arm-embedded

2012-06-07 Thread Koenraad Lelong

Hi,

I want to make an interrupt-vector-table for the cortex-M3 processor. 
When I read the docs of the processor good, the start of that table 
needs to be on a multiple of $100 bytes in memory. Since with FPC there 
seems no way of getting that table in flash I need to have it in RAM. 
But how can I have the table at those $100-bytes multiple ? I found an 
ALIGN directive, but that's limited to 32 bytes.

Any suggestions ?
I had hoped that the first variable would be at the first location in 
RAM and the first variable in the startup-code is that vector-table. 
Unfortunatly, my hope was in vain.


Any help ?

Regards,

Koenraad Lelong.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Accessing open array

2012-06-03 Thread Koenraad Lelong

Hi,

Im trying to access an open array but I get a runtime error. I googled a 
bit, and found some suggestions, but for me they don't work.

It's actually a port of some C-library I want to use on a STM32-processor.

This is my test-code :

program LCDtest1;

type
 TArray = array of byte;

var
 nCols : cardinal;
 nRows : cardinal;
 nBytes : cardinal;
 pFont : ^TArray;

{$include fonts.inc}

begin

// get pointer to the beginning of the selected font table
pFont:=@FONT6x8;
writeln('0');
setlength(pFont^,8);  -- here it crashes
writeln('1');
nCols:=pFont^[0];
//nCols:=pFont^[low(pFont^)];
{writeln('2');
nRows:=pFont^[1];
writeln('3');
nBytes:=pFont^[2];}
writeln('end');
end.

I didn't have the setlength at first, then it crashed at the first 
access of the array (ncols:=...).


The include file contains this (only partly shown) :

originally :

const
  FONT6x8 : array[0..96] of array[0..7] of byte = (
($06,$08,$08,$00,$00,$00,$00,$00), // columns, rows, num_bytes_per_char
($00,$00,$00,$00,$00,$00,$00,$00), // space $20
($20,$20,$20,$20,$20,$00,$20,$00), // !
($50,$50,$50,$00,$00,$00,$00,$00), // 
($50,$50,$F8,$50,$F8,$50,$50,$00), // #
...

modified (with the same error) :

const
  FONT6x8 : array[0..775] of byte = (
($06,$08,$08,$00,$00,$00,$00,$00, // columns, rows, num_bytes_per_char
($00,$00,$00,$00,$00,$00,$00,$00, // space $20
($20,$20,$20,$20,$20,$00,$20,$00, // !
($50,$50,$50,$00,$00,$00,$00,$00, // 
($50,$50,$F8,$50,$F8,$50,$50,$00, // #
...

Any suggestions how I can correct my code ?

Thanks,

Koenraad Lelong.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Accessing open array

2012-06-03 Thread Koenraad Lelong

On 03-06-12 17:53, Koenraad Lelong wrote:

Hi,

Im trying to access an open array but I get a runtime error. I googled a
bit, and found some suggestions, but for me they don't work.

Forgot to say : runtime error is 216.


modified (with the same error) :

const
FONT6x8 : array[0..775] of byte = (
$06,$08,$08,$00,$00,$00,$00,$00, // columns, rows, num_bytes_per_char
$00,$00,$00,$00,$00,$00,$00,$00, // space $20
$20,$20,$20,$20,$20,$00,$20,$00, // !
$50,$50,$50,$00,$00,$00,$00,$00, // 
$50,$50,$F8,$50,$F8,$50,$50,$00, // #
...

This is my actual code.

Koenraad Lelong.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Accessing open array

2012-06-03 Thread Koenraad Lelong

Hi,

Looking at the C-code again, I saw I could actually use a pointer to 
byte, instead of a pointer to an array of bytes.

So I'm using this :

program LCDtest1;

var
 nCols : cardinal;
 nRows : cardinal;
 nBytes : cardinal;
 pFont : ^byte;

{$include fonts.inc}

begin

// get pointer to the beginning of the selected font table
pFont:=@FONT6x8;
nCols:=pFont^;
nRows:=(pFont+1)^;
nBytes:=(pFont+2)^;
end.

Now my library works.

Thanks,

Koenraad Lelong.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] fpc arm-embedded interrupts

2012-05-10 Thread Koenraad Lelong

Hi,

I'm working on an embedded-arm application. I do want to use interrupts 
but I don't find how to easily setup the interrupt-handlers.
In the startup code in C, I see default handlers defined with the 
keyword WEAK. Looking around, I found that this means that if one 
defines a function with the same name, that will be used instead of the 
default-handler. The start-address of that new function will be entered 
in the interrupt-vector table in flash.
Is something similar possible with fpc ? Looking in the 
fpc-startup-code, the rtl, I don't see that, but that could be me.
Or do I have to modify the rtl for every project I will be making ? What 
I did see I think, in some rtl-units for arm-embedded, is that there 
seems to be a contruction to put the start-address of the main 
error-handlers in RAM. Would that be the only way to have interrupts ?


Thanks for any help,

Regards,

Koenraad Lelong.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Assigning absolute record to variable

2012-05-08 Thread Koenraad Lelong

Hi,

I hope I can make myself clear.

I'm making a driver to control an LCD with an STM32 microcontroller, 
using fpc-embedded-arm.
I want to make my driver re-usable, i.e. I want to be able to pass the 
needed RST- and CS-pins only one time, so I don't need to modify the 
code in multiple places if the needed pins change.


Since a pin-port is defined this way :

 PortA: TPortRegisters  absolute (APB2Base+$0800);

I thought of defining a record :

RSTPin : record
 GPIO_Port : ^TPortRegisters;
 GPIO_Pin : word;
end;

and assigned like this :

RSTPin.GPIO_Port:=@PortA;

This does not work, the pins are not initialised when used with the 
initialising function :


   GPIO_Init(RSTPin.GPIO_Port^, GPIO_InitStructure);

does not work while

   GPIO_Init(PortA, GPIO_InitStructure);

does work.

What am I missing ? I'm out of ideas at the moment.

Thanks for any help you can give,

Regards,

Koenraad Lelong.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: RE : RE : [fpc-pascal] Reversing bit-order of byte

2012-05-07 Thread Koenraad Lelong

On 04-05-12 14:53, Koenraad Lelong wrote:

On 04-05-12 14:31, Thomas Schatzl wrote:

...


Compared to the other variants (e.g. with the multiplies, except for the
table lookup) you already save a lot of cycles - although I guess they
would be sufficiently fast anyway, considering the typical uart speeds.

Thomas


Hi Thomas,

My processor flags : -Wpstm32f103rb -Cparmv7m.
The #23 is no typo, I need to reverse 9 bits. I'm using 9 bit
synchronous transmission. My first usart-tests were at 4Mbps. The person
that made the driver recommends max. 6Mbps.


Hi,

I tested some things this weekend. Strange things happen ;-)
The code does not work. Trying to debug with gdb, around the code I got 
an error, something like 'recovering from a double fault'.


After searching the STM32 forum of ST I found that some toolchains 
assemble the rbit instruction in a wrong way. Someone made a work-around :

.word   0xFxAyFA9y  //RBIT Rx,Ry x, y = 0 to F
My Freepascal version is this :
.word   0xFA90
.word   0xF0A0
Then when I disassemble in gdb, I get rbit r0,r0
Disassembling with objdump gives a strange result.

I'm going to try this as soon as I can.

Regards,

Koenraad Lelong.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: RE : RE : [fpc-pascal] Reversing bit-order of byte

2012-05-04 Thread Koenraad Lelong

On 03-05-12 13:27, Thomas Schatzl wrote:
...

function reverse(b : byte) : byte; assembler; nostackframe;
asm
   rbit r0, r0
   // rbit reverses the whole word, so now you have
   // your value in bits 31-24... so shift right by that amount
   // should fix this up (bits 23-0 contain junk, we shift that out
   // anyway)
   lsr r0, r0, #24
end;

However, this may not compile because fpc may not recognize the rbit
instruction.

Following is a version that encodes the instruction directly, retrieved
from disassembling some gcc code:

function reverse(b : byte) : byte; assembler; nostackframe;
asm
   .long 0xe6ff0f30 // rbit r0, r0
   lsr r0, r0, #24
end;



Thanks guys, I'll try and test this weekend.

Regards,

Koenraad Lelong.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: RE : RE : [fpc-pascal] Reversing bit-order of byte

2012-05-04 Thread Koenraad Lelong

On 03-05-12 13:27, Thomas Schatzl wrote:
...

function reverse(b : byte) : byte; assembler; nostackframe;
asm
   .long 0xe6ff0f30 // rbit r0, r0
   lsr r0, r0, #23
end;



Hi,

I've been looking a bit further at this.
I disassembled the code and this is the result :

 8000150:   e6ff0f30rbitr0, r0
 8000154:   ea4f 50d0   mov.w   r0, r0, lsr #23
 8000158:   46f7mov pc, lr

Wouldn't it be possible to do
rbitr0, r0, lsr #23
When reading the ARM programming manual I believe it should.

But do I gain something ?

Regards,

Koenraad Lelong.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: RE : RE : [fpc-pascal] Reversing bit-order of byte

2012-05-04 Thread Koenraad Lelong

On 04-05-12 14:31, Thomas Schatzl wrote:

It might be good to compile with -Cparmv6 (or -Cparmv7, do not know what
type the processor you use is), this generates a better return
instruction (bx lr) - and for the rbit instruction you need armv6
already.


Wouldn't it be possible to do
rbitr0, r0, lsr #23
When reading the ARM programming manual I believe it should.



No, rbit does not allow the flexible operand encoding.


But do I gain something ?



If it were possible, at most a few cpu cycles.

Compared to the other variants (e.g. with the multiplies, except for the
table lookup) you already save a lot of cycles - although I guess they
would be sufficiently fast anyway, considering the typical uart speeds.

Thomas


Hi Thomas,

My processor flags : -Wpstm32f103rb -Cparmv7m.
The #23 is no typo, I need to reverse 9 bits. I'm using 9 bit 
synchronous transmission. My first usart-tests were at 4Mbps. The person 
that made the driver recommends max. 6Mbps.

If I need more spare time I'll have to see what DMA can do.

Thanks for all information.

Regards,

Koenraad Lelong.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Reversing bit-order of byte

2012-05-03 Thread Koenraad Lelong

Hi,

I'm porting a driver, originally written in C, for an LCD to be used 
with an embedded arm-processor (STM32).
The original driver uses SPI, my driver will use a USART in synchronous 
mode because the STM32 has no SPI for 9-bit. Unfortunately, the 
bit-order is reversed between SPI and USART transmission.
Does anyone knows an efficient way to reverse bit-order of a byte for 
the arm-processor ? I'm going to look into the assembly language of the 
arm-processor, but maybe someone knows this immediately.
For old processors like 8085 or Z80 I know how to do this, but 
arm-assembler is new to me.


Thanks for any hints.

Koenraad Lelong.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: RE : [fpc-pascal] Reversing bit-order of byte

2012-05-03 Thread Koenraad Lelong

On 03-05-12 10:45, Ludo Brands wrote:


You might also look into the RBIT instruction which does this in one cpu
cycle. See
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0489c/Cihjgdi
d.html and applied to the STM32 USART
http://forum.micromouseonline.com/viewtopic.php?f=7t=460

Ludo

Hi,

Thanks all for your replies.
I already found the RBIT-instruction. I also found out I need to study 
the arm assembly language ;-)


But how do I get my variable ? Is that in some register ? Is there any 
documentation about such things ? Then I can use inline assembly.


Thanks,

Koenraad Lelong.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] fpc 2.7.1 for arm-embedded

2012-02-10 Thread Koenraad Lelong

On 10-02-12 11:30, Jonas Maebe wrote:


Now I see: that compilerproc is only included in the RTL if
FPC_HAS_FEATURE_ANSISTRINGS is defined. The embedded target by default
probably does not include support for ansistrings (since they in turn
depend on the heap manager). One helper for readstr(ansistring) is
however always included in the RTL currently, and the ansistring
assignment it contains results in a helper call (fpc_ansistr_assign)
since the introduction of the new ansistrings with code page support (in
the past it didn't, which is why that did not cause a problem previously).

So it should be simply a matter of adding some extra {$ifdef
FPC_HAS_FEATURE_ANSISTRINGS} defines around that code.

I think I have it fixed. I modified rtl/inc/text.inc, see the enclosed 
file. But how do I make a proper patch ? Now I did this :

diff fpc-svn/rtl/inc/text.inc.org fpc-svn/rtl/inc/text.inc

I only did make a crosscompiler, so it is not fully tested.
And AFAIK the crosscompiler makes thumb2 code now :-)
Now I have to make an rtl for the processor I'm using.

Thanks.

Koenraad
1893a1894
 {$ifdef FPC_HAS_FEATURE_ANSISTRINGS}
1898a1900
 {$endif FPC_HAS_FEATURE_ANSISTRINGS}
1940c1942
 
---
 {$ifdef FPC_HAS_FEATURE_ANSISTRINGS}
1952a1955
 {$endif FPC_HAS_FEATURE_ANSISTRINGS}

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] fpc 2.7.1 for arm-embedded

2012-02-10 Thread Koenraad Lelong

On 10-02-12 08:57, Rainer Stratmann wrote:

This means that there is a simple install solution for Linux?
All in one directory?


I don't understand what you want. An install solution for what ?

Koenraad.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] fpc 2.7.1 for arm-embedded

2012-02-10 Thread Koenraad Lelong

On 10-02-12 13:58, Sven Barth wrote:

If your fpc-svn directory is a real svn checkout you can just do a
svn diff  your-patch.diff. Alternatively you can use should add
-aur as argument to diff (in front of the filenames).


Enclosed the new patch. This all compiles, but needs to be verified and 
tested.

Or should I make a bugreport ?

Regards,

Koenraad.
Index: fpc-svn/rtl/inc/text.inc
===
--- fpc-svn/rtl/inc/text.inc	(revision 20278)
+++ fpc-svn/rtl/inc/text.inc	(working copy)
@@ -1891,11 +1891,13 @@
 {$endif FPC_WIDESTRING_EQUAL_UNICODESTRING}
 
 
+{$ifdef FPC_HAS_FEATURE_ANSISTRINGS}
 procedure ReadAnsiStrFinal(var t: textrec);
 begin
   { finalise the temp ansistring }
   PAnsiString(@t.userdata[StrPtrIndex])^ := '';
 end;
+{$endif FPC_HAS_FEATURE_ANSISTRINGS}
 
 
 procedure ReadStrCommon(var t: textrec; strdata: pchar; len: sizeint);
@@ -1937,7 +1939,7 @@
   PSizeInt(@t.userdata[BytesReadIndex])^:=0;
 end;
 
-
+{$ifdef FPC_HAS_FEATURE_ANSISTRINGS}
 function fpc_SetupReadStr_Ansistr(const s: ansistring): PText; [public, alias: 'FPC_SETUPREADSTR_ANSISTR']; compilerproc;
 begin
   setupreadstrcommon(ReadWriteStrText);
@@ -1950,6 +1952,7 @@
 end;
 
 function fpc_SetupReadStr_Ansistr_Intern(const s: ansistring): PText; [external name 'FPC_SETUPREADSTR_ANSISTR'];
+{$endif FPC_HAS_FEATURE_ANSISTRINGS}
 
 
 function fpc_SetupReadStr_Shortstr(const s: shortstring): PText; compilerproc;
Index: fpc-svn/compiler/arm/cpuinfo.pas
===
--- fpc-svn/compiler/arm/cpuinfo.pas	(revision 20278)
+++ fpc-svn/compiler/arm/cpuinfo.pas	(working copy)
@@ -74,6 +74,8 @@
   ct_at91sam7xc256,
 		
   { STMicroelectronics }
+  ct_stm32f100rb,
+
   ct_stm32f103rb,
   ct_stm32f103re,
   ct_stm32f103c4t,
@@ -301,6 +303,16 @@
 sramsize:$0001
 ),
 
+  	// ct_stm32f100rb,
+(
+	controllertypestr:'STM32F100RB';
+controllerunitstr:'STM32F103';
+interruptvectors:12;
+flashbase:$0800;
+flashsize:$0002;
+srambase:$2000;
+sramsize:$2000
+),
   	// ct_stm32f103rb,
 (
 	controllertypestr:'STM32F103RB';
Index: fpc-svn/compiler/systems/t_embed.pas
===
--- fpc-svn/compiler/systems/t_embed.pas	(revision 20278)
+++ fpc-svn/compiler/systems/t_embed.pas	(working copy)
@@ -232,6 +232,7 @@
   ct_at91sam7x256,
   ct_at91sam7xc256,
 
+  ct_stm32f100rb,
   ct_stm32f103rb,
   ct_stm32f103re,
   ct_stm32f103c4t,
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] fpc 2.7.1 for arm-embedded

2012-02-10 Thread Koenraad Lelong

On 10-02-12 15:33, Sven Barth wrote:

Am 10.02.2012 14:46, schrieb Koenraad Lelong:

On 10-02-12 13:58, Sven Barth wrote:

If your fpc-svn directory is a real svn checkout you can just do a
svn diff  your-patch.diff. Alternatively you can use should add
-aur as argument to diff (in front of the filenames).


Enclosed the new patch. This all compiles, but needs to be verified and
tested.
Or should I make a bugreport ?


Oh, I didn't know you did other changes as well. Then you should do a
svn diff rtl/inc/text.inc and make a bugreport for that :)



http://bugs.freepascal.org/view.php?id=21260

I tagged it major because without the patch you can't make a 
crosscompiler. Maybe too strong ;-) ?



The other modifications are for the controller I want to use. But I 
can't test this until later.


Koenraad.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] fpc 2.7.1 for arm-embedded

2012-02-09 Thread Koenraad Lelong

On 08-02-12 17:31, Koenraad Lelong wrote:

On 08-02-12 15:42, Jonas Maebe wrote:


On 08 Feb 2012, at 15:31, Koenraad Lelong wrote:


After some debugging, I think my compiler does not work. I'm pretty
certain it outputs arm-code in stead of the needed thumb2 code.


The error below indicates the compiler does not get to emitting any kind
of code at all.


What I say above is from a crosscompiler made with 2.6.0.
Below is what I get when I try to make a new crosscompiler, using svn
20278.



I just tried to make a crosscompiler using svn 20278, which fails :



I did another experiment.
I make a zip-file with a 2.7.1 compiler and its sources. I installled 
this on a brand new virtual machine with OpenSuse, so no fpc 2.6.0 
available. With this I compiled the compiler itself (no install). This 
went fine, so I expect the installation was OK. Then I tried to make the 
crosscompiler. This failed with the same error as before :


make rtl_all FPC=/home/koenraad/devel/fpc-svn/compiler/ppcrossarm RELEASE=1
make[1]: Map '/home/koenraad/devel/fpc-svn' wordt binnengegaan
make -C rtl all
make[2]: Map '/home/koenraad/devel/fpc-svn/rtl' wordt binnengegaan
make -C embedded all
make[3]: Map '/home/koenraad/devel/fpc-svn/rtl/embedded' wordt binnengegaan
/bin/mkdir -p /home/koenraad/devel/fpc-svn/rtl/units/arm-embedded
/home/koenraad/devel/fpc-svn/compiler/ppcrossarm -Cparmv7m @rtl.cfg -Ur 
-Tembedded -Parm -XParm-none-eabi- -Xr -Ur -Xs -O2 -n -Fi../inc 
-Fi../arm 
-FD/home/koenraad/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_EABI/bin 
-FE. -FU/home/koenraad/devel/fpc-svn/rtl/units/arm-embedded -darm 
-dRELEASE -CfSoft -Us -Sg system.pp
text.inc(1897,3) Fatal: Unknown compilerproc fpc_ansistr_assign. Check 
if you use the correct run time library.

Fatal: Compilation aborted
make[3]: *** [system.ppu] Fout 1
make[3]: Map '/home/koenraad/devel/fpc-svn/rtl/embedded' wordt verlaten
make[2]: *** [embedded_all] Fout 2
make[2]: Map '/home/koenraad/devel/fpc-svn/rtl' wordt verlaten
make[1]: *** [rtl_all] Fout 2
make[1]: Map '/home/koenraad/devel/fpc-svn' wordt verlaten
make: *** [base.build-stamp.arm-embedded] Fout 2

What am I doing wrong ? All suggestions to help resolve this are welcomed.

Thanks,

Koenraad Lelong.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] How to ? Using two compiler versions.

2012-02-08 Thread Koenraad Lelong

Hi,

I'm searching for some document how to set up a system to use two 
versions of fpc.
I'm trying to make a working arm-embedded compiler. With 2.6.0 I seem 
unable to do that, so I want to try it with the svn-version of fpc. But 
when I just install that, I lose the 2.6.0 version. What have I to do to 
be able to use the two versions in parallel ?


I tried to make the arm-embedded compiler by compiling the svn-version 
with fpc-2.6.0, but that fails.


Thanks for any info.

Regards,

Koenraad Lelong.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How to ? Using two compiler versions.

2012-02-08 Thread Koenraad Lelong

On 08-02-12 12:53, Henry Vermaak wrote:

How do you install it? I use 2.6.0 and trunk, so it's definitely
possible. I install to /usr/local on linux (but I have a similar setup
on Windows), then I end up with the different versions like this:

/usr/local/lib/fpc/2.6.0
/usr/local/lib/fpc/2.7.1


On my 64-bit OpenSuse I installed it from the rpm, so it went into 
/usr/lib64/fpc/...



Make sure you set up fpc.cfg to look at the right directories, e.g.

-Fu/usr/local/lib/fpc/$fpcversion/units/$fpctarget
-Fu/usr/local/lib/fpc/$fpcversion/units/$fpctarget/*
-Fu/usr/local/lib/fpc/$fpcversion/units/$fpctarget/rtl


My fpc.cfg was similar, all pointing to /usr/lib64/fpc/...
And that will be a problem. When I installed ppcrossarm (2.6.0 version), 
I used PREFIX=/usr, so all went into /usr/lib/fpc/...

Is there  way to select those paths depending on the version ? Like
#if $fpcversion=2.7.1
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget
...
#else
-Fu/usr/lib64/fpc/$fpcversion/units/$fpctarget
...
#end



Then you can just call the compiler directly, like:

/usr/local/lib/fpc/2.7.1/ppcrossarm

You can also set up symlinks/copies with a version suffix:

hcv@technical09:~$ ls -l /usr/local/bin/ppcrossarm*
lrwxrwxrwx 1 root root 35 Feb 8 11:48 /usr/local/bin/ppcrossarm-2.7.1 -
/usr/local/lib/fpc/2.7.1/ppcrossarm

Then use it like this:

hcv@technical09:~$ fpc -Parm -V2.7.1
So you can use different versions by just changing the -V parameter.


That's new to me, interesting.

So how should I make the crosscompiler ? -V seems not to work with the 
make-command.
If I make clean build install svn-trunk I will overwrite 2.6.0. So I 
should make clean build, then rename/link /usr/bin/ppcx64 to something 
e.g. ppcx64-2.6.0, then make install and rename/link ppcx64 to 
ppcx64-2.7.1.

Then to make the crosscompiler how do I specify to use ppcx64-2.7.1 ?

I'll try some things. I use a virtual machine so it would be no big pain 
if things go wrong.


Thanks for the info,

Koenraad.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How to ? Using two compiler versions.

2012-02-08 Thread Koenraad Lelong

On 08-02-12 14:31, Henry Vermaak wrote:
...

Then to make the crosscompiler how do I specify to use ppcx64-2.7.1 ?


I'm afraid I don't understand the question.



Never mind. I now remember that the buildprocess first builds it's own 
compiler, using the 'old' compiler. Then the new compiler is used to 
compile itself, then that compiler is used to compile the rest.


Anyway, trying to build a crosscompiler for cortexm3 fails.

Thanks,

Koenraad.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] fpc 2.6.0 for arm-embedded

2012-02-08 Thread Koenraad Lelong



I do have a working crosscompiler (I think), only I have to call it via
/usr/lib/fpc/2.6.0/ppcrossarm ..., instead of via fpc ...
The code seems not to work, but that could be my own RTL, which I copied
from SMT32F103RE. I'm working on that.



After some debugging, I think my compiler does not work. I'm pretty 
certain it outputs arm-code in stead of the needed thumb2 code.


I just tried to make a crosscompiler using svn 20278, which fails :

make rtl_all FPC=/home/koenraad/devel/fpc-svn/compiler/ppcrossarm RELEASE=1
make[1]: Map '/home/koenraad/devel/fpc-svn' wordt binnengegaan
make -C rtl all
make[2]: Map '/home/koenraad/devel/fpc-svn/rtl' wordt binnengegaan
make -C embedded all
make[3]: Map '/home/koenraad/devel/fpc-svn/rtl/embedded' wordt binnengegaan
/bin/mkdir -p /home/koenraad/devel/fpc-svn/rtl/units/arm-embedded
/home/koenraad/devel/fpc-svn/compiler/ppcrossarm -Cparmv7m @rtl.cfg -Ur 
-Tembedded -Parm -XParm-none-eabi- -Xr -Ur -Xs -O2 -n -Fi../inc 
-Fi../arm 
-FD/home/koenraad/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_EABI/bin 
-FE. -FU/home/koenraad/devel/fpc-svn/rtl/units/arm-embedded -darm 
-dRELEASE -CfSoft -Us -Sg system.pp
text.inc(1897,3) Fatal: Unknown compilerproc fpc_ansistr_assign. Check 
if you use the correct run time library.

Fatal: Compilation aborted
make[3]: *** [system.ppu] Fout 1
make[3]: Map '/home/koenraad/devel/fpc-svn/rtl/embedded' wordt verlaten
make[2]: *** [embedded_all] Fout 2
make[2]: Map '/home/koenraad/devel/fpc-svn/rtl' wordt verlaten
make[1]: *** [rtl_all] Fout 2
make[1]: Map '/home/koenraad/devel/fpc-svn' wordt verlaten
make: *** [base.build-stamp.arm-embedded] Fout 2

Any thoughts ?

Thanks,

Koenraad.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] fpc 2.6.0 for arm-embedded

2012-02-08 Thread Koenraad Lelong

On 08-02-12 15:42, Jonas Maebe wrote:


On 08 Feb 2012, at 15:31, Koenraad Lelong wrote:


After some debugging, I think my compiler does not work. I'm pretty
certain it outputs arm-code in stead of the needed thumb2 code.


The error below indicates the compiler does not get to emitting any kind
of code at all.


What I say above is from a crosscompiler made with 2.6.0.
Below is what I get when I try to make a new crosscompiler, using svn 
20278.



I just tried to make a crosscompiler using svn 20278, which fails :


...


This means you are trying to compile an FPC 2.6.x (or 2.4.x) RTL using
an FPC 2.7.x starting compiler, or an FPC 2.7.x RTL using an FPC 2.7.x
compiler built from a different 2.7.x revision.

Always first build a native compiler for the version you want to use
(starting with the previous release relative to that version), and use
the resulting native compiler to build a cross-compiler from those same
sources.



That's what I think I did.
I had fpc 2.6.0 installed.
I downloaded fpc trunk via svn.
In the root of the download I did make clean build install (as root).
I renamed /usr/lib64/fpc/2.6.0 to -2.6.0- so it would not be found.
I renamed /usr/bin/ppcx64 to ppcx64-2.6.0.
I made a link from /usr/lib/fpc/2.7.0/ppcx64 to /usr/bin/ppcx64.
I modified /etc/fpc.cfg to use /usr/lib/fpc/2.7.0...
fpc -i shows 2.7.1
In the root of the download I tried to make the crosscompiler and then I 
got the error.


Is there a way to verify there are no files left ? I tried fpc -vt but 
that seems not the tool.


Thanks,

Koenraad.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] fpc 2.6.0 for arm-embedded

2012-02-06 Thread Koenraad Lelong

On 06-02-12 10:04, Graeme Geldenhuys wrote:

For a much easier cross-compiling experience, try using Paul
Breneman's downloads. He has packages the FPC arm cross-compiler is a
very small archive. Simply unzip and run - and it works no problems.
As a bonus, he also includes fpGUI (for GUI development) with his
cross-compiler archives.


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


I downloaded that package, and I tried it on my x86_64 Ubuntu-laptop. 
ppcarm can't be executed, file ppcarm shows this :
ppcarm: ELF 32-bit LSB executable, ARM, version 1, statically linked, 
stripped
AFAIK this means it's a binary to run on an arm-system, so it's not a 
crosscompiler and I do not have an arm-system at hand that can run a 
compiler.


I think there is some misunderstanding. What I'm trying to do is make 
software for an embedded system. There is no OS. The controller I'm 
targetting has 128K of flash-rom and 8K of RAM.


I do have a working crosscompiler (I think), only I have to call it via 
/usr/lib/fpc/2.6.0/ppcrossarm ..., instead of via fpc ...
The code seems not to work, but that could be my own RTL, which I copied 
from SMT32F103RE. I'm working on that.


Regards,

Koenraad Lelong.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] fpc 2.6.0 for arm-embedded

2012-02-06 Thread Koenraad Lelong

On 06-02-12 14:34, Rainer Stratmann wrote:

I am also interested in crosscompiling for embedded ARM.
How did you install the crosscompiler on Linux OS?
Is there an easy way of doing this?
Is it in the debian packages precompiled and ready for use?


On a Suse 12.1 virtual machine I downloaded the binutils from 
CodeSourcery and installed them. I downloaded and installed fpc 2.6.0 
and it's sources. In the root of the sources I did (as superuser) :
make clean buildbase installbase CROSSINSTALL=1 OS_TARGET=embedded 
CPU_TARGET=arm SUBARCH=armv7m 
CROSSBINDIR=/home/koenraad/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_EABI/bin 
BINUTILSPREFIX=arm-none-eabi-  CROSSOPT=-CfSoft PREFIX=/usr
I'm afraid there are no ready make packages for crosscompiling. I would 
be interested too. But fpc has a way to make packages (at least rpm) for 
fpc for linux so I think it should be possible to make them for 
crosscompiling too.


Regards,

Koenraad Lelong.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] fpc 2.6.0 for arm-embedded

2012-02-06 Thread Koenraad Lelong

On 06-02-12 14:47, Graeme Geldenhuys wrote:


Strange. Last time I downloaded Paul's Windows archive he released, it
was indeed a cross-compiler for x86 (32-bit) to ARM (and not a native
arm executable). I could then compile my mobile application under
Windows 2000, then copy my compiled application to my ARM / WinCE
based PDA and run in there.


Of the various download links on Paul's website, which one did you download?


http://www.turbocontrol.com/EasyfpGUI-fpc-2.2.2.arm-linux-052111.zip
Like I said, I think these systems are for systems with a full Operating 
System (Linux, WinCE ...).


I'm trying to make software for a bare microcontroller.

Koenraad.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] fpc 2.6.0 for arm-embedded

2012-02-03 Thread Koenraad Lelong

Hi,

I just had some time to look into this again.
I downloaded the latest 2.6.0 sources and mostly followed 
http://wiki.freepascal.org/TARGET_Embedded to make a crosscompiler. In 
/usr/lib/fpc/2.6.0 there is a ppcrossarm with a date of today when I run 
ppcrossarm -i.

But when I try

fpc -Parm -Tembedded -Wplpc2124 -Cparmv7m

I get an error :

Error: ppcarm can't be executed, error message: Failed to execute 
ppcarm, error code: 127


Is this expexted ? If yes, then the wiki should be updated.
If it matters, I'm using OpesSuse 12.1.

Another thing that puzzles me : the wiki says to use SUBARCH=armv7m for 
cortex-m3. ppcrossarm -i says there are cpu instruction sets for

  ARMV3
  ARMV4
  ARMV5
  ARMV6
  ARMV7
  ARMV7M
  CORTEXM3
Should I use SUBARCH=cortexm3 to compile the compiler to use it with 
STM32-processors, which are cortex-m3 ? Or should I just compile the 
applications with -Cpcortexm3 ?


Thanks for any info.

Regards,

Koenraad Lelong.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] fpc 2.6.0-rc1 for arm-embedded

2011-12-12 Thread Koenraad Lelong

On 09-12-11 00:09, Den Jean wrote:

On Thursday 08 December 2011 13:49:16 Koenraad Lelong wrote:

  /usr/lib/fpc/2.6.0/units/arm-embedded/rtl/system.o does not support

  interworking, whereas test-1.elf does

does this thread help ?

http://lists.freepascal.org/lists/fpc-devel/2011-August/025615.html


Hi,

Thanks,

I tried the commands of John Clymer after downloading and installing 
Codesourcery. The compiler and my test-application compiled fine. I 
flashed my device but there I don't see anything.
At the moment I can't debug with JTAG, so I'll have to fix that first 
before I can say more.


Regards,

Koenraad Lelong.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] fpc 2.6.0-rc1 for arm-embedded

2011-12-08 Thread Koenraad Lelong

Hi,

I had some problems making or using a compiler for arm-embedded so I 
tried the new 2.6.0-rc1.

Compiling with :
make clean buildbase installbase CROSSINSTALL=1 CROSSOPT=-CfSoft 
-XParm-elf- OS_TARGET=embedded CPU_TARGET=arm PREFIX=/usr/ SUBARCH=armv7m

went fine.
Compiling a test-app with
/usr/lib/fpc/2.6.0/ppcrossarm -B -al -Tembedded -Wpstm32f103re -Cfsoft 
-Cparmv7m -XParm-elf- test-1.pas

gave me following warnings :
/usr/bin/arm-elf-ld: Warning: 
/usr/lib/fpc/2.6.0/units/arm-embedded/rtl/system.o does not support 
interworking, whereas test-1.elf does
/usr/bin/arm-elf-ld: Warning: 
/usr/lib/fpc/2.6.0/units/arm-embedded/rtl/stm32f103.o does not support 
interworking, whereas test-1.elf does


I think Googling tells me my application will not run. Am I doing 
something wrong ?


Thanks for any hints.

Koenraad Lelong
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Database access in console program

2011-11-09 Thread Koenraad Lelong

Hi,

I don't know if it's the right place to ask, maybe it's for the lazarus 
list.


Anyway, I'm trying to make a console-application that writes data to a 
Firebird database. With Lazarus I created a console application.

I seem to be able to connect and open the table, but I can't insert data.
Are there examples anywhere ? I know how to do this in a graphical 
environment, but I need the console app, it will run on a non-gui server.


Here is my code that goes in the application on-create method :

  MyDB:=TIBConnection.Create(nil);
  MyDB.Hostname:='server';
  MyDB.DatabaseName:='/data/firebird/database.fdb';
  MyDB.Transaction:=DupFilesTransaction;
  MyDB.UserName:='user';
  MyDB.Password:='password';
  try
   MyDB.Open;
   writeln('DB open');
  except
   on E: Exception do
begin
 writeln(E.Message);
end;
  end;
  myTransaction:=TSQLTransaction.Create(nil);
  myTransaction.Database:=MyDB;
  try
   myTransaction.StartTransaction;
   writeln('Transaction open');
  except
   on E: Exception do
begin
 writeln(E.Message);
end;
  end;
  myTable:=TSQLQuery.Create(nil);
  myTable.Database:=MyDB;
  myTable.Transaction:=myTransaction;

  myTable.SQL.Clear;
  myTable.SQL.Add('select * from myTable');
  myTable.InsertSQL.Clear;
  myTable.InsertSQL.Add('INSERT INTO myTable(');
  myTable.InsertSQL.Add(  'Field1,');
  myTable.InsertSQL.Add(  'Field2');
  myTable.InsertSQL.Add(  ')');
  myTable.InsertSQL.Add(  'VALUES(');
  myTable.InsertSQL.Add(  ':Field1,');
  myTable.InsertSQL.Add(  ':Field2');
  myTable.InsertSQL.Add(  ')');
  try
   myTable.Open;
   writeln('Table open');
  except
   on E: Exception do
begin
 writeln(E.Message);
end;
  end;


When I insert values I do :

  myTable.Params.ParamByName('Field1').Value:='Value1';
  myTable.Params.ParamByName('Field2').Value:='Value2';
  try
  myTable.ApplyUpdates;
  except
   on E: Exception do
writeln(E.Message)
  end;

If I try this I get an error stating parameter Field1 does not exist.

Any references ?

Thanks,

Koenraad Lelong.


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Database access in console program

2011-11-09 Thread Koenraad Lelong

On 09-11-11 18:02, michael.vancann...@wisa.be wrote:



...

This should be:

MyTable.Append;
MyTable.FieldByname('Field1').AsString:='Value1';
MyTable.FieldByname('Field2').AsString:='Value2';
MyTable.Post;
MyTable.Applyupdates;


Thanks,

That worked. And I remember using this before.

Thanks,

Koenraad Lelong.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Making a cross-compiler for STM32

2011-10-12 Thread Koenraad Lelong

On 11-10-11 22:05, Jeppe Græsdal Johansen wrote:

That's a problem, since that error was fixed in revision 19238.

Btw. I just tested, and I had no problem building the svn trunk version
using fpc 2.71. What version of fpc did you try to build with?

Regards,
Jeppe


Hi,

I tried with 19167, like you advised ;-)
I'll try 19238 now.

Thanks again,

Koenraad Lelong.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Making a cross-compiler for STM32

2011-10-12 Thread Koenraad Lelong

On 12-10-11 08:12, Koenraad Lelong wrote:

On 11-10-11 22:05, Jeppe Græsdal Johansen wrote:

That's a problem, since that error was fixed in revision 19238.

Btw. I just tested, and I had no problem building the svn trunk version
using fpc 2.71. What version of fpc did you try to build with?

Regards,
Jeppe



Hi,

I think I misunderstood your question. I built my crosscompiler with 
2.4.0 (standard on Ubuntu 10.4 LTS). I'll see if I can get a more recent 
version. Hm, I see that for Debian the most recent version is 2.4.2, 
would this do to make 2.7 ? I'll first try with 2.4.0.


Regards,

Koenraad Lelong.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Making a cross-compiler for STM32

2011-10-12 Thread Koenraad Lelong

On 12-10-11 09:07, Jeppe Græsdal Johansen wrote:

Den 12-10-2011 08:25, Koenraad Lelong skrev:
Neither will do, and that explains the problem. To build the svn trunk
version you need the latest stable release(or latest svn trunk version),
which is version 2.4.4


OK,

I installed the binary version of 2.4.4 from the website, altough I 
prefer the package.
Compiling the snapshot of a few days ago went OK, but how do I install 
this ?

I did a
make all PREFIX=/usr
make singlezipinstall
and unpacked this to /usr. Unfortunatly, in /usr/bin I get fpc 2.4.4.
I checked the archive and /bin/fpc is 2.4.4. /lib/fpc/2.7.1/ppcx64 is 
indeed 2.7.1.

To make my crosscompiler, I'll try
make clean buildbase installbase CROSSINSTALL=1 CROSSOPT=-CfSoft 
-XParm-elf- OS_TARGET=embedded CPU_TARGET=arm 
PREFIX=/home/koenraad/Documents/devel SUBARCH=armv7m 
PP=/usr/lib/fpc/2.7.1/ppcx64


I'll report back.

Regards,

Koenraad Lelong.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Making a cross-compiler for STM32

2011-10-12 Thread Koenraad Lelong

To make my crosscompiler, I'll try
make clean buildbase installbase CROSSINSTALL=1 CROSSOPT=-CfSoft
-XParm-elf- OS_TARGET=embedded CPU_TARGET=arm
PREFIX=/home/koenraad/Documents/devel SUBARCH=armv7m
PP=/usr/lib/fpc/2.7.1/ppcx64


No luck,

I still get those heapmanager errors.

I'm stuck :-(

Regards,

Koenraad Lelong.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Making a cross-compiler for STM32

2011-10-09 Thread Koenraad Lelong
 compiling module, stopping
Fatal: Compilation aborted
make[3]: *** [heapmgr.ppu] Fout 1
make[3]: Map '/home/koenraad/Downloads/STM32/fpc/rtl/embedded' wordt 
verlaten

make[2]: *** [embedded_all] Fout 2
make[2]: Map '/home/koenraad/Downloads/STM32/fpc/rtl' wordt verlaten
make[1]: *** [rtl_all] Fout 2
make[1]: Map '/home/koenraad/Downloads/STM32/fpc' wordt verlaten
make: *** [base.build-stamp.arm-embedded] Fout 2

Did I do anything wrong ? Or is the snapshot unstable for those devices 
? How can I get a working compiler ?


Thanks,

Koenraad Lelong
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] ARM STM32F Processor

2011-09-19 Thread Koenraad Lelong

On 04-09-10 12:40, Jeppe Johansen wrote:

Den 04-09-2010 12:37, Rainer Stratmann skrev:

Am Saturday 04 September 2010 11:57:25 schrieb Jeppe Johansen:

Den 04-09-2010 10:50, Rainer Stratmann skrev:

Is it possible to compile for this device?

Yes


Can somebody help?

Yes


Hello,

I just got my STM32-discovery board. I'm searching how I can program the 
device, but I can't find anything. With programming I mean getting the 
firmware into the device. Can someone give me a link ?

Another question : any links how to get fpc to compile for that device ?

Regards,

Koenraad Lelong.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] ARM STM32F Processor

2011-09-19 Thread Koenraad Lelong

On 19-09-11 14:49, Mark Morgan Lloyd wrote:

Koenraad Lelong wrote:

On 04-09-10 12:40, Jeppe Johansen wrote:

Den 04-09-2010 12:37, Rainer Stratmann skrev:

Am Saturday 04 September 2010 11:57:25 schrieb Jeppe Johansen:

Den 04-09-2010 10:50, Rainer Stratmann skrev:

Is it possible to compile for this device?

Yes


Can somebody help?

Yes


Hello,

I just got my STM32-discovery board. I'm searching how I can program
the device, but I can't find anything. With programming I mean getting
the firmware into the device. Can someone give me a link ?


Google suggests that half of the board is an ST-Link programmer which
expects a proprietary protocol over USB, but that there might be
alternatives.

http://hackaday.com/2010/10/12/arm-prototyping-on-the-cheap-with-stm32-discovery/

http://answerpot.com/showthread.php?1008813-ST-Link+with+OpenOCD%3F



Hi,

Thanks for the links. I didn't google yet, because I thought the 
ST-website would provide the information. I also asked ST-support where 
I could find that information. They said to read the users-manual.
Reading it again for the fifth time, I think you have to download some 
development toolchains in order to be able to program the device. That's 
not clear when you read the user-manual.


I'll google more now.

Regards,

Koenraad Lelong
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] InterProcessCommunication

2009-09-06 Thread Koenraad Lelong
Hi,
I would like to use some form of IPC, but I would like some examples.
In the rtl-reference I found working examples with sockets, but these
use deprecated functions. I translated them to up-to-date functions but
I don't know how to read from the socket, do I use fpRead or fpRecv ?
How do I check if the socket is empty ?
I found references to simpleIPC, but I can't find examples. I found an
xml-file, could this some explanation ?
I'm using FPC 2.2.4. Any pointers ?
TIA

Regards,
Koenraad Lelong.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] DateTimeToUnix bug ?

2009-07-15 Thread Koenraad Lelong

Hi,
I have a linux application where I use DatetimeToUnix. I think it 
contains a bug.
Every minute I put a sample in an rrddb (rrdtool). When I dump the 
rrddb, the time of the samples is 2 hours in the future. Those 2 hours 
happen to be the time-zone difference, between UTC and CEST.

Anyone can verify this ?

This is what I used to test this :
program DateTest;
{$ifdef FPC}{$mode objfpc}{$h+}{$INTERFACES CORBA}{$endif}
{$ifdef mswindows}{$apptype console}{$endif}
uses
 {$ifdef FPC}{$ifdef linux}cthreads,{$endif}{$endif}
 sysutils, dateutils;

var
 Nu : TDateTime;

begin

Nu:=Now;
writeln(nu:1:8,' ',DateTimeToStr(nu),' ',DatetimeToUnix(Nu));
end.

When I run ./DateTest  date +%s  date I get :
40009.44713685 15-7-09 10:43:52 1247654632
1247647432
wo jul 15 10:43:52 CEST 2009

Between the fpc-version and the linux-version of the unix-time there is 
7200 seconds difference, fpc running ahead.


Is it a bug, or am I missing someting ? This happens with FPC 2.4.

Regards,
Koenraad Lelong.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] DateTimeToUnix bug ?

2009-07-15 Thread Koenraad Lelong

Jonas Maebe schreef:


On 15 Jul 2009, at 11:06, Koenraad Lelong wrote:

I have a linux application where I use DatetimeToUnix. I think it 
contains a bug.
Every minute I put a sample in an rrddb (rrdtool). When I dump the 
rrddb, the time of the samples is 2 hours in the future. Those 2 hours 
happen to be the time-zone difference, between UTC and CEST.


DatetimeToUnix is defined as returning the Unix epoch time 
corresponding to AValue. So by definition it does not perform any time 
zone adjustments (which is logical, since there is no information 
regarding what time zone the input value is related to). It's the same 
in Delphi (just google for DatetimeToUnix+timezone


If you want now using the local time zone, use sysutils.getlocaltime 
instead.



Jonas


Thanks Jonas, but that gives the same result. I found that 
fpGetTimeOfDay does the trick.


Regards,
Koenraad.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Daemon question

2009-05-14 Thread Koenraad Lelong
Henry Vermaak schreef:
 2009/5/13 Koenraad Lelong fpas...@brouwerij.homelinux.net:
 Hi,
 I wrote a daemon monitoring my solar powerstation. It works fine but I
 want to extend it.
...
 Now I'm writing this, I could write to a file after receiving a signal,
 and then reading this with php.
 Thinking about it, does php support sending signals ? Back to the books.

 
 i think the most elegant and scalable solution is to write a
 client/controller program that communicates with the server.  this
 client can control the server, set options, get information/status via
 sockets, or some form of ipc.  php can then call this client with the
 required options and use the output.  a lot of unix daemons use this
 approach, see udevadm (for udev) and smbcontrol (for samba), for
 example.
 
 if this is too much trouble, your daemon can just append data to log
 files every x seconds and php can read these files.  you will have to
 implement some log rotation scheme, though, or the log files will take
 over your system.
 
 henry

My big logs are 1.6M per day, but they are about 5000 lines at the end
of the day. Wouldn't it be a waste to read the last line of such a big
file ?
My last remark was about sending a signal via php (it does support
sending signals) and then writing the desired value to a file which
would be a single line, and then php reads this file. There could be
problems with concurrency, although the website will only be available
at home, so the number of possible users will be limited.
I will read about IPC and sockets. Do you have any good references at
hand about these ? I think googling will be difficult, but I will.

Thanks guys,
Koenraad.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Daemon question

2009-05-13 Thread Koenraad Lelong
Hi,
I wrote a daemon monitoring my solar powerstation. It works fine but I
want to extend it.
At the moment I log everything to file, and I put some data into rrdtool.
I would like to be able to ask the daemon some information, but I don't
know how to do this.
I made some signals : sigterm to terminate gracefully, sighup to
restart, sigusr0 to get the uptime and sigusr1 to get some device-info.
Except, sigusr0 and sigusr1 use writeln's to output the data which I
never see when I ask for them (kill -10 processid). Where do these
writeln's write to ? Sigterm and sighup do work fine, so I think my
handler is OK.
How can I get that info ? It should be software-independent, because I
would like to use php to get that information.
I thought of writing the info to a file, but that info is updated every
15 seconds. I think it's not good to write a new file every time.
Now I'm writing this, I could write to a file after receiving a signal,
and then reading this with php.
Thinking about it, does php support sending signals ? Back to the books.

Before you ask, I'm running Linux.

Thanks for any pointers,
Koenraad Lelong.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How to build 2.2.2-crosscompiler for arm-linux ?

2008-11-30 Thread Koenraad Lelong
Joost van der Sluis schreef:
 Op zaterdag 29-11-2008 om 19:48 uur [tijdzone +0100], schreef Koenraad
 Lelong:
 Hello,
 In the past I built numerous fpc-crosscompilers for arm-linux but now I
 can't anymore.
 What I did :
 Downloaded and extracted fpcbuild-2.2.2.tar.gz
 make CPU_TARGET=arm OS_TARGET=linux NOGDB=1 NODOCS=1 crosszipinstall
 This complains that ppcrossarm is not found !
 If I do the same with 2.2.0 I do get my crosscompiler.
 
 I would guess that 'crosszipinstall' creates the installation into
 zip-files. For that the compiler already has to be compiled. Try a
 'clean all' instead of 'crosszipinstall'. And it could be that you have
 to specify the start-compiler with 'PP=ppcx386'
 
 Joost
 
Thanks,
PP=ppc386 did the trick.
B.T.W. is there documentation about crosscompiling ?

Regards,
Koenraad Lelong.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] How to build 2.2.2-crosscompiler for arm-linux ?

2008-11-29 Thread Koenraad Lelong
Hello,
In the past I built numerous fpc-crosscompilers for arm-linux but now I
can't anymore.
What I did :
Downloaded and extracted fpcbuild-2.2.2.tar.gz
make CPU_TARGET=arm OS_TARGET=linux NOGDB=1 NODOCS=1 crosszipinstall
This complains that ppcrossarm is not found !
If I do the same with 2.2.0 I do get my crosscompiler.

I did build some crosscompilers with 2.2.2, but I didn't realise that
the previous ppcrossarm was used. Now I started with a brand-new virtual
machine and I encountered those problems.

Any help ?

Regards,
Koenraad Lelong.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


  1   2   >