diff --git a/lib/nrfutil b/lib/nrfutil index d48561b073..9e7dfb28a5 160000 --- a/lib/nrfutil +++ b/lib/nrfutil @@ -1 +1 @@ -Subproject commit d48561b07386132b849d0125b0ff6a532d833d8b +Subproject commit 9e7dfb28a5c6f3d7a19340971b32e0c2b4128ecf diff --git a/ports/nrf/boards/feather52/mpconfigboard.mk b/ports/nrf/boards/feather52/mpconfigboard.mk index 1e3aa5a249..7ff8684d22 100644 --- a/ports/nrf/boards/feather52/mpconfigboard.mk +++ b/ports/nrf/boards/feather52/mpconfigboard.mk @@ -31,11 +31,11 @@ __check_defined = \ .PHONY: dfu-gen dfu-flash boot-flash dfu-gen: - $(NRFUTIL) dfu genpkg --dev-type 0x0052 --application $(BUILD)/$(OUTPUT_FILENAME).hex $(BUILD)/dfu-package.zip + $(NRFUTIL) dfu genpkg --sd-req 0xFFFE --dev-type 0x0052 --application $(BUILD)/$(OUTPUT_FILENAME).hex $(BUILD)/dfu-package.zip dfu-flash: @:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyUSB0) - $(NRFUTIL) dfu serial --package $(BUILD)/dfu-package.zip -p $(SERIAL) -b 115200 + $(NRFUTIL) dfu serial --package $(BUILD)/dfu-package.zip -p $(SERIAL) -b 115200 --singlebank boot-flash: @:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyUSB0) diff --git a/ports/nrf/boards/feather52840/mpconfigboard_s140.mk b/ports/nrf/boards/feather52840/mpconfigboard_s140.mk index 2a3c98e7dc..c49e3222eb 100644 --- a/ports/nrf/boards/feather52840/mpconfigboard_s140.mk +++ b/ports/nrf/boards/feather52840/mpconfigboard_s140.mk @@ -36,7 +36,7 @@ dfu-gen: dfu-flash: @:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyUSB0) - $(NRFUTIL) --verbose dfu serial --package $(BUILD)/dfu-package.zip -p $(SERIAL) -b 115200 + $(NRFUTIL) --verbose dfu serial --package $(BUILD)/dfu-package.zip -p $(SERIAL) -b 115200 --singlebank boot-flash: nrfjprog --program $(BOOT_UART_FILE).hex -f nrf52 --chiperase --reset diff --git a/ports/nrf/hal/hal_uart.c b/ports/nrf/hal/hal_uart.c index e8d4230816..b0a57a2a6e 100644 --- a/ports/nrf/hal/hal_uart.c +++ b/ports/nrf/hal/hal_uart.c @@ -156,6 +156,10 @@ void hal_uart_init(NRF_UART_Type * p_instance, hal_uart_init_t const * p_uart_in NVIC_EnableIRQ(p_uart_init->irq_num); } +bool hal_uart_inited(NRF_UART_Type * p_instance) +{ + return !(p_instance->PSELTXD & (1 << 31)) && !(p_instance->PSELRXD & (1 << 31)); +} void UARTE0_UART0_IRQHandler(void) { diff --git a/ports/nrf/hal/hal_uart.h b/ports/nrf/hal/hal_uart.h index 76c09b335f..47f10cce1b 100644 --- a/ports/nrf/hal/hal_uart.h +++ b/ports/nrf/hal/hal_uart.h @@ -117,6 +117,7 @@ typedef struct typedef void (*uart_complete_cb)(void); void hal_uart_init(NRF_UART_Type * p_instance, hal_uart_init_t const * p_uart_init); +bool hal_uart_inited(NRF_UART_Type * p_instance); hal_uart_error_t hal_uart_char_write(NRF_UART_Type * p_instance, uint8_t ch); diff --git a/ports/nrf/mpconfigport.h b/ports/nrf/mpconfigport.h index a463108b87..ac5741f771 100644 --- a/ports/nrf/mpconfigport.h +++ b/ports/nrf/mpconfigport.h @@ -330,6 +330,6 @@ extern const struct _mp_obj_module_t ble_module; #include #define MICROPY_PIN_DEFS_PORT_H "pin_defs_nrf5.h" -//#define CIRCUITPY_BOOT_OUTPUT_FILE "/boot_out.txt" +#define CIRCUITPY_BOOT_OUTPUT_FILE "/boot_out.txt" #endif diff --git a/ports/nrf/mphalport.c b/ports/nrf/mphalport.c index 957d3535d2..824ce859ae 100644 --- a/ports/nrf/mphalport.c +++ b/ports/nrf/mphalport.c @@ -65,9 +65,23 @@ bool mp_hal_stdin_any(void) { } void mp_hal_stdout_tx_strn(const char *str, mp_uint_t len) { - while(len--) { - hal_uart_char_write(UART_INSTANCE, *str++); - } + +// #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 + + if ( hal_uart_inited(UART_INSTANCE) ) { + while(len--) { + hal_uart_char_write(UART_INSTANCE, *str++); + } + } } void mp_hal_stdout_tx_strn_cooked(const char *str, mp_uint_t len) {