Skip to content

Puya PY32F07x support#3694

Merged
HiFiPhile merged 9 commits into
hathach:masterfrom
rhgndf:py32f0
Jul 19, 2026
Merged

Puya PY32F07x support#3694
HiFiPhile merged 9 commits into
hathach:masterfrom
rhgndf:py32f0

Conversation

@rhgndf

@rhgndf rhgndf commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

This adds support for another musb variant, py32f07x. The USB block looks like musb with a modified register layout and a lot of functions stripped out.

I'm evaluating this MCU due to it having USB support (also have DFU and is low cost). I also have HC32F460 and HC32F4A0 if anyone is interested to see a port of those.

Dev board is a generic board, no special name

};
uint16_t length; /* the number of bytes in the buffer */
uint16_t remaining; /* the number of bytes remaining in the buffer */
uint16_t mps; /* maximum packet size */

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adds 2 more bytes to the struct, is this ok? py32's maxp field is in increments of multiples of 8 for packet size, instead of per byte for others

Comment thread README.rst
| +---------+-------------------+--------+------+-----------+------------------------+--------------------+
| | RW61x | ✅ | ✅ | ✅ | ci_hs, ehci | |
+--------------+-----------------------------+--------+------+-----------+------------------------+--------------------+
| Puya | PY32F071, PY32F072 | ✅ | ❌ | ❌ | musb | 1-dir ep |

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit more specific than "1-dir ep"? Two dirs are possible with some scheduling, but probably very complex

#if defined(TUP_USBIP_MUSB_PY32)
void dcd_connect(uint8_t rhport)
{
(void) rhport;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A connect/disconnect requires enabling or disabling the entire block through the APB, doesn't look like it can disconnect the resistor by itself.

@github-actions

github-actions Bot commented Jun 11, 2026

Copy link
Copy Markdown

MemBrowse Memory Report

Top 10 targets by memory change (%) (out of 2471 targets) View Project Dashboard →

target .text .rodata .data .bss total % diff
ek_tm4c123gxl/audio_test 12,280 → 12,308 (+28) 12,332 → 12,360 (+28) +0.2%
ek_tm4c123gxl/audio_test_multi_rate 12,492 → 12,520 (+28) 12,544 → 12,572 (+28) +0.2%
ek_tm4c123gxl/video_capture 13,480 → 13,508 (+28) 13,540 → 13,568 (+28) +0.2%
ek_tm4c123gxl/usbtest 13,744 → 13,772 (+28) 13,776 → 13,804 (+28) +0.2%
ek_tm4c123gxl/uac2_headset 13,804 → 13,832 (+28) 13,840 → 13,868 (+28) +0.2%
msp_exp432e401y/usbtest 13,804 → 13,832 (+28) 14,372 → 14,400 (+28) +0.2%
ek_tm4c123gxl/uac2_speaker_fb 14,568 → 14,596 (+28) 14,604 → 14,632 (+28) +0.2%
msp_exp432e401y/audio_test 12,400 → 12,424 (+24) 12,988 → 13,012 (+24) +0.2%
msp_exp432e401y/uac2_speaker_fb 14,756 → 14,784 (+28) 15,328 → 15,356 (+28) +0.2%
msp_exp432e401y/audio_test_multi_rate 12,616 → 12,640 (+24) 13,204 → 13,228 (+24) +0.2%

@rhgndf
rhgndf force-pushed the py32f0 branch 2 times, most recently from 8c0c88e to 9e6e54e Compare June 18, 2026 09:28
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown

Hardware-in-the-loop (HIL) Test Report

hfp.json

✅ 49 passed · ❌ 7 failed · ⚪ 0 skipped · blank not run

Board usbtest cdc_msc_throughput audio_test_freertos cdc_dual_ports cdc_msc cdc_msc_freertos dfu dfu_runtime hid_boot_interface hid_generic_inout midi_test msc_dual_lun mtp printer_to_cdc duration
stm32l412nucleo ✅ 30/30 ✅ C 627/388k M 846/821k 183s
stm32f746disco ✅ 30/30 ✅ C 12.7/10.4M M 14/26.7M 144s
stm32f746disco-DMA ✅ 30/30 ✅ C 12.3/10.2M M 15.8/31.4M 91s
lpcxpresso43s67 ✅ 30/30 185s

tinyusb-esp.json

✅ 10 passed · ❌ 14 failed · ⚪ 0 skipped · blank not run

Board usbtest msc_file_explorer_freertos audio_test_freertos cdc_msc_freertos device_info hid_composite_freertos duration
espressif_p4_function_ev ❌ 0/30 409 KB/s 59s
espressif_p4_function_ev-DMA ❌ 0/30 409 KB/s 59s
espressif_s3_devkitm ❌ 0/30 74s
espressif_s3_devkitm-DMA ❌ 0/30 74s

tinyusb.json

✅ 20 passed · ❌ 327 failed · ⚪ 17 skipped · blank not run

Board usbtest cdc_msc_throughput msc_file_explorer msc_file_explorer_freertos audio_test_freertos cdc_dual_ports cdc_msc cdc_msc_freertos cdc_msc_hid device_info dfu dfu_runtime hid_boot_interface hid_generic_inout host_info_to_device_cdc midi_test msc_dual_lun mtp printer_to_cdc duration
frdm_k64f 9s
ek_tm4c123gxl ❌ 0/30 143s
metro_m4_express ❌ 0/30 138s
raspberry_pi_pico_w 1103 KB/s 1022 KB/s 46s
feather_nrf52840_express ❌ 0/30 137s
raspberry_pi_pico ❌ 0/30 62 KB/s 217s
raspberry_pi_pico2 1110 KB/s 1022 KB/s 15s
max32666fthr ❌ 0/30 138s
adafruit_fruit_jam ❌ 0/30 62 KB/s 62 KB/s 184s
lpcxpresso11u37 ❌ 0/30 144s
stm32f072disco ❌ 0/30 145s
ra4m1_ek ❌ 0/30 125s
stm32f407disco ❌ 0/30 130s
stm32f723disco ❌ 0/30 18078 KB/s 4096 KB/s 163s
stm32f723disco-DMA ❌ 0/30 18724 KB/s 4032 KB/s 157s
stm32h743nucleo ❌ 0/30 134s
stm32h743nucleo-DMA ❌ 0/30 134s
nrf5340dk ❌ 0/30 121s
stm32g0b1nucleo ❌ 0/30 124s
stm32l476disco ❌ 0/30 140s
stm32u083nucleo ❌ 0/30 129s
nanoch32v203-fsdev ❌ 0/30 104s
nanoch32v203-usbfs ❌ 0/30 103s
ch32v103r_r1_1v0 ❌ 0/30 140s
ch32v307v_r1_1v0-usbhs ❌ 0/30 126s
ch32v307v_r1_1v0-usbfs ❌ 0/30 125s
ch582m_evt ❌ 0/30 130s

@ImproperCatGirl

Copy link
Copy Markdown

Great job! Also tested to work on PY32F403 (tested: HID and CDC-ACM) with almost no change.

@rhgndf

rhgndf commented Jul 15, 2026

Copy link
Copy Markdown
Contributor Author

Great job! Also tested to work on PY32F403 (tested: HID and CDC-ACM) with almost no change.

mind adding the setup that you have for f403? Both the bsp and dcd changes

@ImproperCatGirl

Copy link
Copy Markdown

Great job! Also tested to work on PY32F403 (tested: HID and CDC-ACM) with almost no change.

mind adding the setup that you have for f403? Both the bsp and dcd changes

Basically nothing, it's register compatible. DCD no change (though you can utilize the 8 (instead of 6) endpoints through minor changes), BSP solely enabled the clock. https://github.com/ImproperCatGirl/PY32F403_USB/

@HiFiPhile

Copy link
Copy Markdown
Collaborator

Thank you, from Codex:

@rhgndf

rhgndf commented Jul 19, 2026

Copy link
Copy Markdown
Contributor Author
* **[P1] PY32 builds fail under `-Werror`**

fixed by commenting out the line. Should we put in a TU_ASSERT if the ep size exceeds what the hardware can handle?

* **[P2] `cdc_msc_freertos` exceeds the board’s RAM**

fixed

also have rebased the branch

@HiFiPhile

Copy link
Copy Markdown
Collaborator

fixed by commenting out the line. Should we put in a TU_ASSERT if the ep size exceeds what the hardware can handle?

We can let hwfifo_config return false as assert is already in dcd_edpt_open, also add assert to dcd_edpt_iso_alloc.

rhgndf and others added 2 commits July 20, 2026 01:15
@HiFiPhile
HiFiPhile merged commit 2555891 into hathach:master Jul 19, 2026
313 of 316 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants