Commit Graph

313 Commits

Author SHA1 Message Date
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
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
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
jgillick
f8499a468e Remove filesystem from linker script. 2020-11-23 22:56:38 -08:00
jgillick
570353b946 Merge remote-tracking branch 'circuitpython/main' into thunderpack1.2 2020-11-23 22:40:47 -08:00
Jeff Epler
70e978f48b stm: disable ulab on two resource-constrained boards 2020-11-23 10:23:53 -06:00
jgillick
4c5e7520f5 Fix NVM by clearing FLASH_FLAG_PGPERR 2020-11-23 00:25:41 -08:00
jgillick
661c20dd18 Create a new linker script with more space for the firmware. 2020-11-22 18:25:37 -08:00
Dan Halbert
a0f1ec3c4a wip 2020-11-22 19:10:09 -05:00
jgillick
fe6e50b770 Update USB_PID 2020-11-22 01:49:23 -08:00
jgillick
56634eb00e Rename thunderpack to v11 2020-11-22 01:31:41 -08:00
jgillick
381889f6bc Cleanup 2020-11-22 01:19:28 -08:00
jgillick
0b858440b0 Fix formatting. 2020-11-22 01:15:05 -08:00
jgillick
63b0bf9075 Merge remote-tracking branch 'origin/main' into thunderpack1.2 2020-11-22 01:07:03 -08:00
Dan Halbert
75559f35cc wip: ResetReason to microcontroller.cpu 2020-11-21 23:29:52 -05:00
jgillick
5f0a372a22 Merge tag '6.0.0' into thunderpack1.2 2020-11-17 00:02:24 -08:00
jgillick
119e9d3820 Add Thunderpack 1.2 2020-11-16 23:50:00 -08:00
Dan Halbert
ffff02c053 Merge remote-tracking branch 'adafruit/main' into sleep 2020-11-16 12:06:11 -05:00
Scott Shawcroft
68eb809fbf
Update parallel bus signatures 2020-11-13 18:57:52 -08: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
12ed3fc72f disable on winterbloom_sol and thunderpack 2020-10-15 18:48:28 -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
56427d9abe
Fix stm sleep too long 2020-10-13 14:02:29 -07:00
Scott Shawcroft
a0e5e961c5
Fix STM RTC read so it's atomic.
Fixes #3376
2020-10-12 17:43:25 -07:00
Jeff Epler
16ed875f4e canio: remove unused fields
these relate to properties that were removed as well
2020-10-06 20:14:50 -05:00
Jeff Epler
81d7ef0256 stm: canio: remove stray optimization flag for debugging 2020-10-06 20:13:23 -05:00
Jeff Epler
eed3387f4e stm32: canio: Fix message cancellation
.. it's necessary to wait for a cancellation request to actually free
the respective Tx mailbox
2020-10-06 20:12:10 -05:00
Jeff Epler
abe0405d6e stm32: canio: Fix canio.CAN.restart() 2020-10-06 20:12:06 -05:00
Jeff Epler
e5a0af9216 stm32: canio: When Tx mailboxes are full, cancel an old message
.. also add the 8ms wait for transmission that the atmel sam port
has
2020-10-06 20:11:58 -05:00
Jeff Epler
a7dccb39a4 stm32: canio: remove unused functions 2020-10-06 20:11:51 -05:00
Jeff Epler
23bd2496de stm32: canio: remove some unneeded declarations 2020-10-06 20:11:43 -05:00
Jeff Epler
7df01d3fbd stm32: canio: enable on all stm32f405 boards 2020-10-06 20:11:39 -05:00
Jeff Epler
01e9e355ce canio: implement for stm32f405
The has successfully run my loopback self-test program for CAN,
which tests transmission, reception, and filtering.  The 1M baud rate setting
was also verified on saleae to be accurate.
2020-10-06 20:11:35 -05:00
Scott Shawcroft
d62ac24493
Merge pull request #3469 from jepler/noreturn
Add some NORETURN attributes
2020-10-01 11:18:36 -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
mdroberts1243
b1e1237887
Merge branch 'main' into New_quirk_for_SH1107 2020-09-28 19:40:47 -04:00
Mark Roberts
b921543571 Requested changes take 1 2020-09-25 21:27:29 -04:00
Lucian Copeland
00517b2600 Move missing pin warning to shared-bindings 2020-09-23 11:39:39 -04:00
Jeff Epler
ce266425e1
Merge pull request #3441 from hierophect/stm32-rgbmatrix-crashfix
STM32: Add never_reset reservation to RGBMatrix init
2020-09-20 07:51:09 -05:00
Dan Halbert
8cf0171c06
Merge pull request #3431 from hierophect/stm32-spi-writevalue
STM32: Change SPI Read to acknowledge write_value
2020-09-18 19:46:21 -04:00
Lucian Copeland
3a59d30e1a Remove timer debug messages 2020-09-18 12:48:15 -04:00
Lucian Copeland
c58bd4c047 Add never_reset reservation to RGBMatrix init 2020-09-18 12:38:15 -04:00
Scott Shawcroft
4b827b25ad
Merge pull request #2966 from sommersoft/ci_check_vid_pid
Automate USB VID/PID Uniqueness Check
2020-09-17 11:48:46 -07:00
Lucian Copeland
00ee94d24b Add SPI memset, optional flags 2020-09-16 14:22:18 -04:00
Scott Shawcroft
95e27bb8bf
Add more PIDs for unique boards 2020-09-15 13:43:35 -07:00
Scott Shawcroft
9e722c8c99
Merge pull request #3375 from DavePutz/issue3296
Correction for Issue #3296 - ble hanging on nrf52840
2020-09-10 12:36:17 -07:00
root
2690faec43 Moved checks for invalid pin to common-hal/microcontroller/Pin.c 2020-09-05 11:42:06 -05:00
Scott Shawcroft
96cf60fbbd
Merge remote-tracking branch 'adafruit/main' into native_wifi 2020-09-03 16:34:56 -07:00
Scott Shawcroft
5d8ac0428b
-Os espruino_pico to save space 2020-08-27 13:34:37 -07:00
Jeff Epler
563e038c0d stm: Specify max endpoints for stm32f405xx
.. which is why we can't have HID or MIDI on the stm32f405 feather
2020-08-27 15:11:17 -05:00
Jeff Epler
49a22b0c55
Merge pull request #3320 from hierophect/stm32-meowbit-fix
STM32: Fix Meowbit startup and associated bugs
2020-08-27 13:05:56 -05:00
Dan Halbert
24fb08dbd9
Merge pull request #3337 from hierophect/pulseout-errorstyle
Fix problematic whitespace on pulseout parameter errors
2020-08-27 13:22:26 -04:00
Lucian Copeland
8021da08d3 Fix problematic whitespace on pulseout parameter errors 2020-08-27 11:07:47 -04:00
hierophect
772052598d
Merge branch 'main' into stm32-meowbit-fix 2020-08-27 11:00:29 -04:00
hierophect
a15f948a40
Merge branch 'main' into esp32-random 2020-08-27 10:49:14 -04:00
Lucian Copeland
8d2299e61e Merge remote-tracking branch 'upstream/main' into stm32-meowbit-fix 2020-08-26 18:50:26 -04:00
Lucian Copeland
c229345741 improve efficiency of stm32 random gen 2020-08-26 18:47:19 -04:00
Lucian Copeland
c77523503b Fix trailing whitespace errors across ports and docs 2020-08-26 14:48:46 -04:00
Lucian Copeland
05bde255f7 Add random to ESP32-S2, fix it on STM32 2020-08-25 14:00:29 -04:00
Lucian Copeland
de9fd4a0fb Fix null dereference, invert auto_brightness to reenable screen 2020-08-25 10:37:55 -04:00
Scott Shawcroft
1527a3ce92
Merge remote-tracking branch 'adafruit/main' into add_pwmio 2020-08-24 18:25:18 -07:00
Lucian Copeland
c137a16121 Remove Meowbit LSE flag, harsher failure for LSE issues 2020-08-24 14:49:06 -04:00
Scott Shawcroft
644d2ba7a2 Add more "extern" declarations for gcc10 compat
gcc has tightened the restrictions on forward declarations that lack
"extern".  Fix them up.
2020-08-21 14:39:37 -05:00
Scott Shawcroft
a5b01f7361
Merge remote-tracking branch 'adafruit/main' into add_pwmio 2020-08-21 11:13:53 -07:00
Scott Shawcroft
6857f98426
Split pulseio.PWMOut into pwmio
This gives us better granularity when implementing new ports because
PWMOut is commonly implemented before PulseIn and PulseOut.

Fixes #3211
2020-08-18 13:08:33 -07:00
Lucian Copeland
da75445cd5 Style changes, reposition runtime errors 2020-08-18 11:42:06 -04:00
Lucian Copeland
0fc730bc5a Expand PulseOut API, debug cleanup 2020-08-14 16:36:02 -04:00
Dan Halbert
329f4fb2e6
Update mpconfigboard.mk
The stm boards default to `-O2`. Changing to `-Os` brings it back to ~43kB (!) free even for ja.
2020-08-13 10:09:46 -04:00
Jeff Epler
42b860e91a stm: meowbit_v121: remove _pixelbuf to fit ja translation 2020-08-13 07:49:45 -05:00
Jeff Epler
1cf3762392 Merge remote-tracking branch 'origin/main' into stm32-sdioio 2020-08-10 12:54:12 -05:00
Jeff Epler
93b373d617 "pop from empty %q"
Saves 12 bytes code on trinket m0
2020-08-04 18:42:09 -05:00
Jeff Epler
c849b781c0 Combine 'index out of range' messages 2020-08-04 14:45:45 -05:00
Jeff Epler
dddd25a776 Combine similar strings to reduce size of translations
This is a slight trade-off with code size, in places where a "_varg"
mp_raise variant is now used.  The net savings on trinket_m0 is
just 32 bytes.

It also means that the translation will include the original English
text, and cannot be translated.  These are usually names of Python
types such as int, set, or dict or special values such as "inf" or
"Nan".
2020-08-04 13:34:29 -05:00
Jeff Epler
f175a49444 stm: sdioio: include header for common_hal_mcu_pin_claim 2020-07-30 07:18:12 -05:00
Jeff Epler
b57e6e9856 stm: sdioio: call common_hal_mcu_pin_claim 2020-07-30 07:18:12 -05:00
Jeff Epler
d73505a027 stm: fix if-guard of conditional code 2020-07-30 07:18:12 -05:00
Jeff Epler
60dd5a8d7d stm: sdioio: remove unused code related to "SD Card detect pin"
.. this probably came from the examples that I studied at the beginning
of implementation.

The card detection feature is unused.  As a "detect pin" is not
sent from the shared-bindings, there is no way to get the correct pin
anyway.  Instead, if code needs to detect the insertion state it can
directly use the pin as GPIO in Python code.
2020-07-30 07:18:02 -05:00
Jeff Epler
ccd3013396 stm: stioio: correctly claim pins 2020-07-30 07:18:02 -05:00
Jeff Epler
3cf1258c87 stm: sdioio: Get rid of debug code and useless comments 2020-07-30 07:18:02 -05:00
Jeff Epler
6a99a7b551 stm: Use 'Invalid %q pin selection' more places 2020-07-30 07:18:02 -05:00
Jeff Epler
92d2f47503 feather_stm32f405_express: sdio_data_tuple should be static 2020-07-30 07:18:02 -05:00
Jeff Epler
4adbd23b75 stm: Add sdioio support for feather_stm32f405_express
Currently, only the bus specs of the stm32f405xx have been coded.
Other stm-family chips need (at a minimum) the specs added in their
periph.[ch] files.
2020-07-30 07:18:02 -05:00
Jeff Epler
d30f11163c stm: enable SD module in HAL 2020-07-30 07:18:02 -05:00
DavePutz
3dfed3c4aa
Merge pull request #15 from adafruit/main
update from main
2020-07-24 20:29:53 -05:00
root
204cdada7c remove unnecessary mk files parameters 2020-07-24 09:53:40 -05:00
root
778e8bfda9 Changes to optimization option 2020-07-23 19:27:02 -05:00
Lucian Copeland
c1f731d62e Claim USB pins at startup to prevent overwrites 2020-07-22 14:22:05 -04:00
hierophect
e232ec10ce
Merge branch 'main' into stm32-timer-allocator 2020-07-22 13:59:39 -04:00
Lucian Copeland
138189bad1 Free timers when modules de-init 2020-07-22 13:58:57 -04: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
Lucian Copeland
dc6902a33e Exclude timers from H7 builds 2020-07-16 17:11:24 -04:00
Lucian Copeland
6a49766df0 Fix pulseIO reset and frequency issues, remove IRQ conflict 2020-07-16 15:45:18 -04: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