Go Down

Topic: Upload via programmer (usbtinyisp) runs program but stops working after reset (Read 247 times) previous topic - next topic

Mangy_Dog

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?

Mangy_Dog

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 -

http://eleccelerator.com/fusecalc/fusecalc.php?chip=atmega328p

There is at least one that might be important to the boot process.
--
You never learn anything by doing it right.

Mangy_Dog

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... :-)

I played with Nanos without a bootloader and I didn't need to do a thing, they just run ok.
--
You never learn anything by doing it right.

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)
ATtiny core for 841+1634+828 and x313/x4/x5/x61/x7/x8 series Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts (some assembled), mosfets and awesome prototyping board in my store http://tindie.com/stores/DrAzzy

Mangy_Dog

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.





Mangy_Dog

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.

--
You never learn anything by doing it right.

Mangy_Dog

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

Mangy_Dog

Also it looks like i may have accidentally set the low fuse to use external clock :/ 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.

Go Up