From bb5dbd2da838773d8c1443ce52096ab9de63df19 Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 11 Jul 2022 23:57:34 +0700 Subject: [PATCH 1/3] only enable warnings with approriate gcc version for rp2040 --- examples/example.cmake | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/examples/example.cmake b/examples/example.cmake index 3e395d53f..6b5e41dd9 100644 --- a/examples/example.cmake +++ b/examples/example.cmake @@ -4,28 +4,29 @@ target_compile_options(${PROJECT} PUBLIC -Werror -Wfatal-errors -Wdouble-promotion - #-Wstrict-prototypes - -Wstrict-overflow - #-Werror-implicit-function-declaration -Wfloat-equal - #-Wundef -Wshadow -Wwrite-strings -Wsign-compare -Wmissing-format-attribute -Wunreachable-code -Wcast-align - -Wcast-function-type -Wcast-qual -Wnull-dereference -Wuninitialized -Wunused -Wredundant-decls + #-Wstrict-prototypes + #-Werror-implicit-function-declaration + #-Wundef ) -# GCC version 9 or prior has a bug with incorrect Wconversion warnings +# GCC 10 if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 10.0) - target_compile_options(${PROJECT} PUBLIC - -Wconversion - ) + target_compile_options(${PROJECT} PUBLIC -Wconversion) +endif() + +# GCC 8 +if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0) + target_compile_options(${PROJECT} PUBLIC -Wcast-function-type -Wstrict-overflow) endif() From 345558307d06338fdc2c79d88c95c8d97bdeeeb0 Mon Sep 17 00:00:00 2001 From: hathach Date: Tue, 12 Jul 2022 00:50:52 +0700 Subject: [PATCH 2/3] fix incorrect null-dereference warnings when compiling with gcc7 --- src/host/usbh.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/host/usbh.c b/src/host/usbh.c index b6a03b82e..0415a26cb 100644 --- a/src/host/usbh.c +++ b/src/host/usbh.c @@ -123,7 +123,6 @@ typedef struct { // Invalid driver ID in itf2drv[] ep2drv[][] mapping enum { DRVID_INVALID = 0xFFu }; -enum { ADDR_INVALID = 0xFFu }; enum { CONTROLLER_INVALID = 0xFFu }; #if CFG_TUSB_DEBUG >= 2 @@ -1434,7 +1433,8 @@ static uint8_t get_new_address(bool is_hub) { if (!_usbh_devices[idx].connected) return (idx+1); } - return ADDR_INVALID; + + return 0; // invalid address } static bool enum_request_set_addr(void) @@ -1443,7 +1443,7 @@ static bool enum_request_set_addr(void) // Get new address uint8_t const new_addr = get_new_address(desc_device->bDeviceClass == TUSB_CLASS_HUB); - TU_ASSERT(new_addr != ADDR_INVALID); + TU_ASSERT(new_addr != 0); TU_LOG2("Set Address = %d\r\n", new_addr); From 4ea27acd1da9e0144dbfbf805b87b22d16f7db8c Mon Sep 17 00:00:00 2001 From: hathach Date: Tue, 12 Jul 2022 01:55:33 +0700 Subject: [PATCH 3/3] minor update to webusb serial example --- examples/device/webusb_serial/src/main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/device/webusb_serial/src/main.c b/examples/device/webusb_serial/src/main.c index 8eaad7706..604d30a83 100644 --- a/examples/device/webusb_serial/src/main.c +++ b/examples/device/webusb_serial/src/main.c @@ -71,7 +71,7 @@ enum { static uint32_t blink_interval_ms = BLINK_NOT_MOUNTED; -#define URL "example.tinyusb.org/webusb-serial/" +#define URL "example.tinyusb.org/webusb-serial/index.html" const tusb_desc_webusb_url_t desc_url = { @@ -114,6 +114,7 @@ void echo_all(uint8_t buf[], uint32_t count) if ( web_serial_connected ) { tud_vendor_write(buf, count); + tud_vendor_flush(); } // echo to cdc @@ -211,7 +212,8 @@ bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_requ board_led_write(true); blink_interval_ms = BLINK_ALWAYS_ON; - tud_vendor_write_str("\r\nTinyUSB WebUSB device example\r\n"); + tud_vendor_write_str("\r\nWebUSB interface connected\r\n"); + tud_vendor_flush(); }else { blink_interval_ms = BLINK_MOUNTED;