Repository navigation
fix(usb): Bound IRQ-context waits and recover from wedged USB controllers #67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| #pragma once | ||
|
|
||
| // Defined in bsp/tinyusb/src/portable/synopsys/dwc2/dwc2_common.c. | ||
| extern "C" bool dwc2_recovery_required(); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| #include "core/src/utility/assert.hpp" | ||
|
|
||
| #include <source_location> | ||
|
|
||
| #include <main.h> // IWYU pragma: keep (disable irq) | ||
|
|
||
| namespace librmcs::core::utility { | ||
|
|
||
| const char* volatile assert_file = nullptr; | ||
| volatile unsigned int assert_line = 0; | ||
| const char* volatile assert_function = nullptr; | ||
|
|
||
| [[noreturn]] void assert_func(const std::source_location& location) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 将现有 bootloader 断言接入位置记录路径。
|
||
| __disable_irq(); | ||
|
|
||
| assert_file = location.file_name(); | ||
| assert_line = location.line(); | ||
| assert_function = location.function_name(); | ||
|
|
||
| __builtin_trap(); | ||
| } | ||
|
|
||
| } // namespace librmcs::core::utility | ||
| +36 −6 | src/portable/synopsys/dwc2/dcd_dwc2.c | |
| +16 −0 | src/portable/synopsys/dwc2/dwc2_common.c | |
| +39 −2 | src/portable/synopsys/dwc2/dwc2_common.h |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| #pragma once | ||
|
|
||
| // Defined in bsp/hpm_sdk/components/usb/device/hpm_usb_device.c. | ||
| extern "C" bool usb_device_recovery_required(); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| #include "core/src/utility/assert.hpp" | ||
|
|
||
| #include <source_location> | ||
|
|
||
| #include <hpm_csr_regs.h> | ||
| #include <hpm_soc.h> | ||
|
|
||
| namespace librmcs::core::utility { | ||
|
|
||
| const char* volatile assert_file = nullptr; | ||
| volatile unsigned int assert_line = 0; | ||
| const char* volatile assert_function = nullptr; | ||
|
|
||
| [[noreturn]] void assert_func(const std::source_location& location) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 将现有 bootloader 断言接入位置记录路径。
|
||
| disable_global_irq(CSR_MSTATUS_MIE_MASK); | ||
|
|
||
| assert_file = location.file_name(); | ||
| assert_line = location.line(); | ||
| assert_function = location.function_name(); | ||
|
|
||
| __builtin_trap(); | ||
| } | ||
|
|
||
| } // namespace librmcs::core::utility | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在擦除后和编程期间继续喂狗。
如果 DFU 提交完整的 128 KiB 扇区,Line 148 的一次喂狗不能覆盖随后的擦除和逐字编程。ST 给出的 128 KiB 擦除上限为 2 秒,单字编程上限为 100 微秒;连续编程 32,768 个字还可能需要约 3.28 秒。重载值 2000、预分频 64 对应的看门狗周期约为 2.72–4 秒,取决于 LSI 频率。看门狗因此可能在
program_bytes()中复位,使该设备无法完成 DFU 更新。请在擦除结束后喂狗,并在编程循环中定期喂狗。(st.com)