Open JoeToeniskoetter opened 3 years ago
Hi @JoeToeniskoetter !
Can you share more details about your issue?
Hi @ferrarimarco , sure thing.
Here is the error message I receive when attempting to run the example code
Traceback (most recent call last):
File "main.py", line 14, in <module>
File "third_party/rsa/__init__.py", line 1, in <module>
MemoryError: memory allocation failed, allocating 439 bytes
line 14 in my main.py is importing the rsa module
from third_party import rsa
Seems to me that the rsa modules are just too large for the ESP8266 to handle. Running esptool's flash_id returns the following information about my device.
Detecting chip type... ESP8266
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
Manufacturer: 20
Device: 4016
Detected flash size: 4MB
Somethings I've tried so far:
gc.collect()
after each import statementThanks!
@gguuss: Do you have more info to share about possible workarounds? IIRC, the rsa
module is needed to generate the key pair for IoT core.
I'm unsure how we could shrink RSA but you could potentially use the ES JWT by embedding something like the Arduino JWT library and then wrapping the C library. Adding @C4 in case he's investigated a solution that fits the ESP8266.
Also, make sure that you're making full use of the flash, it's possible the 8266 is being partitioned with an OTA option.
Thanks @gguuss ! I will try making use of the full flash size. Do you know how to specify partitions sizes like that when flashing the esp8266?
Try to compile the modules into byte code (.mpy) and then import them. This saves memory. Also a step further is to byte freeze the modules into the micropython .bin, but that requires compiling the whole micropython bin. The first option is more accessible.
Thank you for your work on this library. I tried to port this over to a generic ESP8266 with 4m of flash but am hitting memory errors. Is it possible to make this compatible with the ESP8266 module?
Thanks