Skip to content

Commit

Permalink
🐛 Fix Maple / STM32 serial buffer (#22292)
Browse files Browse the repository at this point in the history
  • Loading branch information
ldursw authored and thinkyhead committed Jul 7, 2021
1 parent cae391b commit ed14d14
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 16 deletions.
12 changes: 0 additions & 12 deletions buildroot/share/PlatformIO/scripts/fix_framework_weakness.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,3 @@ def _touch(path):
print("Done patching exception handler")

print("Libmaple modified and ready for post mortem debugging")

mf = env["MARLIN_FEATURES"]
rxBuf = mf["RX_BUFFER_SIZE"] if "RX_BUFFER_SIZE" in mf else "0"
txBuf = mf["TX_BUFFER_SIZE"] if "TX_BUFFER_SIZE" in mf else "0"
if int(rxBuf) < 64:
rxBuf = "64"
if int(txBuf) < 64:
txBuf = "64"

build_flags = env.get('BUILD_FLAGS')
build_flags.append("-DUSART_RX_BUF_SIZE=" + rxBuf + " -DUSART_TX_BUF_SIZE=" + txBuf)
env.Replace(BUILD_FLAGS=build_flags)
7 changes: 6 additions & 1 deletion buildroot/share/PlatformIO/scripts/stm32_serialbuffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,16 @@
#
# The script will set the value as the default one (64 bytes)
# or the user-configured one, whichever is higher.
#
# Marlin has 128 and 32 as default values for RX_BUFFER_SIZE and
# TX_BUFFER_SIZE respectively. We use the highest value.
mf = env["MARLIN_FEATURES"]
rxBuf = str(max(64, int(mf["RX_BUFFER_SIZE"]) if "RX_BUFFER_SIZE" in mf else 0))
rxBuf = str(max(128, int(mf["RX_BUFFER_SIZE"]) if "RX_BUFFER_SIZE" in mf else 0))
txBuf = str(max(64, int(mf["TX_BUFFER_SIZE"]) if "TX_BUFFER_SIZE" in mf else 0))

build_flags = env.get('BUILD_FLAGS')
build_flags.append("-DSERIAL_RX_BUFFER_SIZE=" + rxBuf)
build_flags.append("-DSERIAL_TX_BUFFER_SIZE=" + txBuf)
build_flags.append("-DUSART_RX_BUF_SIZE=" + rxBuf)
build_flags.append("-DUSART_TX_BUF_SIZE=" + txBuf)
env.Replace(BUILD_FLAGS=build_flags)
4 changes: 3 additions & 1 deletion ini/stm32f1-maple.ini
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ lib_deps = ${common.lib_deps}
platform_packages = tool-stm32duino
extra_scripts = ${common.extra_scripts}
pre:buildroot/share/PlatformIO/scripts/fix_framework_weakness.py
pre:buildroot/share/PlatformIO/scripts/stm32_serialbuffer.py

#
# STM32F103RC
Expand Down Expand Up @@ -325,7 +326,8 @@ lib_ignore = ${common_stm32f1.lib_ignore}
platform = ${common_stm32f1.platform}
extends = common_stm32f1
board = marlin_CHITU_F103
extra_scripts = pre:buildroot/share/PlatformIO/scripts/common-dependencies.py
extra_scripts = ${common_stm32f1.extra_scripts}
pre:buildroot/share/PlatformIO/scripts/common-dependencies.py
pre:buildroot/share/PlatformIO/scripts/STM32F1_create_variant.py
buildroot/share/PlatformIO/scripts/chitu_crypt.py
build_flags = ${common_stm32f1.build_flags}
Expand Down
4 changes: 2 additions & 2 deletions ini/stm32f1.ini
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ board_build.offset = 0x7000
board_build.ldscript = ldscript.ld
board_upload.offset_address = 0x08007000
build_unflags = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC
extra_scripts = ${common.extra_scripts}
extra_scripts = ${common_stm32.extra_scripts}
pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
pre:buildroot/share/PlatformIO/scripts/random-bin.py
buildroot/share/PlatformIO/scripts/stm32_bootloader.py
Expand All @@ -178,7 +178,7 @@ board_build.offset = 0x7000
board_build.ldscript = ldscript.ld
board_upload.offset_address = 0x08007000
build_unflags = ${common_stm32.build_unflags}
extra_scripts = ${common.extra_scripts}
extra_scripts = ${common_stm32.extra_scripts}
pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
buildroot/share/PlatformIO/scripts/stm32_bootloader.py
debug_tool = jlink
Expand Down

0 comments on commit ed14d14

Please sign in to comment.