Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Nice video how to install Mecrisp on ARM STM32F411 / Bootloaders / Mecrisp Forth

471 views
Skip to first unread message

Peter Forth

unread,
Mar 5, 2020, 11:40:20 AM3/5/20
to
https://www.youtube.com/watch?v=KgjYJw_80DA

The 32F411 with floating point unit on board 100MHz - 512kB Flash
- 128kB RAM + this small LC pcb for breadboards,
powered by Mecrisp of Matthias is a real powerhouse.

We should say, that any commercial forth can
hold a candle to Mecrisp on the arm processors.
Thank you very much Matthias for all your knowledge and fantastique
speed of your Mecrisp forth. Unschlagbar !


B.regards
Peter

PS: thank you a lot to 0033mer and the wonderful U2B channel
and to the outstanding Mecrisp unofficial documentation site of Terry Porter.

https://mecrisp-stellaris-folkdoc.sourceforge.io/

PS2:
And for those who want to know I went back to forth thanks the blue-pill
article on Mecrisp, and the Esp8266 punyforth, both are showing the path
to the lost "forth community" how to do things in 2020.
And why I am saying this, because both Forths are fast, work well,
are OPEN SOURCE, are turnkey products = ARE MODERN
--> You use them and you get results.
This is NOT a regurgitated forth of 1970 or 1980 !
which in modern world have any meaning. So, this forths
are really inspiring each on his own class, of course.
But this must be inspiring to younger forthers how to do things,
they show that forth is a competitor , a cool option to develop fast
and easy programms, and fun, lots of fun to code with them, in my opinion.






Paul Rubin

unread,
Mar 5, 2020, 6:30:50 PM3/5/20
to
Peter Forth <peter4...@gmail.com> writes:
> https://www.youtube.com/watch?v=KgjYJw_80DA
> The 32F411 with floating point unit on board 100MHz - 512kB Flash
> - 128kB RAM + this small LC pcb for breadboards,
> powered by Mecrisp of Matthias is a real powerhouse.

Nice, but where does that board come from? I couldn't find it online.
All the STM32F411 boards I could find were much more expensive than the
screen shot near the start of the video, or than the bluepill. There
is a link in the video comments to a Canadian supplier that lists it for
12.90 CAD and is out of stock, for example.

Added: ah, ok, found an info page
https://www.cnx-software.com/2019/12/24/stm32-black-pill-board-features-stm32f4-cortex-m4-mcu-optional-spi-flash/
that links to an AliExpress page (
https://www.aliexpress.com/item/4000103610226.html ) that has a login
wall, so that's why I couldn't find it.
https://forum.micropython.org/viewtopic.php?t=7154 says the STM32F411
board is $7.

I hit some snags trying to buy from Aliexpress before, so it would be
nice to have some other vendors. The smaller STM32F401 version is on
ebay ( https://www.ebay.com/itm/233498979210 ) at US$6.26 plus shipping
but I don't see the STM32F411 version there.

I wouldn't know what do with Mecrisp on a board that powerful anyway ;).
Bluepill or Longan nano seems like plenty for most things I can think of
doing in Forth. These more powerful boards are of more interest for
MicroPython and the like.

Mecrisp also runs on ARM Linux though when I tried it a while back I hit
some snags. Maybe it's better now. I opened a thread about Forth
workflow a few weeks ago because I was thinking it would be nice to
develop the more algorithmic parts of a Forth program under Linux, and
only use the target interpreter for debugging stuff that had to actually
mess with the target hardware.

> We should say, that any commercial forth can
> hold a candle to Mecrisp on the arm processors.
> Thank you very much Matthias for all your knowledge and fantastique
> speed of your Mecrisp forth. Unschlagbar !

Yes, and also to Mikael and others who have released comparable Forth
systems! FlashForth also seems very nice deserves attention too.

> And for those who want to know I went back to forth thanks the blue-pill
> article on Mecrisp, and the Esp8266 punyforth, both are showing the path
> to the lost "forth community" how to do things in 2020.
> And why I am saying this, because both Forths are fast, work well,
> are OPEN SOURCE, are turnkey products = ARE MODERN
> --> You use them and you get results.
> This is NOT a regurgitated forth of 1970 or 1980 !

Unfortunately that video mostly shows closed source ST tools that run
under closed source Windows. I'd like to go with Linux, maybe using a
raspberry pi (preferably Rpi Zero) as a go-between to run ARM Mecrisp
and communicate with the target board.

> But this must be inspiring to younger forthers how to do things,
> they show that forth is a competitor , a cool option to develop fast
> and easy programms, and fun, lots of fun to code with them, in my opinion.

You should also give MicroPython a try. It can't do all the things
Forth can, and it makes less efficient use of the hardware, but IMHO it
is easier to get started with.

Peter Forth

unread,
Mar 5, 2020, 7:37:38 PM3/5/20
to
On Thursday, March 5, 2020 at 8:30:50 PM UTC-3, Paul Rubin wrote:
This is what Mecrisp Forth does to your Micropython

https://www.gif-vif.com/do-this-to-your-ex/?fbrefresh=23&fbclid=IwAR1YU-HtQFqmf861vu_fWiKQlkx1rdNTA9N2FoBfPkLqTy6qRTTtbobnsYE

Paul Rubin

unread,
Mar 6, 2020, 3:38:31 AM3/6/20
to
Peter Forth <peter4...@gmail.com> writes:
> This is what Mecrisp Forth does to your Micropython
> https://www.gif-vif.com/do-this-to-your-ex/

Heh, nice one. It occurs to me: in the Mecrisp video I think the board
was connected through uart pins, and presumably some kind of usb to
serial adapter.

Is there currently a USB stack available, preferably written in Forth
but anything will do, to allow simply plugging one of those boards into
a laptop with a USB cable and getting an OK prompt?

It would really be nice to have something like that as a "Forth starter
kit". The Longan Nano would be a nice host board for that, since it
comes with a display and enclosure and the combo is very affordable. I
don't have one yet but I think Matthias has Mecrisp running on it. I
just don't know the USB situation.

Matthias Koch

unread,
Mar 6, 2020, 6:28:58 AM3/6/20
to
Hi Peter,

thank you ! I am glad you like it :-) The optimisations were an offspring of my realtime digital signal processing needs while doing my doctoral thesis in biophysics and I had a lot of fun with compiler design.

Matthias

Matthias Koch

unread,
Mar 6, 2020, 6:43:57 AM3/6/20
to

> Is there currently a USB stack available, preferably written in Forth
> but anything will do, to allow simply plugging one of those boards into
> a laptop with a USB cable and getting an OK prompt?

Jean-Claude Wippler once wrote an USB stack for STM32F103, which also runs nicely on STM32F303. The STM32F4 family has a different USB module for which no USB driver exists yet.

> It would really be nice to have something like that as a "Forth starter
> kit". The Longan Nano would be a nice host board for that, since it
> comes with a display and enclosure and the combo is very affordable. I
> don't have one yet but I think Matthias has Mecrisp running on it. I
> just don't know the USB situation.

Longan Nano is a nice board and would make a good Forth starter kit, indeed. The board is supported out of the box by Mecrisp-Quintus using an externally attached USB-serial bridge both for flashing and terminal. Friends of mine are currently writing graphics drivers, but we have no USB driver for it yet. Despite its peripherals being quite similiar to STM32F103, it has a different USB module, and porting the USB driver is a quite unpleasant task involving a lot of datasheet research.

If you want to tackle it, have a look at:

mecrisp-stellaris-2.5.3/stm32f103-ra/usb-f1.txt
mecrisp-stellaris-2.5.3/stm32f303-ra/usb-f3.txt

You can keep the USB descriptors and protocol handling, but you need to change the USB module specific code, which is roughly half of the driver.

Matthias

Stephen Pelc

unread,
Mar 6, 2020, 11:14:31 AM3/6/20
to
On Fri, 06 Mar 2020 00:38:28 -0800, Paul Rubin
<no.e...@nospam.invalid> wrote:

>Is there currently a USB stack available, preferably written in Forth
>but anything will do, to allow simply plugging one of those boards into
>a laptop with a USB cable and getting an OK prompt?

With the MPE Forth cross-compilers for ARM. Supports many NXP devices
and STM32F0 and F1.

Stephen

--
Stephen Pelc, ste...@mpeforth.com
MicroProcessor Engineering Ltd - More Real, Less Time
133 Hill Lane, Southampton SO15 5AF, England
tel: +44 (0)23 8063 1441, +44 (0)78 0390 3612
web: http://www.mpeforth.com - free VFX Forth downloads

Paul Rubin

unread,
Mar 6, 2020, 1:05:55 PM3/6/20
to
Matthias Koch <m.c...@gmx.net> writes:
> Jean-Claude Wippler once wrote an USB stack for STM32F103, which also
> runs nicely on STM32F303. The STM32F4 family has a different USB
> module for which no USB driver exists yet.

Oh that's nice about the STM32F103/303 and unfortunate about the
STM32F4. Do you mean USB works on the bluepill? That would also be a
nice starter kit then.

> [Longan Nano] porting the USB driver is a quite unpleasant task
> involving a lot of datasheet research.

Oh well. Is there a USB driver writen in C to refer to?

> If you want to tackle it, have a look at: ...

I'll take a look at those out of general interest, but am unlikely to be
able to work on it. Too many other backlogged projects already.

Thanks!

Cecil - k5nwa

unread,
Mar 6, 2020, 2:28:38 PM3/6/20
to
Nice board, video, and the excellent Stellaris Forth by Matthias.

I still have several Blue Pills that I bought for under $2, it has way
more CPU power than what I usually need but I decided to stick to the
ARM CPUs even when they have too much CPU capability due to their low
cost. This board looks very nice for more advanced projects with an M4 CPU,

--
Cecil - k5nwa

Paul Rubin

unread,
Mar 6, 2020, 3:08:04 PM3/6/20
to
Cecil - k5nwa <cba...@cbayona.com> writes:
> I still have several Blue Pills that I bought for under $2, it has way
> more CPU power than what I usually need but I decided to stick to the
> ARM CPUs even when they have too much CPU capability due to their low
> cost.

Mine were around $2.5 each, but I also got some STM8 boards (8k flash,
1k ram) for under $1 each, heh. I tried out STM8 eForth under emulation
(the real hardware is still sitting around) and it was usable. I
started writing a chipforth-like cross compiler for the STM8 but got
sidetracked by something that came up at the time. Maybe someday.

> This board looks very nice for more advanced projects with an M4 CPU

Yes, though I wasn't able to find them as cheap as the video screen shot
indicated, so I think I'd go with an alternative board. There are quite
a few interesting ones out there, that are smaller, faster, lower
powered, better supported etc, but that cost more. Again though, it's
hard for me to think of good Forth applications for those boards. To
misquote Bill Gates, a Bluepill with 20k ram should be enough for
anyone.

Cecil - k5nwa

unread,
Mar 6, 2020, 6:53:31 PM3/6/20
to
$1.87 to be precise but you need to add shipping to that and that is why
I bought about 20 to make the shipping be not such a big cost. I've used
several already, the last few I loaded Stellaris Forth on it and it was
very nice board to experiment with. That is what made me settle on ARM
only for future purchases as I would use too many different kinds of
CPUs in the past so there was a huge learning curve. One nice thing
about the ARM CPUs is that with a nice Optimizing Forth there is little
need to use assembler as Forth is more than fast enough on those CPUs.

A possible exception in the future might be Risc-V CPUs the prices are
coming down and the have Stellaris Quintus available for them so it
keeps the learning down.
--
Cecil - k5nwa

ccur...@gmail.com

unread,
Mar 11, 2021, 9:07:24 AM3/11/21
to
I got this 'black pill' STM32F411CE on amazon ... when i load the HEX file, it is successful, but FORTH doesn't start.

I got this from sourceforge: mecrisp-stellaris-2.5.6.tar.gz and extracted the mecrisp-stellaris-stm32f411.hex from it.

Please help

ccur...@gmail.com

unread,
Mar 11, 2021, 9:17:39 AM3/11/21
to

Matthias Koch

unread,
Mar 11, 2021, 9:56:51 AM3/11/21
to

Did you erase the whole flash memory on the board before programming the Mecrisp-Stellaris hex file to it ?

Usually, flash tools only rewrite the blocks to be filled with new content, but scanning for the user dictionary crashes silently if there are random bytes left in flash. Make sure you erase them properly.

Matthias

ccur...@gmail.com

unread,
Mar 11, 2021, 10:08:05 AM3/11/21
to
I will try that at my earliest convenience (at my day job currently). While I have you (sorry), might there be supporting code in mecrisp to make the board look like a HID joystick or gamepad? That is my goal for this project. Thanks!

Matthias Koch

unread,
Mar 11, 2021, 10:11:23 AM3/11/21
to
You could try to port the USB driver of STM32F1/F3 to the F4 family. Sorry, I have not received a contributed USB driver for STM32F4.. yet.

ccur...@gmail.com

unread,
Mar 11, 2021, 10:42:19 AM3/11/21
to
On Thursday, March 11, 2021 at 10:11:23 AM UTC-5, Matthias Koch wrote:
> You could try to port the USB driver of STM32F1/F3 to the F4 family. Sorry, I have not received a contributed USB driver for STM32F4.. yet.
Thanks ... it's a plan at least! :)

ccur...@gmail.com

unread,
Mar 11, 2021, 10:52:51 AM3/11/21
to
On Thursday, March 11, 2021 at 10:11:23 AM UTC-5, Matthias Koch wrote:
> You could try to port the USB driver of STM32F1/F3 to the F4 family. Sorry, I have not received a contributed USB driver for STM32F4.. yet.
So ... wait ... sorry ... is there already support for turning ... say one of these boards ... into a HID gamepad/joystick in mecrisp?

https://smile.amazon.com/HiLetgo-STM32F103C8T6-Minimum-Development-Learning/dp/B07VKSVM21/ref=sr_1_24?dchild=1&keywords=STM32F103%2Bboard&qid=1615477732&sr=8-24&th=1

Matthias Koch

unread,
Mar 11, 2021, 12:08:30 PM3/11/21
to
No.

Sven Mühlberg

unread,
Mar 11, 2021, 4:19:53 PM3/11/21
to
Matthias Koch schrieb am Donnerstag, 11. März 2021 um 16:11:23 UTC+1:
> You could try to port the USB driver of STM32F1/F3 to the F4 family. Sorry, I have not received a contributed USB driver for STM32F4.. yet.
Hi Matthias,

I am just on it to create a usb-driver for mecrisp on stm32f4. But I couldn't even set up the port for USB-OTG.

https://github.com/SvenMb/MecrispForth_boards/tree/main/lib/stm32/f4/usb_dev

in file: usb_init2.fs

The init stops always when I try to switch PA12 to alternate function OTG. Maybe you or someone else can point out my stupid mistake here.

regards
Sven

ccur...@gmail.com

unread,
Mar 11, 2021, 7:45:13 PM3/11/21
to
unfortunately, still no LED comes on, after having it erase the whole memory

Sven Mühlberg

unread,
Mar 12, 2021, 3:41:14 AM3/12/21
to
Hi,

this board can be programmed with dfu via USB, without any programmer or whatever.

I use http://dfu-util.sourceforge.net/ :

1. press boot button and plug USB in while pressing, then release

2. device should advertise itdelf as STM32 Bootloader

3. '''dfu-util -a 0 -d 0483:df11 -s 0x8000000:mass-erase:force -D mecrisp-stellaris-stm32f411.bin''' (use .bin file!)

4. after flashing unplug USB and plug in again, without pressing any button

5. you should get a prompt on usart2 (PA2/PA3) (you need a usb/serial adapter)

regards
Sven

ccur...@gmail.com schrieb am Freitag, 12. März 2021 um 01:45:13 UTC+1:
> On Thursday, March 11, 2021 at 9:56:51 AM UTC-5, Matthias Koch wrote:
> > Did you erase the whole flash memory on the board before programming the Mecrisp-Stellaris hex file to it ?
> >
> > Usually, flash tools only rewrite the blocks to be filled with new content, but scanning for the user dictionary crashes silently if there are random bytes left in flash. Make sure you erase them properly.
> >
> > Matthias
> > > I got this 'black pill' STM32F411CE on amazon ... when i load the HEX file, it is successful, but FORTH doesn't start.
[...]

Matthias Koch

unread,
Mar 18, 2021, 5:41:13 PM3/18/21
to
Hi Sven,

you code does not contain obvious stupid mistakes; it looks fine to me so far. I am sure you already double checked the constants and the values that are actually written out by the iomode! helper definitions; then the freeze occours as soon as the USB OTG wires are connected to the pins. I would try to enable interrupts with eint before doing so, in order to see if the peripheral is doing something strange. Also possible that there are reset conditions somewhere deep in the peripheral which need to be released before it can be connected.

If you have a debugger connected, try sniffing the IO access sequence by a known good firmware. Sometimes, strange undocumented silicon bugs hide deep behind layers of HAL code.

You may get inspiration here: https://spyr.ch/twiki/bin/view/MecrispCube/WebHome

Best wishes and good luck conquering this beasty peripheral,
Matthias

Sven Mühlberg

unread,
Mar 22, 2021, 2:23:28 PM3/22/21
to
Hi Mathias,
I already changed to the other UART and now it doesn't stop at this point anymore (why?!)... but found another post about exact this behaviour on stackexchange with a c-program... so maybe a silicon bug, or that poster and me made the same mistake.

I also followed your advice and made a small working usb-cdc c-program and recorded all the register access... but need some time to try it in forth.

Sven
0 new messages