Compiling Edge Impulse Locally

Local or Cloud Installation

I was wondering what prerequisites people are finding work well together for local installations of Edge Impulse on Linux either Ubuntu or Debian?

Background

Someone, probably @janjongboom has done a lot of work showing how to run Edge Impulse locally on Windows, Mac and Linux. See the docs at https://docs.edgeimpulse.com/docs/running-your-impulse-locally-1

I am always trying to simplify coding for my students. I never know if I am doing things the best way. I just try lots of things and see what works best for me! So far, I am having limited results using these:

For the Arduino Client

  1. This worked
 curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh     

For MBED

  1. This worked
python3 -m pip install mbed-cli

For Zephr and Nordic.

Looks like you need a complete package that works well together. Info here and here

  1. not tried yet but it says for nrf-connect try (info above). Not sure if this is nrf-connect or a prerequisite for it
wget http://mirrors.kernel.org/ubuntu/pool/main/d/device-tree-compiler/device-tree-compiler_1.4.7-1_amd64.deb
sudo dpkg -i device-tree-compiler_1.4.7-1_amd64.deb
  1. For West this works, one time it did not like the second command
pip3 install --user west    
west init -l  
  1. not tried yet but this looks useful for a full prerequisite install
sudo apt-get install --no-install-recommends git cmake ninja-build gperf \
  ccache dfu-util device-tree-compiler wget \
  python3-pip python3-setuptools python3-tk python3-wheel xz-utils file \
  make gcc gcc-multilib

  1. Segger Dev tools (I will not need these for work in the cloud) link here

For HiMax

  1. (You need a license, so not going there) info here

For SiliconLabs Thunderboard Sense 2

  1. You need simplicity studio link here This installs really nicely on windows so probably wont install this on the cloud.

For C and C++ and other boards

From the docs here . “You need * GNU Make - to build the application. make should be in your PATH. A modern C++ compiler. The default LLVM version on macOS works, but on Linux upgrade to LLVM 9 (installation instructions).”

For GNU, there are so many installations I am not sure which is best for Edge Impulse.

  1. for Just Make and GCC
sudo apt-get install --no-install-recommends make gcc gcc-multilib

  1. but this also seems to install make and gcc :worried:
sudo apt-get install --no-install-recommends  build-essential
  1. For LLVM I tried but without success
curl -o /var/lib/apt/dazzle-marks/llvm.gpg -fsSL https://apt.llvm.org/llvm-snapshot.gpg.key

Wondering if anyone has all the main prerequisites but not lots of other installs that work well together for use with Edge Impulse local or cloud installation on Linux? Perhaps @aurel ?

@Rocksetta This should work on Linux:

$ sudo apt install -y build-essential
$ bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"
$ cd example-standalone-inferencing
$ CC=clang CXX=clang++ make -j

The latter line could be just make -j depending on whether there already was a working gcc/g++ on the system.

1 Like

So here is what I am working on, the repository is at

and a live Gitpod will be generated using this url (You need a Github login to use Gitpod, and best to use a new browser window as it will sleep when you move between tabs)

I could not get @janjongboom suggestions above working, but by trial and error got something working. Here is the main part of my Docker

RUN apt-get update \
    && DEBIAN_FRONTEND=noninteractive  apt-get install -y --no-install-recommends build-essential gcc-arm-none-eabi make \
    && bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" \
        && install-packages \
        clang \
        clangd \
        clang-format \
        clang-tidy \
        gdb \
        lld  \
    && apt-get update 

and here is the main install part of the .gitpod.yml file. The homebrew is just a location already on the Environment PATH.

              cd /home/linuxbrew/.linuxbrew                                                                                 &&
              curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh                       &&
              python3 -m pip install mbed-cli  west                                                                         &&
              ./arduino-build.sh                                                                                            &&

What was really helpful is Edge Impulse’s arduino-cli installation script installs the correct arm-none-eabi-gcc compiler.

So you can test the install with: (Note weird Arduino syntax no “–”)

arduino-cli version
west --version
mbed-cli --version
make --version
arm-none-eabi-gcc --version


Looks like I installed arm-none-eabi-gcc twice since PATHS are confusing using Gitpod, but as long as things work.

I will probably be breaking things for the next few weeks as I make changes. But it auto loads most of the Local build structures, so the concept is:

  1. upload the Edge Impulse to the correct compile folder and unzip it
  2. build (see bash files typically labelled “a01-build.sh” for help on how to build)
  3. download the .bin file typically in the generated “build” folder to your flash to your board.

I will make a video when it works better. (Eta Compute presently not working)
Today, trying to add Simplicity studio command line. (I will probably break it. :grin:)

Here is an image of the important file structure

If anyone sees anything that could be improved, specifically in the Docker file that would be appreciated. For security reasons “sudo” can not be used in the live webpage, so all “sudo” installs happen in the Docker file.

2 Likes

With the release of the Sony Spresense Edge Impulse Github at

and my own issues getting Edge-Impulse-cli installed on my school computers (and at home) wondering if anyone else has the experience and understands the benefit of cloud dev sites like gitpod.io

Be interesting to get the Spresense working but I might need a bit of help.

The github is here https://github.com/hpssjellis/my-gitpod-of-edge-impulse

and loading the gitpod (needs a github login, and takes about 10 minutes to fully load, so right click and open in a new window so it can do it’s thing) link is

https://gitpod.io/#github.com/hpssjellis/my-gitpod-of-edge-impulse

I already have most of the other boards loaded, with varying success. A gitpod could do all the compiling of local builds. You would still need to figure out how to install the final .bin file, so back to my issues with the edge-impulse-cli.

This post went full circle, LOL.

Anyone joining this topic, gitpod.io is fairly easy to understand. Since you can’t do sudo admin stuff all sudo commands are in the .gitpod.dockerfile

Mine doesn’t really do much link here

FROM gitpod/workspace-full:latest

USER root

RUN apt-get update \
    && DEBIAN_FRONTEND=noninteractive  apt-get install -y --no-install-recommends build-essential gcc-arm-none-eabi make  \
    && bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" \
        && install-packages \
        clang \
        clangd \
        clang-format \
        clang-tidy \
        gdb \
        lld  \
    && apt-get update 



USER gitpod
  
RUN mkdir -p /home/gitpod/logs                                                                            \ 
    && touch /home/gitpod/logs/myDockerlog.txt                                                            \
    && echo "Installation start, made some folders in /home/gitpod" >> /home/gitpod/logs/myDockerlog.txt  \
    && echo "Installation end"                                      >> /home/gitpod/logs/myDockerlog.txt  
   

# Give back control
USER root


# Cleaning
RUN apt-get clean  && rm -rf /var/cache/apt/* && rm -rf /var/lib/apt/lists/* && rm -rf /tmp/*

The magic comes from the .gitpod.yml link here It does all your pip style installs: Here is mine

 
image:
  file: .gitpod.dockerfile

ports:
- port: 8080

tasks:
- init:       mkdir /workspace/my-gitpod-of-edge-impulse/logs                                                                    &&
              touch /workspace/my-gitpod-of-edge-impulse/logs/gitpod-install-log.txt                                             &&
       

              echo "Starting .gitpod.yml installation" &>>  /workspace/my-gitpod-of-edge-impulse/logs/gitpod-install-log.txt     &&
 
                 
     
              cd /workspace/my-gitpod-of-edge-impulse/edge-impulse/local-build-firmware/portenta                             &&
              git clone https://github.com/edgeimpulse/example-portenta-lorawan.git                                          &&
              chmod +x a00-get-lora-example.sh                                                                               &&
              chmod +x a01-portenta.sh                                                                                       &&
              chmod +x a02-portenta-from-scratch.sh                                                                          &&
              chmod +x arduino-build.sh                                                                                      &&
              chmod +x arduino-build-portenta.sh                                                                             &&
              cp arduino-build.sh /home/linuxbrew/.linuxbrew/arduino-build.sh                                                &&            
                 
     
              
              cd /home/linuxbrew/.linuxbrew                                                                                 &&
              curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh                       &&
              python3 -m pip install mbed-cli  west  pyserial==3.4 inquirer==2.7.0                                          &&         
                 
                 
                 
              cd /workspace/my-gitpod-of-edge-impulse/edge-impulse/local-build-firmware/c++                                  &&
              git clone https://github.com/edgeimpulse/example-standalone-inferencing.git                                    &&
              chmod +x a01-cpp.sh                                                                                            &&
              
              cd /workspace/my-gitpod-of-edge-impulse/edge-impulse/local-build-firmware/c                                    &&
              git clone https://github.com/edgeimpulse/example-standalone-inferencing-c.git                                  &&
              chmod +x a01-c.sh                                                                                              &&
              
              cd /workspace/my-gitpod-of-edge-impulse/edge-impulse/local-build-firmware/nano33bleSense                       &&
              chmod +x a01-nano.sh                                                                                           &&
              chmod +x arduino-build-nano33.sh                                                                               &&

                           
              
              
              cd /workspace/my-gitpod-of-edge-impulse/edge-impulse/local-build-firmware/etaCompute                           &&
              git clone https://github.com/edgeimpulse/example-standalone-inferencing-ecm3532.git    eta-compile             &&         
              mv a01-eta-sense.sh eta-compile/                                                                               &&        
              mv a02-eta-vision.sh eta-compile/                                                                              &&         
              cd eta-compile                                                                                                 &&          
              chmod +x a01-eta-sense.sh                                                                                      &&        
              chmod +x a02-eta-vision.sh                                                                                     &&   
                            
                            
              cd /workspace/my-gitpod-of-edge-impulse/edge-impulse/local-build-firmware/siliconLabs                                   &&
              git clone https://github.com/edgeimpulse/example-standalone-inferencing-silabs-tb-sense-2.git   silicon-labs-compile    &&     
              mv a01-siliconLabs.sh   silicon-labs-compile/                                                                           &&
              cd silicon-labs-compile                                                                                                 &&
              mkdir ei-workspace                                                                                                      &&
              chmod +x a01-siliconLabs.sh                                                                                             &&
                        
                            
              cd /workspace/my-gitpod-of-edge-impulse                                                                       &&
              cd /workspace/my-gitpod-of-edge-impulse/edge-impulse/local-build-firmware/nordic                              &&
              git clone https://github.com/edgeimpulse/firmware-nrf52840-5340-dk   nordic-compile                           &&     
              mv a01-nordic-nrf5280.sh   nordic-compile/                                                                    &&
              mv a02-nordic-nrf5340.sh   nordic-compile/                                                                    &&
              cd nordic-compile                                                                                             &&
              chmod +x a01-nordic-nrf5280.sh                                                                                &&
              chmod +x a02-nordic-nrf5340.sh                                                                                &&
              
              
              
                                         
              cd /workspace/my-gitpod-of-edge-impulse/edge-impulse/local-build-firmware/mbed                                  &&
              mbed import https://github.com/edgeimpulse/example-standalone-inferencing-mbed                                  &&
              mv a01-mbed-build.sh   example-standalone-inferencing-mbed/                                                     &&
              cd example-standalone-inferencing-mbed                                                                          &&
              chmod +x a01-mbed-build.sh                                                                                      &&
       

              cd /workspace/my-gitpod-of-edge-impulse/edge-impulse/local-build-firmware/sony-spresense                        &&
              git clone https://github.com/edgeimpulse/example-standalone-inferencing-spresense.git                           &&
              mv a01-spresense.sh   example-standalone-inferencing-spresense/                                                 &&
              cd example-standalone-inferencing-spresense                                                                     &&
              chmod +x a01-spresense.sh                                                                                       &&

              
              
              cd /workspace/my-gitpod-of-edge-impulse                                                                         && 
              ./edge-impulse/local-build-firmware/portenta/arduino-build-portenta.sh                                          &&
              git clone https://github.com/sudar/Arduino-Makefile                                                             &&
              mkdir z-ARDUINO-LIBRARIES                                                                                       &&
              ln -s /home/gitpod/Arduino/libraries z-ARDUINO-LIBRARIES                                                        &&
              mkdir z-ARDUINO-CORES                                                                                           &&
              ln -s /home/gitpod/.arduino15/packages/arduino/hardware   z-ARDUINO-CORES                                       &&             
             arduino-cli version                                                                                              &&
             west --version                                                                                                   &&
             mbed-cli --version                                                                                               &&
             make --version                                                                                                   &&
             arm-none-eabi-gcc --version                                                                                      &&

             echo "Ending .gitpod.yml installation"  &>>   /workspace/my-gitpod-of-edge-impulse/logs/gitpod-install-log.txt
             
             
  command:   echo "Starting this docker"             &>>   /workspace/my-gitpod-of-edge-impulse/logs/gitpod-install-log.txt    &&
             cd /home/linuxbrew/.linuxbrew                                                                                     &&
             curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh                           &&  
             cd /workspace/my-gitpod-of-edge-impulse                                                                           && 
             ./edge-impulse/local-build-firmware/portenta/arduino-build-portenta.sh                                            &&  
             arduino-cli version                                                                                               &&
             west --version                                                                                                    &&
             mbed-cli --version                                                                                                &&
             make --version                                                                                                    &&
             arm-none-eabi-gcc --version                                                                                       &&
             echo "Ending this docker implementation"  &>>   /workspace/my-gitpod-of-edge-impulse/logs/gitpod-install-log.txt
             
             
           

Just like a bash script running everything you need. The nice thing is all your students or people on a zoom meeting are then running the exact same setup and should have the exact same issues. This by far outweighs the problems with designing the Gitpod.io

I am just stuck on the final steps of getting all these C++ programs working on all these different environments. Would be great if someone who knows, could give me some hints.

The github link is https://github.com/hpssjellis/my-gitpod-of-edge-impulse

The Gitpod active link is

https://gitpod.io/#github.com/hpssjellis/my-gitpod-of-edge-impulse

It is not very userfriendly yet as I don’t know how to run the C++ code.

1 Like