cancel
Showing results for 
Search instead for 
Did you mean: 

Problem of TouchGFX and LWIP working together.

Yunus ARI
Senior

Hi everyone,

I am trying to use LWIP with TouchGFX together. But it's not working well. First of all need to say; I have a massive TouchGFX code. And I want to add LWIP in this project. When I try this first, I got a linker error about RAM usage. I use STM32f746BET microprocessor and its has a 320 kb RAM. On the other hand I also has an external RAM about 16 megabytes. I thinked project will use external RAM when internal RAM is full. But that's not working that way. When I notice that, I did some research. As I understand, LWIP using to freeRTOS heap. So I thinked, if I grew up FreeRTOS heap this maybe solve my problem. But I didn't have memory in to my internal RAM. So I decide to use some external RAM for FreeRTOS heap. I thought to use FreeRTOS's heap_5 for do this. I created 20 kb heap in internal RAM and 100kb heap in external RAM. When I did this linker error gone. TouchGFX and LWIP ran together but system couldn't get an IP. :(

When I can't solve problem that way, I changed working plan. I created a working LWIP project and start add other peripheral thats need for TouchGFX. Ist gone well until add real TouchGFX code. This is a dead end too but I learned something when do this. Some interrupts break LWIP connections. On the other hand when activate 'cache' this is break LWIP too.

I have been working on this problem for about 1 week. And I couldn't go too far. I tryed to explain what I do and what I get. If have any advice I would like to hear it.

thanks in advance. stay healthy.

7 REPLIES 7
Martin KJELDSEN
Chief III

I think there's a general issue with LWIP in CubeMX. I seem to remember it took almost a second to initialize.

I don't have a lot of experience with LWIP. How are you experiencing these issues? E.g. interrupts causing issues, cache causing issues. Have some detailed info?

We do use fixed priorities for DMA and LTDC interrupts and it may be interfering with your LWIP interrupts, if using any, but you're free to change these. Look for NVIC configuration code in the STM32HAL class.

/Martin

Yunus ARI
Senior

Thanks for answer Martin,

I changed some interrupt priority like you say. Actually, I find out my RAM is full because of my own variables. So I got my variable in to external RAM. It took awhile but opened some memory in internal RAM. So I could change my freeRtos heap size. When heap get bigger and interrupts is organized, LwIP start to work. Not as good as I want, but is working fine :).

Just I wonder, Does it affect badly TouchGFX performans when I use external RAM for my purpose.

And last one, Do you have any suggestions for reducing internal RAM memory usage of TouchGFX? I will need it because my project getting bigger every day :(.

thank you for interest, stay healthy.

Martin KJELDSEN
Chief III

Glad you solved it.

Depending on the speed of your RAM of course : ) But, generally, SDRAM is used widely for frame buffers because of large screen dimensions. It will always be slower, but acceptable. In some cases, it's possible to move to internal SRAM on MCUs like H7.

Reducing internal RAM usage - Do you mean excluding framebuffer?

/Martin

Yunus ARI
Senior

Actually I don't talk about framebuffer. It's already in external RAM and my external RAM big enough.

I have memory problem on my internal RAM. So I want to reduce internal RAM memory usage. I do this with moving my variables in to external RAM. But TouchGFX still use internal RAM for its own variables. And it will fill my RAM at the end of the work. I want some suggestions about that.

For example, I prefer to drawing my theme with to TouchGFX. I don't use pictures for simple drawing like line or rectangle. Sometimes this drawing is growing and I have to use bigger canvas buffer. I really don't know, is this affect memory or is it just temporary private variables. What I know, I completed my project about forty percent but I used my internal RAM almost all. And it will be give me headache soon. 😅

I'm open to any advice. Thanks lot.

I want to add last one thing. You don't have curved rectangle in TouchGFX. I literally dying for do that. 😁 Please add this one soon.

Martin KJELDSEN
Chief III

You could move your OS Heap to external RAM also.

And, there's the whole issue about coding your application to be efficient with memory.

The canvas buffer can be a big issue - You could place this in external as well at some performance cost.

Why do you need curved rectangles? Consider whether you want to pay the price in RAM and PERFORMANCE (canvas widgets) or in FLASH (images) - In the last case, DMA2D can help you blend pixels with practically no cost.

/Martin

Yunus ARI
Senior

I tried move OS Heap to external RAM first. But its not worked. So I decided to move my variable in to external RAM. Then I find out why I couldn't move OS heap. My external RAM has 16 address bit. When I load variable shorter than 16 bits in to external ram, its not working well. I noticed that her, I had a union in my variables. When I move this union in to external RAM, I started to can't access unions bits. So I changed unions bits to 16 bit variable. And problem solved 😁.

Now, canvas buffers and OS heap has 8 bit variable.  How can I move this two in to external RAM :\. I am ready to accept the performance cost. Enough if i can solve this problem.

Just like I said about in previous message, I prefer to drawing my theme with to TouchGFX. Because I want to change theme color in runtime. If I use pictures for theme, I can't do color change easily. For each theme color would be necessary new picture. To make the theme beautiful, I need curved rectangle (in other words; box with curved edge). 😅

Piranha
Chief II

For a problems of ST's provided non-working networking bloatware look here:

https://community.st.com/s/question/0D50X0000BOtfhnSQB/how-to-make-ethernet-and-lwip-working-on-stm32