Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
10 years ago

Custom Bootloader to copy from flash to external sram

Due to issues with sram byte writes, I'm looking to create a custom bootloader that copies the nios program from flash and writes it (16-bits) into external sram.

(The program's bsp is set for everything to be in external sram, except for the reset (flash) and the exception memory (on-chip))

Would creating a bootloader in flash, be as simple as placing code at the start of flash (where the reset points to), that copies the program data (apparently at offset 0x20) and copies it, 16-bits at a time, over to ext. sram? Before or after it starts to copy, is there any special registers care that must be done, or can it copy it and let the normal user program code (alt_sys_init) handle the initializing of the stack pointer, heap registers, etc? For example looking at the bootloader on Signaltap at power-on, it seems to do reads all over the place (addr 0..0x760.. 0x8.. 0x3c..0x50..0x52) not just a simple copy.

I'm using app note 458, but looking at the dissassembly of altera's byte-copy version of the bootloader (boot_loader_cfi.srec), I don't see where it says the length/source/destination addresses! While the output file of elf2flash is very different throughout depending on where .text points to, the bootloader (0-0x20) itself doesn't seem to contain any specific information.

04000000: wrctl status,zero

04000004: movhi r19,1

04000008: initi r19

0400000c: addi r19,r19,-32

04000010: bne r19,zero,0x4000008

04000014: flushp

04000018: nextpc r23

0400001c: br 0x40000a0

Also anyone know how boot_loader_cfi_be.srec is functionally different from boot_loader_cfi.srec:

04000000: call 0x3a70010

04000004: addi r16,r14,768

04000008: cmpnei r9,r7,8198

0400000c: xori r19,zero,58366

04000010: cmpnei sp,r3,-2818

04000014: call 0x3a20000

04000018: call 0x3ae02e0

0400001c: call 0x620000
No RepliesBe the first to reply