How can I fill an S-record with two byte values starting on even address boundaries?

时光总嘲笑我的痴心妄想 提交于 2019-12-10 14:20:32

问题


When I compile my code I eventually get Motorola S records (a.mot) with gaps (the whole address range is not covered by code and data).

I want to fill those gaps with the pattern 0x01 0x80. However, it is important that all of the two-byte pairs must start at even addresses. 0x0180 is an opcode from my micro that I want to be executed if the PC reaches an address of unused flash area.

Before you start answering I'd like to tell you that -repeat-data in srec_cat has an issue:

  • Given two sections e.g. C and D put one after another (D after C) in address space.
  • Given that last byte of section C ends on address 0x76 and first byte of section D is on address 0x78. In other words there is 1 byte long gap at address 0x77 between them.

Under such conditions, if I use -repeat-data 0x01 0x80 option, srec cat will fill that one byte with 0x01 and start filling following gap from 0x80.

I do not know sizes of those sections because linker handles it.


回答1:


Use srec_cat to create a file covering your required address range filled entirely with the 0x01 0x80 sequence aligned as required.

Then use srec_cat with the -multiple and −disable-sequence-warning options to "merge" the "filler" file with your application image file. You should specify the filler file as the first file so that it is overwritten by the application data specified second.

It will issue many warnings, but it should work.




回答2:


I would write a simple parser in Windows working like this:

  • The program creates a new s-record file based on the one you got from the compiler.
  • Loop through the generated file and read two s-record lines at a time.
  • If the line is an information line, S0, S9, S5 etc, just write it to the new file.
  • If line 1 has an address + size smaller than the address on line 2, you have found a gap. (address1 + size1) < address2.
  • Write line 1 to the new file.
  • If you found a gap, write a line with your gap constants S1xx01800180 and so on. Calculate the checksum as you go.
  • Write line 2 to the new file.


来源:https://stackoverflow.com/questions/7569253/how-can-i-fill-an-s-record-with-two-byte-values-starting-on-even-address-boundar

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!