mirror of
https://github.com/espressif/openthread.git
synced 2026-10-03 14:27:38 +00:00
[nrf52840] add support for the USB DFU software trigger (#3312)
This commit is contained in:
committed by
Jonathan Hui
parent
cc1c1a61ac
commit
6e25f6f15d
@@ -64,10 +64,6 @@ else
|
||||
configure_OPTIONS += --with-ncp-bus=uart
|
||||
endif
|
||||
|
||||
ifeq ($(BOOTLOADER),1)
|
||||
configure_OPTIONS += --with-custom-linker-file=$(AbsTopSourceDir)/examples/platforms/nrf52840/nrf52840_bootloader.ld
|
||||
endif
|
||||
|
||||
TopSourceDir := $(dir $(shell readlink $(firstword $(MAKEFILE_LIST))))..
|
||||
AbsTopSourceDir := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))..
|
||||
|
||||
@@ -104,6 +100,11 @@ ifeq ($(USB),1)
|
||||
COMMONCFLAGS += -DUSB_CDC_AS_SERIAL_TRANSPORT=1
|
||||
endif
|
||||
|
||||
ifeq ($(BOOTLOADER),1)
|
||||
configure_OPTIONS += --with-custom-linker-file=$(AbsTopSourceDir)/examples/platforms/nrf52840/nrf52840_bootloader.ld
|
||||
COMMONCFLAGS += -DAPP_USBD_NRF_DFU_TRIGGER_ENABLED=1
|
||||
endif
|
||||
|
||||
ifeq ($(DISABLE_CC310), 1)
|
||||
NRF52840_MBEDTLS_CPPFLAGS += -DDISABLE_CC310=1
|
||||
endif
|
||||
|
||||
@@ -177,6 +177,8 @@ NORDICSEMI_SOURCES
|
||||
@top_builddir@/third_party/NordicSemiconductor/libraries/usb/app_usbd_core.c \
|
||||
@top_builddir@/third_party/NordicSemiconductor/libraries/usb/app_usbd_string_desc.c \
|
||||
@top_builddir@/third_party/NordicSemiconductor/libraries/usb/app_usbd_serial_num.c \
|
||||
@top_builddir@/third_party/NordicSemiconductor/libraries/usb/app_usbd_nrf_dfu_trigger.c \
|
||||
@top_builddir@/third_party/NordicSemiconductor/libraries/usb/nrf_dfu_trigger_usb.c \
|
||||
@top_builddir@/third_party/NordicSemiconductor/libraries/usb/class/cdc/acm/app_usbd_cdc_acm.c \
|
||||
@top_builddir@/third_party/NordicSemiconductor/libraries/utf_converter/utf.c \
|
||||
@top_builddir@/third_party/NordicSemiconductor/nrfx/drivers/src/nrfx_clock.c \
|
||||
@@ -254,6 +256,8 @@ noinst_HEADERS
|
||||
$(top_srcdir)/third_party/NordicSemiconductor/dependencies/nrf_log_internal.h \
|
||||
$(top_srcdir)/third_party/NordicSemiconductor/dependencies/nrf_log_types.h \
|
||||
$(top_srcdir)/third_party/NordicSemiconductor/dependencies/nrf_log.h \
|
||||
$(top_srcdir)/third_party/NordicSemiconductor/dependencies/nrf_log_ctrl.h \
|
||||
$(top_srcdir)/third_party/NordicSemiconductor/dependencies/nrf_log_ctrl_internal.h \
|
||||
$(top_srcdir)/third_party/NordicSemiconductor/dependencies/nrf_section.h \
|
||||
$(top_srcdir)/third_party/NordicSemiconductor/dependencies/nrfx_config.h \
|
||||
$(top_srcdir)/third_party/NordicSemiconductor/dependencies/nrfx_glue.h \
|
||||
@@ -320,6 +324,9 @@ noinst_HEADERS
|
||||
$(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/app_usbd_string_desc.h \
|
||||
$(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/app_usbd_types.h \
|
||||
$(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/app_usbd.h \
|
||||
$(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/app_usbd_nrf_dfu_trigger.h \
|
||||
$(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/app_usbd_nrf_dfu_trigger_types.h \
|
||||
$(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/app_usbd_nrf_dfu_trigger_internal.h \
|
||||
$(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/class/cdc/app_usbd_cdc_desc.h \
|
||||
$(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/class/cdc/app_usbd_cdc_types.h \
|
||||
$(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/class/cdc/acm/app_usbd_cdc_acm_internal.h \
|
||||
|
||||
@@ -49,8 +49,7 @@ Note, that if Windows 7 or earlier is used, an additional USB CDC driver has to
|
||||
It can be found in third_party/NordicSemiconductor/libraries/usb/nordic_cdc_acm_example.inf
|
||||
|
||||
## nRF52840 dongle support (PCA10059)
|
||||
|
||||
You can build the libraries with support for USB bootloader present in PCA10059. As this dongle uses native USB support we have to enable it as well. To do so, build the libraries with the following parameter:
|
||||
You can build the libraries with support for USB bootloader with automatic USB DFU trigger support in PCA10059. As this dongle uses native USB support we have to enable it as well. To do so, build the libraries with the following parameter:
|
||||
```
|
||||
$ make -f examples/Makefile-nrf52840 USB=1 BOOTLOADER=1
|
||||
```
|
||||
|
||||
@@ -421,6 +421,26 @@
|
||||
#define USB_CDC_AS_SERIAL_TRANSPORT 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def The USB interface to use for CDC ACM COMM.
|
||||
*
|
||||
* According to the USB Specification, interface numbers cannot have gaps. Tailor this value to adhere to this
|
||||
* limitation. Takes values between 0-255.
|
||||
*/
|
||||
#ifndef USB_CDC_ACM_COMM_INTERFACE
|
||||
#define USB_CDC_ACM_COMM_INTERFACE 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def The USB interface to use for CDC ACM DATA.
|
||||
*
|
||||
* According to the USB Specification, interface numbers cannot have gaps. Tailor this value to adhere to this
|
||||
* limitation. Takes values between 0-255.
|
||||
*/
|
||||
#ifndef USB_CDC_ACM_DATA_INTERFACE
|
||||
#define USB_CDC_ACM_DATA_INTERFACE 2
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_PLATFORM_USE_PSEUDO_RESET
|
||||
*
|
||||
|
||||
@@ -57,22 +57,21 @@
|
||||
#include "libraries/usb/app_usbd.h"
|
||||
#include "libraries/usb/app_usbd_serial_num.h"
|
||||
#include "libraries/usb/class/cdc/acm/app_usbd_cdc_acm.h"
|
||||
#include "libraries/usb/nrf_dfu_trigger_usb.h"
|
||||
|
||||
#if (USB_CDC_AS_SERIAL_TRANSPORT == 1)
|
||||
|
||||
static void cdcAcmUserEventHandler(app_usbd_class_inst_t const *aInstance, app_usbd_cdc_acm_user_event_t aEvent);
|
||||
|
||||
#define CDC_ACM_COMM_INTERFACE 0
|
||||
#define CDC_ACM_COMM_EPIN NRF_DRV_USBD_EPIN2
|
||||
|
||||
#define CDC_ACM_DATA_INTERFACE 1
|
||||
#define CDC_ACM_DATA_EPIN NRF_DRV_USBD_EPIN1
|
||||
#define CDC_ACM_DATA_EPOUT NRF_DRV_USBD_EPOUT1
|
||||
|
||||
APP_USBD_CDC_ACM_GLOBAL_DEF(sAppCdcAcm,
|
||||
cdcAcmUserEventHandler,
|
||||
CDC_ACM_COMM_INTERFACE,
|
||||
CDC_ACM_DATA_INTERFACE,
|
||||
USB_CDC_ACM_COMM_INTERFACE,
|
||||
USB_CDC_ACM_DATA_INTERFACE,
|
||||
CDC_ACM_COMM_EPIN,
|
||||
CDC_ACM_DATA_EPIN,
|
||||
CDC_ACM_DATA_EPOUT,
|
||||
@@ -263,6 +262,11 @@ void nrf5UartInit(void)
|
||||
ret_code_t ret = app_usbd_init(&usbdConfig);
|
||||
assert(ret == NRF_SUCCESS);
|
||||
|
||||
#if NRF_MODULE_ENABLED(APP_USBD_NRF_DFU_TRIGGER)
|
||||
ret = nrf_dfu_trigger_usb_init();
|
||||
assert(ret == NRF_SUCCESS);
|
||||
#endif // NRF_MODULE_ENABLED(APP_USBD_NRF_DFU_TRIGGER)
|
||||
|
||||
app_usbd_class_inst_t const *cdcAcmInstance = app_usbd_cdc_acm_class_inst_get(&sAppCdcAcm);
|
||||
ret = app_usbd_class_append(cdcAcmInstance);
|
||||
assert(ret == NRF_SUCCESS);
|
||||
|
||||
Reference in New Issue
Block a user