Commit Graph

118 Commits

Author SHA1 Message Date
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
Scott Shawcroft 2d579cc995
Use NULL for deinited DigitalInOut
This fixes a Display issue where no backlight pin is given but it's
still deinitialized.
2020-06-26 12:33:50 -07:00
Jeff Epler 57fde2e07b sdcardio: implement new library for SD card I/O
Testing performed: That a card is successfully mounted on Pygamer with
the built in SD card slot

This module is enabled for most FULL_BUILD boards, but is disabled for
samd21 ("M0"), litex, and pca10100 for various reasons.
2020-06-26 11:50:23 -05:00
Jeff Epler 1d2cc0b968 I2CPeripheral: Rename class and its module
This is an incompatible change.
2020-06-25 11:44:19 -05:00
Jeff Epler f232aef786 supervisor.mk: Compute USB_DEVICES; remove from boards and ports
Since Actions passed on the previous commit, where this computed value
was checked against the specified value (if any), this is no net change,
except that we no longer need to specify it for particular boards or
ports.
2020-06-23 12:59:01 -05:00
Diego Elio Pettenò dd5d7c86d2 Fix up end of file and trailing whitespace.
This can be enforced by pre-commit, but correct it separately to make it easier to review.
2020-06-03 10:56:35 +01:00
Sean Cross ed8a52d1db litex: remove call to `board_init()`
These calls were all moved into `main.c`, however this call was not
removed from litex. As a result, litex was calling `board_init()` twice.

This is currently not a problem, as `fomu` is able to be initialized
twice without issue, however future boards may have issue with this.

This fixes #2991.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-06-02 10:19:40 +08:00
Scott Shawcroft 796373b8be
A number of small ESP32S2 fixes:
* Fix flash writes that don't end on a sector boundary. Fixes #2944
* Fix enum incompatibility with IDF.
* Fix printf output so it goes out debug UART.
* Increase stack size to 8k.
* Fix sleep of less than a tick so it doesn't crash.
2020-05-28 15:43:55 -07:00
Scott Shawcroft fd0420d432
Update digitalio api for other ports 2020-05-20 09:23:42 -07:00
Scott Shawcroft 6aaab005c5
Initial ESP32S2 port.
Basic blinky works but doesn't check pins.
2020-05-15 15:36:16 -07:00
Daniel Pollard bfa5cd9c13 refactor countio based on feedback 2020-05-05 15:23:38 +10:00
Scott Shawcroft 755d404edf
Merge remote-tracking branch 'adafruit/master' into lower_power 2020-04-27 16:45:10 -07:00
Dan Halbert faa50df05f
Merge pull request #2817 from jepler/stm-linker-scripts
Standardize on FLASH_FIRMWARE section name in linker scripts
2020-04-27 18:43:26 -04:00
Jeff Epler 7f0f0b30d3 linker scripts: Re-align at ":"
With "git show -b" you can verify that this is a whitespace only change
because the diff will be empty.
2020-04-27 17:17:42 -05:00
Jeff Epler 6f6dc835d2 litex: Use FLASH_FIRMWARE instead of FLASH in linker scripts
for compatibility with the build_memory_info script
2020-04-27 09:12:45 -05:00
Scott Shawcroft 67c053e9c4
Add USB include for LiteX 2020-04-24 17:24:05 -07:00
Scott Shawcroft 5c7f6e6211
Remove empty #if and add missing includes. 2020-04-24 11:48:55 -07:00
Scott Shawcroft 5cc8a3ec82
Add back fake us delay. 2020-04-21 14:14:49 -07:00
Scott Shawcroft bebf27e733
Merge remote-tracking branch 'adafruit/master' into lower_power
This isn't perfect and needs a bit more testing.
2020-04-20 18:25:13 -07:00
Scott Shawcroft 7e3d4c61b5
Update TinyUSB and add interrupt hooks. 2020-04-17 14:16:49 -07:00
Scott Shawcroft 5b0d9bdeb0
Update copyright to bump the CI 2020-04-16 14:21:26 -07:00
Sean Cross 61f777c9c6 litex: enable binascii and ujson modules
Signed-off-by: Sean Cross <sean@xobs.io>
2020-04-16 10:02:08 +08:00
Sean Cross bb527ac9ea litex: disable minimal build
Manually specify available modules and disable any modules
that are currently unsupported on the litex target.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-04-16 09:26:08 +08:00
Sean Cross db3933429a litex: add os module
Signed-off-by: Sean Cross <sean@xobs.io>
2020-04-16 09:26:08 +08:00
Sean Cross 6885ffc9af litex: mphalport: add fake mp_hal_delay_us
Add a mp_hal_delay_us, which is required by some of the modules,
that simply calls mp_hal_delay_ms / 1000.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-04-16 09:26:08 +08:00
Scott Shawcroft b580b34cbf
Merge remote-tracking branch 'adafruit/master' into lower_power 2020-04-14 17:14:44 -07:00
Scott Shawcroft d0a25ca9ac
Tweaks based on dhalberts feedback 2020-04-08 10:49:46 -07:00
Sean Cross 9845a064ad ports: fomu: move more functions into ram for stability
The SPI flash on current Fomu firmware is slow.  Circuitpython runs
XIP from SPI flash, and so execution time can also be slow.  Ordinarily
this isn't a problem, however certain operations are time-sensitive.

In particular, USB function needs to be handled quickly in order to
prevent the host from re-enumerating the device.

Place several critical TinyUSB structures into RAM, as well as several
hot functions that are frequently called.  This reduces execution time
at the expense of system memory, and greatly improves system stability.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-04-02 11:21:22 +08:00
Scott Shawcroft 77562a2acd
Update the supported ports 2020-03-31 18:27:55 -07:00
Scott Shawcroft 75b7f583d2
Update LiteX APIs for new tick 2020-03-31 17:52:23 -07:00
Sean Cross c69f7f8657 ports: litex: use dfu.py instead of dfu-suffix.py
dfu.py now generates proper dfu suffixes without the nonstandard prefix.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-31 13:04:59 +08:00
Sean Cross 34ea140783 ports: fomu: build dfu as part of Makefile
Now that we have a replacement for `dfu-suffix`, construct a dfu
image rather than a UF2 image.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-31 11:42:55 +08:00
Sean Cross 065441e58c ports: litex: enable itcm region for fomu
This adds a new command line flag -DFOMU to indicate we're building
for a Fomu board.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-31 09:40:38 +08:00
Sean Cross 786e79ebc9 ports: litex: add port and fomu board
This adds support for Litex, along with support for the Fomu FPGA board.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-31 09:40:38 +08:00