Running on ST Nucleo STM32H743ZI

Going to wire up to some DM860i drivers and big 6A steppers for a project.

I got Raspberry Pi Picos, BTT SKR pro 1.2 and a couple of MKS Robin E3Ds running allready.

I tried flashing klipper to a ST Nucleo STM32H743ZI (i have version ZI, NOT ZI2)

I selected “no bootloader” and comms on USB PA11/PA.
Programmed using STM32CubeProgrammer on win11.

No serial device/connection to the RPI 400 seen with dmesg

Anyone made klipper work with a STM32H743 Nucleo board, and got tips they want to share ?

I found this

Changed the clock to 25MHz, recompiled, flashed and got a connection:

[17128.267372] usb 1-1.2: USB disconnect, device number 12
[17142.317964] usb 1-1.2: new full-speed USB device number 13 using xhci_hcd
[17142.429904] usb 1-1.2: New USB device found, idVendor=1d50, idProduct=614e, bcdDevice= 1.00
[17142.429936] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[17142.429953] usb 1-1.2: Product: stm32h743xx
[17142.429967] usb 1-1.2: Manufacturer: Klipper
[17142.429981] usb 1-1.2: SerialNumber: 120010801451373134393635
[17142.438210] cdc_acm 1-1.2:1.0: ttyACM1: USB ACM device
Summary

Checking the ST schematic

The 25MHz oscillator (X3) is optional - and not mounted on my board.


on another page, it’s an 8 MHz oscillator

image

X4 (a 25Mhz oscillator) is on my board - but it’s mounted to an ethernet IC.

Should I mount the optional a 25MHz oscillator + caps ? It seems to work fine without.

not read the code, but seems the code base on some sepcial board. Most design use 25M of crystal, so I guess and try that. Which really frequency of crystal on your board?

From the ST document p25:

MCO from ST-LINK (Default): MCO output of ST-LINK is used as input clock. This
frequency cannot be changed, it is fixed at 8 MHz and connected to the
PF0/PH0-OSC_IN of STM32 microcontroller

I have checked, and the solder bridges are configured for “MCO from ST-Link”.

But I’m guessing that’s not the same as the 8MHz clock option in klipper “make menuconfig”.

Mainsail GUI shows another frequency of 128MHz - I was expecting 400MHz (?)

Pico RP2040 shows

But i think it works anyway, I can control the onboard LED’s at least - I have not connected to motor drivers etc. yet.

[mcu MCU_ST1]
serial: /dev/serial/by-id/usb-Klipper_stm32h743xx_120010801451373134393635-if00

[mcu]
serial: /tmp/klipper_host_mcu

[mcu pico1]
serial: /dev/serial/by-id/usb-Klipper_rp2040_E66098F29B4D7632-if00

[output_pin LED_MCU_ST1_PB0]
pin: MCU_ST1:PB0
value: 0

[output_pin LED_MCU_ST1_PB14]
pin: MCU_ST1:PB14
value: 0

[output_pin LED_MCU_ST1_PB7]
pin: MCU_ST1:PB7
value: 0

[output_pin LED_Pico1_gpio25]
pin: pico1:gpio25
pwm: True
hardware_pwm: True
value: 0

See Pi Pico - 12Mhz CLOCK_FREQ? - #2 by koconnor

1 Like

I am not connect also. I layout my board, the drivers I design as an “AUX” board. It just be finished machining, on the way to me.
where you read the MCU frequency? I just can find the load of it.

aml
CPU ARMv8 Processor rev 4 (v8l)
64bit aarch64 with 4 cores
Debian GNU/Linux 11 (bullseye)
bullseye
mcu v0.10.0-244-g15ffa859

It shows in the webinterface (Mainsail)

using klipper console.py, i get CLOCK_FREQ=12000000 at the very end (for pico)
and CLOCK_FREQ=400000000 for stm32h743zi

Raspberry Pi Pico

> sudo service klipper stop

> ~/klippy-env/bin/python ~/klipper/klippy/console.py /dev/ttyACM1

  This is a debugging console for the Klipper micro-controller.
  In addition to mcu commands, the following artificial commands are
  available:
    PINS  : Load pin name aliases (eg, "PINS arduino")
    DELAY : Send a command at a clock time (eg, "DELAY 9999 get_uptime")
    FLOOD : Send a command many times (eg, "FLOOD 22 .01 get_uptime")
    SUPPRESS : Suppress a response message (eg, "SUPPRESS analog_in_state 4")
    SET   : Create a local variable (eg, "SET myvar 123.4")
    STATS : Report serial statistics
    LIST  : List available mcu commands, local commands, and local variables
    HELP  : Show this text
  All commands also support evaluation by enclosing an expression in { }.
  For example, "reset_step_clock oid=4 clock={clock + freq}".  In addition
  to user defined variables (via the SET command) the following builtin
  variables may be used in expressions:
    clock : The current mcu clock time (as estimated by the host)
    freq  : The mcu clock frequency

==================== attempting to connect ====================
INFO:root:Starting serial connect
Loaded 100 commands (v0.10.0-358-g7c5b7191 / gcc: (15:8-2019-q3-1+b1) 8.3.1 20190703 (release) [gcc-8-branch revision 273027] binutils: (2.35.2-2+14+b2) 2.35.2)
MCU config: BUS_PINS_spi0a=gpio0,gpio3,gpio2 BUS_PINS_i2c0h=gpio28,gpio29 BUS_PINS_spi0c=gpio16,gpio19,gpio18 BUS_PINS_spi0d=gpio20,gpio23,gpio22 BUS_PINS_i2c0b=gpio4,gpio5 BUS_PINS_i2c0c=gpio8,gpio9 BUS_PINS_i2c1c=gpio10,gpio11 BUS_PINS_i2c0a=gpio0,gpio1 BUS_PINS_i2c0f=gpio20,gpio21 BUS_PINS_i2c0g=gpio24,gpio25 BUS_PINS_i2c1g=gpio26,gpio27 BUS_PINS_i2c0e=gpio16,gpio17 BUS_PINS_i2c0d=gpio12,gpio13 BUS_PINS_i2c1e=gpio18,gpio19 BUS_PINS_i2c1f=gpio22,gpio23 BUS_PINS_spi1c=gpio24,gpio27,gpio26 BUS_PINS_spi1b=gpio12,gpio15,gpio14 BUS_PINS_spi1a=gpio8,gpio11,gpio10 STATS_SUMSQ_BASE=256 BUS_PINS_i2c1d=gpio14,gpio15 BUS_PINS_i2c1b=gpio6,gpio7 STEPPER_BOTH_EDGE=1 BUS_PINS_i2c1a=gpio2,gpio3 ADC_MAX=4095 PWM_MAX=255 BUS_PINS_spi0b=gpio4,gpio7,gpio6 MCU=rp2040 CLOCK_FREQ=12000000
====================       connected       ====================

STM32H743ZI

 ~/klippy-env/bin/python ~/klipper/klippy/console.py /dev/ttyACM0

  This is a debugging console for the Klipper micro-controller.
  In addition to mcu commands, the following artificial commands are
  available:
    PINS  : Load pin name aliases (eg, "PINS arduino")
    DELAY : Send a command at a clock time (eg, "DELAY 9999 get_uptime")
    FLOOD : Send a command many times (eg, "FLOOD 22 .01 get_uptime")
    SUPPRESS : Suppress a response message (eg, "SUPPRESS analog_in_state 4")
    SET   : Create a local variable (eg, "SET myvar 123.4")
    STATS : Report serial statistics
    LIST  : List available mcu commands, local commands, and local variables
    HELP  : Show this text
  All commands also support evaluation by enclosing an expression in { }.
  For example, "reset_step_clock oid=4 clock={clock + freq}".  In addition
  to user defined variables (via the SET command) the following builtin
  variables may be used in expressions:
    clock : The current mcu clock time (as estimated by the host)
    freq  : The mcu clock frequency

==================== attempting to connect ====================
INFO:root:Starting serial connect
Loaded 95 commands (v0.10.0-364-g4d4c8d8f / gcc: (15:8-2019-q3-1+b1) 8.3.1 20190703 (release) [gcc-8-branch revision 273027] binutils: (2.35.2-2+14+b2) 2.35.2)
MCU config: BUS_PINS_spi2b=PI2,PI3,PI1 BUS_PINS_spi2a=PC2,PC3,PB10 BUS_PINS_spi5a=PH7,PF11,PH6 RESERVE_PINS_crystal=PH0,PH1 RESERVE_PINS_USB=PA11,PA12 CLOCK_FREQ=400000000 BUS_PINS_spi3a=PC11,PC12,PC10 BUS_PINS_spi1a=PB4,PB5,PB3 STATS_SUMSQ_BASE=256 BUS_PINS_spi5=PF8,PF9,PF7 STEPPER_BOTH_EDGE=1 BUS_PINS_spi6=PG12,PG14,PG13 ADC_MAX=4095 BUS_PINS_spi4=PE13,PE14,PE12 BUS_PINS_spi3=PB4,PB5,PB3 BUS_PINS_spi2=PB14,PB15,PB13 BUS_PINS_spi1=PA6,PA7,PA5 PWM_MAX=255 MCU=stm32h743xx
INFO:root:Resetting prediction variance 104461.198: freq=400000000 diff=-13773379 stddev=400000.000
====================       connected       ====================

Thank you. My another board got this:
root@aml:/dev# /home/klipper/klippy-env/bin/python /home/klipper/klipper/klippy/console.py /dev/ttyACM0

This is a debugging console for the Klipper micro-controller.
In addition to mcu commands, the following artificial commands are
available:
PINS : Load pin name aliases (eg, “PINS arduino”)
DELAY : Send a command at a clock time (eg, “DELAY 9999 get_uptime”)
FLOOD : Send a command many times (eg, “FLOOD 22 .01 get_uptime”)
SUPPRESS : Suppress a response message (eg, “SUPPRESS analog_in_state 4”)
SET : Create a local variable (eg, “SET myvar 123.4”)
STATS : Report serial statistics
LIST : List available mcu commands, local commands, and local variables
HELP : Show this text
All commands also support evaluation by enclosing an expression in { }.
For example, “reset_step_clock oid=4 clock={clock + freq}”. In addition
to user defined variables (via the SET command) the following builtin
variables may be used in expressions:
clock : The current mcu clock time (as estimated by the host)
freq : The mcu clock frequency

==================== attempting to connect ====================
INFO:root:Starting serial connect
Loaded 94 commands (v0.10.0-244-g15ffa859 / gcc: (15:7-2018-q2-6) 7.3.1 20180622 (release) [ARM/embedded-7-branch revision 261907] binutils: (2.31.1-12+11) 2.31.1)
MCU config: BUS_PINS_i2c1=PB6,PB7 BUS_PINS_i2c2=PB10,PB11 BUS_PINS_spi3a=PC11,PC12,PC10 BUS_PINS_spi2a=PC2,PC3,PB10 BUS_PINS_i2c1a=PB8,PB9 RESERVE_PINS_USB=PA11,PA12 CLOCK_FREQ=180000000 BUS_PINS_spi1a=PB4,PB5,PB3 STATS_SUMSQ_BASE=256 BUS_PINS_spi3=PB4,PB5,PB3 STEPPER_BOTH_EDGE=1 ADC_MAX=4095 BUS_PINS_spi4=PE13,PE14,PE12 PWM_MAX=255 BUS_PINS_spi2=PB14,PB15,PB13 BUS_PINS_spi1=PA6,PA7,PA5 RESERVE_PINS_crystal=PH0,PH1 MCU=stm32f446xx
WARNING:root:got {’#receive_time’: 494.91080911, u’next_clock’: 95486784, u’fault’: 0, u’oid’: 11, u’value’: 20452784, ‘#name’: u’thermocouple_result’, ‘#sent_time’: 494.899798694}
WARNING:root:got {’#receive_time’: 494.937851319, u’next_clock’: 99086784, u’oid’: 13, u’value’: 31585, ‘#name’: u’analog_in_state’, ‘#sent_time’: 494.899798694}

The H743 board:

/home/klipper/klippy-env/bin/python /home/klipper/klipper/klippy/console.py /dev/ttyACM0

This is a debugging console for the Klipper micro-controller.
In addition to mcu commands, the following artificial commands are
available:
PINS : Load pin name aliases (eg, “PINS arduino”)
DELAY : Send a command at a clock time (eg, “DELAY 9999 get_uptime”)
FLOOD : Send a command many times (eg, “FLOOD 22 .01 get_uptime”)
SUPPRESS : Suppress a response message (eg, “SUPPRESS analog_in_state 4”)
SET : Create a local variable (eg, “SET myvar 123.4”)
STATS : Report serial statistics
LIST : List available mcu commands, local commands, and local variables
HELP : Show this text
All commands also support evaluation by enclosing an expression in { }.
For example, “reset_step_clock oid=4 clock={clock + freq}”. In addition
to user defined variables (via the SET command) the following builtin
variables may be used in expressions:
clock : The current mcu clock time (as estimated by the host)
freq : The mcu clock frequency

==================== attempting to connect ====================
INFO:root:Starting serial connect
Loaded 89 commands (v0.10.0-324-g91ba9c00 / gcc: (15:7-2018-q2-6) 7.3.1 20180622 (release) [ARM/embedded-7-branch revision 261907] binutils: (2.31.1-12+11) 2.31.1)
MCU config: BUS_PINS_spi2b=PI2,PI3,PI1 BUS_PINS_spi2a=PC2,PC3,PB10 BUS_PINS_spi5a=PH7,PF11,PH6 RESERVE_PINS_crystal=PH0,PH1 CLOCK_FREQ=400000000 BUS_PINS_spi3a=PC11,PC12,PC10 BUS_PINS_spi1a=PB4,PB5,PB3 STATS_SUMSQ_BASE=256 RESERVE_PINS_USB1=PB14,PB15 BUS_PINS_spi5=PF8,PF9,PF7 STEPPER_BOTH_EDGE=1 BUS_PINS_spi6=PG12,PG14,PG13 ADC_MAX=4095 BUS_PINS_spi4=PE13,PE14,PE12 BUS_PINS_spi3=PB4,PB5,PB3 BUS_PINS_spi2=PB14,PB15,PB13 BUS_PINS_spi1=PA6,PA7,PA5 PWM_MAX=255 MCU=stm32h743xx

Strange, these “Freq” values - a simple stm32f407VGT6 black pcb from aliexpress shows 168 Mhz. I guess I have to run the benchmarks to understand further. and/or get a better understanding of the code.

I am reading this thread since I am interested in Klipper and I am very conversant with the STM32H743. It looks like there is some confusion with clocking but I am not sure since a good deal of this thread is relying on information not written but know to the people posting. In any case if it helps, and if I am not misinterpreting, The crystals on the Nucleo board (typically 8MHz, 8MHz, 32KHz, and 25MHz) are for the MCU, ST-LINK MCU, RealTime Clock, and Ethernet PHY respectively. The 8MHz on the MCU does not necessarily define the system clock of the MCU. The MCU can use it to define its internal clock up to 400MHz. Same for the ST-Link MCU, that is not user select-able. Nor should it be otherwise ST-Link would cease to function correctly. ST-Link provides program load, debug, and USB-COMM functions. Further, the user can choose to not use the 8MHz external clock input and set whatever internal clock they want. The only downside being the system clock is a little less accurate. For most applications, it does not matter since the system clock only needs to be relative to internal operations with respect to precision and not absolute accuracy. I am try this out after I get clear of my current projects. I have the h743 Nucleo and h743i-eval as well.