Po-util: The Ultimate Local Particle Experience for Linux and macOS


#22

@timx

On the Fedora virtual machine I get this when running sestatus:

[nrobinson@localhost po-util]$ sestatus 
SELinux status:                 enabled
SELinuxfs mount:                /sys/fs/selinux
SELinux root directory:         /etc/selinux
Loaded policy name:             targeted
Current mode:                   enforcing
Mode from config file:          error (Permission denied)
Policy MLS status:              enabled
Policy deny_unknown status:     allowed
Max kernel policy version:      30

When I use which and strace, I get:

[nrobinson@localhost po-util]$ which arm-none-eabi-gcc
/usr/local/bin/arm-none-eabi-gcc
[nrobinson@localhost po-util]$ strace arm-none-eabi-gcc
execve("/usr/local/bin/arm-none-eabi-gcc", ["arm-none-eabi-gcc"], [/* 49 vars */]) = -1 ENOENT (No such file or directory)
write(2, "strace: exec: No such file or di"..., 40strace: exec: No such file or directory
) = 40
exit_group(1)                           = ?
+++ exited with 1 +++

I’m going to see what happens when I follow this guide.

Edit:
No change after changing SELinux to permissive mode.

Edit:
I get similar results on Arch for strace:

execve("/usr/local/bin/arm-none-eabi-gcc", ["arm-none-eabi-gcc"], [/* 19 vars */]) = -1 ENOENT (No such file or directory)
write(2, "strace: exec: No such file or di"..., 40strace: exec: No such file or directory
) = 40
exit_group(1)                           = ?
+++ exited with 1 +++

Edit:
This problem has also happened in the past on Ubuntu (14.04) on Travis CI.

However, Circle CI (Also Ubuntu 14.04) does not have any problems.

Neither does my Ubuntu VPS (16.04), which is able to use po-util just fine.


#23

I Googled and found an article that says you can get the not found message if one of the dependent libraries isn’t available. I guess that attempting to execute the compiler causes a cascade load of other modules and it’s one of those that wasn’t found.

Ref: https://ubuntuforums.org/showthread.php?t=2183052

I therefore tried the following on one of my Centos 7 VMs (64 bit):

Downloaded https://launchpad.net/gcc-arm-embedded/5.0/5-2016-q2-update/+download/gcc-arm-none-eabi-5_4-2016q2-20160622-linux.tar.bz2
unzipped it

[root@c7va bin]# ./arm-none-eabi-gcc
-bash: ./arm-none-eabi-gcc: /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory

[root@c7va bin]# strace ./arm-none-eabi-gcc
execve("./arm-none-eabi-gcc", ["./arm-none-eabi-gcc"], [/* 24 vars */]) = -1 ENOENT (No such file or directory)
write(2, "strace: exec: No such file or di"..., 40strace: exec: No such file or directory
) = 40
exit_group(1)                           = ?
+++ exited with 1 +++

[root@c7va bin]# file arm-none-eabi-gcc
arm-none-eabi-gcc: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.8, stripped

yum install glibc.i686

[root@c7va bin]# ./arm-none-eabi-gcc
arm-none-eabi-gcc: fatal error: no input files
compilation terminated.

So I was able pretty much reproduce the error that you get. That last command suggests that the code can now be loaded and it simply needs an input file. The reason why I installed glibc.i686 was because it was one of the packages that I used to install when I was building my own Docker containers for compiling the Particle firmware. That was 18 months ago so I’ve forgotten why I had to do it but this is probably why :slight_smile:


#24

@timx
Thank you for your help. Installing the glibc.i686 package fixed the arm-none-eabi-gcc part of the problem, but I also had to install vim-common to provide the xxd command, and perl-Archive-Zip-1.58-1.fc24.noarch to provide to crc32 command. Installing these 3 extra packages makes po-util work perfectly on my Fedora virtual machine.

I suspect that to fix the problem on Arch, I will have to install something like glibc.

Update:
Installing lib32-glibc, vim and yaourt with pacman and installing perl-archive-zip from yaourt worked for Arch.

Update:
Installing the libc6-i386 package on Ubuntu fixes the problem for Travis CI. :smile:

I have added these packages to the installation part of po-util, and it should now work on all of these distributions. :smile:

Update:

I think arm-none-eabi-gcc requires the 32bit libraries for C.


[SOLVED] Arm-none-eabi-gcc not found when building firmware on Linux
#25

I just made a guide on Hackster about po-util. Read it here https://www.hackster.io/nrobinson2000/use-po-util-to-build-code-for-particle-devices-37629f


#26

Po-util 3.0 released!

I have now built a Library manager into po-util. It lets you download and use libraries hosted on GitHub easily in multiple project directories by creating symbolic links. Here is a preview of the commands for the Libray manager:

"po library": The Particle Library manager for po-util.
                Libraries are kept in ~/.po-util/lib

Commands:
  get          Download a Particle Library from GitHub and optionally name it.
  install      Example:
                      po lib get https://github.com/user/libraryName libraryName

  add          Add a downloaded library to a po-util project.
  import       Libraries are added in the firmware directory as soft links.
               Example:
                      po lib add libraryName

  remove       Remove a library from a po-util project.
  rm           Just the soft links are deleted.
               Example:
                      po lib rm libraryName

  create       Create a library from C++ files in the project directory.
               Example:
                      po lib create someLibrary

  purge        Uninstall (delete) a library from ~/.po-util/lib
               Example:
                      po lib purge someLibrary

  list         Show all libraries in ~/.po-util/lib

  help         Show this help documentation.

I have also fixed some minor bugs.

UPDATE:
I made a post about how to use the library manager to download a library available on the Web IDE.


#27

I can’t heart this enough!


#28

Thanks. The only thing po-util is missing now is a Windows version, although people should just be using GNU/Linux anyway.


#29

I have added support for Atom Build shortcuts for po-util. The shortcuts are interpreted by the atom build package, and the corresponding po-util command is run.

Atom Build Shortcuts:
  Build        CTRL-ALT-1   These shortcuts allow you     This requires the
  Flash        CTRL-ALT-2   to run common po-util         "build" package for
  Clean        CTRL-ALT-3   commands quickly while        Atom.  Get it with:
  DFU          CTRL-ALT-4   using Atom.                   "apm install build"
  OTA          CTRL-ALT-5

As always, po-util can be installed with:

curl -fsSLO https://raw.githubusercontent.com/nrobinson2000/po-util/master/po-util.sh
./po-util.sh install

Or if you already have po-util just run:

po update

#30

UPDATE:

Po-util now supports building firmware for Raspberry Pi and easily flashing it Over The Air.


#31

UPDATE:

Po-util can now be installed with Homebrew. I recommend all users on macOS to switch to the Homebrew version. It can be installed by doing:

$ brew tap nrobinson2000/po
$ brew install po
$ po install

Delete ~/po-util.sh and the po alias in your ~/.bashrc to use the new version.


#32

I have just written a nice manpage for the Homebrew Edition of po-util.


#33

I have updated the library manager commands to automatically add and remove includes to and from the firmware/main.cpp file when a library is added to a project, just like how the Web IDE adds includes when libraries are added.


#34

Hi,
First, thanks a lot for this amazing tool. I finally managed to get everything as I wanted : to be able to work off-line.
Three requests/questions regarding your tool:

  1. When adding a library that has more than one set of .cpp/.h, only the files named by the library is imported. Example: I’m fetching Adafruit_SSD1306 from https://github.com/pkourany/Adafruit_SSD1306.git and I had to manually add the symbolic links to the Adafruit_GFX.* files.
  2. Not sure if you can do something about this one. The following library: Adafruit_GFX has its file within a firware directory which doesnt’t seem to be consistent with what you’re expecting. As I want to kept the “git” update available, I don’t want to mess with the directory in ~.po-util/lib.
  3. Adding automatically the header may be fine for some user but in my case, and I shouldn’t be the only one ;), the main.cpp is not where I want to add the headers. So maybe keep this as an option ?

Once again, your tools is pretty amazing, and really usefull !

Yannick


#35

Hi @YbuQc,

It is possible to break up a library into multiple folders. Just cd to ~/.po-util/lib/Adafruit_SSD1306, and run:

$ po lib create

In order to get updates from git you would have to delete the extra libraries created:

$ po lib rm LibName

Update all of your libraries:

$ po lib update

And run:

$ po lib create

Inside of ~/.po-util/lib/Adafruit_SSD1306.

Adding headers automatically was a new feature that I implemented yesterday. I’m sorry it inconveniences you. I will make it a configurable option.

UPDATE:
I have made automatically adding headers to main.cpp an option that can be opted into with po config.

Just do:

$ po update

To update po-util.


#36

Update:

The po manpage is now available on Linux as well.

Common library routines have been made into functions to optimize the script and reduce length.

Any comments or feature requests can be made on this thread or you can create an issue on GitHub.

Po-util: Classic

Po-util: Homebrew Edition


#37

po-util can now download libraries from Particle Libraries 2.0 using particle-cli.

Libraries can be downloaded using the po lib get command, supplying the name of the library instead of a URL to a repository.

Libraries are added to the central library folder ~/.po-util/lib just like Git libraries.

Example:

$ po lib get neopixel

po-util will use particle-cli to download the library because the argument is not a URL.

If you enter an invalid library name, po-util will use particle-cli to search for libraries instead, so that you can find the library you want.

Example:

$ po lib get liquid

Attempting to download liquid using Particle Libraries 2.0...

Checking library liquid...
Library liquid not found

> Found 4 libraries matching liquid
LiquidCrystal 0.0.3 1121 LiquidCrystal on Spark Core
LiquidCrystal_I2C_Spark 1.1.0 816 LiquidCrystal_I2C ported for Spark Core
Adafruit_LiquidCrystal 1.0.2 125 A fork of Adafruit LiquidCrystal library that support i2c / SPI character LCD backpack.
liquid-crystal-spi 0.0.1 88 A Hardware and Software SPI driven LiquidCrystal library for Spark Core.

You can add a library to a project the same way you would add a Git library:

$ po lib add neopixel

Update po-util to get this feature:

$ po update

#38

I’m trying out PO-util, and first off thanks for making this!

I can’t seem to build my project though:

root@tombuntu-VirtualBox:/media/sf_PARTICLE_LOCAL/JazaHub Controller# po init electron mainMashPO

Directory initialized as a po-util project for electron

root@tombuntu-VirtualBox:/media/sf_PARTICLE_LOCAL/JazaHub Controller# ls
binaries  Datasheets  Main  mainMash  mainMashPO  Purgatory  Testing
root@tombuntu-VirtualBox:/media/sf_PARTICLE_LOCAL/JazaHub Controller# cd mainMashPO
root@tombuntu-VirtualBox:/media/sf_PARTICLE_LOCAL/JazaHub Controller/mainMashPO# po electron build

                                                     __      __  __
                                                    /  |    /  |/  |
              ______    ______           __    __  _██ |_   ██/ ██ |
             /      \  /      \  ______ /  |  /  |/ ██   |  /  |██ |
            /██████  |/██████  |/      |██ |  ██ |██████/   ██ |██ |
            ██ |  ██ |██ |  ██ |██████/ ██ |  ██ |  ██ | __ ██ |██ |
            ██ |__██ |██ \__██ |        ██ \__██ |  ██ |/  |██ |██ |
            ██    ██/ ██    ██/         ██    ██/   ██  ██/ ██ |██ |
            ███████/   ██████/           ██████/     ████/  ██/ ██/
            ██ |
            ██ |
            ██/         Building firmware for electron...
    
../../../build/module.mk:229: warning: overriding recipe for target '/media/sf_PARTICLE_LOCAL/JazaHub'
../../../build/module.mk:222: warning: ignoring old recipe for target '/media/sf_PARTICLE_LOCAL/JazaHub'
../../../build/module.mk:229: warning: overriding recipe for target '/root/github/particle/firmware/main/Controller/mainMashPO/bin//JazaHub'
../../../build/module.mk:222: warning: ignoring old recipe for target '/root/github/particle/firmware/main/Controller/mainMashPO/bin//JazaHub'
../../../build/module.mk:238: warning: overriding recipe for target '/media/sf_PARTICLE_LOCAL/JazaHub'
../../../build/module.mk:229: warning: ignoring old recipe for target '/media/sf_PARTICLE_LOCAL/JazaHub'
../../../build/module.mk:238: warning: overriding recipe for target '/root/github/particle/firmware/main/Controller/mainMashPO/bin//JazaHub'
../../../build/module.mk:229: warning: ignoring old recipe for target '/root/github/particle/firmware/main/Controller/mainMashPO/bin//JazaHub'
../../../build/module.mk:262: warning: overriding recipe for target '/media/sf_PARTICLE_LOCAL/JazaHub'
../../../build/module.mk:238: warning: ignoring old recipe for target '/media/sf_PARTICLE_LOCAL/JazaHub'
../../../build/module.mk:261: *** mixed implicit and normal rules: deprecated syntax
../../../build/module.mk:267: warning: overriding recipe for target '/media/sf_PARTICLE_LOCAL/JazaHub'
../../../build/module.mk:262: warning: ignoring old recipe for target '/media/sf_PARTICLE_LOCAL/JazaHub'
../../../build/module.mk:266: *** mixed implicit and normal rules: deprecated syntax
../../../build/module.mk:267: warning: overriding recipe for target '/root/github/particle/firmware/main/Controller/mainMashPO/bin//obj/%.o'
../../../build/module.mk:262: warning: ignoring old recipe for target '/root/github/particle/firmware/main/Controller/mainMashPO/bin//obj/%.o'
../../../build/module.mk:283: warning: overriding recipe for target '/media/sf_PARTICLE_LOCAL/JazaHub'
../../../build/module.mk:267: warning: ignoring old recipe for target '/media/sf_PARTICLE_LOCAL/JazaHub'
../../../build/module.mk:282: *** mixed implicit and normal rules: deprecated syntax
../../../build/module.mk:283: warning: overriding recipe for target '/root/github/particle/firmware/main/Controller/mainMashPO/bin//obj/%.o'
../../../build/module.mk:267: warning: ignoring old recipe for target '/root/github/particle/firmware/main/Controller/mainMashPO/bin//obj/%.o'
make[1]: Circular /media/sf_PARTICLE_LOCAL/JazaHub <- /media/sf_PARTICLE_LOCAL/JazaHub dependency dropped.
make[1]: Circular /media/sf_PARTICLE_LOCAL/JazaHub <- /media/sf_PARTICLE_LOCAL/JazaHub dependency dropped.
make[1]: Circular /media/sf_PARTICLE_LOCAL/JazaHub <- /media/sf_PARTICLE_LOCAL/JazaHub dependency dropped.
make[1]: Circular /media/sf_PARTICLE_LOCAL/JazaHub <- /media/sf_PARTICLE_LOCAL/JazaHub dependency dropped.
build.mk:63: *** "No sources found in /media/sf_PARTICLE_LOCAL/JazaHub Controller/mainMashPO/firmware/".  Stop.
../../../build/recurse.mk:11: recipe for target 'user' failed
make[1]: *** [user] Error 2
../build/recurse.mk:11: recipe for target 'modules/electron/user-part' failed
make: *** [modules/electron/user-part] Error 2
root@tombuntu-VirtualBox:/media/sf_PARTICLE_LOCAL/JazaHub Controller/mainMashPO# 

_
_
Any idea what I might be doing wrong?

I haven’t made any changes to the default main.cpp file that po init created


#39

@jaza_tom
It could be that it doesn’t like that your folder has a space in it. Never really seen this error before but I would definitely try renaming JazaHub Controller.

Update:
I just confirmed this on my machine, a directory path with a space in it will produce this error. I’ll try to find a fix for this. In the meantime I think po-util will work if you rename the JazaHub Controller directory to something more friendly like JazaHub-Controller.


#40

That did it. Thanks!!!


#41

Hope you enjoy using po-util for your projects! I’d recomend looking into the library manager. It’s pretty slick, and it can use libraries from GitHub or Particle Libraries 2.0.