Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 8f31601

Browse files
authoredMar 9, 2023
[PC-1033] Portenta X8: How To Build a Custom Image for Your Portenta X8 Redefinition (#359)
* Initial commit - Tutorial content update * Tutorial content minor update * Tutorial content update
1 parent c30fe7b commit 8f31601

File tree

1 file changed

+75
-50
lines changed
  • content/hardware/04.pro/boards/portenta-x8/tutorials/image-building

1 file changed

+75
-50
lines changed
 

‎content/hardware/04.pro/boards/portenta-x8/tutorials/image-building/content.md

+75-50
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
beta: true
33
title: 'How To Build a Custom Image for Your Portenta X8'
4-
description: 'This tutorial teaches you how to compile a custom image for your Portenta X8'
4+
description: 'This tutorial teaches you how to compile a custom image for your Portenta X8.'
55
difficulty: advanced
66
tags:
77
- Embedded Linux
@@ -14,24 +14,24 @@ hardware:
1414

1515
## Overview
1616

17-
In this tutorial you will learn how to build an image for the Portenta X8 with the source code provided at our [GitHub repository for lmp-manifest](https://github.com/arduino/lmp-manifest).
18-
Building your image locally can help debug certain aspects of the system, such as the bootloader or kernel support.
17+
In this tutorial, you will learn how to build an image for the Portenta X8 with the source code provided at our [GitHub repository for lmp-manifest](https://github.com/arduino/lmp-manifest). Building your image locally can help debug several aspects of the system, such as the bootloader or kernel support.
1918

20-
***Keep in mind that images built locally cannot register with FoundriesFactory and will not be OTA compatible, but this is a good alternative for those who do not have a FoundriesFactory subscription.
21-
This tutorial targets customers that are not FoundriesFactory subscribers, but still want to extend the functionality of the Arduino pre-built sources by building their own images. For FoundriesFactory subscribers, we strongly suggest making use of your Factory's continuous integration system for creating images.***
19+
***Images built locally cannot register with FoundriesFactory and will not be OTA compatible, but this is a good alternative for those who do not have a FoundriesFactory subscription.***
20+
21+
This tutorial targets customers that are not FoundriesFactory subscribers, but still want to extend the functionality of the Arduino pre-built sources by building their images. For FoundriesFactory subscribers, we strongly suggest making use of your Factory's continuous integration system for image creation.
2222

2323
## Goals
2424

25-
- Build a "builder" Docker image
26-
- Get the required files
27-
- Configure the build settings
28-
- Build the image
29-
- Save the needed files for flashing
25+
- Learn how to build a "builder" Docker image
26+
- Learn how to get the required files
27+
- Learn how to configure the build settings
28+
- Learn how to build the image
29+
- Learn how to save the needed files for flashing
3030

3131
### Required Hardware and Software
3232

33-
- [Docker Engine](https://docs.docker.com/engine/install/)
3433
- [Arduino Portenta X8](https://store.arduino.cc/products/portenta-x8)
34+
- [Docker Engine](https://docs.docker.com/engine/install/)
3535
- ~60GB available space on your machine's drive
3636

3737
## Instructions
@@ -40,108 +40,124 @@ This tutorial targets customers that are not FoundriesFactory subscribers, but s
4040

4141
#### Build the Docker Image
4242

43-
You will create a Docker image that has the dependencies needed to build your device image.
43+
You will create a Docker image that has the dependencies needed to build your device image. To do so, you will need to clone our [lmp-manifest repository](https://github.com/arduino/lmp-manifest). The following steps will guide you through the process:
4444

45-
To do so you will need to clone our [lmp-manifest repository](https://github.com/arduino/lmp-manifest), follow these steps to do so:
45+
First, clone the lmp-manifest repository with the following command:
4646

47-
First, clone the lmp-manifest repository with this command:
48-
```
49-
git clone https://github.com/arduino/lmp-manifest.git
50-
```
51-
![Cloning lmp-manifest repository](assets/git_clone_lmp-manifest.png)
47+
```
48+
git clone https://github.com/arduino/lmp-manifest.git
49+
```
5250

53-
Then build the Docker Image using:
54-
```
55-
cd lmp-manifest
56-
docker build -t yocto-build ./lmp-manifest
57-
```
58-
![Building a Docker Image](assets/docker_build.png)
51+
![Cloning lmp-manifest repository](assets/git_clone_lmp-manifest.png)
52+
53+
After cloning the lmp-manifest repository successfully, we will proceed to build the Docker Image using following command sequence:
54+
55+
```
56+
cd lmp-manifest
57+
docker build -t yocto-build ./lmp-manifest
58+
```
59+
60+
![Building a Docker Image](assets/docker_build.png)
61+
62+
You will be able to see similar result if everything went successfully.
5963

6064
#### Run The Docker Image (Builder)
6165

62-
Run the image with the `-v` argument to mount a volume. This allows you to use a host directory inside the Docker image, so you can store all the data and build artifacts safely.
66+
Once the *Docker Image* is ready, we will run the image with the `-v` argument to mount a volume. This allows you to use a host directory inside the Docker image, so you can store all the data and build artifacts safely.
6367

6468
***If you do not use a volume while running the image, you will lose the data when the image stops***
6569

66-
Run the `yocto-build` builder image with:
70+
Run the `yocto-build` builder image with following command:
71+
6772
```
6873
docker run -v <source>:/dockerVolume -it yocto-build bash
6974
```
7075

71-
Switch to the `builder` user with the following command, the password is **builder**:
76+
We need to switch to the `builder` user with the following command after the previous process, and the password is **builder**:
77+
7278
```
7379
su builder
7480
```
7581

76-
### Setup and Build
82+
### Image Setup and Build
7783

7884
***You can download a [bash script](assets/portenta-x8_build.sh) that wraps all the upcoming steps.***
7985

8086
#### Setup the Environment
8187

8288
Now that you are running inside the Docker Image, you can use tools like **git-repo**, which is already installed.
8389

84-
First configure git with your credentials. They don't need to be the real ones, but are required by `git-repo` to pull.
85-
Copy and paste the following:
90+
First, configure git with your credentials. They don't need to be the real ones but are required by `git-repo` to pull. The following commands can be used for this example:
91+
8692
```
8793
git config --global user.email "you@example.com"
8894
git config --global user.name "Your Name"
8995
```
96+
9097
![Adding credentials to git config](assets/git_config.png)
9198

9299
Change to the home directory, and initialize the repository using **repo**:
100+
93101
```
94102
cd ~
95103
repo init -u https://github.com/arduino/lmp-manifest.git -m arduino.xml -b release
96104
```
105+
97106
![Git-repo initialization](assets/repo_init.png)
98107

99108
Then pull the needed files with:
109+
100110
```
101111
repo sync
102112
```
113+
103114
![Git-repo pulling all the repositories](assets/repo_sync.png)
104115

105-
After completion it should look like the following image:
116+
After completion, it should look like the following image:
106117

107118
![Git-repo finished sync](assets/repo_sync_finished.png)
108119

109120
***NOTE: If you are a FoundriesFactory subscriber and want to build your Factory sources locally, please use the manifest link for your Factory as below. This is not recommended as images built locally cannot register to the Factory and receive OTAs.***
110121

111-
#### Set Up The Portenta X8 Distribution
122+
#### Set Up the Portenta X8 Distribution
112123

113-
You can set `DISTRO` to:
114-
- `lmp-base`: insecure image without ostree, developer friendly, not OTA compatible
124+
It is recommendable to set `DISTRO` to either:
125+
126+
- `lmp-base`: insecure image without ostree, developer-friendly, not OTA compatible
115127
- `lmp`: secure image without xwayland
116128
- `lmp-xwayland`: secure image with xwayland support
117129

118-
***`lmp-partner-arduino-image` will be better supported in the near future.***
130+
It will help to classify the image if it follows any of the previous characteristics and with the following command:
119131

120132
```bash
121133
DISTRO=lmp-xwayland MACHINE=portenta-x8 . setup-environment
122134
```
123135

124-
It will then switch automatically to a new folder. Now to accept the EULA with:
136+
***`lmp-partner-arduino-image` will be better supported soon.***
137+
138+
It will then switch automatically to a new folder. Continuing, you can now proceed to accept the EULA using the following command:
125139

126140
```bash
127141
echo "ACCEPT_FSL_EULA = \"1\"" >> conf/local.conf
128142
```
129143

144+
You will be able to see similar output as following after the previous steps:
145+
130146
![Setup Portenta X8 DISTRO](assets/x8_distro_setup.png)
131147

132-
#### Build Image With Bitbake
148+
#### Build an Image With Bitbake
133149

134-
To start building the image, run:
150+
To start building the image, following command is used:
135151

136152
```
137153
bitbake lmp-partner-arduino-image
138154
```
139-
***This process takes ~7h depending on the build host***
155+
156+
***This process may take ~7 hours depending on the build host***
140157

141158
![Compile Portenta X8 image](assets/x8_build.png)
142159

143-
In case you want to use your computer while it builds, (which is going to take time and resources) you should lower the threads used.
144-
Do so by opening `conf/local.conf` and lower the values of the following variables:
160+
If you want to use your computer while it builds, it is recommendable to lower the threads used since it takes a lot of resources and time. Do so by opening `conf/local.conf` and lowering the values of the following variables:
145161

146162
- `BB_NUMBER_PARSE_THREADS = "4"`
147163
- `BB_NUMBER_THREADS = "4"`
@@ -150,36 +166,44 @@ And add:
150166

151167
- `PARALLEL_MAKE = "-j 4"`
152168

153-
Once it finishes you will see something similar to:
169+
If possible, it is a good practice to understand the available threads of your computer used for this process, to optimize the resources accordingly for optimal balance between build performance and side tasks while waiting for the build. Once it finishes you will see something similar to:
170+
154171
![Portenta X8 Image finished compilation](assets/x8_build_finished.png)
155172

156173
#### Setup Manufacturing Tools
157174

158-
To flash your board you will need to compile **lmp-mfgtool distro** to get additional tools. First go into your home folder and change `DISTRO`:
175+
To flash your board, you will need to compile **lmp-mfgtool distro** to get additional tools. First, go into your home folder and change `DISTRO` following the command sequence:
176+
159177
```
160178
cd ..
161179
DISTRO=lmp-mfgtool MACHINE=portenta-x8 . setup-environment
162180
echo "ACCEPT_FSL_EULA = \"1\"" >> conf/local.conf
163181
echo "MFGTOOL_FLASH_IMAGE = \"lmp-partner-arduino-image\"" >> conf/local.conf
164182
```
183+
184+
You should be able to see similar results as following image when successful:
185+
165186
![Flashing tools DISTRO setup](assets/tools_distro_setup.png)
166187

167188
#### Build Manufacturing Tools: Flash The Board
168189

169-
To compile and get the tools you will need to type:
190+
To compile and get the tools required, we will use following command:
191+
170192
```
171193
bitbake mfgtool-files
172194
```
195+
173196
![Compiling flashing tools](assets/tools_build.png)
174197

175198
After completion:
199+
176200
![Tools compilation finished](assets/tools_finished.png)
177201

178-
***This process takes ~2h depending on your build host***
202+
***This process may take ~2 hours depending on your build host***
179203

180204
#### Save Your Image For Flashing
181205

182-
After a successful build, save the needed files to the host volume you mounted with `docker run`. Use the following commands to copy the files to your storage unit:
206+
After a successful build, save the needed files to the host volume you mounted with `docker run`. Use the following commands to copy the files to your storage unit:
183207

184208
```
185209
cd ..
@@ -199,15 +223,16 @@ tar xvf mfgtool-files-portenta-x8.tar.gz
199223
![Copying compiled files](assets/copy_files.png)
200224

201225
You will be able to see the copied files in your OS file explorer.
202-
![Checking copied files with file explorer](assets/docker_volume_explorer.png)
203226

227+
![Checking copied files with file explorer](assets/docker_volume_explorer.png)
204228

205229
## Conclusion
206230

207-
Now you have all the required files to flash the image you built onto the device.
231+
In this tutorial, you have learned how to build a "builder" Docker image, get its required files, configure the build settings, build the image,a and to save the needed files for flashing. Now you have all the required files to flash the image you built onto the device.
232+
233+
## Next Steps
208234

209-
Please follow the [Flashing tutorial](image-flashing) to flash your device with your custom image.
210-
Keep in mind you will need to use the files provided from this build, not the ones mentioned in the Flashing tutorial.
235+
Please follow the [Flashing tutorial](image-flashing) to flash your device with your custom image. You can use the files provided from this build to flash the Portenta X8 following the tutorial's steps.
211236

212237
## Troubleshooting
213238

0 commit comments

Comments
 (0)
Please sign in to comment.