Hardware AES lock forever

nonagon
Posts: 19
Joined: Thu May 06, 2021 12:56 pm

Hardware AES lock forever

Postby nonagon » Wed May 26, 2021 10:24 am

I'm developing 3 product, two with an ESP32-S2 and one with ESP32.
With the single core MCU (ESP32-S2) I noticed strange behaviuors with an API. It sometimes locks forever at esp_aes_acquire_hardware() function. Same code for ESP32 seems not affected (but I have to check better because sometimes happens after a while)
In the image attached there is the debug stack.
In the last attempt to understand what is happening I removed esp_aes_acquire_hardware() in my code because i realized that API call it internally, but nothing changed, the code works for a while and then it locks random.
In one firmware locked in the aes crypt function it returned to life after a Wifi event, as you can read from my log below.
I think is a problem of hardware mutex or somethings like this, I'm investigating my code with no success.
With disabling AES Hardware Acceleration it seems do not happen.
Please check the image attached for debug stack.
I'm developing with Platformio and visual studio code with idf 3.2.0+sha.56f9c60
Thanks in advice, have a nice day.

Code: Select all

[000029.520] COM          [Tx][R0] 0001 to ffff    INTERFACE          SET  - 3 bytes
[000029.520] COM          Interface Tx Crypto Hash: 4de40778
[000029.520] CRYPTO      Padded encryption, old len:26, new len: 32  <----------- Dead here
W (312539) wifi:inactive timer: now=129c6757 last_rx_time=9e7b83 diff=49b1d, aid[1]8c:eb:c6:ec:07:09 leave<---- Returned to life after 10 minutes
I (312539) wifi:station: 8c:eb:c6:ec:07:09 leave, AID = 1, bss_flags is 134243, bss:0x3fffb99c
I (312546) wifi:new:<5,0>, old:<5,1>, ap:<5,1>, sta:<255,255>, prof:5
[000623.060] COM          0 Wifi Devices Connected <----- Here my code (an infinite loop in main) restart to work
[000624.500] COM          TCP sent 41 bytes to 192.168.87.2
[000624.500] COM          Raw Tx of 32 bytes (Serial Nibble, data dim 26)
Attachments
Immagine.png
Immagine.png (464.6 KiB) Viewed 3126 times

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: Hardware AES lock forever

Postby ESP_Angus » Fri May 28, 2021 12:11 am

Hi nonagon,

Thanks for letting us know about this. I don't think we've seen reports of anything like this before, so it's possible this is memory corruption in your firmware (that corrupts memory used by the hardware encryption lock), or of course possible that this is a bug in ESP-IDF.
nonagon wrote:
Wed May 26, 2021 10:24 am
I'm developing with Platformio and visual studio code with idf 3.2.0+sha.56f9c60
Could you double check these versions please? ESP32-S2 support was only added to ESP-IDF in v4.2, and commit 56f9c60 is not an ESP-IDF commit hash. If these are platform.io versions, please try to find out what the underlying ESP-IDF version is.

Angus

nonagon
Posts: 19
Joined: Thu May 06, 2021 12:56 pm

Re: Hardware AES lock forever

Postby nonagon » Fri May 28, 2021 3:27 pm

Hello,
thanks for the reply, of course it can be a memory corruption, some hidden bugs are possible.
I will update this thread when I have some data or I can reproduce it, I disabled AES and SHA acceleration to go forward with the work and the firmware never lock there.

I can't figure where to get framework version, I have a build defined variable
IDF_VER = 3.40200.210118
can it help to get the current framework version?

Who is online

Users browsing this forum: No registered users and 104 guests