FlashForth: Compile a New Version

2 minute read

Where I describe in detail how to compile a new version of FlashForth.


Its helpful to be able to compile a new version of FlashForth. A simple reason is to increase the baudrate from 38400 to 250000, increasing your productivity. It isn’t difficult, however the tool chain can be a bit complex.


You will need to install both the MPLAB IDE and the XC8 compiler for this exercise. You will also need a hardware programmer such as the Atmel ICE or Microchip SNAP.

Once you have done both the application and programmer, follow these instructions. They are specific to macOS, however, Linux and Windows will be quite similar.

MPLAB X Compilation

1. In terminal:

cd Documents/flashforth
cp -r avr/FF-ATMEGA.X/ ~/Desktop/FF-ATMEGA.X/
cp -r avr/src/ ~/Desktop/FF-ATMEGA.X/src

I do this to keep the flashforth folder clean, so that I can easily update the folder when the overall FlashForth source is updated.

2. Connect both Uno and Atmel ICE to Mac

In my case, I’m using the Atmel ICE to program the Uno. The SNAP will work as well. You might also be able to use another UNO, using the second UNO as an in-circuit-programmer.

3. Open MPLAB X

Follow the following steps in MPLAB IDE:

  1. File -> New Project -> Standalone Project
    1. Device: 328P and Tool: Atmel ICE…
    2. Choose XC8 as your compiler
    3. Browse to Desktop and make the Project Folder FF-ATMEGA.X
    4. Set Project Name: FF and Set as main project (Creates FF.X folder which becomes the main folder)
    5. Finish
  2. In the Projects column on the left, right-click on Source Files and add Existing Item ../src/ff-xc8.asm (you will need to click the file drop down and go up one folder, to select src folder then the file ff-xc8.asm)
  3. Put the following text in Production -> Set Project Configuration -> Customize -> XC8 Global Options -> Additional Options then click Apply and OK

4. In your editor


Convert all <.inc> references to “.inc” (include quotes on change)

# in Sublime Text, Shift-Cmd-F and
# Made 3 replacements


Change the following line 41

# original line
#define BAUDRATE0 38400
# new line
#define BAUDRATE0 250000

Optional Change the following line 5792 (search for FlashForth)

# original line
        .ascii    "FlashForth 5 "
# new line
        .ascii    "FF 5 250k bd "

Confirm the new text matches the same spacing as the previous text!

5. In terminal

cd ~/Desktop/FF-ATMEGA.X/FF.X
cp dist/default/production/FF.X.production.hex ~/Desktop/FF.hex
cd ~/Desktop
# if your using Atmel ICE and ATmega328P (Uno)
avrdude -p m328p -P usb  -c atmelice_isp -e -u -U flash:w:FF.hex :i -U efuse:w:0xff:m -U hfuse:w:0xda:m -U lfuse:w:0xff:m
# if your using Microchip ATmega328PB Xplained Mini
avrdude -p m328pb -P usb  -c xplainedmini -e -u -U flash:w:FF.hex :i -U efuse:w:0xff:m -U hfuse:w:0xda:m -U lfuse:w:0xff:m

The last step will use avrdude to copy the new .hex file from your system to the Uno. Open you serial application and see if it works!

Comments powered by Talkyard.