-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
scripts: board: common: add new FIT support for all platforms
Adds new FIT support to all platforms to enable internal data support for FIT files. To enable the new internal data support for FIT files, use the normal NETBOX_IMAGE_FIT config param. If a need of an old FIT image support, You can use the NETBOX_IMAGE_FIT_LEGACY config param. In this case an FIT image with old external data will be generated. Signed-off-by: Joacim Zetterling <[email protected]>
- Loading branch information
Showing
3 changed files
with
197 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
#!/bin/sh | ||
|
||
die() { | ||
echo "$1" >&2 | ||
rm -rf $workdir | ||
exit 1 | ||
} | ||
|
||
plat=$1 | ||
squash=$2 | ||
out=$3 | ||
load=0 | ||
|
||
case $plat in | ||
basis) | ||
arch="arm" | ||
load="0x20000000" | ||
;; | ||
byron) | ||
arch="arm" | ||
load="0x20000000" | ||
;; | ||
coronet) | ||
arch="powerpc" | ||
;; | ||
dagger) | ||
arch="arm" | ||
;; | ||
envoy) | ||
arch="arm64" | ||
load="0x40000000" | ||
;; | ||
ember) | ||
arch="arm64" | ||
load="0x40000000" | ||
;; | ||
zero) | ||
arch="x86_64" | ||
;; | ||
*) | ||
arch="$plat" | ||
;; | ||
esac | ||
|
||
workdir=$(mktemp -d) | ||
unsquashfs -f -d $workdir $squash boot || die "Invalid SquashFS" | ||
|
||
kernel=$(echo $workdir/boot/*Image | cut -d\ -f1) | ||
[ "$kernel" ] || die "No kernel found" | ||
|
||
dtbs=$workdir/boot/*/device-tree.dtb | ||
|
||
# mkimage will only align images to 4 bytes, but U-Boot will leave | ||
# both DTB and ramdisk in place when starting the kernel. So we pad | ||
# all components up to a 4k boundary. | ||
truncate -s %4k $kernel $dtbs | ||
|
||
for dtb in $dtbs; do | ||
name=$(basename $(dirname $dtb)) | ||
|
||
cat <<EOF >>$workdir/netbox-dtbs.itsi | ||
$name { | ||
description = "$name"; | ||
type = "flat_dt"; | ||
arch = "$arch"; | ||
compression = "none"; | ||
data = /incbin/("$dtb"); | ||
}; | ||
EOF | ||
cat <<EOF >>$workdir/netbox-cfgs.itsi | ||
$name { | ||
description = "$name"; | ||
kernel = "kernel"; | ||
ramdisk = "ramdisk"; | ||
fdt = "$name"; | ||
}; | ||
EOF | ||
done | ||
|
||
cat <<EOF >$workdir/netbox.its | ||
/dts-v1/; | ||
/ { | ||
timestamp = <$(date +%s)>; | ||
description = "Netbox ($plat)"; | ||
creator = "netbox"; | ||
#address-cells = <0x1>; | ||
images { | ||
kernel { | ||
description = "Linux"; | ||
type = "kernel"; | ||
arch = "$arch"; | ||
os = "linux"; | ||
load = <$load>; | ||
entry = <$load>; | ||
compression = "none"; | ||
data = /incbin/("$kernel"); | ||
}; | ||
ramdisk { | ||
description = "Netbox"; | ||
type = "ramdisk"; | ||
os = "linux"; | ||
arch = "$arch"; | ||
compression = "none"; | ||
data = /incbin/("$squash"); | ||
}; | ||
$(cat $workdir/netbox-dtbs.itsi) | ||
}; | ||
configurations { | ||
$(cat $workdir/netbox-cfgs.itsi) | ||
}; | ||
}; | ||
EOF | ||
|
||
mkimage \ | ||
-E -p 0x1000 \ | ||
-f $workdir/netbox.its $out \ | ||
|| die "Unable to create FIT image" | ||
|
||
rm -rf $workdir |