This simplifies allocating outside of the VM because the VM doesn't
take up all remaining memory by default.
On ESP we delegate to the IDF for allocations. For all other ports,
we use TLSF to manage an outer "port" heap. The IDF uses TLSF
internally and we use their fork for the other ports.
This also removes the dynamic C stack sizing. It wasn't often used
and is not possible with a fixed outer heap.
Fixes#8512. Fixes#7334.
micropython puts the pointer-ness into the typedef; we can put the
const-ness there too.
this reduces the delta to micropython; for instance, emitinlinextensa
and emitinlinethumb now match upstream.
Otherwise, the following would occur:
* settings.toml is in the process of being written by host computer
* soft-reset begins
* web workflow tries to grab CIRCUITPY_WIFI_SSID, but loops forever
because FAT filesystem is in inconsistent state and file reads error
* settings.toml write by host computer never completes and the filesystem
remains corrupt
* restarting yields a soft-bricked device, because startup reads
CIRCUITPY_WIFI_SSID again
This is a small optimization, it avoids reading the full file when an
early key is requested.
In the case of an *invalid* TOML file such as
```
K=80
K=81
```
this stops the value of K actually returned being 8081 and makes it 80
instead; but as it's a malformed file it doesn't really matter much.
* use a virtual fat filesystem during the test
* this makes the file I/O part more closely patch runtime which is nice
* side-steps the need to add a special function for testing
* but test still can't be run on a device, because the vfs calls
are incompatible, and you intentionally can't remount "/" anyway
* and side-steps problems with storing 'bad' toml files
os.getenv() will use it (when available) to load variables from
/.env
This will also be useful when we need secrets or config for
CircuitPython outside of the VM (like WiFi credentials.)
Fixes#4212
While finding sources of clicks and buzzes in nrf i2sout, I identified
this site as one which could be long running. Reproducer code was to
play a 22.05kHz sample and repeatedly print `os.listdir('')`
This fixes commit a99f9427420d("'/' and '\' are also acceptable ends of the path now") which broke mkdir.
The problem is where the directory name is a single letter like this:
>>> os.mkdir('a')
>>> os.mkdir('a/b')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [Errno 17] File exists
>>> os.mkdir('a/bb')
>>>
I wasn't smart enough to fix this in the oofatfs library, so I did it in the os shared module by
creating a path lookup function for the os methods that only deals with directories. I reverted
the library change introduced by the aforementioned commit.
This means that os.stat and os.rename can't handle trailing slashes. This is to avoid allowing
filenames with trailing slashes to pass through. In order to handle trailing slashes for these
it would be necessary to check if it really is a directory before stripping. I didn't do this
since the original issue was to make os.chdir tolerate trailing slashes.
There's an open MicroPython issue #2929 wrt. trailing slashes and mkdir.