From a0858f5dc80ec94952af4b32903194c40f61c857 Mon Sep 17 00:00:00 2001 From: patacongo Date: Mon, 6 Sep 2010 16:21:54 +0000 Subject: Fix clearing of SRAM when clocks reset git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2923 42af7a65-404d-4744-a932-0658087f49c3 --- nuttx/arch/arm/src/lpc313x/lpc313x_boot.c | 48 +++++++++++++++++--------- nuttx/arch/arm/src/lpc313x/lpc313x_lowputc.c | 6 +--- nuttx/arch/arm/src/lpc313x/lpc313x_memorymap.h | 2 +- 3 files changed, 33 insertions(+), 23 deletions(-) (limited to 'nuttx/arch/arm/src/lpc313x') diff --git a/nuttx/arch/arm/src/lpc313x/lpc313x_boot.c b/nuttx/arch/arm/src/lpc313x/lpc313x_boot.c index 8840c6fdb..0a6ad34bf 100755 --- a/nuttx/arch/arm/src/lpc313x/lpc313x_boot.c +++ b/nuttx/arch/arm/src/lpc313x/lpc313x_boot.c @@ -285,6 +285,18 @@ static void up_vectormapping(void) static void up_copyvectorblock(void) { + uint32_t *src; + uint32_t *end; + uint32_t *dest; + + /* If we are using vectors in low memory but RAM in that area has been marked + * read only, then temparily mark the mapping write-able (non-buffered). + */ + +#if !defined(CONFIG_ARCH_ROMPGTABLE) && defined(CONFIG_ARCH_LOWVECTORS) && defined(CONFIG_PAGING) + up_vectorpermissions(MMU_L2_VECTRWFLAGS); +#endif + /* Copy the vectors into ISRAM at the address that will be mapped to the vector * address: * @@ -293,15 +305,21 @@ static void up_copyvectorblock(void) * LPC313X_VECTOR_VADDR - Virtual address of vector table (0x00000000 or 0xffff0000) */ - uint32_t *src = (uint32_t*)&_vector_start; - uint32_t *end = (uint32_t*)&_vector_end; - uint32_t *dest = (uint32_t*)LPC313X_VECTOR_VSRAM; + src = (uint32_t*)&_vector_start; + end = (uint32_t*)&_vector_end; + dest = (uint32_t*)LPC313X_VECTOR_VSRAM; while (src < end) { *dest++ = *src++; } + /* Make the vectors read-only, cacheable again */ + +#if !defined(CONFIG_ARCH_ROMPGTABLE) && defined(CONFIG_ARCH_LOWVECTORS) && defined(CONFIG_PAGING) + up_vectorpermissions(MMU_L2_VECTROFLAGS); +#endif + /* Then set the LPC313x shadow register, LPC313X_SYSCREG_ARM926SHADOWPTR, so that * the vector table is mapped to address 0x0000:0000 - NOTE: that there is not yet * full support for the vector table at address 0xffff0000. @@ -331,14 +349,6 @@ void up_boot(void) #ifndef CONFIG_ARCH_ROMPGTABLE up_setupmappings(); - /* If we are using vectors in low memory but RAM in that area has been marked - * read only, then temparily mark the mapping write-able (non-buffered). - */ - -#if defined(CONFIG_ARCH_LOWVECTORS) && defined(CONFIG_PAGING) - up_vectorpermissions(MMU_L2_VECTRWFLAGS); -#endif - /* Provide a special mapping for the IRAM interrupt vector positioned in high * memory. */ @@ -354,12 +364,6 @@ void up_boot(void) up_copyvectorblock(); - /* Make the vectors read-only, cacheable again */ - -#if !defined(CONFIG_ARCH_ROMPGTABLE) && defined(CONFIG_ARCH_LOWVECTORS) && defined(CONFIG_PAGING) - up_vectorpermissions(MMU_L2_VECTROFLAGS); -#endif - /* Reset all clocks */ lpc313x_resetclks(); @@ -381,6 +385,16 @@ void up_boot(void) lpc313x_lowsetup(); + /* NOTE: Something in the operation of lpc313x_resetclks() causes the first + * 6 words of memory to be zeroed, wiping out the interrupt vectors. However, + * moving the vector initialization until after the clock setup seems to hang + * the system (and I can't step though the clock setup to find why without + * losing my JTAG connection). So, the simplest work-around is to simply + * initialize the vectors twice. + */ + + up_copyvectorblock(); + /* Perform early serial initialization if we are going to use the serial driver */ #ifdef CONFIG_USE_EARLYSERIALINIT diff --git a/nuttx/arch/arm/src/lpc313x/lpc313x_lowputc.c b/nuttx/arch/arm/src/lpc313x/lpc313x_lowputc.c index 93f9a37b7..5bfde83fc 100755 --- a/nuttx/arch/arm/src/lpc313x/lpc313x_lowputc.c +++ b/nuttx/arch/arm/src/lpc313x/lpc313x_lowputc.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/lpc313x/lpc313x_lowputc.c * - * Copyright (C) 2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2009-2010 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -339,10 +339,6 @@ void lpc313x_lowsetup(void) #endif } -/**************************************************************************** - * Public Functions - ****************************************************************************/ - /**************************************************************************** * Name: up_lowputc * diff --git a/nuttx/arch/arm/src/lpc313x/lpc313x_memorymap.h b/nuttx/arch/arm/src/lpc313x/lpc313x_memorymap.h index ad2281237..0539495f9 100755 --- a/nuttx/arch/arm/src/lpc313x/lpc313x_memorymap.h +++ b/nuttx/arch/arm/src/lpc313x/lpc313x_memorymap.h @@ -183,7 +183,7 @@ /* Section MMU Flags */ -#define LPC313X_SHADOWSPACE_MMUFLAGS MMU_MEMFLAGS +#define LPC313X_SHADOWSPACE_MMUFLAGS MMU_ROMFLAGS #define LPC313X_INTSRAM_MMUFLAGS MMU_MEMFLAGS #define LPC313X_INTSROM_MMUFLAGS MMU_MEMFLAGS #define LPC313X_APB01_MMUFLAGS MMU_IOFLAGS -- cgit v1.2.3