Skip to content

Commit 0b0af7b

Browse files
nordic-seglnordic-piks
authored andcommitted
tests: benchmarks: current_consumption: rram_write: Fix address check
Test writes data to the TEST_AREA in chunks of BUF_SIZE bytes. Currently, test checks whether the beginning of the chunk is within the TEST_AREA. This does not guarantee that the last chunk fits completely. Fix address checking. Check whether the entire chunk fits within the TEST_AREA. Signed-off-by: Sebastian Głąb <[email protected]>
1 parent 59e2b14 commit 0b0af7b

File tree

1 file changed

+3
-2
lines changed
  • tests/benchmarks/current_consumption/rram_write/src

1 file changed

+3
-2
lines changed

tests/benchmarks/current_consumption/rram_write/src/main.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#if DT_FIXED_PARTITION_EXISTS(DT_NODELABEL(TEST_AREA))
2121
#define TEST_AREA_OFFSET DT_REG_ADDR(DT_NODELABEL(TEST_AREA))
2222
#define TEST_AREA_SIZE DT_REG_SIZE(DT_NODELABEL(TEST_AREA))
23+
#define TEST_AREA_END (TEST_AREA_OFFSET + TEST_AREA_SIZE)
2324
#define TEST_AREA_DEVICE DEVICE_DT_GET(DT_MTD_FROM_FIXED_PARTITION(DT_NODELABEL(TEST_AREA)))
2425
#else
2526
#error "Unsupported configuration"
@@ -60,7 +61,7 @@ void write_to_test_area(void)
6061
gpio_pin_set_dt(&led, 1);
6162
start = k_uptime_get();
6263
for (uint32_t write_offset = TEST_AREA_OFFSET;
63-
write_offset < TEST_AREA_OFFSET + TEST_AREA_SIZE;
64+
write_offset + BUF_SIZE < TEST_AREA_END;
6465
write_offset += BUF_SIZE) {
6566

6667
rc = flash_write(flash_dev, write_offset, data, BUF_SIZE);
@@ -77,7 +78,7 @@ void read_and_verify_test_area(void)
7778
int rc;
7879

7980
for (uint32_t read_offset = TEST_AREA_OFFSET;
80-
read_offset < TEST_AREA_OFFSET + TEST_AREA_SIZE;
81+
read_offset + BUF_SIZE < TEST_AREA_END;
8182
read_offset += BUF_SIZE) {
8283

8384
rc = flash_read(flash_dev, read_offset, read_buf, BUF_SIZE);

0 commit comments

Comments
 (0)