💬 Various bootloader files based on Optiboot 6.2



  • @GertSanders

    I did a short video how I upload optiboot

    Finally, success!
    I think I had to reassemble the breadboard set-up three times before finally being able to upload the sketch. I think the problem was no connection at RTS, but I am not sure. I need to assemble a more permanent board to upload sketches via FTDI.



  • FTDI Adapter



  • My Set-up



  • @GertSanders if I load a sketch via Upload using programmer - how do I control the frequency? (1Mhz or 8Mhz internal or external crystal)


  • Hardware Contributor

    @alexsh1 - You would do this by setting the correct fuses. Can you just confirm my information @GertSanders 🙂

    I would also like to state that Atmel does not support or even recommend using FTDI with the internal crystal, my current board just will not upload via FTDI and no external crystal however yet a arduino pro mini does and that uses an external crystal with no other circuitry compared to my board apart from the physical reset switch.



  • @samuel235 said:

    @alexsh1 - You would do this by setting the correct fuses. Can you just confirm my information @GertSanders 🙂

    I think you have a point, but if I do not change anything, just use "Upload using programmer", what are the default frequency and fuses?


  • Hardware Contributor

    @alexsh1 If you haven't touched the ATmega328p then it should be sitting with fuses of; L:0x62 H:0xD9 E:0xFF, which would run the uC at 1MHz


  • Hardware Contributor

    @*alexsh1
    *
    Which fuses are set when loading a boot loader is defined by wich menu element in tools you have selected. Every processor or board you choose will correspond with values in a board.txt file.

    You can have several board.txt files: 1 file per "family" of boards.

    When uploading sketches, the fusesettings are ignored, only the uploadspeed counts then. Both when uploading with Arduino as ISP as with FTDI interface.

    The internal oscillator of 8 Mhz is not as accurate as a crystal, so at higher uploadspeeds the errorrate can increase or decrease depending on the mcu temperature.

    Some uploadspeeds are closer to optimal then others in relation to the frequency at which the mcu works. The baudcalculator shows the errorrates. Most are non optimal. avrdude can handle an errorrate of 2% or less. So using a specific baudrate in combination with the internal 8Mhz oscillator depends on the worst case combination of transmission errorrate plus clock deviation error.

    For most mcu's the rate of 9600 baud will be acceptable because at that slow rate a clockerror will be relative small. At higher speeds the small clockerror becomes more important. Then it is best to choose an upload speed close to the optimum.

    The fusesettings are only burnt when loading a boot loader (within the Arduino IDE, in AVRStudio you can set fuses seperatly from loading anything).

    The frequency of 8 Mhz can be obtained via a 8mhz crystal or the internal 8mhz oscillator. The low fuse value 0xE2 sets this internal oscillator. By using value 0x62 you also set the clock division bit in combination with the 8mhz internal oscillator, so your mcu will run at 8mhz / 8 = 1mhz

    There are other division values possible. Calculate the low byte value using an avr fuse calculator.

    You can also use an external 8 mhz crystal, and combine this with clock division by 8 to get 1mhz operation.

    And you can choose an external 1mhz crystal.

    All this from choose the right fuse bits.

    Same for Brown out Detection which is set via the three least significant bits of the extended fuse.



  • @samuel235 This is strange. The serial monitor was working only on 74880 - I do not think the AVR was running @ 1Mhz



  • @GertSanders Thanks for a detailed write-up!

    @GertSanders said:

    You can also use an external 8 mhz crystal, and combine this with clock division by 8 to get 1mhz operation.

    And you can choose an external 1mhz crystal.

    How is this influencing low power though? My understanding is that such setup (external crystal) takes more power.


  • Hardware Contributor

    @alexsh1

    Using a 1mhz crystal would not be the best thing for low power use, you are correct there.

    But it gives a more accurate clock base for the timing functions.



  • Not sure what happened, but the following error returned:

    
    
    
    
    Board atmega328p:avr:atmega328pO5M8c doesn't define a 'build.board' preference. Auto-set to: AVR_ATMEGA328PO5M8C
    Board atmega328p:avr:atmega328pO5M16c doesn't define a 'build.board' preference. Auto-set to: AVR_ATMEGA328PO5M16C
    

    I did not change anything so very strange why it comes up.


  • Hardware Contributor

    Actually, i have no proof but i've been informed from the arduino standalone microcontroller forums, that using a external 8mhz crystal is good for power consumption. ONLY if its a sleeping module though, it enables it to perform its tasks quicker and then sleep quicker, resulting in more time sleeping.

    That error code is something i ran into, i'm guessing you're working inside of arduino IDE, if so its to do with your boards.txt entry. Its missing that entry that it speak about. Check that its there, if not enter it in manually.



  • @samuel235

    Thanks - yes you are right it is about boards.txt.
    However, the problem is that I did not change anything. Two days ago I uploaded severa sketches and no errors were coming up and now two different boards are showing the same error. This is just odd...


  • Hardware Contributor

    @alexsh1, have you performed an Arduino IDE update? I had this exact issue simply because I updated my IDE.


  • Hardware Contributor

    This message pops up since IDE 1.6.7
    The new IDE expects this entry for all boards, just add it or ignore (it's more a warning then an error).


  • Hardware Contributor

    And there you go, the forever informative @GertSanders has andwered your questioning 😉



  • @samuel235 Looks like you are right - without realising I did press update button thinking about a sketch rather than about the update 😞

    Corrected this issue aleady in the boards.txt



  • @GertSanders Hello ! I am trying to upload a sketch without success for the moment.

    Burning of the bootloader was done correctly (led on pin 8 lit three times) but impossible to load a sketch.

    For easy deployment I choose to create a new folder to include your bootloaders:

    0_1458389134219_2016-03-19 13.05.30.png

    But it seems that something is missing as upload is not possible:

    Le croquis utilise 1 030 octets (3%) de l'espace de stockage de programmes. Le maximum est de 32 256 octets.
    Les variables globales utilisent 9 octets (0%) de mémoire dynamique, ce qui laisse 2 039 octets pour les variables locales. Le maximum est de 2 048 octets.
    /Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avrdude -C/Applications/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf -v -patmega328p -carduino -P/dev/cu.usbmodem1411 -b38400 -D -Uflash:w:/var/folders/2y/_n7gfzjx5_sgmtyh9t_lp0wc0000gn/T/build8919458311701309495.tmp/Blink.cpp.hex:i 
    
    avrdude: Version 6.0.1, compiled on Apr 14 2015 at 16:30:25
             Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
             Copyright (c) 2007-2009 Joerg Wunsch
    
             System wide configuration file is "/Applications/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf"
             User configuration file is "/Users/carlierd/.avrduderc"
             User configuration file does not exist or is not a regular file, skipping
    
             Using Port                    : /dev/cu.usbmodem1411
             Using Programmer              : arduino
             Overriding Baud Rate          : 38400
    avrdude: ser_open(): can't open device "/dev/cu.usbmodem1411": No such file or directory
    ioctl("TIOCMGET"): Inappropriate ioctl for device
    
    avrdude done.  Thank you.
    
    Problème de téléversement vers la carte. Voir http://www.arduino.cc/en/Guide/Troubleshooting#upload pour suggestions.
    

    Any suggestion ?

    David.


  • Hardware Contributor

    @carlierd
    I am almost certain that you are NOT using my boards.txt because you put the bootloaders outside the reach of the IDE (must be in the sketchfolder and within the hardware subfolder of the sketches folder).



  • @GertSanders
    No doubt that I using your file as I got the same problem as @alexsh1 with the arduino pin file.

    Look at my board choice:

    0_1458392127846_2016-03-19 13.53.48.png

    I find this method very good for deployment but only when it's working 😉

    I check the bootloader with Nick Gammon sketch and it seems good.
    David.



  • I burn the bootloader one more time and now I can upload without any change on configuration.

    Perhaps I made a mistake the first time 🙂

    I will continue my test.

    David.



  • @GertSanders One more question on the LED connected on B0.

    When you wrote that the LED lit on arduino reset, it's when the reset button is pushed ? when the arduino start ? or both ?

    David.


  • Hardware Contributor

    @carlierd

    When the atmega328 is reset, the LED will flash three times if the boot loader is in memory. This also happens when you send a new sketch via the Arduino IDE to the atmega328.

    So if you connect pin 1 shortly to GND, the led should flash.

    The first time you load a boot loader, the atmega328 will "loop" between the startup procedure of the boot loader (and will flash the led), and then try to load the sketch. If there never is a sketch, it will start the boot loader again and again ...



  • @GertSanders

    So it confirms that your bootloader was correctly burnt in the atmega as the first time I failed to upload a sketch the LED flash three time again and again !
    Thanks !

    David.



  • Hello,

    I tested two bootloaders today:

    • optiboot_atmega328_08M_038400_B0.hex
    • optiboot_atmega328_01M_009600_B0.hex

    But I am pretty sure you already tested them.

    I got some issue with 1MHz bootloader but probably because I am using signing feature.
    I will check the forum to be sure.

    David.


  • Hardware Contributor

    @carlierd
    Indeed I am using these two boot loaders already. The 1Mhz in my very slim nodes and the 8Mhz in the red board battery based nodes.
    I also use the 16Mhz in my AC based board (as a repeater or as SMS gateway).
    I will make an AC board with a 20Mhz crystal just to test the faster versions of the bootloader.



  • @GertSanders

    Hello, as I got some issue with the 1MHz bootloader, I tried without the signing feature and I still got st=fail.

    One question for you, perhaps stupid but I need to be sure 😉
    Do you need to set the same serial speed on both node and gateway ?

    David.


  • Hardware Contributor

    @carlierd
    No, the serial speed is not something relevant for the radio communication.
    When I compile the boot loader, I just need to choose the CPU frequency and make sure I also choose an upload speed which is compatible with that CPU frequency. Some combinations of CPU frequency and upload speed give errors and the error rate of the serial upload communication can not be above 2% or AVRDUDE will fail.
    For node to gateway communication (and your ST=FAIL errors) this is not relevant.
    ST=FAIL errors can (in my case) be reduced by lowering the power output of the radio on the node (is default set to MAX, I put it mostly to HIGH).
    st=fail errors can also be the result of poor power to the radio.



  • @GertSanders said:

    ST=FAIL errors can (in my case) be reduced by lowering the power output of the radio on the node (is default set to MAX, I put it mostly to HIGH).
    st=fail errors can also be the result of poor power to the radio.

    Or just a bad radio. There is a huge thread on the forum about fake radio modules.
    I have gone through quite a few - what a waste of time....



  • I am using RFM69. No fake as it's working perfectly at other frequency.

    @GertSanders
    I tried three different configurations:

    • 16 MHz with crystal
    • 8 MHz internal
    • 1 MHz internal (with some st=fail)

    I measured power consumption in sleep mode and found that it's very close to 4uA with all configurations. So why using the 1 MHz ? Do you have better consumption when using 1 MHz ?

    The best configuration for me will be the 8 MHz internal as it avoid to used the crystal.

    David.


  • Hardware Contributor

    @carlierd
    In sleep mode it does not matter which frequency is used. The watchdog timer runs off its own clock and that is the same for all three cases. The fact that you get around 4 uA is just because you still have a watchdogtimer running. With full deep sleep and complete shutdown of the radio we should see 1-2 uA if external pullup of more then 2MOhm is used.
    The mcu frequency is important for the active time. Higher frequency means faster startup and faster completion of tasks.
    8Mhz is a good compromise as the internal oscillator is less powerhungry then fullswing crystal.
    And you need less parts.


  • Hardware Contributor

    @carlierd, all that i can say is; do not rely on serial communication working. I'm running my custom made node on 8MHz internal, can use the serial monitor but i can not upload via serial. Only ISP uploads using programmer.


  • Hardware Contributor

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


  • Hardware Contributor

    @GertSanders said:

    @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.


  • Hardware Contributor

    @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.


  • Hardware Contributor

    @GertSanders, i did do, that's the latest solution i tried. No joy.



  • @GertSanders Thanks for explanation. It confirms what I imagine !

    I am using a 10MOhm resistor but not the full deep sleep as I want to periodically send the battery.
    I will try it because 1-2 uA is very low 😉



  • @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.


  • Hardware Contributor

    @Samuel235
    Would you want to try a bootloader with an upload speed of 4800 ? I can make that for 8Mhz if you want (just to test)?


  • Hardware Contributor

    @GertSanders, that would be fantastic if you wouldn't mind. Its for my in wall light switch custom made node that you're following. Thanks you, much appreciated.


  • Hardware Contributor

    @Samuel235

    here is the boot loader in 2 versions: one will flash port PB0 and the other does not.

    You need to use the following fuse settings in the board file:

    bootloader.low_fuses=0xE2
    bootloader.high_fuses=0xDE
    bootloader.extended_fuses=0x06

    1_1458903521561_optiboot_atmega328_08M_004800_NOLED.hex

    0_1458903521561_optiboot_atmega328_08M_004800_B0.hex

    I saw that you use high fuse 0xDA

    I'm assuming you use a boot loader larger then 512 bytes. Optiboot fits inside 512 bytes, so we need to define a space of 256 words (1 word = 2 bytes in AVR 8bit).


  • Hardware Contributor

    @Samuel235

    For my boot loaders based on Optiboot 6.2, I normally use high fuse set to 0xDE

    Extract from my boards.txt file:

    menu.mhz=CPU Speed
    menu.bod=Brown Out Detection

    28PinBoard.name=atmega328p based - 28 pin DIL

    28PinBoard.upload.tool=arduino:avrdude
    28PinBoard.upload.protocol=arduino
    28PinBoard.upload.maximum_size=32256
    28PinBoard.upload.maximum_data_size=2048

    28PinBoard.bootloader.tool=arduino:avrdude

    28PinBoard.bootloader.unlock_bits=0x3F
    28PinBoard.bootloader.lock_bits=0x0F

    28PinBoard.build.core=arduino:arduino
    28PinBoard.build.mcu=atmega328p

    28PinBoard.build.board=AVR_GERTSANDERS28PinBoard
    28PinBoard.build.variant=28PinBoard

    28PinBoard.menu.bod.4v3=4V3
    28PinBoard.menu.bod.4v3.bootloader.extended_fuses=0x04
    28PinBoard.menu.bod.2v7=2V7
    28PinBoard.menu.bod.2v7.bootloader.extended_fuses=0x05
    28PinBoard.menu.bod.1v8=1V8
    28PinBoard.menu.bod.1v8.bootloader.extended_fuses=0x06
    28PinBoard.menu.bod.off=Disabled
    28PinBoard.menu.bod.off.bootloader.extended_fuses=0x07

    28PinBoard.menu.mhz.8Mi-38K4-D8= 8Mhz - internal - 38K4 - D8
    28PinBoard.menu.mhz.8Mi-38K4-D8.bootloader.low_fuses=0xE2
    28PinBoard.menu.mhz.8Mi-38K4-D8.bootloader.high_fuses=0xDE
    28PinBoard.menu.mhz.8Mi-38K4-D8.build.f_cpu=8000000L
    28PinBoard.menu.mhz.8Mi-38K4-D8.upload.speed=38400
    28PinBoard.menu.mhz.8Mi-38K4-D8.bootloader.file=myoptiboot/optiboot_atmega328_08M_038400_B0.hex


  • Hardware Contributor

    @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 Hello. I tried the full deep sleep and it's really amazing !

    I used your 8MHz with internal crystal and B0 led, BOD disabled. RFM69 for radio and just a switch via a 10MOhm resistor.
    With the switch open: 280nA
    With the switch close: 580nA

    Measures done with a uCurrent Gold.
    So I am sure now that I found the good bootloader for my application. It's simple to install and I can change easily the BOD !
    Thanks !


  • Hardware Contributor

    @carlierd
    Great to hear those low consumption numbers.



  • @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.

    David.


  • Hardware Contributor

    @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;

    bootloader.low_fuses=0xE2
    bootloader.high_fuses=0xDE
    bootloader.extended_fuses=0x06
    

    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.

    I'll be honest, i'm a little confused.


  • Hardware Contributor

    @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 ???


  • Hardware Contributor

    @GertSanders

    Here is the process i have gone through so far:

    1. Soldered the MCU in place.
    2. Soldered the ISP and FTDI header in place.
    3. Soldered the Capacitors and resistor in place.
    4. Connected the board to PC through ISP.
    5. Checked for continuity through-out the board on all ISP header Pins and corresponding MCU pins.
    6. Check for correct voltage on all of the VCC and GND points.
    7. Ran a fuse check on AVRDUDE and got back all the default fuses.
    8. Checked that your fuses were going to be okay with my board using the fuse calculator.
    9. Entered your suggested fuse settings into AVRDUDE and burned.
    10. Went to read the fuses (like i always do after burning them to double check they have been applied). Got no answer for the device.
    11. Disconnected and connected the board back and read fuses over and over again with no hope with all of the speed options available within AVRDUDESS.
    12. Connected a 8MHz external crystal and checked for fuse readings yet again, nothing.
    13. Came here to see if you have any idea what has happened.

    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".


  • Hardware Contributor

    @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


  • Hardware Contributor

    @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 will attempt this tomorrow if so.


  • Hardware Contributor

    @Samuel235
    I just checked the avr calculator.
    The extended fuse is FE for a BOD at 1.8V
    Low E2 means internal oscillator. So that should be OK.

    I always use an arduino as ISP programmer when loading a bootloader onto a blank atmega328.

    Tomorrow I will also test a new board with the AU variant (smd) of the mcu. Should be similar to your setup.


  • Hardware Contributor

    Just to keep you updated on the situation @GertSanders;

    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;

    ##############################################################
    ##                        GERTSANDERS                       ##
    ##############################################################
    
    menu.mhz=CPU Speed
    menu.bod=Brown Out Detection
    
    28PinBoard.name=atmega328p based - 28 pin DIL
    
    28PinBoard.upload.tool=arduino:avrdude
    28PinBoard.upload.protocol=arduino
    28PinBoard.upload.maximum_size=32256
    28PinBoard.upload.maximum_data_size=2048
    
    28PinBoard.bootloader.tool=arduino:avrdude
    
    28PinBoard.bootloader.unlock_bits=0x3F
    28PinBoard.bootloader.lock_bits=0x0F
    
    28PinBoard.build.core=arduino:arduino
    28PinBoard.build.mcu=atmega328p
    
    28PinBoard.build.board=AVR_GERTSANDERS28PinBoard
    28PinBoard.build.variant=28PinBoard
    
    28PinBoard.menu.bod.4v3=4V3
    28PinBoard.menu.bod.4v3.bootloader.extended_fuses=0x04
    28PinBoard.menu.bod.2v7=2V7
    28PinBoard.menu.bod.2v7.bootloader.extended_fuses=0x05
    28PinBoard.menu.bod.1v8=1V8
    28PinBoard.menu.bod.1v8.bootloader.extended_fuses=0x06
    28PinBoard.menu.bod.off=Disabled
    28PinBoard.menu.bod.off.bootloader.extended_fuses=0x07
    
    28PinBoard.menu.mhz.8Mi-38K4-D8= 8Mhz - internal - 38K4 - D8
    28PinBoard.menu.mhz.8Mi-38K4-D8.bootloader.low_fuses=0xE2
    28PinBoard.menu.mhz.8Mi-38K4-D8.bootloader.high_fuses=0xDE
    28PinBoard.menu.mhz.8Mi-38K4-D8.build.f_cpu=8000000L
    28PinBoard.menu.mhz.8Mi-38K4-D8.upload.speed=4800
    28PinBoard.menu.mhz.8Mi-38K4-D8.bootloader.file=gertsoptiboot/optiboot_atmega328_08m_004800_noled.hex
    

    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?


  • Hardware Contributor

    @Samuel235

    So here is my update: on my board I was able to upload my boot loader for 8MHz internal oscillator, with 34K8 upload speed and a led on pin D8. Here is the board running the "blink" sketch:

    0_1460809876803_Screen Shot 2016-04-16 at 14.26.47.jpg

    To make life easier I have zipped my complete folder, which I keep under the "hardware" folder in the sketches folder:

    0_1460809951141_atmega328p.zip

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

    0_1460810124544_IMG_7912.jpg

    Then I choose the following settings in the Arduino IDE:

    0_1460810237368_Screen Shot 2016-04-16 at 14.36.25.jpg

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


  • Hardware Contributor

    @GertSanders I will test this as we speak! May I ask if there is a difference between your DIL and TQFP entries in your boards.txt?


  • Hardware Contributor

    @Samuel235

    In the boards.txt you will see additional entries for the 32 pin version. These are basically a repeat of all the inputs for the 28 pin version.

    So yes, there is a difference in the boards.txt file, but the boot loaders remain the same.


  • Hardware Contributor

    @GertSanders I'm sorry, I didn't look inside of the folder your provided before i asked that question.


  • Hardware Contributor

    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:

    ##############################################################
    ##                        GERTSANDERS                       ##
    ##############################################################
    
    menu.mhz=CPU Speed
    menu.bod=Brown Out Detection
    
    28PinBoard.name=atmega328p based - 28 pin DIL
    
    28PinBoard.upload.tool=arduino:avrdude
    28PinBoard.upload.protocol=arduino
    28PinBoard.upload.maximum_size=32256
    28PinBoard.upload.maximum_data_size=2048
    
    28PinBoard.bootloader.tool=arduino:avrdude
    
    28PinBoard.bootloader.unlock_bits=0x3F
    28PinBoard.bootloader.lock_bits=0x0F
    
    28PinBoard.build.core=arduino:arduino
    28PinBoard.build.mcu=atmega328p
    
    28PinBoard.build.board=AVR_GERTSANDERS28PinBoard
    28PinBoard.build.variant=28PinBoard
    
    28PinBoard.menu.bod.4v3=4V3
    28PinBoard.menu.bod.4v3.bootloader.extended_fuses=0x04
    28PinBoard.menu.bod.2v7=2V7
    28PinBoard.menu.bod.2v7.bootloader.extended_fuses=0x05
    28PinBoard.menu.bod.1v8=1V8
    28PinBoard.menu.bod.1v8.bootloader.extended_fuses=0x06
    28PinBoard.menu.bod.off=Disabled
    28PinBoard.menu.bod.off.bootloader.extended_fuses=0x07
    
    28PinBoard.menu.mhz.8Mi-38K4-D8= 8Mhz - internal - 4K8 - D8
    28PinBoard.menu.mhz.8Mi-38K4-D8.bootloader.low_fuses=0xE2
    28PinBoard.menu.mhz.8Mi-38K4-D8.bootloader.high_fuses=0xDE
    28PinBoard.menu.mhz.8Mi-38K4-D8.build.f_cpu=8000000L
    28PinBoard.menu.mhz.8Mi-38K4-D8.upload.speed=4800
    28PinBoard.menu.mhz.8Mi-38K4-D8.bootloader.file=gertsoptiboot/optiboot_atmega328_08m_004800_noled.hex
    

    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.

    Thank you once again 🙂



  • 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?


  • Hardware Contributor

    @bjacobse

    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.


  • Hardware Contributor

    @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.


  • Hardware Contributor

    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?


  • Hardware Contributor

    @Samuel235
    I see no reason for not using it. The fact that you do not need the led, make no difference in the actual work of the boot loader.


  • Hardware Contributor

    @bjacobse

    Just to be clear for me: did you try to upload a 1Mhz bootloader and then try to send a sketch via FTDI to the same 1Mhz boot loader, and this fails ?


  • Hardware Contributor

    @GertSanders said:

    @Samuel235
    I see no reason for not using it. The fact that you do not need the led, make no difference in the actual work of the boot loader.

    Thank you!



  • 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...


  • Hardware Contributor

    @bjacobse
    Strange, I'm using the 1mhz with 9600 upload on 2 narrow nodes. I will investigate tomorrow.



  • @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?


  • Hardware Contributor

    @bjacobse

    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.



  • @GertSanders
    Thank you Gert for checking with Arduino Pro Mini 8Mhz 3V3.
    Then I will try with windows laptop, different FTDI and another cable. something in my current setup is behaving weird



  • 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 🙂

    False error messages from Arduino 1.6.8...

    WARNING: Category '' in library UIPEthernet is not valid. Setting to 'Uncategorized'
    
    Sketch uses 1,060 bytes (3%) of program storage space. Maximum is 32,256 bytes.
    Global variables use 9 bytes (0%) of dynamic memory, leaving 2,039 bytes for local variables. Maximum is 2,048 bytes.
    avrdude: stk500_recv(): programmer is not responding
    Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.
    

    Now I have to try to verify if my Ubuntu can flash bootloader with tinyUSB



  • 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



  • when I run the below command in Ubuntu I can flash the bootloader

    sudo avrdude -c usbtiny -p m328p -U flash:w:optiboot_atmega328_01M_009600_NOLED.hex  -U lfuse:w:0x62:m -U hfuse:w:0xDE:m -U efuse:w:0x07:m
    
    

    And then I can use the Arduino IDE and upload sketch with settings for 1MHz external 9k6 BOD=1V8


  • Hardware Contributor

    @bjacobse
    Efuse 0x07 actually means no Brown Out Detection. Should save you some nano Amperes during operation.



  • @GertSanders

    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?


  • Hardware Contributor



  • @GertSanders Okey, thanks so In my understanding, that takes care of the fuses also.


  • Hardware Contributor

    @msebbe

    It does if the board definitions are set right. Check out the tutorial to understand how it works, then you should know how to adapt to other boot loaders (like mine).



  • @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?


  • Hardware Contributor

    @msebbe

    Drop this ZIP (unpack it there) into your "hardware" directory. You should find a "hardware" directory in the Sketches directory, then restart the Arduino IDE.

    It should find a complete set of boot loaders for the 28 pin and 32 pin versions.

    0_1463253058014_atmega328p.zip

    You will need to check that the directory is unpacked with all subdirectories. The directory name will be "atmega328p".



  • @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.


  • Hardware Contributor

    @alexsh1

    Indeed, the internal oscillator on some atmega328's is a bit off from 8MHz and enough so that higher speed transmission of sketches can give a problem.



  • @GertSanders thanks for this bootloader pack. After one day of trying I was still unable to upload scetches to atmega burned with bootloader 8Mhz image to atmeg328 - 28 pin DIL from this: https://forum.mysensors.org/topic/3018/tutorial-how-to-burn-1mhz-8mhz-bootloader-using-arduino-ide-1-6-5-r5/1 tutorial.
    With your 0_1463253058014_atmega328p.zip pack unzipped to "hardware" directory worked like a charm.



  • @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?


  • Hardware Contributor

    @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
    No worries! It just caught my eye and was wondering. I'll keep an eye on this as I'm finalising my node network and have to choose a bootloader about now.


  • Admin

    @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!


  • Admin

    @petewill,

    The site will still unpack zips and extract the content. I could disable this, but it would make it harder to upload large projects.

    Like @GertSanders propose, allowing (and not uppacking) rar-files might be a better solution.


  • Admin

    Ok... rar and gz files is now allowed. They will be categorised as "design" files.


  • Hardware Contributor

    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.

    My directory structure looks like this:

    [Arduino]
       [hardware]
          [atmega328p]
             [avr]
                [bootloaders]
                   [myoptiboot]
                      ... all the HEX files ...
                [variants]
                   [28PinBoard]
                      pins_arduino.h
                   [32PinBoard]
                      pins_arduino.h
                   [40PinBoard]
                      pins_arduino.h
                   [44PinBoard]
                      pins_arduino.h
                boards.txt
                platform.txt
    

  • Hardware Contributor

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

    Is this correct or do we merge them?


  • Admin

    @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:
    0_1486996741780_upload-d2b37622-9cf3-4539-9cb1-6f9ab39f1cf3
    After closing/re-opening the Arduino IDE it looks like this:
    0_1486996924662_upload-3cf12bfa-0444-4cd7-8a19-537fdf63a738


  • Hardware Contributor

    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.


  • Hardware Contributor

    @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


  • Hardware Contributor

    This post is deleted!

  • Hardware Contributor

    I'm slightly confused here...

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


  • Hardware Contributor

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


  • Hardware Contributor

    @Samuel235
    It also seems the nano is in a reset loop. I'm at work so I can not check my Mac for the fuse settings I use.


  • Hardware Contributor

    @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.


Log in to reply
 

Suggested Topics

13
Online

11.4k
Users

11.1k
Topics

112.7k
Posts