Forum Discussion
Altera_Forum
Honored Contributor
15 years agoModifying EPCS bootloader
Skip to tl;dr at the bottom if so inclined. Background and such is there to cover some possible questions.
background: (Developing in Q10.1) I am developing a project with two separate firmware images(FW1, FW2) and two separate software images (SW1,SW2). In the EPCS the images are stored as follows: 0x000000 FW1 (After FW1) SW1 0x800000 FW2 0x900000 SW2 (this location can be moved without problems) On boot, FW1 (which includes a NIOS CPU) will load from an EPCS. The software automatically loads using the default boot loader generated by Quartus/sopc. At this time SW1 will do stuff and issue a reconfigure command via the reconfiguration component. FW2 starts up from the reconfiguration. At this point, the default boot loader (in FW2) points (by calculating the size of FW at address 0) to SW1 and loads it. (my problem) desired solution: I would like to modify the boot loader hex file stored in the EPCS boot loader ram to point to my second software location. From what I have gathered (on these forums and elsewhere) the boot loader software is compiled from the assembly code found here: <Quartus_install_dir>\nios2eds\components\altera_nios2\boot_loader_sources\. I would like to modify the boot loader code, recompile it, and replace the default hex file in the EPCS component. I will probably be able to figure out how to set a fixed offset to the boot loader software on my own, but help is always appreciated. tl;dr How exactly do you "re-compile" the boot loader software and generate the hex file? There is a makefile in the directory, but I am not sure how to use it. (just typing make using the nios2 command shell in the directory will not work)18 Replies
- Altera_Forum
Honored Contributor
Figures, I search for hours for a solution and finally ask for help and I make progress not 30 minutes later. :oops:
I am half way there (I hope). I managed to find the "make help" option when running in the nios2 command shell. This generated srec files. (I sort of expected that) Now I need to figure out which SREC file to use and to convert it into my hex file. The hardware I am using is an EPCS128 and a Cyclone IV. (should work the same as a Cyclone III) - Altera_Forum
Honored Contributor
The following script is what I am using to generate a hex file for the bootloader on Cyclone IV:
#!/bin/sh make clean make CODE_BASE=0 elf2hex --input-file=obj/boot_loader_epcs_sii_siii_ciii.elf --output boot.hex --width=32 --base=0 --end=0x3FF - Altera_Forum
Honored Contributor
Kevin,
Thanks for the script! That worked great. Thanks for the help. - - Altera_Forum
Honored Contributor
I've exactly the same issue here.
But if I try my modified bootloader it does not start the NiosII code. When I try to build the original bootloader and replace it in the SOPC directory, do a MIF/HEX Update in Quartus and regenerate the SOF it works... so the compilation and conversion of files works correctly. Are you willing to share you code or can you point me out what you've changed in boot_loader_epcs_bits_sii_siii_ciii.S? - Altera_Forum
Honored Contributor
I still haven't found a solution.
I create one JIC file with following images: BLOCK START ADDRESS END ADDRESS hwimage_app1.hex 0x00000000 0x0002FEB3 swimage_app1.hex 0x0002FEB4 0x00038C83 hwimage_app2.hex 0x00090000 0x000BF762 swimage_app2.hex 0x000BF763 0x000C8502 I would be really helped by some code where I can give an offset in the bootloader files. I think in file boot_loader_epcs_bits_sii_siii_ciii.S the following should have an offset: line 96: // 1) Open EPCS-device at flash-offset zero. movi r_flash_ptr, 0 line 145: // Close & re-open EPCS where we will start extracting the length movi r_flash_ptr, 48 line 182: // Close & re-open EPCS at byte 33 movi r_flash_ptr, 33 It should not be too difficult?! But I cannot manage it to get it working! - Altera_Forum
Honored Contributor
Question: Are you guys able to debug and step through the code in the boot loader? If so, can you please let me know how you are doing this.
- Altera_Forum
Honored Contributor
No, I'm not debugging step by step.
But I'm afraid I've to. First need to understand the complete working of the boot_loader because my simple changes do not work... - Altera_Forum
Honored Contributor
--- Quote Start --- I still haven't found a solution. I create one JIC file with following images: BLOCK START ADDRESS END ADDRESS hwimage_app1.hex 0x00000000 0x0002FEB3 swimage_app1.hex 0x0002FEB4 0x00038C83 hwimage_app2.hex 0x00090000 0x000BF762 swimage_app2.hex 0x000BF763 0x000C8502 I would be really helped by some code where I can give an offset in the bootloader files. I think in file boot_loader_epcs_bits_sii_siii_ciii.S the following should have an offset: line 96: // 1) Open EPCS-device at flash-offset zero. movi r_flash_ptr, 0 line 145: // Close & re-open EPCS where we will start extracting the length movi r_flash_ptr, 48 line 182: // Close & re-open EPCS at byte 33 movi r_flash_ptr, 33 It should not be too difficult?! But I cannot manage it to get it working! --- Quote End --- There's a bit of code further down where it copies the length in bits to r_flash_ptr and converts it to a length in bytes. I think you'll need to add your hwimage offset to this value to get the swimage offset. N.B.: I haven't tried it. ;) - Altera_Forum
Honored Contributor
--- Quote Start --- The following script is what I am using to generate a hex file for the bootloader on Cyclone IV:
--- Quote End --- Could somebodey explain me, what the meaning of "CODE_BASE=0" is? Thanks sim#!/bin/sh make clean make CODE_BASE=0 elf2hex --input-file=obj/boot_loader_epcs_sii_siii_ciii.elf --output boot.hex --width=32 --base=0 --end=0x3FF - Altera_Forum
Honored Contributor
It will assign the 'make' variable 'CODE_BASE' the value 0.
This assignment will not be overridable from within the makefile. What happens next depends on the contents of the makefile.