I am using a 328p programmed with a usbtinyisp. So there is no bootloader. avr/wdt.h was working fine when I had both the bootloader and the program. However, it does not work in the same program without the bootloader. I assume it is just restarting at the wrong address.
Can the start address for the avr/wdt be set to 0 somehow?
The restart address is always 0. If a bootloader is present, it takes over this address, then at some point, jumps to the start of the Arduino program. Note: this depends on the setting of the BOOTRST fuse. See the data sheet, and check whether that fuse is set.
There is something wrong with your approach if the WDT does not successfully reset and restart a program uploaded using the ISP "no bootloader" method.
If you wish forum members to help, post the code and relevant details.
Good news. Building on the following thread, in setup, I changed the first line from wdt disable (with a later wdt enable before the loop) to a single wdt enable with 2s. This fixed it. Still odd that the original code did work when a bootloader was also installed.
I thought I was kind of familiar with WDT behavior, but not anymore.
Do you have WDTON fuse bit programmed?
That would be the only explanation I have. Because in that case the state of WDTCSR (which was reset to 0 according to @westfw's post) doesn't matter (?) and WDT is always in System reset mode. When you changed the first line in setup to set 2s timeout, you prevented/"postponed" the already running 16ms timeout (?).
I know it's doable by loading the sketch hex file directly to the chip through the ICSP pins. The bootloader is a hex file loaded the same way that loads your sketch hex file on top of itself through serial.
30 minutes of sifting through old docs to find what's easy, too many pages for my eyes after a while. It is one choice and IIRC knowing where the IDE put the hex file difficulty.
I have searched and searched. How do I actually send this command?
If you turn on the "verbose" preferences for upload, and try to upload a sketch, you will see the command that the IDE is issuing on your behalf (actually, it's likely to scroll by pretty quickly, so you might have to hunt for it a bit.)
It looks right. It might need the -C option to specify the location of its config file, because the arduino version seems to have been built a bit weird:
~/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/bin/avrdude -carduino -P /dev/tty.usbserial-A20e1Kh4 -b115200 -t -patmega328p
avrdude: can't open config file "/Users/jenkins/jenkins/workspace/avrdude-staging/label/mac-mini/objdir/etc/avrdude.conf": No such file or directory
avrdude: error reading system wide configuration file "/Users/jenkins/jenkins/workspace/avrdude-staging/label/mac-mini/objdir/etc/avrdude.conf"