king2 Posted April 16, 2017 Report Posted April 16, 2017 Hi, i'm backl I have returned to my old project and was found very strange behavior of one button - it displays in a very strange way (see attachments). First picture is a initial look of button, and second one was shot after I have pressed it once (sorry for so big and not sharp photos, but I have no better camera now). These diagonal lines should be just like in lower button - in gray color. I have tried to update uGFX to last one (2.5 -> 2.7) with no luck. I have tried to change order or image definitions - this was not changed anything. I have tried to load other picture in this button - other image was distorted like first 'button_usb_gray' image. This is my code (gdispImageOpenFile returns ERR_OK): gdispImageOpenFile(&button_usb_gray, "rsc/button_usb_gray.gif"); gdispImageOpenFile(&button_usb_green, "rsc/button_usb_green.gif"); gdispImageOpenFile(&button_usb_red, "rsc/button_usb_red.gif"); gdispImageOpenFile(&button_rec_gray, "rsc/button_rec_gray.gif"); gdispImageOpenFile(&button_rec_red, "rsc/button_rec_red.gif"); gdispImageOpenFile(&button_mic_gray, "rsc/button_mic_gray.gif"); gdispImageOpenFile(&button_mic_red, "rsc/button_mic_red.gif"); gdispImageOpenFile(&button_ruler, "rsc/button_ruler.gif"); But when I have tried to load images in different order - for example, place 'ruler' picture at first place, to be loaded first - I got 'ruler' button with bad image and 'usb_gray' image slightly distorted, so I know that distorted first one or two images that was loaded first. As I understand, if I'm not use caching, each redraw raises its own GIF 'read from flash and decode' process, using a little amount of memory for buffering, so this can be some ChibiOS issues or something else, that can rewrite SRAM pieces used in decoding process or something like this. I have tried to track what happens when image was redrawed, but was not able to see any errors returned, everything looks ok. Can you point me, what should I do next? What can I try with debugger to understand what is going on? Thank you in advance!
inmarket Posted April 16, 2017 Report Posted April 16, 2017 I would suggest the following approach... 1. Simplify the program until you have only the buttons of concern and their associated images. As you strip code out that will quite often show where the problem originates. 2. Once you have a short test program that still exhibits the problem play with stack size in case it is a stack overflow issue. 3. Try putting long gfxSleepMillseconds (in the order of a second or so) between each initial button create call. The purpose for this is to spread in time the initial draw of each inage button. Each gif image requires around 12k of RAM while it is decoding (which it does on each draw unless cached). This test is to see if it is a low memory situation while decoding that is causing the problem. Images also have a config macro that can turn on memory usage tracking. You will still need to test that memory usage however. 4. Try rebuilding your gif images with a different image editor. It is not uncommon for gif images to be "non-standard" in some fashion and while uGFX handles most of those there might be something there. 5. If that makes no difference feel free to post a zip of the minimal project. Use #if 0 macros in the source to show the effect of image reordering. We will then debug the decoder itself for you.
king2 Posted April 16, 2017 Author Report Posted April 16, 2017 (edited) I found the problem. I got all my backups and have tried to find when it was failed. Indeed, this was stack overflow to memory area used by GIF decoder. I had IRQSTACK with size 0x400, placed at start of RAM_region (from 0x20000000 to 0x20000400, then variables, then HEAP. Everything was ok. After I was removed linker instruction to place IRQSTACK at start of memory (I needed start for another common variable with bootloader), it was placed just before HEAP (after variables), and here problems were started. I have tried also increase size of IRQSTACK, and it works even in new place, so it was really interrupt stack overflow (but i still cannot understand why it worked before at start and with old size). So, problem is found, and I go to read about sysheap, heap, different stacks, and how chibios works with all this. Thank you very much for helping me and sorry for disturbing you for a such dumb reason (but I think this thread can be helpful to other newbies like me). Edited April 16, 2017 by king2
king2 Posted April 17, 2017 Author Report Posted April 17, 2017 If somebody will met this problem with ChibiOS, you can see my post here: http://www.chibios.com/forum/viewtopic.php?f=16&t=3961&p=29188#p29188. It contains example of my ICF linker file, that was solved this problem.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now