Create wic config file and remove the custom recipe for creating both partitions.
Signed-off-by: Pawel Zalewski pzalewski@thegoodpenguin.co.uk --- .../images/morello-initramfs.bb | 7 +- .../images/morello-linux-image-fvp.inc | 1 - .../images/morello-linux-image-soc.inc | 1 - .../images/morello-linux-image.bb | 153 ------------------ meta-morello/wic/morello-efidisk.wks | 9 ++ meta-morello/wic/morello-fvp-grub.cfg | 35 ++++ meta-morello/wic/morello-soc-grub.cfg | 37 +++++ 7 files changed, 87 insertions(+), 156 deletions(-) delete mode 100644 meta-morello/recipes-morello/images/morello-linux-image-fvp.inc delete mode 100644 meta-morello/recipes-morello/images/morello-linux-image-soc.inc delete mode 100644 meta-morello/recipes-morello/images/morello-linux-image.bb create mode 100644 meta-morello/wic/morello-efidisk.wks create mode 100644 meta-morello/wic/morello-fvp-grub.cfg create mode 100644 meta-morello/wic/morello-soc-grub.cfg
diff --git a/meta-morello/recipes-morello/images/morello-initramfs.bb b/meta-morello/recipes-morello/images/morello-initramfs.bb index c3abac8..4d5e159 100644 --- a/meta-morello/recipes-morello/images/morello-initramfs.bb +++ b/meta-morello/recipes-morello/images/morello-initramfs.bb @@ -49,4 +49,9 @@ do_deploy() { install -d ${DEPLOYDIR}/${OUTPUTS_NAME} install ${D}/${OUTPUTS_NAME}/initramfs ${DEPLOYDIR}/${OUTPUTS_NAME}/initramfs } -addtask deploy after do_install \ No newline at end of file +addtask deploy after do_install + +do_image_complete() { + echo "Image complete" +} +addtask image_complete before do_build diff --git a/meta-morello/recipes-morello/images/morello-linux-image-fvp.inc b/meta-morello/recipes-morello/images/morello-linux-image-fvp.inc deleted file mode 100644 index 1e0424c..0000000 --- a/meta-morello/recipes-morello/images/morello-linux-image-fvp.inc +++ /dev/null @@ -1 +0,0 @@ -TARGET_PLATFORM = "fvp" \ No newline at end of file diff --git a/meta-morello/recipes-morello/images/morello-linux-image-soc.inc b/meta-morello/recipes-morello/images/morello-linux-image-soc.inc deleted file mode 100644 index 94d624b..0000000 --- a/meta-morello/recipes-morello/images/morello-linux-image-soc.inc +++ /dev/null @@ -1 +0,0 @@ -TARGET_PLATFORM = "soc" \ No newline at end of file diff --git a/meta-morello/recipes-morello/images/morello-linux-image.bb b/meta-morello/recipes-morello/images/morello-linux-image.bb deleted file mode 100644 index 6a2b677..0000000 --- a/meta-morello/recipes-morello/images/morello-linux-image.bb +++ /dev/null @@ -1,153 +0,0 @@ -inherit deploy nopackages - -COMPATIBLE_MACHINE = "morello" -SUMMARY = "Bootable Morello Linux Image" -DESCRIPTION = "Image that goes on a bootable device, can be DD'ed onto a USB stick" -LICENSE = "MIT" -LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" -OUTPUTS_NAME = "morello-linux-image" - -INHIBIT_DEFAULT_DEPS = "1" - -MACHINE_LINUX_REQUIRE ?= "" -MACHINE_LINUX_REQUIRE:morello-fvp = "morello-linux-image-fvp.inc" -MACHINE_LINUX_REQUIRE:morello-soc = "morello-linux-image-soc.inc" - -require ${MACHINE_LINUX_REQUIRE} - -PACKAGE_ARCH = "${MACHINE_ARCH}" - -DEPENDS += "virtual/kernel grub-efi morello-initramfs mtools-native e2fsprogs-native coreutils-native bc-native util-linux-native" -PROVIDES = "${OUTPUTS_NAME}" - -ESP_SIZE = "100" -BOOT_SECTORS = "204800" - -LBA = "512" -PART_START_ALIGNMENT = "2048" - -ESP_IMAGE = "${OUTPUTS_NAME}-esp" - -ROOTFS = "${DEPLOY_DIR}/images/morello-${TARGET_PLATFORM}/rootfs-morello-${TARGET_PLATFORM}.ext4" - -do_compile[noexec] = "1" -do_configure[depends] += "${MORELLO_ROOTFS_IMAGE}:do_image_complete morello-initramfs:do_deploy" -do_configure[depends] += "board-firmware-image:do_deploy" - -def get_next_part_start (d): - next_image_start = int(d.getVar('BOOT_SECTORS')) + int(d.getVar('PART_START_ALIGNMENT')) + int(d.getVar('PART_START_ALIGNMENT')) - 1 - next_image_start = next_image_start & ~(int(d.getVar('PART_START_ALIGNMENT')) -1) - return next_image_start - -mult() { - local ret=$(echo "${1} * ${2}" | bc) - echo ${ret} -} - -add() { - local ret=$(echo "${1} + ${2}" | bc) - echo ${ret} -} - -div() { - local ret=$(echo "${1} / ${2}" | bc) - echo ${ret} -} - -get_size() { - local link=$(readlink -f ${1}) - local size=$(stat --dereference --format="%s" ${link}) - local ret=${size% *} - echo ${ret} -} - -add_to_image() { - mcopy -i ${1} -m -D overwrite ${2} ::${3} -} - -get_uuid() { - local part="$(blkid ${1})" - local tmp=${part#*"} - local uuid=$(echo $tmp | head -c 36) - echo ${uuid} -} - -create_gpt() { - - local esp_type="C12A7328-F81F-11D2-BA4B-00A0C93EC93B" - local linux_type="0FC63DAF-8483-4772-8E79-3D69D8477DE4" - - local part_start_esp=${PART_START_ALIGNMENT} - local part_start_linux="${@get_next_part_start(d)}" - - local size=$(get_size ${ROOTFS}) - local tmp=$(add ${size} ${LBA}) - - local rootfs_sectors=$(div ${tmp} ${LBA}) - local rootfs_uuid=$(get_uuid ${ROOTFS}) - - echo "Sectors $rootfs_sectors ${BOOT_SECTORS}" - - { - echo "label: gpt" - echo "start=${part_start_esp}, size=${BOOT_SECTORS}, name=ESP, type=${esp_type}" - echo "start=${part_start_linux}, size=${rootfs_sectors}, name=root, type=${linux_type}, uuid=${rootfs_uuid}" - } | sfdisk -q "${1}" - - dd if="${2}" of="${1}" seek=$(mult ${part_start_esp} ${LBA}) bs=8M conv=notrunc,sparse oflag=seek_bytes status=progress - dd if="${3}" of="${1}" seek=$(mult ${part_start_linux} ${LBA}) bs=8M conv=notrunc,sparse oflag=seek_bytes status=progress -} - -do_configure() { - local grub="${BSP_GRUB_DIR}/grub-config.cfg" - local uuid=$(get_uuid ${ROOTFS}) - echo ${uuid} - rm -f ${BSP_GRUB_DIR}/grub-config.cfg.processed - sed -e "s@%UUID%@${uuid}@" \ - "${BSP_GRUB_DIR}/grub-config.cfg" > "${BSP_GRUB_DIR}/grub-config.cfg.processed" -} - -do_install() { - - local part0="${BSP_GRUB_DIR}/grub-efi-bootaa64.efi" - local part1="${BSP_GRUB_DIR}/grub-config.cfg.processed" - local part2="${BSP_DTB_DIR}/morello-${TARGET_PLATFORM}.dtb" - local part3="${DEPLOY_DIR}/images/morello-${TARGET_PLATFORM}/Image" - local part4="${DEPLOY_DIR}/images/morello-${TARGET_PLATFORM}/morello-initramfs/initramfs" - - rm -f ${ESP_IMAGE}.img - - # create the ESP - dd if=/dev/zero of=${ESP_IMAGE}.img bs=1024K count=${ESP_SIZE} - mformat -i ${ESP_IMAGE}.img -v ESP :: - - mmd -i ${ESP_IMAGE}.img ::/EFI - mmd -i ${ESP_IMAGE}.img ::/EFI/BOOT - - add_to_image ${ESP_IMAGE}.img ${part0} /EFI/BOOT/BOOTAA64.EFI - add_to_image ${ESP_IMAGE}.img ${part1} /EFI/BOOT/grub.cfg - add_to_image ${ESP_IMAGE}.img ${part2} /morello.dtb - add_to_image ${ESP_IMAGE}.img ${part3} /Image - add_to_image ${ESP_IMAGE}.img ${part4} /initramfs - - local size=$(get_size ${ROOTFS}) - - local rootfs_size=$(div ${size} 1048576) - local total_size=$(add ${ESP_SIZE} ${rootfs_size}) - - : > ${OUTPUTS_NAME}.img - truncate --size="$(add ${total_size} 50)M" ${OUTPUTS_NAME}.img - - create_gpt ${OUTPUTS_NAME}.img ${ESP_IMAGE}.img ${ROOTFS} ${size} - - install ${OUTPUTS_NAME}.img ${D}/${OUTPUTS_NAME}.img - install ${ESP_IMAGE}.img ${D}/${ESP_IMAGE}.img -} - -do_deploy() { - install -d ${DEPLOYDIR}/ESP - install ${D}/${OUTPUTS_NAME}.img ${DEPLOYDIR}/${OUTPUTS_NAME}-${TCLIBC}.img - install ${D}/${ESP_IMAGE}.img ${DEPLOYDIR}/ESP/${ESP_IMAGE}.img - -} -addtask deploy after do_install \ No newline at end of file diff --git a/meta-morello/wic/morello-efidisk.wks b/meta-morello/wic/morello-efidisk.wks new file mode 100644 index 0000000..eda618a --- /dev/null +++ b/meta-morello/wic/morello-efidisk.wks @@ -0,0 +1,9 @@ +# short-description: Create an EFI disk image +# long-description: Creates a partitioned EFI disk image that the user +# can directly dd to boot media. Uses a custom grub.cfg file to configure the boot. + +part /boot --source bootimg-efi --sourceparams="loader=grub-efi,initrd=morello-initramfs/initramfs,file=morello-initramfs/initramfs" --ondisk sda --label msdos --active --align 1024 + +part / --source rootfs --ondisk sda --fstype=ext4 --label root --align 1024 --uuid=70ead9cb-4d31-4ffa-8127-7cc8c720eaa8 + +bootloader --ptable gpt --configfile="${MACHINE}-grub.cfg" diff --git a/meta-morello/wic/morello-fvp-grub.cfg b/meta-morello/wic/morello-fvp-grub.cfg new file mode 100644 index 0000000..72c2030 --- /dev/null +++ b/meta-morello/wic/morello-fvp-grub.cfg @@ -0,0 +1,35 @@ +set debug="loader,mm" +set term="vt100" +set default="1" +set timeout="5" + +menuentry 'BusyBox Morello Platform (Device Tree) : a64 + c64 sysroot' { + devicetree /morello-fvp.dtb + linux /Image \ + acpi=off \ + debug \ + earlycon=pl011,0x2A400000 \ + ip=dhcp \ + root=PARTUUID=70ead9cb-4d31-4ffa-8127-7cc8c720eaa8 \ +} + +menuentry 'BusyBox Morello Platform (ACPI) : a64 + c64 sysroot' { + linux /Image \ + acpi=force \ + debug \ + earlycon=pl011,0x2A400000 \ + ip=dhcp \ + root=PARTUUID=70ead9cb-4d31-4ffa-8127-7cc8c720eaa8 \ +} + +menuentry 'BusyBox Morello Platform (Device Tree): initramfs pure c64' { + devicetree /morello-fvp.dtb + linux /Image \ + acpi=off \ + debug \ + earlycon=pl011,0x2A400000 \ + ip=dhcp \ + root=PARTUUID=70ead9cb-4d31-4ffa-8127-7cc8c720eaa8 \ + + initrd /initramfs +} \ No newline at end of file diff --git a/meta-morello/wic/morello-soc-grub.cfg b/meta-morello/wic/morello-soc-grub.cfg new file mode 100644 index 0000000..5356269 --- /dev/null +++ b/meta-morello/wic/morello-soc-grub.cfg @@ -0,0 +1,37 @@ +set debug="loader,mm" +set term="vt100" +set default="1" +set timeout="5" + +menuentry 'BusyBox Morello Platform (Device Tree) : a64 + c64 sysroot' { + devicetree /morello-soc.dtb + linux /Image \ + acpi=off \ + debug \ + console=ttyAMA0,115200 \ + earlycon=pl011,0x2A400000 \ + ip=dhcp \ + root=PARTUUID=70ead9cb-4d31-4ffa-8127-7cc8c720eaa8 \ +} + +menuentry 'BusyBox Morello Platform (ACPI) : a64 + c64 sysroot' { + linux /Image \ + acpi=force \ + debug \ + earlycon=pl011,0x2A400000 \ + ip=dhcp \ + root=PARTUUID=70ead9cb-4d31-4ffa-8127-7cc8c720eaa8 \ +} + +menuentry 'BusyBox Morello Platform (Device Tree): initramfs pure c64' { + devicetree /morello-soc.dtb + linux /Image \ + acpi=off \ + debug \ + console=ttyAMA0,115200 \ + earlycon=pl011,0x2A400000 \ + ip=dhcp \ + root=PARTUUID=70ead9cb-4d31-4ffa-8127-7cc8c720eaa8 \ + + initrd /initramfs +} \ No newline at end of file