|
Forum Index : Microcontroller and PC projects : Gami1000 -- a native FORTH OS for ESP32-P4
| Page 1 of 2 |
|||||
| Author | Message | ||||
| amiga Regular Member Joined: 08/05/2025 Location: BelgiumPosts: 50 |
Gami1000 -- a native FORTH kernel for ESP32-P4, born out of MMBasic frustration Hi all, A word on who's writing this first, since it explains a few of the choices below. I'm a retired developer -- thirty years writing ABAP (SAP's ERP language), retired for about four years now. When AI coding tools took off, my first thought was that this was the end of the road for developers like me. I don't think that anymore. This project, built in collaboration with Claude Code, is what changed my mind. It used to be that being a developer meant being the mechanic, hands in the grease, machining every part yourself. Now it's more like being the pilot of an F1 car: the machine builds the parts, but thirty years as a developer -- and a bomb-disposal expert for other people's broken code -- turned out to be exactly what's needed to fine-tune that car and sense when something is about to blow up before it does. I'm no good at OS design, average at best in C, and the last time I'd touched FORTH before this was on a TRS-80 Model I -- even back then I remember being genuinely in awe of what its creator pulled off: the simplicity, the speed, how little RAM it asked for. Looking at today's RAM prices, that last one hasn't aged out at all. This whole project went from nothing to a working prototype in two weeks. A few years ago, reaching the same result would have taken a full team, working full time, several months. None of that means the machine did the thinking for me -- AI is just the cart; the imagination still has to come from whoever's pulling it. Long-time lurker here, MMBasic user on the Pico for a while now. I want to be upfront about two things before you read any further, because I know this crowd will (rightly) call it out if I don't: this is **not** MMBasic, and it does **not** run on a Pico/RP2040. It's a different language (FORTH) on a different chip (Espressif's ESP32-P4). I'm posting it here anyway because MMBasic's community is the one that got me thinking about this in the first place, and I'd genuinely like this crowd's opinion on it, warts and all. **Where this came from** I like MMBasic a lot for what it represents -- it's basically the only BASIC-on-microcontroller scene with a community that's actually alive and moving fast, thanks to all of you. But I kept running into the same wall: it's still quite a rustic environment once you want more than the basics -- no real concept of running several independent things at once, no built-in way to have a screen and a network stack and background logic all talking to each other without stepping on each other's toes. Gami1000 is my attempt to scratch that itch, on hardware that happens to have a touchscreen and more headroom than a Pico (ESP32-P4, dual-core RISC-V, PSRAM, MIPI-DSI display, WiFi). Instead of BASIC, I went with FORTH -- an old, unfashionable choice, but one that turned out to matter a lot in practice on constrained hardware (more on that below, there's a number behind it, not just a preference). **What it actually is** A small board that runs several independent FORTH programs at the same time, each in its own sandboxed "context" (one drives the touchscreen, one runs a built-in web server that doubles as a code editor and dashboard, and you can spin up as many background contexts as you want for sensor polling, MQTT handling, etc.). Contexts never share memory directly -- they either react to events (an MQTT message, a timer) or exchange data through a small locked key/value table. Nothing exotic conceptually, but it turned out to matter a lot once things ran in parallel for real. There's a full web-based IDE built in: code editor with FORTH syntax highlighting, a DOS-style CLI, a step-by-step debugger with breakpoints, and a simulated screen in the browser so you can test drawing code without touching the real hardware at all. **Why FORTH and not BASIC** Not a philosophical choice, a measured one. I actually started this project by hitting the same performance wall you'd expect: a straightforward tree-walking interpreter (which is roughly what most embedded BASICs, and my first attempt, look like under the hood) costs something like 6ms per interpreted iteration on this chip. An empty FORTH loop costs about 57 microseconds. I ported an old animation demo (a bouncing, spinning checkered ball -- some of you will recognize the Amiga heritage) as a real-world test rather than a synthetic benchmark, and measured roughly a 76x speedup on the interpreter side alone moving from a BASIC-style interpreter to FORTH. That's the whole reason this project exists in its current form. To be fair to BASIC: FORTH's stack notation is genuinely unfriendly the first time you see it, and I don't think it's an accident that BASIC won the popularity contest decades ago. I'm not claiming FORTH is better for everyone -- just that it bought me a very real, measured amount of headroom on this specific hardware, for the price of a learning curve. **Demos** The bouncing ball demo mentioned above is included and is honestly the best three-second pitch for the whole project -- it's what convinced me the interpreter swap was worth it. I'm also attaching/will follow up with a couple of smaller demos: a live sensor dashboard (fake sensor data flowing from a background context to the screen through the shared state table, rendered as a gauge widget) and a plain drawing demo showing the same script running unmodified on both the physical screen and the browser's simulated screen side by side. **The complete technical writeup** I've attached a full architecture reference (~50 pages) covering the kernel, the multi-context model, the hardware BIOS layer, the web server, the screen/rendering pipeline, storage, the IDE, and a full "programming in FORTH on this thing" tutorial chapter with worked examples -- written assuming zero prior FORTH knowledge, since I know most of you are coming from BASIC. Fair warning: it's a reference document, not a light read, but every section stands on its own if you just want to jump to one part (GPIO, MQTT, the screen, whatever). I'd love blunt feedback, especially from people who've pushed MMBasic hard on real projects -- what's missing that would actually matter, what looks like a solution in search of a problem, and whether a FORTH-based alternative is remotely interesting to this community or just a curiosity to look at once and move on. Either answer is useful to me. Thanks for reading this far. From Belgium , with (4-1) and good beer @+ Amiga ![]() ![]() ![]() GAMI1000_Technical_Architecture_EN (1).pdf https://youtube.com/shorts/DXN23D7lQZc?feature=share https://youtube.com/shorts/ATUVxycz6_E?feature=share https://youtube.com/shorts/HaVzCFHa4uI?feature=share https://youtube.com/shorts/zhswdhXTETg?feature=share Edited 2026-07-09 05:03 by amiga |
||||
| PeteCotton Guru Joined: 13/08/2020 Location: CanadaPosts: 645 |
Wow! There's a lot to go over here. But first a very minor point. If you want your URL's to link on your posts, then you need click on the "Add HyperLink" button at the top of your edit window and paste the link there. I've updated them below: https://youtube.com/shorts/DXN23D7lQZc?feature=share https://youtube.com/shorts/ATUVxycz6_E?feature=share https://youtube.com/shorts/HaVzCFHa4uI?feature=share https://youtube.com/shorts/zhswdhXTETg?feature=share But to get back to your project - I say again - Wow!. Excellent job - and thank you for sharing. I particularly like the Boing Ball demo - nice touch. But everything about this project looks great, and great documentation. I tried to get into Forth programming back in the day when one of my mates had a Jupiter Ace, but it was far beyond my little brain, however I did recognise that pushing variables, numbers onto a stack in the order the calculation needed them was a far more efficient method. I also agree with you about AI. Long term developer here as well, and as a co-programmer it is excellent. Well done on the football as well. My team (Scotland) got knocked out in the first round - but we were okay with that. We were just happy to make it to the cup No Scotland, No party! |
||||
| Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 5975 |
I had only one encounter with FORTH, and that was F84 on the PIC16F84. It was either using forth or assembler, and forth was easier because it allowed me to add my OWN Words to the language. I would be interested to look at it again, but am very hesitant to invest in hardware special for this curiosity I think you have a Nice IDE, well done. I have no idea where the speed comparisson comes from, but execution speed on MMBasic is 500.000 instruction per secon on CMM2, and over 100,000 per second on PICO. I have programs that run interrupt routines on 1ms basis, all in basic. No C, no assembly. Volhout Edited 2026-07-09 15:08 by Volhout PicomiteVGA PETSCII ROBOTS |
||||
| phil99 Guru Joined: 11/02/2018 Location: AustraliaPosts: 3316 |
It is a very interesting project and might give it a go if learning new stuff wasn't so hard now. Even the new features of MMBasic have left me behind. As Volhout said the PicoMite is reasonably fast. Pico RP2040 @ 378MHz reading a pin. > clear : dim integer n, x(9999) : setpin 1, din > t=timer:for n=0 to 9999:x(n)=pin(1):next:? (timer-t)/10;"uS/loop" 13.2169uS/loop > Pico 2 VGA @ 378MHz > clear : dim integer n, x(9999) : setpin 1, din :t=timer:for n=0 to 9999:x(n)=pin(1):next:? (timer-t)/10;"uS/loop" 8.6994uS/loop > Edited 2026-07-09 16:20 by phil99 |
||||
| amiga Regular Member Joined: 08/05/2025 Location: BelgiumPosts: 50 |
Hi , my first idea was to adapt MMBASIC to ESP32 family (use for a lot application : WIFI embedded in the silicum is a great enhancement ) But too complexe to adapt to ESP32. I found another interpreter 'MY-BASIC' . And the new chip from espressif 'ESP32-P4' is really a beast With 2D engine,mipi,16MB spram,32MB flash but no wifi (i use a coprocessor ESP32-C6 (wifi,bluetooth and zigbee !). On aliexpress i found a board with LCD mipi(800*400) +P4+C+ for 28€ . It would be really interesting if someone or a group—looked into porting 'MMBASIC' to this processor. I’m talking about source-level compatibility, though obviously adapted to the hardware, since the processor handles all graphics, sound, and floating-point calculations—not to mention the 16MB of SRAM and 32MB of flash integrated into the ESP32-P4. Plus, the cost of the boards is negligible compared to their capabilities. I created a stack with mangoose,lvgl and 'my-basic' . But very slow for my use . It's why i remember 'FORTH' from my 'TRS-80 MKI' . Start a core 'FORTH' from scratch , test are so positive . The stack used for 'MY-BASIC' could be a candidate to implemente a system like an 'AMIGA 1000' not emulate but the spirit. Amiga was ahead : light ,efficient,graphique(hi-res,color) and sound ! it's why this project is very different from others . For the moment i have a multitask system . Graphique system is done with webserver ,and MIPI(HDMI with a simple hardware converter (aliexpress 8€)) . Integration LVGL with LCD/HDMI is in progress , USB stack also . Final goal a standalone system like 'MMBASIC' but more feel like 'AMIGA 1000'. and a very light 'Workbench' as 'AMIGA 1000' Benchmark with demo 'Bouncing ball' done with 'My-BASIC' vs 'FORTH' using the same stack . FORTH was x76 times faster ! Not a counting loop . Real application . IT's why i used FORTH , and the ability to use micro-vm (micro-service) as box for an application it's de main new feature in this project. @+ Amiga |
||||
| Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 8935 |
Oh, memories... lol I briefly attempted Forth before I discovered that macro assembler on the Z80 was more fun. :) I think RPN was one of the things I couldn't get my head around at the time. All credit though, that looks like a lovely IDE! I'm afraid I'm still not tempted to re-visit Forth though. I find MMBasic confusing enough now. :) Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
| PhenixRising Guru Joined: 07/11/2023 Location: United KingdomPosts: 1986 |
There is always a BASIC solution Coridium ArmBasic (compiler) on the RP2350 @150MHz ![]() If I need TRUE multitasking that is jitter/latency-free (no interrupts), I use the eight-processor Propeller from Parallax and the FlexBasic compiler. ![]() Edited 2026-07-09 17:44 by PhenixRising |
||||
| amiga Regular Member Joined: 08/05/2025 Location: BelgiumPosts: 50 |
Hi, thanks for your comment , I'm about to turn 70... and the only way to avoid dying too soon is to step out of one's intellectual and physical comfort zone (easier said than done, I admit). I tried MMBASIC on an RP2040—it's fast, good for small applications. But small applications don't cut it for me anymore. I'm moving on to a ground-based drone project that requires rapid algorithm adjustments during the learning phase. FORTH allows you to modify logic "on the fly" without resetting the entire system. The stack-based system is actually very simple... It just takes a few days of focused effort, and then everything seems much more logical. The big advantage is that I can run programs in parallel,stopping one while the others keep going. A Raspberry Pi 4 running Linux handles that very well! But at €28 and with a 0.5W power draw... The Pi 4 is out of the running. The hardest part of a project is choosing the right architecture, hardware, and framework. But it is also the most exciting part of the project. @+ Amga |
||||
| IanT Senior Member Joined: 29/11/2016 Location: United KingdomPosts: 131 |
Nascom days I suspect Mick :-) I had Forth running on my N2 back then - mainly if I recall correctly to write routines for the (TI) graphics board that wasn't easily supported in other ways. Worked my way through 'Starting Forth' (a really good Forth primer). I still browse 'Thinking Forth' which is more about the Forth 'mindset' than the language. However, like one or two others here, I'm struggling a bit to keep up with Peter's (and his little friend Claude) PicoMite advances but I certainly found your post interesting Amiga and would be happy to hear more. Your comments about AI are also very topical, given companies like Ford are re-hiring 'Greybeards' to complement their AI based systems... Regards, IanT |
||||
| Martin H. Guru Joined: 04/06/2022 Location: GermanyPosts: 1471 |
Hihi, Those were my first steps in 6809 assembly back in 1986 ![]() Edited 2026-07-09 19:51 by Martin H. 'no comment |
||||
| amiga Regular Member Joined: 08/05/2025 Location: BelgiumPosts: 50 |
Hi Martin, It wasn't easy to finalize—there were plenty of issues managing LVGL buffers ,but the flexibility of Forth helped get the bugs fixed fairly quickly. In the pipeline, there's a 'Workbench' like the one on the Amiga 1000... and I'm thinking of implementing the floppy drive 'click-click' sound. It’s not an emulator or a recompilation of Amiga code; it’s simply capturing the spirit as a tribute to its brilliant creators and to Jay Miner’s little cocker spaniel, 'Mitchy' . Personally, I have a little mouse of my own wandering around the house. @+ Amiga |
||||
| Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 8935 |
Yep... Nascom 1, with a 2MHz Z80 all of my own! lol Load Tiny Forth from cassette every time you want to play. I did have Tiny BASIC in EPROM though, but it was *very* limited. Mind you, you can't do a lot on 960 bytes of RAM. (bytes, not Kbytes) I had to save *a lot* of pennies for a buffer board, short motherboard and a 4K RAM A card before I really got to play in ZEAP. (Roumor had it that someone at the computer club would "burn" Zeap onto EPROM for you if you asked nicely. It could then be plugged into a socket or two on the RAM A board. Unsubstantiated though.) And I had to assemble it all myself and find my own power supply (it was an optional extra, and expensive). Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
| amiga Regular Member Joined: 08/05/2025 Location: BelgiumPosts: 50 |
Load Tiny Forth from cassette every time you want to play. I did have Tiny BASIC in EPROM though, but it was *very* limited. Mind you, you can't do a lot on 960 bytes of RAM. (bytes, not Kbytes) I had to save *a lot* of pennies for a buffer board, short motherboard and a 4K RAM A card before I really got to play in ZEAP. (Roumor had it that someone at the computer club would "burn" Zeap onto EPROM for you if you asked nicely. It could then be plugged into a socket or two on the RAM A board. Unsubstantiated though.) And I had to assemble it all myself and find my own power supply (it was an optional extra, and expensive). |
||||
| amiga Regular Member Joined: 08/05/2025 Location: BelgiumPosts: 50 |
Load Tiny Forth from cassette every time you want to play. I did have Tiny BASIC in EPROM though, but it was *very* limited. Mind you, you can't do a lot on 960 bytes of RAM. (bytes, not Kbytes) I had to save *a lot* of pennies for a buffer board, short motherboard and a 4K RAM A card before I really got to play in ZEAP. (Roumor had it that someone at the computer club would "burn" Zeap onto EPROM for you if you asked nicely. It could then be plugged into a socket or two on the RAM A board. Unsubstantiated though.) And I had to assemble it all myself and find my own power supply (it was an optional extra, and expensive). my current board :: https://nl.aliexpress.com/item/1005010425057615.html?pdp_npi=6%40dis%21EUR%2191.97%2141.28%21%21%21696.73%21312.69%21%4021013cc617832963501392317e0f27%2112000052369431819%21affd%21%21%21%211%210%21&cv=92ac0351-dbf4-41c5-b208-99280d8f6669&gclid=Cj0KCQjwjb3SBhDgARIsAMKiWzjWXxlCTS2D9I1MedfbAAJJOtdS6scU4RznDocx9ZhNvdg8yEG2zxgaAgSMEALw_wcB&aff_fcid=1cdf961cecaf40869ef3ee346b342ba4-1783594781884-03517-_c3u0Ii6b&aff_fsk=_c3u0Ii6b&aff_platform=api-new-product-query&sk=_c3u0Ii6b&aff_trace_key=1cdf961cecaf40869ef3ee346b342ba4-1783594781884-03517-_c3u0Ii6b&terminal_id=11816f4e051b43dbb70b146e86af67db&afSmartRedirect=y without screen .. https://nl.aliexpress.com/item/1005009557354669.html?productId=1005009557354669&selectedSkuId=12000049458412174&channel=detailPageDealCombineFloor&combineBizType=platformFreeShipping&intent_extra_sku_from=from_add_to_shopcart&type=mergeorder&pdp_npi=4%40dis%21EUR%2172.53%2134.09%21%21%21550.30%21258.65%21%400b88ac1917835947848946886e1097%2112000049458412174%21fus%21BE%212260364661%21X&trackParams=%7B%22businessScenario%22%3A%22choiceV2%22%2C%22activityType%22%3A%22CHOICE_FREE_SHIPPING%22%7D&spm=a2g0o.detail.fusionpage.0&gatewayAdapt=glo2nld |
||||
| Solar Mike Guru Joined: 08/02/2015 Location: New ZealandPosts: 1228 |
I recall playing with Forth 40 odd years ago, what I liked was you could create your own language functions. Forth is available for the RP2040 and 2350, I was considering it as a possibility for multi tasking in PV charge controllers. zeptoforth Mike |
||||
| Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 8935 |
Very nice little boards. That one with the display is especially cool. :) I've (relatively) recently been playing with a CYD running Annex RDS. A useful little combo, I think, but as usual the ESP32 tells lies when the GPIO is described. In actual fact there are only 3 GPIO pins that are usable. I've learned to always check when considering using a ESP for anything that may need directly connected IO pins. Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
| amiga Regular Member Joined: 08/05/2025 Location: BelgiumPosts: 50 |
I've (relatively) recently been playing with a CYD running Annex RDS. A useful little combo, I think, but as usual the ESP32 tells lies when the GPIO is described. In actual fact there are only 3 GPIO pins that are usable. I've learned to always check when considering using a ESP for anything that may need directly connected IO pins. Annexe RDS , doesn't support the wifi part(the board use esp32-C6 as wifi co-processor) But it support esp32-p4 and hope the screen also @+ Amiga |
||||
| amiga Regular Member Joined: 08/05/2025 Location: BelgiumPosts: 50 |
Forth is available for the RP2040 and 2350, I was considering it as a possibility for multi tasking in PV charge controllers. zeptoforth Mike Hi Mike, Esp32-p4 is a risc-v incompatible with zeptoforth according my last info. @+ Amiga |
||||
| cicciocb Regular Member Joined: 29/04/2014 Location: FrancePosts: 73 |
Annexe RDS , doesn't support the wifi part(the board use esp32-C6 as wifi co-processor) But it support esp32-p4 and hope the screen also @+ Amiga Annex RDS fully supports the esp32-p4 including the WiFi / BLE via the ESP32-C6. The DSI screens are also supported including touch and LVGL. little LVGL demo Edited 2026-07-10 05:25 by cicciocb |
||||
| GerryL Regular Member Joined: 24/01/2019 Location: AustraliaPosts: 45 |
Amiga, very impressive IDE, I can see there is a whole mountain of work hiding behind your GUI. I used Forth on and off for over 20 years in the data acquisition area and have always had a soft spot for it. I had a work colleague who was a bit of an expert at it and he referred to it as his “Gentlemen’s Assembler” as he could do anything assembly could do without getting his hands dirty in registers or re-inventing wheels. I was looking to build my 3rd generation weather station when I stumbled across pFORTH (portable FORTH) and put it on a STM32H7 and added graphics and HW interface but realised I needed an IDE and a similar pFORTH app with graphics and comms port in Windows to write and test the code as its easy to make stack errors if you’re a novice like me. So that distracted me from the STM32H7 project but after starting the IDE I realised it would be great for developing CSub’s so another distraction. Then I realised my IDE needed to support MMBasic with built in help so another fork. In the meantime I’m trying to resurrect a 1939 Westinghouse radio so what I have is a whole bunch of unfinished projects, no closer to building my 3rd generation weather station, and being 75 years old fast running out of time! Clearly your more disciplined than me. Gerry |
||||
| Page 1 of 2 |
|||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2026 |