1 2 3 Previous Next 31 Replies Latest reply on May 16, 2020 7:37 AM by LePo_1062026

    emWin Bus Fault

    EdHa_4455331

      I am trying to use an ST7789 interface with emWin and  FreeRTOS on a Cypress POC 6 system. This is my first project using emWin.


      My code is crashing out with a bus fault error. After initializing the GUI system, I did a simple GUI_DrawLine( 0,0, 1,1). The code gets to the step shown in the attached FatalStep.png. When I do a "step into" on that step, the code encounters a bus fault - see BusFault.png.

       

      To the best of my knowledge my code goes through the initialization sequence call for in your documentation. So at the moment I have no idea why this code is crashing out. I could probably run down the problem myself if I had the source code, but I don’t, so sthis is causing me some schedule/deadline headaches.

       

      I have already asked about this on the emWin forum, but no one has yet proposed a solutions. So I’m getting a tad desperate.

      Can you provide any suggestions to fix this?

      Thanks,

      Ed H.

        • 1. Re: emWin Bus Fault
          DheerajK_81

          Hello,

           

          Please find the code example here which basically interfaces with CY8CKIT-028-TFT Shield which has a display with the same ST7789 driver. So, the driver files will remain the same, you can make use of this in your project.

           

          The code example however isn't using FreeRTOS, so you will need to add it. It's tough to say off the bat what might be resulting in the error without the project. Please attach it so that we can have a closer look.

           

          Please also provide some details of the project you are working on. The kind of display (attach datasheet), the psoc6 device/kit you are using, what the requirements are and we can help you with that

           

          Regards,

          Dheeraj

          • 2. Re: emWin Bus Fault
            EdHa_4455331

            Good afternoon Dheeraj,

             

            I wasn’t sure whether you wanted me to respond directly to you or the forum, so I decided to start with  you first. There is nothing really confidential in the stripped down version that I have attached. So you can put it on the forum if you want to.

             

            Thanks for the suggestion, but the code example you suggested weren’t much help. It doesn’t use FreeRTOS and it uses a parallel interface to the ST8889.

             

            I am working with a  CYBLE-416045 BLE module.

             

            The project is attached. The BIG problem is that I have to use an SPI bus to interface to the ST7789. There is not a built-in component in Psoc Creator for the serial version of the interface. So the system will not auto-generate all the interface files that I need.

             

            I did two things: 1) I read the emWin manual and forums to try get a good understanding of everything I needed to do a custom SPI interface, and 2) I used a dummy project to see what Psoc Creator would generate for a parallel interface. I then tried to combine those two inputs into the attached project.

             

            At the moment, the display doesn’t matter. I haven’t even attached it to the CYBLE module yet. But the absence of a display is NOT the problem. The code locks up before it tries to read or write to the display.

             

            Any help or suggestions would be immensely appreciated.

             

            Thanks,

             

            Ed H.

            • 3. Re: emWin Bus Fault
              LePo_1062026

              Ed H,

               

              I'm looking at your project now.  I still don't have a direct clue for you.  I do have a few questions:

               

              Are you using the CY8CPROTO-063-BLE kit as a base for your project?

               

              Have you ever created a FreeRTOS program on a PSoC before?

               

              Was there a version of this project that was working before?

               

              Here's what I've found so far:

               

              Here's what the stack looks like before the crash:

              xPortStartScheduler in port.c line 367 is where you apparently fall off the rails.

               

              Attached is another project that uses the EINK display and the FreeRTOS.  I retargetted it for the CYBLE-416045-02 module but you will have to reassign the pins as necessary.

               

              Len

              • 4. Re: emWin Bus Fault
                LePo_1062026

                Ed H,

                 

                I get the same issue in the same location in the code as you.  This could be because I don't have your display.

                In your Display tasks you are initializing the GUI_X_Config and LCD_X_Config code.  Once for each Task.

                 

                I don't know if this is a good or bad thing to initialize the HW twice.  I disabled one of the tasks and saw no improvement.

                 

                It's possible that the HW is not being initialized properly.  For me I don't have the HW, this might be why I crash at GUI_DrawLine( 0,0, 1,1).

                 

                Since you need to communicate to the display by SPI you might what to test if the SPI is operating by adding some SPI unit test code to push data out (MOSI) of the SPI port and see that data is coming in (MISO).  You might have a HW wiring issue.

                 

                The issue you are seeing is that the GUI_DrawLine() is provided by Seeger in the emWin library as object code ONLY.  That's why you cannot easily debug the issue.  The source code for this function is not provided. That's why the stack output shows <signal handler called()> as function and "??????" as the file.

                 

                If you're really in the mood for a deep-dive, you can jump into the GUI_DrawLine() function in assembly code.

                 

                Hopefully Seeger who created emWin can be of more help.

                 

                I'd check with them if they have example code that might be close to the interface of your display.

                 

                Len

                • 5. Re: emWin Bus Fault
                  EdHa_4455331

                  Are you using the CY8CPROTO-063-BLE kit as a base for your project?

                  I am using an CYBLE$-416045-EVAL board as the base.

                   

                   

                  Have you ever created a FreeRTOS program on a PSoC before?

                  No.

                   

                   

                  Was there a version of this project that was working before?

                  I actually have developed a large amount of real time code that works quite well and uses a UART port for the console output. But I have never been able to get a call to emWin to work. I stripped all that out of the version that I sent to you.

                   

                  Here's what the stack looks like before the crash:

                   

                  Hmmm.. you didn’t seem to reproduce my results. My before/after call stacks showed that the system crashed out in the WM_ActivateClipRect() function.

                  (see attached).

                   

                  Thanks,

                   

                  Ed H.

                  • 6. Re: emWin Bus Fault
                    LePo_1062026

                    Ed,

                     

                    It's possible that your code might go a little further than mine.  This might be because you can communicate (at least in part) to the display.  I have no display therefore there is no feedback to provide the code.

                     

                    Can you put a scope on the SPI lines and verify in part that the Display is receiving and possibly responding to SPI commands?

                     

                    Len

                    • 7. Re: emWin Bus Fault
                      LePo_1062026

                      Ed,

                       

                      I've ordered a ST7789. I hope to get it in about a week.

                      I actually have developed a large amount of real time code that works quite well and uses a UART port for the console output.

                      Did this code run under FreeRTOS?

                       

                      Len

                      • 8. Re: emWin Bus Fault
                        EdHa_4455331

                        I repeat: I do NOT have a display yet. I put breakpoints where the code SHOULD try to communicate with the display. The code never gets there. Therefore, the problem most likely has NOTHING to do with communications with the display.

                        • 9. Re: emWin Bus Fault
                          EdHa_4455331

                          Did this code run under FreeRTOS?

                           

                          Yes.

                          • 10. Re: emWin Bus Fault
                            LePo_1062026

                            Ed,

                             

                            I haven't given up on you or your issue.

                             

                            I've done some deep debugging and found the following.  Here is a hierarchical breakdown where the "Bus Fault" occurs.

                            • Gui_Drawline  ...
                              • WM_Init_IVSearch  ...
                                • WM_ActivateClipRect ...
                                  • 0x100868EA ldmia    r0!, {r1, r2}

                            Within WM_ActivateClipRect there is a call to an assembly "ldmia r0!, {r1, r2}".  Executing this line causes the Bus Fault.

                             

                            Obvious Reason:  ldmia command loads registers r1 then r2 with the 32-bit contents found at the address pointed to by r0.

                            Since r0 = 0x09 (r1 = 0x80242c8 r2 = 0x01)  There is no accessible memory at address 0x09.  This causes a Bus Fault.

                             

                            What ever is loading r0 at this point is not initialized properly.  I'm still in the process to find the reason but without knowing what WM_ActivateClipRect function arguments are, it is a bit difficult.  (Seeger did not include the source code but they did include the address labels in their object code.)

                             

                            Here's a pic of the code and registers and memory @ address 0x09 just before the Bus Fault.

                             

                            More Info:

                            r0 is getting set to 0x09 in the branch to GUI_ALLOC_LOCKH.  (I assume this is GUI allocate a Lock on the Heap)

                            In GUI_ALLOC_LOCKH it branches to GUI_ALLOC_h2p (I assume this is GUI allocate heap to pointer).

                            GUI_ALLOC_h2p is where the return back in r0 - 0x09.

                             

                            Len

                            • 11. Re: emWin Bus Fault
                              LePo_1062026

                              Ed,

                               

                              Even after changing the heap type to other types I still have the same problem.

                               

                              One thing I noticed.  The version of emWin (V5.46) you're using is specified for the PSoC3 and PSoC5.  The PSoC6 middleware version is V5.48.   Is it that this release of emWin not valid for the PSoC6?

                               

                              Len

                              • 12. Re: emWin Bus Fault
                                EdHa_4455331

                                The version v5.46 version of emWin that I am using arrived as part of the PSoc Creator 4.3 package. I haven’t been able to find a place in the Cypress website where I can switch to a particular version of emWin. Can you please give me a link to where I can download v5.48?

                                 

                                Thanks,

                                 

                                Ed H.

                                • 13. Re: emWin Bus Fault
                                  LePo_1062026

                                  Ed,

                                   

                                  To my understanding, V5.48 is only available when it is built as a ModusToolbox project.  In ModusToolbox 2.1, there is no UDB support.

                                   

                                  Len

                                   

                                  PS:  I'm still trying to find out why it's not working under V5.46.

                                  • 14. Re: emWin Bus Fault
                                    LePo_1062026

                                    Ed,

                                     

                                    I may have some additional info.

                                     

                                    Cypress has an example of a PSoC6 driving a ST7789.  The example project is called: CE223726_EmWin_TFT_Display_ST7789.

                                    I recommend you take a look at it.  It does use emWin V5.46.

                                     

                                    There are some differences to your project.  The example doesn't use FreeRTOS (no OS) and the ST7789 is a parallel interface instead of  serial.  These differences may be minor.

                                     

                                    In examining the example code to yours I noticed the following:

                                    • The example only calls GUI_Init(). GUI_X_Config() and LCD_X_Config() are never directly called.  I suspect they are called indirectly through GUI_Init().  This might explain why running GUI_Drawline() eventually crashes because something wasn't setup properly.
                                    • When I replaced your GUI_X_Config() and LCD_X_Config() calls with GUI_Init() it crashes in GUI_Init().  However debug tracing where it crashes I found your _InitController() function in LCDConf.c has an assert(false) which causes the crash.  In the example, _InitController() actually has code in it.   I believe the app designer is required to place meaningful code here to initialize the LCD controller. 
                                      When I removed MasterSpi_Start() from DisplayManagerTask() and placed it in _InitController() and ran the code, GUI_Drawline() gets continually executed in the for(;;) loop in the DisplayManagerTask().  NO CRASHES!!!

                                     

                                    Consider the following changes recommended above.  Besides moving MasterSpi_Start() into _InitController(), you may have to add some LCD SPI commands to initialize the ST7789.  This should be done in this routine.

                                    Additionally reconsider whether DisplayDriverTask() is actually needed.  It appears redundant.

                                     

                                    Len

                                    1 2 3 Previous Next