4MHz bootloaders



  • Hi all,
    I would like to ask you about 4MHz bootloaders for ATMEGA328P. I make a project where I want to use ATMEGA328P running on 4MHz with external oscilator. Is there any possibility how to convert bootloaders to 4MHz? Or are there any already created? Currently I was using mostly APM Optiboot internal 1MHz noBOD 9600 BAUD bootloader. Would be there possibility to convert it to 4MHz external?

    Here is info about the APM Optiboot bootloader if needed.

    But anyway, it can be any other bootloader which would be converted to 4MHz.

    Thanks.


  • Mod

    Why do you need a 4mhz node?



  • For me it looks like the best solution when I want to run the node for 2AA batteries without power regulator. As the spec of ATMEGA328P is that with 4MHz it can run from 1.8V. Which is exactely 2AA NiMH bateries at the end of the capacity. Then I also do not want to use 1MHz internal oscilator as it makes sometimes troubles when serial communication is used. So that is the reason for 4MHz node.


  • Mod

    It is not the solution to your problem, but I found that a single LiFePO4 AA battery is great for powering 3.3v pro mini without any regulator



  • You are right it looks like a good solution for such project. But I wanted to keep the project running on AA NiMH bateries as for me it is safe way let's say ☺ As I do not have any experiences with LiFePO4 and also no charger for them. But I should start focus also on such power supply in the future. Anyway, like you said it is a bit different topic ☺ but thanks anyway for your reply.


  • Admin

    @boylucky

    Do you need the serial port when running on batteries? Or is it only when uploading a new sketch?

    Also, is it a sleeping node? (it must be, when you want to run it on batteries). Then in theory 8Mhz consumes less power than 1Mhz on an average over time.. This is because when they are sleeping they are using the samme power, regardless of oscillator settings. However, when awake, a 8Mhz performs it's operations faster than a 1Mhz node, and returns to sleep (and low power consumption) 8 times as fast, than a 1Mhz node.

    I have 5 nodes that have been running on the same set of 2xAA batteries for 2½ years now.. They wake up every minute to take a new sample of temperature/humidity, and only transmitting if the new sample differs from the previous sample. they are operating on the 8Mhz internal rc-oscillator.



  • Yes, I need the serial communication also during the operation of the chip. That is the reason why I want to switch to 4MHz. The node is in sleep mode for 8 seconds. Then it wake up for 500ms to listen if any communication is received on NRF24L01+. Then also every 15 minutes, the node is transfering received data from NRF24 to Sigfox backend (6 sensors values in one message) via LoRa module. Currently I tested 11 days running on 1MHz without problem. The voltage drop after this 11 days is about 0,3V. So on 2AA NiMH bateries it should last for about 1 month without bateries charging. There is required serial communication between ATMEGA328P and Sigfox. That is the reason for 4MHz.


  • Admin

    @boylucky

    I think that you should make a calculation of the power requirements, For example the NRF24 uses around 14mA in listen mode, so waking it up for 500 mili seconds, every 8 seconds, will take a toll on your battery capacity, if you only use 2xAA batteries.



  • Actually the capacitance of the battery is not a problem for now. The time of wake up intervals and listen period can be changed. What I need to solve is the 4MHz bootloader.



  • Looks I succeed. I had to change the LOW fuses to correct value. I modified the APM Optiboot bootloader to accept 4MHz external oscilator. Here is the correct settings which need to be add to the boards.txt file:

    ##############################################################
    
    apm96_4MHz.name=APM Optiboot external 4MHz noBOD 38400baud
    
    apm96_4MHz.upload.tool=avrdude
    apm96_4MHz.upload.protocol=arduino
    apm96_4MHz.upload.maximum_size=32256
    apm96_4MHz.upload.speed=38400
    apm96_4MHz.bootloader.tool=avrdude
    apm96_4MHz.bootloader.low_fuses=0xfd
    apm96_4MHz.bootloader.high_fuses=0xde
    apm96_4MHz.bootloader.extended_fuses=0x07
    apm96_4MHz.bootloader.path=optiboot_v50
    apm96_4MHz.bootloader.file=atmega328_1a_4MHz.hex
    apm96_4MHz.bootloader.unlock_bits=0x3F
    apm96_4MHz.bootloader.lock_bits=0x2F
    apm96_4MHz.build.mcu=atmega328p
    apm96_4MHz.build.f_cpu=4000000L
    apm96_4MHz.build.core=arduino
    apm96_4MHz.build.variant=standard
    
    ##############################################################
    

    I had to change following lines:
    apm96_4MHz.upload.speed=38400
    apm96_4MHz.bootloader.low_fuses=0xfd
    apm96_4MHz.build.f_cpu=4000000L

    I also changed the file name to: apm96_4MHz.bootloader.file=atmega328_1a_4MHz.hex but the file is exactely the same as the original one. I also changed the name in the beginning of each line.

    Currently looks it is working well. I will add more info later if all runs ok after some testing.

    And here is also nice FUSES configurator.



  • @boylucky Thank you a lot, you described the changes nicely. Only one question -> you use atmega328_1a_4MHz.hex file. Where does this file came from? Did you just copy and rename one of the .hex files? What need to be change in this hex file or how to make one?


Log in to reply
 

Suggested Topics

  • 1
  • 2
  • 1
  • 1
  • 5
  • 2

48
Online

11.4k
Users

11.1k
Topics

112.6k
Posts