|
1 | 1 | .. _development.rst:
|
2 | 2 |
|
3 |
| -.. include:: ../../includes/development.inc |
| 3 | +.. include:: ../../includes/development_intro.inc |
4 | 4 |
|
5 |
| -.. _cross_compiling: |
| 5 | +.. _development_cross_compiling_everest_modules: |
6 | 6 |
|
7 |
| -Cross-compilation of EVerest modules |
8 |
| -==================================== |
9 |
| - |
10 |
| -Cross-compilation is the fastest and most convenient way to test your own modules directly on the target system during development. |
11 |
| -The cross-compiled project can then either be transferred directly via FTP to the charge controller or |
12 |
| -integrated into a firmware image and installed on the target using the `rauc` command. |
13 |
| - |
14 |
| -The following steps describe how to cross-compile a module for the Tarragon platform. |
15 |
| - |
16 |
| -#. On an Ubuntu or Debian-based Linux distribution, install the cross-compilers for Tarragon: |
17 |
| - |
18 |
| - .. code-block:: console |
19 |
| -
|
20 |
| - sudo apt install build-essential libc6-armhf-cross libc6-dev-armhf-cross binutils-arm-linux-gnueabihf gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf |
21 |
| -
|
22 |
| -#. Download chargebyte's `digital certificate <https://chargebyte.com/controllers-and-modules/evse-controllers/charge-control-c#downloads>`_ |
23 |
| - and use it to extract the root filesystem from the firmware image: |
24 |
| - |
25 |
| - .. code-block:: console |
26 |
| -
|
27 |
| - rauc extract --keyring=<chargebyte_certificate>.crt <shipped_firmware>.image bundle-staging |
28 |
| -
|
29 |
| - .. note:: |
30 |
| - Alternatively, if the above command does not work, you can use the following command: |
31 |
| - |
32 |
| - .. code-block:: console |
33 |
| - |
34 |
| - unsquashfs -d bundle-staging <shipped_firmware>.image |
35 |
| -
|
36 |
| - However, this will not verify the signature of the firmware image. |
37 |
| - |
38 |
| -#. Mount the extracted ext4 root filesystem image as a loop device: |
39 |
| - |
40 |
| - .. code-block:: console |
41 |
| -
|
42 |
| - sudo mkdir -p /mnt/rootfs |
43 |
| - sudo mount bundle-staging/core-image-minimal-tarragon.ext4 /mnt/rootfs |
44 |
| -
|
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`: |
47 |
| - |
48 |
| - .. code-block:: console |
49 |
| -
|
50 |
| - cd everest-workspace |
51 |
| - mkdir toolchain |
52 |
| - cd toolchain |
53 |
| - touch toolchain.cmake |
54 |
| - cd .. |
55 |
| -
|
56 |
| -#. The resulting directory structure should look like this: |
57 |
| - |
58 |
| - .. code-block:: console |
59 |
| -
|
60 |
| - everest-workspace/ |
61 |
| - |── {MyEVerestModule} |
62 |
| - ├── everest-core |
63 |
| - └── toolchain |
64 |
| - └── toolchain.cmake |
65 |
| -
|
66 |
| -#. Save the following content in the :code:`toolchain.cmake` file: |
67 |
| - |
68 |
| - .. literalinclude:: ../../includes/_static/files/toolchain.cmake |
69 |
| - |
70 |
| -#. Create a new :code:`build_tarragon` directory in the EVerest project directory (e.g. within your own EVerest |
71 |
| - module project directory or :code:`everest-core` if you want to build the everest-core modules): |
72 |
| - |
73 |
| - .. code-block:: console |
74 |
| -
|
75 |
| - cd {MyEVerestModule} |
76 |
| - mkdir build_tarragon |
77 |
| - cd build_tarragon |
78 |
| -
|
79 |
| -#. Run the following command inside the `build_tarragon` directory to configure the build: |
80 |
| - |
81 |
| - .. code-block:: console |
82 |
| -
|
83 |
| - cmake -DCMAKE_TOOLCHAIN_FILE=../../toolchain/toolchain.cmake -DCMAKE_SYSROOT=/mnt/rootfs .. |
84 |
| -
|
85 |
| -#. When this completes successfully, start cross-compiling using :code:`make`: |
86 |
| - |
87 |
| - .. code-block:: console |
88 |
| -
|
89 |
| - make install -j$(nproc) |
90 |
| -
|
91 |
| -#. If the build was successful, a dist directory will be created with the cross-compiled binaries and |
92 |
| - the manifest files of the modules. Please check if the following directory structure was created: |
93 |
| - |
94 |
| - .. code-block:: console |
95 |
| -
|
96 |
| - dist/ |
97 |
| - └── libexec |
98 |
| - └── everest |
99 |
| - └── modules |
100 |
| - └── {MyEVerestModule} |
101 |
| - ├── {MyEVerestModule} (binary) |
102 |
| - └── manifest.yaml (manifest file) |
103 |
| -
|
104 |
| -#. Verify that the resulting binaries were compiled for the Tarragon target platform: |
105 |
| - |
106 |
| - .. code-block:: console |
107 |
| -
|
108 |
| - file dist/libexec/everest/modules/{MyEVerestModule}/{MyEVerestModule} |
109 |
| -
|
110 |
| - The output should be something like: |
111 |
| - |
112 |
| - .. code-block:: console |
113 |
| -
|
114 |
| - dist/libexec/everest/modules/{MyEVerestModule}/{MyEVerestModule}: ELF 32-bit LSB pie executable, ARM, EABI5 version 1 (SYSV), |
115 |
| - dynamically linked, interpreter /lib/ld-linux-armhf.so.3, BuildID[sha1]=9f287c2dbdcacd9ecde770df4820de9218deb439, for GNU/Linux 3.2.0, stripped |
116 |
| -
|
117 |
| -The resulting binary and manifest can be found in the :code:`dist/libexec/everest/modules/{MyEVerestModule}` |
118 |
| -directory. If you want to test the module on the target system, you can copy the module directory using |
119 |
| -:code:`scp` or :code:`rsync`: |
120 |
| - |
121 |
| - .. code-block:: console |
122 |
| -
|
123 |
| - scp -r dist/libexec/everest/modules/{MyEVerestModule} root@<ip_address>:/usr/libexec/everest/modules/ |
124 |
| -
|
125 |
| -To include the new module in a firmware image, copy the module directory into the mounted root filesystem: |
126 |
| - |
127 |
| - .. code-block:: console |
128 |
| -
|
129 |
| - sudo cp -av dist/libexec/everest/modules/{MyEVerestModule} /mnt/rootfs/usr/libexec/everest/modules/ |
130 |
| -
|
131 |
| -#. Unmount the loop device: |
132 |
| - |
133 |
| - .. code-block:: console |
134 |
| -
|
135 |
| - sudo umount /mnt/rootfs |
136 |
| -
|
137 |
| -#. Ensure that the modified filesystem is in a clean state: |
138 |
| - |
139 |
| - .. code-block:: console |
140 |
| -
|
141 |
| - fsck.ext4 -f bundle-staging/core-image-minimal-tarragon.ext4 |
142 |
| -
|
143 |
| -Follow the steps under the section :ref:`firmware_customization` to install your PKI certificate, repackage |
144 |
| -the modified root filesystem into a firmware update image, and test the new firmware. |
145 |
| - |
146 |
| -.. _creating_fw_images: |
| 7 | +.. jinja:: target-info |
| 8 | + :file: ../../includes/_templates/development_cross_compiling_everest_modules.rst.j2 |
147 | 9 |
|
148 | 10 | .. include:: ../../includes/development_creating_fw_images.inc
|
149 | 11 |
|
150 |
| -.. _debugging_and_logging: |
151 |
| - |
152 | 12 | .. include:: ../../includes/development_debugging_and_logging.inc
|
0 commit comments