Skip to content
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

Check rows before running hello_otp example #555

Merged
merged 1 commit into from
Sep 27, 2024
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
19 changes: 19 additions & 0 deletions otp/hello_otp/hello_otp.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,25 @@ int main() {
// Row to write raw data
uint16_t raw_row = 0x410;

// Check rows are empty - else the rest of the tests won't behave as expected
unsigned char initial_data[32] = {0};
cmd.flags = ecc_row;
ret = rom_func_otp_access(initial_data, sizeof(initial_data)/2, cmd);
if (ret) {
printf("ERROR: Initial ECC Row Read failed with error %d\n", ret);
}
cmd.flags = raw_row;
ret = rom_func_otp_access(initial_data+(sizeof(initial_data)/2), sizeof(initial_data)/2, cmd);
if (ret) {
printf("ERROR: Initial Raw Row Read failed with error %d\n", ret);
}
for (int i=0; i < sizeof(initial_data); i++) {
if (initial_data[i] != 0) {
printf("ERROR: This example requires empty OTP rows to run - change the ecc_row and raw_row variables to an empty row and recompile\n");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nitpick: I wonder if "to an empty row" should have been "to empty rows", in case people misinterpret "change the ecc_row and raw_row variables to an empty row" to mean "set them to the same empty row"?

return 0;
}
}

if (ecc_row) {
// Write an ECC value to OTP - the buffer must have a multiple of 2 length for ECC data
unsigned char ecc_write_data[16] = "Hello from OTP";
Expand Down
Loading