@@ -80,7 +80,9 @@ bool Flash_If_Init_requested = false;
8080void init_Memories () {
8181 flash.init ();
8282 qspi_flash->init ();
83- dfu_secondary_bd->init ();
83+ if (dfu_secondary_bd != nullptr ) {
84+ dfu_secondary_bd->init ();
85+ }
8486 snprintf (BOOTLOADER_DESC_STR, sizeof (BOOTLOADER_DESC_STR), " @MCUBoot version %d /0x00000000/0*4Kg" , BOOTLOADER_VERSION);
8587}
8688
@@ -107,8 +109,10 @@ uint16_t Flash_If_Init(void)
107109uint16_t Flash_If_DeInit (void )
108110{
109111 flash.deinit ();
110- dfu_secondary_bd->deinit ();
111- boot_set_pending (false );
112+ if (dfu_secondary_bd != nullptr ) {
113+ dfu_secondary_bd->deinit ();
114+ boot_set_pending (false );
115+ }
112116 return 0 ;
113117}
114118
@@ -127,7 +131,9 @@ static bool isFileBlockFlash(uint32_t Add) {
127131 */
128132uint16_t Flash_If_Erase (uint32_t Add)
129133{
130- if (isFileBlockFlash (Add)) {
134+ if (isFileBlockFlash (Add) && dfu_secondary_bd == nullptr ) {
135+ return -1 ;
136+ } else if (isFileBlockFlash (Add) && dfu_secondary_bd != nullptr ) {
131137 Add -= FILEBLOCK_BASE_ADDRESS;
132138 return dfu_secondary_bd->erase (Add, dfu_secondary_bd->get_erase_size (Add));
133139 } else if (isExternalFlash (Add)) {
@@ -159,7 +165,9 @@ void delayed_write(struct writeInfo* info) {
159165 */
160166uint16_t Flash_If_Write (uint8_t * src, uint8_t * dest, uint32_t Len)
161167{
162- if (isFileBlockFlash ((uint32_t )dest)) {
168+ if (isFileBlockFlash ((uint32_t )dest) && dfu_secondary_bd == nullptr ) {
169+ return -1 ;
170+ } else if (isFileBlockFlash ((uint32_t )dest) && dfu_secondary_bd != nullptr ) {
163171 dest -= FILEBLOCK_BASE_ADDRESS;
164172 if (Len < dfu_secondary_bd->get_erase_size (0 )) {
165173 uint8_t * srcCopy = (uint8_t *)malloc (dfu_secondary_bd->get_erase_size (0 ));
@@ -198,7 +206,9 @@ uint8_t *Flash_If_Read(uint8_t * src, uint8_t * dest, uint32_t Len)
198206 uint32_t i = 0 ;
199207 uint8_t *psrc = src;
200208
201- if (isFileBlockFlash ((uint32_t )src)) {
209+ if (isFileBlockFlash ((uint32_t )src) && dfu_secondary_bd == nullptr ) {
210+ Len = 0 ;
211+ } else if (isFileBlockFlash ((uint32_t )src) && dfu_secondary_bd != nullptr ) {
202212 src -= FILEBLOCK_BASE_ADDRESS;
203213 dfu_secondary_bd->read (dest, (uint32_t )src, Len);
204214 } else if (isExternalFlash ((uint32_t )src)) {
0 commit comments