Repository navigation
fastboot: add image profiles, rootfs_ref ramdisk resolution, and SpacemiT K3 support #3285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
61645e2
runtime: add shell quoting for image preparation
yogeshlal 4a33ce5
lava: allow platforms to set the boot and deploy budget
yogeshlal ff867ed
fastboot: separate image profiles from boot orchestration
yogeshlal 5836b91
fastboot: add bounded ext4 image construction
yogeshlal 6bb59fa
fastboot: add the SpacemiT K3 bootfs image profile
yogeshlal 9520900
kselftest: support smaller test-definition overlays
yogeshlal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,12 @@ | ||
| {# Package the caller's STAGE directory; no board layout or fastboot commands. #} | ||
| {% macro create(image_name, label, capacity_mb, features, block_size=4096, minimum_mb=128) -%} | ||
| - PAYLOAD=$(du -sb "$STAGE" | cut -f1) | ||
| - PAYLOAD_MB=$(( (PAYLOAD + 1048575) / 1048576 )) | ||
| {# Payload + 15% + 16 MiB of metadata, rounded up to 16 MiB. #} | ||
| - SIZE=$(( (( (PAYLOAD_MB * 115 + 99) / 100 + 16 + 15) / 16) * 16 )) | ||
| - if [ "$SIZE" -lt {{ minimum_mb }} ]; then SIZE={{ minimum_mb }}; fi | ||
| - if [ "$SIZE" -gt {{ capacity_mb }} ]; then echo "image needs ${SIZE} MiB (payload ${PAYLOAD_MB} MiB), partition capacity is {{ capacity_mb }} MiB" >&2; exit 1; fi | ||
| - rm -f -- {{ image_name | shellquote }} | ||
| - mkfs.ext4 -F -q -L {{ label | shellquote }} -m 0 -b {{ block_size }} -O {{ features | shellquote }} -d "$STAGE" {{ image_name | shellquote }} "${SIZE}M" | ||
| - e2fsck -fn {{ image_name | shellquote }} | ||
| {%- endmacro %} |
This file contains hidden or 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,26 @@ | ||
| {# Preserve the Android image formats used by existing fastboot platforms. #} | ||
| {# This stable branch also uses initramfs boot for jobs labelled NFS. | ||
| The job must still supply node.artifacts.ramdisk. #} | ||
| {% set allow_nfs_fallback = true %} | ||
| {% set image_name = 'boot.img' %} | ||
| {% set image_label = 'boot' %} | ||
| {% set deploy_to = 'fastboot' if fastboot_docker_image|default('') else 'download' %} | ||
| {% set postprocess_image = 'ghcr.io/mwasilew/docker-mkbootimage:master' %} | ||
| {# Preserve job/device timeout inheritance for existing Android platforms. #} | ||
| {% set download_timeout = none %} | ||
| {% set deploy_timeout = 2 %} | ||
|
|
||
| {% macro prepare(kernel, dtb, ramdisk, firmware=none) -%} | ||
| {% set append_dtb = fastboot_boot_image_format|default('android-header-dtb') == 'appended-dtb' %} | ||
| {% set cmdline = fastboot_kernel_cmdline|default('console=ttyMSM0,115200n8 earlycon qcom_geni_serial.con_enabled=1 mem_sleep_default=s2idle mitigations=auto video=efifb:off') %} | ||
| {% if append_dtb %} | ||
| - cat {{ kernel|shellquote }} {{ dtb|shellquote }} > kernel-with-dtb | ||
| - mkbootimg --kernel kernel-with-dtb --cmdline {{ cmdline|shellquote }} --ramdisk {{ ramdisk|shellquote }} --pagesize {{ fastboot_mkbootimg_pagesize|default(4096) }} --base {{ fastboot_mkbootimg_base|default('0x80000000') }} --output boot.img | ||
| {% else %} | ||
| {% if kernel.endswith('.gz') %} | ||
| - gzip -dc {{ kernel|shellquote }} > kernel-uncompressed | ||
| {% set kernel = 'kernel-uncompressed' %} | ||
| {% endif %} | ||
| - mkbootimg --header_version 2 --kernel {{ kernel|shellquote }} --dtb {{ dtb|shellquote }} --cmdline {{ cmdline|shellquote }} --ramdisk {{ ramdisk|shellquote }} --output boot.img | ||
| {% endif %} | ||
| {%- endmacro %} | ||
This file contains hidden or 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,53 @@ | ||
| {# SpacemiT K3 firmware/partition contract. All board assumptions live here. #} | ||
| {% import 'fastboot/images/ext4.jinja2' as ext4 %} | ||
| {% set image_name = 'bootfs.ext4' %} | ||
| {% set image_label = 'bootfs' %} | ||
| {% set deploy_to = 'fastboot' %} | ||
| {% set host_boot_only = true %} | ||
| {% set download_timeout = 30 %} | ||
| {% set deploy_timeout = 10 %} | ||
| {% set postprocess_image = 'artifacts.codelinaro.org/clo-420-qli-registry/kmake-image-ci:ver.1.0' %} | ||
| {% set partition_size_mb = fastboot_bootfs_size_mb|default(256) %} | ||
| {% set dtb_directory = 'spacemit' %} | ||
| {% set environment_file = 'env_k3.txt' %} | ||
| {% set ramdisk_address = '0x130000000' %} | ||
| {% set large_ramdisk_threshold = 134217728 %} | ||
| {% set relocated_dtb_address = '0x13ff00000' %} | ||
| {% set maximum_ramdisk_size = 267386880 %} | ||
| {# An explicit feature list works with older e2fsprogs, which reject even | ||
| ^orphan_file when they do not recognize orphan_file. Keep features readable | ||
| by the board's U-Boot, without orphan_file or metadata_csum_seed. #} | ||
| {% set ext4_features = 'none,has_journal,ext_attr,resize_inode,dir_index,filetype,extent,64bit,flex_bg,sparse_super,large_file,huge_file,dir_nlink,extra_isize,metadata_csum' %} | ||
|
|
||
| {% macro prepare(kernel, dtb, ramdisk, firmware=none) -%} | ||
| - KERNEL={{ kernel | shellquote }} | ||
| - DTB={{ dtb | shellquote }} | ||
| - RAMDISK={{ ramdisk | shellquote }} | ||
| - DTB_DIRECTORY={{ dtb_directory | shellquote }} | ||
| - ENVIRONMENT_FILE={{ environment_file | shellquote }} | ||
| - if gzip -t "$KERNEL" 2>/dev/null; then KCAT="gzip -dc"; else KCAT=cat; fi | ||
| - gzip -t "$RAMDISK" | ||
| - LIST=$(mktemp) | ||
| - STAGE=$(mktemp -d) | ||
| - trap 'rm -rf "$STAGE"; rm -f "$LIST"' EXIT | ||
| - gzip -dc "$RAMDISK" | cpio -it --quiet | sed 's#^\./##' > "$LIST" | ||
| - grep -qx init "$LIST" || { echo "ramdisk does not contain /init" >&2; exit 1; } | ||
| {# Prefer the kernel's version banner; accept one module release as fallback. #} | ||
| - MODVERS=$(sed -n 's#^\(usr/\)\{0,1\}lib/modules/\([^/]*\)/modules\.dep$#\2#p' "$LIST" | sort -u) | ||
| - KVER=$($KCAT "$KERNEL" | grep -a -o -m1 'Linux version [0-9][0-9]*\.[0-9][^ ]*' | cut -d' ' -f3) | ||
| - if [ -z "$KVER" ]; then NMOD=$(echo "$MODVERS" | grep -c . || true); [ "$NMOD" -eq 1 ] || { echo "cannot determine kernel release ($NMOD module releases)" >&2; exit 1; }; KVER=$MODVERS; fi | ||
| - 'echo "Kernel release: $KVER"' | ||
| - 'awk -v p="lib/modules/$KVER/" ''{ sub(/^usr\//, "") } index($0, p) == 1 { f = 1 } END { exit !f }'' "$LIST" || echo "WARNING: no modules for $KVER in the ramdisk"' | ||
| - mkdir -p "$STAGE/$DTB_DIRECTORY/$KVER" | ||
| - install -m 0644 "$KERNEL" "$STAGE/vmlinuz-$KVER" | ||
| - install -m 0644 "$RAMDISK" "$STAGE/initrd.img-$KVER" | ||
| - install -m 0644 "$DTB" "$STAGE/$DTB_DIRECTORY/$KVER/$DTB" | ||
| - printf '%s\n' "knl_name=vmlinuz-$KVER" "ramdisk_name=initrd.img-$KVER" "dtb_dir=$DTB_DIRECTORY/$KVER" {{ ('ramdisk_addr_r=' + ramdisk_address) | shellquote }} 'loglevel=8' 'commonargs=setenv bootargs plymouth.prefer-fbcon plymouth.ignore-serial-consoles splash' > "$STAGE/$ENVIRONMENT_FILE" | ||
| {# Relocate the DTB before a large ramdisk would overwrite its default address. #} | ||
| - RDSIZE=$(stat -c %s "$RAMDISK") | ||
| - if [ "$RDSIZE" -gt {{ large_ramdisk_threshold }} ]; then echo {{ ('fdt_addr_r=' + relocated_dtb_address) | shellquote }} >> "$STAGE/$ENVIRONMENT_FILE"; fi | ||
| - '[ "$RDSIZE" -le {{ maximum_ramdisk_size }} ] || { echo "ramdisk ($RDSIZE bytes) exceeds board load-address limits" >&2; exit 1; }' | ||
| - chmod 0644 "$STAGE/$ENVIRONMENT_FILE" | ||
| {{ ext4.create(image_name, image_label, partition_size_mb, ext4_features) }} | ||
| - find "$STAGE" -type f -printf '%P %s bytes\n' | sort | ||
| {%- endmacro %} |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @docularxu for fixing default cmdline! No behaviour change for existing android device now.