Part Number: MSP432P401R
Hi folks,
I have hit a wall, and need some help. I am using the MSP432P401R with the IAR ARM Cortex-M tools.
I have an image for a SPI Flash, which is 256KB in size. We have reserved the last sector of 4KB for some modifiable calibration parameters, so I have located the CRC32 just before that sector, at locations 0x3FFFC-0x3FFFF. I am trying to calculate the CRC32 over the remaining space, i.e. from 0x00000 to 0x3FFFB.
Here is the command line I use to try to do this in IAR using ielftool:
ielftool --verbose --fill=0x00;0x00000000-0x0003EFFF --checksum=g_CRC32:4,crc32:i,0xFFFFFFFF;0x00000000-0x0003EFFB SPI_Flash.out SPI_Flash.out
ielftool --verbose --bin SPI_Flash.out SPI_Flash.bin
After doing this, I end up with 0x12 0x6D 0x8F 0x22 in the locations 0x3EFFC thru 0x3EFFF, respectively, which is where g_CRC32 is located. If read as a little-endian value, this would be 0x228F6D12. So far so good, and I can read that back in from the SPI Flash without problems.
The difficulty comes when I try to use the CRC32 module in DriverLib. My code does the following (which was borrowed from an example from DriverLib on using the CRC32 module:
MAP_CRC32_setSeed(0xFFFFFFFF, CRC32_MODE); uint8_t spiBuffer[1024]; // Read a page at a time uint32_t addr = 0u; size_t nBytes = 0x3FFFC; // Read all bytes up to stored CRC size_t bytesToRead; // Read a buffer at a time until all bytes have been added to the CRC32 while (nBytes != 0) { if (nBytes >= sizeof(spiBuffer)) { bytesToRead = sizeof(spiBuffer); } else { bytesToRead = nBytes; } Read(addr, spiBuffer, bytesToRead); // Add all of the bytes to the CRC32 calculation for (size_t i = 0; i < bytesToRead; i++) { MAP_CRC32_set8BitData(spiBuffer[i], CRC32_MODE); } addr += bytesToRead; nBytes -= bytesToRead; } // Getting the result back from the hardware module uint32_t hwCalculatedCRC = MAP_CRC32_getResultReversed(CRC32_MODE) ^ 0xFFFFFFFF; return hwCalculatedCRC;
Unfortunately, the value of hwCalculatedCRC is 0x529961DC, which isn't even close to what ielftool generated.
There are many options for configuring ielftool, as well as options for configuring the CRC32 module in DriverLib. I tried to make sure the seed value was consistent, set to 0xFFFFFFFF.
I confess that I'm at a loss, and hoping someone in the forum has gone thru similar pain, perhaps using ielftool to calculate a CRC32 for an executable image on an MSP432, and then using the CRC32 module and DriverLib to calculate a matching CRC32.
I have attached the .out and .bin files that I've been working with, and I'm willing to try any reasonable experiments to get this to work. Not only do I need to get it working for this SPI Flash, but I will need to perform a similar CRC32 check of my executable's image on the MSP432.
Thanks very much for any help, and please let me know if I can clarify in any way.
ScottSPI_Flash.zip