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

Speed up and clean up RPS creation #75

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

jerome-pouiller
Copy link
Contributor

The initial goal of this PR was to drop dependency to CRC python module. I have also greatly speed up the generation of the .rps file (11 time faster) and cleaned up the script.

Unix systems expect to retrieve the script interpreter on the first
line. This patch fix siwx917_isp_prepare.py.

Signed-off-by: Jérôme Pouiller <[email protected]>
The "crc" Python package offer implementation for arbitrary CRC.
Unfortunately, this yet another dependency for the Zephyr project. In
addition, this implementation is rather slow (probably mainly because of
the computation of reflected bytes does not use a table).

I have measured computation time with:

    time zsh -c '
        repeat 20;
            python3 siwx917_isp_prepare.py
                --rom_addr 0x08202000 .../zephyr.bin .../zephyr.bin.rps
    '

With current implementation, I get 9.415s.

Then I get 2.540s with common CRC algorithm:

    register = 0;
    for b in b'123456789':
        register ^= b
        for _ in range(8):
            lsb = register & 1;
            register >>= 1
            if lsb:
                # Reflected polynomial: 0xd95eaae5
                register ^= 0xa7557a9b

Finally table based implementation reach 0.820s. 11x faster than the
initial implementation.

Signed-off-by: Jérôme Pouiller <[email protected]>
Try to clearly show the various steps of the image generation.

Signed-off-by: Jérôme Pouiller <[email protected]>
Argparse is able to do various validation on arguments. Let's use this
ability and simplify the main body of the code.

Signed-off-by: Jérôme Pouiller <[email protected]>
'_' in option name are uncommon. '-' are preferred. Also change the name
of --rom_addr in --load-addr so the Zephyr users won't be confused.

Signed-off-by: Jérôme Pouiller <[email protected]>
@jerome-pouiller jerome-pouiller force-pushed the speed-up-rps-creation branch 2 times, most recently from 3eb90b7 to 0b94b1e Compare December 20, 2024 16:10
Zephyr compliance script is sad because this script use ' rather than ".
This patch try to make it happier.

Signed-off-by: Jérôme Pouiller <[email protected]>
Zephyr compliance script still complain about small details in
siwx917_isp_prepare.py. I don't have strong opinions about these changes,
so let's apply the suggestions.

Signed-off-by: Jérôme Pouiller <[email protected]>
Python "crc" package is no more required.

Signed-off-by: Jérôme Pouiller <[email protected]>
Python "crc" package is no more required.

Signed-off-by: Jérôme Pouiller <[email protected]>
@jerome-pouiller jerome-pouiller marked this pull request as ready for review December 20, 2024 16:29
@jerome-pouiller jerome-pouiller requested a review from a team as a code owner December 20, 2024 16:29
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

Successfully merging this pull request may close these issues.

1 participant