UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Adventurer
Adventurer
8,560 Views
Registered: ‎03-23-2015

How to create C application that can run by U-boot?

Jump to solution

Hi,

  Setup: SP605, Microblaze, SDK 14.7 (FS-boot),  Petalinux 2013.10(u-boot)

 

  In my application, I need U-boot to run a simple program in memory after U-boot completes.  After the program terminates, it will return to U-boot console and stay there.  There is no further OS to load.

  I intend to modify U-boot environment so that it will automatically run

 

    sf read DDR3_base my_prog_spi_offset my_prog_len

 

to load the program the program into memory before running it using go command

 

 

  I have a problem creating the simple program.  Firstly, SDK cannot output a bin format file for me to program using U-boot to SPI flash using sf write command.  

  So I tried

 

    mb-objcopy -I elf32-microblazeel -O binary program.elf program.bin

 

  But the bin file is 3GB large because my DDR3 starts at 0xC000_0000 and mb-objcopy converts from 0x0000_0000 to 0xC000_0000 + program size.  But the elf will not work anyway because it will overwrite the interrupt vectors starting at 0x0.

 

 

  Can anyone advise how to configure SDK to create a program for this use?

 

BTW, here are my other findings that restrict my options

  1. Impact promgen does not seem to program u-boot-s.elf correctly when u-boot-s.elf is added as data file during mcs file creation.  I have to xmd download u-boot.elf onto FPGA, then use the running u-boot to program SPF flash.  I found that if I use impact to create the MCS file, the reloc magic is missing, then  FS-boot will report error.  So I probably cannot use Impact to program my simple program.elf.

 

Regards,

 

Neo

0 Kudos
1 Solution

Accepted Solutions
Scholar stephenm
Scholar
15,846 Views
Registered: ‎05-06-2012

Re: How to create C application that can run by U-boot?

Jump to solution

The bin file is huge cause the bin will pad the jump between the vector and the text section with 0s. If you have your DDR at 0x80000000, then there will be alot of padding resulting in a huge file.

 

To workaround this, you can use the objcopy to create two bin files; one for the vector, the other for all the other sections:

mb-objcopy -O binary -j .vectors.reset -j .vectors.sw_exception -j .vectors.interrupt -j .vectors.hw_exception user_application.elf vector_section.bin

mb-objcopy -O binary -R .vectors.reset -R .vectors.sw_exception -R .vectors.interrupt -R .vectors.hw_exception user_application.elf rest_section.bin

 

Then you can can merge these two files

 

cat vector_section.bin rest_section.bin > new.bin 

 

 

 

 

3 Replies
Scholar stephenm
Scholar
15,847 Views
Registered: ‎05-06-2012

Re: How to create C application that can run by U-boot?

Jump to solution

The bin file is huge cause the bin will pad the jump between the vector and the text section with 0s. If you have your DDR at 0x80000000, then there will be alot of padding resulting in a huge file.

 

To workaround this, you can use the objcopy to create two bin files; one for the vector, the other for all the other sections:

mb-objcopy -O binary -j .vectors.reset -j .vectors.sw_exception -j .vectors.interrupt -j .vectors.hw_exception user_application.elf vector_section.bin

mb-objcopy -O binary -R .vectors.reset -R .vectors.sw_exception -R .vectors.interrupt -R .vectors.hw_exception user_application.elf rest_section.bin

 

Then you can can merge these two files

 

cat vector_section.bin rest_section.bin > new.bin 

 

 

 

 

Highlighted
Adventurer
Adventurer
8,448 Views
Registered: ‎03-23-2015

Re: How to create C application that can run by U-boot?

Jump to solution

Hi Stephen,

 

  Thanks for the tips.

 

  But how can I create a program without any data/initialization of the vector tables?  Because writing vector tables address will overwrite u-boot's vectors such that u-boot will be messed up after running my program.  I found out by booting u-boot, then DOW my program in XMD.  I can GO the program from u-boot, but u-boot goes crazy after that.  I think it is due to the vectors tables being overwritten.

 

Regards,

 

Neo

0 Kudos
Scholar stephenm
Scholar
8,269 Views
Registered: ‎05-06-2012

Re: How to create C application that can run by U-boot?

Jump to solution

This is what I showed in the previous post. The -R will remove the sections. You can use this

0 Kudos