Squeak on Raspberry pi

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Squeak on Raspberry pi

marcelo Cortez
hi 

I'm developing over  Raspberry pi  with squeak and i need access to GPIO. 

Questions:

How load FFI on Raspberry pi?
Any link,paper , advice , pdf.
be appreciated.


tia

best 
jmdc

Reply | Threaded
Open this post in threaded view
|

Re: Squeak on Raspberry pi

timrowledge

On 26-12-2013, at 7:11 AM, marcelo Cortez <[hidden email]> wrote:

> hi
>
> I'm developing over  Raspberry pi  with squeak and i need access to GPIO.
>
> Questions:
>
> How load FFI on Raspberry pi?
> Any link,paper , advice , pdf.
> be appreciated.

To get the FFI working for Pi (and indeed other ARM *nix machines) somebody would need to write any needed ARM assembler bits to interface to the apicall and/or libffi and/or whatever the current facility is called. There is some information on what is needed in the vm sources; see http://squeakvm.org/cgi-bin/viewvc.cgi/squeak/trunk/platforms/unix/plugins/SqueakFFIPrims/ and start with 00README. Probably the best place to ask more specific questions about FFI would be the squeak vm-dev list (sign up at http://lists.squeakfoundation.org/mailman/listinfo/vm-dev)

It’s definitely a job I have on my list of TO DO, but not high and there’s plenty of work piled up above it so please feel free to tackle it!

It *might* be easier in the short term to write a vm plugin specifically for the Pi GPIO interface. You can find out quite a bit about the gpio programming fro mthe Pi forums and particularly from the Scratch forum where simplesi has done a great deal of clever stuff by using python to provide a connection for the Scratch remote sensor connection subsystem, and then driving the gpio from pythin. It’s certainly time there was as more direct interface for him to use.

tim
--
tim Rowledge; [hidden email]; http://www.rowledge.org/tim
Strange OpCodes: SBB: Store in Bit Bucket



Reply | Threaded
Open this post in threaded view
|

Re: Squeak on Raspberry pi

douglas mcpherson
I am also interested in FFI for the Pi. Specifically I'm interested in using the Pi's I2C capability. I noticed that my raspbian distro has so.SqueakFFIPrims installed along with other plugins in /usr/lib/squeak/4.10.2-2793. Does this imply that the necessary support is in place?

Note though I loaded Squeak4.4-12327 onto the Pi and installed FFI, but none of the FFI tests pass. The failures are "Unable to find function address" Errors.  "Smalltalk current listLoadedModules" lists SqueakFFIPrims as a loaded external plugin after attempting to run the tests. I can't tell if there is missing functionality in the FFI support or if I got things misconfigured somehow.

The Scratch/python interaction is quite slick. I tried it out and got Scratch to turn some LEDs on and off. In the spirit of PhysicalEtoys, but for Scratch on the Pi, there's also similar Scratch to python connections used here: http://www.pridopia.co.uk/rs-pi-set-scratch.html.  In addition to GPIO examples, they also have I2C and SPI examples. As Tim says, it would be good to have a more direct interface.
 
Doug

On Dec 26, 2013, at 10:54 , tim Rowledge wrote:

>
> On 26-12-2013, at 7:11 AM, marcelo Cortez <[hidden email]> wrote:
>
>> hi
>>
>> I'm developing over  Raspberry pi  with squeak and i need access to GPIO.
>>
>> Questions:
>>
>> How load FFI on Raspberry pi?
>> Any link,paper , advice , pdf.
>> be appreciated.
>
> To get the FFI working for Pi (and indeed other ARM *nix machines) somebody would need to write any needed ARM assembler bits to interface to the apicall and/or libffi and/or whatever the current facility is called. There is some information on what is needed in the vm sources; see http://squeakvm.org/cgi-bin/viewvc.cgi/squeak/trunk/platforms/unix/plugins/SqueakFFIPrims/ and start with 00README. Probably the best place to ask more specific questions about FFI would be the squeak vm-dev list (sign up at http://lists.squeakfoundation.org/mailman/listinfo/vm-dev)
>
> It’s definitely a job I have on my list of TO DO, but not high and there’s plenty of work piled up above it so please feel free to tackle it!
>
> It *might* be easier in the short term to write a vm plugin specifically for the Pi GPIO interface. You can find out quite a bit about the gpio programming fro mthe Pi forums and particularly from the Scratch forum where simplesi has done a great deal of clever stuff by using python to provide a connection for the Scratch remote sensor connection subsystem, and then driving the gpio from pythin. It’s certainly time there was as more direct interface for him to use.
>
> tim
> --
> tim Rowledge; [hidden email]; http://www.rowledge.org/tim
> Strange OpCodes: SBB: Store in Bit Bucket
>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Squeak on Raspberry pi

Eliot Miranda-2
In reply to this post by timrowledge
Hi Tim,


On Thu, Dec 26, 2013 at 10:54 AM, tim Rowledge <[hidden email]> wrote:

On 26-12-2013, at 7:11 AM, marcelo Cortez <[hidden email]> wrote:

> hi
>
> I'm developing over  Raspberry pi  with squeak and i need access to GPIO.
>
> Questions:
>
> How load FFI on Raspberry pi?
> Any link,paper , advice , pdf.
> be appreciated.

To get the FFI working for Pi (and indeed other ARM *nix machines) somebody would need to write any needed ARM assembler bits to interface to the apicall and/or libffi and/or whatever the current facility is called. There is some information on what is needed in the vm sources; see http://squeakvm.org/cgi-bin/viewvc.cgi/squeak/trunk/platforms/unix/plugins/SqueakFFIPrims/ and start with 00README. Probably the best place to ask more specific questions about FFI would be the squeak vm-dev list (sign up at http://lists.squeakfoundation.org/mailman/listinfo/vm-dev)

Actually it is simpler than this, provided one starts from ThreadedFFIPlugin.  This is a replacement for the old FFIPlugin that uses very little assembler, and that in the form of asm statements.  The old FFIPlugin has two main problems, first that it needs a lots of assembler support, and second that it is not reentrant.  The latter follows from the former, in that the marshalling is done to a static buffer, and so making a call while nested will screw the pooch.

ThreadedFFIPlugin in contrast uses alloca to allocate space for outgoing arguments and is hence reentrant and written in C with two asm statements, getsp and setsp.  Better still ThreadedFFIPlugin was written with ARM (and PowerPC) in mind.  It has three subclasses, ThreadedIA32FFIPlugin, ThreadedARMFFIPlugin, & ThreadedPPCBEFFIPlugin.  The first is fully functional (and has been in Cog since its release).  The second two are only a few days away from completion.  Let me invite anyone interested to have a go.

The secret to an alloca based implementation is that alloca, answering a stack-allocated array, provides space for outgoing arguments, so that subsequently calling a function pointer supplies he called function with its arguments.  This is slightly more complicated on an ABI with register arguments, such as ARM or PowerPC.  The extra work is to also marshal into a struct that holds the arguments, and instead of just calling the function pointer, one calls it with enough arguments to fill the register arguments, taken from the struct.

All the structure is there.  All it needs is someone with am ARM and some gumption to fill in the missing pieces.  I know all this works because I wrote (and/or rewrite) the VisualWorks VM's FFI to use alloca, including for ARM and PowerPC platforms.

It’s definitely a job I have on my list of TO DO, but not high and there’s plenty of work piled up above it so please feel free to tackle it!

It *might* be easier in the short term to write a vm plugin specifically for the Pi GPIO interface. You can find out quite a bit about the gpio programming fro mthe Pi forums and particularly from the Scratch forum where simplesi has done a great deal of clever stuff by using python to provide a connection for the Scratch remote sensor connection subsystem, and then driving the gpio from pythin. It’s certainly time there was as more direct interface for him to use.
 
It might.  But someone who understands the ARM ABI could probably get the ThreadedARMFFIPlugin working in a week or less. 

I'll happily answer any and all questions in getting this to work.
--
best,
Eliot