├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── Wiki ├── AddingOptibootChipsToIde.md ├── BootloaderIntro.txt ├── CompilingOptiboot.md ├── CompilingOptiboot_x.md ├── GoodQuestions.md ├── Home.md ├── HowOptibootWorks.md ├── InstallingOnChips.md ├── Optiboot Basic Logic-1.png ├── OtherVersions.md ├── Virtual-Boot-Partition.md ├── github-issue-labels └── optiboot.png ├── docs ├── arduino-gcc-versions.md ├── optiboot.png └── travis-ci.md ├── optiboot ├── AS7 │ ├── AS7-README.TXT │ ├── Optiboot.atsln │ └── Projects │ │ ├── Optiboot_Curiosity3217.componentinfo.xml │ │ ├── Optiboot_Curiosity3217.cproj │ │ ├── Optiboot_Curiosity4809.componentinfo.xml │ │ ├── Optiboot_Curiosity4809.cproj │ │ ├── Optiboot_Xplained817.componentinfo.xml │ │ ├── Optiboot_Xplained817.cproj │ │ ├── Optiboot_xplained168pb.componentinfo.xml │ │ ├── Optiboot_xplained168pb.cproj │ │ ├── Optiboot_xplained328p.componentinfo.xml │ │ ├── Optiboot_xplained328p.cproj │ │ ├── Optiboot_xplained328pb.componentinfo.xml │ │ └── Optiboot_xplained328pb.cproj ├── AtmelStudio │ ├── xplained168pb.atsln │ ├── xplained168pb.atsuo │ ├── xplained168pb.cproj │ ├── xplained328p.atsln │ ├── xplained328p.atsuo │ ├── xplained328p.cproj │ ├── xplained328pb.atsln │ ├── xplained328pb.atsuo │ └── xplained328pb.cproj ├── boards-1.6.txt ├── boards.txt ├── bootloaders │ └── optiboot │ │ ├── Makefile │ │ ├── Makefile.1284 │ │ ├── Makefile.2560 │ │ ├── Makefile.atmel │ │ ├── Makefile.custom │ │ ├── Makefile.extras │ │ ├── Makefile.isp │ │ ├── Makefile.mcudude │ │ ├── Makefile.mega0 │ │ ├── Makefile.tiny │ │ ├── Makefile.usbmcus │ │ ├── README.TXT │ │ ├── baudcheck.c │ │ ├── boot_opt.h │ │ ├── info.sh │ │ ├── install-avr-tools.bat │ │ ├── link_optiboot.ld │ │ ├── make-ccversions │ │ ├── makeall.arduino.sh │ │ ├── makeall.everycpu.sh │ │ ├── makeall.mcudude.sh │ │ ├── makeall.mega0.sh │ │ ├── makeall.tiny.sh │ │ ├── makeall.usbmcus.sh │ │ ├── makeoptions │ │ ├── omake │ │ ├── omake.bat │ │ ├── optiboot.c │ │ ├── optiboot_atmega1280.hex │ │ ├── optiboot_atmega1280.lst │ │ ├── optiboot_atmega328.hex │ │ ├── optiboot_atmega328.lst │ │ ├── optiboot_atmega644p.hex │ │ ├── optiboot_atmega644p.lst │ │ ├── optiboot_x.c │ │ ├── parse_options.mk │ │ ├── pin_defs.h │ │ ├── pin_defs_x.h │ │ ├── pins_rs485.h │ │ ├── pins_softuart.h │ │ └── stk500.h ├── examples │ ├── chaucer112k │ │ └── chaucer112k.ino │ ├── chaucer16k │ │ └── chaucer16k.ino │ ├── chaucer256k │ │ └── chaucer256k.ino │ ├── chaucer32k │ │ └── chaucer32k.ino │ ├── chaucer64k │ │ └── chaucer64k.ino │ ├── demo_dospm │ │ ├── demo_dospm.ino │ │ └── optiboot.h │ ├── demo_flashwrite │ │ ├── demo_flashwrite.ino │ │ ├── optiboot.h │ │ ├── simpleParser.cpp │ │ ├── simpleParser.h │ │ └── supportfuncs.ino │ ├── demo_reset │ │ └── demo_reset.ino │ ├── eeprom_data.c │ ├── hex-with-FFs.hex │ ├── readme.md │ ├── test_eeprom │ │ └── test_eeprom.ino │ └── test_nvmctrl │ │ ├── optiboot.h │ │ ├── simpleParser.cpp │ │ ├── simpleParser.h │ │ └── test_nvmctrl.ino ├── package_optiboot_optiboot-additional_index.json.TEMPLATE └── release.sh └── scripts ├── travis-build.sh ├── travis-check-sizes.sh ├── travis-download.inc.sh ├── travis-env.inc.sh └── travis-fill-cache.sh /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore compiled output files 2 | /optiboot/bootloaders/optiboot/*.elf # exclude .elf files 3 | /optiboot/bootloaders/optiboot/*.hex # exclude .hex files 4 | /optiboot/bootloaders/optiboot/*.lst # exclude .lst files 5 | /optiboot/bootloaders/optiboot/*.tmp* # exclude .tmp files 6 | 7 | # Ignore additional hexfiles 8 | /optiboot/hexfiles/* # exclude additional hexfiles 9 | !/optiboot/hexfiles/legacy/* # include a few legacy hexfiles 10 | 11 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: bash 2 | dist: trusty 3 | sudo: false 4 | 5 | cache: 6 | directories: 7 | - $HOME/avr-tools 8 | install: true 9 | 10 | stages: 11 | - check sizes 12 | - test 13 | 14 | env: 15 | global: 16 | # - TOOLS_VERSION=1.0.6 17 | # - TOOLS_VERSION=1.6.9 18 | # - TOOLS_VERSION=1.6.13 19 | # - TOOLS_VERSION=1.8.5 20 | - TOOLS_VERSION=1.8.7 21 | # - TOOLS_VERSION=microchip 22 | matrix: 23 | - OPTIBOOT_TARGET=atmega128 24 | - OPTIBOOT_TARGET=atmega1280 25 | - OPTIBOOT_TARGET=atmega1281 26 | - OPTIBOOT_TARGET=atmega1284 27 | - OPTIBOOT_TARGET=atmega1284p 28 | - OPTIBOOT_TARGET=atmega128a 29 | - OPTIBOOT_TARGET=atmega16 30 | - OPTIBOOT_TARGET=atmega162 31 | - OPTIBOOT_TARGET=atmega164 32 | - OPTIBOOT_TARGET=atmega164a 33 | - OPTIBOOT_TARGET=atmega164p 34 | - OPTIBOOT_TARGET=atmega164pa 35 | - OPTIBOOT_TARGET=atmega168 36 | - OPTIBOOT_TARGET=atmega168a 37 | - OPTIBOOT_TARGET=atmega168p 38 | - OPTIBOOT_TARGET=atmega168pa 39 | - OPTIBOOT_TARGET="atmega168pb LED=B5" 40 | - OPTIBOOT_TARGET=atmega169 41 | - OPTIBOOT_TARGET=atmega169a 42 | - OPTIBOOT_TARGET=atmega169p 43 | - OPTIBOOT_TARGET=atmega169pa 44 | - OPTIBOOT_TARGET=atmega16a 45 | - OPTIBOOT_TARGET=atmega2560 46 | - OPTIBOOT_TARGET=atmega2561 47 | - OPTIBOOT_TARGET=atmega32 48 | - OPTIBOOT_TARGET=atmega324 49 | - OPTIBOOT_TARGET=atmega324a 50 | - OPTIBOOT_TARGET=atmega324p 51 | - OPTIBOOT_TARGET=atmega324pa 52 | - OPTIBOOT_TARGET=atmega324pb 53 | - OPTIBOOT_TARGET=atmega328 54 | - OPTIBOOT_TARGET=atmega328_pro8 55 | - OPTIBOOT_TARGET="atmega328 BIGBOOT=1" 56 | - OPTIBOOT_TARGET="atmega328 LED_START_FLASHES=0 LED_START_ON=1 SUPPORT_EEPROM=1" 57 | - OPTIBOOT_TARGET="atmega328 LED_START_FLASHES=0 SUPPORT_EEPROM=1" 58 | - OPTIBOOT_TARGET="atmega328 LED_START_FLASHES=0" 59 | - OPTIBOOT_TARGET="atmega328 SOFT_UART=1" 60 | - OPTIBOOT_TARGET="atmega328pb LED=B5" 61 | - OPTIBOOT_TARGET=atmega329 62 | - OPTIBOOT_TARGET=atmega3290 63 | - OPTIBOOT_TARGET=atmega3290p 64 | - OPTIBOOT_TARGET=atmega3290pa 65 | - OPTIBOOT_TARGET=atmega329a 66 | - OPTIBOOT_TARGET=atmega329p 67 | - OPTIBOOT_TARGET=atmega329pa 68 | - OPTIBOOT_TARGET=atmega64 69 | - OPTIBOOT_TARGET=atmega640 70 | - OPTIBOOT_TARGET=atmega644p 71 | - OPTIBOOT_TARGET=atmega649 72 | - OPTIBOOT_TARGET=atmega6490 73 | - OPTIBOOT_TARGET=atmega6490p 74 | - OPTIBOOT_TARGET=atmega649p 75 | - OPTIBOOT_TARGET=atmega64a 76 | - OPTIBOOT_TARGET=atmega8 77 | - OPTIBOOT_TARGET=atmega8515 78 | - OPTIBOOT_TARGET=atmega8535 79 | - OPTIBOOT_TARGET=atmega88 80 | - OPTIBOOT_TARGET="atmega88p LED=B5" 81 | - OPTIBOOT_TARGET="atmega88pa LED=B5" 82 | - OPTIBOOT_TARGET="atmega88pb LED=B5" 83 | - OPTIBOOT_TARGET=attiny1634 84 | - OPTIBOOT_TARGET=attiny1634at110 85 | - OPTIBOOT_TARGET=attiny1634at110ser1 86 | - OPTIBOOT_TARGET=attiny1634at12 87 | - OPTIBOOT_TARGET=attiny1634at12ser1 88 | - OPTIBOOT_TARGET=attiny1634at147 89 | - OPTIBOOT_TARGET=attiny1634at147ser1 90 | - OPTIBOOT_TARGET=attiny1634at16 91 | - OPTIBOOT_TARGET=attiny1634at16ser1 92 | - OPTIBOOT_TARGET=attiny1634at737 93 | - OPTIBOOT_TARGET=attiny1634at737ser1 94 | - OPTIBOOT_TARGET=attiny1634at8 95 | - OPTIBOOT_TARGET=attiny1634at8_5v 96 | - OPTIBOOT_TARGET=attiny1634at8_5vser1 97 | - OPTIBOOT_TARGET=attiny1634at8ser1 98 | - OPTIBOOT_TARGET=attiny1634at921 99 | - OPTIBOOT_TARGET=attiny1634at921ser1 100 | - OPTIBOOT_TARGET=attiny167 101 | - OPTIBOOT_TARGET=attiny828 102 | - OPTIBOOT_TARGET=attiny828at8 103 | - OPTIBOOT_TARGET=attiny828at8_5v 104 | - OPTIBOOT_TARGET=attiny84 105 | - OPTIBOOT_TARGET=attiny841 106 | - OPTIBOOT_TARGET=attiny841at110 107 | - OPTIBOOT_TARGET=attiny841at110ser1 108 | - OPTIBOOT_TARGET=attiny841at12 109 | - OPTIBOOT_TARGET=attiny841at12ser1 110 | - OPTIBOOT_TARGET=attiny841at147 111 | - OPTIBOOT_TARGET=attiny841at147ser1 112 | - OPTIBOOT_TARGET=attiny841at16 113 | - OPTIBOOT_TARGET=attiny841at16noLED 114 | - OPTIBOOT_TARGET=attiny841at16ser1 115 | - OPTIBOOT_TARGET=attiny841at184 116 | - OPTIBOOT_TARGET=attiny841at184ser1 117 | - OPTIBOOT_TARGET=attiny841at20 118 | - OPTIBOOT_TARGET=attiny841at20noLED 119 | - OPTIBOOT_TARGET=attiny841at20ser1 120 | - OPTIBOOT_TARGET=attiny841at737 121 | - OPTIBOOT_TARGET=attiny841at737ser1 122 | - OPTIBOOT_TARGET=attiny841at8 123 | - OPTIBOOT_TARGET=attiny841at8_5v 124 | - OPTIBOOT_TARGET=attiny841at8noLED 125 | - OPTIBOOT_TARGET=attiny841at8ser1 126 | - OPTIBOOT_TARGET=attiny841at921 127 | - OPTIBOOT_TARGET=attiny841at921ser1 128 | - OPTIBOOT_TARGET=attiny87 129 | - OPTIBOOT_TARGET=bobuino 130 | - OPTIBOOT_TARGET=diecimila 131 | - OPTIBOOT_TARGET=lilypad 132 | - OPTIBOOT_TARGET=lilypad_resonator 133 | - OPTIBOOT_TARGET=luminet 134 | - OPTIBOOT_TARGET=mega1280 135 | - OPTIBOOT_TARGET=mega2560 136 | - OPTIBOOT_TARGET=mighty1284 137 | - OPTIBOOT_TARGET=pro16 138 | - OPTIBOOT_TARGET=pro20 139 | - OPTIBOOT_TARGET=pro8 140 | - OPTIBOOT_TARGET=sanguino 141 | - OPTIBOOT_TARGET=virboot328 142 | - OPTIBOOT_TARGET=virboot8 143 | - OPTIBOOT_TARGET=wildfire 144 | - OPTIBOOT_TARGET=wildfirev2 145 | - OPTIBOOT_TARGET=wildfirev3 146 | - OPTIBOOT_TARGET=xplained168pb 147 | - OPTIBOOT_TARGET=xplained328p 148 | - OPTIBOOT_TARGET=xplained328pb 149 | 150 | matrix: 151 | allow_failures: 152 | - env: OPTIBOOT_TARGET="atmega328 LED_START_FLASHES=0 LED_START_ON=1 SUPPORT_EEPROM=1" 153 | - env: OPTIBOOT_TARGET="atmega328 LED_START_FLASHES=0 SUPPORT_EEPROM=1" 154 | 155 | script: scripts/travis-build.sh $TOOLS_VERSION $OPTIBOOT_TARGET 156 | 157 | jobs: 158 | include: 159 | - stage: check sizes 160 | script: scripts/travis-check-sizes.sh 161 | env: OPTIBOOT_TARGET=none 162 | 163 | notifications: 164 | email: 165 | on_success: always 166 | on_failure: always 167 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Optiboot Bootloader for Arduino and Atmel AVR ## 2 | 3 | ![docs/optiboot.png](docs/optiboot.png) 4 | 5 | Optiboot is an easy to install upgrade to the Arduino bootloader within Arduino boards. It provides the following features: 6 | 7 | * Allows larger sketches. Optiboot is only 512 bytes, freeing 1.5k of extra code space compared to older bootloaders. 8 | * Makes your sketches upload faster. Optiboot operates at higher baud rates and has streamlined programming. 9 | * Adaboot performance improvements. Optiboot implements "fastboot" that starts sketches immediate after power-on. 10 | * Compatible with ATmega8, ATmega168, and ATmega328p Arduinos and derivatives including Lilypad, Pro, Nano, and many derivatives. 11 | * Works with *MANY* additional Atmel AVR chips - almost anything that supports bootloads or "flash self-programming." This includes chips from ATtiny 8pin chips through the 100pin ATmega2560 used on Arduino Mega. 12 | * Supports alternate serial ports, CPU frequencies and baud rates. 13 | * Additional support for AVR-USB-MCUs of the families ATmegaXYu2/4/6 and AT90usbXYZS – e.g. Arduino Uno USB-MCU (ATmega16u2) and Micro (ATmega32u4). 14 | 15 | 16 | Optiboot (an older version) is installed by default on the Arduino Uno and (as of 2018) official Arduino Nano boards. It can be installed on all older mega8, 168 or 328 based Arduinos. 17 | 18 | ## Optiboot_X 19 | As of 2019, Atmel was acquired by Microchip Inc, and released several "new" architectures with the AVR CPU. These are known as the Mega-0, Tiny-0, and Tiny-1 Series. While the basic CPU operation is about the same as older AVRs, the peripherals, including Flash self-programming, are significantly different. This justified a new version of Optiboot with separate source code and Makefiles, which we're calling "optiboot_x" (the new AVR chips closely resemble the "AVR XMega" chips.) 20 | 21 | ## Additional Documentation 22 | More detailed documentation is being added (slowly) to the [repository wiki](https://github.com/Optiboot/optiboot/wiki). 23 | 24 | ## Notes on IDE Version compatibility 25 | Optiboot is "compatible", in a loose sense, with all versions of the Arduino IDE. It was originally written at about the same time as v1.0, and has some "quirks" that date back to that timeframe. Most significantly, the directory structure of the git repository is "weird." 26 | 27 | ## To install into the Arduino software ## 28 | You do NOT need to "install" Optiboot if you are trying to update an installed platform that already uses some form of Optiboot. In fact, you should almost certainly NOT install Optiboot using the board manager. 29 | The Optiboot GitHub repository these days is mostly useful as a source-code repository, for anyone who needs to make a highly customized version for some reason. Or an improvement to Optiboot itself. 30 | 31 | Most end users should find a supported "Arduino Core" that includes Optiboot for their desired target, and install that. Many such cores are provided by the hardware vendor, and they'll include Board definitions, Variant files, and Arduino core code needed to support the target as well as one or more Optiboot .hex files that should work. 32 | 33 | There are also some major repositories of "generic" versions of cores for various targets, including: 34 | 35 | * [MegaCore by MCUdude](https://github.com/MCUdude/MegaCore) Supports large AVRs like ATmega128, ATmega640, ATmega1280, ATmega1281, ATmega2560 and ATmega2561. 36 | * [MightyCore by MCUdude](https://github.com/MCUdude/MightyCore) Supports most 40pin AVRs including ATmega1284, ATmega644, ATmega324, ATmega32, and ATmega8535. 37 | * [MiniCore by MCUdude](https://github.com/MCUdude/MiniCore) Supports most 28pin ATmega AVRs, including the CPUs used by Uno/etc as well as the new CPUs like the ATmega328PB. 38 | * [MajorCore by MCUdude](https://github.com/MCUdude/MajorCore) Supports a couple of relatively obsolete large AVRs, like ATmega8515 and ATmega162. 39 | * [ATTinyCore by Spence Konde](https://github.com/SpenceKonde/ATTinyCore) Supports many ATtiny AVRs, including ATtiny85, ATtiny1634, ATtiny84, and ATtiny841. 40 | * [MegaCoreX by MCUdude](https://github.com/MCUdude/MegaCoreX) Supports the Mega-0 Series AVRs (notably the ATmega480x and ATmega320x) (Using Optiboot_X.) 41 | * [megaTinyCore by Spence Konde](https://github.com/SpenceKonde/megaTinyCore) Supports many of the Tiny-0 and Tiny-1 series AVR chips (using Optiboot_X.) 42 | 43 | 44 | If you need a new Optiboot feature not included in a pre-packaged core, the recommended procedure is to download or fork the source code, manually compile the version you need, and copy the .hex file to the existing board directory (after renaming the old .hex file, in case you need it back.) 45 | 46 | Nevertheless, there is an automatically installable Board Manager package that includes the .hex files for Optiboot on several popular Arduino boards (a very small subset of the possible targets.). Using the Optiboot "install" procedure does not install any cores or variants, so it is only useful for CPUs that are already supported by the standard Arduino core. 47 | 48 | The following instructions are based on using the Arduino "Board Manager", present in IDE versions 1.6.5 and later. 49 | 50 | 1. Find the desired Optiboot release on the [Optiboot Release page](https://github.com/Optiboot/optiboot/releases). 51 | 2. Use the "Copy link address" feature of your browser to copy the URL of the associated **.json** file. 52 | 3. Paste this URL into the "Additional Boards Manager URLs" field in the Arduino IDE "Preferences" pane. (Separate it from other URLs that might be present with a comma or click the icon to the right of the field to insert it on a new line.) 53 | 4. After closing the Preferences window, the **Tools/Boards/Boards Manager** menu should include an entry for that version of Optiboot. Select that entry and click the **Install** button. 54 | 55 | For additional installation information, see the [Optiboot AddingOptibootChipsToIde Wiki page](https://github.com/Optiboot/optiboot/wiki/AddingOptibootChipsToIde) 56 | 57 | 58 | 65 | 66 | ## To burn Optiboot onto an Arduino board ## 67 | 1. Select the appropriate Optiboot board type (or non-Optiboot if you want to change back). 68 | 2. Connect your Arduino to an ISP programmer ([Installing](https://github.com/Optiboot/optiboot/wiki/InstallingOnChips)). 69 | 3. Use the 'Burn Bootloader' item in Arduino. 70 | 4. You can then upload sketches as normal, using the Optiboot board type. 71 | 72 | ---- 73 | 74 | > Although it has evolved considerably, Optiboot builds on the original work of Jason P. Kyle (stk500boot.c), [Arduino group (bootloader)](http://arduino.cc), [Spiff (1K bootloader)](http://spiffie.org/know/arduino_1k_bootloader/bootloader.shtml), [AVR-Libc group](http://nongnu.org/avr-libc) and [Ladyada (Adaboot)](http://www.ladyada.net/library/arduino/bootloader.html). 75 | 76 | > _Optiboot is the work of Peter Knight (aka Cathedrow). Despite some misattributions, it is not sponsored or supported by any organisation or company including Tinker London, Tinker.it! and Arduino._ 77 | > Maintenance of Optiboot was taken over by Bill Westfield (aka WestfW) in 2011. 78 | > Major contributions have also been made by Hans "MCUdude", Spence "DrAzzy" Konde, and majekw. 79 | -------------------------------------------------------------------------------- /Wiki/AddingOptibootChipsToIde.md: -------------------------------------------------------------------------------- 1 | # Not Done yet # 2 | 3 | This involves adding or editing a "boards.txt" file somewhere in the Arduino application or user sketch directory hierarchy. 4 | 5 | Both the preferred location and the format of the file change from version to version of the IDE. 6 | 7 | 8 | # IDE Version 1.6.4 (and later) 9 | ## Boards Manager 10 | Versions 1.5.x (beta) of the IDE added support for a much broader range of non-AVR and 3rd party hardware. This changed the directory structure in the user's sketchbook folder in ways that were incompatible with 1.0.x (in particular, adding a "platform" sub directory, so that boards.txt was in \/hardware/\/\/). 11 | 12 | In 1.6.4 (a production release), the IDE added a "boards manager" that permits a 3rd party extension to be automatically downloaded and installed simply by adding a URL in the preferences panel and (in yet another location and clicking an "Install" button in the Boards Manager panel. (The actual files end up in yet a different place in the file system, but this should be transparent to the users.) This is the preferred way to install the Optiboot boards.txt if you are running 1.6.4 or later, but it does not (currently) install source code. 13 | 14 | # IDE version 1.0.x 15 | In version 1.0 of the Arduino IDE, it became possible to put hardware extensions in the sketchbook folder, by putting new subdirectories in \/hardware/\. You could put a suitably formatted boards.txt there describing the new optiboot cpus, pointing toward .hex files located in that tree, or in other locations. 16 | 17 | 18 | # IDE Version 00xx 19 | Optiboot was written prior to version 1.0 of the IDE. In those days, the only way to add additional boards was to modify the boards.txt file that included within the directory structure of the IDE itself. (\/hardware/arduino/boards.txt, with the .hex files in \/hardware/arduino/bootloaders/optiboot) The directory structure of the Optiboot repository reflects this old structure. 20 | 21 | -------------------------------------------------------------------------------- /Wiki/BootloaderIntro.txt: -------------------------------------------------------------------------------- 1 | What is a "Bootloader" ? 2 | 3 | What is "stk500" ? 4 | 5 | What is "avrdude" ? 6 | 7 | What symptoms indicate a bootloading problem? 8 | 9 | What are common causes of bootloading problems? 10 | 11 | What information can I collect to debug a bootloading problem? 12 | 13 | Can my Arduino have the bootloader damaged? 14 | 15 | How can I tell if my bootloader is damaged? 16 | 17 | Why else would I want to upload a new bootloader? 18 | 19 | Can I replace or upload a new bootloader with no additional equipment? 20 | 21 | How can I replace or upload a new bootloader? 22 | -------------------------------------------------------------------------------- /Wiki/CompilingOptiboot.md: -------------------------------------------------------------------------------- 1 | # Introduction # 2 | 3 | You can compile Optiboot for platforms that do not have pre-existing .hex files, or you can make modifications to the source code and/or Makefile in order to implement "custom" versions of Optiboot. 4 | 5 | This will require some relatively deep knowledge of avr-gcc, Atmel AVR hardware and processor details, Makefiles, and the command line environment. We HAVE tried to take steps to allow Optiboot to be compiled without installing a full AVR development suite. 6 | 7 | 8 | # Details # 9 | 10 | Optiboot is designed to be compiled with the same version of avr-gcc that is distributed with the Arduino environment: 4.3.2. This is actually quite an old version of gcc; some effort has been made to allow the compile to proceed with new versions of the compiler. However, since Optiboot MUST compile to a total size of less than 512 bytes, it is very sensitive to changes in the way the compiler does optimizations, or the way it processes optimization options on the compile command. 11 | 12 | In all cases, Optiboot compiles directly from the command line using "make", rather than from within any IDE. It is currently designed to use compilers installed in one of three different places: 13 | 14 | * Local Development Environment - you have WinAVR (on Windows), CrossPack (on Mac), or an avr-gcc package (linux) installed on your system, with appropriate development tools somewhere in your path. 15 | * You have Arduino installed, and are trying to compile Optiboot from its home directory within the Arduino directory structure (hardware/arduino/bootloaders/optiboot/). The Arduino app includes a pretty complete set of compiler tools, and these can be used to compile optiboot without installing a separate toolchain. (as of Version 1.5 of the Arduino IDE, a much smaller set of tools is included, and this method doesn't work any more.) 16 | * You have downloaded the Arduino Source code, which also includes (binary) copies of avr-gcc toolchains, and a source directory containing the Optiboot source code. 17 | 18 | WARNING: some targets don't compile with "make" 3.81 or 3.82 due to bug in it. See https://github.com/Optiboot/optiboot/issues/106 19 | 20 | 21 | # Compile Options # 22 | 23 | The Optiboot build procedure has been set up to allow a large set of customization options. The general format of a build command is: 24 | 25 | ~~~~ 26 | make help 27 | ~~~~ 28 | The "make help" command should output a list of possible options and targets, probably more complete and up-to-date than this documentation. 29 | 30 | ~~~~ 31 | make 32 | ~~~~ 33 | Where is one of the named chips or boards implemented as normal targets in the makefile (ie "atmega328".) (the order may be reversed.) The implemented include: 34 | 35 | * **AVR\_FREQ=nnnnnn** -- Use CPU frequency as specified (default: target dependent, but usually 16000000L) 36 | 37 | * **BAUD\_RATE=nnnnn** -- Use an alternate bitrate (default: usually 115200)
38 | * **SINGLESPEED=1** -- Operate the UART in single-speed mode. 39 | * **UART=n** -- user UARTn instead of UART0. 40 | * **SOFT_UART=1** -- use a bit-banged Software Uart. Required for chips without a HW UART. 41 | * **LED=\** -- Like "LED=B5" or "LED=L5" - which LED to flash. 42 | * **LED\_START\_FLASHES=n** -- number of flashes to emit when the bootloader executes (default 3) Setting this to 0 omits the LED-flashing code and saves some space. 43 | * **LED\_START\_ON** -- Turn on the LED when the bootloader starts. A smaller alternative to LED\_START\_FLASHES. 44 | * **LED\_DATA\_FLASH=1** -- flash the LED in the data receive function as well as at bootloader startup. 45 | * **BIGBOOT=1** -- include extra features that cause the bootloader to grow to between 512 and 1024 bytes. 46 | * **SUPPORT\_EEPROM=1** -- try to include EEPROM read/write support, without other BIGBOOT features. 47 | * **NO\_APP\_SPM=1** -- Omit the code that allows applications to have Optiboot execute an SPM instruction (for writing to flash.) 48 | 49 | For example: 50 | 51 | ~~~~ 52 | make UART=1 LED=A7 AVR_FREQ=20000000L atmega1284 53 | ~~~~ 54 | Note that many of the board-level targets are implemented using a recursive invocation of make using this options. For example, the "pro20" target ends up being: 55 | 56 | ~~~~ 57 | make atmega168 AVR_FREQ=20000000L LED_START_FLASHES=3 58 | ~~~~ 59 | -------------------------------------------------------------------------------- /Wiki/CompilingOptiboot_x.md: -------------------------------------------------------------------------------- 1 | # Introduction # 2 | 3 | Optiboot_x, the bootloader for Mega0, Tiny0, and Tiny1 architecture AVR chips, uses a slightly different build procedure than Optiboot for the older AVR chips. The major difference is that you must provide the name of the makefile in the make command, and may require that you specify the location of the appropriate PACKS directory. 4 | ~~~ 5 | export PACKS= 6 | make -f Makefile.mega0 7 | ~~~ 8 | 9 | 10 | # Details # 11 | 12 | Optiboot is designed to be compiled with the same version of avr-gcc that is distributed with the Arduino MegaAVR Core. (Currently an Arduino-compiled avr-gcc 7.3), or the latest CLI tools from Microchip (a version of avr-gcc 5.4 (yes, older than the Arduino compiler)) 13 | 14 | In all cases, Optiboot compiles directly from the command line using "make", rather than from within any IDE. It is currently designed to used compilers installed in one of three different places: 15 | 16 | * Local Development Environment - you have WinAVR (on Windows), CrossPack (on Mac), or an avr-gcc package (linux) installed on your system, with appropriate development tools somewhere in your path. 17 | * You have Arduino installed, and are trying to compile Optiboot from its home directory within the Arduino directory structure (hardware/arduino/bootloaders/optiboot/) The Arduino app includes a pretty complete set of compiler tools, and these can be used to compile optiboot without installing a separate toolchain. (as of Version 1.5 of the Arduino IDE, a much smaller set of tools is included, and this method doesn't work any more.) 18 | * You have downloaded the Arduino Source code, which also includes (binary) copies of avr-gcc toolchains, and a source directory containing the Optiboot source code. 19 | 20 | WARNING: some targets don't compile with "make" 3.81 or 3.82 due to bug in it. See https://github.com/Optiboot/optiboot/issues/106 21 | 22 | 23 | # Compile Options # 24 | 25 | The Optiboot build procedure has been set up to allow a large set of customization options. The general format of a build command is: 26 | 27 | ~~~~ 28 | make help 29 | ~~~~ 30 | The "make help" command should output a list of possible options and targets, probably more complete and up-to-date than this documentation. 31 | 32 | ~~~~ 33 | make -f Makefile.mega0 34 | ~~~~ 35 | Where \ is one of the named chips or boards implemented as normal targets in the makefile (ie "drazzy402") (the order may be reversed.) The implemented \ include: 36 | 37 | * **TIMEOUT=n** -- Sets the bootloader timeout to n seconds (n=1, 2, 4, or 8) Longer timeouts are useful on boards/chips that don't implement auto-reset, or that need power-cycled to reset. 38 | * **BAUD\_RATE=nnnnn** -- Use an alternate bitrate (default: 115200)
39 | * **UARTTX=** -- use the designated pin for UART TX. This implies a particular UART and the RX pin as well. The pins that can be used are chip dependent. 40 | * **LED=\** -- Like "LED=B5" or "LED=L5" - which LED to flash. 41 | * **LED\_START\_FLASHES=n** -- number of flashes to emit when the bootloader executes (default 3) Setting this to 0 omits the LED-flashing code and saves some space. 42 | * **LED\_START\_ON** -- Turn on the LED when the bootloader starts. A smaller alternative to LED\_START\_FLASHES. 43 | * **LED\_DATA\_FLASH=1** -- flash the LED in the data receive function as well as at bootloader startup. 44 | * **BIGBOOT=1** -- include extra features that cause the bootloader to grow to between 512 and 1024 bytes. Not implemented. 45 | * **NO\_APP\_SPM=1** -- Omit the code tat allows applications to have Optiboot execute an SPM instruction (for writing to flash.) 46 | * **AVR\_FREQ=nnnnnn** -- Not applicable. 47 | * **SINGLESPEED=1** -- Not applicable. 48 | * **SUPPORT\_EEPROM=1** -- Not applicable. EEPROM is always supported. 49 | * **SOFT_UART=1** -- Not applicable. All chips have UARTS 50 | 51 | 52 | For example: 53 | 54 | ~~~~ 55 | make -f Makefile.mega0 UARTTX=A1 LED=A7 atmega4809 56 | make -f Makefile.mega0 curiosity4809 57 | ~~~~ 58 | Note that many of the board-level targets are implemented using a recursive invocation of make using this options. For example, the "drazzy402" target ends up being: 59 | 60 | ~~~~ 61 | make -f Makefile.mega0 optiboot_attiny402.hex UARTTX=A1 TIMEOUT=8 LED=A7 62 | ~~~~ 63 | 64 | # Mega-0 Differences # 65 | The mega-0 and tiny-0/1 architecture is significantly different (and "nicer") than previous ATmega/ATtiny chips, especially when it comes to implementing a bootloader. Here are some of the more relevant changes: 66 | 67 | 1. The bootloader starts at 0x0, and the Application start after the bootloader.
This means that the bootloader binary is the same for chips in the same family that have different flash memory size (eg ATmega1609 and ATmega4809.) 68 | 2. Commonality of binaries.
These chips have much better cross-chip compatibility than previous AVR generations. Common peripherals are identical and at the same addresses. Combined with (1), this means that the same bootloader binary should run on any of the 14, 20, and 24pin tiny0 or tiny1 chips, if the same UARTTX ports are in use. 69 | 3. Choosing a UART.
In addition to having multiple UARTs, the mega-0 has a pin multiplexing ability that can redirect the functionality to two different sets of pins for each UART. Specifying the port and pin of the TX signal uniquely identifies both the UART and pinmux settings. 70 | 4. Clock speed.
Mega-0 chips normally boot to an internal clock that is accurate and fast enough for uart communications, regardless of whether "normal operation" of that board uses a different clock rate. Optiboot runs off of this internal clock after figuring out the rate 71 | 1. New NVM structure.
Flash and EEPROM are treated very similarly, so that support for both fits easily in the 512byte bootloader. 72 | -------------------------------------------------------------------------------- /Wiki/GoodQuestions.md: -------------------------------------------------------------------------------- 1 | # Good Question! # 2 | 3 | Optiboot occasionally generates questions on various forums (Arduino, AVRFreaks, etc), and I thought I'd collect some of the answers here, without spending a lot of time trying to re-organize them as actual "documentation." 4 | 5 | 1. Do Arduino "sketches" require the Optiboot (or other) bootloader to be loaded on the chip?

6 | No. While it's technically possible for a bootloader to include "support functions" used by the application section, Arduino does NOT do this. Nor do sketches require a bootloader to have done any chip initialization. In fact, Optiboot tries to start the application with the chip in a state as close as possible to its "reset" state.

7 | 8 | 1. Can I put Optiboot on my Arduino MEGA2560 ?

9 | Yes, as of Optiboot v7.0
10 | In older versions, Optiboot was limited by the "Version 1" STK500 communications protocol, which only allows up to 64kwords of flash to be programmed. The v7.0 code uses an out-of-band "SPI Command" to set the RAMPX register.

11 | 12 | 1. Why does Optiboot have its own copy of boot.h ?

13 | The copy of boot.h used by Optiboot has been modified to use "out" instructions instead of "sts." The out instruction is shorter, but only works if the target register is within the first 64 IO addresses.
14 | As of Version 7.0, the Optiboot copy of boot.h has been renamed to boot_opt.h, defines ONLY the special "short" functions, and includes the standard \ to pick up all the standard definitions.

15 | 16 | 1. What is a "Virtual Boot Partition"

17 | VIRTUAL\_BOOT\_PARTITION is a hack for implementing a bootloader on parts that don't have "start at the bootloader address after reset" support. So the start vector always has to be at 0, where it will be overwritten by the application's vectors. Except the bootloader "cleverly substitutes" its own start address for the start of the application during "upload", causing the bootloader to always run first.

18 | 19 | 1. Why is there an extra `BAUD_RATE * 4L` there? Why is it using 4L and 8L rather than just 4 and 8?

20 | It's doing rounding. int(calculated\_divisor + 0.5), except since it's all integers we use algebra and multiply the 0.5 by something big enough to make it an integer. (Hmm. This is probably silly; I should just let it use compile-time floating point. like `__delay_ms()`)

21 | 22 | 1. What is the difference between `"__boot_page_fill_short" and "__boot_page_write_short"`? 23 |

24 | Flash is written a full page at a time, rather than a byte at a time. To write a page of flash, you fill a RAM buffer in the flash controller peripheral (boot\_page\_fill), and then give a "boot\_page\_write" to actually write that buffer to the flash memory. All together, there are three copies (buff, which is filled from the serial comm, the flash page buffer filled by page\_fill, and the flash itself.)

25 | 26 | 1. What's with the "`#define rstVect (*(uint16_t*)(RAMSTART+SPM_PAGESIZE*2+4))`" ? 27 |

28 | These are "manually defined" variables. Normally you'd say `"char buff[SPM_PAGESIZE]; int rstvector, wdtvector;"` But C would want to include code to initialize those variables, which would be "too much" extra code for optiboot to fit in 512 bytes. So instead we define buff as being where we know the first byte of RAM is and rstvetcor as the first byte after buff, and so on.

29 | 30 | 1. What is RAMPZ? what is being done in the "`newAddress += newAddress`" line? 31 |

32 | RAMPZ is the "extra byte" of flash addressing for parts with more than 64k words. 33 |
34 | The addition (multiply by 2) converts from (16bit) word addresses that Atmel likes to use in various place, to byte addresses used by the hardware and avr-libc in most places. 35 |

36 | 37 | 1. What are "sections" and the ".version" section in particular, and what is optiboot doing with them? 38 |

39 | The "section" attribute is equivalent to the .section gnu assembler directive. http://tigcc.ticalc.org/doc/gnuasm.html#SEC119 (one source; generic.) ".version" is an arbitrary name. 40 |
41 | These are essentially commands that transfer information from the source code to the linker, which will then put together the various bits of information in various places in memory, based on the "linker map" (file provided by the infrastructure) and commands given to it explicitly ("-Wl,--section-start=.version=0x3ffe" in the Makefile.) The newer code does this in C with attribute instead of using inline assembler, but it does the same thing. 42 |

43 | 44 | 1. How does Optiboot put the code and version number at the correct absolute flash addresses? 45 |

46 | The output from the compiler is in relocatable "sections" that are then relocated and assigned to appropriate addresses by the linker. The addresses used are normally determined by a "linker map" file that is part of the per-chip definitions included with the compiler, but in the case of Optiboot, they are specified explicitly in the link command using the -Wl,--section-start=.text=0x3e00 type commands.

47 | 48 | 1. Where did 0x3e00 come from? I don't see that in the data sheet! 49 |

50 | There are various places where the Atmel documentation uses WORD addresses for flash memory, while most of the gnu tools use BYTE addresses. 0x3e00 comes from the "boot size configuration" in the boot loader support chapter of the datasheet (where it says "0x1F00")

51 | 52 | 1. Do I need a different version of Optiboot for the non-DIP packages like the ATmega328p-au ? 53 |

54 | No, the package should be irrelevant to the bootloader software. Watch your pin connections, connect all the (multiple) power supply pins, and the same bootloader and bootloader loading procedure should work. If it doesn't work, it is due to some factor other than Optiboot.

55 | 56 | -------------------------------------------------------------------------------- /Wiki/Home.md: -------------------------------------------------------------------------------- 1 | Welcome to the optiboot wiki!
2 | 3 | ## Wiki pages: ## 4 | 5 | * [InstallingOnChips](https://github.com/Optiboot/optiboot/blob/master/Wiki/InstallingOnChips.md) - loading Optiboot onto chips, using various tools. 6 | * [CompilingOptiboot](https://github.com/Optiboot/optiboot/blob/master/Wiki/CompilingOptiboot.md) 7 | * [CompilingOptiboot_X](https://github.com/Optiboot/optiboot/blob/master/Wiki/CompilingOptiboot_X.md) 8 | * [HowOptibootWorks](https://github.com/Optiboot/optiboot/blob/master/Wiki/HowOptibootWorks.md) 9 | * [AddingOptibootChipsToIde](https://github.com/Optiboot/optiboot/blob/master/Wiki/AddingOptibootChipsToIde.md) 10 | * [GoodQuestions](https://github.com/Optiboot/optiboot/blob/master/Wiki/GoodQuestions.md) - Frequently asked technical questions 11 | * [OtherVersions](https://github.com/Optiboot/optiboot/blob/master/Wiki/OtherVersions.md) - 3rd party optiboot derivatives with interesting features. 12 | * [Virtual-Boot-Partition](https://github.com/Optiboot/optiboot/blob/master/Wiki/Virtual-Boot-Partition.md) - More about the Virtual Boot Partition. 13 | -------------------------------------------------------------------------------- /Wiki/HowOptibootWorks.md: -------------------------------------------------------------------------------- 1 | # Introduction # 2 | 3 | Optiboot implements a small subset of the "STK500 communications protocol" (version 1) defined by Atmel in their [Application Note AVR061](http://www.atmel.com/Images/doc2525.pdf) In order to conserve code space, many of the protocol commands are ignored and receive "lies" rather than correct response codes, leading to the possibility that the bootloader may not operate correctly with all host-side software. It is known to work with versions of "avrdude" supporting the "-c arduino" programmer type. 4 | 5 | Optiboot is designed to reside in the bootloader section, and chip fuses should be set appropriately for the size of optiboot (normally 256 words) (BOOTSZx) and to reset to the bootloader start address (BOOTRST). Note that BOOTSZx values are chip-dependent, and some of the chips supported by Optiboot have a 512 word minimum bootloader size.) 6 | 7 | ## Basic Operation ## 8 | 1. On reset, Optiboot starts and reads the reset reason from MCUSR. For any cause other than "external reset", the application is started immediately. Otherwise, optiboot attempts to download new application software: 9 | 1. The "start LED" is flashed to indicate that optiboot is running. (which pin is used, and how many times it flashes, is configurable.) 10 | 1. The (configurable) UART is configured and the WDT is enabled with a 1s timeout. 11 | 1. Optiboot attempts to read commands from the (configurable) serial port. Valid characters will cause the WDT to be reset, and the application flash area to be programmed (hopefully.) 12 | 1. With no valid UART traffic, or after programming, the WDT is allowed to expire, causing the chip to reset. 13 | 1. Since the WDT reset is NOT an 'external reset', the application is started as in (1) - the AVR at the time the application is run has all IO registers except MCUSR and SP in their pristine, reset, state. 14 | 15 | # Details # 16 | ## Implemented Commands ## 17 | The following core commands are "supported"; they actually do something useful WRT loading code via the bootloader: 18 | 19 | |Cmd Name | Value | Description | 20 | |:--------|-------|:------------| 21 | |STK\_LOAD\_ADDRESS|0x55,'U'| Note: 16bit word address, 128kb flash max.| 22 | |STK\_PROG\_PAGE|0x64,'d'| Flash only| 23 | |STK\_READ\_PAGE|0x74,'t'| Flash only| 24 | |STK\_READ\_SIGN|0x75,'u'| Reads compiled-in signature.| 25 | |STK\_LEAVE\_PROGMODE|0x51,'Q'| Starts application code via WDT reset.| 26 | |STK\_GET\_PARAMETER|0x41,'A'| Supports "minor SW version" and "major SW version" Returns 3 for all other parameters.| 27 | 28 | The following commands will have their arguments correctly read, and produce in a "success" response, but they don't actually do anything: 29 | 30 | |Cmd Name | Value | 31 | |:------------- |:-------- | 32 | |STK\_UNIVERSAL|0x56, 'V'| | 33 | |STK\_SET\_DEVICE|0x42, 'B'| | 34 | |STK\_SET\_DEVICE\_EXT|0x45, 'E'| | 35 | 36 | All other commands will result in a success response if they are immediate followed by CRC\_EOP (0x20, ' ') (ie they are ignored), or a WDT reset (start application) otherwise. 37 | 38 | ## Space Saving Techniques ## 39 | In order to save space, Optiboot utilizes a couple of techniques that may be of general interest: 40 | 41 | * The Vector table and normal startup code are omitted by using linker options "-nostdlib -nostartfiles" 42 | * This requires that main() be declared with attribute OS\_main and manually placed in the .init9 section. 43 | * and thus main() has to initialize the known-zero register (r1) and SP on chips that don't automatically set SP to end-of-ram. 44 | * inlining of functions is carefully controlled. -------------------------------------------------------------------------------- /Wiki/InstallingOnChips.md: -------------------------------------------------------------------------------- 1 | # Installing optiboot # 2 | 3 | There are two aspects to "installing optiboot." The first problem, which is discussed here, involves getting the optiboot firmware into chips, whether the chips have an older version of a bootloader, or are completely blank. 4 | 5 | The second problem is configuring the Arduino IDE to support the optiboot-loaded chips. This is easy if you're loading up ATmega328x chips, since any 328 chip with optiboot is essentially an Arduino Uno, and you can use the existing Uno configuration. It is more difficult (and not yet documented) if you're adding a new chip, or putting optiboot on a chip that normally uses a different bootloader. This is (will be) described at [AddingOptibootChipsToIde](https://github.com/Optiboot/optiboot/blob/master/Wiki/AddingOptibootChipsToIde.md). 6 | 7 | Much information about burning optiboot into ATmega chips for use in Arduino can be found in the Arduino forums, especially in [this thread](http://arduino.cc/forum/index.php/topic,64105.0.html). 8 | 9 | There are about three main methods of installing optiboot on an otherwise blank AVR chip. 10 | 11 | ## Installing using the Arduino IDE ## 12 | The Optiboot project here includes ONLY the bootloader, not any support for a chip or chip 13 | options in the "core" Arduino code. It also includes bootloaders for many chips, of which only a few are likely to be of interest to any one person. This means that while it is *possible* to "install" Optiboot in the IDE, this is no longer the preferred way to do thing. 14 | 15 | In recent years, since the introduction of installable 16 | 3rd party hardware in Arduino 1.6.4, open-source developers have been busy creating 17 | additional "boards" for the IDE that can be installed very easily. Many of these cores 18 | use Optiboot, or a modified version of Optiboot, as their bootloader, and the preferred 19 | method of installing "XXX processor with Optiboot bootloader" is to ignore this repository 20 | entirely, find a core for that processor, and use the board manager to install it. 21 | 22 | Here are some of the well-known and well-used "cores" that use Optiboot: 23 | 24 | * https://github.com/MCUdude/MiniCore (ATmega328, ATmega168, ATmega88, ATmega48 and ATmega8) 25 | * https://github.com/MCUdude/MightyCore (ATmega8535, ATmega16, ATmega32, ATmega164, ATmega324, ATmega644 and ATmega1284) 26 | * https://github.com/MCUdude/MegaCore (ATmega64, ATmega128, ATmega640, ATmega1280, ATmega1281, ATmega2560 and ATmega2561) 27 | * https://github.com/SpenceKonde/ATTinyCore (ATtiny 841, 828, 1634, 87, 167) 28 | 29 | 30 | If you are using a chip that is "supported" by the Arduino team, or by some other person who has provided files, you can install optiboot (or for that matter, any other bootloader) directly from the Arduino IDE. This usually has the following steps: 31 | 32 | 1. Install the files as directed, usually (for Arduino 1.0+) in a subdirectory of your personal sketch's ../hardware/ directory. Note that the formats of various files (notably boards.txt) have changed with different versions of the IDE, and you'll need to make sure that the files you have been provided match the version of the IDE you are using. 33 | 1. Connect a device programmer to the ISP connector of the target board, or via wires to an avr chip with appropriate support hardware in a protoboard, as per the instructions associated with that programmer. It will need to be a programmer of a type supported by the Arduino IDE in the tools/programmer Menu. You can use a 2nd Arduino with the ArduinoISP sketch as a programmer. The details are beyond the scope of this document, but are often discussed in the Arduino forums. 34 | 1. Running the Arduino IDE, select the tools/board of the target chip, and the tools/programmer of your programmer, and if necessary the tools/serial port of the programmer. 35 | 1. Select tools/Burn Bootloader 36 | 37 | ## Installing using a specialized bootloader loader sketch ## 38 | There are a couple of Arduino sketches that have been written to make it easier to reprogram Optiboot (or other SW) into other Arduinos, especially in bulk. One example is WestfW's [OptiLoader](https://github.com/WestfW/OptiLoader). Similar programs are available from [Adafruit](https://github.com/adafruit/Standalone-Arduino-AVR-ISP-programmer) and [Nick Gammon](http://www.gammon.com.au/forum/?id=11635). These typically contain a pre-loaded copy of some version of the bootloader for several different chips (OptiLoader supports ATmega8, ATmega168, ATmega328P, and ATmega328.) It's very fast and easy IF you have one of the supported targets: 39 | 40 | 1. Set up an existing Arduino with an Arduino to ISP connector and load the optiLoader sketch using the standard Arduino IDE. 41 | 1. For each target board, connect the ISP connector and hit the reset button on the optiLoader Arduino, or use the "G" command in the Serial Monitor. Programming the bootloader takes about 5 seconds, and reports status and information to the Arduino serial port. 42 | 43 | ## Installing using the optiboot repository Makefile ## 44 | We might assume that you're here at the optiboot code repository because you want to use optiboot on a chip that is NOT supported by another party, but is supposed to be supported by the optiboot in general. (An example might be the ATmega1280, which normally runs a different bootloader.) 45 | 46 | 1. Compile the appropriate binary target (ie "mega1280"), as described on the CompilingOptiboot page. 47 | 1. Connect a device programmer to your target as appropriate. 48 | 1. Edit the Makefile to make the ISPxxx variables correct for your programmer. Make sure that there is a "target\_isp" make target defined, or create it using the existing targets as examples. 49 | 1. Use a command like "make mega1280\_isp" to burn the bootloader. 50 | 1. You can also use avrdude at the command line, manually. Burning the bootloader is usually a two-step process: 51 | * "chip erase" the target and set the fuses and lockbits to allow writing to the bootloader section of the device 52 | * burn the bootloader at its defined address, and reset the lockbits to prevent accidental overwriting of the bootloader section. -------------------------------------------------------------------------------- /Wiki/Optiboot Basic Logic-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Optiboot/optiboot/4fe36af84972cc88c1450d5789ab0be0a8479e1d/Wiki/Optiboot Basic Logic-1.png -------------------------------------------------------------------------------- /Wiki/OtherVersions.md: -------------------------------------------------------------------------------- 1 | A number of people have modified some version of Optiboot to support additional features or communications channels, where I have decided for one reason or another NOT to merge those changes back into the main Optiboot source. Nevertheless, they're worth referencing here... 2 | 3 | Boot over TCP using Wiznet W5100 chip. As small as 1K. 4 | -------------------------------------------------------------------------------- /Wiki/Virtual-Boot-Partition.md: -------------------------------------------------------------------------------- 1 | # Virtual Boot Partition 2 | 3 | 1. What is a "Virtual Boot Partition"?
4 | VIRTUAL\_BOOT\_PARTITION (VBP for short) is a hack for implementing a bootloader on parts that don't have "start at the bootloader address after reset" support. Sometimes it could be useful for normal chips when changing or messing with fuses is impossible or not desired. 5 | 6 | 1. How does it work?
7 | During programming bootloader "cleverly substitutes" start vector of application (located at address 0) by jump to bootloader. This way bootloader is always run after reset. 8 | 9 | 1. How does the bootloader know where the application starts?
10 | Bootloader assumes that start of application is typical vector table generated by most compilers. When Optiboot change start vector, it saves original jump to another free vector. Typically it uses SPM_RDY vector, or WDT if SPM_RDY is unavailable. 11 | 12 | 1. I have chip without SPM_RDY and I need to use WDR vector in my code.
13 | It's possible to use an arbitrary vector by adding an additional option to CFLAGS: `-Dsave_vect_num=xxx` where xxx could be name of vector like `EE_RDY_vect_num` (see virboot8 target in Makefile) or even just number (see attiny84 target in Makefile.extras). In fact, any number could be used, even outside vector table. There is only one limitation: it **MUST** be located in first flash page! 14 | 15 | 1. I don't use a vector table. Can I use this anyway?
16 | Yes, as long as first instruction is **jmp** on chips with more than 8KB memory or **rjmp** on smaller memory devices. You must also provide another jump to store old jump by Optiboot.
17 | It could be done for example by adding `-Dsave_vect_num=1` to CFLAGS during compiling bootloader, and making beginning of application like this:
18 |     ` rjmp app`
19 |    ` rjmp nowhere`
20 | ` app:`
21 |    ` ... ;your code here`
22 | 23 | 1. How do I add VBP to chip XXX
24 | Check Makefile targets **virboot8**, **virboot328** or **attiny84** for examples.
25 | There are 2 things required:
26 | Add `-DVIRTUAL_BOOT_PARTITION` to CFLAGS
27 | Adjust (decrease) address in **.text** part of LDSECTIONS (for example in `--section-start=.text=0x1c00`) to fit larger bootloader in memory. 28 | 29 | 1. Any downsides of this feature?
30 | Sadly, there are 2 of them: 31 |
The Bootloader code is larger and doesn't fit in 512B. 32 |
It requires one unused vector to store original jump to application. And you must be sure that this vector will be unused by applications loaded by Optiboot with VBP enabled. -------------------------------------------------------------------------------- /Wiki/github-issue-labels: -------------------------------------------------------------------------------- 1 | Explanations for possibly mysterious labels used on Optiboot github "issues." 2 | 3 | Component-Docs - requires a fix in the documentation only 4 | Component-Makefiles - requires a change to the makefiles only 5 | Component-Scripts - changes to the scripts only 6 | Discussion - an "issue" that has significant "discussion" involved; may not be an actual bug. 7 | Duplicate 8 | help wanted - "official maintainers" don't have the parts or the interest. A request for someone in the community to provide a patch/pull request/etc. 9 | Invalid - the bug is reported in error, or determined not to exist. 10 | Maintainability - affects the ease of maintenance of the program. 11 | Not-our-issue - the actual problem is determined to lie outside of optiboot itself. 12 | OpSys-Linux 13 | OpSys-OSX 14 | OpSys-Windows 15 | Partly Done - come code has been added/merged, but there is more to do. 16 | Priority-Critical 17 | Priority-High 18 | Priority-Low 19 | Priority-Medium 20 | Question - more of a 21 | Regression - something that used to work correctly has broken 22 | Superseded - was a bug at one time, but is no longer present because of other changes. 23 | Type-Defect 24 | Type-Enhancement 25 | Type-newChip - request for a new chip; usually involves Makefile and pin_defs.h, but not actual program logic. 26 | Type-Other 27 | Type-Patch 28 | wontfix - describes a real problem that can't be fixed, or won't be fixed because we think it is outside the scope of Optiboot. 29 | 30 | -------------------------------------------------------------------------------- /Wiki/optiboot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Optiboot/optiboot/4fe36af84972cc88c1450d5789ab0be0a8479e1d/Wiki/optiboot.png -------------------------------------------------------------------------------- /docs/arduino-gcc-versions.md: -------------------------------------------------------------------------------- 1 | Arduino ships also avr-gcc. This is matrix of versions and changes 2 | based on Linux versions. 3 | 4 | 5 | | Arduino | avr-gcc | differences | test? | 6 | |---------|---------|-------------|-------| 7 | |<=1.0 |none? | | | 8 | |1.0.1 |4.3.2 |new| | 9 | |1.0.2 |4.3.2 |same as 1.0.1| | 10 | |1.0.3 |4.3.2 |same as 1.0.1| | 11 | |1.0.4 |4.3.2 |same as 1.0.1| | 12 | |1.0.5 |4.3.2 |same as 1.0.1| | 13 | |1.0.6 |4.3.2 |same as 1.0.1| yes | 14 | |1.5 |4.3.2 |same as 1.0.1| | 15 | |1.5.1 |4.3.2 |same as 1.0.1| | 16 | |1.5.2 |4.3.2 |same as 1.0.1| | 17 | |1.5.3 |4.3.2 |same as 1.0.1| | 18 | |1.5.4 |4.3.2 |same as 1.0.1| | 19 | |1.5.5 |4.3.2 |same as 1.0.1| | 20 | |1.5.6-r2 |4.3.2 |same as 1.0.1| | 21 | |1.5.7 |4.8.1 |toolchains upgrade, avrdude 6.0.1avrdude| | 22 | |1.5.8 |4.8.1 |same as 1.5.7| | 23 | |1.6.0 |4.8.1 |same as 1.5.7| | 24 | |1.6.1 |4.8.1 |toolchains upgrade, added ATmega48/88/168PB, ATA5702M322, ATA5782; added RAMSTART to io*.h| | 25 | |1.6.2 |packed | | | 26 | |1.6.3 |4.8.1 |toolchains upgrade, cleaned| | 27 | |1.6.4 |4.8.1 |almost the same as 1.6.1| | 28 | |1.6.5-r5 |4.8.1 |same as 1.6.4| | 29 | |1.6.6 |4.8.1 |same as 1.6.4| | 30 | |1.6.7 |4.8.1 |same as 1.6.4| | 31 | |1.6.8 |4.8.1 |same as 1.6.4| | 32 | |1.6.9 |4.8.1 |same as 1.6.4| yes | 33 | |1.6.10 |4.9.2 |toolchains upgrade, , avrdude 6.3 | | 34 | |1.6.11 |4.9.2 |same as 1.6.10, back to avrdude 6.0.1| | 35 | |1.6.12 |4.9.2 |same as 1.6.10, patched avrdude 6.3| | 36 | |1.6.13 |4.9.2 |same as 1.6.12| yes | 37 | |1.8.0 |4.9.2 |same as 1.6.12, another patch for avrdude 6.3 | | 38 | |1.8.1 |4.9.2 |same as 1.8.0| | 39 | |1.8.2 |4.9.2 |recompiled, new toolchains, lot of changes| | 40 | |1.8.3 |4.9.2 |same as 1.8.2| | 41 | |1.8.4 |4.9.2 |same as 1.8.2| | 42 | |1.8.5 |4.9.2 |same as 1.8.2| yes | 43 | |1.8.6 |5.4.0 |new toolchains, added ATmega328PB and ATmega324PB among others| | 44 | |1.8.7 |5.4.0 |same as 1.8.6| yes | 45 | -------------------------------------------------------------------------------- /docs/optiboot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Optiboot/optiboot/4fe36af84972cc88c1450d5789ab0be0a8479e1d/docs/optiboot.png -------------------------------------------------------------------------------- /docs/travis-ci.md: -------------------------------------------------------------------------------- 1 | # Travis-CI and Optiboot 2 | 3 | ## What is Travis? 4 | 5 | https://travis-ci.com is site which allows to make checking builds after 6 | every push of code to git repository. It could also check pull request. 7 | 8 | It nicely integrates with Github, so to enable it's enough to just 9 | install Travis' Github App from: https://github.com/marketplace/travis-ci 10 | 11 | Travis have also free plan for Open Source projects, so there is no 12 | cost involved. 13 | 14 | When installed, after every push a build is started on Travis-CI 15 | servers. After build finish, status of commit is updated, so everyone 16 | can see if build passed or failed. Clicking on details gives more 17 | information about which job(s) within all build failed and even direct 18 | output from virtual machine, so it's easy to check why something went 19 | wrong. 20 | 21 | Of course, Travis-CI also needs configuration to define what should 22 | be run to test code, so every project must have *.travis.yml* file 23 | and some others if external scripts are needed. 24 | 25 | ## Files 26 | 27 | ### .travis.yml 28 | 29 | Standard Travis-CI file with definitions of jobs. 30 | 31 | There are 2 stages of tests: 32 | - *check sizes*: there is only one build in this stage which compiles ALL 33 | targets specified in *.travis.yml* (variable *OPTIBOOT_TARGET* in matrix) 34 | agains ALL compilers marked with 'yes' from *arduino-gcc-versions.md* file 35 | plus latest Microchip's compiler for avr8. There are 2 tables produced 36 | at the end of build: one is output of current compilation and resulting 37 | sizes for every target or 'x' if build failed. Second one is based on 38 | online database of builds and gives comparison between current build 39 | and last commited into repository. Output is markdown compatible, so 40 | it could be just copied and pasted into Github comment to produce 41 | pretty table. 42 | - test: stage with separate build for every *OPTIBOOT_TARGET* against only 43 | one compiler specified in variable *TOOLS_VERSION*. In 'allow_failures' 44 | section there are targets known to fail and ignored in overall status 45 | of test. 46 | 47 | ### scripts/travis-build.sh 48 | 49 | Script used to build single target during 'test' stage. 50 | 51 | ## scripts/travis-check-sizes.sh 52 | 53 | Script used to build all targets using all compilers during 'check sizes' 54 | stage. 55 | 56 | ## scripts/travis-download.inc.sh 57 | 58 | Include script used to download and unpack tools. Used by *travis-build.sh* 59 | and *travis-check-sizes.sh* scripts. 60 | 61 | ## scripts/travis-env.inc.sh 62 | 63 | Helper script for local testing (on Linux) builds. It sets all necessary 64 | environment variables to make *travis-build.sh* or *travis-check-sizes.sh* 65 | on local machine. Need to be sourced from repository parent directory: 66 | ```bash 67 | . scripts/travis-env.inc.sh 68 | ``` 69 | 70 | ## scripts/travis-fill-cache.sh 71 | 72 | Helper script used by *travis-check-sizes.sh* to download and extract all 73 | needed compilers. It uses *docs/arduino-gcc-versions.md* file to find 74 | which Arduino version should be downloaded. 75 | -------------------------------------------------------------------------------- /optiboot/AS7/AS7-README.TXT: -------------------------------------------------------------------------------- 1 | Building Optiboot with Atmel Studio (or Microchip Studio.) 2 | 3 | This is made based on Atmel Studio version 7 (AS7) 4 | 5 | There is one "Solution" containing multiple projects, one project for each 6 | of the common Microchip Development boards that might "want" to use 7 | Optiboot. A big advantage of using AS7 with one of the development boards 8 | is that it allows for debugging using the AS7 debugging features (the 9 | development boards have built-in debug support as well.) 10 | 11 | Building: 12 | 13 | To use AS7 to build one of the Optiboot versions, open the "Optiboot.atsln" 14 | file from Studio (or double-click on it in Explorer.) 15 | 16 | "Build Solution" will compile all of the projects. To build a single 17 | project, select the desired project/board in the "Solution Explorer" and 18 | then use "Build xxx" from the Build menu. To debug, right-click on the 19 | project and select "Set as StartUp Project" before using "Start Debugging 20 | and Break" from the DEBUG menu. You may need to change he Debug "Tool" 21 | setting in the Project Properties as well (my experience is that if you have 22 | an actual hardware tool plugged in, AS will automatically offer it for 23 | selection.) 24 | 25 | 26 | How things work: 27 | 28 | All of the AS projects are built using an "external makefile", so they're 29 | not "real" AS projects in the sense that you could change toolchain settings 30 | and have them take effect. In theory, this means that you can add 31 | additional projects to support any of the other targets supported by the 32 | Optiboot Makefiles. In reality, there is an unknown problem with recursive 33 | makes, so that you have to (for example) build the curiosity4809 board as 34 | make -f Makefile.mega0 optiboot_atmega4809.hex UARTTX=B0 LED=F5 ... 35 | instead of 36 | makef Makefile.mega0 curiosity4809 37 | 38 | The Project should be set for the correct Device, the "Build" Panel should 39 | point to the .../bootloaders/optiboot/Makefile (or Makefile.mega0 for mega-0 40 | anx xTiny chips.) 41 | 42 | The "Build Commandline" should contain the makefile target, and also 43 | PACKS="$(DEVICE_STARTUP_ROOT)" if the chip is dependent on a Pack being 44 | installed. The "Build Events" should copy the .elf file produced by the 45 | makefile: 46 | copy optiboot_attiny817.elf $(MSBuildProjectName).elf 47 | 48 | The current Projects are all "flattened" somewhat from the directory 49 | structure that AS would have produced, but that requires manual editing and 50 | isn't necessary. 51 | 52 | For the sake of clarity, not all of the files actually used in an optiboot 53 | build are shown as "Solution Items." 54 | -------------------------------------------------------------------------------- /optiboot/AS7/Optiboot.atsln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Atmel Studio Solution File, Format Version 11.00 4 | VisualStudioVersion = 14.0.23107.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "Optiboot_xplained328p", "Projects\Optiboot_xplained328p.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}" 7 | EndProject 8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{3773CCBD-E79E-4D62-B530-E1CCDB09D098}" 9 | ProjectSection(SolutionItems) = preProject 10 | AS7-README.TXT = AS7-README.TXT 11 | ..\bootloaders\optiboot\boot_opt.h = ..\bootloaders\optiboot\boot_opt.h 12 | ..\bootloaders\optiboot\Makefile = ..\bootloaders\optiboot\Makefile 13 | ..\bootloaders\optiboot\Makefile.mega0 = ..\bootloaders\optiboot\Makefile.mega0 14 | ..\bootloaders\optiboot\optiboot.c = ..\bootloaders\optiboot\optiboot.c 15 | ..\bootloaders\optiboot\optiboot_x.c = ..\bootloaders\optiboot\optiboot_x.c 16 | ..\bootloaders\optiboot\parse_options.mk = ..\bootloaders\optiboot\parse_options.mk 17 | ..\bootloaders\optiboot\pin_defs.h = ..\bootloaders\optiboot\pin_defs.h 18 | ..\bootloaders\optiboot\pin_defs_x.h = ..\bootloaders\optiboot\pin_defs_x.h 19 | ..\bootloaders\optiboot\pins_rs485.h = ..\bootloaders\optiboot\pins_rs485.h 20 | ..\bootloaders\optiboot\pins_softuart.h = ..\bootloaders\optiboot\pins_softuart.h 21 | ..\bootloaders\optiboot\stk500.h = ..\bootloaders\optiboot\stk500.h 22 | EndProjectSection 23 | EndProject 24 | Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "Optiboot_xplained328pb", "Projects\Optiboot_xplained328pb.cproj", "{1FCE634C-064E-4861-B59B-3D67F19F4E73}" 25 | EndProject 26 | Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "Optiboot_xplained168pb", "Projects\Optiboot_xplained168pb.cproj", "{4743E9BB-60C9-40C5-BE56-B3E6D46FE724}" 27 | EndProject 28 | Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "Optiboot_Curiosity4809", "Projects\Optiboot_Curiosity4809.cproj", "{6227EE60-D2C9-4F42-A423-6FC8100D656A}" 29 | EndProject 30 | Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "Optiboot_Xplained817", "Projects\Optiboot_Xplained817.cproj", "{0DACDF0F-4DFB-40BD-9C7A-8EB6ADD06DF8}" 31 | EndProject 32 | Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "Optiboot_Curiosity3217", "Projects\Optiboot_Curiosity3217.cproj", "{4855869E-70EF-46C8-A56B-159D9DF9C08C}" 33 | EndProject 34 | Global 35 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 36 | Debug|AVR = Debug|AVR 37 | Release|AVR = Release|AVR 38 | EndGlobalSection 39 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 40 | {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.ActiveCfg = Debug|AVR 41 | {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.Build.0 = Debug|AVR 42 | {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.ActiveCfg = Release|AVR 43 | {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.Build.0 = Release|AVR 44 | {1FCE634C-064E-4861-B59B-3D67F19F4E73}.Debug|AVR.ActiveCfg = Debug|AVR 45 | {1FCE634C-064E-4861-B59B-3D67F19F4E73}.Debug|AVR.Build.0 = Debug|AVR 46 | {1FCE634C-064E-4861-B59B-3D67F19F4E73}.Release|AVR.ActiveCfg = Release|AVR 47 | {1FCE634C-064E-4861-B59B-3D67F19F4E73}.Release|AVR.Build.0 = Release|AVR 48 | {4743E9BB-60C9-40C5-BE56-B3E6D46FE724}.Debug|AVR.ActiveCfg = Debug|AVR 49 | {4743E9BB-60C9-40C5-BE56-B3E6D46FE724}.Debug|AVR.Build.0 = Debug|AVR 50 | {4743E9BB-60C9-40C5-BE56-B3E6D46FE724}.Release|AVR.ActiveCfg = Release|AVR 51 | {4743E9BB-60C9-40C5-BE56-B3E6D46FE724}.Release|AVR.Build.0 = Release|AVR 52 | {6227EE60-D2C9-4F42-A423-6FC8100D656A}.Debug|AVR.ActiveCfg = Debug|AVR 53 | {6227EE60-D2C9-4F42-A423-6FC8100D656A}.Debug|AVR.Build.0 = Debug|AVR 54 | {6227EE60-D2C9-4F42-A423-6FC8100D656A}.Release|AVR.ActiveCfg = Release|AVR 55 | {6227EE60-D2C9-4F42-A423-6FC8100D656A}.Release|AVR.Build.0 = Release|AVR 56 | {0DACDF0F-4DFB-40BD-9C7A-8EB6ADD06DF8}.Debug|AVR.ActiveCfg = Debug|AVR 57 | {0DACDF0F-4DFB-40BD-9C7A-8EB6ADD06DF8}.Debug|AVR.Build.0 = Debug|AVR 58 | {0DACDF0F-4DFB-40BD-9C7A-8EB6ADD06DF8}.Release|AVR.ActiveCfg = Release|AVR 59 | {0DACDF0F-4DFB-40BD-9C7A-8EB6ADD06DF8}.Release|AVR.Build.0 = Release|AVR 60 | {4855869E-70EF-46C8-A56B-159D9DF9C08C}.Debug|AVR.ActiveCfg = Debug|AVR 61 | {4855869E-70EF-46C8-A56B-159D9DF9C08C}.Debug|AVR.Build.0 = Debug|AVR 62 | {4855869E-70EF-46C8-A56B-159D9DF9C08C}.Release|AVR.ActiveCfg = Release|AVR 63 | {4855869E-70EF-46C8-A56B-159D9DF9C08C}.Release|AVR.Build.0 = Release|AVR 64 | EndGlobalSection 65 | GlobalSection(SolutionProperties) = preSolution 66 | HideSolutionNode = FALSE 67 | EndGlobalSection 68 | EndGlobal 69 | -------------------------------------------------------------------------------- /optiboot/AS7/Projects/Optiboot_Curiosity3217.componentinfo.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | Device 8 | Startup 9 | 10 | 11 | Atmel 12 | 1.9.0 13 | C:/Program Files (x86)\Atmel\Studio\7.0\Packs 14 | 15 | 16 | 17 | 18 | C:/Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\ATtiny_DFP\1.9.337\include\ 19 | 20 | include 21 | C 22 | 23 | 24 | include/ 25 | 26 | 27 | 28 | 29 | C:/Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\ATtiny_DFP\1.9.337\include\avr\iotn3217.h 30 | 31 | header 32 | C 33 | 2w4jXovAQpu2/KOPyxeSog== 34 | 35 | include/avr/iotn3217.h 36 | 37 | 38 | 39 | 40 | C:/Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\ATtiny_DFP\1.9.337\templates\main.c 41 | template 42 | source 43 | C Exe 44 | izQh6mt2zs6K/tWC7AU5ww== 45 | 46 | templates/main.c 47 | Main file (.c) 48 | 49 | 50 | 51 | C:/Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\ATtiny_DFP\1.9.337\templates\main.cpp 52 | template 53 | source 54 | C Exe 55 | mkKaE95TOoATsuBGv6jmxg== 56 | 57 | templates/main.cpp 58 | Main file (.cpp) 59 | 60 | 61 | 62 | C:/Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\ATtiny_DFP\1.9.337\gcc\dev\attiny3217 63 | 64 | libraryPrefix 65 | GCC 66 | 67 | 68 | gcc/dev/attiny3217 69 | 70 | 71 | 72 | 73 | ATtiny_DFP 74 | C:/Program Files (x86)/Atmel/Studio/7.0/Packs/Atmel/ATtiny_DFP/1.9.337/Atmel.ATtiny_DFP.pdsc 75 | 1.9.337 76 | true 77 | ATtiny3217 78 | 79 | 80 | 81 | Resolved 82 | Fixed 83 | true 84 | 85 | 86 | -------------------------------------------------------------------------------- /optiboot/AS7/Projects/Optiboot_Curiosity3217.cproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 2.0 5 | 7.0 6 | com.Atmel.AVRGCC8.C 7 | {4855869e-70ef-46c8-a56b-159d9df9c08c} 8 | ATtiny3217 9 | none 10 | Executable 11 | C 12 | $(MSBuildProjectName) 13 | .elf 14 | $(MSBuildProjectDirectory)\$(Configuration) 15 | Optiboot_Curiosity3217 16 | Optiboot_Curiosity3217 17 | Optiboot_Curiosity3217 18 | Native 19 | true 20 | false 21 | true 22 | true 23 | 0x20000000 24 | 25 | true 26 | exception_table 27 | 2 28 | 0 29 | 0 30 | 31 | com.atmel.avrdbg.tool.simulator 32 | 33 | 0x1E9522 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | com.atmel.avrdbg.tool.simulator 42 | 43 | 44 | Simulator 45 | 46 | 47 | 48 | 49 | 50 | 51 | -mmcu=attiny3217 -B "%24(PackRepoDir)\Atmel\ATtiny_DFP\1.9.337\gcc\dev\attiny3217" 52 | True 53 | True 54 | True 55 | True 56 | False 57 | True 58 | True 59 | 60 | 61 | NDEBUG 62 | 63 | 64 | 65 | 66 | %24(PackRepoDir)\Atmel\ATtiny_DFP\1.9.337\include\ 67 | 68 | 69 | Optimize for size (-Os) 70 | True 71 | True 72 | True 73 | 74 | 75 | libm 76 | 77 | 78 | 79 | 80 | %24(PackRepoDir)\Atmel\ATtiny_DFP\1.9.337\include\ 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | -mmcu=attiny3217 -B "%24(PackRepoDir)\Atmel\ATtiny_DFP\1.9.337\gcc\dev\attiny3217" 90 | True 91 | True 92 | True 93 | True 94 | False 95 | True 96 | True 97 | 98 | 99 | DEBUG 100 | 101 | 102 | 103 | 104 | %24(PackRepoDir)\Atmel\ATtiny_DFP\1.9.337\include\ 105 | 106 | 107 | Optimize debugging experience (-Og) 108 | True 109 | True 110 | Default (-g2) 111 | True 112 | 113 | 114 | libm 115 | 116 | 117 | 118 | 119 | %24(PackRepoDir)\Atmel\ATtiny_DFP\1.9.337\include\ 120 | 121 | 122 | Default (-Wa,-g) 123 | 124 | 125 | True 126 | $(MSBuildProjectDirectory)\..\..\bootloaders\optiboot 127 | optiboot_attiny3217.hex UARTTX=B2 TIMEOUT=8 LED=C0 BAUD_RATE=57600 PACKS="$(DEVICE_STARTUP_ROOT)" 128 | clean 129 | ..\..\bootloaders\optiboot\Makefile.mega0 130 | copy optiboot_attiny3217.elf $(MSBuildProjectName).elf 131 | 132 | 133 | 134 | -------------------------------------------------------------------------------- /optiboot/AS7/Projects/Optiboot_Curiosity4809.componentinfo.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | Device 8 | Startup 9 | 10 | 11 | Atmel 12 | 1.6.0 13 | C:/Program Files (x86)\Atmel\Studio\7.0\Packs 14 | 15 | 16 | 17 | 18 | C:/Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\ATmega_DFP\1.6.364\include\ 19 | 20 | include 21 | C 22 | 23 | 24 | include/ 25 | 26 | 27 | 28 | 29 | C:/Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\ATmega_DFP\1.6.364\include\avr\iom4809.h 30 | 31 | header 32 | C 33 | E1mt3ptORaPqOFQECBLDLA== 34 | 35 | include/avr/iom4809.h 36 | 37 | 38 | 39 | 40 | C:/Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\ATmega_DFP\1.6.364\templates\main.c 41 | template 42 | source 43 | C Exe 44 | smohjrhj7sM0bCdNcE2kjQ== 45 | 46 | templates/main.c 47 | Main file (.c) 48 | 49 | 50 | 51 | C:/Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\ATmega_DFP\1.6.364\templates\main.cpp 52 | template 53 | source 54 | C Exe 55 | mkKaE95TOoATsuBGv6jmxg== 56 | 57 | templates/main.cpp 58 | Main file (.cpp) 59 | 60 | 61 | 62 | C:/Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\ATmega_DFP\1.6.364\gcc\dev\atmega4809 63 | 64 | libraryPrefix 65 | GCC 66 | 67 | 68 | gcc/dev/atmega4809 69 | 70 | 71 | 72 | 73 | ATmega_DFP 74 | C:/Program Files (x86)/Atmel/Studio/7.0/Packs/Atmel/ATmega_DFP/1.6.364/Atmel.ATmega_DFP.pdsc 75 | 1.6.364 76 | true 77 | ATmega4809 78 | 79 | 80 | 81 | Resolved 82 | Fixed 83 | true 84 | 85 | 86 | -------------------------------------------------------------------------------- /optiboot/AS7/Projects/Optiboot_Xplained817.componentinfo.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | Device 8 | Startup 9 | 10 | 11 | Atmel 12 | 1.9.0 13 | C:/Program Files (x86)\Atmel\Studio\7.0\Packs 14 | 15 | 16 | 17 | 18 | C:/Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\ATtiny_DFP\1.9.337\include\ 19 | 20 | include 21 | C 22 | 23 | 24 | include/ 25 | 26 | 27 | 28 | 29 | C:/Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\ATtiny_DFP\1.9.337\include\avr\iotn817.h 30 | 31 | header 32 | C 33 | 7rUevk0MRKrAMXSkT6Lolw== 34 | 35 | include/avr/iotn817.h 36 | 37 | 38 | 39 | 40 | C:/Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\ATtiny_DFP\1.9.337\templates\main.c 41 | template 42 | source 43 | C Exe 44 | +IIsFvRvmws+RJv4YACspA== 45 | 46 | templates/main.c 47 | Main file (.c) 48 | 49 | 50 | 51 | C:/Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\ATtiny_DFP\1.9.337\templates\main.cpp 52 | template 53 | source 54 | C Exe 55 | mkKaE95TOoATsuBGv6jmxg== 56 | 57 | templates/main.cpp 58 | Main file (.cpp) 59 | 60 | 61 | 62 | C:/Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\ATtiny_DFP\1.9.337\gcc\dev\attiny817 63 | 64 | libraryPrefix 65 | GCC 66 | 67 | 68 | gcc/dev/attiny817 69 | 70 | 71 | 72 | 73 | ATtiny_DFP 74 | C:/Program Files (x86)/Atmel/Studio/7.0/Packs/Atmel/ATtiny_DFP/1.9.337/Atmel.ATtiny_DFP.pdsc 75 | 1.9.337 76 | true 77 | ATtiny817 78 | 79 | 80 | 81 | Resolved 82 | Fixed 83 | true 84 | 85 | 86 | -------------------------------------------------------------------------------- /optiboot/AS7/Projects/Optiboot_xplained168pb.componentinfo.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | Device 8 | Startup 9 | 10 | 11 | Atmel 12 | 1.6.0 13 | C:/Program Files (x86)\Atmel\Studio\7.0\Packs 14 | 15 | 16 | 17 | 18 | C:/Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\ATmega_DFP\1.6.364\include\ 19 | 20 | include 21 | C 22 | 23 | 24 | include/ 25 | 26 | 27 | 28 | 29 | C:/Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\ATmega_DFP\1.6.364\include\avr\iom168pb.h 30 | 31 | header 32 | C 33 | QqKdZQWO5OdEJ/I9dQokRQ== 34 | 35 | include/avr/iom168pb.h 36 | 37 | 38 | 39 | 40 | C:/Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\ATmega_DFP\1.6.364\templates\main.c 41 | template 42 | source 43 | C Exe 44 | 7I9Q+L4k+nPjLWVpVziPaA== 45 | 46 | templates/main.c 47 | Main file (.c) 48 | 49 | 50 | 51 | C:/Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\ATmega_DFP\1.6.364\templates\main.cpp 52 | template 53 | source 54 | C Exe 55 | mkKaE95TOoATsuBGv6jmxg== 56 | 57 | templates/main.cpp 58 | Main file (.cpp) 59 | 60 | 61 | 62 | C:/Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\ATmega_DFP\1.6.364\gcc\dev\atmega168pb 63 | 64 | libraryPrefix 65 | GCC 66 | 67 | 68 | gcc/dev/atmega168pb 69 | 70 | 71 | 72 | 73 | ATmega_DFP 74 | C:/Program Files (x86)/Atmel/Studio/7.0/Packs/Atmel/ATmega_DFP/1.6.364/Atmel.ATmega_DFP.pdsc 75 | 1.6.364 76 | true 77 | ATmega168PB 78 | 79 | 80 | 81 | Resolved 82 | Fixed 83 | true 84 | 85 | 86 | -------------------------------------------------------------------------------- /optiboot/AS7/Projects/Optiboot_xplained328p.componentinfo.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /optiboot/AS7/Projects/Optiboot_xplained328p.cproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2.0 5 | 7.0 6 | com.Atmel.AVRGCC8.C 7 | dce6c7e3-ee26-4d79-826b-08594b9ad897 8 | ATmega328P 9 | none 10 | Executable 11 | C 12 | $(MSBuildProjectName) 13 | .elf 14 | ..\..\bootloaders\optiboot 15 | Optiboot 16 | Optiboot_xplained328p 17 | Optiboot 18 | Native 19 | true 20 | false 21 | true 22 | true 23 | 0x20000000 24 | 25 | true 26 | exception_table 27 | 2 28 | 0 29 | 0 30 | 31 | com.atmel.avrdbg.tool.simulator 32 | 33 | 0x1E950F 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | com.atmel.avrdbg.tool.simulator 42 | 43 | 44 | Simulator 45 | 46 | 47 | 48 | 49 | 50 | 51 | -mmcu=atmega328p -B "%24(PackRepoDir)\Atmel\ATmega_DFP\1.6.364\gcc\dev\atmega328p" 52 | True 53 | True 54 | True 55 | True 56 | False 57 | True 58 | True 59 | 60 | 61 | NDEBUG 62 | 63 | 64 | 65 | 66 | %24(PackRepoDir)\Atmel\ATmega_DFP\1.6.364\include\ 67 | 68 | 69 | Optimize for size (-Os) 70 | True 71 | True 72 | True 73 | 74 | 75 | libm 76 | 77 | 78 | 79 | 80 | %24(PackRepoDir)\Atmel\ATmega_DFP\1.6.364\include\ 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | -mmcu=atmega328p -B "%24(PackRepoDir)\Atmel\ATmega_DFP\1.6.364\gcc\dev\atmega328p" 90 | True 91 | True 92 | True 93 | True 94 | False 95 | True 96 | True 97 | 98 | 99 | DEBUG 100 | 101 | 102 | 103 | 104 | %24(PackRepoDir)\Atmel\ATmega_DFP\1.6.364\include\ 105 | 106 | 107 | Optimize debugging experience (-Og) 108 | True 109 | True 110 | Default (-g2) 111 | True 112 | 113 | 114 | libm 115 | 116 | 117 | 118 | 119 | %24(PackRepoDir)\Atmel\ATmega_DFP\1.6.364\include\ 120 | 121 | 122 | Default (-Wa,-g) 123 | 124 | 125 | True 126 | $(MSBuildProjectDirectory)\..\..\bootloaders\optiboot 127 | xplained328p 128 | clean 129 | ..\..\bootloaders\optiboot\Makefile 130 | copy optiboot_atmega328.elf $(MSBuildProjectName).elf 131 | 132 | 133 | 134 | 135 | -------------------------------------------------------------------------------- /optiboot/AS7/Projects/Optiboot_xplained328pb.componentinfo.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | Device 8 | Startup 9 | 10 | 11 | Atmel 12 | 1.6.0 13 | C:/Program Files (x86)\Atmel\Studio\7.0\Packs 14 | 15 | 16 | 17 | 18 | C:/Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\ATmega_DFP\1.6.364\include\ 19 | 20 | include 21 | C 22 | 23 | 24 | include/ 25 | 26 | 27 | 28 | 29 | C:/Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\ATmega_DFP\1.6.364\include\avr\iom328pb.h 30 | 31 | header 32 | C 33 | G+eVwKFAkNNs30Jr6aGylg== 34 | 35 | include/avr/iom328pb.h 36 | 37 | 38 | 39 | 40 | C:/Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\ATmega_DFP\1.6.364\templates\main.c 41 | template 42 | source 43 | C Exe 44 | A2aesY99x/dOHbRIdMDQKg== 45 | 46 | templates/main.c 47 | Main file (.c) 48 | 49 | 50 | 51 | C:/Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\ATmega_DFP\1.6.364\templates\main.cpp 52 | template 53 | source 54 | C Exe 55 | mkKaE95TOoATsuBGv6jmxg== 56 | 57 | templates/main.cpp 58 | Main file (.cpp) 59 | 60 | 61 | 62 | C:/Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\ATmega_DFP\1.6.364\gcc\dev\atmega328pb 63 | 64 | libraryPrefix 65 | GCC 66 | 67 | 68 | gcc/dev/atmega328pb 69 | 70 | 71 | 72 | 73 | ATmega_DFP 74 | C:/Program Files (x86)/Atmel/Studio/7.0/Packs/Atmel/ATmega_DFP/1.6.364/Atmel.ATmega_DFP.pdsc 75 | 1.6.364 76 | true 77 | ATmega328PB 78 | 79 | 80 | 81 | Resolved 82 | Fixed 83 | true 84 | 85 | 86 | -------------------------------------------------------------------------------- /optiboot/AS7/Projects/Optiboot_xplained328pb.cproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2.0 5 | 7.0 6 | com.Atmel.AVRGCC8.C 7 | {1fce634c-064e-4861-b59b-3d67f19f4e73} 8 | ATmega328PB 9 | none 10 | Executable 11 | C 12 | $(MSBuildProjectName) 13 | .elf 14 | $(MSBuildProjectDirectory)\$(Configuration) 15 | Optiboot_xplained328pb 16 | Optiboot_xplained328pb 17 | Optiboot_xplained328pb 18 | Native 19 | true 20 | false 21 | true 22 | true 23 | 0x20000000 24 | 25 | true 26 | exception_table 27 | 2 28 | 0 29 | 0 30 | 31 | com.atmel.avrdbg.tool.simulator 32 | 33 | 0x1E9516 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | com.atmel.avrdbg.tool.simulator 42 | 43 | 44 | Simulator 45 | 46 | 47 | 48 | 49 | 50 | 51 | -mmcu=atmega328pb -B "%24(PackRepoDir)\Atmel\ATmega_DFP\1.6.364\gcc\dev\atmega328pb" 52 | True 53 | True 54 | True 55 | True 56 | False 57 | True 58 | True 59 | 60 | 61 | NDEBUG 62 | 63 | 64 | 65 | 66 | %24(PackRepoDir)\Atmel\ATmega_DFP\1.6.364\include\ 67 | 68 | 69 | Optimize for size (-Os) 70 | True 71 | True 72 | True 73 | 74 | 75 | libm 76 | 77 | 78 | 79 | 80 | %24(PackRepoDir)\Atmel\ATmega_DFP\1.6.364\include\ 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | -mmcu=atmega328pb -B "%24(PackRepoDir)\Atmel\ATmega_DFP\1.6.364\gcc\dev\atmega328pb" 90 | True 91 | True 92 | True 93 | True 94 | False 95 | True 96 | True 97 | 98 | 99 | DEBUG 100 | 101 | 102 | 103 | 104 | %24(PackRepoDir)\Atmel\ATmega_DFP\1.6.364\include\ 105 | 106 | 107 | Optimize debugging experience (-Og) 108 | True 109 | True 110 | Default (-g2) 111 | True 112 | 113 | 114 | libm 115 | 116 | 117 | 118 | 119 | %24(PackRepoDir)\Atmel\ATmega_DFP\1.6.364\include\ 120 | 121 | 122 | Default (-Wa,-g) 123 | 124 | 125 | True 126 | $(MSBuildProjectDirectory)\..\..\bootloaders\optiboot 127 | xplained328pb 128 | clean 129 | ..\..\bootloaders\optiboot\Makefile 130 | copy optiboot_atmega328.elf $(MSBuildProjectName).elf 131 | 132 | 133 | 134 | 135 | -------------------------------------------------------------------------------- /optiboot/AtmelStudio/xplained168pb.atsln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Atmel Studio Solution File, Format Version 11.00 4 | Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "xplained168pb", "xplained168pb.cproj", "{02F0BC88-77BD-42CC-A94C-4CC452F0F909}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|AVR = Debug|AVR 9 | Release|AVR = Release|AVR 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {02F0BC88-77BD-42CC-A94C-4CC452F0F909}.Debug|AVR.ActiveCfg = Debug|AVR 13 | {02F0BC88-77BD-42CC-A94C-4CC452F0F909}.Debug|AVR.Build.0 = Debug|AVR 14 | {02F0BC88-77BD-42CC-A94C-4CC452F0F909}.Release|AVR.ActiveCfg = Release|AVR 15 | {02F0BC88-77BD-42CC-A94C-4CC452F0F909}.Release|AVR.Build.0 = Release|AVR 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /optiboot/AtmelStudio/xplained168pb.atsuo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Optiboot/optiboot/4fe36af84972cc88c1450d5789ab0be0a8479e1d/optiboot/AtmelStudio/xplained168pb.atsuo -------------------------------------------------------------------------------- /optiboot/AtmelStudio/xplained328p.atsln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Atmel Studio Solution File, Format Version 11.00 4 | Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "xplained328p", "xplained328p.cproj", "{02F0BC88-77BD-42CC-A94C-4CC452F0F909}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|AVR = Debug|AVR 9 | Release|AVR = Release|AVR 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {02F0BC88-77BD-42CC-A94C-4CC452F0F909}.Debug|AVR.ActiveCfg = Debug|AVR 13 | {02F0BC88-77BD-42CC-A94C-4CC452F0F909}.Debug|AVR.Build.0 = Debug|AVR 14 | {02F0BC88-77BD-42CC-A94C-4CC452F0F909}.Release|AVR.ActiveCfg = Release|AVR 15 | {02F0BC88-77BD-42CC-A94C-4CC452F0F909}.Release|AVR.Build.0 = Release|AVR 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /optiboot/AtmelStudio/xplained328p.atsuo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Optiboot/optiboot/4fe36af84972cc88c1450d5789ab0be0a8479e1d/optiboot/AtmelStudio/xplained328p.atsuo -------------------------------------------------------------------------------- /optiboot/AtmelStudio/xplained328pb.atsln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Atmel Studio Solution File, Format Version 11.00 4 | Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "xplained328pb", "xplained328pb.cproj", "{02F0BC88-77BD-42CC-A94C-4CC452F0F909}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|AVR = Debug|AVR 9 | Release|AVR = Release|AVR 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {02F0BC88-77BD-42CC-A94C-4CC452F0F909}.Debug|AVR.ActiveCfg = Release|AVR 13 | {02F0BC88-77BD-42CC-A94C-4CC452F0F909}.Debug|AVR.Build.0 = Release|AVR 14 | {02F0BC88-77BD-42CC-A94C-4CC452F0F909}.Release|AVR.ActiveCfg = Release|AVR 15 | {02F0BC88-77BD-42CC-A94C-4CC452F0F909}.Release|AVR.Build.0 = Release|AVR 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /optiboot/AtmelStudio/xplained328pb.atsuo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Optiboot/optiboot/4fe36af84972cc88c1450d5789ab0be0a8479e1d/optiboot/AtmelStudio/xplained328pb.atsuo -------------------------------------------------------------------------------- /optiboot/bootloaders/optiboot/Makefile.1284: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for 40-pin AVR chips, including ATmega644 and ATmega1284 3 | # 4 | # * Copyright 2013-2015 by Bill Westfield. Part of Optiboot. 5 | # * This software is licensed under version 2 of the Gnu Public Licence. 6 | # * See optiboot.c for details. 7 | 8 | # Chip level targets 9 | # 10 | HELPTEXT += "target atmega644p - ATmega644p\n" 11 | atmega644p: TARGET = atmega644p 12 | atmega644p: MCU_TARGET = atmega644p 13 | atmega644p: CFLAGS += $(COMMON_OPTIONS) -DBIGBOOT 14 | atmega644p: AVR_FREQ ?= 16000000L 15 | atmega644p: CFLAGS += $(UART_CMD) 16 | atmega644p: $(PROGRAM)_atmega644p.hex 17 | ifndef PRODUCTION 18 | atmega644p: $(PROGRAM)_atmega644p.lst 19 | endif 20 | 21 | HELPTEXT += "target atmega1284 - ATmega1284p (40 pin, 128k)\n" 22 | atmega1284: TARGET = atmega1284p 23 | atmega1284: MCU_TARGET = atmega1284p 24 | atmega1284: CFLAGS += $(COMMON_OPTIONS) -DBIGBOOT 25 | atmega1284: AVR_FREQ ?= 16000000L 26 | atmega1284: CFLAGS += $(UART_CMD) 27 | atmega1284: $(PROGRAM)_atmega1284p.hex 28 | ifndef PRODUCTION 29 | atmega1284: $(PROGRAM)_atmega1284p.lst 30 | endif 31 | 32 | atmega1284p: atmega1284 33 | 34 | atmega1284_isp: atmega1284 35 | atmega1284_isp: TARGET = atmega1284p 36 | atmega1284_isp: MCU_TARGET = atmega1284p 37 | # 1024 byte boot 38 | atmega1284_isp: HFUSE ?= DE 39 | # Full Swing xtal (16MHz) 16KCK/14CK+65ms 40 | atmega1284_isp: LFUSE ?= F7 41 | # 2.7V brownout 42 | atmega1284_isp: EFUSE ?= FD 43 | atmega1284_isp: isp 44 | 45 | # 46 | # Board-level targets 47 | # 48 | 49 | # Sanguino has a minimum boot size of 1024 bytes, so enable extra functions 50 | # 51 | HELPTEXT += "target sanguino - ATmega644p board\n" 52 | sanguino: TARGET = $@ 53 | sanguino: CHIP = atmega644p 54 | sanguino: 55 | "$(MAKE)" $(CHIP) AVR_FREQ=16000000L LED=B0 56 | mv $(PROGRAM)_$(CHIP).hex $(PROGRAM)_$(TARGET).hex 57 | ifndef PRODUCTION 58 | mv $(PROGRAM)_$(CHIP).lst $(PROGRAM)_$(TARGET).lst 59 | endif 60 | 61 | sanguino_isp: sanguino 62 | sanguino_isp: TARGET = sanguino 63 | sanguino_isp: MCU_TARGET = atmega644p 64 | # 1024 byte boot 65 | sanguino_isp: HFUSE ?= DE 66 | # Full swing xtal (16MHz) 16KCK/14CK+65ms 67 | sanguino_isp: LFUSE ?= F7 68 | # 2.7V brownout 69 | sanguino_isp: EFUSE ?= FD 70 | sanguino_isp: isp 71 | 72 | HELPTEXT += "target mighty1284 - ManiacBug Mighty1284 board\n" 73 | mighty1284: TARGET = $@ 74 | mighty1284: CHIP = atmega1284p 75 | mighty1284: 76 | "$(MAKE)" $(CHIP) AVR_FREQ=16000000L LED=B7 77 | mv $(PROGRAM)_$(CHIP).hex $(PROGRAM)_$(TARGET).hex 78 | ifndef PRODUCTION 79 | mv $(PROGRAM)_$(CHIP).lst $(PROGRAM)_$(TARGET).lst 80 | endif 81 | 82 | mighty1284_isp: mighty1284 83 | mighty1284_isp: TARGET = mighty1284 84 | mighty1284_isp: MCU_TARGET = atmega1284p 85 | # 1024 byte boot 86 | mighty1284_isp: HFUSE ?= DE 87 | # Full swing xtal (16MHz) 16KCK/14CK+65ms 88 | mighty1284_isp: LFUSE ?= F7 89 | # 2.7V brownout 90 | mighty1284_isp: EFUSE ?= FD 91 | mighty1284_isp: isp 92 | 93 | HELPTEXT += "target bobuino - Crossroads 1284 board\n" 94 | bobuino: TARGET = $@ 95 | bobuino: CHIP = atmega1284p 96 | bobuino: 97 | "$(MAKE)" $(CHIP) AVR_FREQ=16000000L LED=B7 98 | mv $(PROGRAM)_$(CHIP).hex $(PROGRAM)_$(TARGET).hex 99 | ifndef PRODUCTION 100 | mv $(PROGRAM)_$(CHIP).lst $(PROGRAM)_$(TARGET).lst 101 | endif 102 | 103 | bobuino_isp: bobuino 104 | bobuino_isp: TARGET = bobuino 105 | bobuino_isp: MCU_TARGET = atmega1284p 106 | # 1024 byte boot 107 | bobuino_isp: HFUSE ?= DE 108 | # Full swing xtal (16MHz) 16KCK/14CK+65ms 109 | bobuino_isp: LFUSE ?= F7 110 | # 2.7V brownout 111 | bobuino_isp: EFUSE ?= FD 112 | bobuino_isp: isp 113 | 114 | # 115 | # Wicked Devices "Wildfire" boards (1284 with wireless!) 116 | # 117 | 118 | HELPTEXT += "target wildfirev2 - Wicked Devices board\n" 119 | wildfirev2: TARGET = $@ 120 | wildfirev2: CHIP = atmega1284p 121 | wildfirev2: 122 | "$(MAKE)" $(CHIP) AVR_FREQ=16000000L LED=B7 BAUD_RATE=1000000 123 | mv $(PROGRAM)_$(CHIP).hex $(PROGRAM)_$(TARGET).hex 124 | ifndef PRODUCTION 125 | mv $(PROGRAM)_$(CHIP).lst $(PROGRAM)_$(TARGET).lst 126 | endif 127 | 128 | wildfirev2_isp: wildfirev2 129 | wildfirev2_isp: TARGET = wildfirev2 130 | wildfirev2_isp: MCU_TARGET = atmega1284p 131 | # 1024 byte boot 132 | wildfirev2_isp: HFUSE ?= DE 133 | # Full swing xtal (16MHz) 16KCK/14CK+65ms 134 | wildfirev2_isp: LFUSE ?= F7 135 | # 2.7V brownout 136 | wildfirev2_isp: EFUSE ?= FD 137 | wildfirev2_isp: isp 138 | 139 | HELPTEXT += "target wildfirev3 - Wicked Devices board\n" 140 | wildfirev3: TARGET = $@ 141 | wildfirev3: CHIP = atmega1284p 142 | wildfirev3: 143 | "$(MAKE)" $(CHIP) AVR_FREQ=16000000L LED=B5 144 | mv $(PROGRAM)_$(CHIP).hex $(PROGRAM)_$(TARGET).hex 145 | ifndef PRODUCTION 146 | mv $(PROGRAM)_$(CHIP).lst $(PROGRAM)_$(TARGET).lst 147 | endif 148 | 149 | wildfirev3_isp: wildfirev3 150 | wildfirev3_isp: TARGET = wildfirev3 151 | wildfirev3_isp: MCU_TARGET = atmega1284p 152 | # 1024 byte boot 153 | wildfirev3_isp: HFUSE ?= DE 154 | # Full swing xtal (16MHz) 16KCK/14CK+65ms 155 | wildfirev3_isp: LFUSE ?= F7 156 | # 2.7V brownout 157 | wildfirev3_isp: EFUSE ?= FD 158 | wildfirev3_isp: isp 159 | -------------------------------------------------------------------------------- /optiboot/bootloaders/optiboot/Makefile.2560: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for 2560 AVR chips 3 | # 4 | # * Copyright 2013-2015 by Bill Westfield, Marek Wodzinski. Part of Optiboot. 5 | # * This software is licensed under version 2 of the Gnu Public Licence. 6 | # * See optiboot.c for details. 7 | 8 | # Chip level targets 9 | # 10 | HELPTEXT += "target atmega2560 - ATmega2560p (100pin, 256k)\n" 11 | atmega2560: TARGET = atmega2560 12 | atmega2560: MCU_TARGET = atmega2560 13 | atmega2560: CFLAGS += $(COMMON_OPTIONS) -DBIGBOOT 14 | atmega2560: AVR_FREQ ?= 16000000L 15 | atmega2560: CFLAGS += $(UART_CMD) 16 | atmega2560: $(PROGRAM)_atmega2560.hex 17 | ifndef PRODUCTION 18 | atmega2560: $(PROGRAM)_atmega2560.lst 19 | endif 20 | 21 | 22 | atmega2560_isp: atmega2560 23 | atmega2560_isp: TARGET = atmega2560 24 | atmega2560_isp: MCU_TARGET = atmega2560 25 | # 1024 byte boot, JTAG disabled 26 | atmega2560_isp: HFUSE ?= DE 27 | # Full Swing xtal (16MHz) 16KCK/14CK+65ms 28 | atmega2560_isp: LFUSE ?= F7 29 | # 2.7V brownout 30 | atmega2560_isp: EFUSE ?= FD 31 | atmega2560_isp: isp 32 | 33 | # 34 | # Board-level targets 35 | # 36 | 37 | # Arduino/Geniuno MEGA 256 has a minimum boot size of 1024 bytes, so enable extra functions 38 | # 39 | HELPTEXT += "target mega2560 - Arduino MEGA2560 board, 2560ADK\n" 40 | mega2560: TARGET = $@ 41 | mega2560: CHIP = atmega2560 42 | mega2560: 43 | "$(MAKE)" $(CHIP) AVR_FREQ=16000000L 44 | mv $(PROGRAM)_$(CHIP).hex $(PROGRAM)_$(TARGET).hex 45 | ifndef PRODUCTION 46 | mv $(PROGRAM)_$(CHIP).lst $(PROGRAM)_$(TARGET).lst 47 | endif 48 | 49 | mega2560_isp: mega256 50 | mega2560_isp: TARGET = mega2560 51 | mega2560_isp: MCU_TARGET = atmega2560 52 | # 1024 byte boot, JTAG disabled 53 | mega2560_isp: HFUSE ?= DE 54 | # Full swing xtal (16MHz) 16KCK/14CK+65ms 55 | mega2560_isp: LFUSE ?= F7 56 | # 2.7V brownout 57 | mega2560_isp: EFUSE ?= FD 58 | mega2560_isp: isp 59 | 60 | -------------------------------------------------------------------------------- /optiboot/bootloaders/optiboot/Makefile.atmel: -------------------------------------------------------------------------------- 1 | # 2 | # Support for the Atmel Xplained mini eval boards that are mostly 3 | # compatible with Arduino. (168pb, 328p, and 328pb chips.) 4 | # 5 | # Currently these all masquerade as 168 or 328p, because the IDE 6 | # does not yet have compiler support for the -pb variants. 7 | # 8 | # These boards have an mEDBG debug chip that: 9 | # 1) means that optiboot can only be programmed via Atmel Studio 10 | # 2) prevents optiboot from working at 115200bps. 11 | # 3) provides 16MHz (at 5V) via Xin on the chip. 12 | # 13 | # 14 | # 15 | HELPTEXT += "target xplained168pb - Atmel Xplained Mini 168pb Eval board\n" 16 | xplained168pb: TARGET = $@ 17 | xplained168pb: CHIP = atmega168 18 | xplained168pb: 19 | "$(MAKE)" $(CHIP) AVR_FREQ=16000000L BAUD_RATE=57600 20 | mv $(PROGRAM)_$(CHIP).hex $(PROGRAM)_$(TARGET).hex 21 | ifndef PRODUCTION 22 | mv $(PROGRAM)_$(CHIP).lst $(PROGRAM)_$(TARGET).lst 23 | endif 24 | 25 | HELPTEXT += "target xplained328pb - Atmel Xplained Mini 328pb Eval board\n" 26 | xplained328pb: TARGET = $@ 27 | xplained328pb: CHIP = atmega328 28 | xplained328pb: 29 | "$(MAKE)" $(CHIP) AVR_FREQ=16000000L BAUD_RATE=57600 30 | mv $(PROGRAM)_$(CHIP).hex $(PROGRAM)_$(TARGET).hex 31 | ifndef PRODUCTION 32 | mv $(PROGRAM)_$(CHIP).lst $(PROGRAM)_$(TARGET).lst 33 | endif 34 | 35 | HELPTEXT += "target xplained328p - Atmel Xplained Mini 328p Eval board\n" 36 | xplained328p: TARGET = $@ 37 | xplained328p: CHIP = atmega328 38 | xplained328p: 39 | "$(MAKE)" $(CHIP) AVR_FREQ=16000000L BAUD_RATE=57600 40 | mv $(PROGRAM)_$(CHIP).hex $(PROGRAM)_$(TARGET).hex 41 | ifndef PRODUCTION 42 | mv $(PROGRAM)_$(CHIP).lst $(PROGRAM)_$(TARGET).lst 43 | endif 44 | -------------------------------------------------------------------------------- /optiboot/bootloaders/optiboot/Makefile.custom: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for "custom" platforms. Add your board here. 3 | # 4 | # * Copyright 2013-2015 by Bill Westfield. Part of Optiboot. 5 | # * This software is licensed under version 2 of the Gnu Public Licence. 6 | # * See optiboot.c for details. 7 | 8 | 9 | HELPTEXT += "target wildfire - Wicked Devices Wildfire v1 board\n" 10 | wildfire: TARGET = $@ 11 | wildfire: CHIP = atmega1284p 12 | wildfire: 13 | "$(MAKE)" $(CHIP) AVR_FREQ=16000000L LED=B5 14 | mv $(PROGRAM)_$(CHIP).hex $(PROGRAM)_$(TARGET).hex 15 | ifndef PRODUCTION 16 | mv $(PROGRAM)_$(CHIP).lst $(PROGRAM)_$(TARGET).lst 17 | endif 18 | 19 | -------------------------------------------------------------------------------- /optiboot/bootloaders/optiboot/Makefile.extras: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for "other" implemented platforms. 3 | # 4 | # * Copyright 2013-2015 by Bill Westfield. Part of Optiboot. 5 | # * This software is licensed under version 2 of the Gnu Public Licence. 6 | # * See optiboot.c for details. 7 | # 8 | 9 | # 10 | # Extra chips (maybe) supported by optiboot 11 | # Note that these are usually only minimally tested. 12 | # 13 | 14 | # 15 | # ATmega88 16 | # 17 | HELPTEXT += "target atmega88 - ATmega88 or ATmega88p (28pin, 8k)\n" 18 | atmega88: TARGET = atmega88 19 | atmega88: MCU_TARGET = atmega88 20 | atmega88: CFLAGS += $(COMMON_OPTIONS) 21 | atmega88: AVR_FREQ ?= 16000000L 22 | atmega88: $(PROGRAM)_atmega88.hex 23 | atmega88: $(PROGRAM)_atmega88.lst 24 | 25 | atmega88_isp: atmega88 26 | atmega88_isp: TARGET = atmega88 27 | atmega88_isp: MCU_TARGET = atmega88 28 | # 2.7V brownout 29 | atmega88_isp: HFUSE ?= DD 30 | # Low power xtal (16MHz) 16KCK/14CK+65ms 31 | atmega88_isp: LFUSE ?= FF 32 | # 512 byte boot 33 | atmega88_isp: EFUSE ?= 04 34 | atmega88_isp: isp 35 | 36 | atmega88p_isp: atmega88 37 | atmega88p_isp: TARGET = atmega88 38 | atmega88p_isp: MCU_TARGET = atmega88p 39 | # 2.7V brownout 40 | atmega88p_isp: HFUSE ?= DD 41 | # Low power xtal (16MHz) 16KCK/14CK+65ms 42 | atmega88p_isp: LFUSE ?= FF 43 | # 512 byte boot 44 | atmega88p_isp: EFUSE ?= 04 45 | atmega88p_isp: isp 46 | 47 | # 48 | # ATmega168p [QFN32] 49 | # 50 | HELPTEXT += "target atmega168p - ATmega168p\n" 51 | atmega168p: TARGET = atmega168p 52 | atmega168p: MCU_TARGET = atmega168p 53 | atmega168p: CFLAGS += $(COMMON_OPTIONS) 54 | atmega168p: AVR_FREQ ?= 16000000L 55 | atmega168p: $(PROGRAM)_atmega168p_16MHz.hex 56 | atmega168p: $(PROGRAM)_atmega168p_16MHz.lst 57 | 58 | atmega168p_isp: atmega168p 59 | atmega168p_isp: TARGET = atmega168p 60 | # 2.7V brownout 61 | atmega168p_isp: HFUSE ?= DD 62 | # Low power xtal (16MHz) 16KCK/14CK+65ms 63 | atmega168p_isp: LFUSE ?= FF 64 | # 512 byte boot 65 | atmega168p_isp: EFUSE ?= 04 66 | atmega168p_isp: isp 67 | 68 | HELPTEXT += "target atmega16 - ATmega16 (40pin, 16k)\n" 69 | atmega16: TARGET = atmega16 70 | atmega16: MCU_TARGET = atmega16 71 | atmega16: CFLAGS += $(COMMON_OPTIONS) 72 | atmega16: AVR_FREQ ?= 16000000L 73 | atmega16: $(PROGRAM)_atmega16.hex 74 | atmega16: $(PROGRAM)_atmega16.lst 75 | 76 | # 77 | # ATmega32 78 | # 79 | HELPTEXT += "target atmega32 - ATmega32 (40pin, 32k)\n" 80 | atmega32: TARGET = atmega32 81 | atmega32: MCU_TARGET = atmega32 82 | atmega32: CFLAGS += $(COMMON_OPTIONS) 83 | atmega32: AVR_FREQ ?= 11059200L 84 | atmega32: $(PROGRAM)_atmega32.hex 85 | atmega32: $(PROGRAM)_atmega32.lst 86 | 87 | atmega32_isp: atmega32 88 | atmega32_isp: TARGET = atmega32 89 | atmega32_isp: MCU_TARGET = atmega32 90 | # No OCD or JTAG, SPIEN, CKOPT (for full swing xtal), Bootsize=512B 91 | atmega32_isp: HFUSE ?= CE 92 | # 2.7V brownout, 16MHz Xtal, 16KCK/14CK+65ms 93 | atmega32_isp: LFUSE ?= BF 94 | atmega32_isp: isp 95 | 96 | #Atmega128RFA1 97 | HELPTEXT += "target atmega128rfa1 - ATmega128RFA1 (100pin, 128k)\n" 98 | atmega128rfa1: MCU_TARGET = atmega128rfa1 99 | atmega128rfa1: CFLAGS += $(COMMON_OPTIONS) -DBIGBOOT $(UART_CMD) 100 | atmega128rfa1: AVR_FREQ ?= 16000000L 101 | atmega128rfa1: $(PROGRAM)_atmega128rfa1.hex 102 | ifndef PRODUCTION 103 | atmega128rfa1: $(PROGRAM)_atmega128rfa1.lst 104 | endif 105 | 106 | 107 | # 1MHz clocked platforms/boards 108 | # 109 | # These are capable of 9600 baud 110 | # 111 | 112 | luminet: TARGET = $@ 113 | luminet: CHIP = attiny84 114 | luminet: 115 | "$(MAKE)" $(CHIP) AVR_FREQ=1000000L LED_START_FLASHES=0 BAUD_RATE=9600 116 | mv $(PROGRAM)_$(CHIP).hex $(PROGRAM)_$(TARGET).hex 117 | mv $(PROGRAM)_$(CHIP).lst $(PROGRAM)_$(TARGET).lst 118 | 119 | luminet_isp: luminet 120 | luminet_isp: TARGET = luminet 121 | luminet_isp: MCU_TARGET = attiny84 122 | # Brownout disabled 123 | luminet_isp: HFUSE ?= DF 124 | # 1MHz internal oscillator, slowly rising power 125 | luminet_isp: LFUSE ?= 62 126 | # Self-programming enable 127 | luminet_isp: EFUSE ?= FE 128 | luminet_isp: isp 129 | 130 | -------------------------------------------------------------------------------- /optiboot/bootloaders/optiboot/Makefile.isp: -------------------------------------------------------------------------------- 1 | # Makefile.isp for Optiboot 2 | # Bill Westfield (WestfW@yahoo.com) March, 2013 3 | # $Id$ 4 | # 5 | # Instructions: 6 | # 7 | # This is a "daughter" Makefile that burns the bootloader using a ISP 8 | # device programmer. It is designed to inherit assorted variables from 9 | # the parent optiboot "Makefile"... Using a daughter makefile makes 10 | # certain variable manipulations more obvious. 11 | # 12 | # To burn bootloader .hex file, invoke the main Makefile using: 13 | # make diecimila_isp 14 | # make lilypad_isp 15 | # make ng_isp 16 | # etc... 17 | # 18 | # 19 | # Note: inherit paths/etc from parent Makefile. 20 | # 21 | #--------------------------------------------------------------------------- 22 | # 23 | # * Copyright 2013-2015 by Bill Westfield. Part of Optiboot. 24 | # * This software is licensed under version 2 of the Gnu Public Licence. 25 | # * See optiboot.c for details. 26 | # 27 | #--------------------------------------------------------------------------- 28 | 29 | # enter the parameters for the avrdude isp tool -b19200 30 | # 31 | 32 | # Inherit avrdude paths from top-level makefile 33 | AVRDUDE_ROOT ?= $(GCCROOT) 34 | AVRDUDE_CONF ?= -C$(TOOLROOT)/avr/etc/avrdude.conf 35 | 36 | # Default filename for the selected target 37 | FILENAME ?= $(PROGRAM)_$(TARGET).hex 38 | 39 | # These are the parameters for a usb-based STK500v2 programmer. 40 | # Exact type unknown. (historical Makefile values.) 41 | #ISPTOOL = stk500v2 42 | #ISPPORT = usb 43 | #ISPSPEED = -b 115200 44 | # 45 | # 46 | # These are parameters for using an Arduino with the ArduinoISP sketch 47 | # as the programmer. On a mac, for a particular Uno as programmer. 48 | ISPTOOL ?= stk500v1 49 | ISPPORT ?= /dev/tty.usbserial-FTD61T6Q 50 | ISPSPEED ?= -b19200 51 | 52 | 53 | 54 | # Not all chips have EFUSE. 55 | 56 | ifdef EFUSE 57 | EFUSE_CMD= -U efuse:w:0x$(EFUSE):m 58 | endif 59 | 60 | # Default lock fuse configuration (NO lock) 61 | LOCKFUSE ?= 2f# APP protect mode 1, BL protect mode 1 62 | 63 | # 64 | # avrdude commands to erase chip, unlock memory, and program fuses. 65 | # 66 | ISPFUSES = -e -u -U lock:w:0x$(LOCKFUSE):m $(EFUSE_CMD) \ 67 | -U hfuse:w:0x$(HFUSE):m -U lfuse:w:0x$(LFUSE):m 68 | 69 | 70 | # 71 | # avrdude commands to program the new bootloader, and protect the bootloader 72 | # space from accidental SPM writes. Note: "2f" allows boot section to be read 73 | # by the application, which is different than the arduino default. 74 | # 75 | ISPFLASH = -U flash:w:$(FILENAME) -U lock:w:0x$(LOCKFUSE):m 76 | 77 | # There are certain complicated caused by the fact that the default state 78 | # of a fuse is a "1" rather than a "0", especially with respect to fuse bits 79 | # that have not been implemented. Those would normally not be included, but 80 | # unimplemented fuses still default to being "1" 81 | # 82 | # the efuse should really be 0xf8; since, however, only the lower 83 | # three bits of that byte are used on the atmega168, avrdude gets 84 | # confused if you specify 1's for the higher bits, see: 85 | # http://tinker.it/now/2007/02/24/the-tale-of-avrdude-atmega168-and-extended-bits-fuses/ 86 | # 87 | # similarly, the lock bits should be 0xff instead of 0x3f (to 88 | # unlock the bootloader section) and 0xcf instead of 0x2f (to 89 | # lock it), but since the high two bits of the lock byte are 90 | # unused, avrdude would get confused. 91 | 92 | isp: $(FILENAME) 93 | $(AVRDUDE_ROOT)avrdude $(AVRDUDE_CONF) -c $(ISPTOOL) \ 94 | -p $(MCU_TARGET) -P $(ISPPORT) $(ISPSPEED) \ 95 | $(ISPFUSES) \ 96 | $(ISPFLASH) 97 | -------------------------------------------------------------------------------- /optiboot/bootloaders/optiboot/README.TXT: -------------------------------------------------------------------------------- 1 | This directory contains the Optiboot small bootloader for AVR 2 | microcontrollers, somewhat modified specifically for the Arduino 3 | environment. 4 | 5 | Optiboot is more fully described here: http://github.com/Optiboot/optiboot 6 | and is the work of Peter Knight (aka Cathedrow), building on work of Jason P 7 | Kyle, Spiff, and Ladyada. More recent maintenance and modifications are by 8 | Bill Westfield (aka WestfW) 9 | 10 | Arduino-specific issues are tracked as part of the Arduino project 11 | at http://github.com/arduino/Arduino 12 | 13 | 14 | Most of the information in this file is superseded by the wiki content at 15 | https://github.com/Optiboot/optiboot/wiki 16 | 17 | It's till here "just in case." 18 | 19 | ------------------------------------------------------------ 20 | 21 | Building optiboot for Arduino. 22 | 23 | Production builds of optiboot for Arduino are done on a Mac in "unix mode" 24 | using CrossPack-AVR-20100115. CrossPack tracks WINAVR (for windows), which 25 | is just a package of avr-gcc and related utilities, so similar builds should 26 | work on Windows or Linux systems. 27 | 28 | One of the Arduino-specific changes is modifications to the makefile to 29 | allow building optiboot using only the tools installed as part of the 30 | Arduino environment, or the Arduino source development tree. All three 31 | build procedures should yield identical binaries (.hex files) (although 32 | this may change if compiler versions drift apart between CrossPack and 33 | the Arduino IDE.) 34 | 35 | 36 | Building Optiboot in the Arduino IDE Install. 37 | 38 | Work in the .../hardware/arduino/bootloaders/optiboot/ and use the 39 | "omake " command, which just generates a command that uses 40 | the arduino-included "make" utility with a command like: 41 | make OS=windows ENV=arduino 42 | or make OS=macosx ENV=arduino 43 | On windows, this assumes you're using the windows command shell. If 44 | you're using a cygwin or mingw shell, or have one of those in your 45 | path, the build will probably break due to slash vs backslash issues. 46 | On a Mac, if you have the developer tools installed, you can use the 47 | Apple-supplied version of make. 48 | The makefile uses relative paths ("../../../tools/" and such) to find 49 | the programs it needs, so you need to work in the existing optiboot 50 | directory (or something created at the same "level") for it to work. 51 | 52 | 53 | Building Optiboot in the Arduino Source Development Install. 54 | 55 | In this case, there is no special shell script, and you're assumed to 56 | have "make" installed somewhere in your path. 57 | Build the Arduino source ("ant build") to unpack the tools into the 58 | expected directory. 59 | Work in Arduino/hardware/arduino/bootloaders/optiboot and use 60 | make OS=windows ENV=arduinodev 61 | or make OS=macosx ENV=arduinodev 62 | 63 | 64 | Programming Chips Using the _isp Targets 65 | 66 | The CPU targets have corresponding ISP targets that will actually 67 | program the bootloader into a chip. "atmega328_isp" for the atmega328, 68 | for example. These will set the fuses and lock bits as appropriate as 69 | well as uploading the bootloader code. 70 | 71 | ISP Targets in Version 5.0 and later: 72 | 73 | The isp targets are now built using a separate "Makefile.isp" makefile, 74 | which should make modification easier and more obvious. This also fixes 75 | the atmega8_isp target problem mentioned below. The default 76 | configuration assumes an ArduinoISP setup, but you will probably need to 77 | update at least the serial port, since those are different for each 78 | Arduino board and/or system/ 79 | 80 | 81 | ISP Targets in Version 4.6 and earlier: 82 | 83 | The older makefiles default to using a USB programmer, but you can use a 84 | serial programmer like ArduinoISP by changing the appropriate variables 85 | when you invoke make: 86 | 87 | make ISPTOOL=stk500v1 ISPPORT=/dev/tty.usbserial-A20e1eAN \ 88 | ISPSPEED=-b19200 atmega328_isp 89 | 90 | The "atmega8_isp" target does not currently work, because the mega8 91 | doesn't have the "extended" fuse that the generic ISP target wants to 92 | pass on to avrdude. You'll need to run avrdude manually. 93 | 94 | 95 | Standard Targets 96 | 97 | I've reduced the pre-built and source-version-controlled targets 98 | (.hex and .lst files included in the git repository) to just the 99 | three basic 16MHz targets: atmega8, atmega16, atmega328. 100 | -------------------------------------------------------------------------------- /optiboot/bootloaders/optiboot/baudcheck.c: -------------------------------------------------------------------------------- 1 | /* 2 | * baudcheck.c 3 | * Mar, 2013 by Bill Westfield (WestfW@yahoo.com) 4 | * Exercises in executing arithmetic code on a system that we can't count 5 | * on having the usual languages or tools installed. 6 | * 7 | * This little "C program" is run through the C preprocessor using the same 8 | * arguments as our "real" target (which should assure that it gets the 9 | * same values for clock speed and desired baud rate), and produces as 10 | * output a shell script that can be run through bash, and THAT in turn 11 | * writes the desired output... 12 | * 13 | * Note that the C-style comments are stripped by the C preprocessor. 14 | * 15 | * Copyright 2013-2015 by Bill Westfield. 16 | * This software is licensed under version 2 of the Gnu Public Licence. 17 | * See optiboot.c for details. 18 | */ 19 | 20 | /* 21 | * First strip any trailing "L" from the defined constants. To do this 22 | * we need to make the constants into shell variables first. 23 | */ 24 | bpsx=BAUD_RATE 25 | bps=${bpsx/L/} 26 | bps=${bps/U/} 27 | fcpux=F_CPU 28 | fcpu=${fcpux/L/} 29 | fcpu=${fcpu/U/} 30 | 31 | // echo f_cpu = $fcpu, baud = $bps 32 | /* 33 | * Compute the divisor 34 | */ 35 | #ifdef SINGLESPEED 36 | BAUD_SETTING=$(( ( ($fcpu + $bps * 8) / (($bps * 16))) - 1 )) 37 | #else 38 | BAUD_SETTING=$(( ( ($fcpu + $bps * 4) / (($bps * 8))) - 1 )) 39 | #endif 40 | // echo baud setting = $BAUD_SETTING 41 | 42 | /* 43 | * Based on the computer divisor, calculate the actual bitrate, 44 | * And the error. Since we're all integers, we have to calculate 45 | * the tenths part of the error separately. 46 | */ 47 | #ifdef SINGLESPEED 48 | BAUD_ACTUAL=$(( ($fcpu/(16 * (($BAUD_SETTING)+1))) )) 49 | #else 50 | BAUD_ACTUAL=$(( ($fcpu/(8 * (($BAUD_SETTING)+1))) )) 51 | #endif 52 | BAUD_ERROR=$(( (( 100*($BAUD_ACTUAL - $bps) ) / $bps) )) 53 | ERR_TS=$(( ((( 1000*($BAUD_ACTUAL - $bps) ) / $bps) - $BAUD_ERROR * 10) )) 54 | ERR_TENTHS=$(( ERR_TS > 0 ? ERR_TS: -ERR_TS )) 55 | 56 | /* 57 | * Print a nice message containing the info we've calculated 58 | */ 59 | echo BAUD RATE CHECK: Desired: $bps, Real: $BAUD_ACTUAL, UBRRL = $BAUD_SETTING, Difference=$BAUD_ERROR.$ERR_TENTHS\% 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /optiboot/bootloaders/optiboot/boot_opt.h: -------------------------------------------------------------------------------- 1 | // Get all the "standard" definitions from the official boot.h 2 | #include 3 | 4 | 5 | /* 6 | * Implement some optimized versions that will use OUT instead 7 | * of STS to write SPMCSR. 8 | * (However, omit the *_extended_short, since by the time you 9 | * need _extended_, the extra byte shouldn't be relevant any more) 10 | * 11 | * The C preprocessor can not determin at compile time whether SPMCSR is 12 | * "out of range" of the OUT instruction, but we CAN do that in the 13 | * assembler. We can even make it pretty with a macro. 14 | * With this modification, the _short functions should work on cpus 15 | * (like ATmega128) where STS is required. 16 | */ 17 | 18 | asm(".macro __wr_spmcsr p, v \n\t" 19 | ".if \\p > 0x57 \n\t" 20 | "sts \\p, \\v \n\t" 21 | ".else \n\t" 22 | "out \\p-0x20, \\v \n\t" 23 | ".endif \n\t" 24 | ".endm \n"); 25 | 26 | 27 | #if defined(__SPM_REG) 28 | 29 | #define __boot_page_fill_short(address, data) \ 30 | (__extension__({ \ 31 | __asm__ __volatile__ \ 32 | ( \ 33 | "movw r0, %3\n\t" \ 34 | "__wr_spmcsr %0, %1\n\t" \ 35 | "spm\n\t" \ 36 | "clr r1\n\t" \ 37 | : \ 38 | : "i" (_SFR_MEM_ADDR(__SPM_REG)), \ 39 | "r" ((uint8_t)__BOOT_PAGE_FILL), \ 40 | "z" ((uint16_t)address), \ 41 | "r" ((uint16_t)data) \ 42 | : "r0" \ 43 | ); \ 44 | })) 45 | 46 | #define __boot_page_erase_short(address) \ 47 | (__extension__({ \ 48 | __asm__ __volatile__ \ 49 | ( \ 50 | "__wr_spmcsr %0, %1\n\t" \ 51 | "spm\n\t" \ 52 | : \ 53 | : "i" (_SFR_MEM_ADDR(__SPM_REG)), \ 54 | "r" ((uint8_t)__BOOT_PAGE_ERASE), \ 55 | "z" ((uint16_t)address) \ 56 | ); \ 57 | })) 58 | 59 | #define __boot_page_write_short(address) \ 60 | (__extension__({ \ 61 | __asm__ __volatile__ \ 62 | ( \ 63 | "__wr_spmcsr %0, %1\n\t" \ 64 | "spm\n\t" \ 65 | : \ 66 | : "i" (_SFR_MEM_ADDR(__SPM_REG)), \ 67 | "r" ((uint8_t)__BOOT_PAGE_WRITE), \ 68 | "z" ((uint16_t)address) \ 69 | ); \ 70 | })) 71 | 72 | #define __boot_rww_enable_short() \ 73 | (__extension__({ \ 74 | __asm__ __volatile__ \ 75 | ( \ 76 | "__wr_spmcsr %0, %1\n\t" \ 77 | "spm\n\t" \ 78 | : \ 79 | : "i" (_SFR_MEM_ADDR(__SPM_REG)), \ 80 | "r" ((uint8_t)__BOOT_RWW_ENABLE) \ 81 | ); \ 82 | })) 83 | 84 | #endif // __SPM_REG 85 | 86 | #ifndef __boot_page_erase_short 87 | 88 | /* 89 | * if __SPM_REG didn't get defined by now, but we didn't exit it means 90 | * we have some sort of new-fangled chip that post-dates the version 91 | * of boot.h that we know about. In this case, it's possible that the 92 | * standard boot.h still has workable functions, so we'll alias those. 93 | */ 94 | 95 | #define __boot_page_fill_short(address, data) boot_page_fill(address, data) 96 | #define __boot_page_erase_short(address) boot_page_erase(address) 97 | #define __boot_page_write_short(address) boot_page_write(address) 98 | #define __boot_rww_enable_short() boot_rww_enable() 99 | 100 | #endif 101 | 102 | -------------------------------------------------------------------------------- /optiboot/bootloaders/optiboot/info.sh: -------------------------------------------------------------------------------- 1 | #%/bin/bash 2 | for f in $*; do 3 | echo 4 | echo $f 5 | avr-objcopy -I ihex -O binary $f /tmp/__optiboot_tmp.bin 6 | avr-strings -a /tmp/__optiboot_tmp.bin 7 | done 8 | rm /tmp/__optiboot_tmp.bin 9 | 10 | -------------------------------------------------------------------------------- /optiboot/bootloaders/optiboot/link_optiboot.ld: -------------------------------------------------------------------------------- 1 | /* Customized Linker script for Optiboot */ 2 | 3 | /* Copyright (C) 2014-2015 Free Software Foundation, Inc. 4 | Copyright (C) 2021 by William Westfield 5 | Copying and distribution of this script, with or without modification, 6 | are permitted in any medium without royalty provided the copyright 7 | notice and this notice are preserved. 8 | */ 9 | 10 | /* 11 | * this is based off of the default ATmega328 linker script, but it 12 | * has been generalized (since optiboot makes little use of the standard 13 | * chip-specific values), and also specialized to based start addresses 14 | * of the code on symbols passed from the C program, instead of needing 15 | * --section-start commands in the linker command line. 16 | * (The C program does this by using asm() statements to define absolute 17 | * symbols that the linker can see. 18 | * The .data and .bss segments are removed, since the bootloader must not 19 | * use them (and does its own memory management) (this has the added 20 | * "benefit" of spitting out error messages if the code DOES try to 21 | * use data or bss variables. 22 | */ 23 | 24 | OUTPUT_FORMAT("elf32-avr","elf32-avr","elf32-avr") 25 | __FUSE_REGION_LENGTH__ = DEFINED(__FUSE_REGION_LENGTH__) ? __FUSE_REGION_LENGTH__ : 1K; 26 | /* This makes the disassembly listings prettier */ 27 | __RAM__ = 0x800000; 28 | 29 | MEMORY 30 | { 31 | text (rx) : ORIGIN = __BOOT_START__, LENGTH = __BOOT_SIZE__ 32 | version (rx) : ORIGIN = __VERSION_START__, LENGTH = 2 33 | fuse (rw!x) : ORIGIN = 0x820000, LENGTH = __FUSE_REGION_LENGTH__ 34 | } 35 | 36 | SECTIONS 37 | { 38 | /* Read-only sections, merged into text segment: */ 39 | /* Internal text space or external memory. */ 40 | .text : 41 | { 42 | *(.vectors) 43 | KEEP(*(.vectors)) 44 | /* For data that needs to reside in the lower 64k of progmem. */ 45 | *(.progmem.gcc*) 46 | /* PR 13812: Placing the trampolines here gives a better chance 47 | that they will be in range of the code that uses them. */ 48 | . = ALIGN(2); 49 | *(.init0) /* Start here after reset. */ 50 | KEEP (*(.init0)) 51 | *(.init1) 52 | KEEP (*(.init1)) 53 | *(.init2) /* Clear __zero_reg__, set up stack pointer. */ 54 | KEEP (*(.init2)) 55 | *(.init3) 56 | KEEP (*(.init3)) 57 | *(.init4) /* Initialize data and BSS. */ 58 | KEEP (*(.init4)) 59 | *(.init5) 60 | KEEP (*(.init5)) 61 | *(.init6) /* C++ constructors. */ 62 | KEEP (*(.init6)) 63 | *(.init7) 64 | KEEP (*(.init7)) 65 | *(.init8) 66 | KEEP (*(.init8)) 67 | *(.init9) /* Call main(). */ 68 | KEEP (*(.init9)) 69 | *(.text) 70 | . = ALIGN(2); 71 | *(.text.*) 72 | . = ALIGN(2); 73 | *(.fini9) /* _exit() starts here. */ 74 | KEEP (*(.fini9)) 75 | *(.fini8) 76 | KEEP (*(.fini8)) 77 | *(.fini7) 78 | KEEP (*(.fini7)) 79 | *(.fini6) /* C++ destructors. */ 80 | KEEP (*(.fini6)) 81 | *(.fini5) 82 | KEEP (*(.fini5)) 83 | *(.fini4) 84 | KEEP (*(.fini4)) 85 | *(.fini3) 86 | KEEP (*(.fini3)) 87 | *(.fini2) 88 | KEEP (*(.fini2)) 89 | *(.fini1) 90 | KEEP (*(.fini1)) 91 | *(.fini0) /* Infinite loop after program termination. */ 92 | KEEP (*(.fini0)) 93 | _etext = . ; 94 | } > text 95 | .version __VERSION_START__ : 96 | { 97 | *(.version) 98 | } > text 99 | .fuse : 100 | { 101 | KEEP(*(.fuse)) 102 | KEEP(*(.lfuse)) 103 | KEEP(*(.hfuse)) 104 | KEEP(*(.efuse)) 105 | } > fuse 106 | /* Stabs debugging sections. */ 107 | .stab 0 : { *(.stab) } 108 | .stabstr 0 : { *(.stabstr) } 109 | .stab.excl 0 : { *(.stab.excl) } 110 | .stab.exclstr 0 : { *(.stab.exclstr) } 111 | .stab.index 0 : { *(.stab.index) } 112 | .stab.indexstr 0 : { *(.stab.indexstr) } 113 | .comment 0 : { *(.comment) } 114 | .note.gnu.build-id : { *(.note.gnu.build-id) } 115 | /* DWARF debug sections. 116 | Symbols in the DWARF debugging sections are relative to the beginning 117 | of the section so we begin them at 0. */ 118 | /* DWARF 1 */ 119 | .debug 0 : { *(.debug) } 120 | .line 0 : { *(.line) } 121 | /* GNU DWARF 1 extensions */ 122 | .debug_srcinfo 0 : { *(.debug_srcinfo) } 123 | .debug_sfnames 0 : { *(.debug_sfnames) } 124 | /* DWARF 1.1 and DWARF 2 */ 125 | .debug_aranges 0 : { *(.debug_aranges) } 126 | .debug_pubnames 0 : { *(.debug_pubnames) } 127 | /* DWARF 2 */ 128 | .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } 129 | .debug_abbrev 0 : { *(.debug_abbrev) } 130 | .debug_line 0 : { *(.debug_line .debug_line.* .debug_line_end ) } 131 | .debug_frame 0 : { *(.debug_frame) } 132 | .debug_str 0 : { *(.debug_str) } 133 | .debug_loc 0 : { *(.debug_loc) } 134 | .debug_macinfo 0 : { *(.debug_macinfo) } 135 | /* SGI/MIPS DWARF 2 extensions */ 136 | .debug_weaknames 0 : { *(.debug_weaknames) } 137 | .debug_funcnames 0 : { *(.debug_funcnames) } 138 | .debug_typenames 0 : { *(.debug_typenames) } 139 | .debug_varnames 0 : { *(.debug_varnames) } 140 | /* DWARF 3 */ 141 | .debug_pubtypes 0 : { *(.debug_pubtypes) } 142 | .debug_ranges 0 : { *(.debug_ranges) } 143 | /* DWARF Extension. */ 144 | .debug_macro 0 : { *(.debug_macro) } 145 | } 146 | -------------------------------------------------------------------------------- /optiboot/bootloaders/optiboot/make-ccversions: -------------------------------------------------------------------------------- 1 | # 2 | # Compile a couple of Optiboot variations using several different compilers 3 | # 4 | 5 | 6 | # A list of compilers that are available. 7 | # This is, um, 4.3.3, 4.6.2, 4.8.1, 4.9.2, and 5.4.0 8 | # 9 | COMPS=' 10 | /usr/local/CrossPack-AVR-20100115/bin/ 11 | /usr/local/CrossPack-AVR-20121207/bin/ 12 | /usr/local/CrossPack-AVR-48/bin/ 13 | /usr/local/avr8-atmel-20160624/bin/ 14 | /usr/local/avr8-Atmel-3.6.0.487/bin/ 15 | ' 16 | 17 | for c in $COMPS; do 18 | # Pretty print for readability 19 | echo 20 | echo 21 | echo =========================================================== 22 | echo Using compiler in $c 23 | $c/avr-gcc --version | head -1 24 | echo =========================================================== 25 | 26 | echo --------------- make GCCROOT=$c atmega328 27 | make GCCROOT=$c atmega328 28 | echo --------------- make GCCROOT=$c atmega1284 29 | make GCCROOT=$c atmega1284 30 | echo --------------- make GCCROOT=$c luminet 31 | make GCCROOT=$c luminet 32 | echo --------------- make GCCROOT=$c mega1280 33 | make GCCROOT=$c mega1280 34 | done 35 | -------------------------------------------------------------------------------- /optiboot/bootloaders/optiboot/makeall.arduino.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | make clean 3 | # 4 | # buildable platforms of somewhat questionable support level 5 | make lilypad $* 6 | make pro8 $* 7 | make pro16 $* 8 | make pro20 $* 9 | make atmega328_pro8 $* 10 | make sanguino $* 11 | make mega1280 $* 12 | make luminet $* 13 | make diecimila $* 14 | make bobuino $* 15 | make wildfirev2 $* 16 | make atmega1284 $* 17 | make atmega32 $* 18 | make atmega88 $* 19 | make atmega168p $* 20 | 21 | # 22 | # Atmel development board targets 23 | make xplained168pb $* 24 | make xplained328p $* 25 | make xplained328pb $* 26 | 27 | # 28 | # The "big three" standard bootloaders. 29 | # These need to be built AFTER the platforms, or they'll get renamed 30 | make atmega8 $* 31 | make atmega168 $* 32 | make atmega328 $* 33 | -------------------------------------------------------------------------------- /optiboot/bootloaders/optiboot/makeall.everycpu.sh: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile to make one image for each chip that optiboot supports. 3 | # includes Arduino, Spence Konde ATtinyCore, Hans MCUDude cores, and 4 | # some others. 5 | # this is mainly used to sanity check modifications, especially those 6 | # that are expected to cause "no binary changes" (you can diff the 7 | # resulting .hex file with a reference implementation.) 8 | # 9 | 10 | make clean 11 | 12 | #Attinycore 13 | make attiny841at16 14 | make attiny841at16ser1 15 | make attiny441at16 16 | make attiny441at16ser1 17 | make attiny87at16 18 | make attiny167at16 19 | make attiny1634at16 20 | make attiny1634at16ser1 21 | make attiny828at16 22 | make attiny88at16 23 | make attiny48at16 24 | make attiny85at16 25 | make attiny45at16 26 | make attiny84at16 27 | make attiny44at16 28 | make attiny861at16 29 | make attiny461at16 30 | 31 | # mega 32 | make mega2560 33 | make mega1280 34 | 35 | # usb 36 | make atmega8u2 LED=D5 LED_START_FLASHES=2 UART=1 37 | make atmega16u2 LED=D5 LED_START_FLASHES=2 UART=1 38 | make atmega32u2 LED=D5 LED_START_FLASHES=2 UART=1 39 | make atmega16u4 LED=C7 LED_START_FLASHES=0 UART=1 40 | make atmega32u4 LED=C7 LED_START_FLASHES=0 UART=1 41 | make atmega32u6 LED=C6 LED_START_FLASHES=2 UART=1 42 | make at90usb646 LED=C6 LED_START_FLASHES=2 UART=1 NODATE=1 BIGBOOT=1 43 | make at90usb647 LED=C6 LED_START_FLASHES=2 UART=1 NODATE=1 BIGBOOT=1 44 | make at90usb1286 LED=C6 LED_START_FLASHES=2 UART=1 NODATE=1 BIGBOOT=1 45 | make at90usb1287 LED=C6 LED_START_FLASHES=2 UART=1 NODATE=1 BIGBOOT=1 46 | 47 | # buildable platforms of somewhat questionable support level 48 | make lilypad 49 | make pro8 50 | make pro16 51 | make pro20 52 | make atmega328_pro8 53 | make sanguino 54 | make mega1280 55 | make luminet 56 | make diecimila 57 | make bobuino 58 | make wildfirev2 59 | make atmega1284 60 | make atmega32 61 | make atmega168p 62 | 63 | # Atmel development board targets 64 | make xplained168pb 65 | make xplained328p 66 | make xplained328pb 67 | 68 | # mcudude cores 69 | make atmega8 LED=B5 LED_START_FLASHES=2 UART=0 70 | make atmega16 LED=B0 LED_START_FLASHES=2 UART=0 71 | make atmega32 LED=B0 LED_START_FLASHES=2 UART=0 72 | make atmega64 LED=B5 LED_START_FLASHES=2 UART=0 BIGBOOT=1 NODATE=1 73 | make atmega88 LED=B5 LED_START_FLASHES=2 UART=0 74 | make atmega88p LED=B5 LED_START_FLASHES=2 UART=0 75 | make atmega88pb LED=B5 LED_START_FLASHES=2 UART=0 76 | make atmega128 LED=B5 LED_START_FLASHES=2 UART=0 BIGBOOT=1 NODATE=1 77 | make atmega162 LED=B0 LED_START_FLASHES=0 UART=0 78 | make atmega164a LED=B0 LED_START_FLASHES=2 UART=0 79 | make atmega164p LED=B0 LED_START_FLASHES=2 UART=0 80 | make atmega168 LED=B5 LED_START_FLASHES=2 UART=0 81 | make atmega168p LED=B5 LED_START_FLASHES=2 UART=0 82 | make atmega168pb LED=B5 LED_START_FLASHES=2 UART=0 83 | make atmega169 LED=B5 LED_START_FLASHES=2 UART=0 84 | make atmega169p LED=B5 LED_START_FLASHES=2 UART=0 85 | make atmega324a LED=B0 LED_START_FLASHES=2 UART=0 86 | make atmega324p LED=B0 LED_START_FLASHES=2 UART=0 87 | make atmega324pa LED=B0 LED_START_FLASHES=2 UART=0 88 | make atmega324pb LED=B0 LED_START_FLASHES=2 UART=0 89 | make atmega328 LED=B5 LED_START_FLASHES=2 UART=0 90 | make atmega328pb LED=B5 LED_START_FLASHES=2 UART=0 91 | make atmega329 LED=B5 LED_START_FLASHES=2 UART=0 92 | make atmega329p LED=B5 LED_START_FLASHES=2 UART=0 93 | make atmega640 LED=B7 LED_START_FLASHES=2 UART=0 BIGBOOT=1 NODATE=1 94 | make atmega644p LED=B0 LED_START_FLASHES=2 UART=0 BIGBOOT=1 NODATE=1 95 | make atmega649 LED=B5 LED_START_FLASHES=2 UART=0 BIGBOOT=1 NODATE=1 96 | make atmega649p LED=B5 LED_START_FLASHES=2 UART=0 BIGBOOT=1 NODATE=1 97 | make atmega1280 LED=B7 LED_START_FLASHES=2 UART=0 BIGBOOT=1 NODATE=1 98 | make atmega1281 LED=B5 LED_START_FLASHES=2 UART=0 BIGBOOT=1 NODATE=1 99 | make atmega1284 LED=B0 LED_START_FLASHES=2 UART=0 BIGBOOT=1 NODATE=1 100 | make atmega1284p LED=B0 LED_START_FLASHES=2 UART=0 BIGBOOT=1 NODATE=1 101 | make atmega2560 LED=B7 LED_START_FLASHES=2 UART=0 BIGBOOT=1 NODATE=1 102 | make atmega2561 LED=B5 LED_START_FLASHES=2 UART=0 BIGBOOT=1 NODATE=1 103 | make atmega3290 LED=B5 LED_START_FLASHES=2 UART=0 104 | make atmega3290p LED=B5 LED_START_FLASHES=2 UART=0 105 | make atmega6490 LED=B5 LED_START_FLASHES=2 UART=0 BIGBOOT=1 NODATE=1 106 | make atmega6490p LED=B5 LED_START_FLASHES=2 UART=0 BIGBOOT=1 NODATE=1 107 | make atmega8515 LED=B0 LED_START_FLASHES=2 UART=0 108 | make atmega8535 LED=B0 LED_START_FLASHES=2 UART=0 109 | 110 | # default generic platforms 111 | # These need to be built AFTER the platforms, or they'll get renamed 112 | make atmega8 113 | make atmega168 114 | make atmega328 115 | 116 | -------------------------------------------------------------------------------- /optiboot/bootloaders/optiboot/makeall.mega0.sh: -------------------------------------------------------------------------------- 1 | # xTiny 2 | export PACKS=/Downloads/Atmel.ATtiny_DFP.1.3.229 3 | 4 | make -f Makefile.mega0 version 5 | 6 | make -f Makefile.mega0 atmega4809 LED=D6 UARTTX=A0 7 | 8 | make -f Makefile.mega0 attiny402 LED=A3 TIMEOUT=8 UARTTX=A1 9 | make -f Makefile.mega0 attiny412 LED=A3 TIMEOUT=8 UARTTX=A6 10 | 11 | make -f Makefile.mega0 attiny804 LED=A3 TIMEOUT=8 UARTTX=A1 12 | make -f Makefile.mega0 attiny814 LED=A3 TIMEOUT=8 UARTTX=B2 13 | make -f Makefile.mega0 attiny406 LED=A3 TIMEOUT=8 UARTTX=A1 14 | make -f Makefile.mega0 attiny816 LED=A3 TIMEOUT=8 UARTTX=B2 15 | make -f Makefile.mega0 attiny1617 LED=A3 TIMEOUT=8 UARTTX=A1 16 | make -f Makefile.mega0 attiny3217 LED=A3 TIMEOUT=8 UARTTX=B2 17 | 18 | make -f Makefile.mega0 drazzy402 19 | make -f Makefile.mega0 drazzy814 20 | make -f Makefile.mega0 drazzy3216 21 | make -f Makefile.mega0 drazzy1607 22 | make -f Makefile.mega0 curiosity1607 23 | make -f Makefile.mega0 xplained416 24 | 25 | # Mega0 26 | export PACKS=/Downloads/Atmel.ATmega_DFP.1.3.300 27 | 28 | make -f Makefile.mega0 version 29 | 30 | make -f Makefile.mega0 atmega4809 LED=D6 UARTTX=A0 31 | make -f Makefile.mega0 atmega809 LED=D6 UARTTX=A4 32 | make -f Makefile.mega0 atmega1609 LED=D6 UARTTX=C0 33 | make -f Makefile.mega0 atmega3209 LED=D6 UARTTX=C4 34 | make -f Makefile.mega0 atmega4808 LED=D6 UARTTX=F0 35 | make -f Makefile.mega0 atmega4809 LED=D6 UARTTX=F4 36 | make -f Makefile.mega0 atmega4809 LED=D6 UARTTX=B0 37 | make -f Makefile.mega0 atmega4809 LED=D6 UARTTX=B4 38 | 39 | make -f Makefile.mega0 xplained4809 40 | make -f Makefile.mega0 freeduino4809 41 | make -f Makefile.mega0 freeduino4809chip 42 | make -f Makefile.mega0 curiosity4809 43 | make -f Makefile.mega0 xplained4809 44 | 45 | 46 | -------------------------------------------------------------------------------- /optiboot/bootloaders/optiboot/makeall.tiny.sh: -------------------------------------------------------------------------------- 1 | make clean 2 | 3 | make attiny841at184 $* 4 | make attiny841at147 $* 5 | make attiny841at110 $* 6 | make attiny841at921 $* 7 | make attiny841at737 $* 8 | make attiny841at20 $* 9 | make attiny841at16 $* 10 | make attiny841at12 $* 11 | make attiny841at8 $* 12 | make attiny841at8_int $* 13 | make attiny841at1 $* 14 | make attiny841at1_int $* 15 | 16 | make attiny841at184ser1 $* 17 | make attiny841at147ser1 $* 18 | make attiny841at110ser1 $* 19 | make attiny841at921ser1 $* 20 | make attiny841at737ser1 $* 21 | make attiny841at20ser1 $* 22 | make attiny841at16ser1 $* 23 | make attiny841at12ser1 $* 24 | make attiny841at8ser1 $* 25 | make attiny841at1ser1 $* 26 | make attiny841at8_intser1 $* 27 | make attiny841at1_intser1 $* 28 | 29 | make attiny441at184 $* 30 | make attiny441at147 $* 31 | make attiny441at110 $* 32 | make attiny441at921 $* 33 | make attiny441at737 $* 34 | make attiny441at20 $* 35 | make attiny441at16 $* 36 | make attiny441at12 $* 37 | make attiny441at8 $* 38 | make attiny441at8_int $* 39 | make attiny441at1 $* 40 | make attiny441at1_int $* 41 | 42 | make attiny441at184ser1 $* 43 | make attiny441at147ser1 $* 44 | make attiny441at110ser1 $* 45 | make attiny441at921ser1 $* 46 | make attiny441at737ser1 $* 47 | make attiny441at20ser1 $* 48 | make attiny441at16ser1 $* 49 | make attiny441at12ser1 $* 50 | make attiny441at8ser1 $* 51 | make attiny441at1ser1 $* 52 | make attiny441at8_intser1 $* 53 | make attiny441at1_intser1 $* 54 | 55 | make attiny87at184 $* 56 | make attiny87at147 $* 57 | make attiny87at110 $* 58 | make attiny87at921 $* 59 | make attiny87at737 $* 60 | make attiny87at20 $* 61 | make attiny87at16 $* 62 | make attiny87at12 $* 63 | make attiny87at8 $* 64 | make attiny87at1 $* 65 | 66 | make attiny167at184 $* 67 | make attiny167at147 $* 68 | make attiny167at110 $* 69 | make attiny167at921 $* 70 | make attiny167at737 $* 71 | make attiny167at20 $* 72 | make attiny167at16 $* 73 | make attiny167at12 $* 74 | make attiny167at8 $* 75 | make attiny167at1 $* 76 | 77 | make attiny1634at147 $* 78 | make attiny1634at110 $* 79 | make attiny1634at921 $* 80 | make attiny1634at737 $* 81 | make attiny1634at20 $* 82 | make attiny1634at16 $* 83 | make attiny1634at12 $* 84 | make attiny1634at8 $* 85 | make attiny1634at8_int $* 86 | make attiny1634at1 $* 87 | make attiny1634at1_int $* 88 | 89 | make attiny1634at147ser1 $* 90 | make attiny1634at110ser1 $* 91 | make attiny1634at921ser1 $* 92 | make attiny1634at737ser1 $* 93 | make attiny1634at20ser1 $* 94 | make attiny1634at16ser1 $* 95 | make attiny1634at12ser1 $* 96 | make attiny1634at8ser1 $* 97 | make attiny1634at8_intser1 $* 98 | make attiny1634at1ser1 $* 99 | make attiny1634at1_intser1 $* 100 | 101 | 102 | make attiny828at8 $* 103 | make attiny828at12 $* 104 | make attiny828at16 $* 105 | make attiny828at20 $* 106 | make attiny828at8_int $* 107 | make attiny828at1 $* 108 | make attiny828at1_int $* 109 | 110 | make attiny88at20 $* 111 | make attiny88at16 $* 112 | make attiny88at12 $* 113 | make attiny88at8 $* 114 | make attiny88at4 $* 115 | make attiny88at1 $* 116 | 117 | make attiny48at20 $* 118 | make attiny48at16 $* 119 | make attiny48at12 $* 120 | make attiny48at8 $* 121 | make attiny48at4 $* 122 | make attiny48at1 $* 123 | 124 | make attiny85at184 $* 125 | make attiny85at147 $* 126 | make attiny85at110 $* 127 | make attiny85at921 $* 128 | make attiny85at737 $* 129 | make attiny85at20 $* 130 | make attiny85at16 $* 131 | make attiny85at12 $* 132 | make attiny85at8 $* 133 | make attiny85at1 $* 134 | 135 | make attiny45at184 $* 136 | make attiny45at147 $* 137 | make attiny45at110 $* 138 | make attiny45at921 $* 139 | make attiny45at737 $* 140 | make attiny45at20 $* 141 | make attiny45at16 $* 142 | make attiny45at12 $* 143 | make attiny45at8 $* 144 | make attiny45at1 $* 145 | 146 | make attiny84at184 $* 147 | make attiny84at147 $* 148 | make attiny84at110 $* 149 | make attiny84at921 $* 150 | make attiny84at737 $* 151 | make attiny84at20 $* 152 | make attiny84at16 $* 153 | make attiny84at12 $* 154 | make attiny84at8 $* 155 | make attiny84at1 $* 156 | 157 | make attiny44at184 $* 158 | make attiny44at147 $* 159 | make attiny44at110 $* 160 | make attiny44at921 $* 161 | make attiny44at737 $* 162 | make attiny44at20 $* 163 | make attiny44at16 $* 164 | make attiny44at12 $* 165 | make attiny44at8 $* 166 | make attiny44at1 $* 167 | 168 | make attiny861at184 $* 169 | make attiny861at147 $* 170 | make attiny861at110 $* 171 | make attiny861at921 $* 172 | make attiny861at737 $* 173 | make attiny861at20 $* 174 | make attiny861at16 $* 175 | make attiny861at12 $* 176 | make attiny861at8 $* 177 | make attiny861at1 $* 178 | 179 | make attiny461at184 $* 180 | make attiny461at147 $* 181 | make attiny461at110 $* 182 | make attiny461at921 $* 183 | make attiny461at737 $* 184 | make attiny461at20 $* 185 | make attiny461at16 $* 186 | make attiny461at12 $* 187 | make attiny461at8 $* 188 | make attiny461at1 $* 189 | 190 | -------------------------------------------------------------------------------- /optiboot/bootloaders/optiboot/makeall.usbmcus.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | ################################################################################################## 5 | ## Modified to support AVR-USB-MCUs by Virtual Java ## 6 | ## https://github.com/Virtual-Java/optiboot ## 7 | ## ## 8 | ## Created by MCUdude for compiling Optiboot flash from source ## 9 | ## https://github.com/MCUdude/optiboot_flash ## 10 | ## ## 11 | ## Execute ./makeall to build all variants of this bootloader. ## 12 | ## Run $ chmod +x if this file isn't executable. ## 13 | ## ## 14 | ## This is the file contains all all make procedures for all microcontrollers. You can modify ## 15 | ## the mcu_and_params array if you want to add, remove or edit any of the settings. You can ## 16 | ## also modify the clock_and_baud array if you need other F_CPUs or baudrates. ## 17 | ## ## 18 | ## The table below shows the available precompiled bootloaders for the corresponding ## 19 | ## clock frequencies and baud rates. ## 20 | ## ## 21 | ## | | 1000000 | 500000 | 250000 | 230400 | 115200 | 57600 | 38400 | 19200 | 9600 | ## 22 | ## |-------------|---------|--------|--------|--------|--------|-------|-------|-------|------| ## 23 | ## | 20 MHz | | X | X | | X | | | X | | ## 24 | ## | 18.4320 MHz | | | | X | X | X | X | X | X | ## 25 | ## | 16 MHz | X | X | X | | X | | X | X | X | ## 26 | ## | 14.7456 MHz | | | | X | X | X | X | X | X | ## 27 | ## | 12 MHz | | X | X | | | X | | X | X | ## 28 | ## | 11.0592 MHz | | | | X | X | X | X | X | X | ## 29 | ## | 8 MHz | X | X | X | | X | X | X | X | X | ## 30 | ## | 7.3728 MHz | | | | X | X | X | X | X | X | ## 31 | ## | 4 MHz | | X | X | | | | | X | X | ## 32 | ## | 3.6864 MHz | | | | X | X | X | X | X | X | ## 33 | ## | 2 MHz | | | X | | | | | X | X | ## 34 | ## | 1.8432 MHz | | | | X | X | X | X | X | X | ## 35 | ## | 1 MHz | | | | | | | | | X | ## 36 | ## ## 37 | ################################################################################################## 38 | 39 | declare -a mcu_and_params=( 40 | "atmega8u2" "LED=D5 LED_START_FLASHES=2 UART=1" 41 | "atmega16u2" "LED=D5 LED_START_FLASHES=2 UART=1" 42 | "atmega32u2" "LED=D5 LED_START_FLASHES=2 UART=1" 43 | "atmega16u4" "LED=C7 LED_START_FLASHES=0 UART=1" # disable blinking the LED to make the bootloader to fit in 512 Bytes Bootsection 44 | "atmega32u4" "LED=C7 LED_START_FLASHES=0 UART=1" # disable blinking the LED to make the bootloader to fit in 512 Bytes Bootsection 45 | "atmega32u6" "LED=C6 LED_START_FLASHES=2 UART=1" # for some reason it is not necessary to disable blinking the LED for this device 46 | "at90usb646" "LED=C6 LED_START_FLASHES=2 UART=1 BIGBOOT=1" # enable bigboot since at90usbXYZS devices have minimal bootsection of 1048 Bytes 47 | "at90usb647" "LED=C6 LED_START_FLASHES=2 UART=1 BIGBOOT=1" # enable bigboot since at90usbXYZS devices have minimal bootsection of 1048 Bytes 48 | "at90usb1286" "LED=C6 LED_START_FLASHES=2 UART=1 BIGBOOT=1" # enable bigboot since at90usbXYZS devices have minimal bootsection of 1048 Bytes 49 | "at90usb1287" "LED=C6 LED_START_FLASHES=2 UART=1 BIGBOOT=1" # enable bigboot since at90usbXYZS devices have minimal bootsection of 1048 Bytes 50 | ) 51 | 52 | declare -a clock_and_baud=( 53 | # "20000000L" "500000" 54 | "20000000L" "250000" 55 | "20000000L" "115200" 56 | # "20000000L" "19200" 57 | # "18432000L" "230400" 58 | # "18432000L" "115200" 59 | # "18432000L" "57600" 60 | # "18432000L" "38400" 61 | # "18432000L" "19200" 62 | # "18432000L" "9600" 63 | # "16000000L" "1000000" 64 | # "16000000L" "500000" 65 | "16000000L" "250000" 66 | "16000000L" "115200" 67 | # "16000000L" "38400" 68 | # "16000000L" "19200" 69 | # "16000000L" "9600" 70 | # "14745600L" "230400" 71 | # "14745600L" "115200" 72 | # "14745600L" "57600" 73 | # "14745600L" "38400" 74 | # "14745600L" "19200" 75 | # "14745600L" "9600" 76 | # "12000000L" "500000" 77 | # "12000000L" "250000" 78 | #"12000000L" "57600" 79 | # "12000000L" "19200" 80 | # "12000000L" "9600" 81 | # "11059200L" "230400" 82 | # "11059200L" "115200" 83 | # "11059200L" "57600" 84 | # "11059200L" "38400" 85 | # "11059200L" "19200" 86 | # "11059200L" "9600" 87 | # "8000000L" "1000000" 88 | # "8000000L" "500000" 89 | "8000000L" "250000" 90 | "8000000L" "115200" 91 | "8000000L" "57600" 92 | # "8000000L" "38400" 93 | # "8000000L" "19200" 94 | # "8000000L" "9600" 95 | # "7372800L" "230400" 96 | # "7372800L" "115200" 97 | # "7372800L" "57600" 98 | # "7372800L" "38400" 99 | # "7372800L" "19200" 100 | # "7372800L" "9600" 101 | # "4000000L" "500000" 102 | # "4000000L" "250000" 103 | # "4000000L" "19200" 104 | # "4000000L" "9600" 105 | # "3686400L" "230400" 106 | # "3686400L" "115200" 107 | # "3686400L" "57600" 108 | # "3686400L" "38400" 109 | # "3686400L" "19200" 110 | # "3686400L" "9600" 111 | # "2000000L" "250000" 112 | # "2000000L" "19200" 113 | # "2000000L" "9600" 114 | # "1843200L" "230400" 115 | # "1843200L" "115200" 116 | # "1843200L" "57600" 117 | # "1843200L" "38400" 118 | # "1843200L" "19200" 119 | # "1843200L" "9600" 120 | # "1000000L" "9600" 121 | ) 122 | 123 | 124 | # Start out by deleting all previous generated files 125 | echo -e "\x1B[7m\n\nDeleting all previous generated files \x1B[0m" 126 | #make clean_all 127 | make clean 128 | 129 | # Loop through all MCUs and parameters 130 | for((i=0; i < ${#mcu_and_params[@]}; i+=2)); 131 | do 132 | # Loop through all clock speeds and baud rated 133 | for((j=0; j < ${#clock_and_baud[@]}; j+=2)); 134 | do 135 | # Count how many builds that have been ran 136 | COUNTER=$(($COUNTER + 1)) 137 | echo -e "\x1B[7m\n\n$COUNTER of $((${#mcu_and_params[@]} * ${#clock_and_baud[@]} / 4))" 138 | # Print out current build info 139 | echo -e " ${mcu_and_params[$i]} AVR_FREQ=${clock_and_baud[$j]} BAUD_RATE=${clock_and_baud[$j+1]} ${mcu_and_params[$i+1]} \x1B[0m" 140 | # Build 141 | make ${mcu_and_params[$i]} AVR_FREQ=${clock_and_baud[$j]} BAUD_RATE=${clock_and_baud[$j+1]} ${mcu_and_params[$i+1]} $* 142 | done 143 | done 144 | 145 | # Finish up by removing all *.lst files 146 | echo -e "\x1B[7m\n\nDeleting all generated *.lst files \x1B[0m" 147 | make clean_asm 148 | -------------------------------------------------------------------------------- /optiboot/bootloaders/optiboot/makeoptions: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | make clean 3 | # 4 | 5 | # don't build most of the targets already in makeall 6 | 7 | # The "big three" standard bootloaders. 8 | # These need to be built AFTER the platforms, or they'll get renamed 9 | make atmega8 10 | make virboot8 11 | make atmega168 12 | make atmega328 13 | make virboot328 14 | 15 | make atmega328 BIGBOOT=1 16 | make atmega328 SUPPORT_EEPROM=1 LED_START_FLASHES=0 LED_START_ON=1 17 | make atmega328 BAUD_RATE=19200 18 | make atmega328 SOFT_UART=1 19 | make atmega328 LED_START_FLASHES=20 20 | 21 | make atmega1284 UART=1 LED=A1 22 | 23 | echo -------------------------------------------------- 24 | echo Expected to fail !!!! 25 | echo -------------------------------------------------- 26 | 27 | # too big 28 | make atmega328 SUPPORT_EEPROM=1 29 | # no such port 30 | make atmega328 LED=J1 31 | # no such led 32 | make atmega328 LED=fred 33 | # no such port 34 | make atmega328 UART=1 35 | # 36 | #invalid bit rates 37 | make atmega328 BAUD_RATE=300 38 | make atmega328 BAUD_RATE=3000000 39 | 40 | # ===========\ 41 | # usbmcus ==> 42 | # ===========/ 43 | 44 | # atmegaXYu4 45 | make atmega8u2 LED=D5 BAUD_RATE=115200 # default 46 | make atmega16u2 LED=D5 BAUD_RATE=115200 # default 47 | make atmega32u2 LED=D5 BAUD_RATE=115200 # default 48 | 49 | # atmegaXYu4 50 | # disable led blinking at startup to save memory 51 | make atmega16u4 LED=C7 LED_START_FLASHES=0 # default 52 | make atmega32u4 LED=C7 LED_START_FLASHES=0 # default 53 | # use a 1048 Byte bootsection to enable the led 54 | make atmega16u4 LED=C7 LED_START_FLASHES=2 BIGBOOT=1 55 | make atmega32u4 LED=C7 LED_START_FLASHES=2 BIGBOOT=1 56 | make atmega32u6 LED=C6 LED_START_FLASHES=2 # default 57 | 58 | # at90usbXYZ6/7 59 | make at90usb646 LED=C6 LED_START_FLASHES=2 BIGBOOT=1 # default 60 | make at90usb647 LED=C6 LED_START_FLASHES=2 BIGBOOT=1 # default 61 | make at90usb1286 LED=C6 LED_START_FLASHES=2 BIGBOOT=1 # default 62 | make at90usb1287 LED=C6 LED_START_FLASHES=2 BIGBOOT=1 # default 63 | -------------------------------------------------------------------------------- /optiboot/bootloaders/optiboot/omake: -------------------------------------------------------------------------------- 1 | #%/bin/bash 2 | if [ -d ../../../tools ]; then 3 | mypath=../../../tools/avr/bin 4 | else 5 | mypath=../../../../tools/avr/bin 6 | fi 7 | 8 | echo $mypath/make OS=macosx ENV=arduino $* 9 | $mypath/make OS=macosx ENV=arduino $* 10 | -------------------------------------------------------------------------------- /optiboot/bootloaders/optiboot/omake.bat: -------------------------------------------------------------------------------- 1 | call .\install-avr-tools.bat 2 | make %* 3 | -------------------------------------------------------------------------------- /optiboot/bootloaders/optiboot/optiboot_atmega1280.hex: -------------------------------------------------------------------------------- 1 | :020000021000EC 2 | :10FC000001C01DC1112484B7882369F0982F9A7010 3 | :10FC1000923049F081FF02C097EF94BF282E80E018 4 | :10FC2000F9D00C94000085E08093810082E08093FD 5 | :10FC3000C00088E18093C10086E08093C20080E12B 6 | :10FC40008093C4008EE0E6D0279A86E020E33CEF64 7 | :10FC500091E0309385002093840096BBB09BFECF4B 8 | :10FC60001F9AA8954091C00047FD02C0815089F7B6 9 | :10FC7000FF24F39455E0E52E61E1D62EBFD0813408 10 | :10FC800049F4BCD0C82FCCD0C13809F0A6C088E058 11 | :10FC9000AED0AAC0823411F484E103C0853419F4D3 12 | :10FCA00085E0C6D0A1C0853579F4A8D0082FA6D0AC 13 | :10FCB000182F87FF03C08BB7816002C08BB78E7F80 14 | :10FCC0008BBF000F111F8FC0863581F497D08D3404 15 | :10FCD00049F494D0CBB792D0C170880FC82BCBBF5A 16 | :10FCE00081E001C083E0A4D080E0D2CF843609F067 17 | :10FCF00048C084D0C82FD0E0DC2FCC277FD0C82BC1 18 | :10FD00007DD0C82E5E01812C32E0932E77D0F40195 19 | :10FD100081934F01F1E0AF1AB108C1F781D085E4BA 20 | :10FD2000C81212C0DE5F4801A12C92E0B92EAC16B9 21 | :10FD3000BD0609F459C0F50161915F01C40197D076 22 | :10FD4000FFEF8F1A9F0AF3CF83E0F80187BFE89592 23 | :10FD500007B600FCFDCFA0E0B2E0F8018D919D91C7 24 | :10FD60000C01F7BEE8951124229732962097B1F73F 25 | :10FD7000F801E7BEE89507B600FCFDCFD7BEE895D1 26 | :10FD800033C0843719F53AD0C82FD0E0DC2FCC2708 27 | :10FD900035D05E01A82A32D0982E42D0E801F5E491 28 | :10FDA0009F120BC0CE015BD022D081E0A81AB1080F 29 | :10FDB0002196A114B104B1F717C0FE018791EF019C 30 | :10FDC00016D0E1E0AE1AB108C1F70EC0853739F49C 31 | :10FDD00027D08EE10CD087E90AD083E059CF813556 32 | :10FDE00011F488E017D01CD080E101D047CF90916A 33 | :10FDF000C00095FFFCCF8093C60008958091C0009D 34 | :10FE000087FFFCCF8091C00084FD01C0A895809140 35 | :10FE1000C6000895E0E6F0E098E1908380830895BD 36 | :10FE2000EDDF803219F088E0F5DFFFCF84E1DFCF2E 37 | :10FE3000CF93C82FE3DFC150E9F7CF91F1CFFC0199 38 | :10FE40000A0167BFE895112407B600FCFDCF667074 39 | :10FE500029F0452B19F481E187BFE8950895F999B8 40 | :10FE6000FECF92BD81BDF89A992780B50895262FBF 41 | :10FE7000F999FECF1FBA92BD81BD20BD0FB6F8948F 42 | :10FE8000FA9AF99A0FBE01960895FF566572736942 43 | :10FE90006F6E3D382E33004465766963653D61744D 44 | :10FEA0006D6567613132383000465F4350553D31F2 45 | :10FEB000363030303030304C00424947424F4F549A 46 | :10FEC0003D31004275696C743A4E6F7620203420C3 47 | :10FED000323032313A31383A30333A3033005541EA 48 | :10FEE00052543D3000424155445F524154453D31EA 49 | :10FEF0003135323030004C45443D4237004C4544AA 50 | :10FF00005F53544152545F464C41534845533D332F 51 | :01FF100000F0 52 | :02FFFE000308F6 53 | :040000031000FC00ED 54 | :00000001FF 55 | -------------------------------------------------------------------------------- /optiboot/bootloaders/optiboot/optiboot_atmega328.hex: -------------------------------------------------------------------------------- 1 | :107E000001C0DAC0112484B7882361F0982F9A70DA 2 | :107E1000923041F081FF02C097EF94BF282E80E09E 3 | :107E2000B6D0EEC085E08093810082E08093C000F0 4 | :107E300088E18093C10086E08093C20080E1809356 5 | :107E4000C4008EE0A4D0259A86E020E33CEF91E0C8 6 | :107E5000309385002093840096BBB09BFECF1D9A83 7 | :107E6000A8954091C00047FD02C0815089F7EE24DB 8 | :107E7000E39495E0D92E21E1C22E7DD0813451F4D6 9 | :107E80007AD0182F8AD0113811F083E001C088E031 10 | :107E90006BD067C0823411F484E103C0853419F4D7 11 | :107EA00085E083D05EC0853539F465D0C82F63D0B6 12 | :107EB000D82FCC0FDD1F54C0863521F484E075D057 13 | :107EC00080E0E6CF843609F02EC055D054D0F82E8D 14 | :107ED00052D0B82E00E011E04ED0F80181938F010E 15 | :107EE000FE12FACF5AD0F5E4BF1201C0FFCF83E0F3 16 | :107EF000FE0187BFE89507B600FCFDCFA0E0B1E02A 17 | :107F0000FE018D919D910C01E7BEE89511243296FA 18 | :107F1000FA12F7CFFE01D7BEE89507B600FCFDCFF9 19 | :107F2000C7BEE8951EC0843771F425D024D0F82E42 20 | :107F300022D033D08E01F80185918F0115D0FA94AB 21 | :107F4000F110F9CF0EC0853739F427D08EE10CD06F 22 | :107F500085E90AD08FE09CCF813511F488E017D0F5 23 | :107F60001CD080E101D089CF9091C00095FFFCCF5B 24 | :107F70008093C60008958091C00087FFFCCF809158 25 | :107F8000C00084FD01C0A8958091C6000895E0E678 26 | :107F9000F0E098E1908380830895EDDF803219F05E 27 | :107FA00088E0F5DFFFCF84E1DFCFCF93C82FE3DF99 28 | :107FB000C150E9F7CF91F1CFFC010A0167BFE89505 29 | :107FC000112407B600FCFDCF667029F0452B19F48B 30 | :087FD00081E187BFE8950895E7 31 | :027FFE00030876 32 | :0400000300007E007B 33 | :00000001FF 34 | -------------------------------------------------------------------------------- /optiboot/bootloaders/optiboot/optiboot_atmega644p.hex: -------------------------------------------------------------------------------- 1 | :10FC000001C009C1112484B7882361F0982F9A702C 2 | :10FC1000923041F081FF02C097EF94BF282E80E020 3 | :10FC2000E5D0EEC185E08093810082E08093C00042 4 | :10FC300088E18093C10086E08093C20080E18093D8 5 | :10FC4000C4008EE0D3D0209A86E020E33CEF91E020 6 | :10FC5000309385002093840096BBB09BFECF189A0A 7 | :10FC6000A8954091C00047FD02C0815089F7FF244C 8 | :10FC7000F39455E0E52E61E1D62EACD0813451F4F9 9 | :10FC8000A9D0C82FB9D0C13811F083E001C088E0F5 10 | :10FC90009AD096C0823411F484E103C0853419F4FB 11 | :10FCA00085E0B2D08DC0853539F494D0082F92D03C 12 | :10FCB000182F000F111F83C0863521F484E0A4D0D3 13 | :10FCC00080E0E6CF843609F048C084D0C82FD0E069 14 | :10FCD000DC2FCC277FD0C82B7DD0C82E5E01812C95 15 | :10FCE0009924939477D0F40181934F01F1E0AF1AF6 16 | :10FCF000B108C1F781D085E4C81212C0D39548017C 17 | :10FD0000A12CBB24B394AC16BD0609F459C0F5016F 18 | :10FD100061915F01C40197D0FFEF8F1A9F0AF3CF63 19 | :10FD200083E0F80187BFE89507B600FCFDCFA0E0AF 20 | :10FD3000B1E0F8018D919D910C01F7BEE895112479 21 | :10FD4000229732962097B1F7F801E7BEE89507B6FB 22 | :10FD500000FCFDCFD7BEE89533C0843719F53AD003 23 | :10FD6000C82FD0E0DC2FCC2735D05E01A82A32D0B6 24 | :10FD7000982E42D0E801F5E49F120BC0CE015BD073 25 | :10FD800022D081E0A81AB1082196A114B104B1F7DC 26 | :10FD900017C0FE018591EF0116D0E1E0AE1AB1085F 27 | :10FDA000C1F70EC0853739F427D08EE10CD086E933 28 | :10FDB0000AD08AE06DCF813511F488E017D01CD0CD 29 | :10FDC00080E101D05ACF9091C00095FFFCCF809385 30 | :10FDD000C60008958091C00087FFFCCF8091C000CD 31 | :10FDE00084FD01C0A8958091C6000895E0E6F0E08A 32 | :10FDF00098E1908380830895EDDF803219F088E0E8 33 | :10FE0000F5DFFFCF84E1DFCFCF93C82FE3DFC15011 34 | :10FE1000E9F7CF91F1CFFC010A0167BFE895112402 35 | :10FE200007B600FCFDCF667029F0452B19F481E17F 36 | :10FE300087BFE8950895F999FECF92BD81BDF89AE4 37 | :10FE4000992780B50895262FF999FECF1FBA92BD44 38 | :10FE500081BD20BD0FB6F894FA9AF99A0FBE0196AB 39 | :10FE60000895FF56657273696F6E3D382E330044F6 40 | :10FE700065766963653D61746D65676136343470BC 41 | :10FE800000465F4350553D31363030303030304CD5 42 | :10FE900000424947424F4F543D31004275696C74EE 43 | :10FEA0003A4E6F7620203420323032313A31383AAF 44 | :10FEB00030333A313400554152543D3000424155BF 45 | :10FEC000445F524154453D313135323030004C456C 46 | :10FED000443D4230004C45445F53544152545F46C8 47 | :09FEE0004C41534845533D3300E9 48 | :02FFFE000308F6 49 | :040000030000FC00FD 50 | :00000001FF 51 | -------------------------------------------------------------------------------- /optiboot/bootloaders/optiboot/parse_options.mk: -------------------------------------------------------------------------------- 1 | # Make command-line Options for Optiboot, Optiboot-Mega0 2 | # Permit commands like "make atmega4809 LED_START_FLASHES=10" to pass the 3 | # appropriate parameters ("-DLED_START_FLASHES=10") to gcc 4 | # 5 | 6 | ifdef PRODUCTION 7 | ifneq ($(PRODUCTION),0) 8 | VERSION_CMD = -DPRODUCTION=1 9 | endif 10 | dummy = FORCE 11 | endif 12 | 13 | ifdef NODATE 14 | ifneq ($(NODATE),0) 15 | VERSION_CMD = -DPRODUCTION=1 16 | endif 17 | dummy = FORCE 18 | endif 19 | 20 | 21 | # Build Options 22 | 23 | HELPTEXT += "Option CUSTOM_VERSION=nn - set a customer version number\n" 24 | ifdef CUSTOM_VERSION 25 | ifneq ($(CUSTOM_VERSION), 0) 26 | VERSION_CMD = -DOPTIBOOT_CUSTOMVER=$(CUSTOM_VERSION) 27 | else 28 | VERSION_CMD = -DPRODUCTION=1 29 | endif 30 | dummy = FORCE 31 | endif 32 | 33 | HELPTEXT += "Option BIGBOOT=1 - enable extra features up to 1kbytes\n" 34 | # BIGBOOT: Include extra features, up to 1K. 35 | ifdef BIGBOOT 36 | ifneq ($(BIGBOOT), 0) 37 | BIGBOOT_CMD = -DBIGBOOT=1 38 | dummy = FORCE 39 | endif 40 | endif 41 | 42 | HELPTEXT += "Option SUPPORT_EEPROM=1 - Include code to read/write EEPROM\n" 43 | ifdef SUPPORT_EEPROM 44 | ifneq ($(SUPPORT_EEPROM), 0) 45 | SUPPORT_EEPROM_CMD = -DSUPPORT_EEPROM 46 | dummy = FORCE 47 | endif 48 | endif 49 | 50 | HELPTEXT += "Option NO_APP_SPM=1 - disallow application call of do_spm\n" 51 | ifdef NO_APP_SPM 52 | ifneq ($(NO_APP_SPM),0) 53 | APPSPM_CMD = -DAPP_NOSPM=1 54 | endif 55 | endif 56 | 57 | 58 | # LED options 59 | 60 | HELPTEXT += "Option LED=B3 - set LED pin to particular port/bit\n" 61 | ifdef LED 62 | LED_CMD = -DLED=$(LED) 63 | dummy = FORCE 64 | endif 65 | 66 | HELPTEXT += "Option LED_START_FLASHES=n - set number of LED flashes when bootloader starts\n" 67 | ifdef LED_START_FLASHES 68 | LED_START_FLASHES_CMD = -DLED_START_FLASHES=$(LED_START_FLASHES) 69 | dummy = FORCE 70 | else 71 | LED_START_FLASHES_CMD = -DLED_START_FLASHES=3 72 | endif 73 | 74 | HELPTEXT += "Option LED_DATA_FLASH=1 - flash the LED each time data is received.\n" 75 | ifdef LED_DATA_FLASH 76 | ifneq ($(LED_DATA_FLASH), 0) 77 | LED_DATA_FLASH_CMD = -DLED_DATA_FLASH=1 78 | dummy = FORCE 79 | endif 80 | endif 81 | 82 | HELPTEXT += "Option LED_START_ON=1 - Turn the LED on at bootload start\n" 83 | ifdef LED_START_ON 84 | ifneq ($(LED_START_ON), 0) 85 | LED_START_ON_CMD = -DLED_START_ON=1 86 | endif 87 | dummy = FORCE 88 | endif 89 | 90 | HELPTEXT += "Option LED_INVERT=1 - Invert the 'on' state of the LED\n" 91 | ifdef LED_INVERT 92 | ifneq ($(LED_INVERT), 0) 93 | LEDINV_CMD = -DLED_INVERT=1 94 | endif 95 | dummy = FORCE 96 | endif 97 | 98 | 99 | # UART options 100 | 101 | HELPTEXT += "Option BAUD_RATE=nnnn - set the bit rate for communications\n" 102 | ifdef BAUD_RATE 103 | BAUD_RATE_CMD = -DBAUD_RATE=$(BAUD_RATE) 104 | dummy = FORCE 105 | else 106 | BAUD_RATE_CMD = -DBAUD_RATE=115200 107 | endif 108 | 109 | HELPTEXT += "Option SOFT_UART=1 - use a software (bit-banged) UART\n" 110 | ifdef SOFT_UART 111 | ifneq ($(SOFT_UART), 0) 112 | SOFT_UART_CMD = -DSOFT_UART=1 113 | dummy = FORCE 114 | endif 115 | endif 116 | 117 | HELPTEXT += "Option SINGLESPEED=1 - do not use U2X mode on UART\n" 118 | ifdef SINGLESPEED 119 | ifneq ($(SINGLESPEED), 0) 120 | SS_CMD = -DSINGLESPEED=1 121 | endif 122 | endif 123 | 124 | HELPTEXT += "Option RS485=B0 - Pin for optional rs485 tx enable\n" 125 | ifdef RS485 126 | RS485_CMD = -DRS485=$(RS485) 127 | dummy = FORCE 128 | endif 129 | 130 | 131 | #CPU Options 132 | 133 | HELPTEXT += "Option TIMEOUT=n - set WDT to 1, 2, 4, or 8 seconds\n" 134 | ifdef TIMEOUT 135 | TIMEOUT_CMD = -DWDTTIME=$(TIMEOUT) 136 | dummy = FORCE 137 | endif 138 | 139 | HELPTEXT += "Option RESETPIN=0/1 - change RESET pin behavior\n" 140 | ifdef RESETPIN 141 | RESETPIN_CMD = -DRSTPIN=$(RESETPIN) 142 | dummy = FORCE 143 | endif 144 | 145 | ifdef AVR_FREQ 146 | FCPU_CMD = -DF_CPU=$(AVR_FREQ) 147 | dummy = FORCE 148 | endif 149 | 150 | HELPTEXT += "Option AVR_FREQ= - Clock rate of AVR CPU\n" 151 | 152 | HELPTEXT += "Option BOOT_ON_POR - Run bootloader on power-on\n" 153 | ifdef NO_START_APP_ON_POR 154 | ifneq ($(NO_START_APP_ON_POR),0) 155 | POR_CMD = -DNO_START_APP_ON_POR=1 156 | dummy = FORCE 157 | endif 158 | endif 159 | 160 | ifdef BOOT_ON_POR 161 | ifneq ($(NO_START_APP_ON_POR),0) 162 | POR_CMD = -DNO_START_APP_ON_POR=1 163 | dummy = FORCE 164 | endif 165 | endif 166 | 167 | 168 | LED_OPTIONS = $(LED_START_FLASHES_CMD) $(LED_DATA_FLASH_CMD) $(LED_CMD) $(LED_START_ON_CMD) $(LEDINV_CMD) 169 | CPU_OPTIONS = $(RESETPIN_CMD) $(TIMEOUT_CMD) $(FCPU_CMD) 170 | COMMON_OPTIONS = $(BIGBOOT_CMD) $(APPSPM_CMD) $(VERSION_CMD) 171 | COMMON_OPTIONS += $(SUPPORT_EEPROM_CMD) $(POR_CMD) 172 | 173 | #UART is handled separately and only passed for devices with more than one. 174 | HELPTEXT += "Option UART=n - use UARTn for communications\n" 175 | HELPTEXT += "Option UARTTX=B5 - describe UART for Mega0, Xtiny\n" 176 | ifdef UART 177 | UART_CMD = -DUART=$(UART) 178 | endif 179 | ifdef UARTTX 180 | UART_CMD = -DUARTTX=$(UARTTX) 181 | endif 182 | 183 | UART_OPTIONS = $(UART_CMD) $(BAUD_RATE_CMD) $(SOFT_UART_CMD) $(SS_CMD) $(RS485_CMD) 184 | -------------------------------------------------------------------------------- /optiboot/bootloaders/optiboot/stk500.h: -------------------------------------------------------------------------------- 1 | /* STK500 constants list, from AVRDUDE 2 | * 3 | * Trivial set of constants derived from Atmel App Note AVR061 4 | * Not copyrighted. Released to the public domain. 5 | */ 6 | 7 | #define STK_OK 0x10 8 | #define STK_FAILED 0x11 // Not used 9 | #define STK_UNKNOWN 0x12 // Not used 10 | #define STK_NODEVICE 0x13 // Not used 11 | #define STK_INSYNC 0x14 // ' ' 12 | #define STK_NOSYNC 0x15 // Not used 13 | #define ADC_CHANNEL_ERROR 0x16 // Not used 14 | #define ADC_MEASURE_OK 0x17 // Not used 15 | #define PWM_CHANNEL_ERROR 0x18 // Not used 16 | #define PWM_ADJUST_OK 0x19 // Not used 17 | #define CRC_EOP 0x20 // 'SPACE' 18 | #define STK_GET_SYNC 0x30 // '0' 19 | #define STK_GET_SIGN_ON 0x31 // '1' 20 | #define STK_SET_PARAMETER 0x40 // '@' 21 | #define STK_GET_PARAMETER 0x41 // 'A' 22 | #define STK_SET_DEVICE 0x42 // 'B' 23 | #define STK_SET_DEVICE_EXT 0x45 // 'E' 24 | #define STK_ENTER_PROGMODE 0x50 // 'P' 25 | #define STK_LEAVE_PROGMODE 0x51 // 'Q' 26 | #define STK_CHIP_ERASE 0x52 // 'R' 27 | #define STK_CHECK_AUTOINC 0x53 // 'S' 28 | #define STK_LOAD_ADDRESS 0x55 // 'U' 29 | #define STK_UNIVERSAL 0x56 // 'V' 30 | #define STK_PROG_FLASH 0x60 // '`' 31 | #define STK_PROG_DATA 0x61 // 'a' 32 | #define STK_PROG_FUSE 0x62 // 'b' 33 | #define STK_PROG_LOCK 0x63 // 'c' 34 | #define STK_PROG_PAGE 0x64 // 'd' 35 | #define STK_PROG_FUSE_EXT 0x65 // 'e' 36 | #define STK_READ_FLASH 0x70 // 'p' 37 | #define STK_READ_DATA 0x71 // 'q' 38 | #define STK_READ_FUSE 0x72 // 'r' 39 | #define STK_READ_LOCK 0x73 // 's' 40 | #define STK_READ_PAGE 0x74 // 't' 41 | #define STK_READ_SIGN 0x75 // 'u' 42 | #define STK_READ_OSCCAL 0x76 // 'v' 43 | #define STK_READ_FUSE_EXT 0x77 // 'w' 44 | #define STK_READ_OSCCAL_EXT 0x78 // 'x' 45 | #define STK_SW_MAJOR 0x81 // ' ' 46 | #define STK_SW_MINOR 0x82 // ' ' 47 | 48 | /* AVR raw commands sent via STK_UNIVERSAL */ 49 | #define AVR_OP_LOAD_EXT_ADDR 0x4d 50 | -------------------------------------------------------------------------------- /optiboot/examples/demo_flashwrite/simpleParser.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * simpleParser 3 | * Implement a command-line parser. 4 | * Written 2014 by Bill Westfield (WestfW) 5 | * refactored 2020 6 | * Released to the public domain. 7 | */ 8 | 9 | #include "Arduino.h" 10 | #include "simpleParser.h" 11 | #include 12 | 13 | //#define DEBUG 1 14 | 15 | #if defined(DEBUG) && DEBUG 16 | //extern char *spbuffer; 17 | char spbuffer[100]; 18 | #endif 19 | 20 | /* 21 | * Reset the line buffer 22 | */ 23 | void parserCore::reset () 24 | { 25 | memset(buffer, 0, lineLen); 26 | inptr = 0; 27 | parsePtr = 0; 28 | termchar = 0; 29 | } 30 | 31 | /* 32 | * getLine 33 | * Read a line of text from Serial into the internal line buffer. 34 | * With echoing and editing! 35 | * Non-blocking. Returns 0 until end-of-line seen. 36 | */ 37 | uint8_t parserCore::getLine () 38 | { 39 | int c; 40 | 41 | c = S->read(); 42 | switch (c) { 43 | case 127: 44 | case CTRL('H'): 45 | /* 46 | Destructive backspace: remove last character 47 | */ 48 | if (inptr > 0) { 49 | S->print("\010 \010"); 50 | buffer[--inptr] = 0; 51 | } 52 | break; 53 | case CTRL('R'): 54 | /* 55 | Ctrl-R retypes the line 56 | */ 57 | S->print("\r\n"); 58 | S->print(buffer); 59 | break; 60 | case CTRL('U'): 61 | /* 62 | Ctrl-U deletes the entire line and starts over. 63 | */ 64 | S->println("XXX"); 65 | reset(); 66 | break; 67 | case CTRL('J'): 68 | case CTRL('M'): 69 | buffer[inptr++] = '\n'; 70 | S->println(); /* Echo newline too. */ 71 | return inptr; 72 | case -1: 73 | /* 74 | No character present; don't do anything. 75 | */ 76 | return 0; 77 | default: 78 | /* 79 | Otherwise, echo the character and put it into the buffer 80 | */ 81 | buffer[inptr++] = c; 82 | S->write(c); 83 | } 84 | return 0; 85 | } 86 | 87 | /* 88 | * getLineWait 89 | * like getLine, but block until a complete line is read 90 | */ 91 | 92 | uint8_t parserCore::getLineWait (void) 93 | { 94 | uint8_t status; 95 | 96 | do { 97 | status = getLine(); 98 | } while (status == 0); 99 | return status; 100 | } 101 | 102 | 103 | bool parserCore::IsWhitespace (char c) 104 | { 105 | return (c == ' ' || c == CTRL('I')); 106 | } 107 | 108 | 109 | 110 | bool parserCore::delim(char c) 111 | { 112 | static const char Delimiters[] PROGMEM = "\r\n ,;:=\t"; 113 | if (c == 0 || strchr_P(Delimiters, c)) 114 | return true; 115 | return false; 116 | } 117 | 118 | /* 119 | * Number 120 | * Advance the token and parse a number. Accept decimal, hex, octal. 121 | */ 122 | 123 | int parserCore::number() 124 | { 125 | char *p = token(); 126 | if (p) { 127 | return strtol(p, 0, 0); 128 | } 129 | return -1; 130 | } 131 | 132 | /* 133 | * eol 134 | * return true if we're at the end of the line. 135 | */ 136 | boolean parserCore::eol () 137 | { 138 | while (IsWhitespace(buffer[parsePtr])) { /* skip leading whitespace */ 139 | parsePtr++; 140 | } 141 | return buffer[parsePtr] == '\n' || buffer[parsePtr] == 0; 142 | } 143 | 144 | /* 145 | * cliTermChar 146 | * return the termination character of the last token 147 | */ 148 | uint8_t parserCore::termChar () 149 | { 150 | return termchar; 151 | } 152 | 153 | char parserCore::nextChar () { 154 | return buffer[parsePtr]; 155 | } 156 | 157 | char *parserCore::restOfLine() { 158 | return &buffer[parsePtr]; 159 | } 160 | 161 | /* 162 | * cliCharacter 163 | */ 164 | 165 | /* 166 | * token 167 | * A token is a set of non-delimiter characters ending at a delimiter. 168 | * As a line is parsed from the internal buffer, parsePtr is advanced, and 169 | * the delimiters of parsed tokens are replaced with nulls. 170 | * Note that a line always ends with the newline character AND a null. 171 | */ 172 | 173 | char *parserCore::token () 174 | { 175 | uint8_t i; 176 | 177 | if (eol()) { // reached the end of the line? 178 | return NULL; 179 | } 180 | i = parsePtr; // save start position of token 181 | while ((!delim(buffer[parsePtr])) && (parsePtr < lineLen)) { 182 | parsePtr++; // advance pointer till we hit a delimiter. 183 | } 184 | termchar = buffer[parsePtr]; 185 | buffer[parsePtr++] = 0; // replace the delimiter with null 186 | return &buffer[i]; // convert position to pointer for retval 187 | } 188 | 189 | /* 190 | * Match the next token with a list of keywords. 191 | * The list of keywords is in PROGMEM, separated by spaces. 192 | * returns either the position of the found keyword (0..n), 193 | * PARSER_NOMATCH, PARSER_AMB, or PARSER_EOL at the end of line 194 | */ 195 | int8_t parserCore::keyword (const char *keys) 196 | { 197 | char *p = token(); 198 | char *thisKey = (char *)keys; 199 | int8_t i = 0, match, first = PARSER_NOMATCH; 200 | if (!p) { 201 | #if defined(DEBUG) && DEBUG 202 | S->println("Early EOL"); 203 | #endif 204 | return PARSER_EOL; 205 | } 206 | 207 | while (pgm_read_byte(thisKey)) { 208 | match = tokcasecmp(p, thisKey); 209 | #if defined(DEBUG) && DEBUG 210 | sprintf(spbuffer, "key='%S', p='%s', match = %d\n", thisKey, p, match); 211 | S->print(spbuffer); 212 | #endif 213 | if (match == CMP_MATCH) { 214 | #if defined(DEBUG) && DEBUG 215 | sprintf(spbuffer, "Exact match %d\n", i); 216 | S->print(spbuffer); 217 | #endif 218 | return i; 219 | } 220 | byte c; 221 | do { 222 | c = pgm_read_byte(thisKey); 223 | if (c == 0) 224 | break; 225 | thisKey++; // advance to next keyword, but not past end! 226 | } while (c > ' '); 227 | 228 | if (match == CMP_PARTIALMATCH) { 229 | // There was a partial match; check for another... 230 | if (first != PARSER_NOMATCH) { // already another match? 231 | return (PARSER_AMB); 232 | } else { 233 | first = i; 234 | continue; 235 | } 236 | #if defined(DEBUG) && DEBUG 237 | sprintf(spbuffer, "Match %d\n", i); 238 | S->print(spbuffer); 239 | #endif 240 | return i; // match 241 | } 242 | i++; // next keyword 243 | } 244 | #if defined(DEBUG) && DEBUG 245 | sprintf(spbuffer, "Partial match %d\n", first); 246 | S->print(spbuffer); 247 | #endif 248 | return first; 249 | } 250 | 251 | /* 252 | * tokcasecmp 253 | * tokcasecmp is like strcasecmp_P, except that the strings are terminated 254 | * by any char < 32. Return value is 0 for match, or pointer to the delimiter 255 | * for non-match (to expedite comparing against strings of targets.) 256 | */ 257 | uint8_t parserCore::tokcasecmp(const char *tok, const char *target) 258 | { 259 | char tokc, keyc; 260 | const char *t = (char *)target; 261 | 262 | do { 263 | tokc = toupper(*tok++); 264 | keyc = toupper(pgm_read_byte(t++)); 265 | // tok++; t++; 266 | if (tokc == 0) { 267 | // End of token; see if end of keyword as well 268 | if (keyc <= ' ') { 269 | return CMP_MATCH; // both ended - exact match 270 | } 271 | return CMP_PARTIALMATCH; // keyword is longer - partial 272 | } 273 | // Not end of token 274 | if (keyc <= ' ') { 275 | return CMP_NONMATCH; // key ended before tok - non match 276 | } 277 | } while (tokc == keyc); 278 | return CMP_NONMATCH; // neither string ended, but non-match 279 | } 280 | -------------------------------------------------------------------------------- /optiboot/examples/demo_flashwrite/simpleParser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Written 2014 by Bill Westfield (WestfW) 3 | * Refactored 2020 4 | * Released to the public domain. 5 | */ 6 | #include "Arduino.h" 7 | 8 | 9 | class parserCore { 10 | private: 11 | char *buffer; 12 | char *lastToken; 13 | byte lineLen; 14 | Stream *S; 15 | 16 | byte inptr; /* read character into here */ 17 | byte parsePtr; 18 | byte termchar; 19 | // Internal functions. 20 | bool IsWhitespace(char c); 21 | bool delim(char c); 22 | char *token(void); 23 | // int8_t KeywordPM (const char *keys); 24 | uint8_t tokcasecmp(const char *tok, const char * target); 25 | 26 | public: 27 | parserCore(char *buf, byte buflen, Stream &io) { 28 | buffer = buf; 29 | lineLen = buflen; 30 | S = &io; 31 | } 32 | uint8_t getLine(void); /* Non-blocking read line w/editing*/ 33 | uint8_t getLineWait(void); /* wait for a full line of input */ 34 | void reset(void); /* reset the parser */ 35 | int number(); /* parse a number */ 36 | int lastNumber(); 37 | boolean eol(); /* check for EOL */ 38 | char nextChar(); 39 | char *restOfLine(); 40 | uint8_t termChar(); /* return the terminating char of last token */ 41 | int8_t keyword(const char *keys); /* keyword with partial matching */ 42 | // int8_t keywordExact(const char *keys); /* keyword exact match */ 43 | }; 44 | 45 | /* 46 | * Constants 47 | */ 48 | #define PARSER_NOMATCH -1 49 | #define PARSER_EOL -2 50 | #define PARSER_AMB -3 51 | 52 | #define CMP_PARTIALMATCH 2 53 | #define CMP_NONMATCH 1 54 | #define CMP_MATCH 0 55 | 56 | #define CTRL(x) (x-64) 57 | 58 | template 59 | class simpleParser: public parserCore { 60 | private: 61 | char buf[maxline]; 62 | public: 63 | simpleParser(Stream &io) : parserCore(buf, sizeof(buf), io) {} 64 | }; 65 | -------------------------------------------------------------------------------- /optiboot/examples/demo_flashwrite/supportfuncs.ino: -------------------------------------------------------------------------------- 1 | // Dump a byte as two hex characters. 2 | void hexout(uint8_t b) 3 | { 4 | uint8_t high, low; 5 | 6 | high = b >> 4; 7 | low = b & 0xF; 8 | if (high > 9) { 9 | high += ('A'-10) - '0'; 10 | } 11 | Serial.write(high + '0'); 12 | if (low > 9) { 13 | low += ('A'-10) - '0'; 14 | } 15 | Serial.write(low + '0'); 16 | } 17 | 18 | void DumpHex(uint8_t *p, uint8_t len) { 19 | for (int i = 0; i < len; i++) { 20 | Serial.write(' '); 21 | hexout(p[i]); 22 | } 23 | Serial.print(" "); 24 | for (int i = 0; i < len; i++) { 25 | if (p[i] < ' ') { 26 | Serial.write('.'); 27 | } else { 28 | Serial.write(p[i]); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /optiboot/examples/demo_reset/demo_reset.ino: -------------------------------------------------------------------------------- 1 | /* 2 | demo_reset 3 | May 2015 by Bill Westfield (WestfW) 4 | Released to the public domain. 5 | 6 | This sketch demonstrates retrival of the Reset Cause register (MCUSR) of the AVR. 7 | Normally, MCUSR itself is destroyed by the use of a bootloader, but Optiboot v4.6 8 | and later save the contents in register r2, where it can be accessed by an 9 | application. 10 | */ 11 | #include 12 | #if defined (__AVR_ATmega328P__) || defined (__AVR_ATmega168__) 13 | #include 14 | #endif 15 | 16 | /* 17 | First, we need a variable to hold the reset cause that can be written before 18 | early sketch initialization (that might change r2), and won't be reset by the 19 | various initialization code. 20 | avr-gcc provides for this via the ".noinit" section. 21 | */ 22 | uint8_t resetFlag __attribute__ ((section(".noinit"))); 23 | 24 | /* 25 | Next, we need to put some code to save reset cause from the bootload (in r2) 26 | to the variable. Again, avr-gcc provides special code sections for this. 27 | If compiled with link time optimization (-flto), as done by the Arduno 28 | IDE version 1.6 and higher, we need the "used" attribute to prevent this 29 | from being omitted. 30 | */ 31 | void resetFlagsInit(void) __attribute__ ((naked)) 32 | __attribute__ ((used)) 33 | __attribute__ ((section (".init0"))); 34 | void resetFlagsInit(void) 35 | { 36 | /* 37 | save the reset flags passed from the bootloader 38 | This is a "simple" matter of storing (STS) r2 in the special variable 39 | that we have created. We use assembler to access the right variable. 40 | */ 41 | __asm__ __volatile__ ("sts %0, r2\n" : "=m" (resetFlag) :); 42 | } 43 | 44 | void printReset(const char *label, uint8_t resetFlags) 45 | { 46 | Serial.print(label); 47 | Serial.print(resetFlags, HEX); 48 | /* 49 | check for the usual bits. Note that the symnbols defined in wdt.h are 50 | bit numbers, so they have to be shifted before comparison. 51 | */ 52 | if (resetFlags & (1 << WDRF)) 53 | { 54 | Serial.print(F(" Watchdog")); 55 | resetFlags &= ~(1 << WDRF); 56 | } 57 | if (resetFlags & (1 << BORF)) 58 | { 59 | Serial.print(F(" Brownout")); 60 | resetFlags &= ~(1 << BORF); 61 | } 62 | if (resetFlags & (1 << EXTRF)) 63 | { 64 | Serial.print(F(" External")); 65 | resetFlags &= ~(1 << EXTRF); 66 | } 67 | if (resetFlags & (1 << PORF)) 68 | { 69 | Serial.print(F(" PowerOn")); 70 | resetFlags &= ~(1 << PORF); 71 | } 72 | if (resetFlags != 0x00) 73 | { 74 | // It should never enter here 75 | Serial.print(" Unknown"); 76 | } 77 | Serial.println(""); 78 | } 79 | 80 | void setup() { 81 | #if 1 82 | /* 83 | * if we're going to allow the bootloader to be called as a service ('j" command), 84 | * then we need to disable the WDT when the sketch starts. Essentially, there is no 85 | * way to tell a watchdog that occurs during the sketch from the watchdog that will 86 | * re-start the sketch when the bootloader is called from the application. 87 | */ 88 | MCUSR = ~(1 << WDRF); // allow us to disable WD 89 | wdt_disable(); 90 | #endif 91 | Serial.begin(9600); // Initialize serial port 92 | 93 | Serial.println(F("Reset flag test\n")); 94 | 95 | printReset("Actual MCUSR content: 0x", MCUSR); 96 | printReset("Passed in R2: 0x", resetFlag); 97 | #ifdef GPIOR0 98 | printReset("Passed in GPIOR0: 0x", GPIOR0); 99 | #endif 100 | } 101 | 102 | void loop() { 103 | int ch; 104 | Serial.println(F("\nSend 0-9 to set MCUSR, (W)atchdog enable, (J)mp to bootload, (S)leep")); 105 | while ((ch = Serial.read()) < 0) ; 106 | if (ch >= '0' && ch <= '9') { 107 | MCUSR = ch & 0xF; 108 | printReset("\nNew MCUSR content: 0x", MCUSR); 109 | } else 110 | switch (ch & ~('a' - 'A')) { 111 | 112 | case 'W': 113 | wdt_enable(WDTO_15MS); 114 | while (1); // To prevent the loop to start again before WDT resets the board 115 | break; 116 | case 'S': 117 | #if defined (__AVR_ATmega328P__) || defined (__AVR_ATmega168__) 118 | // Enter power down state for 8 s with ADC and BOD module disabled 119 | Serial.println(F("Low Power Sleep Mode")); 120 | Serial.flush(); 121 | LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF); 122 | Serial.println(F("Sleep Wakeup")); 123 | Serial.flush(); 124 | #else 125 | Serial.print(F("\nPower down not supported on this CPU\n")); 126 | #endif 127 | break; 128 | 129 | case 'J': 130 | /* Figure out where the bootloader starts. */ 131 | #if FLASHEND > 140000 132 | Serial.println(F("Jump to bootloader not supported on chips with >128k memory")); 133 | #else 134 | typedef void (*do_reboot_t)(void); 135 | const do_reboot_t do_reboot = (do_reboot_t)((FLASHEND - 511) >> 1); 136 | 137 | Serial.print("bootstart = "); 138 | Serial.println((unsigned int)do_reboot, HEX); 139 | Serial.flush(); 140 | cli(); TCCR0A = TCCR1A = TCCR2A = 0; // make sure interrupts are off and timers are reset. 141 | do_reboot(); 142 | #endif 143 | break; 144 | } 145 | 146 | } 147 | 148 | -------------------------------------------------------------------------------- /optiboot/examples/eeprom_data.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This short C progam creates a .elf file with EEPROM contents that 3 | * can be extracted to form a .hex file for testing EEPROM upload/downloads 4 | * via the bootloader. 5 | * 6 | * Compile with: 7 | * avr-gcc -mmcu=atmega328p eeprom_data.c -o eeprom_data.elf 8 | * avr-objcopy -j .eeprom --change-section-lma .eeprom=0 -O ihex eeprom_data.elf eeprom_data.hex 9 | * Upload with: 10 | * avrdude ... -U eeprom:w:eeprom_data.hex 11 | */ 12 | #include 13 | #include 14 | 15 | #define zero16 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0 16 | #define zero32 zero16, zero16 17 | 18 | const EEMEM unsigned long longs[32] = {0x12345678, 0x9abcdef0, 0x11223344, 0, 0xdeadbeef, zero16, 0xdecade, 0x78563412}; 19 | const EEMEM unsigned int integers[64] = {0x1234, 0x5678, 0x9ABC, 0, 0, 0, 1, 2 , zero32, 0xAB90, 0x3412}; 20 | const EEMEM char characters[128] = "test 1 2 3 4 5 6 7 8 9 0" " " 21 | "more testing abcdefghijklmnop"; 22 | 23 | 24 | int main() {} 25 | 26 | 27 | -------------------------------------------------------------------------------- /optiboot/examples/readme.md: -------------------------------------------------------------------------------- 1 | ## "Examples." 2 | 3 | In general, **test_xxx** is a test program for checking some optiboot functionality, while **demo_xxx** is an example of how a user might use an optiboot feature. 4 | 5 | ---- 6 | ---- 7 | 8 | ### chaucer* 9 | 10 | "big" sketches for testing behavior as sketch sizes get closer to the flash capacity of chips. Especially, "bigger than the old bootloader" and "more than 64k". 11 | 12 | ---- 13 | 14 | ### demo_reset 15 | Shows out to figure out the reset cause from an application. Since the bootloaders need to fiddle with the normal registers that provide this information, there need to be some extra effort to tell what the original reset cause was. 16 | 17 | ---- 18 | 19 | ### demo_dospm 20 | Demonstration of an application writing to PROGMEM data arrays using the **do_spm()** or **do_nvmctrl()** features of v8+ optiboot and optiboot_x. 21 | 22 | This demo uses the "higher level" macros from Marek Wodzinsk's "optiboot.h", and so works with both older and new AVRs. 23 | 24 | ---- 25 | 26 | ### test_nvmctrl 27 | Try out the nvmctrl features of the Mega0 and xTiny chips with optiboot.x 28 | This is rather bare-bones and requires knowledge of the nvctrl "peripheral" 29 | 30 | -------------------------------------------------------------------------------- /optiboot/examples/test_eeprom/test_eeprom.ino: -------------------------------------------------------------------------------- 1 | /* 2 | EEPROM test program with more features. 3 | */ 4 | 5 | #include 6 | 7 | void setup() { 8 | // initialize the LED pin as an output. 9 | pinMode(13, OUTPUT); 10 | Serial.begin(115200); 11 | Serial.println("EEPROM test program.\n" 12 | "Enter one of (C)lear, (E)rase, (I)incrementing, (U)p&Down, (0)check,\n" 13 | "(D)ump, (F)check, (T)inccheck"); 14 | 15 | } 16 | 17 | void hex2(uint8_t n) { 18 | if (n <= 15) 19 | Serial.write('0'); 20 | Serial.print(n, HEX); 21 | Serial.write(' '); 22 | } 23 | 24 | void print16(uint8_t *buf) { 25 | for (int i = 0; i < 16; i++) { 26 | hex2(buf[i]); 27 | } 28 | Serial.print(" "); 29 | for (int i = 0; i < 16; i++) { 30 | uint8_t c = buf[i]; 31 | if (c < 32 || c > 126) 32 | Serial.write('.'); 33 | else 34 | Serial.write(c); 35 | } 36 | Serial.println(); 37 | } 38 | 39 | void dump16(uint16_t addr) { 40 | struct { 41 | uint8_t buf[16]; 42 | } s; 43 | 44 | EEPROM.get(addr, s); 45 | print16(s.buf); 46 | } 47 | 48 | 49 | int cmd = -1; 50 | void loop() { 51 | uint16_t i; 52 | do { 53 | cmd = Serial.read(); 54 | } while (cmd < 0); 55 | 56 | switch (cmd & ~('a' - 'A')) { 57 | case 'C': 58 | for (i = 0 ; i < EEPROM.length() ; i++) { 59 | EEPROM.write(i, 0); 60 | } 61 | break; 62 | case 'D': 63 | Serial.println("EEPROM Dump\n"); 64 | for (i = 0; i < EEPROM.length(); i += 16) { 65 | Serial.print(i, HEX); 66 | Serial.print(": "); 67 | dump16(i); 68 | } 69 | Serial.println(); 70 | break; 71 | case 'E': 72 | for (i = 0 ; i < EEPROM.length() ; i++) { 73 | EEPROM.write(i, 0xFF); 74 | } 75 | break; 76 | case 'I': 77 | for (i = 0 ; i < EEPROM.length() ; i++) { 78 | EEPROM.write(i, i & 0xFF); 79 | } 80 | break; 81 | case 'U': 82 | for (i = 0 ; i < EEPROM.length() ; i++) { 83 | if ((i & 0x100) == 0) { 84 | EEPROM.write(i, i & 0xFF); 85 | } else { 86 | EEPROM.write(i, 255 - (i & 0xFF)); 87 | } 88 | } 89 | break; 90 | case '?': 91 | Serial.println("EEPROM test program.\n" 92 | "Enter one of (C)lear, (E)rase, (I)incrementing, (0)check,\n" 93 | "(D)ump, (F)check, (T)inccheck"); 94 | // Fall through 95 | case '\n': 96 | case '\r': 97 | break; 98 | default: 99 | Serial.print("unrecognized command "); 100 | Serial.println(cmd); 101 | break; 102 | // turn the LED on when we're done 103 | digitalWrite(13, HIGH); 104 | } 105 | } 106 | 107 | 108 | -------------------------------------------------------------------------------- /optiboot/examples/test_nvmctrl/simpleParser.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * simpleParser 3 | * Implement a command-line parser. 4 | * Written 2014 by Bill Westfield (WestfW) 5 | * refactored 2020 6 | * Released to the public domain. 7 | */ 8 | 9 | #include "Arduino.h" 10 | #include "simpleParser.h" 11 | #include 12 | 13 | 14 | /* 15 | * Reset the line buffer 16 | */ 17 | void parserCore::reset () 18 | { 19 | memset(buffer, 0, lineLen); 20 | inptr = 0; 21 | parsePtr = 0; 22 | termchar = 0; 23 | } 24 | 25 | /* 26 | * getLine 27 | * Read a line of text from Serial into the internal line buffer. 28 | * With echoing and editing! 29 | * Non-blocking. Returns 0 until end-of-line seen. 30 | */ 31 | uint8_t parserCore::getLine () 32 | { 33 | int c; 34 | 35 | c = S->read(); 36 | switch (c) { 37 | case 127: 38 | case CTRL('H'): 39 | /* 40 | Destructive backspace: remove last character 41 | */ 42 | if (inptr > 0) { 43 | S->print("\010 \010"); 44 | buffer[--inptr] = 0; 45 | } 46 | break; 47 | case CTRL('R'): 48 | /* 49 | Ctrl-R retypes the line 50 | */ 51 | S->print("\r\n"); 52 | S->print(buffer); 53 | break; 54 | case CTRL('U'): 55 | /* 56 | Ctrl-U deletes the entire line and starts over. 57 | */ 58 | S->println("XXX"); 59 | reset(); 60 | break; 61 | case CTRL('J'): 62 | case CTRL('M'): 63 | buffer[inptr++] = '\n'; 64 | S->println(); /* Echo newline too. */ 65 | return inptr; 66 | case -1: 67 | /* 68 | No character present; don't do anything. 69 | */ 70 | return 0; 71 | default: 72 | /* 73 | Otherwise, echo the character and put it into the buffer 74 | */ 75 | buffer[inptr++] = c; 76 | S->write(c); 77 | } 78 | return 0; 79 | } 80 | 81 | /* 82 | * getLineWait 83 | * like getLine, but block until a complete line is read 84 | */ 85 | 86 | uint8_t parserCore::getLineWait (void) 87 | { 88 | uint8_t status; 89 | 90 | do { 91 | status = getLine(); 92 | } while (status == 0); 93 | return status; 94 | } 95 | 96 | 97 | bool parserCore::IsWhitespace (char c) 98 | { 99 | return (c == ' ' || c == CTRL('I')); 100 | } 101 | 102 | 103 | 104 | bool parserCore::delim(char c) 105 | { 106 | static const char Delimiters[] PROGMEM = "\r\n ,;:=\t"; 107 | if (c == 0 || strchr_P(Delimiters, c)) 108 | return true; 109 | return false; 110 | } 111 | 112 | /* 113 | * Number 114 | * Advance the token and parse a number. Accept decimal, hex, octal. 115 | */ 116 | 117 | int parserCore::number() 118 | { 119 | char *p = token(); 120 | if (p) { 121 | return strtol(p, 0, 0); 122 | } 123 | return -1; 124 | } 125 | 126 | int parserCore::lastNumber() 127 | { 128 | if (lastToken && *lastToken) { 129 | return strtol(lastToken, 0, 0); 130 | } 131 | return -1; 132 | } 133 | /* 134 | * eol 135 | * return true if we're at the end of the line. 136 | */ 137 | boolean parserCore::eol () 138 | { 139 | while (IsWhitespace(buffer[parsePtr])) { /* skip leading whitespace */ 140 | parsePtr++; 141 | } 142 | return buffer[parsePtr] == '\n' || buffer[parsePtr] == 0; 143 | } 144 | 145 | /* 146 | * cliTermChar 147 | * return the termination character of the last token 148 | */ 149 | uint8_t parserCore::termChar () 150 | { 151 | return termchar; 152 | } 153 | 154 | /* 155 | * Character 156 | */ 157 | 158 | /* 159 | * token 160 | * A token is a set of non-delimiter characters ending at a delimiter. 161 | * As a line is parsed from the internal buffer, parsePtr is advanced, and 162 | * the delimiters of parsed tokens are replaced with nulls. 163 | * Note that a line always ends with the newline character AND a null. 164 | */ 165 | 166 | char *parserCore::token () 167 | { 168 | uint8_t i; 169 | 170 | if (eol()) { // reached the end of the line? 171 | return NULL; 172 | } 173 | i = parsePtr; // save start position of token 174 | while ((!delim(buffer[parsePtr])) && (parsePtr < lineLen)) { 175 | parsePtr++; // advance pointer till we hit a delimiter. 176 | } 177 | termchar = buffer[parsePtr]; 178 | buffer[parsePtr++] = 0; // replace the delimiter with null 179 | lastToken = &buffer[i]; 180 | return lastToken; // convert position to pointer for retval 181 | } 182 | 183 | /* 184 | * Match the next token with a list of keywords. 185 | * The list of keywords is in PROGMEM, separated by spaces. 186 | * returns either the position of the found keyword (0..n), 187 | * PARSER_NOMATCH, PARSER_AMB, or PARSER_EOL at the end of line 188 | */ 189 | int8_t parserCore::keyword (const char *keys) 190 | { 191 | char *p = token(); 192 | char *thisKey = (char *)keys; 193 | int8_t i = 0, match, first=PARSER_NOMATCH; 194 | if (!p) 195 | return PARSER_EOL; 196 | 197 | while (pgm_read_byte(thisKey)) { 198 | match = tokcasecmp(p, thisKey); 199 | #if defined(DEBUG) && DEBUG 200 | extern char spbuffer[]; 201 | sprintf(spbuffer, "key='%s', p='%s', match = %d\n", thisKey, p, match); 202 | S->print(spbuffer); 203 | #endif 204 | if (match == CMP_MATCH) { 205 | return i; 206 | } 207 | while (pgm_read_byte(thisKey) > ' ') { 208 | thisKey++; // advance to next keyword 209 | } 210 | thisKey++; // skip delimiter 211 | if (match == CMP_PARTIALMATCH) { 212 | // There was a partial match; check for another... 213 | if (first != PARSER_NOMATCH) { // already another match? 214 | return (PARSER_AMB); 215 | } else { 216 | first = i; 217 | continue; 218 | } 219 | return i; // match 220 | } 221 | i++; // next keyword 222 | } 223 | return first; 224 | } 225 | 226 | /* 227 | * tokcasecmp 228 | * tokcasecmp is like strcasecmp_P, except that the strings are terminated 229 | * by any char < 32. Return value is 0 for match, or pointer to the delimiter 230 | * for non-match (to expedite comparing against strings of targets.) 231 | */ 232 | uint8_t parserCore::tokcasecmp(const char *tok, const char *target) 233 | { 234 | char tokc, keyc; 235 | const char *t = (char *)target; 236 | 237 | do { 238 | tokc = toupper(*tok++); 239 | keyc = toupper(pgm_read_byte(t++)); 240 | // tok++; t++; 241 | if (tokc == 0) { 242 | // End of token; see if end of keyword as well 243 | if (keyc <= ' ') { 244 | return CMP_MATCH; // both ended - exact match 245 | } 246 | return CMP_PARTIALMATCH; // keyword is longer - partial 247 | } 248 | // Not end of token 249 | if (keyc <= ' ') { 250 | return CMP_NONMATCH; // key ended before tok - non match 251 | } 252 | } while (tokc == keyc); 253 | return CMP_NONMATCH; // neither string ended, but non-match 254 | } 255 | -------------------------------------------------------------------------------- /optiboot/examples/test_nvmctrl/simpleParser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Written 2014 by Bill Westfield (WestfW) 3 | * Refactored 2020 4 | * Released to the public domain. 5 | */ 6 | #include "Arduino.h" 7 | 8 | 9 | class parserCore { 10 | private: 11 | char *buffer; 12 | char *lastToken; 13 | byte lineLen; 14 | Stream *S; 15 | 16 | byte inptr; /* read character into here */ 17 | byte parsePtr; 18 | byte termchar; 19 | // Internal functions. 20 | bool IsWhitespace(char c); 21 | bool delim(char c); 22 | char *token(void); 23 | // int8_t KeywordPM (const char *keys); 24 | uint8_t tokcasecmp(const char *tok, const char * target); 25 | 26 | public: 27 | parserCore(char *buf, byte buflen, Stream &io) { 28 | buffer = buf; 29 | lineLen = buflen; 30 | S = &io; 31 | } 32 | uint8_t getLine(void); /* Non-blocking read line w/editing*/ 33 | uint8_t getLineWait(void); /* wait for a full line of input */ 34 | void reset(void); /* reset the parser */ 35 | int number(); /* parse a number */ 36 | int lastNumber(); 37 | boolean eol(); /* check for EOL */ 38 | uint8_t termChar(); /* return the terminating char of last token */ 39 | int8_t keyword(const char *keys); /* keyword with partial matching */ 40 | // int8_t keywordExact(const char *keys); /* keyword exact match */ 41 | }; 42 | 43 | /* 44 | * Constants 45 | */ 46 | #define PARSER_NOMATCH -1 47 | #define PARSER_EOL -2 48 | #define PARSER_AMB -3 49 | 50 | #define CMP_PARTIALMATCH 2 51 | #define CMP_NONMATCH 1 52 | #define CMP_MATCH 0 53 | 54 | #define CTRL(x) (x-64) 55 | 56 | template 57 | class simpleParser: public parserCore { 58 | private: 59 | char buf[maxline]; 60 | public: 61 | simpleParser(Stream &io) : parserCore(buf, sizeof(buf), io) {} 62 | }; 63 | -------------------------------------------------------------------------------- /optiboot/examples/test_nvmctrl/test_nvmctrl.ino: -------------------------------------------------------------------------------- 1 | #include "optiboot.h" 2 | #include "simpleParser.h" 3 | 4 | static int debug = 0; 5 | 6 | #define debugtxt(a) if (debug) Serial.println(a) 7 | #define debugnum(a) do {if (debug) { Serial.print(#a " = "); Serial.println(a); }} while (0) 8 | 9 | // Configure the baud rate: 10 | 11 | #undef SERIAL 12 | 13 | #ifdef SERIAL_PORT_USBVIRTUAL 14 | #define SERIAL SERIAL_PORT_USBVIRTUAL 15 | #else 16 | #define SERIAL Serial 17 | #endif 18 | 19 | #define BAUDRATE 19200 20 | 21 | void setup() { 22 | SERIAL.begin(BAUDRATE); 23 | while (!SERIAL) 24 | ; 25 | SERIAL.flush(); 26 | delay(500); 27 | SERIAL.println(F("Flash Self-Programming test tool\n")); 28 | } 29 | 30 | simpleParser<> ttycli(SERIAL); 31 | static const char PROGMEM cmd_strings[] = 32 | "dump_a " "dospm_c_a_v... " "nvmctrla_v " "set_a_v... " "spm " "statusnv " "datanv " "addrnv " 33 | "help " "? "; 34 | enum { 35 | CMD_DUMP = 0, CMD_DOSPM, CMD_NVMCTRL, CMD_SET, CMD_SPM, CMD_STAT, CMD_DATA, CMD_ADDR, 36 | CMD_HELP, CMD_HELP2 // make sure this matches the string 37 | }; 38 | 39 | void loop() { 40 | int8_t clicmd; 41 | int16_t addr, val, nvcmd, i; 42 | Serial.print("Cmd: "); 43 | ttycli.reset(); 44 | ttycli.getLineWait(); 45 | clicmd = ttycli.keyword(cmd_strings); // look for a command. 46 | debugnum(clicmd); 47 | switch (clicmd) { 48 | case CMD_DUMP: 49 | addr = parse_memoryRegion(); 50 | if (val <= 0) 51 | val = MAPPED_PROGMEM_PAGE_SIZE; 52 | for (i = 0; i < val / 16 ; i++) { 53 | SERIAL.print(addr, HEX); SERIAL.print(": "); 54 | DumpHex((uint8_t *)addr, 16); 55 | addr += 16; 56 | SERIAL.println(); 57 | } 58 | SERIAL.println(); 59 | break; 60 | case CMD_DOSPM: 61 | if (FUSE_BOOTEND == 0) { 62 | SERIAL.println(F("No bootlaoder present. DOSPM not possible.")); 63 | break; 64 | } 65 | debugtxt("cmd_dospm"); 66 | nvcmd = parse_nvmctrlCmd(); 67 | addr = parse_memoryRegion(); 68 | while (1) { 69 | val = ttycli.number(); 70 | if (val < 0) 71 | break; 72 | #if 0 73 | SERIAL.print(F("dospm(0x")); SERIAL.print(addr, HEX); 74 | SERIAL.print(F(", ")); SERIAL.print(nvcmd); 75 | SERIAL.print(F(", ")); SERIAL.print(val); 76 | SERIAL.println(F(")")); 77 | #endif 78 | do_nvmctrl(addr++, nvcmd, val); 79 | } 80 | printNVMStat(); 81 | break; 82 | case CMD_NVMCTRL: 83 | debugtxt("cmd_nvmctrl"); 84 | nvcmd = parse_nvmctrlCmd(); 85 | debugnum(nvcmd); 86 | _PROTECTED_WRITE_SPM(NVMCTRL.CTRLA, nvcmd); 87 | printNVMStat(); 88 | break; 89 | case CMD_SET: 90 | debugtxt("cmd_set"); 91 | addr = parse_memoryRegion(); 92 | debugnum(addr); 93 | while (1) { 94 | val = ttycli.number(); 95 | if (val < 0) 96 | break; 97 | *(uint8_t *)addr++ = val; 98 | } 99 | printNVMStat(); 100 | break; 101 | case CMD_SPM: 102 | debugtxt("cmd_spm"); 103 | break; 104 | case CMD_STAT: 105 | debugtxt("cmd_stat"); 106 | printNVMStat(); 107 | break; 108 | case CMD_DATA: 109 | debugtxt("cmd_data"); 110 | SERIAL.print("NVMCTRL.DATA = 0x"); 111 | SERIAL.print(NVMCTRL.DATA, HEX); 112 | SERIAL.println("\n"); 113 | break; 114 | case CMD_ADDR: 115 | debugtxt("cmd_addr"); 116 | SERIAL.print("NVMCTRL.ADDR = 0x"); 117 | SERIAL.print(NVMCTRL.ADDR, HEX); 118 | SERIAL.println("\n"); 119 | break; 120 | case PARSER_EOL: 121 | case CMD_HELP2: 122 | case CMD_HELP: 123 | SERIAL.println(F("Flash Self-Programming test tool\n")); 124 | SERIAL.println(F("Enter a command. One of:")); 125 | SERIAL.println(reinterpret_cast(cmd_strings)); 126 | SERIAL.println(); 127 | break; 128 | default: 129 | break; 130 | } 131 | } 132 | 133 | static const char PROGMEM regions[] = "sigrow fuses userrow eeprom "; 134 | static const uint16_t PROGMEM regionValues[] = { 0x1100, 0x1280, 0x1300, 0x1400 }; 135 | 136 | int32_t parse_memoryRegion() { 137 | int cmd; 138 | 139 | cmd = ttycli.keyword(regions); 140 | if (cmd >= 0) 141 | return pgm_read_word(®ionValues[cmd]); 142 | return ttycli.lastNumber(); 143 | } 144 | 145 | static const char PROGMEM nvcmds[] = "copy write wp erase ep erwp pbc cher eeer "; 146 | static const byte PROGMEM cmdValues[] ={ 99, 1, 1, 2, 2, 3, 4, 5, 6 }; 147 | int32_t parse_nvmctrlCmd() { 148 | 149 | int cmd = ttycli.keyword(nvcmds); 150 | if (cmd >= 0) 151 | return pgm_read_word(&cmdValues[cmd]); 152 | return (ttycli.lastNumber()); 153 | } 154 | 155 | // Dump a byte as two hex characters. 156 | void hexout(uint8_t b) 157 | { 158 | uint8_t high, low; 159 | 160 | high = b >> 4; 161 | low = b & 0xF; 162 | if (high > 9) { 163 | high += 'A' - ('9' + 1); 164 | } 165 | SERIAL.write(high + '0'); 166 | if (low > 9) { 167 | low += 'A' - ('9' + 1); 168 | } 169 | SERIAL.write(low + '0'); 170 | } 171 | 172 | void DumpHex(uint8_t *p, uint8_t len) { 173 | for (int i = 0; i < len; i++) { 174 | SERIAL.write(' '); 175 | hexout(p[i]); 176 | } 177 | SERIAL.print(" "); 178 | for (int i = 0; i < len; i++) { 179 | if (p[i] < ' ') { 180 | SERIAL.write('.'); 181 | } else { 182 | SERIAL.write(p[i]); 183 | } 184 | } 185 | } 186 | 187 | void printNVMStat() { 188 | SERIAL.print("NVMCTRL.STATUS = "); 189 | SERIAL.print(NVMCTRL.STATUS, HEX); 190 | SERIAL.println("\n"); 191 | } 192 | -------------------------------------------------------------------------------- /optiboot/package_optiboot_optiboot-additional_index.json.TEMPLATE: -------------------------------------------------------------------------------- 1 | # Template file for generating the .json file that the Arduino IDE 2 | # "Boards Manager" wants to see. This file must be pre-processed 3 | # before it will be valid: 4 | # Strip comments. 5 | # Replace variables: 6 | # %VERSION% gets the Optiboot Version 7 | # %HASH% gets the SHA-256 has for the .zip file. 8 | # (generate with: openssl dgst -sha256 optiboot.zip | sed -e 's/.* //' 9 | # %SIZE% gets the size of the .zip file 10 | # 11 | { 12 | "packages": [ 13 | { 14 | "name": "Optiboot", 15 | "maintainer": "westfw", 16 | "websiteURL": "https://github.com/Optiboot/optiboot", 17 | "email": "", 18 | "help": { 19 | "online": "" 20 | }, 21 | "platforms": [ 22 | { 23 | "name": "Optiboot %VERSION%", 24 | "architecture": "avr", 25 | "version": "0.%VERSION%", 26 | # 27 | # 3r party packages must use "Contributed" 28 | # 29 | "category": "Contributed", 30 | "help": { 31 | "online": "https://github.com/Optiboot/optiboot/wiki" 32 | }, 33 | "url": "https://github.com/Optiboot/optiboot/releases/download/v%VERSION%/Optiboot-%VERSION%.zip", 34 | "archiveFileName": "optiboot-%VERSION%.zip", 35 | # 36 | # Package file verification data 37 | # 38 | "checksum": "SHA-256:%HASH%", 39 | "size": "%SIZE%", 40 | # 41 | "boards": [ 42 | {"name": "New Optiboot"} 43 | ], 44 | "toolsDependencies": [ 45 | { 46 | "packager": "arduino", 47 | "name": "avrdude", 48 | "version": "6.0.1-arduino5" 49 | } 50 | ] 51 | } 52 | ], 53 | "tools": [] 54 | } 55 | ] 56 | } 57 | -------------------------------------------------------------------------------- /optiboot/release.sh: -------------------------------------------------------------------------------- 1 | #%/bin/bash 2 | # 3 | # Use like: "sh release.sh " 4 | # 5 | # Build a "release" .zip file for Optiboot bootloader 6 | # Run from the build directory 7 | 8 | version=$1 9 | 10 | # Uncomment if you want a clean builds of specific files 11 | # make clean 12 | # make atmega328 13 | # make atmega168 14 | # make atmega8 15 | 16 | rm -Rf /tmp/optiboot-release 17 | 18 | # 19 | # Create the 3rd-party hardware extension directory structure 20 | # Note that the structure under "packages" (handed by boards manager) 21 | # is different than the structure under "sketchbook/hardware" would be. 22 | 23 | TOP=/tmp/optiboot-release/Optiboot-$version/ 24 | # 25 | # Bootloaders directory 26 | mkdir -p $TOP/bootloaders/optiboot 27 | # cores, variants, libraries 28 | # mkdir -p $TOP/variants/ 29 | mkdir -p $TOP/libraries/ 30 | # Less common: firmware, system. 31 | # mkdir -p $TOP/firmwares/ 32 | # mkdir -p $TOP/system/ 33 | 34 | # 35 | # Copy files from whereever into the release directory 36 | cp ../../boards-1.6.txt $TOP/boards.txt 37 | #cp -R ../../examples $TOP/libraries/ 38 | #cp -R ../../variants $TOP/ 39 | #cp -R ../../system $TOP/ 40 | 41 | # 42 | # Create platform.txt, because it contains the "group" name for the boards menu 43 | echo name=Optiboot $version > $TOP/platform.txt 44 | echo version=$version >> $TOP/platform.txt 45 | 46 | # 47 | # Create a README file. 48 | echo This is an Optiboot version $version \"Binary\" Release. > $TOP/README.TXT 49 | echo >> $TOP/README.TXT 50 | echo For Source code see http://github.com/Optiboot/optiboot>> $TOP/README.TXT 51 | 52 | # 53 | # Copy over our "binaries." 54 | cp *.hex $TOP/bootloaders/optiboot 55 | 56 | # 57 | # Copy examples ? (examples for a boards.txt don't seem possible?) 58 | 59 | 60 | # files we'd specifical exclude, if we weren't doing only .hex files. 61 | #rm /tmp/optiboot-release/Optiboot/avr/bootloaders/optiboot/*.lst 62 | #rm /tmp/optiboot-release/Optiboot/avr/bootloaders/optiboot/*~ 63 | #rm /tmp/optiboot-release/Optiboot/avr/bootloaders/optiboot/#* 64 | 65 | # 66 | # zip everything up. 67 | pushd /tmp/optiboot-release 68 | zip -r Optiboot-$version.zip Optiboot-$version 69 | HASH=`openssl dgst -sha256 Optiboot-$version.zip | sed -e 's/.* //'` 70 | SIZE=`stat -f %z Optiboot-$version.zip` 71 | popd 72 | sed -e "s/#.*//" -e "s/%HASH%/$HASH/g" -e "s/%VERSION%/$version/g" -e "s/%SIZE%/$SIZE/g" ../../package_optiboot_optiboot-additional_index.json.TEMPLATE > /tmp/optiboot-release/package_optiboot_optiboot-additional_index.json 73 | 74 | # 75 | # This leaves the .zip and the .json file in /tmp/optiboot-release 76 | # where it can be copied to a suitable network location. 77 | 78 | -------------------------------------------------------------------------------- /scripts/travis-build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | LOCAL_TOOLS_DIR=$HOME/avr-tools 4 | 5 | if [ -z "$TRAVIS_BUILD_DIR" ]; then 6 | echo "This script should be run by Travis-CI environment" 7 | echo "If you want to simulate Travis build, please set TRAVIS_BUILD_DIR" 8 | echo "environment variable to directory where your code lives" 9 | exit 1 10 | fi 11 | 12 | if [ -z "$1" ]; then 13 | echo "Arduino version required" 14 | exit 1 15 | fi 16 | 17 | if [ -z "$2" ]; then 18 | echo "Target required" 19 | exit 1 20 | fi 21 | 22 | 23 | # Include functions to download stuff 24 | . $TRAVIS_BUILD_DIR/scripts/travis-download.inc.sh 25 | 26 | # Make directory for tools 27 | mkdir -p $LOCAL_TOOLS_DIR 28 | 29 | # get new make as Optiboot requires version >4.0 30 | download_make4 31 | 32 | # download specific tools version 33 | if [ "$1" = "microchip" ]; then 34 | download_avr_toolchain 35 | 36 | # set search path 37 | PATH=$LOCAL_TOOLS_DIR/usr/bin:$PATH:$LOCAL_TOOLS_DIR/avr8-gnu-toolchain-linux_x86_64/bin 38 | avr-gcc --version 39 | else 40 | download_arduino $1 41 | 42 | # set search path 43 | PATH=$LOCAL_TOOLS_DIR/usr/bin:$PATH:$LOCAL_TOOLS_DIR/arduino-$1/hardware/tools/avr/bin 44 | fi 45 | 46 | cd $TRAVIS_BUILD_DIR/optiboot/bootloaders/optiboot 47 | 48 | make --version 49 | make clean 50 | shift 51 | make $@ 52 | -------------------------------------------------------------------------------- /scripts/travis-check-sizes.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | LOCAL_TOOLS_DIR=$HOME/avr-tools 4 | 5 | if [ -z "$TRAVIS_BUILD_DIR" ]; then 6 | echo "This script should be run by Travis-CI environment" 7 | echo "If you want to simulate Travis build, please set TRAVIS_BUILD_DIR" 8 | echo "environment variable to directory where your code lives" 9 | exit 1 10 | fi 11 | 12 | 13 | # download all compilers 14 | $TRAVIS_BUILD_DIR/scripts/travis-fill-cache.sh 15 | 16 | # prepare output dir 17 | OUTPUT_DIR="$TRAVIS_BUILD_DIR/sizes-out" 18 | mkdir -p "$OUTPUT_DIR" 19 | OUTPUT_TABLE="$OUTPUT_DIR/sizes.txt" 20 | OUTPUT_JSON="$OUTPUT_DIR/sizes.json" 21 | 22 | # compiler list 23 | COMPILERS=$(cat $TRAVIS_BUILD_DIR/docs/arduino-gcc-versions.md |grep -i "| yes |"|cut -f 2 -d '|') 24 | COMPILERS="$COMPILERS microchip" 25 | 26 | # table header 27 | echo -n "| target \ compiler |" >"$OUTPUT_TABLE" 28 | for compiler in $COMPILERS; do 29 | echo -n " $compiler |" >>"$OUTPUT_TABLE" 30 | done 31 | echo >>"$OUTPUT_TABLE" 32 | # table header separator 33 | echo -n "|-|" >>"$OUTPUT_TABLE" 34 | for compiler in $COMPILERS; do 35 | echo -n "-|">>"$OUTPUT_TABLE" 36 | done 37 | echo >>"$OUTPUT_TABLE" 38 | 39 | # get repo and commit info for json output 40 | if [[ "$TRAVIS_PULL_REQUEST" = "false" ]]; then 41 | REPO="$TRAVIS_REPO_SLUG" 42 | BRANCH="$TRAVIS_BRANCH" 43 | else 44 | REPO="$TRAVIS_PULL_REQUEST_SLUG" 45 | BRANCH="$TRAVIS_PULL_REQUEST_BRANCH" 46 | fi 47 | 48 | # start json 49 | echo "{\"slug\":\"$REPO\",\"branch\":\"$BRANCH\",\"commit\":\"$TRAVIS_COMMIT\",\"emoji\":\"true\",\"builds\":[" >"$OUTPUT_JSON" 50 | 51 | # build everything 52 | cat $TRAVIS_BUILD_DIR/.travis.yml|grep " - OPTIBOOT_TARGET="|cut -f 2- -d '=' \ 53 | |tr -d '"'|sort|while read target; do 54 | echo -n "| $target |" >>"$OUTPUT_TABLE" 55 | echo "{\"t\":\"$target\",\"v\":[">>"$OUTPUT_JSON" 56 | for compiler in $COMPILERS; do 57 | echo "Checking size for $target @ $compiler" 58 | size=$($TRAVIS_BUILD_DIR/scripts/travis-build.sh $compiler $target 2>/dev/null|grep -A 2 avr-size|tail -n1|awk '{ print $1;}') 59 | if [[ -z "$size" ]]; then 60 | size="x" 61 | fi 62 | echo -n " $size |" >>"$OUTPUT_TABLE" 63 | echo "{\"c\":\"$compiler\",\"s\":\"$size\"}," >>"$OUTPUT_JSON" 64 | done 65 | echo >>"$OUTPUT_TABLE" 66 | sed -i '$ s/.$//' "$OUTPUT_JSON" 67 | echo "]}," >>"$OUTPUT_JSON" 68 | done 69 | sed -i '$ s/.$//' "$OUTPUT_JSON" 70 | echo "]}">>"$OUTPUT_JSON" 71 | 72 | echo "========= OUTPUT SIZES START =============" 73 | cat "$OUTPUT_TABLE" 74 | echo "========== OUTPUT SIZES END ==============" 75 | 76 | echo "Checking results against last commit" 77 | echo "========= OUTPUT SIZES COMPARE START =============" 78 | curl -H "Content-Type: application/json" --data @$OUTPUT_JSON https://api.travisjoin.w7i.pl/tj/compare/$REPO/$BRANCH/last 79 | echo "========== OUTPUT SIZES COMPARE END ==============" 80 | 81 | echo "Uploading results to TravisJoin" 82 | curl -H "Content-Type: application/json" --data @$OUTPUT_JSON https://api.travisjoin.w7i.pl/tj/add/$REPO/$BRANCH/$TRAVIS_COMMIT 83 | 84 | exit 0 85 | -------------------------------------------------------------------------------- /scripts/travis-download.inc.sh: -------------------------------------------------------------------------------- 1 | # common functions to get avr-gcc tools 2 | # 3 | 4 | MAKE_PACKAGE=make_4.1-6_amd64.deb 5 | WGET_FLAGS="--retry-connrefused --tries=3 --timeout=60 --continue" 6 | 7 | 8 | # download and unpack package 9 | function download_arduino() 10 | { 11 | cd $LOCAL_TOOLS_DIR 12 | 13 | # check if tools are already in place 14 | if [ -d arduino-$1/hardware/tools/avr ]; then 15 | echo "Arduino version $1 already downloaded and extracted, skipping" 16 | return 17 | fi 18 | 19 | echo "Downloading Arduino version $1" 20 | 21 | # default package extension 22 | local arduExt="tar.xz" 23 | 24 | # for packages in version <1.6 extension is .tgz 25 | local regex="1\.[05]" 26 | if [[ "$1" =~ $regex ]]; then arduExt="tgz"; fi 27 | 28 | # download package 29 | wget $WGET_FLAGS "http://downloads.arduino.cc/arduino-$1-linux64.$arduExt" 30 | if [ $? -ne 0 ]; then 31 | echo "ERROR: Can't download Arduino" 32 | rm arduino-$1-linux64.$arduExt* 33 | exit 1 34 | fi 35 | 36 | # try to check md5sum, but Arduino provide only checksums for version 1.6 and greater 37 | wget $WGET_FLAGS https://downloads.arduino.cc/arduino-$1.md5sum.txt 38 | if [ $? -eq -0 ]; then 39 | cat arduino-$1.md5sum.txt|grep "linux64"|md5sum -c 40 | if [ $? -ne 0 ]; then 41 | echo "ERROR: md5sum for downloaded Arduino doesn't match" 42 | rm arduino-$1.md5sum.txt* 43 | exit 1 44 | fi 45 | rm arduino-$1.md5sum.txt* 46 | fi 47 | 48 | # extract only avr-gcc 49 | tar xf arduino-$1-linux64.$arduExt --wildcards '*/hardware/tools/avr/' 50 | 51 | # clean up 52 | rm arduino-$1-linux64.$arduExt* 53 | } 54 | 55 | function download_make4() 56 | { 57 | cd $LOCAL_TOOLS_DIR 58 | 59 | # check for existence 60 | if [ -x usr/bin/make ]; then 61 | echo "Make already in place, skipping" 62 | return 63 | fi 64 | 65 | # download 66 | wget http://archive.ubuntu.com/ubuntu/pool/main/m/make-dfsg/$MAKE_PACKAGE 67 | if [ $? -ne 0 ]; then 68 | echo "ERROR: Can't download make4" 69 | exit 1 70 | fi 71 | 72 | # unpack 73 | dpkg-deb -x $MAKE_PACKAGE $LOCAL_TOOLS_DIR 74 | 75 | # clean up 76 | rm ${MAKE_PACKAGE}* 77 | } 78 | 79 | function download_avr_toolchain() 80 | { 81 | cd $LOCAL_TOOLS_DIR 82 | 83 | # check if tools are already in place 84 | if [ -d avr8-gnu-toolchain-linux_x86_64 ]; then 85 | echo "AVR 8-bit Toolchain already downloaded and extracted, skipping" 86 | return 87 | fi 88 | 89 | echo "Downloading AVR 8-bit Toolchain" 90 | 91 | # download package 92 | wget $WGET_FLAGS --content-disposition "https://www.microchip.com/mymicrochip/filehandler.aspx?ddocname=en605750" 93 | if [ $? -ne 0 ]; then 94 | echo "ERROR: Can't download AVR 8-bit Toolchain" 95 | rm avr8-gnu-toolchain-*-linux.any.x86_64.tar.gz* 96 | exit 1 97 | fi 98 | 99 | # unpack 100 | tar xf avr8-gnu-toolchain-*-linux.any.x86_64.tar.gz 101 | 102 | # clean up 103 | rm avr8-gnu-toolchain-*-linux.any.x86_64.tar.gz* 104 | } 105 | -------------------------------------------------------------------------------- /scripts/travis-env.inc.sh: -------------------------------------------------------------------------------- 1 | # source it from parent directory to mimic Travis-CI 2 | # environmental variables needed in scripts 3 | 4 | if [[ -d .git ]]; then 5 | export TRAVIS_BUILD_DIR=`pwd` 6 | else 7 | echo "ERROR: include it from repository parent directory!!!" 8 | return 9 | fi 10 | 11 | export TRAVIS_COMMIT="THIS_IS_FAKE_COMMIT_HASH_FOR_TESTS_ONLY1" 12 | export TRAVIS_COMMIT_MESSAGE="Example commit message" 13 | export TRAVIS_EVENT_TYPE="push" 14 | export TRAVIS_OS_NAME="linux" 15 | export TRAVIS_PULL_REQUEST="false" 16 | export TRAVIS_PULL_REQUEST_BRANCH="" 17 | export TRAVIS_PULL_REQUEST_SHA="" 18 | export TRAVIS_PULL_REQUEST_SLUG="" 19 | 20 | export TRAVIS_REPO_SLUG=$(git config --get travis.slug) 21 | if [[ -z "$TRAVIS_REPO_SLUG" ]]; then 22 | export TRAVIS_REPO_SLUG=$(git config --get remote.origin.url|sed 's/.*github\.com.//'|sed 's/\.git$//') 23 | fi 24 | 25 | export TRAVIS_SUDO="false" 26 | export TRAVIS_BRANCH=$(git rev-parse --abbrev-ref HEAD) 27 | -------------------------------------------------------------------------------- /scripts/travis-fill-cache.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Download avr-gcc from Arduino and Microchip 4 | # Get also make 4 required to compile Optiboot 5 | # 6 | 7 | # path where tools are extracted 8 | LOCAL_TOOLS_DIR=$HOME/avr-tools 9 | 10 | 11 | # check if we are running by Travis-CI 12 | if [ -z "$TRAVIS_BUILD_DIR" ]; then 13 | echo "This script should be run by Travis-CI environment" 14 | echo "If you want to simulate Travis build, please set TRAVIS_BUILD_DIR" 15 | echo "environment variable to directory where your code lives" 16 | exit 1 17 | fi 18 | 19 | # include functions to download stuff 20 | . $TRAVIS_BUILD_DIR/scripts/travis-download.inc.sh 21 | 22 | # make directory for tools 23 | mkdir -p $LOCAL_TOOLS_DIR 24 | 25 | # get new make as Optiboot requires version >4.0 26 | download_make4 27 | 28 | # download Arduino versions 29 | for version in $(cat $TRAVIS_BUILD_DIR/docs/arduino-gcc-versions.md |grep -i "| yes |"|cut -f 2 -d '|'); do 30 | download_arduino $version 31 | done 32 | 33 | # download Microchip's AVR8 Toolchain 34 | download_avr_toolchain 35 | --------------------------------------------------------------------------------