Forum Discussion

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

custom Nios bootloader

Hello,

I have a very small board containing ethernet phy, sdram and cyclone III fpga only. The fpga upload is done from another board, which has microcontroller on it, using passive serial mode. The .sof upload is easy, I enable TTF file generation in Quartus and give that generated code to the microcontroller.

Now the difficult part is Nios upload. I don't have neither EPCS nor CFI flash, but I have 8bit interface with microcontroller with some control signals, so I need other methods to upload Nios .elf file to the system, instead of epcs and cfi methods described in manual.

One of the ideas would be to place reset vector into onchip memory where I would place a small program, that copies software into sdram, but I am not sure if the option enabling memory initialization from .hex is directly compiled into the .sof or not. Are there any solutions?

Thanks.

15 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Well, that's actually strange, because I am writing data from 0x00800000, which is SDRAM_BASE. It always stops writing at 0x00800864. I am also using SPI interrupt to get byte and then write it to SDRAM.

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    How can you be using the SPI interrupt in the bootloader, when the interrupt vector address is in SDRAM - where you are loading the code to.

    I'd have thought you'd need to run the boot loader with interrupts disabled (polling for status).

    Also, where is your bootloader's stack (if the code actually uses one). If that is in SDRAM you might be writing over the stack.

    It ought to be possible to write a bootloader (in C) that has almost no memory accesses. I couldn't stop the function prologue saving registers - they are the only references to %sp in my entire hdlc and mtp2 engines.

    (gcc would need a rebuild to let me use %sp as a general register!)
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hm, I've set all the vectors to on_chip ram except the exception one. Just a minute ago, I've managed to run the bootloader using SPI status register polling. Now I'll try to use interrupts if possible.

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Why bother using interrupts?

    The processor isn't doing anything else is it?
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Using interrupts is elegant solution :) but anyway, it doesn't work as You've said. I've left the bootloader to poll bytes from SPI.