From e02e6694b157d667ca57caaead48ad0d2e95c7dd Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 26 Jun 2013 10:54:12 -0600 Subject: [PATCH] Fix integration of RAM test into the build and configuration system --- configs/sam4s-xplained/README.txt | 67 ++++++++++++++++++--- configs/sam4s-xplained/nsh/defconfig | 16 +++-- configs/sam4s-xplained/nsh/setenv.sh | 14 +++++ configs/sam4s-xplained/ostest/defconfig | 2 +- configs/sam4s-xplained/src/Makefile | 4 ++ configs/sam4s-xplained/src/sam4s-xplained.h | 35 ++++++++--- configs/sam4s-xplained/src/sam_boot.c | 8 ++- configs/sure-pic32mx/README.txt | 26 +++++++- 8 files changed, 147 insertions(+), 25 deletions(-) diff --git a/configs/sam4s-xplained/README.txt b/configs/sam4s-xplained/README.txt index edc7c753cf..c07aae4c18 100644 --- a/configs/sam4s-xplained/README.txt +++ b/configs/sam4s-xplained/README.txt @@ -322,9 +322,8 @@ Buttons and LEDs Serial Consoles ^^^^^^^^^^^^^^^ - USART0 - ------ - + UART1 + ----- If you have a TTL to RS-232 convertor then this is the most convenient serial console to use. UART1 is the default in all of these configurations. @@ -334,6 +333,8 @@ Serial Consoles GND J1 pin 9 J4 pin 9 Vdd J1 pin 10 J4 pin 10 + USART1 + ------ USART1 is another option: USART1 RXD PA21 J2 pin 6 @@ -341,13 +342,12 @@ Serial Consoles GND J2 pin 9 Vdd J2 pin 10 + Virtual COM Port + ---------------- Yet another option is to use UART0 and the virtual COM port. This option may be more convenient for long term development, but was painful to use during board bring-up. - Virtual COM Port - ---------------- - The SAM4S Xplained contains an Embedded Debugger (EDBG) that can be used to program and debug the ATSAM4S16C using Serial Wire Debug (SWD). The Embedded debugger also include a Virtual Com port interface over @@ -587,5 +587,56 @@ Configuration sub-directories nsh: This configuration directory will built the NuttShell. See NOTES above. - nsh: - This configuration directory will built the NuttShell. See NOTES above. + NOTES: + 1. The configuration configuration can be modified to include support + for the on-board SRAM (1MB). + + System Type -> External Memory Configuration + CONFIG_ARCH_EXTSRAM0=y : Select SRAM on CS0 + CONFIG_ARCH_EXTSRAM0SIZE=1048576 : Size=1MB + + Now what are you going to do with the SRAM. There are two choices: + + a) To enable the NuttX RAM test that may be used to verify the + external SRAM: + + System Type -> External Memory Configuration + CONFIG_ARCH_EXTSRAM0HEAP=n : Don't add to heap + + Application Configuration -> System NSH Add-Ons + CONFIG_SYSTEM_RAMTEST=y : Enable the RAM test built-in + + In this configuration, the SDRAM is not added to heap and so is + not excessible to the applications. So the RAM test can be + freely executed against the SRAM memory beginning at address + 0x6000:0000 (CS0). + + nsh> ramtest -h + Usage: [-w|h|b] + + Where: + starting address of the test. + number of memory locations (in bytes). + -w Sets the width of a memory location to 32-bits. + -h Sets the width of a memory location to 16-bits (default). + -b Sets the width of a memory location to 8-bits. + + To test the entire external SRAM: + + nsh> ramtest 60000000 1048576 + RAMTest: Marching ones: 60000000 1048576 + RAMTest: Marching zeroes: 60000000 1048576 + RAMTest: Pattern test: 60000000 1048576 55555555 aaaaaaaa + RAMTest: Pattern test: 60000000 1048576 66666666 99999999 + RAMTest: Pattern test: 60000000 1048576 33333333 cccccccc + RAMTest: Address-in-address test: 60000000 1048576 + + b) To add this RAM to the NuttX heap, you would need to change the + configuration as follows: + + System Type -> External Memory Configuration + CONFIG_ARCH_EXTSRAM0HEAP=y : Add external RAM to heap + + Memory Management + -CONFIG_MM_REGIONS=1 : Only the internal SRAM + +CONFIG_MM_REGIONS=2 : Also include external SRAM diff --git a/configs/sam4s-xplained/nsh/defconfig b/configs/sam4s-xplained/nsh/defconfig index f064d3f014..dbe1d14a9a 100644 --- a/configs/sam4s-xplained/nsh/defconfig +++ b/configs/sam4s-xplained/nsh/defconfig @@ -92,6 +92,7 @@ CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT=y # CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYL is not set # CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL is not set CONFIG_ARMV7M_OABI_TOOLCHAIN=y +# CONFIG_GPIO_IRQ is not set # # AT91SAM3/4 Configuration Options @@ -162,13 +163,18 @@ CONFIG_SAM34_UART1=y # # AT91SAM3/4 GPIO Interrupt Configuration # -# CONFIG_GPIOA_IRQ is not set -# CONFIG_GPIOB_IRQ is not set -# CONFIG_GPIOC_IRQ is not set # # External Memory Configuration # +CONFIG_ARCH_HAVE_EXTNAND=y +CONFIG_ARCH_HAVE_EXTNOR=y +CONFIG_ARCH_HAVE_EXTSRAM0=y +CONFIG_ARCH_HAVE_EXTSRAM1=y +# CONFIG_ARCH_EXTNAND is not set +# CONFIG_ARCH_EXTNOR is not set +# CONFIG_ARCH_EXTSRAM0 is not set +# CONFIG_ARCH_EXTSRAM1 is not set # # Architecture Options @@ -247,7 +253,7 @@ CONFIG_DEV_CONSOLE=y # CONFIG_FDCLONE_DISABLE is not set # CONFIG_FDCLONE_STDIO is not set CONFIG_SDCLONE_DISABLE=y -# CONFIG_SCHED_WAITPID is not set +CONFIG_SCHED_WAITPID=y # CONFIG_SCHED_STARTHOOK is not set # CONFIG_SCHED_ATEXIT is not set # CONFIG_SCHED_ONEXIT is not set @@ -383,7 +389,7 @@ CONFIG_DISABLE_MOUNTPOINT=y # # CONFIG_MM_MULTIHEAP is not set # CONFIG_MM_SMALL is not set -CONFIG_MM_REGIONS=3 +CONFIG_MM_REGIONS=1 # CONFIG_GRAN is not set # diff --git a/configs/sam4s-xplained/nsh/setenv.sh b/configs/sam4s-xplained/nsh/setenv.sh index 493fe18c14..0e97bb38b7 100755 --- a/configs/sam4s-xplained/nsh/setenv.sh +++ b/configs/sam4s-xplained/nsh/setenv.sh @@ -31,6 +31,20 @@ # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # +if [ "$_" = "$0" ] ; then + echo "You must source this script, not run it!" 1>&2 + exit 1 +fi + +WD=`pwd` +if [ ! -x "setenv.sh" ]; then + echo "This script must be executed from the top-level NuttX build directory" + exit 1 +fi + +if [ -z "${PATH_ORIG}" ]; then + export PATH_ORIG="${PATH}" +fi # This is the Cygwin path to the location where I installed the Atmel GCC # toolchain under Windows. You will also have to edit this if you install diff --git a/configs/sam4s-xplained/ostest/defconfig b/configs/sam4s-xplained/ostest/defconfig index b26c9c8276..eb3ddaf6ee 100644 --- a/configs/sam4s-xplained/ostest/defconfig +++ b/configs/sam4s-xplained/ostest/defconfig @@ -379,7 +379,7 @@ CONFIG_DISABLE_MOUNTPOINT=y # # CONFIG_MM_MULTIHEAP is not set # CONFIG_MM_SMALL is not set -CONFIG_MM_REGIONS=3 +CONFIG_MM_REGIONS=1 # CONFIG_GRAN is not set # diff --git a/configs/sam4s-xplained/src/Makefile b/configs/sam4s-xplained/src/Makefile index 80d8f4719a..4103dd7cfd 100644 --- a/configs/sam4s-xplained/src/Makefile +++ b/configs/sam4s-xplained/src/Makefile @@ -42,6 +42,10 @@ AOBJS = $(ASRCS:.S=$(OBJEXT)) CSRCS = sam_boot.c +ifeq ($(CONFIG_ARCH_EXTSRAM0),y) +CSRCS += sam_sram.c +endif + ifeq ($(CONFIG_HAVE_CXX),y) CSRCS += sam_cxxinitialize.c endif diff --git a/configs/sam4s-xplained/src/sam4s-xplained.h b/configs/sam4s-xplained/src/sam4s-xplained.h index 1d6877d33e..ace4bb1868 100644 --- a/configs/sam4s-xplained/src/sam4s-xplained.h +++ b/configs/sam4s-xplained/src/sam4s-xplained.h @@ -87,10 +87,10 @@ */ -#define GPIO_D9 (GPIO_OUTPUT | GPIO_CFG_PULLUP | GPIO_OUTPUT_SET | \ - GPIO_PORT_PIOC | GPIO_PIN10) -#define GPIO_D10 (GPIO_OUTPUT | GPIO_CFG_PULLUP | GPIO_OUTPUT_SET | \ - GPIO_PORT_PIOC | GPIO_PIN17) +#define GPIO_D9 (GPIO_OUTPUT | GPIO_CFG_PULLUP | GPIO_OUTPUT_SET | \ + GPIO_PORT_PIOC | GPIO_PIN10) +#define GPIO_D10 (GPIO_OUTPUT | GPIO_CFG_PULLUP | GPIO_OUTPUT_SET | \ + GPIO_PORT_PIOC | GPIO_PIN17) /* Mechanical buttons: * @@ -101,9 +101,14 @@ * PA5 BP2 */ -#define GPIO_BP2 (GPIO_INPUT | GPIO_CFG_PULLUP | GPIO_CFG_DEGLITCH | \ - GPIO_INT_BOTHEDGES | GPIO_PORT_PIOA | GPIO_PIN5) -#define IRQ_BP2 SAM_IRQ_PA5 +#define GPIO_BP2 (GPIO_INPUT | GPIO_CFG_PULLUP | GPIO_CFG_DEGLITCH | \ + GPIO_INT_BOTHEDGES | GPIO_PORT_PIOA | GPIO_PIN5) +#define IRQ_BP2 SAM_IRQ_PA5 + +/* SRAM Enable. EBI_NLB PC16. Active=low; Standby=high */ + +#define GPIO_EBI_NLB (GPIO_OUTPUT | GPIO_CFG_PULLUP | GPIO_OUTPUT_SET | \ + GPIO_PORT_PIOC | GPIO_PIN16) /************************************************************************************ * Public Types @@ -119,9 +124,21 @@ * Public Functions ************************************************************************************/ -/**************************************************************************** +/************************************************************************************ + * Name: sam_sram_initialize + * + * Description: + * Configure and enable SRAM on board the SAM4S Xplained + * + ************************************************************************************/ + +#ifdef CONFIG_ARCH_EXTSRAM0 +void sam_sram_initialize(void); +#endif + +/************************************************************************************ * Name: up_ledinit - ****************************************************************************/ + ************************************************************************************/ #ifdef CONFIG_ARCH_LEDS void up_ledinit(void); diff --git a/configs/sam4s-xplained/src/sam_boot.c b/configs/sam4s-xplained/src/sam_boot.c index 54d29053ee..a302d3efbf 100644 --- a/configs/sam4s-xplained/src/sam_boot.c +++ b/configs/sam4s-xplained/src/sam_boot.c @@ -67,9 +67,15 @@ void sam_boardinitialize(void) { - /* Configure on-board LEDs if LED support has been selected. */ +#ifdef CONFIG_ARCH_EXTSRAM0 + /* Configure and enable SRAM on board the SAM4S Xplained */ + + sam_sram_initialize(); +#endif #ifdef CONFIG_ARCH_LEDS + /* Configure on-board LEDs if LED support has been selected. */ + up_ledinit(); #endif } diff --git a/configs/sure-pic32mx/README.txt b/configs/sure-pic32mx/README.txt index 48877a498b..a57815657f 100644 --- a/configs/sure-pic32mx/README.txt +++ b/configs/sure-pic32mx/README.txt @@ -896,7 +896,7 @@ Where is one of the following: device will save encoded trace output in in-memory buffer; if the USB monitor is enabled, that trace buffer will be periodically emptied and dumped to the system logging device (UART2 in this - configuraion): + configuration): Device Drivers -> "USB Device Driver Support: CONFIG_USBDEV_TRACE=y : Enable USB trace feature @@ -931,5 +931,29 @@ Where is one of the following: System Type -> PIC32MX Peripheral Support: CONFIG_PIC32MX_UART2=n : Disable UART2 + The SYSLOG output on UART2 cannot by used. You have two choices, + first, you can simply disable the SYSLOG device. Then 1) debug + output will come the USB console, and 2) all debug output prior + to connecting the USB console will be lost: + Device Drivers -> System Logging Device Options: CONFIG_SYSLOG=n : Disable SYSLOG output + + The second options is to configure a RAM SYLOG device. This is + a circular buffer that accumulated debug output in memory. The + contents of the circular buffer can be dumped from the NSH command + line using the 'dmesg' command. + + Device Drivers -> System Logging Device Options: + CONFIG_SYSLOG=y : Enables the System Logging feature. + CONFIG_RAMLOG=y : Enable the RAM-based logging feature. + CONFIG_RAMLOG_CONSOLE=n : (there is no default console device) + CONFIG_RAMLOG_SYSLOG=y : This enables the RAM-based logger as the + system logger. + + Logging is currently can be set up to use any amount of memorym (here 8KB): + + CONFIG_RAMLOG_CONSOLE_BUFSIZE=8192 + + 7. See the notes for the nsh configuration. Most also apply to the usbnsh + configuration.