FreeRTOS-Kernel/FreeRTOS/Demo/CORTEX_LM3S6965_GCC_QEMU/gcc-arm-embedded.cmake
Kovacsics Robert e933faf3ee
Fix build of & add CMake to LM3S Qemu Demo (#1368)
* Demo/CORTEX_LM3S6965_GCC_QEMU: Trim trailing spaces & lines

* Demo/CORTEX_LM3S6965_GCC_QEMU: Fix Eclipse build 1/2 (examples)

It was trying to build the examples, which pulled in symbols such as
`_write` that are not implemented.

* Demo/CORTEX_LM3S6965_GCC_QEMU: Fix Eclipse build 1/2 (discard .ARM.exidx)

Somewhere along the line now there is the .ARM.exidx section in the
files, we don't use exceptions so can just discard it.

* Demo/CORTEX_LM3S6965_GCC_QEMU: Add CMake

* Debug/CORTEX_LM3S6965_GCC_QEMU: Fix Qemu startup

It was tripping on port.c

        /* Check that the maximum system call priority is nonzero after
         * accounting for the number of priority bits supported by the
         * hardware. A priority of 0 is invalid because setting the BASEPRI
         * register to 0 unmasks all interrupts, and interrupts with priority 0
         * cannot be masked using BASEPRI.
         * See https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
        configASSERT( ucMaxSysCallPriority );

Inspecting the value ucMaxPriorityValue gave 0xE0, and setting it to
0xE0 complains about overflow in
FreeRTOS/Demo/CORTEX_LM3S6965_GCC_QEMU/LocalDemoFiles/IntQueueTimer.c:57

    /* Shift left 5 as only the top 3 bits are implemented. */
    IntPrioritySet( INT_TIMER2A, configMAX_SYSCALL_INTERRUPT_PRIORITY + ( 1 << 5 ) );

* Add qemu options to run in headless mode

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>

---------

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
Co-authored-by: Gaurav Aggarwal <aggarg@amazon.com>
2025-08-15 12:48:14 +05:30

52 lines
2.1 KiB
CMake

set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(CMAKE_TOOLCHAIN_PREFIX arm-none-eabi-)
set(CMAKE_C_COMPILER ${CMAKE_TOOLCHAIN_PREFIX}gcc)
set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER})
set(CMAKE_CXX_COMPILER ${CMAKE_TOOLCHAIN_PREFIX}g++)
set(CMAKE_LINKER ${CMAKE_TOOLCHAIN_PREFIX}gcc)
set(CMAKE_OBJCOPY ${CMAKE_TOOLCHAIN_PREFIX}objcopy)
set(CMAKE_SIZE ${CMAKE_TOOLCHAIN_PREFIX}size)
set(CMAKE_EXECUTABLE_SUFFIX_ASM ".elf")
set(CMAKE_EXECUTABLE_SUFFIX_C ".elf")
set(CMAKE_EXECUTABLE_SUFFIX_CXX ".elf")
# Adjust the default behavior of the FIND_XXX() commands:
# - Search programs in the host environment
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# - Search headers and libraries in the target environment
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
# Don't try to execute linked programs
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
set(CMAKE_C_FLAGS_INIT "-mcpu=cortex-m3 -mthumb")
set(CMAKE_C_FLAGS_INIT "${CMAKE_C_FLAGS_INIT} --specs=nano.specs")
# Always build debug information (stripped out for executable)
# Add `-g3` to put macro values into debug information
if(CMAKE_BUILD_TYPE MATCHES Debug)
set(CMAKE_C_FLAGS_INIT "${CMAKE_C_FLAGS_INIT} -O0 -g3")
endif()
if(CMAKE_BUILD_TYPE MATCHES Release)
set(CMAKE_C_FLAGS_INIT "${CMAKE_C_FLAGS_INIT} -O3 -g3")
endif()
if(CMAKE_BUILD_TYPE MATCHES MinSizeRel)
set(CMAKE_C_FLAGS_INIT "${CMAKE_C_FLAGS_INIT} -Os -g3")
endif()
set(CMAKE_ASM_FLAGS_INIT "${CMAKE_C_FLAGS_INIT} -x assembler-with-cpp")
set(CMAKE_CXX_FLAGS_INIT "${CMAKE_C_FLAGS_INIT} -fno-rtti -fno-exceptions")
set(CMAKE_ASM_LINK_FLAGS "-T ${CMAKE_CURRENT_LIST_DIR}/standalone.ld -nostartfiles")
set(CMAKE_ASM_LINK_FLAGS "${CMAKE_ASM_LINK_FLAGS} -Wl,-Map=${CMAKE_PROJECT_NAME}.map")
set(CMAKE_ASM_LINK_FLAGS "${CMAKE_ASM_LINK_FLAGS} -Wl,--print-memory-usage")
set(CMAKE_C_LINK_FLAGS "${CMAKE_ASM_LINK_FLAGS} -Wl,--start-group -lc -lm -Wl,--end-group")
set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -ffunction-sections -fdata-sections -Wl,--gc-sections")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -Wl,--start-group -lstdc++ -lsupc++ -Wl,--end-group")