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

TE0600 Bootloading Issues

Started by signumfx, July 04, 2014, 02:54:56 PM

Previous topic - Next topic

signumfx

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:


  • As the application was small enough I already worked out how the configure the FPGA from Flash solely using the BRAM - so I got the tool chain from EDK - SDK - iMPACT working.
  • Now, that the application does not fit within the BRAM anymore, I have an ELF bootloader in place that uses the Quad-SPI interface to copy the data from Flash to DDR. This bootloader is embedded in the configuration bitstream using EDK (update bitstream).
  • I use the iMPACT 14.6 GUI (SPI Flash - Configure Single FPGA) to generate a MCS file in order to perform the progamming of the WinBond flash memory. Using that, I made sure to check the "Add Non-Configuration Data Files" option in the iMPACT wizard. The ELF file is added at offset of 0x500000.
  • Hitting "Generate File ..." produces "Generate Succeeded" and the corresponding MCS file.
  • Within the Boundary Scan menu I configure my external SPI flash accordingly and program the flash without any errors.
   
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:


       
  • What's all about the "INTERNAL_ERROR::45" error messages?
  • Why are there no errors using MCS file generation within the iMPACT GUI?
  • Where's my ELF file going?
  • What am I doing wrong here? Any ideas?

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

Oleksandr Kiyenko

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

signumfx

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

Oleksandr Kiyenko

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

signumfx

#4
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:

  • iMPACT also expects a *.cfi file, which is (of course) not generated within the python script. I suppose this is just optional, correct?
  • You mentioned the "sector erase option" for programming this MCS to the Flash. It looked like this is done automatically, when using your ssb_write.cmd (the -e option is not set) - or do I have to do anything else?

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.

  • MCS_Comparision_ELF_magic_number.png shows the comparision of the first few data sections.
  • MCS_Comparision_Mismatch.png shows the section of the mismatch. The red box shows the last matching line - above that: mismatch. Below that: match.

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

Oleksandr Kiyenko

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

signumfx

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