Skip to content

Conversation

@rprakas-gsc
Copy link
Contributor

@rprakas-gsc rprakas-gsc commented Oct 31, 2025

This commit updates the flash_ctrl test files to check for unlocked regions before flash operations.

@rprakas-gsc rprakas-gsc requested a review from a team as a code owner October 31, 2025 17:56
@rprakas-gsc rprakas-gsc requested review from engdoreis and removed request for a team October 31, 2025 17:56
@rprakas-gsc rprakas-gsc mentioned this pull request Nov 2, 2025
Copy link
Contributor

@AlexJones0 AlexJones0 left a comment

Choose a reason for hiding this comment

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

This PR still seems to have several instances of commented-out code and old comments. Ideally, if not needed these would be removed or if they are being kept for some purpose (i.e. to be re-introduced after a TODO is resolved) then they would be annotated with a comment as such. I haven't commented on these specifically as there are multiple occurrences.

As an aside - what is the motivation for this change? I think these should currently be correct, at least for FPGA. Is the goal to enable these tests to run in environments with more/different flash memory protection regions configured?

@rprakas-gsc
Copy link
Contributor Author

This PR still seems to have several instances of commented-out code and old comments. Ideally, if not needed these would be removed or if they are being kept for some purpose (i.e. to be re-introduced after a TODO is resolved) then they would be annotated with a comment as such. I haven't commented on these specifically as there are multiple occurrences.

As an aside - what is the motivation for this change? I think these should currently be correct, at least for FPGA. Is the goal to enable these tests to run in environments with more/different flash memory protection regions configured?

Hi Alex,
Yes , The motivation for this change, is to run these tests on Silicon (different SKUs) and FPGA. Currently in BGA74/BGA63 silicon, as you highlighted some of these flash regions are locked for read/write access - want to avoid false test failures

Copy link
Contributor

@AlexJones0 AlexJones0 left a comment

Choose a reason for hiding this comment

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

Thanks @rprakas-gsc, this is looking really good now. I've got a few more small comments that would be nice to address but I think after those this should be all good to merge.

…rite

This commit updates the flash_ctrl test files and flash_ctrl test_utils for
read/write access before flash operations.

Signed-off-by: Ramesh Prakash <[email protected]>
Copy link
Contributor

@AlexJones0 AlexJones0 left a comment

Choose a reason for hiding this comment

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

Sorry for the churn, a last couple of comments to address and then I'm happy for this to be merged.

void flash_ctrl_testutils_info_region_print(
dif_flash_ctrl_info_region_t region, dif_flash_ctrl_region_properties_t *p,
bool locked);
// #endif // OPENTITAN_SW_DEVICE_LIB_TESTING_FLASH_CTRL_TESTUTILS_H_
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you need to remove this stale comment :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed it

// Find the first unlocked flash region and use that for testing

CHECK_STATUS_OK(flash_ctrl_testutils_find_unlocked_region(
&flash, 0, kDataRegions, &flash_region_index));
Copy link
Contributor

Choose a reason for hiding this comment

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

Because of the change to use data_region <= end, I think we should be passing in:

Suggested change
&flash, 0, kDataRegions, &flash_region_index));
&flash, 0, kDataRegions - 1, &flash_region_index));

into each of these calls (repeated in several tests).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I updated all the tests (flash_ctrl_idle_low_power_test, rv_core_ibex_mem_test, flash_ctrl_ops_test, and flash_ctrl_write_clear_test.c)


kFlashTestLoc = TOP_EARLGREY_FLASH_CTRL_MEM_BASE_ADDR +
kBank1StartPageNum * kFlashBytesPerPage,
// The ROM_EXT protects itself using regions 0-1.
Copy link
Contributor

Choose a reason for hiding this comment

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

Stale comment here now that you've removed kFlashRegionNum

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed the stale comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants