Skip to content

Commit c64589d

Browse files
authored
Merge pull request #69 from espressif/sync/partial_upstream
Upstream Synchronization - Partial [v0.19]
2 parents 7e146ce + 9851796 commit c64589d

File tree

10 files changed

+225
-979
lines changed

10 files changed

+225
-979
lines changed

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ Supported CPUs
122122
+--------------+-----------------------------+--------+------+-----------+------------------------+-------------------+
123123
| Dialog | DA1469x |||| da146xx | |
124124
+--------------+-----------------------------+--------+------+-----------+------------------------+-------------------+
125-
| Espressif | S2, S3 |||| dwc2 or esp32sx | |
125+
| Espressif | S2, S3 |||| dwc2 | |
126126
| ESP32 +-----------------------------+--------+------+-----------+------------------------+-------------------+
127127
| | P4 |||| dwc2 | |
128128
| +-----------------------------+--------+------+-----------+------------------------+-------------------+

hw/bsp/BoardPresets.json

Lines changed: 69 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,17 @@
1313
}
1414
},
1515
{
16-
"name": "adafruit_clue",
17-
"inherits": "default"
18-
},
19-
{
20-
"name": "adafruit_feather_esp32_v2",
21-
"inherits": "default"
22-
},
23-
{
24-
"name": "adafruit_feather_esp32c6",
25-
"inherits": "default"
26-
},
27-
{
28-
"name": "adafruit_feather_esp32s2",
29-
"inherits": "default"
16+
"name": "default single config",
17+
"hidden": true,
18+
"description": "Configure preset for the ${presetName} board",
19+
"generator": "Ninja",
20+
"binaryDir": "${sourceDir}/build/${presetName}",
21+
"cacheVariables": {
22+
"BOARD": "${presetName}"
23+
}
3024
},
3125
{
32-
"name": "adafruit_feather_esp32s3",
26+
"name": "adafruit_clue",
3327
"inherits": "default"
3428
},
3529
{
@@ -40,14 +34,6 @@
4034
"name": "adafruit_fruit_jam",
4135
"inherits": "default"
4236
},
43-
{
44-
"name": "adafruit_magtag_29gray",
45-
"inherits": "default"
46-
},
47-
{
48-
"name": "adafruit_metro_esp32s2",
49-
"inherits": "default"
50-
},
5137
{
5238
"name": "adafruit_metro_rp2350",
5339
"inherits": "default"
@@ -188,42 +174,6 @@
188174
"name": "ek_tm4c123gxl",
189175
"inherits": "default"
190176
},
191-
{
192-
"name": "espressif_addax_1",
193-
"inherits": "default"
194-
},
195-
{
196-
"name": "espressif_c3_devkitc",
197-
"inherits": "default"
198-
},
199-
{
200-
"name": "espressif_c6_devkitc",
201-
"inherits": "default"
202-
},
203-
{
204-
"name": "espressif_kaluga_1",
205-
"inherits": "default"
206-
},
207-
{
208-
"name": "espressif_p4_function_ev",
209-
"inherits": "default"
210-
},
211-
{
212-
"name": "espressif_s2_devkitc",
213-
"inherits": "default"
214-
},
215-
{
216-
"name": "espressif_s3_devkitc",
217-
"inherits": "default"
218-
},
219-
{
220-
"name": "espressif_s3_devkitm",
221-
"inherits": "default"
222-
},
223-
{
224-
"name": "espressif_saola_1",
225-
"inherits": "default"
226-
},
227177
{
228178
"name": "f1c100s",
229179
"inherits": "default"
@@ -823,6 +773,66 @@
823773
{
824774
"name": "xmc4700_relax",
825775
"inherits": "default"
776+
},
777+
{
778+
"name": "adafruit_feather_esp32_v2",
779+
"inherits": "default single config"
780+
},
781+
{
782+
"name": "adafruit_feather_esp32c6",
783+
"inherits": "default single config"
784+
},
785+
{
786+
"name": "adafruit_feather_esp32s2",
787+
"inherits": "default single config"
788+
},
789+
{
790+
"name": "adafruit_feather_esp32s3",
791+
"inherits": "default single config"
792+
},
793+
{
794+
"name": "adafruit_magtag_29gray",
795+
"inherits": "default single config"
796+
},
797+
{
798+
"name": "adafruit_metro_esp32s2",
799+
"inherits": "default single config"
800+
},
801+
{
802+
"name": "espressif_addax_1",
803+
"inherits": "default single config"
804+
},
805+
{
806+
"name": "espressif_c3_devkitc",
807+
"inherits": "default single config"
808+
},
809+
{
810+
"name": "espressif_c6_devkitc",
811+
"inherits": "default single config"
812+
},
813+
{
814+
"name": "espressif_kaluga_1",
815+
"inherits": "default single config"
816+
},
817+
{
818+
"name": "espressif_p4_function_ev",
819+
"inherits": "default single config"
820+
},
821+
{
822+
"name": "espressif_s2_devkitc",
823+
"inherits": "default single config"
824+
},
825+
{
826+
"name": "espressif_s3_devkitc",
827+
"inherits": "default single config"
828+
},
829+
{
830+
"name": "espressif_s3_devkitm",
831+
"inherits": "default single config"
832+
},
833+
{
834+
"name": "espressif_saola_1",
835+
"inherits": "default single config"
826836
}
827837
],
828838
"buildPresets": [

src/class/audio/audio_device.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,9 @@
7979
// Linear buffer in case target MCU is not capable of handling a ring buffer FIFO e.g. no hardware buffer
8080
// is available or driver is would need to be changed dramatically
8181

82-
// Only STM32 and dcd_transdimension use non-linear buffer for now
83-
// dwc2 except esp32sx (since it may use dcd_esp32sx)
82+
// Only STM32 and ChipIdea HS use non-linear buffer for now
8483
// Ring buffer is incompatible with dcache, since neither address nor size is aligned to cache line
85-
#if (defined(TUP_USBIP_DWC2) && !TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)) || \
84+
#if defined(TUP_USBIP_DWC2) || \
8685
defined(TUP_USBIP_FSDEV) || \
8786
CFG_TUSB_MCU == OPT_MCU_RX63X || \
8887
CFG_TUSB_MCU == OPT_MCU_RX65X || \

src/class/mtp/mtp_device.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ static bool mtpd_data_xfer(mtp_container_info_t* p_container, uint8_t ep_addr) {
215215
TU_ASSERT(p_mtp->phase == MTP_PHASE_DATA);
216216
}
217217

218-
const uint16_t xact_len = tu_min16((uint16_t) (p_mtp->total_len - p_mtp->xferred_len), CFG_TUD_MTP_EP_BUFSIZE);
218+
const uint16_t xact_len = (uint16_t) tu_min32(p_mtp->total_len - p_mtp->xferred_len, CFG_TUD_MTP_EP_BUFSIZE);
219219
if (xact_len) {
220220
// already transferred all bytes in header's length. Application make an unnecessary extra call
221221
TU_VERIFY(usbd_edpt_claim(p_mtp->rhport, ep_addr));

src/common/tusb_common.h

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,20 +109,35 @@ extern void* tusb_app_phys_to_virt(void *phys_addr);
109109

110110
// This is a backport of memset_s from c11
111111
TU_ATTR_ALWAYS_INLINE static inline int tu_memset_s(void *dest, size_t destsz, int ch, size_t count) {
112-
// TODO may check if desst and src is not NULL
113-
if ( count > destsz ) {
112+
// Validate parameters
113+
if (dest == NULL) {
114114
return -1;
115115
}
116+
117+
if (count > destsz) {
118+
return -1;
119+
}
120+
116121
memset(dest, ch, count);
117122
return 0;
118123
}
119124

120125
// This is a backport of memcpy_s from c11
121126
TU_ATTR_ALWAYS_INLINE static inline int tu_memcpy_s(void *dest, size_t destsz, const void *src, size_t count) {
122-
// TODO may check if desst and src is not NULL
123-
if ( count > destsz ) {
127+
// Validate parameters
128+
if (dest == NULL) {
124129
return -1;
125130
}
131+
132+
// For memcpy, src may be NULL only if count == 0. Reject otherwise.
133+
if (src == NULL && count != 0) {
134+
return -1;
135+
}
136+
137+
if (count > destsz) {
138+
return -1;
139+
}
140+
126141
memcpy(dest, src, count);
127142
return 0;
128143
}

0 commit comments

Comments
 (0)