2020-02-26 10:46 AM
Hi All,
We are using STM32F429ZIT6 MCU with 8 Mega byte SD RAM connected to FMC peripheral. And 16 Mega Byte Serial flash which is connected via SPI.
The internal memory is 2 MByte for this MCU
We are working on a touch GFX project wich have many assets so the size of total binary exceeds the 2 MB internal Flash. So I have written a bootloader which takes the binary in via a python script and places Application in the Flash memory and assets(modified the linker script) in the SPI flash
Now on every boot up the application will copy assets from spi flash and place it in SD RAM. I verified the memory dump of ram is exactly matching the assets binary contents. So I am confident that the assets are properly copied.
I am following this webpage to do this.
https://touchgfx.zendesk.com/hc/en-us/articles/203564102
As mentioned in the above webpage I am following the exact same method.
Below is the code.
class myHAL: public STM32F4HAL
{
public:
virtual bool blockCopy(void* RESTRICT dest, const void* RESTRICT src, uint32_t numBytes);
};
bool myHAL::blockCopy(void* RESTRICT dest, const void* RESTRICT src, uint32_t numBytes)
{
copySerialFlashToToRam();
HAL_Delay(1000);
return true;
}
STM32F4DMA dma;
STM32F4TouchController tc;
STM32F4Instrumentation mcuInstr;
static LCD16bpp display;
static uint16_t bitdepth = 16;
namespace touchgfx
{
void touchgfx_init()
{
uint16_t dispWidth = 218;
uint16_t dispHeight = 480;
uint16_t* cacheStartAddr = (uint16_t*)ASSETS_START_ADDRESS;
uint32_t cacheSize = SIZE_OF_ASSETS_BINARY + 100000U ;
Bitmap::cacheAll();
HAL& hal = touchgfx_generic_init<STM32F4HAL>(dma, display, tc, dispWidth, dispHeight,cacheStartAddr,
cacheSize, 0);
hal.setFrameBufferStartAddress((uint16_t*)frameBuf0, bitdepth ,true , true);
hal.setTouchSampleRate(2);
hal.setFingerSize(1);
// By default frame rate compensation is off.
// Enable frame rate compensation to smooth out animations in case there is periodic slow frame rates.
hal.setFrameRateCompensation(false);
// This platform can handle simultaneous DMA and TFT accesses to SDRAM, so disable lock to increase performance.
hal.lockDMAToFrontPorch(false);
mcuInstr.init();
//Set MCU instrumentation and Load calculation
hal.setMCUInstrumentation(&mcuInstr);
hal.enableMCULoadCalculation(true);
}
}
Now the problem is touch gfx is not taking this configuration in. I can see no image is coming up. I am not understanding what mistake I am doing.
Any help is highly appreciated.
Thanks,
Krishna
2020-02-27 05:16 AM
Hi,
What're you expecting to happen? How does your application look? Not seeing any view code. Are you caching specific image ids?
blockCopy() will be called with a virtual address (specified in your linker script) of the image that is located in your non-memory mapped flash.
You have a call to copySerialFlashToToRam(); but this should map the particular address to somewhere in your flash and you should read numBytes from there into dst.
/Martin
2020-02-27 10:27 AM
Hi Martin,
From that point I modified my code a bit.
Previous code is the part of code in BoardConfiguration.cpp I made a basic touchGFX application with two buttons which alter the text forth and back. Look at the attached image
We are not using the dynamic bitmaps cacheing. We have enough SD ram to copy all the assets during Reboot at once. My plan is to copy the assets from External Flash and put them in RAM and change the TouchGFX config to take assets from that Location of RAM and render. Please correct me if my though tprocess is wrong.
As of now the assets are just 81 KB but before Implementing the logic in our master code I decided to create a new STM cube project and try this out.
So the attached image is if I let the ExtFlashSection to sit in flash(normal configuration). Everything works perfectly without any problem.
The problem comes when I put the ExtFlashSection in SDRAM by linker. Below is my linker config
. = ALIGN(4);
.ExtFlashSection 0xD00F4240 :
{
KEEP(*(ExtFlashSection))
}
Below is the Code which copies assets from serial flash to ram
void copySerialFlashToToRam(void)
{
uint32_t address = SERIAL_FLASH_START_ADDRESS;
uint32_t size = SIZE_OF_ASSETS_BINARY;
uint32_t singleBlkSize = 1024;
uint8_t rxBuff[singleBlkSize];
uint32_t destinationAddress = ASSETS_START_ADDRESS;
int i = 0;
uint32_t sizeTobeCopied = singleBlkSize;
while(i < size)
{
HAL_GPIO_WritePin(DEBUG_LED_GPIO_Port, DEBUG_LED_Pin, GPIO_PIN_SET);
if((size - i) > singleBlkSize)
{
i+=singleBlkSize;
sizeTobeCopied = singleBlkSize;
}
else
{
singleBlkSize = size -i ;
i = size;
}
serialFlashread(rxBuff,address,sizeTobeCopied);
for(uint32_t i = 0 ; i < sizeTobeCopied ; i ++ )
{
*((uint8_t *)destinationAddress + i) = rxBuff[i];
}
address += sizeTobeCopied;
destinationAddress +=sizeTobeCopied;
HAL_GPIO_WritePin(DEBUG_LED_GPIO_Port, DEBUG_LED_Pin, GPIO_PIN_RESET);
}
}
Below is my new code I dont wat to use Bitmap::cacheAll() function I want to manually copy all assests my self as I know where is the start address and end address.
Below is my new touchgfx_init() code
#define ASSETS_START_ADDRESS 0xD00F4240U
#define SERIAL_FLASH_START_ADDRESS 0x000000U
#define SIZE_OF_ASSETS_BINARY 81600U
void touchgfx_init()
{
uint16_t dispWidth = 218;
uint16_t dispHeight = 480;
HAL& hal = touchgfx_generic_init<STM32F4HAL>(dma, display, tc, dispWidth, dispHeight,(uint16_t*)ASSETS_START_ADDRESS,
SIZE_OF_ASSETS_BINARY , 0);
copySerialFlashToToRam();
hal.setFrameBufferStartAddress((uint16_t*)frameBuf0, bitdepth ,true , true);
hal.setTouchSampleRate(2);
hal.setFingerSize(1);
// By default frame rate compensation is off.
// Enable frame rate compensation to smooth out animations in case there is periodic slow frame rates.
hal.setFrameRateCompensation(false);
// This platform can handle simultaneous DMA and TFT accesses to SDRAM, so disable lock to increase performance.
hal.lockDMAToFrontPorch(false);
mcuInstr.init();
//Set MCU instrumentation and Load calculation
hal.setMCUInstrumentation(&mcuInstr);
hal.enableMCULoadCalculation(true);
}
So my Idea is....
My code is above as shown. The new problem is it is working fine for a second or two and it is crashing. Please let me know If I am doing anything wrong
2020-06-01 04:53 AM
I'm having a similar problem with whether your Bitmap::cacheAll() method will work. If you can, share the specific code you implemented, thanks.