Klipper not working with neopixel in config

Basic Information:

Printer Model: Voron 0.2
MCU / Printerboard: BTT SKR Pico
Host / SBC: BTT Pi
klippy.log
klippy (4).log (286.7 KB)

I have installed a klippyexpander board and can not get it to work.

If I have this in klipperEpander.cfg:

[mcu expander]
serial:/dev/serial/by-id/usb-Klipper_stm32f042x6_23000F000843565036343620-if00
restart_method: command

[output_pin mosfet0]
pin: expander:PA0
#pwm: false
#cycle_time: 0.010
value: 0
shutdown_value: 0

#[neopixel Pixel]
#pin: expander:PB1
#chain_count: 2
#initial_RED: 0.9
#initial_GREEN: 0.9
#initial_BLUE: 0.9

then all works fine and in Systems load it says:

mcu rp2040
Version: v0.13.0-152-gf54b7b937
Load: 0.00, Awake: 0.00, Freq: 12 MHz, Temp: 41°C

mcu display stm32f042x6
Version: v0.13.0-152-gf54b7b937
Load: 0.01, Awake: 0.00, Freq: 48 MHz,

mcu expander stm32f042x6
Version: v0.13.0-152-gf54b7b937
Load: 0.01, Awake: 0.00, Freq: 48 MHz,

Host aarch64, 64bit
Version: v0.13.0-152-gf54b7b937-dirty
OS: Debian GNU/Linux 11 (bullseye)
Load: 0.27, Mem: 307.3 MB / 986.9 MB , Temp: 47°C
wlan0 (192.168.0.114) : Bandwidth: 4.1 kB/s , Received: 19.9 MB , Transmitted: 24.3 MB

BUT if I uncomment the bit about neopixel in klipperEpander.cfg to:

[mcu expander]
serial:/dev/serial/by-id/usb-Klipper_stm32f042x6_23000F000843565036343620-if00
restart_method: command

[output_pin mosfet0]
pin: expander:PA0
#pwm: false
#cycle_time: 0.010
value: 0
shutdown_value: 0

[neopixel Pixel]
pin: expander:PB1
chain_count: 2
initial_RED: 0.9
initial_GREEN: 0.9
initial_BLUE: 0.9

Then in Systems load it says:

Klipper reports: ERROR
MCU Protocol error

This is frequently caused by running an older version of the
firmware on the MCU(s). Fix by recompiling and flashing the
firmware.

Your Klipper version is: v0.13.0-152-gf54b7b937-dirty
MCU(s) which should be updated:
mcu: Current version v0.13.0-152-gf54b7b937
display: Current version v0.13.0-152-gf54b7b937
expander: Current version v0.13.0-152-gf54b7b937
Up-to-date MCU(s):

Once the underlying issue is corrected, use the “RESTART”
command to reload the config and restart the host software.

mcu ‘expander’: Unknown command: neopixel_update

I have tried to figure out what is wrong, but I can not solve this with my limited knowledge and google.

Any suggestions?

$ make menuconfig
---
[*] Enable extra low-level configuration options
    Micro-controller Architecture (STMicroelectronics STM32)  --->
    Processor model (STM32F042)  --->
    Bootloader offset (8KiB bootloader)  --->
    Clock Reference (25 MHz crystal)  --->
    Communication interface (USB (on PA11/PA12))  --->
    USB ids  --->
    Optional features (to reduce code size)  --->            # You want to look here
[*] Optimize stepper code for 'step on both edges'
()  GPIO pins to set at micro-controller startup
-----
[ ] Support micro-controller based ADC (analog to digital)
[ ] Support communicating with external chips via SPI bus
[ ] Support communicating with external chips via I2C bus
[ ] Support GPIO based button reading
[ ] Support Trinamic stepper motor driver UART communication
[*] Support 'neopixel' type LED control                      # Do make sure that it is checked
[ ] Support measuring fan tachometer GPIO pins
    *** LCD chips ***
[ ] Support ST7920 LCD display
[ ] Support HD44780 LCD display
    *** External ADC type chips ***
[ ] Support HX711 and HX717 ADC chips

Hope that helps.

??? Why would you suggest this?

First, the MCU on the SKR Pico (which @mullemeck is using) is an RP2040 which has 240k of Flash.

Secondly, his Klipper version is dirty.

Thirdly, in the original post, @mullemeck has indicated that the [neopixel Pixel], which is on pin expander:PB1 is commented out and is part of a file called expander.cfg.

@mullemeck could you:

  1. Reload Klipper so that it is no longer “dirty”.
  2. Post your printer.cfg and expander.cfg as well as any *.cfg files used in your printer.

Well, because:

MCU 'expander' config: BUS_PINS_spi1=PA6,PA7,PA5 BUS_PINS_spi1a=PB4,PB5,PB3 BUS_PINS_spi2=PB14,PB15,PB13 BUS_PINS_spi2a=PC2,PC3,PB10 CLOCK_FREQ=48000000 MCU=stm32f042x6 RESERVE_PINS_USB=PA11,PA12 STATS_SUMSQ_BASE=256 STEPPER_STEP_BOTH_EDGE=1
mcu_temperature 'mcu' nominal base=437.226612 slope=-1917.489831

So, it is expander, it is stm32f042.

Hope that helps.

Sorry, missed that - but, from the OP, it looks like the expander neopixel statement is still commented out and I don’t see it in the klippy.log.

AND, Klipper is “dirty”.

1 Like

Log contains several start attempts, one of which includes it and shows the error:


[neopixel expanderPixel]
pin = expander:PB1
chain_count = 2
initial_red = 0.9
initial_green = 0.9
initial_blue = 0.9
=======================
...
Loaded MCU 'mcu' 132 commands (v0.13.0-152-gf54b7b937 / 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 'mcu' config: ....
...
Loaded MCU 'display' 111 commands (v0.13.0-152-gf54b7b937 / 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 'display' config: ADC_MAX=4095 BUS_PINS_i2c1=PB6,PB7 BUS_PINS_i2c1_PB6_PB7=PB6,PB7 BUS_PINS_i2c1_PB8_PB7=PB8,PB7 BUS_PINS_i2c1_PB8_PB9=PB8,PB9 BUS_PINS_i2c1_PF1_PF0=PF1,PF0 BUS_PINS_i2c1a=PF1,PF0 BUS_PINS_spi1=PA6,PA7,PA5 BUS_PINS_spi1a=PB4,PB5,PB3 BUS_PINS_spi2=PB14,PB15,PB13 BUS_PINS_spi2a=PC2,PC3,PB10 CLOCK_FREQ=48000000 MCU=stm32f042x6 RESERVE_PINS_USB=PA11,PA12 STATS_SUMSQ_BASE=256 STEPPER_OPTIMIZED_EDGE=6 STEPPER_STEP_BOTH_EDGE=1
Loaded MCU 'expander' 65 commands (v0.13.0-152-gf54b7b937 / 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 'expander' config: BUS_PINS_spi1=PA6,PA7,PA5 BUS_PINS_spi1a=PB4,PB5,PB3 BUS_PINS_spi2=PB14,PB15,PB13 BUS_PINS_spi2a=PC2,PC3,PB10 CLOCK_FREQ=48000000 MCU=stm32f042x6 RESERVE_PINS_USB=PA11,PA12 STATS_SUMSQ_BASE=256 STEPPER_STEP_BOTH_EDGE=1
...
Protocol error
Traceback (most recent call last):
  File "/home/biqu/klipper/klippy/klippy.py", line 135, in _connect
    cb()
  File "/home/biqu/klipper/klippy/mcu.py", line 754, in _connect
    self._send_config(None)
  File "/home/biqu/klipper/klippy/mcu.py", line 685, in _send_config
    cb()
  File "/home/biqu/klipper/klippy/extras/neopixel.py", line 58, in build_config
    self.neopixel_update_cmd = self.mcu.lookup_command(
  File "/home/biqu/klipper/klippy/mcu.py", line 890, in lookup_command
    return CommandWrapper(self._serial, msgformat, cq)
  File "/home/biqu/klipper/klippy/mcu.py", line 86, in __init__
    self._cmd = msgparser.lookup_command(msgformat)
  File "/home/biqu/klipper/klippy/msgproto.py", line 314, in lookup_command
    self._error("Unknown command: %s", msgname)
  File "/home/biqu/klipper/klippy/msgproto.py", line 242, in _error
    raise error(self.warn_prefix + (msg % params))
msgproto.error: mcu 'expander': Unknown command: neopixel_update
MCU Protocol error

This is frequently caused by running an older version of the
firmware on the MCU(s). Fix by recompiling and flashing the
firmware.

Your Klipper version is: v0.13.0-152-gf54b7b937-dirty
MCU(s) which should be updated:
mcu: Current version v0.13.0-152-gf54b7b937
display: Current version v0.13.0-152-gf54b7b937
expander: Current version v0.13.0-152-gf54b7b937
Up-to-date MCU(s):
<none>

Once the underlying issue is corrected, use the "RESTART"
command to reload the config and restart the host software.

mcu 'expander': Unknown command: neopixel_update
No build file /home/biqu/klipper/klippy/../.config
No build file /home/biqu/klipper/klippy/../out/klipper.dict
No build file /home/biqu/klipper/klippy/../out/klipper.elf

Yes, it is and it is not cool, of course, but I suspect it has nothing to do with neopixel:

Git version: 'v0.13.0-152-gf54b7b937-dirty'
Untracked files: klippy/extras/autotune_tmc.py, klippy/extras/motor_constants.py

So, from my humble point of view, it is the MCU config issue.

1 Like

In my (admittedly limited) experience when building the Klipper Firmware image for a limited Flash device you will get an error if there isn’t enough space in the selected device for the built Flash.

Now, I just tried to build for the SMT32F042 without limiting any of the build options and the make failed as expected and when I looked in ~/klipper/out there is no klipper.bin firmware image file:

biqu@kgpft1:~/klipper $ make menuconfig
Loaded configuration '/home/biqu/klipper/.config'
Configuration saved to '/home/biqu/klipper/.config'
biqu@kgpft1:~/klipper $ make clean
  Creating symbolic link out/board
biqu@kgpft1:~/klipper $ make
  Creating symbolic link out/board
  Building out/autoconf.h
  Compiling out/src/sched.o
  Compiling out/src/command.o
  Compiling out/src/basecmd.o
  Compiling out/src/debugcmds.o
  Compiling out/src/initial_pins.o
  Compiling out/src/gpiocmds.o
  Compiling out/src/stepper.o
  Compiling out/src/endstop.o
  Compiling out/src/trsync.o
  Compiling out/src/adccmds.o
  Compiling out/src/spicmds.o
  Compiling out/src/i2ccmds.o
  Compiling out/src/buttons.o
  Compiling out/src/tmcuart.o
  Compiling out/src/neopixel.o
  Compiling out/src/pulse_counter.o
  Compiling out/src/lcd_st7920.o
  Compiling out/src/lcd_hd44780.o
  Compiling out/src/spi_software.o
  Compiling out/src/i2c_software.o
  Compiling out/src/thermocouple.o
  Compiling out/src/sensor_adxl345.o
  Compiling out/src/sensor_lis2dw.o
  Compiling out/src/sensor_mpu9250.o
  Compiling out/src/sensor_icm20948.o
  Compiling out/src/sensor_hx71x.o
  Compiling out/src/sensor_ads1220.o
  Compiling out/src/sensor_ldc1612.o
  Compiling out/src/sensor_angle.o
  Compiling out/src/sensor_bulk.o
  Compiling out/src/sos_filter.o
  Compiling out/src/load_cell_probe.o
  Compiling out/src/stm32/watchdog.o
  Compiling out/src/stm32/clockline.o
  Compiling out/src/stm32/dfu_reboot.o
  Compiling out/src/generic/crc16_ccitt.o
  Compiling out/src/generic/armcm_boot.o
  Compiling out/src/generic/armcm_irq.o
  Compiling out/src/generic/armcm_reset.o
  Compiling out/src/stm32/stm32f0.o
  Compiling out/src/../lib/stm32f0/system_stm32f0xx.o
  Compiling out/src/generic/timer_irq.o
  Compiling out/src/stm32/stm32f0_timer.o
  Compiling out/src/stm32/gpio.o
  Compiling out/src/stm32/gpioperiph.o
  Compiling out/src/stm32/stm32f0_adc.o
  Compiling out/src/stm32/spi.o
  Compiling out/src/stm32/stm32f0_i2c.o
  Compiling out/src/stm32/usbfs.o
  Compiling out/src/stm32/chipid.o
  Compiling out/src/generic/usb_cdc.o
  Building out/compile_time_request.o
Version: v0.13.0-149-g607d0b42
  Preprocessing out/src/generic/armcm_link.ld
  Linking out/klipper.elf
/usr/lib/gcc/arm-none-eabi/12.2.1/../../../arm-none-eabi/bin/ld: out/klipper.elf section `.text' will not fit in region `rom'
/usr/lib/gcc/arm-none-eabi/12.2.1/../../../arm-none-eabi/bin/ld: region `rom' overflowed by 3627 bytes
collect2: error: ld returned 1 exit status
make: *** [Makefile:73: out/klipper.elf] Error 1
biqu@kgpft1:~/klipper $ ls out/klipper.bin -l
ls: cannot access 'out/klipper.bin': No such file or directory
biqu@kgpft1:~/klipper $

Now, in the OP, @mullemeck seems to indicate that he was able to build an image for the STM32F042 - I think there needs to be an understanding what happened there.

@mullemeck the ball’s in your court. I guess what we’re looking for is:

  1. An explanation of how you built the firmware for the expander board and what were the results.
  2. The latest/correct printer.cfg and expander.cfg as well as any other *.cfg files that you are using. I’m asking this because Klipper can be a bit funny with device/operating statements that are not in printer.cfg. If you have something outside of printer.cfg then it may not be picked up and I’ve seen some cases where they aren’t applied properly. The rule of thumb that I use is that everything with the exception of macros should be in printer.cfg.
  3. A Klipper installation that is “dirty” is often problematic and could mean that the Klipper image was loaded from a third party site and has been modified for some specific reason. Please reload so that it is no longer reported as “dirty” or explain where you got the version of Klipper that you’re using and why you’re using it.
1 Like

Thank you for your coments.
I have been out of town so hav not been able to test your suggestions untill today.
Since my latest atempts there has been some updates for klipper, but stupid as I am i did not dokument what they were about, I just applied them.
And after I had read all of your comments I recompiler the firmware for the expander board, with the same settings as before, I think, and now everything works!
Maybe I did some thing different this time but I think it was the update of klipper that made it.
The reason the klipper is dirty is that i have instaled Klipper TMC Autotune.
Here is the settings I used:

1 Like

You may find a bit of documentation here: Region ROM Overflowed / Region Text Overflowed