Pages: 1 [2]   Go Down
Author Topic: Trouble with optiboot @ 20MHz  (Read 1799 times)
0 Members and 1 Guest are viewing this topic.
Rapa Nui
Offline Offline
Edison Member
*
Karma: 60
Posts: 2066
Pukao hats cleaning services
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
« Last Edit: March 21, 2013, 10:53:28 am by pito » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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...
« Last Edit: March 22, 2013, 04:41:00 pm by mre521 » Logged

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 124
Posts: 6654
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Output:
Code:
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:
make atmega328_isp

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

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

##############################################################
Logged

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 124
Posts: 6654
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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."  :-(
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yay its fixed! Please note though, I could not get the bootloader to flash the chip with a 115200 baud rate:
Code:
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.
Logged

Rapa Nui
Offline Offline
Edison Member
*
Karma: 60
Posts: 2066
Pukao hats cleaning services
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

..did you try with low fuse = F7 ?
..what Xtal capacitor values do you use ?
« Last Edit: March 24, 2013, 05:21:15 am by pito » Logged

Pages: 1 [2]   Go Up
Jump to: