Forum Discussion
Altera_Forum
Honored Contributor
19 years agoMy last post was slightly wrong - it seems that once I added a change to an LED on the board I noticed that things did sometimes work - I just wasn't getting any printf output. Once I realised that it did sometimes run OK I was able to come up with something which seems to work all the time:
The bootloader now disables all interrupts (and does not bother to keep the returned context) before the jump to the downloaded program: // Disable ALL Interrupts alt_irq_disable_all(); // Start downloadable asm("MOVIA %0, %1" : "=r" (Jump) : "i" DOWNLOADABLE_START_ADDRESS)); asm("JMP %0" : : "r" (Jump)); The alt_main function now starts like this: /* Copy exception code from 0x000FFE00 to 0x20. */ unsigned char *src = (unsigned char *) 0x000FFE00; unsigned char *dest = (unsigned char *) 0x00000020; unsigned char *end = (unsigned char *) 0x000001C8; int context = alt_irq_disable_all(); while (dest != end) { *dest = *src; dest++; src++; } alt_dcache_flush_all(); alt_icache_flush_all(); alt_irq_enable_all(context); Note that I've removed the redundant dereference('*') from *dest++ and *src++. I still need to wait for or clear pending interrupts in the bootloader program, at the moment I allow any printf output to finish by putting in a call to usleep. Without this it seems to still work but not all the printf output is seen.