Intel HEX firmware
The microcontroller manufacturer sent the firmware as firmware.hex (Intel HEX). Format: each line is :LLAAAATT<ma'lumot>CC — LL is the length, AAAA is the address, TT is the type (00 data, 01 end of file, 04 the upper 16 bits of the extended linear address, 05 start address), and CC is the checksum (the sum of all bytes must be 0 mod 256).
In the firmware image, the production secret is stored after the MFG_SECRET: marker: the flag (ending with \0) is XOR-ed with a single-byte key. The key is written in the image itself, in a configuration string (xor_key=...). During transfer the file was slightly corrupted: the checksum of one record is wrong.
Convert the hex to binary (placing the addresses correctly) and reveal the secret. Flag format: BAYROQ{...} (the last 16 characters are lowercase hexadecimal digits).