]> git.donarmstrong.com Git - kiibohd-controller.git/commitdiff
Some initial bringup of the dfu bootloader on the mk20dx256vlh7
authorJacob Alexander <haata@kiibohd.com>
Sun, 5 Apr 2015 06:21:11 +0000 (23:21 -0700)
committerJacob Alexander <haata@kiibohd.com>
Sun, 14 Jun 2015 21:33:39 +0000 (14:33 -0700)
17 files changed:
Bootloader/CMakeLists.txt
Bootloader/Scripts/swdLoad.bash
Bootloader/_buildvars.h
Bootloader/dfu.c
Bootloader/dfu.desc.c
Bootloader/flash.c
Bootloader/flash.h
Bootloader/main.c
Debug/cli/cli.h
Lib/mk20dx.c
Lib/mk20dx128.ld
Lib/mk20dx128vlf5.bootloader.ld
Lib/mk20dx256.ld
Lib/mk20dx256vlh7.bootloader.ld
Lib/mk20dx256vlh7.ld
Scan/ISSILed/led_scan.c
main.c

index 4db6e230e46eb43ef089bba104fa150b85cd00f6..cad2b1b5e400e467799fb832c226bf77e4bfb231 100644 (file)
@@ -20,8 +20,8 @@
 #| You _MUST_ clean the build directory if you change this value
 #|
 set( CHIP
-       "mk20dx128vlf5"    # McHCK       mk20dx128vlf5
-#       "mk20dx256vlh7"    # Kiibohd-dfu mk20dx256vlh7
+       #"mk20dx128vlf5"    # McHCK       mk20dx128vlf5
+       "mk20dx256vlh7"    # Kiibohd-dfu mk20dx256vlh7
 )
 
 
index 7cf688a705d8cc1349ffec6eacca3a5d0cffdffe..12b1e9badebe39f92b1a20336482b6972a064f25 100755 (executable)
@@ -21,11 +21,13 @@ fi
 
 # Make sure the toolchain is up to date
 cd programmer
-git pull --rebase
+#git pull --rebase
 cd ..
 
 # Attempt to flash
 # Udev rules have been applied to name the buspirate as /dev/buspirate (instead of something like /dev/ttyUSB0)
 # By default only root can access serial devices on Linux
+#ruby programmer/flash.rb name=buspirate:dev=/dev/buspirate --mass-erase
 ruby programmer/flash.rb name=buspirate:dev=/dev/buspirate "$1" "$2"
+#ruby programmer/flash.rb name=buspirate:dev=/dev/buspirate --mass-erase "$1" "$2"
 
index d6c2a6bf09a73f406e65c6c1ea4e6bf42e26e13c..4097a7a368142e89808616a063667c684f3337fa 100644 (file)
@@ -32,7 +32,7 @@
 #define STR_MANUFACTURER        u"Kiibohd"
 #define STR_PRODUCT             u"Kiibohd DFU Bootloader"
 #define STR_SERIAL              u"@CHIP@"
-#define STR_ALTNAME             u"@BOOT_DFU_ALTNAME"
+#define STR_ALTNAME             u"@BOOT_DFU_ALTNAME@"
 
 
 // Mac OS-X and Linux automatically load the correct drivers.  On
index 8a4aa7d2db6abe0c40df5d723ceacc794a56166b..41a3e2d1be8afe59831d146321a65296a8f57313 100644 (file)
@@ -1,5 +1,5 @@
 /* Copyright (c) 2011,2012 Simon Schubert <2@0x2c.org>.
- * Modifications by Jacob Alexander 2014 <haata@kiibohd.com>
+ * Modifications by Jacob Alexander 2014-2015 <haata@kiibohd.com>
  *
  * 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
@@ -98,12 +98,80 @@ static int dfu_handle_control( struct usb_ctrl_req_t *req, void *data )
                        dfu_dnload_complete(NULL, 0, ctx);
                goto out_no_status;
        }
+       case USB_CTRL_REQ_DFU_UPLOAD: {
+               return (0); // TODO
+               /*
+               void *buf;
+
+               switch (ctx->state) {
+               case DFU_STATE_dfuIDLE:
+                       ctx->off = 0;
+                       break;
+               case DFU_STATE_dfuUPLOAD_IDLE:
+                       break;
+               default:
+                       goto err;
+               }
+
+               // XXX Don't STALL? -HaaTa
+               // TODO
+               ctx->status = ctx->setup_write(ctx->off, req->wLength, &buf);
+               if (ctx->status != DFU_STATUS_OK) {
+                       ctx->state = DFU_STATE_dfuERROR;
+                       goto err_have_status;
+               }
+
+               if (req->wLength > 0)
+                       usb_ep0_rx(buf, req->wLength, dfu_dnload_complete, ctx);
+               else
+                       dfu_dnload_complete(NULL, 0, ctx);
+               goto out_no_status;
+               */
+       }
        case USB_CTRL_REQ_DFU_GETSTATUS: {
                struct dfu_status_t st;
 
                st.bState = ctx->state;
                st.bStatus = ctx->status;
                st.bwPollTimeout = 1000; /* XXX */
+
+               // XXX FAKE WRITE
+               if ( ctx->state == DFU_STATE_dfuMANIFEST )
+               {
+                       uint8_t data[] = { 0x10, 0x20, 0x30, 0x40 };
+                       flash_program_longword((uintptr_t)&_app_rom, data);
+               }
+               /*
+
+                       uint32_t *position = &_app_rom + 0x100;
+               for ( ; position < &_app_rom + 0x200; position++ )
+               //for ( ; position < &_app_rom + 0x800; position++ )
+               {
+                       if ( *position != 0xFFFFFFFF )
+                       {
+                       while( 1 )
+                       {
+                               GPIOA_PTOR |= (1<<5);
+                               for (uint32_t d = 0; d < 7200000; d++ );
+                       }
+                       }
+               }*/
+
+               // Check to see if vector table was flashed correctly
+               // Return a flash error if it was not
+               if (_app_rom == 0xffffffff && ctx->state == DFU_STATE_dfuMANIFEST)
+                       st.bStatus = DFU_STATUS_errPROG;
+               //}
+               /*
+               if (ctx->state == DFU_STATE_dfuMANIFEST)
+               {
+                       uint8_t *addr = (uint8_t*)_app_rom;
+                       //while (*(addr++) != 0x80);
+                       //st.bStatus = DFU_STATUS_errPROG;
+                       st.bStatus = (uint8_t)((uint32_t)(&_app_rom) >> 16);
+               }
+               */
+
                /**
                 * If we're in DFU_STATE_dfuMANIFEST, we just finished
                 * the download, and we're just about to send our last
@@ -131,14 +199,13 @@ static int dfu_handle_control( struct usb_ctrl_req_t *req, void *data )
                switch (ctx->state) {
                case DFU_STATE_dfuIDLE:
                case DFU_STATE_dfuDNLOAD_IDLE:
-               /* case DFU_STATE_dfuUPLOAD_IDLE: */
+               case DFU_STATE_dfuUPLOAD_IDLE:
                        ctx->state = DFU_STATE_dfuIDLE;
                        break;
                default:
                        goto err;
                }
                break;
-       /* case USB_CTRL_REQ_DFU_UPLOAD: */
        default:
                return (0);
        }
index 52377ea5dfc504aa9175cd2f981f451261fffb45..c705300a40f644523ff98d7fbe54c34a5151a247 100644 (file)
@@ -1,5 +1,5 @@
 // Originally Generated from MCHCK Toolkit
-/* Copyright (c) Jacob Alexander 2014 <haata@kiibohd.com>
+/* Copyright (c) Jacob Alexander 2014-2015 <haata@kiibohd.com>
  *
  * 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
@@ -61,7 +61,7 @@ static const struct usb_config_1 usb_config_1 = {
                },
                .will_detach = 1,
                .manifestation_tolerant = 0,
-               .can_upload = 0,
+               .can_upload = 1,
                .can_download = 1,
                .wDetachTimeOut = 0,
                .wTransferSize = USB_DFU_TRANSFER_SIZE,
index 2a531174d63fb7b0754357615b376a192e0786c6..57edc16876d7f3270c9f9bd6cd79471e9ea33ac2 100644 (file)
@@ -1,5 +1,5 @@
 /* Copyright (c) 2011,2012 Simon Schubert <2@0x2c.org>.
- * Modifications by Jacob Alexander 2014 <haata@kiibohd.com>
+ * Modifications by Jacob Alexander 2014-2015 <haata@kiibohd.com>
  *
  * 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
@@ -35,14 +35,18 @@ int ftfl_submit_cmd(void)
 {
        FTFL.fstat.raw = ((struct FTFL_FSTAT_t){
                        .ccif = 1,
-                               .rdcolerr = 1,
-                               .accerr = 1,
-                               .fpviol = 1
-                               }).raw;
+                       //.rdcolerr = 1,
+                       .accerr = 1,
+                       .fpviol = 1
+               }).raw;
+
+       // Wait for the operation to complete
        struct FTFL_FSTAT_t stat;
-       while (!(stat = FTFL.fstat).ccif)
-               /* NOTHING */; /* XXX maybe WFI? */
-       return (!!stat.mgstat0);
+       while (!(stat = FTFL.fstat).ccif); // XXX maybe WFI?
+
+       // Mask error bits
+       return stat.raw & (FTFL_FSTAT_RDCOLERR | FTFL_FSTAT_ACCERR | FTFL_FSTAT_FPVIOL | FTFL_FSTAT_MGSTAT0);
+       //return (!!stat.mgstat0);
 }
 
 int flash_prepare_flashing(void)
@@ -66,20 +70,65 @@ int flash_erase_sector(uintptr_t addr)
        return (ftfl_submit_cmd());
 }
 
-int flash_program_section(uintptr_t addr, size_t num_words)
+int flash_program_section_longwords(uintptr_t addr, size_t num_words)
 {
        FTFL.fccob.program_section.fcmd = FTFL_FCMD_PROGRAM_SECTION;
        FTFL.fccob.program_section.addr = addr;
        FTFL.fccob.program_section.num_words = num_words;
-       return (ftfl_submit_cmd());
+
+       return ftfl_submit_cmd();
+}
+
+int flash_program_section_phrases(uintptr_t addr, size_t num_phrases)
+{
+       FTFL.fccob.program_section.fcmd = FTFL_FCMD_PROGRAM_SECTION;
+       FTFL.fccob.program_section.addr = addr;
+       FTFL.fccob.program_section.num_words = num_phrases;
+
+       return ftfl_submit_cmd();
+}
+
+int flash_program_longword(uintptr_t addr, uint8_t *data)
+{
+       FTFL.fccob.program_longword.fcmd = FTFL_FCMD_PROGRAM_LONGWORD;
+       FTFL.fccob.program_longword.addr = addr;
+       FTFL.fccob.program_longword.data_be[0] = data[0];
+       FTFL.fccob.program_longword.data_be[1] = data[1];
+       FTFL.fccob.program_longword.data_be[2] = data[2];
+       FTFL.fccob.program_longword.data_be[3] = data[3];
+
+       return ftfl_submit_cmd();
 }
 
 int flash_program_sector(uintptr_t addr, size_t len)
 {
+#if defined(_mk20dx128vlf5_)
        return (len != FLASH_SECTOR_SIZE ||
                (addr & (FLASH_SECTOR_SIZE - 1)) != 0 ||
                flash_erase_sector(addr) ||
-               flash_program_section(addr, FLASH_SECTOR_SIZE/4));
+               flash_program_section_longwords(addr, FLASH_SECTOR_SIZE / 4));
+#elif defined(_mk20dx256vlh7_)
+       /*
+       return (len != FLASH_SECTOR_SIZE ||
+               (addr & (FLASH_SECTOR_SIZE - 1)) != 0 ||
+               flash_erase_sector(addr) ||
+               flash_program_section_phrases(addr, FLASH_SECTOR_SIZE / 8));
+       */
+       return (len != FLASH_SECTOR_SIZE ||
+               (addr & (FLASH_SECTOR_SIZE - 1)) != 0 ||
+               flash_erase_sector(addr) ||
+               flash_program_section_phrases(addr, FLASH_SECTOR_SIZE / 8));
+#endif
+}
+
+int flash_prepare_reading(void)
+{
+       return (0);
+}
+
+int flash_read_sector(uintptr_t addr, size_t len)
+{
+       return (0);
 }
 
 void *flash_get_staging_area(uintptr_t addr, size_t len)
index 590329598420356b1ea9fdbdd61f8691efa941be..83a592a4f682b2b675c06bf7e042f1553d7b1bba 100644 (file)
@@ -1,5 +1,5 @@
 /* Copyright (c) 2011,2012 Simon Schubert <2@0x2c.org>.
- * Modifications by Jacob Alexander 2014 <haata@kiibohd.com>
+ * Modifications by Jacob Alexander 2014-2015 <haata@kiibohd.com>
  *
  * 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
 
 // ----- Defines -----
 
+#if defined(_mk20dx128vlf5_)
 #define FLASH_SECTOR_SIZE 1024
+#elif defined(_mk20dx256vlh7_)
+#define FLASH_SECTOR_SIZE 2048
+#endif
 
 
 
@@ -30,8 +34,9 @@ __attribute__((section(".ramtext.ftfl_submit_cmd"), long_call))
 int ftfl_submit_cmd(void);
 int flash_prepare_flashing(void);
 int flash_erase_sector(uintptr_t);
-int flash_program_section(uintptr_t, size_t);
+//int flash_program_section(uintptr_t, size_t);
 int flash_program_sector(uintptr_t, size_t);
+int flash_program_longword(uintptr_t, uint8_t*);
 void *flash_get_staging_area(uintptr_t, size_t);
 
 #endif
index a61de7a0f4aeacc51bcb005a586678a373d12092..fd30b6fc2d8f9435e03cfe77b0773560ab1766ef 100644 (file)
 /**
  * Unfortunately we can't DMA directly to FlexRAM, so we'll have to stage here.
  */
-static char staging[FLASH_SECTOR_SIZE];
+static char staging[ FLASH_SECTOR_SIZE ];
 
 
 
 // ----- Functions -----
 
-static enum dfu_status setup_write(size_t off, size_t len, void **buf)
+static enum dfu_status setup_write( size_t off, size_t len, void **buf )
 {
+       GPIOA_PCOR |= (1<<5);
        static int last = 0;
 
-       if (len > sizeof(staging))
+       if ( len > sizeof(staging) )
                return (DFU_STATUS_errADDRESS);
 
        // We only allow the last write to be less than one sector size.
-       if (off == 0)
+       if ( off == 0 )
                last = 0;
-       if (last && len != 0)
+       if ( last && len != 0 )
                return (DFU_STATUS_errADDRESS);
-       if (len != FLASH_SECTOR_SIZE) {
+       if ( len != FLASH_SECTOR_SIZE )
+       {
                last = 1;
-               memset(staging, 0xff, sizeof(staging));
+               memset( staging, 0xff, sizeof(staging) );
        }
 
        *buf = staging;
@@ -58,16 +60,30 @@ static enum dfu_status setup_write(size_t off, size_t len, void **buf)
 static enum dfu_status finish_write( void *buf, size_t off, size_t len )
 {
        void *target;
-       if (len == 0)
+       if ( len == 0 )
                return (DFU_STATUS_OK);
 
        target = flash_get_staging_area(off + (uintptr_t)&_app_rom, FLASH_SECTOR_SIZE);
-       if (!target)
+       if ( !target )
                return (DFU_STATUS_errADDRESS);
-       memcpy(target, buf, len);
-       if (flash_program_sector(off + (uintptr_t)&_app_rom, FLASH_SECTOR_SIZE) != 0)
+       memcpy( target, buf, len );
+
+       // Depending on the error return a different status
+       switch ( flash_program_sector(off + (uintptr_t)&_app_rom, FLASH_SECTOR_SIZE) )
+       {
+       /*
+       case FTFL_FSTAT_RDCOLERR: // Flash Read Collision Error
+       case FTFL_FSTAT_ACCERR:   // Flash Access Error
+       case FTFL_FSTAT_FPVIOL:   // Flash Protection Violation Error
                return (DFU_STATUS_errADDRESS);
-       return (DFU_STATUS_OK);
+       case FTFL_FSTAT_MGSTAT0:  // Memory Controller Command Completion Error
+               return (DFU_STATUS_errADDRESS);
+       */
+
+       case 0:
+       default: // No error
+               return (DFU_STATUS_OK);
+       }
 }
 
 
@@ -93,17 +109,51 @@ void main()
        // Enabling LED to indicate we are in the bootloader
        GPIOA_PDDR |= (1<<5);
        // Setup pin - A5 - See Lib/pin_map.mchck for more details on pins
-       PORTA_PCR19 = PORT_PCR_SRE | PORT_PCR_DSE | PORT_PCR_MUX(1);
+       PORTA_PCR5 = PORT_PCR_SRE | PORT_PCR_DSE | PORT_PCR_MUX(1);
        GPIOA_PSOR |= (1<<5);
-
+#else
+#error "Incompatible chip for bootloader"
 #endif
 
+       //for (uint8_t c = 0; c < 20; c++)
+       /*
+       while( 1 )
+       {
+               GPIOA_PTOR |= (1<<5);
+               for (uint32_t d = 0; d < 7200000; d++ );
+       }
+       */
+
+       // XXX REMOVEME
+       /*
+       GPIOB_PDDR |= (1<<16);
+       PORTB_PCR16 = PORT_PCR_SRE | PORT_PCR_DSE | PORT_PCR_MUX(1);
+       GPIOB_PSOR |= (1<<16);
+       */
+
        flash_prepare_flashing();
 
+       uint32_t *position = &_app_rom;
        usb_init( &dfu_device );
        for (;;)
        {
                usb_poll();
+
+               /*
+               for ( ; position < &_app_rom + 0x201; position++ )
+               //for ( ; position < &_app_rom + 0x800; position++ )
+               {
+                       if ( *position != 0xFFFFFFFF )
+                       {
+                       while( 1 )
+                       {
+                               GPIOA_PTOR |= (1<<5);
+                               for (uint32_t d = 0; d < 7200000; d++ );
+                       }
+                       }
+               }
+               */
+
        }
 }
 
index f4bd36d566e7a1aec90a4c7f09fa407cb3abd375..89cff9985fffdba130736385b73310001b511901 100644 (file)
@@ -55,7 +55,7 @@
        const PROGMEM char name##CLIDict_DescEntry[] = description;
 
 // ARM is easy :P
-#elif defined(_mk20dx128_) || defined(_mk20dx128vlf5_) || defined(_mk20dx256_) // ARM
+#elif defined(_mk20dx128_) || defined(_mk20dx128vlf5_) || defined(_mk20dx256_) || defined(_mk20dx256vlh7_) // ARM
 #define CLIDict_Def(name,description) \
        const char name##Name[] = description; \
        const CLIDictItem name[]
index acd98f5357a2fb1dc29a83a298c29601b807eba0..eb45b9727dac5f698932c1e8c7f87818a97ba3ea 100644 (file)
@@ -394,7 +394,7 @@ const uint8_t flashconfigbytes[16] = {
        //  http://cache.freescale.com/files/microcontrollers/doc/app_note/AN4507.pdf
        //  http://cache.freescale.com/files/32bit/doc/ref_manual/K20P64M72SF1RM.pdf (28.34.6)
        //
-       0xFF, 0xFF, 0xFF, 0xFE, // Program Flash Protection Bytes FPROT0-3
+       0xFF, 0xFF, 0xFF, 0xFF, // Program Flash Protection Bytes FPROT0-3 // XXX TODO PROTECT
 
        0xBE, // Flash security byte FSEC
        0x03, // Flash nonvolatile option byte FOPT
@@ -469,8 +469,17 @@ void ResetHandler()
        //
        // Also checking for ARM lock-up signal (invalid firmware image)
        // RCM_SRS1 & 0x02
-       if ( RCM_SRS0 & 0x40 || RCM_SRS0 & 0x20 || RCM_SRS1 & 0x02 || _app_rom == 0xffffffff ||
-         memcmp( (uint8_t*)&VBAT, sys_reset_to_loader_magic, sizeof(sys_reset_to_loader_magic) ) == 0 ) // Check for soft reload
+       if (    // PIN  (External Reset Pin/Switch)
+                  RCM_SRS0 & 0x40
+               // WDOG (Watchdog timeout)
+               || RCM_SRS0 & 0x20
+               // LOCKUP (ARM Core LOCKUP event)
+               || RCM_SRS1 & 0x02
+               // Blank flash check
+               || _app_rom == 0xffffffff
+               // Software reset
+               || memcmp( (uint8_t*)&VBAT, sys_reset_to_loader_magic, sizeof(sys_reset_to_loader_magic) ) == 0
+       )
        {
                memset( (uint8_t*)&VBAT, 0, sizeof(VBAT) );
        }
index e246d384190d6c101a414b487898d3600ac74939..4e57f8b419d90630d51e3be7f12b6c47e1a32f13 100644 (file)
@@ -85,10 +85,10 @@ SECTIONS
 
        .data : AT (_etext) {
                . = ALIGN(4);
-               _sdata = .; 
+               _sdata = .;
                *(.data*)
                . = ALIGN(4);
-               _edata = .; 
+               _edata = .;
        } > RAM
 
        .noinit (NOLOAD) : {
@@ -97,7 +97,7 @@ SECTIONS
 
        .bss : {
                . = ALIGN(4);
-               _sbss = .; 
+               _sbss = .;
                *(.bss*)
                *(COMMON)
                . = ALIGN(4);
index 1d45a8e072900fd02d4cbde1886036f903cd4de8..3e663d78ef36378fb23623d199869feb2bf52fe5 100644 (file)
@@ -50,12 +50,10 @@ SECTIONS
 {
        .text :
        {
-               . = 0;
-               KEEP(* (.vectors))
+               . = 0; KEEP(* (.vectors)) /* MUST BE AT 0 */
                *(.startup*)
                *(.rodata*)
-               . = 0x400;
-               KEEP(* (.flashconfig))
+               . = 0x400; KEEP(* (.flashconfig)) /* MUST BE AT 0x400 */
                *(.text*)
                . = ALIGN(4);
                KEEP(*(.init))
index 8b787b3a2903593f2942a066d55997855ab25884..27528444a8c726da0bf69f40365641db3e0bb87b 100644 (file)
  * permit persons to whom the Software is furnished to do so, subject to
  * the following conditions:
  *
- * 1. The above copyright notice and this permission notice shall be 
+ * 1. The above copyright notice and this permission notice shall be
  * included in all copies or substantial portions of the Software.
  *
- * 2. If the Software is incorporated into a build system that allows 
+ * 2. If the Software is incorporated into a build system that allows
  * selection among a list of target devices, then similar target
  * devices manufactured by PJRC.COM must be included in the list of
  * target devices and selectable in the same manner.
@@ -50,10 +50,10 @@ MEMORY
  * permit persons to whom the Software is furnished to do so, subject to
  * the following conditions:
  *
- * 1. The above copyright notice and this permission notice shall be 
+ * 1. The above copyright notice and this permission notice shall be
  * included in all copies or substantial portions of the Software.
  *
- * 2. If the Software is incorporated into a build system that allows 
+ * 2. If the Software is incorporated into a build system that allows
  * selection among a list of target devices, then similar target
  * devices manufactured by PJRC.COM must be included in the list of
  * target devices and selectable in the same manner.
@@ -118,10 +118,10 @@ SECTIONS
 
        .data : AT (_etext) {
                . = ALIGN(4);
-               _sdata = .; 
+               _sdata = .;
                *(.data*)
                . = ALIGN(4);
-               _edata = .; 
+               _edata = .;
        } > RAM
 
        .noinit (NOLOAD) : {
@@ -130,7 +130,7 @@ SECTIONS
 
        .bss : {
                . = ALIGN(4);
-               _sbss = .; 
+               _sbss = .;
                *(.bss*)
                *(COMMON)
                . = ALIGN(4);
index aa06f99d6bb7877f84d31e10735794c191a288c6..91ae4fd729c16e4a601c257c4cd4d5c4959b2fcf 100644 (file)
@@ -1,7 +1,7 @@
 /* Teensyduino Core Library
  * http://www.pjrc.com/teensy/
  * Copyright (c) 2013 PJRC.COM, LLC.
- * Modifications by Jacob Alexander 2014 for use with McHCK and Kiibohd-dfu
+ * Modifications by Jacob Alexander 2014-2015 for use with McHCK and Kiibohd-dfu
  *
  * Permission is hereby granted, free of charge, to any person obtaining
  * a copy of this software and associated documentation files (the
@@ -29,8 +29,6 @@
  * SOFTWARE.
  */
 
-/* XXX Not tested yet -HaaTa */
-
 MEMORY
 {
        FLASH (rx)     : ORIGIN = 0x0, LENGTH = 256K
@@ -52,12 +50,10 @@ SECTIONS
 {
        .text :
        {
-               . = 0;
-               KEEP(* (.vectors))
+               . = 0; KEEP(* (.vectors)) /* MUST BE AT 0 */
                *(.startup*)
-               . = 0x400;
+               . = 0x400; KEEP(* (.flashconfig)) /* MUST BE AT 0x400 */
                *(.rodata*)
-               KEEP(* (.flashconfig))
                *(.text*)
                . = ALIGN(4);
                KEEP(*(.init))
index 7189194060f84ce9f7690fae101e2f1e04e30994..a1be3accbac4b4eef99a70d2ca325730f7e1bcc7 100644 (file)
@@ -1,7 +1,7 @@
 /* Teensyduino Core Library
  * http://www.pjrc.com/teensy/
  * Copyright (c) 2013 PJRC.COM, LLC.
- * Modifications by Jacob Alexander 2014 for use with McHCK and Kiibohd-dfu
+ * Modifications by Jacob Alexander 2014-2015 for use with McHCK and Kiibohd-dfu
  *
  * Permission is hereby granted, free of charge, to any person obtaining
  * a copy of this software and associated documentation files (the
@@ -29,8 +29,6 @@
  * SOFTWARE.
  */
 
-/* XXX Not tested yet -HaaTa */
-
 MEMORY
 {
        FLASH (rx) : ORIGIN = 8K, LENGTH = 256K-8K
index 5bb1335bca9297107b81b2999db2d492a6d633ca..d0204b9626d20eabfa8e61c90d472d398a692c85 100644 (file)
@@ -271,7 +271,6 @@ inline void I2C_setup()
        I2C0_FLT = 4;
        I2C0_C1 = I2C_C1_IICEN;
        I2C0_C2 = I2C_C2_HDRS; // High drive select
-//},
 
        // Enable I2C Interrupt
        NVIC_ENABLE_IRQ( IRQ_I2C0 );
diff --git a/main.c b/main.c
index 3b48941dfca0ed1e647378b51b8998fa1138362c..1fa2177d1dd3ba4dd99b6cac4ffa6db7aff81b03 100644 (file)
--- a/main.c
+++ b/main.c
 
 int main()
 {
+       /*
+       GPIOA_PDDR |= (1<<5);
+       // Setup pin - A5 - See Lib/pin_map.mchck for more details on pins
+       PORTA_PCR5 = PORT_PCR_SRE | PORT_PCR_DSE | PORT_PCR_MUX(1);
+       while( 1 )
+       {
+               GPIOA_PTOR |= (1<<5);
+               for (uint32_t d = 0; d < 720000; d++ );
+       }
+       */
+
        // AVR - Teensy Set Clock speed to 16 MHz
 #if defined(_at90usb162_) || defined(_atmega32u4_) || defined(_at90usb646_) || defined(_at90usb1286_)
        CLKPR = 0x80;