From 2c634a4b00f7268e827f4693c9f841b94b6a746c Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Mon, 11 Apr 2022 22:11:50 +0100 Subject: [PATCH] hmm go back to mtspr for now, also add explicit loading-offset of 0x600000 like there is in the microwatt-verilator work --- coldboot/coldboot.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/coldboot/coldboot.c b/coldboot/coldboot.c index b48b6ef..d5f8c49 100644 --- a/coldboot/coldboot.c +++ b/coldboot/coldboot.c @@ -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; -- 2.30.2