I am working on OTA. I want to set password in OTA BIM project and oad_target.c so BIM first check that password and then upload that File(imgx.bin)
1-I used OAD_IMAGE_A_USER_ID /OAD_IMAGE_B_USER_ID For this purpose(While creating bin file for OTA) in oad_target.c
#if !defined (OAD_IMAGE_A_USER_ID)
#define OAD_IMAGE_A_USER_ID {'A', 'B', 'C', 'D'}
#endif
#if !defined (OAD_IMAGE_B_USER_ID)
#define OAD_IMAGE_B_USER_ID {'A', 'B', 'C', 'D'}
#endif
2-Then I changed in BIM to check OAD_IMAGE_A_USER_ID /OAD_IMAGE_B_USER_ID:
void main(void)
{
uint8 password[4];
uint16 crc[2];
// Check for valid password before running program.
HalFlashRead(BIM_IMG_B_PAGE, 8 , (uint8 *)password, 4);
if((password[0] == 'A') && (password[1] == 'B') &&(password[2] == 'C')&&(password[3] == 'D'))
{
// Prefer to run Image-B over Image-A so that Image-A does not have to invalidate itself.
HalFlashRead(BIM_IMG_B_PAGE, BIM_CRC_OSET, (uint8 *)crc, 4);
if ((crc[0] != 0xFFFF) && (crc[0] != 0x0000))
{
if (crc[0] == crc[1])
{
JumpToImageAorB = 1;
// Simulate a reset for the Application code by an absolute jump to the expected INTVEC addr.
asm("LJMP 0x4030");
HAL_SYSTEM_RESET(); // Should not get here.
}
crcCheck(BIM_IMG_B_PAGE, crc);
}
}
// Check for valid password before running program.
HalFlashRead(BIM_IMG_A_PAGE, 8 , (uint8 *)password, 4);
if((password[0] == 'A') && (password[1] == 'B') &&(password[2] == 'C')&&(password[3] == 'D'))
{
HalFlashRead(BIM_IMG_A_PAGE, BIM_CRC_OSET, (uint8 *)crc, 4);
if ((crc[0] != 0xFFFF) && (crc[0] != 0x0000))
{
if (crc[0] == crc[1])
{
JumpToImageAorB = 0;
// Simulate a reset for the Application code by an absolute jump to the expected INTVEC addr.
asm("LJMP 0x0830");
HAL_SYSTEM_RESET(); // Should not get here.
}
else if (crc[1] == 0xFFFF) // If first run of an image that was physically downloaded.
{
crcCheck(BIM_IMG_A_PAGE, crc);
}
}
SLEEPCMD |= 0x03; // PM3, All clock oscillators off, voltage regulator off.
halSleepExec();
HAL_SYSTEM_RESET(); // Should not get here.
}
}
Now I uploaded(OTA) a bin file with wrong OAD_IMAGE_A_USER_ID/OAD_IMAGE_B_USER_ID
#if !defined (OAD_IMAGE_A_USER_ID)
#define OAD_IMAGE_A_USER_ID {'A', 'A', 'A', 'A'}
#endif
#if !defined (OAD_IMAGE_B_USER_ID)
#define OAD_IMAGE_B_USER_ID {'B', 'B', 'B', 'B'}
#endif
And device accepted this bin file successfully..
Where I am making mistske.?
is this correct way?and correct syntax i using?
Kindly mention how can i set this password?