如何使用 srec_cat 插入两个常量?

How to insert two constants using srec_cat?

我有 srec_cat 的以下脚本。我的目标是将两个常量插入 .srec 文件中的已知位置:

srcfile.srec
# carve a hole for and insert crc byte count
-exclude 0x43c8 0x43cc
-generate 0x43c8 0x43cc -constant-l-e 0x8e2c 4
# carve a hole for and insert crc expected value
-exclude 0x43cc 0x43d0
-generate 0x43cc 0x43d0 -constant-l-e 0x194fa71a 4
# output into new file
-o dstfile.srec

如果我注释掉任何一半,脚本就可以正常运行。但是两者都在场,我收到消息:

srec_cat: generate repeat data: multiple 0x000043CC values (previous = 0x00, this one = 0x1A)

我可以写出一个中间文件并对其进行处理以插入第二个常量,但这似乎有点笨拙。把我从这样的黑客中拯救出来! :)

我认为您需要括号 man srec_examples:

Filtering After Joining
There are times when you want to join two sets of data together, and then apply a filter to the joined result. To do this you use parentheses.

srec_cat                                                  \
    '('                                                   \
        infile -exclude 0xFFF0 0x10000                      \
        -generate 0xFFF0 0xFFF8 -repeat‐string 'Bananas ' \
    ')'                                                   \
    -b‐e‐length 0xFFF8 4                                  \
    -b‐e‐checksum‐neg 0xFFFC 4 4                          \
    -o outfile

The above example command catenates an input file (with the generated data area excluded) with a constant string. This catenated input is then filtered to add a 4‐byte length, and a 4‐byte checksum.

你的情况:

srec_cat '(' srcfile.srec -exclude 0x43c8 0x43cc -generate 0x43c8 0x43cc -l-e-constant 0x8e2c 4 ')' -exclude 0x43cc 0x43d0 -generate 0x43cc 0x43d0 -l-e-constant 0x194fa71a 4 -o dstfile.srec