Skip to content

Commit e933faf

Browse files
KoviRobiaggarg
andauthored
Fix build of & add CMake to LM3S Qemu Demo (FreeRTOS#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>
1 parent 1aa4785 commit e933faf

File tree

9 files changed

+159
-10
lines changed

9 files changed

+159
-10
lines changed

FreeRTOS/Demo/CORTEX_LM3S6965_GCC_QEMU/.cproject

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@
202202
</tool>
203203
</fileInfo>
204204
<sourceEntries>
205-
<entry excluding="FreeRTOS+Trace Recorder" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
205+
<entry excluding="FreeRTOS_Source/examples|build|FreeRTOS+Trace Recorder" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
206206
</sourceEntries>
207207
</configuration>
208208
</storageModule>
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
cmake_minimum_required(VERSION 3.21)
2+
3+
project(RTOSDemo LANGUAGES C ASM)
4+
5+
set(FREERTOS_BASE "${CMAKE_CURRENT_LIST_DIR}/../../")
6+
set(FREERTOS_PORT GCC_ARM_CM3)
7+
set(FREERTOS_HEAP 4)
8+
add_library(freertos_config INTERFACE)
9+
target_include_directories(freertos_config INTERFACE .)
10+
add_subdirectory("${FREERTOS_BASE}/Source" FreeRTOS_kernel)
11+
12+
add_executable(RTOSDemo
13+
startup.c
14+
main.c
15+
LocalDemoFiles/IntQueueTimer.c
16+
LocalDemoFiles/osram128x64x4.c
17+
LocalDemoFiles/printf-stdarg.c
18+
LocalDemoFiles/timertest.c
19+
20+
../Common/Minimal/blocktim.c
21+
../Common/Minimal/death.c
22+
../Common/Minimal/EventGroupsDemo.c
23+
../Common/Minimal/IntQueue.c
24+
../Common/Minimal/MessageBufferDemo.c
25+
../Common/Minimal/QPeek.c
26+
../Common/Minimal/QueueSet.c
27+
../Common/Minimal/recmutex.c
28+
../Common/Minimal/semtest.c
29+
../Common/Minimal/StreamBufferDemo.c
30+
31+
../Common/drivers/LuminaryMicro/ustdlib.c
32+
)
33+
target_include_directories(RTOSDemo PUBLIC
34+
.
35+
LocalDemoFiles
36+
../Common/include
37+
../Common/drivers/LuminaryMicro
38+
)
39+
target_link_libraries(RTOSDemo PUBLIC
40+
freertos_kernel
41+
"${CMAKE_CURRENT_LIST_DIR}/../Common/drivers/LuminaryMicro/arm-none-eabi-gcc/libdriver.a"
42+
"${CMAKE_CURRENT_LIST_DIR}/../Common/drivers/LuminaryMicro/arm-none-eabi-gcc/libgr.a"
43+
)
44+
45+
add_custom_target(run
46+
COMMAND qemu-system-arm
47+
-machine lm3s6965evb
48+
-monitor null
49+
-semihosting
50+
--semihosting-config enable=on,target=native
51+
-serial stdio
52+
-nographic
53+
-s # gdb tcp::1234
54+
-S
55+
-kernel $<TARGET_FILE:RTOSDemo>
56+
VERBATIM COMMAND_EXPAND_LISTS
57+
COMMENT "You can now attach GDB to localhost:1234"
58+
)
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"version": 6,
3+
"configurePresets": [
4+
{
5+
"name": "debug",
6+
"toolchainFile": "gcc-arm-embedded.cmake",
7+
"binaryDir": "build",
8+
"generator": "Ninja",
9+
"cacheVariables": {
10+
"CMAKE_BUILD_TYPE": "debug",
11+
"CMAKE_EXPORT_COMPILE_COMMANDS": true
12+
}
13+
}
14+
],
15+
"buildPresets": [
16+
{
17+
"name": "debug",
18+
"configurePreset": "debug"
19+
}
20+
],
21+
"workflowPresets": [
22+
{
23+
"name": "debug",
24+
"steps": [
25+
{
26+
"type": "configure",
27+
"name": "debug"
28+
},
29+
{
30+
"type": "build",
31+
"name": "debug"
32+
}
33+
]
34+
}
35+
]
36+
}

FreeRTOS/Demo/CORTEX_LM3S6965_GCC_QEMU/FreeRTOSConfig.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ FreeRTOS/Source/tasks.c for limitations. */
9595
#define configKERNEL_INTERRUPT_PRIORITY ( 255 ) /* All eight bits as QEMU doesn't model the priority bits. */
9696
/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!
9797
See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
98-
#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( 4 )
98+
#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( 0x40 )
9999

100100
/* Use the Cortex-M3 optimised task selection rather than the generic C code
101101
version. */
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
qemu-system-arm -machine lm3s6965evb -s -S -kernel ./debug/RTOSDemo.elf
2-
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
set(CMAKE_SYSTEM_NAME Generic)
2+
set(CMAKE_SYSTEM_PROCESSOR arm)
3+
4+
set(CMAKE_TOOLCHAIN_PREFIX arm-none-eabi-)
5+
6+
set(CMAKE_C_COMPILER ${CMAKE_TOOLCHAIN_PREFIX}gcc)
7+
set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER})
8+
set(CMAKE_CXX_COMPILER ${CMAKE_TOOLCHAIN_PREFIX}g++)
9+
set(CMAKE_LINKER ${CMAKE_TOOLCHAIN_PREFIX}gcc)
10+
set(CMAKE_OBJCOPY ${CMAKE_TOOLCHAIN_PREFIX}objcopy)
11+
set(CMAKE_SIZE ${CMAKE_TOOLCHAIN_PREFIX}size)
12+
13+
set(CMAKE_EXECUTABLE_SUFFIX_ASM ".elf")
14+
set(CMAKE_EXECUTABLE_SUFFIX_C ".elf")
15+
set(CMAKE_EXECUTABLE_SUFFIX_CXX ".elf")
16+
17+
# Adjust the default behavior of the FIND_XXX() commands:
18+
# - Search programs in the host environment
19+
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
20+
# - Search headers and libraries in the target environment
21+
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
22+
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
23+
24+
# Don't try to execute linked programs
25+
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
26+
27+
set(CMAKE_C_FLAGS_INIT "-mcpu=cortex-m3 -mthumb")
28+
set(CMAKE_C_FLAGS_INIT "${CMAKE_C_FLAGS_INIT} --specs=nano.specs")
29+
30+
# Always build debug information (stripped out for executable)
31+
# Add `-g3` to put macro values into debug information
32+
if(CMAKE_BUILD_TYPE MATCHES Debug)
33+
set(CMAKE_C_FLAGS_INIT "${CMAKE_C_FLAGS_INIT} -O0 -g3")
34+
endif()
35+
if(CMAKE_BUILD_TYPE MATCHES Release)
36+
set(CMAKE_C_FLAGS_INIT "${CMAKE_C_FLAGS_INIT} -O3 -g3")
37+
endif()
38+
if(CMAKE_BUILD_TYPE MATCHES MinSizeRel)
39+
set(CMAKE_C_FLAGS_INIT "${CMAKE_C_FLAGS_INIT} -Os -g3")
40+
endif()
41+
42+
set(CMAKE_ASM_FLAGS_INIT "${CMAKE_C_FLAGS_INIT} -x assembler-with-cpp")
43+
set(CMAKE_CXX_FLAGS_INIT "${CMAKE_C_FLAGS_INIT} -fno-rtti -fno-exceptions")
44+
45+
set(CMAKE_ASM_LINK_FLAGS "-T ${CMAKE_CURRENT_LIST_DIR}/standalone.ld -nostartfiles")
46+
set(CMAKE_ASM_LINK_FLAGS "${CMAKE_ASM_LINK_FLAGS} -Wl,-Map=${CMAKE_PROJECT_NAME}.map")
47+
set(CMAKE_ASM_LINK_FLAGS "${CMAKE_ASM_LINK_FLAGS} -Wl,--print-memory-usage")
48+
49+
set(CMAKE_C_LINK_FLAGS "${CMAKE_ASM_LINK_FLAGS} -Wl,--start-group -lc -lm -Wl,--end-group")
50+
set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -ffunction-sections -fdata-sections -Wl,--gc-sections")
51+
52+
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -Wl,--start-group -lstdc++ -lsupc++ -Wl,--end-group")

FreeRTOS/Demo/CORTEX_LM3S6965_GCC_QEMU/standalone.ld

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,24 @@
44
* DriverLib.
55
*
66
* Copyright (c) 2005-2007 Luminary Micro, Inc. All rights reserved.
7-
*
7+
*
88
* Software License Agreement
9-
*
9+
*
1010
* Luminary Micro, Inc. (LMI) is supplying this software for use solely and
1111
* exclusively on LMI's microcontroller products.
12-
*
12+
*
1313
* The software is owned by LMI and/or its suppliers, and is protected under
1414
* applicable copyright laws. All rights are reserved. Any use in violation
1515
* of the foregoing restrictions may subject the user to criminal sanctions
1616
* under applicable laws, as well as to civil liability for the breach of the
1717
* terms and conditions of this license.
18-
*
18+
*
1919
* THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
2020
* OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
2121
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
2222
* LMI SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
2323
* CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
24-
*
24+
*
2525
* This is part of revision 1392 of the Stellaris Peripheral Driver Library.
2626
*
2727
*****************************************************************************/
@@ -57,4 +57,9 @@ SECTIONS
5757
*(COMMON)
5858
_ebss = .;
5959
} > SRAM
60+
61+
/DISCARD/ :
62+
{
63+
*(.ARM.exidx)
64+
}
6065
}

FreeRTOS/Demo/CORTEX_LM3S6965_GCC_QEMU/startup.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,4 +252,3 @@ uipprintf(const char *fmt, ...)
252252
( void ) fmt;
253253
return(0);
254254
}
255-

FreeRTOS/Demo/CORTEX_LM3S6965_GCC_QEMU/trcConfig.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ __attribute__( ( always_inline ) ) static inline void __set_PRIMASK(uint32_t pri
123123
* trace recorder library with an older version of FreeRTOS).
124124
*
125125
* TRC_FREERTOS_VERSION_7_3_X If using FreeRTOS v7.3.X
126-
* TRC_FREERTOS_VERSION_7_4_X If using FreeRTOS v7.4.X
126+
* TRC_FREERTOS_VERSION_7_4_X If using FreeRTOS v7.4.X
127127
* TRC_FREERTOS_VERSION_7_5_X If using FreeRTOS v7.5.X
128128
* TRC_FREERTOS_VERSION_7_6_X If using FreeRTOS v7.6.X
129129
* TRC_FREERTOS_VERSION_8_X_X If using FreeRTOS v8.X.X

0 commit comments

Comments
 (0)