Skip to content

Commit 1ac5d57

Browse files
authored
Merge pull request #32 from YIO-Remote/dev
Enhanced build and improved wifi scripts
2 parents bed9888 + c918c3e commit 1ac5d57

File tree

134 files changed

+1801
-8291
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

134 files changed

+1801
-8291
lines changed

.gitattributes

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# https://git-scm.com/docs/gitattributes
2+
#
3+
4+
# Set the default behavior, in case people don't have core.autocrlf set.
5+
* text=auto
6+
7+
# Declare files that will always have LF line endings on checkout.
8+
*.sh text eol=lf
9+
10+
# Declare files that will always have CRLF line endings on checkout.
11+
*.cmd text eol=crlf

.gitignore

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,3 @@
1-
/output
2-
/dl
3-
/.auto.deps
4-
/.config.cmd
5-
/.config.old
6-
/..config.tmp
7-
/.config
8-
*.depend
9-
*.o
10-
/*.patch
11-
/*.diff
12-
*.orig
13-
*.rej
14-
*~
15-
*.pyc
16-
*.bak
17-
*.old
18-
*.log
19-
201
### macOS ###
212
# General
223
.DS_Store
@@ -81,3 +62,24 @@ $RECYCLE.BIN/
8162

8263
# Windows shortcuts
8364
*.lnk
65+
66+
# Project specific
67+
/output
68+
/dl
69+
/.auto.deps
70+
/.config.cmd
71+
/.config.old
72+
/..config.tmp
73+
/.config
74+
*.depend
75+
*.o
76+
/*.patch
77+
/*.diff
78+
*.orig
79+
*.rej
80+
*~
81+
*.pyc
82+
*.bak
83+
*.old
84+
*.log
85+
.toolchain-ready

Config.in

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# make the variant name available as a Config.in variable
2+
#
3+
# you can use BR2SM_PROJECT_NAME to have some options only appear for some variants
4+
#
5+
config BR2SM_PROJECT_NAME
6+
string
7+
option env="PROJECT_NAME"

Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# This file is part of buildroot-submodule.
2+
#
3+
# buildroot-submodule is free software: you can redistribute it and/or modify
4+
# it under the terms of the GNU General Public License as published by
5+
# the Free Software Foundation, either version 3 of the License, or
6+
# (at your option) any later version.
7+
#
8+
# buildroot-submodule is distributed in the hope that it will be useful,
9+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
# GNU General Public License for more details.
12+
#
13+
# You should have received a copy of the GNU General Public License
14+
# along with buildroot-submodule. If not, see <http://www.gnu.org/licenses/>. 2
15+
16+
17+
#Makefile for the YIO-remote rpi0 project
18+
PROJECT_NAME := rpi0
19+
20+
include common.mk

README.md

Lines changed: 116 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,48 @@
11
# YIO Remote OS Repository
22

3-
For details about the YIO Remote, please visit our documentation repository which can be found under
4-
<https://github.com/YIO-Remote/documentation>
3+
For details about the YIO Remote, please visit our documentation wiki: <https://github.com/YIO-Remote/documentation/wiki>
54

6-
This repository contains the custom Linux OS built with [buildroot](https://www.buildroot.org/) for the YIO Remote.
5+
This repository contains the custom Linux OS for the YIO Remote application.
6+
It is built with [Buildroot](https://www.buildroot.org/) and managed with [Buildroot Submodule](README_buildroot-submodule.md).
77

88
## Build
99

1010
Requirements:
1111

12-
- Preferably a Linux box or VM.
13-
- At least 20 GB of free space.
12+
- A Linux box or VM, otherwise Docker.
13+
- At least 20 GB of free space. A SSD is highly recommended.
1414
- At least 4 GB RAM. More RAM = better file system caching.
15-
- Fast CPU with many cores for quicker build times.
16-
- SSD is highly recommended.
15+
- Fast CPU. More cores = quicker build times.
1716
- Internet connection: packages will be downloaded during the build.
1817
- 1+ GB microSD card
1918
- Future images might be larger!
2019
- Recommended card: Samsung EVO Plus (64 and 128GB have much higher write speed!)
2120
- See: [RPi microSD card performance comparison 2019](https://www.jeffgeerling.com/blog/2019/raspberry-pi-microsd-card-performance-comparison-2019)
2221

23-
### Prepare Build Environment
22+
### Docker
23+
24+
If you don't have a Linux machine then the easiest way to build all Qt projects and the SD card image is with the provided Docker image.
25+
26+
Features:
27+
28+
- Buildroot build and output directories are stored in a Docker Volume due to hard links performance reasons.
29+
- Binary outputs are copied to bind mounted directory on the host.
30+
- YIO Remote projects can be bind mounted from the host or stored in a Docker Volume.
31+
- A convenient build script handles all common build tasks (single project builds, full build, Git operations, etc.).
32+
33+
See dedicated [Docker Readme](docker/README.md) for further information.
34+
35+
### Linux
2436

25-
#### Linux Ubuntu 18.04.3 or newer
37+
The build process has been tested on Ubuntu 18.04.3, 19.04 and 19.10. Other Linux distributions should work as well.
2638

27-
- If you just need a headless build VM then use the minimal [Ubuntu 18.04.3 LTS Server](http://cdimage.ubuntu.com/releases/18.04.3/release/) version.
28-
- Some packages might already be installed depending on the version (desktop or server).
39+
#### Prepare Build Environment
40+
41+
The minimal [Ubuntu 18.04.3 LTS Server](http://cdimage.ubuntu.com/releases/18.04.3/release/) version is well suited for a headless build VM. Use a desktop version if the VM should also be used for Qt development with Qt Creator.
2942

3043
Install required tools:
3144

32-
1. Prepare Ubuntu for buildroot:
45+
1. Prepare Ubuntu to build the Buildroot toolchain:
3346

3447
sudo apt-get install \
3548
build-essential \
@@ -41,77 +54,134 @@ Install required tools:
4154
libtool \
4255
python \
4356
texinfo \
44-
unzip
57+
unzip \
58+
screen \
59+
openssh-server
4560

46-
2. Optional: convenient packages for development
61+
The system is now ready to compile Buildroot and build the base Linux image for YIO.
4762

48-
sudo apt-get install \
49-
mc \
50-
nano \
51-
screen
63+
2. Optional: Qt Linguist.
64+
Qt Linguist is required to compile language files in *remote-software* before cross compilation.
65+
- Unfortunately there's no standalone package of the required command line tools `lupdate` and `lrelease`. Therefore the complete Qt development environment needs to be installed!
66+
- Attention: only use *apt* to install Qt on Ubuntu 19.10 or newer! Otherwise the Qt version is too old and the command line tools might be incompatible. Use the [Qt online installer](https://www.qt.io/download-open-source) instead.
5267

53-
3. Optional: SSH server for remote access
68+
sudo apt-get install \
69+
qttools5-dev-tools qt5-default
5470

55-
sudo apt-get install openssh-server
71+
3. Optional: dependencies for Qt development and building Linux target in Qt Creator:
5672

57-
#### macOS
73+
sudo apt-get install \
74+
libavahi-client-dev \
75+
libgl1-mesa-dev
5876

59-
TODO
77+
#### Build Environment Variables
6078

61-
#### Windows
79+
The following optional environment variables control where the build output and other artefacts during the build are stored:
6280

63-
TODO maybe
81+
| **Variable** | **Description** |
82+
|--------------------------|------------------|
83+
| `BUILDROOT_OUTPUT` | Buildroot output directory. Default: ./rpi0/output |
84+
| `BR2_DL_DIR` | Buildroot download directory. Default: $HOME/buildroot/dl |
85+
| `BR2_CCACHE_DIR` | Buildroot ccache directory. Default: $HOME/buildroot/ccache |
6486

65-
### Build SD Card Image
87+
#### Initial Checkout and Toolchain Build
6688

67-
#### Initial Checkout
89+
Checkout project and build full cross compiler toolchain incl. target system:
6890

91+
# define root directory for project checkout
6992
SRC_DIR=~/projects/yio
7093

71-
mkdir -p ${SRC_DIR}
72-
cd ${SRC_DIR}
94+
mkdir -p $SRC_DIR
95+
cd $SRC_DIR
7396
git clone https://github.com/YIO-Remote/remote-os.git
7497

7598
# switch to development branch
7699
cd remote-os
77100
git checkout develop
78101

79-
# checkout buildroot (Git submodule)
80-
git submodule init
81-
git submodule update
102+
# build full toolchain without YIO remote SD card image
103+
make SKIP_BUILD_IMAGE=y
82104

83-
#### Build Image
105+
This will take at least an hour or much longer on a slower system.
106+
The `make` command will automatically initialize the buildroot Git submodule (`git submodule init && git submodule update`).
84107

85-
cd ${SRC_DIR}/remote-os/buildroot
86-
87-
make defconfig BR2_DEFCONFIG=../yio_rpi0w_defconfig
108+
#### Build SD Card Image
109+
110+
The SD card image build requires at least a YIO remote configuration file in `./rpi0/boot/config.json`. The latest version can be found in the [remote-software](https://github.com/YIO-Remote/remote-software) repository.
111+
Furthermore all application binaries and resources have to be put in `./overlay/usr/bin/yio-remote/`. These are the remote-software binary, integration plugins, fonts, icons, images and the web-configurator. See [build script in the Docker image](docker/yio-image/scripts/yio.sh) for a quick and dirty approach until each component will be properly released.
112+
113+
Once all resources are in place the build is a simple command:
114+
115+
cd $SRC_DIR/remote-os
88116
make
89117

90118
Hint: redirect the `make` output log into a logfile to easy find an error during building or when using `screen` without scrollback capability:
91119

92-
make 2>&1 | tee ../buildlog-$(date +"%Y%m%d_%H%M%S").log
120+
make 2>&1 | tee remote-os_build_$(date +"%Y%m%d_%H%M%S").log
121+
122+
The final SD card image will be written to: `${BUILDROOT_OUTPUT}/images/yio-remote-sdcard.img`
123+
124+
### Buildroot Commands
93125

94-
The built SD card image can be found at: `${SRC_DIR}/remote-os/buildroot/output/images/yio-remote-sdcard.img`
126+
All Buildroot make commands must be executed in the `remote-os` project and *not* within the /buildroot sub-directory!
127+
The main makefile wraps all comands and takes care of configuration handling and output directories.
128+
Most important commands:
95129

96-
#### Buildroot Commands
130+
| **Command** | **Description** |
131+
|--------------------------|------------------|
132+
| `make` | Update configuration from project's defconfig and start build. |
133+
| `make clean` | Deletes all of the generated files, including build files and the generated toolchain! |
134+
| `make menuconfig` | Shows the configuration menu with the project's defconfig. All changes will be written back to the project configuration. |
135+
| `make linux-menuconfig` | Configure Linux kernel options. |
136+
| `make help` | Shows all options. |
97137

98-
TODO: shortly describe the main commands (menuconfig, clean, rebuild, etc.)
138+
The project configuration in `rpi0/defconfig` is automatically loaded and saved back depending on the Buildroot command (see [common.mk](common.mk)). Manual `make savedefconfig BR2_DEFCONFIG=...` and `make defconfig BR2_DEFCONFIG=...` commands are no longer required and automatically taken care of!
99139

100-
#### Write SD Card Image
140+
## Write SD Card Image
101141

102142
Use [balenaEtcher](https://www.balena.io/etcher/) - available for Linux, macOS and Windows - or your favorite tool.
103143

104144
## Technology Research
105145

106146
The following technologies were / are investigated for finding an easy and automated solution to build the RPi image.
107147

108-
### Docker
148+
### Build and Use external Toolchain with Buildroot
149+
150+
A separate toolchain would speed up the build process. This can easily be achieved with [Buildroot Submodule](https://github.com/Openwide-Ingenierie/buildroot-submodule#using-buildroot-submodule-to-build-a-toolchain-separately).
151+
152+
A *make clean* will no longer erase the compiler toolchain and therefore speedup a new full build. Since Qt is required to build the YIO remote projects the complete Qt tools would have to be included as well to use the separate toolchain for the remote-software and -plugin projects. Therefore we are not using this feature to keep it simple and not to introduce another build dependency.
109153

110-
Docker works best for running services. But it can also be used to build software or anything else. Well, that's a service too :-)
154+
Using an external toolchain involves the following changes:
111155

112-
TODO:
156+
1. Dedicated Makefile for the toolchain: `Makefile.toolchain`
113157

114-
- [ ] Docker setup using Docker Volumes for the build cache. (Volume mounts have too many issues on Windows).
158+
PROJECT_NAME := toolchain
159+
include common.mk
160+
161+
2. A toolchain subproject with the toolchain configuration: `toolchain/defconfig`
162+
163+
BR2_arm=y
164+
BR2_arm1176jzf_s=y
165+
BR2_DL_DIR="$(HOME)/buildroot/dl"
166+
BR2_PACKAGE_OVERRIDE_FILE="$(BR2_EXTERNAL_BUILDROOT_SUBMODULE_PATH)/local.mk"
167+
BR2_GLOBAL_PATCH_DIR="$(BR2_EXTERNAL_BUILDROOT_SUBMODULE_PATH)/patch"
168+
BR2_TOOLCHAIN_BUILDROOT_GLIBC=y
169+
BR2_KERNEL_HEADERS_CUSTOM_TARBALL=y
170+
BR2_KERNEL_HEADERS_CUSTOM_TARBALL_LOCATION="https://github.com/raspberrypi/linux/archive/raspberrypi-kernel_1.20190401-1.tar.gz"
171+
BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_14=y
172+
BR2_TOOLCHAIN_BUILDROOT_CXX=y
173+
BR2_INIT_NONE=y
174+
# BR2_PACKAGE_BUSYBOX is not set
175+
# BR2_TARGET_ROOTFS_TAR is not set
176+
177+
3. Referencing the external toolchain in the main project: `rpi0/defconfig`
178+
179+
BR2_TOOLCHAIN_EXTERNAL=y
180+
BR2_TOOLCHAIN_EXTERNAL_PATH="$(BR2_EXTERNAL_BUILDROOT_SUBMODULE_PATH)/toolchain/output/host/usr"
181+
BR2_TOOLCHAIN_EXTERNAL_GCC_8=y
182+
BR2_TOOLCHAIN_EXTERNAL_HEADERS_4_14=y
183+
BR2_TOOLCHAIN_EXTERNAL_CUSTOM_GLIBC=y
184+
BR2_TOOLCHAIN_EXTERNAL_CXX=y
115185

116186
### Vagrant
117187

@@ -121,13 +191,10 @@ Found issues so far:
121191

122192
- Almost all official Linux boxes have a 'small' 10 GB disk:
123193
- Not enough to build the image.
124-
- No standard way of extending the disk, or limited to one virtualization provider.
194+
- No standard way of extending the disk, or limited to one virtualization provider (vagrant-disksize plugin).
125195
- Synced folders don't work because of hard links
126196
- Serious issues with VirtualBox 6 in combination with newer Ubuntu images
127197
- Bootup takes 5+ minutes instead of seconds
128198
- Issue is something with the UART console
129199

130-
TODO:
131-
132-
- [ ] Search for suitable official Box with at least 20 GB volume
133-
- [ ] Investigate further...
200+
Vagrant might be investigated again in the future. For now the Docker Image provides an easy way to build on Linux, macOS and Windows.

0 commit comments

Comments
 (0)