X-Git-Url: https://git.friedersdorff.com/?a=blobdiff_plain;f=common%2Fbootloader.c;h=6e04efbbda4e2ff91a8855571382f8fc4563ef2c;hb=81141ad0eba1a9db9abd0f7903d8077c28e76b40;hp=5cbfc72e5b9bce076ca5ed91523247934a6eb3aa;hpb=62d1ebb91c7b381ce3d88aad9ee0b03bea9fce26;p=max%2Ftmk_keyboard.git diff --git a/common/bootloader.c b/common/bootloader.c index 5cbfc72e..6e04efbb 100644 --- a/common/bootloader.c +++ b/common/bootloader.c @@ -1,22 +1,87 @@ -/* -Copyright 2011 Jun Wako +#include +#include +#include +#include "bootloader.h" -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 2 of the License, or -(at your option) any later version. +/* Start Bootloader from Application + * See + * http://www.pjrc.com/teensy/jump_to_bootloader.html + * http://www.fourwalledcubicle.com/files/LUFA/Doc/120219/html/_page__software_bootloader_start.html + */ -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. +// TODO: support usbasp +/* Boot Section Size in bytes + * Teensy halfKay 512 + * Atmel DFU loader 4096 + * LUFA bootloader 4096 + */ +#ifndef BOOT_SIZE +#define BOOT_SIZE 512 +#endif -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ +#define FLASH_SIZE (FLASHEND + 1) +#define BOOTLOADER_START (FLASHEND - BOOT_SIZE) -#include "bootloader.h" +void bootloader_jump(void) { + cli(); + + // + //Teensy + // +#if defined(__AVR_AT90USB162__) || defined(__AVR_ATmega32U4__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) + // disable watchdog, if enabled + // disable all peripherals + UDCON = 1; + USBCON = (1<