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

HW SHA Calculation Error in esp32c3-hal #1607

Closed
AldenClark opened this issue Aug 18, 2023 · 4 comments
Closed

HW SHA Calculation Error in esp32c3-hal #1607

AldenClark opened this issue Aug 18, 2023 · 4 comments
Labels
package:esp-wifi Issues related to the esp-wifi package

Comments

@AldenClark
Copy link

I'm currently working on a project based on the ESP32-C3 platform and utilizing the esp-wifi library. As per the library's requirements, I've added link-arg=-Trom_functions.x to the /.cargo/config.toml file. However, I've encountered an unexpected issue: the Hardware-accelerated SHA (HW SHA) calculation results from the esp32c3-hal library are incorrect after making this modification.

What's puzzling is that when applying the same configuration, specifically link-arg=-Trom_functions.x, to the ESP32-S3 platform, the Hardware-accelerated SHA calculation works as expected without any errors.

To diagnose this, I've also tried using the code provided in the https://github.com/esp-rs/esp-hal/blob/main/esp32c3-hal/examples/sha.rs example, and the issue still persists.

Could you please help me understand why the Hardware-accelerated SHA calculation is encountering errors in ESP32-C3, while ESP32-S3 does not exhibit this issue under the same configuration? Is there something I might be overlooking or not handling correctly in my setup?

@bjoernQ
Copy link
Contributor

bjoernQ commented Aug 18, 2023

Is adding link-arg=-Trom_functions.x to the /.cargo/config.toml file (and adding the dependency) already enough to trigger this problem or is it also needed to initialize esp-wifi or even maybe be connected to WiFi?

If just linking rom_functions.x is enough then that's very surprising since apparently the SHA driver code doesn't use any ROM functions

@AldenClark
Copy link
Author

Only add to config.toml file causes the issue, esp-wifi initialization is not necessary.

@bjoernQ
Copy link
Contributor

bjoernQ commented Aug 18, 2023

Ok this is wild!

I was able to track it down to:

memset = 0x40000354;

This will replace Rust's memset compiler-builtin function with the ROM function. They should do the exact same thing but apparently, they don't. 🤯

Most probably we can remove those things from esp-wifi's rom_functions.x but we need to carefully test things

Still, I wonder how exactly the implementation differ

@jessebraham jessebraham transferred this issue from esp-rs/esp-hal Aug 22, 2023
@bjoernQ bjoernQ transferred this issue from esp-rs/esp-wifi-sys May 27, 2024
@bjoernQ bjoernQ added the package:esp-wifi Issues related to the esp-wifi package label May 27, 2024
@bjoernQ
Copy link
Contributor

bjoernQ commented Jul 15, 2024

I cannot reproduce this issue anymore

@bjoernQ bjoernQ closed this as completed Jul 15, 2024
@github-project-automation github-project-automation bot moved this from Todo to Done in esp-rs Jul 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package:esp-wifi Issues related to the esp-wifi package
Projects
Archived in project
Development

No branches or pull requests

2 participants