Code Monkey home page Code Monkey logo

Comments (3)

rs1729 avatar rs1729 commented on September 26, 2024

The RS92-NGP (still flying in the US) might have different calibration data or a new firmware.

from rs.

rs1729 avatar rs1729 commented on September 26, 2024

RS92-NGP calib-data and PTU seems to be xor-obfuscated.
345f60d

from rs.

rs1729 avatar rs1729 commented on September 26, 2024

RS92-NGP

The RS92-SGP has 66 calibration coefficients starting at offset 0x40 (5 bytes each, 1 byte index plus 4 byte float32).
At first glance the RS92-NGP calibration data does not show these calibration values, although the config bytes suggest there are also 0x14A bytes for the coefficients, 5 bytes each.
However the XOR difference of two NGP-config/calib datasets shows the same parts being constant that are constant across RS92-SGP:
xor_diff_ngp
Though XORing NGP and SGP does not immediately reveal a potential XOR mask:
xor_diff_ngp_sgp
It turns out that except for the index and the float32-MSB, the middle bytes are permuted.

The 8x3=24 raw PTU values are also obfuscated. Here there are no constant values to be expected, only the MSB of each int24 should be constant most of the time. Observing a longer recording one can notice that the bytes change along with the (16 bit) frame counter, hence XORing the frame counter and the raw PTU gives data that looks more like 8 int24 values.
From a whole flight all the bytes (more or less) can be reconstructed. This shows that after 16 bytes the mask repeats, i.e. probably again 16 bytes (or 8 16-bit words).
Now a look into the EEPROM data shows, how the mask is generated and how the data is scrambled. Thanks to @pinkavaj for making a disassembler!
https://github.com/pinkavaj/vsdsp_asm
The seed starts at offset 0x24 in the config data, the raw asm function does something like this:

RS/rs92/rs92mod_ngp.c

Lines 365 to 418 in 471e023

static int xor_ptu(gpx_t *gpx) {
int j, k;
ui32_t a, c, tmp;
ui8_t *pcal = gpx->calibytes+0x24;
for (j = 0; j < 8; j++) {
tmp = 0x1d89;
for (k = 0; k < 4; k++) {
a = pcal[j+k] & 0xFF;
c = tmp;
//add(A, C, A);
a = a + c;
c = a;
//shl_add(A, 10, C, A);
a = (a << 10) + c;
c = a;
//shr_xor(A, 6, C, A);
a = (a >> 6) ^ c;
tmp = a;
}
a = tmp;
c = a;
//shl_add(A, 3, C, A);
a = (a << 3) + c;
c = a;
//shr_xor(A, 11, C, A);
a = (a >> 11) ^ c;
c = a;
//shl_add(A, 15, C, A);
a = (a << 15) + c;
//y = a & 0xFFFF;
gpx->xptu16[2*j ] = a & 0xFF;
gpx->xptu16[2*j+1] = (a>>8) & 0xFF;
}
return 0;
}

Another interesting observation is the data whitening sequence that RS92-AGP (and RS41) use instead of Manchester coding, this sequence can be found in the RS92-SGP and RS92-NGP as well. But the PTU scrambling of RS92-NGP is probably done for a different reason, it uses Manchester coding anyway.

from rs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.