I have inherited a legacy project which uses a Texas Instruments microcontroller. The Texas Instruments microcontroller can be upgraded over USB, and there is an i2c line running from the Texas Instruments microcontroller to a header on the board.
This is a legacy product and I can't swap the Texas Instruments microcontroller out for another chip, nor can I change anything else on the board. The hardware must remain intact.
What I can do though is run wires from the i2c header to a separate board, and I can do whatever I want on the other board.
I'm thinking I'll make another board with an Arduino Due on it with the sam3x8e microcontroller, and here are the details of my idea:
- Only use a maximum of 256 kilobytes of the Flash for the firmware (there is 512 kB available)
- When I want to perform a firmware upgrade, get the Texas Instruments microcontroller to send the binary of the new firmware over i2c to the sam3x8e.
- I will separate the sam3x8e Flash memory into two 'banks'. If the first bank is currently in use, then the new firmware gets written to the second bank. If the second bank is currently in use, then the new firmware gets written to the first bank.
- After the new firmware has been fully-transferred over i2c and saved on the opposite bank, I will check the sha256sum to make sure it's not corrupt. If it's corrupt then I won't flip bank.
- When the sam3x8e microcontroller boots up, it will check a boolean flag. If the flag is false, it jumps to bank 0. If it's true, it jumps to bank 1.
I don't mind if I have to write the jump code in assembler. I can write x86_64 assembler already so it won't be a big deal trying to write ARM assembler.
Has anyone else done something like this before?