Instal Flash FORTH on Arduino card

published: 20 April 2024 / updated 20 April 2024

Lire cette page en français

 

Instal Flash FORTH on Arduino card

article: 30 mai 2019 / mis à jour 01 juin 2019


Preamble

FORTH is a programming language in its own right. It has the distinction of being extremely compact. The FORTH flash version for ARDUINO occupies about 12 kilobytes in flash memory on any ARDUINO board.

Knowing that the majority of ARDUINO cards have at least 32 KB of flash memory, it leaves a free space of 20 kilobytes for programs in FORTH language.

FORTH has the particularity that at least half of the language is written in FORTH. FORTH has an expandable dictionary by you when you are programming.

When you type a word, in FORTH language, it will be executed immediately.

When you type a word definition, this word will be compiled. This is a one-pass compilation, only doing call to no external library. The compiled code will be part of the FORTH dictionary just like the words pre-defined.

The compiled FORTH code can not work without the FORTH kernel.

So that your code written in FORTH language works on a blank ARDUINO card, it will be necessary beforehand to install a version of the FORTH language.

What is the place of applications in FORTH?

Our first tests of programs, the example of the flashing LED for example, show that the equivalent program compiled in FORTH occupies 2 to 4 times less space in flash memory than its equivalent program written in C language.

FORTH is THE alternative solution to the C language because:

...FORTH has no limit except those of your imagination...

Where to find Flash FORTH

Go here: Github FlashForth development.

Flash Forth on Github

Click on Clone or Download. In the small window that opens, click Download ZIP.

Save the ZIP file. Normally, the ZIP file must arrive in the download folder. Once downloaded, unzip the content into the directory of your choice. Open the folder named flashforth-master:

Le dossier flashforth-master

The files we are interested in installing Flash FORTH on the ARDUINO board are in the subfolder avr / hex:

It seems (to be verified) that the version for ARDUINO Uno also works on ARDUINO Nano.

Instal Flash FORTH

Several websites indicate sometimes complex procedures for installing Flash FORTH - or any other hex file - on an Arduino board only through the serial link connected to the PC. This process implies that the ARDUINO card has an operational bootloader.

However, once Flash FORTH is installed, there is no longer the bootloader of origin. It becomes impossible to reinstall thebootloader or any other program ... including FORTH if there are malfunctions of FORTH.

That's why it's imperative to have a reliable and proven solution to install or reinstall any program on the ARDUINO card (s) that you will have to use.

The AVRISP USB programmer

The AVRISP USB programmer allows you to install any ARDUINO compatible program on a card Arduino:

The AVR ISP programmer

The AVRISP programmer on Amazon: Compatible Atmel AT AVR ISP mk2 MKII ATMEL AVR Programmer USB AVRISP XPII In-System Programmer Supports AVR Studio 4/5/6/7

But before using it, you have to download the program Atmel Studio 7.0

Instal Atmel Studio

The AtmelStudio program is available here.

Go down the page until you see this:

Choice of downloading Atmel Studio

Instal Atmel Studio.

Even if you only program in C language, Atmel Studio is an essential tool in the list useful programs to develop on ARDUINO. AVR Studio or Atmel Studio is the same thing.

FlashForth has been tested on Atmega 2560, 128 and 328.

FlashForth should also work on Atmegas 168 and 644.

FlashForth has been tested on Arduino Duemilanove, Mega 2560 R3 and Uno R3.

Instal Flash FORTH

If your ARDUINO board is connected to a PC serial port, disconnect the board and find a separate power supply.

Run Atmel Studio. And:

Connection order before loading FORTH on ARDUINO board

Until then, if everything went well, the programmer should display two green LEDs.

Now, start Atmel Studio:

Sélec Tools et Device Programming on Atmel Studio

A window opens. We will select various parameters:

setup before upload Fast Forth

The click on Apply. After Apply, on the same line, click on sur Read. If all goes well, the Device Signature and Target Voltage boxes fill up. It's a very good sign!

On the right side, the menu is completed with different choices. Click on Fuses:

following setup

You have three named fields EXTENDED, HIGH et LOW:

This is done, in the side menu, click Memories. In the fiels Flash (xxx KB), specify the location of the HEX format file to be transferred to the ARDUINO, ff_mega.hex for a ARDUINO Mega card, ff_uno.hex for an ARDUINO Uno or compatible card:

location indication HEX format file to transfer

Then click on the button marked Program. The programmer must have a LED that turns red. The transfer takes about 30 seconds.

ATTENTION

From now on, your ARDUINO card no longer has the bootloader. You will not be able more inject programs written in C language, except to restore a bootloader.

The AVRISP programmer will have to be used again:

The AVRISP programmer will be needed to inject FORTH on all cards where you want to run programs written in FORTH.

That's it. You can now stop Atmel Studio and unplug the ARDUINO board from its external power supply and the AVRISP programmer.

We will now see how to communicate with the FORTH language installed on your ARDUINO board: Communiquer avec Flash Forth