News:

Attention: For security reasons,please choose a user name *different* from your login name.
Also make sure to choose a secure password and change it regularly.

Main Menu

How to merge bit file and elf file to mcs file which boot from spi flash

Started by ringo, October 14, 2013, 05:18:28 PM

Previous topic - Next topic

ringo

Hello,
I have several sets TE600 GigaBee S6 LX45. I use the trenz sample flashwriter folder's xmp system file to build the .bit successfully and then export to sdk to make a simple control problem(turn on LED) elf file from ( modified from hello world example). Unfortunately, I have no idea how to put  the bit file and the elf file into SPI flash to boot from power on without PC. I have spent weeks , look into a lot of documents to see how to generate mcs file , iMACT etc and trying a lot but still not success.
Does any one can help! Thanks in advance.

Oleksandr Kiyenko

Hi Ringo,
There are 2 possibilities.

1) If your program code is not too large, you can put it to block RAM.
1a) If you prefer to use XPS:
Open XPS project. On "Project" tab right click "Elf Files"->microblaze_0->Imp Executable, Select "Browse" and select your elf file from SDK workspace.
Device configuration -> Update bitstream.
After that download.bit file will be created in implementation directory. This file can be used to create MCS and it contains program in BRAM.
1b) If you prefer to use SDK:
Each time when you download project to board by JTAG, SDK created download.bit file in hardware platform folder.
This file can be used to create MCS and it contains program in BRAM.

2) If your program is to big to fit into BRAM, you should create a bootloader which fits into BRAM and fetch code from Flash. See http://forum.trenz-electronic.de/index.php/topic,279.msg898.html#msg898 discussion, it's more for Serial PROM, but in general describes what to do.

Best regards
Oleksandr

ringo

Hi Oleksandr,
Thanks for your information. I spent one day to try based on your first 2 methods but it still fails. I start from the beginning using Trenz-GigaBee_XPS14.2-Base\system.xmp to generated bit file and export to SDK using hello world (just add one item to turn on LED) and get elf file.
In debug mode: program FPGA ( ELF File to Initialize in Block RAM: select "bootloop")  and right click Binaries/myfile.elf and Run as  - launch on hardware. It works fine. Then I follow your step1. It generated download.bit file in xmp/implementation folder. Then I convert to mcs file using impact and download it to spi flash by impact. The TE600/603 only work for bit file (configuration) but not the microblaze elf file when boot.
Also, if I select  (ELF File to Initialize in Block RAM: select "myfile.elf" but not "bootloop")   in SDK / program FPGA menu, it shows "Program FPGA failed"
Reason: " ELF check failed for ELF file".
In addition, in SDK/ Program Flash menu.  It shows " No usable flash memory controllers were found in the hardware system".

I am really anxious now. I will be grateful if you can help me further.
Thanks in advance.
Regards,
Ringo


Oleksandr Kiyenko

Hi Ringo,
Simplest way is:
1) Test that your application works in SDK (As I understand it's already done)
2) Check that your application linked to be executed from BRAM (regenerate linker script and elf if not)
3) Go to XPS and assign elf file as "Imp Executable"
4) Run "Update bitstream with software platform information"
5) Run iMPACT and generate MCS from implemantation/download.bit
6) Program MCS to Flash

Best regards
Oleksandr

Horsa

A)
Further to Oleksandr's 1a = XPS procedure, you can have a look at this picture:
http://forums.xilinx.com/t5/Embedded-Development-Tools/can-sdk-elf-and-bit-download-FPGA-together/td-p/202393

The file system.bit, created after hardware generation, is an uninitialized bitstream and does not include the ELF file. It is only when you execute the command to download or update the bitstream that the system.bit and ELF files merge into download.bit.

The download.bit file generated is a merge of system.bit and blinkLED.elf. The blinkLED.elf is (converted and) loaded into FPGA's BRAM using data2mem (automatically called in this procedure).

You should use Xilinx iMPACT to transform download.bit into download.mcs to write into the SPI Flash (as you have already done before).


B)
Further to Oleksandr's 1b = SDK procedure "SDK / Program Fpga menu":
"1b) If you prefer to use SDK:
Each time when you download project to board by JTAG, SDK created download.bit file in hardware platform folder.
This file can be used to create MCS and it contains program in BRAM.
"

You should select
B*1) the correct system.bit file
B*2) the correct system_bd.bmm file
B*3) your blinkLED.elf file

The generated download.bit file is a merge of system.bit and blinkLED.elf. The blinkLED.elf is (converted and) loaded into FPGA's BRAM using data2mem (automatically called when you click <Program FPGA>).

I assume that you have already performed correctly these steps, but it is better to double check.

To be safer, you could try to create a new SDK project (if the current one may have become corrupted), copy your C code and be sure that your C project uses your BSP project and your HW project. You should also check your link script.

In the new (or in the old) project, you should check the following:

B#1)
Select your project in SDK.
Click Project > Properties
Select Project References
Both Hardware and BSP project should be checked

B#2)
Select your BSP in SDK
Click Project > Properties
Select Project References
Hardware project should be checked.

B#3)
point 2 recommended by Oleksandr in « Reply #3 on: Today at 11:20:13 AM »
Check that the BRAM is selected in the link script, not the DDR RAM.
Generate a new link script if necessary.


C)
About "SDK/ Program Flash menu".
It shows "No usable flash memory controllers were found in the hardware system".
TE modules use an SPI Flash. SDK only support BPI Flash. You cannot use SDK to program an SPI Flash, you shall use Xilinx iMPACT.

ringo

Hi Horsa,
First of all, thanks both Horsa and Oleksandr for your help. I work it out now. The problem is : I have not changed the linker script to run in local ram.
Then, I go to further step to make a small boot loader and then run my application elf that stored in spi flash. I think it is a common way in general. I follow some procedures that I found in the web. Unfortunately, it is failed. It shows " Error while reading an SREC line from flash".
The procedures are:
1.generate bit file from xmp.
2. export to sdk and take the "SREC Bootloader" from trmplate as application project. The address point to 0x00800000 at flash.
3.same procedure as before which boots it from local ram and merge with bit file.
3. make a "hello world" elf file and use the command "mb-objcopy -O srec hello_world.elf hello_world.srec" to make a srec file. The file is generated.
4. Use impact to make a PROM.  Firstly put the config. file ".bit file" and then put data file "hello_world.srec" at address 0x00800000.
5. Finally program the flash.

Please help to see what will be the problems from.
Once again. Thanks for your help so far.
Regards,
Ringo