This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi,
I made a state machine for the different acces modes, but for some reason I'm not able to write to the control status.
Returning the control status, always gives the value 2080, no matter what I write to it.
Writing to the dataFlash works perfectly, I'm able to change config A for example.
void setSecurityMode(uint8_t setState){ uint8_t data[2]= {0}; enum states{ FULL_ACCESS, UNSEALED, SEALED, }; enum states state = setState; switch(state){ case FULL_ACCESS: data[1] = 0xFF; data[0] = 0xFF; DelayMs(300); I2cWriteBuffer(&I2c, 0xAA, 0x3e, data ,2); data[1] = 0xFF; data[0] = 0xFF; DelayMs(300); I2cWriteBuffer(&I2c, 0xAA, 0x3e, data ,2); DelayMs(300); break; case UNSEALED: data[0] = 0x04; data[1] = 0x14; DelayMs(300); I2cWriteBuffer(&I2c, 0xAA, 0x3e, data ,2); data[0] = 0x36; data[1] = 0x72; DelayMs(300); I2cWriteBuffer(&I2c, 0xAA, 0x3e, data ,2); break; case SEALED: data[0] = 0x20; // First byte of SEALED sub-command (0x20) data[1] = 0x00; // Second byte of SEALED sub-command (0x00) (register address will auto-increment) I2cWriteBuffer(&I2c, 0xAA, 0x3E, data ,2); DelayMs(100); break; } }
Reading the control status:
void controlStatus() { uint8_t bufferRead[2] = {0}; uint8_t bufferWrite[2] = {0}; I2cSetAddrSize( I2C_ADDR_SIZE_8 ); I2cWriteBuffer(&I2c, 0xAA, 0x00 , bufferWrite, 2); DelayMs(100); I2cReadBuffer(&I2c,0xAA, 0x00 , bufferRead, 2); DelayMs(100); }
So I found out how to write to the control status:
uint16_t controlSubCmd(uint16_t nSubCmd) { uint16_t nResult = 0; uint16_t pData[2] = {0}; pData[0] = nSubCmd & 0xFF; pData[1] = (nSubCmd >> 8) & 0xFF; DelayMs(100); I2cWriteBuffer(&I2c, 0xAA, 0x00,(uint8_t *)pData, 2); // issue control and sub command DelayMs(100); I2cReadBuffer(&I2c, 0xAA, 0x00, (uint8_t *)pData, 2); // read data DelayMs(100); nResult = (pData[1] <<8) | pData[0]; return nResult; }
But I'm still not able to change the security mode, even with this command replaced inside the state machine...
I follow the exact same instructions as in slua790. Writing and reading via I2C is not the problem, but sealing and unsealing doesn't work.
Hi Jorg,
Unseal has to be sent back to back. If you are using the default keys please try them in little endian.
key1[0] = 0x14; key1[1] = 0x04; key2[0] = 0x72; key2[1] = 0x36; I2cWriteBuffer(&I2c, 0xAA, 0x3e,(uint8_t *)key1, 2); //step1= 0x1404 DelayMs(10); I2cWriteBuffer(&I2c, 0xAA, 0x3e,(uint8_t *)key2, 2); //step2 = 0x7236 DelayMs(100);
The keys are now in little endian order. But unfortunately it had no effect.
I used a i2c decoder to see if there is any interference or i2c code running in between the write buffers, but it seems like they send in the correct order.
Maybe by little endian you mean both keys together in little endian? Now the steps are separated from each other.
This is my scope view:
Thank you for the help!
Jorg
Hi Jorg,
You have to write 0x1404 first all at once and then 0x7236. Then follow back to back with 0xffff and 0xffff.