Page 1 of 1

New script downloaded to board but old one still runs

Posted: Thu Apr 04, 2019 9:32 pm
by pmulvey
I had a problem with the "MemoryError: memory allocation failed" error. I was using the __init__.py structure. After trying to remove offending code from my library module (~10k) for days the problem persisted. Finally I split the module into two 5k modules and the situation resolved itself. Now I have a problem whereby my Testing module will download to the esp but the esp runs the previous version. The new script is definitely there because I have read it off the esp. My program has 13 files together amounting to 49k. I know I will be criticised for lack of specific code but there is just too much to upload. I might be doing something really silly here that someone may spot.

I am using Wemos D1 mini
Micropython v1.10-8-g8b7039d7d

On a hard reset I get:

Code: Select all

ets_post: task 31 queue full
ets_post: task 31 queue full
After importing via the __init__.py the first line of code
print (gc.mem_free())
gives me:
9904

Using the os.statvfs and a few lines of manipulation code I get 3.277Mb free

The response to sys.modules is:

Code: Select all

{'Globals.PCF8574': <module 'Globals.PCF8574'>,
 'Globals.MiscLib_02': <module 'Globals.MiscLib_02'>,
 'Demo': <module 'Demo'>,
 'Globals.lcd_api': <module 'Globals.lcd_api'>, 
 'onewire': <module 'onewire'>, 
 'Globals.DS18B20': <module 'Globals.DS18B20'>, 
 'Globals.WebServer': <module 'Globals.WebServer'>, 
 'Globals.MiscLib_01': <module 'Globals.MiscLib_01'>, 
 'Globals.esp8266_i2c_lcd': <module 'Globals.esp8266_i2c_lcd'>, 
 'Globals': <module 'Globals'>, 
 'flashbdev': <module 'flashbdev'>, 
 'Globals.Sound': <module 'Globals.Sound'>}
**Update**
I erased the esp, downloaded all of the files again and it now seems OK.
Previously print (gc.mem_free()) after all imports gave me 9904, I am now seeing 13488. It seems that many of the other modules download correctly as well but some other version of each was running. It's as if the esp accepted the script but never converted it into the current byte code or whatever it does. We'll see how long this lasts!

Is there any possibility that my constant development on this esp has wasted the flash assuming that I didn't have code that wrote to it incessantly. Has anyone ever worn down an esp through intensive development?

Re: New script downloaded to board but old one still runs

Posted: Thu Apr 04, 2019 9:52 pm
by dhylands
If you created a frozen module, then that might be getting loaded instead of the internal one.

You can use help('modules') to see the list of internal modules.

When loading modules, micropython searches for them along the path specified in sys.path. So check that as well:

Code: Select all

>>> sys.path
['', '/lib', '/']
>>> 
The location of the empty string in the list is where it will check for internal modules.