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
The 'machine' module on Raspberry Pi
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: The 'machine' module on Raspberry Pi
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.
I think the options of accessing hardware directly and having an underlying Linux OS are mutually exclusive.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
-
- Posts: 35
- Joined: Fri Apr 12, 2019 8:55 am
Re: The 'machine' module on Raspberry Pi
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
Feel free to use.
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)
Re: The 'machine' module on Raspberry Pi
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 )
(But the `mpbcm2835` module linked above looks heaps better )
-
- Posts: 288
- Joined: Sun May 04, 2014 8:54 am
Re: The 'machine' module on Raspberry Pi
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.
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
"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.
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/
-
- Posts: 969
- Joined: Sat Feb 03, 2018 7:02 pm
Re: The 'machine' module on Raspberry Pi
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.ProudPagan wrote: ↑Fri Apr 26, 2019 2:23 pmThere'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
Feel free to use.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)
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode