Go Down

Topic: Trouble with optiboot @ 20MHz (Read 2309 times) previous topic - next topic

pito

#15
Mar 21, 2013, 04:05 pm Last Edit: Mar 21, 2013, 04:53 pm by pito Reason: 1
fyi - the maximum recommended RX error for double speed mode is 0.5% less than for the normal mode..
PS: I've changed the error calc in the above table based on atmel's equation.
PS1: based on that the following combinations seem to be safe:
20MHz 115k2 DS
16MHz 57k6 DS
8MHz 38k4 N (DS)
4MHz 38k4 DS

mre521

#16
Mar 22, 2013, 10:35 pm Last Edit: Mar 22, 2013, 10:41 pm by mre521 Reason: 1
Hey I just tested uploading blink to the protoboarded avr (20MHz one) using the upload with programmer feature and it works fine. Then I tried the ascii table example and it also is able to send the table properly from the protoboard through the arduino to the computer with serial comms. So this seems to confirm for me that optiboot is what's problematic here.

Edit:
just modified the asciitable sketch to use 115200 baud and it still works with no errors in the output...

westfw

Quote
You probably did not properly modify the optiboot compile for 20MHz.  Could you tell us exactly what you did, and post a log of the compilation step?

mre521

Well I compiled it with this command
Code: [Select]
make atmega328 AVR_FREQ=20000000
in the optiboot (mercurial clone) directory

Output:
Code: [Select]
BAUD RATE CHECK: Desired: 115200, Real: 113636, UBRRL = 21, Error=1.3%
avr-gcc -g -Wall -Os -fno-inline-small-functions -fno-split-wide-types -mshort-calls -mmcu=atmega328p -DF_CPU=20000000  -DBAUD_RATE=115200 -DLED_START_FLASHES=3       -c -o optiboot.o optiboot.c
avr-gcc -g -Wall -Os -fno-inline-small-functions -fno-split-wide-types -mshort-calls -mmcu=atmega328p -DF_CPU=20000000  -DBAUD_RATE=115200 -DLED_START_FLASHES=3     -Wl,--section-start=.text=0x7e00 -Wl,--section-start=.version=0x7ffe -Wl,--relax -Wl,--gc-sections -nostartfiles -nostdlib -o optiboot_atmega328.elf optiboot.o
avr-size optiboot_atmega328.elf
   text    data     bss     dec     hex filename
    482       0       0     482     1e2 optiboot_atmega328.elf
avr-objcopy -j .text -j .data -j .version --set-section-flags .version=alloc,load -O ihex optiboot_atmega328.elf optiboot_atmega328.hex
avr-objdump -h -S optiboot_atmega328.elf > optiboot_atmega328.lst
rm optiboot.o optiboot_atmega328.elf


Then burn it with:
Code: [Select]
make atmega328_isp

The bootloader flashes the 'L' led on reset so the burn worked but upload always fails.
also, boards.txt:
Code: [Select]
##############################################################

atmega328_20.name=atmega328p @ 20MHz
atmega328_20.upload.protocol=arduino
atmega328_20.upload.maximum_size=32256
atmega328_20.upload.speed=115200
atmega328_20.bootloader.low_fuses=0xff
atmega328_20.bootloader.high_fuses=0xde
atmega328_20.bootloader.extended_fuses=0x05
atmega328_20.bootloader.path=optiboot
atmega328_20.bootloader.file=optiboot_atmega328_20MHz.hex
atmega328_20.bootloader.unlock_bits=0x3F
atmega328_20.bootloader.lock_bits=0x0F
atmega328_20.build.mcu=atmega328p
atmega328_20.build.f_cpu=20000000L
atmega328_20.build.core=arduino
atmega328_20.build.variant=standard

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

westfw

Quote
Then burn it with:   make atmega328_isp

Ah.  There's the problem!  The second make will (probably?) re-build from the source, using the default avr_freq value.
Do it all at once:
    make atmega328_isp AVR_FREQ=20000000

I can't decide whether I consider the behavior you found to be a bug in the optiboot makefile, or not.  On the one hand, I'm considering it a feature that the actual compile happens more often; having .hex files sitting around with who-knows-what options compiled in would be dangerous.  On the other hand, having the ISP build undo the option violates the "rule of least surprise."  :-(

mre521

Yay its fixed! Please note though, I could not get the bootloader to flash the chip with a 115200 baud rate:
Code: [Select]
BAUD RATE CHECK: Desired: 115200, Real: 113636, UBRRL = 21, Error=1.3%

If i set the baud rate in boards.txt to 113636 it works fine. So I guess that 1.3% error is just enough for it not to work

Thank you for the help.

side note: I originally modified the optiboot makefile in the arduino distribution to set F_CPU to 20MHz and the built hex did not work either, but it may suffer from the same baud problem.

pito

#21
Mar 24, 2013, 11:18 am Last Edit: Mar 24, 2013, 11:21 am by pito Reason: 1
..did you try with low fuse = F7 ?
..what Xtal capacitor values do you use ?

Go Up