Python REPL not starting on STM32H743 based board

Discussion and questions about boards that can run MicroPython but don't have a dedicated forum.
Target audience: Everyone interested in running MicroPython on other hardware.
Post Reply
User avatar
WZab
Posts: 6
Joined: Tue Jan 21, 2020 7:45 pm

Python REPL not starting on STM32H743 based board

Post by WZab » Tue Jan 21, 2020 7:58 pm

Hi,
I need to install the MicroPython on a board https://github.com/elhep/MCORD_HUB/tree/master/Hub_PCB based on NUCLEO_H743ZI
I have successfully compiled the MicroPython, hower after I run `make BOARD=NUCLEO_H743ZI deploy`, I can see the following in my console:

Code: Select all

$ make BOARD=NUCLEO_H743ZI deploy
Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity.
GEN build-NUCLEO_H743ZI/genhdr/qstrdefs.collected.h
QSTR not updated
Writing build-NUCLEO_H743ZI/firmware.dfu to the board
File: build-NUCLEO_H743ZI/firmware.dfu
    b'DfuSe' v1, image size: 454133, targets: 1
    b'Target' 0, alt setting: 0, name: "ST...", size: 453848, elements: 2
      0, address: 0x08000000, size: 15024
      1, address: 0x08040000, size: 438808
    usb: 0483:df11, device: 0x0000, dfu: 0x011a, b'UFD', 16, 0xd9d4728f
Writing memory...
0x08000000   15024 [=========================] 100% 
0x08040000  438808 [=========================] 100% 
Exiting DFU...
And the following as the output of `dmesg -w`:

Code: Select all

[ 5183.396365] usb 2-11: new full-speed USB device number 36 using xhci_hcd
[ 5183.546193] usb 2-11: New USB device found, idVendor=0483, idProduct=df11, bcdDevice= 2.00
[ 5183.546200] usb 2-11: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 5183.546203] usb 2-11: Product: DFU in FS Mode
[ 5183.546205] usb 2-11: Manufacturer: STMicroelectronics
[ 5183.546208] usb 2-11: SerialNumber: 100364500000
[ 5187.256027] usb 2-11: USB disconnect, device number 36
[ 5213.008134] usb 2-11: new full-speed USB device number 37 using xhci_hcd
[ 5213.157759] usb 2-11: New USB device found, idVendor=0483, idProduct=df11, bcdDevice= 2.00
[ 5213.157762] usb 2-11: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 5213.157764] usb 2-11: Product: DFU in FS Mode
[ 5213.157766] usb 2-11: Manufacturer: STMicroelectronics
[ 5213.157767] usb 2-11: SerialNumber: 100364500000
[ 5283.658262] usb 2-11: USB disconnect, device number 37
[ 5283.963523] usb 2-11: new full-speed USB device number 38 using xhci_hcd
[ 5299.439372] usb 2-11: device descriptor read/64, error -110
[ 5315.059266] usb 2-11: device descriptor read/64, error -110
[ 5315.295213] usb 2-11: new full-speed USB device number 39 using xhci_hcd
[ 5330.671446] usb 2-11: device descriptor read/64, error -110
[ 5346.286952] usb 2-11: device descriptor read/64, error -110
[ 5346.394973] usb usb2-port11: attempt power cycle
[ 5347.046933] usb 2-11: new full-speed USB device number 40 using xhci_hcd
[ 5352.302860] xhci_hcd 0000:00:14.0: Timeout while waiting for setup device command
[ 5357.678823] xhci_hcd 0000:00:14.0: Timeout while waiting for setup device command
[ 5357.886762] usb 2-11: device not accepting address 40, error -62
[ 5358.014773] usb 2-11: new full-speed USB device number 41 using xhci_hcd
[ 5363.054806] xhci_hcd 0000:00:14.0: Timeout while waiting for setup device command
[ 5368.430698] xhci_hcd 0000:00:14.0: Timeout while waiting for setup device command
[ 5368.638691] usb 2-11: device not accepting address 41, error -62
[ 5368.638762] usb usb2-port11: unable to enumerate USB device
It is rather not a signal integrity problem, as DFU is able to communicate via strictly he same cable...
I have tried to disable the SD card (as it is not connected in that board) and to comment out
definition of the HW_UART:

Code: Select all

#define MICROPY_HW_ENABLE_SDCARD    (0)
[...]
//#define MICROPY_HW_UART_REPL        PYB_UART_3
//#define MICROPY_HW_UART_REPL_BAUD   115200
but it does not help...
What can be the cause of that misbehavior?

TIA & Regards,
Wojtek

User avatar
WZab
Posts: 6
Joined: Tue Jan 21, 2020 7:45 pm

Re: Python REPL not starting on STM32H743 based board

Post by WZab » Tue Jan 21, 2020 8:33 pm

I have yet another finding. If I disconnect the "BOOT" jumper and power-cycle the board, it does not connect to the USB.
The host does not detect the new device at all.

Regards,
Wojtek

User avatar
dhylands
Posts: 3268
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Python REPL not starting on STM32H743 based board

Post by dhylands » Tue Jan 21, 2020 8:52 pm

Does your board use the same crystal frequency as the NUCLEO board? DFU is able to figure out the crystal frequency dynamically (which is why it works even if it differs) where Micropython needs to be configured with the correct frequency and other PLL settings.

User avatar
WZab
Posts: 6
Joined: Tue Jan 21, 2020 7:45 pm

Re: Python REPL not starting on STM32H743 based board

Post by WZab » Tue Jan 21, 2020 10:07 pm

Yes, it uses 8MHz crystal.
I can see, however, that programming of MicroPython does not touch the "Option Bytes" in the STM32.
Is it possible that the original values are incorrect and must be modified, when the MicroPython is programmed the first time?

Regards,
Wojtek

User avatar
dhylands
Posts: 3268
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Python REPL not starting on STM32H743 based board

Post by dhylands » Tue Jan 21, 2020 10:52 pm

I've not heard of having to program option bytes.

User avatar
WZab
Posts: 6
Joined: Tue Jan 21, 2020 7:45 pm

Re: Python REPL not starting on STM32H743 based board

Post by WZab » Tue Jan 21, 2020 11:28 pm

OK. The problem is explained. It was an hardware error. Incorrect voltage divider was connected to VBUS_DET. I had to disable VBUS sensing:

Code: Select all

-#define MICROPY_HW_USB_VBUS_DETECT_PIN (pin_A9)
-#define MICROPY_HW_USB_OTG_ID_PIN      (pin_A10)
+//#define MICROPY_HW_USB_VBUS_DETECT_PIN (pin_A9)
+//#define MICROPY_HW_USB_OTG_ID_PIN      (pin_A10)
Now REPL is starting correctly.

Regards,
Wojtek

Post Reply