Skip to content

Commit c8e280b

Browse files
committed
improve buildroot, restore kernel_vermagic
1 parent 92d3a56 commit c8e280b

7 files changed

Lines changed: 281 additions & 74 deletions

File tree

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@ node_modules/
1717

1818
/docs/build/lime-sdk.md
1919

20-
!/docs/development/hacking/kernel_vermagic.md
21-
/docs/development/**
20+
/docs/development/*
21+
!/docs/development/hacking/
22+

docs/build/buildroot.md

Lines changed: 170 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,20 @@ aside: false
44

55
<script setup>
66
import { data as openwrt } from '/openwrt.data.js'
7+
8+
let arch = 'mips_24kc'
9+
let target ='ath79-generic'
10+
let _target =target.replace('-','/')
11+
12+
const build = {
13+
arch: arch,
14+
target: target,
15+
file_host: "https://downloads.openwrt.org",
16+
download_file: "imagebuilder-.*x86_64.tar.[xz|zst]",
17+
profile: "librerouter_librerouter-v1"
18+
}
19+
20+
721
</script>
822

923
# Buildroot
@@ -22,24 +36,27 @@ gcc-multilib g++-multilib gettext git libncurses5-dev libssl-dev \
2236
python3-setuptools rsync swig unzip zlib1g-dev file wget
2337
```
2438

25-
## Clone the OpenWrt source code
39+
## Download
40+
41+
### Clone the OpenWrt source code
2642
Refers to the OpenWrt wiki [Build System Usage](https://openwrt.org/docs/guide-developer/toolchain/use-buildsystem).
2743
Run all the above commands as normal user (do not use root).
2844

2945
::: code-group
3046

31-
``` sh-vue [{{ openwrt.stable_version }}]
47+
```sh-vue [{{ openwrt.stable_version }}]
3248
git clone -b v{{ openwrt.stable_version }} --single-branch https://github.com/openwrt/openwrt
3349
cd openwrt
3450
```
3551

36-
``` sh-vue [{{ openwrt.oldstable_version }}]
52+
```sh-vue [{{ openwrt.oldstable_version }}]
3753
git clone -b v{{ openwrt.oldstable_version }} --single-branch https://github.com/openwrt/openwrt
3854
cd openwrt
3955
```
4056

4157
:::
4258

59+
### Add the LibreMesh feeds
4360
Copy the defalt OpenWrt repositories file, and add the LibreMesh repositories
4461

4562
::: tip
@@ -49,15 +66,15 @@ Use `2024.1` to build the latest LibreMesh release (compatible with openwrt-24.1
4966

5067
::: code-group
5168

52-
``` sh [master]
69+
```sh [master]
5370
cp feeds.conf.default feeds.conf
5471
cat << EOF >> feeds.conf
5572
src-git libremesh https://github.com/libremesh/lime-packages.git;master
5673
src-git profiles https://github.com/libremesh/network-profiles.git
5774
EOF
5875
```
5976

60-
``` sh [2024.1]
77+
```sh [2024.1]
6178
cp feeds.conf.default feeds.conf
6279
cat << EOF >> feeds.conf
6380
src-git libremesh https://github.com/libremesh/lime-packages.git;v2024.1
@@ -68,115 +85,205 @@ EOF
6885
:::
6986

7087

71-
### Update the packages from the feeds
72-
``` sh
88+
### Download and install packages from the feeds
89+
```sh
7390
scripts/feeds update -a
7491
scripts/feeds install -a
7592
```
7693

7794

78-
### Run the configuration menu
95+
## Configure
96+
97+
### Using menuconfig
7998
```
8099
make menuconfig
81100
```
82101

102+
![menuconfig1](/buildroot-menuconfig0.webp)
83103

104+
Check out the `target`, `subtarget` and `profile` of your router on [OpenWrt Table of Hardware](https://toh.openwrt.org).
84105

106+
Select then:
107+
- `Target System` - default `Mediatek ARM`
108+
- `Subtarget` - default `Filogic`
109+
- `Target Profile` - default`OpenWrt One`
85110

86-
Check out the +target+ (e.g. +ATH79+), +subtarget+ (e.g. +generic+) and +profile+ (e.g. +tl-wdr3600-v1+) of your router on [OpenWrt table of hardware](https://openwrt.org/toh/start).
111+
#### Packages selection
87112

88-
Select the _Target System_, _Subtarget_ and _Target Profile_ accordingly.
113+
##### Default packages
114+
**Deselect** conflicting Packages:
89115

116+
- `Base system` -> `< >` `dnsmasq`
117+
- `Network` -> `< >` `odhcpd-ipv6only`
118+
119+
By default LibreMesh uses `dnsmasq-dhcpv6` instead of the OpenWrt's default `dnsmasq` and `odhcpd-ipv6only`.
90120

91121
**Deselect** erroneous feeds locations:
92122

93-
- Image configurationSeparate feed repositoriesEnable feed libremesh
94-
- Image configurationSeparate feed repositoriesEnable feed profiles
123+
- `Image configuration` -> `Separate feed repositories` -> `< >` `Enable feed libremesh`
124+
- `Image configuration` -> `Separate feed repositories` -> `< >` `Enable feed profiles`
95125

96-
**Deselect** problematic packages:
126+
OpenWrt packages are available from the download server https://downloads.openwrt.org.
127+
Remove LibreMesh repositories from this list since precompiled packages will not be available from there.
128+
Precompiled LibreMesh packages are available from https://feed.libremesh.org/.
129+
These are installable:
130+
- via package manager directly on the router
131+
- via ImageBuilder during the firmware generation
97132

98-
- Base system -> dnsmasq
99-
- Network -> odhcpd-ipv6only
133+
##### Saving space and RAM
100134

101135
Optionally, **deselect** unused packages:
102-
- Network -> ppp
136+
- `Network` -> `< >` `ppp`
137+
- `Network` -> `< >` `ppp-mod-pppoe`
138+
- `Kernel Modules` -> `Network Support` -> `< >` `kmod-ppp`
139+
- `Kernel Modules` -> `Network Support` -> `< >` `kmod-pppoe`
140+
- `Kernel Modules` -> `Network Support` -> `< >` `kmod-pppox`
103141

104-
If you local community has a profile in the [network-profiles repository](https://github.com/libremesh/network-profiles/), you can select it in:
142+
Refers to [Packages Selection](../guide/packages-selection#saving-space-and-ram) for a list of other optionally deselectable packages.
105143

106-
- LibreMesh -> network-profile -> profile-your_community-your_profile
144+
##### LibreMesh packages
145+
**Select** (press space until when an asterisk appears, like `<*>`) LibreMesh packages:
107146

108-
::: tip NOTE
109-
Network profiles are the specific configuration from the communities, and are stored in this collective
110-
[repository](https://github.com/libremesh/network-profiles/), but they can also be kept locally, depending on how every community network manages itself. For more instructions on how to create a profile or how to use a local one, check out the [network profiles page](../guide/network-profiles).
111-
:::
147+
![menuconfig1](/buildroot-menuconfig1.webp)
148+
149+
* `LibreMesh``Offline Documentation``<*>` `lime-docs-minimal` (LibreMesh minimal documentation)
150+
* `LibreMesh``<*>` `lime-app` (LimeApp) **(optional)**
151+
* `LibreMesh``<*>` `lime-hwd-openwrt-wan` (Respect openwrt wan interface as default)
152+
* `LibreMesh``<*>` `lime-proto-anygw` (LibreMesh anygw proto support)
153+
* `LibreMesh``<*>` `lime-proto-babeld` (LibreMesh babeld proto support)
154+
* `LibreMesh``<*>` `lime-proto-batadv` (LibreMesh batman-adv proto support)
155+
* `LibreMesh``<*>` `shared-state`
156+
* `LibreMesh``<*>` `shared-state-async` **(optional)**
157+
* `<*>` `shared-state-babeld_hosts` (babeld-hosts module for shared-state)
158+
* `<*>` `shared-state-bat_hosts` (bat-hosts module for shared-state) **(optional)**
159+
* `<*>` `shared-state-nodes_and_links` (nodes_and_links module for shared-state)
160+
* `LibreMesh` -> `<*>` `babeld-auto-gw-mode`
161+
* `LibreMesh` -> `<*>` `check-date-http` (Keep local date under NTP too far away skew) **(optional)**
162+
* `LibreMesh` -> `<*>` `Offline Documentation` -> `lime-docs` (LibreMesh full documentation) **(optional)**
163+
* `LibreMesh` -> `<*>` `lime-debug` (libremesh debug utils) **(optional)**
164+
165+
**Optional packages** are recommended but not mandatory for a working LibreMesh network.
166+
Consider avoiding to select these packages `only` if the created image is too large and does not fit in the router memory.
112167

113-
**Select** (press space until when an asterisk appears, like `<*>`) LibreMesh packages:
168+
Additionally and optionally, httpS for the web interface can be enabled selecting (beware that the web interace will be shown as *not trusted*):
169+
170+
- `Utilities` -> `Encryption` -> `<*>` `px5g-standalone`
114171

115-
* LibreMesh → Offline Documentation → lime-docs-minimal (LibreMesh minimal documentation)
116-
* LibreMesh → lime-app (LibreMeshApp)
117-
* LibreMesh → lime-hwd-openwrt-wan (Respect openwrt wan interface as default)
118-
* LibreMesh → lime-proto-anygw (LibreMesh anygw proto support)
119-
* LibreMesh → lime-proto-babeld (LibreMesh babeld proto support)
120-
* LibreMesh → lime-proto-batadv (LibreMesh batman-adv proto support)
121-
* LibreMesh → shared-state
122-
** shared-state-babeld_hosts (babeld-hosts module for shared-state)
123-
** shared-state-bat_hosts (bat-hosts module for shared-state)
124-
** shared-state-nodes_and_links (nodes_and_links module for shared-state)
125-
* LibreMesh -> babeld-auto-gw-mode
172+
If you planning to use encrypted 802.11s mesh, you need to make sure to have the `wpad-mesh-*`, not `wpad-basic-*` package, where `*` is `mbedtls`, `openssl` or `wolfssl`. OpenWrt since branch 23.05 by default uses `mbedtls`.
173+
- `Network` -> `WirelessAPD` -> `< >` `wpad-basic-mbedtls`
174+
- `Network` -> `WirelessAPD` -> `<*>` `wpad-mesh-mbedtls`
126175

127176
::: tip NOTE
128-
If after the compilation you don't see the compiled image in the `bin/targets/.../.../` folder, it is possible that your router has such a small flash memory that the aforementioed packages don't fit in it (it can happen also with routers having 8 MB of flash memory when selecting huge packages to be included). In this case, you can remove the `.config` generated packages list and repeat the packages selection without including `lime-app`. If the compiled image is still too large, try selecting only `lime-proto-anygw`, `lime-proto-batadv` and `lime-proto-babeld` or following [this guide](https://openwrt.org/docs/guide-user/additional-software/saving_space).
177+
In order to have additional packages, the easiest way is to select them in menuconfig. More packages can be installed afterwards via `apk` or the older `opkg`, but some of these require a specific kernel configuration to be in place. This can be achieved following [these additional instructions dealing with kernel vermagic](../development/hacking/kernel_vermagic.md) Beware that this will increase noticeably the time and storage space required for the compilation.
129178
:::
130179

131-
Some more packages are recommended but not mandatory for a working LibreMesh network. Consider avoiding to select the following packages _only_ if the created image is too large and does not fit in the router memory.
180+
#### Save the configuration
181+
Save the configuration and exit.
132182

133-
- LibreMesh -> check-date-http (Keep local date under NTP too far away skew)
134-
- LibreMesh -> Offline Documentation -> lime-docs (LibreMesh full documentation)
135-
- LibreMesh -> lime-debug (libremesh debug utils)
183+
#### Additional files
136184

137-
Additionally and optionally, httpS for the web interface can be enabled selecting (beware that the web interace will be shown as *not trusted*):
185+
At this stage there is the possibility to include custom files in the compiled firmware image. For this, you will have to create, inside the `openwrt/` directory, a `files/` directory containing the directory structure and files you want to add. For example, if you want to have a `/etc/config/lime-community` file you need to do the following:
138186

139-
- Utilities -> Encryption -> px5g-standalone
187+
``` sh
188+
mkdir -p files/etc/config/
189+
touch files/etc/config/lime-community
190+
```
140191

141-
Finally, also the 802.11s mesh connections can be password protected, this will require a specific configuration and this package to be selected:
192+
and then edit the newly created `lime-community` file including your custom content. If a file from a package has the same name and path as a file in this directory, it will be overwritten. This is a quick way to include a custom configuration file, without the need to create an online [network profile](../guide/network-profiles).
142193

143-
- Network -> WirelessAPD -> wpad-mesh-openssl
144194

145-
and this to be **de**-selected:
195+
##### Network Profiles
196+
If you local community has a profile in the [network-profiles repository](https://github.com/libremesh/network-profiles/), you can select it in:
197+
198+
- LibreMesh -> network-profile -> profile-your_community-your_profile
146199

147-
- Network -> WirelessAPD -> wpad-basic-mbedtls
200+
![menuconfig2](/buildroot-menuconfig2.webp)
148201

149202
::: tip NOTE
150-
In order to have additional packages, the easiest way is to select them in menuconfig. More packages can be installed afterwards via +opkg+, but some of these require a specific kernel configuration to be in place. This can be achieved following link:development-kernel_vermagic.html[these additional instructions dealing with kernel vermagic]. Beware that this will increase noticeably the time and storage space required for the compilation.
203+
Network profiles are the specific configuration from the communities, and are stored in this collective
204+
[repository](https://github.com/libremesh/network-profiles/), but they can also be kept locally, depending on how every community network manages itself. For more instructions on how to create a profile or how to use a local one, check out the [network profiles page](../guide/network-profiles).
151205
:::
152206

153-
Save and exit.
154207

155-
At this stage there is the possibility to include custom files in the compiled firmware image. For this, you will have to create, inside the `openwrt/` directory, a `files/` directory containing the directory structure and files you want to add. For example, if you want to have a `/etc/config/lime-community` file you need to do the following:
208+
### Using make defconfig
156209

157-
``` sh
158-
mkdir -p files/etc/config/
159-
touch files/etc/config/lime-community
210+
#### export target-subtarget to env
211+
``` sh-vue
212+
export TARGET={{ build.target }}
213+
export ARCH=$(curl -s https://downloads.openwrt.org/snapshots/.targets.json | \
214+
sed 's/\//-/' | jq -r '."${TARGET}"')
160215
```
161216

162-
and then edit the newly created `lime-community` file including your custom content. If a file from a package has the same name and path as a file in this directory, it will be overwritten. This is a quick way to include a custom configuration file, without the need to create an online [network profile](../guide/network-profiles).
217+
#### configure
163218

164-
.Finally, compile the images
165-
``` sh
166-
make -j$(nproc)
219+
#### Target, subtarget and generic configs
220+
221+
```sh
222+
cat << EOF > .config
223+
CONFIG_TARGET_${TARGET}=y
224+
CONFIG_TARGET_${TARGET}_${SUBTARGET}=y
225+
CONFIG_TARGET_ROOTFS_INITRAMFS=y
226+
CONFIG_TARGET_MULTI_PROFILE=y
227+
CONFIG_TARGET_PER_DEVICE_ROOTFS=y
228+
# CONFIG_FEED_libremesh is not set
229+
# CONFIG_FEED_profiles is not set
230+
CONFIG_IMAGEOPT=y
231+
CONFIG_VERSIONOPT=y
232+
CONFIG_KERNEL_BUILD_USER=\"builder\"
233+
CONFIG_KERNEL_BUILD_DOMAIN=\"buildhost\"
234+
# CONFIG_VERSION_CODE_FILENAMES is not set
235+
EOF
236+
make defconfig
237+
```
238+
239+
#### Kernel modules (optional)
240+
Optional build all kernel modules to later expose them in an http server
241+
Needed to install via the package manager packages that depend on non-defaults kernel modules.
242+
```sh
243+
cat << EOF >> .config
244+
CONFIG_DEVEL=y
245+
CONFIG_ALL_KMODS=y
246+
CONFIG_ALL_NONSHARED=y
247+
EOF
248+
make defconfig
167249
```
168250

169-
If everything goes well you should find the produced binaries inside the +bin/+ directory.
251+
#### LibreMesh packages
252+
```sh
253+
cat << EOF >> .config
254+
# CONFIG_PACKAGE_dnsmasq is not set
255+
# CONFIG_PACKAGE_odhcpd-ipv6only is not set
256+
# CONFIG_PACKAGE_ppp is not set
257+
# CONFIG_PACKAGE_ppp-mod-pppoe is not set
258+
CONFIG_PACKAGE_kmod-ppp=m
259+
CONFIG_PACKAGE_kmod-pppoe=m
260+
CONFIG_PACKAGE_kmod-pppox=m
261+
CONFIG_PACKAGE_profile-libremesh-suggested-packages=y
262+
EOF
263+
make defconfig
264+
```
170265

171-
== Emulating on your computer with qemu
266+
#### Router profile
267+
Selects the router profile based on the compatible string:
172268

173-
Its possible to emulate a image compiled for x86_64 architecture. See [script](https://github.com/libremesh/lime-packages/tree/master/tools) qemu_dev_start.sh and qemu_dev_stop.sh scripts.
269+
```
270+
echo "CONFIG_TARGET_DEVICE_ath79_generic_DEVICE_librerouter_librerouter-v1=y" >> .config
271+
make defconfig
272+
```
174273

175-
::: tip NOTE
176-
You will be running something like:
177-
``` sh
178-
sudo ./qemu_dev_start openwrt-x86-64-combined-ext4.img openwrt-x86-64-ramfs.bzImage
274+
## Build Libremesh
275+
276+
Finally, compile the images
277+
```sh
278+
make -j$(nproc)
179279
```
180-
More information in [TESTING.md](https://github.com/libremesh/lime-packages/blob/master/TESTING.md)
280+
Refers to OpenWrt [make tips](https://openwrt.org/docs/guide-developer/toolchain/use-buildsystem#make_tips) for detailed options.
281+
282+
If everything goes well you should find the produced binaries inside the `bin/` directory.
181283

284+
::: tip NOTE
285+
If after the compilation you don't see the compiled image in the `bin/targets/.../.../` folder, it is possible that your router has such a small flash memory that the aforementioed packages don't fit in it (it can happen also with routers having 8 MB of flash memory when selecting huge packages to be included). In this case, you can remove the `.config` generated packages list and repeat the packages selection without including `lime-app`. If the compiled image is still too large, try selecting only `lime-proto-anygw`, `lime-proto-batadv` and `lime-proto-babeld` or following [this guide](https://openwrt.org/docs/guide-user/additional-software/saving_space).
182286
:::
287+
288+
Refers to the pages under **Development guide** [testing](/development/testing) and [virtualizing](/development/virtualizing)
289+
for emulating on your computer with qemu.

0 commit comments

Comments
 (0)