mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-12 15:03:41 +00:00
nrf52840: add support for flashing with the BOSSA tool
This only works with a custom bossac build from Arduino, not with the upstream version. It avoids needing the manual "double tap" to enter bootloader mode before flashing firmware.
This commit is contained in:
committed by
Ron Evans
parent
d1f445735c
commit
cd628bcde6
@@ -0,0 +1,26 @@
|
|||||||
|
// +build nrf52840,nrf52840_reset_bossa
|
||||||
|
|
||||||
|
package machine
|
||||||
|
|
||||||
|
import (
|
||||||
|
"device/arm"
|
||||||
|
"device/nrf"
|
||||||
|
)
|
||||||
|
|
||||||
|
const DFU_MAGIC_SERIAL_ONLY_RESET = 0xb0
|
||||||
|
|
||||||
|
// checkShouldReset is called by the USB-CDC implementation to check whether to
|
||||||
|
// reset into the bootloader/OTA and if so, resets the chip appropriately.
|
||||||
|
func checkShouldReset() {
|
||||||
|
if usbLineInfo.dwDTERate == 1200 && usbLineInfo.lineState&usb_CDC_LINESTATE_DTR == 0 {
|
||||||
|
EnterSerialBootloader()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// EnterSerialBootloader resets the chip into the serial bootloader. After
|
||||||
|
// reset, it can be flashed using serial/nrfutil.
|
||||||
|
func EnterSerialBootloader() {
|
||||||
|
arm.DisableInterrupts()
|
||||||
|
nrf.POWER.GPREGRET.Set(DFU_MAGIC_SERIAL_ONLY_RESET)
|
||||||
|
arm.SystemReset()
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// +build nrf52840,!nrf52840_reset_uf2
|
// +build nrf52840,!nrf52840_reset_uf2,!nrf52840_reset_bossa
|
||||||
|
|
||||||
package machine
|
package machine
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"inherits": ["nrf52840"],
|
"inherits": ["nrf52840"],
|
||||||
"build-tags": ["nano_33_ble"],
|
"build-tags": ["nano_33_ble", "nrf52840_reset_bossa"],
|
||||||
"flash-command": "bossac_arduino2 -d -i -e -w -v -R --port={port} {bin}",
|
"flash-command": "bossac_arduino2 -d -i -e -w -v -R --port={port} {bin}",
|
||||||
"flash-1200-bps-reset": "true",
|
"flash-1200-bps-reset": "true",
|
||||||
"linkerscript": "targets/nano-33-ble.ld"
|
"linkerscript": "targets/nano-33-ble.ld"
|
||||||
|
|||||||
Reference in New Issue
Block a user