Shop OBEX P1 Docs P2 Docs Learn Events
Propeller Chip - Raspberry Pi 2- Interfacing With Free Pascal & Lazarus — Parallax Forums

Propeller Chip - Raspberry Pi 2- Interfacing With Free Pascal & Lazarus

Bob Lawrence (VE1RLL)Bob Lawrence (VE1RLL) Posts: 1,720
edited 2015-04-15 20:26 in Propeller 1
Pascal is another development option for the Pi 2 . You can use Free Pascal compiler with the command line or you can use the Lazarus IDE . To get the latest versions of FPC and Lazarus, Free Pascal is installed first then the latest packages for FPC & Lazarus are downloaded to the Pi and compiled from there.

Lazarus on Raspberry Pi
http://wiki.freepascal.org/Lazarus_on_Raspberry_Pi

There is a Lazarus version for the Pi B+ but it's quite slow to compile and I didn't find it usable for me. The instructions in the URL below are only for the Raspberry Pi 2 and not for the Model's A+ B+ etc .The CPU's are different for the Pi 2(quad-core ARM Cortex-A7 CPU running at up to 900MHz)

You can follow the install instructions from here: http://otapi.com/2015/02/10/raspberry-pi-2-freepascal-lazarus-and-delphi/

From the comments on that web site you can see that some people installed it without any problems while others struggled. Free Pascal installed with no problems for me. Lazarus had some challenges during the make stages. One of the changes recommended on the website (that helped me) was to increase the Pi swap size from 100MB to 500MB on a temporary basis, to complete the install and then set it back once everything is completed. However, I always got stuck at the last make stage for Lazarus. I then realized that I was running out for hard drive space (I was using a 8GB micro SD card) Then I deleted everything I could such as Games , until I got enough free space to continue the process. Eventually I was able to complete the process and get it all installed and working . I decided that 8GB is not big enough and today I picked up a 16 GB , class 10 micro SD card and re-did the OS and Pascal/Lazarus install. I still had to increase the swap size but everything else went smoothly I then made a test program(screen shots attached) . It doesn't do much LOL but it does display the versatility Lazarus and free Pascal. The compile time was a little slow but quite reasonable.

The next step is to get the GPIO working and then see how many ways I can communicate with the Propeller Chip

Everyone has their favorite language and I'm sure happy to be able to use Pascal on the Pi :)

attachment.php?attachmentid=113811&d=1428454607

attachment.php?attachmentid=113812&d=1428454619

Lazarus Info
http://en.wikipedia.org/wiki/Lazarus_%28IDE%29
816 x 509 - 134K
816 x 509 - 66K

Comments

  • jmgjmg Posts: 15,173
    edited 2015-04-07 18:00
    Interesting.
    With Lazarus installed, I presume you can Set breakpoints, and source-step, Watch vars etc ?
    (the image links did not seem to work)

    No surprise a Pi2 is more tolerable than earlier models.

    This could make a PropPascal more viable too ? BEAN has mentioned that may be possible.
  • jmgjmg Posts: 15,173
    edited 2015-04-07 18:17
    Now the images work, very nice! . ( The Last FPC example I saw on Pi, lacked the Lazarus portion )
    The next step is to get the GPIO working and then see how many ways I can communicate with the Propeller Chip

    Let us know how fast you can get the serial port working.
    I've seen reports of 4MBd working, and some comments suggesting higher is possible, but no reports of actual working examples above 4MBd.

    Does code compiled on a Pi-2, run ok on the earlier PI's ?
  • Bob Lawrence (VE1RLL)Bob Lawrence (VE1RLL) Posts: 1,720
    edited 2015-04-07 18:39
    @ jmg

    re: I presume you can Set breakpoints, and source-step, Watch vars etc ?

    Yes

    attachment.php?attachmentid=113814&d=1428457142
    816 x 509 - 126K
  • jmgjmg Posts: 15,173
    edited 2015-04-07 19:06
    Cool, all this leads to musings of remote debug, which indeed seems to be viable in some cases (eg)
    http://forum.lazarus.freepascal.org/index.php?topic=20101.0
    I wonder how small a gdbserver can be on a Prop ?
  • Bob Lawrence (VE1RLL)Bob Lawrence (VE1RLL) Posts: 1,720
    edited 2015-04-07 19:20
    I added the Lazarus Wiki to the top thread as well as here

    Lazarus Info:

    http://en.wikipedia.org/wiki/Lazarus_%28IDE%29
  • Bob Lawrence (VE1RLL)Bob Lawrence (VE1RLL) Posts: 1,720
    edited 2015-04-07 19:54
    @ jmg

    Re:Let us know how fast you can get the serial port working.

    Ok but that may take awhile. I guess I have two options to try.

    1. Serial through the GPIO port or
    2. serial through the USB port.

    I`ll have a look at the USB port tonight and connect a Propeller board to see if I can see a FTDI device on the port first.
  • jmgjmg Posts: 15,173
    edited 2015-04-07 20:04
    Some of the serial interface choices on RaspPi are given here
    http://www.raspberrypi.org/forums/viewtopic.php?f=44&t=17559

    * Uart1
    * SPI0
    * SPI1,2
    * BSC (Broadcoms name for the I2C engine )
    * Uart0


    and near the end, someone mentions achieving 4MBd on a UART with an OS patch

    addit: and more is found here
    http://fw.hardijzer.nl/?p=138
    Main UART seems to map as /dev/ttyAMA0
  • Bob Lawrence (VE1RLL)Bob Lawrence (VE1RLL) Posts: 1,720
    edited 2015-04-07 20:24
    I found a com program on :

    http://elinux.org/RPi_Serial_Connection


    Run minicom with the following parameters:

    minicom -b 115200 -o -D Port_Name

    Then I did a scan of USB devices:
    ===============================================================
    pi@raspberrypi ~ $ lsusb
    Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp.
    Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
    Bus 001 Device 004: ID 0461:4d8a Primax Electronics, Ltd
    Bus 001 Device 005: ID 046d:c52b Logitech, Inc. Unifying Receiver
    Bus 001 Device 006: ID 148f:5370 Ralink Technology, Corp. RT5370 Wireless Adapter

    ls/dev/tty

    pi@raspberrypi ~ $ pi@raspberrypi ~ $ lsusb
    bash: pi@raspberrypi: command not found
    pi@raspberrypi ~ $ Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp.
    bash: Bus: command not found
    pi@raspberrypi ~ $ Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    bash: Bus: command not found
    pi@raspberrypi ~ $ Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
    bash: Bus: command not found
    pi@raspberrypi ~ $ Bus 001 Device 004: ID 0461:4d8a Primax Electronics, Ltd
    bash: Bus: command not found
    pi@raspberrypi ~ $ Bus 001 Device 005: ID 046d:c52b Logitech, Inc. Unifying Receiver
    bash: Bus: command not found
    pi@raspberrypi ~ $ Bus 001 Device 006: ID 148f:5370 Ralink Technology, Corp. RT5370 Wireless Adapter
    bash: Bus: command not found
    pi@raspberrypi ~ $


    Then I plugged in the Propeller Development Board:

    pi@raspberrypi ~ $ lsusb
    Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp.
    Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
    Bus 001 Device 004: ID 0461:4d8a Primax Electronics, Ltd
    Bus 001 Device 005: ID 046d:c52b Logitech, Inc. Unifying Receiver

    *** (here we have the FTDI device)
    Bus 001 Device 007: ID 0403:6001 Future Technology Devices International, Ltd FT232 USB-Serial (UART) IC

    Bus 001 Device 006: ID 148f:5370 Ralink Technology, Corp. RT5370 Wireless Adapter

    ========================================================================================
    root@raspberrypi:/home/pi# ls /dev/tty*
    /dev/tty /dev/tty12 /dev/tty17 /dev/tty21 /dev/tty26 /dev/tty30 /dev/tty35 /dev/tty4 /dev/tty44 /dev/tty49 /dev/tty53 /dev/tty58 /dev/tty62 /dev/ttyAMA0
    /dev/tty0 /dev/tty13 /dev/tty18 /dev/tty22 /dev/tty27 /dev/tty31 /dev/tty36 /dev/tty40 /dev/tty45 /dev/tty5 /dev/tty54 /dev/tty59 /dev/tty63 /dev/ttyprintk
    /dev/tty1 /dev/tty14 /dev/tty19 /dev/tty23 /dev/tty28 /dev/tty32 /dev/tty37 /dev/tty41 /dev/tty46 /dev/tty50 /dev/tty55 /dev/tty6 /dev/tty7 /dev/ttyUSB0 ******* Here it is ****
    /dev/tty10 /dev/tty15 /dev/tty2 /dev/tty24 /dev/tty29 /dev/tty33 /dev/tty38 /dev/tty42 /dev/tty47 /dev/tty51 /dev/tty56 /dev/tty60 /dev/tty8
    /dev/tty11 /dev/tty16 /dev/tty20 /dev/tty25 /dev/tty3 /dev/tty34 /dev/tty39 /dev/tty43 /dev/tty48 /dev/tty52 /dev/tty57 /dev/tty61 /dev/tty9
    root@raspberrypi:/home/pi#
  • Bob Lawrence (VE1RLL)Bob Lawrence (VE1RLL) Posts: 1,720
    edited 2015-04-07 20:51
    Ok I did a quick test and Minicom was able to receive a message from the Prop Spin program (FullDuplexSerial_Test1.spin)


    attachment.php?attachmentid=113816&d=1428465084


    Cool!!
    704 x 384 - 13K
  • Bob Lawrence (VE1RLL)Bob Lawrence (VE1RLL) Posts: 1,720
    edited 2015-04-08 01:07
    This is nothing serious. I was just playing around with the IDE because it's been many years since I've used it and I got a little carried away. :)

    attachment.php?attachmentid=113817&d=1428480381
    816 x 509 - 153K
  • Bob Lawrence (VE1RLL)Bob Lawrence (VE1RLL) Posts: 1,720
    edited 2015-04-09 15:23
    This Library can do Serial on the RBP2 side

    Ararat Synapse FPC/Lazarus Port.

    http://www.ararat.cz/synapse/doku.php/start

    Snippet's from the synaser.pas File
    =============================================================================|
    | Project : Ararat Synapse | 007.005.002 |
    |==============================================================================|
    | Content: Serial port support |
    |==============================================================================|
    | Copyright (c)2001-2011, Lukas Gebauer |
    | All rights reserved.

    {: @abstract(Serial port communication library)
    This unit contains a class that implements serial port communication
    for Windows, Linux, Unix or MacOSx. This class provides numerous methods with
    same name and functionality as methods of the Ararat Synapse TCP/IP library.

    The following is a small example how establish a connection by modem (in this
    case with my USB modem):
    @longcode(#
    ser:=TBlockSerial.Create;
    try
    ser.Connect('COM3');
    ser.config(460800,8,'N',0,false,true);
    ser.ATCommand('AT');
    if (ser.LastError <> 0) or (not ser.ATResult) then
    Exit;
    ser.ATConnect('ATDT+420971200111');
    if (ser.LastError <> 0) or (not ser.ATResult) then
    Exit;
    // you are now connected to a modem at +420971200111
    // you can transmit or receive data now
    finally
    ser.free;
    end;
    #)
    }
  • jmgjmg Posts: 15,173
    edited 2015-04-09 15:30
    This Library can do Serial on the RBP2 side

    Ararat Synapse FPC/Lazarus Port.

    http://www.ararat.cz/synapse/doku.php/start
      ser:=TBlockSerial.Create;
      try
        ser.Connect('COM3');
        ser.config(460800,8,'N',0,false,true);
    ...
      finally
        ser.free;
      end;
    

    Looks deceptively simple - just like a PC :)
    - does that work on a Pi2, and what baud values can it run to, on a Pi2 ?

    (I found earlier web mentions of an OS patch for 4MBd, but paybe Pi2 includes that as shipped )

    For testing serial ports at higher Bauds, I create large files of 0x55 ("U") and send a couple of seconds worth, while measuring the TX line with a Frequency Counter. That reveals any 'bonus' stop bits and gives the supported streaming speed, for that requested BAUD rate. It also shows Baud rounding effects.
    Most USB-Uarts can accept any baud value, and they round (in various ways) to the 'close' practical value. I think Pi2 is more restrictive on baud-values.
  • Bob Lawrence (VE1RLL)Bob Lawrence (VE1RLL) Posts: 1,720
    edited 2015-04-13 23:44
    My little test program is working.

    Test 1:I sent Bytes from the Prop , converted them to Hex and displayed them on the RBP Pascal test program .
    Test 2 : I sent ASCII text from the prop (default Full Serial Duplex demo program message) and was able to receive and display it on the RBP Pascal test program .

    ASCII Text Demo:
    attachment.php?attachmentid=113881&d=1428993827

    .
    488 x 558 - 18K
  • jmgjmg Posts: 15,173
    edited 2015-04-14 00:28
    My little test program is working.
    .
    Cool, now you now I'm going to ask ;) - how high can the BAUD be set, and what sustained flow (one and two way) can you achieve ? PropBASIC Serout I think can go up to ~ 4MBd
  • Bob Lawrence (VE1RLL)Bob Lawrence (VE1RLL) Posts: 1,720
    edited 2015-04-15 19:53
    Baud rates selectable in the Progam:

    Rates: array[0..MaxRates, 0..1] of cardinal =
    (
    (0, B0),
    (50, B50),
    (75, B75),
    (110, B110),
    (134, B134),
    (150, B150),
    (200, B200),
    (300, B300),
    (600, B600),
    (1200, B1200),
    (1800, B1800),
    (2400, B2400),
    (4800, B4800),
    (9600, B9600),
    (19200, B19200),
    (38400, B38400),
    (57600, B57600),
    (115200, B115200),
    (230400, B230400)



    BCM2835 Doc:
    https://www.raspberrypi.org/wp-content/uploads/2012/02/BCM2835-ARM-Peripherals.pdf

    Auxiliaries: UART1 P8
    UART - P175
    USB 15 - P 200

    The baud rate is dependent on the clock rate thus you need to make adjustments if you use the over RBP2 over clocking feature .
    ======================================================================
    From My Book ( Raspberry Pi Hardware Reference)

    - Raspberry Pi console Baud Rate : 115200
    - Tested with no parity and 1 stop bit.

    = 11,250 bytes per second unless you use a parity bit which will reduce it to 10,472.7 Bytes/sec

    (Baud Formula Pict From the Book noted above)
    attachment.php?attachmentid=113902&d=1429152015

    =======================================================================
    @ jmg

    re: how high can the BAUD be set, and what sustained flow (one and two way) can you achieve ? PropBASIC Serout I think can go up to ~ 4MBd

    Does that answer your question or is there some other test you require?
    1013 x 415 - 60K
  • jmgjmg Posts: 15,173
    edited 2015-04-15 20:26
    Rates: array[0..MaxRates, 0..1] of cardinal =
    (
    (0, B0),
    (50, B50),
    (75, B75),
    (110, B110),
    (134, B134),
    (150, B150),
    (200, B200),
    (300, B300),
    (600, B600),
    (1200, B1200),
    (1800, B1800),
    (2400, B2400),
    (4800, B4800),
    (9600, B9600),
    (19200, B19200),
    (38400, B38400),
    (57600, B57600),
    (115200, B115200),
    (230400, B230400)

    Does that answer your question or is there some other test you require?

    Thanks, more tests depends on how deep you want to dig... :)

    ( Linux is somewhat behind USB-UARTS in the baud handling.)

    I found other links, where 4MBd is mentioned,
    http://stackoverflow.com/questions/19371438/setting-linux-serial-baud-rate-higher-than-4-mega-baud
    and this mentions version upgrades..
    http://fw.hardijzer.nl/?p=138

    Not sure if Pi2 comes with mentioned support for init_uart_clock built in, one would hope it has latest changes.
    The highest confirmed speed I have seen is 4MBd (Pi, not Pi2) but there is also chatter from some who want to go faster - so someone may have cracked it.

    The FIFOs are not large in Pi, so high speed needs care on large payloads, but the HW itself some claim is set-able to ~ 25MBd. (maybe more on Pi2?)

    I also find this
    https://www.raspberrypi.org/forums/viewtopic.php?t=73673&p=596997

    says this
    ["Wed Aug 13, 2014 3:38 pm
    Above 115200 kbps, these values are supported by stty: 230400, 460800, 500000, 576000, 921600, 1000000, 1152000, 1500000, 2000000, 2500000, 3000000, 3500000 and 4000000.

    Reference: coreutils.info section 19.2.7 Special settings. Use "info stty" to read the built-in info file."]


    & this thread
    https://www.raspberrypi.org/forums/viewtopic.php?f=44&t=17559
    has mentions of 4MBd tests
    ["After reading around, I did some testing to see what the maximum achievable baud rate is. Using the latest stable raspbian build (3.6.11+) and [B]editing init_uart_clock [/B]in /boot/config.txt, I was able to get up to [B]4Mbaud read speeds[/B]. However, past that point it seems that the linux OS stops support, as bits/termios.h has __MAX_BAUD at 4Mbaud"]
Sign In or Register to comment.