blob: 8f094e5abc2b01b1117a55e1838db349e23e8912 (
plain)
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
|
#!/usr/bin/env sh
help() {
cat >&2 <<EOF
$0: BSP Generator for the SiFive Freedom E SDK
--help Prints this help text.
--target-name Specify bsp target name.
--sdk-path=* The path to the freedom-e-sdk clone directory, public or private.
--target-dts=*.dts The path to the target device tree that will be used.
EOF
}
unset DTSFILE
unset CUSTOM_PATH
unset CUSTOM_NAME
while [[ "$1" != "" ]]
do
case "$1" in
--help) help "$0"; exit 0;;
--target-name) CUSTOM_NAME="$2"; shift 2;;
--sdk-path=*) CUSTOM_PATH="$(echo "$1" | cut -d= -f2-)"; shift 1;;
--sdk-path) CUSTOM_PATH="$2"; shift 2;;
--target-dts=*) DTSFILE="$(echo "$1" | cut -d= -f2-)"; shift 1;;
--target-dts) DTSFILE="$2"; shift 2;;
*) echo "$0: Unknown argument $1" >&2; exit 1;;
esac
done
if [[ "$CUSTOM_PATH" == "" && "$CUSTOM_NAME" == "" && "$DTSFILE" == "" ]]
then
TARGET_LIST="$(ls -d coreip*) "
TARGET_LIST+="sifive-hifive1 freedom-e310-arty "
else
if [[ ! -f "$DTSFILE" && "$DTSFILE" != "*.dts" ]]
then
echo "[ERROR] $0: $DTSFILE must be a dts file" >&2
help "$0"
exit 1
fi
if [[ "$CUSTOM_NAME" == "" ]]
then
echo "[ERROR] $0: --target-name is mandatory" >&2
help "$0"
exit 1
fi
CUSTOM_TARGET="$CUSTOM_PATH/bsp/$CUSTOM_NAME"
if [[ ! -d "$CUSTOM_TARGET" ]]
then
echo "[ERROR] $0: "$CUSTOM_TARGET" not found!" >&2
help "$0"
exit 1
fi
cp $DTSFILE $CUSTOM_TARGET
TARGET_LIST="$CUSTOM_TARGET "
fi
DTC=dtc
MEE_HEADER_GENERATOR=freedom-metal_header-generator
LDSCRIPT_GENERATOR=freedom-ldscript-generator
DTS_FILENAME=design.dts
DTB_FILENAME=temp.dtb
HEADER_FILENAME=metal.h
LDSCRIPT_FILENAME=metal.lds
update_target() {
TARGET=$1
echo "Updating target $TARGET"
# Compile temporary .dtb
$DTC -I dts -O dtb -o $TARGET/$DTB_FILENAME $TARGET/$DTS_FILENAME || die "Failed to compile $TARGET/$DTS_FILENAME to dtb"
# Produce parameterized files
$MEE_HEADER_GENERATOR -d $TARGET/$DTB_FILENAME -o $TARGET/$HEADER_FILENAME || die "Failed to produce $TARGET/$HEADER_FILENAME"
$LDSCRIPT_GENERATOR -d $TARGET/$DTB_FILENAME -l $TARGET/$LDSCRIPT_FILENAME || die "Failed to produce $TARGET/$LDSCRIPT_FILENAME"
# Remove temporary .dtb
rm $TARGET/$DTB_FILENAME
echo ""
}
for TARGET in $TARGET_LIST
do
update_target $TARGET
done
|