forked from CTSRD-CHERI/socfpga-ubuntu-sdcard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_ubuntu_sdcard.sh
executable file
·131 lines (117 loc) · 3.8 KB
/
build_ubuntu_sdcard.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/bin/bash
#-
# SPDX-License-Identifier: BSD-2-Clause
#
# Copyright (c) 2018 A. Theodore Markettos
# All rights reserved.
#
# This software was developed by SRI International and the University of
# Cambridge Computer Laboratory (Department of Computer Science and
# Technology) under DARPA contract HR0011-18-C-0016 ("ECATS"), as part of the
# DARPA SSITH research programme.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
FPGA_DIR=$1
FPGA_PROJECT=$2
QSYS=$3
PAYLOAD=$4
FPGA_HANDOFF_DIR=hps_isw_handoff
FPGA_BITFILE_RBF=$FPGA_DIR/output_files/$FPGA_PROJECT-hps.core.rbf
UBOOT_DIR=u-boot-socfpga
UBOOT_BIN=spl/u-boot-spl-dtb.ihex
LINUX_DIR=linux-socfpga
SD_IMAGE=sdimage.img
ROOT_SIZE_MIB=3270
SD_SIZE_MIB=3810
shift
shift
shift
shift
# parameters 5 and later
PACKAGES="$@"
DTB=socfpga_stratix10_de10_pro.dtb
DTB2=socfpga_stratix10_de10_pro2.dtb
SCRIPT_NAME=$(readlink -f "$0")
SCRIPT_PATH=$(dirname "$SCRIPT_NAME")
function ubuntu() {
BOOT=mnt/1
ROOT=mnt/2
echo "fetch_ubuntu"
$SCRIPT_PATH/fetch_ubuntu.sh
echo "configure_system"
$SCRIPT_PATH/configure_system.sh $ROOT/
echo "configure_networking"
$SCRIPT_PATH/configure_networking.sh $ROOT/
echo "ubuntu_packages"
$SCRIPT_PATH/ubuntu_packages.sh $ROOT/ $PACKAGES
if [ -n "$PAYLOAD" ] ; then
echo "Copying extra files into tree"
sudo cp -av $PAYLOAD/* $ROOT/
fi
echo "Copying cloud_init files"
cp -a $BOOT/meta-data .
cp -a $BOOT/user-data .
cp -a $BOOT/network-config .
}
function kernel() {
echo "build_linux"
$SCRIPT_PATH/build_linux.sh
}
function uboot() {
echo "make_uboot"
$SCRIPT_PATH/build_uboot.sh $FPGA_DIR/$FPGA_HANDOFF_DIR
cp $UBOOT_DIR/u-boot-dtb.img .
cp $SCRIPT_PATH/u-boot.txt .
$UBOOT_DIR/tools/mkimage -A arm -T script -O linux -d u-boot.txt u-boot.scr
}
function devicetree() {
# $SCRIPT_PATH/make_device_tree.sh $FPGA_DIR $QSYS.sopcinfo
# cp -a $FPGA_DIR/$DTB $DTB
echo "make_device_tree"
cp $UBOOT_DIR/arch/arm/dts/$DTB .
cp $LINUX_DIR/arch/arm64/boot/dts/altera/$DTB ./$DTB2
}
function bitfile() {
$SCRIPT_PATH/make_bitfile.sh $FPGA_DIR $FPGA_PROJECT $UBOOT_DIR/$UBOOT_BIN
cp -a $FPGA_BITFILE_RBF socfpga.core.rbf
}
function sdimage() {
CLOUD_INIT="meta-data,user-data,network-config"
echo "Building SD card image"
sudo rm -f $SD_IMAGE
sudo $SCRIPT_PATH/make_sdimage.py -f \
-P mnt/2/*,num=2,format=ext3,size=${ROOT_SIZE_MIB}M,label=cloudimg-rootfs \
-P Image,${DTB},${DTB2},u-boot-dtb.img,u-boot.scr,socfpga.core.rbf,$CLOUD_INIT,num=1,format=vfat,size=500M,label=system-boot \
-s ${SD_SIZE_MIB}M \
-n $SD_IMAGE
}
function tidy() {
sudo umount mnt/1 mnt/2
}
ubuntu && \
kernel && \
uboot && \
devicetree && \
bitfile && \
sdimage && \
tidy