Problem installing amforth on Leonardo board

I downloaded amforth-6.8.tar.gz and unpacked it. Then I tried to install it using the command:

[i]avrdude -P /dev/ttyACM0 -DV -p atmega32u4 -c avr109 -b 57600 -U flash:w:./amforth-6.8/appl/arduino/leonardo.hex -U eeprom:w:./amforth-6.8/appl/arduino/leonardo.eep.hex -U efuse:w:0x07:m -U hfuse:w:0xda:m -U lfuse:w:0xff:m -v[/i]

BTW, I tried other assignments to: efuse, lfuse, and hfuse. I also tried deleting the writes from the command line. Not sure this has any affect.

Then I try to attach to /dev/ttyACM0 using Putty and Minicom using 9600 8N1. Every keystroke shows up as '?'.

Within a short period of time, maybe 10 seconds, /dev/ttyACM0 is lost ... no more ttyACM0 device file.

Advice?

PS> Yes, I bang on the "RESET" button when I loose /dev/ttyACM0 and it reappears for another fews seconds.

Using 'dmesg', I see:

cdc_acm: usb 1-1.1.2: Product: Arduino Leonardo
[22703.481710] usb 1-1.1.2: Manufacturer: Arduino LLC
[22703.482841] cdc_acm 1-1.1.2:1.0: ttyACM0: USB ACM device
[22710.982560] usb 1-1.1.2: USB disconnect, device number 14

You need to use a ISP programmer. The bootloader will not write to the fuses or the eeprom and it will not overwrite itself. See the example sketch ArduinoISP for how to use another Arduino as an ISP programmer.

Do I need to write to efuse, lfuse, and/or hfuse to load amforth? Is the bootloader on the Leonardo board overwritten by amforth?

When I execute:

$ avrdude -P /dev/ttyACM0 -DV -p atmega32u4 -c avr109 -b 57600 -U flash:w:./amforth-6.8/appl/arduino/leonardo.hex -U eeprom:w:./amforth-6.8/appl/arduino/leonardo.eep.hex

This is some of the output.

avrdude: reading input file "./amforth-6.8/appl/arduino/leonardo.hex"
avrdude: input file ./amforth-6.8/appl/arduino/leonardo.hex auto detected as Intel Hex
avrdude: writing flash (32638 bytes):

Writing | ################################################## | 100% 0.56s

avrdude: 32638 bytes of flash written

avrdude: reading input file "./amforth-6.8/appl/arduino/leonardo.eep.hex"
avrdude: input file ./amforth-6.8/appl/arduino/leonardo.eep.hex auto detected as Intel Hex
avrdude: writing eeprom (178 bytes):

Writing | ################################################## | 100% 0.00s

avrdude: 178 bytes of eeprom written

It appears that both flash and eeprom memory are written to?

jski3:
It appears that both flash and eeprom memory are written to?

The Arduino bootloader will often just report "SUCCESS!" for any command that it does not understand. Include the "verify" option (-v ?) in your command line to see if you can read back the data you wrote.
For a long time I was getting a verify error when using the Arduino ISP sketch to load fresh firmware into a ATmega328p. The problem was that when avrdude connected to the Arduino running Arduino ISP it reset that Arduino and suddenly I was talking to that Arduino's bootloader instead of the Arduino ISP sketch. They speak the same STK500V1 protocol. The bootloader was happy to report "SUCCESS!" for commands it didn't understand and when avrdude asked it to read back the fuses it read back the current fuses which did NOT match the value that the bootloader had just reported successfully setting!

jski3:
Do I need to write to efuse, lfuse, and/or hfuse to load amforth?

What do the amforth instructions say about that?

jski3:
Is the bootloader on the Leonardo board overwritten by amforth?

Not with the avrdude command you're currently using.

jski3:
It appears that both flash and eeprom memory are written to?

I believe so. The bootloader on the Leonardo does support writing to EEPROM.

johnwasser:
Include the "verify" option (-v ?) in your command line to see if you can read back the data you wrote.

-v is verbose output (add more -v for more verbosity). Verification is on by default, but jski3 has disabled it in their avrdude command by passing the -V option (combined with the -D option as -DV). @jski3 if you want to enable verification, you should use this command:

$ avrdude -P /dev/ttyACM0 -D -p atmega32u4 -c avr109 -b 57600 -U flash:w:./amforth-6.8/appl/arduino/leonardo.hex -U eeprom:w:./amforth-6.8/appl/arduino/leonardo.eep.hex

Just giving in and using C++ has to be starting to look a lot more appealing at this point. I'm sure you will be able to get Forth going with enough perseverance though!

The Amforth binary uses the bootloader space. You need to use an ISP programmer to upload this. The bootloader cannot overwrite itself. You need to set the fuses as Amforth advises.