FreeRTOS-Kernel/FreeRTOS/Demo/CORTEX_M3_MPS2_QEMU_GCC
Aniruddha Kanhere 1277ba1661
Revert "Remove coroutines (#874)" (#1019)
* Revert "Remove coroutines (#874)"

This reverts commit 569c78fd8c.

* Update freertos Kernel submodule to latest head

* Remove temporary files

* Fix MingW demos and spell check

* Fix manifest version; fix headers

* Add ignore files and paths to core-checker.py

* Fix copyright in remaining files

* Fix PR check build failure

1. Remove defining `inline` in Makefile. This was causing build
   warnings.
2. Ensure that the linker removed unused functions from various
   compilation units.
3. Update the linker script so that all the functions are correctly
   placed in FLASH section.

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>

---------

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
Co-authored-by: Gaurav Aggarwal <aggarg@amazon.com>
2023-06-09 15:25:48 -07:00
..
.vscode Add build dependency (#486) 2020-12-24 09:39:54 -08:00
CMSIS Qemu mps2 networking (#439) 2020-12-03 23:44:57 -08:00
init Demo/CORTEX_M3_MPS2_QEMU_GCC: Prepare startup.c for use with --gc-sections 2023-03-30 12:32:55 -07:00
scripts Demo/CORTEX_M3_MPS2_QEMU_GCC: Define symbols needed for picolibc sbrk implementation 2023-03-30 12:32:55 -07:00
console.c [AUTO][RELEASE]: Bump file header version to "202212.00" 2022-12-10 01:17:30 +00:00
console.h [AUTO][RELEASE]: Bump file header version to "202212.00" 2022-12-10 01:17:30 +00:00
FreeRTOSConfig.h Revert "Remove coroutines (#874)" (#1019) 2023-06-09 15:25:48 -07:00
main.c Improve vAssertCalled function to include filename / line number info. 2023-03-30 12:32:55 -07:00
main_blinky.c [AUTO][RELEASE]: Bump file header version to "202212.00" 2022-12-10 01:17:30 +00:00
main_full.c [AUTO][RELEASE]: Bump file header version to "202212.00" 2022-12-10 01:17:30 +00:00
Makefile Enable newlib and picolibc thread local storage 2023-03-30 12:32:55 -07:00
Readme.md Doc: Add new lines 2021-06-28 17:07:24 -07:00
syscall.c Demo/CORTEX_M3_MPS2_QEMU_GCC: Provide picolibc syscall implementation 2023-03-30 12:32:55 -07:00

Emulating MPS2 Cortex M3 AN385 on QEMU

Requirements

  1. GNU Arm Embedded Toolchain download here (tested on versiom 9.3.1 20200408)
  2. qemu-arm-system download here (tested on version 5.0.1 (v5.0.1-dirty))
  3. Make (tested on version 3.82)
  4. Linux OS (tested on Ubuntu 18.04)

How to download

Navigate to a parent directory of your choice and run the following command

$ git clone https://github.com/FreeRTOS/FreeRTOS.git --recurse-submodules --depth 1

The previous command should create a directory named FreeRTOS

Getting Started on Windows using WSL

The Windows Subsystem for Linux allows you to run native Linux applications from a shell on your windows machine.

To set up your Windows 10 machine to run this QEMU based demo you can follow these steps

  1. Install Ubuntu 20.04 LTS version from Microsoft Store, search for "Ubuntu"
  2. Update apt-get
sudo apt-get update
  1. Install Make and Qemu
sudo apt-get install -y make qemu qemu-system-arm
  1. Download and unzip Arm tools
cd ~
curl https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu-rm/10-2020q4/gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2 -o gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2
tar -xjvf gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2
  1. Update your path to include the arm toolchain Edit ".profile", add the unzipped bin folder to the front of the path. You can run the same command in the terminal to update the path temporarily in the current shell
export PATH="$HOME/gcc-arm-none-eabi-10-2020-q4-major/bin:$PATH"
  1. Clone FreeRTOS
git clone https://github.com/FreeRTOS/FreeRTOS.git --recurse-submodules
  1. Compile the code
cd ./FreeRTOS/FreeRTOS/Demo/CORTEX_M3_MPS2_QEMU_GCC
make
  1. Run the Blinky Demo
sudo qemu-system-arm -machine mps2-an385 -monitor null -semihosting --semihosting-config enable=on,target=native -kernel ./build/RTOSDemo.axf -serial stdio -nographic

Blinky Demo

How to build blinky demo

Navigate with the command line to FreeRTOS/Demo/CORTEX_M3_MPS2_QEMU_GCC For a release build run:

$ export PATH=/path/to/arm/toolchain:$PATH
$ make

For a versions with debugging symbols and no optimizations -O0, run:

$ make DEBUG=1

How to run the blinky demo

run:

$ sudo qemu-system-arm -machine mps2-an385 -monitor null -semihosting \
        --semihosting-config enable=on,target=native \
        -kernel ./build/RTOSDemo.axf \
        -serial stdio -nographic

Blinky Demo Expectations

After running the blinky demo you shoud see on the screen the word blinking printed continuously

Full Demo

How to build the Full Demo

Navigate with the command line to FreeRTOS/Demo/CORTEX_M3_MPS2_QEMU_GCC For a release build run:

$ export PATH=/path/to/arm/toolchain:$PATH
$ make FULL_DEMO=1

For a versions with debugging symbols and no optimizations -O0, run:

$ make FULL_DEMO=1 DEBUG=1

How to run the Full Demo

run:

$ sudo qemu-system-arm -machine mps2-an385 -monitor null -semihosting \
        --semihosting-config enable=on,target=native \
        -kernel ./build/RTOSDemo.axf \
        -serial stdio -nographic

Full Demo Expectations

The full demo includes a check that executes every (simulated) ten seconds, but has the highest priority to ensure it gets processing time. Its main function is to check all the standard demo tasks are still operational. The check task maintains a status string that is output to the console each time it executes. If all the standard demo tasks are running without error, then the string contains “OK” and the current tick count. If an error has been detected, then the string contains a message that indicates which task reported the error.

How to start debugging

  1. Build the debug version by using DEBUG=1:
$ make DEBUG=1
  1. Run the binary with -s and -S flags:
$ sudo qemu-system-arm -machine mps2-an385 -monitor null -semihosting \
        --semihosting-config enable=on,target=native \
        -kernel ./build/RTOSDemo.axf \
        -serial stdio -nographic -s -S

The options:
-s allows gdb to be attached to the process remotely at port 1234
-S starts the program in the paused state.

  1. Open another terminal to run GDB and connect to the process:
$ arm-none-eabi-gdb -q ./build/RTOSDemo.axf
(gdb) target remote :1234
(gdb) break main
(gdb) c