Skip to main content
Datome
Associate II
December 28, 2020
Question

How to read .bin file for Touchgfx

  • December 28, 2020
  • 19 replies
  • 4576 views

Normally I can display all projects of touchgfx (which can be stored in internal memory) on my touchscreen without any problem.

For a larger project I needed to use a SD card. For this purpose, I compiled all the images into a .bin file and then saved it to SD card. I try to use blockcopy function as shown below but all I get is just a black screen.

To sum up, I dont know how to call the images. it will be appreciated if someone correct the mistakes or shift me to the the correct way.

bool TouchGFXHAL::blockCopy(void* RESTRICT dest, const void* RESTRICT src, uint32_t numBytes)
{
	uint32_t dataOffset = (uint32_t)src;
	if (dataOffset >= 0x9A000000 && dataOffset < 0xA0000000)
	{
		int fd;
 
		if(f_mount(&myFatFs,SDPath,1) == FR_OK)
		 {
			 if (f_open(&myFile,"images.bin",FA_OPEN_EXISTING | FA_READ) == FR_OK)
			 {
				 fd = open("images.bin", O_RDONLY, 0);
				 dataOffset = dataOffset - 0x9A000000;
				 lseek(fd, dataOffset, SEEK_SET);
				 read(fd, (uint8_t *)dest, numBytes);
				 close(fd);
			 }
				 return true;
		 }
 
	 else { return false;}
	}
 
 else
 { return HAL::blockCopy(dest, src, numBytes); }
 
}

for initialization ;

void TouchGFXHAL::initialize()
 
{
 
 uint16_t* cacheStartAddr = (uint16_t *) malloc(0x3000000);
 
 uint32_t cacheSize = 0x3000000; 
 
 Bitmap::removeCache();
 
 Bitmap::setCache(cacheStartAddr,cacheSize,1024);
 
 Bitmap::cacheAll();
 
 
}

This topic has been closed for replies.

19 replies

Datome
DatomeAuthor
Associate II
January 3, 2021

I couldn't achieve to display the images and I attached the result.

I can navigate through the pages of GUI coz it displays the buttons like a shadow. I couldn't find out the missing point.

0693W000006HKvFQAW.jpg

MM..1
Super User
January 3, 2021

can you reply for question

Check in debuger breakpoint at line 2 how address is in cacheStartAddr.?

Datome
DatomeAuthor
Associate II
January 3, 2021

I changed it as;

uint16_t* cacheStartAddr = (uint16_t*)0xD1000000;

MM..1
Super User
January 3, 2021

This is next chaos information please explain your full config, how SDRAM, where mapped, STM32xxxx usw ????

Adress 0xD1000000 is FYI 16M in SDRAM then your SDRAM when is mapped on 0xD0000000 must be 32M or more. ?

How big is your bin graphics file ?

?

?

Datome
DatomeAuthor
Associate II
January 3, 2021

sorry for the missing information. yes my sdram is 32M and it is mapped to 0xD. I used 0xD0000000 and 0xD00D2F00 as double buffers of touchgfx. This demo version graphics occupies 4.7 MB.

 uint16_t* cacheStartAddr = (uint16_t*)0xD1000000;
 uint32_t cacheSize = 0x500000;

MM..1
Super User
January 3, 2021

Then you read Using Non-Memory Mapped Flash for Storing Images | TouchGFX Documentation

and apply last part link in RAM, when your 16M is free and dont plan bigger bin file.

Remove all caching...

Datome
DatomeAuthor
Associate II
January 4, 2021

the GUI size will be bigger than the ram size so I cannot store them as you suggested.

MM..1
Super User
January 4, 2021

Then all you need is  Using Non-Memory Mapped Flash for Storing Images | TouchGFX Documentation

except last part link. But i mean your idea cacheall when your image is over ram size isnt logic.

You need apply one screen graphics must have size under ram size for cache and too empty your cache on change screens.

Normal use

void Screen1View::setupScreen()
{
 //ensure background is cached
 Bitmap::cache(BITMAP_SCREEN2_ID);
 //cache some icons
 Bitmap::cache(BITMAP_ICON10_ID);
 Bitmap::cache(BITMAP_ICON11_ID);
 Bitmap::cache(BITMAP_ICON12_ID);
}
 
void Screen1View::tearDownScreen()
{
 //Remove all bitmaps from the cache
 Bitmap::clearCache();
}