discussion icon indicating copy to clipboard operation
discussion copied to clipboard

Forth for ESP32

Open quozl opened this issue 7 years ago • 12 comments

Mitch Bradley has ported C Forth to ESP32.

  • https://github.com/MitchBradley/cforth/commit/b3c56890599353149275ece80977d9fbcad844c8

I have begun testing. My build steps on Ubuntu;

  • https://github.com/quozl/cforth-1/blob/esp32/README.md

Hardware so far is;

Any other Forth implementations for ESP32 yet?

quozl avatar Jan 06 '17 20:01 quozl

Yes, swapforth has a port:

https://github.com/jamesbowman/swapforth/tree/master/esp8266

It's a bare-metal subroutine-theaded Forth. It currently passes the ANS compliance tests. The difficult part (for me, at least) is providing a Forth interface to the various APIs that are in the SDK. They're gnarly.

jamesbowman avatar Jan 06 '17 21:01 jamesbowman

Thanks for the announcement James.

As it turns out, I was in the process of composing an announcement myself, so I'll just fill in some blanks here.

ESP32 is an extremely cost-effective dual-core 32-bit, 240 MHz, processor module with 512KB RAM, 16 MB FLASH, WiFi and Bluetooth. Modules can be had for US$4 to US$8, and development boards for US$15 to US$20.

The current state of the port to the module is fairly rudimentary, with "ok" on serial console and file access to SPI FLASH. The WiFi and Bluetooth interfaces are not yet present, but will eventually be supported based on similar features in other CForth ports.

CForth is a full-featured, stable ANS Forth system with extensive debugging tools. It has been in active development for 35 years.

I have been building on Windows using the msys2 tools recommended by esp-idf, testing on the Adafruit board cited below.

Mitch

MitchBradley avatar Jan 06 '17 21:01 MitchBradley

Yeah, gnarly is a good description of those APIs.  It was even worse for the ESP8266 because of the event-driven callbacks.  ESP32 should be easier, given the possibility of using the second core for a Forth thread.

MitchBradley avatar Jan 06 '17 21:01 MitchBradley

On the topic of Bluetooth APIs, I'll offer some recent experience. A couple of years ago I was using CForth under Linux on a Raspberry Pi, building a manufacturing test station for a Bluetooth LE gadget. I started out using the BlueZ API, but kept having trouble with conflicts between the framework's event handling and the control flow of the Forth application. I eventually switched to having Forth get raw L2CAP packets directly from a socket, letting Forth do all the packet decoding above that level. That solved all the problems.

The code is in https://github.com/MitchBradley/cforth/blob/master/src/app/bluez/bluetooth.fth

MitchBradley avatar Jan 06 '17 21:01 MitchBradley

@jamesbowman, thanks for the link to swapforth. I've looked through the esp8266 directory but can't find anything to build on esp32. I did find the esp8266 bootrom disassembly interesting.

quozl avatar Jan 06 '17 22:01 quozl

These chips are intriguing… some of those boards are actually cheaper than hooking the cheapest bluetooth uart to a msp430 for a wireless forth experience. Did some new ports happen since 2017?

anse1 avatar Jul 05 '19 16:07 anse1

China got busy: https://www.seeedstudio.com/Sipeed-Maixduino-Kit-for-RISC-V-AI-IoT-p-4047.html

DRuffer avatar Jul 05 '19 16:07 DRuffer

cforth (https://github.com/MitchBradley/cforth) runs pretty well on ESP32. It has interfaces to the SDK socket layer and I2C. It should be easy enough to add bluetooth interfaces via cforth's C-to-Forth gateway mechanism, assuming you understand bluetooth. cforth has some bluetooth app code that runs on top of other cforth ports that could be used as examples. It's not comprehensive; I didn't try to handle every possible bluetooth device, but focused on the task at hand at the time, which was talking to a BLE IoT gadget.

MitchBradley avatar Jul 05 '19 16:07 MitchBradley

Hello, I am starting to get started with ESP32forth produced by CH TING and completed by Brad NELSON. It is a FORTH rather than complete. It even integrates a "TELNET Daemon" and an "HTTP Daemon". In short, you have an HTTP server in the ESP32 card! Access ESP32Forth web UI: https://arduino-forth.com/article/ESP32_installation_accessWEBUI BR

MPETREMANN11 avatar Jun 12 '21 07:06 MPETREMANN11

Where's the source code?

It is odd that, per the serial port output, mDNS is started and yet the instructions say to use IP address instead of mDNS host name, and further on the instructions show how to add the IP address to a router DNS.

In theory all it takes is to include the mDNS header file, then call MDNS.begin with a hostname, call MDNS.addService with a port, then call MDNS.udpate in the main loop. After that, the user should be able to telnet to hostname.local on port 23 or access http://hostname.local/

Perhaps I'm misunderstanding. Hence the question about how to find the source code so I can check it.

quozl avatar Jun 12 '21 09:06 quozl

I think the source is somewhere around here: https://github.com/flagxor/eforth/tree/main/ueforth/

On Sat, 12 Jun 2021 at 7:33 pm, James Cameron @.***> wrote:

Where's the source code?

It is odd that, per the serial port output, mDNS is started and yet the instructions say to use IP address instead of mDNS host name, and further on the instructions show how to add the IP address to a router DNS.

In theory all it takes is to include the mDNS header file, then call MDNS.begin with a hostname, call MDNS.addService with a port, then call MDNS.udpate in the main loop. After that, the user should be able to telnet to hostname.local on port 23 or access http://hostname.local/

Perhaps I'm misunderstanding. Hence the question about how to find the source code so I can check it.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ForthHub/discussion/issues/39#issuecomment-860028253, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADXT4GBPRACGDSON3LNJQQTTSMSYDANCNFSM4C3UNAQA .

-- -- Remy

RGD2 avatar Jun 13 '21 23:06 RGD2

Thanks! According to the source code, and documentation, the system should respond to a URL of http://forth

https://github.com/flagxor/eforth/search?q=mdns

So if original poster couldn't make that work because of missing operating system and browser support, it is reasonable to use IP address and manual DNS registration. Way easier to use mDNS though, if they can.

quozl avatar Jun 13 '21 23:06 quozl