Explorar el Código

fix dfu example build

hathach hace 4 años
padre
commit
f9c542aa52

+ 0 - 0
examples/device/dfu/.skip.MCU_SAMD11


+ 3 - 7
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()

+ 7 - 8
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)
 {

+ 1 - 1
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

+ 3 - 3
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

+ 2 - 1
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,-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

+ 1 - 0
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

+ 1 - 0
hw/bsp/samd11/boards/luna_d11/samd11d14am_flash.ld

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

+ 0 - 1
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 $<

+ 1 - 0
hw/bsp/samd11/boards/samd11_xplained/samd11d14am_flash.ld

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

+ 2 - 1
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 \

+ 1 - 0
hw/bsp/saml22/boards/saml22_feather/saml22_feather.ld

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

+ 1 - 0
hw/bsp/saml22/boards/sensorwatch_m0/sensorwatch_m0.ld

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

+ 2 - 0
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;