docs(torizon): update torizon os docs to work with latest LVGL (#9095)

This commit is contained in:
André Costa
2025-11-24 09:11:49 +01:00
committed by GitHub
parent e47ce852cc
commit e6c44aec92
@@ -40,21 +40,21 @@ The address is displayed in the bottom right corner. It will be used later.
Once the setup is complete, the device will boot into TorizonOS.
VS Code extension
-----------------
Toradex provides a `VS Code extension <https://developer.toradex.com/torizon/application-development/ide-extension/>`_ that offers a collection of templates used
to configure and automate the tasks needed to cross-compile applications and build Docker images.
These templates now include support for LVGL applications, available as one of the `partner templates <https://github.com/torizon/vscode-torizon-templates?tab=readme-ov-file#partner-templates>`_.
This guide explains how to perform those operations manually.
Creating the Docker image
-------------------------
Toradex provides a `VSCode extension <https://developer.toradex.com/torizon/application-development/ide-extension/>`_ that offers a collection of templates used to configure
and automate the tasks needed to cross-compile applications and build Docker images.
However, this guide explains how to perform those operations manually.
.. note::
The template for a LVGL application is currently being added to the VSCode extension and will be available soon.
To build a Torizon container Docker ARM emulation needs to be enabled
by typing the following commands:
To build a Torizon container for ARM on your development machine, you need to enable Docker emulation.
Run the following commands to enable it:
.. code-block:: sh
@@ -92,56 +92,48 @@ These commands create the project directory and the ``Dockerfile``.
Now edit the Dockerfile. Copy-paste the block below into the file:
.. code-block::
.. code-block:: docker
ARG CROSS_SDK_BASE_TAG=3.2.1-bookworm
ARG BASE_VERSION=3.2.1-bookworm
##
# Board architecture
# arm or arm64
##
ARG IMAGE_ARCH=arm64
##
# Directory of the application inside container
##
ARG APP_ROOT=/usr/lvgl_application
# BUILD ------------------------------------------------------------------------
FROM torizon/debian-cross-toolchain-${IMAGE_ARCH}:${CROSS_SDK_BASE_TAG} AS build
ARG APP_ROOT
ARG IMAGE_ARCH
RUN apt-get -q -y update && \
apt-get -q -y install && \
apt-get clean && apt-get autoremove && \
apt-get install -q -y curl git cmake file && \
rm -rf /var/lib/apt/lists/*
COPY . ${APP_ROOT}
WORKDIR ${APP_ROOT}
# Compile lv_port_linux
RUN CC=aarch64-linux-gnu-gcc cmake -S ./lv_port_linux -B build
RUN make -j 4 -C ${APP_ROOT}/build
# DEPLOY -----------------------------------------------------------------------
FROM --platform=linux/${IMAGE_ARCH} torizon/debian:${BASE_VERSION} AS deploy
ARG IMAGE_ARCH
ARG APP_ROOT
RUN apt-get -y update && apt-get install -y --no-install-recommends \
&& apt-get clean && apt-get autoremove && rm -rf /var/lib/apt/lists/*
# Copy the lvglsim executable compiled in the build step to the $APP_ROOT directory
# path inside the container
COPY --from=build ${APP_ROOT}/lv_port_linux/bin/lvglsim ${APP_ROOT}
# Command executed during runtime when the container starts
ENTRYPOINT [ "./lvglsim" ]
ARG CROSS_SDK_BASE_TAG=3.2.1-bookworm
ARG BASE_VERSION=3.2.1-bookworm
##
# Board architecture
# arm or arm64
##
ARG IMAGE_ARCH=arm64
# BUILD ------------------------------------------------------------------------
FROM torizon/debian-cross-toolchain-${IMAGE_ARCH}:${CROSS_SDK_BASE_TAG} AS build
ARG IMAGE_ARCH
RUN apt-get -q -y update && \
apt-get clean && apt-get autoremove && \
apt-get install -q -y curl git cmake file python3 python3-venv pkg-config libevdev-dev:arm64 && \
rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY . .
# Compile lv_port_linux
RUN CC=aarch64-linux-gnu-gcc cmake -S ./lv_port_linux -B build
RUN cmake --build build -j$(nproc)
# DEPLOY -----------------------------------------------------------------------
FROM --platform=linux/${IMAGE_ARCH} torizon/debian:${BASE_VERSION} AS deploy
ARG IMAGE_ARCH
RUN apt-get -y update && apt-get clean && apt-get autoremove && rm -rf /var/lib/apt/lists/*
# Copy the lvglsim executable compiled in the build step to the /usr/lvgl_widgets directory
# path inside the container
COPY --from=build /app/build/bin/lvglsim /usr/lvgl_widgets
# Command executed during runtime when the container starts
ENTRYPOINT [ "/usr/lvgl_widgets" ]
The ``Dockerfile`` acts like a recipe to build two images: ``build`` and ``deploy``.
@@ -156,16 +148,22 @@ This creates a smaller image that does not include the tool chain and the build
The images are built with the following command:
``docker build . -t lvgl_app``
.. code-block:: sh
docker build . -t lvgl_app
Docker will interpret the ``Dockerfile`` present in the current working directory.
The ``-t`` argument gives a name to the resulting image.
Upon completion, ensure that the image is listed by Docker:
``docker image list | grep lvgl_app``
.. code-block:: sh
It should display the image along with its ID that will be used later.
docker image list | grep lvgl_app
lvgl_app latest 2967a34a9e74 2 minutes ago 118MB
Alongside the image name, you'll also find its ID (``2967a34a9e74`` in this example). This will be useful for later.
Deploying the container image to the device
-------------------------------------------
@@ -179,18 +177,23 @@ For this guide, we are going to setup a Docker registry container on the develop
which will be accessible from any device on your LAN. The Toradex board being on the same network
will be able to pull the image from the registry.
The registry is created like so:
The registry can be installed and started with a single command:
.. code-block:: sh
docker run -d -p 5000:5000 --name registry registry:2.7
``docker run -d -p 5000:5000 --name registry registry:2.7``
The ``-d`` flag runs the container in detached mode. The ``-p`` argument specifies the port mapping.
The registry container will listen on port ``TCP/5000`` and will map to the same port externally.
Push the image created in the previous step to the newly created registry:
``docker tag <IMAGE_ID> 127.0.0.1:5000/lvgl-app``
.. code-block:: sh
docker tag lvgl_app 127.0.0.1:5000/lvgl-app
docker push 127.0.0.1:5000/lvgl-app
``docker push 127.0.0.1:5000/lvgl-app``
By default a local container registry uses clear text HTTP so the Docker instance
running on the device has to be configured to allow fetching images from an 'insecure' repository.
@@ -225,9 +228,11 @@ The container running the LVGL application needs access to the framebuffer devic
By using the ``--device`` argument it is possible to map a device to a container.
Start the container like so:
Start the container like so, using the image ID:
``docker run --device /dev/fb0:/dev/fb0 <IMAGE_ID>``
.. code-block:: sh
docker run --device /dev/fb0:/dev/fb0 <IMAGE_ID>
Conclusion
----------