Skip to content

Commit 3b2eb94

Browse files
Merge pull request #182 from OnionIoT/content/build-pkg-fw-updates
Update docker image used in compile package and build firmware articles
2 parents 7a7cde1 + 8af4cc9 commit 3b2eb94

File tree

6 files changed

+125
-69
lines changed

6 files changed

+125
-69
lines changed

docs/firmware/_build-env-notes.mdx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,12 @@ import WslNote from './_wsl-note.mdx';
1212
<WslNote/>
1313

1414

15-
**The method recommended by Onion is to use Ubuntu 22.04 Linux in a Docker container.** Using Docker provides isolation, which helps prevent dependency conflicts with existing software on the host system and ensures a clean, reproducible development environment.
15+
**The method recommended by Onion is to use Linux in a Docker container.** Using Docker provides isolation, which helps prevent dependency conflicts with existing software on the host system and ensures a clean, reproducible development environment.
16+
17+
**Onion recommends using the `onion/openwrt-builder` Docker image.** This Docker image is based on Ubuntu 22.04 and has all of the [software packages required to use the OpenWRT build tools](https://openwrt.org/docs/guide-developer/toolchain/install-buildsystem#debianubuntumint) already installed.
18+
19+
:::tip
20+
21+
For those new to Docker, see [Docker's installation guide](https://docs.docker.com/desktop/) and the manual on [running a Docker container](https://docs.docker.com/engine/reference/run).
22+
23+
:::
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
To download the `onion/openwrt-builder` Docker image, make sure Docker is installed and running, and run the following command:
2+
3+
```
4+
docker pull onion/openwrt-builder
5+
```
6+
7+
:::note Only needs to be done once
8+
9+
It might take a few minutes to download the Docker image depending on your internet connection. After the image downloads, you won't need to download it again and this step can be skipped next time.
10+
11+
:::
Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
1-
:::tip
2-
3-
For those new to Docker, see [Docker's installation guide](https://docs.docker.com/desktop/) and the manual on [running a Docker container](https://docs.docker.com/engine/reference/run).
4-
5-
:::
6-
7-
To start a Docker container running Ubuntu 22.04, make sure Docker is installed and running, and then run the following command:
1+
To start a Docker container based on the `onion/openwrt-builder` image run the following command:
82

93
```
10-
docker run -it ubuntu:22.04 /bin/bash
4+
docker run -it onion/openwrt-builder /bin/bash
115
```
126

137
:::info Macs with Apple Silicon
@@ -16,4 +10,13 @@ The OpenWRT build system, SDK, and Image Builder expect an x86_64 processor arch
1610

1711
Some users have reported successful compilation if Rosetta for x86/amd64 emulation on Apple Silicon is enabled in Docker.
1812

19-
:::
13+
:::
14+
15+
You should see something similar to:
16+
17+
```shell
18+
~ docker run -it onion/openwrt-builder /bin/bash
19+
root@385d649fdab7:~#
20+
```
21+
22+
You are now inside the Docker container.

docs/firmware/_install-deps.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
<!-- NO LONGER USED! -->
2+
13
When using Ubuntu 22.04 Linux or newer, you need to install the software packages required to use the OpenWRT build tools. These can be installed using the packager manager.
24

35
:::tip

docs/firmware/how-to-build-firmware.md

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -84,28 +84,34 @@ import BuildEnvNotes from './_build-env-notes.mdx';
8484

8585
<BuildEnvNotes tool="Image Builder" />
8686

87-
#### 1. Start your Docker container
87+
#### Step 1: Pull the Docker Image
8888

89-
import DockerInstructions from './_docker-instructions.mdx';
89+
import DockerPullInstructions from './_docker-pull-instructions.mdx';
9090

91-
<DockerInstructions/>
91+
<DockerPullInstructions/>
9292

93-
#### 2. Install software dependencies
93+
#### Step 2: Start your Docker Container
9494

95-
import InstallDeps from './_install-deps.mdx';
95+
import DockerStartInstructions from './_docker-start-instructions.mdx';
9696

97-
<InstallDeps/>
97+
<DockerStartInstructions/>
9898

99-
#### 3. Clone the OnionIoT/openwrt-imagebuilder-wrapper repo
99+
#### Step 3: Clone the OnionIoT/openwrt-imagebuilder-wrapper repo
100100

101101
This repository is set up to build OpenWRT firmware for the Onion Omega2 and Omega2+.
102102

103-
To clone the openwrt-imagebuilder-wrapper repo, issue the following command:
103+
To clone the **openwrt-imagebuilder-wrapper** repo in the Docker container, run the following command:
104104

105105
```Shell
106106
git clone https://github.com/OnionIoT/openwrt-imagebuilder-wrapper.git
107107
```
108108

109+
When the repo is cloned, enter the directory:
110+
111+
```Shell
112+
cd openwrt-imagebuilder-wrapper
113+
```
114+
109115
### Customizing the firmware image
110116

111117
The firmware image specifications are defined in the `profile` configuration file.
@@ -174,25 +180,29 @@ After completing this step, the OpenWRT Image Builder will download and is set u
174180

175181
The following steps show you how to build a firmware image.
176182

177-
#### 1. Run the build script
183+
#### Step 1: Run the build script
178184

179185
To build the firmware image(s), run the following command:
180186

181187
```Shell
182188
bash onion_buildenv build_all_firmware
183189
```
184190

185-
The build should take less than 5 minutes.
191+
The build should take **about 2 minutes.** It might be more or less depending on the CPU performance of your development computer.
186192

187-
#### 2. Locate the compiled firmware image
193+
#### Step 2: Locate the compiled firmware image
188194

189195
Compiled firmware images are in the `output` directory.
190196

191197
The firmware images are named based on the device model name, the OpenWRT version number specified in the `profile` file, and the date of the build: `<BUILD_MODEL>-<OPENWRT_VERSION>-<BUILD_DATE>.bin` .
192198

193-
For example:
199+
##### For example
200+
201+
For an Omega2+ device, with:
202+
- `OPENWRT_VERSION="23.05.3"` set in the `profile` config file
203+
- built on May 31, 2024
194204

195-
For an Omega2+ device, with OPENWRT_VERSION="23.05.3" set in the `profile` config file and built on May 31, 2024. The firmware image name will be `onion_omega2p-23.05.3-20240531.bin`.
205+
The firmware image name will be `onion_omega2p-23.05.3-20240531.bin`.
196206

197207
<!-- NOTE: Ok to keep OpenWRT release numbers hard-coded in this section -->
198208

docs/packages/compile-package.md

Lines changed: 68 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -37,51 +37,59 @@ Onion's OpenWRT SDK wrapper is the recommended method to build packages for Omeg
3737

3838
The system set up instructions are the same for compiling packages in **development** and in **production**. The configuration and compilation steps differ between the two environments.
3939

40-
**Step 1: Set up local environment**
40+
#### A Note on the Build Environment
4141

4242
import BuildEnvNotes from '../firmware/_build-env-notes.mdx';
4343

4444
<BuildEnvNotes tool="OpenWRT SDK" />
4545

46-
**Step 2: Start your Docker Container**
46+
#### Step 1: Pull the Docker Image
4747

48-
import DockerInstructions from '../firmware/_docker-instructions.mdx';
48+
import DockerPullInstructions from '../firmware/_docker-pull-instructions.mdx';
4949

50-
<DockerInstructions/>
50+
<DockerPullInstructions/>
5151

52-
**Step 3: Install software dependancies**
52+
#### Step 2: Start your Docker Container
5353

54-
import InstallDeps from '../firmware/_install-deps.mdx';
54+
import DockerStartInstructions from '../firmware/_docker-start-instructions.mdx';
5555

56-
<InstallDeps/>
56+
<DockerStartInstructions/>
5757

58-
**Step 4: Clone the repository**
58+
#### Step 3: Clone the OnionIoT/penwrt-sdk-wrapper repository
5959

60-
To clone the **openwrt-sdk-wrapper** repository in the development environment, open the terminal and run the following command:
60+
To clone the **openwrt-sdk-wrapper** repository in the Docker container, run the following command:
6161

6262
```shell
6363
git clone https://github.com/OnionIoT/openwrt-sdk-wrapper.git
6464
```
6565

66+
When the repo is cloned, enter the directory:
67+
68+
```shell
69+
cd openwrt-sdk-wrapper
70+
```
71+
6672
## Compiling packages for development
6773

6874
The following sections cover configuration changes and compiling packages for a development environment.
6975

76+
To compile packages for production, see the [relevant section below](#compiling-packages-for-production).
77+
7078
### Config changes
7179

7280
After setting up the `openwrt-sdk-wrapper`, it is necessary to configure the required changes for system updates, package installations, or environment customization.
7381

7482
#### Step 1: Update package feed variable
7583

76-
Locate the `PACKAGE_FEEDS` variable in the profile file and modify it to reference the local source. This is necessary during development if there is a need to retrieve package makefiles from a local repository.
84+
Locate the `PACKAGE_FEEDS` variable in the `profile` file and modify it to reference the local source. This is necessary during development if there is a need to retrieve package makefiles from a local repository.
7785

78-
**Example:** Assuming the custom package source is in the `/home/ubuntu/OpenWRT-Packages` directory, the updated `PACKAGE_FEEDS` variable should be:
79-
80-
```shell
81-
PACKAGE_FEEDS="
82-
src-link custom /home/ubuntu/OpenWRT-Packages
83-
"
84-
```
86+
> **For example:** Assuming the custom package source is in the `/home/ubuntu/OpenWRT-Packages` directory, the updated `PACKAGE_FEEDS` variable should be:
87+
>
88+
>```shell
89+
>PACKAGE_FEEDS="
90+
>src-link custom /home/ubuntu/OpenWRT-Packages
91+
>"
92+
>```
8593
8694
#### Step 2: Run build environment setup script
8795
@@ -97,14 +105,16 @@ After completing this step, the OpenWRT SDK will be downloaded and set up for us
97105
98106
#### Step 1: Run the build script
99107
100-
To compile and build the desired packages, run the following commands in the development environment:
108+
To compile and build the desired packages, run the following command:
101109
102110
```bash
103111
bash onion_buildenv build_packages <PACKAGE_NAME>
104112
```
105113
106114
Replace `<PACKAGE_NAME>` with the actual package name.
107115
116+
This will compile the selected pacakge and its dependencies.
117+
108118
#### Step 2: Compiled package location
109119
110120
All compiled packages can be found in the following directory:
@@ -115,6 +125,8 @@ openwrt-sdk/bin/packages/mipsel_24kc/custom/
115125
116126
These packages have the extension `.ipk` and are compiled specifically for the `mipsel_24kc` architecture. The compiled packages can be used for testing on a device to confirm proper operation.
117127
128+
---
129+
118130
## Compiling packages for production
119131
120132
The following sections cover configuration changes and compiling package feeds for a production environment.
@@ -123,21 +135,24 @@ The following sections cover configuration changes and compiling package feeds f
123135
124136
#### Step 1: Point to the package feed
125137
126-
Navigate to the cloned **openwrt-sdk-wrapper** repo to update the `PACKAGE_FEEDS` variable.
138+
In you local copy of the **openwrt-sdk-wrapper**, update the `PACKAGE_FEEDS` variable in the `profile` configuration file.
127139
128-
Follow these steps:
140+
Use the following syntax:
129141
130-
1. Modify the profile configuration file.
131-
2. Update the `PACKAGE_FEEDS` variable using the following syntax: `src-git <feed-name> <package-feed-url>[;<package-feed-branch>]`
132-
- `<feed-name>`: Choose an arbitrary name for SDK usage.
133-
- `<package-feed-url>`: Provide the Git repository URL.
134-
- `<package-feed-branch>`: Optionally, specify a branch of the package feed repository.
142+
```
143+
src-git <feed-name> <package-feed-url>[;<package-feed-branch>]
144+
```
135145
136-
For example, say the `openwrt-23.05` branch of the `https://github.com/OnionIoT/OpenWRT-Packages` repo is the package feed, the addition to the `PACKAGE_FEEDS` variable should be: <!-- TODO: update this 23.05 with OPENWRT_VERSION variable -->
146+
Replace the placeholder parameters with:
147+
- `<feed-name>` - choose a name for the package feed
148+
- `<package-feed-url>` - provide the Git repository URL
149+
- `<package-feed-branch>` - optionally, specify a branch of the package feed repository
137150
138-
```shell
139-
src-git myfeed https://github.com/OnionIoT/OpenWRT-Packages.git;openwrt-23.05
140-
```
151+
> **For example:** say the `openwrt-23.05` branch of the `https://github.com/OnionIoT/OpenWRT-Packages` repo is the package feed, the addition to the `PACKAGE_FEEDS` variable should be: <!-- TODO: update this 23.05 with OPENWRT_VERSION variable -->
152+
>
153+
> ```shell
154+
> src-git myfeed https://github.com/OnionIoT/OpenWRT-Packages.git;openwrt-23.05
155+
>```
141156
<!-- TODO: update this 23.05 with OPENWRT_VERSION variable -->
142157
143158
#### Step 2: Select packages from the package feed
@@ -148,17 +163,17 @@ To select specific packages from the package feed to compile, follow these steps
148163
2. Locate the `SDK_PACKAGES` variable.
149164
3. Modify the `SDK_PACKAGES` variable to include the packages from the package feed that you want to compile. Ensure that the list is new-line delimited.
150165
151-
For example:
152-
153-
```shell
154-
SDK_PACKAGES="
155-
custom-lib
156-
custom-package1
157-
new-software
158-
"
159-
```
160-
161-
In this example, `custom-lib`, `custom-package1`, and `new-software` packages, along with any dependencies they require, will be compiled and built.
166+
>For example:
167+
>
168+
>```shell
169+
>SDK_PACKAGES="
170+
> custom-lib
171+
> custom-package1
172+
> new-software
173+
> "
174+
> ```
175+
>
176+
>In this example, `custom-lib`, `custom-package1`, and `new-software` packages, along with any dependencies they require, will be compiled and built.
162177
163178
#### Step 3: Set up the SDK and environment
164179
@@ -172,28 +187,35 @@ First, download and setup the OpenWRT SDK with the following command:
172187
173188
#### Step 1: Build packages
174189
175-
Build and compile all desired packages listed in the `SDK_PACKAGES` variable in the profile, and run the following command:
190+
Build and compile all the packages listed in the `SDK_PACKAGES` variable in the profile, along with their dependencies, by running the following command:
176191
177192
```bash
178193
bash onion_buildenv build_all_packages
179194
```
180195
181-
#### Step 2: Compiled packages location
196+
Compilation time depends on the packages that are being compiled. Packages that are complex and/or have many dependencies take longer to compile. For reference, it takes about 30 minutes to compile the packages from the [OnionIoT/OpenWRT-Packages repo](https://github.com/OnionIoT/openwrt-packages/tree/openwrt-23.05).
197+
198+
#### Step 2: Compiled package location
182199
183200
All compiled packages can be found in the following directory:
184201
185202
```shell
186203
openwrt-sdk/bin/packages/mipsel_24kc/<feed-name>/
187204
```
188205
189-
Where `<feed-name>` is the name of the feed that was added to the `profile` configuration file in Step 1 above.
206+
Where `<feed-name>` is the name of the feed that was added to the `profile` configuration file in [Step 1 in the Config Changes section above](#config-changes-1).
207+
208+
The packages have the extension `.ipk` and are compiled specifically for the Omega2 `mipsel_24kc` architecture. Also included are **package index files** that are required by OPKG on the device to recognize and install the packages from the repository.
190209
191-
The packages have the extension `.ipk` and are compiled specifically for the `mipsel_24kc` architecture. Also included are package index files that will be used by the package manager on the device to install the packages.
192210
193-
:::note Important note
211+
:::info Package Indexing and Signing
194212
195-
The last step of compiling a package feed is creating an index of the packages and signing the packages. This step is required so the compiled packages can be used as an opkg package repository by the device.
213+
The last step of compiling a package feed is creating an index of the packages and signing the packages. This step is required so the compiled packages can be used as a package repository by the device.
214+
215+
When the `bash onion_buildenv build_all_packages` command is run, the Onion OpenWRT SDK Wrapper will automatically perform indexing and signing as the last step.
196216
197217
:::
198218
219+
The compiled packages can now be deployed as a package repo. See the [Deploy a Package Repo article](./deploy-package-repo) for more details.
220+
199221
<GiscusDocComment />

0 commit comments

Comments
 (0)