Commit Graph

83 Commits

Author SHA1 Message Date
Dan Halbert fa6c06fb38 count in/out endpoints; allow more usb modules on low-endpoint boards 2021-05-13 21:59:02 -04:00
Scott Shawcroft 42f4065c8a
Merge remote-tracking branch 'adafruit/main' into merge_1.13 2021-05-06 11:17:53 -07:00
Scott Shawcroft f0bb26d70f
Merge MicroPython 1.13 into CircuitPython 2021-05-04 18:06:33 -07:00
Dan Halbert d2b558993e merge from main, including MicroPython 1.12 merge 2021-05-03 20:56:04 -04:00
Dan Halbert e475dc8899 Fix broken builds 2021-05-03 00:09:15 -04:00
Dan Halbert 749a3ac978 remove pwmio from litex port 2021-05-01 23:22:52 -04:00
Dan Halbert f06d54524d merge from adafruit 2021-04-28 23:48:26 -04:00
Scott Shawcroft 17fcd499b2
Merge pull request #4649 from tannewt/merge_1.11_2
Merge MicroPython v1.11 into CircuitPython
2021-04-27 11:02:02 -07:00
Scott Shawcroft 76033d5115
Merge MicroPython v1.11 into CircuitPython 2021-04-26 15:47:41 -07:00
Dan Halbert 9d1fcc3b14 merge from main 2021-04-25 10:27:52 -04:00
Artyom Skrobov 4e3c1d4a4c [build] Allow USB to be set to 0
Unify USB-related makefile var and C def as CIRCUITPY_USB.

Always define it as 0 or 1, same as all other settings.

USB_AVAILABLE was conditionally defined in supervisor.mk,
but never actually used to #ifdef USB-related code.

Loosely related to #4546
2021-04-23 11:13:34 -04:00
Dan Halbert 64e0958916 wip: descriptor building 2021-04-21 23:25:36 -04:00
microDev a52eb88031
run code formatting script 2021-03-15 19:27:36 +05:30
Dan Halbert f0564b4986 merge from upstream; complicated webusb merge 2021-02-11 18:50:02 -05:00
Dan Halbert 0802b22ed6 usb descriptors all set; rework of enabling for USB devices 2021-02-04 19:23:40 -05:00
Dan Halbert 69869e1439 CIRCUITPY_* switches for JSON, RE, etc. Doc cleanup 2021-01-24 23:10:20 -05:00
Jeff Epler 7401aa8e85
Merge pull request #3888 from microDev1/fix-reset-pin
FIX : common_hal_reset_pin()
2020-12-29 10:08:47 -06:00
Scott Shawcroft f9d9c031a9
Merge pull request #3878 from xobs/fomu-fixes-6.0.0
Fomu fixes for 6.0.0
2020-12-28 11:51:26 -08:00
microDev dc332baa87
update common_hal_reset_pin() 2020-12-28 20:04:00 +05:30
Sean Cross 2f95cc95a4 litex: move more critical code to RAM
The XIP SPI flash on Fomu is slow, which results in certain operations
taking a long time. This becomes a problem for time-critical operations
such as USB.

Move various calls into RAM to improve performance.

This includes the call to __modsi3 and __udivsi3 which are used by the
supervisor handler to determine if periodic callbacks need to be run.

This finishes fixing #3841

Signed-off-by: Sean Cross <sean@xobs.io>
2020-12-24 14:06:57 +08:00
Sean Cross f3e54414e5 litex: ensure we don't re-enable interrups during ISR
During an interrupt handler, interrupts are implicitly disabled. They
will be re-enabled when the interrupt handler returns.

Due to some changes that were made, varous calls will re-enable
interrupts after they're finished. Examples of this include calling
`CALLBACK_CRITICAL_END` and getting the number of ticks with
`port_get_raw_ticks()`.

This patch prevents this from happening by doing two things:

1. Use standard calls in `port_get_raw_ticks()` to disable and re-enable
interrupts, preventing nesting issues, and
2. Increase the nesting count inside `isr()`, reflecting the implicit
call that is made by hardware when an interrupt is handled

This helps to address #3841.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-12-24 14:03:10 +08:00
Dan Halbert 8f9cd7075e
Merge pull request #3752 from jepler/gcc10
build: Update to gcc10
2020-12-17 11:03:40 -05:00
Dan Halbert fb33c4e1c0 -ftree-vrp better diagnostics on -Os builds; -fno-inline-functions for -O2; fix struct init in HCI bleio 2020-12-15 12:23:56 -05:00
Scott Shawcroft 40118bcf57
Add `board_deinit` for use with sleep
This changes lots of files to unify `board.h` across ports. It adds
`board_deinit` when CIRCUITPY_ALARM is set. `main.c` uses it to
deinit the board before deep sleeping (even when pretending.)

Deep sleep is now a two step process for the port. First, the
port should prepare to deep sleep based on the given alarms. It
should set alarms for both deep and pretend sleep. In particular,
the pretend versions should be set immediately so that we don't
miss an alarm as we shutdown. These alarms should also wake from
`port_idle_until_interrupt` which is used when pretending to deep
sleep.

Second, when real deep sleeping, `alarm_enter_deep_sleep` is called.
The port should set any alarms it didn't during prepare based on
data it saved internally during prepare.

ESP32-S2 sleep is a bit reorganized to locate more logic with
TimeAlarm. This will help it scale to more alarm types.

Fixes #3786
2020-12-08 10:52:25 -08:00
Scott Shawcroft 1130b80e2a
Merge pull request #3612 from gamblor21/bus_device
Moving Adafruit_CircuitPython_BusDevice to core
2020-12-02 13:23:02 -08:00
Scott Shawcroft d7ba641ff6
Merge pull request #3767 from dhalbert/sleep
Initial alarm and sleep PR: time alarms with light and deep sleep; PinAlarms not yet implemented
2020-12-02 12:51:43 -08:00
Dan Halbert 8b7c23c1ee address review comments 2020-12-01 20:01:14 -05:00
Mark 237385798c
Merge branch 'main' into bus_device 2020-12-01 15:47:16 -06: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
Dan Halbert 104a089677 deep sleep working; deep sleep delay when connected 2020-11-26 22:06:37 -05:00
Dan Halbert ef0830bfe2 merge from upstream + wip 2020-11-25 17:52:06 -05:00
Dan Halbert a0f1ec3c4a wip 2020-11-22 19:10:09 -05:00
Dan Halbert 75559f35cc wip: ResetReason to microcontroller.cpu 2020-11-21 23:29:52 -05:00
gamblor21 f61c4e62c1 Removing from smaller builds 2020-11-11 10:24:33 -06:00
microDev 930cf14dce
Add check for invalid io, function to disable all alarms 2020-10-27 16:17:26 -07:00
microDev e35938971a
Add description of alarm modules 2020-10-27 16:16:55 -07:00
Dan Halbert 1d05ad6b22 no _bleio for litex; ESP32S2 defines BIT() already 2020-10-15 16:34:19 -04:00
Dan Halbert f1e8f2b404
Merge pull request #3554 from gamblor21/move_ordereddict
Moved ORDEREDDICT define to central location
2020-10-14 22:39:04 -04:00
gamblor21 4270061db4 Moved ORDEREDDICT define to central location 2020-10-13 18:52:27 -05:00
Scott Shawcroft 379e73af2e
Finer grained, per port tick locking
Fixes #3504 hopefully.
2020-10-12 18:43:21 -07:00
Jeff Epler 726dcdb60a Add some NORETURN attributes
I have a function where it should be impossible to reach the end, so I put in a safe-mode reset at the bottom:
```
int find_unused_slot(void) {
    // precondition: you already verified that a slot was available
    for (int i=0; i<NUM_SLOTS; i++) {
        if( slot_free(i)) {
            return i;
        }
    }
    safe_mode_reset(MICROPY_FATAL_ERROR);
}
```
However, the compiler still gave a diagnostic, because safe_mode_reset was not declared NORETURN.

So I started by teaching the compiler that reset_into_safe_mode never returned.  This leads at least one level deeper due to reset_cpu needing to be a NORETURN function.  Each port is a little different in this area.  I also marked reset_to_bootloader as NORETURN.
Additional notes:

 * stm32's reset_to_bootloader was not implemented, but now does a bare reset.  Most stm32s are not fitted with uf2 bootloaders anyway.
 * ditto cxd56
 * esp32s2 did not implement reset_cpu at all.  I used esp_restart().  (not tested)
 * litex did not implement reset_cpu at all.  I used reboot_ctrl_write.  But notably this is what reset_to_bootloader already did, so one or the other must be incorrect (not tested).  reboot_ctrl_write cannot be declared NORETURN, as it returns unless the special value 0xac is written), so a new unreachable forever-loop is added.
 * cxd56's reset is via a boardctl() call which can't generically be declared NORETURN, so a new unreacahble "for(;;)" forever-loop is added.
 * In several places, NVIC_SystemReset is redeclared with NORETURN applied.  This is accepted just fine by gcc.  I chose this as preferable to editing the multiple copies of CMSIS headers where it is normally declared.
 * the stub safe_mode reset simply aborts.  This is used in mpy-cross.
2020-09-28 18:55:56 -05:00
DavePutz 3dfed3c4aa
Merge pull request #15 from adafruit/main
update from main
2020-07-24 20:29:53 -05:00
Lucian Copeland 356b1a8d6d Finish common-hal pin API 2020-07-24 12:29:18 -04:00
root 778e8bfda9 Changes to optimization option 2020-07-23 19:27:02 -05:00
root d83a4ac72d Changes to add compiler optimization option 2020-07-22 12:44:41 -05:00
root 49decf90c9 Add option for higher optimization levels 2020-07-21 10:11:08 -05:00
Jeff Epler 1df48176ce supervisor: factor supervisor_background_tasks from sundry ports 2020-07-15 11:49:44 -05:00
Jeff Epler 6160d11c5a supervisor: factor out, Handle USB via background callback 2020-07-15 11:49:44 -05:00
Diego Elio Pettenò 34b4993d63 Add license to some obvious files. 2020-07-06 19:16:25 +01:00
Jeff Epler fcddfd0f39
Merge pull request #3083 from tannewt/esp32s2_busio
Add busio support for the ESP32-S2
2020-07-01 21:02:08 -05:00