There are 2 ways to debug the SigmaStudio For SHARC schematic custom plug-in.
Reference document: AE_42_SS4G_AlgorithmDesignerGuide.pdf and AE_42_SS4G_QuickStartGuide.pdf documents available in SigmaStudio For SHARC installation folder.
The easy way is to use function pointer method, example code taken based on Scaler example provided in the AE_42_SS4G_AlgorithmDesignerGuide.pdf.
- Include the algorithm source file into the SHARC core project of target application, the function name should be other than actual BPROCESS_xxxx and INIT_xxxx function of algorithm. For example,
#pragma section("seg_swco")
void BPROCESS_Scaler_Debug(SSBlockAlgo* pBlkAlgoInfo)
{
int index, sample, gain, blockSize, repCount;
float *pInput, *pOutput;
repCount = pBlkAlgoInfo->nGrowth;
for(index = 0; index < repCount; index++)
{
blockSize = pBlkAlgoInfo->pInputs[index].pBlockProperties->nBlockSize;
gain = ((float *)pBlkAlgoInfo->pParam)[index];
pInput = pBlkAlgoInfo->pInputs[index].pSamples;
pOutput = pBlkAlgoInfo->pOutputs[index].pSamples;
for(sample = 0; sample < blockSize; sample++)
{
pOutput[sample] = pInput[sample] * gain;
}
}
}
#pragma section("seg_swco")
void INIT_Scaler_Debug (SSBlockAlgo* pBlkAlgoInfo)
{
int index, repCount;
repCount = pBlkAlgoInfo->nGrowth;
for(index = 0; index < repCount; index++)
{
((float *)pBlkAlgoInfo->pParam)[index]=0.0f;
}
}
- Compile the target application in Debug build by enabling the "Generate symbol map" file option.
- The algorithm function symbol should be available in generated map file, sometimes due to linker elimination option the algorithm functions might be removed. So please use "KEEP" command inside SHARC ldf file to retain the algorithm function and symbols. Please refer the below image,
- Compile the target application and note the pointer of both function where it mapped.
- Refer the plug-in generation procedure in "AE_42_SS4G_AlgorithmDesignerGuide.pdf" document section "SigmaStudio Plug-In Generation".
- Add source of actual BPROCESS_xxxx and INIT_xxxx algorithm function or add a .dlb with calling of algorithm function pointer which is added in target application. Please refer below code,
#include <string.h>
#include "adi_ss_extmod.h"typedef void (*pfProcessFunction)(SSBlockAlgo* pBlockAlgo);
typedef void (*pfInitFunction)(SSBlockAlgo* pBlockAlgo);void BPROCESS_Scaler(SSBlockAlgo* pBlockAlgoInfo)
{pfProcessFunction ProcessFunction=(pfProcessFunction)0x1c0db9; // Assign the function pointer of the Algorithm process function included in target application
ProcessFunction(pBlockAlgoInfo);
}void INIT_Scaler(SSBlockAlgo* pBlockAlgoInfo)
{pfInitFunction InitFunction=(pfInitFunction)0x1c0d8c; // Assign the function pointer of the Algorithm process function included in target application
InitFunction(pBlockAlgoInfo);
} - Using the above source code method create SigmaStudio for SHARC plugin.
- Add the plugin to SigmaStudio using "Tools -- Add-Ins Browser..." option.
- Create SigmaStudio schematic with the generated plug-in algorithm block.
- Run target application with setting up break point in "INIT_Scaler_Debug" and "BPROCESS_Scaler_Debug" function. "Link compile download" the schematic into the target platform by connecting USBi.
- Now the break point shall hit at the target application algorithm functions.
- Instead of function pointer we can even use extern function call as below which is the easier way, by keeping the symbols in target application using "KEEP" command as explained in above steps.
Note: If any modifications to target application, the algorithm plug-in should be regenerated with modified function pointers. Also, the ldf "RESOLVE" command can be used to fix the address of the algorithm function which is running on target application.
The 2nd debugging method is little tedious one and sometime break points won't hit properly. The workspace needs to be cleaned up and setup the debug session again to solve the break point issue.
The debugging method is already explained in section " Debugging Schematics using CCES" under "AE_42_SS4G_QuickStartGuide.pdf" document available in SigmaStudio For SHARC installation folder.