Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement/add support for 32 kb mcu #390

Merged
merged 3 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions roles/install_klipper/files/enable-i2c.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
diff --git a/src/stm32/Kconfig b/src/stm32/Kconfig
index e3961176..66363170 100644
--- a/src/stm32/Kconfig
+++ b/src/stm32/Kconfig
@@ -7,7 +7,7 @@ config STM32_SELECT
default y
select HAVE_GPIO
select HAVE_GPIO_ADC
- select HAVE_GPIO_I2C if !MACH_STM32F031
+ select HAVE_GPIO_I2C
select HAVE_GPIO_SPI if !MACH_STM32F031
select HAVE_GPIO_SDIO if MACH_STM32F4
select HAVE_GPIO_HARD_PWM if MACH_STM32F1 || MACH_STM32F4 || MACH_STM32F7 || MACH_STM32G0 || MACH_STM32H7
@@ -206,7 +206,7 @@ config CLOCK_FREQ

config FLASH_SIZE
hex
- default 0x4000 if MACH_STM32F031
+ default 0x8000 if MACH_STM32F031
default 0x8000 if MACH_STM32F042
default 0x20000 if MACH_STM32F070 || MACH_STM32F072
default 0x10000 if MACH_STM32F103 || MACH_STM32L412 # Flash size of stm32f103x8 (64KiB)
diff --git a/src/stm32/stm32f0_i2c.c b/src/stm32/stm32f0_i2c.c
index e9cadccb..0157bd32 100644
--- a/src/stm32/stm32f0_i2c.c
+++ b/src/stm32/stm32f0_i2c.c
@@ -22,6 +22,8 @@ struct i2c_info {
DECL_CONSTANT_STR("BUS_PINS_i2c1_PF1_PF0", "PF1,PF0");
DECL_ENUMERATION("i2c_bus", "i2c1_PB8_PB9", 2);
DECL_CONSTANT_STR("BUS_PINS_i2c1_PB8_PB9", "PB8,PB9");
+ DECL_ENUMERATION("i2c_bus", "i2c1_PB7_PB8", 3);
+ DECL_CONSTANT_STR("BUS_PINS_i2c1_PB7_PB8", "PB7,PB8");
// Deprecated "i2c1a" style mappings
DECL_ENUMERATION("i2c_bus", "i2c1", 0);
DECL_CONSTANT_STR("BUS_PINS_i2c1", "PB6,PB7");
@@ -89,6 +91,7 @@ static const struct i2c_info i2c_bus[] = {
{ I2C1, GPIO('B', 6), GPIO('B', 7), GPIO_FUNCTION(1) },
{ I2C1, GPIO('F', 1), GPIO('F', 0), GPIO_FUNCTION(1) },
{ I2C1, GPIO('B', 8), GPIO('B', 9), GPIO_FUNCTION(1) },
+ { I2C1, GPIO('B', 7), GPIO('B', 8), GPIO_FUNCTION(1) },
#elif CONFIG_MACH_STM32F7
{ I2C1, GPIO('B', 6), GPIO('B', 7), GPIO_FUNCTION(1) },
#elif CONFIG_MACH_STM32G0
3 changes: 3 additions & 0 deletions roles/install_klipper/files/flash-stm32
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ REVISION=`cat "$CONFIG" | jq -r ".Revision" | tr '[:upper:]' '[:lower:]'`
FLASH_DEVICE=/dev/ttyS2

STM32_BINARY=/opt/firmware/stm32.bin
if [ "$REVISION" == "a7" ] ; then
STM32_BINARY=/opt/firmware/stm32-32KB.bin
fi

systemctl stop klipper

Expand Down
10 changes: 10 additions & 0 deletions roles/install_klipper/files/stm32f031-32KB-serial.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Base config file for STM32F031 boards with serial on PA14/PA15
CONFIG_MACH_STM32=y
CONFIG_MACH_STM32F031=y
CONFIG_SERIAL=y
CONFIG_STM32_FLASH_START_0000=y
CONFIG_STM32_SERIAL_USART2_ALT_PA15_PA14=y
CONFIG_STM32_CLOCK_REF_INTERNAL=y
CONFIG_LOW_LEVEL_OPTIONS=y
CONFIG_WANT_GPIO_BITBANGING=y
CONFIG_WANT_DISPLAYS=n
43 changes: 43 additions & 0 deletions roles/install_klipper/tasks/recore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,49 @@
remote_src: yes
force: no

- name: Recore - Copy patch
copy:
src: "{{ role_path }}/files/enable-i2c.patch"
dest: "{{ klipper_home }}"
owner: debian
group: debian

- name: Recore - Increase flash size and add i2c
shell: |
patch -p1 < enable-i2c.patch
args:
chdir: "{{ klipper_home }}"

- name: Recore - Copy STM32 config with 32 KB flash
copy:
src: "{{ role_path }}/files/stm32f031-32KB-serial.config"
dest: "{{ klipper_home }}/.config"
owner: debian
group: debian

- name: Recore - Compile STM32 binary with 32 KB flash
shell: |
make clean
make olddefconfig
make -j
args:
chdir: "{{ klipper_home }}"

- name: Recore - Copy STM32 binary with 32 KB flash
copy:
src: "{{ klipper_home }}/out/klipper.bin"
dest: /opt/firmware/stm32-32KB.bin
owner: debian
group: debian
remote_src: yes
force: no

- name: Recore - reset folder
shell: |
git reset --hard
args:
chdir: "{{ klipper_home }}"

- name: Recore - Install stm32 flasher script
copy:
src: "{{ role_path }}/files/flash-stm32"
Expand Down
Loading