MecrispCube

https://spyr.ch/twiki/bin/view/MecrispCube by Peter Schmid

Peter Schmid Intro

STM32WB Forth without BLE, USB, Filesystems and RTOS etc, is not complete.

To build this in Forth by myself from the scratch overwhelms me.

Note

everyone else as well - Terry P

I would like to go the reverse way and use the STM tools like CubeIDE, HAL, CubeMX and integrate the Mecrips Forth into it.

Forth as an interactive extension for the STM32 ecosystem.

Mecrisp Forth running as a CMSIS-RTOS thread.

Already done

Integrated in STM32 Cube ecosystem. Create C code from CubeMX for internal peripherals and use it in Forth.
Forth as CMSIS-RTOS thread. CMSIS-RTOS API to use FreeRTOS from Forth.
Buffered terminal I/O (5 KiB buffer for UART Rx). Interrupt driven and RTOS aware, key and emit block the calling thread.
USB-CDC for serial communication via USB. Redirect console I/O like cdc-emit, cdc-key
microSD and internal Flash mass storage for blocks and FAT filesystem.
    Internal Flash drive 384 KiB
    Filesystem API
    UNIX like Shell commands
Calling C Functions from Forth and vice versa
vi Editor origin in BusyBox tiny vi. Workflow development: begin Edit EVALUATE while SaveFile repeat
Board Support Package BSP (for other boards see Adafruit Feather STM32F405, STM32WB5MM Discovery Kit, and STM32WB Feather development board)
    LEDs: LED1 (blue), LED2 (green), LED3 (red)
    Switches: SW1, SW2, SW3 (dongle: SW1)
    Digital port pins: D0 to D15 (Dongle: D0, D1, D6, D10 to D15)
    Analog port pins: A0 to A5 (Dongle: A2, A3)
    PWM: D3, D6, D9 (Dongle: D6)
    Input capture: A2
    Output compare: D0, D1, D5 (Dongle: D0, D1)
    SPI: D11 MOSI, D12 MISO, D13 SCK (e.g. for display, memory)
    I2C: D14 SDA, D15 SCL (external peripherals e.g. pressure)
BLE 5.0 GAP Peripheral Role
    DIS Device Information Service
    HRS Heart Rate Service (heart rate depends on A0 for Nucleo and A2 for Dongle)
    CRS Cable Replacement Server service (proprietary service from STM, similar to Classic Bluetooth SPP). Redirect console I/O like crs-emit, crs-key.
Real Time Clock (32 bit UNIX time stamp, valid times are from 1.1.2000 to 31.12.2099 because of the STM32WB RTC peripheral) time!, time@, and .time (YYYY-MM-DDTHH:MM:SS ISO 8601).
Watchdog
Assertation and Logging

OLED Display 128x32, 128x64, I2C
NeoPixel
Markdown manual pages

Planned TODO

USB-MSC to read and write blocks or files from a host computer UsbCompositeMscCdc.
Command line editing like Gforth Arrow right no longer needed, see EditorVi
BLE 5.0 GAP Peripheral Role
    BLE Event driven programming like LAIRD's smartBASIC, WAITEVENT ONEVENT.
    BLE GATT (Characteristics, Services, Profiles)
    Current Time Service
BLE 5.0 GAP Central Role
    Scan, Pairing
    Cable Replacement Client CRC
    HID profile (keyboard)
E-Ink FeatherWing
Low power
Integration of FFL - Forth Foundation Library http://irdvo.nl/FFL/index.html https://github.com/irdvo/ffl
Support for the floating point unit, CMSIS-DSP
VIS: VOCs, ITEMs and STICKY Words (Forth Namespaces and Context Switching based on VOCs, ITEMs and STICKY Words)

UML state machine (extended state machine, hierarchically nested states), see Finite State Machine module in the ffl
Thread (network protocol)
SQLite https://en.wikipedia.org/wiki/SQLite
SSH https://www.oryx-embedded.com/pdf/CycloneSSH_Datasheet.pdf

https://stackoverflow.com/questions/8422287/how-to-call-c-functions-from-arm-assembly
https://static.docs.arm.com/ihi0042/g/aapcs32.pdf

Getting Started

These instructions will get you a copy of the project up and running on your local machine (STM32 Nucleo board) for development and testing purposes.

Prerequisites

  • STM32WB Nucleo Board - The highly affordable STM32 Nucleo boards allow anyone to try out new ideas and to quickly create prototypes with any STM32 MCU. The STM32 Nucleo boards integrate an ST-Link debugger/programmer, so there is no need for a separate probe.

  • Terminal emulator application for PC, e.g.:

  • PuTTY - Windows and Linux

  • Tera Term - Windows

  • Realterm - Windows

  • minicom, microcom, screen - Linux

  • Use the built in Eclipse console (but no LF)

Flash the Mecrisp-Cube binary

Or the FS binary with local filesystem and some tools to the Nucleo Board.

Connect the Nucleo Board USB ST-LINK to the PC
Copy binary (MecrispCube.bin) to the USB mass storage NODE_WB55RG

Start the terminal emulator application on the PC.

Check for the serial communication port (e.g. for Linux /dev/ttyACM0) and set the speed to 115200 baud. I set the putty terminal configuration to

Implicit CR in every LF
Local echo: Auto
Local line editing: Auto
Keyboard Backspace: Control-H
Keyboard Function: Keys VT100
Remote character set: CP850

For Unix terminal emulator configs please see this link

Mecrisp-Stellaris RA 2.5.4 by Matthias Koch.

Mecrisp-Cube 1.4.1 for STM32WB55, 63/128 KiB RAM/FLASH dictionary (C) 2020 peter@spyr.ch

  • Firmware Package STM32Cube FW_WB V1.10.0, USB-CDC, BLE Stack 5.0 (C) 2020 STMicroelectronics

  • CMSIS-RTOS V2 FreeRTOS wrapper, FreeRTOS Kernel V10.2.1 (C) 2017 Amazon.com

  • FatFs for internal flash and microSD - Generic FAT fs module R0.12c (C) 2017 ChaN

  • tiny vi - part of BusyBox (C) 2000, 2001 Sterling Huxley

23 5 / .[CR] 4  ok.
: hello ." World" ;[CR]  ok.
hello[CR] World ok.

Installing

A step by step series of examples that tell you how to get a development env running

Install the IDE STM32CubeIDE, it is Eclipse and GCC based. STM32CubeMX is included in the IDE, you need a stand alone installation only if you do not want to use the STM32CubeIDE.

Get the sources from github:

psi@homer:~> git clone https://github.com/spyren/Mecrisp-Cube
Klone nach 'Mecrisp-Cube' ...
remote: Enumerating objects: 106, done.
remote: Counting objects: 100% (106/106), done.
remote: Compressing objects: 100% (71/71), done.
remote: Total 106 (delta 33), reused 106 (delta 33), pack-reused 0
Empfange Objekte: 100% (106/106), 938.96 KiB | 2.39 MiB/s, Fertig.
Löse Unterschiede auf: 100% (33/33), Fertig.

Import the project into the IDE:

File -> Import -> General -> Existing Projects into Workspace -> Select root directory
Copy project into workspace
Browse to Mecrisp-Cube directory

Generate code from the STM32CubeMX MecrispCube.ioc file:

Project -> Generate Code

Restore changed source files

$ git status
{list of changed files}
$ git restore {files to restore}

Select the Build Configuration

(Debug if you want to debug the project) and Build the project:

Project -> Build Configurations -> Set Active -> Debug/Reelease
Project -> Build Project