Init-Howto

The key: “static” words vs “running” words — two different things

Fact 1 — Words can be stored in flash so they SURVIVE a reboot. That’s what compiletoflash does.

The definition (: bit …) gets written to flash; after reset it’s still there.

Fact 2 — But being stored is NOT the same as being RUN. A word sitting in flash does nothing until something executes it. Flash storage is like having the instruction manual on the shelf; it doesn’t flip the switch by itself.

The kernel’s source is static because IT RUNS AT BOOT. The Mecrisp .s source (terminal.s, the kernel core) is executed by the chip’s boot sequence — it runs automatically after every reset.

However your Forth words, even in flash, are only run if something calls them, either from the Forth terminal or in a Word that’s called from the Forth terminal.

So after a reboot: your word definitions will survive only if flash-compiled but they won’t run unless called by the ‘init’ word.

Init: wrap your “must run after reboot” code in a “init” Word, compile it to flash, and they will run.