diff options
| author | hathach <[email protected]> | 2021-05-26 18:16:56 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2021-05-26 18:16:56 +0700 |
| commit | f9c542aa52f7f2e5e532343384441234a019e53d (patch) | |
| tree | 768260844929b861be3bee1fa2fa4996967d976c | |
| parent | dbef50f8ffb6892297456aeb409f3d52d3731f0a (diff) | |
fix dfu example build
| -rw-r--r-- | examples/device/dfu/.skip.MCU_SAMD11 | 0 | ||||
| -rw-r--r-- | examples/device/dfu/CMakeLists.txt | 10 | ||||
| -rw-r--r-- | examples/device/dfu/src/main.c | 15 | ||||
| -rw-r--r-- | examples/device/dfu/src/tusb_config.h | 2 | ||||
| -rw-r--r-- | examples/device/dfu/src/usb_descriptors.c | 6 | ||||
| -rw-r--r-- | examples/rules.mk | 3 | ||||
| -rw-r--r-- | hw/bsp/rp2040/family.cmake | 1 | ||||
| -rw-r--r-- | hw/bsp/samd11/boards/luna_d11/samd11d14am_flash.ld | 1 | ||||
| -rw-r--r-- | hw/bsp/samd11/boards/samd11_xplained/board.mk | 1 | ||||
| -rw-r--r-- | hw/bsp/samd11/boards/samd11_xplained/samd11d14am_flash.ld | 1 | ||||
| -rw-r--r-- | hw/bsp/samd11/family.mk | 3 | ||||
| -rw-r--r-- | hw/bsp/saml22/boards/saml22_feather/saml22_feather.ld | 1 | ||||
| -rw-r--r-- | hw/bsp/saml22/boards/sensorwatch_m0/sensorwatch_m0.ld | 1 | ||||
| -rw-r--r-- | src/class/dfu/dfu_device.c | 2 |
14 files changed, 25 insertions, 22 deletions
diff --git a/examples/device/dfu/.skip.MCU_SAMD11 b/examples/device/dfu/.skip.MCU_SAMD11 new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/examples/device/dfu/.skip.MCU_SAMD11 diff --git a/examples/device/dfu/CMakeLists.txt b/examples/device/dfu/CMakeLists.txt index f4bf75c26..4160c0c88 100644 --- a/examples/device/dfu/CMakeLists.txt +++ b/examples/device/dfu/CMakeLists.txt @@ -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() diff --git a/examples/device/dfu/src/main.c b/examples/device/dfu/src/main.c index 3849de44d..1c09066a8 100644 --- a/examples/device/dfu/src/main.c +++ b/examples/device/dfu/src/main.c @@ -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) { diff --git a/examples/device/dfu/src/tusb_config.h b/examples/device/dfu/src/tusb_config.h index 0bb59a06c..90e90b2e4 100644 --- a/examples/device/dfu/src/tusb_config.h +++ b/examples/device/dfu/src/tusb_config.h @@ -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 diff --git a/examples/device/dfu/src/usb_descriptors.c b/examples/device/dfu/src/usb_descriptors.c index 77662542d..8ad64354b 100644 --- a/examples/device/dfu/src/usb_descriptors.c +++ b/examples/device/dfu/src/usb_descriptors.c @@ -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 diff --git a/examples/rules.mk b/examples/rules.mk index 2d86d5c79..4fce468fd 100644 --- a/examples/rules.mk +++ b/examples/rules.mk @@ -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,[email protected] -Wl,-cref -Wl,-gc-sections +LDFLAGS += $(CFLAGS) -Wl,-T,$(TOP)/$(LD_FILE) -Wl,[email protected] -Wl,-cref -Wl,-gc-sections ifneq ($(SKIP_NANOLIB), 1) LDFLAGS += -specs=nosys.specs -specs=nano.specs endif diff --git a/hw/bsp/rp2040/family.cmake b/hw/bsp/rp2040/family.cmake index 63c7daa38..73108e2c4 100644 --- a/hw/bsp/rp2040/family.cmake +++ b/hw/bsp/rp2040/family.cmake @@ -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 diff --git a/hw/bsp/samd11/boards/luna_d11/samd11d14am_flash.ld b/hw/bsp/samd11/boards/luna_d11/samd11d14am_flash.ld index c9b825d6f..cb633c195 100644 --- a/hw/bsp/samd11/boards/luna_d11/samd11d14am_flash.ld +++ b/hw/bsp/samd11/boards/luna_d11/samd11d14am_flash.ld @@ -126,6 +126,7 @@ SECTIONS . = ALIGN(4); _ebss = . ; _ezero = .; + end = .; } > ram /* stack section */ diff --git a/hw/bsp/samd11/boards/samd11_xplained/board.mk b/hw/bsp/samd11/boards/samd11_xplained/board.mk index 79ad87068..e351cf0b8 100644 --- a/hw/bsp/samd11/boards/samd11_xplained/board.mk +++ b/hw/bsp/samd11/boards/samd11_xplained/board.mk @@ -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 $< diff --git a/hw/bsp/samd11/boards/samd11_xplained/samd11d14am_flash.ld b/hw/bsp/samd11/boards/samd11_xplained/samd11d14am_flash.ld index 2153f5f50..8b3124c0e 100644 --- a/hw/bsp/samd11/boards/samd11_xplained/samd11d14am_flash.ld +++ b/hw/bsp/samd11/boards/samd11_xplained/samd11d14am_flash.ld @@ -126,6 +126,7 @@ SECTIONS . = ALIGN(4); _ebss = . ; _ezero = .; + end = .; } > ram /* stack section */ diff --git a/hw/bsp/samd11/family.mk b/hw/bsp/samd11/family.mk index 6fbdc35af..70120ec94 100644 --- a/hw/bsp/samd11/family.mk +++ b/hw/bsp/samd11/family.mk @@ -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 \ diff --git a/hw/bsp/saml22/boards/saml22_feather/saml22_feather.ld b/hw/bsp/saml22/boards/saml22_feather/saml22_feather.ld index 2e0e1b256..d1aaa44fc 100644 --- a/hw/bsp/saml22/boards/saml22_feather/saml22_feather.ld +++ b/hw/bsp/saml22/boards/saml22_feather/saml22_feather.ld @@ -128,6 +128,7 @@ SECTIONS . = ALIGN(4); _ebss = . ; _ezero = .; + end = .; } > ram /* stack section */ diff --git a/hw/bsp/saml22/boards/sensorwatch_m0/sensorwatch_m0.ld b/hw/bsp/saml22/boards/sensorwatch_m0/sensorwatch_m0.ld index 2e0e1b256..d1aaa44fc 100644 --- a/hw/bsp/saml22/boards/sensorwatch_m0/sensorwatch_m0.ld +++ b/hw/bsp/saml22/boards/sensorwatch_m0/sensorwatch_m0.ld @@ -128,6 +128,7 @@ SECTIONS . = ALIGN(4); _ebss = . ; _ezero = .; + end = .; } > ram /* stack section */ diff --git a/src/class/dfu/dfu_device.c b/src/class/dfu/dfu_device.c index da9f189aa..8496cb02b 100644 --- a/src/class/dfu/dfu_device.c +++ b/src/class/dfu/dfu_device.c @@ -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; |
