Comments (4)
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.
'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.
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.
Thanks for the comments. Closing as answered.
from uf2-samdx1.
Related Issues (20)
- SAMD21 Clock Config HOT 5
- NeoKey Trinkey update files missing HOT 3
- SAME51 update for Adafruit Feather M4 CAN? HOT 2
- Compiling for the SAMDA1G16B HOT 5
- circuit playground express 3.14 macos Monterey HOT 4
- Having an issue with USB device disappearing if the programmer is not connected HOT 1
- Makefile issues HOT 4
- macOS 13.0 (Ventura) Finder gives error when uploading UF2 files HOT 4
- Linking issue HOT 1
- Custom pin mapping for ATSAMD21G18A HOT 1
- Problem building the project in VS code HOT 1
- Reading logs - how???? HOT 3
- MKR Vidor 4000 Arduino Sketch Upload halts at around 50% only when loaded via uf2 bootloader
- Building an "unlocked" (no flash write protection) bootloader? HOT 1
- Change the filesystem be changed to FAT or FAT32 ? HOT 1
- Double definition of WDT for SAMD51
- Adding a timeout to the bootloader HOT 12
- Add Wire Mux HOT 1
- Flash corruptioin on SAMD51 HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from uf2-samdx1.