How touchGFX read the image from image.bin stored in SD card?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-05-24 1:53 AM - edited ‎2024-05-24 2:37 AM
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!
Solved! Go to Solution.
- Labels:
-
TouchGFX
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-05-25 12:52 AM
Not only should we store the image on the SD card, but we also need to get the image from the SD card actively.
Refer to the Document Here and the Video Here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-05-24 2:20 AM - edited ‎2024-05-24 2:35 AM
The map file info:
the read_bin_file() test result:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-05-25 12:52 AM
Not only should we store the image on the SD card, but we also need to get the image from the SD card actively.
Refer to the Document Here and the Video Here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-06-01 9:33 PM
If you you use SDRAM it's better to replace your image to the address of your pervious image.
Just read the image file then set the address
At the start of image address in the SDRAM
For example, 0xD0789000
This is work for PNG format and same size images
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-06-02 6:16 PM
Hi @Arisha
My board has an external SDRAM, and I think the SD card is just for storing the image data for non-volatile.
Each time the system power on, the touchGFX will read the image data to SDRAM, and keep it for later access.
This is finished by "void Bitmap::cacheAll()"(if the SDRAM is enough), or "bool Bitmap::cache(BitmapId id)"(if the SDRAM is not enough for all the images).
