make SD default to s140 and s132 for nrf52840 and nrf52832

add CFG_HWUART_FOR_SERIAL for using jlink as REPL
This commit is contained in:
hathach 2018-07-06 14:39:49 +07:00
parent 6ef3a0b181
commit 948ddf8463
12 changed files with 65 additions and 48 deletions

View File

@ -1,19 +1,21 @@
# Select the board to build for: if not given on the command line,
# then default to feather52832.
BOARD ?= feather52832
ifeq ($(wildcard boards/$(BOARD)/.),)
$(error Invalid BOARD specified)
# Select the board to build for.
ifeq ($(BOARD),)
$(info You must provide a BOARD parameter with 'BOARD=')
$(info Possible values are:)
$(info $(sort $(subst /.,,$(subst boards/,,$(wildcard boards/*/.)))))
$(error BOARD not defined)
else
ifeq ($(wildcard boards/$(BOARD)/.),)
$(error Invalid BOARD specified)
endif
endif
# If SoftDevice is selected, try to use that one.
# Default to SD132 (exact version can be set with SOFTDEV_VERSION)
SD ?= s132
SD_LOWER = $(shell echo $(SD) | tr '[:upper:]' '[:lower:]')
# TODO: Verify that it is a valid target.
# If the build directory is not given, make it reflect the board name
BUILD ?= $(if $(SD),build-$(BOARD)-$(SD_LOWER),build-$(BOARD))
# If the build directory with SD
BUILD = $(if $(SD),build-$(BOARD)-$(SD_LOWER),build-$(BOARD))
include ../../py/mkenv.mk
include boards/$(BOARD)/mpconfigboard.mk

View File

@ -36,19 +36,11 @@
#include "tusb.h"
/*------------------------------------------------------------------*/
/* MACRO TYPEDEF CONSTANT ENUM
*------------------------------------------------------------------*/
/*------------------------------------------------------------------*/
/* VARIABLE DECLARATION
*------------------------------------------------------------------*/
/*------------------------------------------------------------------*/
/* FUNCTION DECLARATION
*------------------------------------------------------------------*/
void run_background_tasks(void) {
#ifdef NRF52840_XXAA
tusb_task();
tud_cdc_flush();
#endif
}

View File

@ -1,6 +1,7 @@
MCU_SERIES = m4
MCU_VARIANT = nrf52
MCU_SUB_VARIANT = nrf52
SD ?= s132
SOFTDEV_VERSION ?= 2.0.1
LD_FILE = boards/feather52832/custom_nrf52832_dfu_app_$(SOFTDEV_VERSION).ld

View File

@ -1,6 +1,7 @@
MCU_SERIES = m4
MCU_VARIANT = nrf52
MCU_SUB_VARIANT = nrf52840
SD ?= s140
SOFTDEV_VERSION ?= 6.0.0
BOOT_SETTING_ADDR = 0xFF000

View File

@ -1,6 +1,7 @@
MCU_SERIES = m4
MCU_VARIANT = nrf52
MCU_SUB_VARIANT = nrf52
SD ?= s132
SOFTDEV_VERSION ?= 5.0.0
ifeq ($(SD),)

View File

@ -36,10 +36,12 @@
void board_init(void) {
// Init USB
// Clock
NRF_CLOCK->LFCLKSRC = (uint32_t)((CLOCK_LFCLKSRC_SRC_Xtal << CLOCK_LFCLKSRC_SRC_Pos) & CLOCK_LFCLKSRC_SRC_Msk);
NRF_CLOCK->TASKS_LFCLKSTART = 1UL;
// Init USB
#ifdef SOFTDEVICE_PRESENT
// TODO support Softdevice config
#else

View File

@ -28,7 +28,7 @@
#define MICROPY_HW_BOARD_NAME "PCA10056"
#define MICROPY_HW_MCU_NAME "NRF52840"
#define MICROPY_PY_SYS_PLATFORM "nrf52840-PDK"
#define MICROPY_PY_SYS_PLATFORM "nrf52840-DK"
#define MICROPY_HW_HAS_LED (1)
#define MICROPY_HW_HAS_SWITCH (0)
@ -77,3 +77,8 @@
#define PORT_HEAP_SIZE (128*1024)
#define CIRCUITPY_AUTORELOAD_DELAY_MS 500
// Temp (could be removed) 0: usb cdc (default), 1 : hwuart (jlink)
#define CFG_HWUART_FOR_SERIAL 0

View File

@ -1,6 +1,7 @@
MCU_SERIES = m4
MCU_VARIANT = nrf52
MCU_SUB_VARIANT = nrf52840
SD ?= s140
SOFTDEV_VERSION ?= 6.0.0
BOOT_SETTING_ADDR = 0xFF000

View File

@ -74,7 +74,6 @@ void internal_flash_init(void) {
port_pin_set_config(MICROPY_HW_LED_MSC, &pin_conf);
port_pin_set_output_level(MICROPY_HW_LED_MSC, false);
#endif
// flash_init(&internal_flash_desc, NVMCTRL);
}
uint32_t internal_flash_get_block_size(void) {

View File

@ -33,17 +33,17 @@
#define FLASH_ROOT_POINTERS
#define FLASH_PAGE_SIZE 0x1000
#define CIRCUITPY_INTERNAL_NVM_SIZE 0
#define FLASH_PAGE_SIZE 0x1000
#define CIRCUITPY_INTERNAL_NVM_SIZE 0
#define INTERNAL_FLASH_SYSTICK_MASK (0x1ff) // 512ms
#define INTERNAL_FLASH_IDLE_TICK(tick) (((tick) & INTERNAL_FLASH_SYSTICK_MASK) == 2)
#define INTERNAL_FLASH_SYSTICK_MASK (0x1ff) // 512ms
#define INTERNAL_FLASH_IDLE_TICK(tick) (((tick) & INTERNAL_FLASH_SYSTICK_MASK) == 2)
void internal_flash_init(void);
uint32_t internal_flash_get_block_size(void);
uint32_t internal_flash_get_block_count(void);
void internal_flash_irq_handler(void);
void internal_flash_flush(void);
void internal_flash_init(void);
uint32_t internal_flash_get_block_size(void);
uint32_t internal_flash_get_block_count(void);
void internal_flash_irq_handler(void);
void internal_flash_flush(void);
// these return 0 on success, non-zero on error
mp_uint_t internal_flash_read_blocks(uint8_t *dest, uint32_t block_num, uint32_t num_blocks);

View File

@ -32,13 +32,20 @@
#include "py/mperrno.h"
#include "hal_uart.h"
#ifndef NRF52840_XXAA
#if !defined( NRF52840_XXAA) || ( defined(CFG_HWUART_FOR_SERIAL) && CFG_HWUART_FOR_SERIAL == 1 )
#define UART_INSTANCE UART_BASE(0)
#if (MICROPY_PY_BLE_NUS == 0)
int mp_hal_stdin_rx_chr(void) {
for (;;) {
#ifdef MICROPY_VM_HOOK_LOOP
MICROPY_VM_HOOK_LOOP
#endif
// if (reload_requested) {
// return CHAR_CTRL_D;
// }
if ( hal_uart_available(UART_INSTANCE) ) {
uint8_t ch;
hal_uart_char_read(UART_INSTANCE, &ch);
@ -99,6 +106,7 @@ int mp_hal_stdin_rx_chr(void) {
// if (reload_requested) {
// return CHAR_CTRL_D;
// }
if (tud_cdc_available()) {
#ifdef MICROPY_HW_LED_RX
gpio_toggle_pin_level(MICROPY_HW_LED_RX);
@ -106,6 +114,8 @@ int mp_hal_stdin_rx_chr(void) {
return tud_cdc_read_char();
}
}
return 0;
}
bool mp_hal_stdin_any(void) {
@ -114,20 +124,21 @@ bool mp_hal_stdin_any(void) {
void mp_hal_stdout_tx_strn(const char *str, mp_uint_t len) {
// #ifdef MICROPY_HW_LED_TX
// gpio_toggle_pin_level(MICROPY_HW_LED_TX);
// #endif
//
// #ifdef CIRCUITPY_BOOT_OUTPUT_FILE
// if (boot_output_file != NULL) {
// UINT bytes_written = 0;
// f_write(boot_output_file, str, len, &bytes_written);
// }
// #endif
#ifdef MICROPY_HW_LED_TX
gpio_toggle_pin_level(MICROPY_HW_LED_TX);
#endif
#ifdef CIRCUITPY_BOOT_OUTPUT_FILE
if (boot_output_file != NULL) {
UINT bytes_written = 0;
f_write(boot_output_file, str, len, &bytes_written);
}
#endif
tud_cdc_write(str, len);
}
// TODO use stdout_helper.c
void mp_hal_stdout_tx_strn_cooked(const char *str, size_t len) {
while (len--) {
if (*str == '\n') {
@ -137,9 +148,11 @@ void mp_hal_stdout_tx_strn_cooked(const char *str, size_t len) {
}
}
#endif
void mp_hal_stdout_tx_str(const char *str) {
mp_hal_stdout_tx_strn(str, strlen(str));
}
#endif

View File

@ -36,7 +36,7 @@
#include "ble_uart.h"
#endif
#ifndef NRF52840_XXAA
#if !defined( NRF52840_XXAA) || ( defined(CFG_HWUART_FOR_SERIAL) && CFG_HWUART_FOR_SERIAL == 1 )
void serial_init(void) {
@ -91,7 +91,7 @@ void serial_write(const char* text) {
#include "tusb.h"
void serial_init(void) {
// usb should be initialized in board_init()
// usb is already initialized in board_init()
}