Improved sandbox demo.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@13245 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
Giovanni Di Sirio 2020-01-02 08:43:06 +00:00
parent af4c60a3ef
commit 6003782d71
14 changed files with 514 additions and 93 deletions

View File

@ -37,7 +37,7 @@
</cconfiguration>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<project id="RT-STM32L476-DISCOVERY-SB_CLIENT.null.1004513353" name="RT-STM32L476-DISCOVERY-SB_CLIENT"/>
<project id="RT-STM32L476-DISCOVERY-SB_CLIENT1.null.1004513353" name="RT-STM32L476-DISCOVERY-SB_CLIENT1"/>
</storageModule>
<storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
@ -48,7 +48,7 @@
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
<storageModule moduleId="refreshScope" versionNumber="2">
<configuration configurationName="Default">
<resource resourceType="PROJECT" workspacePath="/RT-STM32L476-DISCOVERY-SB_CLIENT"/>
<resource resourceType="PROJECT" workspacePath="/RT-STM32L476-DISCOVERY-SB_CLIENT1"/>
</configuration>
</storageModule>
</cproject>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>RT-STM32L476-DISCOVERY-SB_CLIENT</name>
<name>RT-STM32L476-DISCOVERY-SB_CLIENT1</name>
<comment></comment>
<projects>
</projects>

View File

@ -42,8 +42,8 @@ int main(void) {
#endif
while (true) {
msg_t msg = sbMsgWait();
printf("Hello World (%u)!!\r\n", (unsigned)msg);
// sbFileWrite(1U, (const uint8_t *)"Hello World!!\r\n", 15U);
printf("#1 Hello World (%u)!!\r\n", (unsigned)msg);
// sbFileWrite(1U, (const uint8_t *)"#1 Hello World!!\r\n", 15U);
sbMsgReply(msg);
// sbSleepMilliseconds(500);
}

View File

@ -0,0 +1,33 @@
/*
ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
* Sandbox memory setup.
*/
MEMORY
{
flash0 (rx) : org = 0x080F0000, len = 32k
ram0 (wx) : org = 0x20016000, len = 4k
}
/* Flash region to be used for exception vectors.*/
REGION_ALIAS("CODE_SPACE", flash0);
/* RAM region to be used for data.*/
REGION_ALIAS("DATA_SPACE", ram0);
/* Generic rules inclusion.*/
INCLUDE rules.ld

View File

@ -0,0 +1,54 @@
<?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="0.603687198">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="0.603687198" moduleId="org.eclipse.cdt.core.settings" name="Default">
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.VCErrorParser" 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.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactName="${ProjName}" buildProperties="" description="" id="0.603687198" name="Default" parent="org.eclipse.cdt.build.core.prefbase.cfg">
<folderInfo id="0.603687198." name="/" resourcePath="">
<toolChain id="org.eclipse.cdt.build.core.prefbase.toolchain.586709963" name="No ToolChain" resourceTypeBasedDiscovery="false" superClass="org.eclipse.cdt.build.core.prefbase.toolchain">
<targetPlatform id="org.eclipse.cdt.build.core.prefbase.toolchain.586709963.1446538340" name=""/>
<builder autoBuildTarget="all" cleanBuildTarget="clean" enableAutoBuild="false" enableCleanBuild="true" enabledIncrementalBuild="true" id="org.eclipse.cdt.build.core.settings.default.builder.1490952991" incrementalBuildTarget="all" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="org.eclipse.cdt.build.core.settings.default.builder"/>
<tool id="org.eclipse.cdt.build.core.settings.holder.libs.1134067298" name="holder for library settings" superClass="org.eclipse.cdt.build.core.settings.holder.libs"/>
<tool id="org.eclipse.cdt.build.core.settings.holder.1927705259" name="Assembly" superClass="org.eclipse.cdt.build.core.settings.holder">
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1013764026" languageId="org.eclipse.cdt.core.assembly" languageName="Assembly" sourceContentType="org.eclipse.cdt.core.asmSource" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
</tool>
<tool id="org.eclipse.cdt.build.core.settings.holder.1367371861" name="GNU C++" superClass="org.eclipse.cdt.build.core.settings.holder">
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1824820452" languageId="org.eclipse.cdt.core.g++" languageName="GNU C++" sourceContentType="org.eclipse.cdt.core.cxxSource,org.eclipse.cdt.core.cxxHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
</tool>
<tool id="org.eclipse.cdt.build.core.settings.holder.1584496456" name="GNU C" superClass="org.eclipse.cdt.build.core.settings.holder">
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1781547795" languageId="org.eclipse.cdt.core.gcc" languageName="GNU C" sourceContentType="org.eclipse.cdt.core.cSource,org.eclipse.cdt.core.cHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
</tool>
</toolChain>
</folderInfo>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<project id="RT-STM32L476-DISCOVERY-SB_CLIENT2.null.1004513353" name="RT-STM32L476-DISCOVERY-SB_CLIENT2"/>
</storageModule>
<storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
<scannerConfigBuildInfo instanceId="0.603687198">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"/>
</scannerConfigBuildInfo>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
<storageModule moduleId="refreshScope" versionNumber="2">
<configuration configurationName="Default">
<resource resourceType="PROJECT" workspacePath="/RT-STM32L476-DISCOVERY-SB_CLIENT2"/>
</configuration>
</storageModule>
</cproject>

View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>RT-STM32L476-DISCOVERY-SB_CLIENT2</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.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures>
<linkedResources>
<link>
<name>sb</name>
<type>2</type>
<locationURI>CHIBIOS/os/sb</locationURI>
</link>
</linkedResources>
</projectDescription>

View File

@ -0,0 +1,191 @@
##############################################################################
# Build global options
# NOTE: Can be overridden externally.
#
# Compiler options here.
ifeq ($(USE_OPT),)
USE_OPT = -O2 -ggdb -fomit-frame-pointer -falign-functions=16
endif
# C specific options here (added to USE_OPT).
ifeq ($(USE_COPT),)
USE_COPT =
endif
# C++ specific options here (added to USE_OPT).
ifeq ($(USE_CPPOPT),)
USE_CPPOPT = -fno-rtti
endif
# Enable this if you want the linker to remove unused code and data.
ifeq ($(USE_LINK_GC),)
USE_LINK_GC = yes
endif
# Linker extra options here.
ifeq ($(USE_LDOPT),)
USE_LDOPT =
endif
# Enable this if you want link time optimizations (LTO).
ifeq ($(USE_LTO),)
USE_LTO = yes
endif
# Enable this if you want to see the full log while compiling.
ifeq ($(USE_VERBOSE_COMPILE),)
USE_VERBOSE_COMPILE = no
endif
# If enabled, this option makes the build process faster by not compiling
# modules not used in the current configuration.
ifeq ($(USE_SMART_BUILD),)
USE_SMART_BUILD = yes
endif
#
# Build global options
##############################################################################
##############################################################################
# Architecture or project specific options
#
# Stack size to be allocated to the Cortex-M process stack. This stack is
# the stack used by the main() thread.
ifeq ($(USE_PROCESS_STACKSIZE),)
USE_PROCESS_STACKSIZE = 0x400
endif
# Stack size to the allocated to the Cortex-M main/exceptions stack. This
# stack is used for processing interrupts and exceptions.
ifeq ($(USE_EXCEPTIONS_STACKSIZE),)
USE_EXCEPTIONS_STACKSIZE = 0x400
endif
# Enables the use of FPU (no, softfp, hard).
ifeq ($(USE_FPU),)
USE_FPU = no
endif
# FPU-related options.
ifeq ($(USE_FPU_OPT),)
USE_FPU_OPT = -mfloat-abi=$(USE_FPU) -mfpu=fpv4-sp-d16
endif
#
# Architecture or project specific options
##############################################################################
##############################################################################
# Project, target, sources and paths
#
# Define project name here
PROJECT = ch
# Target settings.
MCU = cortex-m4
# Imported source files and paths.
CHIBIOS := ../../..
CONFDIR := ./cfg
BUILDDIR := ./build
DEPDIR := ./.dep
# Licensing files.
include $(CHIBIOS)/os/license/license.mk
# Startup files.
include $(CHIBIOS)/os/common/startup/ARMCMx-SB/compilers/GCC/mk/startup.mk
# HAL-OSAL files (optional).
#include $(CHIBIOS)/os/hal/hal.mk
#include $(CHIBIOS)/os/hal/ports/STM32/STM32L4xx/platform.mk
#include $(CHIBIOS)/os/hal/boards/ST_STM32L476_DISCOVERY/board.mk
#include $(CHIBIOS)/os/hal/osal/rt-nil/osal.mk
# RTOS files (optional).
#include $(CHIBIOS)/os/rt/rt.mk
#include $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/port_v7m.mk
include $(CHIBIOS)/os/sb/user/sbuser.mk
# Auto-build files in ./source recursively.
include $(CHIBIOS)/tools/mk/autobuild.mk
# Other files (optional).
#include $(CHIBIOS)/test/lib/test.mk
#include $(CHIBIOS)/test/rt/rt_test.mk
#include $(CHIBIOS)/test/oslib/oslib_test.mk
# Define linker script file here.
LDSCRIPT= ./sandbox.ld
# C sources that can be compiled in ARM or THUMB mode depending on the global
# setting.
CSRC = $(ALLCSRC) \
$(TESTSRC) \
$(CHIBIOS)/os/sb/various/syscalls.c \
main.c
# C++ sources that can be compiled in ARM or THUMB mode depending on the global
# setting.
CPPSRC = $(ALLCPPSRC)
# List ASM source files here.
ASMSRC = $(ALLASMSRC)
# List ASM with preprocessor source files here.
ASMXSRC = $(ALLXASMSRC)
# Inclusion directories.
INCDIR = $(CONFDIR) $(ALLINC) $(TESTINC)
# Define C warning options here.
CWARN = -Wall -Wextra -Wundef -Wstrict-prototypes
# Define C++ warning options here.
CPPWARN = -Wall -Wextra -Wundef
#
# Project, target, sources and paths
##############################################################################
##############################################################################
# Start of user section
#
# List all user C define here, like -D_DEBUG=1
UDEFS =
# Define ASM defines here
UADEFS =
# List all user directories here
UINCDIR =
# List the user directory to look for the libraries here
ULIBDIR =
# List all user libraries here
ULIBS =
#
# End of user section
##############################################################################
##############################################################################
# Common rules
#
RULESPATH = $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC/mk
include $(RULESPATH)/arm-none-eabi.mk
include $(RULESPATH)/rules.mk
#
# Common rules
##############################################################################
##############################################################################
# Custom rules
#
#
# Custom rules
##############################################################################

View File

@ -0,0 +1,50 @@
/*
ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdio.h>
#include "sbuser.h"
/*
* Application entry point.
*/
int main(void) {
/* API layer initialization.*/
sbApiInit();
/*
* Normal main() activity, in this demo it does nothing except
* sleeping in a loop.
*/
#if 0
/* Test for exception on interrupt.*/
asm volatile ("mov r0, #64");
asm volatile ("mov sp, r0");
while (true) {
}
#endif
while (true) {
msg_t msg = sbMsgWait();
printf("#2 Hello World (%u)!!\r\n", (unsigned)msg);
// sbFileWrite(1U, (const uint8_t *)"#2 Hello World!!\r\n", 15U);
sbMsgReply(msg);
// sbSleepMilliseconds(500);
}
}

View File

@ -19,22 +19,22 @@
*/
MEMORY
{
flash0 (rx) : org = 0x08000000, len = 1M - 32k
flash0 (rx) : org = 0x08000000, len = 1M - 64k
flash1 (rx) : org = 0x00000000, len = 0
flash2 (rx) : org = 0x00000000, len = 0
flash3 (rx) : org = 0x00000000, len = 0
flash4 (rx) : org = 0x00000000, len = 0
flash5 (rx) : org = 0x00000000, len = 0
flash6 (rx) : org = 0x00000000, len = 0
flash7 (rx) : org = 0x08000000 + 1M - 32k, len = 32k
flash6 (rx) : org = 0x08000000 + 1M - 64k, len = 32k /* Flash for SB1.*/
flash7 (rx) : org = 0x08000000 + 1M - 32k, len = 32k /* Flash for SB2.*/
ram0 (wx) : org = 0x20000000, len = 96k - 4k
ram1 (wx) : org = 0x00000000, len = 0
ram2 (wx) : org = 0x00000000, len = 0
ram3 (wx) : org = 0x00000000, len = 0
ram4 (wx) : org = 0x10000000, len = 32k
ram5 (wx) : org = 0x00000000, len = 0
ram6 (wx) : org = 0x00000000, len = 0
ram7 (wx) : org = 0x20000000 + 96k - 4k, len = 4k
ram6 (wx) : org = 0x20000000 + 96k - 8k, len = 4k /* RAM for SB1.*/
ram7 (wx) : org = 0x20000000 + 96k - 4k, len = 4k /* RAM for SB2.*/
}
/* For each data/text section two region are defined, a virtual region

View File

@ -1,52 +1,52 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.cdt.debug.gdbjtag.launchConfigurationType">
<stringAttribute key="bad_container_name" value="\RT-STM32L476-DISCOVERY-SB_HOST\debug"/>
<intAttribute key="org.eclipse.cdt.debug.gdbjtag.core.delay" value="1"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.doHalt" value="true"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.doReset" value="true"/>
<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="set remotetimeout 20&#13;&#10;monitor reset init&#13;&#10;monitor sleep 50&#13;&#10;&#10;load C:/_projects/chibios-trunk/demos/STM32/RT-STM32L476-DISCOVERY-SB_CLIENT/build/ch.elf&#10;"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.ipAddress" value="localhost"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.jtagDevice" value="Generic TCP/IP"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadImage" value="true"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadSymbols" value="true"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.pcRegister" value=""/>
<intAttribute key="org.eclipse.cdt.debug.gdbjtag.core.portNumber" value="3333"/>
<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.debug.mi.core.DEBUG_NAME" value="arm-none-eabi-gdb"/>
<stringAttribute key="org.eclipse.cdt.debug.mi.core.commandFactory" value="Standard"/>
<stringAttribute key="org.eclipse.cdt.debug.mi.core.protocol" value="mi"/>
<booleanAttribute key="org.eclipse.cdt.debug.mi.core.verboseMode" value="false"/>
<stringAttribute key="org.eclipse.cdt.dsf.gdb.DEBUG_NAME" value="arm-none-eabi-gdb"/>
<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_REGISTER_GROUPS" value=""/>
<stringAttribute key="org.eclipse.cdt.launch.FORMAT" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&lt;contentList&gt;&lt;content id=&quot;psp-SVC_Handler-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;s_psp-SVC_Handler-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;s_psp-port_unprivileged_jump-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;r0-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;r1-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;r2-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;xPSR-(format)&quot; val=&quot;4&quot;/&gt;&lt;/contentList&gt;"/>
<stringAttribute key="org.eclipse.cdt.launch.GLOBAL_VARIABLES" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;globalVariableList/&gt;&#13;&#10;"/>
<stringAttribute key="org.eclipse.cdt.launch.MEMORY_BLOCKS" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;memoryBlockExpressionList&gt;&#13;&#10;&lt;memoryBlockExpressionItem&gt;&#13;&#10;&lt;expression text=&quot;0x20000300&quot;/&gt;&#13;&#10;&lt;/memoryBlockExpressionItem&gt;&#13;&#10;&lt;/memoryBlockExpressionList&gt;&#13;&#10;"/>
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="./build/ch.elf"/>
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="RT-STM32L476-DISCOVERY-SB_HOST"/>
<booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="false"/>
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value="0.603687198"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/RT-STM32L476-DISCOVERY-SB_HOST"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
</listAttribute>
</launchConfiguration>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.cdt.debug.gdbjtag.launchConfigurationType">
<stringAttribute key="bad_container_name" value="\RT-STM32L476-DISCOVERY-SB_HOST\debug"/>
<intAttribute key="org.eclipse.cdt.debug.gdbjtag.core.delay" value="1"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.doHalt" value="true"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.doReset" value="true"/>
<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="set remotetimeout 20&#13;&#10;monitor reset init&#13;&#10;monitor sleep 50&#13;&#10;monitor erase_address pad 0x080F0000 0x00100000&#10;load /home/giovanni/Projects/ChibiStudio/chibios_trunk/demos/STM32/RT-STM32L476-DISCOVERY-SB_CLIENT1/build/ch.elf&#10;load /home/giovanni/Projects/ChibiStudio/chibios_trunk/demos/STM32/RT-STM32L476-DISCOVERY-SB_CLIENT2/build/ch.elf&#10;"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.ipAddress" value="localhost"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.jtagDevice" value="Generic TCP/IP"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadImage" value="true"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadSymbols" value="true"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.pcRegister" value=""/>
<intAttribute key="org.eclipse.cdt.debug.gdbjtag.core.portNumber" value="3333"/>
<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.debug.mi.core.DEBUG_NAME" value="arm-none-eabi-gdb"/>
<stringAttribute key="org.eclipse.cdt.debug.mi.core.commandFactory" value="Standard"/>
<stringAttribute key="org.eclipse.cdt.debug.mi.core.protocol" value="mi"/>
<booleanAttribute key="org.eclipse.cdt.debug.mi.core.verboseMode" value="false"/>
<stringAttribute key="org.eclipse.cdt.dsf.gdb.DEBUG_NAME" value="arm-none-eabi-gdb"/>
<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_REGISTER_GROUPS" value=""/>
<stringAttribute key="org.eclipse.cdt.launch.FORMAT" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&lt;contentList&gt;&lt;content id=&quot;hdr_magic2-sbhp-sbStart-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;hdr_magic1-sbhp-sbStart-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;s_psp-SVC_Handler-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;r0-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;r1-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;r2-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;xPSR-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;s_psp-port_unprivileged_jump-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;psp-SVC_Handler-(format)&quot; val=&quot;4&quot;/&gt;&lt;/contentList&gt;"/>
<stringAttribute key="org.eclipse.cdt.launch.GLOBAL_VARIABLES" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;globalVariableList/&gt;&#10;"/>
<stringAttribute key="org.eclipse.cdt.launch.MEMORY_BLOCKS" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;memoryBlockExpressionList&gt;&#10;&lt;memoryBlockExpressionItem&gt;&#10;&lt;expression text=&quot;0x80f8000&quot;/&gt;&#10;&lt;/memoryBlockExpressionItem&gt;&#10;&lt;/memoryBlockExpressionList&gt;&#10;"/>
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="./build/ch.elf"/>
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="RT-STM32L476-DISCOVERY-SB_HOST"/>
<booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="false"/>
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value="0.603687198"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/RT-STM32L476-DISCOVERY-SB_HOST"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
</listAttribute>
</launchConfiguration>

View File

@ -22,8 +22,39 @@
#include "chprintf.h"
#include "sb.h"
/* SandBox object.*/
sb_class_t sbx1;
/* Static memory areas used by sandboxes.*/
extern uint32_t __flash6_base__, __flash6_end__,
__flash7_base__, __flash7_end__,
__ram6_base__, __ram6_end__,
__ram7_base__, __ram7_end__;
/* Sandbox objects.*/
sb_class_t sbx1, sbx2;
/* Sandbox configurations.*/
static const sb_config_t sb_config1 = {
.code_region = 0U,
.data_region = 1U,
.regions = {
{(uint32_t)&__flash6_base__, (uint32_t)&__flash6_end__, false},
{(uint32_t)&__ram6_base__, (uint32_t)&__ram6_end__, true}
},
.stdin_stream = (SandboxStream *)&SD2,
.stdout_stream = (SandboxStream *)&SD2,
.stderr_stream = (SandboxStream *)&SD2
};
static const sb_config_t sb_config2 = {
.code_region = 0U,
.data_region = 1U,
.regions = {
{(uint32_t)&__flash7_base__, (uint32_t)&__flash7_end__, false},
{(uint32_t)&__ram7_base__, (uint32_t)&__ram7_end__, true}
},
.stdin_stream = (SandboxStream *)&SD2,
.stdout_stream = (SandboxStream *)&SD2,
.stderr_stream = (SandboxStream *)&SD2
};
/*
* LEDs blinker thread, times are in milliseconds.
@ -39,36 +70,24 @@ static THD_FUNCTION(Thread1, arg) {
chThdSleepMilliseconds(50);
palClearLine(LINE_LED_RED);
chThdSleepMilliseconds(200);
(void) sbSendMessage(&sbx1, (msg_t)i);
palSetLine(LINE_LED_GREEN);
chThdSleepMilliseconds(50);
palSetLine(LINE_LED_RED);
chThdSleepMilliseconds(200);
(void) sbSendMessage(&sbx1, (msg_t)i);
(void) sbSendMessage(&sbx2, (msg_t)i);
i++;
}
}
/*
* Unprivileged thread.
* Unprivileged thread1.
*/
static THD_WORKING_AREA(waUnprivileged1, 128);
static THD_FUNCTION(Unprivileged1, arg) {
extern uint32_t __flash7_base__, __flash7_end__,
__ram7_base__, __ram7_end__;
static const sb_config_t sb_config = {
.code_region = 0U,
.data_region = 1U,
.regions = {
{(uint32_t)&__flash7_base__, (uint32_t)&__flash7_end__, false},
{(uint32_t)&__ram7_base__, (uint32_t)&__ram7_end__, true}
},
.stdin_stream = (SandboxStream *)&SD2,
.stdout_stream = (SandboxStream *)&SD2,
.stderr_stream = (SandboxStream *)&SD2
};
(void)arg;
chRegSetThreadName("unprivileged");
chRegSetThreadName("unprivileged1");
/* Sandbox object initialization.*/
sbObjectInit(&sbx1);
@ -76,13 +95,13 @@ static THD_FUNCTION(Unprivileged1, arg) {
/* Static MPU setup for the sandbox, both regions are used because in this
demo it requires both a flash and a RAM regions.*/
mpuConfigureRegion(MPU_REGION_0,
sb_config.regions[0].base,
sb_config1.regions[0].base,
MPU_RASR_ATTR_AP_RO_RO |
MPU_RASR_ATTR_CACHEABLE_WT_NWA |
MPU_RASR_SIZE_32K |
MPU_RASR_ENABLE);
mpuConfigureRegion(MPU_REGION_1,
sb_config.regions[1].base,
sb_config1.regions[1].base,
MPU_RASR_ATTR_AP_RW_RW |
MPU_RASR_ATTR_CACHEABLE_WB_WA |
MPU_RASR_SIZE_4K |
@ -90,7 +109,42 @@ static THD_FUNCTION(Unprivileged1, arg) {
/* This thread goes in the sandbox and is trapped there, it cannot
return, only invoke the sandbox API.*/
sbStart(&sbx1, &sb_config);
sbStart(&sbx1, &sb_config1);
/* Function sbStart() only fails if the sandbox cannot be started
because code header problems.*/
}
/*
* Unprivileged thread2.
*/
static THD_WORKING_AREA(waUnprivileged2, 128);
static THD_FUNCTION(Unprivileged2, arg) {
(void)arg;
chRegSetThreadName("unprivileged2");
/* Sandbox object initialization.*/
sbObjectInit(&sbx2);
/* Static MPU setup for the sandbox, both regions are used because in this
demo it requires both a flash and a RAM regions.*/
mpuConfigureRegion(MPU_REGION_2,
sb_config2.regions[0].base,
MPU_RASR_ATTR_AP_RO_RO |
MPU_RASR_ATTR_CACHEABLE_WT_NWA |
MPU_RASR_SIZE_32K |
MPU_RASR_ENABLE);
mpuConfigureRegion(MPU_REGION_3,
sb_config2.regions[1].base,
MPU_RASR_ATTR_AP_RW_RW |
MPU_RASR_ATTR_CACHEABLE_WB_WA |
MPU_RASR_SIZE_4K |
MPU_RASR_ENABLE);
/* This thread goes in the sandbox and is trapped there, it cannot
return, only invoke the sandbox API.*/
sbStart(&sbx2, &sb_config2);
/* Function sbStart() only fails if the sandbox cannot be started
because code header problems.*/
@ -100,8 +154,8 @@ static THD_FUNCTION(Unprivileged1, arg) {
* Application entry point.
*/
int main(void) {
thread_t *tp;
msg_t msg;
thread_t *tp1, *tp2;
// msg_t msg;
/*
* System initializations.
@ -120,14 +174,19 @@ int main(void) {
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO+10,
Thread1, NULL);
/* Creating the unprivileged thread.*/
chprintf((BaseSequentialStream *)&SD2, "Starting unprivileged thread\r\n");
tp = chThdCreateStatic(waUnprivileged1, sizeof(waUnprivileged1),
NORMALPRIO - 10U, Unprivileged1, NULL);
/* Creating the unprivileged threads.*/
chprintf((BaseSequentialStream *)&SD2, "Starting unprivileged thread 1\r\n");
tp1 = chThdCreateStatic(waUnprivileged1, sizeof(waUnprivileged1),
NORMALPRIO - 10U, Unprivileged1, NULL);
chprintf((BaseSequentialStream *)&SD2, "Starting unprivileged thread 2\r\n");
tp2 = chThdCreateStatic(waUnprivileged2, sizeof(waUnprivileged2),
NORMALPRIO - 10U, Unprivileged2, NULL);
/* Waiting for the unprivileged thread to exit or fail.*/
msg = chThdWait(tp);
chprintf((BaseSequentialStream *)&SD2, "Exit code 0x%x\r\n", msg);
/* Waiting for the unprivileged threads to exit or fail.*/
(void)tp1;
(void)tp2;
// msg = chThdWait(tp1);
// chprintf((BaseSequentialStream *)&SD2, "Exit code 0x%x\r\n", msg);
/* Normal main() thread activity, in this demo it does nothing except
sleeping in a loop and check the button state.*/

View File

@ -90,7 +90,6 @@
.cpu cortex-m3
.thumb
.text
.section .sandbox, "ax"
.align 4
@ -99,7 +98,9 @@ _sandbox: .long 0xFE9154C0
.long 0x0C4519EF
.long 16
.long 0
b _crt0_entry
.text
/*
* CRT0 entry point.
*/