avr: add lgt8f328p support
The Logic Green LGT8F328P is a low-cost, high-performance alternative to the ATmega328P. Unfortunately, due to several differences in chip specifications, firmware built for the ATmega328P cannot be used directly.
The main issue in Klipper is that the baud rate is corrupted by the chip’s clock configuration, causing serial communication to fail. This change resolves the issue by adjusting the CLKPR, and furthermore allows the clock to be increased up to 32 MHz, which is supported by the LGT8F328P.
oh, I found #6918 right before and I agree to this patch is (maybe) not have much users. But i decide to request this patch because... I have this board, and need small devboard to connect some devices, and... implementation is so simple. 🤗
I add Port E and Port F for additional GPIO and ADC pins.
Is it tested and ready from your side?
yes, I tested some peripherals (250000 host serial, BTT eddy with i2c, 12bit ADC)
Thanks. Can you do something like the following to avoid having to overload CONFIG_MCU?
--- a/src/avr/Kconfig
+++ b/src/avr/Kconfig
@@ -54,6 +54,11 @@ config MCU
default "atmega1280" if MACH_atmega1280
default "atmega2560" if MACH_atmega2560
+config AVR_BUILD_MCU
+ string
+ default MCU if !MACH_lgt8f328p
+ default "atmega328p" if MACH_lgt8f328p
+
config AVRDUDE_PROTOCOL
string
default "wiring" if MACH_atmega2560
diff --git a/src/avr/Makefile b/src/avr/Makefile
index f667de3b..7cf6d68f 100644
--- a/src/avr/Makefile
+++ b/src/avr/Makefile
@@ -6,7 +6,7 @@ CROSS_PREFIX=avr-
dirs-y += src/avr src/generic
CFLAGS-$(CONFIG_HAVE_LIMITED_CODE_SIZE) += -Os
-CFLAGS += $(CFLAGS-y) -mmcu=$(CONFIG_MCU)
+CFLAGS += $(CFLAGS-y) -mmcu=$(CONFIG_AVR_BUILD_MCU)
# Add avr source files
src-y += avr/main.c avr/timer.c
-Kevin
Done!
Thanks.
-Kevin