@Samuel235
I have no issues with ftdi uploads at 8Mhz internal and 38k upload speed on my nodes. Even for 25k byte sketches.

I've been told that it should work but atmel do not advise it or support it apparently. There are chances that it wont work and mine doesn't. I had the discussion regarding it in my nodes topic but the conversation just dropped off and went stale.

@Samuel235
That depends on the upload speed. At higher speeds the error on the frequency of the internal oscillator gets more important. It can be off by several percent (from 8mhz) and then avrdude can fail. I have experimented with 9600 baud and there the deviation of the internal 8mhz has to be severe before the serial uploads starts to feel the effect.
So try using a 8Mhz boot loader prepared for an 9600 baud upload.

@Samuel235 No issue to with the FTDI.
I just found a small problem due to the Arduino IDE. As I often change board (from UNO to different bootloader) I discover that the menu is sometime not coherent with the real setting. So I found that selecting two or three times board parameters (including port) is the solution to avoid communication issue.

@GertSanders I used that DA high fuse simply to make sure the default bootloader fitted, however if its too big will it cause issues on serial ipload even if its a very small upload? Could that be the reason?

I will try your bootloader without the LED as my module doesn't contain the LED. This is very hard to read from a mobile device so i will attempt this when i get home tonight. Thank you once again for your files and time.

@GertSanders
Yes, very impressive ! But finally not a lot of difference with the same node using interruption and sleep.
The auto-discharge of AA batteries is really important compare to node consumption.

@GertSanders, I have just managed to make time to remake a node and troubleshoot its upload issues with your suggested solution. So i went a head, got everything made up the minimal version, MCU, caps, and programming headers. I made sure all connections were working fine, they were. I then read the fuses, all fine and dandy. I then burnt your suggested fuses of;

Then the problem came. I lost all contact to the node, tried slowing the clock rate down on AVRDUDE to read it, nothing. I've hooked up my crystal just in case it burnt it incorrectly and thought it had an external crystal, nothing there either.

@Samuel235
I'm out of ideas myself. I have been using several boot loader versions with the LED on different pins and different upload speeds or clockspeeds, and so far all my boot loaders work on my nodes.
Maybe you should write down step by step what you do, without assuming we know which steps you take, so we can see if the procedure is correct. Other then that it could be a board issue, but then if you already have a working board which allows uploading ???

I didn't even get to the point of choosing one of your bootloaders that you gave me to try, so i'm more than sure it is either a fuse problem or a board problem (which i'm doubtful of since it was working before i burned the new fuse settings).

I haven't soldered the Radio, the radio's capacitor, battery holder, or the screw terminal block. Other than that, everything else has been assembled. The only other hardware thing that it could be, but not sure why it would work until i burnt the fuse settings, is there may be a 4.7uF as one of the capacitors where it should be a 0.1uF. I have replaced the one on the reset line so i can guarantee it is not that one. The only other caps on the board are decoupling/filtering caps.

I do already have one board with the fuses that you saw me use before (which you questioned why i used the size of the boot sector that i did) and that is working perfectly fine. But as you know that is just running a sketch that was uploaded through "Upload using programmer".

@Samuel235
One possible reason: the BOD setting is now 0x06, which is the value if you use the Arduino IDE to burn the bootloader and set the fuses.
Since you use AVRDUDE ditectly, the extended fuse needs a different value (the one you get from the AVR fuse calculator at ATMEL).
I'm using my phone for this reply, so can not check the actual site right now

@GertSanders, you're correct in that. I encountered this issue with my first board but the avrdude still contacted the board unlike this one. To test this out would you suggest me trying to burn the bootloader with the Arduino IDE?

I have now double checked it hasn't burnt a external 8MHz crystal fuse setting, which it hasn't. I can't check for 16MHz setting as i do not have a 16MHz crystal or a board with one on. I will be making a new board later with a fresh MCU to see if it happens all over again. I need to stock up on 0.1uF caps to make any more boards after this one today so this is my only option for the moment.

Keep me posted on your AU style board that you're assembling today

EDIT/UPDATE

After remaking another board, the only thing i can think i did incorrectly was burn a high fuse of 0xEE. This would disable all SPI downloads and turn on watch dog timer. Do you think this may be whats happened here?

The new board is working perfectly fine. I've burnt the correct fuses and can read the fuses back.

I have downloaded your bootloader you included above (optiboot_atmega328_08m_004800_noled.hex). I made a new directory in 'C:\Program Files (x86)\Arduino\hardware\arduino\avr\bootloaders' called gertsoptiboot and saved the .hex file inside of there. So the overall directory of the bootloader is: 'C:\Program Files (x86)\Arduino\hardware\arduino\avr\bootloaders\gertsoptiboot\optiboot_atmega328_08m_004800_noled.hex'.

The board.txt file i have added your included text in there but i assumed that i need to change the bootloader file path and name, so my boards.txt entry for you looks like this;

I have changed the bottom two lines and will change the arduino menu name when its working. While this all like fine to me (obviously point out any errors for me here if i have done any) I'm getting a little error of "pins_arduino.h: No such file or directory". I have done a little searching around and basically i think its because i do not have a variant folder for this board/entry. I'm assuming that you have a subfolder inside of 'C:\Program Files (x86)\Arduino\hardware\arduino\avr\variants' titled something like "28PinBoard"?

To fix my issue i think i either need a copy of your variant folder OR to change the variant inside of boards.txt to that of something like 28PinBoard.build.variant=arduino:standard. Would this work considering there is nothing different on my MCU to that of a arduino board?

I started with loading the ISP sketch on my Uno compatible board (it is set up for loading boot loaders on DIL type of atmega328):

Then I choose the following settings in the Arduino IDE:

After choosing these settings I selected "Burn Bootloader", which resulted in a good loading. Since there is no sketch yet, my board cycles through a reset fase (and thus the LED blinks three times every few seconds).

After that I selected my FTDI interface and uploaded the BLINK sketch with the same settings, and bingo: blinky lights.

My next step will now be to add the radio and do a LED dimming test, to be continued ...

Last update on this topic to save bogging it down now, just to assist anyone else looking to use your bootloaders. I have managed to upload sketches to my MCU. I'm running the 'optiboot_atmega328_08m_004800_noled.hex' bootloader with the following boards.txt entry:

I'de like to thank you for the time and effort you have put in to assist me on this problem. I will be making entries for the rest of your bootloaders that you have also kindly given to us. I'll be changing this to a faster upload speed bootloader variant to allow for quicker uploads, maybe the 'optiboot_atmega328_08M_038400_NOLED.hex'. Would you advise me to use this bootloader with the correct boards.txt entry for it, would it be okay to have on my switch node permanently or is there something in there that wouldn't make it appropriate?

After seeing the extent that you have gone to with your customization with the bootloaders, it has inspired me to get into bootloaders myself. All in due time.

I have upgraded my Arduino to 1.6.8, running Ubuntu 14.04LTS and downloaded the GertSander great optiboot
I use Arduino Pro mini clones from ebay. I have removed power LED and LDO, since those shall be powered from 2pcs AAA . I can read "80e" on the crystal - I assume this is 8MHz
But I get weird troubles, I can flash bootloader via TinyUSB and upload sketch via FTDI, but not the lower frequencies like 1MHz or 4MHz, my working sketch upload is with 8 MHz (I have not tried with a higer freq). I can upload both using internal and external crystal settings. I use BOD=1.8V
I have been suspecting my USB cable to MiniUSB to FTDI, but it's working when I use the 8MHz frequencey and 38K4baud rate
any good ideas?

You should not flash the 4Mhz bootloader to a pro mini, because it works in 2 ways: with 8Mhz crystal or using the internal oscillator.

When using the internal oscillator, you can use it at 8Mhz (default) or at 1Mhz. In this last case, the fuse for clockdivision by 8 need to be set.

I have not experimented with a clock division by 2, which would allow the 4MHz boot loader to work.

I have some 4MHz crystals, so that is why I compiled the 4Mhz version of the boot loader.

When uploading via FTDI, you need to keep the settings at which you flashed the bootloader.

I found that when using the internal oscillator, there is a difference when you flash at 5V or at 3V3 for the same processor. If you flash the boatloader while it is powered at 5V, and then use the processor at 3V3 you may have issues with loading via FTDI at higher speeds, because the actual speed of the internal oscillator is different at 5V or 3V3.

So I think it is best to always use the crystal.

If you do need to run the processor at slower speed, keep the 8Mhz crystal setting, but use clock division. This means you need to change the fuse settings to make that work.

@hek I wanted to upload a ZIP file of my hardware sub folder so people can just expand that ZIP into their <sketches>\hardware directory, but the Openhardware.io site unpacks the ZIP and puts the files in various places.
Is there a way to upload a ZIP without it being unpacked ? Is a RAR file allowed (not tested this). I tried renaming the extension to .unzip_this but that "file type" is not accepted by the import function.

Good afternoon @GertSanders, I'm over the moon with your bootloaders than you provided me. Is there anything that would make you advice me not to use your 'optiboot_atmega328_08M_038400_NOLED.hex' bootloader full time on my light switches?

oki I got it 4 MHz wont work on Pro Mini. but I would assume 1MHz bootloaders should be ok?

1)I have first selected board: atmega328 based 32pins TQFP, then the frequency.
2)Flashed bootloader via tiny USB
3)Then put Pro Mini to FTDI, and then tried to upload sketch. (no changes at all to which board type, speed, or BOD)

(I use 1 USB port on laptop for tinyUSB and another USB port for FTDI.)

Then I change speed/frequency, and do the step 1,2,3 as above

Selecting 8MHz-crystal-38k4-D8 is working flawless.
None of the 1MHz selection is working for me...

@GertSanders
I it's quite strange, I believe your bootloadser are in good shape and also your boards.txt
Thats why I suspect my USB to miniUSB cable to FTDI to behave odd.
Do you have Arduino Pro Mini 3,3V 8MHz that you can try at your place?

I uploaded two boot loaders on a pro mini 3V3 version with 8Mhz resonator.

On this board I loaded a boot loader for 1MHz clock frequency and upload speed of 9600 baud. This worked fine. Then I tried the 4800 baud upload speed version: same thing. Both boot loaders uploaded fine, and I was able to load sketches on both with an Adafruit FTDI friend at the specified upload speeds. 4800 is really "sloooooow".
Just to be sure I also used a cheap Chinese FTDI interface: same good results.

This is strange I tried to use win7 + Arduino IDE 1.6.7, and things are behaving normal, but it's not possible to at the same time, have FTDI + tinyUSB connected on each USB port, it's only working when 1 USB is used. I have 3 pcs Arduino Pro mini, 2 is working as they should. and 1 is only to be flashed with 8 MHZ bootloaders. I will have to look at this Pro Mini in a microscope at work - maybe it's a 5V 16MHz?!?

Something else I use Ubuntu and Arduino IDE 1.6.8. The Arduino IDE is behaing weird.
I now only use the 2 pcs good Arduini Pro Mini, both bootloader flased with tinyUSB and Win7 IDE 1.6.7. with 1MHz 4k8 bootloader. when I use FTDI in Ubuntu IDE 1.6.8 I get error message that upload failed. But is is working.
I can first upload sketch "bare minimum" upload and get error, no LED is flashing in Pro Mini (Expected), then I upload "Blink", upload shows error, but Pro Mini LED is blinking.
so Arduino IDE 1.6.8 in my Ubuntu is uploading sketches with FTDI fine - but shows an Arduino error. So I can flash Gert bootloadesr with windows7 and Arduino 1.6.7

My Ubuntu won't let me successfully flash a 1MHz bootloader, only 8MHz with speed 38k4, it's not working with 8MHz 9k6 either,
but at least I can also confirm that Gert's bootloaders are working as they shall, since it's working for me using windows7 laptop

Hi, and thanks for your amazing work! I am trying to make your Narrow node with a Atmega 328P-PU and the pcb you made. I have low understanding of how I am going to upload "optiboot_atmega328_08M_038400_D6.hex" via a arduino uno.. Do I need to make anything with fuses or so? And how do I do it if that is the case?

@GertSanders Okey, I almost got it! I am stuck on compiling the sketch. It says "pins_arduino.h" is missing. Apparently I need a folder called "28PinBoard" with a file "pins_arduino.h" in it. Wich one can I use for this project?

@GertSanders My personal observations - some chips are more temperamental than the others. I recently tried to upload the sketch (8Mhz internal clock) and it failed a few times. Then I reflashed Optiboot and used the external clock (8Mhz external clock) and this cured the issue. With other chips I did not have this problem.

@GertSanders : Ive downloaded the files and boards.txt. I noticed you've made a distinction between the 28p DIP and the 32p TQFP. But in the boards.txt I can find no differences besides that the high fuse bits are global for the 28p version and individual (but all the same!) for the 32p version.
Does that have a reason?

@DavidZH
No particular reason, I did not spend as much effort in defining the options for the 32-pin package as I did for the 28-pin package.
When my free time becomes mine again, I will be able to take this up again. For now I have to be content with a relatively short online presence every week.

@GertSanders I am finally getting around to trying some of these bootloaders. Thanks for making them! Would you mind posting the latest .zip file to the openhardware site? I started with those files and was getting the same errors as others mentioned. As I got further down this thread I noticed I was missing some files.
Thanks again for making these!

I have added my atmega328 directory in a RAR file and uploaded it to the site.

This compressed file contains a directory structure that contains all bootloaders I use, and the extra files needed to make most of those available from the Arduino IDE.

To use it:
Close the Arduino IDE
Unpack the RAR file
Open the IDE

This compressed file needs to be unpacked inside the "hardware" directory which sits inside the Arduino Sketches directory. If you do not have a "hardware" directory inside the Arduino Sketches directory, then you need to make this first.
Then go inside the "hardware" directory and there unpack the RAR file.

I'm finally managing to update my Arduino IDE and would like to ask how you have your boards.txt setup. Do you have your boards.txt file that is zipped up in your config zip file just located in the avr folder without running the default boards.txt file or are we supposed to merge your boards file with the original one? Back when i was developing my own boards, i seem to remember just running your board file without any of the default files....

@GertSanders Awesome, thank you for uploading it as a .rar!!! So easy now

@Samuel235 You should be able to just copy the entire folder from the .rar file into your Arduino folder. I had to create a "Hardware" folder as it didn't exist. I'm on Windows 10 and it looks like this:
After closing/re-opening the Arduino IDE it looks like this:

The boards .txt and platform.txt files are not complete yet, and I still need to check and change the pins_arduino.h boards for the 40 and 44 pin atmega's. That is still on my to do list, but the structure is there already. I'm still learning from other hardware deployments how to define this in a practical way. Hopefully by sharing this will be improved.

@petewill - I do that, however i do already have the hardware folder (and its a clean install of windows and arduino IDE) and then inside the hardware folder i have the boards.txt file (the default one, the list that shows in the IDE without installing gertsanders'. So, i either need to put the new one in there and rename the old or to merge the two together.

Or am i getting this completely wrong some how?

EDIT: It was a mistake on my own part but will leave this comment here for anyone to see and to not make the same mistake as myself:

I was attempting to put it inside of the "arduino" folder that was inside of the hardware folder. My own fault XD

I'm using a arduino nano, hooked it up to avrdude and read the fuses as Low:FF, High:DA, Extended:05. I then burn new fuses of Low:FF, High:DE and Extended:07. Burnt fine, so i go into arduino IDE and select the bootloader for 32pin, TQFP, 8MHz external crystal 38K4 D13 and then burn bootloader. I get a little warning but that is only because of the new IDE issues with extended bits ("You probably want to use 0xfd instead of 0x05 (double check with your datasheet first)."). But now the LED on the nano is blinking rapid then stop, then blinking rapid and then stop. I can't upload a sketch to the nano either now. I can however burn the old bootloader back on and upload like normal. What could be the issue here?

It almost seems like there is something wrong with the bootloader as it is uploading to it but the LED is blinking weirdly. May not be the bootloader itself, could just be some corruption as it gets uploaded....

@Samuel235
If you are using a nano, what crystal is mounted on it ? Fast flashing indicates the processor is running faster then the expected 8MHz (expected by the timing routines of the bootloader). Could it be a 16MHz model ?
In that case you could try to upload a sketch at a higher speed: 76K8 baud.
Or you can try to load the bootloader for 16MHz/D13 (which in effect is the standard bootloader of an Arduino).

@GertSanders Soon as i say the fast flashing I instantly thought that its running quicker than needed, but i had no idea about the resetting that you have pointed out, so thanks for pointing that one out. The reason i didn't even bother trying the 16MHz settings in fuses would be that because when i read the fuses of the arduino before i did anything, it indicated that it was running with fuses of 8MHz and the blink sketch was perfectly timed on those settings.... Could it be a miss read on the fuse settings maybe? Should i read at a slower speed when using avrdude?

The crystal is so small on the nano and i can't even see the engraving with a microscope properly either.

I can confirm that the 16MHz bootloader is working perfectly on this nano. Thanks.

I have been running your bootloader for all my nodes now and that works very well.
But there is something that surprised me. When I compile the next sketch and compare that with the Moteino bootloader it's substantially larger.

@DavidZH
Do you also get these differences when compiling for both 16Mhz ? In this case one node is 16MHz (Moteino) and the second is 8MHz.
Apart from that I have no clue why this would result in different sizes.

@Samuel235
Hy
My project is simple atmega328 with internal clock 8 mhz in powerdown mode end rfm69 hw which send to gateway when pir motion is high powered all with 2 aa battery.
The First test what i do is in breadboard atmega328 with optiboot 6.2 ( i have upload bootloader 8mhz internal , 38vk, bod 2v7) and simple sketch j gammon: result no microampere but around 2/5 mah in sleep mode;

@Samuel235
Resolved
I have try with sketc j gammon https://www.gammon.com.au/forum/?id=11497
And the problem are pir input (model hrc-501)
Are ever high and the cpu dont go in sleep.
I have remove pir and all ok the atmega run 20 uah very good.
Can you advise a good pir wich run to 3,3 V for my project?
Tanks

Firstly, i can't read the structure the way you have posted your sketch. You should use the code function in the reply, the icon looks like "</>" above where you make your reply. Put your code in there for us to have any chance of reading it at all.

Secondly, I don't think that this is the place to be posting this issue. For a start, this isn't an issue relevant to the bootloader in this thread and secondly, it doesn't even have anything to do with MySensors.

@mar.conte yes, you can measure consumption (should be in uA) while sleeping with a good voltmeter.

However, I really fail to understand what has Nick's sketch you mentioned to do with MySensors? I suppose some people here may be aware of sleeping issues, but again your problem has nothing to do with MySensors.

@Samuel235
I wanted to build my projects with mysensors, first of all I started with bootloader found in this section to try them with examples that I know because I do not know yet mysensors, I wanted to learn it so I took the liberty to insert code in your section. if you can figure out my problem thank you or I apologize for the trouble thanks

I get why you done it, but i don't understand why. You don't need to 'know' mysensors.... There is a getting started page, i suggest you take a few hours and read through everything. I'm not helping with an issue that is completely not related to mysensors while on the mysensors forum. Just simply for future readers of this thread that come here to solve their issue, if this thread is bloated out with over 10/20 replies that is not related to the question at hand its much harder for them to find their resolution here. I suggest contacting the author of the code himself as i'm pretty sure that your issue is not the bootloader.

Thanks anyway, this section introduced me to some very interesting bootloader, at least with these bootloader I can get a few microamperes for my projects, I will take note of your good day and thank you tips

thx for your quick reply. I could upload the bootloader using ver 1.6.5 of the Arduino IDE. After that I realized ther is already a 1.8.2 version released which is closing the gaps between arduino.cc and arduino.org.
I havent tested this version now, but I guess it was just an IDE error, so everything´s fine now...

I'm probably a rare case but I successfully burn the bootloader (atmel 328p stand alone with slimeNode board) using atmel studio7 with an AVRMK2ISP, flash the mySensors code using arduino IDE and the "nodeManager" libraries succesfully too and everythings appear properly in my HomeAssistant, very nice, I've just give a paypal tips ;o)

But I have no idea why I use this bootloader ??? If I used a nano, I wont change the bootloader ? Is there something better ? It could look stupid but their is no real explain about WHY I must change my bootloader on this page...

Found these bootloaders and using the 1MHz for some low power experiments. I did get this error message when burning the bootloader (using USBASP programmer) :"avrdude: WARNING: invalid value for unused bits in fuse "efuse", should be set to 1 according to datasheet
This behaviour is deprecated and will result in an error in future version
You probably want to use 0xfd instead of 0x05 (double check with your datasheet first)."
The bootloader woas succesfully burned so the message was informational. I did look into this and made the following changes in boards.txt :
I changed all the lines containing "......bootloader.extended_fuses="
There are multiples sections in the file that have these lines.

old value -> new value
0x04 0xFC
0x05 0xFD
0x06 0xFE
0x07 0xFF

I used this site link text
for calculating the new values for the extended fuse.
Now the error message is gone. Maybe this is of any help when using these bootloaders.