Coder Social home page Coder Social logo

Comments (4)

dhalbert avatar dhalbert commented on July 25, 2024

If you write DBL_TAP_MAGIC into *DBL_TAP_PTR (which is at the very high end of RAM), and then do an NVIC_SystemReset(), it is as if the user double-tapped, and you will remain in the bootloader. Search the source for those symbols if you want more background on this.

from uf2-samdx1.

Knochi avatar Knochi commented on July 25, 2024

'DBL_TAP_PTR' was not declared in this scope

but i found this (link):

void reset_to_bootloader() {
  *(uint32_t *)(0x20000000 + 32768 -4) = 0xf01669ef;   // Store special flag value in last word in RAM.
  NVIC_SystemReset();    // Like pushing the reset button.
}

from uf2-samdx1.

tfcroft4 avatar tfcroft4 commented on July 25, 2024

I asked a similar question with Adafruit forum for a QTPY project. The Adafruit bootloader can use UF2 files.

You need something like this:

//Double Tap used to branch to the bootloader so we can load a new uf2 file
// see https://forums.adafruit.com/viewtopic.php?f=62&t=151707
#if defined(__SAMD51__)
#define BOOT_DOUBLE_TAP_ADDRESS ((volatile uint32_t *)(HSRAM_ADDR + HSRAM_SIZE - 4))
#else
#define BOOT_DOUBLE_TAP_ADDRESS ((volatile uint32_t *)(HMCRAMC0_ADDR + HMCRAMC0_SIZE - 4))
#endif
#define BOOT_DOUBLE_TAP_DATA              (*((volatile uint32_t *)BOOT_DOUBLE_TAP_ADDRESS))
#define DOUBLE_TAP_MAGIC                  0xf01669efUL // Randomly selected, adjusted to have first and last bit set 
void doUpload (char *args)
{
  //will call the boot loader but will pre-load the magic number so that the boot loader stays active
  //the  boot loader drive should appear on the PC
  //either load new firmware or cycle power to exit the boot loader
  Serial.println("Upload New  Firmware: ");
  Serial.print("The board will now reset and a new drive called ");
  #ifdef ADAFRUIT_QT_PY_M0
  Serial.print("QTPY_");
  #else 
  #ifdef ADAFRUIT_ITSTY_BITSY_M0  
  Serial.print("ITSY");
  #else
  Serial.print("??");
  #endif
  #endif
  Serial.println("BOOT will appear on your connected PC.");
  Serial.println("You can drag/copy a UF2 file onto the drive to update the Firmware.");
  Serial.println("The board will reboot after a successful upload.");
  Serial.println("To cancel upload turn power off then on again!");
  delay(1000) ; //delay to let Serial buffer clear
  //pre load the magic number normally used in bootloader first pass
  BOOT_DOUBLE_TAP_DATA = DOUBLE_TAP_MAGIC;
  NVIC_SystemReset();      // processor software reset
}

I hope this helps
Ted
kitst.co.uk

from uf2-samdx1.

dhalbert avatar dhalbert commented on July 25, 2024

Thanks for the comments. Closing as answered.

from uf2-samdx1.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.