|
|
@@ -529,6 +529,7 @@ static int32_t prvSDMMC_Init(char const*name)
|
|
|
#if DEVICE_TYPE_SELECT == EMMC_FLASH
|
|
|
static uint32_t cached_sector = 0xffffffff;
|
|
|
static uint8_t cached_data[emmcSECTOR_SIZE];
|
|
|
+static SemaphoreHandle_t cached_mutex = NULL;
|
|
|
|
|
|
int32_t phyRead( uint8_t *pucBuffer, uint32_t ulSectorNumber, uint32_t ulSectorCount)
|
|
|
{
|
|
|
@@ -685,18 +686,26 @@ int emmc_write(uint32_t offset, size_t size, uint8_t *data)
|
|
|
uint32_t wsize;
|
|
|
int ret;
|
|
|
|
|
|
+ if (cached_mutex == NULL)
|
|
|
+ cached_mutex = xSemaphoreCreateMutex();
|
|
|
+
|
|
|
+ xSemaphoreTake(cached_mutex, portMAX_DELAY);
|
|
|
+
|
|
|
while (leftsize > 0) {
|
|
|
wsize = leftsize > EMMC_RW_MAX_SIZE ? EMMC_RW_MAX_SIZE : leftsize;
|
|
|
ret = raw_emmc_write(off, wsize, buf);
|
|
|
- if (ret)
|
|
|
+ if (ret) {
|
|
|
+ xSemaphoreGive(cached_mutex);
|
|
|
return ret;
|
|
|
+ }
|
|
|
leftsize -= wsize;
|
|
|
off += wsize;
|
|
|
if (buf)
|
|
|
buf += wsize;
|
|
|
}
|
|
|
|
|
|
+ xSemaphoreGive(cached_mutex);
|
|
|
+
|
|
|
return 0;
|
|
|
}
|
|
|
-
|
|
|
#endif
|