Browse Source
Merge pull request #139 from mirzak/MEN-2784-boot-gap
Implement MENDER_COPY_BOOT_GAP feature
2.0.x
Mirza Krak
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with
40 additions and
2 deletions
-
configs/beaglebone_black_base_config
-
configs/mender_convert_config
-
configs/qemux86-64_config
-
configs/raspberrypi_config
-
configs/rockpro64_config
-
mender-convert-extract
-
mender-convert-package
|
|
@ -6,6 +6,9 @@ |
|
|
|
# There are reported issues with GRUB bootloader integration, fallback to U-boot. |
|
|
|
MENDER_GRUB_EFI_INTEGRATION=n |
|
|
|
|
|
|
|
# We will write a modified bootloader |
|
|
|
MENDER_COPY_BOOT_GAP=n |
|
|
|
|
|
|
|
# 4MB alignment |
|
|
|
MENDER_PARTITION_ALIGNMENT="4194304" |
|
|
|
|
|
|
|
|
|
@ -120,6 +120,13 @@ MENDER_KERNEL_DEVICETREE=kernel.dtb |
|
|
|
# https://github.com/intel/bmap-tools |
|
|
|
MENDER_USE_BMAP="n" |
|
|
|
|
|
|
|
# Copy the boot gap, which is the area from sector 1 until first parition, |
|
|
|
# this is done because some images might contain the bootloader embedded here |
|
|
|
# and we need to copy the bootloader to the output image. |
|
|
|
# |
|
|
|
# In most cases you would like this enabled. |
|
|
|
MENDER_COPY_BOOT_GAP="y" |
|
|
|
|
|
|
|
source configs/mender_grub_config |
|
|
|
|
|
|
|
# Function to create Mender Artifact |
|
|
|
|
|
@ -14,3 +14,6 @@ |
|
|
|
|
|
|
|
MENDER_STORAGE_DEVICE=/dev/sda |
|
|
|
MENDER_DEVICE_TYPE="qemux86_64" |
|
|
|
|
|
|
|
# Nothing to copy |
|
|
|
MENDER_COPY_BOOT_GAP="n" |
|
|
|
|
|
@ -1,6 +1,9 @@ |
|
|
|
# Raspberry Pi does not support GRUB bootloader integration, fallback to U-boot. |
|
|
|
MENDER_GRUB_EFI_INTEGRATION=n |
|
|
|
|
|
|
|
# Nothing to copy |
|
|
|
MENDER_COPY_BOOT_GAP=n |
|
|
|
|
|
|
|
# 4MB alignment |
|
|
|
MENDER_PARTITION_ALIGNMENT="4194304" |
|
|
|
|
|
|
|
|
|
@ -1,6 +1,9 @@ |
|
|
|
# ROCKPro64 do not support GRUB bootloader integration, fallback to U-boot. |
|
|
|
MENDER_GRUB_EFI_INTEGRATION=n |
|
|
|
|
|
|
|
# We will write a modified bootloader |
|
|
|
MENDER_COPY_BOOT_GAP=n |
|
|
|
|
|
|
|
ROCKPRO64_BINARIES_URL="${MENDER_STORAGE_URL}/mender-convert/armbian/rockpro64/${ROCKPRO64_BINARIES}" |
|
|
|
|
|
|
|
function platform_modify() { |
|
|
|
|
|
@ -102,5 +102,8 @@ fi |
|
|
|
# this is done because some images might contain the bootloader embedded here |
|
|
|
# and we might need to keep this area intact when we generate our custom |
|
|
|
# image. |
|
|
|
if [ "${MENDER_COPY_BOOT_GAP}" == "y" ]; then |
|
|
|
log_info "Extracting boot gap to work/boot-gap.bin" |
|
|
|
disk_extract_part "${disk_image}" \ |
|
|
|
1 $(( $(disk_get_part_value ${disk_image} 1 START) - 1)) work/boot-gap.bin |
|
|
|
fi |
|
|
|
|
|
@ -102,6 +102,16 @@ else |
|
|
|
overhead_sectors=$(( ${alignment_sectors} * 6 )) |
|
|
|
fi |
|
|
|
|
|
|
|
# Validate boot-gap.bin size, ensuring it will fit between MBR and boot_part_start |
|
|
|
if [ "${MENDER_COPY_BOOT_GAP}" == "y" ]; then |
|
|
|
# Add one block for MBR |
|
|
|
boot_gap_sectors=$(( $(stat --printf="%b" work/boot-gap.bin) + 1)) |
|
|
|
if [ ${boot_gap_sectors} -ge ${boot_part_start} ]; then |
|
|
|
log_warn "The work/boot-gap.bin file will overwrite the boot partition" |
|
|
|
log_fatal "Please increase MENDER_PARTITION_ALIGNMENT (2x will typically solve this))" |
|
|
|
fi |
|
|
|
fi |
|
|
|
|
|
|
|
# Validate boot part size |
|
|
|
actual_boot_size=$(du --apparent-size -s --block-size=512 ${boot_part} | cut -f 1) |
|
|
|
if [ ${actual_boot_size} -gt ${boot_part_sectors} ]; then |
|
|
@ -199,6 +209,12 @@ run_and_log_cmd "${PARTED} -s ${sdimg_path} -- unit s mkpart primary ext2 ${root |
|
|
|
run_and_log_cmd "${PARTED} -s ${sdimg_path} -- unit s mkpart primary ext2 ${data_start} ${data_end}" |
|
|
|
run_and_log_cmd "${PARTED} -s ${sdimg_path} print" |
|
|
|
|
|
|
|
# Write boot-gap |
|
|
|
if [ "${MENDER_COPY_BOOT_GAP}" == "y" ]; then |
|
|
|
log_info "Writing boot gap of size: ${boot_part_sectors} (sectors)" |
|
|
|
disk_write_at_offset "${output_dir}/boot-gap.bin" "${sdimg_path}" "1" |
|
|
|
fi |
|
|
|
|
|
|
|
# Burn Partitions |
|
|
|
disk_write_at_offset "${boot_part}" "${sdimg_path}" "${boot_part_start}" |
|
|
|
disk_write_at_offset "${output_dir}/rootfs.img" "${sdimg_path}" "${rootfsa_start}" |
|
|
|