From cdd95074935074c4afa1f467ef16c9e9c0325bfa Mon Sep 17 00:00:00 2001 From: ellensp Date: Tue, 15 Jun 2021 09:43:50 +1200 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=91=EF=B8=8F=20Prevent=20BFT=20unalign?= =?UTF-8?q?ed=20compressed=20data=20corruption=20(#22134)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/feature/binary_stream.h | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/Marlin/src/feature/binary_stream.h b/Marlin/src/feature/binary_stream.h index 9eb151b27..2ad7f236a 100644 --- a/Marlin/src/feature/binary_stream.h +++ b/Marlin/src/feature/binary_stream.h @@ -24,9 +24,11 @@ #include "../inc/MarlinConfig.h" #define BINARY_STREAM_COMPRESSION - #if ENABLED(BINARY_STREAM_COMPRESSION) #include "../libs/heatshrink/heatshrink_decoder.h" + // STM32 (and others?) require a word-aligned buffer for SD card transfers via DMA + static __attribute__((aligned(sizeof(size_t)))) uint8_t decode_buffer[512] = {}; + static heatshrink_decoder hsd; #endif inline bool bs_serial_data_available(const serial_index_t index) { @@ -37,16 +39,6 @@ inline int bs_read_serial(const serial_index_t index) { return SERIAL_IMPL.read(index); } -#if ENABLED(BINARY_STREAM_COMPRESSION) - static heatshrink_decoder hsd; - #if BOTH(ARDUINO_ARCH_STM32F1, SDIO_SUPPORT) - // STM32 requires a word-aligned buffer for SD card transfers via DMA - static __attribute__((aligned(sizeof(size_t)))) uint8_t decode_buffer[512] = {}; - #else - static uint8_t decode_buffer[512] = {}; - #endif -#endif - class SDFileTransferProtocol { private: struct Packet {