use RESIZABLE_JSVARS for other boards than linux ? #6994
Replies: 1 comment
-
Posted at 2018-02-06 by @gfwilliams Yes, I think that could work. It's worth a try... However:
Posted at 2018-02-06 by JumJum hmm, we have 2 versions_
Would it be possible to replace static allocated block with malloc allocated block ? My expectations for speed is the same. Espruino supports an option to move all WIFI and BLE memory to psram. I'm pretty sure, they would not do this, if its much slower. Posted at 2018-02-07 by @gfwilliams Ahh, I think really there are 2 options...
About 32 bits - yes, it's bad :) See http://www.espruino.com/Internals for the layout - 32 bits means vars are no longer 16 bytes each, but are 24 (IIRC) - so you now only get 2/3 of the amount of variables in the same RAM :( Posted at 2018-02-07 by JumJum Hmm, for ESP32 I would prefer simple malloc solution. Anyway I'm still confused about the impact of 32bits. BTW is there a limit for variables ? I can see ESPRUINOWIFI has 7135.
and this:
Posted at 2018-02-08 by @gfwilliams Normal JsVarRefs for most boards are 16 bits, so can store up to 65535 variables. But the Resizable vars build can do 4 billion because of 32 bit references (I believe). But adding 32 bit references really pushes the size of a JsVar up, so you don't want to do that. Basically, what you've done is fine - although ultimately I guess you'll want to set jsVarsSize to something else before calling jsvInit? I would do this instead in the second bit though - no point hard-coding numbers where it's not needed:
Posted at 2018-02-08 by JumJum Hardcoded value was for easy testing only :) Hmmm, I could move the functionality to assign jsVarSize into function main of jshardware.c. What would you prefer ? Or is there another(better) option, which did not come to my mind ? Posted at 2018-02-08 by Wilberforce My be a bit hacky.... and need a suitable comment. Set the jsvars to 0 in the board py to mean allocated at runtime? And then fix anything that depends on that? Posted at 2018-02-08 by DrAzzy If you've got 4mb of PSRAM to play with, why wouldn't one make the whole 64K jsvars permitted by the 16-bit addressing available? Posted at 2018-02-09 by Wilberforce
Sure - for the psram case - @jumjum was looking to have one firmware that could be used on both psram and the non-psram boards as I understand it. Posted at 2018-02-09 by JumJum @wilberforce, Posted at 2018-02-09 by @gfwilliams
That sounds like the best idea, and wouldn't require any board-specific defines in Posted at 2018-02-09 by JumJum Could we move definition for jsVarBlocks, jsVarsSize and jsVars into jsvars.h ? As always, if you have any better idea... Posted at 2018-02-09 by JumJum I got it running this way. ESP32.py
jsvar.h
jsvar.c
build_platform_config.py
last not least in main.c
Posted at 2018-02-09 by @gfwilliams That looks good - I guess you could change If someone's interested in it, there's the possibility of using this on some STM32 devices - for instance the original Espruino board has a chip that's only supposed to have 48kB of RAM, but which actually has 64kB (I believe). I just can't be sure every chip has it so I can't enable it in firmware. Potentially some code could check for the RAM at boot and rearrange the stack to use what was available - although it's more difficult as Espruino for STM32 doesn't use malloc :) Posted at 2018-02-09 by DrAzzy So a build that would be like the bigram builds I used to do (at some point, the toolchain stopped working, and then I was forced to rebuild the system by amazon and forgot how to set it up anyway), only it would auto-detect whether that RAM was actually there? That would be really cool An esp32 build that had 64K jsvars would be pretty cool. Would finally be hard to run out of ram on espruino. Posted at 2018-02-09 by JumJum @gfwilliams, Posted at 2018-02-09 by @gfwilliams @jumjum I can do that, but I've got a bunch of other stuff on my list at the moment. Maybe let me know when it makes it into ESP-IDF and I can do the changes then?
Yep, that's the idea. @drazzy maybe you know something about this: https://github.com/espressif/ESP8266_MP3_DECODER For that they needed more RAM on an ESP8266 so they piggy-backed an SPI RAM chip onto the SPI flash. Do you think that would end up getting exposed in the ESP8266's address space as well? Could be a really interesting way of boosting cheap ESP8266s as well? Posted at 2025-01-10 by dponyatov What should I add to board configs and compiler defines to make build of Espruino 2v22 for STM32F4 with I added
What I need is enabling block allocation mode but build fw with three precompiled blocks:
PS: I take old 2v22 thus modern versions compiles into ELF file with broken LMA/VMA table but I don't have time to fix it (all source code debug info bounded to zero address etc) Posted at 2025-01-10 by @fanoush
So you don't actually need resizable vars with its dynamic memory allocation, you need just 3 fixed separate blocks right from the start. I don't think there is a solution for this combination but it could be useful. I'd like to have something similar on nrf52 too, currently the most simple way used for nrf52 and stm32 is (one) big static Posted at 2025-01-10 by dponyatov @gfwilliams: Did you maybe tested some experimental version of As I see in source & debugger, for STM32F4 series there is defult build used with a single preallocated array isn't it?
Posted at 2025-01-10 by @gfwilliams So far I've only used RESIZABLE_JSVARS on Linux - otherwise you have to build in malloc/free/etc which we don't currently do (and it hurts performance). If you want 3 distinct blocks I'd add jsVars2/jsVars3 arrays where you want them and then make your own Posted at 2025-01-10 by @fanoush
That looks related to your previous conversation https://forum.espruino.com/conversations/401187/ I just compiled STM32F4DISCOVERY target which is linked to address zero too and in the lst file I see
and it looks like both VMA and LMA are correct, they point to 0 where the code really is, so there is nothing to fix with VMA/LMA. If you still have some issue with that, then maybe continue in that previous conversation you created. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2018-02-06 by JumJum
AFAIK, RESIZABLE_JSVARS are set for linux only.
Would it be possible to use this for other boards, like ESP32, too ?
I've some boards with additional psram, so memory is available like crazy.
Since psram needs a driver, its not available from start, means cannot be used for statically allocated block
Idea would be to check available heap during init and based on that malloc, memory for JsVars.
There would be a definitions in board.py for large heap and for small heap.
If something sounds as easy as this, usually there are some hidden problems,....
Any comment ?
Beta Was this translation helpful? Give feedback.
All reactions