Forum Discussion
Altera_Forum
Honored Contributor
19 years agoI'm afraid I'm still not fully understanding what I need to do.
So far, I've done the following: Firstly the bootloader now resides at the bottom of memory rather than the top of memory. This allowed me to create a large static array to hold the downloaded program. I've based the program I want to run from another program on hello_world_alt_main. I've added code to the start of alt_main to copy the .exceptions section to 0x20. When I build this and download as a .srec it works and displays some output. We are not using reduced device drivers so the printf should be using an interrupt on the UART. My additions to the start of alt_main are as follows: /* 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; while (dest != end) { *dest = *src; *dest++; *src++; } alt_dcache_flush_all(); alt_icache_flush_all(); I made the program have a start address of 0x00100000 and relocated the .exceptions section to 0x000FFE00 using the following command: nios2-elf-objcopy --change-section-lma .exceptions=0x000FFE00 my_hello_alt_main.elf my_ham_exc.elf However when I try and run this from my bootloader program everything appears to hang. I have tried removing some of the other parts of alt_main e.g. alt_irq_init and turning off interrupts before and after copying the exception code but nothing seems to do anything. I'm not certain how to remove pending interrupts from the UART. The bootloader receives the program data to run over a USB link, turns off everything to do with USB interrupts and stops the hardware from generating any more USB interrupts before running the downloaded code using the following: // Start downloadable asm("MOVIA %0, %1" : "=r" (Jump) : "i" DOWNLOADABLE_START_ADDRESS)); asm("JMP %0" : : "r" (Jump)); Where DOWNLOADABLE_START_ADDRESS is defined as:# define DOWNLOADABLE_START_ADDRESS (unsigned char *) 0x100000 Any ideas where I am going wrong?