Skip to content
This repository has been archived by the owner on Oct 1, 2021. It is now read-only.

Merge OTP for factory jig information #62

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix coding style
proficnc committed Jul 21, 2016
commit 6a99e0251b27ba579fb10ad551afde343f207778
37 changes: 22 additions & 15 deletions src/modules/systemlib/otp.c
Original file line number Diff line number Diff line change
@@ -76,29 +76,36 @@ int write_otp(uint8_t id_type, uint32_t vid, uint32_t pid, char *signature)
int errors = 0;

// descriptor
if (F_write_byte(ADDR_OTP_START, 'P'))
if (F_write_byte(ADDR_OTP_START, 'P')){
errors++;
}
// write the 'P' from PX4. to first byte in OTP
if (F_write_byte(ADDR_OTP_START + 1, 'X'))
errors++; // write the 'P' from PX4. to first byte in OTP
if (F_write_byte(ADDR_OTP_START + 2, '4'))
errors++;
if (F_write_byte(ADDR_OTP_START + 3, '\0'))
errors++;
if (F_write_byte(ADDR_OTP_START + 1, 'X')){
errors++; // write the 'P' from PX4. to first byte in OTP
}
if (F_write_byte(ADDR_OTP_START + 2, '4')){
errors++;
}
if (F_write_byte(ADDR_OTP_START + 3, '\0')){
errors++;
}
//id_type
if (F_write_byte(ADDR_OTP_START + 4, id_type))
errors++;
if (F_write_byte(ADDR_OTP_START + 4, id_type)){
}
// vid and pid are 4 bytes each
if (F_write_word(ADDR_OTP_START + 5, vid))
errors++;
if (F_write_word(ADDR_OTP_START + 9, pid))
errors++;
if (F_write_word(ADDR_OTP_START + 5, vid)){
errors++;
}
if (F_write_word(ADDR_OTP_START + 9, pid)){
errors++;
}

// leave some 19 bytes of space, and go to the next block...
// then the auth sig starts
for (int i = 0 ; i < 128 ; i++) {
if (F_write_byte(ADDR_OTP_START + 32 + i, signature[i]))
errors++;
if (F_write_byte(ADDR_OTP_START + 32 + i, signature[i])){
errors++;
}
}

return errors;