diff --git a/README.md b/README.md index 801ba6a..ddef411 100644 --- a/README.md +++ b/README.md @@ -66,11 +66,12 @@ x86) before running on bare metal. ## Building and Running ### Prerequisites -You will need QEMU for aarch64 emulation. +You will need QEMU for aarch64 emulation, dosfstools to create the virtual file system +and gcc-aarch64-linux-gnu to compile bash for the image. ```bash -# Install QEMU (Ubuntu/Debian) -sudo apt install qemu-system-aarch64 +# Install QEMU (Ubuntu/Debian), dosfstools and gcc-aarch64-linux-gnu +sudo apt install qemu-system-aarch64 dosfstools gcc-aarch64-linux-gnu ``` Additionally you will need a version of the [aarch64-none-elf](https://developer.arm.com/Tools%20and%20Software/GNU%20Toolchain) toolchain installed. diff --git a/mkrootfs-aarch64.sh b/mkrootfs-aarch64.sh index 4d2d2d9..53eaa4f 100755 --- a/mkrootfs-aarch64.sh +++ b/mkrootfs-aarch64.sh @@ -21,24 +21,27 @@ fi pushd /tmp/bash -if [ ! -f "$MOUNT/bin/bash" ]; then +if [ ! -f "/tmp/bash/bash" ]; then ./configure --without-bash-malloc --enable-static-link --host=aarch64-linux-gnu CC=aarch64-linux-gnu-gcc make +fi - mkdir -p "$MOUNT/bin" - cp bash "$MOUNT/bin" +if [ ! -f "$MOUNT/bin/bash" ]; then + sudo mkdir -p "$MOUNT/bin" + sudo cp bash "$MOUNT/bin" fi popd # busybox -- I couldn't get this to build. I ended up restoring to a third-party static binary which isn't ideal but it get's things running. -pushd "$MOUNT/bin" -if [ ! -f busybox-aarch64-linux-gnu ]; then +pushd "/tmp" +if [ ! -f "$MOUNT/bin/busybox-aarch64-linux-gnu" ]; then wget https://github.com/shutingrz/busybox-static-binaries-fat/raw/refs/heads/main/busybox-aarch64-linux-gnu chmod +x busybox-aarch64-linux-gnu + sudo cp busybox-aarch64-linux-gnu "$MOUNT/bin" fi popd -mkdir -p "$MOUNT/dev" +sudo mkdir -p "$MOUNT/dev" if mountpoint -q "$MOUNT"; then sudo umount "$MOUNT" diff --git a/qemu-runner.sh b/qemu-runner.sh index 5768dbf..202d4ca 100755 --- a/qemu-runner.sh +++ b/qemu-runner.sh @@ -4,7 +4,7 @@ set -e ELF="$1" BIN="${ELF%.elf}.bin" -sudo bash -c "./mkrootfs-aarch64.sh" +./mkrootfs-aarch64.sh # Convert to binary format aarch64-none-elf-objcopy -O binary "$ELF" "$BIN"