-
Notifications
You must be signed in to change notification settings - Fork 7
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
boot-utils: Initial bring up #1
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
5247162
buildroot/rebuild.sh: Add die function
nathanchance a1c229c
buildroot/rebuild.sh: Add an informative error message when there are…
nathanchance 6d2104e
buildroot: Update to 2020.02
nathanchance e6875f5
buildroot: Compress images with zstd
nathanchance ff1d673
images: Generate from latest buildroot source
nathanchance b4586cd
images/ppc64le: Add a script to build the skiboot image
nathanchance 51bc49e
images/ppc64le: Add prebuilt skiboot-6.5.4 image
nathanchance 101ef4f
boot-qemu.sh: Initial version
nathanchance e3ff4b5
boot-qemu-help: Clarify that -i causes -t to be ignored
nathanchance 2780f39
boot-qemu: Add comment around arm rootfs location
nathanchance 936f954
boot-qemu: Be more clear when erroring about required values
nathanchance 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 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 @@ | ||
rootfs.cpio |
This file contains 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,43 @@ | ||
Usage: ./boot-qemu.sh <options> | ||
|
||
Script description: Boots a Linux kernel in QEMU. | ||
|
||
Required parameters: | ||
-a | --arch | --architecture: | ||
The architecture to boot. Possible values are: | ||
* arm32_v5 | ||
* arm32_v6 | ||
* arm32_v7 | ||
* arm64 | ||
* mips | ||
* mipsel | ||
* ppc32 | ||
* ppc64 | ||
* ppc64le | ||
* x86_64 | ||
|
||
-k | --kbuild-folder: | ||
The kernel build folder, as an absolute path or relative path | ||
from wherever the script is being run. This is wherever the | ||
compiled vmlinux image lives, not the architecture's boot folder. | ||
|
||
Optional parameters: | ||
-d | --debug: | ||
Invokes 'set -x' for debugging the script. | ||
|
||
-h | --help: | ||
Prints this message then exits. | ||
|
||
-i | --interactive | --shell: | ||
By default, the rootfs images in this repo just boots the kernel, | ||
print the version string, then exit. If you would like to actually | ||
interact with the machine, this option passes 'rdinit=/bin/sh' to | ||
the kernel command line so that you are thrown into an interactive | ||
shell. When this is set, there is no timeout so any value supplied | ||
via the script's -t option is ignored. | ||
|
||
-t | --timeout: | ||
By default, the timeout command waits 3 minutes before killing the | ||
QEMU machine. Depending on the power of the host machine, this might | ||
not be long enough for a kernel to boot so this allows that timeout | ||
to be configured. Takes the value passed to timeout (e.g. 30s or 4m). | ||
nathanchance marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains 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,200 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Root of the repo | ||
BASE=$(cd "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" && pwd) | ||
|
||
|
||
# Prints an error message in bold red then exits | ||
function die() { | ||
printf "\n\033[01;31m%s\033[0m\n" "${1}" | ||
exit 1 | ||
} | ||
|
||
|
||
# Check that a binary is found | ||
function checkbin() { | ||
command -v "${1}" &>/dev/null || die "${1} could not be found, please install it!" | ||
} | ||
|
||
|
||
# Parse inputs to the script | ||
function parse_parameters() { | ||
while (( ${#} )); do | ||
case ${1} in | ||
-a|--arch|--architecture) | ||
shift | ||
case ${1} in | ||
arm32_v5|arm32_v6|arm32_v7|arm64|mips|mipsel|ppc32|ppc64|ppc64le|x86_64) ARCH=${1} ;; | ||
*) die "Invalid --arch value '${1}'" ;; | ||
tpimh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
esac ;; | ||
|
||
-d|--debug) | ||
set -x ;; | ||
|
||
-h|--help) | ||
echo | ||
cat "${BASE}"/boot-qemu-help.txt | ||
echo | ||
exit 0 ;; | ||
|
||
-i|--interactive|--shell) | ||
INTERACTIVE=true ;; | ||
|
||
-k|--kbuild-folder) | ||
shift && KBUILD_DIR=${1} ;; | ||
|
||
-t|--timeout) | ||
shift && TIMEOUT=${1} ;; | ||
|
||
*) | ||
die "Invalid parameter '${1}'" ;; | ||
esac | ||
shift | ||
done | ||
} | ||
|
||
|
||
# Sanity check parameters and required tools | ||
function sanity_check() { | ||
# Kernel build folder and architecture are required paramters | ||
[[ -z ${ARCH} ]] && die "Architecture ('-a') is required but not specified!" | ||
[[ -z ${KBUILD_DIR} ]] && die "Kernel build folder ('-k') is required but not specified!" | ||
|
||
# KBUILD_DIR could be a relative path; turn it into an absolute one with readlink | ||
KBUILD_DIR=$(readlink -f "${KBUILD_DIR}") | ||
|
||
# Let the user know if the kernel build folder does not exist | ||
[[ -d ${KBUILD_DIR} ]] || die "${KBUILD_DIR} does not exist!" | ||
|
||
# Make sure zstd is install | ||
checkbin zstd | ||
} | ||
|
||
|
||
# Decompress rootfs images | ||
function decomp_rootfs() { | ||
# All arm32_* options share the same rootfs, under images/arm | ||
[[ ${ARCH} =~ arm32 ]] && ARCH_RTFS_DIR=arm | ||
nathanchance marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
IMAGES_DIR=${BASE}/images/${ARCH_RTFS_DIR:-${ARCH}} | ||
ROOTFS=${IMAGES_DIR}/rootfs.cpio | ||
|
||
rm -rf "${ROOTFS}" | ||
zstd -d "${ROOTFS}".zst -o "${ROOTFS}" | ||
} | ||
|
||
|
||
# Boot QEMU | ||
function setup_qemu_args() { | ||
if ${INTERACTIVE:=false}; then | ||
RDINIT=" rdinit=/bin/sh" | ||
APPEND_RDINIT=( -append "${RDINIT}" ) | ||
fi | ||
|
||
case ${ARCH} in | ||
tpimh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
arm32_v5) | ||
ARCH=arm | ||
QEMU_ARCH_ARGS=( "${APPEND_RDINIT[@]}" | ||
-dtb "${KBUILD_DIR}"/arch/arm/boot/dts/aspeed-bmc-opp-palmetto.dtb | ||
-machine palmetto-bmc | ||
-no-reboot ) | ||
QEMU=( qemu-system-arm ) ;; | ||
|
||
arm32_v6) | ||
ARCH=arm | ||
QEMU_ARCH_ARGS=( "${APPEND_RDINIT[@]}" | ||
-dtb "${KBUILD_DIR}"/arch/arm/boot/dts/aspeed-bmc-opp-romulus.dtb | ||
-machine romulus-bmc | ||
-no-reboot ) | ||
QEMU=( qemu-system-arm ) ;; | ||
|
||
arm32_v7) | ||
ARCH=arm | ||
QEMU_ARCH_ARGS=( -append "console=ttyAMA0${RDINIT}" | ||
-machine virt | ||
-no-reboot ) | ||
QEMU=( qemu-system-arm ) ;; | ||
|
||
arm64) | ||
KIMAGE=Image.gz | ||
QEMU_ARCH_ARGS=( -append "console=ttyAMA0${RDINIT}" | ||
-cpu cortex-a57 | ||
-machine virt ) | ||
QEMU=( qemu-system-aarch64 ) ;; | ||
|
||
mips|mipsel) | ||
KIMAGE=vmlinux | ||
QEMU_ARCH_ARGS=( "${APPEND_RDINIT[@]}" | ||
-cpu 24Kf | ||
-machine malta ) | ||
QEMU=( qemu-system-"${ARCH}" ) | ||
ARCH=mips ;; | ||
|
||
ppc32) | ||
ARCH=powerpc | ||
QEMU_ARCH_ARGS=( -append "console=ttyS0${RDINIT}" | ||
-machine bamboo | ||
-no-reboot ) | ||
QEMU_RAM=128m | ||
QEMU=( qemu-system-ppc ) ;; | ||
|
||
ppc64) | ||
ARCH=powerpc | ||
KIMAGE=vmlinux | ||
QEMU_ARCH_ARGS=( "${APPEND_RDINIT[@]}" | ||
-machine pseries | ||
-vga none ) | ||
QEMU_RAM=1G | ||
QEMU=( qemu-system-ppc64 ) ;; | ||
|
||
ppc64le) | ||
ARCH=powerpc | ||
KIMAGE=zImage.epapr | ||
QEMU_ARCH_ARGS=( "${APPEND_RDINIT[@]}" | ||
-device "ipmi-bmc-sim,id=bmc0" | ||
-device "isa-ipmi-bt,bmc=bmc0,irq=10" | ||
-L "${IMAGES_DIR}/" -bios skiboot.lid | ||
-machine powernv ) | ||
QEMU_RAM=2G | ||
QEMU=( qemu-system-ppc64 ) ;; | ||
|
||
x86_64) | ||
KIMAGE=bzImage | ||
QEMU_ARCH_ARGS=( -append "console=ttyS0${RDINIT}" ) | ||
# Use KVM if the processor supports it (first part) and the KVM module is loaded (second part) | ||
[[ $(grep -c -E 'vmx|svm' /proc/cpuinfo) -gt 0 && $(lsmod 2>/dev/null | grep -c kvm) -gt 0 ]] && \ | ||
QEMU_ARCH_ARGS=( "${QEMU_ARCH_ARGS[@]}" -cpu host -d "unimp,guest_errors" -enable-kvm ) | ||
QEMU=( qemu-system-x86_64 ) ;; | ||
esac | ||
checkbin "${QEMU[*]}" | ||
|
||
[[ ${KIMAGE:=zImage} = "vmlinux" ]] || BOOT_DIR=arch/${ARCH}/boot/ | ||
KERNEL=${KBUILD_DIR}/${BOOT_DIR}${KIMAGE} | ||
[[ -f ${KERNEL} ]] || die "${KERNEL} does not exist!" | ||
} | ||
|
||
|
||
# Invoke QEMU | ||
function invoke_qemu() { | ||
${INTERACTIVE} || QEMU=( timeout "${TIMEOUT:=3m}" unbuffer "${QEMU[@]}" ) | ||
|
||
set -x | ||
"${QEMU[@]}" \ | ||
"${QEMU_ARCH_ARGS[@]}" \ | ||
-display none \ | ||
-initrd "${ROOTFS}" \ | ||
-kernel "${KERNEL}" \ | ||
-m "${QEMU_RAM:=512m}" \ | ||
-serial mon:stdio | ||
RET=${?} | ||
set +x | ||
|
||
return ${RET} | ||
} | ||
|
||
|
||
parse_parameters "${@}" | ||
sanity_check | ||
decomp_rootfs | ||
setup_qemu_args | ||
invoke_qemu |
This file was deleted.
Oops, something went wrong.
This file contains 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 @@ | ||
d1fa8ee1a3a79d42266db41e470e8d31075de0ebd36bc9b424648c4d100c4105 buildroot-2020.02.tar.gz |
This file contains 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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains 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,17 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eux | ||
|
||
BASE=$(cd "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" && pwd) | ||
VER=${1} | ||
TMP=$(mktemp -d) | ||
|
||
trap 'rm -rf "${TMP}"' EXIT INT TERM | ||
|
||
# Build skiboot | ||
cd "${TMP}" | ||
curl -LSs https://github.com/open-power/skiboot/archive/v"${VER}".tar.gz | tar xzf - | ||
cd skiboot-"${VER}" | ||
CROSS=${CROSS:-powerpc64le-linux-gnu-} SKIBOOT_VERSION=v${VER} make -j"$(nproc)" | ||
cp -v skiboot.lid "${BASE}" | ||
rm -rf "${PWD}" |
Binary file not shown.
Binary file not shown.
Binary file not shown.
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.
Why the folder and not path to kernel image?
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.
For a couple of the ARM devices, we need the dtb to boot:
https://github.com/nathanchance/boot-utils/blob/101ef4f4258719dd4879cf68ae28af8cc9351595/boot-qemu.sh#L97
https://github.com/nathanchance/boot-utils/blob/101ef4f4258719dd4879cf68ae28af8cc9351595/boot-qemu.sh#L105