Browse Source

🚑️ Prevent BFT unaligned compressed data corruption (#22134)

vanilla_fb_2.0.x
ellensp 3 years ago
committed by Scott Lahteine
parent
commit
cdd9507493
  1. 14
      Marlin/src/feature/binary_stream.h

14
Marlin/src/feature/binary_stream.h

@ -24,9 +24,11 @@
#include "../inc/MarlinConfig.h" #include "../inc/MarlinConfig.h"
#define BINARY_STREAM_COMPRESSION #define BINARY_STREAM_COMPRESSION
#if ENABLED(BINARY_STREAM_COMPRESSION) #if ENABLED(BINARY_STREAM_COMPRESSION)
#include "../libs/heatshrink/heatshrink_decoder.h" #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 #endif
inline bool bs_serial_data_available(const serial_index_t index) { 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); 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 { class SDFileTransferProtocol {
private: private:
struct Packet { struct Packet {

Loading…
Cancel
Save