From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3307 invoked by alias); 7 Feb 2009 12:39:34 -0000 Received: (qmail 3299 invoked by uid 22791); 7 Feb 2009 12:39:33 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00,SPF_PASS X-Spam-Check-By: sourceware.org Received: from alicia.2020media.com (HELO alicia.2020mail.com) (212.124.192.215) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 07 Feb 2009 12:39:28 +0000 Received: from [212.124.199.38] (helo=[192.168.0.2]) by alicia.2020mail.com with esmtp (Exim 4.30; FreeBSD) id 1LVmSZ-000PTj-Og for ecos-patches@sourceware.org; Sat, 07 Feb 2009 12:38:59 +0000 Message-ID: <498D80F5.3030606@zynaptic.com> Date: Sat, 07 Feb 2009 12:39:00 -0000 From: Chris Holgate User-Agent: Thunderbird 2.0.0.19 (X11/20081227) MIME-Version: 1.0 To: ecos-patches@sourceware.org Subject: STM32 - Allow initialisation of SRAM area from ROM. Content-Type: multipart/mixed; boundary="------------040808060600040306080301" Mailing-List: contact ecos-patches-help@ecos.sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: ecos-patches-owner@ecos.sourceware.org X-SW-Source: 2009-02/txt/msg00042.txt.bz2 This is a multi-part message in MIME format. --------------040808060600040306080301 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-length: 407 This patch adds support for SRAM initialisation from ROM in STM32 ROM based builds. It allows declarations such as the following to correctly allocate and initialise variables in the SRAM area. static cyg_uint16 dma_tx_null __attribute__((section (".sram"))) = 0xFFFF; Please could someone who is a linker script expert check my changes to src/cortexm.ld, since linker scripts are not my forte! Chris. --------------040808060600040306080301 Content-Type: text/x-patch; name="stm32_sram_initialisation.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="stm32_sram_initialisation.patch" Content-length: 4965 diff -u5 -r cvs-06.02.09/ecos/packages//hal/cortexm/arch/current/ChangeLog working-06.02.09/ecos/packages//hal/cortexm/arch/current/ChangeLog --- cvs-06.02.09/ecos/packages//hal/cortexm/arch/current/ChangeLog 2009-01-29 17:49:15.000000000 +0000 +++ working-06.02.09/ecos/packages//hal/cortexm/arch/current/ChangeLog 2009-02-07 12:22:34.000000000 +0000 @@ -1,5 +1,11 @@ +2009-02-07 Chris Holgate + + * src/hal_misc.c: + * src/cortexm.ld: + Modified SRAM linker section to support initialisation from ROM. + 2008-12-03 Nick Garnett * src/hal_misc.c (hal_deliver_interrupt): Fix instrumentation call to allow it to compile properly. diff -u5 -r cvs-06.02.09/ecos/packages//hal/cortexm/arch/current/src/cortexm.ld working-06.02.09/ecos/packages//hal/cortexm/arch/current/src/cortexm.ld --- cvs-06.02.09/ecos/packages//hal/cortexm/arch/current/src/cortexm.ld 2009-01-29 17:49:15.000000000 +0000 +++ working-06.02.09/ecos/packages//hal/cortexm/arch/current/src/cortexm.ld 2009-02-06 20:18:07.000000000 +0000 @@ -233,12 +233,16 @@ { FORCE_OUTPUT; *(.mmu_tables) } \ > _region_ #define SECTION_sram(_region_, _vma_, _lma_) \ .sram _vma_ : _lma_ \ - { FORCE_OUTPUT; *(.sram*) } \ - > _region_ + { __sram_data_start = ABSOLUTE (.); \ + *(.sram*) . = ALIGN (4); } \ + > _region_ \ + __srom_data_start = LOADADDR (.sram); \ + __sram_data_end = .; PROVIDE (__sram_data_end = .); \ + PROVIDE (__srom_data_end = LOADADDR (.sram) + SIZEOF(.sram)); #define SECTION_data(_region_, _vma_, _lma_) \ .data _vma_ : _lma_ \ { __ram_data_start = ABSOLUTE (.); \ *(.data*) *(.data1) *(.gnu.linkonce.d.*) \ diff -u5 -r cvs-06.02.09/ecos/packages//hal/cortexm/arch/current/src/hal_misc.c working-06.02.09/ecos/packages//hal/cortexm/arch/current/src/hal_misc.c --- cvs-06.02.09/ecos/packages//hal/cortexm/arch/current/src/hal_misc.c 2009-01-29 17:49:15.000000000 +0000 +++ working-06.02.09/ecos/packages//hal/cortexm/arch/current/src/hal_misc.c 2009-02-06 20:33:11.000000000 +0000 @@ -95,10 +95,13 @@ // DATA and BSS locations __externC cyg_uint32 __ram_data_start; __externC cyg_uint32 __ram_data_end; __externC cyg_uint32 __rom_data_start; +__externC cyg_uint32 __sram_data_start; +__externC cyg_uint32 __sram_data_end; +__externC cyg_uint32 __srom_data_start; __externC cyg_uint32 __bss_start; __externC cyg_uint32 __bss_end; // Scheduler lock __externC volatile cyg_uint32 cyg_scheduler_sched_lock; @@ -195,10 +198,19 @@ for( p = &__ram_data_start, q = &__rom_data_start; p < &__ram_data_end; p++, q++ ) *p = *q; } + + // Relocate data from ROM to SRAM + { + register cyg_uint32 *p, *q; + for( p = &__sram_data_start, q = &__srom_data_start; + p < &__sram_data_end; + p++, q++ ) + *p = *q; + } #endif // Clear BSS { register cyg_uint32 *p; diff -u5 -r cvs-06.02.09/ecos/packages//hal/cortexm/stm32/stm3210e_eval/current/ChangeLog working-06.02.09/ecos/packages//hal/cortexm/stm32/stm3210e_eval/current/ChangeLog --- cvs-06.02.09/ecos/packages//hal/cortexm/stm32/stm3210e_eval/current/ChangeLog 2009-02-02 14:13:43.000000000 +0000 +++ working-06.02.09/ecos/packages//hal/cortexm/stm32/stm3210e_eval/current/ChangeLog 2009-02-07 12:19:50.000000000 +0000 @@ -1,5 +1,10 @@ +2009-02-07 Chris Holgate + + * include/pkgconf/mlt_cortexm_stm3210e_eval_rom.ldi: + Modified SRAM section so that initialisation data is placed in ROM. + 2009-01-31 Bart Veer * cdl/hal_cortexm_stm32_stm3210e_eval.cdl: update compiler flags for gcc 4.x 2008-12-10 Nick Garnett diff -u5 -r cvs-06.02.09/ecos/packages//hal/cortexm/stm32/stm3210e_eval/current/include/pkgconf/mlt_cortexm_stm3210e_eval_rom.ldi working-06.02.09/ecos/packages//hal/cortexm/stm32/stm3210e_eval/current/include/pkgconf/mlt_cortexm_stm3210e_eval_rom.ldi --- cvs-06.02.09/ecos/packages//hal/cortexm/stm32/stm3210e_eval/current/include/pkgconf/mlt_cortexm_stm3210e_eval_rom.ldi 2009-02-04 11:37:42.000000000 +0000 +++ working-06.02.09/ecos/packages//hal/cortexm/stm32/stm3210e_eval/current/include/pkgconf/mlt_cortexm_stm3210e_eval_rom.ldi 2009-02-06 20:08:37.000000000 +0000 @@ -22,12 +22,12 @@ SECTION_rodata1 (flash, ALIGN (0x8), LMA_EQ_VMA) SECTION_fixup (flash, ALIGN (0x8), LMA_EQ_VMA) SECTION_gcc_except_table (flash, ALIGN (0x8), LMA_EQ_VMA) SECTION_eh_frame (flash, ALIGN (0x8), LMA_EQ_VMA) SECTION_got (flash, ALIGN (0x8), LMA_EQ_VMA) - SECTION_sram (sram, 0x20000400, LMA_EQ_VMA) - SECTION_data (ram, 0x68000000, FOLLOWING (.got)) + SECTION_sram (sram, 0x20000400, FOLLOWING (.got)) + SECTION_data (ram, 0x68000000, FOLLOWING (.sram)) SECTION_bss (ram, ALIGN (0x8), LMA_EQ_VMA) CYG_LABEL_DEFN(__heap1) = ALIGN (0x8); SECTIONS_END } --------------040808060600040306080301--