[ Main Page ]

Arduinoを20MHzで動かす

通常のArduinoは、後方互換性のために16MHzまたは8MHz(3.3V)での駆動となっているが、場合によっては最高速度で駆動 させたいこともある。その場合は、20MHz用のファームウエアに書き換える必要がある。

optiboot

Arduino用のブートローダは、IDEに同梱のバージョン(4.4)と、修正が加えられたバージョン(6.2)があり、後者はgithubで入手できる。

前者は特に追加のファイルは必要なくビルド出来る。

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Windows\system32>cd "C:\Program Files (x86)\Arduino\hardware\arduino\bootloaders\optiboot"

C:\Program Files (x86)\Arduino\hardware\arduino\bootloaders\optiboot>omake clean

C:\Program Files (x86)\Arduino\hardware\arduino\bootloaders\optiboot>..\..\..\tools\avr\utils\bin\make OS=windows ENV=arduino clean
rm -rf *.o *.elf *.lst *.map *.sym *.lss *.eep *.srec *.bin *.hex

C:\Program Files (x86)\Arduino\hardware\arduino\bootloaders\optiboot>omake AVR_FREQ=20000000L atmega328

C:\Program Files (x86)\Arduino\hardware\arduino\bootloaders\optiboot>..\..\..\tools\avr\utils\bin\make OS=windows ENV=arduino AVR_FREQ=20000000L atmega328
../../../tools/avr/bin/avr-gcc -g -Wall -Os -fno-inline-small-functions -fno-split-wide-types -mshort-calls -mmcu=atmega328p -DF_CPU=20000000L  '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200' -c -o optiboot.o optiboot.c
../../../tools/avr/bin/avr-gcc -g -Wall -Os -fno-inline-small-functions -fno-split-wide-types -mshort-calls -mmcu=atmega328p -DF_CPU=20000000L  '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
 -Wl,--section-start=.text=0x7e00 -Wl,--section-start=.version=0x7ffe -Wl,--relax -Wl,--gc-sections -nostartfiles -nostdlib -o optiboot_atmega328.elf optiboot.o
../../../tools/avr/bin/avr-size optiboot_atmega328.elf
   text    data     bss     dec     hex filename
    500       0       0     500     1f4 optiboot_atmega328.elf
../../../tools/avr/bin/avr-objcopy -j .text -j .data -j .version --set-section-flags .version=alloc,load -O ihex optiboot_atmega328.elf optiboot_atmega328.hex
..\..\..\tools\avr\bin\avr-objdump -h -S optiboot_atmega328.elf > optiboot_atmega328.lst
rm optiboot.o optiboot_atmega328.elf

C:\Program Files (x86)\Arduino\hardware\arduino\bootloaders\optiboot>
    

githubの方は、optiboot-master\optiboot\bootloaders\optiboot\をoptiboot-6.2に名前変更し、C:\Program Files (x86)\Arduino\hardware\arduino\bootloaders\にコピーし、 下記のようにビルドする。

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Windows\system32>cd "C:\Program Files (x86)\Arduino\hardware\arduino\bootloaders\optiboot-6.2"

C:\Program Files (x86)\Arduino\hardware\arduino\bootloaders\optiboot-6.2>omake AVR_FREQ=20000000L atmega328

C:\Program Files (x86)\Arduino\hardware\arduino\bootloaders\optiboot-6.2>..\..\..\tools\avr\utils\bin\make OS=windows ENV=arduino AVR_FREQ=20000000L atmega328
avr-gcc (WinAVR 20081205) 4.3.2
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

BAUD RATE CHECK: Desired: 115200, Real: 113636, UBRRL = 21, Error=-1.3%
../../../tools/avr/bin/avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax -mmcu=atmega328p -DF_CPU=20000000L  -DBAUD_RATE=115200 -DLED_START_FLASHES=3 -c -o optiboot.o optiboot.c
../../../tools/avr/bin/avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax -mmcu=atmega328p -DF_CPU=20000000L  -DBAUD_RATE=115200 -DLED_START_FLASHES=3
 -Wl,--section-start=.text=0x7e00 -Wl,--section-start=.version=0x7ffe -Wl,--relax -nostartfiles -nostdlib -o optiboot_atmega328.elf optiboot.o -lc
../../../tools/avr/bin/avr-size optiboot_atmega328.elf
   text    data     bss     dec     hex filename
    474       0       0     474     1da optiboot_atmega328.elf
../../../tools/avr/bin/avr-objcopy -j .text -j .data -j .version --set-section-flags .version=alloc,load -O ihex optiboot_atmega328.elf optiboot_atmega328.hex
..\..\..\tools\avr\bin\avr-objdump -h -S optiboot_atmega328.elf > optiboot_atmega328.lst
rm optiboot.o optiboot_atmega328.elf

C:\Program Files (x86)\Arduino\hardware\arduino\bootloaders\optiboot-6.2>
    

github.com/Optiboot/optiboot 6.2 2017-04-20 スナップショット

atmega328 20MHz optiboot 4.4

atmega328 20MHz optiboot 6.2

最後にIDEの方に20MHzのボードを登録し、あとは通常と同じように使用出来る。

# C:\Program Files (x86)\Arduino\hardware\arduino\boards.txt に追記

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

ブートローダ書き込み方法は別項目

There is an IGLU Cabal, but its only purpose is to deny the existence of an
IGLU Cabal

Martha Greenberg in Hackers-IL message No. 2057

    -- Martha Greenberg
    -- Hackers-IL Message No. 2057 ( http://tech.groups.yahoo.com/group/hackers-il/message/2057 )

Rule of Open-Source Programming #7:

Release early, release often. Clean compilation is optional.

    -- Omer Zak
    -- "Rules of Open Source Programming"


Powered by UNIX fortune(6)
[ Main Page ]