]> git.zerfleddert.de Git - proxmark3-svn/commitdiff
Eradicate all occurences of hardcoded memory addresses from all sources files, except...
authorhenryk@ploetzli.ch <henryk@ploetzli.ch@ef4ab9da-24cd-11de-8aaa-f3a34680c41f>
Mon, 31 Aug 2009 14:52:59 +0000 (14:52 +0000)
committerhenryk@ploetzli.ch <henryk@ploetzli.ch@ef4ab9da-24cd-11de-8aaa-f3a34680c41f>
Mon, 31 Aug 2009 14:52:59 +0000 (14:52 +0000)
armsrc/fpgaloader.c
bootrom/bootrom.c
bootrom/flash-reset.s
bootrom/fromflash.c
bootrom/ldscript-flash
bootrom/ram-reset.s
common/ldscript.common

index 88fdc4cfc08a6517e092ef2aa892936fdb447285..58385588b417affa07ef1b0adeac5b7668a14159 100644 (file)
@@ -275,14 +275,14 @@ void FpgaDownloadAndGo(void)
        }\r
        \r
        /* Fallback for the old flash image format: Check for the magic marker 0xFFFFFFFF\r
-        * 0xAA995566 at address 0x2000. This is raw bitstream with a size of 336,768 bits \r
+        * 0xAA995566 at address 0x102000. This is raw bitstream with a size of 336,768 bits \r
         * = 10,524 DWORDs, stored as DWORDS e.g. little-endian in memory, but each DWORD\r
         * is still to be transmitted in MSBit first order. Set the invert flag to indicate\r
         * that the DownloadFPGA function should invert every 4 byte sequence when doing\r
         * the bytewise download.
         */\r
-       if( *(DWORD*)0x2000 == 0xFFFFFFFF && *(DWORD*)0x2004 == 0xAA995566 )\r
-               DownloadFPGA((DWORD *)0x2000, 10524, 1);\r
+       if( *(DWORD*)0x102000 == 0xFFFFFFFF && *(DWORD*)0x102004 == 0xAA995566 )\r
+               DownloadFPGA((DWORD *)0x102000, 10524, 1);\r
 }\r
 \r
 void FpgaGatherVersion(char *dst, int len)\r
index 3dba041e67757d79396b5cd1f595448dc9fe622c..2d94f01ae4559d6c56ca7cf8f9bb7ae0716bed4f 100644 (file)
@@ -107,6 +107,7 @@ void UsbPacketReceived(BYTE *packet, int len)
     UsbSendPacket(packet, len);\r
 }\r
 \r
+extern char _osimage_entry;\r
 void BootROM(void)\r
 {\r
     //------------\r
@@ -182,9 +183,8 @@ void BootROM(void)
             USB_D_PLUS_PULLUP_OFF();\r
             LED_B_ON();\r
 \r
-                       // jump to Flash address 0x10000 (LSBit set for thumb mode, 0x100000 added for Flash base address)\r
-            asm("ldr r3, = 0x00110001\n");\r
-            asm("bx r3\n");\r
+                       // jump to Flash address of the osimage entry point (LSBit set for thumb mode)\r
+            asm("bx %0\n" : : "r" ( ((int)&_osimage_entry) | 0x1 ) );\r
         }\r
     }\r
 }\r
index 48c111a703315260758b01c0b076a02b1dd5a8df..64134033c630c4b8ac1414f2a555a7d5efd76e26 100644 (file)
@@ -16,12 +16,17 @@ flashstart:
     b       Fiq\r
 \r
 Reset:\r
-    ldr     sp,     = 0x0020FFF8       @ initialize stack pointer to top of RAM\r
+    ldr     sp,     .stack_end @ initialize stack pointer to top of RAM\r
     bl      CopyBootToRAM                      @ copy bootloader to RAM (in case the\r
                                                                @ user re-flashes the bootloader)\r
-    ldr     r3,     = 0x00200000       @ start address of RAM bootloader\r
+    ldr     r3,     .bootphase2_start  @ start address of RAM bootloader\r
     bx      r3                                         @ jump to it\r
 \r
+       .stack_end:\r
+       .word _stack_end\r
+       .bootphase2_start:\r
+       .word __bootphase2_start__\r
+\r
 Fiq:\r
     b       Fiq\r
 UndefinedInstruction:\r
index 0065e19e81cfb52101ac0ed05a87057bbf823b7d..6b41c408c3a6968711675ac0a343100a578f5f2e 100644 (file)
@@ -1,11 +1,13 @@
 #include <proxmark3.h>\r
 \r
+extern char __bootphase2_src_start__, __bootphase2_start__, __bootphase2_end__;\r
 void __attribute__((section(".bootphase1"))) CopyBootToRAM(void)\r
 {\r
        int i;\r
 \r
-       volatile DWORD *s = (volatile DWORD *)0x200;\r
-       volatile DWORD *d = (volatile DWORD *)0x200000;\r
+       volatile DWORD *s = (volatile DWORD *)&__bootphase2_src_start__;\r
+       volatile DWORD *d = (volatile DWORD *)&__bootphase2_start__;\r
+       unsigned int l = (int)&__bootphase2_end__ - (int)&__bootphase2_start__;\r
 \r
-       for(i = 0; i < 1024; i++) *d++ = *s++;\r
+       for(i = 0; i < l/sizeof(DWORD); i++) *d++ = *s++;\r
 }\r
index 37bfaaa1060bf7f7b9b99bb3ed182a75ce119d4e..142924a8508dc51b35d718d4e94d9bbd19fc0277 100644 (file)
@@ -25,6 +25,7 @@ SECTIONS
        LONG(_version_information_start)\r
     } >bootphase1\r
     \r
+    __bootphase2_src_start__ = ORIGIN(bootphase2);\r
     .bootphase2 : {\r
        __bootphase2_start__ = .;\r
        *(.startphase2)\r
index 6155b0026abead31b125d0582bd4cbd63c130b3e..691cd0db1958d4ace3e0ab1aa8ddabdb1011e587 100644 (file)
@@ -6,5 +6,8 @@
 \r
 .global ramstart\r
 ramstart:\r
-    ldr     sp,     = 0x0020FFF8\r
+    ldr     sp,     .stack_end\r
     bl      BootROM\r
+\r
+       .stack_end:\r
+       .word _stack_end\r
index 4379d40c8511ec26dd4c1d6a5206c74be5a6b955..98161d3ad7455f10ad018db29914ccb7c42eb44d 100644 (file)
@@ -16,5 +16,7 @@ MEMORY
 
 /* Export some information that can be used from within the firmware */
 _bootphase1_version_pointer = ORIGIN(bootphase1) + LENGTH(bootphase1) - 0x4;
+_osimage_entry = ORIGIN(osimage);
 _flash_start = ORIGIN(bootphase1);
-_flash_end = ORIGIN(osimage) + LENGTH(osimage);
\ No newline at end of file
+_flash_end = ORIGIN(osimage) + LENGTH(osimage);
+_stack_end = ORIGIN(ram) + LENGTH(ram) - 8;
Impressum, Datenschutz