Skip to content

Commit

Permalink
fix(esp_tinyusb): Add possibility to configure NCM NTB buffers via me…
Browse files Browse the repository at this point in the history
…nuconfig
  • Loading branch information
peter-marcisovsky committed Jan 13, 2025
1 parent d8041fd commit 3a9f7a6
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
4 changes: 4 additions & 0 deletions device/esp_tinyusb/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [Unreleased]

- esp_tinyusb: Added possibility to configure NCM Transfer Blocks (NTB) via menuconfig

## 1.6.0

- CDC-ACM: Fixed memory leak on deinit
Expand Down
37 changes: 37 additions & 0 deletions device/esp_tinyusb/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,43 @@ menu "TinyUSB Stack"
config TINYUSB_NET_MODE_NONE
bool "None"
endchoice

config TINYUSB_NCM_OUT_NTB_BUFFS_COUNT
int "Number of NCM NTB buffers for reception side"
depends on TINYUSB_NET_MODE_NCM
default 2
range 1 4
help
Number of NTB buffers for reception side.
Can be increased to improve performance and stability with the cost of additional RAM requirements.
Helps to mitigate "tud_network_can_xmit: request blocked" warning message when running NCM device.

config TINYUSB_NCM_IN_NTB_BUFFS_COUNT
int "Number of NCM NTB buffers for transmission side"
depends on TINYUSB_NET_MODE_NCM
default 2
range 1 4
help
Number of NTB buffers for transmission side.
Can be increased to improve performance and stability with the cost of additional RAM requirements.
Helps to mitigate "tud_network_can_xmit: request blocked" warning message when running NCM device.

config TINYUSB_NCM_OUT_NTB_BUFF_MAX_SIZE
int "NCM NTB Buffer size for reception size"
depends on TINYUSB_NET_MODE_NCM
default 3200
range 2048 4096
help
Size of NTB buffers for reception side. Linux uses 2048 as minimal size.

config TINYUSB_NCM_IN_NTB_BUFF_MAX_SIZE
int "NCM NTB Buffer size for transmission size"
depends on TINYUSB_NET_MODE_NCM
default 3200
range 2048 4096
help
Size of NTB buffers for transmission side. Linux uses 2048 as minimal size.

endmenu # "Network driver (ECM/NCM/RNDIS)"

menu "Vendor Specific Interface"
Expand Down
8 changes: 7 additions & 1 deletion device/esp_tinyusb/include/tusb_config.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* SPDX-FileCopyrightText: 2019 Ha Thach (tinyusb.org),
* SPDX-FileContributor: 2020-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileContributor: 2020-2025 Espressif Systems (Shanghai) CO LTD
* SPDX-License-Identifier: MIT
*
* Copyright (c) 2019 Ha Thach (tinyusb.org),
Expand Down Expand Up @@ -173,6 +173,12 @@ extern "C" {
#define CFG_TUD_DFU_RUNTIME CONFIG_TINYUSB_DFU_MODE_DFU_RUNTIME
#define CFG_TUD_BTH CONFIG_TINYUSB_BTH_ENABLED

// NCM NET Mode NTB buffers configuration
#define CFG_TUD_NCM_OUT_NTB_N CONFIG_TINYUSB_NCM_OUT_NTB_BUFFS_COUNT
#define CFG_TUD_NCM_IN_NTB_N CONFIG_TINYUSB_NCM_IN_NTB_BUFFS_COUNT
#define CFG_TUD_NCM_OUT_NTB_MAX_SIZE CONFIG_TINYUSB_NCM_OUT_NTB_BUFF_MAX_SIZE
#define CFG_TUD_NCM_IN_NTB_MAX_SIZE CONFIG_TINYUSB_NCM_IN_NTB_BUFF_MAX_SIZE

#ifdef __cplusplus
}
#endif

0 comments on commit 3a9f7a6

Please sign in to comment.