mirror of
https://github.com/home-assistant/operating-system.git
synced 2025-07-24 13:36:31 +00:00
P1
This commit is contained in:
parent
9b170812d6
commit
74ff13e25e
@ -27,10 +27,13 @@ rm -f $BINARIES_DIR/u-boot-spl-dtb.img
|
||||
mkimage -n rk3288 -T rksd -d $BINARIES_DIR/u-boot-spl-dtb.bin $BINARIES_DIR/u-boot-spl-dtb.img
|
||||
cat $BINARIES_DIR/u-boot-dtb.bin >> $BINARIES_DIR/u-boot-spl-dtb.img
|
||||
|
||||
# Create other layers
|
||||
prepare_disk_image
|
||||
create_spl_image u-boot-spl-dtb.img 64
|
||||
# SPL
|
||||
create_spl_image
|
||||
|
||||
create_disk_image 2
|
||||
dd if=$BINARIES_DIR/u-boot-spl-dtb.img of=$BINARIES_DIR/spl.img conv=notrunc bs=512 seek=64
|
||||
|
||||
# Disk
|
||||
create_disk_image
|
||||
convert_disk_image_gz
|
||||
|
||||
create_ota_update
|
||||
|
@ -32,10 +32,12 @@ function make_bootable() {
|
||||
dd if=${UBOOT_GXBB} of=${hdd_img} conv=notrunc bs=512 seek=97
|
||||
}
|
||||
|
||||
# Create other layers
|
||||
prepare_disk_image
|
||||
# SPL
|
||||
create_spl_image
|
||||
|
||||
create_disk_mbr 2
|
||||
make_bootable
|
||||
# Disk
|
||||
create_disk_image
|
||||
convert_disk_image_gz
|
||||
|
||||
create_ota_update
|
||||
|
||||
|
@ -22,11 +22,10 @@ cp ${BR2_EXTERNAL_HASSOS_PATH}/misc/barebox-state-efi.dtb ${BOOT_DATA}/EFI/bareb
|
||||
|
||||
echo "console=tty1" > ${BOOT_DATA}/cmdline.txt
|
||||
|
||||
# Create other layers
|
||||
prepare_disk_image
|
||||
|
||||
# Create disk images
|
||||
create_disk_image 6
|
||||
create_disk_image
|
||||
|
||||
# Make VM
|
||||
convert_disk_image_vmdk
|
||||
convert_disk_image_gz vmdk
|
||||
|
||||
|
@ -40,10 +40,8 @@ if [ "${BOARD_ID}" == "rpi3-64" ]; then
|
||||
echo "arm_64bit=1" >> ${BOOT_DATA}/config.txt
|
||||
fi
|
||||
|
||||
# Create other layers
|
||||
prepare_disk_image
|
||||
|
||||
create_disk_image 2
|
||||
# Disk
|
||||
create_disk_image
|
||||
convert_disk_image_gz
|
||||
|
||||
# OTA
|
||||
|
@ -5,16 +5,30 @@
|
||||
|
||||
# Handle boot hocks
|
||||
if [ "${RAUC_SLOT_CLASS}" = "boot" ]; then
|
||||
if [ "${1}" = "slot-post-install" ]; then
|
||||
/usr/lib/rauc/post-install-boot
|
||||
elif [ "${1}" = "slot-pre-install" ]; then
|
||||
/usr/lib/rauc/pre-install-boot
|
||||
BOOT_DATA=/tmp/boot-data
|
||||
|
||||
mkdir -p ${BOOT_DATA}
|
||||
if [ "${1}" = "slot-pre-install" ]; then
|
||||
cp -f ${RAUC_SLOT_MOUNT_POINT}/*.txt ${BOOT_DATA}/
|
||||
elif [ "${1}" = "slot-post-install" ]; then
|
||||
cp -f ${BOOT_DATA}/*.txt ${RAUC_SLOT_MOUNT_POINT}/
|
||||
fi
|
||||
fi
|
||||
|
||||
# Handle spl install
|
||||
if [ "${RAUC_SLOT_CLASS}" = "spl" ]; then
|
||||
/usr/lib/rauc/install-spl "${RAUC_IMAGE_NAME}"
|
||||
DEVICE_CHILD="$(findfs LABEL="hassos-boot")"
|
||||
DEVICE_ROOT="/dev/$(lsblk -no pkname ${DEVICE_CHILD})"
|
||||
|
||||
if sfdisk -dq ${DEVICE_ROOT} | grep -q 'label: gpt'; then
|
||||
dd if=${RAUC_IMAGE_NAME} of=${DEVICE_ROOT} conv=notrunc bs=512 seek=2 skip=2
|
||||
else
|
||||
BACKUP_MBR="/tmp/mbr-backup.bin"
|
||||
|
||||
dd if=${DEVICE_ROOT} of=${BACKUP_MBR} bs=1 count=72 skip=440
|
||||
dd if=${RAUC_IMAGE_NAME} of=${DEVICE_ROOT} conv=notrunc bs=512
|
||||
dd if=${BACKUP_MBR} of=${DEVICE_ROOT} conv=notrunc bs=1 skip=440
|
||||
fi
|
||||
fi
|
||||
|
||||
##
|
||||
|
@ -1,13 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
DEVICE_CHILD="$(findfs LABEL="hassos-boot")"
|
||||
DEVICE_ROOT="/dev/$(lsblk -no pkname ${DEVICE_CHILD})"
|
||||
IMAGE_FILE="${1}"
|
||||
|
||||
# Check params
|
||||
if [ ! -f "${IMAGE_FILE}" ]; then
|
||||
echo "[Error] Can't find image: ${IMAGE_FILE}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
dd if=${IMAGE_FILE} of=${DEVICE_ROOT} conv=notrunc bs=512 seek=2
|
@ -1,7 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
BOOT_DATA=/tmp/boot-data
|
||||
|
||||
cp -f ${BOOT_DATA}/*.txt ${RAUC_SLOT_MOUNT_POINT}/
|
||||
|
||||
rm -rf ${BOOT_DATA}
|
@ -1,8 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
BOOT_DATA=/tmp/boot-data
|
||||
|
||||
rm -rf ${BOOT_DATA}
|
||||
mkdir -p ${BOOT_DATA}
|
||||
|
||||
cp -f ${RAUC_SLOT_MOUNT_POINT}/*.txt ${BOOT_DATA}/
|
@ -5,27 +5,12 @@ DEVICE_CHILD="$(findfs LABEL="hassos-data")"
|
||||
DEVICE_ROOT="/dev/$(lsblk -no pkname ${DEVICE_CHILD})"
|
||||
PART_NUM="${DEVICE_CHILD: -1}"
|
||||
|
||||
# Disk is MBR
|
||||
if sfdisk -dq ${DEVICE_ROOT} | grep -q 'label: dos'; then
|
||||
# Need resize
|
||||
UNUSED=$(sfdisk -Fq ${DEVICE_ROOT} | cut -d " " -f 3 | tail -1)
|
||||
if [ -z "${UNUSED}" ]; then
|
||||
echo "[INFO] No resize of data partition needed"
|
||||
exit
|
||||
fi
|
||||
if [ ${UNUSED} -le 2048 ]; then
|
||||
echo "[INFO] No resize of data partition needed"
|
||||
exit
|
||||
fi
|
||||
|
||||
echo ", +" | sfdisk -N ${PART_NUM} ${DEVICE_ROOT} --force
|
||||
sfdisk -V ${DEVICE_ROOT}
|
||||
else
|
||||
if sfdisk -dq ${DEVICE_ROOT} | grep -q 'label: gpt'; then
|
||||
|
||||
# Need resize
|
||||
if [ $(sgdisk -E ${DEVICE_ROOT}) -le 2048 ]; then
|
||||
echo "[INFO] No resize of data partition needed"
|
||||
exit
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Resize & Reload partition
|
||||
@ -33,6 +18,17 @@ else
|
||||
sgdisk -e ${DEVICE_ROOT}
|
||||
sgdisk -d ${PART_NUM} -n ${PART_NUM}:0:0 -c ${PART_NUM}:"hassos-data" -t ${PART_NUM}:"0FC63DAF-8483-4772-8E79-3D69D8477DE4" -u ${PART_NUM}:"a52a4597-fa3a-4851-aefd-2fbe9f849079" ${DEVICE_ROOT}
|
||||
sgdisk -v ${DEVICE_ROOT}
|
||||
else
|
||||
|
||||
# Need resize
|
||||
UNUSED=$(sfdisk -Fq ${DEVICE_ROOT} | cut -d " " -f 3 | tail -1)
|
||||
if [ -z "${UNUSED}" ] || [ ${UNUSED} -le 2048 ]; then
|
||||
echo "[INFO] No resize of data partition needed"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo ", +" | sfdisk -N ${PART_NUM} ${DEVICE_ROOT} --force
|
||||
sfdisk -V ${DEVICE_ROOT}
|
||||
fi
|
||||
|
||||
partx -u ${DEVICE_ROOT}
|
||||
|
@ -49,18 +49,15 @@ function get_boot_size() {
|
||||
|
||||
|
||||
function create_spl_image() {
|
||||
local spl_data="${BINARIES_DIR}/${1}"
|
||||
local spl_img="${BINARIES_DIR}/spl.img"
|
||||
local spl_seek=$(($2-2))
|
||||
local boot_img="$(path_spl_img)"
|
||||
|
||||
dd if=/dev/zero of=${spl_img} bs=512 count=16382
|
||||
dd if=${spl_data} of=${spl_img} conv=notrunc bs=512 seek=${spl_seek}
|
||||
dd if=/dev/zero of=${boot_img} bs=512 count=16382
|
||||
}
|
||||
|
||||
|
||||
function create_boot_image() {
|
||||
local boot_data="${BINARIES_DIR}/boot"
|
||||
local boot_img="${BINARIES_DIR}/boot.vfat"
|
||||
local boot_data="$(path_boot_dir)"
|
||||
local boot_img="$(path_boot_img)"
|
||||
|
||||
echo "mtools_skip_check=1" > ~/.mtoolsrc
|
||||
dd if=/dev/zero of=${boot_img} bs=$(get_boot_size) count=1
|
||||
@ -70,7 +67,7 @@ function create_boot_image() {
|
||||
|
||||
|
||||
function create_overlay_image() {
|
||||
local overlay_img="${BINARIES_DIR}/overlay.ext4"
|
||||
local overlay_img="$(path_overlay_img)"
|
||||
|
||||
dd if=/dev/zero of=${overlay_img} bs=${OVERLAY_SIZE} count=1
|
||||
mkfs.ext4 -L "hassos-overlay" -E lazy_itable_init=0,lazy_journal_init=0 ${overlay_img}
|
||||
@ -78,7 +75,7 @@ function create_overlay_image() {
|
||||
|
||||
|
||||
function create_kernel_image() {
|
||||
local kernel_img="${BINARIES_DIR}/kernel.ext4"
|
||||
local kernel_img="$(path_kernel_img)"
|
||||
local kernel="${BINARIES_DIR}/${KERNEL_FILE}"
|
||||
|
||||
# Make image
|
||||
@ -93,7 +90,7 @@ function create_kernel_image() {
|
||||
}
|
||||
|
||||
|
||||
function prepare_disk_image() {
|
||||
function _prepare_disk_image() {
|
||||
create_boot_image
|
||||
create_overlay_image
|
||||
create_kernel_image
|
||||
@ -101,13 +98,24 @@ function prepare_disk_image() {
|
||||
|
||||
|
||||
function create_disk_image() {
|
||||
local boot_img="${BINARIES_DIR}/boot.vfat"
|
||||
local rootfs_img="${BINARIES_DIR}/rootfs.squashfs"
|
||||
local overlay_img="${BINARIES_DIR}/overlay.ext4"
|
||||
local data_img="${BINARIES_DIR}/data.ext4"
|
||||
local kernel_img="${BINARIES_DIR}/kernel.ext4"
|
||||
_prepare_disk_image
|
||||
|
||||
if [ "${BOOT_SYS}" == "mbr" ]; then
|
||||
_create_disk_mbr
|
||||
else
|
||||
_create_disk_gpt
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
function _create_disk_gpt() {
|
||||
local boot_img="$(path_boot_img)"
|
||||
local rootfs_img="$(path_boot_img)"
|
||||
local overlay_img="$(path_overlay_img)"
|
||||
local data_img="$(path_data_img)"
|
||||
local kernel_img="$(path_kernel_img)"
|
||||
local hdd_img="$(hassos_image_name img)"
|
||||
local hdd_count=${1:-2}
|
||||
local hdd_count=${DISK_SIZE:-2}
|
||||
|
||||
local boot_offset=0
|
||||
local rootfs_offset=0
|
||||
@ -167,28 +175,28 @@ function create_disk_image() {
|
||||
dd if=${data_img} of=${hdd_img} conv=notrunc bs=512 seek=${data_offset}
|
||||
|
||||
# Fix boot
|
||||
if [ "${BOOT_SYS}" == "mbr" ]; then
|
||||
fix_disk_image_mbr
|
||||
if [ "${BOOT_SYS}" == "hyprid" ]; then
|
||||
_fix_disk_hyprid
|
||||
elif [ "${BOOT_SYS}" == "spl" ]; then
|
||||
fix_disk_image_spl
|
||||
_fix_disk_spl_gpt
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
function create_disk_mbr() {
|
||||
local disk_layout="${BINARIES_DIR}/disk.layout"
|
||||
local boot_img="${BINARIES_DIR}/boot.vfat"
|
||||
local rootfs_img="${BINARIES_DIR}/rootfs.squashfs"
|
||||
local overlay_img="${BINARIES_DIR}/overlay.ext4"
|
||||
local data_img="${BINARIES_DIR}/data.ext4"
|
||||
local kernel_img="${BINARIES_DIR}/kernel.ext4"
|
||||
function _create_disk_mbr() {
|
||||
local boot_img="$(path_boot_img)"
|
||||
local rootfs_img="$(path_boot_img)"
|
||||
local overlay_img="$(path_overlay_img)"
|
||||
local data_img="$(path_data_img)"
|
||||
local kernel_img="$(path_kernel_img)"
|
||||
local hdd_img="$(hassos_image_name img)"
|
||||
local hdd_count=${1:-2}
|
||||
local hdd_count=${DISK_SIZE:-2}
|
||||
local disk_layout="${BINARIES_DIR}/disk.layout"
|
||||
|
||||
# Write new image & MBR
|
||||
dd if=/dev/zero of=${hdd_img} bs=1G count=${hdd_count}
|
||||
|
||||
local boot_start=2048
|
||||
let boot_start=16384
|
||||
|
||||
let boot_size=$(size2sectors ${BOOT_SIZE})+2
|
||||
let kernel0_size=$(size2sectors ${KERNEL_SIZE})+2
|
||||
@ -223,10 +231,10 @@ function create_disk_mbr() {
|
||||
echo "unit: sectors"
|
||||
echo "hassos-boot : start= ${boot_start}, size= ${boot_size}, type=c, bootable" #create the boot partition
|
||||
echo "hassos-extended : start= ${extended_start}, size= ${extended_size}, type=5" #Make an extended partition
|
||||
echo "hassos-kernela : start= ${kernel0_start}, size= ${kernel0_size}, type=83" #Make a logical partition
|
||||
echo "hassos-systema : start= ${system0_start}, size= ${system0_size}, type=83" #Make a logical partition
|
||||
echo "hassos-kernelb : start= ${kernel1_start} size= ${kernel1_size}, type=83" #Make a logical partition
|
||||
echo "hassos-systemb : start= ${system1_start}, size= ${system1_size}, type=83" #Make a logical partition
|
||||
echo "hassos-kernel0 : start= ${kernel0_start}, size= ${kernel0_size}, type=83" #Make a logical partition
|
||||
echo "hassos-system0 : start= ${system0_start}, size= ${system0_size}, type=83" #Make a logical partition
|
||||
echo "hassos-kernel1 : start= ${kernel1_start} size= ${kernel1_size}, type=83" #Make a logical partition
|
||||
echo "hassos-system1 : start= ${system1_start}, size= ${system1_size}, type=83" #Make a logical partition
|
||||
echo "hassos-bootstate : start= ${bootstate_start}, size= ${bootstate_size}, type=83" #Make a logical partition
|
||||
echo "hassos-overlay : start= ${overlay_start}, size= ${overlay_size}, type=83" #Make a logical partition
|
||||
echo "hassos-data : start= ${data_start}, size= ${data_size}, type=83" #Make a logical partition
|
||||
@ -236,15 +244,18 @@ function create_disk_mbr() {
|
||||
sfdisk ${hdd_img} < ${disk_layout}
|
||||
|
||||
# Write Images
|
||||
dd if=${boot_img} of=${hdd_img} conv=notrunc bs=512 obs=512 seek=${boot_offset}
|
||||
dd if=${kernel_img} of=${hdd_img} conv=notrunc bs=512 obs=512 seek=${kernel_offset}
|
||||
dd if=${rootfs_img} of=${hdd_img} conv=notrunc bs=512 obs=512 seek=${rootfs_offset}
|
||||
dd if=${overlay_img} of=${hdd_img} conv=notrunc bs=512 obs=512 seek=${overlay_offset}
|
||||
dd if=${data_img} of=${hdd_img} conv=notrunc bs=512 obs=512 seek=${data_offset}
|
||||
dd if=${boot_img} of=${hdd_img} conv=notrunc bs=512 seek=${boot_offset}
|
||||
dd if=${kernel_img} of=${hdd_img} conv=notrunc bs=512 seek=${kernel_offset}
|
||||
dd if=${rootfs_img} of=${hdd_img} conv=notrunc bs=512 seek=${rootfs_offset}
|
||||
dd if=${overlay_img} of=${hdd_img} conv=notrunc bs=512 seek=${overlay_offset}
|
||||
dd if=${data_img} of=${hdd_img} conv=notrunc bs=512 seek=${data_offset}
|
||||
|
||||
# Wripte SPL
|
||||
_fix_disk_spl_mbr
|
||||
}
|
||||
|
||||
|
||||
function fix_disk_image_mbr() {
|
||||
function _fix_disk_hyprid() {
|
||||
local hdd_img="$(hassos_image_name img)"
|
||||
|
||||
sgdisk -t 1:"E3C9E316-0B5C-4DB8-817D-F92DF00215AE" ${hdd_img}
|
||||
@ -252,13 +263,25 @@ function fix_disk_image_mbr() {
|
||||
}
|
||||
|
||||
|
||||
function fix_disk_image_spl() {
|
||||
function _fix_disk_spl_gpt() {
|
||||
local hdd_img="$(hassos_image_name img)"
|
||||
local spl_img="${BINARIES_DIR}/spl.img"
|
||||
local spl_img="$(path_spl_img)"
|
||||
local backup="/tmp/mbr-backup.bin"
|
||||
|
||||
sgdisk -t 1:"E3C9E316-0B5C-4DB8-817D-F92DF00215AE" ${hdd_img}
|
||||
dd if=${BR2_EXTERNAL_HASSOS_PATH}/misc/mbr-spl.img of=${hdd_img} conv=notrunc bs=512 count=1
|
||||
dd if=${spl_img} of=${hdd_img} conv=notrunc bs=512 seek=2
|
||||
dd if=${spl_img} of=${hdd_img} conv=notrunc bs=512 seek=2 skip=2
|
||||
}
|
||||
|
||||
|
||||
function _fix_disk_spl_mbr() {
|
||||
local hdd_img="$(hassos_image_name img)"
|
||||
local spl_img="$(path_spl_img)"
|
||||
|
||||
# backup MBR
|
||||
dd if=${hdd_img} of=${backup} bs=1 count=72 skip=440
|
||||
dd if=${spl_img} of=${hdd_img} conv=notrunc bs=512
|
||||
dd if=${backup} of=${hdd_img} conv=notrunc bs=1 skip=440
|
||||
}
|
||||
|
||||
|
||||
|
@ -11,3 +11,32 @@ function hassos_rauc_compatible() {
|
||||
function hassos_version() {
|
||||
echo "${VERSION_MAJOR}.${VERSION_BUILD}"
|
||||
}
|
||||
|
||||
function path_spl_img() {
|
||||
echo "${BINARIES_DIR}/spl.img"
|
||||
}
|
||||
|
||||
function path_kernel_img() {
|
||||
echo "${BINARIES_DIR}/kernel.ext4"
|
||||
}
|
||||
|
||||
function path_boot_img() {
|
||||
echo "${BINARIES_DIR}/boot.vfat"
|
||||
}
|
||||
|
||||
function path_boot_dir() {
|
||||
echo "${BINARIES_DIR}/boot"
|
||||
}
|
||||
|
||||
function path_data_img() {
|
||||
echo "${BINARIES_DIR}/data.ext4"
|
||||
}
|
||||
|
||||
function path_overlay_img() {
|
||||
echo "${BINARIES_DIR}/overlay.ext4"
|
||||
}
|
||||
|
||||
function path_rootfs_img() {
|
||||
echo "${BINARIES_DIR}/rootfs.squashfs"
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,11 @@ function create_ota_update() {
|
||||
local key="/build/key.pem"
|
||||
local cert="/build/cert.pem"
|
||||
|
||||
# Skeep if no dev key is arround
|
||||
if [ ! -f "${key}" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
rm -rf ${rauc_folder} ${ota_file}
|
||||
mkdir -p ${rauc_folder}
|
||||
|
||||
@ -44,9 +49,5 @@ function create_ota_update() {
|
||||
) >> ${rauc_folder}/manifest.raucm
|
||||
fi
|
||||
|
||||
if [ ! -f "${key}" ]; then
|
||||
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout ${key} -out ${cert} -outform PEM -batch
|
||||
fi
|
||||
|
||||
rauc bundle -d --cert=${cert} --key=${key} ${rauc_folder} ${ota_file}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user