cancel
Showing results for 
Search instead for 
Did you mean: 

Installing the binary font at the external SDRAM on the STM32F429BI board will Cause program crash.

Fchen.1864
Associate II

Here are my programs:

const int FontCacheSize = 10000;

uint8_t fontdata[FontCacheSize] __attribute__((at(0XC0E00000))) __attribute__ ((aligned(4)));

FrontendApplication::FrontendApplication(Model& m, FrontendHeap& heap)

   : FrontendApplicationBase(m, heap)

{

 FIL fil;      /* File object */

 FRESULT fr;   /* FatFs return code */

 UINT br;

 fontCache.setMemory(fontdata, FontCacheSize);

 /* Open a text file */

 fr = f_open(&fil, "0:/Font_VINERITC_TTF_20_4bpp.bin", FA_READ|FA_WRITE|FA_OPEN_ALWAYS);

 if(fr == FR_OK)

 {

  fr = f_read(&fil, fontdata, FontCacheSize, &br);

  fr = f_close(&fil);

  

  new (&bf) BinaryFont((const struct touchgfx::BinaryFontData*)fontdata);

   TypedTextDatabase::setFont(Typography::DEFAULT, &bf);

 }

}

Sometimes it able to work. But , if I touch the screen the program will crash.

Most of the time,the program crash on the power on.

2�?I'm not sure what this filedatareader is. Who can give me an example. The chip is stm32f429bi, and the file system is FatFs.Thank you .

0690X00000At5P6QAJ.png

5 REPLIES 5
Martin KJELDSEN
Chief III

Normally you'd use Binary Fonts because you have a typography that is incredibly large, and you cannot or won't place it in external flash memory, so you place it on an SD-Card. You then have to read this data from the SD-Card (Here's where the FileDataReader comes into play).

/Martin

Hello​, Martin, Thank you for your answer. 

What you say is what I need.

I want to read ​the typography to SDRAM from the Sd-card. 

1.Can you give me a specific example for the FileDataReader. 

2. How about my first question?Do you know why?When I define the fontdata[FontCacheSize] in the internal RAM, it go good.

Re: 2 - You're allocating some buffer. Are you using an RTOS? Check your stack/heap settings - If they're large enough. Do you have external ram? Also note that there's a difference between "Font cache" (in which you only read few glyphs into ram that you need) and binary fonts in which you can install a font from somewhere in SD-RAM because you want to replace the font with a new one - This example is e.g. for when you want to update typographies on the fly or through an update.

1. I'll try to make an example for binary fonts using FileDataReader that just reads the file from a filesystem (in a simulator).

Do you really know what you're trying to achieve? Are you trying to install a complate binary font, or are you trying to read glyphs into a cache in the case where loading a complete binary font is not possible? (e.g. for asian languages).

/Martin

Fchen.1864
Associate II

1.I have an external sdram of 16MB.

2. I want trying to read glyphs into a cache( preferably define in Sdram) in the case where loading a complete binary font is not possible.(e.g. Chinese).

jguo.2
Associate

I have the same problem as you. Has this problem been solved ?