This is the mail archive of the ecos-patches@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GCC 4.2, Memory ranges displayed by RedBoot


Hello!

We encountered a problem with compiling RedBoot in the functions cyg_start and do_go (main.c). GCC 4.2.4 refused to compile the usage of workspace_end in conjunction with the macro HAL_THREAD_INIT_CONTEXT. We fixed this by using a temporary variable in the attached patch.

Additionally, we found the memory ranges displayed by RedBoot's version command a little bit confusing. Having flash memory at the very end of the address space produced results like

FLASH: 0xffe00000 - 0x0, 32 blocks of 0x00010000 bytes each.

where we would expect something like:

FLASH: 0xffe00000 - 0xffffffff, 32 blocks of 0x00010000 bytes each.

Especially by the bracket notation "[ ... ]" used for displaying available RAM looks like the boundaries given refer to a closed interval.


Best regards,


Christian
Index: redboot/current/src/flash.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/redboot/current/src/flash.c,v
retrieving revision 1.84
diff -u -5 -p -r1.84 flash.c
--- redboot/current/src/flash.c	28 Aug 2007 10:59:52 -0000	1.84
+++ redboot/current/src/flash.c	19 Aug 2008 14:41:12 -0000
@@ -1554,11 +1554,11 @@ int __flash_init = 0;
 void
 _flash_info(void)
 {
     if (!__flash_init) return;
     diag_printf("FLASH: %p - 0x%x, %d blocks of %p bytes each.\n", 
-           flash_start, (CYG_ADDRWORD)flash_end + 1, flash_num_blocks, (void *)flash_block_size);
+           flash_start, (CYG_ADDRWORD)flash_end, flash_num_blocks, (void *)flash_block_size);
 }
 
 /* Returns -1 on failure, 0 on success, 1 if it was successfull
  but a failed fis update was detected  */
 int
Index: redboot/current/src/main.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/redboot/current/src/main.c,v
retrieving revision 1.66
diff -u -5 -p -r1.66 main.c
--- redboot/current/src/main.c	20 Jul 2006 20:27:47 -0000	1.66
+++ redboot/current/src/main.c	19 Aug 2008 14:41:12 -0000
@@ -176,18 +176,18 @@ do_version(int argc, char *argv[])
 #ifdef HAL_PLATFORM_CPU
     diag_printf("Platform: %s (%s) %s\n", HAL_PLATFORM_BOARD, HAL_PLATFORM_CPU, HAL_PLATFORM_EXTRA);
 #endif
     diag_printf("Copyright (C) 2000, 2001, 2002, 2003, 2004 Red Hat, Inc.\n");
     diag_printf("Copyright (C) 2003, 2004, 2005, 2006 eCosCentric Limited\n\n");
-    diag_printf("RAM: %p-%p, ", (void*)ram_start, (void*)ram_end);
-    diag_printf("[%p-%p]", mem_segments[0].start, mem_segments[0].end);
+    diag_printf("RAM: %p-%p, ", (void*)ram_start, (void*)(ram_end - 1));
+    diag_printf("[%p-%p]", mem_segments[0].start, mem_segments[0].end - 1);
     diag_printf(" available\n");
 #if CYGBLD_REDBOOT_MAX_MEM_SEGMENTS > 1
     for (seg = 1;  seg < CYGBLD_REDBOOT_MAX_MEM_SEGMENTS;  seg++) {
         if (mem_segments[seg].start != NO_MEMORY) {
-            diag_printf("     %p-%p, ", mem_segments[seg].start, mem_segments[seg].end);
-            diag_printf("[%p-%p]", mem_segments[seg].start, mem_segments[seg].end);
+            diag_printf("     %p-%p, ", mem_segments[seg].start, mem_segments[seg].end - 1);
+            diag_printf("[%p-%p]", mem_segments[seg].start, mem_segments[seg].end - 1);
             diag_printf(" available\n");
         }
     }
 #endif
 #ifdef CYGPKG_REDBOOT_FLASH
@@ -392,12 +392,14 @@ cyg_start(void)
                 }
     
                 CYGACC_CALL_IF_SET_CONSOLE_COMM(cur);
 
                 // set up a temporary context that will take us to the trampoline
-                HAL_THREAD_INIT_CONTEXT((CYG_ADDRWORD)workspace_end,
+                CYG_ADDRWORD workspace_temp = (CYG_ADDRWORD)workspace_end;
+                HAL_THREAD_INIT_CONTEXT(workspace_temp,
                                         breakpoint, trampoline,0);
+                workspace_end = (unsigned char *)workspace_temp;
 
                 // switch context to trampoline (get GDB stubs started)
                 HAL_THREAD_SWITCH_CONTEXT(&saved_context, &workspace_end);
 
                 gdb_active = false;
@@ -598,12 +600,14 @@ do_go(int argc, char *argv[])
 	HAL_DCACHE_SYNC();
     }
     HAL_ICACHE_INVALIDATE_ALL();
     HAL_DCACHE_INVALIDATE_ALL();
     // set up a temporary context that will take us to the trampoline
-    HAL_THREAD_INIT_CONTEXT((CYG_ADDRWORD)workspace_end, 
+    CYG_ADDRWORD workspace_temp = (CYG_ADDRWORD)workspace_end;
+    HAL_THREAD_INIT_CONTEXT(workspace_temp,
                             entry, trampoline, 0);
+    workspace_end = (unsigned char *)workspace_temp;
 
     // switch context to trampoline
     HAL_THREAD_SWITCH_CONTEXT(&saved_context, &workspace_end);
 
     // we get back here by way of return_to_redboot()

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]