How touchGFX read the image from image.bin stored in SD card?
Hi all,
According to the document, I already store my image data to SD card and I can read the image data correctly by below function:
FRESULT read_bin_file(char *name, uint32_t offset, uint32_t numBytesToRead, uint8_t* dest)
{
fresult = f_stat (name, &fno);
if (fresult != FR_OK) {
SD_ERR("\"%s\" does not exists\n", name);
return fresult;
}
fresult = f_open(&fil, name, FA_READ);
if(fresult != FR_OK) {
SD_ERR("opening file \"%s\" err[%d]\n", name, fresult);
return fresult;
}
uint32_t numBytesRead = 0;
f_lseek(&fil, offset);
f_read(&fil, dest, numBytesToRead, &numBytesRead);
if (fresult != FR_OK || numBytesRead != numBytesToRead) {
memset(dest, 0, numBytesToRead);
SD_ERR("read bin file \"%s\" err[%d]\n", name, fresult);
f_close(&fil);
return fresult;
}
fresult = f_close(&fil);
if (fresult != FR_OK) {
SD_ERR("close file[%s] err[%d]\n", name, fresult);
}
return fresult;
}
I rewrite the TouchGFXHAL::blockCopy() function as below:
bool TouchGFXHAL::blockCopy(void* RESTRICT dest, const void* RESTRICT src, uint32_t numBytes)
{
if ((uint32_t)src >= 0x70000000 && (uint32_t)src < 0x78000000)
{
LOG_DBG((char*)"read %d bytes at 0x%08x ", numBytes, (uint32_t)src);
uint32_t offset = (uint32_t)src - 0x70000000;
Mount_SD("");
FRESULT res = read_bin_file((char*)"IMAGE/images.bin", offset, numBytes, (uint8_t*)dest);
Unmount_SD("");
if(res == FR_OK) {
LOG_DBG((char*)"OK\n");
return true;
} else {
LOG_DBG((char*)"err[%d]\n", res);
return false;
}
} else {
LOG_DBG((char*)"read %d bytes at 0x%08x", numBytes, (uint32_t)src);
return TouchGFXGeneratedHAL::blockCopy(dest, src, numBytes);
}
}
After compiler and flash the program, however, the display can NOT show the screen, and there is nothing LOG output.
Does the blockCopy() NOT be called normally?
Can anyone give me some ideas, Thanks!
