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