Add a GCC build to the QEMU/IAR project (#728)
* Rename the CORTEX_MPS2_QEMU_IAR directory to CORTEX_MPS2_QEMU_IAR_GCC * Add makefile and startup.c. * GCC build is working, but not yet running. * Add eclipse project. * Tidy up the linker file. Add the debug launch file to the file system. * Add printf-stdarg.c to the GCC build. * Increase heap size for the GCC build. * Copy IAR project files into a dedicated IAR build directory. * Delete the IAR project from its original location now it is in its own build directory. * Update headers to correct version number. * Update lexicon.txt. * Update core_checker.py. * Change line endings in lexicon.txt. * Increase the stack size of the task that prints out strings. * Update linker script to build with older ld versions. * Add links to the online documentation page for this demo. * Fix line endings Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com> * Remove linker and project files from header check Eclipse project files have names .project and .cproject. Python splitext will treat these as file names and not as extension and as a result, it is not enough to just add these to ignored extension list. Instead, we need to add them to ignored files list. Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com> * Remove startup files from header check Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com> Co-authored-by: RichardBarry <richardbarry.c@gmail.com> Co-authored-by: none <> Co-authored-by: Gaurav Aggarwal <aggarg@amazon.com>pull/748/head
parent
21f2799392
commit
dc263aa3a2
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,5 @@
|
||||
[{000214A0-0000-0000-C000-000000000046}]
|
||||
Prop3=19,11
|
||||
[InternetShortcut]
|
||||
IDList=
|
||||
URL=https://www.freertos.org/freertos-on-qemu-mps2-an385-model.html
|
@ -0,0 +1,61 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
|
||||
<storageModule moduleId="org.eclipse.cdt.core.settings">
|
||||
<cconfiguration id="cdt.managedbuild.toolchain.gnu.cross.base.330997021">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.toolchain.gnu.cross.base.330997021" moduleId="org.eclipse.cdt.core.settings" name="Default">
|
||||
<externalSettings/>
|
||||
<extensions>
|
||||
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration buildProperties="" description="" id="cdt.managedbuild.toolchain.gnu.cross.base.330997021" name="Default" optionalBuildProperties="" parent="org.eclipse.cdt.build.core.emptycfg">
|
||||
<folderInfo id="cdt.managedbuild.toolchain.gnu.cross.base.330997021.1663168963" name="/" resourcePath="">
|
||||
<toolChain id="cdt.managedbuild.toolchain.gnu.cross.base.1196792679" name="Cross GCC" superClass="cdt.managedbuild.toolchain.gnu.cross.base">
|
||||
<option id="cdt.managedbuild.option.gnu.cross.prefix.6922571" name="Prefix" superClass="cdt.managedbuild.option.gnu.cross.prefix"/>
|
||||
<option id="cdt.managedbuild.option.gnu.cross.path.271060658" name="Path" superClass="cdt.managedbuild.option.gnu.cross.path"/>
|
||||
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.targetPlatform.gnu.cross.654185196" isAbstract="false" osList="all" superClass="cdt.managedbuild.targetPlatform.gnu.cross"/>
|
||||
<builder id="cdt.managedbuild.builder.gnu.cross.1009432283" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="cdt.managedbuild.builder.gnu.cross"/>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cross.c.compiler.1391085233" name="Cross GCC Compiler" superClass="cdt.managedbuild.tool.gnu.cross.c.compiler">
|
||||
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1754740170" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cross.cpp.compiler.1564031466" name="Cross G++ Compiler" superClass="cdt.managedbuild.tool.gnu.cross.cpp.compiler">
|
||||
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.799786214" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cross.c.linker.13091740" name="Cross GCC Linker" superClass="cdt.managedbuild.tool.gnu.cross.c.linker"/>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cross.cpp.linker.302675999" name="Cross G++ Linker" superClass="cdt.managedbuild.tool.gnu.cross.cpp.linker">
|
||||
<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.1405236271" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
|
||||
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
||||
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
|
||||
</inputType>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cross.archiver.1465394660" name="Cross GCC Archiver" superClass="cdt.managedbuild.tool.gnu.cross.archiver"/>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cross.assembler.1569045660" name="Cross GCC Assembler" superClass="cdt.managedbuild.tool.gnu.cross.assembler">
|
||||
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.65276216" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
|
||||
</tool>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
</cconfiguration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<project id="FreeRTOSDemo.null.149924748" name="FreeRTOSDemo"/>
|
||||
</storageModule>
|
||||
<storageModule moduleId="scannerConfiguration">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
|
||||
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
|
||||
<storageModule moduleId="refreshScope" versionNumber="2">
|
||||
<configuration configurationName="Default">
|
||||
<resource resourceType="PROJECT" workspacePath="/FreeRTOSDemo"/>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
</cproject>
|
@ -0,0 +1,109 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>FreeRTOSDemo</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
|
||||
<triggers>clean,full,incremental,</triggers>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
|
||||
<triggers>full,incremental,</triggers>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.cdt.core.cnature</nature>
|
||||
<nature>org.eclipse.cdt.core.ccnature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
|
||||
</natures>
|
||||
<linkedResources>
|
||||
<link>
|
||||
<name>CommonDemoSource</name>
|
||||
<type>2</type>
|
||||
<locationURI>FREERTOS_ROOT/Demo/Common/Minimal</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>FreeRTOS_kernel</name>
|
||||
<type>2</type>
|
||||
<locationURI>FREERTOS_ROOT/Source</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>Source</name>
|
||||
<type>2</type>
|
||||
<locationURI>virtual:/virtual</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>Source/FreeRTOSConfig.h</name>
|
||||
<type>1</type>
|
||||
<locationURI>FREERTOS_ROOT/Demo/CORTEX_MPS2_QEMU_IAR_GCC/FreeRTOSConfig.h</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>Source/IntQueueTimer.c</name>
|
||||
<type>1</type>
|
||||
<locationURI>FREERTOS_ROOT/Demo/CORTEX_MPS2_QEMU_IAR_GCC/IntQueueTimer.c</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>Source/IntQueueTimer.h</name>
|
||||
<type>1</type>
|
||||
<locationURI>FREERTOS_ROOT/Demo/CORTEX_MPS2_QEMU_IAR_GCC/IntQueueTimer.h</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>Source/main.c</name>
|
||||
<type>1</type>
|
||||
<locationURI>FREERTOS_ROOT/Demo/CORTEX_MPS2_QEMU_IAR_GCC/main.c</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>Source/main_blinky.c</name>
|
||||
<type>1</type>
|
||||
<locationURI>FREERTOS_ROOT/Demo/CORTEX_MPS2_QEMU_IAR_GCC/main_blinky.c</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>Source/main_full.c</name>
|
||||
<type>1</type>
|
||||
<locationURI>FREERTOS_ROOT/Demo/CORTEX_MPS2_QEMU_IAR_GCC/main_full.c</locationURI>
|
||||
</link>
|
||||
</linkedResources>
|
||||
<filteredResources>
|
||||
<filter>
|
||||
<id>1638931119117</id>
|
||||
<name>FreeRTOS_kernel/portable</name>
|
||||
<type>9</type>
|
||||
<matcher>
|
||||
<id>org.eclipse.ui.ide.multiFilter</id>
|
||||
<arguments>1.0-name-matches-false-false-GCC</arguments>
|
||||
</matcher>
|
||||
</filter>
|
||||
<filter>
|
||||
<id>1638931119125</id>
|
||||
<name>FreeRTOS_kernel/portable</name>
|
||||
<type>9</type>
|
||||
<matcher>
|
||||
<id>org.eclipse.ui.ide.multiFilter</id>
|
||||
<arguments>1.0-name-matches-false-false-MemMang</arguments>
|
||||
</matcher>
|
||||
</filter>
|
||||
<filter>
|
||||
<id>1638931142581</id>
|
||||
<name>FreeRTOS_kernel/portable/GCC</name>
|
||||
<type>9</type>
|
||||
<matcher>
|
||||
<id>org.eclipse.ui.ide.multiFilter</id>
|
||||
<arguments>1.0-name-matches-false-false-ARM_CM3</arguments>
|
||||
</matcher>
|
||||
</filter>
|
||||
</filteredResources>
|
||||
<variableList>
|
||||
<variable>
|
||||
<name>FREERTOS_ROOT</name>
|
||||
<value>$%7BPARENT-4-PROJECT_LOC%7D</value>
|
||||
</variable>
|
||||
</variableList>
|
||||
</projectDescription>
|
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<project>
|
||||
<configuration id="cdt.managedbuild.toolchain.gnu.cross.base.330997021" name="Default">
|
||||
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
|
||||
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
|
||||
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
||||
<provider copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/>
|
||||
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="-1494139136553" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
||||
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
||||
<language-scope id="org.eclipse.cdt.core.g++"/>
|
||||
</provider>
|
||||
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
||||
</extension>
|
||||
</configuration>
|
||||
</project>
|
@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchConfiguration type="org.eclipse.cdt.debug.gdbjtag.launchConfigurationType">
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.connection" value="gdb:localhost:1234#"/>
|
||||
<intAttribute key="org.eclipse.cdt.debug.gdbjtag.core.delay" value="0"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.doHalt" value="false"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.doReset" value="false"/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.imageFileName" value=""/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.imageOffset" value=""/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.initCommands" value=""/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.jtagDeviceId" value="org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.genericDevice"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadImage" value="false"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadSymbols" value="true"/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.pcRegister" value=""/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.runCommands" value=""/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setPcRegister" value="false"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setResume" value="true"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setStopAt" value="true"/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.stopAt" value="main"/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsFileName" value=""/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsOffset" value=""/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useFileForImage" value="false"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useFileForSymbols" value="false"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useProjBinaryForImage" value="true"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useProjBinaryForSymbols" value="true"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useRemoteTarget" value="true"/>
|
||||
<stringAttribute key="org.eclipse.cdt.dsf.gdb.DEBUG_NAME" value="arm-none-eabi-gdb"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.REMOTE_TIMEOUT_ENABLED" value="false"/>
|
||||
<stringAttribute key="org.eclipse.cdt.dsf.gdb.REMOTE_TIMEOUT_VALUE" value=""/>
|
||||
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.UPDATE_THREADLIST_ON_SUSPEND" value="false"/>
|
||||
<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_START_MODE" value="remote"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="output\RTOSDemo.out"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="FreeRTOSDemo"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="true"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value="cdt.managedbuild.toolchain.gnu.cross.base.330997021"/>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||
<listEntry value="/FreeRTOSDemo"/>
|
||||
</listAttribute>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="4"/>
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_id" value="org.eclipse.cdt.debug.core.sourceLocator"/>
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <sourceLookupDirector> <sourceContainers duplicates="false"> <container memento="AbsolutePath" typeId="org.eclipse.cdt.debug.core.containerType.absolutePath"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;default/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.default"/> </sourceContainers> </sourceLookupDirector> "/>
|
||||
<stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?><memoryBlockExpressionList context="reserved-for-future-use"/>"/>
|
||||
<stringAttribute key="process_factory_id" value="org.eclipse.cdt.dsf.gdb.GdbProcessFactory"/>
|
||||
</launchConfiguration>
|
@ -0,0 +1,123 @@
|
||||
OUTPUT_DIR := ./output
|
||||
IMAGE := RTOSDemo.out
|
||||
SUB_MAKEFILE_DIR = ./library-makefiles
|
||||
|
||||
# The directory that contains the /source and /demo sub directories.
|
||||
FREERTOS_ROOT = ./../../../../
|
||||
|
||||
CC = arm-none-eabi-gcc
|
||||
LD = arm-none-eabi-gcc
|
||||
SIZE = arm-none-eabi-size
|
||||
MAKE = make
|
||||
|
||||
|
||||
CFLAGS += $(INCLUDE_DIRS) -nostartfiles -ffreestanding -mthumb -mcpu=cortex-m3 \
|
||||
-Wall -Wextra -g3 -O0 -ffunction-sections -fdata-sections \
|
||||
-MMD -MP -MF"$(@:%.o=%.d)" -MT $@
|
||||
|
||||
#
|
||||
# Kernel build.
|
||||
#
|
||||
KERNEL_DIR = $(FREERTOS_ROOT)/Source
|
||||
KERNEL_PORT_DIR += $(KERNEL_DIR)/portable/GCC/ARM_CM3
|
||||
INCLUDE_DIRS += -I$(KERNEL_DIR)/include \
|
||||
-I$(KERNEL_PORT_DIR)
|
||||
VPATH += $(KERNEL_DIR) $(KERNEL_PORT_DIR) $(KERNEL_DIR)/portable/MemMang
|
||||
SOURCE_FILES += $(KERNEL_DIR)/tasks.c
|
||||
SOURCE_FILES += $(KERNEL_DIR)/list.c
|
||||
SOURCE_FILES += $(KERNEL_DIR)/queue.c
|
||||
SOURCE_FILES += $(KERNEL_DIR)/timers.c
|
||||
SOURCE_FILES += $(KERNEL_DIR)/event_groups.c
|
||||
SOURCE_FILES += $(KERNEL_DIR)/stream_buffer.c
|
||||
SOURCE_FILES += $(KERNEL_DIR)/portable/MemMang/heap_4.c
|
||||
SOURCE_FILES += $(KERNEL_DIR)/portable/GCC/ARM_CM3/port.c
|
||||
|
||||
#
|
||||
# Common demo files for the "full" build, as opposed to the "blinky" build -
|
||||
# these files are build by all the FreeRTOS kernel demos.
|
||||
#
|
||||
DEMO_ROOT = $(FREERTOS_ROOT)/Demo
|
||||
COMMON_DEMO_FILES = $(DEMO_ROOT)/Common/Minimal
|
||||
INCLUDE_DIRS += -I$(DEMO_ROOT)/Common/include
|
||||
VPATH += $(COMMON_DEMO_FILES)
|
||||
SOURCE_FILES += (COMMON_DEMO_FILES)/AbortDelay.c
|
||||
SOURCE_FILES += (COMMON_DEMO_FILES)/BlockQ.c
|
||||
SOURCE_FILES += (COMMON_DEMO_FILES)/blocktim.c
|
||||
SOURCE_FILES += (COMMON_DEMO_FILES)/countsem.c
|
||||
SOURCE_FILES += (COMMON_DEMO_FILES)/death.c
|
||||
SOURCE_FILES += (COMMON_DEMO_FILES)/dynamic.c
|
||||
SOURCE_FILES += (COMMON_DEMO_FILES)/EventGroupsDemo.c
|
||||
SOURCE_FILES += (COMMON_DEMO_FILES)/GenQTest.c
|
||||
SOURCE_FILES += (COMMON_DEMO_FILES)/integer.c
|
||||
SOURCE_FILES += (COMMON_DEMO_FILES)/IntQueue.c
|
||||
SOURCE_FILES += (COMMON_DEMO_FILES)/IntQueueTimer.c
|
||||
SOURCE_FILES += (COMMON_DEMO_FILES)/IntSemTest.c
|
||||
SOURCE_FILES += (COMMON_DEMO_FILES)/MessageBufferAMP.c
|
||||
SOURCE_FILES += (COMMON_DEMO_FILES)/MessageBufferDemo.c
|
||||
SOURCE_FILES += (COMMON_DEMO_FILES)/PollQ.c
|
||||
SOURCE_FILES += (COMMON_DEMO_FILES)/QPeek.c
|
||||
SOURCE_FILES += (COMMON_DEMO_FILES)/QueueOverwrite.c
|
||||
SOURCE_FILES += (COMMON_DEMO_FILES)/QueueSet.c
|
||||
SOURCE_FILES += (COMMON_DEMO_FILES)/QueueSetPolling.c
|
||||
SOURCE_FILES += (COMMON_DEMO_FILES)/recmutex.c
|
||||
SOURCE_FILES += (COMMON_DEMO_FILES)/semtest.c
|
||||
SOURCE_FILES += (COMMON_DEMO_FILES)/StaticAllocation.c
|
||||
SOURCE_FILES += (COMMON_DEMO_FILES)/StreamBufferDemo.c
|
||||
SOURCE_FILES += (COMMON_DEMO_FILES)/StreamBufferInterrupt.c
|
||||
SOURCE_FILES += (COMMON_DEMO_FILES)/TaskNotify.c
|
||||
SOURCE_FILES += (COMMON_DEMO_FILES)/TaskNotifyArray.c
|
||||
SOURCE_FILES += (COMMON_DEMO_FILES)/TimerDemo.c
|
||||
|
||||
#
|
||||
# Application entry point. main_blinky is self contained. main_full builds
|
||||
# the above common demo (and test) files too.
|
||||
#
|
||||
DEMO_PROJECT = $(DEMO_ROOT)/CORTEX_MPS2_QEMU_IAR_GCC
|
||||
VPATH += $(DEMO_PROJECT)
|
||||
INCLUDE_DIRS += -I$(DEMO_PROJECT) -I$(DEMO_PROJECT)/CMSIS
|
||||
SOURCE_FILES += (DEMO_PROJECT)/main.c
|
||||
SOURCE_FILES += (DEMO_PROJECT)/main_blinky.c
|
||||
SOURCE_FILES += (DEMO_PROJECT)/main_full.c
|
||||
SOURCE_FILES += ./startup_gcc.c
|
||||
# Lightweight print formatting to use in place of the heavier GCC equivalent.
|
||||
SOURCE_FILES += ./printf-stdarg.c
|
||||
|
||||
#Create a list of object files with the desired output directory path.
|
||||
OBJS = $(SOURCE_FILES:%.c=%.o)
|
||||
OBJS_NO_PATH = $(notdir $(OBJS))
|
||||
OBJS_OUTPUT = $(OBJS_NO_PATH:%.o=$(OUTPUT_DIR)/%.o)
|
||||
|
||||
#Create a list of dependency files with the desired output directory path.
|
||||
DEP_FILES := $(SOURCE_FILES:%.c=$(OUTPUT_DIR)/%.d)
|
||||
DEP_FILES_NO_PATH = $(notdir $(DEP_FILES))
|
||||
DEP_OUTPUT = $(DEP_FILES_NO_PATH:%.d=$(OUTPUT_DIR)/%.d)
|
||||
|
||||
all: $(OUTPUT_DIR)/$(IMAGE)
|
||||
|
||||
%.o : %.c
|
||||
$(OUTPUT_DIR)/%.o : %.c $(OUTPUT_DIR)/%.d Makefile
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
$(OUTPUT_DIR)/$(IMAGE): ./mps2_m3.ld $(OBJS_OUTPUT) Makefile
|
||||
@echo ""
|
||||
@echo ""
|
||||
@echo "--- Final linking ---"
|
||||
@echo ""
|
||||
$(LD) $(OBJS_OUTPUT) $(CFLAGS) -Xlinker --gc-sections -Xlinker -T ./mps2_m3.ld \
|
||||
-Xlinker -Map=$(OUTPUT_DIR)/RTOSDemo.map -specs=nano.specs \
|
||||
-specs=nosys.specs -specs=rdimon.specs -o $(OUTPUT_DIR)/$(IMAGE)
|
||||
$(SIZE) $(OUTPUT_DIR)/$(IMAGE)
|
||||
|
||||
$(DEP_OUTPUT):
|
||||
include $(wildcard $(DEP_OUTPUT))
|
||||
|
||||
clean:
|
||||
rm -f $(OUTPUT_DIR)/$(IMAGE) $(OUTPUT_DIR)/*.o $(OUTPUT_DIR)/*.d
|
||||
|
||||
#use "make print-[VARIABLE_NAME] to print the value of a variable generated by
|
||||
#this makefile.
|
||||
print-% : ; @echo $* = $($*)
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
|
@ -0,0 +1,98 @@
|
||||
/*
|
||||
* FreeRTOS V202111.00
|
||||
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* 1 tab == 4 spaces!
|
||||
*/
|
||||
|
||||
MEMORY
|
||||
{
|
||||
FLASH (xr) : ORIGIN = 0x00000000, LENGTH = 4M /* to 0x00003FFF = 0x007FFFFF*/
|
||||
RAM (rw) : ORIGIN = 0x20000000, LENGTH = 4M /* to 0x21FFFFFF = 0xFFFFFF */
|
||||
}
|
||||
ENTRY(Reset_Handler)
|
||||
|
||||
_Min_Heap_Size = 0x8 ; /* Not used as building heap_4.c */
|
||||
_Min_Stack_Size = 0x400 ; /* Required amount of stack. Used by main(), then re-used as the interrupt stack after the kernel starts. */
|
||||
_estack = ORIGIN(RAM) + LENGTH(RAM);
|
||||
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.isr_vector :
|
||||
{
|
||||
__vector_table = .;
|
||||
KEEP(*(.isr_vector))
|
||||
. = ALIGN(4);
|
||||
} > FLASH
|
||||
|
||||
.text :
|
||||
{
|
||||
*(.text)
|
||||
*(.rodata*)
|
||||
*(.constdata*)
|
||||
_etext = .;
|
||||
_sidata = .;
|
||||
} > FLASH
|
||||
|
||||
.data :
|
||||
{
|
||||
. = ALIGN(8);
|
||||
_data = .;
|
||||
_sdata = .;
|
||||
*(vtable)
|
||||
*(.data)
|
||||
_edata = .;
|
||||
} > RAM
|
||||
|
||||
.bss :
|
||||
{
|
||||
. = ALIGN(8);
|
||||
_bss = .;
|
||||
_sbss = .;
|
||||
*(.bss)
|
||||
_ebss = .;
|
||||
} > RAM
|
||||
|
||||
.heap :
|
||||
{
|
||||
. = ALIGN(8);
|
||||
PROVIDE ( end = . );
|
||||
PROVIDE ( _end = . );
|
||||
_heap_bottom = .;
|
||||
. = . + _Min_Heap_Size;
|
||||
_heap_top = .;
|
||||
. = . + _Min_Stack_Size;
|
||||
. = ALIGN(8);
|
||||
} >RAM
|
||||
|
||||
/* Set stack top to end of RAM, and stack limit move down by
|
||||
* size of stack_dummy section */
|
||||
__StackTop = ORIGIN(RAM) + LENGTH(RAM);
|
||||
__StackLimit = __StackTop - _Min_Stack_Size;
|
||||
PROVIDE(__stack = __StackTop);
|
||||
|
||||
/* Check if data + heap + stack exceeds RAM limit */
|
||||
ASSERT(__StackLimit >= _heap_top, "region RAM overflowed with stack")
|
||||
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
File included to ensure the "output" directory is not empty, and can therefore
|
||||
be checked into Git. This prevents the necessity to have a cross platform
|
||||
method of creating the directory from within the makefile.
|
@ -0,0 +1,312 @@
|
||||
/*
|
||||
Copyright 2001, 2002 Georges Menie (www.menie.org)
|
||||
stdarg version contributed by Christian Ettinger
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
putchar is the only external dependency for this file,
|
||||
if you have a working putchar, leave it commented out.
|
||||
If not, uncomment the define below and
|
||||
replace outbyte(c) by your own function call.
|
||||
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#define UART0_ADDRESS ( 0x40004000UL )
|
||||
#define UART0_DATA ( * ( ( ( volatile unsigned int * )( UART0_ADDRESS + 0UL ) ) ) )
|
||||
#define putchar(c) UART0_DATA = c
|
||||
|
||||
static int tiny_print( char **out, const char *format, va_list args, unsigned int buflen );
|
||||
|
||||
static void printchar(char **str, int c, char *buflimit)
|
||||
{
|
||||
if (str) {
|
||||
if( buflimit == ( char * ) 0 ) {
|
||||
/* Limit of buffer not known, write charater to buffer. */
|
||||
**str = (char)c;
|
||||
++(*str);
|
||||
}
|
||||
else if( ( ( unsigned long ) *str ) < ( ( unsigned long ) buflimit ) ) {
|
||||
/* Within known limit of buffer, write character. */
|
||||
**str = (char)c;
|
||||
++(*str);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
putchar(c);
|
||||
}
|
||||
}
|
||||
|
||||
#define PAD_RIGHT 1
|
||||
#define PAD_ZERO 2
|
||||
|
||||
static int prints(char **out, const char *string, int width, int pad, char *buflimit)
|
||||
{
|
||||
register int pc = 0, padchar = ' ';
|
||||
|
||||
if (width > 0) {
|
||||
register int len = 0;
|
||||
register const char *ptr;
|
||||
for (ptr = string; *ptr; ++ptr) ++len;
|
||||
if (len >= width) width = 0;
|
||||
else width -= len;
|
||||
if (pad & PAD_ZERO) padchar = '0';
|
||||
}
|
||||
if (!(pad & PAD_RIGHT)) {
|
||||
for ( ; width > 0; --width) {
|
||||
printchar (out, padchar, buflimit);
|
||||
++pc;
|
||||
}
|
||||
}
|
||||
for ( ; *string ; ++string) {
|
||||
printchar (out, *string, buflimit);
|
||||
++pc;
|
||||
}
|
||||
for ( ; width > 0; --width) {
|
||||
printchar (out, padchar, buflimit);
|
||||
++pc;
|
||||
}
|
||||
|
||||
return pc;
|
||||
}
|
||||
|
||||
/* the following should be enough for 32 bit int */
|
||||
#define PRINT_BUF_LEN 12
|
||||
|
||||
static int printi(char **out, int i, int b, int sg, int width, int pad, int letbase, char *buflimit)
|
||||
{
|
||||
char print_buf[PRINT_BUF_LEN];
|
||||
register char *s;
|
||||
register int t, neg = 0, pc = 0;
|
||||
register unsigned int u = (unsigned int)i;
|
||||
|
||||
if (i == 0) {
|
||||
print_buf[0] = '0';
|
||||
print_buf[1] = '\0';
|
||||
return prints (out, print_buf, width, pad, buflimit);
|
||||
}
|
||||
|
||||
if (sg && b == 10 && i < 0) {
|
||||
neg = 1;
|
||||
u = (unsigned int)-i;
|
||||
}
|
||||
|
||||
s = print_buf + PRINT_BUF_LEN-1;
|
||||
*s = '\0';
|
||||
|
||||
while (u) {
|
||||
t = (unsigned int)u % b;
|
||||
if( t >= 10 )
|
||||
t += letbase - '0' - 10;
|
||||
*--s = (char)(t + '0');
|
||||
u /= b;
|
||||
}
|
||||
|
||||
if (neg) {
|
||||
if( width && (pad & PAD_ZERO) ) {
|
||||
printchar (out, '-', buflimit);
|
||||
++pc;
|
||||
--width;
|
||||
}
|
||||
else {
|
||||
*--s = '-';
|
||||
}
|
||||
}
|
||||
|
||||
return pc + prints (out, s, width, pad, buflimit);
|
||||
}
|
||||
|
||||
static int tiny_print( char **out, const char *format, va_list args, unsigned int buflen )
|
||||
{
|
||||
register int width, pad;
|
||||
register int pc = 0;
|
||||
char scr[2], *buflimit;
|
||||
|
||||
if( buflen == 0 ){
|
||||
buflimit = ( char * ) 0;
|
||||
}
|
||||
else {
|
||||
/* Calculate the last valid buffer space, leaving space for the NULL
|
||||
terminator. */
|
||||
buflimit = ( *out ) + ( buflen - 1 );
|
||||
}
|
||||
|
||||
for (; *format != 0; ++format) {
|
||||
if (*format == '%') {
|
||||
++format;
|
||||
width = pad = 0;
|
||||
if (*format == '\0') break;
|
||||
if (*format == '%') goto out;
|
||||
if (*format == '-') {
|
||||
++format;
|
||||
pad = PAD_RIGHT;
|
||||
}
|
||||
while (*format == '0') {
|
||||
++format;
|
||||
pad |= PAD_ZERO;
|
||||
}
|
||||
for ( ; *format >= '0' && *format <= '9'; ++format) {
|
||||
width *= 10;
|
||||
width += *format - '0';
|
||||
}
|
||||
if( *format == 's' ) {
|
||||
register char *s = (char *)va_arg( args, int );
|
||||
pc += prints (out, s?s:"(null)", width, pad, buflimit);
|
||||
continue;
|
||||
}
|
||||
if( *format == 'd' ) {
|
||||
pc += printi (out, va_arg( args, int ), 10, 1, width, pad, 'a', buflimit);
|
||||
continue;
|
||||
}
|
||||
if( *format == 'x' ) {
|
||||
pc += printi (out, va_arg( args, int ), 16, 0, width, pad, 'a', buflimit);
|
||||
continue;
|
||||
}
|
||||
if( *format == 'X' ) {
|
||||
pc += printi (out, va_arg( args, int ), 16, 0, width, pad, 'A', buflimit);
|
||||
continue;
|
||||
}
|
||||
if( *format == 'u' ) {
|
||||
pc += printi (out, va_arg( args, int ), 10, 0, width, pad, 'a', buflimit);
|
||||
continue;
|
||||
}
|
||||
if( *format == 'c' ) {
|
||||
/* char are converted to int then pushed on the stack */
|
||||
scr[0] = (char)va_arg( args, int );
|
||||
scr[1] = '\0';
|
||||
pc += prints (out, scr, width, pad, buflimit);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else {
|
||||
out:
|
||||
printchar (out, *format, buflimit);
|
||||
++pc;
|
||||
}
|
||||
}
|
||||
if (out) **out = '\0';
|
||||
va_end( args );
|
||||
return pc;
|
||||
}
|
||||
|
||||
int printf(const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
va_start( args, format );
|
||||
return tiny_print( 0, format, args, 0 );
|
||||
}
|
||||
|
||||
int sprintf(char *out, const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
va_start( args, format );
|
||||
return tiny_print( &out, format, args, 0 );
|
||||
}
|
||||
|
||||
|
||||
int snprintf( char *buf, unsigned int count, const char *format, ... )
|
||||
{
|
||||
va_list args;
|
||||
|
||||
( void ) count;
|
||||
|
||||
va_start( args, format );
|
||||
return tiny_print( &buf, format, args, count );
|
||||
}
|
||||
|
||||
|
||||
#ifdef TEST_PRINTF
|
||||
int main(void)
|
||||
{
|
||||
char *ptr = "Hello world!";
|
||||
char *np = 0;
|
||||
int i = 5;
|
||||
unsigned int bs = sizeof(int)*8;
|
||||
int mi;
|
||||
char buf[80];
|
||||
|
||||
mi = (1 << (bs-1)) + 1;
|
||||
printf("%s\n", ptr);
|
||||
printf("printf test\n");
|
||||
printf("%s is null pointer\n", np);
|
||||
printf("%d = 5\n", i);
|
||||
printf("%d = - max int\n", mi);
|
||||
printf("char %c = 'a'\n", 'a');
|
||||
printf("hex %x = ff\n", 0xff);
|
||||
printf("hex %02x = 00\n", 0);
|
||||
printf("signed %d = unsigned %u = hex %x\n", -3, -3, -3);
|
||||
printf("%d %s(s)%", 0, "message");
|
||||
printf("\n");
|
||||
printf("%d %s(s) with %%\n", 0, "message");
|
||||
sprintf(buf, "justif: \"%-10s\"\n", "left"); printf("%s", buf);
|
||||
sprintf(buf, "justif: \"%10s\"\n", "right"); printf("%s", buf);
|
||||
sprintf(buf, " 3: %04d zero padded\n", 3); printf("%s", buf);
|
||||
sprintf(buf, " 3: %-4d left justif.\n", 3); printf("%s", buf);
|
||||
sprintf(buf, " 3: %4d right justif.\n", 3); printf("%s", buf);
|
||||
sprintf(buf, "-3: %04d zero padded\n", -3); printf("%s", buf);
|
||||
sprintf(buf, "-3: %-4d left justif.\n", -3); printf("%s", buf);
|
||||
sprintf(buf, "-3: %4d right justif.\n", -3); printf("%s", buf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* if you compile this file with
|
||||
* gcc -Wall $(YOUR_C_OPTIONS) -DTEST_PRINTF -c printf.c
|
||||
* you will get a normal warning:
|
||||
* printf.c:214: warning: spurious trailing `%' in format
|
||||
* this line is testing an invalid % at the end of the format string.
|
||||
*
|
||||
* this should display (on 32bit int machine) :
|
||||
*
|
||||
* Hello world!
|
||||
* printf test
|
||||
* (null) is null pointer
|
||||
* 5 = 5
|
||||
* -2147483647 = - max int
|
||||
* char a = 'a'
|
||||
* hex ff = ff
|
||||
* hex 00 = 00
|
||||
* signed -3 = unsigned 4294967293 = hex fffffffd
|
||||
* 0 message(s)
|
||||
* 0 message(s) with %
|
||||
* justif: "left "
|
||||
* justif: " right"
|
||||
* 3: 0003 zero padded
|
||||
* 3: 3 left justif.
|
||||
* 3: 3 right justif.
|
||||
* -3: -003 zero padded
|
||||
* -3: -3 left justif.
|
||||
* -3: -3 right justif.
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* To keep linker happy. */
|
||||
int write( int i, char* c, int n)
|
||||
{
|
||||
(void)i;
|
||||
(void)n;
|
||||
(void)c;
|
||||
return 0;
|
||||
}
|
||||
|
@ -0,0 +1,168 @@
|
||||
/*
|
||||
* FreeRTOS V202111.00
|
||||
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* 1 tab == 4 spaces!
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/* UART peripheral register addresses and bits. */
|
||||
#define UART0_ADDR ( ( UART_t * ) ( 0x40004000 ) )
|
||||
#define UART_DR( baseaddr ) ( *( uint32_t * ) ( baseaddr ) )
|
||||
#define UART_STATE( baseaddr ) ( *( uint32_t * ) ( baseaddr + 4 ) )
|
||||
#define UART_STATE_TXFULL ( 1 << 0 )
|
||||
|
||||
typedef struct UART_t
|
||||
{
|
||||
volatile uint32_t DATA;
|
||||
volatile uint32_t STATE;
|
||||
volatile uint32_t CTRL;
|
||||
volatile uint32_t INTSTATUS;
|
||||
volatile uint32_t BAUDDIV;
|
||||
} UART_t;
|
||||
|
||||
|
||||
/* FreeRTOS interrupt handlers. */
|
||||
extern void vPortSVCHandler( void );
|
||||
extern void xPortPendSVHandler( void );
|
||||
extern void xPortSysTickHandler( void );
|
||||
extern void TIMER0_Handler( void );
|
||||
extern void TIMER1_Handler( void );
|
||||
|
||||
/* Exception handlers. */
|
||||
static void HardFault_Handler( void ) __attribute__( ( naked ) );
|
||||
static void Default_Handler( void ) __attribute__( ( naked ) );
|
||||
void Reset_Handler( void );
|
||||
|
||||
extern int main( void );
|
||||
extern uint32_t _estack;
|
||||
|
||||
/* Vector table. */
|
||||
const uint32_t* isr_vector[] __attribute__((section(".isr_vector"))) =
|
||||
{
|
||||
( uint32_t * ) &_estack,
|
||||
( uint32_t * ) &Reset_Handler, // Reset -15
|
||||
( uint32_t * ) &Default_Handler, // NMI_Handler -14
|
||||
( uint32_t * ) &HardFault_Handler, // HardFault_Handler -13
|
||||
( uint32_t * ) &Default_Handler, // MemManage_Handler -12
|
||||
( uint32_t * ) &Default_Handler, // BusFault_Handler -11
|
||||
( uint32_t * ) &Default_Handler, // UsageFault_Handler -10
|
||||
0, // reserved
|
||||
0, // reserved
|
||||
0, // reserved
|
||||
0, // reserved -6
|
||||
( uint32_t * ) &vPortSVCHandler, // SVC_Handler -5
|
||||
( uint32_t * ) &Default_Handler, // DebugMon_Handler -4
|
||||
0, // reserved
|
||||
( uint32_t * ) &xPortPendSVHandler, // PendSV handler -2
|
||||
( uint32_t * ) &xPortSysTickHandler,// SysTick_Handler -1
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
( uint32_t * ) TIMER0_Handler, // Timer 0
|
||||
( uint32_t * ) TIMER1_Handler, // Timer 1
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0, // Ethernet 13
|
||||
};
|
||||
|
||||
void Reset_Handler( void )
|
||||
{
|
||||
main();
|
||||
}
|
||||
|
||||
/* Variables used to store the value of registers at the time a hardfault
|
||||
* occurs. These are volatile to try and prevent the compiler/linker optimising
|
||||
* them away as the variables never actually get used. */
|
||||
volatile uint32_t r0;
|
||||
volatile uint32_t r1;
|
||||
volatile uint32_t r2;
|
||||
volatile uint32_t r3;
|
||||
volatile uint32_t r12;
|
||||
volatile uint32_t lr; /* Link register. */
|
||||
volatile uint32_t pc; /* Program counter. */
|
||||
volatile uint32_t psr;/* Program status register. */
|
||||
|
||||
/* Called from the hardfault handler to provide information on the processor
|
||||
* state at the time of the fault.
|
||||
*/
|
||||
void prvGetRegistersFromStack( uint32_t *pulFaultStackAddress )
|
||||
{
|
||||
r0 = pulFaultStackAddress[ 0 ];
|
||||
r1 = pulFaultStackAddress[ 1 ];
|
||||
r2 = pulFaultStackAddress[ 2 ];
|
||||
r3 = pulFaultStackAddress[ 3 ];
|
||||
|
||||
r12 = pulFaultStackAddress[ 4 ];
|
||||
lr = pulFaultStackAddress[ 5 ];
|
||||
pc = pulFaultStackAddress[ 6 ];
|
||||
psr = pulFaultStackAddress[ 7 ];
|
||||
|
||||
printf( "Calling prvGetRegistersFromStack() from fault handler" );
|
||||
fflush( stdout );
|
||||
|
||||
/* When the following line is hit, the variables contain the register values. */
|
||||
for( ;; );
|
||||
}
|
||||
|
||||
|
||||
void Default_Handler( void )
|
||||
{
|
||||
__asm volatile
|
||||
(
|
||||
".align 8 \n"
|
||||
" ldr r3, NVIC_INT_CTRL_CONST \n" /* Load the address of the interrupt control register into r3. */
|
||||
" ldr r2, [r3, #0] \n" /* Load the value of the interrupt control register into r2. */
|
||||
" uxtb r2, r2 \n" /* The interrupt number is in the least significant byte - clear all other bits. */
|
||||
"Infinite_Loop: \n" /* Sit in an infinite loop - the number of the executing interrupt is held in r2. */
|
||||
" b Infinite_Loop \n"
|
||||
".align 4 \n"
|
||||
"NVIC_INT_CTRL_CONST: .word 0xe000ed04 \n"
|
||||
);
|
||||
}
|
||||
|
||||
void HardFault_Handler( void )
|
||||
{
|
||||
__asm volatile
|
||||
(
|
||||
".align 8 \n"
|
||||
" tst lr, #4 \n"
|
||||
" ite eq \n"
|
||||
" mrseq r0, msp \n"
|
||||
" mrsne r0, psp \n"
|
||||
" ldr r1, [r0, #24] \n"
|
||||
" ldr r2, handler2_address_const \n"
|
||||
" bx r2 \n"
|
||||
" handler2_address_const: .word prvGetRegistersFromStack \n"
|
||||
);
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue