From d6019ded26bf8b5dd3a9ad7a0ae0231868c8fc13 Mon Sep 17 00:00:00 2001 From: geeksville Date: Thu, 4 Jun 2020 16:45:31 -0700 Subject: [PATCH 1/2] Place data from .uicrREGOUT0 into UICR.REGOUT0 flash word. Used to set VCC voltage upon power-up. --- linker/nrf52840.ld | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/linker/nrf52840.ld b/linker/nrf52840.ld index fcfa425e..bc1adc12 100644 --- a/linker/nrf52840.ld +++ b/linker/nrf52840.ld @@ -41,6 +41,9 @@ MEMORY /** Location in UICR where mbr params page address is stored. */ UICR_MBR_PARAM_PAGE(r) : ORIGIN = 0x10001018, LENGTH = 0x04 + + /** Location in UICR of REGOUT0 (used to set voltage levels for VCC at boot) */ + UICR_REGOUT0(r) : ORIGIN = 0x10001304, LENGTH = 0x04 } SECTIONS @@ -81,6 +84,12 @@ SECTIONS KEEP(*(.uicrMbrParamsPageAddress)) } > UICR_MBR_PARAM_PAGE + /* Write REGOUT0 in UICR. */ + .uicrREGOUT0 : + { + KEEP(*(.uicrREGOUT0)) + } > UICR_REGOUT0 + .dbl_reset(NOLOAD) : { From 9478eb7ed3eebe0cd41a3a137e9673e376ca8a23 Mon Sep 17 00:00:00 2001 From: geeksville Date: Tue, 16 Jun 2020 09:29:46 -0700 Subject: [PATCH 2/2] address comments from review (warn users, also support 833) --- linker/nrf52833.ld | 16 ++++++++++++++++ linker/nrf52840.ld | 9 ++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/linker/nrf52833.ld b/linker/nrf52833.ld index 46a23dca..4cac961e 100644 --- a/linker/nrf52833.ld +++ b/linker/nrf52833.ld @@ -39,6 +39,16 @@ MEMORY /** Location in UICR where mbr params page address is stored. */ UICR_MBR_PARAM_PAGE(r) : ORIGIN = 0x10001018, LENGTH = 0x04 + + /** Location in UICR of REGOUT0 (used to set voltage levels for VCC at boot) + * + * IMPORTANT NOTE: This controls the voltage provided on the VCC output of the CPU. Changing this value from the default + * can physically damage parts on your board. If using a SWD debugger you should consider connecting the Vref input + * for that debugger to the VCC rail. Think carefully before using this feature. + * Example usage: + * __attribute__ ((section(".uicrREGOUT0"))) volatile uint32_t m_uicr_regout0 = 0xfffffff4; + */ + UICR_REGOUT0(r) : ORIGIN = 0x10001304, LENGTH = 0x04 } SECTIONS @@ -74,6 +84,12 @@ SECTIONS KEEP(*(.uicrMbrParamsPageAddress)) } > UICR_MBR_PARAM_PAGE + /* Write REGOUT0 in UICR. */ + .uicrREGOUT0 : + { + KEEP(*(.uicrREGOUT0)) + } > UICR_REGOUT0 + .dbl_reset(NOLOAD) : { diff --git a/linker/nrf52840.ld b/linker/nrf52840.ld index bc1adc12..dfd11e2d 100644 --- a/linker/nrf52840.ld +++ b/linker/nrf52840.ld @@ -42,7 +42,14 @@ MEMORY /** Location in UICR where mbr params page address is stored. */ UICR_MBR_PARAM_PAGE(r) : ORIGIN = 0x10001018, LENGTH = 0x04 - /** Location in UICR of REGOUT0 (used to set voltage levels for VCC at boot) */ + /** Location in UICR of REGOUT0 (used to set voltage levels for VCC at boot) + * + * IMPORTANT NOTE: This controls the voltage provided on the VCC output of the CPU. Changing this value from the default + * can physically damage parts on your board. If using a SWD debugger you should consider connecting the Vref input + * for that debugger to the VCC rail. Think carefully before using this feature. + * Example usage: + * __attribute__ ((section(".uicrREGOUT0"))) volatile uint32_t m_uicr_regout0 = 0xfffffff4; + */ UICR_REGOUT0(r) : ORIGIN = 0x10001304, LENGTH = 0x04 }