fix dfu example build

This commit is contained in:
hathach 2021-05-26 18:16:56 +07:00
parent dbef50f8ff
commit f9c542aa52
No known key found for this signature in database
GPG Key ID: 2FA891220FBFD581
14 changed files with 25 additions and 22 deletions

View File

View File

@ -9,10 +9,9 @@ get_filename_component(TOP "${TOP}" REALPATH)
# Check for -DFAMILY=
if(FAMILY STREQUAL "rp2040")
cmake_minimum_required(VERSION 3.12)
set(PICO_SDK_PATH ${TOP}/hw/mcu/raspberrypi/pico-sdk)
include(${PICO_SDK_PATH}/pico_sdk_init.cmake)
include(${TOP}/hw/bsp/${FAMILY}/pico_sdk_import.cmake)
project(${PROJECT})
pico_sdk_init()
add_executable(${PROJECT})
include(${TOP}/hw/bsp/${FAMILY}/family.cmake)
@ -33,9 +32,6 @@ if(FAMILY STREQUAL "rp2040")
CFG_TUSB_OS=OPT_OS_PICO
)
target_link_libraries(${PROJECT} pico_stdlib pico_fix_rp2040_usb_device_enumeration)
pico_add_extra_outputs(${PROJECT})
else()
message(FATAL_ERROR "Invalid FAMILY specified")
message(FATAL_ERROR "Invalid FAMILY specified: ${FAMILY}")
endif()

View File

@ -126,21 +126,20 @@ void tud_dfu_runtime_reboot_to_dfu_cb(void)
//--------------------------------------------------------------------+
bool tud_dfu_firmware_valid_check_cb(void)
{
TU_LOG2(" Firmware check\r\n");
printf(" Firmware check\r\n");
return true;
}
void tud_dfu_req_dnload_data_cb(uint16_t wBlockNum, uint8_t* data, uint16_t length)
{
TU_LOG2(" Received BlockNum %u of length %u\r\n", wBlockNum, length);
(void) data;
printf(" Received BlockNum %u of length %u\r\n", wBlockNum, length);
#if DFU_VERBOSE
for(uint16_t i=0; i<length; i++)
{
TU_LOG2(" [%u][%u]: %x\r\n", wBlockNum, i, (uint8_t)data[i]);
printf(" [%u][%u]: %x\r\n", wBlockNum, i, (uint8_t)data[i]);
}
#else
(void) data;
#endif
tud_dfu_dnload_complete();
@ -148,17 +147,17 @@ void tud_dfu_req_dnload_data_cb(uint16_t wBlockNum, uint8_t* data, uint16_t leng
bool tud_dfu_device_data_done_check_cb(void)
{
TU_LOG2(" Host said no more data... Returning true\r\n");
printf(" Host said no more data... Returning true\r\n");
return true;
}
void tud_dfu_abort_cb(void)
{
TU_LOG2(" Host aborted transfer\r\n");
printf(" Host aborted transfer\r\n");
}
#define UPLOAD_SIZE (29)
const uint8_t upload_test[UPLOAD_SIZE] = "Hello world from TinyUSB DFU!"
const uint8_t upload_test[UPLOAD_SIZE] = "Hello world from TinyUSB DFU!";
uint16_t tud_dfu_req_upload_data_cb(uint16_t block_num, uint8_t* data, uint16_t length)
{

View File

@ -80,7 +80,7 @@
//------------- CLASS -------------//
#define CFG_TUD_DFU_RUNTIME 1
#define CFG_TUD_DFU_RUNTIME 0
#define CFG_TUD_DFU_MODE 1
#ifdef __cplusplus

View File

@ -83,7 +83,7 @@ uint8_t const * tud_descriptor_device_cb(void)
enum
{
ITF1_NUM_DFU_MODE,
ITF_NUM_DFU_MODE,
ITF_NUM_TOTAL
};
@ -94,10 +94,10 @@ enum
uint8_t const desc_configuration[] =
{
// Config number, interface count, string index, total length, attribute, power in mA
TUD_CONFIG_DESCRIPTOR(1, ITF1_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100),
TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100),
// Interface number, string index, attributes, detach timeout, transfer size */
TUD_DFU_MODE_DESCRIPTOR(ITF1_NUM_DFU_MODE, 0, FUNC_ATTRS, 1000, CFG_TUD_DFU_TRANSFER_BUFFER_SIZE),
TUD_DFU_MODE_DESCRIPTOR(ITF_NUM_DFU_MODE, 0, FUNC_ATTRS, 1000, CFG_TUD_DFU_TRANSFER_BUFFER_SIZE),
};
// Invoked when received GET CONFIGURATION DESCRIPTOR

View File

@ -28,6 +28,7 @@ SRC_C += \
src/device/usbd_control.c \
src/class/audio/audio_device.c \
src/class/cdc/cdc_device.c \
src/class/dfu/dfu_device.c \
src/class/dfu/dfu_rt_device.c \
src/class/hid/hid_device.c \
src/class/midi/midi_device.c \
@ -41,7 +42,7 @@ INC += $(TOP)/src
CFLAGS += $(addprefix -I,$(INC))
LDFLAGS += $(CFLAGS) -fshort-enums -Wl,-T,$(TOP)/$(LD_FILE) -Wl,-Map=$@.map -Wl,-cref -Wl,-gc-sections
LDFLAGS += $(CFLAGS) -Wl,-T,$(TOP)/$(LD_FILE) -Wl,-Map=$@.map -Wl,-cref -Wl,-gc-sections
ifneq ($(SKIP_NANOLIB), 1)
LDFLAGS += -specs=nosys.specs -specs=nano.specs
endif

View File

@ -21,6 +21,7 @@ set(SRC_TINYUSB
${TOP}/src/device/usbd_control.c
${TOP}/src/class/audio/audio_device.c
${TOP}/src/class/cdc/cdc_device.c
${TOP}/src/class/dfu/dfu_device.c
${TOP}/src/class/dfu/dfu_rt_device.c
${TOP}/src/class/hid/hid_device.c
${TOP}/src/class/midi/midi_device.c

View File

@ -126,6 +126,7 @@ SECTIONS
. = ALIGN(4);
_ebss = . ;
_ezero = .;
end = .;
} > ram
/* stack section */

View File

@ -6,7 +6,6 @@ LD_FILE = $(BOARD_PATH)/samd11d14am_flash.ld
# For flash-jlink target
JLINK_DEVICE = ATSAMD11D14
# flash using edbg
flash: $(BUILD)/$(PROJECT).bin
edbg -b -t samd11 -e -pv -f $<

View File

@ -126,6 +126,7 @@ SECTIONS
. = ALIGN(4);
_ebss = . ;
_ezero = .;
end = .;
} > ram
/* stack section */

View File

@ -3,8 +3,9 @@ DEPS_SUBMODULES += hw/mcu/microchip
include $(TOP)/$(BOARD_PATH)/board.mk
CFLAGS += \
-flto \
-mthumb \
-mabi=aapcs-linux \
-mabi=aapcs \
-mcpu=cortex-m0plus \
-nostdlib -nostartfiles \
-DCONF_DFLL_OVERWRITE_CALIBRATION=0 \

View File

@ -128,6 +128,7 @@ SECTIONS
. = ALIGN(4);
_ebss = . ;
_ezero = .;
end = .;
} > ram
/* stack section */

View File

@ -128,6 +128,7 @@ SECTIONS
. = ALIGN(4);
_ebss = . ;
_ezero = .;
end = .;
} > ram
/* stack section */

View File

@ -150,6 +150,8 @@ void dfu_moded_init(void)
void dfu_moded_reset(uint8_t rhport)
{
(void) rhport;
_dfu_state_ctx.state = DFU_IDLE;
_dfu_state_ctx.status = DFU_STATUS_OK;
_dfu_state_ctx.blk_transfer_in_proc = false;