How to deploy FreeRTOS on PINAKA with a sample application?

  • Post author:
  • Reading time:9 mins read
  • Post category:RTOS
You are currently viewing How to deploy FreeRTOS on PINAKA with a sample application?

FreeRTOS is an open source, real-time operating system for microcontrollers that makes small, low-power edge devices easy to program, deploy, secure, connect, and manage. This article is a step by step guide to install and cross-compile FreeRTOS with PINAKA (SHAKTI SoC). Check out this article, to deploy FreeRTOS on PARASHU(e-class on Arty100t) and VAJRA(c-class on Arty7 100t).

Here, we are going to see FreeRTOS running on PINAKA(e-class on Arty7 35t).

Step 1: Prerequisites

  • shakti-tools installed and PATH exported.
  • Arty7 35t with pinaka programmed on it.
  • Bread board
  • Micro USB Cable.
  • Jumper Wires.
  • One Led.
  • Resistors (to protect LED).

Note: shakti-sdk and shakti-tools are currently a private repository. Please login or sign up to Gitlab and request access here before using it.

Step 2:  Getting FreeRTOS repository

Then clone the FreeRTOS repository to your system.

git clone https://gitlab.com/shaktiproject/software/FreeRTOS.git

Step 3: Demo application on FreeRTOS

In this demo, Firstly we are going to deploy FreeRTOS on Arty7 board. Then add an application on that and then execute it. We are going to read values from the GPIO0 port. Based on this value control the LED connected to GPIO1 port.

3.1 Circuit connection:

  • GPIO0 to VCC
  • GPIO1 to LED

3.2 Code

Please click here to have a look at the code.

Step 4: Deploying on SHAKTI

4.1.1 Compile and Build

Go to the PINAKA repo and the execute make

$ cd FreeRTOS/FreeRTOS/Demo/shakti/pinaka
$ make

The output executable is created in <path-to-FreeRTOS>/FreeRTOS/Demo/shakti/pinaka as freeRtos-e32-35t.elf

4.1.2 Execution:

Once the application is built, the executable is generated in the output folder. The executable is in ELF file format and they have the extension .elf. Now, open three terminals, one for each of the following,

  • One terminal for UART terminal display (miniterm)
  • And the last one for OpenOCD.
  • Another for GDB server.

Terminal 1: Firstly, Connect to serial output by using miniterm or gtkterm with the baud rate of 19200.

For instance,

$ sudo miniterm.py /dev/ttyUSB1 19200

Note:

  • “/dev/ttyUSB1” – ttyUSB means “USB serial port adapter”
  • The “1” (“0” or “1” or “2”“here means the USB device number on your system. Please connect the FPGA board to that USB device number.


Terminal 2: After that, Connect to the FPGA board by using the OpenOCD provided by shakti-tools and its respective configuration file.  (Read how OpenOCD and RISC-V GDB work together to establish a connection between our PC and the Microprocessor)

For PINAKA,

$ cd FreeRTOS/FreeRTOS/Demo/shakti/bsp/third_party/pinaka/
$ sudo $(which openocd) -f ftdi.cfg

Terminal 3: Now, open either 32-bit or 64-bit RISC-V GDB based on your architecture i.e riscv32-unknown-elf-gdb or riscv64-unknown-elf-gdb respectively from shakti-tools.

The output executable is created in <path-to-FreeRTOS>/FreeRTOS/Demo/shakti/pinaka as freeRtos-e32-35t.elf

Load up the .elf file by following the below steps,

For pinaka,

$ riscv32-unknown-elf-gdb
(gdb) set remotetimeout unlimited
(gdb) target remote localhost:3333
(gdb) file path/to/executable
(gdb) load
(gdb) c

Miniterm Output

--- Miniterm on /dev/ttyUSB1: 19200,8,N,1 ---
--- Quit: Ctrl+]  |  Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---                  ((                                          
                                    ,(((((
                                *((((((
                           ./(((((((
                       ./((((((((
                    *(((((((((
                .(((((((((((
             ,((((((((((((
           ((((((((((((((
          .((((((((((((((
              *(((((((((((
                   /(((((((
                  *((((((((
                     *(((((((
                       (((((((((
                        ((((((((((
                         (((((((((((((
                         ((((((((((((((
                        ((((((((((((
                      *(((((((((( 
                    (((((((((               
              *(((((((
           *((((((
       .(((((
   ./(((  
SHAKTI PROCESSORS
Booting... vspi1.0

Booting on Pinaka! hart 0
Pinaka is a SoC build on top of Artix7 35T.
The core belongs to Shakti E class, 32 bit.


Supported ISA: RV32IMACNU.
Processor Arch ID: 0.
Device ID 1
extracted device id 2018
No content to boot

FreeRTOS Starting
  

 4.1.3 Upload to flash

Steps to generate standalone user application:

The FreeRTOS has an uploader tool that is used to load content (such as ELF) to flash, after building the image.

  • Goto the right directory.
cd FreeRTOS/FreeRTOS/Demo/shakti/vajra
  • The make upload command is used to build and upload the application to the flash automatically.
make upload

Miniterm Output (Upload)

Erasing…
Erase complete.
Writing.......
Write complete.
Please reset.
  • Now press Reset Button on board(arty7 board with pinaka)
--- Miniterm on /dev/ttyUSB1: 19200,8,N,1 ---
--- Quit: Ctrl+]  |  Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---                  ((                                          
                                    ,(((((
                                *((((((
                           ./(((((((
                       ./((((((((
                    *(((((((((
                .(((((((((((
             ,((((((((((((
           ((((((((((((((
          .((((((((((((((
              *(((((((((((
                   /(((((((
                  *((((((((
                     *(((((((
                       (((((((((
                        ((((((((((
                         (((((((((((((
                         ((((((((((((((
                        ((((((((((((
                      *((((((((((
                    (((((((((               
              *(((((((
           *((((((
       .(((((
   ./(((  
SHAKTI PROCESSORS
Booting... vspi1.0
Booting on Pinaka! hart 0
Pinaka is a SoC build on top of Artix7 35T.
The core belongs to Shakti E class, 32 bit.

Supported ISA: RV32IMACNU.
Processor Arch ID: 0.
Device ID 1
extracted device id 2018
................
Control transferred to RAM
FreeRTOS Starting