Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Pansky committed Oct 1, 2012
2 parents 9273d4d + 5181143 commit 50f6cd5
Show file tree
Hide file tree
Showing 12 changed files with 145 additions and 14 deletions.
7 changes: 7 additions & 0 deletions kernel/atom.h
Expand Up @@ -30,6 +30,10 @@
#ifndef __ATOM_H
#define __ATOM_H

#ifdef __cplusplus
extern "C" {
#endif

#include "atomtimer.h"
#include "atomport.h"

Expand Down Expand Up @@ -122,5 +126,8 @@ extern void archFirstThreadRestore(ATOM_TCB *new_tcb_ptr);

extern void atomTimerTick (void);

#ifdef __cplusplus
}
#endif

#endif /* __ATOM_H */
8 changes: 8 additions & 0 deletions kernel/atommutex.h
Expand Up @@ -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 */
Expand All @@ -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 */
8 changes: 8 additions & 0 deletions kernel/atomqueue.h
Expand Up @@ -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 */
Expand All @@ -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 */
8 changes: 8 additions & 0 deletions kernel/atomsem.h
Expand Up @@ -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 */
Expand All @@ -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 */
8 changes: 8 additions & 0 deletions kernel/atomtimer.h
Expand Up @@ -30,6 +30,10 @@
#ifndef __ATOM_TIMER_H
#define __ATOM_TIMER_H

#ifdef __cplusplus
extern "C" {
#endif

#include "atomport.h"


Expand Down Expand Up @@ -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 */
2 changes: 2 additions & 0 deletions ports/armv7a/README
Expand Up @@ -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).
17 changes: 16 additions & 1 deletion ports/avr/Makefile
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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


#################
Expand Down Expand Up @@ -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 $@)
56 changes: 46 additions & 10 deletions ports/avr/README
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -188,6 +192,35 @@ the OS, creates a main thread, and calls out to the test modules. It also
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
Expand All @@ -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
Expand Down
39 changes: 39 additions & 0 deletions 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
}
}

2 changes: 1 addition & 1 deletion ports/stm8/README-COSMIC
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion ports/stm8/README-IAR
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion ports/stm8/README-RAISONANCE
Expand Up @@ -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.
Expand Down

0 comments on commit 50f6cd5

Please sign in to comment.