Upload via programmer (usbtinyisp) runs program but stops working after reset

So im working on a project where I have my promini soldered into the project... Serial is populated so Ive resorted to using an ISP programmer to upload the program.

My current issue is, when I upload via programmer through the IDE, it uploads successfully, and the program starts running right away. So the software works at least. However, after I cut power and start it up again (or reset) it doesnt start the program.

This is all done through the IDE, I have tried to do it with AVRdude directly but I've not been so successful there. Says my hex file is invalid when i do it in cmd prompt.

Before anyone asks I have also tried removing the programmer, after upload and the program still wont start, so its not the programmer blocking anything.

I have confirmed that the upload via programmer option is using the no boot version of the hex. Which is kinda what I want too as I want instant startup for the program.

What else needs to be done?

I should point out that its on a atmega328p

Anyway if anyone can help this is really holding back my project...

I was under the impression when you upload a program without the bootloader the program is placed at 0x00000 and should run automatically. But you loose the ability to upload via normal serial(because of no boot loader)

Have i got this assumption wrong?
Are there more steps to take?

Are the fuses right ?

I don't have any experience with this situation but according to this fuse calculator -

There is at least one that might be important to the boot process.

I must admit i dont know... Ive never done anything to the fuses. So is there a fuse flag that tell it to start program at 0?

Boot Reset vector Enabled (default address=$0000); [BOOTRST=0]
I guess it must be ON in order to run from 0000 on boot.

But if I were you I would wait for a 2nd opinion... :slight_smile:

I played with Nanos without a bootloader and I didn't need to do a thing, they just run ok.

Is your sketch taking up the whole chip? (within 512 bytes, assuming you're bootloading as uno) In this case, you must change bootrst to 1 (disabled), otherwise, it will try to start from where the bootloader would be - but there's bits of your code there, which are unlikely to result in proper behavior (if you don't fill that last bit, 0xFFFF is a no-op, so it will just go through those until the PC wraps around to 0 and runs the program.

Are you making use of the watchdog timer to reset the board? If so, are you turning it off correctly at the start of your program? If board resets from WDT, it will restart with the WDT running with the minimum interval, so you need to immediately deal with that. The bootloaders do this (well, optiboot does. IIRC the nano and pro mini bootloaders don't, and the boards hang if you do a WDT reset)

DrAzzy:
Is your sketch taking up the whole chip? (within 512 bytes, assuming you're bootloading as uno) In this case, you must change bootrst to 1 (disabled), otherwise, it will try to start from where the bootloader would be - but there's bits of your code there, which are unlikely to result in proper behavior (if you don't fill that last bit, 0xFFFF is a no-op, so it will just go through those until the PC wraps around to 0 and runs the program.

Are you making use of the watchdog timer to reset the board? If so, are you turning it off correctly at the start of your program? If board resets from WDT, it will restart with the WDT running with the minimum interval, so you need to immediately deal with that. The bootloaders do this (well, optiboot does. IIRC the nano and pro mini bootloaders don't, and the boards hang if you do a WDT reset)

Well the programs no too big. As it is uploading... It previously happily uploaded via serial before.

Ive been practicing messing with the fuses. I tried setting bootrst, but doesnt appear to make any difference to my program.

However I have noticed that after setting the fuse by editing my board config in the board.txt, and i burn the boot loader the blink sketch put on, appears to start instantly.

Im using the Pro Mini board as a base. (made a copy to edit)

The fuse settings im currently using is l=0xFF h=0xD8 e=0xFD

Heres my program. Its still deep in a work of progress... But in a normal situation with a boot loader the thing works.

in fact If i upload with avrdude via and selecting the version with the boot loader added. My program starts. Trouble is it starts a couple of seconds after start. I need it to start right away.

Right sort of got it working...

Fuses D7 DE FF

While the program now starts its not instant... Its still a about a second boot up.

My guess would be:

AVRDUDE
-U lfuse:w:0x42:m
-U hfuse:w:0xF8:m
-U efuse:w:0xFF:m
-U lock:w:0xFF:m

http://eleccelerator.com/fusecalc/fusecalc.php?chip=atmega328p&LOW=42&HIGH=F8&EXTENDED=FF&LOCKBIT=FF

Or maybe

AVRDUDE
-U lfuse:w:0x42:m
-U hfuse:w:0xFE:m
-U efuse:w:0xFF:m
-U lock:w:0xFF:m

http://eleccelerator.com/fusecalc/fusecalc.php?chip=atmega328p&LOW=42&HIGH=FE&EXTENDED=FF&LOCKBIT=FF

But if i use the internal oscillator wont it no longer run at 16mhz?

Also it looks like i may have accidentally set the low fuse to use external clock :confused: and soft bricked this second chip

I need a Arduino as ISP sketch that includes a clock signal. Some one did post one in another thread but it doesnt appear to have the clock.