diff options
author | Marti Bolivar <mbolivar@leaflabs.com> | 2014-04-29 19:56:39 -0700 |
---|---|---|
committer | Marti Bolivar <mbolivar@leaflabs.com> | 2014-04-29 19:56:39 -0700 |
commit | 746d6fecf86572c9fe95dbbffdf541a8d3875dd0 (patch) | |
tree | 8dc7170e295756116dcdc9e973dee028b9cb2454 /wirish | |
parent | 139e4b1a1ae547540d32aa66d47c4e69b1b57bbf (diff) | |
parent | 731e2ab24755b3706daf7d64eaa53f2ec0512277 (diff) | |
download | librambutan-746d6fecf86572c9fe95dbbffdf541a8d3875dd0.tar.gz librambutan-746d6fecf86572c9fe95dbbffdf541a8d3875dd0.zip |
Merge pull request #89 from Gregwar/bootloader-option
Adding BOOTLOADER option to support Robotis bootloader different ROM
Diffstat (limited to 'wirish')
-rw-r--r-- | wirish/boards.cpp | 4 | ||||
-rw-r--r-- | wirish/usb_serial.cpp | 26 |
2 files changed, 30 insertions, 0 deletions
diff --git a/wirish/boards.cpp b/wirish/boards.cpp index a693fa6..77a05de 100644 --- a/wirish/boards.cpp +++ b/wirish/boards.cpp @@ -144,7 +144,11 @@ static void setup_clocks(void) { * present. If no bootloader is present, the user NVIC usually starts * at the Flash base address, 0x08000000. */ +#if defined(BOOTLOADER_maple) #define USER_ADDR_ROM 0x08005000 +#elif defined(BOOTLOADER_robotis) +#define USER_ADDR_ROM 0x08003000 +#endif #define USER_ADDR_RAM 0x20000C00 extern char __text_start__; diff --git a/wirish/usb_serial.cpp b/wirish/usb_serial.cpp index d21766f..3bb1923 100644 --- a/wirish/usb_serial.cpp +++ b/wirish/usb_serial.cpp @@ -36,6 +36,7 @@ #include <libmaple/nvic.h> #include <libmaple/usb_cdcacm.h> #include <libmaple/usb.h> +#include <libmaple/iwdg.h> #include <wirish/wirish.h> @@ -179,6 +180,7 @@ static void ifaceSetupHook(unsigned hook, void *requestvp) { return; } +#if defined(BOOTLOADER_maple) // We need to see a negative edge on DTR before we start looking // for the in-band magic reset byte sequence. uint8 dtr = usb_cdcacm_get_dtr(); @@ -196,13 +198,25 @@ static void ifaceSetupHook(unsigned hook, void *requestvp) { reset_state = dtr ? DTR_HIGH : DTR_LOW; break; } +#endif + +#if defined(BOOTLOADER_robotis) + uint8 dtr = usb_cdcacm_get_dtr(); + uint8 rts = usb_cdcacm_get_rts(); + + if (rts && !dtr) { + reset_state = DTR_NEGEDGE; + } +#endif } #define RESET_DELAY 100000 +#if defined(BOOTLOADER_maple) static void wait_reset(void) { delay_us(RESET_DELAY); nvic_sys_reset(); } +#endif #define STACK_TOP 0x20000800 #define EXC_RETURN 0xFFFFFFF9 @@ -215,7 +229,12 @@ static void rxHook(unsigned hook, void *ignored) { if (usb_cdcacm_data_available() >= 4) { // The magic reset sequence is "1EAF". +#if defined(BOOTLOADER_maple) static const uint8 magic[4] = {'1', 'E', 'A', 'F'}; +#endif +#if defined(BOOTLOADER_robotis) + static const uint8 magic[4] = {'C', 'M', '9', 'X'}; +#endif uint8 chkBuf[4]; // Peek at the waiting bytes, looking for reset sequence, @@ -227,6 +246,7 @@ static void rxHook(unsigned hook, void *ignored) { } } +#if defined(BOOTLOADER_maple) // Got the magic sequence -> reset, presumably into the bootloader. // Return address is wait_reset, but we must set the thumb bit. uintptr_t target = (uintptr_t)wait_reset | 0x1; @@ -251,6 +271,12 @@ static void rxHook(unsigned hook, void *ignored) { [exc_return] "r" (EXC_RETURN), [cpsr] "r" (DEFAULT_CPSR) : "r0", "r1", "r2"); +#endif + +#if defined(BOOTLOADER_robotis) + iwdg_init(IWDG_PRE_4, 10); +#endif + /* Can't happen. */ ASSERT_FAULT(0); } |