MCPcopy Create free account
hub / github.com/ArduPilot/ardupilot / test_flash

Function test_flash

Tools/AP_Bootloader/bl_protocol.cpp:408–455  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

406
407#if TEST_FLASH
408static void test_flash()
409{
410 uint32_t loop = 1;
411 bool init_done = false;
412 while (true) {
413 uint32_t addr = 0;
414 uint32_t page = 0;
415 while (true) {
416 uint32_t v[8];
417 for (uint8_t i=0; i<8; i++) {
418 v[i] = (page<<16) + loop;
419 }
420 if (flash_func_sector_size(page) == 0) {
421 continue;
422 }
423 uint32_t num_writes = flash_func_sector_size(page) / sizeof(v);
424 uprintf("page %u size %u addr=0x%08x v=0x%08x\n",
425 unsigned(page), unsigned(flash_func_sector_size(page)), unsigned(addr), unsigned(v[0])); delay(10);
426 if (init_done) {
427 for (uint32_t j=0; j<flash_func_sector_size(page)/4; j++) {
428 uint32_t v1 = (page<<16) + (loop-1);
429 uint32_t v2 = flash_func_read_word(addr+j*4);
430 if (v2 != v1) {
431 uprintf("read error at 0x%08x v=0x%08x v2=0x%08x\n", unsigned(addr+j*4), unsigned(v1), unsigned(v2));
432 break;
433 }
434 }
435 }
436 if (!flash_func_erase_sector(page)) {
437 uprintf("erase of %u failed\n", unsigned(page));
438 }
439 for (uint32_t j=0; j<num_writes; j++) {
440 if (!flash_func_write_words(addr+j*sizeof(v), v, ARRAY_SIZE(v))) {
441 uprintf("write failed at 0x%08x\n", unsigned(addr+j*sizeof(v)));
442 break;
443 }
444 }
445 addr += flash_func_sector_size(page);
446 page++;
447 if (flash_func_sector_size(page) == 0) {
448 break;
449 }
450 }
451 init_done = true;
452 delay(1000);
453 loop++;
454 }
455}
456#endif
457
458void

Callers 1

bl_protocol.cppFile · 0.85

Calls 6

flash_func_sector_sizeFunction · 0.85
uprintfFunction · 0.85
delayFunction · 0.85
flash_func_read_wordFunction · 0.85
flash_func_erase_sectorFunction · 0.85
flash_func_write_wordsFunction · 0.85

Tested by

no test coverage detected