From b68231e9668449e51ec1fc1c1f46c95745a4f485 Mon Sep 17 00:00:00 2001 From: sys64738 Date: Mon, 28 Jun 2021 21:39:19 +0200 Subject: [PATCH] cherry-pick more haskal stuff, update CMSIS-DAP to 5.0.8 release, fix warnings --- CMSIS_5 | 2 +- CMakeLists.txt | 2 ++ Makefile | 22 --------------- bsp/default/unique.c | 4 +-- bsp/rp2040/DAP_config.h | 56 +++++++++++++++++++++++++++++++++++-- bsp/rp2040/cdc_uart.c | 7 +++-- bsp/rp2040/i2c_tinyusb.c | 3 ++ bsp/rp2040/unique.c | 4 +-- bsp/stm32f072disco/unique.c | 4 +-- scripts/fix_clang_db.py | 1 + src/vnd_i2ctinyusb.c | 11 ++++++++ 11 files changed, 83 insertions(+), 33 deletions(-) delete mode 100644 Makefile diff --git a/CMSIS_5 b/CMSIS_5 index d61cf40..13b9f72 160000 --- a/CMSIS_5 +++ b/CMSIS_5 @@ -1 +1 @@ -Subproject commit d61cf40e6c44726917d9085660f7eb2691547cc7 +Subproject commit 13b9f72f212688d2306d0d085d87cbb4bf9e5d3f diff --git a/CMakeLists.txt b/CMakeLists.txt index e277c70..cc7781c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,8 @@ set(BOARD "raspberry_pi_pico" CACHE STRING "Board used, determines the pinout. D get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) set(PROJECT ${BOARD}-${PROJECT}) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + # TOP is absolute path to root directory of TinyUSB git repo set(TOP "./tinyusb") get_filename_component(TOP "${TOP}" REALPATH) diff --git a/Makefile b/Makefile deleted file mode 100644 index 67af816..0000000 --- a/Makefile +++ /dev/null @@ -1,22 +0,0 @@ -include ./tinyusb/tools/top.mk -include ./tinyusb/examples/make.mk - -INC += \ - . \ - ./CMSIS_5/CMSIS/DAP/Firmware/Include \ - ./bsp/$(BOARD) \ - ./bsp/default \ - $(TOP)/hw - -APP_SOURCE += $(wildcard ./*.c) $(wildcard ./bsp/$(BOARD)/*.c) - -SRC_C += $(addprefix $(CURRENT_PATH)/, $(APP_SOURCE)) - -SRC_C += \ - ./CMSIS_5/CMSIS/DAP/Firmware/Source/DAP.c \ - ./CMSIS_5/CMSIS/DAP/Firmware/Source/JTAG_DP.c \ - ./CMSIS_5/CMSIS/DAP/Firmware/Source/DAP_vendor.c \ - ./CMSIS_5/CMSIS/DAP/Firmware/Source/SWO.c \ - ./CMSIS_5/CMSIS/DAP/Firmware/Source/SW_DP.c - -include ./tinyusb/examples/rules.mk diff --git a/bsp/default/unique.c b/bsp/default/unique.c index bc91aa1..1a093e4 100644 --- a/bsp/default/unique.c +++ b/bsp/default/unique.c @@ -8,7 +8,7 @@ __attribute__((__weak__)) uint8_t get_unique_id_u8(uint8_t *desc_str) { static const char canned[] = "123456"; - for (int i=0; iCapabilities. +#define DAP_UART 0 ///< DAP UART: 1 = available, 0 = not available. + +/// USART Driver instance number for the UART Communication Port. +#define DAP_UART_DRIVER 1 ///< USART Driver instance number (Driver_USART#). + +/// UART Receive Buffer Size. +#define DAP_UART_RX_BUFFER_SIZE 64U ///< Uart Receive Buffer Size in bytes (must be 2^n). + +/// UART Transmit Buffer Size. +#define DAP_UART_TX_BUFFER_SIZE 64U ///< Uart Transmit Buffer Size in bytes (must be 2^n). + +/// Indicate that UART Communication via USB COM Port is available. +/// This information is returned by the command \ref DAP_Info as part of Capabilities. +#ifdef USE_USBCDC_FOR_STDIO +#define DAP_UART_USB_COM_PORT 1 ///< USB COM Port: 1 = available, 0 = not available. +#else +#define DAP_UART_USB_COM_PORT 0 +#endif + /// Clock frequency of the Test Domain Timer. Timer value is returned with \ref TIMESTAMP_GET. #define TIMESTAMP_CLOCK 0U ///< Timestamp clock in Hz (0 = timestamps not supported). @@ -161,7 +182,7 @@ This information includes: \return String length. */ __STATIC_INLINE uint8_t DAP_GetVendorString (char *str) { - const static char vnd[] = INFO_MANUFACTURER; + static const char vnd[] = INFO_MANUFACTURER; for (size_t i = 0; i < sizeof(vnd); ++i) str[i] = vnd[i]; return sizeof(vnd)-1; } @@ -171,7 +192,7 @@ __STATIC_INLINE uint8_t DAP_GetVendorString (char *str) { \return String length. */ __STATIC_INLINE uint8_t DAP_GetProductString (char *str) { - const static char prd[] = INFO_PRODUCT(INFO_BOARDNAME); + static const char prd[] = INFO_PRODUCT(INFO_BOARDNAME); for (size_t i = 0; i < sizeof(prd); ++i) str[i] = prd[i]; return sizeof(prd)-1; } @@ -184,6 +205,37 @@ __STATIC_INLINE uint8_t DAP_GetSerNumString (char *str) { return get_unique_id_u8((uint8_t*)str); } +/** Get Target Device Vendor string. +\param str Pointer to buffer to store the string (max 60 characters). +\return String length (including terminating NULL character) or 0 (no string). +*/ +__STATIC_INLINE uint8_t DAP_GetTargetDeviceVendorString (char *str) { (void)str; return 0; } + +/** Get Target Device Name string. +\param str Pointer to buffer to store the string (max 60 characters). +\return String length (including terminating NULL character) or 0 (no string). +*/ +__STATIC_INLINE uint8_t DAP_GetTargetDeviceNameString (char *str) { (void)str; return 0; } + +/** Get Target Board Vendor string. +\param str Pointer to buffer to store the string (max 60 characters). +\return String length (including terminating NULL character) or 0 (no string). +*/ +__STATIC_INLINE uint8_t DAP_GetTargetBoardVendorString (char *str) { (void)str; return 0; } + +/** Get Target Board Name string. +\param str Pointer to buffer to store the string (max 60 characters). +\return String length (including terminating NULL character) or 0 (no string). +*/ +__STATIC_INLINE uint8_t DAP_GetTargetBoardNameString (char *str) { (void)str; return 0; } + +/* TODO! */ +/** Get Product Firmware Version string. +\param str Pointer to buffer to store the string (max 60 characters). +\return String length (including terminating NULL character) or 0 (no string). +*/ +__STATIC_INLINE uint8_t DAP_GetProductFirmwareVersionString (char *str) { (void)str; return 0; } + ///@} diff --git a/bsp/rp2040/cdc_uart.c b/bsp/rp2040/cdc_uart.c index 42b5ddc..98a4976 100644 --- a/bsp/rp2040/cdc_uart.c +++ b/bsp/rp2040/cdc_uart.c @@ -70,8 +70,11 @@ void cdc_uart_set_hwflow(bool enable) { uart_set_hw_flow(PINOUT_UART_INTERFACE, enable, enable); } +/* TODO: properly dispatch to others? */ void tud_cdc_line_coding_cb(uint8_t itf, cdc_line_coding_t const* line_coding) { - //picoprobe_info("New baud rate %d\n", line_coding->bit_rate); - uart_init(PINOUT_UART_INTERFACE, line_coding->bit_rate); + if (itf == CDC_N_UART) { + //picoprobe_info("New baud rate %d\n", line_coding->bit_rate); + uart_init(PINOUT_UART_INTERFACE, line_coding->bit_rate); + } } diff --git a/bsp/rp2040/i2c_tinyusb.c b/bsp/rp2040/i2c_tinyusb.c index fec8096..8ecd162 100644 --- a/bsp/rp2040/i2c_tinyusb.c +++ b/bsp/rp2040/i2c_tinyusb.c @@ -106,6 +106,8 @@ static uint8_t __no_inline_not_in_flash_func(i2cio_read8)(bool last) { i2cio_scl_toggle(); i2cio_set_sda(true); + + return rv; } // replicating/rewriting some SDK functions because they don't do what I want @@ -144,6 +146,7 @@ static int __no_inline_not_in_flash_func(i2cex_probe_address)(uint16_t addr, boo inline static void i2cex_abort_xfer(i2c_inst_t* i2c) { #if 1 // may be bugged??? so doesnt do anything for now + (void)i2c; return; #else // now do the abort diff --git a/bsp/rp2040/unique.c b/bsp/rp2040/unique.c index 74a5d81..0d33117 100644 --- a/bsp/rp2040/unique.c +++ b/bsp/rp2040/unique.c @@ -11,7 +11,7 @@ uint8_t get_unique_id_u8(uint8_t *desc_str) { pico_get_unique_board_id(&uid); - for (int byte = 0; byte < TU_ARRAY_SIZE(uid.id); byte++) { + for (size_t byte = 0; byte < TU_ARRAY_SIZE(uid.id); byte++) { uint8_t tmp = uid.id[byte]; for (int digit = 0; digit < 2; digit++) { desc_str[chr_count++] = nyb2hex(tmp & 0xf); @@ -28,7 +28,7 @@ uint8_t get_unique_id_u16(uint16_t *desc_str) { pico_get_unique_board_id(&uid); - for (int byte = 0; byte < TU_ARRAY_SIZE(uid.id); byte++) { + for (size_t byte = 0; byte < TU_ARRAY_SIZE(uid.id); byte++) { uint8_t tmp = uid.id[byte]; for (int digit = 0; digit < 2; digit++) { desc_str[chr_count++] = nyb2hex(tmp & 0xf); diff --git a/bsp/stm32f072disco/unique.c b/bsp/stm32f072disco/unique.c index 814fc88..d23f9ae 100644 --- a/bsp/stm32f072disco/unique.c +++ b/bsp/stm32f072disco/unique.c @@ -8,7 +8,7 @@ uint8_t get_unique_id_u8(uint8_t *desc_str) { uint32_t tmp = 0; uint8_t chr_count = 0; - for (int digit = 0; digit < 24; digit++) { + for (size_t digit = 0; digit < 24; digit++) { if (0 == (digit & 7)) tmp = *idpnt++; desc_str[chr_count++] = nyb2hex(tmp & 0xf); tmp >>= 4; @@ -22,7 +22,7 @@ uint8_t get_unique_id_u16(uint16_t *desc_str) { uint32_t tmp = 0; uint8_t chr_count = 0; - for (int digit = 0; digit < 24; digit++) { + for (size_t digit = 0; digit < 24; digit++) { if (0 == (digit & 7)) tmp = *idpnt++; desc_str[chr_count++] = nyb2hex(tmp & 0xf); tmp >>= 4; diff --git a/scripts/fix_clang_db.py b/scripts/fix_clang_db.py index fb130fe..e42e4eb 100755 --- a/scripts/fix_clang_db.py +++ b/scripts/fix_clang_db.py @@ -14,3 +14,4 @@ for i in range(len(data)): with open("compile_commands.json", "w") as f: json.dump(data, f) + diff --git a/src/vnd_i2ctinyusb.c b/src/vnd_i2ctinyusb.c index ea84e38..a62d9c7 100644 --- a/src/vnd_i2ctinyusb.c +++ b/src/vnd_i2ctinyusb.c @@ -38,6 +38,8 @@ static void iub_init(void) { } static void iub_reset(uint8_t rhport) { + (void)rhport; + status = ITU_STATUS_IDLE; memset(&curcmd, 0, sizeof curcmd); @@ -51,6 +53,8 @@ static void iub_reset(uint8_t rhport) { static uint16_t iub_open(uint8_t rhport, tusb_desc_interface_t const* itf_desc, uint16_t max_len) { + (void)rhport; + TU_VERIFY(itf_desc->bInterfaceClass == 0 && itf_desc->bInterfaceSubClass == 0 && itf_desc->bInterfaceProtocol == 0, 0); @@ -64,6 +68,8 @@ static uint16_t iub_open(uint8_t rhport, tusb_desc_interface_t const* itf_desc, } static bool iub_ctl_req(uint8_t rhport, uint8_t stage, tusb_control_request_t const* req) { + (void)rhport; + /*static char* stages[]={"SETUP","DATA","ACK"}; static char* types[]={"STD","CLS","VND","INV"}; @@ -209,6 +215,11 @@ static bool iub_ctl_req(uint8_t rhport, uint8_t stage, tusb_control_request_t co // never actually called fsr static bool iub_xfer(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_t xferred_bytes) { + (void)rhport; + (void)ep_addr; + (void)result; + (void)xferred_bytes; + return true; }