3
# Boot script for devices attached to a PoE switch, using NFS for the root
6
# We're run from the root of the repo, make a helper var for our paths
7
BM=$CI_PROJECT_DIR/install/bare-metal
8
CI_COMMON=$CI_PROJECT_DIR/install/common
10
# Runner config checks
11
if [ -z "$BM_SERIAL" ]; then
12
echo "Must set BM_SERIAL in your gitlab-runner config.toml [[runners]] environment"
13
echo "This is the serial port to listen the device."
17
if [ -z "$BM_POE_ADDRESS" ]; then
18
echo "Must set BM_POE_ADDRESS in your gitlab-runner config.toml [[runners]] environment"
19
echo "This is the PoE switch address to connect for powering up/down devices."
23
if [ -z "$BM_POE_INTERFACE" ]; then
24
echo "Must set BM_POE_INTERFACE in your gitlab-runner config.toml [[runners]] environment"
25
echo "This is the PoE switch interface where the device is connected."
29
if [ -z "$BM_POWERUP" ]; then
30
echo "Must set BM_POWERUP in your gitlab-runner config.toml [[runners]] environment"
31
echo "This is a shell script that should power up the device and begin its boot sequence."
35
if [ -z "$BM_POWERDOWN" ]; then
36
echo "Must set BM_POWERDOWN in your gitlab-runner config.toml [[runners]] environment"
37
echo "This is a shell script that should power off the device."
41
if [ ! -d /nfs ]; then
42
echo "NFS rootfs directory needs to be mounted at /nfs by the gitlab runner"
46
if [ ! -d /tftp ]; then
47
echo "TFTP directory for this board needs to be mounted at /tftp by the gitlab runner"
52
if [ -z "$BM_ROOTFS" ]; then
53
echo "Must set BM_ROOTFS to your board's rootfs directory in the job's variables"
57
if [ -z "$BM_BOOTFS" ]; then
58
echo "Must set /boot files for the TFTP boot in the job's variables"
62
if [ -z "$BM_CMDLINE" ]; then
63
echo "Must set BM_CMDLINE to your board's kernel command line arguments"
67
if [ -z "$BM_BOOTCONFIG" ]; then
68
echo "Must set BM_BOOTCONFIG to your board's required boot configuration arguments"
74
# Clear out any previous run's artifacts.
78
# Create the rootfs in the NFS directory. rm to make sure it's in a pristine
79
# state, since it's volume-mounted on the host.
80
rsync -a --delete $BM_ROOTFS/ /nfs/
82
# If BM_BOOTFS is an URL, download it
83
if echo $BM_BOOTFS | grep -q http; then
85
wget ${FDO_HTTP_CACHE_URI:-}$BM_BOOTFS -O /tmp/bootfs.tar
86
BM_BOOTFS=/tmp/bootfs.tar
89
# If BM_BOOTFS is a file, assume it is a tarball and uncompress it
90
if [ -f $BM_BOOTFS ]; then
92
tar xf $BM_BOOTFS -C /tmp/bootfs
96
# Install kernel modules (it could be either in /lib/modules or
97
# /usr/lib/modules, but we want to install in the latter)
98
[ -d $BM_BOOTFS/usr/lib/modules ] && rsync -a $BM_BOOTFS/usr/lib/modules/ /nfs/usr/lib/modules/
99
[ -d $BM_BOOTFS/lib/modules ] && rsync -a $BM_BOOTFS/lib/modules/ /nfs/lib/modules/
101
# Install kernel image + bootloader files
102
rsync -aL --delete $BM_BOOTFS/boot/ /tftp/
104
# Set up the pxelinux config for Jetson Nano
105
mkdir -p /tftp/pxelinux.cfg
106
cat <<EOF >/tftp/pxelinux.cfg/default-arm-tegra210-p3450-0000
110
MENU TITLE jetson nano boot options
112
MENU LABEL CI kernel on TFTP
114
FDT tegra210-p3450-0000.dtb
115
APPEND \${cbootargs} $BM_CMDLINE
118
# Create the rootfs in the NFS directory
119
mkdir -p /nfs/results
120
. $BM/rootfs-setup.sh /nfs
122
echo "$BM_CMDLINE" > /tftp/cmdline.txt
124
# Add some required options in config.txt
125
printf "$BM_BOOTCONFIG" >> /tftp/config.txt
129
while [ $((ATTEMPTS--)) -gt 0 ]; do
130
python3 $BM/poe_run.py \
132
--powerup="$BM_POWERUP" \
133
--powerdown="$BM_POWERDOWN" \
134
--timeout="${BM_POE_TIMEOUT:-60}"
137
if [ $ret -eq 2 ]; then
138
echo "Did not detect boot sequence, retrying..."
145
# Bring artifacts back from the NFS dir to the build dir where gitlab-runner
146
# will look for them.
147
cp -Rp /nfs/results/. results/