mirror of
https://github.com/oltaco/Adafruit_nRF52_Bootloader_OTAFIX.git
synced 2026-10-24 17:14:06 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0f40a6076e | ||
|
|
f9c032fbd7 | ||
|
|
941b1ddfeb | ||
|
|
f6c9614976 | ||
|
|
68959e00c4 | ||
|
|
1d85a000e2 | ||
|
|
05fcc9f32d | ||
|
|
527aa4df08 | ||
|
|
7211d3847c | ||
|
|
d02d6c8114 | ||
|
|
993ac762ca | ||
|
|
d099cda94c | ||
|
|
569e64f504 | ||
|
|
4946c0388f | ||
|
|
d6743ea8a1 | ||
|
|
f205fcd6fb | ||
|
|
41db95f28e | ||
|
|
66b6712682 | ||
|
|
0d97c2108d | ||
|
|
0889a68a7a | ||
|
|
38a67d1896 | ||
|
|
0fc9f2f4bd | ||
|
|
3791f9376e | ||
|
|
0f052bcee0 | ||
|
|
3d04d61bc6 | ||
|
|
235c0fac5b |
No files matched your search
@@ -24,7 +24,7 @@ jobs:
|
||||
- 'itsybitsy_nrf52840_express'
|
||||
- 'metro_nrf52840_express'
|
||||
- 'ledglasses_nrf52840'
|
||||
# Alphabetical order
|
||||
# Other Makers (Alphabetical order)
|
||||
- 'adm_b_nrf52840_1'
|
||||
- 'ae_bl652_bo'
|
||||
- 'aramcon_badge_2019'
|
||||
@@ -32,6 +32,7 @@ jobs:
|
||||
- 'arcade_feather_nrf52840_express'
|
||||
- 'arduino_nano_33_ble'
|
||||
- 'bast_ble'
|
||||
- 'bluemicro_nrf52833'
|
||||
- 'bluemicro_nrf52840'
|
||||
- 'ebyte_e104_bt5032a'
|
||||
- 'ebyte_e73_tbb'
|
||||
@@ -49,6 +50,7 @@ jobs:
|
||||
- 'pca10059'
|
||||
- 'pca10100'
|
||||
- 'pitaya_go'
|
||||
- 'raytac_mdbt50q_db_40'
|
||||
- 'raytac_mdbt50q_rx'
|
||||
- 'sparkfun_nrf52840_micromod'
|
||||
- 'waveshare_nrf52840_eval'
|
||||
@@ -63,11 +65,18 @@ jobs:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v1
|
||||
with:
|
||||
submodules: true
|
||||
submodules: true
|
||||
|
||||
- name: Checkout linkermap
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
repository: hathach/linkermap
|
||||
path: linkermap
|
||||
|
||||
- name: Install Toolchains
|
||||
run: |
|
||||
pip3 install adafruit-nrfutil uritemplate requests intelhex
|
||||
pip3 install linkermap/
|
||||
npm install --global xpm
|
||||
# 9.3.1-1.2.1 is xpack modified version which significantly increased compiled size to 6-7KB and cause flash overflow.
|
||||
# Skip this version for now, we will try again with next official release from ARM
|
||||
@@ -78,34 +87,20 @@ jobs:
|
||||
run: |
|
||||
make BOARD=${{ matrix.board }} all
|
||||
make BOARD=${{ matrix.board }} copy-artifact
|
||||
|
||||
- name: Linker Map
|
||||
run: make BOARD=${{ matrix.board }} linkermap
|
||||
|
||||
- uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: ${{ matrix.board }}
|
||||
path: _bin/${{ matrix.board }}
|
||||
|
||||
- name: Create Release Asset
|
||||
if: ${{ github.event_name == 'release' }}
|
||||
run: zip -jr ${{ matrix.board }}_bootloader-${{ github.event.release.tag_name }}.zip _bin/${{ matrix.board }}
|
||||
|
||||
- name: Upload Release Asset
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
uses: softprops/action-gh-release@v1
|
||||
if: ${{ github.event_name == 'release' }}
|
||||
with:
|
||||
upload_url: ${{ github.event.release.upload_url }}
|
||||
asset_path: ${{ matrix.board }}_bootloader-${{ github.event.release.tag_name }}.zip
|
||||
asset_name: ${{ matrix.board }}_bootloader-${{ github.event.release.tag_name }}.zip
|
||||
asset_content_type: application/zip
|
||||
|
||||
- name: Upload Release Asset for Self-Update
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
if: ${{ github.event_name == 'release' }}
|
||||
with:
|
||||
upload_url: ${{ github.event.release.upload_url }}
|
||||
asset_path: _bin/${{ matrix.board }}/update-${{ matrix.board }}_bootloader-${{ github.event.release.tag_name }}_nosd.uf2
|
||||
asset_name: update-${{ matrix.board }}_bootloader-${{ github.event.release.tag_name }}_nosd.uf2
|
||||
asset_content_type: application/x-binary
|
||||
files: |
|
||||
_bin/${{ matrix.board }}/${{ matrix.board }}_bootloader-*.zip
|
||||
_bin/${{ matrix.board }}/${{ matrix.board }}_bootloader-*.hex
|
||||
_bin/${{ matrix.board }}/update-${{ matrix.board }}_bootloader-*.uf2
|
||||
@@ -124,13 +124,14 @@ endif
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# all files in src
|
||||
C_SRC += $(wildcard src/*.c)
|
||||
C_SRC += \
|
||||
src/dfu_ble_svc.c \
|
||||
src/dfu_init.c \
|
||||
src/flash_nrf5x.c \
|
||||
src/main.c \
|
||||
|
||||
# all files in boards
|
||||
C_SRC += $(wildcard src/boards/*.c)
|
||||
|
||||
# all sources files in specific board
|
||||
C_SRC += $(wildcard src/boards/$(BOARD)/*.c)
|
||||
C_SRC += src/boards/boards.c
|
||||
|
||||
# nrfx
|
||||
C_SRC += $(NRFX_PATH)/drivers/src/nrfx_power.c
|
||||
@@ -172,18 +173,25 @@ IPATH += $(SDK_PATH)/drivers_nrf/uart
|
||||
|
||||
else
|
||||
|
||||
# pinconfig is required for 840 for CF2
|
||||
C_SRC += src/boards/$(BOARD)/pinconfig.c
|
||||
|
||||
# USB Application ( MSC + UF2 )
|
||||
C_SRC += $(wildcard src/usb/*.c)
|
||||
C_SRC += $(wildcard src/usb/uf2/*.c)
|
||||
C_SRC += \
|
||||
src/usb/msc_uf2.c \
|
||||
src/usb/usb_desc.c \
|
||||
src/usb/usb.c \
|
||||
src/usb/uf2/ghostfat.c
|
||||
|
||||
# TinyUSB stack
|
||||
C_SRC += $(TUSB_PATH)/portable/nordic/nrf5x/dcd_nrf5x.c
|
||||
C_SRC += $(TUSB_PATH)/common/tusb_fifo.c
|
||||
C_SRC += $(TUSB_PATH)/device/usbd.c
|
||||
C_SRC += $(TUSB_PATH)/device/usbd_control.c
|
||||
C_SRC += $(TUSB_PATH)/class/cdc/cdc_device.c
|
||||
C_SRC += $(TUSB_PATH)/class/msc/msc_device.c
|
||||
C_SRC += $(TUSB_PATH)/tusb.c
|
||||
C_SRC += \
|
||||
$(TUSB_PATH)/portable/nordic/nrf5x/dcd_nrf5x.c \
|
||||
$(TUSB_PATH)/common/tusb_fifo.c \
|
||||
$(TUSB_PATH)/device/usbd.c \
|
||||
$(TUSB_PATH)/device/usbd_control.c \
|
||||
$(TUSB_PATH)/class/cdc/cdc_device.c \
|
||||
$(TUSB_PATH)/class/msc/msc_device.c \
|
||||
$(TUSB_PATH)/tusb.c
|
||||
|
||||
endif
|
||||
|
||||
@@ -270,6 +278,18 @@ CFLAGS += -Wno-unused-parameter -Wno-expansion-to-defined
|
||||
# TinyUSB tusb_hal_nrf_power_event
|
||||
CFLAGS += -Wno-cast-function-type
|
||||
|
||||
# Nordic Softdevice SDK header files contains inline assembler that has
|
||||
# broken constraints. As a result the IPA-modref pass, introduced in gcc-11,
|
||||
# is able to "prove" that arguments to wrapper functions generated with
|
||||
# the SVCALL() macro are unused and, as a result, the optimizer will remove
|
||||
# code within the callers that sets up these arguments (which results in
|
||||
# a broken bootloader). The broken headers come from Nordic-supplied zip
|
||||
# files and are not trivial to patch so, for now, we'll simply disable the
|
||||
# new gcc-11 inter-procedural optimizations.
|
||||
ifeq (,$(findstring unrecognized,$(shell $(CC) $(CFLAGS) -fno-ipa-modref 2>&1)))
|
||||
CFLAGS += -fno-ipa-modref
|
||||
endif
|
||||
|
||||
# Defined Symbol (MACROS)
|
||||
CFLAGS += -D__HEAP_SIZE=0
|
||||
CFLAGS += -DCONFIG_GPIO_AS_PINRESET
|
||||
@@ -353,6 +373,10 @@ clean:
|
||||
@$(RM) $(BUILD)
|
||||
@$(RM) $(BIN)
|
||||
|
||||
# linkermap must be install previously at https://github.com/hathach/linkermap
|
||||
linkermap: $(BUILD)/$(OUT_NAME).out
|
||||
@linkermap -v $<.map
|
||||
|
||||
# Create objects from C SRC files
|
||||
$(BUILD)/%.o: %.c
|
||||
@echo CC $(notdir $<)
|
||||
|
||||
@@ -10,6 +10,7 @@ This is a CDC/DFU/UF2 bootloader for nRF52 boards.
|
||||
- [Adafruit Feather nRF52840 Express](https://www.adafruit.com/product/4062)
|
||||
- [Adafruit Feather nRF52840 Sense](https://www.adafruit.com/product/4516)
|
||||
- [Adafruit ItsyBitsy nRF52840 Express](https://www.adafruit.com/product/4481)
|
||||
- [Adafruit LED Glasses Driver nRF52840](https://www.adafruit.com/product/5217)
|
||||
- Adafruit Metro nRF52840 Express
|
||||
- [Akizukidenshi AE-BL652-BO](https://akizukidenshi.com/catalog/g/gK-15567/)
|
||||
- [Electronut Labs Papyr](https://docs.electronut.in/papyr/)
|
||||
|
||||
@@ -736,8 +736,8 @@ static void on_ble_evt(ble_evt_t * p_ble_evt)
|
||||
ble_gatts_rw_authorize_reply_params_t auth_reply;
|
||||
|
||||
#ifdef CFG_DEBUG
|
||||
extern const char* dbg_ble_event_str(uint16_t evt_id);
|
||||
PRINTF("BLE %s\r\n", dbg_ble_event_str(p_ble_evt->header.evt_id));
|
||||
extern void print_ble_event(uint16_t evt_id);
|
||||
print_ble_event(p_ble_evt->header.evt_id);
|
||||
#endif
|
||||
|
||||
switch (p_ble_evt->header.evt_id)
|
||||
@@ -1085,6 +1085,7 @@ uint32_t dfu_transport_ble_close()
|
||||
|
||||
#ifdef CFG_DEBUG
|
||||
|
||||
#if 0
|
||||
typedef struct
|
||||
{
|
||||
uint32_t key;
|
||||
@@ -1173,18 +1174,22 @@ lookup_table_t const _strevt_table =
|
||||
.items = _strevt_lookup
|
||||
};
|
||||
|
||||
const char* dbg_ble_event_str(uint16_t evt_id)
|
||||
{
|
||||
const char * str = (const char *) lookup_find(&_strevt_table, evt_id);
|
||||
static char unknown_str[7] = {0};
|
||||
#endif
|
||||
|
||||
void print_ble_event(uint16_t evt_id)
|
||||
{
|
||||
// const char * str = (const char *) lookup_find(&_strevt_table, evt_id);
|
||||
const char * str = NULL;
|
||||
PRINTF("BLE event: ");
|
||||
if ( str == NULL )
|
||||
{
|
||||
sprintf(unknown_str, "0x%04X", evt_id);
|
||||
str = unknown_str;
|
||||
PRINTF("0x%04X", evt_id);
|
||||
}else
|
||||
{
|
||||
PRINTF(str);
|
||||
}
|
||||
|
||||
return str;
|
||||
PRINTF("\r\n");
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
Binary file not shown.
+1
-1
Submodule lib/tinyusb updated: af8e5a90f4...9775e76910.
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2020 Pierre Constantineau
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef _BLUEMICRO_NRF52833_H
|
||||
#define _BLUEMICRO_NRF52833_H
|
||||
|
||||
#define _PINNUM(port, pin) ((port)*32 + (pin))
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* LED
|
||||
*------------------------------------------------------------------*/
|
||||
#define LEDS_NUMBER 2
|
||||
#define LED_PRIMARY_PIN _PINNUM(1, 4)
|
||||
#define LED_SECONDARY_PIN _PINNUM(0, 25)
|
||||
#define LED_STATE_ON 1
|
||||
|
||||
#define LED_NEOPIXEL _PINNUM(0, 7)
|
||||
#define NEOPIXELS_NUMBER 1
|
||||
#define BOARD_RGB_BRIGHTNESS 0x040404
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* BUTTON
|
||||
*------------------------------------------------------------------*/
|
||||
#define BUTTONS_NUMBER 2 // none connected at all
|
||||
#define BUTTON_1 _PINNUM(0, 18) // unusable: RESET
|
||||
#define BUTTON_2 _PINNUM(1, 1) // no connection on E73-2G4M08S1E Module
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// BLE OTA
|
||||
//--------------------------------------------------------------------+
|
||||
#define BLEDIS_MANUFACTURER "BlueMicro"
|
||||
#define BLEDIS_MODEL "BlueMicro 833"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USB PID from openmoko:
|
||||
// PR https://github.com/openmoko/openmoko-usb-oui/pull/34
|
||||
//--------------------------------------------------------------------+
|
||||
#define USB_DESC_VID 0x1d50
|
||||
#define USB_DESC_UF2_PID 0x616f
|
||||
#define USB_DESC_CDC_ONLY_PID 0x616f
|
||||
|
||||
#define UF2_PRODUCT_NAME "BlueMicro"
|
||||
#define UF2_VOLUME_LABEL "BLUEMICRO"
|
||||
#define UF2_BOARD_ID "nRF52833-BlueMicro-v1"
|
||||
#define UF2_INDEX_URL "http://bluemicro.jpconstantineau.com/"
|
||||
|
||||
#endif // _BLUEMICRO_H
|
||||
@@ -0,0 +1 @@
|
||||
MCU_SUB_VARIANT = nrf52833
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "boards.h"
|
||||
#include "uf2/configkeys.h"
|
||||
|
||||
__attribute__((used, section(".bootloaderConfig")))
|
||||
const uint32_t bootloaderConfig[] =
|
||||
{
|
||||
/* CF2 START */
|
||||
CFG_MAGIC0, CFG_MAGIC1, // magic
|
||||
5, 100, // used entries, total entries
|
||||
|
||||
204, 0x100000, // FLASH_BYTES = 0x100000
|
||||
205, 0x40000, // RAM_BYTES = 0x40000
|
||||
208, (USB_DESC_VID << 16) | USB_DESC_UF2_PID, // BOOTLOADER_BOARD_ID = USB VID+PID, used for verification when updating bootloader via uf2
|
||||
209, 0xada52840, // UF2_FAMILY = 0xada52840
|
||||
210, 0x20, // PINS_PORT_SIZE = PA_32
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0
|
||||
/* CF2 END */
|
||||
};
|
||||
@@ -60,7 +60,8 @@
|
||||
#define UF2_BOARD_ID "nRF52840-Papyr-v1"
|
||||
#define UF2_INDEX_URL "https://docs.electronut.in/papyr"
|
||||
|
||||
#define USB_DESC_VID 0x239A
|
||||
#define USB_DESC_UF2_PID 0x003B
|
||||
#define USB_DESC_VID 0x239A
|
||||
#define USB_DESC_UF2_PID 0x003B
|
||||
#define USB_DESC_CDC_ONLY_PID 0x003B
|
||||
|
||||
#endif // PPAPYR_H
|
||||
@@ -63,6 +63,6 @@
|
||||
#define UF2_PRODUCT_NAME "Adafruit LED Glasses Driver nRF52840"
|
||||
#define UF2_VOLUME_LABEL "GLASSESBOOT"
|
||||
#define UF2_BOARD_ID "nRF52840-LedGlasses-revA"
|
||||
#define UF2_INDEX_URL "https://www.adafruit.com/"
|
||||
#define UF2_INDEX_URL "https://www.adafruit.com/product/5217"
|
||||
|
||||
#endif // _LEDGLASSES_NRF52840_H
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018 Ha Thach for Adafruit Industries
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef RAYTAC_MDBT50Q_DB_40_H
|
||||
#define RAYTAC_MDBT50Q_DB_40_H
|
||||
|
||||
#define _PINNUM(port, pin) ((port)*32 + (pin))
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* LED
|
||||
*------------------------------------------------------------------*/
|
||||
#define LEDS_NUMBER 3
|
||||
/* This is the Green led marked D1 on the board */
|
||||
#define LED_PRIMARY_PIN _PINNUM(1, 13)
|
||||
/* This is the Red led marked D2 on the board */
|
||||
#define LED_SECONDARY_PIN _PINNUM(1, 14)
|
||||
/* This is the Blue led marked D3 on the board */
|
||||
#define LED_TERTIARY_PIN _PINNUM(1, 15)
|
||||
/* There are one more unpopulated LEDs, but for the purposes of bootloader that
|
||||
* doesn't matter. */
|
||||
#define LED_STATE_ON 0
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* BUTTON
|
||||
*------------------------------------------------------------------*/
|
||||
#define BUTTONS_NUMBER 4
|
||||
|
||||
#define BUTTON_1 _PINNUM(0, 11)
|
||||
#define BUTTON_2 _PINNUM(0, 12)
|
||||
#define BUTTON_3 _PINNUM(0, 24)
|
||||
#define BUTTON_4 _PINNUM(0, 25)
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// BLE OTA
|
||||
//--------------------------------------------------------------------+
|
||||
#define BLEDIS_MANUFACTURER "Raytac"
|
||||
#define BLEDIS_MODEL "MDBT50Q-DB-40"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USB
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
#define USB_DESC_VID 0x239A
|
||||
#define USB_DESC_UF2_PID 0x00BB
|
||||
#define USB_DESC_CDC_ONLY_PID 0x00BB
|
||||
|
||||
//------------- UF2 -------------//
|
||||
#define UF2_PRODUCT_NAME "Raytac MDBT50Q Demo Board 40"
|
||||
#define UF2_VOLUME_LABEL "MDBT50QBOOT"
|
||||
#define UF2_BOARD_ID "nRF52840-MDBT50Q-1MV2"
|
||||
#define UF2_INDEX_URL "https://www.raytac.com/product/ins.php?index_id=81"
|
||||
|
||||
#endif // RAYTAC_MDBT50Q_DB_40_H
|
||||
@@ -0,0 +1 @@
|
||||
MCU_SUB_VARIANT = nrf52840
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "boards.h"
|
||||
#include "uf2/configkeys.h"
|
||||
|
||||
__attribute__((used, section(".bootloaderConfig")))
|
||||
const uint32_t bootloaderConfig[] =
|
||||
{
|
||||
/* CF2 START */
|
||||
CFG_MAGIC0, CFG_MAGIC1, // magic
|
||||
5, 100, // used entries, total entries
|
||||
|
||||
204, 0x100000, // FLASH_BYTES = 0x100000
|
||||
205, 0x40000, // RAM_BYTES = 0x40000
|
||||
208, (USB_DESC_VID << 16) | USB_DESC_UF2_PID, // BOOTLOADER_BOARD_ID = USB VID+PID, used for verification when updating bootloader via uf2
|
||||
209, 0xada52840, // UF2_FAMILY = 0xada52840
|
||||
210, 0x20, // PINS_PORT_SIZE = PA_32
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0
|
||||
/* CF2 END */
|
||||
};
|
||||
+16
-11
@@ -238,14 +238,15 @@ static void check_dfu_mode(void)
|
||||
_ota_dfu = (gpregret == DFU_MAGIC_OTA_APPJUM) || (gpregret == DFU_MAGIC_OTA_RESET);
|
||||
|
||||
// Serial only mode
|
||||
bool serial_only_dfu = (gpregret == DFU_MAGIC_SERIAL_ONLY_RESET);
|
||||
bool uf2_dfu = (gpregret == DFU_MAGIC_UF2_RESET);
|
||||
bool const serial_only_dfu = (gpregret == DFU_MAGIC_SERIAL_ONLY_RESET);
|
||||
bool const uf2_dfu = (gpregret == DFU_MAGIC_UF2_RESET);
|
||||
bool const dfu_skip = (gpregret == DFU_MAGIC_SKIP);
|
||||
|
||||
bool const reason_reset_pin = (NRF_POWER->RESETREAS & POWER_RESETREAS_RESETPIN_Msk) ? true : false;
|
||||
|
||||
// start either serial, uf2 or ble
|
||||
bool dfu_start = _ota_dfu || serial_only_dfu || uf2_dfu ||
|
||||
(((*dbl_reset_mem) == DFU_DBL_RESET_MAGIC) && (NRF_POWER->RESETREAS & POWER_RESETREAS_RESETPIN_Msk));
|
||||
|
||||
bool const dfu_skip = (gpregret == DFU_MAGIC_SKIP);
|
||||
(((*dbl_reset_mem) == DFU_DBL_RESET_MAGIC) && reason_reset_pin);
|
||||
|
||||
// Clear GPREGRET if it is our values
|
||||
if (dfu_start || dfu_skip) NRF_POWER->GPREGRET = 0;
|
||||
@@ -265,12 +266,9 @@ static void check_dfu_mode(void)
|
||||
|
||||
if (!just_start_app && APP_ASKS_FOR_SINGLE_TAP_RESET()) dfu_start = 1;
|
||||
|
||||
// App mode: register 1st reset or DFU startup for nrf52832
|
||||
// App mode: Double Reset detection or DFU startup for nrf52832
|
||||
if ( ! (just_start_app || dfu_start || !valid_app) )
|
||||
{
|
||||
// Register our first reset for double reset detection
|
||||
(*dbl_reset_mem) = DFU_DBL_RESET_MAGIC;
|
||||
|
||||
#ifdef NRF52832_XXAA
|
||||
/* Even DFU is not active, we still force an 1000 ms dfu serial mode when startup
|
||||
* to support auto programming from Arduino IDE
|
||||
@@ -279,8 +277,15 @@ static void check_dfu_mode(void)
|
||||
*/
|
||||
bootloader_dfu_start(false, DFU_SERIAL_STARTUP_INTERVAL, false);
|
||||
#else
|
||||
// if RST is pressed during this delay (double reset)--> if will enter dfu
|
||||
NRFX_DELAY_MS(DFU_DBL_RESET_DELAY);
|
||||
// Note: RESETREAS is not clear by bootloader, it should be cleared by application upon init()
|
||||
if (reason_reset_pin)
|
||||
{
|
||||
// Register our first reset for double reset detection
|
||||
(*dbl_reset_mem) = DFU_DBL_RESET_MAGIC;
|
||||
|
||||
// if RST is pressed during this delay (double reset)--> if will enter dfu
|
||||
NRFX_DELAY_MS(DFU_DBL_RESET_DELAY);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
+25
-7
@@ -31,6 +31,7 @@
|
||||
#include "flash_nrf5x.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "bootloader_settings.h"
|
||||
#include "bootloader.h"
|
||||
@@ -119,7 +120,8 @@ STATIC_ASSERT(FAT_ENTRIES_PER_SECTOR == 256); // FAT
|
||||
char infoUf2File[128*3] =
|
||||
"UF2 Bootloader " UF2_VERSION "\r\n"
|
||||
"Model: " UF2_PRODUCT_NAME "\r\n"
|
||||
"Board-ID: " UF2_BOARD_ID "\r\n";
|
||||
"Board-ID: " UF2_BOARD_ID "\r\n"
|
||||
"Date: " __DATE__ "\r\n";
|
||||
|
||||
const char indexFile[] =
|
||||
"<!doctype html>\n"
|
||||
@@ -250,17 +252,33 @@ void uf2_init(void)
|
||||
uint32_t const sd_id = SD_ID_GET(MBR_SIZE);
|
||||
uint32_t const sd_version = SD_VERSION_GET(MBR_SIZE);
|
||||
|
||||
uint32_t const ver1 = sd_version / 1000000;
|
||||
uint32_t const ver2 = (sd_version % 1000000)/1000;
|
||||
uint32_t const ver3 = sd_version % 1000;
|
||||
uint32_t ver[3];
|
||||
ver[0] = sd_version / 1000000;
|
||||
ver[1] = (sd_version - ver[0]*1000000)/1000;
|
||||
ver[2] = (sd_version - ver[0]*1000000 - ver[1]*1000);
|
||||
|
||||
sprintf(infoUf2File + strlen(infoUf2File), "S%lu version %lu.%lu.%lu\r\n", sd_id, ver1, ver2, ver3);
|
||||
char str[10];
|
||||
utoa(sd_id, str, 10);
|
||||
|
||||
strcat(infoUf2File, "S");
|
||||
strcat(infoUf2File, str);
|
||||
strcat(infoUf2File, " ");
|
||||
|
||||
utoa(ver[0], str, 10);
|
||||
strcat(infoUf2File, str);
|
||||
strcat(infoUf2File, ".");
|
||||
|
||||
utoa(ver[1], str, 10);
|
||||
strcat(infoUf2File, str);
|
||||
strcat(infoUf2File, ".");
|
||||
|
||||
utoa(ver[2], str, 10);
|
||||
strcat(infoUf2File, str);
|
||||
strcat(infoUf2File, "\r\n");
|
||||
}else
|
||||
{
|
||||
strcat(infoUf2File, "not found\r\n");
|
||||
}
|
||||
|
||||
strcat(infoUf2File, "Date: " __DATE__ "\r\n");
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
|
||||
+27
-15
@@ -25,12 +25,12 @@
|
||||
#include "usb_desc.h"
|
||||
|
||||
enum {
|
||||
ITF_STR_LANGUAGE = 0 ,
|
||||
ITF_STR_MANUFACTURER ,
|
||||
ITF_STR_PRODUCT ,
|
||||
ITF_STR_SERIAL ,
|
||||
ITF_STR_CDC ,
|
||||
ITF_STR_MSC
|
||||
STRID_LANGUAGE = 0 ,
|
||||
STRID_MANUFACTURER ,
|
||||
STRID_PRODUCT ,
|
||||
STRID_SERIAL ,
|
||||
STRID_CDC ,
|
||||
STRID_MSC
|
||||
};
|
||||
|
||||
// CDC + MSC or CDC only mode
|
||||
@@ -84,25 +84,25 @@ enum {
|
||||
ITF_NUM_TOTAL
|
||||
};
|
||||
|
||||
uint8_t const desc_configuration_cdc_msc[] =
|
||||
uint8_t desc_configuration_cdc_msc[] =
|
||||
{
|
||||
// Interface count, string index, total length, attribute, power in mA
|
||||
TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, TUD_CONFIG_DESC_LEN + TUD_CDC_DESC_LEN + TUD_MSC_DESC_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100),
|
||||
TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, TUD_CONFIG_DESC_LEN + TUD_CDC_DESC_LEN + TUD_MSC_DESC_LEN, 0, 100),
|
||||
|
||||
// Interface number, string index, EP notification address and size, EP data address (out, in) and size.
|
||||
TUD_CDC_DESCRIPTOR(ITF_NUM_CDC, ITF_STR_CDC, 0x81, 8, 0x02, 0x82, 64),
|
||||
TUD_CDC_DESCRIPTOR(ITF_NUM_CDC, STRID_CDC, 0x81, 8, 0x02, 0x82, 64),
|
||||
|
||||
// Interface number, string index, EP Out & EP In address, EP size
|
||||
TUD_MSC_DESCRIPTOR(ITF_NUM_MSC, ITF_STR_MSC, 0x03, 0x83, 64),
|
||||
TUD_MSC_DESCRIPTOR(ITF_NUM_MSC, STRID_MSC, 0x03, 0x83, 64),
|
||||
};
|
||||
|
||||
uint8_t const desc_configuration_cdc_only[] =
|
||||
uint8_t desc_configuration_cdc_only[] =
|
||||
{
|
||||
// Interface count, string index, total length, attribute, power in mA
|
||||
TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL-1, 0, TUD_CONFIG_DESC_LEN + TUD_CDC_DESC_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100),
|
||||
TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL-1, 0, TUD_CONFIG_DESC_LEN + TUD_CDC_DESC_LEN, 0, 100),
|
||||
|
||||
// Interface number, string index, EP notification address and size, EP data address (out, in) and size.
|
||||
TUD_CDC_DESCRIPTOR(ITF_NUM_CDC, ITF_STR_CDC, 0x81, 8, 0x02, 0x82, 64),
|
||||
TUD_CDC_DESCRIPTOR(ITF_NUM_CDC, STRID_CDC, 0x81, 8, 0x02, 0x82, 64),
|
||||
};
|
||||
|
||||
|
||||
@@ -127,7 +127,19 @@ void usb_desc_init(bool cdc_only)
|
||||
}
|
||||
|
||||
// Create Serial string descriptor
|
||||
sprintf(desc_str_serial, "%08lX%08lX", NRF_FICR->DEVICEID[1], NRF_FICR->DEVICEID[0]);
|
||||
uint8_t const* device_id = (uint8_t const*) &NRF_FICR->DEVICEID;
|
||||
|
||||
for ( uint8_t i = 0; i < 8; i++ )
|
||||
{
|
||||
for ( uint8_t j = 0; j < 2; j++ )
|
||||
{
|
||||
const char nibble_to_hex[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
|
||||
|
||||
uint8_t nibble = (device_id[i] >> (j * 4)) & 0xf;
|
||||
desc_str_serial[15 - (i * 2 + j)] = nibble_to_hex[nibble]; // memory is little endian
|
||||
}
|
||||
}
|
||||
desc_str_serial[16] = 0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
@@ -156,7 +168,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
|
||||
|
||||
uint8_t chr_count;
|
||||
|
||||
if ( index == 0)
|
||||
if ( index == STRID_LANGUAGE )
|
||||
{
|
||||
memcpy(&_desc_str[1], string_desc_arr[0], 2);
|
||||
chr_count = 1;
|
||||
|
||||
@@ -30,16 +30,4 @@
|
||||
|
||||
void usb_desc_init(bool cdc_only);
|
||||
|
||||
#ifndef USB_DESC_VID
|
||||
#define USB_DESC_VID 0x239A
|
||||
#endif
|
||||
|
||||
#ifndef USB_DESC_UF2_PID
|
||||
#define USB_DESC_UF2_PID 0x0029
|
||||
#endif
|
||||
|
||||
#ifndef USB_DESC_CDC_ONLY_PID
|
||||
#define USB_DESC_CDC_ONLY_PID 0x002A
|
||||
#endif
|
||||
|
||||
#endif /* USB_DESC_H_ */
|
||||
Reference in new issue
Block a user