Page 1 of 1
The 'machine' module on Raspberry Pi
Posted: Tue Apr 23, 2019 3:37 pm
by ProudPagan
Hi,
Does anyone know how to build the 'machine' module on a Raspberry Pi running Raspbian or Buildroot?
I know boochow has a bare metal version with SPI and I2C, but I need MicroPython to run inside Buildroot.
Thanks
Re: The 'machine' module on Raspberry Pi
Posted: Tue Apr 23, 2019 5:40 pm
by pythoncoder
As I understand it buildroot has the option of installing a Linux kernel, filesystem and bootloader. If you plan to use it in that mode I'd try the official Unix build. However this does not support machine. Otherwise I guess you'll need to skip the Linux OS options and build one of the baremetal ports.
I think the options of accessing hardware directly and having an underlying Linux OS are mutually exclusive.
Re: The 'machine' module on Raspberry Pi
Posted: Fri Apr 26, 2019 2:23 pm
by ProudPagan
There's a low level RPi C library at
http://www.airspayce.com/mikem/bcm2835/index.html
I could not find anything like the Python RPi.GPIO modules so I am trying to get a MicroPython wrapper working on top of this:
https://github.com/hacksterous/micropyt ... /mpbcm2835
I have tested simple GPIO writes, and it seems to work
Code: Select all
import mpbcm2835
mpbcm2835.init()
#select GPIO17 (RPi-2 pin-P1-11) as output
mpbcm2835.fsel(17, 1)
#write '1'
mpbcm2835.write(17, 1)
#delay of 1000 milliseconds
mpbcm2835.delay(1000)
#write '0'
mpbcm2835.write(17, 0)
Feel free to use.
Re: The 'machine' module on Raspberry Pi
Posted: Sat Apr 27, 2019 1:11 pm
by jimmo
Not sure if this is useful or not (or even a good idea), but depending on what you need from `machine` (e.g. just basic pin control), can you get by with filesystem access to sysfs-gpio? (Write the pin number to `/sys/class/gpio/export` then access `/sys/class/gpio/gpioN/value` )
(But the `mpbcm2835` module linked above looks heaps better
)
Re: The 'machine' module on Raspberry Pi
Posted: Sat Apr 27, 2019 5:34 pm
by Turbinenreiter
The CircuitPython HAL works on Raspberry Pi with Linux, its using CPython tough.
https://learn.adafruit.com/circuitpytho ... x/overview
Having the machine module on Raspberry Pi is definitely possible, but nobody wrote it yet.
Re: The 'machine' module on Raspberry Pi
Posted: Tue Apr 30, 2019 7:58 pm
by pfalcon
"machine" module for Unix port was written 3 years ago:
https://github.com/pfalcon/micropython- ... ne/machine . Obviously, the amount of the code written so far is based on the needs of people who contributed to the module.
Re: The 'machine' module on Raspberry Pi
Posted: Wed May 08, 2019 3:55 pm
by kevinkk525
This looks very promising and recent. But it doesn't conform to the typical machine.Pin interface so needs another wrapper around it to be compatible.