I wanted to add just some hardware buttons to my Klipper powered RatRig v-core 3 ish printer.
Since I only want to run one wire to the panel I decided to add an other mcu and do something like gcode_buttons...
Looking into my electronics bins, I found some >10 years old buttons, a stripboard and an Arduino (pro) Micro, nice. So of to designing a case, cut the stripboard, solder the buttons and test it with an expanded Arduino Button example... yeah all buttons are working :thumpsup:
Now just compile and upload klipper, easy right? No.
The first problem klipper is too big for the tiny atmega32u4. -> can be fixed by disabling stuff which is not needed, I hope, for buttons.
Edit klipper/.config and set the stuff ant the end to n
, idk yet what is needed
CONFIG_MACH_AVR=y
CONFIG_AVR_SELECT=y
CONFIG_BOARD_DIRECTORY="avr"
CONFIG_MACH_atmega32u4=y
CONFIG_MCU="atmega32u4"
CONFIG_AVRDUDE_PROTOCOL="avr109"
CONFIG_CLOCK_FREQ=16000000
CONFIG_CLEAR_PRESCALER=y
CONFIG_AVR_CLKPR=0
CONFIG_AVR_STACK_SIZE=256
CONFIG_AVR_WATCHDOG=y
CONFIG_USBSERIAL=y
CONFIG_SERIAL_PORT=0
CONFIG_USB=y
CONFIG_USB_VENDOR_ID=0x1d50
CONFIG_USB_DEVICE_ID=0x614e
CONFIG_USB_SERIAL_NUMBER="12345"
CONFIG_WANT_GPIO_BITBANGING=y
CONFIG_WANT_DISPLAYS=n
CONFIG_WANT_SENSORS=n
CONFIG_WANT_LIS2DW=n
CONFIG_WANT_SOFTWARE_I2C=n
CONFIG_WANT_SOFTWARE_SPI=n
CONFIG_CANBUS_FREQUENCY=1000000
CONFIG_HAVE_GPIO=y
CONFIG_HAVE_GPIO_ADC=n
CONFIG_HAVE_GPIO_SPI=n
CONFIG_HAVE_GPIO_I2C=n
CONFIG_HAVE_GPIO_HARD_PWM=n
CONFIG_HAVE_STRICT_TIMING=n
CONFIG_INLINE_STEPPER_HACK=n
Yeah, it compiles, now just flash it right? No.
> make flash FLASH_DEVICE=/dev/serial/by-id/usb-Arduino_LLC_Arduino_Micro-if00
Flashing out/klipper.elf.hex to /dev/serial/by-id/usb-Arduino_LLC_Arduino_Micro-if00 via avrdude
Connecting to programmer: .avrdude: butterfly_recv(): programmer is not responding
avrdude: butterfly_recv(): programmer is not responding
Because the atmega32u4 needs a 1200 bps bootloader reset and avrdude does not do it, or I could not figure out how.
> avrdude -p m32u4 -c arduino -b 9600 -P /dev/ttyACM0 -v -D -U flash:w:out/klipper.elf.hex:i
avrdude: Version 6.3-20171130
...
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
arduino-cli to the rescue
> arduino-cli upload -i out/klipper.elf.hex -p /dev/ttyACM0 -b arduino:avr:micro
Connecting to programmer: .
Found programmer: Id = "CATERIN"; type = S
Software Version = 1.0; No Hardware Version given.
Programmer supports auto addr increment.
Programmer supports buffered memory access with buffersize=128 bytes.
Programmer supports the following devices:
Device code: 0x44
Famous last words: Next just add the klipper macro stuff... what could possibly go wrong
The author does not allow comments to this entry
No comments