FTDI Community

Please login or register.

Login with username, password and session length.
Advanced Search  

News:

Welcome to the FTDI Community!

Please read our Welcome Note

Technical Support enquires
please contact the team
@ FTDI Support


New Bridgetek Community is now open

Please note that we have created the Bridgetek Community to discuss all Bridgetek products e.g. EVE, MCU.

Please follow this link and create a new user account to get started.

Bridgetek Community

Author Topic: My Gui keeps crashing  (Read 9253 times)

scorpioprise

  • Newbie
  • *
  • Posts: 18
    • View Profile
My Gui keeps crashing
« on: April 12, 2019, 10:48:17 AM »

The problem is that every since my GUI stops working, let's start from the beginning

-FT902 + FT812 custom board-

From EVE 4.5 I got widgets and so on, positioned with layouts, built images and all of this mess.
Then I've done many under-the-hood personalizations (added CANBus support, USB DFU function, Power Supply Managemet,  code cleaning). Now the project is almost done 8).

BUT, if I switch back and forth many times, the toy crashes  :-\: the application freezes, and there's no other way than reset (reboot via reset pin).

As It apparently was like a memory corruption, when loading some complex page, i've began reading the mallinfo() structure, and every time I switch away and back to a slide, I find the HEAP grew by 96Byte... Also, my first slide, which for a while had a fixed address, after some jumps moved to another address...

This is a 250kB compressed bin application, full of stuff, variables and icons. Where shall I search for the leak?

Let me say there is no room for attach a debug ... code needed a -o3 -oS optimization to be built under eclipse and sent to board. Everything I have is the UART console... or writing on SD, maybe?

Any help will be appreciated.
Logged

scorpioprise

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: My Gui keeps crashing
« Reply #1 on: April 15, 2019, 09:16:23 AM »

Update: I've traversed the structure and noticed that the structure built by EVE has a very lazy garbage collector, I've moved a Ft_Esd_Widget_ProcessFree() to the Ft_Esd_widget_Free() [I'm working within ft_esd_wiget.c] and so I' "improved" it.
But that's not enough, instead of locking after 10-15 page moves, now it locks after 50 (not counted)?

Seems to me that the malloc()/free() function has some fragmentation
This is a simple printout of my mallinfo() after each of page switch:

Code: [Select]
Before Init page 1 Heap Blocks = 17252; free = 20360 ; total = 37612
 After Init page 1 Heap Blocks = 23300; free = 14312 ; total = 37612
Before Init page 0 Heap Blocks = 17252; free = 20360 ; total = 37612
 After Init page 0 Heap Blocks = 20628; free = 16984 ; total = 37612
Before Init page 1 Heap Blocks = 17348; free = 20264 ; total = 37612
 After Init page 1 Heap Blocks = 23396; free = 14216 ; total = 37612

mi.uordblks, mi.fordblks, mi.arena

as you can see, the heap [uordblks] keeps growing...

Any suggestion?
Logged

scorpioprise

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: My Gui keeps crashing
« Reply #2 on: April 15, 2019, 01:22:53 PM »

For anybody interested in, I found my leak. ;D ;D ;D ;D

Path: FT_Esd_Widgets\Ft_Esd_FixedPointNumericLabel.c
Method Ft_Esd_FixedPointNumericLabel_End_Signal

The Free(context) is not reached (IMHO), but I've implemented che context-> Number char * as a statically created
Code: [Select]
char Number_string[Size_Buffer];so,
Code: [Select]
context->Number = &(context->Number_string[0]);

makes everything work like before. *but* without any leakage, as the array is destroyed when the widget is destroyed.

I suggest, for anybody using the fixed point numeric label, altering the library.
Also, same structure can be found in Ft_Esd_NumericLabel, so I suggest doing the same there.

This will loose ten precious bytes, but will leave the heap cleaner.
Logged

FTDI Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 891
    • View Profile
Re: My Gui keeps crashing
« Reply #3 on: April 16, 2019, 04:27:37 PM »

Hello,

Please note that we have created the Bridgetek Community to discuss all Bridgetek products e.g. EVE, MCU.

Please follow this link and create a new user account to get started.

Bridgetek Community

Please clarify what you mean by “the toy crashes  :-\: the application freezes”

Is FT9xx Eclipse IDE or ESD freezing or your custom application?

The UART debug interface can be good enough to debug.

You may want to consider moving pictures and icons to the SD card.

Also, ESD includes a lot of framework code to implement functionality, thus increasing the code size, and as such the code output is very ESD specific. The tool is intended for use by those who have very little to no programming experience. I would suggest that it would be far more productive for you to look at our Sample Applications and programmers guide. Thus being able to eliminate the ESD code from the equation and work directly with the Display List code to drive the FT81x.

Please take some time to look at the following examples in either Visual Studio or the FT9xx Toolchain:
https://www.ftdichip.com/Support/SoftwareExamples/FT800_Projects.htm

You will also find the EVE platform guide useful:
https://brtchip.com/wp-content/uploads/Support/Documentation/Application_Notes/ICs/EVE/AN_391-EVE-Platform-Guide.pdf

Best Regards,
FTDI Community
Logged

scorpioprise

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: My Gui keeps crashing
« Reply #4 on: April 17, 2019, 08:28:08 AM »

Hi FTDI,
my custom application, of course, was leaking.

All pictures were already on SD card, and with optimization of Eclipse ( -o3 -os ) most of the un-essential part of code were torn off from linker (inspection with map file helped).
The structure itself of ESD is very powerful, instead, in this case I keep it, as it resembles the android app approach.
I had only to tweak some of the generated code to shrink it.
Of course, not all the library code went away, so it has still a big footprint in flash, if only I had more time to work on the prototype I would have worked without ESD.
But now that I've found the problem, I could change 7000+ times (literally) slide without problems, while before the 10th slide change was a dice roll with death....

OT: I'm already registered in Bridgetek community  ;)
Logged