static void loadWatchpointTestProgram() { int i , isIdenticalProgram = 1 ; uint32_t machineCodeReadFromTarget[CODE_SIZE] ; uint32_t address = 0x08100000 ; for(i = 0 ; i <CODE_SIZE ; i++, address+=2) { memoryReadHalfword(address,&machineCodeReadFromTarget[i]); printf("Address : %x \tMachineCodeRead %x vs MachineCode %x\n",address,machineCodeReadFromTarget[i],machineCode[i]); if(machineCodeReadFromTarget[i] != machineCode[i]) { isIdenticalProgram = 0 ; break ; } } if(isIdenticalProgram == 0) { address = 0x08100000 ; printf("Flashing program\n"); for(i = 0 ; i < CODE_SIZE ; i++,address +=2) _flashWrite(address,machineCode[i],HALFWORD_SIZE); } else printf("No Flashing is required\n"); }
void test_flashWrite_should_write_data_into_specified_flash_address(void) { uint8_t data[] = {0xba, 0xba, 0xef, 0xbe}; eraseSection_ExpectAndReturn(_session, 0x8000000, 4, PROCESS_DONE); writeMemory_ExpectAndReturn(_session, data, 0x8000000, 4, TLV_WRITE_FLASH, 0); tlvService_Expect(_session); writeMemory_ExpectAndReturn(_session, data, 0x8000000, 4, TLV_WRITE_FLASH, PROCESS_DONE); int result = _flashWrite(0x8000000, data, 4); TEST_ASSERT_EQUAL(PROCESS_DONE, result); }