Commit Graph

29 Commits

Author SHA1 Message Date
Christian Walther
cf97793af8 Add supervisor.get_previous_traceback() function.
Useful for #1084.
2021-07-22 12:23:55 -04:00
Scott Shawcroft
d67fb852a1
Merge pull request #3454 from cwalther/setnextcode
Add supervisor.set_next_code_file()
2021-06-25 11:00:53 -07:00
Lucian Copeland
cf9741bd3a Merge remote-tracking branch 'upstream/main' into setnextcode 2021-06-20 15:25:37 -04:00
Jeff Epler
1d03ec12b5 supervisor: Fix assertion error in supervisor_move_memory
It was possible for _only_ a low allocation to be performed.
In this case, `high_head` is NULL, and the comparison
`MP_STATE_VM(first_embedded_allocation) < high_head` would fail.

Closes: #4871
2021-06-10 11:10:27 -05:00
Dan Halbert
be7b2b00a8 uncrustify with newer version of uncrustify 2021-04-30 10:40:12 -04:00
Dan Halbert
587aedd14f rework storage allocation 2021-04-28 13:00:44 -04:00
Dan Halbert
8500e846c6 partially working 2021-04-27 23:53:23 -04:00
Dan Halbert
aea3c4d3ab wip 2021-04-25 10:23:59 -04:00
Dan Halbert
556a126917 wip: getting closer 2021-04-23 21:44:13 -04:00
Scott Shawcroft
5d2b60cbf6
Redo RP2040 flash settings
This switches stage2 to C and uses Jinja to change the C code based
on flash settings from https://github.com/adafruit/nvm.toml. It
produces the fastest settings for the given set of external flashes.
Flash size is no longer hard coded so switching flashes with similar
capabilities but different sizes should *just work*.

This PR also places "ITCM" code in RAM to save the XIP cache for
code execution. Further optimization is possible. A blink code.py
still requires a number of flash fetches every blink.

Fixes #4041
2021-03-18 16:55:42 -07:00
microDev
a52eb88031
run code formatting script 2021-03-15 19:27:36 +05:30
Christian Walther
8889ac12e1 Add supervisor.set_next_code() function (prototype).
Part of #1084.
2021-01-23 23:05:31 +01:00
Christian Walther
d6f8a43f6c Eliminate goto. 2020-11-30 23:33:38 +01:00
Christian Walther
11ed6f86f0 Optimize out allocation moving code on boards that don't need it.
When no features are enabled that use movable allocations, supervisor_move_memory() is not needed.
2020-11-29 16:27:36 +01:00
Christian Walther
9ecaa16ece Unify redundant low/high_address computation to save a bit of code size. 2020-11-29 16:04:31 +01:00
Christian Walther
993a581f5e Make CIRCUITPY_SUPERVISOR_ALLOC_COUNT dependent on enabled features.
Avoids wasted memory and makes it easier to keep track of who needs how much for future additions.
2020-11-28 17:54:34 +01:00
Christian Walther
c7404a3ff8 Add movable allocation system.
This allows calls to `allocate_memory()` while the VM is running, it will then allocate from the GC heap (unless there is a suitable hole among the supervisor allocations), and when the VM exits and the GC heap is freed, the allocation will be moved to the bottom of the former GC heap and transformed into a proper supervisor allocation. Existing movable allocations will also be moved to defragment the supervisor heap and ensure that the next VM run gets as much memory as possible for the GC heap.

By itself this breaks terminalio because it violates the assumption that supervisor_display_move_memory() still has access to an undisturbed heap to copy the tilegrid from. It will work in many cases, but if you're unlucky you will get garbled terminal contents after exiting from the vm run that created the display. This will be fixed in the following commit, which is separate to simplify review.
2020-11-28 17:50:23 +01:00
Christian Walther
be8092f4d3 When there is not enough free space, but a matching hole on the other side, use it. 2020-10-02 23:07:07 +02:00
Christian Walther
5bdb8c45dd Allow allocate_memory() to reuse holes when matching exactly.
This requires recovering the pointer of the allocation, which could be done by adding up neighbor lengths, but the simpler way is to stop NULLing it out in the first place and instead mark an allocation as freed by the client by setting the lowest bit of the length (which is always zero in a valid length).
2020-10-02 23:03:21 +02:00
Christian Walther
d6d02c67d2 Fix inconsistent supervisor heap.
When allocations were freed in a different order from the reverse of how they were allocated (leaving holes), the heap would get into an inconsistent state, eventually resulting in crashes.

free_memory() relies on having allocations in order, but allocate_memory() did not guarantee that: It reused the first allocation with a NULL ptr without ensuring that it was between low_address and high_address. When it belongs to a hole in the allocated memory, such an allocation is not really free for reuse, because free_memory() still needs its length.

Instead, explicitly mark allocations available for reuse with a special (invalid) value in the length field. Only allocations that lie between low_address and high_address are marked that way.
2020-10-02 23:03:21 +02:00
Scott Shawcroft
6aaab005c5
Initial ESP32S2 port.
Basic blinky works but doesn't check pins.
2020-05-15 15:36:16 -07:00
Jeff Epler
3a94412cd3 protomatter: more memory allocation fixes
- bump supervisor alloc count by 4 (we actually use 5)
 - move reconstruct to after gc heap is reset
 - destroy protomatter object entirely if not used by a FramebufferDisplay
 - ensure previous supervisor allocations are released
 - zero out pointers so GC can collect them
2020-04-14 18:24:58 -05:00
Jeff Epler
094fe05bdd allow retrieving info about a supervisor allocation 2020-04-14 18:24:54 -05:00
Scott Shawcroft
7d8dac9211
Refine iMX RT memory layout and add three boards
Introduces a way to place CircuitPython code and data into
tightly coupled memory (TCM) which is accessible by the CPU in a
single cycle. It also frees up room in the corresponding cache for
intermittent data. Loading from external flash is slow!

The data cache is also now enabled.

Adds support for the iMX RT 1021 chip. Adds three new boards:
* iMX RT 1020 EVK
* iMX RT 1060 EVK
* Teensy 4.0

Related to #2492, #2472 and #2477. Fixes #2475.
2020-01-17 17:36:08 -08:00
Kamil Tomaszewski
f3151bb6c4 Use get top and limit stack functions 2019-10-18 11:05:08 +02:00
Scott Shawcroft
1a1dbef992
Hook up the terminal based on the first display. 2019-01-31 11:42:14 -08:00
Scott Shawcroft
e72cebbad6
Fix crash due to unsigned index and 0 boundary loop. 2018-08-16 00:29:18 -07:00
Scott Shawcroft
4b247eacd8
Add todo for handling improper free. 2018-08-02 14:45:21 -07:00
Scott Shawcroft
5704bc8c93
Share memory.c and a bit of polish. 2018-08-02 14:35:46 -07:00