Mac OS 环境中如何制作自己的 Arduino Bootloader

发布于: 27 January, 2014
分享:

第一步:

  • Mac: 安装 Homebrew, 并通过 Homebrew

第二步:

Mac 平台下安装 avr-gcc:

 

$ brew tap tonylabs/homebrew-avr $ brew install avr-libc ==> Installing avr-libc from tonylabs/homebrew-avr ==> Installing dependencies for tonylabs/avr/avr-libc: gmp, mpfr, libmpc, isl, cloog, avr-binutils, avr-gcc ==> Installing tonylabs/avr/avr-libc dependency: gmp ==> Downloading https://homebrew.bintray.com/bottles/gmp-6.1.0.el_capitan.bottle.tar.gz Ubuntu 平台下安装  avr-gcc apt-get install avr-libc 安装 avrdude: brew install avrdude --with-usb ISL 报错 checking for the correct version of the gmp/mpfr/mpc libraries... yes checking for version 0.10 of ISL... no checking for version 0.11 of ISL... no checking for version 0.12 of ISL... no configure: error: Unable to find a usable ISL.  See config.log for details.

如上述方法遇到错误,请尝试

$ brew tap homebrew/versions
$ brew tap larsimmisch/homebrew-avr
$ brew tap neonquill/homebrew-avr
$ brew install avr-libc
$ brew tap homebrew/versions

第三步:

下载 LUFA-111009,并放到指定的目录 

  • Windows: 如果当前的 Arduino 安装在 C:\arduino-1.0.5,那么 LUFA 库就放在 C:\LUFA-111009
  • Mac 平台下,将 LUFA 放在根目录:/LUFA/LUFA-111009/...
lufa-folder-location

第四步:

修改 Descriptors.c 文件中 196 行至 215 行中的设备名称,此名称将出现在设备管理器 const USB_Descriptor_String_t ProductString = {    #if DEVICE_PID == 0x0036    .Header                 = {.Size = USB_STRING_LEN(16), .Type = DTYPE_String},    .UnicodeString          = L"Arduino Leonardo"     #elif DEVICE_PID == 0x0151    .Header                 = {.Size = USB_STRING_LEN(20), .Type = DTYPE_String},    .UnicodeString          = L"TONYLABS DEVICE NAME"    #else    .Header                 = {.Size = USB_STRING_LEN(12), .Type = DTYPE_String},    .UnicodeString         = L"USB IO board"    #endif }; const USB_Descriptor_String_t ManufNameString =  {    .Header               = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String},    #if DEVICE_VID == 0x2341    .UnicodeString         = L"Arduino LLC"    #elif DEVICE_VID == 0x20A0    .UnicodeString          = L"TONYLABS"    #else    .UnicodeString         = L"Unknown    "    #endif };

第五步:

设置编译环境,请注意 BASEDIR 一定要确保设置正确 set BASEDIR=c:\arduino-1.0.5\hardware set DIRAVRUTIL=%BASEDIR%\tools\avr\utils\bin set DIRAVRBIN=%BASEDIR%\tools\avr\bin set DIRAVRAVR=%BASEDIR%\tools\avr\avr\bin set DIRLIBEXEC=%BASEDIR%\tools\avr\libexec\gcc\avr\4.3.2 set OLDPATH=%PATH% @path %DIRAVRUTIL%;%DIRAVRBIN%;%DIRAVRAVR%;%DIRLIBEXEC%;%PATH% cd %BASEDIR%\arduino\bootloaders\caterina %DIRAVRUTIL%\make.exe clean %DIRAVRUTIL%\make.exe all VID=0x20A0 PID=0x0151 copy Caterina.hex Caterina-Tonylabs.hex %DIRAVRUTIL%\make.exe clean @path %OLDPATH%

第六步:

对于 Windows 来说,我们要准备好一个驱动程序(INF)文件,设备才可以正常工作 [DeviceList] %DESCRIPTION%=DriverInstall, USB\VID_20A0&PID_0151 %DESCRIPTION%=DriverInstall, USB\VID_20A0&PID_4151&MI_00 [DeviceList.NTamd64] %DESCRIPTION%=DriverInstall, USB\VID_20A0&PID_0151 %DESCRIPTION%=DriverInstall, USB\VID_20A0&PID_4151&MI_00  

第七步:

如果需要使用 Arduino 直接下载程序到设备中,我们可以添加一个新的板型,修改boards.txt ################################ leostick.name=TONYLABS leostick.upload.protocol=avr109 leostick.upload.maximum_size=28672 leostick.upload.speed=57600 leostick.upload.disable_flushing=true leostick.bootloader.low_fuses=0xff leostick.bootloader.high_fuses=0xd8 leostick.bootloader.extended_fuses=0xcb leostick.bootloader.path=caterina leostick.bootloader.file=Caterina-Tonylabs.hex leostick.bootloader.unlock_bits=0x3F leostick.bootloader.lock_bits=0x2F leostick.build.mcu=atmega32u4 leostick.build.f_cpu=16000000L leostick.build.vid=0x20A0 leostick.build.pid=0x4151 leostick.build.core=arduino leostick.build.variant=tonylabs

第八步:

使用 Atmel AVR MKII 下载器,通过 avrdude 烧写 hex 固件程序: $ avrdude -p atmega32u4 -P usb -c avrispmkii -e -U flash:w:PATH/FIRMWIRE.hex    

分享:

0 留言

留言

您的留言将被人工审核,请勿发表色情、反动言论。