Installation and Programming Blinky Blocks V2 - ProgrammableMatterProject/BlinkyBlocks GitHub Wiki

In order to contribute you need to install qtcreator open-source IDE.

Ubuntu installation of the Qt Creator IDE

sudo apt-get install qt5-default

sudo apt-get install libqt5serialport5-dev

sudo apt-get install qtcreator

Now two projects have to be compiled, first the libraries that contains the code, and then the CLI.

Generate library libblinkyApploader.so

Switch to layer2_base branch and clone from the repo or download apploader2.zip

Unzip it in your local workspace directory

cd BBV2/apploader2.git

qtcreator blinkyApploader.pro

Select Configure Project Then execute Clean, qmake, Build all

The file /build-blinkyApploader-Desktop-Debug/libblinkyApploader.so.1.0.0 (> 1MB) should have been created.


Clone from the repo or download apploader-cli.zip

Unzip it in your local workspace directory

cd ../apploader-cli.git

qtcreator apploader-cli.pro

Select Configure Project In the .pro check these lines

INCLUDEPATH += $$PWD/../apploader2.git

DEPENDPATH += $$PWD/../apploader2.git

Then execute Clean, Build all

The file /build-blinkyApploaderCLI-Desktop-Debug/blinkyApploaderCLI should have been created.


Install library in the default system path for libraries

sudo cp ../build-blinkyApploader-Desktop-Debug/libblinkyApploader.so.1.0.0 /usr/lib/

Link the library to the different existing revisions

sudo ln -s /usr/lib/libblinkyApploader.so.1.0.0 /usr/lib/libblinkyApploader.so.1.0

sudo ln -s /usr/lib/libblinkyApploader.so.1.0.0 /usr/lib/libblinkyApploader.so.1

sudo ln -s /usr/lib/libblinkyApploader.so.1.0.0 /usr/lib/libblinkyApploader.so


Now everything should be ready to launch. Try to display the help with :

cd build-blinkyApploaderCLI-Desktop-Debug/

./blinkyApploaderCLI -h You must get:

Help

Usage: ./blinkyApploaderCLI
    -h display this message
    -s <SERIAL> sets serial interface name
    -c <R,G,B> sets connected blinky to color R,G,B
    -t applies command to blocks ensemble (builds a spanning tree)
    -e erase configuration
    -p <HEX file> starts sending HEX file to connected blinky ensemble
    -j 0xAAAAAAAA jumps to application address AAAAAAAA
    -k <ID min> sets blinky blocks software ID, starting with <ID min>
    -g requests blinky block to send its configuration
    -w <VAR ID,VAR VALUE> sets blinky block variable <VAR ID> to value <VAR VALUE>
                          	Application autostart -> 1 (jump auto after bootloading)
                          	Application autostart delay -> 2
                          	ID sur le spanning tree (doublons) -> 3
                          	Application address -> 4 (default is 0x8010000, param must be decimals)
                          	Commit configuration -> 128 (copy of previous -w modifications from RAM to Flash, with param 0)

QTCreator Troubleshoot

Sometimes you can encounter errors while building Apploader2 for the first time. It is mostly related to gcc version and here are the steps to update it to version 9 and tell your system to use this version:

sudo add-apt-repository ppa:ubuntu-toolchain-r/test

sudo apt update

sudo apt install gcc-9 g++-9

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 60 --slave /usr/bin/g++ g++ /usr/bin/g++-9

Quitting the blinkyApploaderCLI program

You will see that, aside from running with the -h option, the application remains active even when network communications between the computer and the blinky blocks ended. Therefore, in the following instructions, when you read "Quitting" in the output, it means that the program has been closed by the Ctrl-C signal. Indeed, for each step, you must send this signal to your application before being able to send the next command.

Set ids to an ensemble of BB

First create a spanning tree to propagate the IDs

sudo ./blinkyApploaderCLI -t

Opening serial port on /dev/ttyUSB0
Quitting
Closing port

Check the spanning tree in changing colors, all the BBs must change their color (here to black). If only the block directly connected to serial changes color, then the spanning tree is not available.

sudo ./blinkyApploaderCLI -c 0

Opening serial port on /dev/ttyUSB0
Quitting
Closing port

Change the ids, the connected BB (8) receives 1000, the next one 1001, and so on 3F0 is equal to 1000 + 8 the number of the last updated id.

sudo ./blinkyApploaderCLI -k 1000

Opening serial port on /dev/ttyUSB0
8A EA 00 00 A0
03 00 00 03 F0
Quitting
Closing port

Set the color to red

sudo ./blinkyApploaderCLI -c 100,0,0

Opening serial port on /dev/ttyUSB0
Quitting
Closing port

Programming a set of Blocks

Install the development environment

We now know how to send basic commands to the BB and we will learn how to send a whole application/program through the CLI/IHM. Applications are located at bb-applications Let’s take distance_gradient as an example. First, you need to download OpenSTM32CubeIDE and extract STM32IDE-1.0.1.tar.gz to your favorite folder. To launch the IDE run /stm32cubeide_x.x.x/stm32cubeide Then import our example as follows: File > Open Projects from File System… > Import Source > Archive > appli.tar.gz > Finish

Compilation

Now the STM32 on our hardware accepts .hex compiled files. By default if you build the code you will obtain a .elf file. We need to tell our IDE to post-build convert it to .hex as follows: Project > Properties > C/C++ Build > Settings > Tab : Build Steps > Post-build steps > Commands And write: arm-none-eabi-objcopy -O ihex "${BuildArtifactFileBaseName}.elf" "${BuildArtifactFileBaseName}.hex" Apply & Close

You can now build all and search inside /Debug or /Release folder of your project, an Appli-ng.hex should have appeared aside the Appli-ng.elf. For flash size requirements, and since the BB has no debugging interface, you shall build the release version of the application.

Upload

To upload and deploy the application on the BB go back to the CLI and enter:

sudo ./blinkyApploaderCLI -p ~/yourpathtoproject/Appli-ng/Release/Appli-ng.hex

A series of Request for chunk XXX should then appear. If nothing reflects on the BB disconnect/reconnect them and run the spanning tree command beforehand:

sudo ./blinkyApploaderCLI -t

You shall see each BB with increasing green light intensity one after the other as a progress bar materializing the deployment of the bootloader and the application over each BB.

Run

When every BB is green and ready to run your example application, you need to tell them to jump to the address of the application within the flash memory with:

sudo ./blinkyApploaderCLI -j 0x8010000

⚠️ **GitHub.com Fallback** ⚠️