Generate .bin file from KDS 3.2

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

Generate .bin file from KDS 3.2

跳至解决方案
5,716 次查看
javierhernande1
Contributor IV

Hi,

 

It's possible to generate the .bin file when running 'Build project' in a SDK_2.0 project?

 

To avoid having to do it manually.

 

arm-none-eabi-objcopy -O binary hello_world_frdmk64f.elf hello_world_frdmk64f.bin

 

 

Best regards,

Javier

标签 (1)
1 解答
6 回复数
4,644 次查看
john71
Senior Contributor I

My main program starts at 0x5000 so my linker file is

MEMORY {
  m_interrupts (RX) : ORIGIN = 0x00005000, LENGTH = 0x000001E8
  m_text      (RX) : ORIGIN = 0x00005410, LENGTH = 0x000FABF0
  m_data      (RW) : ORIGIN = 0x1FFF0000, LENGTH = 0x00010000
  m_data_20000000 (RW) : ORIGIN = 0x20000000, LENGTH = 0x00010000
  /*m_cfmprotrom  (RX) : ORIGIN = 0x00000400, LENGTH = 0x00000010*/
}

But a bin file generated at the offset 0x5000 not at 0. Even if I feed the file to a bootloader starting at 0x5000 in the bin file - main program doesn't run after exit from a bootloader.

0 项奖励
4,641 次查看
ErichStyger
Senior Contributor V

That's exepcted, see https://sourceware.org/binutils/docs/binutils/objcopy.html

objcopy can be used to generate a raw binary file by using an output target of ‘binary’ (e.g., use -O binary). When objcopy generates a raw binary file, it will essentially produce a memory dump of the contents of the input object file. All symbols and relocation information will be discarded. The memory dump will start at the load address of the lowest section copied into the output file.

If you indeed want to have a binary starting with address 0, then I recommend using the SRecord tool which allows you to do any kind of manipulation and conversion, see for example https://mcuoneclipse.com/2018/03/07/converting-binary-files-to-intel-hex-format-with-the-srecord-too...

I hope this helps,

Erich

0 项奖励
4,638 次查看
john71
Senior Contributor I

Thank you. I did so. But when I burn the file with a bootloader - the main program doesn't  run. May be I miss something?

I cut out the block 0-4fff that bootloader address space and burn the file starting at 0x5000.

0 项奖励
4,629 次查看
ErichStyger
Senior Contributor V

I guess either your bootloader has a problem or your application has a problem.

If you just look at the bin file you won't see the problem.

You have to kick in the debugger to see what is going on: See for example https://mcuoneclipse.com/2020/11/03/debugging-bootloader-and-application-with-one-debug-session/

 

I hope this helps,

Erich

0 项奖励
4,816 次查看
BlackNight
NXP Employee
NXP Employee
4,815 次查看
javierhernande1
Contributor IV

Hi Erich,

Works as a charm. Very useful articles, thanks very much!

Best regards,

Javier

0 项奖励