@@ -112,8 +112,6 @@ void test_getInfo()
112
112
113
113
TEST_ASSERT_EQUAL (0 , info.security .reserved1 );
114
114
TEST_ASSERT_EQUAL (0 , info.security .reserved2 );
115
- TEST_ASSERT_EQUAL (1 , info.erased_value );
116
- TEST_ASSERT ((info.program_cycles == ARM_STORAGE_PROGRAM_CYCLES_INFINITE) || (info.program_cycles > 0 ));
117
115
TEST_ASSERT (info.total_storage > 0 );
118
116
}
119
117
@@ -299,8 +297,15 @@ void programDataCompleteCallback(int32_t status, ARM_STORAGE_OPERATION operation
299
297
TEST_ASSERT ((operation == ARM_STORAGE_OPERATION_ERASE) || (operation == ARM_STORAGE_OPERATION_PROGRAM_DATA));
300
298
if (operation == ARM_STORAGE_OPERATION_ERASE) {
301
299
// printf("programming %u bytes at address %lu with pattern 0x%" PRIx32 "\n", sizeofData, (uint32_t)addr, BYTE_PATTERN);
302
- status = drv->ProgramData (addr, buffer, sizeofData);
303
300
301
+ size_t sizeofData = info.program_unit ;
302
+ TEST_ASSERT (BUFFER_SIZE >= sizeofData);
303
+ TEST_ASSERT ((sizeofData % sizeof (uint32_t )) == 0 );
304
+ for (size_t index = 0 ; index < sizeofData / sizeof (uint32_t ); index++) {
305
+ ((uint32_t *)buffer)[index] = BYTE_PATTERN;
306
+ }
307
+
308
+ status = drv->ProgramData (addr, buffer, sizeofData);
304
309
if (status < ARM_DRIVER_OK) {
305
310
return ; /* failure. this will trigger a timeout and cause test failure. */
306
311
}
@@ -348,13 +353,6 @@ control_t test_programDataUsingProgramUnit(const size_t call_count)
348
353
349
354
/* initialize the buffer to hold the pattern. */
350
355
ARM_STORAGE_CAPABILITIES capabilities = drv->GetCapabilities ();
351
- static const uint32_t BYTE_PATTERN = 0xAA551122 ;
352
- size_t sizeofData = info.program_unit ;
353
- TEST_ASSERT (BUFFER_SIZE >= sizeofData);
354
- TEST_ASSERT ((sizeofData % sizeof (uint32_t )) == 0 );
355
- for (size_t index = 0 ; index < sizeofData / sizeof (uint32_t ); index++) {
356
- ((uint32_t *)buffer)[index] = BYTE_PATTERN;
357
- }
358
356
359
357
/* Update the completion callback to 'programDataCompleteCallback'. */
360
358
if (call_count == 2 ) {
@@ -374,7 +372,16 @@ control_t test_programDataUsingProgramUnit(const size_t call_count)
374
372
TEST_ASSERT_EQUAL (1 , capabilities.asynchronous_ops );
375
373
return (call_count < REPEAT_INSTANCES) ? CaseTimeout (200 ) + CaseRepeatAll: CaseTimeout (200 );
376
374
} else {
377
- TEST_ASSERT (rc > 0 );
375
+ TEST_ASSERT_EQUAL (firstBlock.attributes .erase_unit , rc);
376
+ verifyBytePattern (addr, firstBlock.attributes .erase_unit , (uint8_t )0xFF );
377
+
378
+ static const uint32_t BYTE_PATTERN = 0xAA551122 ;
379
+ size_t sizeofData = info.program_unit ;
380
+ TEST_ASSERT (BUFFER_SIZE >= sizeofData);
381
+ TEST_ASSERT ((sizeofData % sizeof (uint32_t )) == 0 );
382
+ for (size_t index = 0 ; index < sizeofData / sizeof (uint32_t ); index++) {
383
+ ((uint32_t *)buffer)[index] = BYTE_PATTERN;
384
+ }
378
385
379
386
/* program the sector at addr */
380
387
// printf("programming %u bytes at address %lu with pattern 0x%" PRIx32 "\n", sizeofData, (uint32_t)addr, BYTE_PATTERN);
@@ -416,8 +423,11 @@ void programDataOptimalCompleteCallback(int32_t status, ARM_STORAGE_OPERATION op
416
423
#ifndef __CC_ARM
417
424
printf (" programming %u bytes at address %lu with pattern 0x%x\n " , sizeofData, (uint32_t )addr, BYTE_PATTERN);
418
425
#endif
419
- status = drv->ProgramData (addr, buffer, sizeofData);
426
+ size_t sizeofData = info.optimal_program_unit ;
427
+ TEST_ASSERT (BUFFER_SIZE >= sizeofData);
428
+ memset (buffer, BYTE_PATTERN, sizeofData);
420
429
430
+ status = drv->ProgramData (addr, buffer, sizeofData);
421
431
if (status < ARM_DRIVER_OK) {
422
432
return ; /* failure. this will trigger a timeout and cause test failure. */
423
433
}
@@ -465,10 +475,6 @@ control_t test_programDataUsingOptimalProgramUnit(const size_t call_count)
465
475
466
476
/* initialize the buffer to hold the pattern. */
467
477
ARM_STORAGE_CAPABILITIES capabilities = drv->GetCapabilities ();
468
- static const uint8_t BYTE_PATTERN = 0xAA ;
469
- size_t sizeofData = info.optimal_program_unit ;
470
- TEST_ASSERT (BUFFER_SIZE >= sizeofData);
471
- memset (buffer, BYTE_PATTERN, sizeofData);
472
478
473
479
/* Update the completion callback to 'programDataCompleteCallback'. */
474
480
if (call_count == 2 ) {
@@ -491,14 +497,19 @@ control_t test_programDataUsingOptimalProgramUnit(const size_t call_count)
491
497
TEST_ASSERT_EQUAL (firstBlock.attributes .erase_unit , rc);
492
498
verifyBytePattern (addr, firstBlock.attributes .erase_unit , (uint8_t )0xFF );
493
499
500
+ static const uint8_t BYTE_PATTERN = 0xAA ;
501
+ size_t sizeofData = info.optimal_program_unit ;
502
+ TEST_ASSERT (BUFFER_SIZE >= sizeofData);
503
+ memset (buffer, BYTE_PATTERN, sizeofData);
504
+
494
505
/* program the sector at addr */
495
506
printf (" programming %u bytes at address %lu with pattern 0x%x\n " , sizeofData, (uint32_t )addr, BYTE_PATTERN);
496
507
rc = drv->ProgramData ((uint32_t )addr, buffer, sizeofData);
497
508
if (rc == ARM_DRIVER_OK) {
498
509
TEST_ASSERT_EQUAL (1 , capabilities.asynchronous_ops );
499
510
return (call_count < REPEAT_INSTANCES) ? CaseTimeout (200 ) + CaseRepeatAll: CaseTimeout (200 );
500
511
} else {
501
- TEST_ASSERT (rc > 0 );
512
+ TEST_ASSERT_EQUAL (sizeofData, rc );
502
513
503
514
printf (" verifying programmed sector at addr %lu\n " , (uint32_t )addr);
504
515
verifyBytePattern (addr, sizeofData, BYTE_PATTERN);
@@ -858,6 +869,11 @@ control_t test_programDataWithMultipleProgramUnits(const size_t call_count)
858
869
return CaseNext; /* first block isn't large enough for the intended operation */
859
870
}
860
871
872
+ if (rangeNeededForTest > BUFFER_SIZE) {
873
+ printf (" buffer (%u) not large enough; rangeNeededForTest: %u\n " , BUFFER_SIZE, rangeNeededForTest);
874
+ return CaseNext;
875
+ }
876
+
861
877
// printf("erasing %u bytes at addr %lu\n", rangeNeededForTest, (uint32_t)firstBlock.addr);
862
878
rc = drv->Erase (firstBlock.addr , rangeNeededForTest);
863
879
TEST_ASSERT (rc >= 0 );
@@ -867,8 +883,6 @@ control_t test_programDataWithMultipleProgramUnits(const size_t call_count)
867
883
} else {
868
884
TEST_ASSERT_EQUAL (rangeNeededForTest, rc);
869
885
870
- TEST_ASSERT ((N_UNITS * info.program_unit ) <= BUFFER_SIZE);
871
-
872
886
/* setup byte pattern in buffer */
873
887
static const uint32_t BYTE_PATTERN = 0xABCDEF00 ;
874
888
if (info.program_unit >= sizeof (BYTE_PATTERN)) {
0 commit comments