.. index:: unusual-forths, sockpuppet, mecrisp-across,staapl,atlast,pico_atlast,moving forth,racket,lisp .. _unusual-forths: .. Created unusual-forths.rst: Thu 11 Aug 2022 21:21:49 AEST .. Full Path: /home/tp/mecrisp-unofficial-doc/unusual-forths.rst .. Author Copyright 2022 by t.j.porter .. Made by /home/tp/projects/scripts/makerst.sh -->/usr/local/bin/makerst .. license: MIT, please see COPYING Unusual Forths ============== And related items we should know about. .. _mecrisp-cube: Mecrisp-Cube ------------ By Peter Schmidt Links ----- Mecrisp-Cube: https://github.com/spyren/Mecrisp-Cube/blob/master/README.md Calling C Functions from Forth and Vice Versa: https://github.com/spyren/Mecrisp-Cube/blob/master/sdcard/man/CallingCFunction.md https://www.spyr.ch/twiki/bin/view/MecrispCube https://giters.com/spyren/Mecrisp-Cube Updated Documentation --------------------- Why a Preemptive Real Time Operating System? Forth systems traditionally make use of cooperative multitasking. It is very simple and clever. But it has its limits. If you write all your software by yourself, each software part can be cooperative. But if you want to benefit from middleware written by somebody else (and most probably not written in Forth), you can be sure that software is not cooperative (in the context of multitasking). Forth wants to rule your system. I would like to have a Forth system that is cooperative. It should extend the system, to make it interactive and easy to use. The Forth interpreter (called terminal task in Forth jargon) itself is only a thread and can be used as some sort of CLI for testing purposes or could be the main part of the application. Rest of article at https://github.com/spyren/Mecrisp-Cube/blob/master/sdcard/man/CmsisRtos.md User Manual ^^^^^^^^^^^ https://www.spyr.ch/twiki/bin/view/MecrispCube/MarkdownManual * Mecrisp-Stellaris Forth words * FAT and block filesystem * Board Support Package BSP * Terminal IO * CMSIS-RTOS * :ref:`How to call C functions` * Built-in editor vi * Real Time Clock RTC Integration in STM32 Cube Ecosystem ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :: Integrated in STM32 Cube ecosystem. Create C code from CubeMX for internal peripherals and use it in Forth. Calling C Functions from Forth and vice versa RTOS ~~~~ :: 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 ~~~ :: USB-CDC for serial communication via USB. Redirect console I/O like cdc-emit, cdc-key Filesystem ~~~~~~~~~~ :: microSD and internal Flash mass storage for blocks and FAT filesystem. Filesystem API UNIX like Shell commands vi Editor origin in BusyBox tiny vi. Workflow development: begin Edit EVALUATE while SaveFile repeat Board Support Package (BSP) ~~~~~~~~~~~~~~~~~~~~~~~~~~~ :: Onboard LEDs: LED1 (blue), LED2 (green), LED3 (red) Switches: SW1, SW2, SW3 Digital port pins: D0 to D15 Analog port pins: A0 to A5 PWMs Input capture, Output compare SPI (e.g. for display, memory) I2C: (external peripherals e.g. pressure) 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 BSPs ~~~~ :: Nucleo STM32WB55 STM32WB5MM Discovery Kit STM32WB Feather development board Adafruit Feather STM32F405 NUCLEO-H743ZI Arduino Portenta H7 BLE ~~~ :: USB, BLE (for STM32WB55) and other Middlewares BLE 5.0 GAP Peripheral Role (STM32WB) 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. External Peripherals (e.g. Feather Wings) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :: OLED Display 128x32, 128x64, I2C NeoPixel CharlieWing NeoPixelWing DotStarWing Parallax Propeller ------------------ https://www.parallax.com/propeller/ P1 and P2 ^^^^^^^^^ The Propeller microcontrollers’ eight processing cogs (cores) each operate independently or cooperatively, communicating through shared resources at-will. Each cog has direct access to its internal memory and shares equal access to all I/O pins and system resources. This nimble design affords flexible processing power and easy adaption to numerous uses, freeing developers from task-specific ICs while reducing part counts and design-to-production time. .. image:: pics/p1-hub-ram-interface.gif .. image:: pics/p2-hub-ram-interface.gif Specs ~~~~~ .. image:: pics/parallax-specs.jpg Propeller 1 Forth ~~~~~~~~~~~~~~~~~ Propforth - https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/propforth/PropForth-V5.5-20130317.zip Propeller 2 Forth ~~~~~~~~~~~~~~~~~ Comes with Tachyon Forth preloaded on the chip. https://sourceforge.net/projects/tachyon-forth/ Sockpuppet ---------- https://github.com/rbsexton/sockpuppet The Sockpuppet API is a minimalist system call interface that is Cortex-M Specific. This system call interface includes getchar/putchar and friends, plus a runtime linkSP32ing mechanism so that the client application can look up selected variables and functions in the C layer. **This was originally written to simplify porting Forth to new microcontroller environments**, but has since gone on to be a more general-purpose tool. This code has accumulated over a hundred million hours of runtime. The basic mechanism is a SVC instruction that hooks into a system call layer that is written in C. The client code can be in any language that complies or can comply with the ARM AAPCS calling convention. This allows you to leverage the large body of vendor-supplied SOC initialization code (for good or ill!) and write all of the device-specific interrupt handlers in C. Mecrisp-Across -------------- https://mecrisp-across-folkdoc.sourceforge.io/index.html A Tethered Forth which utilises a STM32F407 Host and cross compiles for a MSP430 target. Staapl ------ http://zwizwa.be/staapl A :ref:`Racket` based tethered Forth / Macro Assembler on steroids for PIC18F and seems to have Cortex-M3 support as well. Forth typically enables direct low–level machine resource access while providing a base for constructing high–level abstractions. Traditionally Forth is implemented in machine language. However, since the Staapl Forth doesn’t need to be self–hosting and so has no constraints about compiler complexity, it can be written almost entirely in macro form, instantiated by a meta–system running on a workstation instead of a small target system. Staapl’s Forth is subroutine threaded, with each Forth word corresponding to a piece of inlined machine code or a procedure call. Build Failures ^^^^^^^^^^^^^^ I tried to use Staapl in August 2022 but it failed. Staapl is a bit old now and not been updated in eight years. Details ~~~~~~~ I installed DrRacket 8.5 but Stappl failed looking for files not present in that version after running "(require (planet zwizwa/staapl/pic18/demo))" After reading https://github.com/zwizwa/staapl/blob/master/Makefile I then installed DrRacket 6.1.1 on FreeBSD-11.2 (this version fails to build on FreeBSD later than 12.3 with "ld: error: undefined symbol: libiconv_close"). Staapl also failed with various errors although DRRacket built perfectly. At this point I had reached the limit of my DrRacket and Staapl knowledge and stopped. Atlast ------ https://www.fourmilab.ch/atlast/ Mecrisp-Cube Forth is running as a CMSIS-RTOS thread.Autodesk Threaded Language Application System Toolkit Atlast(TM) is a toolkit that makes applications programmable. Deliberately designed to be easy to integrate both into existing programs and newly-developed ones, Atlast provides any program that incorporates it most of the benefits of programmability with very little explicit effort on the part of the developer. Indeed, once you begin to "think Atlast" as part of the design cycle, you'll probably find that the way you design and build programs changes substantially. I'm coming to think of Atlast as the "monster that feeds on programs," because including it in a program tends to shrink the amount of special-purpose code that would otherwise have to be written while resulting in finished applications that are open, extensible, and more easily adapted to other operating environments such as the event driven paradigm. TP Note: I corresponded with a designer who used Atlast to write a Forth which ran under Freertos on a Esp32 board. He said it was incredibly useful. Pico Atlast ^^^^^^^^^^^ https://github.com/skvamme/pico_atlast ATLAST Forth for Raspberry Pi Pico is a C application with a built in forth scripting environment. Compiles out of the box, no C-programming knowledge required to use the ATLAST forth console. Get full access to the Raspberry Pi Pico C API in atlast.c and use forth as a quick yet powerful scripting engine. Moving Forth ------------ https://www.bradrodriguez.com/papers/moving1.htm This is a series of learn and build papers by the Forth legend Brad Rodriguez. This seems to be the place that forth implementers start. .. _drracket: DrRacket -------- https://racket-lang.org/ .. note:: LISP and Forth have 'Metaprogramming' in common, they're related! Want to learn a LISP dialect in a well designed IDE ? The Racket language is a modern dialect of Lisp and a descendant of Scheme. .. image:: pics/drracket8.5.jpg A great article to help understand what LISP really is: https://www.defmacro.org/ramblings/lisp.html