forked from starfive-tech/VisionFive2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
genimage.sh
executable file
·58 lines (51 loc) · 2.06 KB
/
genimage.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
#!/bin/bash
##################################################################
## ##
## SPDX-License-Identifier: GPL-2.0-or-later ##
## ##
## Copyright (C) 2018-2022 Starfive Technology ##
## ##
## Author: Andy Hu <andy.hu@starfivetech.com> ##
## Date: 2022-07-27 ##
## Description: This script used to generate img file ##
## which could be burned to tf card through dd or ##
## rpi-imager or balenaEtcher tool. ##
## Run it after the usdk initramfs and rootfs had been built ##
## ##
##################################################################
COLOR_NORMAL="\033[0m"
COLOR_GREEN="\033[1;32m"
COLOR_YELLOW="\033[1;33m"
COLOR_RED="\033[1;31m"
COLOR_GREY="\033[1;30m"
HWBOARD=visionfive2
TOPDIR=`dirname $0`
BUILD_DIR=$TOPDIR/work
INPUT_DIR=$TOPDIR
OUTPUT_DIR=$TOPDIR/work
if [ $HWBOARD == "visionfive2" ]; then
GENIMAGE_CFG=$TOPDIR/conf/genimage-vf2.cfg
else
GENIMAGE_CFG=$TOPDIR/conf/genimage.cfg
fi
GENIMAGE=$TOPDIR/work/buildroot_initramfs/host/bin/genimage
if [ ! -f $GENIMAGE ]; then
printf $COLOR_RED
echo "Error: $GENIMAGE not found. need building the usdk first"
printf $COLOR_NORMAL
exit 1
fi
GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp"
# Pass an empty rootpath. genimage makes a full copy of the given rootpath to
# ${GENIMAGE_TMP}/root so passing TARGET_DIR would be a waste of time and disk
# space. We don't rely on genimage to build the rootfs image, just to insert a
# pre-built one in the disk image.
trap 'rm -rf "${ROOTPATH_TMP}"' EXIT
ROOTPATH_TMP="$(mktemp -d)"
rm -rf "${GENIMAGE_TMP}"
$GENIMAGE \
--rootpath "${ROOTPATH_TMP}" \
--tmppath "${GENIMAGE_TMP}" \
--inputpath "${INPUT_DIR}" \
--outputpath "${OUTPUT_DIR}" \
--config "${GENIMAGE_CFG}"