}\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
UsbSendPacket(packet, len);\r
}\r
\r
+extern char _osimage_entry;\r
void BootROM(void)\r
{\r
//------------\r
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
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
#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
LONG(_version_information_start)\r
} >bootphase1\r
\r
+ __bootphase2_src_start__ = ORIGIN(bootphase2);\r
.bootphase2 : {\r
__bootphase2_start__ = .;\r
*(.startphase2)\r
\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
/* 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;