hmm go back to mtspr for now, also add explicit loading-offset of 0x600000
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 11 Apr 2022 21:11:50 +0000 (22:11 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 11 Apr 2022 21:11:50 +0000 (22:11 +0100)
like there is in the microwatt-verilator work

coldboot/coldboot.c

index b48b6ef0f4d70da22d69004ec2a9840544e16450..d5f8c4973e97271ecdc5342d2c554856e2c9fabe 100644 (file)
@@ -100,7 +100,7 @@ static bool fl_read(void *dst, uint32_t offset, uint32_t size)
     return true;
 }
 
-static unsigned long copy_flash(unsigned int offset)
+static unsigned long copy_flash(unsigned int offset, unsigned int dst_offs)
 {
     Elf64_Ehdr ehdr;
     Elf64_Phdr ph;
@@ -155,7 +155,7 @@ static unsigned long copy_flash(unsigned int offset)
         puts(" addr ");
         uart_writeuint32((uint32_t)(unsigned long)addr);
         puts("\r\n");
-        fl_read(addr, off, size);
+        fl_read(addr+dst_offs, off, size);
         poff += ehdr.e_phentsize;
     }
 
@@ -487,13 +487,12 @@ int main(void) {
         (failcnt == 0))
     {
         // identify ELF, copy if present, and get the start address
-        unsigned long faddr = copy_flash(spi_offs);
+        unsigned long faddr = copy_flash(spi_offs,
+                                         0x600000); // hack!
         if (faddr != -1ul) {
             // jump to absolute address
-            /* could do it this way but hey modify head.S instead
-               mtspr(8, faddr); // move address to LR
-               __asm__ volatile("blr");
-            */
+            mtspr(8, faddr); // move address to LR
+            __asm__ volatile("blr");
 
             // works with head.S which copies r3 into ctr then does bctr
             return faddr;