-
Notifications
You must be signed in to change notification settings - Fork 205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to keep the device in bootloader mode? #679
Comments
I think this is related, but for a different board? Seems like this code is no longer in master. #161 |
@rvdende, here is a snippet which should achieve what your're after: use atsamd_hal::pac::SCB;
/// RAM size (32 kB for ATSAMD21E18A)
const HMCRAMC0_SIZE: u32 = 0x00008000;
/// RAM base address
const HMCRAMC0_ADDR: u32 = 0x20000000;
/// Writing this value into `BOOTLOADER_DBL_TAP_PTR` and resetting will
/// cause the bootloader to 'stick'
const BOOTLOADER_DBL_TAP_MAGIC: u32 = 0xF01669EF;
/// Writing this value into `BOOTLOADER_DBL_TAP_PTR` and resetting will
/// cause the bootloader pass right through to the app
const BOOTLOADER_DBL_TAP_MAGIC_QUICK_BOOT: u32 = 0xF02669EF;
/// Bootloader magic values need to be written here
const BOOTLOADER_DBL_TAP_PTR: *mut u32 = (HMCRAMC0_ADDR + HMCRAMC0_SIZE - 4) as *mut _;
/// Reset into the bootloader, and stay there in order to flash a new
/// firmware image.
#[inline]
pub fn reset() -> ! {
unsafe {
core::ptr::write_volatile(BOOTLOADER_DBL_TAP_PTR, BOOTLOADER_DBL_TAP_MAGIC);
}
SCB::sys_reset();
} |
@rvdende - did @jbeaurivage's code snippet work for you? I wonder if we should find some place to document this, because it seems like a lot of folks using atsamd-rs will also be using the Adafruit bootloader and potentially interested. |
I've added @jbeaurivage 's snippet to a page to the atsamd wiki https://github.com/atsamd-rs/atsamd/wiki/Code-Snippets |
I'm using the metro_m0 board example blinky. However, I have to double press the physical reset button every time and this gets annoying. The arduino IDE somehow gets around this limitation. I think I read somewhere that its related to a few bits at the end of the memory, but I'm not sure how to set those. Can anyone help?
This is the physical board I'm using: https://www.robotics.org.za/6970622930204?search=m0 and the chip says ATSAMD21 G18A-U and I can alter the blink durations in the rust code and that works when I do an upload. I'm on linux and using this script to upload:
The text was updated successfully, but these errors were encountered: