Trenz Electronic GmbH Support Forum

Trenz Electronic Products => Trenz Electronic FPGA Modules => Topic started by: signumfx on July 04, 2014, 02:54:56 PM

Title: TE0600 Bootloading Issues
Post by: signumfx on July 04, 2014, 02:54:56 PM
Dear all,

My setup:

I am working on an EDK Microblaze project (ISE Design Suite 14.2) with a Trenz Electronic GigaBee XC6SLX Series Board (Spartan-6 XC6SLX150) interfacing with a WinBond W25Q64BV Flash memory (64Mbit) using Quad-SPI. In order to automatically configure the FPGA on start-up I am using an ELF bootloader from Mr. Kiyenko to copy the executable from the Flash memory to the onboard DDR memory. So far so good.

What I've done so far:

   
After configuration the bootloader executes (DDR testing successful, Quad-SPI initialization successful) and tries to find the ELF magic number to start copying to DDR ... and finds nothing.
I debugged the bootloading process and checked for the data read at the corresponding offset --> 0xFFFFFFFF (empty)

Now I wondered why the ELF magic number is not found ...

I checked the generated MCS file and tried to locate the beginning of the ELF file manually ... nothing.

When executing the "promgen" command stated as follows:
promgen -w -p mcs -c FF -o <outputMCSfile> -s 8192 -u 0000 <BITfile> -bd <ELFfile> start 500000 -spi[/color]

The output looks something like this:

ERROR::6 - Illegal token '(', 'ADDRESS_RANGE' expected.
(null)END_ADDRESS_SPACE;
^


I also noticed several errors popping up:
INTERNAL_ERROR::45 - Memory allocation leak of xxx Bytes found at xxx for 'xxx' data.
After that.

I compared the generated MCS file with and without the added ELF file and found no difference at all - which led me to the conclusion the the ELF file is simply not where it should be - or at least not where I thought it should be!

My questions:


Any help would be really appreciated.

Currently I'm also trying a different approach using a BIN bootloader from Avnet - although having not much success either.

Thank you for your time,

  Thomas
Title: Re: TE0600 Bootloading Issues
Post by: Oleksandr Kiyenko on July 06, 2014, 02:12:45 PM
Hello,

- What's all about the "INTERNAL_ERROR::45" error messages?
As I know promgen command is not good supported at the moment, recommended way is to use iMPACT batch features.

- Why are there no errors using MCS file generation within the iMPACT GUI?
I know about problems in iMPACT with generation/flashing MCS files with gaps between data blocks.
You should check result MCS file to find if your additional binary data is really in it.

- Where's my ELF file going?
Can't answer this question.

- What am I doing wrong here? Any ideas?
I think that you should  try:
1) Generate MCS file with bit and additional elf using iMPACT GUI or iMPACT batch (try to make minimal gap in flash between data blocks)
2) Check if elf file really writen to MCS (you can easily check it opening MCS in text editor by address and ELF signature)
3) Try to programm this MSC and check that flash writen correctly
4) If you see that iMPACT generate incorrect MCS only way is to write own script to generate MCS.
I use my own python scripts to add extra binary data to MCS. You can ask Xilinx support if you define problem.

Best regards
Oleksandr Kiyenko
Title: Re: TE0600 Bootloading Issues
Post by: signumfx on July 07, 2014, 03:21:19 PM
Hello Oleksandr,

thank you for your input.

Well "not good supported" is not really what I expect from a software at version 14.7 :( - but anyways I'm trying batch mode instead.

This is what I came up with, using the _impact.log file as a reference to see what the GUI has put together:

Snippet:


cd ./%prom_dir%
@echo setMode        -pff                                                                             >> convert_to_mcs.cmd
@echo setPreference  -pref StartupClock:Auto_Correction                                             >> convert_to_mcs.cmd
@echo setSubmode     -pffspi                                                                        >> convert_to_mcs.cmd
@echo addDesign      -version 0 -startaddress 0                                                    >> convert_to_mcs.cmd
@echo addDeviceChain -index 0                                                            >> convert_to_mcs.cmd
@echo setAttribute    -configdevice -attr compressed -value "FALSE"                           >> convert_to_mcs.cmd
@echo setAttribute    -configdevice -attr autoSize -value "FALSE"                              >> convert_to_mcs.cmd
@echo setAttribute    -configdevice -attr swapBit -value "FALSE"                              >> convert_to_mcs.cmd
@echo setAttribute    -configdevice -attr dir -value "UP"                                    >> convert_to_mcs.cmd
@echo setAttribute    -configdevice -attr multiboot -value "FALSE"                           >> convert_to_mcs.cmd
@echo setAttribute    -configdevice -attr spiSelected -value "TRUE"                           >> convert_to_mcs.cmd
@echo addPromDevice -p 1 -size 8192                                                    >> convert_to_mcs.cmd
@echo addDevice     -p 1 -file "%bitstream%.bit"                                        >> convert_to_mcs.cmd
@echo addDesign    -version 1 -startaddress %elf_offset%                                 >> convert_to_mcs.cmd
@echo setMode        -pff                                                                             >> convert_to_mcs.cmd
@echo addDeviceChain -index 0                                                            >> convert_to_mcs.cmd
@echo addDevice     -p 1 -file "%elffile%.elf"                                           >> convert_to_mcs.cmd 
@echo generate      -format %format% -generic -spi -fillvalue FF -output %prom_image%.mcs             >> convert_to_mcs.cmd
@echo quit                                                                                            >> convert_to_mcs.cmd
impact -batch convert_to_mcs.cmd




Still, this approach does not produce the MCS file as expected due to errors concerning the added ELF file. Before the errors show up iMPACT says it added the ELF file successfully!

But somehow the ELF file is not accepted as a valid file:
ERROR:Bitstream:52 - Bitstream file (ELF has a bad of invalid format)
ERROR:Bitstream:53 - Missing or invalid bit files found after the -u option.


The GUI seems to use the same commands - I don't know what's going on here. The documentation of this stuff is rather poor.

Any suggestions to get this to work?
Maybe you could post a working batch-file?

Best Regards,
  Thomas
Title: Re: TE0600 Bootloading Issues
Post by: Oleksandr Kiyenko on July 08, 2014, 09:33:27 AM
Hello Thomas,
In one of my projects I use bat file and python script to generate mcs file from elf. This mcs file should be writen to flash after it already contain bitstream with FSBL. MCS configured to have 4MB offset from begining (after bitstream).
So in bat file

@rem Configure environment
set RESULT="bootloader.mcs"
set ELF="SDK\SDK_Workspace\hello_world_ddr\Release\hello_world_ddr.elf"

call C:\Xilinx\14.2\ISE_DS\settings64.bat
@rem generate MCS with 4M offset
python scripts\bin2mcs.py -s 64 -f %ELF% > %RESULT%
@rem write MCS to Flash
impact -batch etc\ssb_write.cmd
@rem clean
del %RESULT%


I attach bin2mcs.py (you should change extension from txt to py)

You need to do:
1) Generate bit file with bootloader in BRAM
2) Generate MCS from this file and write it to flash
3) Ganerate MCS from your elf file using commands from script above
4) Write this MCS to flash. Note that you should not do full flash erase during this write, only sector erase!
This way I divide hardware and software development (hardware and software can be reflashed independently). It's also possible to combine this 2 MCS files to one using additional generation script but more safely to use 2 separate files and write it to flash with sector erase option.

Best regards
Oleksandr
Title: Re: TE0600 Bootloading Issues
Post by: signumfx on July 10, 2014, 09:49:04 AM
Hi Oleksandr,

thank you again for your support.

I followed your instructions and completed all steps as listed.

Just as a side note: I am not a python expert, so I struggled at first to get the script working. It turned out when I tried to get the script running using Python 3.4 led to syntax errors - I noted that there is a difference between version 2.x and 3.x but didn't investigate any further. So, when giving Python 2.7 a try, the script did work as intended.

Additionally I used your ssb_write.cmd script (from GitHub - GigaBee_XPS14.2-Base) and adapted it for the W25Q64BV.

The generated MCS file from the ELF file looked promising (ELF magic number is clearly seen within the text editor.

Programming the MCS file to the Flash was also successful.
Just some questions here:

Now, when the FPGA reboots and the bootloader tries to find the ELF magic number - nothing is found at the corresponding offset (5MB, 0x500000).

What I did ist the following:
I read back the entire Flash memory content and looked for the ELF magic number myself - as expected nothing.

Now here comes the weird part:
I checked the memory content of the readback at the end of the file and found that the content matches the content of the generated MCS file (from ELF). Further investigations showed that at some point in memory there is a mismatch between those two files. I've added a snapshot from the text editors - the left column represents the generated MCS file, whereas the right column is the readback data from the Flash.

Any ideas?
I'm pretty sure that the offset for the generated MCS is correct (I used sector 80 for the python script, which should match address 0x500000).

Best Regards,
  Thomas
Title: Re: TE0600 Bootloading Issues
Post by: Oleksandr Kiyenko on July 11, 2014, 09:57:08 AM
Hi Thomas,
- This script was tested only with python 2.7.
- CFI file not needed for flash programming, you can ignore this message
- I wrote to use "sector erase" to be sure that you not use full erase (for example from GUI)

You can try to write MCS generated from ELF from iMPACT GUI and check "Verify" to be sure that it was written.
P.S. Address looks correct.

Best regards
Oleksandr
Title: Re: TE0600 Bootloading Issues
Post by: signumfx on July 15, 2014, 04:42:09 PM
Hi Oleksandr,

I got everything to work - thank you very much for your help and support!

This is how I got it running:
Writing the MCS via the iMPACT GUI showed no difference to the script based approach at first - I did a couple of readbacks and noted that the data is not written to the Flash as expected.

Finally I chose to do a full chip erase and gave it another try (maybe someone finds this useful):

1) Generate bit file with ELF-bootloader in BRAM (Update Bitstream in EDK)
2) Generate MCS from this file and write it to Flash memory (using PROM file generation within iMPACT GUI, no data file added)
3) Generate MCS from application ELF file using the python script (see above)
4) Write this application MCS to Flash using iMPACT GUI (sector erase is automatically active)

... and the bootloader found the image at the correct offset and started booting the application.

Don't really know what was going on, but anyways, everything is fine now.

Thanks again,

Best Regards,
  Thomas