Skip to content

A very weird Issue in the esp32s3 port caused by recent update #12325

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

Closed
nspsck opened this issue Aug 28, 2023 · 4 comments
Closed

A very weird Issue in the esp32s3 port caused by recent update #12325

nspsck opened this issue Aug 28, 2023 · 4 comments
Labels

Comments

@nspsck
Copy link
Contributor

nspsck commented Aug 28, 2023

It is very hard to describe what the actual issue is... And I could not locate where the Issue lies.

Basically, if you run the following code 2 times in a row in Thonny

#Code
from micropython import mem_info

mem_info()
b = bytearray(150 * 1024)
mem_info()

#Output
stack: 688 out of 15360
GC: total: 64000, used: 2416, free: 61584, max new split: 8257536
 No. of 1-blocks: 35, 2-blocks: 7, max blk sz: 18, max free sz: 3836
stack: 688 out of 15360
GC: total: 217856, used: 155344, free: 62512, max new split: 8126464
 No. of 1-blocks: 23, 2-blocks: 5, max blk sz: 9600, max free sz: 3839

you will notice, that the first time it goes very fast and the second time it takes a really long time for it to complete. This behavior can be observed on a lot boards using N16R8 module. Like: LOLIN S3, LOLIN S3 Pro, WeAct Studio esp32s3 N16R8, Official ESP32-S3-DevKitM-1.

The same piece of code causes some boards (Lilygo T-Display S3 AMOLED) to hard reset automatically.

For the testing, I always used the native USB.

To build the firmware I used:

make BOARD=ESP32_GENERIC_S3 BOARD_VARIANT=SPIRAM_OCT USER_C_MODULES=#A display driver written in C

Note: I tried simplely delete the line in this file, I also tried to set it to 0.

#define MICROPY_HW_ENABLE_UART_REPL (1)

Neither approach had any effects on this Issue.

@nspsck nspsck added the bug label Aug 28, 2023
@projectgus
Copy link
Contributor

Hi @nspsck ,

This sounds like it might be the same as this issue - thonny/thonny#2886

However, just in case, there are some recent esp32 memory allocation changes as described in https://github.com/orgs/micropython/discussions/12316 . This shouldn't cause more than a very short delay (much less than a second) between iterations, though. (Previously, the whole PSRAM could fill up before any garbage collection pass - meaning no garbage collection pauses would happen until it filled up and then one long garbage collection pause would happen. Now, running code like this will trigger frequent smaller and much shorter garbage collection pauses.)

@nspsck
Copy link
Contributor Author

nspsck commented Aug 30, 2023

Hi projectgus,

This sounds like it might be the same as this issue - thonny/thonny#2886

Thank you for your response. I can confirm (well I hope...) that this is actually the case. As both using screen and the repl in thonny with the following code causes no issue what so ever.

import machine

b = bytearray(1024 * 100)

machine.soft_reset()

However, just in case, there are some recent esp32 memory allocation changes as described in https://github.com/orgs/micropython/discussions/12316 . This shouldn't cause more than a very short delay (much less than a second) between iterations, though. (Previously, the whole PSRAM could fill up before any garbage collection pass - meaning no garbage collection pauses would happen until it filled up and then one long garbage collection pause would happen. Now, running code like this will trigger frequent smaller and much shorter garbage collection pauses.)

Would there still be a possibility, that this is a gc related problem, if something like

b = bytearray(1024 * 100)
b = bytearray(1024 * 100)
b = bytearray(1024 * 100)
b = bytearray(1024 * 100)
b = bytearray(1024 * 100)
b = bytearray(1024 * 100)
b = bytearray(1024 * 100)
b = bytearray(1024 * 100)
b = bytearray(1024 * 100)
b = bytearray(1024 * 100)
b = bytearray(1024 * 100)
b = bytearray(1024 * 100)
b = bytearray(1024 * 100)
b = bytearray(1024 * 100)
b = bytearray(1024 * 100)

runs perfectly? The code is "at one go".

@peterhinch
Copy link
Contributor

I tested this using mpremote with the latest firmware and couldn't replicate the problem. It does look like Thonny is the culprit.

MicroPython v1.20.0-396-g1dedb65e6 on 2023-08-24; FeatherS3 with ESP32-S3
Type "help()" for more information.
>>> 
paste mode; Ctrl-C to cancel, Ctrl-D to finish
=== from micropython import mem_info
=== 
=== mem_info()
=== b = bytearray(150 * 1024)
=== mem_info()
=== 
stack: 672 out of 15360
GC: total: 64000, used: 1840, free: 62160, max new split: 8257536
 No. of 1-blocks: 23, 2-blocks: 3, max blk sz: 18, max free sz: 3836
stack: 672 out of 15360
GC: total: 217856, used: 154960, free: 62896, max new split: 8126464
 No. of 1-blocks: 13, 2-blocks: 3, max blk sz: 9600, max free sz: 3836
>>> 

@nspsck
Copy link
Contributor Author

nspsck commented Aug 30, 2023

I tested this using mpremote with the latest firmware and couldn't replicate the problem. It does look like Thonny is the culprit.

Ye, Thonny is most likely the cause for this problem. Time to bothering them!

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

No branches or pull requests

3 participants