Tool/software:
I am adding custom processing to the AWR2944EVM's DDM demo. Ultimately an STFT (Short Time FFT) for classification data is to be added, but for starters I write in objectdetection.c a single byte to memory and try to transport it up to the PC via UART.
The transport up the DPM to dss_main.c is successful as I have observed in the debugger and test_printed in debug mode. But after writing my data to the shared memory in dss_main.c when I try to read these data in mss_main.c it fails with the following error (note both dss and mss test print 83 which is what I write to memory in objectdetection.c - 83 in ASCI is 'S' just like STFT):
Starting Sensor (issuing MMWave_start)
[C66xx_DSP] DEBUG: STFT payload[0] on DSS = 0x53 (83)
[Cortex_R5_0] DEBUG: STFT payload[0] on MSS = 0x53 (83)
[C66xx_DSP] DEBUG: STFT payload[0] on DSS = 0x53 (83)
[Cortex_R5_0] DEBUG: STFT payload[0] on MSS = 0x53 (83)
UART processing not completed: numObjOut 37 Time 207
ASSERT: 20.910911s: ../mss/mss_main.c:MmwDemo_DPC_ObjectDetection_reportFxn:2738: 0 failed !!!
Line 2738 is the else statement which is executed if this is false: gMmwMssMCB.stats.isLastFrameDataProcessed this suggests to me that something is wrong with synchronization of the messages or perhaps the reading of my data, though interestingly both the MSS and DSS see my written data properly.
So I am asking myself the following and it would be great if you could help me with the these questions:
- What is the proper way for copying the DPM results into the shared HSRAM am I missing something, like a cache invalidation etc. in my sketch?
- What is the proper way of reading these data on the MSS side?
- I understand that the payload "object" within MmWDemo_HSRAM struct is used by the default demo. What method do you recommend to transport custom data up to the MSS?
All help is appreciated,
Regards
Mark
To give you more context the modification that I have made are as follows:
- On the MSS side the only modification that I have added is in MmwDemo_transmitProcessedOutput, when this is commented out the demo works:
////////////////////////////////////////////////////////////////////////
/////////////////////// STFT data translation //////////////////////////
////////////////////////////////////////////////////////////////////////
stftBusPtr = gMmwMssMCB.ptrResult.ptrBuffer[2];
if(stftBusPtr != NULL)
{
//stftSize = gMmwMssMCB.ptrResult.size[2];
stftLocalPtr = (uint8_t *) AddrTranslateP_getLocalAddr((uint32_t) stftBusPtr);
//Test print what we have read and check if it is hex=0x53 and decimal=83
uint8_t firstByte = stftLocalPtr[0];
test_print("DEBUG: STFT payload[0] on MSS = 0x%02X (%u), Length = %u bytes\n", firstByte, firstByte, tl[tlvIdx].length);
}
///////////////////////// End of data translation //////////////////////
- On the dss side I have added a custom function and made modifications to the dpmTask:
static int32_t MmwDemo_copySTFTToHSRAM(MmwDemo_HSRAM *ptrHsramBuffer, const void *buf, uint32_t numBytes)
{
uint8_t *ptrCurr;
uint32_t freeBytes;
if ((ptrHsramBuffer == NULL) || (buf == NULL))
{
return -1;
}
//ptrCurr is where in the HSRAM we will write to,
//payload is an unused slot within MmwDemo_HSRAM struct designed for additional data
ptrCurr = ptrHsramBuffer->payload;
freeBytes = MMWDEMO_HSRAM_PAYLOAD_SIZE;
if (numBytes > freeBytes)
{
return -1;
}
// Copy STFT data into the very start of payload[]
memcpy(ptrCurr, buf, numBytes);
// return how many bytes remain free
return (int32_t)(freeBytes - numBytes);
}
Within the dpmTask
if ((retVal = MmwDemo_copyResultToHSRAM(&gHSRAM, result, &gMmwDssMCB.dataPathObj.subFrameStats[result->subFrameIdx])) >= 0)
{
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////// Write STFT results to shared HSRAM ////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Copy STFT results to HSRAM
retVal = MmwDemo_copySTFTToHSRAM(&gHSRAM, resultBuffer.ptrBuffer[2], resultBuffer.size[2]);
gHSRAM.outStats.interFrameProcessingMargin -= ((CycleCounterP_getCount32() - startTime)/DSP_CLOCK_MHZ);
if (retVal < 0)
{
test_print("Error: STFT -> HSRAM failed [Error: %d]\n", retVal);
MmwDemo_debugAssert(0);
}
uint8_t first = ((uint8_t*)gHSRAM.payload)[0];
test_print("DEBUG: STFT payload[0] on DSS = 0x%02X (%u)\n", first, first);
//Reassign DPM slot 2 to the new address of the STFT payload in HSRAM,
//The size is as it was, thus there is no need to update it (just as in the original code above)
resultBuffer.ptrBuffer[2] = (uint8_t *)&gHSRAM.payload;
//End of modification: Send all three buffers, this stays as it was
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Update DPM buffer
resultBuffer.ptrBuffer[0] = (uint8_t *)&gHSRAM.result;
resultBuffer.ptrBuffer[1] = (uint8_t *)&gHSRAM.outStats;
resultBuffer.size[1] = sizeof(MmwDemo_output_message_stats);
/* YES: Results are available send them. */
retVal = DPM_sendResult (gMmwDssMCB.dataPathObj.objDetDpmHandle, true, &resultBuffer);
if (retVal < 0)
{
test_print ("Error: Failed to send results [Error: %d] to remote\n", retVal);
}
}