HardFalt when rendering PNG (STM32F746g disco)

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • HardFalt when rendering PNG (STM32F746g disco)

      Hi !
      A HardFalt error occurred while drawing PNG

      Source Code

      1. pData = _GetImageById(ID_IMAGE_0_IMAGE_0, &FileSize);
      2. IMAGE_SetPNG(hItem, pData, FileSize);

      What could be the problem?
      The program code in the attachment

      I use:
      STM32F746g discovery
      STemWin540_CM7_IAR.a
      IAR C/C++ Compiler for ARM 7.50.2.10312 (7.50.2.10312)
      png and zlib libraries

      Regards,
      shal
      Images
      • slide1.PNG

        1.95 kB, 244×65, viewed 611 times
      Files
      • arch.zip

        (18.1 kB, downloaded 436 times, last: )
    • The stack size in the project is 0x2000

      The PNG picture is not drawn when using Windows Manager, but using GUI_PNG_Draw() - draws.

      I need to draw using WM :)

      The post was edited 1 time, last by shal ().

    • Hi Shal,


      You have allocated 128Kb of memory for EMWIN from microcontrollers ram. (GUIConfig.c file).

      //
      // Define the available number of bytes available for the GUI
      //
      #define GUI_NUMBYTES ( 128 * 1024) //4*1024

      //
      // 32 bit aligned memory area
      //
      static __no_init U32 g_emWinMemory[GUI_NUMBYTES / 4];// @ 0xC0400000;


      Try allocating it into SDRAM Space, by modifying above code as follows.
      static __no_init U32 g_emWinMemory[GUI_NUMBYTES / 4] @ 0xC0400000;
    • From what I remembered the png lib need to allocate at least 1 MB of memory (emwin replaced malloc function by emwin_alloc in the pool).
      I compiled the distributed lib by segger by my own with keil, in debug mode.
      I remembered that when missing memory the lib clearly pointed it out.

      Also it would be interesting to send us the call stack, or try using the fault analyzer in IAR (if there is one).
    • Solved!

      Hello!

      Thank you for your answers.

      Before initializing emWin, you need to configure the MPU with the following function:


      C Source Code

      1. static void MPU_Config()
      2. {
      3. MPU_Region_InitTypeDef MPU_InitStruct;
      4. /* Disable the MPU */
      5. HAL_MPU_Disable();
      6. /* Configure the MPU attributes for SDRAM */
      7. MPU_InitStruct.Enable = MPU_REGION_ENABLE;
      8. MPU_InitStruct.BaseAddress = 0xC0000000;
      9. MPU_InitStruct.Size = MPU_REGION_SIZE_8MB; //MPU_REGION_SIZE_4MB;
      10. MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;
      11. MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;
      12. MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;
      13. MPU_InitStruct.IsShareable = MPU_ACCESS_NOT_SHAREABLE;
      14. MPU_InitStruct.Number = MPU_REGION_NUMBER0;
      15. MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL1;
      16. MPU_InitStruct.SubRegionDisable = 0x00;
      17. MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_DISABLE;
      18. HAL_MPU_ConfigRegion(&MPU_InitStruct);
      19. /* Enable the MPU */
      20. HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT);
      21. }
      Display All