diff options
author | Giovanni Di Sirio <gdisirio@gmail.com> | 2015-04-11 18:08:14 +0000 |
---|---|---|
committer | Giovanni Di Sirio <gdisirio@gmail.com> | 2015-04-11 18:08:14 +0000 |
commit | c54ddc8ef6c00bfd1bbb7163bfd1db3210366b6e (patch) | |
tree | 1563ce5d121256c28cdafcd2a5c2326bc7c747ff | |
parent | b89d451592f0bd9877e6e2bd3ca29cfb4d5ee9d2 (diff) | |
download | ChibiOS-c54ddc8ef6c00bfd1bbb7163bfd1db3210366b6e.tar.gz ChibiOS-c54ddc8ef6c00bfd1bbb7163bfd1db3210366b6e.tar.bz2 ChibiOS-c54ddc8ef6c00bfd1bbb7163bfd1db3210366b6e.zip |
All IRQ_STORM applications reworked.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@7884 35acf78f-673a-0410-8e92-d51de3d6d3f4
27 files changed, 441 insertions, 1397 deletions
diff --git a/readme.txt b/readme.txt index 7c07b3e0e..a5baddcca 100644 --- a/readme.txt +++ b/readme.txt @@ -76,6 +76,7 @@ *** 3.0.0p2 ***
- HAL: Fixed instances of RT API in HAL drivers (bug 574).
- RT: Fixed system time overflow issue in tickless mode (bug 573).
+- RT: Improvements to the IRQ_STORM applications.
*** 3.0.0p1 ***
- First 3.0.0 release, see release note 3.0.0.
diff --git a/testhal/STM32/STM32F0xx/IRQ_STORM/.cproject b/testhal/STM32/STM32F0xx/IRQ_STORM/.cproject index 8c3040aad..8feb5c219 100644 --- a/testhal/STM32/STM32F0xx/IRQ_STORM/.cproject +++ b/testhal/STM32/STM32F0xx/IRQ_STORM/.cproject @@ -1,7 +1,5 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<?fileVersion 4.0.0?>
-
-<cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
+<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<storageModule moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="0.958990767">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="0.958990767" moduleId="org.eclipse.cdt.core.settings" name="Default">
diff --git a/testhal/STM32/STM32F0xx/IRQ_STORM/.project b/testhal/STM32/STM32F0xx/IRQ_STORM/.project index 8c63b9bf4..8d92ecdc8 100644 --- a/testhal/STM32/STM32F0xx/IRQ_STORM/.project +++ b/testhal/STM32/STM32F0xx/IRQ_STORM/.project @@ -30,6 +30,11 @@ <locationURI>CHIBIOS/os/hal/boards/ST_STM32F0_DISCOVERY</locationURI>
</link>
<link>
+ <name>common</name>
+ <type>2</type>
+ <locationURI>CHIBIOS/testhal/common</locationURI>
+ </link>
+ <link>
<name>os</name>
<type>2</type>
<locationURI>CHIBIOS/os</locationURI>
diff --git a/testhal/STM32/STM32F0xx/IRQ_STORM/Makefile b/testhal/STM32/STM32F0xx/IRQ_STORM/Makefile index 40bdd6a62..b83d8487b 100644 --- a/testhal/STM32/STM32F0xx/IRQ_STORM/Makefile +++ b/testhal/STM32/STM32F0xx/IRQ_STORM/Makefile @@ -102,6 +102,9 @@ CSRC = $(STARTUPSRC) \ $(PLATFORMSRC) \
$(BOARDSRC) \
$(TESTSRC) \
+ $(CHIBIOS)/os/hal/lib/streams/memstreams.c \
+ $(CHIBIOS)/os/hal/lib/streams/chprintf.c \
+ $(CHIBIOS)/testhal/common/irq_storm.c \
main.c
# C++ sources that can be compiled in ARM or THUMB mode depending on the global
@@ -133,7 +136,9 @@ ASMSRC = $(STARTUPASM) $(PORTASM) $(OSALASM) INCDIR = $(STARTUPINC) $(KERNINC) $(PORTINC) $(OSALINC) \
$(HALINC) $(PLATFORMINC) $(BOARDINC) $(TESTINC) \
- $(CHIBIOS)/os/various
+ $(CHIBIOS)/os/hal/lib/streams \
+ $(CHIBIOS)/os/various \
+ $(CHIBIOS)/testhal/common
#
# Project, sources and paths
diff --git a/testhal/STM32/STM32F0xx/IRQ_STORM/debug/STM32F0xx-IRQ_STORM (OpenOCD, Flash and Run).launch b/testhal/STM32/STM32F0xx/IRQ_STORM/debug/STM32F0xx-IRQ_STORM (OpenOCD, Flash and Run).launch new file mode 100644 index 000000000..daaac228b --- /dev/null +++ b/testhal/STM32/STM32F0xx/IRQ_STORM/debug/STM32F0xx-IRQ_STORM (OpenOCD, Flash and Run).launch @@ -0,0 +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="\STM32F0xx-IRQ_STORM\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 monitor reset init monitor sleep 50 "/>
+<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="<?xml version="1.0" encoding="UTF-8" standalone="no"?><contentList/>"/>
+<stringAttribute key="org.eclipse.cdt.launch.GLOBAL_VARIABLES" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <globalVariableList/> "/>
+<stringAttribute key="org.eclipse.cdt.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <memoryBlockExpressionList/> "/>
+<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="./build/ch.elf"/>
+<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="STM32F0xx-IRQ_STORM"/>
+<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="0.958990767"/>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/STM32F0xx-IRQ_STORM"/>
+</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>
diff --git a/testhal/STM32/STM32F0xx/IRQ_STORM/main.c b/testhal/STM32/STM32F0xx/IRQ_STORM/main.c index ef5e498a9..96d5fbaae 100644 --- a/testhal/STM32/STM32F0xx/IRQ_STORM/main.c +++ b/testhal/STM32/STM32F0xx/IRQ_STORM/main.c @@ -14,140 +14,17 @@ limitations under the License.
*/
-#include <stdlib.h>
-
#include "ch.h"
#include "hal.h"
-/*===========================================================================*/
-/* Configurable settings. */
-/*===========================================================================*/
-
-#ifndef RANDOMIZE
-#define RANDOMIZE FALSE
-#endif
-
-#ifndef ITERATIONS
-#define ITERATIONS 100
-#endif
-
-#ifndef NUM_THREADS
-#define NUM_THREADS 4
-#endif
-
-#ifndef MAILBOX_SIZE
-#define MAILBOX_SIZE 4
-#endif
-
-/*===========================================================================*/
-/* Test related code. */
-/*===========================================================================*/
-
-#define MSG_SEND_LEFT 0
-#define MSG_SEND_RIGHT 1
-
-static bool saturated;
+#include "irq_storm.h"
/*
- * Mailboxes and buffers.
+ * GPT1 configuration.
*/
-static mailbox_t mb[NUM_THREADS];
-static msg_t b[NUM_THREADS][MAILBOX_SIZE];
-
-/*
- * Test worker threads.
- */
-static THD_WORKING_AREA(waWorkerThread[NUM_THREADS], 128);
-static THD_FUNCTION(WorkerThread, arg) {
- static volatile unsigned x = 0;
- static unsigned cnt = 0;
- unsigned me = (unsigned)arg;
- unsigned target;
- unsigned r;
- msg_t msg;
-
- chRegSetThreadName("worker");
-
- /* Work loop.*/
- while (true) {
- /* Waiting for a message.*/
- chMBFetch(&mb[me], &msg, TIME_INFINITE);
-
-#if RANDOMIZE
- /* Pseudo-random delay.*/
- {
- chSysLock();
- r = rand() & 15;
- chSysUnlock();
- while (r--)
- x++;
- }
-#else
- /* Fixed delay.*/
- {
- r = me >> 4;
- while (r--)
- x++;
- }
-#endif
-
- /* Deciding in which direction to re-send the message.*/
- if (msg == MSG_SEND_LEFT)
- target = me - 1;
- else
- target = me + 1;
-
- if (target < NUM_THREADS) {
- /* If this thread is not at the end of a chain re-sending the message,
- note this check works because the variable target is unsigned.*/
- msg = chMBPost(&mb[target], msg, TIME_IMMEDIATE);
- if (msg != MSG_OK)
- saturated = TRUE;
- }
- else {
- /* Provides a visual feedback about the system.*/
- if (++cnt >= 500) {
- cnt = 0;
- palTogglePad(GPIOC, GPIOC_LED4);
- }
- }
- }
-}
-
-/*
- * GPT2 callback.
- */
-static void gpt2cb(GPTDriver *gptp) {
- msg_t msg;
-
- (void)gptp;
- chSysLockFromISR();
- msg = chMBPostI(&mb[0], MSG_SEND_RIGHT);
- if (msg != MSG_OK)
- saturated = TRUE;
- chSysUnlockFromISR();
-}
-
-/*
- * GPT3 callback.
- */
-static void gpt3cb(GPTDriver *gptp) {
- msg_t msg;
-
- (void)gptp;
- chSysLockFromISR();
- msg = chMBPostI(&mb[NUM_THREADS - 1], MSG_SEND_LEFT);
- if (msg != MSG_OK)
- saturated = TRUE;
- chSysUnlockFromISR();
-}
-
-/*
- * GPT2 configuration.
- */
-static const GPTConfig gpt2cfg = {
- 1000000, /* 1MHz timer clock.*/
- gpt2cb, /* Timer callback.*/
+static const GPTConfig gpt1cfg = {
+ 1000000, /* 1MHz timer clock.*/
+ irq_storm_gpt1_cb, /* Timer callback.*/
0,
0
};
@@ -156,52 +33,30 @@ static const GPTConfig gpt2cfg = { * GPT3 configuration.
*/
static const GPTConfig gpt3cfg = {
- 1000000, /* 1MHz timer clock.*/
- gpt3cb, /* Timer callback.*/
+ 1000000, /* 1MHz timer clock.*/
+ irq_storm_gpt2_cb, /* Timer callback.*/
0,
0
};
-
-/*===========================================================================*/
-/* Generic demo code. */
-/*===========================================================================*/
-
-static void print(char *p) {
-
- while (*p) {
- chSequentialStreamPut(&SD1, *p++);
- }
-}
-
-static void println(char *p) {
-
- while (*p) {
- chSequentialStreamPut(&SD1, *p++);
- }
- chSequentialStreamWrite(&SD1, (uint8_t *)"\r\n", 2);
-}
-
-static void printn(uint32_t n) {
- char buf[16], *p;
-
- if (!n)
- chSequentialStreamPut(&SD1, '0');
- else {
- p = buf;
- while (n)
- *p++ = (n % 10) + '0', n /= 10;
- while (p > buf)
- chSequentialStreamPut(&SD1, *--p);
- }
-}
+/*
+ * IRQ Storm configuration.
+ */
+static const irq_storm_config_t irq_storm_config = {
+ (BaseSequentialStream *)&SD1,
+ GPIOC,
+ GPIOC_LED4,
+ &GPTD1,
+ &GPTD3,
+ &gpt1cfg,
+ &gpt3cfg,
+ STM32_SYSCLK
+};
/*
* Application entry point.
*/
int main(void) {
- unsigned i;
- gptcnt_t interval, threshold, worst;
/*
* System initializations.
@@ -213,120 +68,16 @@ int main(void) { halInit();
chSysInit();
- /*
- * Prepares the Serial driver 1 and GPT drivers 2 and 3.
- */
+ /* Prepares the Serial driver 1.*/
sdStart(&SD1, NULL);
palSetPadMode(GPIOA, 9, PAL_MODE_ALTERNATE(1)); /* USART1 TX. */
palSetPadMode(GPIOA, 10, PAL_MODE_ALTERNATE(1)); /* USART1 RX. */
- gptStart(&GPTD1, &gpt2cfg);
- gptStart(&GPTD3, &gpt3cfg);
- /*
- * Initializes the mailboxes and creates the worker threads.
- */
- for (i = 0; i < NUM_THREADS; i++) {
- chMBObjectInit(&mb[i], b[i], MAILBOX_SIZE);
- chThdCreateStatic(waWorkerThread[i], sizeof waWorkerThread[i],
- NORMALPRIO - 20, WorkerThread, (void *)i);
- }
+ /* Running the test.*/
+ irq_storm_execute(&irq_storm_config);
- /*
- * Test procedure.
- */
- println("");
- println("*** ChibiOS/RT IRQ-STORM long duration test");
- println("***");
- print("*** Kernel: ");
- println(CH_KERNEL_VERSION);
- print("*** Compiled: ");
- println(__DATE__ " - " __TIME__);
-#ifdef PORT_COMPILER_NAME
- print("*** Compiler: ");
- println(PORT_COMPILER_NAME);
-#endif
- print("*** Architecture: ");
- println(PORT_ARCHITECTURE_NAME);
-#ifdef PORT_CORE_VARIANT_NAME
- print("*** Core Variant: ");
- println(PORT_CORE_VARIANT_NAME);
-#endif
-#ifdef PORT_INFO
- print("*** Port Info: ");
- println(PORT_INFO);
-#endif
-#ifdef PLATFORM_NAME
- print("*** Platform: ");
- println(PLATFORM_NAME);
-#endif
-#ifdef BOARD_NAME
- print("*** Test Board: ");
- println(BOARD_NAME);
-#endif
- println("***");
- print("*** System Clock: ");
- printn(STM32_SYSCLK);
- println("");
- print("*** Iterations: ");
- printn(ITERATIONS);
- println("");
- print("*** Randomize: ");
- printn(RANDOMIZE);
- println("");
- print("*** Threads: ");
- printn(NUM_THREADS);
- println("");
- print("*** Mailbox size: ");
- printn(MAILBOX_SIZE);
- println("");
-
- println("");
- worst = 0;
- for (i = 1; i <= ITERATIONS; i++){
- print("Iteration ");
- printn(i);
- println("");
- saturated = FALSE;
- threshold = 0;
- for (interval = 2000; interval >= 20; interval -= interval / 10) {
- gptStartContinuous(&GPTD1, interval - 1); /* Slightly out of phase.*/
- gptStartContinuous(&GPTD3, interval + 1); /* Slightly out of phase.*/
- chThdSleepMilliseconds(1000);
- gptStopTimer(&GPTD1);
- gptStopTimer(&GPTD3);
- if (!saturated)
- print(".");
- else {
- print("#");
- if (threshold == 0)
- threshold = interval;
- }
- }
- /* Gives the worker threads a chance to empty the mailboxes before next
- cycle.*/
- chThdSleepMilliseconds(20);
- println("");
- print("Saturated at ");
- printn(threshold);
- println(" uS");
- println("");
- if (threshold > worst)
- worst = threshold;
- }
- gptStopTimer(&GPTD1);
- gptStopTimer(&GPTD3);
-
- print("Worst case at ");
- printn(worst);
- println(" uS");
- println("");
- println("Test Complete");
-
- /*
- * Normal main() thread activity, nothing in this test.
- */
+ /* Normal main() thread activity, nothing in this test.*/
while (true) {
chThdSleepMilliseconds(5000);
}
- return 0;
}
diff --git a/testhal/STM32/STM32F1xx/IRQ_STORM/.cproject b/testhal/STM32/STM32F1xx/IRQ_STORM/.cproject index 34b2612a8..e798a40c2 100644 --- a/testhal/STM32/STM32F1xx/IRQ_STORM/.cproject +++ b/testhal/STM32/STM32F1xx/IRQ_STORM/.cproject @@ -1,7 +1,5 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<?fileVersion 4.0.0?>
-
-<cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
+<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<storageModule moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="0.1100010532">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="0.1100010532" moduleId="org.eclipse.cdt.core.settings" name="Default">
@@ -48,4 +46,5 @@ </scannerConfigBuildInfo>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
+ <storageModule moduleId="refreshScope"/>
</cproject>
diff --git a/testhal/STM32/STM32F1xx/IRQ_STORM/.project b/testhal/STM32/STM32F1xx/IRQ_STORM/.project index 8a26197ea..16c19220c 100644 --- a/testhal/STM32/STM32F1xx/IRQ_STORM/.project +++ b/testhal/STM32/STM32F1xx/IRQ_STORM/.project @@ -25,6 +25,11 @@ </natures>
<linkedResources>
<link>
+ <name>common</name>
+ <type>2</type>
+ <locationURI>CHIBIOS/testhal/common</locationURI>
+ </link>
+ <link>
<name>os</name>
<type>2</type>
<locationURI>CHIBIOS/os</locationURI>
diff --git a/testhal/STM32/STM32F1xx/IRQ_STORM/Makefile b/testhal/STM32/STM32F1xx/IRQ_STORM/Makefile index 2386f0ae0..d7923ac4c 100644 --- a/testhal/STM32/STM32F1xx/IRQ_STORM/Makefile +++ b/testhal/STM32/STM32F1xx/IRQ_STORM/Makefile @@ -107,6 +107,9 @@ CSRC = $(STARTUPSRC) \ $(PLATFORMSRC) \
$(BOARDSRC) \
$(TESTSRC) \
+ $(CHIBIOS)/os/hal/lib/streams/memstreams.c \
+ $(CHIBIOS)/os/hal/lib/streams/chprintf.c \
+ $(CHIBIOS)/testhal/common/irq_storm.c \
main.c
# C++ sources that can be compiled in ARM or THUMB mode depending on the global
@@ -138,7 +141,9 @@ ASMSRC = $(STARTUPASM) $(PORTASM) $(OSALASM) INCDIR = $(STARTUPINC) $(KERNINC) $(PORTINC) $(OSALINC) \
$(HALINC) $(PLATFORMINC) $(BOARDINC) $(TESTINC) \
- $(CHIBIOS)/os/various
+ $(CHIBIOS)/os/hal/lib/streams \
+ $(CHIBIOS)/os/various \
+ $(CHIBIOS)/testhal/common
#
# Project, sources and paths
diff --git a/testhal/STM32/STM32F1xx/IRQ_STORM/debug/STM32F1xx-IRQ_STORM (OpenOCD, Flash and Run).launch b/testhal/STM32/STM32F1xx/IRQ_STORM/debug/STM32F1xx-IRQ_STORM (OpenOCD, Flash and Run).launch new file mode 100644 index 000000000..3a714d154 --- /dev/null +++ b/testhal/STM32/STM32F1xx/IRQ_STORM/debug/STM32F1xx-IRQ_STORM (OpenOCD, Flash and Run).launch @@ -0,0 +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="\STM32F1xx-IRQ_STORM\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 monitor reset init monitor sleep 50 "/>
+<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="<?xml version="1.0" encoding="UTF-8" standalone="no"?><contentList/>"/>
+<stringAttribute key="org.eclipse.cdt.launch.GLOBAL_VARIABLES" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <globalVariableList/> "/>
+<stringAttribute key="org.eclipse.cdt.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <memoryBlockExpressionList/> "/>
+<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="./build/ch.elf"/>
+<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="STM32F1xx-IRQ_STORM"/>
+<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="0.51705747"/>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/STM32F1xx-IRQ_STORM"/>
+</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>
diff --git a/testhal/STM32/STM32F1xx/IRQ_STORM/main.c b/testhal/STM32/STM32F1xx/IRQ_STORM/main.c index 1cc385d86..cf6519863 100644 --- a/testhal/STM32/STM32F1xx/IRQ_STORM/main.c +++ b/testhal/STM32/STM32F1xx/IRQ_STORM/main.c @@ -14,140 +14,17 @@ limitations under the License.
*/
-#include <stdlib.h>
-
#include "ch.h"
#include "hal.h"
-/*===========================================================================*/
-/* Configurable settings. */
-/*===========================================================================*/
-
-#ifndef RANDOMIZE
-#define RANDOMIZE FALSE
-#endif
-
-#ifndef ITERATIONS
-#define ITERATIONS 100
-#endif
-
-#ifndef NUM_THREADS
-#define NUM_THREADS 4
-#endif
-
-#ifndef MAILBOX_SIZE
-#define MAILBOX_SIZE 4
-#endif
-
-/*===========================================================================*/
-/* Test related code. */
-/*===========================================================================*/
-
-#define MSG_SEND_LEFT 0
-#define MSG_SEND_RIGHT 1
-
-static bool saturated;
-
-/*
- * Mailboxes and buffers.
- */
-static mailbox_t mb[NUM_THREADS];
-static msg_t b[NUM_THREADS][MAILBOX_SIZE];
-
-/*
- * Test worker threads.
- */
-static THD_WORKING_AREA(waWorkerThread[NUM_THREADS], 128);
-static THD_FUNCTION(WorkerThread, arg) {
- static volatile unsigned x = 0;
- static unsigned cnt = 0;
- unsigned me = (unsigned)arg;
- unsigned target;
- unsigned r;
- msg_t msg;
-
- chRegSetThreadName("worker");
-
- /* Work loop.*/
- while (true) {
- /* Waiting for a message.*/
- chMBFetch(&mb[me], &msg, TIME_INFINITE);
-
-#if RANDOMIZE
- /* Pseudo-random delay.*/
- {
- chSysLock();
- r = rand() & 15;
- chSysUnlock();
- while (r--)
- x++;
- }
-#else
- /* Fixed delay.*/
- {
- r = me >> 4;
- while (r--)
- x++;
- }
-#endif
-
- /* Deciding in which direction to re-send the message.*/
- if (msg == MSG_SEND_LEFT)
- target = me - 1;
- else
- target = me + 1;
-
- if (target < NUM_THREADS) {
- /* If this thread is not at the end of a chain re-sending the message,
- note this check works because the variable target is unsigned.*/
- msg = chMBPost(&mb[target], msg, TIME_IMMEDIATE);
- if (msg != MSG_OK)
- saturated = TRUE;
- }
- else {
- /* Provides a visual feedback about the system.*/
- if (++cnt >= 500) {
- cnt = 0;
- palTogglePad(GPIOC, GPIOC_LED);
- }
- }
- }
-}
-
-/*
- * GPT2 callback.
- */
-static void gpt4cb(GPTDriver *gptp) {
- msg_t msg;
-
- (void)gptp;
- chSysLockFromISR();
- msg = chMBPostI(&mb[0], MSG_SEND_RIGHT);
- if (msg != MSG_OK)
- saturated = TRUE;
- chSysUnlockFromISR();
-}
-
-/*
- * GPT3 callback.
- */
-static void gpt3cb(GPTDriver *gptp) {
- msg_t msg;
-
- (void)gptp;
- chSysLockFromISR();
- msg = chMBPostI(&mb[NUM_THREADS - 1], MSG_SEND_LEFT);
- if (msg != MSG_OK)
- saturated = TRUE;
- chSysUnlockFromISR();
-}
+#include "irq_storm.h"
/*
- * GPT2 configuration.
+ * GPT4 configuration.
*/
static const GPTConfig gpt4cfg = {
- 1000000, /* 1MHz timer clock.*/
- gpt4cb, /* Timer callback.*/
+ 1000000, /* 1MHz timer clock.*/
+ irq_storm_gpt1_cb, /* Timer callback.*/
0,
0
};
@@ -156,52 +33,30 @@ static const GPTConfig gpt4cfg = { * GPT3 configuration.
*/
static const GPTConfig gpt3cfg = {
- 1000000, /* 1MHz timer clock.*/
- gpt3cb, /* Timer callback.*/
+ 1000000, /* 1MHz timer clock.*/
+ irq_storm_gpt2_cb, /* Timer callback.*/
0,
0
};
-
-/*===========================================================================*/
-/* Generic demo code. */
-/*===========================================================================*/
-
-static void print(char *p) {
-
- while (*p) {
- chSequentialStreamPut(&SD2, *p++);
- }
-}
-
-static void println(char *p) {
-
- while (*p) {
- chSequentialStreamPut(&SD2, *p++);
- }
- chSequentialStreamWrite(&SD2, (uint8_t *)"\r\n", 2);
-}
-
-static void printn(uint32_t n) {
- char buf[16], *p;
-
- if (!n)
- chSequentialStreamPut(&SD2, '0');
- else {
- p = buf;
- while (n)
- *p++ = (n % 10) + '0', n /= 10;
- while (p > buf)
- chSequentialStreamPut(&SD2, *--p);
- }
-}
+/*
+ * IRQ Storm configuration.
+ */
+static const irq_storm_config_t irq_storm_config = {
+ (BaseSequentialStream *)&SD2,
+ GPIOC,
+ GPIOC_LED,
+ &GPTD4,
+ &GPTD3,
+ &gpt4cfg,
+ &gpt3cfg,
+ STM32_SYSCLK
+};
/*
* Application entry point.
*/
int main(void) {
- unsigned i;
- gptcnt_t interval, threshold, worst;
/*
* System initializations.
@@ -213,120 +68,13 @@ int main(void) { halInit();
chSysInit();
- /*
- * Activates the serial driver 2.
- */
+ /* Prepares the Serial driver 2.*/
sdStart(&SD2, NULL);
- /*
- * Activates GPTs.
- */
- gptStart(&GPTD4, &gpt4cfg);
- gptStart(&GPTD3, &gpt3cfg);
-
- /*
- * Initializes the mailboxes and creates the worker threads.
- */
- for (i = 0; i < NUM_THREADS; i++) {
- chMBObjectInit(&mb[i], b[i], MAILBOX_SIZE);
- chThdCreateStatic(waWorkerThread[i], sizeof waWorkerThread[i],
- NORMALPRIO - 20, WorkerThread, (void *)i);
- }
-
- /*
- * Test procedure.
- */
- println("");
- println("*** ChibiOS/RT IRQ-STORM long duration test");
- println("***");
- print("*** Kernel: ");
- println(CH_KERNEL_VERSION);
- print("*** Compiled: ");
- println(__DATE__ " - " __TIME__);
-#ifdef PORT_COMPILER_NAME
- print("*** Compiler: ");
- println(PORT_COMPILER_NAME);
-#endif
- print("*** Architecture: ");
- println(PORT_ARCHITECTURE_NAME);
-#ifdef PORT_CORE_VARIANT_NAME
- print("*** Core Variant: ");
- println(PORT_CORE_VARIANT_NAME);
-#endif
-#ifdef PORT_INFO
- print("*** Port Info: ");
- println(PORT_INFO);
-#endif
-#ifdef PLATFORM_NAME
- print("*** Platform: ");
- println(PLATFORM_NAME);
-#endif
-#ifdef BOARD_NAME
- print("*** Test Board: ");
- println(BOARD_NAME);
-#endif
- println("***");
- print("*** System Clock: ");
- printn(STM32_SYSCLK);
- println("");
- print("*** Iterations: ");
- printn(ITERATIONS);
- println("");
- print("*** Randomize: ");
- printn(RANDOMIZE);
- println("");
- print("*** Threads: ");
- printn(NUM_THREADS);
- println("");
- print("*** Mailbox size: ");
- printn(MAILBOX_SIZE);
- println("");
-
- println("");
- worst = 0;
- for (i = 1; i <= ITERATIONS; i++){
- print("Iteration ");
- printn(i);
- println("");
- saturated = FALSE;
- threshold = 0;
- for (interval = 2000; interval >= 10; interval -= interval / 10) {
- gptStartContinuous(&GPTD4, interval - 1); /* Slightly out of phase.*/
- gptStartContinuous(&GPTD3, interval + 1); /* Slightly out of phase.*/
- chThdSleepMilliseconds(1000);
- gptStopTimer(&GPTD4);
- gptStopTimer(&GPTD3);
- if (!saturated)
- print(".");
- else {
- print("#");
- if (threshold == 0)
- threshold = interval;
- }
- }
- /* Gives the worker threads a chance to empty the mailboxes before next
- cycle.*/
- chThdSleepMilliseconds(20);
- println("");
- print("Saturated at ");
- printn(threshold);
- println(" uS");
- println("");
- if (threshold > worst)
- worst = threshold;
- }
- gptStopTimer(&GPTD4);
- gptStopTimer(&GPTD3);
-
- print("Worst case at ");
- printn(worst);
- println(" uS");
- println("");
- println("Test Complete");
+ /* Running the test.*/
+ irq_storm_execute(&irq_storm_config);
- /*
- * Normal main() thread activity, nothing in this test.
- */
+ /* Normal main() thread activity, nothing in this test.*/
while (true) {
chThdSleepMilliseconds(5000);
}
diff --git a/testhal/STM32/STM32F30x/IRQ_STORM/.cproject b/testhal/STM32/STM32F30x/IRQ_STORM/.cproject index e59cf38b3..22e472dc2 100644 --- a/testhal/STM32/STM32F30x/IRQ_STORM/.cproject +++ b/testhal/STM32/STM32F30x/IRQ_STORM/.cproject @@ -1,7 +1,5 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<?fileVersion 4.0.0?>
-
-<cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
+<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<storageModule moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="0.51705747">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="0.51705747" moduleId="org.eclipse.cdt.core.settings" name="Default">
diff --git a/testhal/STM32/STM32F30x/IRQ_STORM/.project b/testhal/STM32/STM32F30x/IRQ_STORM/.project index c3e2f6a31..f7ea1cdb0 100644 --- a/testhal/STM32/STM32F30x/IRQ_STORM/.project +++ b/testhal/STM32/STM32F30x/IRQ_STORM/.project @@ -30,6 +30,11 @@ <locationURI>CHIBIOS/os/hal/boards/ST_STM32F3_DISCOVERY</locationURI>
</link>
<link>
+ <name>common</name>
+ <type>2</type>
+ <locationURI>CHIBIOS/testhal/common</locationURI>
+ </link>
+ <link>
<name>os</name>
<type>2</type>
<locationURI>CHIBIOS/os</locationURI>
diff --git a/testhal/STM32/STM32F30x/IRQ_STORM/Makefile b/testhal/STM32/STM32F30x/IRQ_STORM/Makefile index 95ca4593e..bfaa51678 100644 --- a/testhal/STM32/STM32F30x/IRQ_STORM/Makefile +++ b/testhal/STM32/STM32F30x/IRQ_STORM/Makefile @@ -107,6 +107,9 @@ CSRC = $(STARTUPSRC) \ $(PLATFORMSRC) \
$(BOARDSRC) \
$(TESTSRC) \
+ $(CHIBIOS)/os/hal/lib/streams/memstreams.c \
+ $(CHIBIOS)/os/hal/lib/streams/chprintf.c \
+ $(CHIBIOS)/testhal/common/irq_storm.c \
main.c
# C++ sources that can be compiled in ARM or THUMB mode depending on the global
@@ -138,7 +141,9 @@ ASMSRC = $(STARTUPASM) $(PORTASM) $(OSALASM) INCDIR = $(STARTUPINC) $(KERNINC) $(PORTINC) $(OSALINC) \
$(HALINC) $(PLATFORMINC) $(BOARDINC) $(TESTINC) \
- $(CHIBIOS)/os/various
+ $(CHIBIOS)/os/hal/lib/streams \
+ $(CHIBIOS)/os/various \
+ $(CHIBIOS)/testhal/common
#
# Project, sources and paths
diff --git a/testhal/STM32/STM32F30x/IRQ_STORM/debug/STM32F30x-IRQ_STORM (OpenOCD, Flash and Run).launch b/testhal/STM32/STM32F30x/IRQ_STORM/debug/STM32F30x-IRQ_STORM (OpenOCD, Flash and Run).launch new file mode 100644 index 000000000..ccd0b3029 --- /dev/null +++ b/testhal/STM32/STM32F30x/IRQ_STORM/debug/STM32F30x-IRQ_STORM (OpenOCD, Flash and Run).launch @@ -0,0 +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="\STM32F30x-IRQ_STORM\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 monitor reset init monitor sleep 50 "/>
+<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="<?xml version="1.0" encoding="UTF-8" standalone="no"?><contentList/>"/>
+<stringAttribute key="org.eclipse.cdt.launch.GLOBAL_VARIABLES" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <globalVariableList/> "/>
+<stringAttribute key="org.eclipse.cdt.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <memoryBlockExpressionList/> "/>
+<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="./build/ch.elf"/>
+<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="STM32F30x-IRQ_STORM"/>
+<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="0.51705747"/>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/STM32F30x-IRQ_STORM"/>
+</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>
diff --git a/testhal/STM32/STM32F30x/IRQ_STORM/main.c b/testhal/STM32/STM32F30x/IRQ_STORM/main.c index 09d922afe..dd0fa938e 100644 --- a/testhal/STM32/STM32F30x/IRQ_STORM/main.c +++ b/testhal/STM32/STM32F30x/IRQ_STORM/main.c @@ -14,140 +14,17 @@ limitations under the License.
*/
-#include <stdlib.h>
-
#include "ch.h"
#include "hal.h"
-/*===========================================================================*/
-/* Configurable settings. */
-/*===========================================================================*/
-
-#ifndef RANDOMIZE
-#define RANDOMIZE FALSE
-#endif
-
-#ifndef ITERATIONS
-#define ITERATIONS 100
-#endif
-
-#ifndef NUM_THREADS
-#define NUM_THREADS 4
-#endif
-
-#ifndef MAILBOX_SIZE
-#define MAILBOX_SIZE 4
-#endif
-
-/*===========================================================================*/
-/* Test related code. */
-/*===========================================================================*/
-
-#define MSG_SEND_LEFT 0
-#define MSG_SEND_RIGHT 1
-
-static bool saturated;
-
-/*
- * Mailboxes and buffers.
- */
-static mailbox_t mb[NUM_THREADS];
-static msg_t b[NUM_THREADS][MAILBOX_SIZE];
-
-/*
- * Test worker threads.
- */
-static THD_WORKING_AREA(waWorkerThread[NUM_THREADS], 128);
-static THD_FUNCTION(WorkerThread, arg) {
- static volatile unsigned x = 0;
- static unsigned cnt = 0;
- unsigned me = (unsigned)arg;
- unsigned target;
- unsigned r;
- msg_t msg;
-
- chRegSetThreadName("worker");
-
- /* Work loop.*/
- while (true) {
- /* Waiting for a message.*/
- chMBFetch(&mb[me], &msg, TIME_INFINITE);
-
-#if RANDOMIZE
- /* Pseudo-random delay.*/
- {
- chSysLock();
- r = rand() & 15;
- chSysUnlock();
- while (r--)
- x++;
- }
-#else
- /* Fixed delay.*/
- {
- r = me >> 4;
- while (r--)
- x++;
- }
-#endif
-
- /* Deciding in which direction to re-send the message.*/
- if (msg == MSG_SEND_LEFT)
- target = me - 1;
- else
- target = me + 1;
-
- if (target < NUM_THREADS) {
- /* If this thread is not at the end of a chain re-sending the message,
- note this check works because the variable target is unsigned.*/
- msg = chMBPost(&mb[target], msg, TIME_IMMEDIATE);
- if (msg != MSG_OK)
- saturated = TRUE;
- }
- else {
- /* Provides a visual feedback about the system.*/
- if (++cnt >= 500) {
- cnt = 0;
- palTogglePad(GPIOE, GPIOE_LED10_RED);
- }
- }
- }
-}
-
-/*
- * GPT2 callback.
- */
-static void gpt4cb(GPTDriver *gptp) {
- msg_t msg;
-
- (void)gptp;
- chSysLockFromISR();
- msg = chMBPostI(&mb[0], MSG_SEND_RIGHT);
- if (msg != MSG_OK)
- saturated = TRUE;
- chSysUnlockFromISR();
-}
-
-/*
- * GPT3 callback.
- */
-static void gpt3cb(GPTDriver *gptp) {
- msg_t msg;
-
- (void)gptp;
- chSysLockFromISR();
- msg = chMBPostI(&mb[NUM_THREADS - 1], MSG_SEND_LEFT);
- if (msg != MSG_OK)
- saturated = TRUE;
- chSysUnlockFromISR();
-}
+#include "irq_storm.h"
/*
- * GPT2 configuration.
+ * GPT4 configuration.
*/
static const GPTConfig gpt4cfg = {
- 1000000, /* 1MHz timer clock.*/
- gpt4cb, /* Timer callback.*/
+ 1000000, /* 1MHz timer clock.*/
+ irq_storm_gpt1_cb, /* Timer callback.*/
0,
0
};
@@ -156,52 +33,30 @@ static const GPTConfig gpt4cfg = { * GPT3 configuration.
*/
static const GPTConfig gpt3cfg = {
- 1000000, /* 1MHz timer clock.*/
- gpt3cb, /* Timer callback.*/
+ 1000000, /* 1MHz timer clock.*/
+ irq_storm_gpt2_cb, /* Timer callback.*/
0,
0
};
-
-/*===========================================================================*/
-/* Generic demo code. */
-/*===========================================================================*/
-
-static void print(char *p) {
-
- while (*p) {
- chSequentialStreamPut(&SD1, *p++);
- }
-}
-
-static void println(char *p) {
-
- while (*p) {
- chSequentialStreamPut(&SD1, *p++);
- }
- chSequentialStreamWrite(&SD1, (uint8_t *)"\r\n", 2);
-}
-
-static void printn(uint32_t n) {
- char buf[16], *p;
-
- if (!n)
- chSequentialStreamPut(&SD1, '0');
- else {
- p = buf;
- while (n)
- *p++ = (n % 10) + '0', n /= 10;
- while (p > buf)
- chSequentialStreamPut(&SD1, *--p);
- }
-}
+/*
+ * IRQ Storm configuration.
+ */
+static const irq_storm_config_t irq_storm_config = {
+ (BaseSequentialStream *)&SD1,
+ GPIOE,
+ GPIOE_LED10_RED,
+ &GPTD4,
+ &GPTD3,
+ &gpt4cfg,
+ &gpt3cfg,
+ STM32_SYSCLK
+};
/*
* Application entry point.
*/
int main(void) {
- unsigned i;
- gptcnt_t interval, threshold, worst;
/*
* System initializations.
@@ -213,122 +68,15 @@ int main(void) { halInit();
chSysInit();
- /*
- * Activates the serial driver 1, PA9 and PA10 are routed to USART1.
- */
+ /* Prepares the Serial driver 1.*/
sdStart(&SD1, NULL);
palSetPadMode(GPIOA, 9, PAL_MODE_ALTERNATE(7)); /* USART1 TX. */
palSetPadMode(GPIOA, 10, PAL_MODE_ALTERNATE(7)); /* USART1 RX. */
- /*
- * Activates GPTs.
- */
- gptStart(&GPTD4, &gpt4cfg);
- gptStart(&GPTD3, &gpt3cfg);
-
- /*
- * Initializes the mailboxes and creates the worker threads.
- */
- for (i = 0; i < NUM_THREADS; i++) {
- chMBObjectInit(&mb[i], b[i], MAILBOX_SIZE);
- chThdCreateStatic(waWorkerThread[i], sizeof waWorkerThread[i],
- NORMALPRIO - 20, WorkerThread, (void *)i);
- }
-
- /*
- * Test procedure.
- */
- println("");
- println("*** ChibiOS/RT IRQ-STORM long duration test");
- println("***");
- print("*** Kernel: ");
- println(CH_KERNEL_VERSION);
- print("*** Compiled: ");
- println(__DATE__ " - " __TIME__);
-#ifdef PORT_COMPILER_NAME
- print("*** Compiler: ");
- println(PORT_COMPILER_NAME);
-#endif
- print("*** Architecture: ");
- println(PORT_ARCHITECTURE_NAME);
-#ifdef PORT_CORE_VARIANT_NAME
- print("*** Core Variant: ");
- println(PORT_CORE_VARIANT_NAME);
-#endif
-#ifdef PORT_INFO
- print("*** Port Info: ");
- println(PORT_INFO);
-#endif
-#ifdef PLATFORM_NAME
- print("*** Platform: ");
- println(PLATFORM_NAME);
-#endif
-#ifdef BOARD_NAME
- print("*** Test Board: ");
- println(BOARD_NAME);
-#endif
- println("***");
- print("*** System Clock: ");
- printn(STM32_SYSCLK);
- println("");
- print("*** Iterations: ");
- printn(ITERATIONS);
- println("");
- print("*** Randomize: ");
- printn(RANDOMIZE);
- println("");
- print("*** Threads: ");
- printn(NUM_THREADS);
- println("");
- print("*** Mailbox size: ");
- printn(MAILBOX_SIZE);
- println("");
-
- println("");
- worst = 0;
- for (i = 1; i <= ITERATIONS; i++){
- print("Iteration ");
- printn(i);
- println("");
- saturated = FALSE;
- threshold = 0;
- for (interval = 2000; interval >= 10; interval -= interval / 10) {
- gptStartContinuous(&GPTD4, interval - 1); /* Slightly out of phase.*/
- gptStartContinuous(&GPTD3, interval + 1); /* Slightly out of phase.*/
- chThdSleepMilliseconds(1000);
- gptStopTimer(&GPTD4);
- gptStopTimer(&GPTD3);
- if (!saturated)
- print(".");
- else {
- print("#");
- if (threshold == 0)
- threshold = interval;
- }
- }
- /* Gives the worker threads a chance to empty the mailboxes before next
- cycle.*/
- chThdSleepMilliseconds(20);
- println("");
- print("Saturated at ");
- printn(threshold);
- println(" uS");
- println("");
- if (threshold > worst)
- worst = threshold;
- }
- gptStopTimer(&GPTD4);
- gptStopTimer(&GPTD3);
-
- print("Worst case at ");
- printn(worst);
- println(" uS");
- println("");
- println("Test Complete");
+ /* Running the test.*/
+ irq_storm_execute(&irq_storm_config);
- /*
- * Normal main() thread activity, nothing in this test.
- */
+ /* Normal main() thread activity, nothing in this test.*/
while (true) {
chThdSleepMilliseconds(5000);
}
diff --git a/testhal/STM32/STM32F37x/IRQ_STORM/.cproject b/testhal/STM32/STM32F37x/IRQ_STORM/.cproject index 77982a8a0..70c4251f8 100644 --- a/testhal/STM32/STM32F37x/IRQ_STORM/.cproject +++ b/testhal/STM32/STM32F37x/IRQ_STORM/.cproject @@ -1,7 +1,5 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<?fileVersion 4.0.0?>
-
-<cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
+<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<storageModule moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="0.922537871">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="0.922537871" moduleId="org.eclipse.cdt.core.settings" name="Default">
diff --git a/testhal/STM32/STM32F37x/IRQ_STORM/.project b/testhal/STM32/STM32F37x/IRQ_STORM/.project index 9768d6602..f524c509e 100644 --- a/testhal/STM32/STM32F37x/IRQ_STORM/.project +++ b/testhal/STM32/STM32F37x/IRQ_STORM/.project @@ -30,6 +30,11 @@ <locationURI>CHIBIOS/os/hal/boards/ST_STM32373C_EVAL</locationURI>
</link>
<link>
+ <name>common</name>
+ <type>2</type>
+ <locationURI>CHIBIOS/testhal/common</locationURI>
+ </link>
+ <link>
<name>os</name>
<type>2</type>
<locationURI>CHIBIOS/os</locationURI>
diff --git a/testhal/STM32/STM32F37x/IRQ_STORM/Makefile b/testhal/STM32/STM32F37x/IRQ_STORM/Makefile index 4fe2e3058..b48408ea6 100644 --- a/testhal/STM32/STM32F37x/IRQ_STORM/Makefile +++ b/testhal/STM32/STM32F37x/IRQ_STORM/Makefile @@ -107,6 +107,9 @@ CSRC = $(STARTUPSRC) \ $(PLATFORMSRC) \
$(BOARDSRC) \
$(TESTSRC) \
+ $(CHIBIOS)/os/hal/lib/streams/memstreams.c \
+ $(CHIBIOS)/os/hal/lib/streams/chprintf.c \
+ $(CHIBIOS)/testhal/common/irq_storm.c \
main.c
# C++ sources that can be compiled in ARM or THUMB mode depending on the global
@@ -138,7 +141,9 @@ ASMSRC = $(STARTUPASM) $(PORTASM) $(OSALASM) INCDIR = $(STARTUPINC) $(KERNINC) $(PORTINC) $(OSALINC) \
$(HALINC) $(PLATFORMINC) $(BOARDINC) $(TESTINC) \
- $(CHIBIOS)/os/various
+ $(CHIBIOS)/os/hal/lib/streams \
+ $(CHIBIOS)/os/various \
+ $(CHIBIOS)/testhal/common
#
# Project, sources and paths
diff --git a/testhal/STM32/STM32F37x/IRQ_STORM/debug/STM32F37x-IRQ_STORM (OpenOCD, Flash and Run).launch b/testhal/STM32/STM32F37x/IRQ_STORM/debug/STM32F37x-IRQ_STORM (OpenOCD, Flash and Run).launch new file mode 100644 index 000000000..ded2fefe1 --- /dev/null +++ b/testhal/STM32/STM32F37x/IRQ_STORM/debug/STM32F37x-IRQ_STORM (OpenOCD, Flash and Run).launch @@ -0,0 +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="\STM32F37x-IRQ_STORM\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 monitor reset init monitor sleep 50 "/>
+<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="<?xml version="1.0" encoding="UTF-8" standalone="no"?><contentList/>"/>
+<stringAttribute key="org.eclipse.cdt.launch.GLOBAL_VARIABLES" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <globalVariableList/> "/>
+<stringAttribute key="org.eclipse.cdt.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <memoryBlockExpressionList/> "/>
+<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="./build/ch.elf"/>
+<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="STM32F37x-IRQ_STORM"/>
+<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="0.922537871"/>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/STM32F37x-IRQ_STORM"/>
+</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>
diff --git a/testhal/STM32/STM32F37x/IRQ_STORM/main.c b/testhal/STM32/STM32F37x/IRQ_STORM/main.c index f7a2fd642..deb8b9503 100644 --- a/testhal/STM32/STM32F37x/IRQ_STORM/main.c +++ b/testhal/STM32/STM32F37x/IRQ_STORM/main.c @@ -14,140 +14,17 @@ limitations under the License.
*/
-#include <stdlib.h>
-
#include "ch.h"
#include "hal.h"
-/*===========================================================================*/
-/* Configurable settings. */
-/*===========================================================================*/
-
-#ifndef RANDOMIZE
-#define RANDOMIZE FALSE
-#endif
-
-#ifndef ITERATIONS
-#define ITERATIONS 100
-#endif
-
-#ifndef NUM_THREADS
-#define NUM_THREADS 4
-#endif
-
-#ifndef MAILBOX_SIZE
-#define MAILBOX_SIZE 4
-#endif
-
-/*===========================================================================*/
-/* Test related code. */
-/*===========================================================================*/
-
-#define MSG_SEND_LEFT 0
-#define MSG_SEND_RIGHT 1
-
-static bool saturated;
-
-/*
- * Mailboxes and buffers.
- */
-static mailbox_t mb[NUM_THREADS];
-static msg_t b[NUM_THREADS][MAILBOX_SIZE];
-
-/*
- * Test worker threads.
- */
-static THD_WORKING_AREA(waWorkerThread[NUM_THREADS], 128);
-static THD_FUNCTION(WorkerThread, arg) {
- static volatile unsigned x = 0;
- static unsigned cnt = 0;
- unsigned me = (unsigned)arg;
- unsigned target;
- unsigned r;
- msg_t msg;
-
- chRegSetThreadName("worker");
-
- /* Work loop.*/
- while (true) {
- /* Waiting for a message.*/
- chMBFetch(&mb[me], &msg, TIME_INFINITE);
-
-#if RANDOMIZE
- /* Pseudo-random delay.*/
- {
- chSysLock();
- r = rand() & 15;
- chSysUnlock();
- while (r--)
- x++;
- }
-#else
- /* Fixed delay.*/
- {
- r = me >> 4;
- while (r--)
- x++;
- }
-#endif
-
- /* Deciding in which direction to re-send the message.*/
- if (msg == MSG_SEND_LEFT)
- target = me - 1;
- else
- target = me + 1;
-
- if (target < NUM_THREADS) {
- /* If this thread is not at the end of a chain re-sending the message,
- note this check works because the variable target is unsigned.*/
- msg = chMBPost(&mb[target], msg, TIME_IMMEDIATE);
- if (msg != MSG_OK)
- saturated = TRUE;
- }
- else {
- /* Provides a visual feedback about the system.*/
- if (++cnt >= 500) {
- cnt = 0;
- palTogglePad(GPIOC, GPIOC_LED1);
- }
- }
- }
-}
-
-/*
- * GPT2 callback.
- */
-static void gpt2cb(GPTDriver *gptp) {
- msg_t msg;
-
- (void)gptp;
- chSysLockFromISR();
- msg = chMBPostI(&mb[0], MSG_SEND_RIGHT);
- if (msg != MSG_OK)
- saturated = TRUE;
- chSysUnlockFromISR();
-}
-
-/*
- * GPT3 callback.
- */
-static void gpt3cb(GPTDriver *gptp) {
- msg_t msg;
-
- (void)gptp;
- chSysLockFromISR();
- msg = chMBPostI(&mb[NUM_THREADS - 1], MSG_SEND_LEFT);
- if (msg != MSG_OK)
- saturated = TRUE;
- chSysUnlockFromISR();
-}
+#include "irq_storm.h"
/*
- * GPT2 configuration.
+ * GPT4 configuration.
*/
-static const GPTConfig gpt2cfg = {
- 1000000, /* 1MHz timer clock.*/
- gpt2cb, /* Timer callback.*/
+static const GPTConfig gpt4cfg = {
+ 1000000, /* 1MHz timer clock.*/
+ irq_storm_gpt1_cb, /* Timer callback.*/
0,
0
};
@@ -156,52 +33,30 @@ static const GPTConfig gpt2cfg = { * GPT3 configuration.
*/
static const GPTConfig gpt3cfg = {
- 1000000, /* 1MHz timer clock.*/
- gpt3cb, /* Timer callback.*/
+ 1000000, /* 1MHz timer clock.*/
+ irq_storm_gpt2_cb, /* Timer callback.*/
0,
0
};
-
-/*===========================================================================*/
-/* Generic demo code. */
-/*===========================================================================*/
-
-static void print(char *p) {
-
- while (*p) {
- chSequentialStreamPut(&SD2, *p++);
- }
-}
-
-static void println(char *p) {
-
- while (*p) {
- chSequentialStreamPut(&SD2, *p++);
- }
- chSequentialStreamWrite(&SD2, (uint8_t *)"\r\n", 2);
-}
-
-static void printn(uint32_t n) {
- char buf[16], *p;
-
- if (!n)
- chSequentialStreamPut(&SD2, '0');
- else {
- p = buf;
- while (n)
- *p++ = (n % 10) + '0', n /= 10;
- while (p > buf)
- chSequentialStreamPut(&SD2, *--p);
- }
-}
+/*
+ * IRQ Storm configuration.
+ */
+static const irq_storm_config_t irq_storm_config = {
+ (BaseSequentialStream *)&SD2,
+ GPIOC,
+ GPIOC_LED1,
+ &GPTD4,
+ &GPTD3,
+ &gpt4cfg,
+ &gpt3cfg,
+ STM32_SYSCLK
+};
/*
* Application entry point.
*/
int main(void) {
- unsigned i;
- gptcnt_t interval, threshold, worst;
/*
* System initializations.
@@ -213,121 +68,13 @@ int main(void) { halInit();
chSysInit();
- /*
- * Activates the serial driver 2 using the default configuration, pins
- * are pre-configured in board.h.
- */
+ /* Prepares the Serial driver 1.*/
sdStart(&SD2, NULL);
- /*
- * Activates GPTs.
- */
- gptStart(&GPTD4, &gpt2cfg);
- gptStart(&GPTD3, &gpt3cfg);
-
- /*
- * Initializes the mailboxes and creates the worker threads.
- */
- for (i = 0; i < NUM_THREADS; i++) {
- chMBObjectInit(&mb[i], b[i], MAILBOX_SIZE);
- chThdCreateStatic(waWorkerThread[i], sizeof waWorkerThread[i],
- NORMALPRIO - 20, WorkerThread, (void *)i);
- }
-
- /*
- * Test procedure.
- */
- println("");
- println("*** ChibiOS/RT IRQ-STORM long duration test");
- println("***");
- print("*** Kernel: ");
- println(CH_KERNEL_VERSION);
- print("*** Compiled: ");
- println(__DATE__ " - " __TIME__);
-#ifdef PORT_COMPILER_NAME
- print("*** Compiler: ");
- println(PORT_COMPILER_NAME);
-#endif
- print("*** Architecture: ");
- println(PORT_ARCHITECTURE_NAME);
-#ifdef PORT_CORE_VARIANT_NAME
- print("*** Core Variant: ");
- println(PORT_CORE_VARIANT_NAME);
-#endif
-#ifdef PORT_INFO
- print("*** Port Info: ");
- println(PORT_INFO);
-#endif
-#ifdef PLATFORM_NAME
- print("*** Platform: ");
- println(PLATFORM_NAME);
-#endif
-#ifdef BOARD_NAME
- print("*** Test Board: ");
- println(BOARD_NAME);
-#endif
- println("***");
- print("*** System Clock: ");
- printn(STM32_SYSCLK);
- println("");
- print("*** Iterations: ");
- printn(ITERATIONS);
- println("");
- print("*** Randomize: ");
- printn(RANDOMIZE);
- println("");
- print("*** Threads: ");
- printn(NUM_THREADS);
- println("");
- print("*** Mailbox size: ");
- printn(MAILBOX_SIZE);
- println("");
-
- println("");
- worst = 0;
- for (i = 1; i <= ITERATIONS; i++){
- print("Iteration ");
- printn(i);
- println("");
- saturated = FALSE;
- threshold = 0;
- for (interval = 2000; interval >= 10; interval -= interval / 10) {
- gptStartContinuous(&GPTD4, interval - 1); /* Slightly out of phase.*/
- gptStartContinuous(&GPTD3, interval + 1); /* Slightly out of phase.*/
- chThdSleepMilliseconds(1000);
- gptStopTimer(&GPTD4);
- gptStopTimer(&GPTD3);
- if (!saturated)
- print(".");
- else {
- print("#");
- if (threshold == 0)
- threshold = interval;
- }
- }
- /* Gives the worker threads a chance to empty the mailboxes before next
- cycle.*/
- chThdSleepMilliseconds(20);
- println("");
- print("Saturated at ");
- printn(threshold);
- println(" uS");
- println("");
- if (threshold > worst)
- worst = threshold;
- }
- gptStopTimer(&GPTD4);
- gptStopTimer(&GPTD3);
-
- print("Worst case at ");
- printn(worst);
- println(" uS");
- println("");
- println("Test Complete");
+ /* Running the test.*/
+ irq_storm_execute(&irq_storm_config);
- /*
- * Normal main() thread activity, nothing in this test.
- */
+ /* Normal main() thread activity, nothing in this test.*/
while (true) {
chThdSleepMilliseconds(5000);
}
diff --git a/testhal/STM32/STM32L1xx/IRQ_STORM/.cproject b/testhal/STM32/STM32L1xx/IRQ_STORM/.cproject index c40e67d63..a75fb8d5c 100644 --- a/testhal/STM32/STM32L1xx/IRQ_STORM/.cproject +++ b/testhal/STM32/STM32L1xx/IRQ_STORM/.cproject @@ -1,7 +1,5 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<?fileVersion 4.0.0?>
-
-<cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
+<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<storageModule moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="0.200678309">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="0.200678309" moduleId="org.eclipse.cdt.core.settings" name="Default">
diff --git a/testhal/STM32/STM32L1xx/IRQ_STORM/.project b/testhal/STM32/STM32L1xx/IRQ_STORM/.project index 9fd81bee3..b81d66f7e 100644 --- a/testhal/STM32/STM32L1xx/IRQ_STORM/.project +++ b/testhal/STM32/STM32L1xx/IRQ_STORM/.project @@ -25,6 +25,11 @@ </natures>
<linkedResources>
<link>
+ <name>common</name>
+ <type>2</type>
+ <locationURI>CHIBIOS/testhal/common</locationURI>
+ </link>
+ <link>
<name>os</name>
<type>2</type>
<locationURI>CHIBIOS/os</locationURI>
diff --git a/testhal/STM32/STM32L1xx/IRQ_STORM/Makefile b/testhal/STM32/STM32L1xx/IRQ_STORM/Makefile index 9d4785aa1..db07590f9 100644 --- a/testhal/STM32/STM32L1xx/IRQ_STORM/Makefile +++ b/testhal/STM32/STM32L1xx/IRQ_STORM/Makefile @@ -107,6 +107,9 @@ CSRC = $(STARTUPSRC) \ $(PLATFORMSRC) \
$(BOARDSRC) \
$(TESTSRC) \
+ $(CHIBIOS)/os/hal/lib/streams/memstreams.c \
+ $(CHIBIOS)/os/hal/lib/streams/chprintf.c \
+ $(CHIBIOS)/testhal/common/irq_storm.c \
main.c
# C++ sources that can be compiled in ARM or THUMB mode depending on the global
@@ -138,7 +141,9 @@ ASMSRC = $(STARTUPASM) $(PORTASM) $(OSALASM) INCDIR = $(STARTUPINC) $(KERNINC) $(PORTINC) $(OSALINC) \
$(HALINC) $(PLATFORMINC) $(BOARDINC) $(TESTINC) \
- $(CHIBIOS)/os/various
+ $(CHIBIOS)/os/hal/lib/streams \
+ $(CHIBIOS)/os/various \
+ $(CHIBIOS)/testhal/common
#
# Project, sources and paths
diff --git a/testhal/STM32/STM32L1xx/IRQ_STORM/debug/STM32L1xx-IRQ_STORM (OpenOCD, Flash and Run).launch b/testhal/STM32/STM32L1xx/IRQ_STORM/debug/STM32L1xx-IRQ_STORM (OpenOCD, Flash and Run).launch new file mode 100644 index 000000000..564bedf01 --- /dev/null +++ b/testhal/STM32/STM32L1xx/IRQ_STORM/debug/STM32L1xx-IRQ_STORM (OpenOCD, Flash and Run).launch @@ -0,0 +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="\STM32L1xx-IRQ_STORM\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 monitor reset init monitor sleep 50 "/>
+<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="<?xml version="1.0" encoding="UTF-8" standalone="no"?><contentList/>"/>
+<stringAttribute key="org.eclipse.cdt.launch.GLOBAL_VARIABLES" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <globalVariableList/> "/>
+<stringAttribute key="org.eclipse.cdt.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <memoryBlockExpressionList/> "/>
+<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="./build/ch.elf"/>
+<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="STM32L1xx-IRQ_STORM"/>
+<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="0.200678309"/>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/STM32L1xx-IRQ_STORM"/>
+</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>
diff --git a/testhal/STM32/STM32L1xx/IRQ_STORM/main.c b/testhal/STM32/STM32L1xx/IRQ_STORM/main.c index 3d3ea3a1f..a4b843c5b 100644 --- a/testhal/STM32/STM32L1xx/IRQ_STORM/main.c +++ b/testhal/STM32/STM32L1xx/IRQ_STORM/main.c @@ -14,140 +14,17 @@ limitations under the License.
*/
-#include <stdlib.h>
-
#include "ch.h"
#include "hal.h"
-/*===========================================================================*/
-/* Configurable settings. */
-/*===========================================================================*/
-
-#ifndef RANDOMIZE
-#define RANDOMIZE FALSE
-#endif
-
-#ifndef ITERATIONS
-#define ITERATIONS 100
-#endif
-
-#ifndef NUM_THREADS
-#define NUM_THREADS 4
-#endif
-
-#ifndef MAILBOX_SIZE
-#define MAILBOX_SIZE 4
-#endif
-
-/*===========================================================================*/
-/* Test related code. */
-/*===========================================================================*/
-
-#define MSG_SEND_LEFT 0
-#define MSG_SEND_RIGHT 1
-
-static bool saturated;
-
-/*
- * Mailboxes and buffers.
- */
-static mailbox_t mb[NUM_THREADS];
-static msg_t b[NUM_THREADS][MAILBOX_SIZE];
-
-/*
- * Test worker threads.
- */
-static THD_WORKING_AREA(waWorkerThread[NUM_THREADS], 128);
-static THD_FUNCTION(WorkerThread, arg) {
- static volatile unsigned x = 0;
- static unsigned cnt = 0;
- unsigned me = (unsigned)arg;
- unsigned target;
- unsigned r;
- msg_t msg;
-
- chRegSetThreadName("worker");
-
- /* Work loop.*/
- while (true) {
- /* Waiting for a message.*/
- chMBFetch(&mb[me], &msg, TIME_INFINITE);
-
-#if RANDOMIZE
- /* Pseudo-random delay.*/
- {
- chSysLock();
- r = rand() & 15;
- chSysUnlock();
- while (r--)
- x++;
- }
-#else
- /* Fixed delay.*/
- {
- r = me >> 4;
- while (r--)
- x++;
- }
-#endif
-
- /* Deciding in which direction to re-send the message.*/
- if (msg == MSG_SEND_LEFT)
- target = me - 1;
- else
- target = me + 1;
-
- if (target < NUM_THREADS) {
- /* If this thread is not at the end of a chain re-sending the message,
- note this check works because the variable target is unsigned.*/
- msg = chMBPost(&mb[target], msg, TIME_IMMEDIATE);
- if (msg != MSG_OK)
- saturated = TRUE;
- }
- else {
- /* Provides a visual feedback about the system.*/
- if (++cnt >= 500) {
- cnt = 0;
- palTogglePad(GPIOB, GPIOB_LED4);
- }
- }
- }
-}
-
-/*
- * GPT2 callback.
- */
-static void gpt4cb(GPTDriver *gptp) {
- msg_t msg;
-
- (void)gptp;
- chSysLockFromISR();
- msg = chMBPostI(&mb[0], MSG_SEND_RIGHT);
- if (msg != MSG_OK)
- saturated = TRUE;
- chSysUnlockFromISR();
-}
-
-/*
- * GPT3 callback.
- */
-static void gpt3cb(GPTDriver *gptp) {
- msg_t msg;
-
- (void)gptp;
- chSysLockFromISR();
- msg = chMBPostI(&mb[NUM_THREADS - 1], MSG_SEND_LEFT);
- if (msg != MSG_OK)
- saturated = TRUE;
- chSysUnlockFromISR();
-}
+#include "irq_storm.h"
/*
- * GPT2 configuration.
+ * GPT4 configuration.
*/
static const GPTConfig gpt4cfg = {
- 1000000, /* 1MHz timer clock.*/
- gpt4cb, /* Timer callback.*/
+ 1000000, /* 1MHz timer clock.*/
+ irq_storm_gpt1_cb, /* Timer callback.*/
0,
0
};
@@ -156,52 +33,30 @@ static const GPTConfig gpt4cfg = { * GPT3 configuration.
*/
static const GPTConfig gpt3cfg = {
- 1000000, /* 1MHz timer clock.*/
- gpt3cb, /* Timer callback.*/
+ 1000000, /* 1MHz timer clock.*/
+ irq_storm_gpt2_cb, /* Timer callback.*/
0,
0
};
-
-/*===========================================================================*/
-/* Generic demo code. */
-/*===========================================================================*/
-
-static void print(char *p) {
-
- while (*p) {
- chSequentialStreamPut(&SD1, *p++);
- }
-}
-
-static void println(char *p) {
-
- while (*p) {
- chSequentialStreamPut(&SD1, *p++);
- }
- chSequentialStreamWrite(&SD1, (uint8_t *)"\r\n", 2);
-}
-
-static void printn(uint32_t n) {
- char buf[16], *p;
-
- if (!n)
- chSequentialStreamPut(&SD1, '0');
- else {
- p = buf;
- while (n)
- *p++ = (n % 10) + '0', n /= 10;
- while (p > buf)
- chSequentialStreamPut(&SD1, *--p);
- }
-}
+/*
+ * IRQ Storm configuration.
+ */
+static const irq_storm_config_t irq_storm_config = {
+ (BaseSequentialStream *)&SD1,
+ GPIOB,
+ GPIOB_LED4,
+ &GPTD4,
+ &GPTD3,
+ &gpt4cfg,
+ &gpt3cfg,
+ STM32_SYSCLK
+};
/*
* Application entry point.
*/
int main(void) {
- unsigned i;
- gptcnt_t interval, threshold, worst;
/*
* System initializations.
@@ -213,122 +68,15 @@ int main(void) { halInit();
chSysInit();
- /*
- * Activates the serial driver 1, PA9 and PA10 are routed to USART1.
- */
+ /* Prepares the Serial driver 1.*/
sdStart(&SD1, NULL);
palSetPadMode(GPIOA, 9, PAL_MODE_ALTERNATE(7)); /* USART1 TX. */
palSetPadMode(GPIOA, 10, PAL_MODE_ALTERNATE(7)); /* USART1 RX. */
- /*
- * Activates GPTs.
- */
- gptStart(&GPTD4, &gpt4cfg);
- gptStart(&GPTD3, &gpt3cfg);
-
- /*
- * Initializes the mailboxes and creates the worker threads.
- */
- for (i = 0; i < NUM_THREADS; i++) {
- chMBObjectInit(&mb[i], b[i], MAILBOX_SIZE);
- chThdCreateStatic(waWorkerThread[i], sizeof waWorkerThread[i],
- NORMALPRIO - 20, WorkerThread, (void *)i);
- }
-
- /*
- * Test procedure.
- */
- println("");
- println("*** ChibiOS/RT IRQ-STORM long duration test");
- println("***");
- print("*** Kernel: ");
- println(CH_KERNEL_VERSION);
- print("*** Compiled: ");
- println(__DATE__ " - " __TIME__);
-#ifdef PORT_COMPILER_NAME
- print("*** Compiler: ");
- println(PORT_COMPILER_NAME);
-#endif
- print("*** Architecture: ");
- println(PORT_ARCHITECTURE_NAME);
-#ifdef PORT_CORE_VARIANT_NAME
- print("*** Core Variant: ");
- println(PORT_CORE_VARIANT_NAME);
-#endif
-#ifdef PORT_INFO
- print("*** Port Info: ");
- println(PORT_INFO);
-#endif
-#ifdef PLATFORM_NAME
- print("*** Platform: ");
- println(PLATFORM_NAME);
-#endif
-#ifdef BOARD_NAME
- print("*** Test Board: ");
- println(BOARD_NAME);
-#endif
- println("***");
- print("*** System Clock: ");
- printn(STM32_SYSCLK);
- println("");
- print("*** Iterations: ");
- printn(ITERATIONS);
- println("");
- print("*** Randomize: ");
- printn(RANDOMIZE);
- println("");
- print("*** Threads: ");
- printn(NUM_THREADS);
- println("");
- print("*** Mailbox size: ");
- printn(MAILBOX_SIZE);
- println("");
-
- println("");
- worst = 0;
- for (i = 1; i <= ITERATIONS; i++){
- print("Iteration ");
- printn(i);
- println("");
- saturated = FALSE;
- threshold = 0;
- for (interval = 2000; interval >= 10; interval -= interval / 10) {
- gptStartContinuous(&GPTD4, interval - 1); /* Slightly out of phase.*/
- gptStartContinuous(&GPTD3, interval + 1); /* Slightly out of phase.*/
- chThdSleepMilliseconds(1000);
- gptStopTimer(&GPTD4);
- gptStopTimer(&GPTD3);
- if (!saturated)
- print(".");
- else {
- print("#");
- if (threshold == 0)
- threshold = interval;
- }
- }
- /* Gives the worker threads a chance to empty the mailboxes before next
- cycle.*/
- chThdSleepMilliseconds(20);
- println("");
- print("Saturated at ");
- printn(threshold);
- println(" uS");
- println("");
- if (threshold > worst)
- worst = threshold;
- }
- gptStopTimer(&GPTD4);
- gptStopTimer(&GPTD3);
-
- print("Worst case at ");
- printn(worst);
- println(" uS");
- println("");
- println("Test Complete");
+ /* Running the test.*/
+ irq_storm_execute(&irq_storm_config);
- /*
- * Normal main() thread activity, nothing in this test.
- */
+ /* Normal main() thread activity, nothing in this test.*/
while (true) {
chThdSleepMilliseconds(5000);
}
diff --git a/testhal/common/irq_storm.c b/testhal/common/irq_storm.c index 5e0e4cc69..2e5382881 100644 --- a/testhal/common/irq_storm.c +++ b/testhal/common/irq_storm.c @@ -263,8 +263,8 @@ void irq_storm_execute(const irq_storm_config_t *cfg) { if (threshold > worst)
worst = threshold;
}
- gptStopTimer(&GPTD4);
- gptStopTimer(&GPTD3);
+ gptStopTimer(cfg->gpt1p);
+ gptStopTimer(cfg->gpt2p);
chprintf(cfg->out, "Worst case at %d uS\r\n", worst);
chprintf(cfg->out, "\r\nTest Complete\r\n");
|