I would like to know if PIO is supported for single board computers like Raspberry Pi and Beaglebone. I haven’t been able to find many resources for it. Also if there are any on going projects for it, I’d like to contribute.
PlatformIO is currently not capable of cross-compiling a program for a Raspberry Pi / Linux ARM from a regular desktop PC. (see here).
On the other hand, if you have a real Raspberry Pi on hand, you can use PIO Remote to use it as the machine that runs the compiler and outputs a native binary.
If you meant whether you can build a microcontroller on a Raspberry Pi, e.g., for an Arduino, then most likely yes, if the package is available for Linux ARM. For example, you can create a firmware for an Arduino Uno just fine because toolchain-atmelavr is available.
Thank you for the reply. I was meaning to get code cross compiled for the Beagle Bone Black(As that is the one I currently have). Would it be possible to integrate it into PlatformIO if we get the toolchain working? I know it might be a farfetched goal but I would like to know if it’s possible.
If you have a self contained toolchain / buildroot for the board, where PlatformIO can just invoke their arm-linux-gnueabihf-gcc or whatever to generate a valid program, sure.
You can
- fork https://github.com/platformio/platform-linux_arm
- fixup the location of the package (defined here,
"version": "symlink://path/to/your/toolchain
), with an appropriatepackage.json
see here - fixup the compiler tuple here
And then try to compile a simple hello world program.
It’s funny, because reading the platform code now and looking at the referenced package in the registry, it appears that there is one cross-compiling toolchain uploaded, that runs on Mac OS and compiles for arm-willtm-linux-gnueabi
, which Google references against a BeagleBone Black. But the issue states no cross-compilation is in place.
I managed to get a cross-compiler setup and was able to compile a hello world program and run it on my target system. Although I am unable to follow these steps to integrate with platform io. I am unable to create a project without selecting the board(I have tried to setup the project with RPi devices but it gives an error, maybe because wiringpi is deprecated). Any help is apprecated.
Can you also setup a project without wiringpi by omitting the framework
. I.e., try a platformio.ini
of e.g. just
[env:raspberrypi_3b]
platform = linux_arm
board = raspberrypi_3b
Works, managed to setup the project, but how do I make it use my local fork?
You can refer to modified platforms in the plaformio.ini
by e.g. a github URL or a local path, see docs
[env:raspberrypi_3b]
platform = symlink:///home/myuser/modifed_platform
; or e.g.
; platform = https://github.com/myuser/platform-linux_arm.git
board = raspberrypi_3b
I have set up most things where it is able to identify my tool chain as well as the custom platform but I’m stuck at
Could be because the original platform was only supported for Mac OS. How do I configure it to work with windows?
What is the section for the gcc-linaro package in the platform’s platform.json
file? I thought you’d redefine location of the existing toolchain-gccarmlinuxgnueabi
package to the toolchain that compile for the BeagleBone. Like,
"toolchain-gccarmlinuxgnueabi": {
"type": "toolchain",
"owner": "platformio",
"version": "symlink:////path/to/your/toolchain"
},
with the pointed-to directory having a package.json
like linked to here but with windows_amd64
in the “system” array to signal it’s compatible to run on Windows x64.
I seem to have found some success. I was able to get the tool chain detected. I was able to run the ‘pio run’ command and it wass successful. Although it seems to have generated a program.exe. I guess I’ll have to modify some build parameters(I am yet to set the hardware parameters). What do you think?
‘pio run’ output for reference:
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/linux_arm/beaglebone_black.html
PLATFORM: Linux ARM (1.6.0) > Beagle Bone Black
HARDWARE: BCM2835 1000MHz, 512MB RAM, 512MB Flash
PACKAGES:
- toolchain-gcc-i686-mingw32 @ 1.0.0
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 0 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
`.pio\build\beaglebone_black\program.exe' is up to date.
Checking size .pio\build\beaglebone_black\program.exe
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM: [ ] 0.0% (used 308 bytes from 536870912 bytes)
Flash: [ ] 0.0% (used 1321 bytes from 536870912 bytes)
========================================================== [SUCCESS] Took 0.75 seconds ==========================================================
Please don’t forget that sometimes one needs to download the root filesystem from single board computers. This is typically needed when the project uses a library which is not included in the default system image but can be installed from a repository. Then I install that library to the SBC and download the sysroot.
Would be nice to do it via PlatformIO and not through manual commands over SSH connection.
I did realize this when I tried to run my binary but came across a GLIBC issue. I was going to compile using ‘sysroot’ but got the proper tool chain setup. Will I need to do it for other purposes too?
Update:
Progress till now:
- I am able to run
pio run
to generate an executable i.eprogram.exe
. This is actually an elf with .exe extension. I was able to scp it to the beagle bone black and execute it
Next Steps:
- Need to modify build parameters to generate a proper elf for execution on target platform
- Setup accurate board details
- Configure for direct upload to board, execution and output logs
Mhm, seems like it has set $PROGSUFFIX
to ".exe"
somehow. You can get rid of that extension by adding
PROGSUFFIX = "",
in this section here
The name of that toolchain is confusing. The toolchain name should be for the target architecture, not the host architecture. Since you’re compiling for an ARM Linux system, the original toolchain name toolchain-gccarmlinuxgnueabi
was already fitting well.
Update:
Progress till now:
- Now executable is created without .exe extension
- Renamed the toolchain to original name
- Able to monitor board on COM port with proper
monitor_speed
and echoes can be seen from board on the monitor terminal of platform io
Next Steps:
- Need to figure out how to upload (either via ssh or through serial)
- Setup Monitoring for the board
For uploading, the platform-linux_arm currently doesn’t even have the Upload
target defined in the main.py
. You can see the pattern here to add it into main.py
. You can freely define the name for a upload_protocol
, e.g. ssh
. The board definition has to mirror that as supported. You can then make it such that the UPLOADCMD
is essentially scp $SOURCE $UPLOADPORT
, with $SOURCE
being subsituted for e.g. .pio/build/beagleboneblack/program
and $UPLOADPORT
(equivalent to upload_port = ...
in the platformio.ini
) to e.g. beagleboneuser@beagleboneip:/home/beagleboneuser/program
or whatever.
Capturing the output of the program might be a bit trickier, since essentially one would have to login via SSH and execute the binary. Same goes for remote debugging, requiring a gdb-server on one side and a gdb-multiarch similiar on the PC side.