LowPowerLab Forum

Hardware support => Moteino => Topic started by: lilpint97 on January 27, 2014, 01:04:27 PM

Title: Burning Optiboot / DualOptiboot bootloader [solved]
Post by: lilpint97 on January 27, 2014, 01:04:27 PM
This may be a dumb question, but if one needed to reload the optiboot loader, can this be done through the moteino pins? If so which pins would one connect to the AVR programmer? I am looking at the following one: http://www.amazon.com/SparkFun-Pocket-AVR-Programmer/dp/B004G54E9I/ref=pd_sim_sbs_indust_2

I am new to this level of programming so hope not sounding to silly.

Thanks.
Title: Re: optiboot loader
Post by: Felix on January 27, 2014, 02:17:23 PM
If you need to reflash a Moteino you:

- need an AVR programmer - just get the AVR ISP MKii (digikey, don't mess with other cheapie non OEM ones. Saving $10 here is REALLY not worth it - see http://www.digikey.com/product-search/en?keywords=ATAVRISP2-ND
- need to power the Moteino independently of the AVR programmer
- need to pullup pin D10 if the RFM69 radio is already soldered
- the pins are the standard ISP protocol pins (VCC, GND, RST, SPI_CK, SPI_MISO, SPI_MOSI)
- use AVR Studio with target Atmega328p
Title: Re: optiboot loader
Post by: lilpint97 on January 27, 2014, 02:41:08 PM
Thanks that is helpful, and one last dense question, when you say "need to pullup pin D10 if the RFM69 radio is already soldered" add a pull up resistor or de-solder pin 10?

Thanks.
Title: Re: optiboot loader
Post by: Felix on January 27, 2014, 03:26:56 PM
Pull up D10 to VCC with a high K resistor, ie 10K is good enough.
Title: Re: optiboot loader
Post by: ltj on January 28, 2014, 08:59:20 AM
Everything Felix said :) However it works absolutely fine using the "Arduino as ISP" trick. That could save you the AVR ISP mkII if you really only need to do this on rare occasions. Check out http://jeelabs.org/2011/05/29/summary-of-isp-options/ for some rather creative takes on ISP.
Title: Re: optiboot loader
Post by: vectorspace on February 01, 2015, 03:12:32 PM
Quote from: Felix on January 27, 2014, 02:17:23 PM
If you need to reflash a Moteino you:

- need an AVR programmer - just get the AVR ISP MKii (digikey, don't mess with other cheapie non OEM ones. Saving $10 here is REALLY not worth it - see http://www.digikey.com/product-search/en?keywords=ATAVRISP2-ND
- need to power the Moteino independently of the AVR programmer
- need to pullup pin D10 if the RFM69 radio is already soldered
- the pins are the standard ISP protocol pins (VCC, GND, RST, SPI_CK, SPI_MISO, SPI_MOSI)
- use AVR Studio with target Atmega328p

I've built a DIY Moteino and 2 DIY MoteinoMegas and can't get past burning the bootloader. I'm trying to use an AVRasp programmer and also tried a USBTinyISP on the 328P. From the instructions above, should I assume that using "Burn Bootloader" in the Arduino IDE won't work? Doing that with the 328P results in:
***failed; 
avrdude: verification error, first mismatch at byte 0x0000
         0xfd != 0x05
avrdude: verification error; content mismatch


I started with the Mega and had similar errors. I kept fooling around with the IDE Burn Bootloader and also with AVRDUDESS until I bricked it. I put together another Mega but until I can get a bootloader into the 328P I don't want to chance killing another 1284P.

I was able to read the signature of both MCUs and change the fuses with avrdude. I then tried avrdude to burn the flash and got this:

~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

avrdude.exe: set SCK frequency to 32000 Hz
avrdude.exe: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude.exe: Device signature = 0x1e950f
avrdude.exe: NOTE: "flash" memory has been specified, an erase cycle will be performed
             To disable this feature, specify the -D option.
avrdude.exe: erasing chip
avrdude.exe: set SCK frequency to 32000 Hz
avrdude.exe: reading input file "C:\Users\Jphn\OneDrive\Elec\ArduinoLib\userSketch\hardware\Moteino\bootloaders\Moteino\DualOptiboot_V5.0_atmega328_BlinkD9.hex"
avrdude.exe: input file C:\Users\Jphn\OneDrive\Elec\ArduinoLib\userSketch\hardware\Moteino\bootloaders\Moteino\DualOptiboot_V5.0_atmega328_BlinkD9.hex auto detected as Intel Hex
avrdude.exe: writing flash (32768 bytes):

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

avrdude.exe: 32768 bytes of flash written
avrdude.exe: verifying flash memory against C:\Users\Jphn\OneDrive\Elec\ArduinoLib\userSketch\hardware\Moteino\bootloaders\Moteino\DualOptiboot_V5.0_atmega328_BlinkD9.hex:
avrdude.exe: load data flash data from input file C:\Users\Jphn\OneDrive\Elec\ArduinoLib\userSketch\hardware\Moteino\bootloaders\Moteino\DualOptiboot_V5.0_atmega328_BlinkD9.hex:
avrdude.exe: input file C:\Users\Jphn\OneDrive\Elec\ArduinoLib\userSketch\hardware\Moteino\bootloaders\Moteino\DualOptiboot_V5.0_atmega328_BlinkD9.hex auto detected as Intel Hex
avrdude.exe: input file C:\Users\Jphn\OneDrive\Elec\ArduinoLib\userSketch\hardware\Moteino\bootloaders\Moteino\DualOptiboot_V5.0_atmega328_BlinkD9.hex contains 32768 bytes
avrdude.exe: reading on-chip flash data:

Reading | ################################################## | 100% 0.00s

avrdude.exe: verifying ...
avrdude.exe: verification error, first mismatch at byte 0x7c00
             0x00 != 0x11
avrdude.exe: verification error; content mismatch

avrdude.exe done.  Thank you.


I tried numerous SCK frequencies and also specified the -b at sever different rates without success.
No radios soldered and no Flash.

Do I need to install/use AVR Studio?
Do I need a different programmer?

The Moteinos I purchased from you have been performing flawlessly. Thanks for a great project/product.

Title: Re: optiboot loader
Post by: Felix on February 01, 2015, 07:26:49 PM
Since I always used AVR Studio for flashing I don't have the patience to try something else since I know that method just works. So it's the default I recommend. I too tried other methods and the IDE and avrdude etc etc... just a mess and waste of time. AVR Studio does the job, every time :)
Title: Re: optiboot loader
Post by: vectorspace on February 01, 2015, 08:01:38 PM
Thanks for the quick-fast reply.

I'll d/l and run AVR Studio and give it a spin.

Title: Re: optiboot loader
Post by: vectorspace on February 03, 2015, 07:15:58 PM
So, I've got the latest AVR Studio installed. I looked up how to use the USBasp and decided to use the AVR Dragon instead. Wired up the ISP connection to my DIY Moteino board. And just as you stated, AVR Studio worked much better and there were no errors. I set the fuses to LO:DE   HI:DC   EX:FD and then burned the DualOptiboot hex file.

For the first time since I built the board the LED lit up and it does so each time I read or write to the board!!

I didn't really understand the UNlock_bit line in the boards.txt file (Moteino.bootloader.unlock_bits=0x3F    Moteino.bootloader.lock_bits=0xCF) so I left those at default. I'm assuming that the bootloader should blink the LED regardless of the Lock (and UNlock) bits??

But I'm not getting the blinking LED after the bootloader is burned and confirmed. Below are the results:

Fuses:
(http://i.imgur.com/K5kmgOB.jpg)

Flash:
(http://i.imgur.com/AzrvaH4.jpg)

Lock bits:
(http://i.imgur.com/L9u6Sfb.jpg)

Do you have any suggestions as to what I'm doing wrong?




Title: Re: optiboot loader
Post by: Felix on February 03, 2015, 07:48:00 PM
Everything looks good. You need not touch the lock fuses unless you want to block access to the bootloader section from the program section.
The fuses are good and the bootloader should work.
The LED blinking is caused by the bootloader, that is expected after you burn the bootloader.
I am not sure what other blinking you are expecting?
Title: Re: optiboot loader
Post by: vectorspace on February 03, 2015, 07:54:40 PM
The only time the LED does anything is when AVR Studio reads or writes. It's not blinking after the bootload burn.

I also just tried to burn the bootloader for the DIY MoteinoMega and got the same results. The fuses and Flash burn all show good in AVR Studio but no blinking LED.

No telling what I've screwed up here. . .

:(

Title: Re: optiboot loader
Post by: Felix on February 03, 2015, 09:01:05 PM
So after the burn you can't program them via FTDI?
Any LED activity is ONLY going to be caused by the bootloader. Nothing else will turn digital pins on/off randomly like that. So my guess is you've burned the bootloader right.
For the MEGA the bootloader is different, make sure you fetch the HEX compiled for the 1284p MCU.
Title: Re: optiboot loader
Post by: vectorspace on February 04, 2015, 06:09:10 AM
Haven't tried the FTDI burn yet. After the burning described, if I provide 3.3V and GND, neither board does anything and no LED activity. The LED lit only when reading/writing Fuse bits or reading/writing Flash with Dragon.

I did use the other .hex file for the mega.

Title: Re: optiboot loader
Post by: Felix on February 04, 2015, 08:11:17 AM
Of course, applying power will cause the bootloader to jump directly to the program section, which in your case is blank.
So I dont think there's any issue. Please report back once you try the sketch upload via FTDI header.
Title: Re: optiboot loader
Post by: vectorspace on February 04, 2015, 08:18:32 AM
"I see" said the blind man, as he picked up his hammer and saw.   8)
So when you burn the bootloader you also burn a program that flashes the LED? Somehow I was under the impression that the bootloader did that itself.
That's definitely the piece I was missing. I really appreciate the help. In spite of the issues I encounter doing this kind of stuff (or perhaps because of them??) I'm enjoying the learning experience.

I'll report back as soon as I give it a try. Thanks!
Title: Re: optiboot loader
Post by: Felix on February 04, 2015, 08:30:03 AM
The bootloader is itself a program that sits at the END of the flash region (in our case the last KB of the available 32KB).
Its function is to help you load the real program via serial (and hence FTDI) instead of having to load it via ISP/AVR programmer every time.
The bootloader starts every time you power the board. It checks whether there was a hardware reset (FTDI does that via the DTR line which in turn asserts the RST signal through a 0.1uF cap, see schematic) and if so it will wait for about 1-3 seconds for a serial programming request. If there was no reset (in the case of plain power up from GND+VCC) or there was no sketch upload request via serial, it will jump directly to the existing program section at the START of the flash region. If there is no program there (blank chip) it does nothing, no blinking, nothing. Blank memory doesnt flash LEDS (it would be very disturbing if it did!).
So once you burn your bootloader, the chip still doesnt do anything useful other than look for a sketch upload request via FTDI. When you load your real sketch via FTDI it will jump to that sketch and start doing things. That's when you can load a blinky sketch so once its uploaded you should see your LED blinking.
I hope this clears things up a bit.
Title: Re: optiboot loader
Post by: vectorspace on February 04, 2015, 08:47:31 AM
Clears it up very well.

I'll be posting my Moteino based Davis VP2 wireless weather receiver display project once it's cleaned up a bit.

(http://i.imgur.com/EgDf077.png)

I've got it pretty close to done but still needs some work right now.
Title: Re: optiboot loader
Post by: vectorspace on February 04, 2015, 03:00:06 PM
Just uploaded a blink program with FTDI into both the DIYMoteino and DIYMoteinoMega.

BINGO!

Both are blinking quite nicely.  Thank you so much for taking the time to help teach me some things AND help me get these going.

Cheers!!!   ;D
Title: Re: optiboot loader
Post by: Felix on February 04, 2015, 08:53:28 PM
Awesome, good for you!
Title: Re: Burning Optiboot / DualOptiboot bootloader [solved]
Post by: ivars211 on February 27, 2015, 10:30:07 AM
I am trying to make a custom board using Atmega1284p and would love to use the wireless programming features. But I am having the same problem, i.e.
avrdude: Device signature = 0x1e9705
....
....
avrdude: verification error, first mismatch at byte 0x0000
         0xff != 0x3f
avrdude: verification error; content mismatch

when trying to burn moteino dual optiboot from Arduino IDE and using uno board as ISP programmer. I can however, burn "Mighty 1284p 16Mhz using optiboot" and "Original Mighty 1284p 16Mhz" without any problem.
Since I am cheap and don't want to spend money on proper programmer, is there any way to burn the bootloader without buying extra hardware? (Arduino as ISP programmer worked well so far).
Title: Re: Burning Optiboot / DualOptiboot bootloader [solved]
Post by: Felix on February 27, 2015, 10:50:16 AM
I don't know ... i always use a real programmer. Cheap is only cheap if your time is not worth anything ;)
Title: Re: Burning Optiboot / DualOptiboot bootloader [solved]
Post by: ivars211 on February 27, 2015, 01:12:16 PM
Although I am a lazy bastard, I feel the need to share the solution with community.

In this example my ArduinoISP is on port 4 and I am using Arduino uno (atmega328pu) and I am trying to program atmega1284p

1) Download avrdude and extract. http://mirror6.layerjet.com/nongnu//avrdude/avrdude-5.11-Patch7610-win32.zip
2) make a new folder on your C: drive called "avrdude"
3) Copy the extracted files in step 1 to that folder
4) Download/copy the bootloader file to the avrdude folder created in step2. (DualOptiboot_V5.0_atmega1284p_BlinkD15.hex in my case hardware\MoteinoMEGA_Core\bootloaders\MoteinoMEGA)
5) Rename the .hex file to boot.hex
4) Connect your ArduinoISP, check on which port it is.
5) Open cmd, start->cmd
6) write "cd C:\avrdude"
7) write "avrdude -c arduino -p m1284p -P \\.\COM4 -b 19200 -v"
All the information about the chip should show up. If not, check your power supply and wiring. You are good to go to step 8
8 ) write "avrdude -c arduino -p m1284p -P \\.\COM4 -b 19200 -U flash:w:boot.hex:i -U efuse:w:0xFD:m -U hfuse:w:0xDE:m -U lfuse:w:0xDE:m"
9) should take a minute or so and if no error, just upload the code through Arduino IDE


References: http://heliosoph.mit-links.info/arduinoisp-reading-writing-fuses-atmega328p/

P.S. Saved 50 pounds and spent 2 hours googling, thats 3 times my wage per hour there. :D
Title: Re: optiboot loader
Post by: dale.s on June 11, 2015, 05:59:10 PM
Quote from: Felix on January 27, 2014, 02:17:23 PM
If you need to reflash a Moteino you:

- need an AVR programmer - just get the AVR ISP MKii (digikey, don't mess with other cheapie non OEM ones. Saving $10 here is REALLY not worth it - see http://www.digikey.com/product-search/en?keywords=ATAVRISP2-ND
- need to power the Moteino independently of the AVR programmer
- need to pullup pin D10 if the RFM69 radio is already soldered
- the pins are the standard ISP protocol pins (VCC, GND, RST, SPI_CK, SPI_MISO, SPI_MOSI)
- use AVR Studio with target Atmega328p

Now that the AVR ISP MKii has been discontinued, do you have a suggestion on another programmer to use? I can find lots of MKii clones, but somehow i just don't trust them without good reports!
Title: Re: Burning Optiboot / DualOptiboot bootloader [solved]
Post by: joelucid on June 11, 2015, 06:12:05 PM
I've successfully used a moteino to program another moteino using the sketch that ships with Arduino and avrdude. I did this while I was waiting for the mkii to ship (yes impatient). It might be worth a try.

I did fry a moteino but that was due to my bootloader accessing the radio after install and talking against the programmer on spi.
Title: Re: optiboot loader
Post by: TomWS on June 11, 2015, 06:53:47 PM
Quote from: dale.s on June 11, 2015, 05:59:10 PM
Quote from: Felix on January 27, 2014, 02:17:23 PM
If you need to reflash a Moteino you:

- need an AVR programmer - just get the AVR ISP MKii (digikey, don't mess with other cheapie non OEM ones. Saving $10 here is REALLY not worth it - see http://www.digikey.com/product-search/en?keywords=ATAVRISP2-ND
- need to power the Moteino independently of the AVR programmer
- need to pullup pin D10 if the RFM69 radio is already soldered
- the pins are the standard ISP protocol pins (VCC, GND, RST, SPI_CK, SPI_MISO, SPI_MOSI)
- use AVR Studio with target Atmega328p

Now that the AVR ISP MKii has been discontinued, do you have a suggestion on another programmer to use? I can find lots of MKii clones, but somehow i just don't trust them without good reports!
Have you answered the very first question from above? 
Quote from: Felix on January 27, 2014, 02:17:23 PM
If you need to reflash a Moteino...
You only need an ISP programmer if you need to reflash the fuses or bootloader.  If you're using a standard Moteino and just changing sketchcode, you can use an FTDI cable to program your Moteino.  Very few people need the former.

Tom
Title: Re: Burning Optiboot / DualOptiboot bootloader [solved]
Post by: TomWS on June 11, 2015, 07:04:22 PM
Quote from: joelucid on June 11, 2015, 06:12:05 PM
I've successfully used a moteino to program another moteino using the sketch that ships with Arduino and avrdude. I did this while I was waiting for the mkii to ship (yes impatient). It might be worth a try.

I did fry a moteino but that was due to my bootloader accessing the radio after install and talking against the programmer on spi.
Does this mean we finally get to see the code?

When you say you 'fried' a moteino (I prefer them toasted) does that mean you need to wait for the MKII to arrive or did you really 'fry' it?

Tom
Title: Re: Burning Optiboot / DualOptiboot bootloader [solved]
Post by: dale.s on June 11, 2015, 08:03:15 PM
I do like tweeking bootloaders so i use one for that, and i do a fair amount with attiny chips so i tend to use one with that, uptill now ive been using arduino-as-isp then moved onto a usbasp.  Im sick of all the little problems you get with these, they can be so flaky!

I found a few sites with what they claim to be "real" MKii's but they price is upto $55+ and im not 100% sure they are accually REAL MKii's.
Lots of clones out there, some with interesting extra bits, saw one with a logic analyser built in, seems interesting, however id much rather have somthing i know is 100% supported and 100% working!
Title: Re: Burning Optiboot / DualOptiboot bootloader [solved]
Post by: TomWS on June 11, 2015, 08:47:50 PM
Quote from: dale.s on June 11, 2015, 08:03:15 PM
I do like tweeking bootloaders so i use one for that, and i do a fair amount with attiny chips so i tend to use one with that, uptill now ive been using arduino-as-isp then moved onto a usbasp.  Im sick of all the little problems you get with these, they can be so flaky!

I found a few sites with what they claim to be "real" MKii's but they price is upto $55+ and im not 100% sure they are accually REAL MKii's.
Lots of clones out there, some with interesting extra bits, saw one with a logic analyser built in, seems interesting, however id much rather have somthing i know is 100% supported and 100% working!
I've managed with Sparkfun's pocket programmer.  It's sort of a PITA, but, supremely flexible.  I don't use it for Sketch loading, only fuse and bootloader 'adjustments'.

Tom
Title: Re: Burning Optiboot / DualOptiboot bootloader [solved]
Post by: joelucid on June 12, 2015, 03:01:27 AM
QuoteWhen you say you 'fried' a moteino (I prefer them toasted) does that mean you need to wait for the MKII to arrive or did you really 'fry' it?

As i remember this one didn't come back to life. It seems understandable that two SPI masters talking at the same time could do some damage to the atmega328. I've had the mkii for months and I'm happy with it.

QuoteDoes this mean we finally get to see the code?

I'd say from a functionality perspective it's ready. It now does adaptive bitrate downgrading so it'll work wherever Felix 55kbaud bitrate works (it actually goes down to 19200baud if necessary but clients initially connect at 55kbaud). It's just still pretty tightly coupled with the rest of my stuff and right now I'm also a bit occupied work wise  :-\
Title: Re: Burning Optiboot / DualOptiboot bootloader [solved]
Post by: Felix on June 12, 2015, 08:55:27 AM
First there's a difference between fried and bricked. Fried is physical damage/magic smoke etc. Bricked is at a fuse/firmware level and there's various degrees to that as well.

I will forever stay away from programmer clones and aftermarket stuff, or things made by 3rd parties. I will only use a genuine mkII or ICE AVR programmer. I've had bad experiences. If the programming of the fuses is not done right or there's a glitch and you write an invalid byte there, your mega can be bricked. It happened a lot in my early days and it was driving me crazy and thought it was me doing something wrong or pogo pins weren't making good contact etc.

It will take a lot of effort to unbrick it with HV programming and I've done that too in the old days, and about half the chips were salvaged. Not to mention having to desolder and resolder them. Even that is a big issue with the packages being moisture rated and could get damaged when desoldering with hot air etc.
Title: Re: Burning Optiboot / DualOptiboot bootloader [solved]
Post by: gurari on November 16, 2015, 04:28:51 PM
Sorry for the dumb question, but I never tried burning bootloader to moteino when the radio module is soldered. Is this possible using AtmelStudio?
Title: Re: Burning Optiboot / DualOptiboot bootloader [solved]
Post by: Felix on November 16, 2015, 04:52:54 PM
You can but you will need to pullup D10.
Title: Re: optiboot loader
Post by: underwater on May 09, 2016, 05:03:21 AM
Quote from: Felix on January 27, 2014, 02:17:23 PM
If you need to reflash a Moteino you:

- need an AVR programmer - just get the AVR ISP MKii (digikey, don't mess with other cheapie non OEM ones. Saving $10 here is REALLY not worth it - see http://www.digikey.com/product-search/en?keywords=ATAVRISP2-ND
- need to power the Moteino independently of the AVR programmer
- need to pullup pin D10 if the RFM69 radio is already soldered
- the pins are the standard ISP protocol pins (VCC, GND, RST, SPI_CK, SPI_MISO, SPI_MOSI)
- use AVR Studio with target Atmega328p

Hello Felix, thanks for the information.
Can you (or any of you in the forum) please detail the last part which is ''use AVR Studio with target Atmega328p''?

How can I load the bootloader inside atmega328p chip by using avrdude?

According to sparkfun tutorial (https://learn.sparkfun.com/tutorials/installing-an-arduino-bootloader) it is defined with the commands below;

First step setting the fusebits;
avrdude -b 19200 -c usbtiny -p m328p -v -e -U efuse:w:0x05:m -U hfuse:w:0xD6:m -U lfuse:w:0xFF:m
Second step is uploading the program;
avrdude -b19200 -c usbtiny -p m328p -v -e -U flash:w:hexfilename.hex -U lock:w:0x0F:m

Can you detail these commands regarding DualOptiboot?

best regards,
Mirac
Title: Re: optiboot loader
Post by: Felix on May 09, 2016, 07:40:19 AM
Quote from: underwater on May 09, 2016, 05:03:21 AM
Quote from: Felix on January 27, 2014, 02:17:23 PM

Hello Felix, thanks for the information.
Can you (or any of you in the forum) please detail the last part which is ''use AVR Studio with target Atmega328p''?

How can I load the bootloader inside atmega328p chip by using avrdude?

If you need to reflash a Moteino with any bootloader you:

- cannot do it with avrdude (serially burn the bootloader, only through ISP method) still needs an AVR/ISP programmer with avrdude
- need an AVR ISP programmer (I use AVR ISP MKii)
- need to power the Moteino independently of the AVR programmer
- need to pullup pin D10 if the RFM69 radio is already soldered
- the pins are the standard ISP protocol pins (VCC, GND, RST, SPI_CK, SPI_MISO, SPI_MOSI)
- use AVR Studio with target Atmega328p - self explanatory once you look at it
Title: Re: optiboot loader
Post by: TomWS on May 09, 2016, 08:26:20 AM
Quote from: Felix on May 09, 2016, 07:40:19 AM

If you need to reflash a Moteino with any bootloader you:

- cannot do it with avrdude
This is not correct.  You can use avrdude, however...
Quote
- need an AVR ISP programmer (I use AVR ISP MKii)
you need this programmer or, as in the Sparkfun example, you use the AVR Pocket Programmer, which you can buy from Sparkfun and follow their hookup guide. In this case the instructions are exactly like Sparkfun's EXCEPT:

avrdude -c usbtiny -p m328p -v -v -e -u -U flash:w:arduino\avr\bootloaders\Moteino\DualOptiboot_V5.0_atmega328_BlinkD9.hex  -U lock:w:0x0F:m


Also, if you have flash memory installed on your Moteino I recommend that you have a 10K pullup resistor on pin 8 of the Moteino.


Tom
Title: Re: Burning Optiboot / DualOptiboot bootloader [solved]
Post by: Felix on May 09, 2016, 08:56:33 AM
Tom,
Right, I was vague, I meant you cannot use avrdude via the traditional serial/ftdi method.
Also I did not see a need for a D8 pullup when FLASHMEM is present, only for D10 whenever a RFM69 is present.
Title: Re: Burning Optiboot / DualOptiboot bootloader [solved]
Post by: TomWS on May 09, 2016, 09:11:01 AM
Quote from: Felix on May 09, 2016, 08:56:33 AM
Also I did not see a need for a D8 pullup when FLASHMEM is present, only for D10 whenever a RFM69 is present.
Yes, my mistake.  I knew one of them needed a pullup and forgot which one.  Although a pullup on every SPI CS pin isn't a bad idea with ISP.

Tom
Title: Re: Burning Optiboot / DualOptiboot bootloader [solved]
Post by: Felix on May 09, 2016, 09:15:49 AM
Quote from: TomWS on May 09, 2016, 09:11:01 AM
Quote from: Felix on May 09, 2016, 08:56:33 AM
Also I did not see a need for a D8 pullup when FLASHMEM is present, only for D10 whenever a RFM69 is present.
Yes, my mistake.  I knew one of them needed a pullup and forgot which one.  Although a pullup on every SPI CS pin isn't a bad idea with ISP.

Tom
Yeah not a bad practice. Although all Moteinos with FLASHMEM I ever burned with ISP I never used a pullup and never had an issue. In contrast if I solder a RFM69 and I need to reflash it, it never works, the RFM69 scrambles the SPI/ISP and if I try it a few times it can brick the atmega with bad fuses.
Title: Re: Burning Optiboot / DualOptiboot bootloader [solved]
Post by: OSBSS on May 16, 2016, 03:18:12 PM
Was anyone able to reprogram a Moteino/MoteinoMEGA using an Arduino Uno as ISP? I have a 10K pullup on pin 4 (MoteinoMEGA) and I'm trying to use the example code in the IDE, but it isn't recognizing it: avrdude: Expected signature for ATmega1284P is 1E 97 05. Tried programming another Uno with an Uno ISP and it works fine.
Title: Re: Burning Optiboot / DualOptiboot bootloader [solved]
Post by: VdesmedT on June 13, 2017, 04:15:43 AM
Is this little guy good enough : http://www.newark.com/olimex/avr-isp-mk2/flash-programmer-avr-mcu/dp/27W3730 ?
Title: Re: Burning Optiboot / DualOptiboot bootloader [solved]
Post by: TomWS on June 13, 2017, 07:21:33 AM
Quote from: VdesmedT on June 13, 2017, 04:15:43 AM
Is this little guy good enough : http://www.newark.com/olimex/avr-isp-mk2/flash-programmer-avr-mcu/dp/27W3730 ?
It's got the right 'words' (you need ISP for the 328P) but no experience with it.   

You'll also have to add some pullup resistors if you're going to patch into a Moteino board (pullups on all SPI CS pins - Radio, Flash, etc).

Tom
Title: Re: Burning Optiboot / DualOptiboot bootloader [solved]
Post by: VdesmedT on June 13, 2017, 08:11:23 AM
Same remarks for this guy : http://be.farnell.com/fr-BE/atmel/atatmel-ice/debogeur-atmel-arm-avr-kit-complet/dp/2407173 ?
Title: Re: Burning Optiboot / DualOptiboot bootloader [solved]
Post by: fgomes on November 27, 2017, 06:15:44 AM
Quote from: Felix on November 16, 2015, 04:52:54 PM
You can but you will need to pullup D10.
Hi Felix, why not to consider the pull-up resistor (10k) always assembled? It will just add a small additional current consumption each time the RFM module is accessed, or do you see any other problem having the resistor always there?

Best regards

Fernando
Title: Re: Burning Optiboot / DualOptiboot bootloader [solved]
Post by: Felix on November 27, 2017, 01:48:07 PM
I would rather not add parts that are not needed in most cases.
Title: Re: Burning Optiboot / DualOptiboot bootloader [solved]
Post by: perky on November 27, 2017, 10:04:35 PM
I think it may be possible to use an FTDI cable directly as an ISP programmer using bit-bang mode, albeit slowly. I think AVRdude supports bit-banging using the '-c ft232r' programmer type, defined in avrdude.conf. I'm not sure how reset is handled though, I've never tried this.

Mark.
Title: Re: Burning Optiboot / DualOptiboot bootloader [solved]
Post by: Uncle Buzz on April 03, 2018, 06:07:00 AM
Hi !
The pullup resistor (10k) on D10 should be at 3.6V maximum (maximum voltage for RFM69) or might be on VCC from the programmer (5V) and the 10k will protect the RFM69 ?
Thank you.
Title: Re: Burning Optiboot / DualOptiboot bootloader [solved]
Post by: Felix on April 03, 2018, 09:59:54 AM
3.3V if you have the FLASH/radio module.
Title: Re: Burning Optiboot / DualOptiboot bootloader [solved]
Post by: Uncle Buzz on April 03, 2018, 01:40:15 PM
D10 is only used by the radio, so no need to pullup D10 if there is the flash chip but no radio ?
With flash and radio, should we also use something like a level shifter on SPI signals from programmer ?
Title: Re: Burning Optiboot / DualOptiboot bootloader [solved]
Post by: Felix on April 03, 2018, 03:14:57 PM
D10 needs to be pulled up. Thats the radio CS. The FLASH CS (D8 on Moteino) does not need it.
The programmer does NOT power your project, a common misconception. The programmer only senses the project VCC. So no level shifting required. Just power the Moteino or MCU as you normally would while you program it.
Title: Re: Burning Optiboot / DualOptiboot bootloader [solved]
Post by: Uncle Buzz on April 05, 2018, 07:58:46 AM
Ok, so if I understand how it works, the programmer pull down voltages set by the atmega like on I2C , so no needs to protect SCK MISO and MOSI from 5V ?
the pulup resistor on D10 avoids the radio to also pull down SPI bus trying to communicate in same time than programmer.
Why the flash doesn't act like radio ? Maybe I misunderstood something...
Title: Re: Burning Optiboot / DualOptiboot bootloader [solved]
Post by: Felix on April 05, 2018, 12:16:36 PM
Quote from: Uncle Buzz on April 05, 2018, 07:58:46 AM
Ok, so if I understand how it works, the programmer pull down voltages set by the atmega like on I2C , so no needs to protect SCK MISO and MOSI from 5V ?
the pulup resistor on D10 avoids the radio to also pull down SPI bus trying to communicate in same time than programmer.
The programmer reads the VCC of the board and uses that to assert ISP/programming port. Makes a lot of sense. The programmer NEVER powers your project, that would be a very bad idea. What if it's a power plant running on an AVR MCU, would it make sense for the programmer to supply 3275kW  while programming? - No.

Quote from: Uncle Buzz on April 05, 2018, 07:58:46 AM
Why the flash doesn't act like radio ? Maybe I misunderstood something...
It's more like the radio misbehaves. The FLASH is quiet when its CS is floating, the radio is not.
Title: Re: Burning Optiboot / DualOptiboot bootloader [solved]
Post by: Uncle Buzz on April 05, 2018, 12:50:34 PM
Vcc pin on programmer is not power supply but a sensing to set voltage on communication pin ?
So Vcc from programmer should be connected to 3V3 output of moteino while moteino is powered otherway ?
Title: Re: Burning Optiboot / DualOptiboot bootloader [solved]
Post by: Felix on April 05, 2018, 01:31:09 PM
Quote from: Uncle Buzz on April 05, 2018, 12:50:34 PM
Vcc pin on programmer is not power supply but a sensing to set voltage on communication pin ?
So Vcc from programmer should be connected to 3V3 output of moteino while moteino is powered otherway ?
Yes.
Yes.
Title: Re: Burning Optiboot / DualOptiboot bootloader [solved]
Post by: perky on June 14, 2019, 04:41:41 PM
In reality the VCC input to the programmer powers a buffer inside the programmer, so the outputs of the buffer like MOSI, SCK and CS# are driven to that voltage.

Mark.
Title: Re: Burning Optiboot / DualOptiboot bootloader [solved]
Post by: overlord on December 08, 2019, 08:21:05 AM
Because my AVR MKII ISP clone was fried, I tried to use an Arduino UNO as ISP with avrdude to burn the 8MHz Bootloader on some original and homegrown R4 Moteinos.
https://www.arduino.cc/en/tutorial/arduinoISP (https://www.arduino.cc/en/tutorial/arduinoISP)
To power the R4 Board from the Uno I used the 3,3 V not the 5 V output.
D10 was pulled up with 10K against Vcc. I did not set lockbits.

avrdude -P /dev/ttyACM0 -b 19200 -c avrisp -p m328p -U efuse:w:0xFD:m -U hfuse:w:0xDC:m -U lfuse:w:0xDE:m
avrdude -P /dev/ttyACM0 -b 19200 -c avrisp -p m328p -U efuse:w:0xFD:m -U hfuse:w:0xDC:m -U lfuse:w:0xDE:m -e -U flash:w:DualOptiboot_V5.0_atmega328_BlinkD9.hex

The avdude process in my case is only reliable with USB Ports under Windows. I used avrdude which came with Arduino Toools.
With Linux, Raspi and MacOSX I got verification errors while fuse burning and flashing the Bootloader.
Anyway I will again buy an ISP and use Atmel Studio for the Bootloader only, depending on only one Machine/USB combination is not so good.
Once the bootloader is burnt I use VS Code/Platform IO under Linux/MacOS which works well.

René

Title: Re: Burning Optiboot / DualOptiboot bootloader [solved]
Post by: overlord on December 14, 2019, 06:32:12 AM
I have a new AVR ISP II Clone which is able to power the Board with 3,3 Volt, even if the RFM69 receiver is already soldered, during Bootloader Burning.
It does also level shifting to 3,3V for the Logic Signals and has adaptive bit rate adoption. I will now convert all my Moteinos into 3V versions, once the last 9 Volt Batteries are weared out.
https://www.diamex.de/dxshop/mediafiles//Sonstiges/ENG%20erfos-avr-isp2.pdf (https://www.diamex.de/dxshop/mediafiles//Sonstiges/ENG%20erfos-avr-isp2.pdf)
This works out of the box with avrdude on Linux (8MHz variant fuses and bootloader example command lines ).
avrdude -P /dev/ttyACM0 -c avrisp2 -p m328p -U efuse:w:0xFE:m -U hfuse:w:0xDC:m -U lfuse:w:0xD2:m
avrdude -P /dev/ttyACM0 -c avrisp2 -p m328p -v -e -U flash:w:Dualoptiboot_v5.0_atmega328_8mhz_57600baud_BlinkD9.hex