This repository was archived by the owner on Apr 16, 2021. It is now read-only.
This repository was archived by the owner on Apr 16, 2021. It is now read-only.
Is it possible to put the Arduino 33 BLE into bootloader mode from code? #64
Closed
Description
I would like to be sure that my Arduino is in upload mode before pressing the upload button from IDE. This is because my Arduino is not easy to reach and I often have to press the reset button to load the sketch.
I could put Arduino in upload mode, from bluetooth, with a code if this were possible.
Thanks
Activity
facchinm commentedon Apr 7, 2020
Hi Giorgio, sure you can 🙂
The function we invoke to reboot into bootloader is
_ontouch1200bps_()
(from here) .You can add a BLE characteristic that will call that function when written.
I'm a bit more interested in why you often need to double press the reset button... Are you on Linux? In that case there might be
modemmanager
interfering with the upload procedure (as reported multiple times, for example here arduino/Arduino#7690)morettigiorgio commentedon Apr 8, 2020
Hi Martino.
It is perfect. It is properly that I looked for. Thanks
I hope I'm not off topic too:
The problem is only when I use the WDT routine.
At the end of compile, my IDE looks for COMs and Arduino changes from COM12 in COM13, the upload starting but after a few seconds, Arduino disconnects from USB (LED_BUILTIN flash 2 fast and 2 slow).
Only reset with bootload mode resolves it
It seems that WDT interrupts the uploading
facchinm commentedon Apr 8, 2020
Ah, it's what surely happens... How often is your watchdog configured to fire? From what I read on Nordic forum, there's no way to deactivate it using a soft reset, only the reset button works, so the code I gave you is unlikely to fix the problem.
A workaround could be to configure the watchdog period to a long one just before calling
NVIC_SystemReset
inside_ontouch1200bps_()
(https://devzone.nordicsemi.com/f/nordic-q-a/53904/nrf52840-watchdog-for-arduino-nano-33-ble-sense/217952#217952) and then, when the sketch boots, reconfigure it to the desired periodmorettigiorgio commentedon Apr 8, 2020
In fact, your code works only with WDT disable and my uploading problem is the same of your link indicates. I use that WDT code (5 sec) and once it started there is not way to stop it. I also tried to modify the WDT time with NRF_WDT->CRV = 3932159; (120s) before ontouch1200bps(); but, unfortunately, it seams irrelevat
leomonan commentedon Apr 17, 2020
I use this code and it works (reset to bootloader):
manchoz commentedon Apr 17, 2020
@morettigiorgio in order to actually change the timeout value you also need to feed the WDT. Please, refer to Reload Criteria for more information.
The complete sequence should be:
This feature is also available via the NRF5 SDK that you can use directly from the Arduino sketch.
FYI, NRF52840's watchdog is fully supported via the MbedOS Watchdog API even on Arduino Nano 33. Still, the MbedOS Watchdog API is pretty simple/naive and Nordic's Watchdog can't be stopped.
morettigiorgio commentedon Apr 17, 2020
Thanks @leomonan and @manchoz, I will test them soon.
facchinm commentedon Apr 22, 2020
Closing as answered 😉