From ec27eee5ad0ab79dc89cbd495e364f2bae6bf37b Mon Sep 17 00:00:00 2001 From: tmk Date: Sat, 30 Jun 2012 11:19:07 +0900 Subject: [PATCH] Fix bootloader.c --- common/bootloader.c | 72 +++++++++++++++++++++++-------- protocol/pjrc.mk | 3 +- protocol/pjrc/bootloader_teensy.c | 40 ----------------- 3 files changed, 54 insertions(+), 61 deletions(-) delete mode 100644 protocol/pjrc/bootloader_teensy.c diff --git a/common/bootloader.c b/common/bootloader.c index 5cbfc72e..cb971c70 100644 --- a/common/bootloader.c +++ b/common/bootloader.c @@ -1,22 +1,56 @@ -/* -Copyright 2011 Jun Wako - -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. - -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. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ - +#include +#include +#include #include "bootloader.h" +/* 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 + */ -void bootloader_jump(void) __attribute__ ((weak)); -void bootloader_jump(void) {} +/* Boot Section Size in bytes + * Teensy halfKay 512 + * Atmel DFU loader 4096 + * LUFA bootloader 4096 + */ +#ifndef BOOT_SIZE +#define BOOT_SIZE 512 +#endif + +#define FLASH_SIZE (FLASHEND + 1) +#define BOOTLOADER_START (FLASHEND - BOOT_SIZE) + +void bootloader_jump(void) { + cli(); + // disable watchdog, if enabled + // disable all peripherals + UDCON = 1; + USBCON = (1< -#include -#include -#include "bootloader.h" - -void bootloader_jump(void) { - cli(); - // disable watchdog, if enabled - // disable all peripherals - UDCON = 1; - USBCON = (1<