1

Because I have to use a third-party bootloader which cannot handle varying lengths of lines in an SREC file, I need a way to instrument objcopy to create a SREC file, where every S1 line has the same lengths (if no info from ELF file is provided, it should be filled with FF).

We can assume that the address increments are consistent, so we do not jump higher in addresses than our specified line length. So we do not need to create in-between lines with all FF e.g.

I found out about --srec-len but this only sets the maximum length size.
I would need something that sets a fixed length size, is there something I can use?

A possible solution would be also to transform the earlier generated SREC file from objcopy with a (third-party) tool

RoQuOTriX
  • 2,871
  • 14
  • 25
  • 1
    Since you've tagged it [c] and [c++], it's worth mentioning that you could create your own tool. It sounds like a reasonably simple task to convert an SREC file with varying lengths into an SREC file with fixed lengths. – user253751 Dec 04 '19 at 17:31
  • 1
    @user253751 I did it already "by hand" and I thought about writing a small python script and if until next week I find now better solution, I am going to do this. But I thougt maybe there are possible other users who came across the same problem – RoQuOTriX Dec 04 '19 at 17:36
  • 2
    If you come from automotive world you can use the Vector HexView or WindRiver ddump as an alternative 3rd party, both can be used to generate SREC with fixed length. – 0x6261627564 Dec 04 '19 at 20:45
  • Probably worth seeing if there's some combination of options to srec_cat which could do this, either by itself or with modifications to fill out the end of a line. Going through an intermediate flat binary stage could also be an option - start with a block of "erased", `dd` a partial binary over it, re-encode to hex. – Chris Stratton Dec 04 '19 at 20:50
  • 1
    Writing such a program yourself is indeed not rocket science. Read the file and write a new one simultaneously. Store all data in RAM until you have enough to write a fixed length to the new file. Recalculate address and checksum. Repeat until done. Leave S0 and S9 as they were. Couple of hours of work, at most. – Lundin Dec 05 '19 at 08:33

1 Answers1

0

You can try the srec_cat utility to do this. Following is an example command.

"srec_cat long.srec −o short.s19 −line-length=46"

Ummer K K
  • 9
  • 4