Forum Rule: Always post complete source code & details to reproduce any issue!
Page 2 of 3 FirstFirst 1 2 3 LastLast
Results 26 to 50 of 64

Thread: Over the air updates

  1. #26
    Junior Member
    Join Date
    Mar 2017
    Posts
    2
    The Dropbox link is dead (I think they eliminated public folders recently). Is there any other place to download this? Thanks.

  2. #27
    Senior Member
    Join Date
    May 2015
    Location
    USA
    Posts
    303
    OK, I updated the first post with a new URL.

  3. #28
    Junior Member
    Join Date
    Mar 2017
    Posts
    2
    Quote Originally Posted by jonr View Post
    OK, I updated the first post with a new URL.
    Very nice, thanks. I can verify that it works on a Teensy 3.2 (same processor as a Teensy 3.1).

  4. #29
    Member
    Join Date
    Jul 2016
    Location
    Denmark
    Posts
    26
    Hey jonr
    i have taken out everything but the flasher stuff and i am considering making it into a library, would that be ok and should keep it as a fork from you or make a new repository
    link: https://github.com/alex-Arc/Photosyn...e/flasher_only
    renamed to https://github.com/alex-Arc/Firmware...ree/lib_format
    Last edited by alex-arc; 08-15-2017 at 10:07 PM. Reason: link update

  5. #30
    Senior Member
    Join Date
    May 2015
    Location
    USA
    Posts
    303
    That would be great. Would be really nice to get the Teensy 3.5 and 3.6 modifications into it too.

  6. #31
    Member
    Join Date
    Jul 2016
    Location
    Denmark
    Posts
    26
    i found some info on the Teensy 3.5 and 3.6 and the selector looks like this now
    Code:
    #define RESERVE_FLASH (2 * FLASH_SECTOR_SIZE)
    #elif defined(__MK20DX256__)//T_3.1 and T_3.2
    #define FLASH_SIZE              0x40000
    #define FLASH_SECTOR_SIZE       0x800
    #define FLASH_ID                "fw_teensy3.1"
    #define RESERVE_FLASH (1 * FLASH_SECTOR_SIZE)
    #elif defined(__MK64FX512__)//T_3.5
    #define FLASH_SIZE              0x80000
    #define FLASH_SECTOR_SIZE       0x1000
    #define FLASH_ID                "fw_teensy3.5"
    #define RESERVE_FLASH (1 * FLASH_SECTOR_SIZE)
    #elif defined(__MK66FX1M0__)//T_3.6
    #define FLASH_SIZE              0x100000
    #define FLASH_SECTOR_SIZE       0x1000
    #define FLASH_ID                "fw_teensy3.6"
    #define RESERVE_FLASH (1 * FLASH_SECTOR_SIZE)
    #else
    #error NOT SUPPORTED
    #endif
    from the datasheets
    Click image for larger version. 

Name:	k20.PNG 
Views:	45 
Size:	88.2 KB 
ID:	11285Click image for larger version. 

Name:	k64.PNG 
Views:	52 
Size:	260.4 KB 
ID:	11286Click image for larger version. 

Name:	k66.PNG 
Views:	45 
Size:	256.1 KB 
ID:	11287
    the only thing i don't know is what size the RESERVE_FLASH should be?

  7. #32
    Member
    Join Date
    Jul 2016
    Location
    Denmark
    Posts
    26
    i also found that the .5 and .6 dons't have at flash command (0x06) for writhing a 4 byte word. instead they have a command (0x07) for writing 8 bytes. so i added this:
    Code:
     
     // program long word!
      #if defined(__MK20DX128__) || defined(__MK20DX256__)
      FTFL_FCCOB0 = 0x06;    // PGM
      #elif defined(__MK64FX512__) || defined(__MK66FX1M0__)
      FTFL_FCCOB0 = 0x07;   // PGM
      #endif
    to the flash_word function hoping it would work, but i dose not. Maybe a separate 8 byte flash function is needed.

  8. #33
    Senior Member
    Join Date
    May 2015
    Location
    USA
    Posts
    303
    See here for some discussion of 3.5/3.6 changes.

    https://forum.pjrc.com/threads/43165...sy-3-5-amp-3-6

    If you have untested code, please make it very clear the nobody should run it.

  9. #34
    Member
    Join Date
    Jul 2016
    Location
    Denmark
    Posts
    26
    Quote Originally Posted by jonr View Post
    If you have untested code, please make it very clear the nobody should run it.
    good call. it's
    done

  10. #35
    Senior Member
    Join Date
    May 2015
    Location
    USA
    Posts
    303
    Alex: sorry, it's not clear to me. You tested your code on the 3.5 and 3.6 and it works now? Line 2 of the code suggests otherwise.

  11. #36
    Member
    Join Date
    Jul 2016
    Location
    Denmark
    Posts
    26
    i currently don't have the time to continue, but i'm planing to in the future.
    i only tested with the 3.5 and it seemed to work fine, but i haven't tested it fully. therefor the line "This code is not ready for use" because it should only be used for testing

  12. #37
    Senior Member
    Join Date
    Jan 2013
    Posts
    184
    I haven't been following this thread because I didn't have an immediate need. Just been noting that it's here.

    Today, thanks to Four Short Links, I was made aware of:

    A Firmware Update Architecture for Internet of Things Devices

  13. #38
    Is there someone who has a working version of the serial flasher (for teensy 3.5)?
    It would be worth something to me!

  14. #39
    Junior Member
    Join Date
    Jan 2019
    Posts
    1
    I would really dive into this more, we have a project using older atmega2560's with custom bootloader to flash directly over uart (No reset toggle). I am hoping to get us switched over to the same chip as the Teensy 3.1-3.6, and we would need a bootloader to allow flashing over Uart and not native usb, since we incorporate controls and security using the ft232. Does any one have a write up on such a task, a bootloader with ability to flash over uart, possibly some sort of examples? Im on the hunt to gather all required info to move in this direction, I have downloaded and installed all of the lib's linked in this thread, and uploaded the test01 to my teensy 3.2, just not sure what to do from here.

  15. #40
    Usable for Teensy 4.0 ?

  16. #41
    Member
    Join Date
    Jul 2016
    Location
    Denmark
    Posts
    26
    I don't have a T_4.0 yet
    But i never got it to work on the T_3.6 because of the high clock speeds and needing to clock down before writing to flash. I am guessing it is the same for the T_4.0
    There is most likely a way around it but i never found it.

    In good news i have used this version of the firmware flasher on the T_3.2 i production for over a year now
    https://github.com/alex-Arc/Firmware...flash_from_udp

  17. #42
    Senior Member
    Join Date
    May 2015
    Location
    USA
    Posts
    303
    With the goal of increasing teensy use in IOT applications, I've created a new version of the program for Teensy 4.0. I'm looking for a private alpha tester who will do lots of testing and improve the code. Send me a private message.

  18. #43
    You have an email.

  19. #44
    Senior Member
    Join Date
    May 2015
    Location
    USA
    Posts
    303
    A couple of alpha testers verified that the teensy 4 firmware loader works. But some minor issues remain (like how does one get a teensy 4 to do a full reset from software?).

  20. #45
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,134
    Tie a gpio to reset pin ?

  21. #46
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,367
    Quote Originally Posted by tonton81 View Post
    Tie a gpio to reset pin ?
    Unfortunately, the Teensy 4.0 does not have a reset pin. If the OTA uses the USB programming, then you could tie a pin to the program pin (or you could have whatever microprocessor is doing the USB connection assert the reset pin directly).

  22. #47
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    10,093
    Round about way to Reset : issue-to-reporogram-T4-0

    That code works to SLEEP the T4 with a timer to wake. When it wakes it enters setup() after fresh load from flash in ResetHandler(). Not seen another easy way to reset?

    Using that code with a 2 sec sleep will have it restart. The RTC only works in units of seconds there - and asking for 0 is a fail and asking for 1 sec can fail if the sec is the same by the time is gets to sleep it seems. So asking for 2 assures a full 1 sec sleep then restart.

    I tested minimally to see it work - did not try to purge unneeded code in that sample - and if the cycle works not sure the 'rtc_stopAlarm();' noted in last post is needed. Also did not test on non battery backup T4 - with USB power it should work the same?

  23. #48
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    10,093
    Opened the sample for that RTC_Sleep code, here is where I left it in loop() there is a normal 20 second cycle and sleep 10 secs. If during the 20 secs push over Serial 'Enter' it does a RESET and is back online in 2 seconds. This does work under USB power without RTC battery.

    As noted the code is from @WMXZ - just did some playing with it as it was refined to explain observed issues. Lots of extra code. Should all be safe - worst case is unplug USB to clear and battery if present.


    Code:
    // WMXZ :: SLEEP RTC
    // https://forum.pjrc.com/threads/58484-issue-to-reporogram-T4-0?p=222073&viewfull=1#post222073
    #include "core_pins.h"
    #include "TimeLib.h"
    
    /******************* Seting Alarm ***************/
    #define SNVS_LPSR_PGD_MASK              (0x8U)
    #define SNVS_LPCR_LPTA_EN_MASK          (0x2U)
    
    void rtc_init()
    {
      CCM_CCGR2 |= CCM_CCGR2_IOMUXC_SNVS(CCM_CCGR_ON);
      SNVS_LPGPR = SNVS_DEFAULT_PGD_VALUE;
      SNVS_LPSR = SNVS_LPSR_PGD_MASK;
      // ? calibration
      // ? tamper pins
    
      SNVS_LPCR &= ~SNVS_LPCR_LPTA_EN_MASK; // clear alarm
      while (SNVS_LPCR & SNVS_LPCR_LPTA_EN_MASK);
      SNVS_LPTAR = 0;
    
      SNVS_LPCR |= 1;             // start RTC
      while (!(SNVS_LPCR & 1));
    }
    
    void rtc_set_time(uint32_t secs)
    { //uint32_t secs = 1547051415;
      SNVS_LPCR &= ~1;   // stop RTC
      while (SNVS_LPCR & 1);
      SNVS_LPSRTCMR = (uint32_t)(secs >> 17U);
      SNVS_LPSRTCLR = (uint32_t)(secs << 15U);
      SNVS_LPCR |= 1;             // start RTC
      while (!(SNVS_LPCR & 1));
    }
    
    uint32_t rtc_secs() {
      uint32_t seconds = 0;
      uint32_t tmp = 0;
    
      /* Do consecutive reads until value is correct */
      do
      { seconds = tmp;
        tmp = (SNVS_LPSRTCMR << 17U) | (SNVS_LPSRTCLR >> 15U);
      } while (tmp != seconds);
    
      return seconds;
    }
    
    //PROGMEM
    void rtc_resetAlarm()
    {
      SNVS_LPCR &= ~SNVS_LPCR_LPTA_EN_MASK;
      while (SNVS_LPCR & SNVS_LPCR_LPTA_EN_MASK);
    }
    
    //PROGMEM
    void rtc_stopAlarm()
    {
      SNVS_LPSR |= 1;
      rtc_resetAlarm();
    }
    
    //PROGMEM
    void rtc_isr(void)
    {
      //rtc_stopAlarm();
      SNVS_LPSR |= 1;
      //  Serial.println("Alarm");
      asm volatile ("DSB");
    }
    
    void rtc_initAlarm(uint32_t prio = 13)
    {
      SNVS_LPSR |= 1;
      attachInterruptVector(IRQ_SNVS_IRQ, rtc_isr);
      NVIC_SET_PRIORITY(IRQ_SNVS_IRQ, prio * 16); // 8 is normal priority
      NVIC_DISABLE_IRQ(IRQ_SNVS_IRQ);
    }
    
    void rtc_setAlarm(uint32_t alarmSeconds)
    { uint32_t tmp = SNVS_LPCR; //save control register
    
      /* disable SRTC alarm interrupt */
      rtc_stopAlarm();
    
      SNVS_LPTAR = alarmSeconds;
      while (SNVS_LPTAR != alarmSeconds);
    
      NVIC_ENABLE_IRQ(IRQ_SNVS_IRQ);
    
      SNVS_LPCR = tmp | SNVS_LPCR_LPTA_EN_MASK; // restore control register and set alarm
      while (!(SNVS_LPCR & SNVS_LPCR_LPTA_EN_MASK));
    }
    
    uint32_t rtc_getAlarm()
    {
      return SNVS_LPTAR;
    }
    
    void doShutdown(void)
    {
      //  SNVS_LPCR |=(1<<3) ; // enable wake-up
      SNVS_LPCR |= (1 << 6) ; // turn off power
      while (1) continue;
    }
    
    void setWakeupCallandSleep(uint32_t nsec)
    {
      uint32_t to = now();
      if (!(SNVS_LPCR & 1))
      { rtc_init();
        rtc_set_time(to);   //LPSRTC will start at 0 otherwise
      }
      rtc_initAlarm(4);
      rtc_setAlarm(to + nsec);
      doShutdown();
    }
    
    uint32_t blink(void)
    { static uint32_t tx0;
      if (millis() > tx0 + 1000)
      { digitalWriteFast(13, !digitalReadFast(13));
        tx0 = millis();
        Serial.print("blink @ms=");
        Serial.print(millis());
        Serial.print(" :: ");
        showTime();
        return 1;
      }
      return 0;
    }
    
    void setup() {
      Serial.begin(9600);
      while (!Serial);
      Serial.println("\n" __FILE__ " " __DATE__ " " __TIME__);
    #if defined(__IMXRT1062__)
      Serial.printf("\t F_CPU=%u", F_CPU_ACTUAL );
      Serial.printf( "\tdeg  C=%u\n" , (uint32_t)tempmonGetTemp() );
    #endif
    
      // set the Time library to use Teensy 3.0's RTC to keep time
      setSyncProvider(Teensy3Clock.get);
      delay(100);
      Serial.print("Start :: ");
      if (timeStatus() != timeSet)
        Serial.println("Unable to sync with the RTC");
      else {
        Serial.print("RTC has set the system time :: ");
        showTime( );
      }
      rtc_stopAlarm();  // This clears RTC low power wake settings
      pinMode(13, OUTPUT);
    
    }
    
    void loop() {
      static uint32_t ic = 0;
      ic += blink();
      if (ic >= 20 || Serial.available())
      {
        if ( Serial.available() ) {
          while ( Serial.available() ) Serial.read();
          Serial.println("... RESET ..."); Serial.flush();
          setWakeupCallandSleep(2);
        }
        Serial.printf( "\tdeg  C=%u\n" , (uint32_t)tempmonGetTemp() );
        Serial.println("End"); Serial.flush();
        delay(1000);
        setWakeupCallandSleep(10);
      }
    }
    
    time_t RTCTime;
    void showTime() {
      Serial.print("[c] ");
      Serial.print(hour());
      Serial.print(":");
      Serial.print(minute());
      Serial.print(":");
      Serial.print(second());
      Serial.print(" ");
      Serial.print(month());
      Serial.print("/");
      Serial.print(day());
      Serial.print("/");
      Serial.print(year());
      Serial.println();
    }
    Here is what it looks like sending two ENTER keys over USB after it starts:
    Code:
    T:\tCode\T4\Sleep_RTC_WMXZ\Sleep_RTC_WMXZ.ino Dec  3 2019 12:36:36
    	 F_CPU=600000000	deg  C=47
    Start :: RTC has set the system time :: [c] 14:12:42 12/3/2019
    blink @ms=1001 :: [c] 14:12:42 12/3/2019
    ... RESET ...
    
    T:\tCode\T4\Sleep_RTC_WMXZ\Sleep_RTC_WMXZ.ino Dec  3 2019 12:36:36
    	 F_CPU=600000000	deg  C=47
    Start :: RTC has set the system time :: [c] 14:12:44 12/3/2019
    ... RESET ...
    
    T:\tCode\T4\Sleep_RTC_WMXZ\Sleep_RTC_WMXZ.ino Dec  3 2019 12:36:36
    	 F_CPU=600000000	deg  C=46
    Start :: RTC has set the system time :: [c] 14:12:46 12/3/2019
    blink @ms=1001 :: [c] 14:12:46 12/3/2019

  24. #49
    For me the code is not working at all.

    1. Can not compile the code (error)
    2. if the code is running (modified a bit), then the reset is not done.



    /Applications/Entwicklung/Flasher/flasher4/flasher4.ino:143:35: warning: invalid conversion from 'long unsigned int (*)()' to 'getExternalTime {aka long int (*)()}' [-fpermissive]
    setSyncProvider(Teensy3Clock.get);
    ^
    In file included from /Applications/Entwicklung/Flasher/flasher4/flasher4.ino:4:0:
    /Applications/Arduino.app/Contents/Java/hardware/teensy/avr/libraries/Time/TimeLib.h:134:9: note: initializing argument 1 of 'void setSyncProvider(getExternalTime)'
    void setSyncProvider( getExternalTime getTimeFunction); // identify the external time provider



    But for me it's ok that this is not working, because i can place a message for the User : "Please Power Off and On your Computer".

    In my opinion it would be better to call a reset register of the CPU (like Teensy 3.2) instead of using all these RTC tricks (complicated)

  25. #50
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    10,093
    Quote Originally Posted by Utak View Post
    For me the code is not working at all.

    1. Can not compile the code (error)
    2. if the code is running (modified a bit), then the reset is not done.



    /Applications/Entwicklung/Flasher/flasher4/flasher4.ino:143:35: warning: invalid conversion from 'long unsigned int (*)()' to 'getExternalTime {aka long int (*)()}' [-fpermissive]
    setSyncProvider(Teensy3Clock.get);
    ^
    In file included from /Applications/Entwicklung/Flasher/flasher4/flasher4.ino:4:0:
    /Applications/Arduino.app/Contents/Java/hardware/teensy/avr/libraries/Time/TimeLib.h:134:9: note: initializing argument 1 of 'void setSyncProvider(getExternalTime)'
    void setSyncProvider( getExternalTime getTimeFunction); // identify the external time provider



    But for me it's ok that this is not working, because i can place a message for the User : "Please Power Off and On your Computer".

    In my opinion it would be better to call a reset register of the CPU (like Teensy 3.2) instead of using all these RTC tricks (complicated)
    Is that in ref to post #48 code? Came working from IDE 1.8.10 install with TD 1.49b1. Yes there is 'THAT' warning about a type I didn't clean up - but it runs to T4 - that is a warning and the right thing ends up happening.

    Didn't say it was a good solution - it would need minimization - the RTC time print is DEBUG extraneous and was added just to see continuity in function and clock ticks across the process.

    To date all notes on issuing reset RESET to T4 seemed to indicate it just triggers the bootloader. If there is one that works "to call a reset register of the CPU (like Teensy 3.2) " - please post ...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •