Advent 2023 banner

Managing Multiple SoM Platforms in the Same Factory

Photo of Raul Muñoz

Posted on Dec 14, 2023 by Raul Muñoz

7 min read

Welcome to the final and fourteenth of our AI Powered Christmas Tree Series!

If you have been following along with the series, you should have your very own AI Powered Christmas Tree up and running. In the previous entry, we discussed how easily the project could be recreated on a Raspberry Pi 4 with a new Factory.

In this tutorial we will instead be managing multiple platforms within one Factory.

Introduction

It is often the case that testing your proof–of–concept on a singular hardware/platform is not enough. Throughout development, circumstances or requirements can change, resulting in a need to change hardware. You have seen in the previous blog how the FoundriesFactory® platform and the Linux microPlatform™ OS facilitates running Docker Compose applications on different platforms. However, creating a new Factory for every platform you wish to test for your proof–of–concept is not the best use of your time.

When you become a subscriber, FoundriesFactory gives you the ability to upgrade your licenses to add multiple platforms within the same Factory. This would allow you to keep multiple devices—like the Raspberry Pi 4 and the AM62xx—running side by side during the development and prototyping phases of your project.

Both platforms would share the same Factory repositories, allowing you to share resources during development, reducing your overall time to market.

Prerequisites

This is part fourteen of our AI Powered Christmas Tree Series. This entry assumes that you have completed the previous tutorials in the series, and have created a Docker Compose application.

Please refer back to the overview page for any entries you may have missed.

Managing Multiple Platforms in FoundriesFactory

End users are not authorized to add new platforms to their existing Factory directly. Any subscribers who identify the need for an additional new platform alongside their existing one can contact the Foundries.io team, who can adjust your subscription according to the number of platforms you need.

After enabling multiple platforms for your Factory, your Targets page on app.foundries.io will reflect that additional machine builds are now triggered with each platform build:

This Factory was used to test the AI powered Christmas Tree application on Raspberry Pi 4. Therefore, its meta-subscriber-overrides.git already has all the requisite Yocto Project build changes discussed throughout the series.

When the CI job for Target version 6 is complete, both the raspberrypi4-64 and the am62xx-evm will be sharing the same Linux microPlatform image version.

At this point, you will be able to download both images:

After downloading, flashing, and booting the am62xx image, it is time to register the device to your Factory. After registering, it will be possible to see the AM62XX device and the Raspberry Pi 4 device on your Devices tab:

Both devices are running their respective lmp target version 6

Trigger a Docker Container Build

After adding AM62xx to the platform builds, you will also need to launch a new Docker container build so that your Docker Compose applications can be added to the AM62xx target list. You can see in the above image that the AM62xx Target does not have any available apps. This is because the platform build for AM62xx was made after the containers build, so the ‘publish Compose app’ function does not include AM62xx. To solve this, we simply need to launch a new containers build and the FoundriesFactory CI/CD system will automatically add the list of Compose apps to the AM62xx Target list and make it available on the device.

To trigger a new build, send an empty commit to the container.git repository:

host:~$ git clone https://source.foundries.io/factories/<factory>/containers.git
host:~$ git commit --allow-empty -m "Adding New machine"
host:~$ git push

When it is complete, you can see both Targets sharing the same application:

Enabling Your Docker Application with Fioctl

Make sure you have connected the camera to your AM62XX. Then use your host machine to enable the application using Fioctl:

host:~$ fioctl devices config updates --apps christmas-tree <device-name> -f <factory>

Changing apps from: [] -> [christmas-tree]

Testing Your AI Powered Christmas Tree

When the device finishes the over-the-air update, the application will automatically launch.

Check if the Docker Compose app is already running with the command below:

device:~$ docker ps

The output will show the app name:

CONTAINER ID   IMAGE                                             COMMAND                  CREATED         STATUS                                  PORTS     NAMES
7322c5df8636   hub.foundries.io/my-rasp-factory/christmas-tree   "/usr/bin/python3 ch…"   8 seconds ago   Restarting (1) Less than a second ago             christmas-tree-christmas-tree-1

You can now debug your application by following the container log:

device:~$ docker logs -f christmas-tree-christmas-tree-1

The logs will show the Python code output. If any people are detected within view of the camera—and the switch module is correctly connected to the MQTT broker running on your device—it will turn the Christmas Tree lights on and off!

This is an example output of the christmas-tree app running on an embedded device:

Initializing camera at port 0, FPS 30
Camera V4L2 (360.0 x 640.0) in port 0 selected.
Send `OFF` to topic `cmnd/switch/POWER1`
Christmas tree turned off
Current person detection count: 0
Current person detection count: 0
Current person detection count: 0
Current person detection count: 0
Current person detection count: 1
Current person detection count: 2
Two or more people detected
Send `ON` to topic `cmnd/switch/POWER1`
Christmas tree turned on
Current person detection count: 0
Current person detection count: 0
Current person detection count: 0
Current person detection count: 0
Turning off Christmas tree after 3 seconds of last detection
Send `OFF` to topic `cmnd/switch/POWER1`
Christmas tree turned off
Current person detection count: 0
Current person detection count: 0
Current person detection count: 0
Current person detection count: 1
Current person detection count: 2
Two or more people detected
Send `ON` to topic `cmnd/switch/POWER1`
Christmas tree turned on
Current person detection count: 0
Current person detection count: 1
Current person detection count: 2
Current person detection count: 2
Current person detection count: 2
...

Recap and Conclusion

In this tutorial, you have seen the capability of a single Factory to manage multiple devices. The Factory used previously for Raspberry Pi 4 was able to integrate the same application on the AM62xx without any major revisions or duplication of effort. The flexibility to develop and manage multiple hardware platforms is one of the key strengths of FoundriesFactory, and can be invaluable in accelerating your hardware considerations when developing a new product. If you feel that this is something you could benefit from, contact the Foundries.io team to talk about upgrading your subscription to include multiple machine builds.

Continue Building Ai-Powered Christmas Tree

If you are interested in our entire 14-part series on how to build an AI powdered Christmas tree, browse through each section below. Each part brings you closer to mastering your build:

Related posts