From 54c777ef0de5af1361b717fe41888d7c8497fd38 Mon Sep 17 00:00:00 2001
From: Gregory Nutt Last Updated: March 20, 2013 Last Updated: June 11, 2013
NuttX RTOS Porting Guide
-
2.4.2.2 Board Specific Configuration Sub-Directories
- 2.4.3 Supported Boards
+ 2.4.3 Supported Boards
+ 2.4.4 Adding a New Board Configuration
2.5 nuttx/drivers/
2.6 nuttx/fs/
@@ -795,13 +796,13 @@
configs/ea3131
:
- Embedded Artists EA3131 Development bard. This board is based on the
+ Embedded Artists EA3131 Development bard. This board is based on the
an NXP LPC3131 MCU. This OS is built with the arm-nuttx-elf toolchain.
STATUS: This port is complete and mature.
configs/eagle100
:
- Micromint Eagle-100 Development board. This board is based on the
+ Micromint Eagle-100 Development board. This board is based on the
an ARM Cortex-M3 MCU, the Luminary LM3S6918. This OS is built with the
arm-nuttx-elf toolchain. STATUS: This port is complete and mature.
configs/lm3s6965-ek
:
- Stellaris LM3S6965 Evaluation Kit. This board is based on the
+ Stellaris LM3S6965 Evaluation Kit. This board is based on the
an ARM Cortex-M3 MCU, the Luminary/TI LM3S6965. This OS is built with the
arm-nuttx-elf toolchain. STATUS: This port is complete and mature.
configs/rgmp
:
- RGMP stands for RTOS and GPOS on Multi-Processor. RGMP is a project for
+ RGMP stands for RTOS and GPOS on Multi-Processor. RGMP is a project for
running GPOS and RTOS simultaneously on multi-processor platforms. You can
port your favorite RTOS to RGMP together with an unmodified Linux to form a
hybrid operating system. This makes your application able to use both RTOS
@@ -978,7 +979,7 @@
configs/xtrs
:
TRS80 Model 3. This port uses a vintage computer based on the Z80.
- An emulator for this computer is available to run TRS80 programs on a
+ An emulator for this computer is available to run TRS80 programs on a
Linux platform (http://www.tim-mann.org/xtrs.html).
+ Okay, so you have created a new board configuration directory.
+ Now, how do you hook this board into the configuration system so that you can select with make menuconfig
?
+
+ You will need modify the file configs/Kconfig
.
+ Let's look at the STM32F4-Discovery configuration in the Kconfig
file and see how we would add a new board directory to the configuration.
+ For this configuration let's say that you new board resides in the directory configs/myboard
;
+ It uses an MCU selected with CONFIG_ARCH_CHIP_MYMCU
; and you want the board to be selected with CONFIG_ARCH_BOARD_MYBOARD
.
+ Then here is how you can clone the STM32F4-Discovery configuration in configs/Kconfig
to support your new board configuration.
+
+ In configs/Kconfig
for the stm32f4-discovery, you will see a configuration definition like this:
+
+
+config ARCH_BOARD_STM32F4_DISCOVERY + bool "STMicro STM32F4-Discovery board" + depends on ARCH_CHIP_STM32F407VG + select ARCH_HAVE_LEDS + select ARCH_HAVE_BUTTONS + select ARCH_HAVE_IRQBUTTONS + ---help--- + STMicro STM32F4-Discovery board based on the STMicro STM32F407VGT6 MCU. ++
+ The above selects the STM32F4-Discovery board.
+ The select
lines say that the board has both LEDs and buttons and that the board can generate interrupts from the button presses.
+ You can just copy the above configuration definition to a new location (notice that they the configurations are in alphabetical order).
+ Then you should edit the configuration to support your board.
+ The final configuration definition might look something like:
+
+config ARCH_BOARD_MYBOARD + bool "My very own board configuration" + depends on ARCH_CHIP_MYMCU + select ARCH_HAVE_LEDS + select ARCH_HAVE_BUTTONS + select ARCH_HAVE_IRQBUTTONS + ---help--- + This options selects the board configuration for my very own board + based on the MYMCU processor. ++
+ Later in the configs/Kconfig
file, you will see a long, long string configuration with lots of defaults like this:
+
+config ARCH_BOARD + string + default "amber" if ARCH_BOARD_AMBER + default "avr32dev1" if ARCH_BOARD_AVR32DEV1 + default "c5471evm" if ARCH_BOARD_C5471EVM +... + default "stm32f4discovery" if ARCH_BOARD_STM32F4_DISCOVERY +... ++
+ This logic will assign string value to a configuration variable called CONFIG_ARCH_BOARD
that will name the directory where the board-specific files reside.
+ In our case, these files reside in configs/myboard
and we add the following to the long list of defaults (again in alphabetical order):
+
+ default "myboar" if ARCH_BOARD_MYBOARD ++
+ Now the build system knows where to find your board configuration! +
+
+ And finally, add something like this near the bottom of configs/myboard
:
+
+if ARCH_BOARD_MYBOARD +source "configs/myboard/Kconfig" +endif ++
+ This includes additional, board-specific configuration variabled defintion in configs/myboard/Kconfig
.
+
@@ -1078,7 +1157,7 @@ drivers/
| |-- Kconfig
| |-- Make.defs
| `-- (Common USB host driver source files)
-|-- wirelss/
+|-- wireless/
| |-- Kconfig
| |-- Make.defs
| `-- (Common wireless driver source files)
@@ -1666,7 +1745,7 @@ The system can be re-made subsequently by just typing make
.
up_use_stack()
Prototype: +
Prototype:
STATUS up_use_stack(FAR struct tcb_s *tcb, FAR void *stack, size_t stack_size);
make
.
Description. Called when the priority of a running or - ready-to-run task changes and the reprioritization will + ready-to-run task changes and the reprioritization will cause a context switch. Two cases:
CONFIG_RTC
- CONFIG_RTC_DATETIME
CONFIG_RTC_HIRES
is defined, then the frequency of the high resolution RTC must be provided.
If CONFIG_RTC_HIRES
is not defined, CONFIG_RTC_FREQUENCY
is assumed to be one.
CONFIG_RTC_ALARM
- @@ -2175,13 +2254,13 @@ else Initialize the hardware RTC per the selected configuration. This function is called once during the OS initialization sequence -
up_rtc_time()
.
+ up_rtc_time()
.
Get the current time in seconds. This is similar to the standard time()
function.
This interface is only required if the low-resolution RTC/counter hardware implementation selected.
It is only used by the RTOS during intialization to set up the system time when CONFIG_RTC
is set
but neither CONFIG_RTC_HIRES
nor CONFIG_RTC_DATETIME
are set.
up_rtc_gettime()
.
+ up_rtc_gettime()
.
Get the current time from the high resolution RTC clock/counter.
This interface is only supported by the hight-resolution RTC/counter hardware implementation.
It is used to replace the system timer (g_system_tick
).
@@ -2250,11 +2329,11 @@ else
Returns the virtual base address of the address environment.
up_addrenv_select()
:
+ 4.1.22.3 up_addrenv_select()
:
Instantiate an address environment.
up_addrenv_restore()
:
+ 4.1.22.4 up_addrenv_restore()
:
Restore an address environment.
Description:
Input Parameters:
@@ -2531,9 +2610,9 @@ else- The implementation of LED support is very specific to a board architecture. - Some boards have several LEDS, others have only one or two. - Some have none. + The implementation of LED support is very specific to a board architecture. + Some boards have several LEDS, others have only one or two. + Some have none. Others LED matrices and show alphanumeric data, etc. The NuttX logic does not refer to specific LEDS, rather, it refers to an event to be shown on the LEDS in whatever manner is appropriate for the board; @@ -2705,7 +2784,7 @@ extern void up_ledoff(int led); These different device driver types are discussed in the following paragraphs. Note: device driver support requires that the in-memory, pseudo file system - is enabled by setting the CONFIG_NFILE_DESCRIPTORS in the NuttX configuration file to a + is enabled by setting the CONFIG_NFILE_DESCRIPTORS in the NuttX configuration file to a non-zero value.
@@ -3451,7 +3530,7 @@ extern void up_ledoff(int led);
As part of its operation during the binding operation, the USB host class driver will register an instances of a standard NuttX driver under the /dev
directory.
To repeat the above example, the USB host mass storage class driver (drivers/usbhost/usbhost_storage.c
) will register a standard, NuttX block driver interface (like /dev/sda
)
- that can be used to mount a file system just as with any other other block driver instance.
+ that can be used to mount a file system just as with any other other block driver instance.
Examples: @@ -3487,7 +3566,7 @@ extern void up_ledoff(int led);
Examples:
- arch/arm/src/dm320/dm320_usbdev.c
, arch/arm/src/lpc17xx/lpc17_usbdev.c
,
+ arch/arm/src/dm320/dm320_usbdev.c
, arch/arm/src/lpc17xx/lpc17_usbdev.c
,
arch/arm/src/lpc214x/lpc214x_usbdev.c
, arch/arm/src/lpc313x/lpc313x_usbdev.c
, and
arch/arm/src/stm32/stm32_usbdev.c
.
stream
: An instance of lib_instream_s
to perform the actual low-level get operation.
pch
: The location to save the returned value.
+ pch
: The location to save the returned value.
This may be either a normal, character code or a special command (i.e., a value from enum kbd_getstate_s
.
state
: A user provided buffer to support parsing.
+ state
: A user provided buffer to support parsing.
This structure should be cleared the first time that kbd_decode()
is called.
- Reports of relevant driver or other system activity. + Reports of relevant driver or other system activity.
- Registration and callback mechanism to interface with individual device drivers. + Registration and callback mechanism to interface with individual device drivers.
OK
) means the event was successfully processed and that the driver is prepared for the PM state change.
Non-zero means that the driver is not prepared to perform the tasks needed achieve this power setting and will cause the state change to be aborted.
NOTE: The prepare()
method will also be called when reverting from lower back to higher power consumption modes (say because another driver refused a lower power state change).
- Drivers are not permitted to return non-zero values when reverting back to higher power
+ Drivers are not permitted to return non-zero values when reverting back to higher power
consumption modes!
@@ -4391,7 +4470,7 @@ build
If the 2 pass build option is selected, then these options configure the make system build a extra link object.
This link object is assumed to be an incremental (relative) link object, but could be a static library (archive)
(some modification to this Makefile would be required if CONFIG_PASS1_TARGET generates an archive).
- Pass 1 1ncremental (relative) link objects should be put into the processor-specific source directory
+ Pass 1 1ncremental (relative) link objects should be put into the processor-specific source directory
where other link objects will be created - ff the pass1 obect is an archive, it could go anywhere.
CONFIG_PASS1_OBJECT
: May be used to include an extra, pass1 object into the final link.
- This would probably be the object generated from the CONFIG_PASS1_TARGET
.
+ This would probably be the object generated from the CONFIG_PASS1_TARGET
.
It may be available at link time in the arch/<architecture>/src
directory.
CONFIG_SCHED_INSTRUMENTATION
: enables instrumentation in
+ CONFIG_SCHED_INSTRUMENTATION
: enables instrumentation in
scheduler to monitor system performance
CONFIG_PAGING_NDATA
should be defined to prevent the data region from extending all the way to the end of memory.
+ CONFIG_PAGING_NDATA
should be defined to prevent the data region from extending all the way to the end of memory.
CONFIG_PAGING_DEFPRIO
:
@@ -5058,7 +5137,7 @@ int ret = sigaction(SIGCHLD, &sa, NULL);
Default: No timeouts monitored.
- Some architecture-specific settings. + Some architecture-specific settings. Defaults are architecture specific. If you don't know what you are doing, it is best to leave these undefined and try the system defaults:
@@ -5198,7 +5277,7 @@ int ret = sigaction(SIGCHLD, &sa, NULL);CONFIG_MEMCPY_VIK
:
Select this option to use the optimized memcpy()
function by Daniel Vik.
- Select this option for improved performance at the expense of increased size.
+ Select this option for improved performance at the expense of increased size.
See licensing information in the top-level COPYING
file.
Default: n
.
CONFIG_FS_NXFFS
: Enable NuttX FLASH file system (NXFF) support.
CONFIG_NXFFS_ERASEDSTATE
: The erased state of FLASH.
+ CONFIG_NXFFS_ERASEDSTATE
: The erased state of FLASH.
This must have one of the values of 0xff
or 0x00
.
Default: 0xff
.
CONFIG_RTC
:
- Enables general support for a hardware RTC.
+ Enables general support for a hardware RTC.
Specific architectures may require other specific settings.
CONFIG_RTC_ALARM
:
- Enable if the RTC hardware supports setting of an alarm.
+ Enable if the RTC hardware supports setting of an alarm.
A callback function will be executed when the alarm goes off
CONFIG_STMPE811_NPOLLWAITERS
:
- Maximum number of threads that can be waiting on poll() (ignored if
+ Maximum number of threads that can be waiting on poll() (ignored if
CONFIG_DISABLE_POLL
is set).
CONFIG_THTTPD_IOBUFFERSIZE
:
+ CONFIG_THTTPD_IOBUFFERSIZE
:
CONFIG_THTTPD_INDEX_NAMES
: A list of index filenames to check. The
@@ -6087,7 +6166,7 @@ int ret = sigaction(SIGCHLD, &sa, NULL);
You can also leave both options undefined, and thttpd will not do
anything special about tildes. Enabling both options is an error.
Typical values, if they're defined, are "users" for
- CONFIG_THTTPD_TILDE_MAP1 and "public_html" forCONFIG_THTTPD_TILDE_MAP2.
+ CONFIG_THTTPD_TILDE_MAP1 and "public_html" forCONFIG_THTTPD_TILDE_MAP2.
CONFIG_THTTPD_GENERATE_INDICES
:
@@ -6157,7 +6236,7 @@ int ret = sigaction(SIGCHLD, &sa, NULL);
CONFIG_PL2303
: Enable compilation of the USB serial driver
@@ -6197,14 +6276,14 @@ int ret = sigaction(SIGCHLD, &sa, NULL);
CONFIG_CDCACM_IFNOBASE
:
- If the CDC driver is part of a composite device, then this may need to
+ If the CDC driver is part of a composite device, then this may need to
be defined to offset the CDC/ACM interface numbers so that they are
unique and contiguous. When used with the Mass Storage driver, the
correct value for this offset is zero.
CONFIG_CDCACM_STRBASE
:
- If the CDC driver is part of a composite device, then this may need to
+ If the CDC driver is part of a composite device, then this may need to
be defined to offset the CDC/ACM string numbers so that they are
unique and contiguous. When used with the Mass Storage driver, the
correct value for this offset is four (this value actuallly only needs
@@ -6275,7 +6354,7 @@ int ret = sigaction(SIGCHLD, &sa, NULL);
CONFIG_USBMSC_IFNOBASE
:
- If the CDC driver is part of a composite device, then this may need to
+ If the CDC driver is part of a composite device, then this may need to
be defined to offset the mass storage interface number so that it is
unique and contiguous. When used with the CDC/ACM driver, the
correct value for this offset is two (because of the two CDC/ACM
@@ -6283,7 +6362,7 @@ int ret = sigaction(SIGCHLD, &sa, NULL);
CONFIG_USBMSC_STRBASE
:
- If the CDC driver is part of a composite device, then this may need to
+ If the CDC driver is part of a composite device, then this may need to
be defined to offset the mass storage string numbers so that they are
unique and contiguous. When used with the CDC/ACM driver, the
correct value for this offset is four (or perhaps 5 or 6, depending
diff --git a/arch/arm/src/sam34/chip/sam3u_pmc.h b/arch/arm/src/sam34/chip/sam3u_pmc.h
index 4f26b83d9c..1eebd7df51 100644
--- a/arch/arm/src/sam34/chip/sam3u_pmc.h
+++ b/arch/arm/src/sam34/chip/sam3u_pmc.h
@@ -56,9 +56,15 @@
#define SAM_PMC_SCDR_OFFSET 0x0004 /* System Clock Disable Register */
#define SAM_PMC_SCSR_OFFSET 0x0008 /* System Clock Status Register */
/* 0x000c: Reserved */
-#define SAM_PMC_PCER_OFFSET 0x0010 /* Peripheral Clock Enable Register */
-#define SAM_PMC_PCDR_OFFSET 0x0014 /* Peripheral Clock Disable Register */
-#define SAM_PMC_PCSR_OFFSET 0x0018 /* Peripheral Clock Status Register */
+#if defined(CONFIG_ARCH_CHIP_SAM4S)
+# define SAM_PMC_PCER0_OFFSET 0x0010 /* Peripheral Clock Enable Register 0 */
+# define SAM_PMC_PCDR0_OFFSET 0x0014 /* Peripheral Clock Disable Register 0 */
+# define SAM_PMC_PCSR0_OFFSET 0x0018 /* Peripheral Clock Status Register 0 */
+#elif defined(CONFIG_ARCH_CHIP_SAM3U)
+# define SAM_PMC_PCER_OFFSET 0x0010 /* Peripheral Clock Enable Register */
+# define SAM_PMC_PCDR_OFFSET 0x0014 /* Peripheral Clock Disable Register */
+# define SAM_PMC_PCSR_OFFSET 0x0018 /* Peripheral Clock Status Register */
+#endif
#if defined(CONFIG_ARCH_CHIP_SAM3U)
# define SAM_PMC_CKGR_UCKR_OFFSET 0x001c /* UTMI Clock Register */
@@ -111,7 +117,13 @@
#define SAM_PMC_SCER (SAM_PMC_BASE+SAM_PMC_SCER_OFFSET)
#define SAM_PMC_SCDR (SAM_PMC_BASE+SAM_PMC_SCDR_OFFSET)
#define SAM_PMC_SCSR (SAM_PMC_BASE+SAM_PMC_SCSR_OFFSET)
-#define SAM_PMC_PCER (SAM_PMC_BASE+SAM_PMC_PCER_OFFSET)
+
+#if defined(CONFIG_ARCH_CHIP_SAM4S)
+# define SAM_PMC_PCER0 (SAM_PMC_BASE+SAM_PMC_PCER0_OFFSET)
+#elif defined(CONFIG_ARCH_CHIP_SAM3U)
+# define SAM_PMC_PCER (SAM_PMC_BASE+SAM_PMC_PCER_OFFSET)
+#endif
+
#define SAM_PMC_PCDR (SAM_PMC_BASE+SAM_PMC_PCDR_OFFSET)
#define SAM_PMC_PCSR (SAM_PMC_BASE+SAM_PMC_PCSR_OFFSET)
diff --git a/arch/arm/src/sam34/sam3u_periphclks.h b/arch/arm/src/sam34/sam3u_periphclks.h
index 0b0466f8c1..09c1abb4d2 100644
--- a/arch/arm/src/sam34/sam3u_periphclks.h
+++ b/arch/arm/src/sam34/sam3u_periphclks.h
@@ -1,7 +1,7 @@
/************************************************************************************
* arch/arm/src/sam34/sam3u_periphclks.h
*
- * Copyright (C) 2009-2011, 2013 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt