1
NXPTM M522XX, KINETIS and i.MX RT / "Intentional Crash" hit in SD simulator?
« on: January 09, 2014, 10:53:20 PM »
I just was simulating my project, and hit this code in fnSimSD_write:
case SD_CARD_INIT:
if ((ucTxByte == 0x40) || (ucTxByte == 0x42) || (ucTxByte == 0x43) || (ucTxByte == 0x46) || (ucTxByte == 0x47) || (ucTxByte == 0x48) || (ucTxByte == 0x50) || (ucTxByte == 0x77) || (ucTxByte == 0x69) || (ucTxByte == 0x7a) || (ucTxByte == 0x58) || (ucTxByte == 0x51) || (ucTxByte == 0x49)) { // all expected commands
ucCommand = ucTxByte;
iArguments = 0;
iSD_Card_State = SD_CARD_ARGUMENTS;
break;
}
else if (ucTxByte != 0xff) { // accept idle line, which is used when poll for busy
*(unsigned char *)0 = 0; // <==== here
}
break;
This code died on the line that attempts to write 0 into the NULL address. ucTxByte is 0. It seems to be the second byte in a message from the function fnSendSD_command, with this code:
for ( ; iCommandState < 6; iCommandState++) { // command content is always 6 bytes in length
WRITE_SPI_CMD(ucCommand[iCommandState]); // send the command and arguments
WAIT_TRANSMISSON_END(); // wait until transmission complete
READ_SPI_DATA(); // read to clear the flag
} // fall through intentional after sending the command
So the call stack indicates we are on the WRITE_SPI_CMD line, and the iCommandState is 1 (ucCommand[0] is 'Q')
More in the call stack:
case _READING_MEMORY:
{
unsigned char ucResult;
while ((iActionResult = fnSendSD_command(fnCreateCommand(READ_SINGLE_BLOCK_CMD17, ulSector), &ucResult, 0)) == CARD_BUSY_WAIT) {}
if (iActionResult < 0) {
SET_SD_CS_HIGH();
iMemoryOperation &= ~_READING_MEMORY; // read operation has completed
return iActionResult;
}
In this case, ulSector is 30446.
One thing I should note is that I updated my utFat code but did not delete the simuated SDcard.bin file. Is that the problem?
-Steve
case SD_CARD_INIT:
if ((ucTxByte == 0x40) || (ucTxByte == 0x42) || (ucTxByte == 0x43) || (ucTxByte == 0x46) || (ucTxByte == 0x47) || (ucTxByte == 0x48) || (ucTxByte == 0x50) || (ucTxByte == 0x77) || (ucTxByte == 0x69) || (ucTxByte == 0x7a) || (ucTxByte == 0x58) || (ucTxByte == 0x51) || (ucTxByte == 0x49)) { // all expected commands
ucCommand = ucTxByte;
iArguments = 0;
iSD_Card_State = SD_CARD_ARGUMENTS;
break;
}
else if (ucTxByte != 0xff) { // accept idle line, which is used when poll for busy
*(unsigned char *)0 = 0; // <==== here
}
break;
This code died on the line that attempts to write 0 into the NULL address. ucTxByte is 0. It seems to be the second byte in a message from the function fnSendSD_command, with this code:
for ( ; iCommandState < 6; iCommandState++) { // command content is always 6 bytes in length
WRITE_SPI_CMD(ucCommand[iCommandState]); // send the command and arguments
WAIT_TRANSMISSON_END(); // wait until transmission complete
READ_SPI_DATA(); // read to clear the flag
} // fall through intentional after sending the command
So the call stack indicates we are on the WRITE_SPI_CMD line, and the iCommandState is 1 (ucCommand[0] is 'Q')
More in the call stack:
case _READING_MEMORY:
{
unsigned char ucResult;
while ((iActionResult = fnSendSD_command(fnCreateCommand(READ_SINGLE_BLOCK_CMD17, ulSector), &ucResult, 0)) == CARD_BUSY_WAIT) {}
if (iActionResult < 0) {
SET_SD_CS_HIGH();
iMemoryOperation &= ~_READING_MEMORY; // read operation has completed
return iActionResult;
}
In this case, ulSector is 30446.
One thing I should note is that I updated my utFat code but did not delete the simuated SDcard.bin file. Is that the problem?
-Steve