 Hello and welcome to this presentation. My name is Badr Dean and in this video we will learn how to cache the bitmaps stored in the SD card. In the first part we saw how to set up the SDMMC peripheral and add FatFS file system to the SDM32F746 3rdGFX template. In this second part we'll see how to cache the bitmaps stored in the SD card into the SDRA. I have my SDM32Q by DE launcher asking me to select a new workspace. I will use a new workspace for this project and click launch. Here I have my SDM32Q by DE project open. I'll close the information center and expand the project here. I will start by setting up the bitmap cache which consists of a pointer to a buffer and the size of the buffer. I will expand project, then application, user and then touch GFX and then target. The bitmap cache setup is done in touch GFX hull.cpp, double click on the file. The initialize method we will set up the bitmap cache. By default the template uses 3 frame buffers of 261 kilobytes each. The total size of the feed frame buffer is BF400. Here we set up the start address of the cache right after the 3 frame buffers. The total size of the cache is 8 MB which is the size of the SDRA. For the user manual of the SDM32F746 discovery board we have an SDRA of 128 MB but only 64 MB is accessible, so 8 MB. So the size is 8 MB minus the size of the 3 frame buffers which gives us 7.4 MB or 7400C00. Then I will remove the default bitmap cache configuration. And last but not least we set up the cache based on the start address and the size defined above. Here we cache up to 128 dynamic bitmaps. Next we will go to GUI and MainView.cpp. And here we tell touch GFX framework which bitmaps to cache. We have two cache strategies. Either we cache all the bitmaps or we cache specific bitmaps per ID. For example I can cache the background image on the setup screen. And I can cache the image that I have in the main screen, image 00. Or I can cache all the bitmaps using cache all. So I can do bitmaps, cache all. And of course in this case I need to remove these two lines. If we need to cache all the bitmaps of course the size of the cache must be large enough to contain all the bitmap data. Then of course we need to clear the cache and the tear down method. So here in the setup screen method we cache all the bitmaps and then in the tear down screen we clear all the cache. Now I will modify the linker script in a way to add a new virtual memory area SD card that starts from 0xA00000 with the length of 7 megabytes. So I go to the linker script here and in the memory section I add a new memory area that is virtual that starts from the address A00000 and the length of 7 megabytes. And then here I tell the linker to place the external flash section which contains all the bitmaps into the SD card virtual memory. And then I'll add the keyword noload here to tell Q by D not to load the binary to that section. If we look into that JFX designer and then images tab we see that the background image and image 0xA00000 are both placed in the external flash section. We go back here and what we did is we placed the external flash section in the SD card. I'll keep the font and the text flash section and the quad-spy. When you cache a bitmap, that JFX copies the pixels from the original location to the bitmap cache using the block copy function in that JFX.cpp. In our case the bitmaps are stored in the SD card which is not a memory map memory. Then we need to add the FatFS red operation from the SD card. If the address is within the SD card virtual memory region then we use FatFS file to read the data. We calculate the offset within the SD card virtual memory. We place the file pointer to that offset. Then we read the number of bytes from the SD file to the destination address which is an SDM address. Else meaning if the address is not within the SD card virtual memory region then we use the default implementation. Of course before I can read it from the SD card I need to mount the file system and then open the file. And I want to do that only once. So I do FatFS. If FatFS init is 0 then mount the file system to SDFATFS and then open the file SD file and then set the variable to 1 to make sure I mount and open the file only once. Then I need to define these variables. So I already have the FatFS files or FatFS variables defined here. And the FatFS.FATFS.CIC SDPATH is defined here. The SDFATFS file system object is defined here. The SD file is defined here. So what I need to do is to define them here as extra. And then I need to include the header file for the FatFS. And I still need to define the FatFS init variable and the byte shared variable. And here I have SDPATH copied twice. I need to remove it. Now I'm ready to build the project. Select the project and click on build. We see here the build finished successfully.