RTOS on Cortex‐A - MarekBykowski/readme GitHub Wiki

RTOS support for Cortex-A

We target two RTOS's, ThreadX and Zephyr.

ThreadX

https://github.com/eclipse-threadx

MCUXpresso SDK https://mcuxpresso.nxp.com/en ThreadX and at al. are available as extention to MCUXpresso IDE https://nxp.flexnetoperations.com/control/frse/download?agree=Accept&element=6642171

Try to run a sample project

  • git clone --recursive https://github.com/azure-rtos/getting-started.git
    cd ~; git clone --recursive https://github.com/azure-rtos/getting-started.git
  • Use vcpkg, an open source package manager by Microsoft https://learn.arm.com/learning-paths/embedded-and-microcontrollers/vcpkg-tool-installation/.
    • Do not follow the vcpkg howto from threadx as these are unprecise and won't work. Follow vcpkg the arm link above. Steps are:
    • Install
      . <(curl https://aka.ms/vcpkg-init.sh -L)
    • Init vcpkg
      . ~/.vcpkg/vcpkg-init
    • Go to the git repo cloned
      cd getting-started/NXP/MIMXRT1060-EVK
    • and use vcpkg against vcpkg-configuration.json there. This activates and downloads all tools specified by the configuration file
      vcpkg-shell activate
xxbykowm@ubuntu:~/eclipse-threadx/getting-started/NXP/MIMXRT1060-EVK$ vcpkg-shell activate
warning: vcpkg-artifacts is experimental and may change at any time.
A suitable version of node was not found (required v16.15.1).
Downloading https://nodejs.org/dist/v16.15.1/node-v16.15.1-linux-x64.tar.gz -> node-v16.15.1-linux-x64.tar.gz
Successfully downloaded node-v16.15.1-linux-x64.tar.gz
Extracting node...
Artifact                           Version   Status       Dependency Summary                                                        
microsoft:compilers/arm/gcc 2020.10.0 will install            GCC compiler for ARM CPUs.                                     
microsoft:tools/compuphase/termite 3.4.0     will install            Termite is an easy to use and easy to configure RS232 terminal.
microsoft:tools/kitware/cmake 3.20.1    will install            Kitware's cmake tool                                           
microsoft:tools/ninja-build/ninja 1.10.2    will install            Ninja is a small build system with a focus on speed.           

warning: microsoft:compilers/arm/gcc - Ensure libncurses5 is installed with your system package manager before running arm-none-eabi-gdb.
Deactivating: /home/xxbykowm/eclipse-threadx/getting-started/NXP/MIMXRT1060-EVK
Activating: /home/xxbykowm/eclipse-threadx/getting-started/NXP/MIMXRT1060-EVK
  • switch to ./tools there and run rebuild.sh
xxbykowm@ubuntu:~/eclipse-threadx/getting-started/NXP/MIMXRT1060-EVK/tools$ ./rebuild.sh 
mb: /home/xxbykowm/eclipse-threadx/getting-started/NXP/MIMXRT1060-EVK
-- Using ARM GCC from path = /home/xxbykowm/.vcpkg/downloads/artifacts/vcpkg-ce-default/compilers.arm.gcc/2020.10.0/bin
-- Using ARM GCC from path = /home/xxbykowm/.vcpkg/downloads/artifacts/vcpkg-ce-default/compilers.arm.gcc/2020.10.0/bin
-- The C compiler identification is GNU 10.2.1
-- The CXX compiler identification is GNU 10.2.1
-- The ASM compiler identification is GNU
-- Found assembler: /home/xxbykowm/.vcpkg/downloads/artifacts/vcpkg-ce-default/compilers.arm.gcc/2020.10.0/bin/arm-none-eabi-gcc
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /home/xxbykowm/.vcpkg/downloads/artifacts/vcpkg-ce-default/compilers.arm.gcc/2020.10.0/bin/arm-none-eabi-gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /home/xxbykowm/.vcpkg/downloads/artifacts/vcpkg-ce-default/compilers.arm.gcc/2020.10.0/bin/arm-none-eabi-g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- THREADX_ARCH: cortex_m7
-- THREADX_TOOLCHAIN: gnu
-- Using custom tx_user.h file from /home/xxbykowm/eclipse-threadx/getting-started/NXP/MIMXRT1060-EVK/lib/threadx/tx_user.h
-- NXD_ENABLE_AZURE_IOT - defined
-- Read version from /home/xxbykowm/eclipse-threadx/getting-started/shared/lib/netxduo/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/az_version.h
-- AZ_SDK_VERSION_MAJOR 1
-- AZ_SDK_VERSION_MINOR 3
-- AZ_SDK_VERSION_PATCH 2
-- AZ_SDK_VERSION_PRERELEASE 
Target Distribution Undefined, setting default 'RTOS_BASE'
Seting distribution RTOS_BASE
Merging platform asc_config.h.in
-- target architecture: ARM
-- setTargetCompileOptions for target asc_security_core
-- Using '-Wpedantic' flag for compilation as warning only for target asc_security_core
-- setTargetCompileOptions for target iot_security_module
-- Using '-Wpedantic' flag for compilation as warning only for target iot_security_module
-- Using custom nx_user.h file from /home/xxbykowm/eclipse-threadx/getting-started/NXP/MIMXRT1060-EVK/lib/netxduo/nx_user.h
-- Configuring done
-- Generating done
-- Build files have been written to: /home/xxbykowm/eclipse-threadx/getting-started/NXP/MIMXRT1060-EVK/build
[1210/1211] Linking C executable app/mimxrt1060_azure_iot.elf
Memory region         Used Size  Region Size  %age Used
  m_flash_config:         512 B         4 KB     12.50%
           m_ivt:        1088 B         4 KB     26.56%
    m_interrupts:          1 KB         1 KB    100.00%
          m_text:      378440 B      8183 KB      4.52%
          m_data:         12 KB       128 KB      9.38%
         m_data2:      177888 B       768 KB     22.62%
[1211/1211] cd /home/xxbykowm/eclipse-threadx/getting-started/NXP/MIMXRT1060-EVK/build/app && /home/xxbykowm/.vcpkg/d...efault/compilers.arm.gcc/2020.10.0/bin/arm-none-eabi-objcopy -Oihex mimxrt1060_azure_iot.elf mimxrt1060_azure_iot.hex

Zephyr

https://github.com/zephyrproject-rtos

image

Zephyr is already ported:

Run Zephyr on Cortex-A FVP simulator

Zephyr is thorough documentation that you can rely on. Start off Getting Started Guide

It covers Installation of the Host Dependencies, Running west (managing multiple Git repositories under a single directory using a single file, called the west manifest), Installation of the Zephyr SDK/toolchain and Building & Running a Sample app/s. For convience I pasted the steps into here

python3 -m venv ~/zephyrproject/.venv
source ~/zephyrproject/.venv/bin/activate
pip install west
west init ~/zephyrproject
cd ~/zephyrproject
west update
west zephyr-export
west packages pip --install
cd ~/zephyrproject/zephyr
west sdk install

FVP path is /home/xxbykowm/Downloads/Base_RevC_AEM_Fast_Models_11.26/Base_RevC_AEMvA_pkg/models/Linux64_GCC-9.3/FVP_Base_RevC-2xAEMvA

Switch to ~/zephyrproject/zephyr, create run_hello_on_qemu.sh

cat << 'EOF' >> run_hello_fvp_cortex-a.sh
export ARMFVP_BIN_PATH=~/Downloads/Base_RevC_AEM_Fast_Models_11.26/Base_RevC_AEMvA_pkg/models/Linux64_GCC-9.3
export ZEPHYR_TOOLCHAIN_VARIANT=zephyr                                          
west build -p always -b fvp_base_revc_2xaemv8a samples/synchronization          
west -v build -t run
EOF
chmod +x run_hello_fvp_cortex-a.sh

and run it

$ ./run_hello_fvp_cortex-a.sh
[0/1] cd /home/xxbykowm/zephyrproject/zephyr/build && /home/xxbykowm/Downloads/Base_RevC_AEM_Fast_Models_11.26/Base_RevC_AEMvA_pkg/models/Linux64_GCC-9.3/FVP_Base_RevC-2xAEMvA -C bp.secure_memory=0 -C cluster0.NUM_CORES=1 -C bp.refcounte
r.non_arch_start_at_default=1 -C bp.pl011_uart0.out_file=- -C bp.pl011_uart0.unbuffered_output=1 -C bp.terminal_0.start_telnet=0 -C bp.pl011_uart1.out_file=- -C bp.pl011_uart1.unbuffered_output=1 -C bp.terminal_1.start_telnet=0 -C bp.pl0
11_uart2.out_file=- -C bp.pl011_uart2.unbuffered_output=1 -C bp.terminal_2.start_telnet=0 -C bp.pl011_uart3.out_file=- -C bp.pl011_uart3.unbuffered_output=1 -C bp.terminal_3.start_telnet=0 -C bp.vis.disable_visualisation=1 -C bp.vis.rate
_limit-enable=0 -C gic_distributor.ARE-fixed-to-one=1 -C gic_distributor.ITS-device-bits=16 -C cache_state_modelled=0 -a /home/xxbykowm/zephyrproject/zephyr/build/zephyr/zephyr.elf
terminal_0: Listening for serial connection on port 5000
terminal_1: Listening for serial connection on port 5001
terminal_3: Listening for serial connection on port 5002
terminal_2: Listening for serial connection on port 5003
*** Booting Zephyr OS build v4.1.0-rc1-57-g50c21f159143 ***
thread_a: Hello World from cpu 0 on fvp_base_revc_2xaemv8a!
thread_b: Hello World from cpu 0 on fvp_base_revc_2xaemv8a!
thread_a: Hello World from cpu 0 on fvp_base_revc_2xaemv8a!
thread_b: Hello World from cpu 0 on fvp_base_revc_2xaemv8a!

Run Zephyr on QEMU simulator

In addition to running Zephyr on FVP you can run it on QEMU shipped with the Zephyr SDK.

QEMU -> ~/zephyr-sdk-0.17.0/sysroots/x86_64-pokysdk-linux/usr/bin/qemu-system-i386

Switch to ~/zephyrproject/zephyr, and run

cat << 'EOF' >> run_hello_on_qemu.sh
export ZEPHYR_TOOLCHAIN_VARIANT=zephyr              
west build -p always -b qemu_x86 samples/hello_world
west -v build -t run                                
EOF
chmod +x run_hello_on_qemu.sh

Then run the script created to see Hello World from QEMU

$ ./run_hello_on_qemu.sh
[0/1] cd /home/xxbykowm/zephyrproject/zephyr/build && /home/xxbykowm/zephyr-sdk-0.17.0/sysroots/x86_64-pokysdk-linux/usr/bin/qemu-system-i386 -m 32 -cpu qemu32,+nx,+pae -machine q35 -device isa-debug-exit,iobase=0xf4,iosize=0x04 -no-rebo
ot -nographic -machine acpi=off -net none -pidfile qemu.pid -chardev stdio,id=con,mux=on -serial chardev:con -mon chardev=con,mode=readline -icount shift=5,align=off,sleep=off -rtc clock=vm -kernel /home/xxbykowm/zephyrproject/zephyr/bui
ld/zephyr/zephyr.elf
SeaBIOS (version zephyr-v1.0.0-0-g31d4e0e-dirty-20200714_234759-fv-az50-zephyr)
Booting from ROM..
*** Booting Zephyr OS build v4.1.0-rc1-57-g50c21f159143 ***
Hello World! qemu_x86/atom
⚠️ **GitHub.com Fallback** ⚠️