Solved - import femtosip - MemoryError: - Too large modul?

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
robert1968
Posts: 4
Joined: Sun Oct 01, 2017 4:20 pm

Solved - import femtosip - MemoryError: - Too large modul?

Post by robert1968 » Sun Jun 13, 2021 2:47 pm

Update: Resolved by using "mpy-cross" compiler. This compile the "too large" module to be imported.

Hi,

I tried to import an excellent custom SIP - VOIP module. https://github.com/astoeckel/femtosip
(This great SIP protocol implementation allows ringing voip line. I need this for to make a remote belldoor ring with ESP8266.)

In spite of its name implies "femto" (very small) - it seems still too big for ESP8266.
Unfortunately i have this error message:

Code: Select all

>>> import femtosip                                                                                             
Traceback (most recent call last):                                                                              
  File "<stdin>", line 1, in <module>                                                                           
MemoryError:                                                                                                    
>>>                 
I assume this is because this microcontroller has too small memory.
My ESP01 has 1Mbyte only.
Then i tried with Wemos D1. ESP12 4MB Flash - but same error message.
As i understand ESP01 and ESP12 RAM size is the same...

>>> micropython.mem_info(1)
stack: 2128 out of 8192
GC: total: 37952, used: 3936, free: 34016
No. of 1-blocks: 24, 2-blocks: 12, max blk sz: 21, max free sz: 506
GC memory layout; from 3ffeee80:
00000: h=hhhhhMh=Dh=hDBBBhB=hhhB=h===h===h==h=================h=======h
00400: =======h=h==Bh=B..hh=h=.......h=hBMD.h..h=......h=..............
00800: .............h=======h=====.....................................
00c00: ...............................h=======.........................
01000: ...............................................................h
01400: ==========.....h=======.........................................
01800: ................................................................
01c00: ............h=======............................................
02000: ..h=======......................................................
02400: ...........................................h=======.............
(5 lines all free)
03c00: ......h=======..................................................
04000: ................................................................
04400: ............................h====================...............
04800: ...........................................................h====
04c00: ===.............................................................
05000: ...h=======.....................................................
05400: ................................................................
05800: ..........................h=======..............................
05c00: ................................................................
06000: ......................h=======..................................
(7 lines all free)
08000: ........................h=======................................
08400: ................................................................
08800: ............................h=======............................
08c00: ................................................................
09000: .................................................h=======.......
09400: ....

Then i tried to compile this module to .mpy as i read it will provide frozen code.

Code: Select all

./micropython-master/mpy-cross/mpy-cross -mcache-lookup-bc femtosip.py 
Unfortunately this rose another error:

Code: Select all

>>> import femtosip
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: incompatible .mpy file
>>> 

Any advice how to resolve memory issue? femtoSIP module maker advised to try to reduce module size with eliminate some libraries,
but im not good enought python programmer to do.

Or any advise to resolve mpy compatibility issue?

best regards,
Robert.
Last edited by robert1968 on Sun Jun 13, 2021 4:51 pm, edited 3 times in total.

robert1968
Posts: 4
Joined: Sun Oct 01, 2017 4:20 pm

Re: import femtosip - MemoryError: - Too large modul?

Post by robert1968 » Sun Jun 13, 2021 4:34 pm

Compile issue resolved.
("-mcache-lookup-bc " options was not needed when compile.)

Lesson learnt:
If your module too big when import, and you have MemoryError:
then download https://github.com/micropython/micropyt ... /mpy-cross
cd to mpy-cross
make
and compile your py module to mpy.

Code: Select all

./micropython-master/mpy-cross/mpy-cross femtosip.py 
upload your module. e.g.: femtosip.mpy to ESP.
delete femtosip.py from ESP.
and import yr module e.g.: import femtosip

there was no complain from ESP.
ESP imported the SIP module without memory error.

So please close the issue.
FYI. still have issue with the module, but asked the author help to resolve it.
Anyone interested pls see here: https://github.com/astoeckel/femtosip/issues/3

best regards,
Robert

Post Reply