Skip to content
Browse files

Merge branch 'master' of https://github.com/kelvinlawson/atomthreads

  • Loading branch information...
2 parents 9273d4d + 5181143 commit 50f6cd593a308a71a75dfd48a517cd43371d8e44 Kevin Pansky committed Sep 30, 2012
View
7 kernel/atom.h
@@ -30,6 +30,10 @@
#ifndef __ATOM_H
#define __ATOM_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#include "atomtimer.h"
#include "atomport.h"
@@ -122,5 +126,8 @@ extern void archFirstThreadRestore(ATOM_TCB *new_tcb_ptr);
extern void atomTimerTick (void);
+#ifdef __cplusplus
+}
+#endif
#endif /* __ATOM_H */
View
8 kernel/atommutex.h
@@ -29,6 +29,10 @@
#ifndef __ATOM_MUTEX_H
#define __ATOM_MUTEX_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
typedef struct atom_mutex
{
ATOM_TCB * suspQ; /* Queue of threads suspended on this mutex */
@@ -41,4 +45,8 @@ extern uint8_t atomMutexDelete (ATOM_MUTEX *mutex);
extern uint8_t atomMutexGet (ATOM_MUTEX *mutex, int32_t timeout);
extern uint8_t atomMutexPut (ATOM_MUTEX *mutex);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* __ATOM_MUTEX_H */
View
8 kernel/atomqueue.h
@@ -29,6 +29,10 @@
#ifndef __ATOM_QUEUE_H
#define __ATOM_QUEUE_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
typedef struct atom_queue
{
ATOM_TCB * putSuspQ; /* Queue of threads waiting to send */
@@ -46,4 +50,8 @@ extern uint8_t atomQueueDelete (ATOM_QUEUE *qptr);
extern uint8_t atomQueueGet (ATOM_QUEUE *qptr, int32_t timeout, uint8_t *msgptr);
extern uint8_t atomQueuePut (ATOM_QUEUE *qptr, int32_t timeout, uint8_t *msgptr);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* __ATOM_QUEUE_H */
View
8 kernel/atomsem.h
@@ -30,6 +30,10 @@
#ifndef __ATOM_SEM_H
#define __ATOM_SEM_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
typedef struct atom_sem
{
ATOM_TCB * suspQ; /* Queue of threads suspended on this semaphore */
@@ -42,4 +46,8 @@ extern uint8_t atomSemGet (ATOM_SEM *sem, int32_t timeout);
extern uint8_t atomSemPut (ATOM_SEM *sem);
extern uint8_t atomSemResetCount (ATOM_SEM *sem, uint8_t count);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* __ATOM_SEM_H */
View
8 kernel/atomtimer.h
@@ -30,6 +30,10 @@
#ifndef __ATOM_TIMER_H
#define __ATOM_TIMER_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#include "atomport.h"
@@ -58,4 +62,8 @@ extern uint8_t atomTimerDelay (uint32_t ticks);
extern uint32_t atomTimeGet (void);
extern void atomTimeSet (uint32_t new_time);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* __ATOM_TIMER_H */
View
2 ports/armv7a/README
@@ -10,3 +10,5 @@ Following are the steps to add new board <abc> under armv7a port:
4. Add .c files in ports/armv7a/<abc> to implement the board specific functions expected in arm_pic.h, arm_timer.h, and arm_uart.h
5. Add Makefile in ports/armv7a/<abc> (similar to the one in ports/armv7a/pb-a8) to build board specific objects corresponding to the .c files added in step 4.
5. To build atomthreads for <abc> board use following command "make BOARD=<abc>" with ports/armv7a as current directory.
+
+Port contributed by Anup Patel (http://brainfault.blogspot.com).
View
17 ports/avr/Makefile
@@ -15,6 +15,7 @@ CC=/usr/bin/avr-gcc
OBJCOPY=/usr/bin/avr-objcopy
SIZE=/usr/bin/avr-size
UISP=/usr/bin/uisp
+SIMAVR=/tmp/run_avr
# Modify this to the device name of the UART used for UISP
UISP_DEV=/dev/ttyUSB0
@@ -28,6 +29,9 @@ PART=atmega16
# must disable stack-checking to run all of the automated tests.
#STACK_CHECK=true
+# Test programs: Log stack usage to UART (if STACK_CHECK is enabled)
+#TESTS_LOG_STACK=true
+
# Directory for built objects
BUILD_DIR=build
@@ -57,10 +61,13 @@ vpath %.hex ./$(BUILD_DIR)
# GCC flags
CFLAGS=-g -mmcu=$(PART) -Wall -Werror
-# Enable stack-checking (disable if not required)
+# Enable stack-checking options (disable if not required)
ifeq ($(STACK_CHECK),true)
CFLAGS += -DATOM_STACK_CHECKING
endif
+ifeq ($(TESTS_LOG_STACK),true)
+CFLAGS += -DTESTS_LOG_STACK_USAGE
+endif
#################
@@ -115,6 +122,14 @@ program : $(BUILD_DIR)/$(app).hex
$(SIZE) -C --mcu=$(PART) $(BUILD_DIR)/$(app).elf
$(UISP) -dprog=stk500 -dserial=$(UISP_DEV) -dpart=$(PART) --erase --upload --verify if=$(BUILD_DIR)/$(app).hex
+# Generate Doxygen documentation
doxygen:
doxygen $(KERNEL_DIR)/Doxyfile
doxygen ./Doxyfile
+
+# Run tests within simavr simulator
+phony_sim_elfs = $(addsuffix .sim, $(TEST_ELFS))
+simtests: $(phony_sim_elfs)
+.PHONY: simtests $(phony_sim_elfs)
+$(phony_sim_elfs):
+ ./run_test.exp $(SIMAVR) $(PART) $(BUILD_DIR)/$(basename $@)
View
56 ports/avr/README
@@ -37,7 +37,9 @@ A couple of additional source files are also included here:
Atomthreads includes a suite of automated tests which prove the key OS
functionality, and can be used with any architecture ports. This port
provides an easy mechanism for building, downloading and running the test
-suite to prove the OS on your target.
+suite to prove the OS on your target. You may also use the simavr
+simulator to run the entire test suite and prove the OS without real
+hardware.
The port was carried out and tested on both an ATmega16 and ATmega32
running within an STK500 board, utilising the gcc-avr tools. It is possible
@@ -66,9 +68,10 @@ can easily replace UISP by your own favourite programmer if required.
BUILDING THE SOURCE
A Makefile is provided for building the kernel, port and automated tests.
-The full build is carried out using simply:
+The full build is carried out using the following (replacing PART by the
+ATmega device you are using):
- * make
+ * make PART=atmega128
All objects are built into the 'build' folder under ports/avr. The build
process builds separate target applications for each automated test, and
@@ -96,11 +99,12 @@ PROGRAMMING TO THE TARGET DEVICE
Application HEX files which are built into the build folder can be
downloaded to the target using:
- * make program app=<appname>
+ * make PART=<cpu> program app=<appname>
-For example to download the 'sem1.hex' test application to the target use:
+For example to download the 'sem1.hex' test application to an ATmega128
+target use:
- * make program app=sem1
+ * make PART=atmega128 program app=sem1
This uses UISP which will write the application into flash and reset the
CPU to start running the program automatically.
@@ -143,11 +147,11 @@ The full set of tests can be found in the top-level 'tests' folder. Each of
these tests is built as an independent application in the 'build' folder.
Run them individually using:
- * make program app=testname
+ * make PART=<cpu> program app=<testname>
-For example to run the 'kern1.c' test use:
+For example to run the 'kern1.c' test on an ATmega128 device use:
- * make program app=kern1
+ * make PART=atmega128 program app=kern1
Before running the program and data size for the application is printed
out on the terminal. You can use this to verify that your platform has
@@ -190,6 +194,35 @@ initialises the UART driver and redirects stdout via the UART.
---------------------------------------------------------------------------
+RUNNING TESTS WITHIN THE SIMAVR SIMULATOR
+
+It is also possible to run the full automated test suite in a simulator
+without programming the test applications into real hardware. This is very
+useful for quick verification of the entire test suite after making any
+software changes, and is much faster than download each test application to
+a real target.
+
+A single command runs every single test application, and checks the
+(simulated) UART output to verify that each test case passes.
+
+This requires two applications on your development PC: expect and the
+simavr simulator. You can edit the SIMAVR variable in the Makefile to point
+it at the simavr install location on your PC and then run:
+
+ * make PART=atmega128 simtests
+
+This will run every single test application within the simulator and quit
+immediately if any one test fails. You should pick an ATmega device that is
+supported by the simavr simulator: atmega128 is a good choice.
+
+The ability to run these automated tests in one command (and without real
+hardware) allows you to easily include the OS test suite in your nightly
+build or continous integration system and quickly find out if any of your
+local changes have caused any of the operating system tests to fail.
+
+
+---------------------------------------------------------------------------
+
WRITING APPLICATIONS
The easiest way to start a new application which utilises the Atomthreads
@@ -204,7 +237,10 @@ a call to your own application startup code.
PORTING TO OTHER HARDWARE PLATFORMS
If you are using a CPU other than the ATmega16, change the PART definition
-in the Makefile to your own CPU.
+in the Makefile to your own CPU, or specify the PART on the make command
+line using:
+
+ * make PART=atmega128
On CPUs with multiple UARTs, the port uses UART0 to output debug
information. If you wish to use an alternative UART you may change the
View
39 ports/avr/run_test.exp
@@ -0,0 +1,39 @@
+#!/usr/bin/env expect
+
+# Expect script to run an automated test within the AVR simulator (simavr) and
+# check for successful completion.
+#
+# Arguments: <path_to_simavr> <cpu_part> <test_elf_file>
+#
+# Returns 0 on successful test run within AVR simulator, 1 on failure
+
+
+# Start the test
+spawn [lindex $argv 0] -m [lindex $argv 1] [lindex $argv 2]
+
+# Expect to see the test starting within 10 seconds
+set timeout 10
+
+# Wait for the test to start ("Go..")
+expect {
+ "Go.." {
+ puts "Test started"
+
+ # The test could take up to 3 minutes to complete once started
+ set timeout 180
+
+ # Now expect to see "Pass.." or "Fail" within 3 minutes
+ expect {
+ "Pass.." { puts "Test passed"; exit 0 }
+ "Fail" { puts "Test failed"; exit 1 }
+ timeout { puts "Test timed out without completing"; exit 1 }
+ }
+ }
+
+ timeout {
+ # Didn't receive "Go.." within 10 seconds
+ puts "Test failed to start ('Go' not seen)"
+ exit 1
+ }
+}
+
View
2 ports/stm8/README-COSMIC
@@ -237,8 +237,8 @@ To connect a serial cable to the Discovery you will need to connect to
the following pins on the external connectors:
Vcc: CN2 pin 8
GND: CN2 pin 7
+ UART RX: CN4 pin 11 (connect to TX at the PC end)
UART TX: CN4 pin 10 (connect to RX at the PC end)
- UART RX: CN4 pin 9 (connect to TX at the PC end)
Note that the board uses TTL levels so you may need to use a level
converter. External level converters may need to be powered using
a Vdd of 5v, which can be achieved by positioning JP1 on the Discovery.
View
2 ports/stm8/README-IAR
@@ -213,8 +213,8 @@ To connect a serial cable to the Discovery you will need to connect to
the following pins on the external connectors:
Vcc: CN2 pin 8
GND: CN2 pin 7
+ UART RX: CN4 pin 11 (connect to TX at the PC end)
UART TX: CN4 pin 10 (connect to RX at the PC end)
- UART RX: CN4 pin 9 (connect to TX at the PC end)
Note that the board uses TTL levels so you may need to use a level
converter. External level converters may need to be powered using
a Vdd of 5v, which can be achieved by positioning JP1 on the Discovery.
View
2 ports/stm8/README-RAISONANCE
@@ -229,8 +229,8 @@ To connect a serial cable to the Discovery you will need to connect to
the following pins on the external connectors:
Vcc: CN2 pin 8
GND: CN2 pin 7
+ UART RX: CN4 pin 11 (connect to TX at the PC end)
UART TX: CN4 pin 10 (connect to RX at the PC end)
- UART RX: CN4 pin 9 (connect to TX at the PC end)
Note that the board uses TTL levels so you may need to use a level
converter. External level converters may need to be powered using
a Vdd of 5v, which can be achieved by positioning JP1 on the Discovery.

0 comments on commit 50f6cd5

Please sign in to comment.
Something went wrong with that request. Please try again.