Skip to content
Snippets Groups Projects
Unverified Commit c1485972 authored by methanal's avatar methanal Committed by Clayton Craft
Browse files

copy target dtb to a temp directory for qcom and sprd dt.img types (MR 57)

The dtbTool and dtbTool-sprd programs require the dtb directory as an
argument. These programs tend to combine multiple devicetrees. We can't
determine for whether the directory has devicetree blobs for a single
device, or multiple devices.

It's safer to copy the target dtb over to a temporary directory, and
pass that directory as an argument to dtbTool.
parent d308fdc3
No related branches found
No related tags found
No related merge requests found
......@@ -645,8 +645,11 @@ create_bootimg() {
fi
local _dt_img=""
if [ "${deviceinfo_bootimg_qcdt}" = "true" ]; then
_dt_img="--dt /boot/dt.img"
# Only mkbootimg-osm0sis has support for dt.img
# Make sure that the program is available.
require_package "mkbootimg-osm0sis" "mkbootimg" "bootimg_qcdt"
if [ -n "${deviceinfo_bootimg_qcdt_type}" ]; then
_dt_img="$work_dir/dt.img"
if [ -z "${deviceinfo_dtb}" ]; then
log "ERROR: deviceinfo_bootimg_qcdt_type is set, but"
log "'deviceinfo_dtb' is missing. Set 'deviceinfo_dtb'"
......@@ -658,36 +661,48 @@ create_bootimg() {
log "ERROR: Couldn't find DTB for ${deviceinfo_dtb}"
exit 1
fi
fi
case "${deviceinfo_bootimg_qcdt_type}" in
"exynos")
require_package "dtbTool-exynos" "dtbtool-exynos" "bootimg_qcdt_type"
dtbTool-exynos -o "/boot/dt.img" "${_dtb}";;
"sprd")
require_package "dtbTool-sprd" "dtbtool-sprd" "bootimg_qcdt_type"
dtbTool-sprd -o "/boot/dt.img" "${_dtb}";;
"qcom")
require_package "dtbTool" "dtbtool" "bootimg_qcdt_type"
dtbTool -o "/boot/dt.img" "${_dtb}";;
"")
# When 'bootimg_qcdt_type` is not set, expect that
# dt.img has been generated by the linux APKBUILD.
;;
*)
log "ERROR: deviceinfo_bootimg_qcdt_type has an unrecognized"
log "value. See also <https://postmarketos.org/deviceinfo>"
local _tmp_dtb_path="$work_dir/tmp-dtb"
case "${deviceinfo_bootimg_qcdt_type}" in
"exynos")
require_package "dtbTool-exynos" "dtbtool-exynos" "bootimg_qcdt_type"
dtbTool-exynos -o "${_dt_img}" "${_dtb}";;
"sprd")
require_package "dtbTool-sprd" "dtbtool-sprd" "bootimg_qcdt_type"
copy "${_dtb}" "$_tmp_dtb_path/$(basename "$_dtb")"
dtbTool-sprd -o "${_dt_img}" "${_tmp_dtb_path}"
rm -r "$_tmp_dtb_path";;
"qcom")
require_package "dtbTool" "dtbtool" "bootimg_qcdt_type"
copy "${_dtb}" "$_tmp_dtb_path/$(basename "$_dtb")"
dtbTool -o "${_dt_img}" "${_tmp_dtb_path}"
rm -r "$_tmp_dtb_path";;
"")
# When 'bootimg_qcdt_type` is not set, expect that
# dt.img has been generated by the linux APKBUILD.
;;
*)
log "ERROR: deviceinfo_bootimg_qcdt_type has an unrecognized"
log "value. See also <https://postmarketos.org/deviceinfo>"
exit 1
esac
additional_files="$additional_files $(basename "$_dt_img")"
else
# The kernel APKBUILD usually installs the dt.img in /boot/.
# Check whether the file exists or not.
_dt_img="/boot/dt.img"
if ! [ -e "$_dt_img" ]; then
log "ERROR: File not found: $_dt_img, but"
log "'deviceinfo_bootimg_qcdt' is set. Please verify that your"
log "device is a QCDT device by analyzing the boot.img file"
log "(e.g. 'pmbootstrap bootimg_analyze path/to/twrp.img')"
log "and based on that, set the deviceinfo variable to false or"
log "adjust your linux APKBUILD to properly generate the dt.img"
log "file. See also: <https://postmarketos.org/deviceinfo>"
exit 1
esac
if ! [ -e "/boot/dt.img" ]; then
log "ERROR: File not found: /boot/dt.img, but"
log "'deviceinfo_bootimg_qcdt' is set. Please verify that your"
log "device is a QCDT device by analyzing the boot.img file"
log "(e.g. 'pmbootstrap bootimg_analyze path/to/twrp.img')"
log "and based on that, set the deviceinfo variable to false or"
log "adjust your linux APKBUILD to properly generate the dt.img"
log "file. See also: <https://postmarketos.org/deviceinfo>"
exit 1
fi
fi
# Prepend --dt to pass it as an parameter to mkbootimg.
_dt_img="--dt $_dt_img"
fi
local _header_v2=""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment