Browse Source

cherry-pick more haskal stuff, update CMSIS-DAP to 5.0.8 release, fix warnings

haskal/packaging
sys64738 5 months ago
parent
commit
b68231e966
  1. 2
      CMSIS_5
  2. 2
      CMakeLists.txt
  3. 22
      Makefile
  4. 4
      bsp/default/unique.c
  5. 56
      bsp/rp2040/DAP_config.h
  6. 7
      bsp/rp2040/cdc_uart.c
  7. 3
      bsp/rp2040/i2c_tinyusb.c
  8. 4
      bsp/rp2040/unique.c
  9. 4
      bsp/stm32f072disco/unique.c
  10. 1
      scripts/fix_clang_db.py
  11. 11
      src/vnd_i2ctinyusb.c

2
CMSIS_5

@ -1 +1 @@
Subproject commit d61cf40e6c44726917d9085660f7eb2691547cc7
Subproject commit 13b9f72f212688d2306d0d085d87cbb4bf9e5d3f

2
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)

22
Makefile

@ -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

4
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; i<TU_ARRAY_SIZE(canned); i++) {
for (size_t i=0; i<TU_ARRAY_SIZE(canned); i++) {
desc_str[i] = canned[i];
}
@ -18,7 +18,7 @@ __attribute__((__weak__)) uint8_t get_unique_id_u8(uint8_t *desc_str) {
__attribute__((__weak__)) uint8_t get_unique_id_u16(uint16_t *desc_str) {
static const char canned[] = "123456";
for (int i=0; i<TU_ARRAY_SIZE(canned); i++) {
for (size_t i=0; i<TU_ARRAY_SIZE(canned); i++) {
desc_str[i] = canned[i];
}

56
bsp/rp2040/DAP_config.h

@ -140,6 +140,27 @@ This information includes:
/// SWO Streaming Trace.
#define SWO_STREAM 0 ///< SWO Streaming Trace: 1 = available, 0 = not available.
/// Indicate that UART Communication Port is available.
/// This information is returned by the command \ref DAP_Info as part of <b>Capabilities</b>.
#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 <b>Capabilities</b>.
#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; }
///@}

7
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);
}
}

3
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

4
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);

4
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;

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

11
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;
}

Loading…
Cancel
Save