The example from Segger does not work

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

    • The example from Segger does not work

      Hello!
      I'm studying the example MOTION_SmartFoneMenu.

      This is from the package: SeggerEval_WIN32_MSVC_MinGW_GUI_V546 \ Sample \ Tutorial \ MOTION_SmartFoneMenu

      After the firmware, the following error occurs in the microcontroller

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



      Regards,
      shal
      Images
      • err_MotionMenu.png

        18.16 kB, 429×544, viewed 68 times
    • Dear shal,

      It seems the hardfault was caused by an unaligned memory access.
      Does your application use the STM32F7's external SDRAM?
      If so, the hardfault is probably related to the hardware's memory specifications.

      This is for the reason that the STM32F7's SDRAM is mapped to 0xC0000000 - 0xC03FFFFF.
      That area, however, is specified as device memory type according to the ARMv7-M architecture.
      This means that all accesses to this area must be naturally aligned, whereas any unaligned access will cause a hardfault.

      In case this is what causes the observed issue, there's several ways to avoid this:
      - Using the STM32F7's MPU to re-configure the respective area to normal memory type instead of device memory type.
      - Remapping the SDRAM to a different address.
      - Preventing the compiler from generating any unaligned accesses.

      Best regards,
      Martin
    • Solved!

      Hello!

      Thank you for your reply! :)

      The solution is as follows:

      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

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