Hi Scott,
>Ok, so your processor's exception address is in the internal memory.
Yes
>If I understand you correctly, for your user application, you are placing >the .exception section in SDRAM???
>If this is the case, this is your problem. :
Sorry my fault. No the user app .exception segment is set to internal memory. so it should be ok.
> If the on chip memory is actually ram, then resetting the CPU (not the FPGA)
>also cause problems if your bootloader code enables interrupts -- since the
> exception handler has been overwritten by the application.
The on chip memory is ram, and i'm not using interrupts in the bootloader.
However the bootloader project is not a freestanding application.
So if this enables interrupts i'm not avere of it, but i don't use them anyway, so this shouldn't be a problem?
>- And finally, if alt_load is not called, then your application's exception handler is
>not copied to the correct address -- you're app will have to do that itself -- unless
>your bootloader is smart enough to do it.
My user application is a freestanding project.
I don't call alt_load in my user application or in the bootloader.
If I understand you correct, this is a problem because the .exception segment,
from my bootloader program, is still in internal memory when the user application is started.
This fact will course a conflict when the user application uses or initialises interrupt.
So to sum up, this is really important.
-BOOTLOADER
After transfer of user application to SDRAM:
-make sure interrupts is not used
If your not using _alt_load in the user application.
-Copy .exception from user app image(now in sdram, look in objdump file to locate, normally sdrambase + 0x20 to ??).
Copy this segment to the .exception address defined in SOPC builder, overwriting the bootloaders .exception code.
-flush icache, dcache and the pipeline, using alt_icache_flush_all(), alt_dcache_flush_all()
-Call _start address to start the user application
USER APPLICATiON
If boot loader doesn’t handle the .exception copy thing.
Call the alt_load function at the start of main/alt_main to do the same job.
-Do whatever to code needs to do.
Hope this is correct?
Regards,
Rasdan
EDIT UPDATE!!
Ok I still have the same questions
I tried flushing icache and dcache.
The result was the same no execution of the user program.
Then I tried something new:
I edited the bootloader so it only loads code into sdram nothing more, no calls, no flush.
Then I made a new freestanding project witch sole purpose was to call/jump to _start (were my userprogram is located after the bootloader ends)
I compiled the quartus project with the new no_jump bootloader, reset my board and let the bootloader load the user app into sdram.
Then I used the nios IDE to run my new jump program into internal ram (making sure not to destroy the user program in sdram).
The jump program look like this:
int alt_main(void)
{
void (*AppStartP)(void);
alt_irq_init (ALT_IRQ_BASE);
alt_sys_init();
alt_icache_flush_all();
alt_dcache_flush_all();
AppStartP = (void*)0x1000000; //_start
AppStartP();
}
I run the jump program and nothing happen, no led flashing.
I then edit the jump program to look like this:
int alt_main(void)
{
void (*AppStartP)(void);
//alt_irq_init (ALT_IRQ_BASE);
alt_sys_init();
alt_icache_flush_all();
alt_dcache_flush_all();
AppStartP = (void*)0x1000000; //_start
AppStartP();
}
I run it and my user application starts and the led flashing begins.
My conclusion:
If the bootloader (nonfreestanding) init interrupts the jump/call doesn’t work.
I think this happens with a non freestanding application just before main
QUESTION: Why does this irq init affect the call/jump to the user application?