- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Loading an image (picture) file with a software applicatio n in SDK
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
12-21-2011 04:26 PM
I have a software application that uses an image file (picture) which is currently in the src directory of my project in SDK. I'm trying to load the picture to a specific section of DDR memory during FPGA programming along with my application, then access it later during software runtime via C pointers. From what I gather this can be done with the linker script, but I'm having trouble determining exactly how to do it inside SDK. I can create a new memory section within the DDR address range, but how do I specify that I want to load the file to this memory?
Thanks in advance.
Re: Loading an image (picture) file with a software applicatio n in SDK
[ Edited ]
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
12-22-2011 08:30 AM - edited 12-22-2011 08:31 AM
c,
The design has to be running to read and write the DDR memory. So, it isn't going to be able to load it to this memory in the same way you load the bitstream Instead, you will have to bring up the entire design, and then have the design "get" the file to be processed. How you do that is up to you. The design could request the data over a serial port, from a multi-gigabit transceiver, or use the LWIP ethernet interface. Depends on what logic and interfaces you have on your board. A bit clunky, but would work, is to put the image in the same flash memory after the configuration file (if it will fit). Then you need a way to reade the picture out of the flash, and place it in the DDR memory...
Principal Engineer
Xilinx San Jose
Re: Loading an image (picture) file with a software applicatio n in SDK
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
12-23-2011 10:24 AM
Make sure you adjust the linker script in the SDK to run your program from external memory, otherwise elfcheck will fail.
There may be a more elegant way to do this automatically using a Makefile and the linker.
EM Photonics, Inc.
Re: Loading an image (picture) file with a software applicatio n in SDK
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
12-26-2011 10:38 AM
Thanks for both of the replies.
I considered both methods, and was originally using the script version to convert the image to a char array. I didn't really like that method, mainly because if I wanted to open the array file for any reason, it bogged down SDK to where it was unusable. I did find another method to get the image data into DDR. It was a little convoluted, so I'll describe it here in case anyone else wants the information.
Using mb-objcopy (MicroBlaze version of the objcopy utility), I converted the image (lena.pnm) to an object file (lena.o). The command I used follows:
mb-objcopy -I binary -O elf32-microblazele -B microblaze lena.pnm lena.o
I used elf32-microblazele (as opposed to elf32-microblaze) so the object file would be compatible with the little endian AXI bus. I linked the object file into the software application in SDK which effectively embedded the data into the elf file, and my linker script wrote the elf sections to the DDR. The data then was accessible using the variables _binary_lena_pnm_start (starting address of the data), _binary_lena_pnm_size (size of the data), and _binary_lena_pnm_end (ending address of the data). Casting the start address to a char * allowed me to access the individual characters in the image data.
I don't know if there is any real benefit to the object file method instead of the char array method, save not having to write a script, but I thought it might be useful to have a couple different ways to accomplish the task.











