Hi,
when it comes to (Micro-)Python I am a very beginner. Or in other words:
I am learning from my mistakes.
From my Linux PC I connect to my ESP32 board via rshell or Thonny.
When loading (for example) /pyboard/main.py into an editor (rshell) or into the editor of Thonny and
run that script, it will be saved to the flash of the chip.
But:
When I paste code line by line to the REPL (which is tidious) it seems that it can be executed without being saved to the flash - or
at least I cannot find traces of such a writing.
As said I am learning from my mistakes -- but decreasing the write cycles to the flash will preserve its lifetime.
Is it somehow possible to automate this "pasting to the REPL" -- or to avoid writing to the flash in some other ways?
Is there an ESP32 emulator for Linux...for example?
Cheers!
mcc
Avoid writing to the flash for the simplest corrections?
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: Avoid writing to the flash for the simplest corrections?
This is correct, but you don't need to paste one line at a time. After copying several lines, press ctrl-e, paste them, press ctrl-d to run them. There is a limit to how much code you can paste in that way - you'll have to experiment.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: Avoid writing to the flash for the simplest corrections?
You will find that flash writing isn't that much of a problem ? WHY ?
Because in the end your shiny new board will be get replaced by the next new shiny board the esp64 and finish it's life in a box somewhere or as a dedicated project, nowhere near to the amount of writes to the flash.
I have a Arduino which is now about 15 years old which I still program for projects !!!!
Because in the end your shiny new board will be get replaced by the next new shiny board the esp64 and finish it's life in a box somewhere or as a dedicated project, nowhere near to the amount of writes to the flash.
I have a Arduino which is now about 15 years old which I still program for projects !!!!
Just use Thonny's built in python 3 , it is hard to emulate the physical hardware of the ESP32 for controlling ports , try getting a raspberry pi which stores it's program on a sd card or hard drive , it as SPI and i2c so most will work on both with a little tweak or two .Is there an ESP32 emulator for Linux...for example?
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: Avoid writing to the flash for the simplest corrections?
I agree, but cut and paste is still a seriously useful feature of MicroPython 
The worst figure I've seen for flash is an endurance of 10,000 writes and littlefs is designed for intrinsic wear levelling. This means that you can write out program files >>10,000 times before wearing out the flash. I reckon you could get over 20 years of intensive use out of a cheap ESP32.
OTOH it is easy to run up >>10,000 writes by programmatic writing to flash.

The worst figure I've seen for flash is an endurance of 10,000 writes and littlefs is designed for intrinsic wear levelling. This means that you can write out program files >>10,000 times before wearing out the flash. I reckon you could get over 20 years of intensive use out of a cheap ESP32.
OTOH it is easy to run up >>10,000 writes by programmatic writing to flash.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: Avoid writing to the flash for the simplest corrections?
Hi,
thanks a lot for the information -- it helps me a very much!
Everytime I handle flash in one or the other way a creepy fear crawls up my spine whispering " BE CAREFUL ! IT'S DEADLY! YOU HAVE BEEN WARNED!"
I know, it is not <cough> scientifically based <cough>...but it still exists.
The CTRL-E feature is GREAT! Didn't know that before...
By the way: Is the amount of lines which can be pasted limited by rshell or by the µPython interpreter or only
limited by SRAM (SPIRAM?) of the board?
Cheers!
mcc
thanks a lot for the information -- it helps me a very much!
Everytime I handle flash in one or the other way a creepy fear crawls up my spine whispering " BE CAREFUL ! IT'S DEADLY! YOU HAVE BEEN WARNED!"

I know, it is not <cough> scientifically based <cough>...but it still exists.
The CTRL-E feature is GREAT! Didn't know that before...
By the way: Is the amount of lines which can be pasted limited by rshell or by the µPython interpreter or only
limited by SRAM (SPIRAM?) of the board?
Cheers!
mcc
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: Avoid writing to the flash for the simplest corrections?
My guess is that it's limited by UART buffering but I haven't studied the raw REPL. The limit is far too small to be RAM limited. You can usually paste a long script in parts, but when it gets that long I generally save it as a file.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.