Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

memory allocation failed wiznet5k
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

memory allocation failed wiznet5k

by ArdeaSolutionsBelgium on Mon Aug 03, 2020 2:00 pm

When i try to use the wiznet5k on my feather M0 i get the following error

File "code.py", line 5, in <module>
MemoryError: memory allocation failed, allocating 238 byte

5: from adafruit_wiznet5k.adafruit_wiznet5k import WIZNET5K

for the rest i just copied the webclient example. (https://github.com/adafruit/Adafruit_Ci ... pletest.py)
I also copied adafruit-circuitpython-feather_m0_express-en_US-5.3.1.uf2 and update-bootloader-feather_m0_express-v3.10.0.uf2 to the FEATHERBOOT
in the subdir lib i copied adafruit_requests.mpy and subdir adafruit_wiznet5k with all included files. Ofcourse i used the files from the corresponding python version ;)

any suggestions what can be wrong ?

wkr Stefan

ArdeaSolutionsBelgium
 
Posts: 10
Joined: Mon Aug 03, 2020 12:56 pm

Re: memory allocation failed wiznet5k

by dherrada on Mon Aug 03, 2020 2:04 pm

Are you using the .py or the .mpy version?

dherrada
 
Posts: 99
Joined: Thu Jan 04, 2018 4:59 pm

Re: memory allocation failed wiznet5k

by ardeasolutions on Mon Aug 03, 2020 2:44 pm

dherrada wrote:Are you using the .py or the .mpy version?


i'm using the mpy version.
Do i have to use the .py ?

ardeasolutions
 
Posts: 3
Joined: Mon Aug 03, 2020 2:43 pm

Re: memory allocation failed wiznet5k

by ArdeaSolutionsBelgium on Mon Aug 03, 2020 4:08 pm

I changed the files with the .py version,
After no succes i changed again to the .mpy files.

Strange, now i don't get the previous error again, now it's say's OSError: [Errno 5] Input/output error

and it's pointing to the line 5 again
5: from adafruit_wiznet5k.adafruit_wiznet5k import WIZNET5K

ArdeaSolutionsBelgium
 
Posts: 10
Joined: Mon Aug 03, 2020 12:56 pm

Re: memory allocation failed wiznet5k

by ArdeaSolutionsBelgium on Mon Aug 03, 2020 4:59 pm

When i delete the lib subdir and copy the lib files again,
the error "memory allocation failed" is back ?

I'm just trying to run the example, i'm not running so self written stuff.
I don't understand what i'm doing wrong.

ArdeaSolutionsBelgium
 
Posts: 10
Joined: Mon Aug 03, 2020 12:56 pm

Re: memory allocation failed wiznet5k

by dherrada on Tue Aug 04, 2020 11:50 am

So the .mpy will take up less memory. If you're already using that, then you may simply be out of memory. Later today, I can try putting it on my M0 express, but it would not surprise me if it simply doesn't have enough memory to handle it as I know wiznet5k is one of the larger libraries.

dherrada
 
Posts: 99
Joined: Thu Jan 04, 2018 4:59 pm

Re: memory allocation failed wiznet5k

by ardeasolutions on Tue Aug 04, 2020 12:16 pm

can we expand the memory ?
is there an other feather that supports micropython with a LOT more memory ?
My project alone is already 1500 lines of python code :(

wkr,
Stefan

ardeasolutions
 
Posts: 3
Joined: Mon Aug 03, 2020 2:43 pm

Re: memory allocation failed wiznet5k

by dherrada on Tue Aug 04, 2020 3:24 pm

Yeah, the Feather M4 has 192KB of RAM, whereas the Feather M0 and Feather M0 Express both only have 32KB. If you need even more than 192KB, the PyPortals all use the ATSAMD51J20, which has 256KB of RAM, although they're not in the Feather form-factor.

dherrada
 
Posts: 99
Joined: Thu Jan 04, 2018 4:59 pm

Re: memory allocation failed wiznet5k

by ardeasolutions on Tue Aug 04, 2020 4:33 pm

Can you give me an idea how many lines of python code i can apply when i'm using the M4 feather version ?
Do the lines of code in the lib files also count ? or is this managed somewhere else in the chip ?

can i also change my program to .mpy to make it more compact ?

How easy can we redirect the pinset of the processor so we can add an external memory ?
if so where and how can we reconfigure this ?

wkr
Stefan

ardeasolutions
 
Posts: 3
Joined: Mon Aug 03, 2020 2:43 pm

Re: memory allocation failed wiznet5k

by dherrada on Wed Aug 05, 2020 9:42 am

Can you give me an idea how many lines of python code i can apply when i'm using the M4 feather version ?

I'm not sure but I've only ever run out of memory when doing complicated stuff involving graphics.

Do the lines of code in the lib files also count ?

Yep, they do. One way you can lessen the amount of memory they take is only importing the specific functions you need, so instead of
Code: Select all | TOGGLE FULL SIZE
import foo
, you can do
Code: Select all | TOGGLE FULL SIZE
from foo import bar
. I see you're already doing that to an extent, but you may be able to get more specific in your imports. Another thing I've done occasionally is edit the library I'm importing and remove the dependencies I won't be using or just copy the functions I need across to my code.py. Now, I've only done this for simpler projects, but it's also worth looking in to.

can i also change my program to .mpy to make it more compact ?

I think you can, but I honestly couldn't say for sure. Fortunately, it's not that hard to do. If you clone circuitpython (https://github.com/adafruit/circuitpython), and follow the instructions in the mpy-cross directory, you can try turning your code into a .mpy.

How easy can we redirect the pinset of the processor so we can add an external memory ?

I think you'll find that 192KB will be more than enough. It's actually pretty hard to run out of that much memory, although it does seem like you've got a pretty good If it's not, then you might be able to try something like this (https://www.adafruit.com/product/4677) which has 8MB and uses SPI. However, I'm not sure if there are any tutorials for doing that with CircuitPython, and looking at the product description, it seems like it could be a reasonably involved process.

dherrada
 
Posts: 99
Joined: Thu Jan 04, 2018 4:59 pm

Please be positive and constructive with your questions and comments.