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