Skip to content

Commit 6d4f470

Browse files
authored
Merge pull request #55 from chargebyte/everest/chargesom-revision-of-development-chapter
Everest/chargesom: Revision of development chapter
2 parents 3a71cfe + 63a984a commit 6d4f470

1 file changed

Lines changed: 67 additions & 29 deletions

File tree

docs/source/development.rst

Lines changed: 67 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@
77
Cross-compiling for Charge SOM
88
==============================
99

10-
Another way to integrate custom applications into the firmware image is to cross-compile the application
11-
for Charge SOM and include it in the image. A pre-requisite for this is to have the latest firmware image
12-
as a developer build. Always keep in mind, if you want to build a new EVerest module it must be
13-
compatible to the EVerest release within the firmware. Please have a look at the official
14-
`EVerest documentation <https://everest.github.io/nightly/dev_tools/edm.html#setting-up-and-updating-a-workspace>`_,
15-
how to checkout a dedicated EVerest release.
10+
Cross-compilation is the fastest and most convenient way to test your own modules directly on the target
11+
system during development. The cross-compiled project can then either be transferred directly via SFTP
12+
to the charge controller or integrated into a firmware image and installed on the target using the `rauc` command.
1613

17-
#. On an Ubuntu or Debian-based Linux distribution, install the cross-compilers for Charge SOM.
14+
The following steps describe how to cross-compile a module for the Charge SOM platform.
15+
16+
#. On an Ubuntu or Debian-based Linux distribution, install the cross-compilers for Charge SOM:
1817

1918
.. code-block:: console
2019
@@ -29,85 +28,124 @@ how to checkout a dedicated EVerest release.
2928
3029
.. note::
3130
Alternatively, if the above command does not work, you can use the following command:
31+
3232
.. code-block:: console
3333
3434
unsquashfs -d bundle-staging <shipped_firmware>.image
3535
36-
But this will not verify the signature of the firmware image.
36+
However, this will not verify the signature of the firmware image.
3737

38-
#. Mount the ext4 root filesystem image as a loop device.
38+
#. Mount the extracted ext4 root filesystem image as a loop device:
3939

4040
.. code-block:: console
4141
4242
sudo mkdir -p /mnt/rootfs
4343
sudo mount bundle-staging/core-image-minimal-chargesom.ext4 /mnt/rootfs
4444
45-
#. Create a new directory in the folder where the new module was created (my-module) and create a new
46-
file called :code:`toolchain.cmake`. This file is used to set the toolchain for the cross-compilation.
45+
#. Create a new directory in your `everest-workspace` directory (in parallel to the `everest-core` directory) and
46+
create a new file named :code:`toolchain.cmake`:
4747

4848
.. code-block:: console
4949
50-
cd my-module
50+
cd everest-workspace
5151
mkdir toolchain
5252
cd toolchain
5353
touch toolchain.cmake
5454
55-
56-
#. Store the following lines in the :code:`toolchain.cmake` file:
55+
#. Save the following content in the :code:`toolchain.cmake` file:
5756

5857
.. literalinclude:: ../../includes/_static/files/toolchain.cmake
5958

60-
#. Create a new :code:`build` directory in "my-module" and navigate to it.
59+
#. The resulting directory structure should look like this:
6160

6261
.. code-block:: console
6362
64-
mkdir build
65-
cd build
63+
everest-workspace/
64+
|── {MyEVerestModule}
65+
├── everest-core
66+
└── toolchain
67+
└── toolchain.cmake
6668
67-
#. Run the following command inside to configure the build.
69+
#. Create a new :code:`build_csom` directory in the EVerest project directory (e.g. within your own EVerest
70+
module project directory or :code:`everest-core` if you want to build the everest-core modules):
6871

6972
.. code-block:: console
7073
71-
cmake -DCMAKE_TOOLCHAIN_FILE=../toolchain/toolchain.cmake -DCMAKE_SYSROOT=/mnt/rootfs ..
74+
cd ../{MyEVerestModule}
75+
mkdir build_csom
76+
cd build_csom
7277
73-
#. When this ends successfully, start cross-compiling using :code:`make`:
78+
#. Run the following command inside the `build_csom` directory to configure the build:
79+
80+
.. code-block:: console
81+
82+
cmake -DCMAKE_TOOLCHAIN_FILE=../../toolchain/toolchain.cmake -DCMAKE_SYSROOT=/mnt/rootfs ..
83+
84+
#. When this completes successfully, start cross-compiling using :code:`make`:
7485

7586
.. code-block:: console
7687
7788
make install -j$(nproc)
7889
79-
#. Test that the resulting binaries are compiled for Charge SOM as a target:
90+
#. If the build was successful, a dist directory will be created with the cross-compiled binaries and
91+
the manifest files of the modules. Please check if the following directory structure was created:
8092

8193
.. code-block:: console
8294
83-
file dist/libexec/everest/modules/MyModule/MyModule
95+
dist/
96+
└── libexec
97+
└── everest
98+
└── modules
99+
└── {MyEVerestModule}
100+
├── {MyEVerestModule} (binary)
101+
└── manifest.yaml (manifest file)
102+
103+
#. Verify that the resulting binaries were compiled for the Charge SOM platform:
104+
105+
.. code-block:: console
106+
107+
file dist/libexec/everest/modules/{MyEVerestModule}/{MyEVerestModule}
84108
85109
The output should be something like:
86110

87111
.. code-block:: console
88112
89-
dist/libexec/everest/modules/MyModule/MyModule: ELF 64-bit LSB pie executable, ARM aarch64, version 1 (SYSV),
113+
dist/libexec/everest/modules/{MyEVerestModule}/{MyEVerestModule}: ELF 64-bit LSB pie executable, ARM aarch64, version 1 (SYSV),
90114
dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, BuildID[sha1]=ad2342fdd3b8fb1949fc3e13b77382d3da72f28a, for GNU/Linux 3.7.0, stripped
91115
92-
#. The resulting binary and manifest file can be copied to the previously mounted root filesystem.
116+
#. The resulting binary and manifest can be found in the :code:`dist/libexec/everest/modules/{MyEVerestModule}`
117+
directory. If you want to test the module on the target system, you can copy the module directory using
118+
:code:`scp` or :code:`rsync`:
119+
120+
.. code-block:: console
121+
122+
scp -r dist/libexec/everest/modules/{MyEVerestModule} root@<ip_address>:/usr/libexec/everest/modules/
123+
124+
#. To include the new module in a firmware image, copy the module directory into the mounted root filesystem:
93125

94126
.. code-block:: console
95127
96-
cp dist/libexec/everest/modules/MyModule /mnt/rootfs/usr/libexec/everest/modules/
128+
cp -r dist/libexec/everest/modules/{MyEVerestModule} /mnt/rootfs/usr/libexec/everest/modules/
97129
98-
#. umount the loop device.
130+
#. Unmount the loop device:
99131

100132
.. code-block:: console
101133
102134
sudo umount /mnt/rootfs
103135
104-
#. Make sure that the customized filesystem is in a clean state.
136+
#. Ensure that the modified filesystem is in a clean state:
105137

106138
.. code-block:: console
107139
108140
fsck.ext4 -f bundle-staging/core-image-minimal-chargesom.ext4
109141
110-
#. Follow the steps under the section :ref:`firmware_customization` to install your PKI certificate, pack
111-
the modified root filesystem image again into the firmware update image, and test the new firmware image.
142+
#. Follow the steps under the section :ref:`firmware_customization` to install your PKI certificate, repackage
143+
the modified root filesystem into a firmware update image, and test the new firmware.
144+
145+
.. _creating_fw_images:
146+
147+
.. include:: ../../includes/development_creating_fw_images.inc
148+
149+
.. _debugging_and_logging:
112150

113151
.. include:: ../../includes/development_debugging_and_logging.inc

0 commit comments

Comments
 (0)