create binary file for uboot to start M4 from SDcard

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

create binary file for uboot to start M4 from SDcard

跳至解决方案
4,442 次查看
stefansinger
NXP Employee
NXP Employee

Hi, we use the Mentor CodeSourcery Sourcery_CodeBench_Lite_for_ARM_EABI Compiler to develop an applications for the M4 core of Vybrid. Everything works fine with the debugger. For a standalone operation we do now want to put the application just onto the SD card and let uboot start it. We have done this before. I need now to convert the ELF file into a .bin file, which uboot can load.

I am trying to do this with arm-eabi-objcopy and also the arm-none-eabi-objcopy. I run the following steps in a batch file (therefore the %1):

arm-none-eabi-objcopy --strip-debug -R.devdata %1 %1.img

arm-none-eabi-objcopy -O srec %1.img %1.srec           

arm-none-eabi-objcopy -O binary %1.img %1.bin 

all files look reasonable, however the created .bin file is huge ! I have also tried to do this directly from the elf file with -S -O. All attempts lead to some huge file. I assume this has to do with the fact, that the project uses small sections of memory accross all the RAMs on vybrid and that the objdump seems to create a contiguos memory file ?

What is the solution ?

1 解答
3,393 次查看
timesyssupport
Senior Contributor II

Hello Stefan,

Are you able to upload the elf file you have generated? As per Bill's advice, do you have a contiguous elf file? You could try using mainline u-boot (which has Vybrid support) in case the issue is with u-boot 2011.12.

Regards,

Timesys Support

在原帖中查看解决方案

0 项奖励
回复
8 回复数
3,393 次查看
billpringlemeir
Contributor V

What does objdump -h %1 have to say?  If you have setup the images with huge holes, then the binary image will be large.  You can objcopy the sections individually and load each of them separately.  You will call multiple fatload commands.  One to load text and another to load data.  This actually makes sense as the M4 has a separate code/data space, so most likely the ELF has a large hole which the binary will fill with empty data.

Alternatively, you can only use BSS data and then write some start-up which clears all of the data section.  People who do this typically have a bunch of init_module() functions which initialize things, including setting some static/global variables to non-zero constants.  Then there is no data binary that needs generation, which might be the better case if you are going to move away from u-boot for your production system.

Edit: Some of the addresses in the MQX Elf may not work with u-boot.  Remember u-boot is running on the A5 and some addresses are different between the two CPUs.

0 项奖励
回复
3,393 次查看
karina_valencia
NXP Apps Support
NXP Apps Support

timesyssupport please continue with the follow up on this case.

0 项奖励
回复
3,394 次查看
timesyssupport
Senior Contributor II

Hello Stefan,

Are you able to upload the elf file you have generated? As per Bill's advice, do you have a contiguous elf file? You could try using mainline u-boot (which has Vybrid support) in case the issue is with u-boot 2011.12.

Regards,

Timesys Support

0 项奖励
回复
3,393 次查看
stefansinger
NXP Employee
NXP Employee

Are you sure, that fatload supports ELF files on the Vybrid UBOOT ? I tried this now with an ELF file working perfectly in the debugger.

When I try this, the following happens:

>fatload mmc 0:1 0x1F000200 vybrid_amp.elf

>reading vybrid_amp.elf

and than it hangs forever .....

0 项奖励
回复
3,393 次查看
timesyssupport
Senior Contributor II

Hello Stefan,

Allow us some time to investigate; if you have an example elf we can use to test with, that would be much appreciated.

Regards,

Timesys Support

0 项奖励
回复
3,393 次查看
dirkdoerr
Contributor III

My example is exactly what I am doing. But I must admit that I target the A5 core not M4 and everything is loaded to DRAM.

0 项奖励
回复
3,393 次查看
karina_valencia
NXP Apps Support
NXP Apps Support

timesyssupport can you help on this case?

0 项奖励
回复
3,393 次查看
dirkdoerr
Contributor III

Your assumption is right. The bin includes the RAM areas.

But why not using the elf file directly? u-boot supports loading an elf.

You could setup your SDCard to have a FAT filesystem. Then copy the elf to the FAT partition. And finally load it like that:

fatload mmc 0:1 0x85C00000 app.elf; bootelf 0x85C00000

0x85C00000 is just an address within the external RAM.

Of course instead of FAT you could also use ext2 and use the u-boot command ext2load.

u-boot cmds:

U-Boot: Quick reference - Wiki

Regards

   Dirk