QEMU

https://www.qemu.org/

A generic and open source machine emulator and virtualizer

Installation

sudo apt-get install qemu-system

NuttX

Install Toolchain

wget https://developer.arm.com/-/media/Files/downloads/gnu/11.2-2022.02/binrel/gcc-arm-11.2-2022.02-x86_64-aarch64-none-elf.tar.xz
xz -d gcc-arm-11.2-2022.02-x86_64-aarch64-none-elf.tar.xz
tar xf gcc-arm-11.2-2022.02-x86_64-aarch64-none-elf.tar

Put gcc-arm-11.2-2022.02-x86_64-aarch64-none-elf/bin/ to your host PATH environment variable, like:

export PATH=$PATH:~/toolchain/gcc-arm-11.2-2022.02-x86_64-aarch64-none-elf/bin

check the toolchain:

aarch64-none-elf-gcc -v

Output

Using built-in specs.
COLLECT_GCC=aarch64-none-elf-gcc
COLLECT_LTO_WRAPPER=/home/arcslab/toolchain/gcc-arm-11.2-2022.02-x86_64-aarch64-none-elf/bin/../libexec/gcc/aarch64-none-elf/11.2.1/lto-wrapper
Target: aarch64-none-elf
Configured with: /data/jenkins/workspace/GNU-toolchain/arm-11/src/gcc/configure --target=aarch64-none-elf --prefix=/data/jenkins/workspace/GNU-toolchain/arm-11/build-aarch64-none-elf/install// --with-gmp=/data/jenkins/workspace/GNU-toolchain/arm-11/build-aarch64-none-elf/host-tools --with-mpfr=/data/jenkins/workspace/GNU-toolchain/arm-11/build-aarch64-none-elf/host-tools --with-mpc=/data/jenkins/workspace/GNU-toolchain/arm-11/build-aarch64-none-elf/host-tools --with-isl=/data/jenkins/workspace/GNU-toolchain/arm-11/build-aarch64-none-elf/host-tools --disable-shared --disable-nls --disable-threads --disable-tls --enable-checking=release --enable-languages=c,c++,fortran --with-newlib --with-pkgversion='GNU Toolchain for the Arm Architecture 11.2-2022.02 (arm-11.14)' --with-bugurl=https://bugs.linaro.org/
Thread model: single
Supported LTO compression algorithms: zlib
gcc version 11.2.1 20220111 (GNU Toolchain for the Arm Architecture 11.2-2022.02 (arm-11.14)) 

Install QEMU

sudo apt-get install qemu-system-arm qemu-efi-aarch64 qemu-utils

And make sure install is properly:

qemu-system-aarch64 --help

Configuring and running

Single Core (GICv3)

Configuring NuttX and compile:

cd nuttx
export PATH=$PATH:~/toolchain/gcc-arm-11.2-2022.02-x86_64-aarch64-none-elf/bin
make distclean
./tools/configure.sh -l qemu-armv8a:nsh

Running with qemu

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

Output

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
- Ready to Boot Primary CPU
- Boot from EL2
- Boot from EL1
- Boot to C runtime for OS Initialize
psci_detect: Detected PSCI v0.2
nx_start: Entry
up_allocate_heap: heap_start=0x0x403cb000, heap_size=0x7c35000
gic_validate_dist_version: GICv3 version detect
gic_validate_dist_version: GICD_TYPER = 0x37a0007
gic_validate_dist_version: 224 SPIs implemented
gic_validate_dist_version: 0 Extended SPIs implemented
gic_validate_dist_version: Distributor has no Range Selector support
gic_validate_redist_version: GICR_TYPER = 0x1000011
gic_validate_redist_version: 16 PPIs implemented
gic_validate_redist_version: no VLPI support, no direct LPI support
uart_register: Registering /dev/console
uart_register: Registering /dev/ttyS0
work_start_highpri: Starting high-priority kernel worker thread(s)
nx_start_application: Starting init thread
task_spawn: name=nsh_main entry=0x40290710 file_actions=0 attr=0x403caf90 argv=0x403caf88
lib_cxx_initialize: _sinit: 0x402ae000 _einit: 0x402ae000
nsh: mkfatfs: command not found

NuttShell (NSH) NuttX-12.3.0
nsh> nx_start: CPU0: Beginning Idle Loop

Last updated