Parcourir la source

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

ellensp il y a 4 ans
Parent
révision
a9eff3597d
Aucun compte lié à l'adresse e-mail de l'auteur
1 fichiers modifiés avec 3 ajouts et 11 suppressions
  1. 3
    11
      Marlin/src/feature/binary_stream.h

+ 3
- 11
Marlin/src/feature/binary_stream.h Voir le fichier

24
 #include "../inc/MarlinConfig.h"
24
 #include "../inc/MarlinConfig.h"
25
 
25
 
26
 #define BINARY_STREAM_COMPRESSION
26
 #define BINARY_STREAM_COMPRESSION
27
-
28
 #if ENABLED(BINARY_STREAM_COMPRESSION)
27
 #if ENABLED(BINARY_STREAM_COMPRESSION)
29
   #include "../libs/heatshrink/heatshrink_decoder.h"
28
   #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;
30
 #endif
32
 #endif
31
 
33
 
32
 inline bool bs_serial_data_available(const serial_index_t index) {
34
 inline bool bs_serial_data_available(const serial_index_t index) {
37
   return SERIAL_IMPL.read(index);
39
   return SERIAL_IMPL.read(index);
38
 }
40
 }
39
 
41
 
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
-
50
 class SDFileTransferProtocol  {
42
 class SDFileTransferProtocol  {
51
 private:
43
 private:
52
   struct Packet {
44
   struct Packet {

Chargement…
Annuler
Enregistrer