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>
This commit is contained in:
Kovacsics Robert 2025-08-15 08:18:14 +01:00 committed by GitHub
parent 1aa47857a0
commit e933faf3ee
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 159 additions and 10 deletions

View file

@ -202,7 +202,7 @@
</tool> </tool>
</fileInfo> </fileInfo>
<sourceEntries> <sourceEntries>
<entry excluding="FreeRTOS+Trace Recorder" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/> <entry excluding="FreeRTOS_Source/examples|build|FreeRTOS+Trace Recorder" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
</sourceEntries> </sourceEntries>
</configuration> </configuration>
</storageModule> </storageModule>

View file

@ -0,0 +1,58 @@
cmake_minimum_required(VERSION 3.21)
project(RTOSDemo LANGUAGES C ASM)
set(FREERTOS_BASE "${CMAKE_CURRENT_LIST_DIR}/../../")
set(FREERTOS_PORT GCC_ARM_CM3)
set(FREERTOS_HEAP 4)
add_library(freertos_config INTERFACE)
target_include_directories(freertos_config INTERFACE .)
add_subdirectory("${FREERTOS_BASE}/Source" FreeRTOS_kernel)
add_executable(RTOSDemo
startup.c
main.c
LocalDemoFiles/IntQueueTimer.c
LocalDemoFiles/osram128x64x4.c
LocalDemoFiles/printf-stdarg.c
LocalDemoFiles/timertest.c
../Common/Minimal/blocktim.c
../Common/Minimal/death.c
../Common/Minimal/EventGroupsDemo.c
../Common/Minimal/IntQueue.c
../Common/Minimal/MessageBufferDemo.c
../Common/Minimal/QPeek.c
../Common/Minimal/QueueSet.c
../Common/Minimal/recmutex.c
../Common/Minimal/semtest.c
../Common/Minimal/StreamBufferDemo.c
../Common/drivers/LuminaryMicro/ustdlib.c
)
target_include_directories(RTOSDemo PUBLIC
.
LocalDemoFiles
../Common/include
../Common/drivers/LuminaryMicro
)
target_link_libraries(RTOSDemo PUBLIC
freertos_kernel
"${CMAKE_CURRENT_LIST_DIR}/../Common/drivers/LuminaryMicro/arm-none-eabi-gcc/libdriver.a"
"${CMAKE_CURRENT_LIST_DIR}/../Common/drivers/LuminaryMicro/arm-none-eabi-gcc/libgr.a"
)
add_custom_target(run
COMMAND qemu-system-arm
-machine lm3s6965evb
-monitor null
-semihosting
--semihosting-config enable=on,target=native
-serial stdio
-nographic
-s # gdb tcp::1234
-S
-kernel $<TARGET_FILE:RTOSDemo>
VERBATIM COMMAND_EXPAND_LISTS
COMMENT "You can now attach GDB to localhost:1234"
)

View file

@ -0,0 +1,36 @@
{
"version": 6,
"configurePresets": [
{
"name": "debug",
"toolchainFile": "gcc-arm-embedded.cmake",
"binaryDir": "build",
"generator": "Ninja",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "debug",
"CMAKE_EXPORT_COMPILE_COMMANDS": true
}
}
],
"buildPresets": [
{
"name": "debug",
"configurePreset": "debug"
}
],
"workflowPresets": [
{
"name": "debug",
"steps": [
{
"type": "configure",
"name": "debug"
},
{
"type": "build",
"name": "debug"
}
]
}
]
}

View file

@ -95,7 +95,7 @@ FreeRTOS/Source/tasks.c for limitations. */
#define configKERNEL_INTERRUPT_PRIORITY ( 255 ) /* All eight bits as QEMU doesn't model the priority bits. */ #define configKERNEL_INTERRUPT_PRIORITY ( 255 ) /* All eight bits as QEMU doesn't model the priority bits. */
/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!! /* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!
See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */ See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( 4 ) #define configMAX_SYSCALL_INTERRUPT_PRIORITY ( 0x40 )
/* Use the Cortex-M3 optimised task selection rather than the generic C code /* Use the Cortex-M3 optimised task selection rather than the generic C code
version. */ version. */

View file

@ -1,2 +1 @@
qemu-system-arm -machine lm3s6965evb -s -S -kernel ./debug/RTOSDemo.elf qemu-system-arm -machine lm3s6965evb -s -S -kernel ./debug/RTOSDemo.elf

View file

@ -0,0 +1,52 @@
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")

View file

@ -4,24 +4,24 @@
* DriverLib. * DriverLib.
* *
* Copyright (c) 2005-2007 Luminary Micro, Inc. All rights reserved. * Copyright (c) 2005-2007 Luminary Micro, Inc. All rights reserved.
* *
* Software License Agreement * Software License Agreement
* *
* Luminary Micro, Inc. (LMI) is supplying this software for use solely and * Luminary Micro, Inc. (LMI) is supplying this software for use solely and
* exclusively on LMI's microcontroller products. * exclusively on LMI's microcontroller products.
* *
* The software is owned by LMI and/or its suppliers, and is protected under * The software is owned by LMI and/or its suppliers, and is protected under
* applicable copyright laws. All rights are reserved. Any use in violation * applicable copyright laws. All rights are reserved. Any use in violation
* of the foregoing restrictions may subject the user to criminal sanctions * of the foregoing restrictions may subject the user to criminal sanctions
* under applicable laws, as well as to civil liability for the breach of the * under applicable laws, as well as to civil liability for the breach of the
* terms and conditions of this license. * terms and conditions of this license.
* *
* THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
* OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
* LMI SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR * LMI SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
* CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
* *
* This is part of revision 1392 of the Stellaris Peripheral Driver Library. * This is part of revision 1392 of the Stellaris Peripheral Driver Library.
* *
*****************************************************************************/ *****************************************************************************/
@ -57,4 +57,9 @@ SECTIONS
*(COMMON) *(COMMON)
_ebss = .; _ebss = .;
} > SRAM } > SRAM
/DISCARD/ :
{
*(.ARM.exidx)
}
} }

View file

@ -252,4 +252,3 @@ uipprintf(const char *fmt, ...)
( void ) fmt; ( void ) fmt;
return(0); return(0);
} }

View file

@ -123,7 +123,7 @@ __attribute__( ( always_inline ) ) static inline void __set_PRIMASK(uint32_t pri
* trace recorder library with an older version of FreeRTOS). * trace recorder library with an older version of FreeRTOS).
* *
* TRC_FREERTOS_VERSION_7_3_X If using FreeRTOS v7.3.X * TRC_FREERTOS_VERSION_7_3_X If using FreeRTOS v7.3.X
* TRC_FREERTOS_VERSION_7_4_X If using FreeRTOS v7.4.X * TRC_FREERTOS_VERSION_7_4_X If using FreeRTOS v7.4.X
* TRC_FREERTOS_VERSION_7_5_X If using FreeRTOS v7.5.X * TRC_FREERTOS_VERSION_7_5_X If using FreeRTOS v7.5.X
* TRC_FREERTOS_VERSION_7_6_X If using FreeRTOS v7.6.X * TRC_FREERTOS_VERSION_7_6_X If using FreeRTOS v7.6.X
* TRC_FREERTOS_VERSION_8_X_X If using FreeRTOS v8.X.X * TRC_FREERTOS_VERSION_8_X_X If using FreeRTOS v8.X.X