Skip to content

SecureQSPIFBlockDevice: deinit after reading info #568

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions variants/PORTENTA_H7_M7/variant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,18 +254,20 @@ class SecureQSPIFBlockDevice: public QSPIFBlockDevice {
static uint8_t *_boardInfo = (uint8_t*)(0x801F000);
static bool has_otp_info = false;

static SecureQSPIFBlockDevice secure_root;

// 8Kbit secure OTP area (on MX25L12833F)
bool getSecureFlashData() {
static SecureQSPIFBlockDevice root;
static PortentaBoardInfo* info = new PortentaBoardInfo();
root.init();
auto ret = root.readSecure(info, 0, sizeof(PortentaBoardInfo));
secure_root.init();
auto ret = secure_root.readSecure(info, 0, sizeof(PortentaBoardInfo));
if (info->magic == OTP_QSPI_MAGIC) {
_boardInfo = (uint8_t*)info;
has_otp_info = true;
} else {
delete info;
}
secure_root.deinit();
return ret == 0;
}

Expand Down