Skip to content

Commit 5bc71f4

Browse files
ellenspptoal
authored andcommitted
🚑️ Prevent BFT unaligned compressed data corruption (MarlinFirmware#22134)
1 parent 5a5d31e commit 5bc71f4

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

Marlin/src/feature/binary_stream.h

+3-11
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@
2424
#include "../inc/MarlinConfig.h"
2525

2626
#define BINARY_STREAM_COMPRESSION
27-
2827
#if ENABLED(BINARY_STREAM_COMPRESSION)
2928
#include "../libs/heatshrink/heatshrink_decoder.h"
29+
// STM32 (and others?) require a word-aligned buffer for SD card transfers via DMA
30+
static __attribute__((aligned(sizeof(size_t)))) uint8_t decode_buffer[512] = {};
31+
static heatshrink_decoder hsd;
3032
#endif
3133

3234
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) {
3739
return SERIAL_IMPL.read(index);
3840
}
3941

40-
#if ENABLED(BINARY_STREAM_COMPRESSION)
41-
static heatshrink_decoder hsd;
42-
#if BOTH(ARDUINO_ARCH_STM32F1, SDIO_SUPPORT)
43-
// STM32 requires a word-aligned buffer for SD card transfers via DMA
44-
static __attribute__((aligned(sizeof(size_t)))) uint8_t decode_buffer[512] = {};
45-
#else
46-
static uint8_t decode_buffer[512] = {};
47-
#endif
48-
#endif
49-
5042
class SDFileTransferProtocol {
5143
private:
5244
struct Packet {

0 commit comments

Comments
 (0)