fix for L0 flash loader
authorPiotr Haber <gluedig@gmail.com>
Fri, 6 May 2016 07:08:31 +0000 (09:08 +0200)
committerPiotr Haber <gluedig@gmail.com>
Mon, 9 May 2016 06:22:32 +0000 (08:22 +0200)
src/common.c

index a167bb6d4bfce32976fd69987c43ed35db48edb3..883a045483183c7fec9d21eddd7c0d235f80996a 100644 (file)
@@ -1537,17 +1537,18 @@ int write_loader_to_sram(stlink_t *sl, stm32_addr_t* addr, size_t* size) {
            r2, output, remaining word count
          */
 
-        0x04, 0xe0,
-
-        0x04, 0x68,
-        0x0c, 0x60,
-        0x01, 0x3a,
-        0x04, 0x31,
-        0x04, 0x30,
-
-        0x00, 0x2a,
-        0xf8, 0xd3,
-        0x00, 0xbe
+       0x00, 0xbf, // nop /* to make loader length % 4 = 0 */
+       0x04, 0xe0, // b test_done /* Go to compare */
+       //write_word
+       0x04, 0x68, // ldr r4, [r0] /* Load one word from address in r0 */
+       0x0c, 0x60, // str r4, [r1] /* Store the word to address in r1 */
+       0x04, 0x30, // adds r0, #4 /* Increment r0 */
+       0x04, 0x31, // adds r1, #4 /* Increment r1 */
+       0x01, 0x3a, // subs r2, #1 /* Decrement r2 */
+       //test_done:
+       0x00, 0x2a, // cmp r2, #0 /* Compare r2 to 0 */
+       0xf8, 0xd8, // bhi write_word /* Loop if above 0 */
+       0x00, 0xbe  // bkpt #0x00 /* Set breakpoint to exit */
     };
 
     static const uint8_t loader_code_stm32f4[] = {