ports: On cold boot, enable USB after boot.py completes.
For mimxrt, nrf, renesas-ra, rp2 and samd ports, this commit implements similar behaviour to the stm32 port, where USB is only brought up after boot.py completes execution. Currently this doesn't add any useful functionality (and may break workflows that depend on USB-CDC being live in boot.py), however it's a precondition for more usable workflows with USB devices defined in Python (allows setting up USB interfaces in boot.py before the device enumerates for the first time). This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
This commit is contained in:
committed by
Damien George
parent
5d83bbca60
commit
00ba6aaae4
@@ -38,7 +38,7 @@
|
||||
#include "shared/runtime/gchelper.h"
|
||||
#include "shared/runtime/pyexec.h"
|
||||
#include "shared/runtime/softtimer.h"
|
||||
#include "tusb.h"
|
||||
#include "shared/tinyusb/mp_usbd.h"
|
||||
#include "uart.h"
|
||||
#include "modmachine.h"
|
||||
#include "modrp2.h"
|
||||
@@ -86,12 +86,9 @@ int main(int argc, char **argv) {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if MICROPY_HW_ENABLE_USBDEV
|
||||
#if MICROPY_HW_USB_CDC
|
||||
#if MICROPY_HW_ENABLE_USBDEV && MICROPY_HW_USB_CDC
|
||||
bi_decl(bi_program_feature("USB REPL"))
|
||||
#endif
|
||||
tusb_init();
|
||||
#endif
|
||||
|
||||
#if MICROPY_PY_THREAD
|
||||
bi_decl(bi_program_feature("thread support"))
|
||||
@@ -181,6 +178,11 @@ int main(int argc, char **argv) {
|
||||
|
||||
// Execute user scripts.
|
||||
int ret = pyexec_file_if_exists("boot.py");
|
||||
|
||||
#if MICROPY_HW_ENABLE_USBDEV
|
||||
mp_usbd_init();
|
||||
#endif
|
||||
|
||||
if (ret & PYEXEC_FORCED_EXIT) {
|
||||
goto soft_reset_exit;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user