Skip to content

Commit 0595b87

Browse files
authored
🐛 Fix Maple / STM32 serial buffer (#22292)
1 parent 1093224 commit 0595b87

File tree

4 files changed

+11
-16
lines changed

4 files changed

+11
-16
lines changed

buildroot/share/PlatformIO/scripts/fix_framework_weakness.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,3 @@ def _touch(path):
3030
print("Done patching exception handler")
3131

3232
print("Libmaple modified and ready for post mortem debugging")
33-
34-
mf = env["MARLIN_FEATURES"]
35-
rxBuf = mf["RX_BUFFER_SIZE"] if "RX_BUFFER_SIZE" in mf else "0"
36-
txBuf = mf["TX_BUFFER_SIZE"] if "TX_BUFFER_SIZE" in mf else "0"
37-
if int(rxBuf) < 64:
38-
rxBuf = "64"
39-
if int(txBuf) < 64:
40-
txBuf = "64"
41-
42-
build_flags = env.get('BUILD_FLAGS')
43-
build_flags.append("-DUSART_RX_BUF_SIZE=" + rxBuf + " -DUSART_TX_BUF_SIZE=" + txBuf)
44-
env.Replace(BUILD_FLAGS=build_flags)

buildroot/share/PlatformIO/scripts/stm32_serialbuffer.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,16 @@
1313
#
1414
# The script will set the value as the default one (64 bytes)
1515
# or the user-configured one, whichever is higher.
16+
#
17+
# Marlin has 128 and 32 as default values for RX_BUFFER_SIZE and
18+
# TX_BUFFER_SIZE respectively. We use the highest value.
1619
mf = env["MARLIN_FEATURES"]
17-
rxBuf = str(max(64, int(mf["RX_BUFFER_SIZE"]) if "RX_BUFFER_SIZE" in mf else 0))
20+
rxBuf = str(max(128, int(mf["RX_BUFFER_SIZE"]) if "RX_BUFFER_SIZE" in mf else 0))
1821
txBuf = str(max(64, int(mf["TX_BUFFER_SIZE"]) if "TX_BUFFER_SIZE" in mf else 0))
1922

2023
build_flags = env.get('BUILD_FLAGS')
2124
build_flags.append("-DSERIAL_RX_BUFFER_SIZE=" + rxBuf)
2225
build_flags.append("-DSERIAL_TX_BUFFER_SIZE=" + txBuf)
26+
build_flags.append("-DUSART_RX_BUF_SIZE=" + rxBuf)
27+
build_flags.append("-DUSART_TX_BUF_SIZE=" + txBuf)
2328
env.Replace(BUILD_FLAGS=build_flags)

ini/stm32f1-maple.ini

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ lib_deps = ${common.lib_deps}
3636
platform_packages = tool-stm32duino
3737
extra_scripts = ${common.extra_scripts}
3838
pre:buildroot/share/PlatformIO/scripts/fix_framework_weakness.py
39+
pre:buildroot/share/PlatformIO/scripts/stm32_serialbuffer.py
3940

4041
#
4142
# STM32F103RC
@@ -325,7 +326,8 @@ lib_ignore = ${common_stm32f1.lib_ignore}
325326
platform = ${common_stm32f1.platform}
326327
extends = common_stm32f1
327328
board = marlin_CHITU_F103
328-
extra_scripts = pre:buildroot/share/PlatformIO/scripts/common-dependencies.py
329+
extra_scripts = ${common_stm32f1.extra_scripts}
330+
pre:buildroot/share/PlatformIO/scripts/common-dependencies.py
329331
pre:buildroot/share/PlatformIO/scripts/STM32F1_create_variant.py
330332
buildroot/share/PlatformIO/scripts/chitu_crypt.py
331333
build_flags = ${common_stm32f1.build_flags}

ini/stm32f1.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ board_build.variant = MARLIN_F103Rx
150150
board_build.offset = 0x7000
151151
board_upload.offset_address = 0x08007000
152152
build_unflags = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC
153-
extra_scripts = ${common.extra_scripts}
153+
extra_scripts = ${common_stm32.extra_scripts}
154154
pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
155155
pre:buildroot/share/PlatformIO/scripts/random-bin.py
156156
buildroot/share/PlatformIO/scripts/stm32_bootloader.py
@@ -174,7 +174,7 @@ board_build.variant = MARLIN_F103Rx
174174
board_build.offset = 0x7000
175175
board_upload.offset_address = 0x08007000
176176
build_unflags = ${common_stm32.build_unflags}
177-
extra_scripts = ${common.extra_scripts}
177+
extra_scripts = ${common_stm32.extra_scripts}
178178
pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
179179
buildroot/share/PlatformIO/scripts/stm32_bootloader.py
180180
debug_tool = jlink

0 commit comments

Comments
 (0)