Can resource data in binary file format be loaded from FileX?
JoelSchofield opened this issue · comments
I have external NOR Flash that is formatted with Azure FileX, and am wondering if I can use gx_binres_theme_load
or similar to load a resource data binary file that is stored on the filesystem?
From my understanding I would need to expose the file's data as a raw pointer, which would require copying the file to RAM first (not an option given RAM constraints). Is there some functionality I'm missing that could make this work?
gx_binres_theme_load isn't designed to work from a file. The function dynamically creates resource tables, i.e. tables of pointers to the resource data. Pointers of course must point to directly accessible memory, not to a filesystem. People usually use flashing tools provided by their silicon provider or with their debugging tools to program the resource data to the external flash memory. Can you reserve a block of your flash for this purpose, rather than allocating the entire memory to FileX?
The external flash we have is controlled over the FSMC bus, and involves setup commands to place into read-mode before reading a section of data. Heres the snippet from the STM32F4 HAL library HAL_NOR_ReadBuffer
func:
/* Send read data command */
NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_FIRST), NOR_CMD_DATA_FIRST);
NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_SECOND), NOR_CMD_DATA_SECOND);
NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_THIRD), NOR_CMD_DATA_READ_RESET);
/* Read buffer */
while( uwBufferSize > 0U)
{
*pData++ = *(__IO uint16_t *)uwAddress;
uwAddress += 2U;
uwBufferSize--;
}
Perhaps gx_binres_theme_load
would work if we configured the flash for 8bit reads and left it in read-mode, however FileX would be regularly performing reads/writes to the same peripheral, and I doubt they will play nicely together.
We may need to make some hardware changes for this to work. Is there an example project which utilises loading resources from external flash that I could refer to?
If you clone or have cloned the GUIX repository (GUIX Studio will do this for you), you should see guix/tutorials/demo_guix_binres, which is configured to run either on the desktop (using a filesystem to load the resource data to a block of RAM) or the STM32_F439xx target board (resource data pre-loaded to NOR flash). This should be a useful example for you.
We are working with another customer on supporting a "data read callback" function to allow reading resource data from external serial flash, however the initial design is to support only a few custom canvas drawing APIs (gx_canvas_streamed_pixelmap_draw(), etc..) and not full widget set support for this model. I don't think this model is feasible from a performance perspective, especially as relates to glyph drawing, without some data caching mechanism. For the near future we really need to be able to directly access the resource data without the overhead of a "data read callback".
Thats understandable, I appreciate the help! The demo_guix_binres STM32F439 project uses a similar NOR Flash configuration as my project which is very convenient. Like you originally said if I can have a section of the NOR Flash for binres and the remainder for FileX then that will be the ideal solution; I'll just need to be confident that they dont clash when FileX needs to performs writes etc.
Thanks again for the help :)