Running FreeRTOS Command Line Interface

This application note explains the interactive Command Line Interface (CLI) implemented by the FreeRTOS BSP.

1. Understanding FreeRTOS Command Line Interface

1.1. FreeRTOS CLI Purpose

The FreeRTOS test application integrates implementation of a FreeRTOS Command Line Interface (CLI). The CLI provides an interactive user interface on the serial console, allowing the user to run various commands from the FreeRTOS test application in interactive mode.

The FreeRTOS test application is enhanced to provide various custom CLI commands, used to validate and demonstrate the features supported by the FreeRTOS BSP. These custom CLI commands are documented in the other application notes available on the site.

1.2. FreeRTOS CLI UART Port

The FreeRTOS BSP is enhanced to implement a serial console interface on the STM32H7 USART1 port.

The serial console is configured to run at 115200 rate.

1.3. FreeRTOS CLI Source Files

Implementation of the serial console interface can be found in the Applications/FreeRTOS/freertos_stm32h750/Src/console.[ch] source files.

1.4. FreeRTOS CLI C-Binding API

The serial console interface will implement the following C-binding API:

Function

Description

Comments

int console_init(void)

Initialise the serial console interface

Serial console available on USART1, at 115200 rate

void console_putc(char c)

Print a character to the serial console

Can be called from multiple parallel threads

void console_puts(char * str)

Print a string to the serial console

Can be called from multiple parallel threads

char console_getc(void)

Get a character from the serial console

Implementation is interrupt-driven. Use shall be limited to a single thread

2. FreeRTOS CLI Sample Session

The following is a FreeRTOS sample session:

$ picocom -b 115200 /dev/ttyUSB1 picocom v3.1 port is : /dev/ttyUSB1 flowcontrol : none baudrate is : 115200 parity is : none databits are : 8 stopbits are : 1 escape is : C-a local echo is : no noinit is : no noreset is : no hangup is : no nolock is : no send_cmd is : sz -vv receive_cmd is : rz -vv -E imap is : omap is : emap is : crcrlf,delbs, logfile is : none initstring : none exit_after is : not set exit is : no Type [C-a] [C-h] to see available commands Terminal ready U-Boot SPL 2019.04-gb41e2dbf49-dirty (Mar 14 2023 - 01:00:44 +0300) Hit 's' key to enter spl shell: Trying to boot from SPI U-Boot 2019.04-gb41e2dbf49-dirty (Mar 14 2023 - 01:00:44 +0300) Model: STMicroelectronics STM32H7 SOM DRAM: 32 MiB SF: Detected n25q512ax3 with page size 256 Bytes, erase size 4 KiB, total 64 MiB Flash: 128 KiB MMC: STM32 SDMMC2: 0 Loading Environment from UBI... ubi0: default fastmap pool size: 190 ubi0: default fastmap WL pool size: 95 ubi0: attaching mtd2 ubi0: scanning is finished ubi0: attached mtd2 (name "system", size 15 MiB) ubi0: PEB size: 4096 bytes (4 KiB), LEB size: 3968 bytes ubi0: min./max. I/O unit sizes: 1/256, sub-page size 1 ubi0: VID header offset: 64 (aligned 64), data offset: 128 ubi0: good PEBs: 3840, bad PEBs: 0, corrupted PEBs: 0 ubi0: user volume: 5, internal volumes: 1, max. volumes count: 23 ubi0: max/mean erase counter: 2/1, WL threshold: 4096, image sequence number: 0 ubi0: available PEBs: 1145, total reserved PEBs: 2695, PEBs reserved for bad PEB handling: 0 Read 16384 bytes from volume env1 to d1e72960 Read 16384 bytes from volume env2 to d1e76980 OK In: serial Out: serial Err: serial No size specified -> Using max size (2099072) Read 2099072 bytes from volume splash to d0400000 Net: Net Initialization Skipped No ethernet found. Hit any key to stop autoboot: 0 Booting Image #1 No size specified -> Using max size (4198144) Read 4198144 bytes from volume rtos1 to d0400000 ## Loading kernel from FIT Image at d0400000 ... Using 'config-1' configuration Verifying Hash Integrity ... sha1,rsa2048:dev+ OK Trying 'kernel' kernel subimage Description: FreeRTOS Image Type: Kernel Image Compression: uncompressed Data Start: 0xd04000d0 Data Size: 77376 Bytes = 75.6 KiB Architecture: ARM OS: Linux Load Address: 0xd0600000 Entry Point: 0xd0610279 Hash algo: sha1 Hash value: 413d02bfc42ad673db4f077d8f84dd4e48d2de79 Verifying Hash Integrity ... sha1+ OK Loading Kernel Image ... OK Starting kernel ... STM32H7 SOM FreeRTOS CLI, www.emcraft.com Type help to view a list of available commands. CLI> help help: Lists all the registered commands i2c_scan <bus> i2c_read <bus> <i2c_addr> <addr_data> <cnt> i2c_write <bus> <i2c_addr> <addr_data> <data> rtc_get_date rtc_set_date <date> wdt_stop sdram_test <ptrn> <cnt> uart_test <port> <baudrate> <cnt> lcdtest pwm_start <tim> <chnl> <period> <duty> pwm_stop <tim> <chnl> adc_se <nadc> <chnl> spi_flash_test <spi_bus> timer_cnt ubipart <mtdpart> ubifsmount <vol> ubifsumount ubifsls <path> ubifsload <path> <addr> <size> ubifswrite <path> <addr> <size> ubifsmkdir <path> ubifsrmdir <path> ubifsunlink <path> ubifsstress usbfatls uboot_getenv <var> uboot_setenv <var=val> uboot_saveenv sdram_info reliable_upgrade <image> CLI>