|
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-compiling for Charge SOM |
8 | | -============================== |
9 | | - |
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. |
13 | | - |
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: |
17 | | - |
18 | | - .. code-block:: console |
19 | | -
|
20 | | - sudo apt install build-essential libc6-arm64-cross gcc-aarch64-linux-gnu g++-aarch64-linux-gnu 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. The digital certificate is the same between Charge SOM and Charge Control C. |
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-chargesom.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 | | -
|
55 | | -#. Save the following content in the :code:`toolchain.cmake` file: |
56 | | - |
57 | | - .. literalinclude:: ../../includes/_static/files/toolchain.cmake |
58 | | - |
59 | | -#. The resulting directory structure should look like this: |
60 | | - |
61 | | - .. code-block:: console |
62 | | -
|
63 | | - everest-workspace/ |
64 | | - |── {MyEVerestModule} |
65 | | - ├── everest-core |
66 | | - └── toolchain |
67 | | - └── toolchain.cmake |
68 | | -
|
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): |
71 | | - |
72 | | - .. code-block:: console |
73 | | -
|
74 | | - cd ../{MyEVerestModule} |
75 | | - mkdir build_csom |
76 | | - cd build_csom |
77 | | -
|
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`: |
85 | | - |
86 | | - .. code-block:: console |
87 | | -
|
88 | | - make install -j$(nproc) |
89 | | -
|
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: |
92 | | - |
93 | | - .. code-block:: console |
94 | | -
|
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} |
108 | | -
|
109 | | - The output should be something like: |
110 | | - |
111 | | - .. code-block:: console |
112 | | -
|
113 | | - dist/libexec/everest/modules/{MyEVerestModule}/{MyEVerestModule}: ELF 64-bit LSB pie executable, ARM aarch64, version 1 (SYSV), |
114 | | - dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, BuildID[sha1]=ad2342fdd3b8fb1949fc3e13b77382d3da72f28a, for GNU/Linux 3.7.0, stripped |
115 | | -
|
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: |
125 | | - |
126 | | - .. code-block:: console |
127 | | -
|
128 | | - sudo cp -av dist/libexec/everest/modules/{MyEVerestModule} /mnt/rootfs/usr/libexec/everest/modules/ |
129 | | -
|
130 | | -#. Unmount the loop device: |
131 | | - |
132 | | - .. code-block:: console |
133 | | -
|
134 | | - sudo umount /mnt/rootfs |
135 | | -
|
136 | | -#. Ensure that the modified filesystem is in a clean state: |
137 | | - |
138 | | - .. code-block:: console |
139 | | -
|
140 | | - fsck.ext4 -f bundle-staging/core-image-minimal-chargesom.ext4 |
141 | | -
|
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: |
| 7 | +.. jinja:: target-info |
| 8 | + :file: ../../includes/_templates/development_cross_compiling_everest_modules.rst.j2 |
146 | 9 |
|
147 | 10 | .. include:: ../../includes/development_creating_fw_images.inc |
148 | 11 |
|
149 | | -.. _debugging_and_logging: |
150 | | - |
151 | 12 | .. include:: ../../includes/development_debugging_and_logging.inc |
0 commit comments