rp2040 knockoff memory alloc fail #18126
-
Got an rp2040 clone from aliexpress. Looks identical, in particular the amount of ram is the same for both boards. |
Beta Was this translation helpful? Give feedback.
Replies: 9 comments 14 replies
-
I'd find it rather unlikely — quite unlikely to be precise — that they've cloned the RP2040 chip. |
Beta Was this translation helpful? Give feedback.
-
Ah OK, didn't realise the pico does not use external psram like the esp32s. Same firmware on both boards & curiously the 'MemoryError: memory allocation failed, allocating 157476 bytes' remains if I shrink the .py I'm trying to run down to a ~4 times smaller .mpy My instinct is the genuine pico I've just ordered is gonna arrive here before I get to the bottom of this. |
Beta Was this translation helpful? Give feedback.
-
I do the 19k byte array memory reservation in the first few lines, after that all is sweet on the genuine rp2040 board. But on the knockoff, just a few lines after the reservation, the next variable I declare gives the mem alloc error. Weird, especially considering it still does it when I run the program as a .mpy instead of a .py which uses about a quarter as much ram. |
Beta Was this translation helpful? Give feedback.
-
Happens when I try to read battery voltage with the adc. But knockoff board has the same 200k/100k divider for battery voltage on gpio4 as the genuine & the harmless little adc routine runs OK by itself on both boards so it's not that it's producing crazy high count values. But definitely something in the adc def because the rest of the program runs OK on the knockoff if I skip the adc read.
|
Beta Was this translation helpful? Give feedback.
-
Limited myself to 1 stmt/line & 1 ADC instance Rob
& ran it on the rp2040 knockoff board. Got 491 in m 396 in _getmetrics 347 in _getbatt 362 in _adc MemoryError: memory allocation failed, allocating 120186 bytes (log full, not saved). Not sure what you mean by 'all that's written on the rp2040 chip'? Do you mean the files in flash? |
Beta Was this translation helpful? Give feedback.
-
Got some genuine rp2040s today, they have the same mem alloc problem as the knockoff. So something different about the these latter days boards than the 2-3 year old picos I've been running this code on! |
Beta Was this translation helpful? Give feedback.
-
You're an inspiration Rob! The V3v3 value on the latter boards was stored as a string instead of a float, json is gonna be the death of me one of these days. When I run the _adc function in isolation it returns a more sensible error about not being able to convert a string to an int instead of the red herring mem alloc error I get in the full program. Tnx for the suggestion, I'd still be running around in circles here otherwise. |
Beta Was this translation helpful? Give feedback.
-
Fair point. My problem is scrolling. I already do way too much of it. If I limit myself to 1 stmt/line I'll be doing 2 to 3 times as much. I've tried alternatives like hiving the 'mature' functions off into a separate import but that has issues of its own & no matter how 'mature' I think a function is as soon as I move it to a separate import it needs to be edited which means opening another file. What I really need is a portrait oriented monitor that is about 1.5m long! |
Beta Was this translation helpful? Give feedback.
-
You're probably right. The _adc was originally developed for esp32s where large outliers seem to popup from nowhere & I just moded it for the pico, probably overkill. There's a lot to like about the pico, wish esp32 RTCs kept time as well as the pico. |
Beta Was this translation helpful? Give feedback.
I do not understand theses sentences. Does that tell that the error does not happen in the _adc() function? How is
V3v3
defined? Is it by chance a string? Thenmode*V3v3
would attempt to create a large string.