Demo/Posix_GCC: add demo application for Posix port using GCC

This is largely a copy of the Windows demo application with a few key
changes:

- heap_3 (use malloc()/free()) so tools like valgrind "just work".

- printf() wrapped in a mutex to prevent deadlocks on the internal
  pthread mutexes inside printf().

SCons (https://scons.org/) is used as the build system.

This will be built as a 64-bit application, but note that the memory
allocation trace points only record the lower 32-bits of the address.
This commit is contained in:
David Vrabel 2020-03-16 11:21:46 +00:00 committed by Yuhui Zheng
parent f78f919b3e
commit 9f316c246b
13 changed files with 3318 additions and 0 deletions

View file

@ -0,0 +1,124 @@
# FreeRTOS Kernel V10.3.0
# Copyright (C) 2020 Cambridge Consultants Ltd.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
# the Software, and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# http://www.FreeRTOS.org
# http://aws.amazon.com/freertos
Import("env")
env.Append(CPPPATH = [
".",
"FreeRTOS/Source/include",
"FreeRTOS/Source/portable/ThirdParty/GCC/Posix",
"FreeRTOS/Demo/Common/include",
"FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include",
])
env.Append(LIBS = [
"pthread",
])
src = [
"console.c",
"main.c",
"main_blinky.c",
"main_full.c",
"run-time-stats-utils.c",
# FreeRTOS kernel
"FreeRTOS/Source/event_groups.c",
"FreeRTOS/Source/list.c",
"FreeRTOS/Source/queue.c",
"FreeRTOS/Source/stream_buffer.c",
"FreeRTOS/Source/tasks.c",
"FreeRTOS/Source/timers.c",
# Memory manager (use malloc()/free()).
"FreeRTOS/Source/portable/MemMang/heap_3.c",
# Posix port.
"FreeRTOS/Source/portable/ThirdParty/GCC/Posix/port.c",
# Demo library.
"FreeRTOS/Demo/Common/Minimal/AbortDelay.c",
"FreeRTOS/Demo/Common/Minimal/BlockQ.c",
"FreeRTOS/Demo/Common/Minimal/blocktim.c",
"FreeRTOS/Demo/Common/Minimal/countsem.c",
"FreeRTOS/Demo/Common/Minimal/death.c",
"FreeRTOS/Demo/Common/Minimal/dynamic.c",
"FreeRTOS/Demo/Common/Minimal/EventGroupsDemo.c",
"FreeRTOS/Demo/Common/Minimal/flop.c",
"FreeRTOS/Demo/Common/Minimal/GenQTest.c",
"FreeRTOS/Demo/Common/Minimal/integer.c",
"FreeRTOS/Demo/Common/Minimal/IntSemTest.c",
"FreeRTOS/Demo/Common/Minimal/MessageBufferAMP.c",
"FreeRTOS/Demo/Common/Minimal/MessageBufferDemo.c",
"FreeRTOS/Demo/Common/Minimal/PollQ.c",
"FreeRTOS/Demo/Common/Minimal/QPeek.c",
"FreeRTOS/Demo/Common/Minimal/QueueOverwrite.c",
"FreeRTOS/Demo/Common/Minimal/QueueSet.c",
"FreeRTOS/Demo/Common/Minimal/QueueSetPolling.c",
"FreeRTOS/Demo/Common/Minimal/recmutex.c",
"FreeRTOS/Demo/Common/Minimal/semtest.c",
"FreeRTOS/Demo/Common/Minimal/StaticAllocation.c",
"FreeRTOS/Demo/Common/Minimal/StreamBufferDemo.c",
"FreeRTOS/Demo/Common/Minimal/StreamBufferInterrupt.c",
"FreeRTOS/Demo/Common/Minimal/TaskNotify.c",
"FreeRTOS/Demo/Common/Minimal/TimerDemo.c",
]
if GetOption("coverage"):
env.Append(CPPDEFINES = [
"projCOVERAGE_TEST=1",
])
env.Append(CFLAGS = [
"-fprofile-arcs",
"-ftest-coverage",
])
env.Append(LINKFLAGS = [
"-fprofile-arcs",
"-ftest-coverage",
])
src += [
"code_coverage_additions.c",
]
else:
env.Append(CPPDEFINES = [
"projCOVERAGE_TEST=0",
])
src += [
# Trace library.
"FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcKernelPort.c",
"FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcSnapshotRecorder.c",
"FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcStreamingRecorder.c",
"FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/File/trcStreamingPort.c",
]
# Build the simple "blinky" demo application, or the full test
# applicaton?
if GetOption("simple"):
env.Append(CPPDEFINES = [
"mainCREATE_SIMPLE_BLINKY_DEMO_ONLY=1",
])
env.Program("posix_demo", src)