Cannot define spi_bus in printer.conf

Basic Information:

Printer Model: Voron2
MCU / Printerboard: PrintSmartCoreH7x (Board with a STM32H723 MCU)
Host / SBC: Dell laptop with ubuntu 24.04, klipper installed with kiauh
klippy.log
klippy.log.zip (5.5 KB)

Describe your issue:

I am trying to use a FYSETC V2.1 RGB Mini 12864 Graphic LCD Screen, but it wouldn’t work without defining SPI in the configuration. I don’t know yet if it would work with SPI defined, because I cannot add the “spi_bus:” parameter. As far as I see from the klipper source, the name would indeed be “spi4”, and BUS_PINS_spi4=PE13,PE14,PE12 shows up in the log.

In stm32h7_spi.c:

#ifdef SPI4
DECL_ENUMERATION("spi_bus", "spi4", __COUNTER__);
DECL_CONSTANT_STR("BUS_PINS_spi4", "PE13,PE14,PE12");
#endif

What am I doing wrong?

[display]
lcd_type = uc1701
cs_pin = z:PE15
a0_pin = z:PE14
rst_pin = z:PE13
contrast = 63
encoder_pins = ^z:PD14,^z:PD15
click_pin = ^!z:PC14
spi_bus = z:spi4
...
pins.error: Unknown spi_bus 'z:spi4'

Hmmm, this can be counterintuitive, but you do not need to prefix the SPI bus.
The MCU would be determined by the cs_pin.

[adxl345]
cs_pin: ebb42:PB12
spi_bus: spi2_PB2_PB11_PB10
# spi_software_miso_pin: ebb42:PB2 
# spi_software_mosi_pin: ebb42:PB11
# spi_software_sclk_pin: ebb42:PB10
axes_map: x, z, y
rate: 3200

Yes, that’s it, thank you! :slight_smile:

I am realizing though, that I missed something else. SPI4 in an STM32H723 is a “dual” interface. There is another set of pins used as SPI4 (PE2,PE5,PE6).

And so, now I am getting a different error message.

pins.error: pin PE14 is reserved for spi4

Since I don’t see any “a” and “b” of SPI4 in the source code, and no trace of those pins, I guess I have to fall back to spi_software_ …

Yes, with spi_software it works. Here’s my final configuration.

[display]
lcd_type: uc1701
cs_pin: z:PE15 # EXP1_3
a0_pin: z:PE14 # EXP1_4
rst_pin: z:PE13 # EXP1_5
contrast: 63
encoder_pins: ^z:PD14,^z:PD15 # ^EXP2_5, ^EXP2_3
click_pin: ^!z:PC14 # ^!EXP1_2
spi_software_miso_pin: z:PE5 # EXP2_1
spi_software_mosi_pin: z:PE6 # EXP2_6
spi_software_sclk_pin: z:PE2 # EXP2_2

[output_pin beeper]
pin: z:PC15 # EXP1_1

[neopixel fysetc_mini12864]
pin: z:PE12 # EXP1_6
chain_count: 3
color_order: RGB
initial_RED: 0.4
initial_GREEN: 0.4
initial_BLUE: 0.4

[delayed_gcode setdisplayneopixel]
initial_duration: 1
gcode:
        SET_LED LED=fysetc_mini12864 RED=1 GREEN=1 BLUE=1 INDEX=1 TRANSMIT=0
        SET_LED LED=fysetc_mini12864 RED=1 GREEN=0 BLUE=0 INDEX=2 TRANSMIT=0
        SET_LED LED=fysetc_mini12864 RED=1 GREEN=0 BLUE=0 INDEX=3 

Thank you again!