Go Down

Topic: Bootloader for Atmega328p with 1 MHz and internal Osc. for Byttery use (Read 248 times) previous topic - next topic

meddie

Hi together,

i need some help from you. I already used arduino in few small projects. In this time i want to use only an atmega328p as a minimum circuit. Because i want to use this as a window sensor for FHEM Homeautomation.
I would like to flash an arduino optiboot bootloader on the atmega328p which runs with 1 MHz at 9600 bauds. Beacause the atmega should runs with 2 AA Batteries, i would to get him to smalles powerconsume as possible.

Some years ago i flashed some atmega32, but with an parallel isp adapter and ponyprog. Now i dont have a pc with parallel interface and ponyprog dont run with win 10.

I have found a how to flash the atmega with an arduino as isp. Bit i got a failure "invalid signature" if i try to burn the bootloader.
I have found here an thrad but it is 2 yoears old and i dont know, maybe the bootloader is too old for my atmega.
Can you please help me.
The reason why i cant use a arduino nano, is the case for the window sensor has a width 15mm only.
Thynk you very much in advance.
Greets Eddie

westfw

Quote
Bit i got a failure "invalid signature" if i try to burn the bootloader.
You might have to slow down ArduinoISP to burn a bootloader to a 1MHz AVR.

It might be better to set the fuses for 8MHz and use an 8MHz bootloader, and then reduce the clock rate in the sketch initialization instead.  Higher current draw DURING programming shouldn't be an issue...

meddie

You might have to slow down ArduinoISP to burn a bootloader to a 1MHz AVR.
thanks for your answer! Can you tell me how to slow down?

It might be better to set the fuses for 8MHz and use an 8MHz bootloader, and then reduce the clock rate in the sketch initialization instead.  Higher current draw DURING programming shouldn't be an issue...
ok, and if i set the clock to 1 MHz the current will be so small like a bootloader with 1 mhz?

westfw

Quote
Can you tell me how to slow down?
What version of the IDE are you using?  Apparently the arduinoISP sketch has been changed relatively recently (between 1.0.6 and 1.6.7), and the clock should already be slow enough..

Quote
if i set the clock to 1 MHz the current will be so small like a bootloader with 1 mhz?
If you set the fuses for an 8MHz internal clock, and later set the CLKPR register to divide by 8, that should be exactly the same as if you used the fuse to set the divisor to 8.  See  section 9.12.2: CLKPR - Clock Prescale Register

meddie


meddie

YEAH! Thank you very much! I have just now puted the atmega328p into an arduino uno. (i pulled the original controller out)
A second arduino uno i programmed with the isp sketch. Then i tried to burn the bootloader and it worked!
Now i can upload sketches to the atmeg328.

But now i have to set the fuses correctly, can you help me please. What fuses i have to set and with which values? Thank you in advance
Greets Eddie

meddie

OK, now i have the next question.

I have now edited the boards.txt to:
Code: [Select]

##############################################################

atmega328bb.name=ATmega328 on a breadboard (8 MHz internal clock)

atmega328bb.upload.protocol=arduino
atmega328bb.upload.maximum_size=30720
atmega328bb.upload.speed=57600

atmega328bb.bootloader.low_fuses=0xE2
atmega328bb.bootloader.high_fuses=0xDA
atmega328bb.bootloader.extended_fuses=0x05

atmega328bb.bootloader.file=atmega/ATmegaBOOT_168_atmega328_pro_8MHz.hex
atmega328bb.bootloader.unlock_bits=0x3F
atmega328bb.bootloader.lock_bits=0x0F

atmega328bb.build.mcu=atmega328p
atmega328bb.build.f_cpu=8000000L
atmega328bb.build.core=arduino:arduino
atmega328bb.build.variant=arduino:standard


atmega328bb.bootloader.tool=arduino:avrdude
atmega328bb.upload.tool=arduino:avrdude

##############################################################

atmega328_1mhz_4800baud.name=ATmega328 on a breadboard 1MHz internal clock, fast start, 1.8V BOD, 4800baud upload

atmega328_1mhz_4800baud.upload.protocol=arduino
atmega328_1mhz_4800baud.upload.maximum_size=32256
atmega328_1mhz_4800baud.upload.speed=4800

atmega328_1mhz_4800baud.bootloader.low_fuses=0x42
atmega328_1mhz_4800baud.bootloader.high_fuses=0xDE
atmega328_1mhz_4800baud.bootloader.extended_fuses=0x06

atmega328_1mhz_4800baud.bootloader.file=atmega/ATmegaBOOT_168_atmega328_pro_8MHz.hex
atmega328_1mhz_4800baud.bootloader.unlock_bits=0x3F
atmega328_1mhz_4800baud.bootloader.lock_bits=0x2F

atmega328_1mhz_4800baud.build.mcu=atmega328p
atmega328_1mhz_4800baud.build.f_cpu=1000000L
atmega328_1mhz_4800baud.build.core=arduino:arduino
atmega328_1mhz_4800baud.build.variant=arduino:standard


atmega328_1mhz_4800baud.bootloader.tool=arduino:avrdude
atmega328_1mhz_4800baud.upload.tool=arduino:avrdude


When i burn the 8 mhz bootloader, then everything works fine, and i can upload sketches.
But when i burn the second bootloder with fuses for 1mhz the bootloader is burned, and the blink sketch is working because the LED on Pin 13 is blinking but not with 1 second rythm.
But the i cant upload sketches because i get this error
Code: [Select]

avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0xe4
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0xe4
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0xe4
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0xe4
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0xe4
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0xe4
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0xe4
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0xe4
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0xe4
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0xe4
Problem beim Hochladen auf das Board. Hilfestellung dazu unter http://www.arduino.cc/en/Guide/Troubleshooting#upload.


Can you help me please one more time
Thank you

westfw

Code: [Select]
atmega328_1mhz_4800baud.bootloader.low_fuses=0x42
atmega328_1mhz_4800baud.bootloader.high_fuses=0xDE
atmega328_1mhz_4800baud.bootloader.extended_fuses=0x06

atmega328_1mhz_4800baud.bootloader.file=atmega/ATmegaBOOT_168_atmega328_pro_8MHz.hex


I think you have fuses for Optiboot, but the old bootloader .hex file.
I use http://www.engbedded.com/fusecalc



meddie

i have downloaded here :
https://github.com/Optiboot/optiboot/tree/master/optiboot/bootloaders/optiboot

the new optiboot hex file:
optiboot_atmega328_pro_8MHz.hex

But now i cant burn the bootloader and get this error:
avrdude: ERROR: No valid record found in Intel Hex file


hansibull

First you'll need to build a 1MHz version of Optiboot. When you build, you define the baud rate (4800 baud is fine).
Code: [Select]
make atmega328p AVR_FREQ=1000000L BAUD_RATE=4800

 Then you'll have to edit the boards.txt file, and set the correct fuses before you can upload a sketch using a USB to serial adapter
MightyCore -  ATmega1284p, ATmega644p, ATmega324p, ATmega164p, ATmega32, ATmega16 and ATmega8535.
https://github.com/MCUdude/MightyCore

MegaCore - ATmega64 and ATmega128.
https://github.com/MCUdude/MegaCore

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy