Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ODS2: Does not calculate interleave correctly #24

Open
al20878 opened this issue Nov 25, 2024 · 0 comments
Open

ODS2: Does not calculate interleave correctly #24

al20878 opened this issue Nov 25, 2024 · 0 comments

Comments

@al20878
Copy link
Contributor

al20878 commented Nov 25, 2024

The formula in phyvirt.c for the maplbn() function is wrong:

    if( s >= dp->sectors / dp->interleave )
        s = (s * dp->interleave) - (dp->sectors -1);  /* <<< BUG HERE! */
    else
        s = s * dp->interleave;

    s = (s + (dp->skew * c)) % dp->sectors;

First, since the last line shown in the snippet above operates with the reminders modulo dp->sectors, then subtracting dp->sectors -1 on the line marked "BUG HERE" is the same as just adding 1. Thus, the formula on that line can be simplified as:

s = (s * dp->interleave) +1;

That, however, is a problem for dp->sectors not being a multiple of dp->interleave (given, DEC did not use those values in practice, so it may not "trigger" the bug, but still). An example: if sectors:=10 and interleave:=3, the mapping sequence of sectors, which the code calculates, yields:

0, 1, 2, 3, 4, 5, 6, 7, 8, 9 -> 0, 3, 6, 0, 3, 6, 9, 2, 5, 8

The problem is quite obvious -- there cannot be any repeated sectors! Instead, the correct output sector sequence in these conditions would be:

0, 3, 6, 9, 2, 5, 8, 1, 4, 7

The correct interleave formula can be found in the lbn2pbn tool, which was added recently to the simtools/converters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant