nrf/boards/seeed_xiao_nrf52: Add defn for Seeed XIAO NRF52840 Sense.

It keeps compatibility with the XIAO bootloader by:
- using Soft Device 7.3.0
- reserving 48k memory for the bootloader.

So on double reset a drive pops for uploading an uf2 image or a nrfutil zip
pkg file.  Instructions to create it from a hex file are included.  The
bootloader can as well be activated with the touch 1200 option of nrfutil.

The script download_ble_stack.sh has been adapted to get the version 7.3.0
soft device files.  It may have to be executed once before building.

The file system is set to 256k and the pin definitions are adapted.
Besides that, it has the common functionality and omissions.  The on-board
sensors and additional flash can be supported by Python scripts.
This commit is contained in:
robert-hh 2022-12-06 08:00:56 +01:00 committed by Damien George
parent 6d460d33dc
commit 564945a2a0
9 changed files with 299 additions and 0 deletions

View File

@ -0,0 +1,4 @@
/* GNU linker script for s140 SoftDevice version 7.3.0 */
_sd_size = 0x00027000;
_sd_ram = 0x0000e000;

View File

@ -0,0 +1,4 @@
/* GNU linker script for Adafruit nrf52840 Bootloader */
_bootloader_head_size = 0x1000; /* MBR */
_bootloader_tail_size = 0xC000; /* Bootloader start address 0x000F4000 */

View File

@ -0,0 +1,68 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2022 Arduino SA
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "nrf.h"
#include "nrf_gpio.h"
#include "nrf_rtc.h"
#define PIN_ENABLE_SENSORS_3V3 (40)
#define DFU_MAGIC_SERIAL_ONLY_RESET 0x4e
#define DFU_MAGIC_UF2_RESET 0x57
#define DFU_MAGIC_OTA_RESET 0xA8
void XIAO_board_early_init(void) {
// Errata XIAOBLE - I2C pullup is on SWO line, need to disable TRACE
// was being enabled by nrfx_clock_anomaly_132
CoreDebug->DEMCR = 0;
NRF_CLOCK->TRACECONFIG = 0;
// Bootloader enables interrupt on COMPARE[0], which we don't handle
// Disable it here to avoid getting stuck when OVERFLOW irq is triggered
nrf_rtc_event_disable(NRF_RTC1, NRF_RTC_INT_COMPARE0_MASK);
nrf_rtc_int_disable(NRF_RTC1, NRF_RTC_INT_COMPARE0_MASK);
// Always enable IMU power and I2C Pull-up on startup
nrf_gpio_cfg(PIN_ENABLE_SENSORS_3V3,
NRF_GPIO_PIN_DIR_OUTPUT,
NRF_GPIO_PIN_INPUT_DISCONNECT,
NRF_GPIO_PIN_NOPULL,
GPIO_PIN_CNF_DRIVE_S0H1,
NRF_GPIO_PIN_NOSENSE);
nrf_gpio_pin_set(PIN_ENABLE_SENSORS_3V3);
}
void XIAO_board_deinit(void) {
nrf_gpio_cfg_output(PIN_ENABLE_SENSORS_3V3);
nrf_gpio_pin_clear(PIN_ENABLE_SENSORS_3V3);
}
void XIAO_board_enter_bootloader(void) {
__disable_irq();
NRF_POWER->GPREGRET = DFU_MAGIC_UF2_RESET;
NVIC_SystemReset();
}

View File

@ -0,0 +1,24 @@
{
"deploy": [
"deploy.md"
],
"docs": "",
"features": [
"Bluetooth 5.0",
"IMU LSM6DS3TR",
"Microphone MSM261D3526H1CPM",
"USB-C",
"Breadboard Friendly",
"Battery Management",
"RGB LED",
"QSPI Flash"
],
"images": [
"XIAO_nrf52840_front.jpg"
],
"mcu": "nrf52",
"product": "SEEED XIAO nRF52840 Sense",
"thumbnail": "",
"url": "https://www.seeedstudio.com",
"vendor": "Seeed Studio"
}

View File

@ -0,0 +1,31 @@
The steps below let you create and install the firmware file. For
a .uf2 type file taken from the MicroPython downloads source only
step 4 is needed. For the .hex version of the firmware file, steps
1, 3 and 4 are required.
1. Download and install u2fconv.py. It is available e.g. in the tools
directory of MicroPython.
2. Create a firmware for the SEEED nrf52840 if needed, with the command
`make BOARD=SEEED_XIAO_NRF52 -j5`
in the directory build-SEEED_XIAO_NRF52-s140. The firmware file will have the
name firmware.uf2.
3. Create the .uf2 file if needed in the build directory with the command:
`uf2conv.py -c -f 0xADA52840 -o firmware.uf2 firmware.hex`
It must report the start address as 0x27000. If you omit the -o option,
the output file will have the name flash.uf2.
4. Enable the upload mode by pushing reset twice or calling
machine.bootloader() and copy the file firmware.uf2 to the board drive,
which will pop up on your PC.
In case the XIAO bootloader is lost or overwritten, it can be found
at https://github.com/Seeed-Studio/Adafruit_nRF52_Arduino.git in different
formats. Using a JLINK adapter or interface, it can be uploaded as hex version.
The bootloader is as well available through the Arduino IDE.

View File

@ -0,0 +1,82 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2016 Glenn Ruben Bakke
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#define MICROPY_HW_BOARD_NAME "XIAO nRF52840 Sense"
#define MICROPY_HW_MCU_NAME "NRF52840"
#define MICROPY_PY_SYS_PLATFORM "nrf52"
#define MICROPY_BOARD_EARLY_INIT XIAO_board_early_init
#define MICROPY_BOARD_DEINIT XIAO_board_deinit
#define MICROPY_BOARD_ENTER_BOOTLOADER(nargs, args) XIAO_board_enter_bootloader()
#define MICROPY_HW_USB_CDC (1)
#define MICROPY_PY_MACHINE_UART (1)
#define MICROPY_PY_MACHINE_HW_PWM (1)
#define MICROPY_PY_MACHINE_HW_SPI (1)
#define MICROPY_PY_MACHINE_RTCOUNTER (1)
#define MICROPY_PY_MACHINE_I2C (1)
#define MICROPY_PY_MACHINE_ADC (1)
#define MICROPY_PY_MACHINE_TEMP (1)
#define MICROPY_HW_HAS_FLASH (1)
#define MICROPY_HW_ENABLE_RNG (1)
#define MICROPY_HW_HAS_LED (1)
#define MICROPY_HW_LED_COUNT (4)
#define MICROPY_HW_LED_PULLUP (1)
#define MICROPY_HW_LED1 (17) // LED1
#define MICROPY_HW_LED2 (26) // LED2
#define MICROPY_HW_LED3 (30) // LED3
#define MICROPY_HW_LED4 (6) // LED4
// UART config
#define MICROPY_HW_UART1_TX (32 + 11)
#define MICROPY_HW_UART1_RX (32 + 12)
// SPI0 config
#define MICROPY_HW_SPI0_NAME "SPI0"
#define MICROPY_HW_SPI0_SCK (32 + 13)
#define MICROPY_HW_SPI0_MISO (32 + 14)
#define MICROPY_HW_SPI0_MOSI (32 + 15)
#define MICROPY_HW_PWM0_NAME "PWM0"
#define MICROPY_HW_PWM1_NAME "PWM1"
#define MICROPY_HW_PWM2_NAME "PWM2"
#define HELP_TEXT_BOARD_LED "1,2,3,4"
// Enabling these VID/PID values require to include mpconfigboard.h into usb_descriptors.c.
// But there is an open discussion on whether specific VID/PID values are wanted.
// 1200BPS touch is not supported at the moment in the USB driver, but at least the flag is set.
#define MICROPY_HW_USB_VID (0x2886)
#define MICROPY_HW_USB_PID (0x0045)
#define MICROPY_HW_USB_CDC_1200BPS_TOUCH (1)
void XIAO_board_early_init(void);
void XIAO_board_deinit(void);
void XIAO_board_enter_bootloader(void);

View File

@ -0,0 +1,16 @@
MCU_SERIES = m4
MCU_VARIANT = nrf52
MCU_SUB_VARIANT = nrf52840
SOFTDEV_VERSION = 7.3.0
SD=s140
LD_FILES += boards/seeed_xiao_nrf52/XIAO_bootloader.ld boards/nrf52840_1M_256k.ld
NRF_DEFINES += -DNRF52840_XXAA
MICROPY_VFS_LFS2 = 1
FS_SIZE = 256k
# DEBUG ?= 1
uf2: hex
python3 $(TOP)/tools/uf2conv.py -c -o $(BUILD)/firmware.uf2 -f 0xADA52840 $(BUILD)/firmware.hex

View File

@ -0,0 +1,48 @@
P0,P0
P1,P1
D0_A0,P2
D1_A1,P3
D4_A4,P4
D5_A5,P5
P6,P6
IMU_SDA,P7
P8,P8
NFC1,P9
NFC2,P10
IMU_INT1,P11
P12,P12
P13,P13
READ_BAT,P14
P15,P15
PDM_DATA,P16
P17,P17
P18,P18
P19,P19
QSPI_D0,P20
QSPI_SCK,P21
QSPI_D2,P22
QSPI_D3,P23
QSPI_D1,P24
QSPI_CS,P25
P26,P26
IMU_SCL,P27
D2_A2,P28
D3_A3,P29
P30,P30
ADC0_BAT,P31
PDM_CLK,P32
P33,P33
P34,P34
P35,P35
P36,P36
P37,P37
P38,P38
P39,P39
IMU_PWR,P40
P41,P41
P42,P42
UART1_TX,P43
UART1_RX,P44
SPI0_SCK,P45
SPI0_MISO,P46
SPI0_MOSI,P47
1 P0 P0
2 P1 P1
3 D0_A0 P2
4 D1_A1 P3
5 D4_A4 P4
6 D5_A5 P5
7 P6 P6
8 IMU_SDA P7
9 P8 P8
10 NFC1 P9
11 NFC2 P10
12 IMU_INT1 P11
13 P12 P12
14 P13 P13
15 READ_BAT P14
16 P15 P15
17 PDM_DATA P16
18 P17 P17
19 P18 P18
20 P19 P19
21 QSPI_D0 P20
22 QSPI_SCK P21
23 QSPI_D2 P22
24 QSPI_D3 P23
25 QSPI_D1 P24
26 QSPI_CS P25
27 P26 P26
28 IMU_SCL P27
29 D2_A2 P28
30 D3_A3 P29
31 P30 P30
32 ADC0_BAT P31
33 PDM_CLK P32
34 P33 P33
35 P34 P34
36 P35 P35
37 P36 P36
38 P37 P37
39 P38 P38
40 P39 P39
41 IMU_PWR P40
42 P41 P41
43 P42 P42
44 UART1_TX P43
45 UART1_RX P44
46 SPI0_SCK P45
47 SPI0_MISO P46
48 SPI0_MOSI P47

View File

@ -57,6 +57,25 @@ function download_s140_nrf52_6_1_1
cd - cd -
} }
function download_s140_nrf52_7_3_0
{
echo ""
echo "####################################"
echo "### Downloading s140_nrf52_7.3.0 ###"
echo "####################################"
echo ""
mkdir -p $1/s140_nrf52_7.3.0
cd $1/s140_nrf52_7.3.0
wget --post-data="fileName=DeviceDownload&ids=59452FDD13BA46EEAD0810A57359F294" https://www.nordicsemi.com/api/sitecore/Products/MedialibraryZipDownload2
mv MedialibraryZipDownload2 temp.zip
unzip -u temp.zip
unzip -u s140_nrf52_7.3.0.zip
rm s140_nrf52_7.3.0.zip
rm temp.zip
cd -
}
SCRIPT_DIR="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
@ -64,6 +83,7 @@ if [ $# -eq 0 ]; then
download_s110_nrf51_8_0_0 ${SCRIPT_DIR} download_s110_nrf51_8_0_0 ${SCRIPT_DIR}
download_s132_nrf52_6_1_1 ${SCRIPT_DIR} download_s132_nrf52_6_1_1 ${SCRIPT_DIR}
download_s140_nrf52_6_1_1 ${SCRIPT_DIR} download_s140_nrf52_6_1_1 ${SCRIPT_DIR}
download_s140_nrf52_7_3_0 ${SCRIPT_DIR}
else else
case $1 in case $1 in
"s110_nrf51" ) "s110_nrf51" )
@ -72,6 +92,8 @@ else
download_s132_nrf52_6_1_1 ${SCRIPT_DIR} ;; download_s132_nrf52_6_1_1 ${SCRIPT_DIR} ;;
"s140_nrf52_6_1_1" ) "s140_nrf52_6_1_1" )
download_s140_nrf52_6_1_1 ${SCRIPT_DIR} ;; download_s140_nrf52_6_1_1 ${SCRIPT_DIR} ;;
"s140_nrf52_7_3_0" )
download_s140_nrf52_7_3_0 ${SCRIPT_DIR} ;;
esac esac
fi fi