You copied the Doc URL to your clipboard.

Why 'debug_tests' and 'trace_tests' in CMSDK stall when using ARM GCC for compilation

Article ID: 103489477

Published date: 24 Jul 2017

Last updated: -

Applies to: Cortex-M0, Cortex-M0Plus, Cortex-M3, Cortex-M4, Cortex-M System Design Kit (CMSDK)

Problem/Question

Why do "debug_tests" and "trace_tests" in CMSDK stall when using ARM GCC for compilation?

Scenario

This Knowledge Article is for chip designers who are using ARM's Cortex-M System Design Kit (CMSDK) to design a chip containing a Cortex-M processor.

The debug_tests and trace_tests of the CMSDK go into unexpected HardFault and cannot finish if one of the following versions of ARM GCC has been used for compilation:

    • arm-none-eabi-gcc-4.9.3

      • arm-none-eabi-gcc-5.2.1

        • arm-none-eabi-gcc-5.3.1

          • arm-none-eabi-gcc-5.4.1

          The problem does not occur if the following ARM GCC versions have been used:

            • arm-none-eabi-gcc-4.6.2

              • arm-none-eabi-gcc-4.7.3

                • arm-none-eabi-gcc-4.7.4

                  • arm-none-eabi-gcc-4.8.3

                    • arm-none-eabi-gcc-4.8.4

                    Other ARM GCC versions have not been tested, but it is likely that versions after arm-none-eabi-gcc-4.8.4 will cause the same issue.

                    Answer

                    The problem is caused by null pointer dereferencing in debug_tests and trace_tests, which are undefined and lead the ARM GCC compiler to optimize them away and replace them with UDF (Undefined) instructions. The UDF instructions ultimately cause a HardFault in the simulation.

                    Workaround

                    The workaround for the problem is to reduce the compiler's optimization by modifying the appropriate makefiles.

                    In case of Cortex-M3/M4

                      • open <CMSDK folder>/system/cortex_m_mcu/testcodes/trace_tests/makefile

                        • go to line 151

                          • append the following compiler option to the end of the line

                              • -fno-delete-null-pointer-checks
                            • open <CMSDK folder>/system/cortex_m_mcu/testcodes/debug_tests/makefile

                              • go to line 154

                                • append the following compiler option to the end of the line

                                    • -fno-delete-null-pointer-checks

                                  In case of Cortex-M0/M0+

                                    • open <CMSDK folder>/system/cortex_m0_mcu/testcodes/debug_tests/makefile

                                      • go to line 147

                                        • append the following compiler option to the end of the line

                                            • -fno-delete-null-pointer-checks

                                          Example

                                          No example.

                                          Related Information

                                          None.

                                          Was this page helpful? Yes No