From f427529a30487de45ebfbe6fbba9c290738878ab Mon Sep 17 00:00:00 2001 From: tmk Date: Sat, 30 Jun 2012 11:19:07 +0900 Subject: Fix bootloader.c --- common/bootloader.c | 68 +++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 51 insertions(+), 17 deletions(-) (limited to 'common') diff --git a/common/bootloader.c b/common/bootloader.c index 5cbfc72e5b..cb971c7043 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. +#include +#include +#include +#include "bootloader.h" -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. +/* 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 + */ -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ +/* Boot Section Size in bytes + * Teensy halfKay 512 + * Atmel DFU loader 4096 + * LUFA bootloader 4096 + */ +#ifndef BOOT_SIZE +#define BOOT_SIZE 512 +#endif -#include "bootloader.h" +#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<