Skip to content

Instantly share code, notes, and snippets.

@lupyuen
Last active November 27, 2022 08:07
Show Gist options
  • Save lupyuen/5e2fba642a33bf64d3378df3795042d7 to your computer and use it in GitHub Desktop.
Save lupyuen/5e2fba642a33bf64d3378df3795042d7 to your computer and use it in GitHub Desktop.
Shell Script to build, test and run NuttX on QEMU Arm64
#!/usr/bin/env bash
## Shell Script to build, test and run NuttX on QEMU Arm64
## TODO: Update PATH
export PATH="$PATH:/Applications/ArmGNUToolchain/11.3.rel1/aarch64-none-elf/bin"
set -e # Exit when any command fails
set -x # Echo commands
## Show the GCC version
aarch64-none-elf-gcc -v
## TODO: Configure NuttX
## make clean && make distclean && ./tools/configure.sh -l qemu-armv8a:nsh
## make clean && make distclean && ./tools/configure.sh -l qemu-armv8a:nsh_smp
## make clean && make distclean && ./tools/configure.sh -l qemu-armv8a:nsh_gicv2
## Build the firmware
make -j
## Show the size
aarch64-none-elf-size nuttx
## Dump the disassembly to nuttx.S
aarch64-none-elf-objdump \
-t -S --demangle --line-numbers --wide \
nuttx \
>nuttx.S \
2>&1
## Check coding style
../nxstyle arch/arm64/Kconfig
../nxstyle arch/arm64/include/qemu/chip.h
../nxstyle arch/arm64/src/common/Make.defs
../nxstyle arch/arm64/src/common/arm64_gic.h
../nxstyle arch/arm64/src/common/arm64_gicv2.c
../nxstyle arch/arm64/src/common/arm64_gicv3.c
../nxstyle boards/arm64/qemu/qemu-armv8a/README.txt
../nxstyle boards/arm64/qemu/qemu-armv8a/configs/nsh_gicv2/defconfig
## Boot NuttX on QEMU (Single Core) with GIC v3
# qemu-system-aarch64 \
# -cpu cortex-a53 \
# -nographic \
# -machine virt,virtualization=on,gic-version=3 \
# -net none \
# -chardev stdio,id=con,mux=on \
# -serial chardev:con \
# -mon chardev=con,mode=readline \
# -kernel ./nuttx \
## Boot NuttX on QEMU (Quad Core) with GIC v3
# qemu-system-aarch64 \
# -smp 4 \
# -cpu cortex-a53 \
# -nographic \
# -machine virt,virtualization=on,gic-version=3 \
# -net none \
# -chardev stdio,id=con,mux=on \
# -serial chardev:con \
# -mon chardev=con,mode=readline \
# -kernel ./nuttx \
## Boot NuttX on QEMU (Single Core) with GIC v2
qemu-system-aarch64 \
-cpu cortex-a53 \
-nographic \
-machine virt,virtualization=on,gic-version=2 \
-net none \
-chardev stdio,id=con,mux=on \
-serial chardev:con \
-mon chardev=con,mode=readline \
-kernel ./nuttx \
&
sleep 2
kill %1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment