Part Number: AM5728
Other Parts Discussed in Thread: SYSBIOS
Tool/software: TI-RTOS
Hello,
We're working on a project that is utilizing the System DMA to manage reading data into ping pong buffers. When one buffer is full, we'd like to be able to write that data to the SD card using FATFS. The MMU is enabled with the following configuration for the System DMA for register access during runtime:
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//System DMA register ACCESS via MMU descriptor modifications
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var Mmu = xdc.useModule('ti.sysbios.family.arm.a15.Mmu');
Mmu.enableMMU = true;
// descriptor attribute structure
var peripheralAttrs1 = new Mmu.DescriptorAttrs();
Mmu.initDescAttrsMeta(peripheralAttrs1);
peripheralAttrs1.type = Mmu.DescriptorType_BLOCK; // BLOCK descriptor
peripheralAttrs1.noExecute = true; // not executable
peripheralAttrs1.accPerm = 0; // read/write at PL1
peripheralAttrs1.attrIndx = 1; // MAIR0 Byte1 describes
// memory attributes for
// each BLOCK MMU entry
// write memory region attribute in mairRegAttr[1] i.e. MAIR0 Reg Byte1
Mmu.setMAIRMeta(2, 0x0); // Mark mem regions as strongly ordered memory
// Define the base address of the 2 MB page
// the peripheral resides in.
//0x4A056000//dma_system
var peripheralBaseAddr1 = 0x4A056000;
// Configure the corresponding MMU page descriptor accordingly
Mmu.setSecondLevelDescMeta(peripheralBaseAddr1,
peripheralBaseAddr1,
peripheralAttrs1);
And our FATFS initialization:
// MMCSD function table for MMCSD implementation
FATFS_DrvFxnTable FATFS_drvFxnTable = {
MMCSD_close,
MMCSD_control,
MMCSD_init,
MMCSD_open,
MMCSD_write,
MMCSD_read
};
// FATFS configuration structure
FATFS_HwAttrs FATFS_initCfg[_VOLUMES] =
{
{
0U
},
{
1U
},
{
2U
},
{
3U
}
};
// FATFS objects
FATFS_Object FATFS_objects[_VOLUMES];
// FATFS configuration structure
const FATFS_Config FATFS_config[_VOLUMES + 1] = {
{
&FATFS_drvFxnTable,
&FATFS_objects[0],
&FATFS_initCfg[0]
},
{
&FATFS_drvFxnTable,
&FATFS_objects[1],
&FATFS_initCfg[1]
},
{
&FATFS_drvFxnTable,
&FATFS_objects[2],
&FATFS_initCfg[2]
},
{NULL, NULL, NULL},
{NULL, NULL, NULL}
};
FATFS_Handle fatfsHandle = NULL;
void initFATFS()
{
EDMA3_DRV_Result edmaResult = 0;
EDMA3_RM_Handle gEdmaHandle = NULL;
MMCSD_v1_HwAttrs hwAttrsConfig;
gEdmaHandle = (EDMA3_RM_Handle)edma3init(MMCSD_EDMACC_NUM, &edmaResult);
if(MMCSD_socGetInitCfg(0,&hwAttrsConfig)!=0) {
//MMCSD_log("\nUnable to obtain MMCSD config.Exiting. TEST FAILED.\r\n");
return;
}
hwAttrsConfig.edmaHandle = gEdmaHandle;
if(MMCSD_socSetInitCfg(0,&hwAttrsConfig)!=0) {
//MMCSD_log("\nUnable to set config.Exiting. TEST FAILED.\r\n");
return;
}
FATFS_init();
FATFS_open(0U, NULL, &fatfsHandle);
}
Writing to SD card:
while(1)
{
Semaphore_pend(sdWrite_sem_handle, BIOS_WAIT_FOREVER);
powerDown_FLAG = 0; // turn off power down for rest of fatfs writing
fr = f_stat(fileName, &fno);
while(fno.fsize > MAX_FILE_SIZE)
{
if(fr == FR_NO_FILE) break;
fileCntr++;
snprintf(fileName, sizeof(char) * 32, "%s-%i.txt", sysTimeFormatted, fileCntr); // format filename with counter
fr = f_stat(fileName, &fno);
}
fr = f_open(&fil, fileName, FA_OPEN_ALWAYS | FA_WRITE);
if (fr) return;
f_lseek(&fil, f_size(&fil));
if(buffer2Process == 1)
{
f_write(&fil, msgBuf1, sizeof(msgBuf1)-1, &bytesRead);
}
else if(buffer2Process == 2)
{
f_write(&fil, msgBuf2, sizeof(msgBuf2)-1, &bytesRead);
}
else
{
f_write(&fil, msgBuf3, sizeof(msgBuf3)-1, &bytesRead);
}
f_close(&fil); // Close the file
powerDown_FLAG = 1; // turn on power down mode
}
With this setup, as soon as it reaches the first FATFS command in the while loop, the system exits. If I remove the MMU configuration then the FATFS works properly, but our data is not collected via the system DMA. Any insights would be greatly appreciated!
Thanks,
John