forked from drewmoseley/mender-convert-integration-scripts
/
build-uboot-rpi.sh
executable file
·108 lines (90 loc) · 2.75 KB
/
build-uboot-rpi.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/bin/bash
# Copyright 2022 Northern.tech AS
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Script to generate Mender integration binaries for Raspberry Pi boards
#
# Files that will be packaged:
#
# - u-boot.bin
# - fw_printenv
# - fw_env.config
# - boot.scr
#
# NOTE! This script is not necessarily well tested and the main purpose
# is to provide an reference on how the current integration binaries where
# generated.
set -e
function usage() {
echo "./$(basename $0) <defconfig> <board name>"
}
if [ -z "$1" ] || [ -z "$2" ]; then
usage
exit 1
fi
# Availabile defconfigs:
#
# - rpi_0_w_defconfig
# - rpi_3_32b_defconfig
# - rpi_4_32b_defconfig
#
rpi_defconfig=$1
rpi_board=$2
# ARM 32bit build (custom toolchain to support ARMv6)
export PATH="$PATH:/armv6-eabihf--glibc--stable-2018.11-1/bin"
export CROSS_COMPILE=arm-buildroot-linux-gnueabihf-
export ARCH=arm
# Test if the toolchain is actually installed
arm-buildroot-linux-gnueabihf-gcc --version
UBOOT_MENDER_BRANCH=2020.01
# Clean-up old builds
rm -rf uboot-mender
git clone https://github.com/mendersoftware/uboot-mender.git -b mender-rpi-${UBOOT_MENDER_BRANCH}
cd uboot-mender
make ${rpi_defconfig}
make -j $(nproc)
make -j $(nproc) envtools
cat <<- 'EOF' > boot.cmd
# DO NOT EDIT THIS FILE
#
fdt addr ${fdt_addr} && fdt get value bootargs /chosen bootargs
run mender_setup
mmc dev ${mender_uboot_dev}
if load ${mender_uboot_root} ${kernel_addr_r} /boot/zImage; then
bootz ${kernel_addr_r} - ${fdt_addr}
elif load ${mender_uboot_root} ${kernel_addr_r} /boot/uImage; then
bootm ${kernel_addr_r} - ${fdt_addr}
else
echo "No bootable Kernel found."
fi
run mender_try_to_recover
# Recompile with:
# mkimage -C none -A arm -T script -d boot.cmd boot.scr
EOF
mkimage -C none -A arm -T script -d boot.cmd boot.scr
cat <<- EOF > fw_env.config
/dev/mmcblk0 0x400000 0x4000
/dev/mmcblk0 0x800000 0x4000
EOF
mkdir integration-binaries
cp u-boot.bin tools/env/fw_printenv fw_env.config boot.scr integration-binaries/
git log --graph --pretty=oneline -15 > integration-binaries/uboot-git-log.txt
cd integration-binaries
# Availabile boards:
#
# - raspberrypi0w
# - raspberrypi3
# - raspberrypi4
#
tar czvf ${rpi_board}-${UBOOT_MENDER_BRANCH}.tar.gz ./*
cd -