Hi Giovanni,
I have added the
sdiotest part of an example to my project. I have checked that the reading operations are working. However, the same does not apply to write operations.
In the code, when it is executed the following, the thread falls asleep waiting for the writing operation (
f_write() function) to be completed.
Code: Select all
chprintf(chp, "Write some data in it (wait ~1min)... ");
chThdSleepMilliseconds(100);
//timemeasurement
uint32_t cnt = chVTGetSystemTime();
for (uint32_t i = 0; i < 10000; i++) {
err = f_write(&FileObject, teststring, sizeof(teststring),
(void*)&bytes_written);
if (err != FR_OK) {
kernel_panic(chp, fresult_to_str(err));
}
}
In the
sdc_lld_wait_transaction_end() function, the
sdcp->sdmmc->MASK field is not equal to 0 and the thread is sent to sleep.
Code: Select all
**
* @brief Wait end of data transaction and performs finalizations.
*
* @param[in] sdcp pointer to the @p SDCDriver object
* @param[in] n number of blocks in transaction
* @param[in] resp pointer to the response buffer
*
* @return The operation status.
* @retval HAL_SUCCESS operation succeeded.
* @retval HAL_FAILED operation failed.
*/
static bool sdc_lld_wait_transaction_end(SDCDriver *sdcp, uint32_t n,
uint32_t *resp) {
/* Note the mask is checked before going to sleep because the interrupt
may have occurred before reaching the critical zone.*/
osalSysLock();
if (sdcp->sdmmc->MASK != 0)
osalThreadSuspendS(&sdcp->thread);
/* Stopping operations.*/
sdcp->sdmmc->IDMACTRL = 0;
sdcp->sdmmc->MASK = 0;
sdcp->sdmmc->DCTRL = 0;
if ((sdcp->sdmmc->STA & SDMMC_STA_DATAEND) == 0) {
osalSysUnlock();
return HAL_FAILED;
}
/* Clearing status.*/
sdcp->sdmmc->ICR = SDMMC_ICR_ALL_FLAGS;
osalSysUnlock();
/* Finalize transaction.*/
if (n > 1)
return sdc_lld_send_cmd_short_crc(sdcp, MMCSD_CMD_STOP_TRANSMISSION, 0, resp);
return HAL_SUCCESS;
}
The trace:
Code: Select all
TEST-SDMMC-FATFS-RT-STM32L4R5ZI-NUCLEO144 (OpenOCD, Flash and Run) [GDB Hardware Debugging]
ch.elf
Thread #1 (Suspended : Step)
sdc_lld_wait_transaction_end() at hal_sdc_lld.c:234 0x8002e1a
sdc_lld_write_aligned() at hal_sdc_lld.c:761 0x80034c6
sdc_lld_write() at hal_sdc_lld.c:838 0x80035f0
sdcWrite() at hal_sdc.c:857 0x8001fa4
disk_write() at fatfs_diskio.c:188 0x800a790
sync_window() at ff.c:1.050 0x800aad8
move_window() at ff.c:1.074 0x800ab4e
get_fat() at ff.c:1.181 0x800add4
create_chain() at ff.c:1.581 0x800b1c4
f_write() at ff.c:3.867 0x800c8d4
<...more frames...>
arm-none-eabi-gdb (8.3.0.20190703)
The thread doesn't work again. I couldn't find the problem. I'm attaching the test project.
Cheers.