Open sabankaradeniz opened 1 year ago
same problem,hope somebody can fix it or share some successed firmware
https://github.com/Klipper3d/klipper/issues/4938
The problem is that avr toolchain that comes in the latest ubuntu/raspberry pi packages is buggy. Possible solutions are to use a toolchain version from the older OS releases (easier, described in the comments of issue above), to build and install a more recent toolchain (hard, also slow to build on RPi), or to use MainsailOS.
Btw somebody can build newer toolchain packages and publish them so others can just download and install. Building gcc is not an easy task, especially if building for another architecture (building for arm on a x86_64 host).
Hope someone will find it useful here is a hex file I compiled today on off the master branch of the 328p. ~I was able to compile and install it on a virtual box image on ubuntu 18.~ something was messed up with the version I built, it wouldn't install properly. I ended up finding this compiled version from Janurary: https://gist.github.com/kirill578/b9ac61f4df8c7ce80a17eebd76691649
hello i also have the same problem how do i convert to .hex file?
I really don't understand why #4938 had to be locked, this is poor form to say the least :\
In any case, I report that I was to implement the buster rollback for gcc
fix as per https://github.com/Klipper3d/klipper/issues/4938#issuecomment-1094246978 by orobardet
I'm on debian 12 on x86, running kiauth for klipper management
Add the line of text to /etc/apt/sources.list
deb http://deb.debian.org/debian/ buster main contrib non-free
then added text to /etc/apt/preferences.d/avr-buster
Package: avr-libc avrdude binutils-avr gcc-avr
Pin: release n=buster
Pin-Priority: 1001
then
apt update
apt install avr-libc avrdude binutils-avr gcc-avr
went back to ~/klipper
make clean
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/pwmcmds.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_angle.o
Compiling out/src/sensor_mpu9250.o
Compiling out/src/sensor_lis2dw.o
Compiling out/src/sensor_ldc1612.o
src/sensor_ldc1612.c: In function ‘ldc1612_query’:
src/sensor_ldc1612.c:143:35: warning: left shift count >= width of type [-Wshift-count-overflow]
uint32_t data = (d[0] << 24L) | (d[1] << 16L) | (d[2] << 8) | d[3];
^
src/sensor_ldc1612.c:143:51: warning: left shift count >= width of type [-Wshift-count-overflow]
uint32_t data = (d[0] << 24L) | (d[1] << 16L) | (d[2] << 8) | d[3];
^
Compiling out/src/sensor_bulk.o
Compiling out/src/avr/main.o
Compiling out/src/avr/timer.o
Compiling out/src/avr/gpio.o
Compiling out/src/avr/adc.o
Compiling out/src/avr/spi.o
Compiling out/src/avr/i2c.o
Compiling out/src/avr/hard_pwm.o
Compiling out/src/avr/watchdog.o
Compiling out/src/avr/serial.o
Compiling out/src/generic/serial_irq.o
Building out/compile_time_request.o
Version: v0.12.0-171-g2f6e94c9-dirty-20240423_023324-klippa
Linking out/klipper.elf
Creating hex file out/klipper.elf.hex
beautiful !
total 708
12 -rw-r--r-- 1 user user 10720 Apr 23 02:33 autoconf.h
0 lrwxrwxrwx 1 user user 26 Apr 23 02:33 board -> /home/user/klipper/src/avr
4 drwxr-xr-x 2 user user 4096 Apr 23 02:33 board-generic
4 -rw-r--r-- 1 user user 27 Apr 23 02:33 board-link
60 -rw-r--r-- 1 user user 58827 Apr 23 02:33 compile_time_request.c
4 -rw-r--r-- 1 user user 715 Apr 23 02:33 compile_time_request.d
216 -rw-r--r-- 1 user user 217660 Apr 23 02:33 compile_time_request.o
16 -rw-r--r-- 1 user user 13955 Apr 23 02:33 compile_time_request.txt
8 -rw-r--r-- 1 user user 7603 Apr 23 02:33 klipper.dict
292 -rwxr-xr-x 1 user user 296376 Apr 23 02:33 klipper.elf
88 -rw-r--r-- 1 user user 89191 Apr 23 02:33 klipper.elf.hex
4 drwxr-xr-x 4 user user 4096 Apr 23 02:33 src
89K klipper is a big boy nowadays !
This is with current settings as follows
CONFIG_MACH_AVR=y
CONFIG_AVR_SELECT=y
CONFIG_BOARD_DIRECTORY="avr"
CONFIG_MACH_atmega328p=y
CONFIG_MCU="atmega328p"
CONFIG_AVRDUDE_PROTOCOL="arduino"
CONFIG_CLOCK_FREQ=16000000
CONFIG_AVR_CLKPR=-1
CONFIG_AVR_STACK_SIZE=256
CONFIG_AVR_WATCHDOG=y
CONFIG_SERIAL=y
CONFIG_SERIAL_BAUD_U2X=y
CONFIG_SERIAL_PORT=0
CONFIG_SERIAL_BAUD=250000
CONFIG_USB_VENDOR_ID=0x1d50
CONFIG_USB_DEVICE_ID=0x614e
CONFIG_USB_SERIAL_NUMBER="12345"
CONFIG_WANT_GPIO_BITBANGING=y
CONFIG_WANT_DISPLAYS=y
CONFIG_WANT_SENSORS=y
CONFIG_WANT_LIS2DW=y
CONFIG_WANT_LDC1612=y
CONFIG_WANT_SOFTWARE_I2C=y
CONFIG_WANT_SOFTWARE_SPI=y
CONFIG_NEED_SENSOR_BULK=y
CONFIG_CANBUS_FREQUENCY=1000000
CONFIG_HAVE_GPIO=y
CONFIG_HAVE_GPIO_ADC=y
CONFIG_HAVE_GPIO_SPI=y
CONFIG_HAVE_GPIO_I2C=y
CONFIG_HAVE_GPIO_HARD_PWM=y
CONFIG_HAVE_STRICT_TIMING=y
CONFIG_HAVE_LIMITED_CODE_SIZE=y
CONFIG_INLINE_STEPPER_HACK=y
With all accessible options turned off, still 49K
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/pwmcmds.o
Compiling out/src/avr/main.o
Compiling out/src/avr/timer.o
Compiling out/src/avr/gpio.o
Compiling out/src/avr/adc.o
Compiling out/src/avr/spi.o
Compiling out/src/avr/i2c.o
Compiling out/src/avr/hard_pwm.o
Compiling out/src/avr/watchdog.o
Compiling out/src/avr/serial.o
Compiling out/src/generic/serial_irq.o
Building out/compile_time_request.o
Version: v0.12.0-171-g2f6e94c9-dirty-20240423_023627-klippa
Linking out/klipper.elf
Creating hex file out/klipper.elf.hex
user@klippa:~/klipper$ grep -v '^#' .config
CONFIG_MACH_AVR=y
CONFIG_AVR_SELECT=y
CONFIG_BOARD_DIRECTORY="avr"
CONFIG_MACH_atmega328p=y
CONFIG_MCU="atmega328p"
CONFIG_AVRDUDE_PROTOCOL="arduino"
CONFIG_CLOCK_FREQ=16000000
CONFIG_AVR_CLKPR=-1
CONFIG_AVR_STACK_SIZE=256
CONFIG_AVR_WATCHDOG=y
CONFIG_SERIAL=y
CONFIG_SERIAL_BAUD_U2X=y
CONFIG_SERIAL_PORT=0
CONFIG_SERIAL_BAUD=250000
CONFIG_USB_VENDOR_ID=0x1d50
CONFIG_USB_DEVICE_ID=0x614e
CONFIG_USB_SERIAL_NUMBER="12345"
CONFIG_CANBUS_FREQUENCY=1000000
CONFIG_HAVE_GPIO=y
CONFIG_HAVE_GPIO_ADC=y
CONFIG_HAVE_GPIO_SPI=y
CONFIG_HAVE_GPIO_I2C=y
CONFIG_HAVE_GPIO_HARD_PWM=y
CONFIG_HAVE_STRICT_TIMING=y
CONFIG_HAVE_LIMITED_CODE_SIZE=y
CONFIG_INLINE_STEPPER_HACK=y
user@klippa:~/klipper$ ls -ls out/
total 480
12 -rw-r--r-- 1 user user 10720 Apr 23 02:36 autoconf.h
0 lrwxrwxrwx 1 user user 26 Apr 23 02:36 board -> /home/user/klipper/src/avr
4 drwxr-xr-x 2 user user 4096 Apr 23 02:36 board-generic
4 -rw-r--r-- 1 user user 27 Apr 23 02:36 board-link
40 -rw-r--r-- 1 user user 37320 Apr 23 02:36 compile_time_request.c
4 -rw-r--r-- 1 user user 715 Apr 23 02:36 compile_time_request.d
176 -rw-r--r-- 1 user user 177072 Apr 23 02:36 compile_time_request.o
12 -rw-r--r-- 1 user user 8335 Apr 23 02:36 compile_time_request.txt
8 -rw-r--r-- 1 user user 4591 Apr 23 02:36 klipper.dict
164 -rwxr-xr-x 1 user user 167316 Apr 23 02:36 klipper.elf
52 -rw-r--r-- 1 user user 49448 Apr 23 02:36 klipper.elf.hex
4 drwxr-xr-x 4 user user 4096 Apr 23 02:36 src
Perhaps there is still some fat that can be cut off.
I would be happy with a klipper that only has heater controls, or only has stepper controls, or only acceleromater, or maybe even only endstop+rgb+fan
I will try removing the following and see what we're left with.
out/src/spicmds.o
out/src/i2ccmds.o
out/src/pwmcmds.o
out/src/stepper.o
out/src/avr/adc.o
out/src/avr/spi.o
out/src/avr/i2c.o
Ok so far I've got
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/avr/main.o
Compiling out/src/avr/timer.o
Compiling out/src/avr/gpio.o
Compiling out/src/avr/watchdog.o
Compiling out/src/avr/serial.o
Compiling out/src/generic/serial_irq.o
Building out/compile_time_request.o
Version: v0.12.0-171-g2f6e94c9-dirty-20240423_024518-klippa
Linking out/klipper.elf
Creating hex file out/klipper.elf.hex
user@klippa:~/klipper$ ls -ls out
total 372
12 -rw-r--r-- 1 user user 10720 Apr 23 02:45 autoconf.h
0 lrwxrwxrwx 1 user user 26 Apr 23 02:45 board -> /home/user/klipper/src/avr
4 drwxr-xr-x 2 user user 4096 Apr 23 02:45 board-generic
4 -rw-r--r-- 1 user user 27 Apr 23 02:45 board-link
28 -rw-r--r-- 1 user user 26786 Apr 23 02:45 compile_time_request.c
4 -rw-r--r-- 1 user user 715 Apr 23 02:45 compile_time_request.d
152 -rw-r--r-- 1 user user 154212 Apr 23 02:45 compile_time_request.o
8 -rw-r--r-- 1 user user 5608 Apr 23 02:45 compile_time_request.txt
4 -rw-r--r-- 1 user user 3064 Apr 23 02:45 klipper.dict
116 -rwxr-xr-x 1 user user 118344 Apr 23 02:45 klipper.elf
36 -rw-r--r-- 1 user user 35891 Apr 23 02:45 klipper.elf.hex
4 drwxr-xr-x 4 user user 4096 Apr 23 02:45 src
36K, still overweight by 10K Same .config as above but I modified src/Makefile as follows
src-y += sched.c command.c basecmd.c debugcmds.c
src-$(CONFIG_HAVE_GPIO) += initial_pins.c gpiocmds.c stepper.c endstop.c \
trsync.c
#src-$(CONFIG_HAVE_GPIO_ADC) += adccmds.c
#src-$(CONFIG_HAVE_GPIO_SPI) += spicmds.c
#src-$(CONFIG_HAVE_GPIO_SDIO) += sdiocmds.c
#src-$(CONFIG_HAVE_GPIO_I2C) += i2ccmds.c
#src-$(CONFIG_HAVE_GPIO_HARD_PWM) += pwmcmds.c
#src-$(CONFIG_WANT_GPIO_BITBANGING) += buttons.c tmcuart.c neopixel.c \
pulse_counter.c
#src-$(CONFIG_WANT_DISPLAYS) += lcd_st7920.c lcd_hd44780.c
#src-$(CONFIG_WANT_SOFTWARE_SPI) += spi_software.c
#src-$(CONFIG_WANT_SOFTWARE_I2C) += i2c_software.c
#sensors-src-$(CONFIG_HAVE_GPIO_SPI) := thermocouple.c sensor_adxl345.c \
# sensor_angle.c
#sensors-src-$(CONFIG_HAVE_GPIO_I2C) += sensor_mpu9250.c
src-$(CONFIG_WANT_SENSORS) += $(sensors-src-y)
#src-$(CONFIG_WANT_LIS2DW) += sensor_lis2dw.c
#src-$(CONFIG_WANT_LDC1612) += sensor_ldc1612.c
src-$(CONFIG_NEED_SENSOR_BULK) += sensor_bulk.c
Plus I modified this section of /src/avr/Makefile
# Add avr source files
src-y += avr/main.c avr/timer.c
src-$(CONFIG_HAVE_GPIO) += avr/gpio.c
#src-$(CONFIG_HAVE_GPIO_ADC) += avr/adc.c
#src-$(CONFIG_HAVE_GPIO_SPI) += avr/spi.c
#src-$(CONFIG_HAVE_GPIO_I2C) += avr/i2c.c
#src-$(CONFIG_HAVE_GPIO_HARD_PWM) += avr/hard_pwm.c
src-$(CONFIG_AVR_WATCHDOG) += avr/watchdog.c
src-$(CONFIG_USBSERIAL) += avr/usbserial.c generic/usb_cdc.c
src-$(CONFIG_SERIAL) += avr/serial.c generic/serial_irq.c
maybe some combination of removing endstop, debugcmds, stepper, trsync ... there might be something to get under that 27K limit ...
My hope was actually to find a configuration to get below 10K and control just two stepper driver or just one heater+thermistor, that would be perfect for my goal of a CH32V003 (0.30$ 48MHZ risc MCU with 16K) plus a W5500 ethernet driving only steppers or heater. but it might not possible at all.
Many thanks to the contributors to this thread to date. Using 32bit bookworm on a Pi Zero W (not a Zero 2), I have, running Klipper installed using KIAUH, successfully compiled/linked the image for an Arduino UNO without having to revert to the buster version of the tool chain. To achieve this, did require some trial and error editing the .config file for the very simple hardware required, just 2 steppers and a servo motor, making up a drawbot. Note that the image has not been flashed to the Arduino nor tested yet. However, it has been possible at least to build the image using just the 32bit bookworm and the tool chain in that release.
Hello,
First of all, thanks for sharing. When I try to build frimware in Klipper as you show in the guide. I'm getting an error. I am using Arduino Uno + Cnc Shield as card. On the Arduino Mega processors, I do not have any compilation problems.