circuitpython/ports/nrf
Jeff Epler 726dcdb60a Add some NORETURN attributes
I have a function where it should be impossible to reach the end, so I put in a safe-mode reset at the bottom:
```
int find_unused_slot(void) {
    // precondition: you already verified that a slot was available
    for (int i=0; i<NUM_SLOTS; i++) {
        if( slot_free(i)) {
            return i;
        }
    }
    safe_mode_reset(MICROPY_FATAL_ERROR);
}
```
However, the compiler still gave a diagnostic, because safe_mode_reset was not declared NORETURN.

So I started by teaching the compiler that reset_into_safe_mode never returned.  This leads at least one level deeper due to reset_cpu needing to be a NORETURN function.  Each port is a little different in this area.  I also marked reset_to_bootloader as NORETURN.
Additional notes:

 * stm32's reset_to_bootloader was not implemented, but now does a bare reset.  Most stm32s are not fitted with uf2 bootloaders anyway.
 * ditto cxd56
 * esp32s2 did not implement reset_cpu at all.  I used esp_restart().  (not tested)
 * litex did not implement reset_cpu at all.  I used reboot_ctrl_write.  But notably this is what reset_to_bootloader already did, so one or the other must be incorrect (not tested).  reboot_ctrl_write cannot be declared NORETURN, as it returns unless the special value 0xac is written), so a new unreachable forever-loop is added.
 * cxd56's reset is via a boardctl() call which can't generically be declared NORETURN, so a new unreacahble "for(;;)" forever-loop is added.
 * In several places, NVIC_SystemReset is redeclared with NORETURN applied.  This is accepted just fine by gcc.  I chose this as preferable to editing the multiple copies of CMSIS headers where it is normally declared.
 * the stub safe_mode reset simply aborts.  This is used in mpy-cross.
2020-09-28 18:55:56 -05:00
..
bluetooth hci early wip; refactor supervisor bluetooth.c for nrf: tested 2020-06-25 20:57:17 -04:00
boards Update user button names. 2020-09-18 17:01:44 -04:00
common-hal PacketBuffer: add missing 'break's, remove unneeded {} 2020-09-13 15:10:38 -05:00
device/nrf52 nrf: add support for nrf52833 2020-04-21 12:29:56 +08:00
examples Add license to some obvious files. 2020-07-06 19:16:25 +01:00
freeze ports/nrf: Moving nrf51/52 port to new ports directory 2017-10-04 21:46:48 +02:00
nrfx@3f55e49eb1 update nrfx submodule to v2 2019-12-18 15:39:11 +07:00
peripherals/nrf Add license to some obvious files. 2020-07-06 19:16:25 +01:00
supervisor Add some NORETURN attributes 2020-09-28 18:55:56 -05:00
.gitignore add CharacteristicBuffer; UART seems to work! 2019-01-07 22:46:20 -05:00
background.c supervisor: factor supervisor_background_tasks from sundry ports 2020-07-15 11:49:44 -05:00
background.h supervisor: factor supervisor_background_tasks from sundry ports 2020-07-15 11:49:44 -05:00
fatfs_port.c Add license to some obvious files. 2020-07-06 19:16:25 +01:00
gccollect.c Fix up end of file and trailing whitespace. 2020-06-03 10:56:35 +01:00
ld_defines.c SPIM3 buffer must be in first 64kB of RAM 2020-08-15 10:31:56 -04:00
Makefile nrf: Improve commenting about disabled warnings 2020-08-12 12:59:48 -05:00
mpconfigport.h SPIM3 buffer must be in first 64kB of RAM 2020-08-15 10:31:56 -04:00
mpconfigport.mk I2CPeripheral: Rename class and its module 2020-06-25 11:44:19 -05:00
mphalport.h Supervisor: move most of systick to the supervisor 2019-11-18 11:01:23 -06:00
nrfx_config.h SPIM3 buffer must be in first 64kB of RAM 2020-08-15 10:31:56 -04:00
nrfx_glue.h nrf: watchdog: use nrfx_wdt driver 2020-05-27 11:28:49 +08:00
nrfx_log.h nrf: Rewrite the SPI common-hal using nrfx 2018-06-25 23:46:34 +02:00
qstrdefsport.h nrf: Remove old qstr defines 2018-06-27 20:52:13 +02:00
README.md address review comments 2019-12-11 15:43:06 -05:00
sd_mutex.c nrf: Use RUN_BACKGROUND_TASKS 2019-08-11 08:53:02 -05:00
sd_mutex.h CharacteristicBuffer: make it be a stream class; add locking 2019-01-19 19:45:35 -05:00

CircuitPython Port To The Nordic Semiconductor nRF52 Series

This is a port of CircuitPython to the Nordic Semiconductor nRF52 series of chips.

Note

: There are board-specific READMEs that may be more up to date than the generic board-neutral documentation below.

Flash

Some boards have UF2 bootloaders and can simply be flashed in the normal way, by copying firmware.uf2 to the BOOT drive.

For some boards, you can use the flash target:

make BOARD=pca10056 flash

Segger Targets

Install the necessary tools to flash and debug using Segger:

JLink Download

nrfjprog linux-32bit Download

nrfjprog linux-64bit Download

nrfjprog osx Download

nrfjprog win32 Download

note: On Linux it might be required to link SEGGER's libjlinkarm.so inside nrfjprog's folder.

DFU Targets

run follow command to install adafruit-nrfutil from PyPi

$ pip3 install --user adafruit-nrfutil

make flash and make sd will not work with DFU targets. Hence, dfu-gen and dfu-flash must be used instead.

  • dfu-gen: Generates a Firmware zip to be used by the DFU flash application.
  • dfu-flash: Triggers the DFU flash application to upload the firmware from the generated Firmware zip file.

When enabled you have different options to test it: