From 921379ceb9c7a04e4f567f5acb1d2b32fb169d0d Mon Sep 17 00:00:00 2001 From: Andy Piper Date: Thu, 31 Mar 2022 21:34:33 +0100 Subject: [PATCH] AP_FlashIface: make sure XIP flash is ready before returning --- libraries/AP_FlashIface/AP_FlashIface_JEDEC.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/libraries/AP_FlashIface/AP_FlashIface_JEDEC.cpp b/libraries/AP_FlashIface/AP_FlashIface_JEDEC.cpp index 7447187928..a2a8b1bfc1 100644 --- a/libraries/AP_FlashIface/AP_FlashIface_JEDEC.cpp +++ b/libraries/AP_FlashIface/AP_FlashIface_JEDEC.cpp @@ -921,6 +921,9 @@ bool AP_FlashIface_JEDEC::start_xip_mode(void** addr) Debug("XIP mode unsupported on this chip"); return false; } + + bool success = false; + switch(_desc.entry_method) { case AP_FlashIface_JEDEC::XIP_ENTRY_METHOD_1: { @@ -937,7 +940,8 @@ bool AP_FlashIface_JEDEC::start_xip_mode(void** addr) cmd.addr = 0; cmd.dummy = _desc.fast_read_dummy_cycles; _dev->set_cmd_header(cmd); - return _dev->enter_xip_mode(addr); + success = _dev->enter_xip_mode(addr); + break; } case AP_FlashIface_JEDEC::XIP_ENTRY_METHOD_2: { @@ -965,7 +969,8 @@ bool AP_FlashIface_JEDEC::start_xip_mode(void** addr) // correct dummy bytes because of addition of alt bytes cmd.dummy = _desc.fast_read_dummy_cycles - 1; _dev->set_cmd_header(cmd); - return _dev->enter_xip_mode(addr); + success = _dev->enter_xip_mode(addr); + break; } default: { @@ -973,6 +978,9 @@ bool AP_FlashIface_JEDEC::start_xip_mode(void** addr) return false; } } + // make sure that the flash is ready once we enter XIP + DELAY_MICROS(100); + return success; } bool AP_FlashIface_JEDEC::stop_xip_mode()