@@ -45,14 +45,13 @@ void flash_init(void) {
45
45
__attribute__((section (".ram_functions" ))) status_t flash_erase_block (uint32_t erase_addr ) {
46
46
status_t status = kStatus_Fail ;
47
47
48
- SCB_CleanInvalidateDCache ();
49
- SCB_DisableDCache ();
50
48
__disable_irq ();
49
+ SCB_DisableDCache ();
51
50
52
51
status = flexspi_nor_flash_erase_block (BOARD_FLEX_SPI , erase_addr );
53
52
54
- __enable_irq ();
55
53
SCB_EnableDCache ();
54
+ __enable_irq ();
56
55
57
56
return status ;
58
57
}
@@ -62,14 +61,13 @@ __attribute__((section(".ram_functions"))) status_t flash_erase_block(uint32_t e
62
61
__attribute__((section (".ram_functions" ))) status_t flash_erase_sector (uint32_t erase_addr ) {
63
62
status_t status = kStatus_Fail ;
64
63
65
- SCB_CleanInvalidateDCache ();
66
- SCB_DisableDCache ();
67
64
__disable_irq ();
65
+ SCB_DisableDCache ();
68
66
69
67
status = flexspi_nor_flash_erase_sector (BOARD_FLEX_SPI , erase_addr );
70
68
71
- __enable_irq ();
72
69
SCB_EnableDCache ();
70
+ __enable_irq ();
73
71
74
72
return status ;
75
73
}
@@ -86,8 +84,6 @@ __attribute__((section(".ram_functions"))) status_t flash_write_block(uint32_t d
86
84
status = kStatus_Success ; // Nothing to do
87
85
} else {
88
86
89
- SCB_CleanInvalidateDCache ();
90
- SCB_DisableDCache ();
91
87
92
88
// write data in chunks not crossing a page boundary
93
89
do {
@@ -98,7 +94,11 @@ __attribute__((section(".ram_functions"))) status_t flash_write_block(uint32_t d
98
94
}
99
95
100
96
__disable_irq ();
97
+ SCB_DisableDCache ();
98
+
101
99
status = flexspi_nor_flash_page_program (BOARD_FLEX_SPI , dest_addr , (uint32_t * )src , write_length );
100
+
101
+ SCB_EnableDCache ();
102
102
__enable_irq ();
103
103
104
104
// Update remaining data length
@@ -109,7 +109,6 @@ __attribute__((section(".ram_functions"))) status_t flash_write_block(uint32_t d
109
109
dest_addr += write_length ;
110
110
} while ((length > 0 ) && (status == kStatus_Success ));
111
111
112
- SCB_EnableDCache ();
113
112
114
113
}
115
114
return status ;
0 commit comments