public inbox for ecos-patches@sourceware.org
 help / color / mirror / Atom feed
* FR30 Flash support
@ 2008-07-01 12:23 Lars Poeschel
  2008-07-11 18:03 ` Andrew Lunn
  0 siblings, 1 reply; 2+ messages in thread
From: Lars Poeschel @ 2008-07-01 12:23 UTC (permalink / raw)
  To: ecos-patches


[-- Attachment #1.1: Type: text/plain, Size: 119 bytes --]

Hello!

I have created a patch that adds flash support to the fr30  
architecture, skmb91302 platform.

Regards,
Lars


[-- Attachment #1.2: fr30flash.patch --]
[-- Type: application/octet-stream, Size: 30452 bytes --]

Index: packages/devs/flash/fr30/skmb91302/current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/devs/flash/fr30/skmb91302/current/ChangeLog,v
retrieving revision 1.1
diff -u -3 -r1.1 ChangeLog
--- packages/devs/flash/fr30/skmb91302/current/ChangeLog	6 Jan 2008 14:06:41 -0000	1.1
+++ packages/devs/flash/fr30/skmb91302/current/ChangeLog	1 Jul 2008 12:17:40 -0000
@@ -1,6 +1,11 @@
+2008-07-01  Lars Poeschel  <larsi@wh2.tu-dresden.de>
+
+    * src/skmb91302_flash.c: Changed CYGNUM_FLASH_BASE to 0x1000000 for real
+                             flash support
+
 2007-07-09  Lars Poeschel  <larsi@wh2.tu-dresden.de>
 
-	* src/skmb91302_flash.c: 
+	* src/skmb91302_flash.c:
 	* cdl/flash_skmb91302.cdl: New package - platform specifics.
 
 //===========================================================================
Index: packages/devs/flash/fr30/skmb91302/current/src/skmb91302_flash.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/devs/flash/fr30/skmb91302/current/src/skmb91302_flash.c,v
retrieving revision 1.1
diff -u -3 -r1.1 skmb91302_flash.c
--- packages/devs/flash/fr30/skmb91302/current/src/skmb91302_flash.c	6 Jan 2008 14:06:41 -0000	1.1
+++ packages/devs/flash/fr30/skmb91302/current/src/skmb91302_flash.c	1 Jul 2008 12:17:40 -0000
@@ -59,7 +59,7 @@
 #define CYGNUM_FLASH_INTERLEAVE (1)
 #define CYGNUM_FLASH_SERIES     (1)
 #define CYGNUM_FLASH_WIDTH      (16)
-#define CYGNUM_FLASH_BASE       (0x100000)
+#define CYGNUM_FLASH_BASE       (0x1000000)
 
 //--------------------------------------------------------------------------
 // Platform specific extras
Index: packages/hal/fr30/arch/current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/fr30/arch/current/ChangeLog,v
retrieving revision 1.1
diff -u -3 -r1.1 ChangeLog
--- packages/hal/fr30/arch/current/ChangeLog	6 Jan 2008 14:17:43 -0000	1.1
+++ packages/hal/fr30/arch/current/ChangeLog	1 Jul 2008 12:17:49 -0000
@@ -1,3 +1,10 @@
+2008-07-01  Lars Poeschel  <larsi@wh2.tu-dresden.de>
+
+    * src/vectors.S:
+    * include/arch.inc:
+    * include/hal_arch.h: Introduced CYGPKG_HAL_FR30_LMA_OFFSET for supporting
+                          remapping a flash chip during initialisation.
+
 2007-07-09  Lars Poeschel  <larsi@wh2.tu-dresden.de>
 
     * src/context.S:
Index: packages/hal/fr30/arch/current/include/arch.inc
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/fr30/arch/current/include/arch.inc,v
retrieving revision 1.1
diff -u -3 -r1.1 arch.inc
--- packages/hal/fr30/arch/current/include/arch.inc	6 Jan 2008 14:17:43 -0000	1.1
+++ packages/hal/fr30/arch/current/include/arch.inc	1 Jul 2008 12:17:49 -0000
@@ -185,6 +185,16 @@
 
 #endif
 
+#------------------------------------------------------------------------------
+# Difference of the flash memory from the linkers LMA (loadmemoryaddress) after
+# the new mapping in (mapping is done in hal_fr30_ram_startup_trampoline).
+
+#ifndef CYGPKG_HAL_FR30_LMA_OFFSET
+
+#define CYGPKG_HAL_FR30_LMA_OFFSET  0x0
+
+#endif
+
 
 #endif // ifndef CYGONCE_HAL_ARCH_INC
 # end of arch.inc
Index: packages/hal/fr30/arch/current/include/hal_arch.h
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/fr30/arch/current/include/hal_arch.h,v
retrieving revision 1.1
diff -u -3 -r1.1 hal_arch.h
--- packages/hal/fr30/arch/current/include/hal_arch.h	6 Jan 2008 14:17:43 -0000	1.1
+++ packages/hal/fr30/arch/current/include/hal_arch.h	1 Jul 2008 12:17:49 -0000
@@ -12,7 +12,6 @@
 // -------------------------------------------
 // This file is part of eCos, the Embedded Configurable Operating System.
 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
-// Copyright (C) 2007 eCosCentric Ltd.
 //
 // eCos is free software; you can redistribute it and/or modify it under
 // the terms of the GNU General Public License as published by the Free
@@ -128,7 +127,7 @@
     (_regs_)->r[04] = (CYG_HAL_FR30_REG)(_thread_);   /* R4 = arg1 = thread ptr  */     \
     (_regs_)->pc = (CYG_WORD)(_entry_);               /* PC = entry point        */     \
     (_regs_)->ps = (CYG_HAL_FR30_REG)0x1f0030;        /* 0x000F0030;  set flags  */     \
-    (_regs_)->tbr = (CYG_HAL_FR30_REG)0xffc00;        /*system standard tbr value*/     \
+    (_regs_)->tbr = (CYG_HAL_FR30_REG)0x10ffc00;      /*system standard tbr value*/     \
     (_regs_)->rp = (CYG_HAL_FR30_REG)0x0;             /* return pointer = 0x0    */     \
     (_regs_)->ssp = (CYG_HAL_FR30_REG)0x0;            /* R4 = arg1 = thread ptr  */     \
     (_regs_)->usp = (CYG_HAL_FR30_REG)(_regs_);       /* r15 = USP = top of stack*/     \
Index: packages/hal/fr30/arch/current/src/vectors.S
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/fr30/arch/current/src/vectors.S,v
retrieving revision 1.1
diff -u -3 -r1.1 vectors.S
--- packages/hal/fr30/arch/current/src/vectors.S	6 Jan 2008 14:17:43 -0000	1.1
+++ packages/hal/fr30/arch/current/src/vectors.S	1 Jul 2008 12:17:49 -0000
@@ -110,24 +111,25 @@
     ble:d   2b
     st      r0,     @r13
 
-
 #if defined(CYG_HAL_STARTUP_ROM) || defined(CYG_HAL_STARTUP_ROMRAM)
 
 # In a ROM booted system, we also need to copy the data section
 # out to the RAM.
-    ldi:32  #__rom_data_start - 4,  r11
-    ldi:32  #__ram_data_start - 4,  r13
-    ldi:32  #__ram_data_end - 8,    r12
+
+    ldi:32  #__rom_data_start - 4 + CYGPKG_HAL_FR30_LMA_OFFSET,  r11
+    ldi:32  #__ram_data_start - 4,  r9
+    ldi:32  #__ram_data_end - 8,    r10
 3:
     add     #0x4,   r11
-    add     #0x4,   r13
+    add     #0x4,   r9
     ld      @r11,   r0
-    cmp     r12,    r13
+    cmp     r10,    r9
     ble:d   3b
-    st      r0,     @r13
+    st      r0,     @r9
 
 #endif
 
+
     # Set up the stacks
     # Begin with interrupt (system) stack
 
@@ -158,7 +160,6 @@
     ldi:32  #hal_platform_init,  r11
     call    @r11
 
-
 #ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
     // This is here so we can debug the constructors.
     .extern initialize_stub
@@ -181,6 +182,7 @@
         call breakpoint
 #endif
 
+
     .extern cyg_start
     ldi:32  #cyg_start,  r11
     call    @r11
@@ -392,6 +394,7 @@
     andccr  #0xdf
     reti
 
+
 #==============================================================================
 # Exception trampolines
 # TBR table points to these short code sequences here that push the vector
Index: packages/hal/fr30/mb91301/current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/fr30/mb91301/current/ChangeLog,v
retrieving revision 1.1
diff -u -3 -r1.1 ChangeLog
--- packages/hal/fr30/mb91301/current/ChangeLog	6 Jan 2008 14:17:43 -0000	1.1
+++ packages/hal/fr30/mb91301/current/ChangeLog	1 Jul 2008 12:17:49 -0000
@@ -1,3 +1,14 @@
+2008-07-01  Lars Poeschel  <larsi@wh2.tu-dresden.de>
+
+    * src/fr30_md91301.ld: Reworked memory layout for flash support.
+
+    * src/hal_diag.c:      Little updates in serial0 configuration registers.
+
+    * src/variant.S:       Made it possible for the platform to override
+                           variants rom vectors.
+
+    * include/variant.inc: Moved macros for sdram config addresses to platform.
+
 2007-07-09  Lars Poeschel  <larsi@wh2.tu-dresden.de>
 
     * src/fr30_md91301.ld:
Index: packages/hal/fr30/mb91301/current/include/variant.inc
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/fr30/mb91301/current/include/variant.inc,v
retrieving revision 1.1
diff -u -3 -r1.1 variant.inc
--- packages/hal/fr30/mb91301/current/include/variant.inc	6 Jan 2008 14:17:43 -0000	1.1
+++ packages/hal/fr30/mb91301/current/include/variant.inc	1 Jul 2008 12:17:49 -0000
@@ -128,6 +128,7 @@
 
 ##-----------------------------------------------------------------------------
 ## ext bus interface registers
+## part used for flash
 
     .equ FR30_MB91301_ASR0,     0x640
     .equ FR30_MB91301_ACR0,     0x642
@@ -144,6 +145,15 @@
     .equ FR30_MB91301_PFR8,     0x618
     .equ FR30_MB91301_PCR8,     0x628
 
+## part used for sdram
+    .equ FR30_MB91301_ASR6,     0x658
+    .equ FR30_MB91301_ACR6,     0x65a
+    .equ FR30_MB91301_AWR6,     0x66c
+    .equ FR30_MB91301_MCRA,     0x670
+    .equ FR30_MB91301_MCRB,     0x671
+    .equ FR30_MB91301_RCR,      0x684
+
+
 ##-----------------------------------------------------------------------------
 ## registers for serial0 and U-timer settings
 ##
Index: packages/hal/fr30/mb91301/current/src/fr30_mb91301.ld
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/fr30/mb91301/current/src/fr30_mb91301.ld,v
retrieving revision 1.1
diff -u -3 -r1.1 fr30_mb91301.ld
--- packages/hal/fr30/mb91301/current/src/fr30_mb91301.ld	6 Jan 2008 14:17:43 -0000	1.1
+++ packages/hal/fr30/mb91301/current/src/fr30_mb91301.ld	1 Jul 2008 12:17:49 -0000
@@ -78,6 +78,18 @@
     { FORCE_OUTPUT; KEEP (*(.rom_vectors)) } \
     > _region_
 
+#define SECTION_rom_startup(_region_, _vma_, _lma_) \
+    .rom_startup_trampoline _vma_ : _lma_ \
+    { FORCE_OUTPUT; KEEP(*(.rom_startup_trampoline*)) } \
+    > _region_
+
+#define SECTION_ram_startup(_region_, _vma_, _lma_) \
+    .ram_startup_trampoline _vma_ : _lma_ \
+    { __ram_trampoline_start = ABSOLUTE (.); FORCE_OUTPUT; KEEP(*(.ram_startup_trampoline*)) } \
+    > _region_ \
+    __rom_trampoline_start = LOADADDR (.ram_startup_trampoline); \
+    __rom_trampoline_end = LOADADDR (.ram_startup_trampoline) + SIZEOF(.ram_startup_trampoline);
+
 #define SECTION_text(_region_, _vma_, _lma_) \
     .text _vma_ : _lma_ \
     { _stext = ABSOLUTE(.); \
@@ -97,11 +109,6 @@
     { FORCE_OUTPUT; *(.rodata*) } \
     > _region_
 
-/* #define SECTION_startup_trampoline(_region_, _vma_, _lma_)
-    .startup_trampoline _vma_ : _lma_
-    { FORCE_OUTPUT; *(.startup_trampoline*) }
-    > _region_ */
-
 #define SECTION_rodata1(_region_, _vma_, _lma_) \
     .rodata1 _vma_ : _lma_ \
     { FORCE_OUTPUT; *(.rodata1) } \
@@ -117,11 +124,6 @@
     { FORCE_OUTPUT; *(.gcc_except_table) } \
     > _region_
 
-#define SECTION_mmu_tables(_region_, _vma_, _lma_) \
-    .mmu_tables _vma_ : _lma_ \
-    { FORCE_OUTPUT; *(.mmu_tables) } \
-    > _region_
-
 #define SECTION_sram(_region_, _vma_, _lma_) \
     .sram _vma_ : _lma_ \
     { FORCE_OUTPUT; *(.sram*) } \
Index: packages/hal/fr30/mb91301/current/src/hal_diag.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/fr30/mb91301/current/src/hal_diag.c,v
retrieving revision 1.1
diff -u -3 -r1.1 hal_diag.c
--- packages/hal/fr30/mb91301/current/src/hal_diag.c	6 Jan 2008 14:17:43 -0000	1.1
+++ packages/hal/fr30/mb91301/current/src/hal_diag.c	1 Jul 2008 12:17:49 -0000
@@ -100,8 +100,10 @@
 
 void hal_diag_init(void){
 
-    HAL_WRITE_UINT8(CYG_HAL_FR30_MB91301_DDRJ, 0x2);
-    HAL_WRITE_UINT8(CYG_HAL_FR30_MB91301_PFRJ, 0x3);
+    // PJ2(SCK0) & PJ1(SOT0) output, PJ0(SIN0) input
+    HAL_WRITE_UINT8(CYG_HAL_FR30_MB91301_DDRJ, 0x6);
+    // PJ2(SCK0) & PJ1(SOT0) & PJ0(SIN0) to peripheral operation
+    HAL_WRITE_UINT8(CYG_HAL_FR30_MB91301_PFRJ, 0x7);
 
     // set up U-Timer
     HAL_WRITE_UINT8(CYG_HAL_FR30_MB91301_UTIMC0, 0x02);
Index: packages/hal/fr30/mb91301/current/src/variant.S
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/fr30/mb91301/current/src/variant.S,v
retrieving revision 1.1
diff -u -3 -r1.1 variant.S
--- packages/hal/fr30/mb91301/current/src/variant.S	6 Jan 2008 14:17:43 -0000	1.1
+++ packages/hal/fr30/mb91301/current/src/variant.S	1 Jul 2008 12:17:49 -0000
@@ -69,12 +69,13 @@
 # alterable. Vectors 255 to 80 are used by the INT instruction and set to 0
 # here for now ...
 
+#ifndef CYGPKG_HAL_FR30_ROM_VECTORS_DEFINED
+#define CYGPKG_HAL_FR30_ROM_VECTORS_DEFINED
+
 #if defined(CYG_HAL_STARTUP_ROM) || defined(CYG_HAL_STARTUP_ROMRAM)
 
      .section ".rom_vectors","ax"
 
-#    .data
-
     .balign 4
     .global hal_fr30_vector_table
 hal_fr30_vector_table:
@@ -161,7 +162,8 @@
 # reset vector
     .long   _start
 
-#endif
+#endif /*CYG_HAL_STARTUP_ROM || CYG_HAL_STARTUP_ROMRAM*/
+#endif /*CYGPKG_HAL_FR30_ROM_VECTORS_DEFINED*/
 
 ##-----------------------------------------------------------------------------
 # Interrupt vector tables.
Index: packages/hal/fr30/skmb91302/current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/fr30/skmb91302/current/ChangeLog,v
retrieving revision 1.1
diff -u -3 -r1.1 ChangeLog
--- packages/hal/fr30/skmb91302/current/ChangeLog	6 Jan 2008 14:17:43 -0000	1.1
+++ packages/hal/fr30/skmb91302/current/ChangeLog	1 Jul 2008 12:17:49 -0000
@@ -1,3 +1,16 @@
+2008-07-01  Lars Poeschel  <larsi@wh2.tu-dresden.de>
+
+    * src/platform.S: Startup routines for remapping the flash during startup.
+                      Defined own rom_vector table.
+
+    * src/ser.c: Little updates that could cause problems after a reset with 
+                 wrong settings in the serial configuration registers.
+
+    * include/pkgconf/mlt_fr30_skmb91302_rom.h:
+    * include/pkgconf/mlt_fr30_skmb91302_rom.ldi: Reworked memory layout for
+                                                  flash support.
+
+
 2007-07-09  Lars Poeschel  <larsi@wh2.tu-dresden.de>
 
     * src/platform.S:
Index: packages/hal/fr30/skmb91302/current/include/platform.inc
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/fr30/skmb91302/current/include/platform.inc,v
retrieving revision 1.1
diff -u -3 -r1.1 platform.inc
--- packages/hal/fr30/skmb91302/current/include/platform.inc	6 Jan 2008 14:17:43 -0000	1.1
+++ packages/hal/fr30/skmb91302/current/include/platform.inc	1 Jul 2008 12:17:49 -0000
@@ -60,38 +59,6 @@
 
 #include <cyg/hal/fr30.inc>
 
-#------------------------------------------------------------------------------
-
-#define CYGPKG_HAL_RESET_VECTOR_FIRST_CODE
-	.macro hal_reset_vector_first_code
-	.endm
-
-
-##-----------------------------------------------------------------------------
-## ext bus interface registers
-## flash part
-    .equ FR30_MB91301_ASR0,     0x640
-    .equ FR30_MB91301_ACR0,     0x642
-    .equ FR30_MB91301_AWR0,     0x660
-    .equ FR30_MB91301_CSER,     0x680
-
-    .equ FR30_MB91301_PDR9,     0x9
-    .equ FR30_MB91301_DDR9,     0x609
-    .equ FR30_MB91301_PFR9,     0x619
-    .equ FR30_MB91301_PCR9,     0x629
-
-    .equ FR30_MB91301_PDR8,     0x8
-    .equ FR30_MB91301_DDR8,     0x608
-    .equ FR30_MB91301_PFR8,     0x618
-    .equ FR30_MB91301_PCR8,     0x628
-
-## sdram part
-    .equ FR30_MB91301_ASR6,     0x658
-    .equ FR30_MB91301_ACR6,     0x65a
-    .equ FR30_MB91301_AWR6,     0x66c
-    .equ FR30_MB91301_MCRA,     0x670
-    .equ FR30_MB91301_MCRB,     0x671
-    .equ FR30_MB91301_RCR,      0x684
 
 ##------------------------------------------------------------------------------
 ## ext Bus (memory controller) initialisation macros
@@ -100,10 +67,17 @@
 
 
 #define CYGPKG_HAL_FR30_FLASH_INIT_DEFINED
+## flash init is empty for this platform because it is initialized in the
+## special hal_fr30_ram_startup_trampoline to map flash to 0x100000
 .macro hal_flash_init
+.endm
+
+## and the following macro is used in the special
+## hal_fr30_ram_startup_trampoline for flash initialisation
+.macro hal_flash_init_from_ram
 
     ldi:20  #FR30_MB91301_ASR0, r10 ; CS0 area starts at
-    ldi:8   0x000,   r0             ; 0x00000000
+    ldi:20  0x100,   r0             ; 0x01000000
     sth     r0,     @r10            ;
 
     ldi:20  #FR30_MB91301_ACR0, r11 ; configuration parameters for CS0
@@ -140,6 +114,16 @@
 
 .macro hal_memc_init
 
+## The following instruction is without function. It is only to reference
+## hal_fr30_rom_startup_trampoline, because when not referenced the linker
+## does not include the file platform.S in the link. If somewhen some other
+## referenced code appears in platform.S the instruction here can be deleted
+## (including the surrounding macro)!
+
+#if defined(CYG_HAL_STARTUP_ROM) || defined(CYG_HAL_STARTUP_ROMRAM)
+    ldi:32  #hal_fr30_rom_startup_trampoline, r10
+#endif
+
     ldi:20  #FR30_MB91301_ASR6, r10 ; CS6 area starts at
     ldi:20  0x200,   r0             ; 0x02000000
     sth     r0,     @r10            ;
@@ -185,5 +169,19 @@
 .endm
 
 #------------------------------------------------------------------------------
+## Vector table for storage. platform.S defines a vector table and wants to
+## override the one from variant.S with this define
+
+#define CYGPKG_HAL_FR30_ROM_VECTORS_DEFINED
+
+#------------------------------------------------------------------------------
+# Difference of the flash memory from the linkers LMA (loadmemoryaddress) after
+# the new mapping in (mapping is done in hal_fr30_ram_startup_trampoline).
+
+#define CYGPKG_HAL_FR30_LMA_OFFSET  0x1000000
+
+
+
+#------------------------------------------------------------------------------
 #endif // ifndef CYGONCE_HAL_PLATFORM_INC
 # end of platform.inc
Index: packages/hal/fr30/skmb91302/current/include/pkgconf/mlt_fr30_skmb91302_ram.h
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/fr30/skmb91302/current/include/pkgconf/mlt_fr30_skmb91302_ram.h,v
retrieving revision 1.1
diff -u -3 -r1.1 mlt_fr30_skmb91302_ram.h
--- packages/hal/fr30/skmb91302/current/include/pkgconf/mlt_fr30_skmb91302_ram.h	6 Jan 2008 14:17:44 -0000	1.1
+++ packages/hal/fr30/skmb91302/current/include/pkgconf/mlt_fr30_skmb91302_ram.h	1 Jul 2008 12:17:49 -0000
@@ -8,7 +8,7 @@
 
 #endif
 #define CYGMEM_REGION_ram (0x2000000)
-#define CYGMEM_REGION_ram_SIZE (0x7fffff)
+#define CYGMEM_REGION_ram_SIZE (0x800000)
 #define CYGMEM_REGION_ram_ATTR (CYGMEM_REGION_ATTR_R | CYGMEM_REGION_ATTR_W)
 #ifndef __ASSEMBLER__
 extern char CYG_LABEL_NAME (__heap1) [];
Index: packages/hal/fr30/skmb91302/current/include/pkgconf/mlt_fr30_skmb91302_rom.h
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/fr30/skmb91302/current/include/pkgconf/mlt_fr30_skmb91302_rom.h,v
retrieving revision 1.1
diff -u -3 -r1.1 mlt_fr30_skmb91302_rom.h
--- packages/hal/fr30/skmb91302/current/include/pkgconf/mlt_fr30_skmb91302_rom.h	6 Jan 2008 14:17:44 -0000	1.1
+++ packages/hal/fr30/skmb91302/current/include/pkgconf/mlt_fr30_skmb91302_rom.h	1 Jul 2008 12:17:49 -0000
@@ -8,7 +8,7 @@
 
 #endif
 #define CYGMEM_REGION_ram (0x2000000)
-#define CYGMEM_REGION_ram_SIZE (0x7fffff)
+#define CYGMEM_REGION_ram_SIZE (0x800000)
 #define CYGMEM_REGION_ram_ATTR (CYGMEM_REGION_ATTR_R | CYGMEM_REGION_ATTR_W)
 #ifndef __ASSEMBLER__
 extern char CYG_LABEL_NAME (__heap1) [];
Index: packages/hal/fr30/skmb91302/current/include/pkgconf/mlt_fr30_skmb91302_rom.ldi
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/fr30/skmb91302/current/include/pkgconf/mlt_fr30_skmb91302_rom.ldi,v
retrieving revision 1.1
diff -u -3 -r1.1 mlt_fr30_skmb91302_rom.ldi
--- packages/hal/fr30/skmb91302/current/include/pkgconf/mlt_fr30_skmb91302_rom.ldi	6 Jan 2008 14:17:44 -0000	1.1
+++ packages/hal/fr30/skmb91302/current/include/pkgconf/mlt_fr30_skmb91302_rom.ldi	1 Jul 2008 12:17:49 -0000
@@ -6,26 +6,26 @@
 
 MEMORY
 {
-    ram   : ORIGIN = 0x3F000, LENGTH = 0x1000
+    ram   : ORIGIN = 0x18000, LENGTH = 0x1000
     rom1  : ORIGIN = 0x80000, LENGTH = 0x7fc00 // Length = 511 kB
     ints  : ORIGIN = 0xFFC00, LENGTH = 0x400
-    rom2  : ORIGIN = 0x100000, LENGTH = 0x700000
+    rom2  : ORIGIN = 0x1100000, LENGTH = 0x700000
     sdram : ORIGIN = 0x2000000, LENGTH = 0x800000
 }
 
 SECTIONS
 {
     SECTIONS_BEGIN
-    SECTION_text (rom1, 0x80000, LMA_EQ_VMA)
-    SECTION_fini (rom1, ALIGN (0x4), LMA_EQ_VMA)
-    SECTION_rodata (rom1, ALIGN (0x4), LMA_EQ_VMA)
-//    SECTION_rodata1 (rom, ALIGN (0x4), LMA_EQ_VMA)
-    SECTION_fixup (rom1, ALIGN (0x4), LMA_EQ_VMA)
-    SECTION_gcc_except_table (rom1, ALIGN (0x4), LMA_EQ_VMA)
-    SECTION_rom_vectors (ints,0xffc00 , LMA_EQ_VMA)
+    SECTION_rom_startup(rom1, 0x80000, LMA_EQ_VMA)
+    SECTION_ram_startup(ram, 0x18000, FOLLOWING(.rom_startup_trampoline))
+    SECTION_rom_vectors (ints, 0xffc00 , LMA_EQ_VMA)
+    SECTION_text (rom2, 0x1100000, AT(0x100000))
+    SECTION_fini (rom2, ALIGN (0x4), FOLLOWING (.text))
+    SECTION_rodata (rom2, ALIGN (0x4), FOLLOWING (.fini))
+    SECTION_fixup (rom2, ALIGN (0x4), FOLLOWING (.rodata))
+    SECTION_gcc_except_table (rom2, ALIGN (0x4), FOLLOWING (.fixup))
     SECTION_fixed_vectors (sdram, 0x2000000, LMA_EQ_VMA)
     SECTION_data (sdram, ALIGN(0x4), FOLLOWING (.gcc_except_table))
-//    SECTION_data (sdram, ALIGN(0x4), LMA_EQ_VMA)
     SECTION_bss (sdram, ALIGN (0x4), LMA_EQ_VMA)
     CYG_LABEL_DEFN(__heap1) = ALIGN (0x1000);
     SECTIONS_END
Index: packages/hal/fr30/skmb91302/current/src/platform.S
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/fr30/skmb91302/current/src/platform.S,v
retrieving revision 1.1
diff -u -3 -r1.1 platform.S
--- packages/hal/fr30/skmb91302/current/src/platform.S	6 Jan 2008 14:17:44 -0000	1.1
+++ packages/hal/fr30/skmb91302/current/src/platform.S	1 Jul 2008 12:17:49 -0000
@@ -1,5 +1,5 @@
+##=============================================================================
 ##
-#=============================================================================
 ##	platform.S
 ##
 ##	Fujitsu Starterkit MB91302 platform code
@@ -63,10 +63,171 @@
 #include <cyg/hal/arch.inc>
 
 ##-----------------------------------------------------------------------------
+## platforms special entry point.
+## it copies the code from hal_fr30_ram_startup_trampoline until
+## hal_fr30_ram_startup_trampoline_end to ram and jumps there. The code there
+## is for mapping the flash to 0x1000000 and then jumping to real entry
+## (_start).
+
+#if defined(CYG_HAL_STARTUP_ROM) || defined(CYG_HAL_STARTUP_ROMRAM)
+
+    .section ".rom_startup_trampoline","ax"
+
+    .balign 4
+    .global hal_fr30_rom_startup_trampoline
+hal_fr30_rom_startup_trampoline:
+    # disable interrupts and set priority to lowest (=disable)
+    andccr  #0xef
+    stilm   #0x0
+
+    ldi:32  #__rom_trampoline_start - 4,       r11
+    ldi:32  #__ram_trampoline_start - 4,                r13
+    ldi:32  #__rom_trampoline_end - 8,   r12
+1:
+    add     #0x4,   r11
+    add     #0x4,   r13
+    ld      @r11,   r0
+    cmp     r12,    r11
+    ble:d   1b
+    st      r0,     @r13
+
+## jump to the code in ram
+    ldi:32  #hal_fr30_ram_startup_trampoline, r0
+    jmp     @r0
+
+#endif
 
 ##-----------------------------------------------------------------------------
 # Platform Initialization.
-# This code performs platform specific initialization.
+# This code is copied to a location in RAM on startup and is executed there.
+# It maps the the FLASH chip to 0x1000000 and sets the TBR to the new location
+# of the hardware vector table (hal_fr30_vector_table). So we can reach the full
+# range of the FLASH and it can be used for flashfilesystem. After that it jumps
+# to the real application.
+
+#if defined(CYG_HAL_STARTUP_ROM) || defined(CYG_HAL_STARTUP_ROMRAM)
+
+    .section ".ram_startup_trampoline","ax"
+
+    .balign 4
+    .global hal_fr30_ram_startup_trampoline
+hal_fr30_ram_startup_trampoline:
+    hal_flash_init_from_ram
+
+## map TBR to the new location (for vector tables)
+    ldi:32  #0x10ffc00, r0
+    mov     r0,     tbr
+
+## jump to real startup
+    ldi:32  #_start,    r0
+    jmp     @r0
+
+#endif
+
+
+#==============================================================================
+# Vector table for storage in flash, version for skmb91302 platform.
+# it differs from variants/archs version in that uses a different reset vector
+# that points to the special startup procedure that jumps to the normal entry
+# (_start) later.
+# base address is 0x000FFC00 and 0x10ffc00 after remapping the flash.
+# This address stores the vector address for number 255
+# address 0x000FFFFC (0x10ffffc) is the last vector, the reset vector, which
+# is not alterable. Vectors 255 to 80 are used by the INT instruction and set
+# to 0 here for now ...
+
+
+#if defined(CYG_HAL_STARTUP_ROM) || defined(CYG_HAL_STARTUP_ROMRAM)
+
+     .section ".rom_vectors","ax"
+
+    .balign 4
+    .global hal_fr30_vector_table
+hal_fr30_vector_table:
+    .rept   255-80 + 1
+    .long   0x0
+    .endr
+    .rept   79-67 + 1
+    .long   0x0
+    .endr
+
+    .long   0x0
+    .long   0x0
+    .long   0x0
+# number 63 first interrupt source
+    .long   hal_fr30_irq_63
+    .long   hal_fr30_irq_62
+    .long   hal_fr30_irq_61
+    .long   hal_fr30_irq_60
+    .long   hal_fr30_irq_59
+    .long   hal_fr30_irq_58
+    .long   hal_fr30_irq_57
+    .long   hal_fr30_irq_56
+    .long   hal_fr30_irq_55
+    .long   hal_fr30_irq_54
+    .long   hal_fr30_irq_53
+    .long   hal_fr30_irq_52
+    .long   hal_fr30_irq_51
+    .long   hal_fr30_irq_50
+    .long   hal_fr30_irq_49
+    .long   hal_fr30_irq_48
+    .long   hal_fr30_irq_47
+    .long   hal_fr30_irq_46
+    .long   hal_fr30_irq_45
+    .long   hal_fr30_irq_44
+    .long   hal_fr30_irq_43
+    .long   hal_fr30_irq_42
+    .long   hal_fr30_irq_41
+    .long   hal_fr30_irq_40
+    .long   hal_fr30_irq_39
+    .long   hal_fr30_irq_38
+    .long   hal_fr30_irq_37
+    .long   hal_fr30_irq_36
+    .long   hal_fr30_irq_35
+    .long   hal_fr30_irq_34
+    .long   hal_fr30_irq_33
+    .long   hal_fr30_irq_32
+    .long   hal_fr30_irq_31
+    .long   hal_fr30_irq_30
+    .long   hal_fr30_irq_29
+    .long   hal_fr30_irq_28
+    .long   hal_fr30_irq_27
+    .long   hal_fr30_irq_26
+    .long   hal_fr30_irq_25
+    .long   hal_fr30_irq_24
+    .long   hal_fr30_irq_23
+    .long   hal_fr30_irq_22
+    .long   hal_fr30_irq_21
+    .long   hal_fr30_irq_20
+    .long   hal_fr30_irq_19
+    .long   hal_fr30_irq_18
+    .long   hal_fr30_irq_17
+    .long   hal_fr30_irq_16
+    .long   hal_fr30_irq_15
+    .long   hal_fr30_exception_noerr_14
+    .long   hal_fr30_exception_noerr_13
+    .long   hal_fr30_exception_noerr_12
+    .long   hal_fr30_exception_noerr_11
+    .long   hal_fr30_exception_noerr_10
+    .long   hal_fr30_exception_noerr_9
+    .long   hal_fr30_exception_noerr_8
+    .long   hal_fr30_exception_noerr_7
+    .long   hal_fr30_exception_noerr_6
+    .long   hal_fr30_exception_noerr_5
+    .long   hal_fr30_exception_noerr_4
+    .long   hal_fr30_exception_noerr_3
+    .long   hal_fr30_exception_noerr_2
+
+# mode vector (only the first of the four byte is relevant)
+    .byte   0x1
+    .byte   0
+    .byte   0
+    .byte   0
+
+# reset vector
+    .long   hal_fr30_rom_startup_trampoline
+
+#endif /*CYG_HAL_STARTUP_ROM || CYG_HAL_STARTUP_ROMRAM*/
 
 
 ##-----------------------------------------------------------------------------
Index: packages/hal/fr30/skmb91302/current/src/ser.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/fr30/skmb91302/current/src/ser.c,v
retrieving revision 1.1
diff -u -3 -r1.1 ser.c
--- packages/hal/fr30/skmb91302/current/src/ser.c	6 Jan 2008 14:17:44 -0000	1.1
+++ packages/hal/fr30/skmb91302/current/src/ser.c	1 Jul 2008 12:17:49 -0000
@@ -152,12 +152,12 @@
     /* and finally take the best */
     if (n < nn){
         /* UCC1 = 0 */
-        HAL_WRITE_UINT8(port + CYG_HAL_FR30_MB91301_UTIMC_OFFSET, 0x02);
         HAL_WRITE_UINT16(port + CYG_HAL_FR30_MB91301_UTIMR_OFFSET, t);
+        HAL_WRITE_UINT8(port + CYG_HAL_FR30_MB91301_UTIMC_OFFSET, 0x02);
     } else {
         /* UCC1 = 1 */
-        HAL_WRITE_UINT8(port + CYG_HAL_FR30_MB91301_UTIMC_OFFSET, 0x82);
         HAL_WRITE_UINT16(port + CYG_HAL_FR30_MB91301_UTIMR_OFFSET, tt);
+        HAL_WRITE_UINT8(port + CYG_HAL_FR30_MB91301_UTIMC_OFFSET, 0x82);
     }
 }
 
@@ -176,9 +176,11 @@
     switch (port){
         case CYG_HAL_FR30_MB91301_SER0_BASE:
             HAL_READ_UINT8(CYG_HAL_FR30_MB91301_DDRJ, value);
-            HAL_WRITE_UINT8(CYG_HAL_FR30_MB91301_DDRJ, value | 0x2);
+            value |= 0x6;
+            value &= ~0x1;
+            HAL_WRITE_UINT8(CYG_HAL_FR30_MB91301_DDRJ, value);
             HAL_READ_UINT8(CYG_HAL_FR30_MB91301_PFRJ, value);
-            HAL_WRITE_UINT8(CYG_HAL_FR30_MB91301_PFRJ, value | 0x3);
+            HAL_WRITE_UINT8(CYG_HAL_FR30_MB91301_PFRJ, value | 0x7);
             if (CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL_DEFAULT == 0){
                 cyg_hal_plf_serial_set_baudrate_internal(port, CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL_BAUD);
             } else {
@@ -188,9 +190,11 @@
 
         case CYG_HAL_FR30_MB91301_SER1_BASE:
             HAL_READ_UINT8(CYG_HAL_FR30_MB91301_DDRJ, value);
-            HAL_WRITE_UINT8(CYG_HAL_FR30_MB91301_DDRJ, value | 0x10);
+            value |= 0x30;
+            value &= ~0x8;
+            HAL_WRITE_UINT8(CYG_HAL_FR30_MB91301_DDRJ, value);
             HAL_READ_UINT8(CYG_HAL_FR30_MB91301_PFRJ, value);
-            HAL_WRITE_UINT8(CYG_HAL_FR30_MB91301_PFRJ, value | 0x18);
+            HAL_WRITE_UINT8(CYG_HAL_FR30_MB91301_PFRJ, value | 0x38);
             if (CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL_DEFAULT == 1){
                 cyg_hal_plf_serial_set_baudrate_internal(port, CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL_BAUD);
             } else {
@@ -207,7 +211,6 @@
 */
     }
 
-
     // set up U-Timer
 /*    HAL_WRITE_UINT8(port + CYG_HAL_FR30_MB91301_UTIMC_OFFSET, 0x02);
     // 115200 bps
@@ -226,8 +229,8 @@
     cyg_uint8 ssr;
     cyg_uint8 port;
 
-    // wait for tx rdy
     port = ((channel_data_t*)__ch_data)->base;
+    // wait for tx rdy
     do
     {
         HAL_READ_UINT8(port + CYG_HAL_FR30_MB91301_SSR_OFFSET, ssr);
@@ -349,6 +352,7 @@
     case __COMMCTL_SETBAUD:
     {
         cyg_uint32 baud_rate;
+        cyg_uint16 n, nn;
         va_list ap;
 
         va_start(ap, __func);
@@ -389,7 +393,6 @@
 
 	// Init channels
 	cyg_hal_plf_serial_init_channel((void*)&channels[i]);
-    
 	// Setup procs in the vector table
 
 	// Set COMM callbacks for channel
@@ -417,7 +420,6 @@
         return;
 
     initialized = 1;
-
     cyg_hal_plf_serial_init();
 
 }

[-- Attachment #1.3: Type: text/plain, Size: 1 bytes --]



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 194 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: FR30 Flash support
  2008-07-01 12:23 FR30 Flash support Lars Poeschel
@ 2008-07-11 18:03 ` Andrew Lunn
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Lunn @ 2008-07-11 18:03 UTC (permalink / raw)
  To: Lars Poeschel; +Cc: ecos-patches

On Tue, Jul 01, 2008 at 02:23:11PM +0200, Lars Poeschel wrote:
> Hello!
>
> I have created a patch that adds flash support to the fr30 architecture, 
> skmb91302 platform.

Committed, thanks

    Andrew

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-07-11 18:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-07-01 12:23 FR30 Flash support Lars Poeschel
2008-07-11 18:03 ` Andrew Lunn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).