Commit Graph

765 Commits

Author SHA1 Message Date
Scott Shawcroft
7867632a81
Merge remote-tracking branch 'adafruit/main' into rp2040_flash 2021-03-22 15:29:43 -07:00
Jeff Epler
904e94abeb make declatations of usb_msc_ routines conditional
.. as suggested by @dhalbert
2021-03-22 15:04:57 -05:00
Linar Yusupov
76c1ae7194 fix for MX25R1635F QSPI mode of operation 2021-03-22 09:12:26 +03: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
Jeff Epler
1e5ffe1a53 Revert "circuitpy_mpconfig: Disable flash multi-partition"
This reverts commit 156ee4833a.
2021-03-09 11:08:36 -06:00
Scott Shawcroft
b5a955a168
Merge pull request #4354 from jepler/disable-fat-partition
circuitpy_mpconfig: Disable flash multi-partition
2021-03-08 15:25:58 -08:00
Jeff Epler
32475ce98c Automatically count EXTERNAL_FLASH_DEVICES (mk2)
Instead of counting words in make, which is slightly awful, notice that
possible_devices is local to external_flash.c, so we can declare the array
with an automatic bound, and then get the count as the element-count
(MP_ARRAY_SIZE) of the array.

Since EXTERNAL_FLASH_DEVICE_COUNT is no longer a global macro, switch
a few sites to using EXTERNAL_FLASH_DEVICES in `#if` checks instead.
2021-03-07 12:51:47 -06:00
Jeff Epler
f1ada8e880 Automatically count EXTERNAL_FLASH_DEVICES 2021-03-07 11:48:39 -06:00
Jeff Epler
156ee4833a circuitpy_mpconfig: Disable flash multi-partition
This adds some additional code in mkfs which doesn't seem necessary, and
Disabling it saves 172 bytes flash.

Testing performed: Using a Feather M0 Adalogger, checked that
 * an sdcard could still be mounted (using adafruit_sdcard)
 * os.listdir() of "/" and "/sd" worked
 * CIRCUITPY still mounted
2021-03-07 09:37:18 -06:00
jun2sak
51c7a49853 Merge branch 'main' into nrf52-sleep 2021-03-07 20:50:53 +09:00
Dan Halbert
cd48c5ee83
Merge pull request #4315 from dhalbert/rp2040-i2c-short-writes
RP2040: Implement short I2C writes (2 bytes or less) using bitbangio
2021-03-03 12:42:47 -05:00
Dan Halbert
0a58d451ad
Merge pull request #4306 from Neradoc/fix-reset-to-safe
press reset to safe mode on ports where reset reason is not implemented
2021-03-02 15:44:52 -05:00
Dan Halbert
f31b472309 Merge remote-tracking branch 'adafruit/main' into rp2040-i2c-short-writes 2021-03-02 15:17:12 -05:00
Dan Halbert
9939c59caa wip 2021-03-02 15:16:55 -05:00
Neradoc
7441625f37 allow the safe mode danse if RESET_REASON_UNKNOWN 2021-03-02 00:41:43 +01:00
Radomir Dopieralski
121c6bcc9b Replace displaio.Group.children with a python list
This is a first go at it, done by naive replacing of all array
operations with corresponding operations on the list. Note that
there is a lot of unnecessary type conversions, here. Also, list_pop
has been copied, because it's decalerd STATIC in py/objlist.h
2021-02-27 20:52:38 +01:00
Radomir Dopieralski
6e0ce23f3e displaio: don't store group children native object
Since we want to expose the list of group's children to the user,
we should only have the original objects in it, without any other
additional data, and compute the native object as needed.
2021-02-27 20:52:38 +01:00
Radomir Dopieralski
8c8d60fb80 Fix for CIRCUITPY_USB_MSC=0
Avoid undefined functions when MSC is disabled.
2021-02-27 15:05:00 +01:00
Kamil Tomaszewski
ef3a61432b Add the missing argument to the HID functions 2021-02-24 19:09:17 +01:00
jun2sak
9661d67cd3 replace MY_DEBUG_UART -> NRF_DEBUG_PRINT. 2021-02-25 01:49:57 +09:00
jun2sak
105042e870 move dump_xxx functions to debug_uart.c. 2021-02-23 12:22:33 +09:00
Jeff Epler
aa1de69645 fix length of generated serial number descriptor 2021-02-22 07:33:04 -06:00
Jeff Epler
144acfcb98 USB descriptors: Save flash storage for serial number
This saves about 60 bytes (Feather M4 went from 45040 -> 45100 bytes free)
66 bytes of data eliminated, but 6 bytes paid back to initialize the length
field.
2021-02-21 21:24:49 -06:00
jun2sak
1da8b9900a Merge branch 'main' into nrf52-sleep 2021-02-21 13:35:06 +09:00
jun2sak
d659c2ce34 move port-specific debug functions from supervisor/shared/serial.c to ports/nrf/supervisor/port.c 2021-02-21 09:55:10 +09:00
jun2sak
26f8f532f1 safe mode fix. 2021-02-21 00:47:07 +09:00
Dan Halbert
e344c6d684 fix some builds 2021-02-18 14:24:58 -05:00
jun2sak
e6350ff834 Initial commit. 2021-02-17 20:53:18 +09:00
Dan Halbert
0b8f1b9a90 wip: usb_cdc.serials 2021-02-15 20:06:18 -05:00
Dan Halbert
d54b5861a3 wip 2021-02-12 19:01:14 -05:00
Dan Halbert
f0564b4986 merge from upstream; complicated webusb merge 2021-02-11 18:50:02 -05:00
Dan Halbert
1b7f3d11e7 wip 2021-02-08 10:57:41 -05:00
Dan Halbert
5bb722b927
Merge pull request #4122 from hathach/fix-3986
Fix 3986 background reset remove existing usb callback
2021-02-05 09:13:28 -05:00
Dan Halbert
0802b22ed6 usb descriptors all set; rework of enabling for USB devices 2021-02-04 19:23:40 -05:00
Kevin Banks
c4a795b1e7 Changed URL 2021-02-04 16:31:18 -06:00
hathach
8d7b1f9e8c add usb_background_schedule()
unconditionally schedule usb background after
background_callback_reset()
2021-02-04 16:00:14 +07:00
Kevin Banks
215a56c920 Merge branch 'main' into webusb (trying to get CI back online) 2021-02-03 16:48:28 -06:00
hathach
e699a59890 hack to fix 3986
just a proof to show that issue analysis is correct
2021-02-03 11:01:33 +07:00
Kevin Banks
1b031508e1 BOS and MS_OS_2.0 descriptors have been added. Still more descriptor work TODO. 2021-01-26 20:43:19 -06:00
Kevin Banks
fbfb7b68cc Most of the code we need has been pulled in from the tinyusb webusb_serial demo. Still LOTS to do regarding descriptors. 2021-01-25 20:37:58 -06:00
Christian Walther
8889ac12e1 Add supervisor.set_next_code() function (prototype).
Part of #1084.
2021-01-23 23:05:31 +01:00
Scott Shawcroft
b73b30ff9f
Switch to upstream TinyUSB 2021-01-21 11:33:13 -08:00
Scott Shawcroft
af8cc9345d
Fix ESP build 2021-01-21 10:24:21 -08:00
Scott Shawcroft
733094aead
Add initial RP2040 support
The RP2040 is new microcontroller from Raspberry Pi that features
two Cortex M0s and eight PIO state machines that are good for
crunching lots of data. It has 264k RAM and a built in UF2
bootloader too.

Datasheet: https://pico.raspberrypi.org/files/rp2040_datasheet.pdf
2021-01-20 19:16:56 -08:00
Jeff Epler
1ca29ec47c Merge remote-tracking branch 'origin/main' into audioout-esp32 2021-01-12 09:23:07 -06:00
Dan Halbert
047708e36e
Merge pull request #3973 from kattni/update-code-py
Update created code.py file formatting.
2021-01-11 19:56:18 -05:00
Kattni Rembor
09596ddca2 Adding escape characters. 2021-01-11 16:26:27 -05:00
Kattni Rembor
9e9291777f Update created code.py file formatting. 2021-01-11 16:09:05 -05:00
Jeff Epler
e20c65d8f0 background tasks: Add, use port_wake_main_task
Some ports need an extra operation to ensure that the main task is
awoken so that a queued background task will execute during an ongoing
light sleep.

This removes the need to enable supervisor ticks while I2SOut is operating.

Closes: #3952
2021-01-09 14:02:47 -06:00
Dan Halbert
255ffa979c avoid inline compile errors 2021-01-08 23:07:21 -05:00
DavePutz
ce55822680
Fix size of memset in board_reset_user_neopixels() 2021-01-04 15:50:09 -06:00
Dan Halbert
938a0fa2fc
Add include to tick.c for mp_hal_is_interrupted() 2020-12-26 13:39:48 -05:00
Dan Halbert
8061a2574d
Merge branch 'main' into pin_alarm 2020-12-23 22:05:02 -05:00
Scott Shawcroft
8b5b602ea7
Merge pull request #3862 from dhalbert/storage-remount
unmounted filesystems start as ejected
2020-12-22 10:11:54 -08:00
Dan Halbert
f226f4a233
Merge pull request #3864 from djix123/w25q64fv
Add support for Winbond W25Q64FV
2020-12-22 09:29:22 -05:00
Jonathan Giles
17e7973ff2 Add support for Winbond W25Q64FV 2020-12-22 07:50:56 -05:00
Dan Halbert
3b4c14f3ec unmounted filesystems start as ejected 2020-12-21 20:43:46 -05:00
Dan Halbert
233ccaac58
Merge pull request #3824 from skerr92/add_more_spi_flash
Adding Support for AT25DF641A SPI Flash
2020-12-21 14:48:36 -05:00
Hany Elkomy
70a9c601a8
Update devices.h
Correct capacity value for the MX25R1635F from 0x18 to 0x15 (tested and working)
refer to 
https://github.com/adafruit/circuitpython/issues/3558
2020-12-17 12:52:51 +08:00
Seth Kerr
ca757f2ead removed comments on 64MiB SPI flash causing build test issues 2020-12-16 10:25:20 -05:00
Scott Shawcroft
1ad49d9a18
Add alarm.pin that wakes on pin level
Fixes #3787
2020-12-15 18:12:59 -08:00
Seth Kerr
6d8642bf41 fixing line comment issue with CI build tests 2020-12-14 17:17:28 -05:00
Seth Kerr
731cdefe80 this should be it. 2020-12-14 16:25:33 -05:00
Scott Shawcroft
0b4bcd9599
Fix build and more comments 2020-12-08 13:05:21 -08: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
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
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
7ca36d45a4 Fix align32_size().
It not only caused crashes with requests larger than 64K (can happen with RGBMatrix), but also generated a lot longer code than necessary.
2020-11-28 17:54:34 +01:00
Christian Walther
2ba9805f84 Use movable allocation system for terminal tilegrid.
Moving memory is now done by the infrastructure and neither necessary nor correct here anymore.
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
Dan Halbert
e308a9ec11 working! PinAlarm not implemented yet. 2020-11-27 16:03:37 -05:00
Dan Halbert
ef0830bfe2 merge from upstream + wip 2020-11-25 17:52:06 -05:00
Dan Halbert
7a45afc549 working, but need to avoid deep sleeping too fast before USB ready 2020-11-23 22:44:53 -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
Dan Halbert
e4c66990e2 compiles 2020-11-20 23:33:39 -05:00
Dan Halbert
39e1f52e28 wip; not compiling yet 2020-11-19 17:47:12 -05:00
Dan Halbert
649c930536 wip 2020-11-19 15:43:39 -05:00
Jeff Epler
331aa6e59f displayio: When the display is tall, move blinka above the text
This makes a more useful display on the portrait magtag, allowing 21
characters across instead of just 18.  There are 20 full rows of text,
instead of 21.  The total number of characters increases slightly from 378
to 420.

For comparison, the Commodore VIC 20 had 22 rows of 23 characters for a
total of 506 characters. :-P
2020-11-19 11:43:18 -06:00
Dan Halbert
ffff02c053 Merge remote-tracking branch 'adafruit/main' into sleep 2020-11-16 12:06:11 -05:00
Dan Halbert
bb77f1d130 wip: initial code changes, starting from @tannewt's sleepio branch 2020-11-16 11:56:20 -05:00
Scott Shawcroft
bda3267432
Save flash space
* No weak link for modules. It only impacts _os and _time and is
  already disabled for non-full builds.
* Turn off PA00 and PA01 because they are the crystal on the Metro
  M0 Express.
* Change ejected default to false to move it to BSS. It is set on
  USB connection anyway.
* Set sinc_filter to const. Doesn't help flash but keeps it out of
  RAM.
2020-11-13 18:57:52 -08:00
Dan Halbert
144eb131ae
Merge pull request #3627 from adafruit/6.0.x
Merge 6.0.x bugfixes to main
2020-10-31 12:28:20 -04:00
Dan Halbert
345d84ffde improve USB CDC disconnect/reconnect checking 2020-10-30 22:25:50 -04:00
Scott Shawcroft
9a4efed8cb
Start tweaking the workflow to sleep 2020-10-27 17:55:03 -07:00
Jeff Epler
3c05a8c68c
Merge pull request #3482 from cwalther/alloc
Fix inconsistent supervisor heap
2020-10-16 21:31:32 -05:00
Scott Shawcroft
379e73af2e
Finer grained, per port tick locking
Fixes #3504 hopefully.
2020-10-12 18:43:21 -07:00
Scott Shawcroft
09bc415751
Unify iMX flash config and add Metro M7 1011
This unifies the flash config to the settings used by the Boot ROM.
This makes the config unique per board which allows for changing
quad enable and status bit differences per flash device. It also
allows for timing differences due to the board layout.

This change also tweaks linker layout to leave more ram space for
the CircuitPython heap.
2020-10-07 15:23:47 -07: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
d62ac24493
Merge pull request #3469 from jepler/noreturn
Add some NORETURN attributes
2020-10-01 11:18:36 -07:00
microDev
4c7d9e3aaf
Update make translate script 2020-09-29 11:14:30 +05:30
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
Jeff Epler
6bcbe51f7f supervisor: stub: make unimplemented safe_mode loop forever 2020-09-24 16:57:20 -05:00
Jeff Epler
28043c94b5 supervisor: Improve serial connection detection
These changes remove the caveat from supervisor.runtime.serial_connected.

It appears that _tud_cdc_connected() only tracks explicit changes to the
"DTR" bit, which leads to disconnects not being registered.

Instead:
 * when line state is changed explicitly, track the dtr value in
   _serial_connected
 * when the USB bus is suspended, set _serial_connected to False

Testing performed (using sam e54 xplained):  Run a program to show
the state of `serial_connected` on the LED:
```
import digitalio
import supervisor
import board

led = digitalio.DigitalInOut(board.LED)
while True:
    led.switch_to_output(not supervisor.runtime.serial_connected)
```

Try all the following:
 * open, close serial terminal program
    - LED status tracks whether terminal is open
 * turn on/off data lines using the switchable charge-only cable
    - LED turns off when switch is in "charger" position
    - LED turns back on when switch is in Data position and terminal is
      opened (but doesn't turn back on just because switch position is
      changed)
2020-09-17 18:32:06 -05:00
Scott Shawcroft
750bc1e04a
Merge pull request #3398 from jepler/better-dictionary-compression
compression: Implement @ciscorn's dictionary approach
2020-09-16 11:10:22 -07:00
Jeff Epler
d9e336d39f supervisor translate: explain the dictionary 2020-09-15 13:18:04 -05:00
microDev
506bb097f7
Update safe_mode.c 2020-09-13 23:17:14 +05:30
microDev
36da92075b Update safe mode reason 2020-09-13 22:57:24 +05:30
Taku Fukada
d18d79ac47 Small improvements to the dictionary compression 2020-09-14 01:50:01 +09:00
Jeff Epler
40ab5c6b21 compression: Implement ciscorn's dictionary approach
Massive savings.  Thanks so much @ciscorn for providing the initial
code for choosing the dictionary.

This adds a bit of time to the build, both to find the dictionary
but also because (for reasons I don't fully understand), the binary
search in the compress() function no longer worked and had to be
replaced with a linear search.

I think this is because the intended invariant is that for codebook
entries that encode to the same number of bits, the entries are ordered
in ascending value.  However, I mis-placed the transition from "words"
to "byte/char values" so the codebook entries for words are in word-order
rather than their code order.

Because this price is only paid at build time, I didn't care to determine
exactly where the correct fix was.

I also commented out a line to produce the "estimated total memory size"
-- at least on the unix build with TRANSLATION=ja, this led to a build
time KeyError trying to compute the codebook size for all the strings.
I think this occurs because some single unicode code point ('ァ') is
no longer present as itself in the compressed strings, due to always
being replaced by a word.

As promised, this seems to save hundreds of bytes in the German translation
on the trinket m0.

Testing performed:
 - built trinket_m0 in several languages
 - built and ran unix port in several languages (en, de_DE, ja) and ran
   simple error-producing codes like ./micropython -c '1/0'
2020-09-12 10:10:45 -05:00
microDev
4da478382d Fix serial console output & add more boards 2020-09-12 17:46:52 +05:30
microDev
305bed6d9e Added esp32s2 safe_mode & fixed user_safe_mode 2020-09-11 21:06:54 +05:30
Scott Shawcroft
1ba28b3edc
Merge pull request #3370 from jepler/compression-bigrams
add bigram compression to makeqstrdata (save ~100 bytes on trinket m0 de_DE)
2020-09-10 11:44:56 -07:00
Jeff Epler
0eee93729a Fix decompression of unicode values above 2047
Two problems: The lead byte for 3-byte sequences was wrong, and one
mid-byte was not even filled in due to a missing "++"!

Apparently this was broken ever since the first "Compress as unicode,
not bytes" commit, but I believed I'd "tested" it by running on the
Pinyin translation.

This rendered at least the Korean and Japanese translations completely
illegible, affecting 5.0 and all later releases.
2020-09-08 20:54:47 -05:00
Jeff Epler
bdb07adfcc translations: Make decompression clearer
Now this gets filled in with values e.g., 128 (0x80) and 159 (0x9f).
2020-09-08 19:07:53 -05:00
Scott Shawcroft
99f5011d74
Fix heap without PSRAM. Never set heap_size. 2020-09-08 17:06:09 -07:00
Scott Shawcroft
96cf60fbbd
Merge remote-tracking branch 'adafruit/main' into native_wifi 2020-09-03 16:34:56 -07:00
Scott Shawcroft
786f4ed114
Merge pull request #3344 from jepler/issue-3184
Fix RGBMatrix, FrameBufferDisplay bugs
2020-09-02 15:32:30 -07:00
Jeff Epler
07740d19f3 add bigram compression to makeqstrdata
Compress common unicode bigrams by making code points in the range
0x80 - 0xbf (inclusive) represent them.  Then, they can be greedily
encoded and the substituted code points handled by the existing Huffman
compression.  Normally code points in the range 0x80-0xbf are not used
in Unicode, so we stake our own claim.  Using the more arguably correct
"Private Use Area" (PUA) would mean that for scripts that only use
code points under 256 we would use more memory for the "values" table.

bigram means "two letters", and is also sometimes called a "digram".
It's nothing to do with "big RAM".  For our purposes, a bigram represents
two successive unicode code points, so for instance in our build on
trinket m0 for english the most frequent are:
['t ', 'e ', 'in', 'd ', ...].

The bigrams are selected based on frequency in the corpus, but the
selection is not necessarily optimal, for these reasons I can think of:
 * Suppose the corpus was just "tea" repeated 100 times.  The
   top bigrams would be "te", and "ea".  However,
   overlap, "te" could never be used.  Thus, some bigrams might actually
   waste space
    * I _assume_ this has to be why e.g., bigram 0x86 "s " is more
      frequent than bigram 0x85 " a" in English for Trinket M0, because
      sequences like "can't add" would get the "t " digram and then
      be unable to use the " a" digram.

 * And generally, if a bigram is frequent then so are its constituents.
   Say that "i" and "n" both encode to just 5 or 6 bits, then the huffman
   code for "in" had better compress to 10 or fewer bits or it's a net
   loss!
    * I checked though!  "i" is 5 bits, "n" is 6 bits (lucky guess)
      but the bigram 0x83 also just 6 bits, so this one is a win of
      5 bits for every "it" minus overhead.  Yay, this round goes to team
      compression.
    * On the other hand, the least frequent bigram 0x9d " n" is 10 bits
      long and its constituent code points are 4+6 bits so there's no
      savings, but there is the cost of the table entry.
    * and somehow 0x9f 'an' is never used at all!

With or without accounting for overlaps, there is some optimum number
of bigrams.  Adding one more bigram uses at least 2 bytes (for the
entry in the bigram table; 4 bytes if code points >255 are in the
source text) and also needs a slot in the Huffman dictionary, so
adding bigrams beyond the optimim number makes compression worse again.

If it's an improvement, the fact that it's not guaranteed optimal
doesn't seem to matter too much.  It just leaves a little more fruit
for the next sweep to pick up.  Perhaps try adding the most frequent
bigram not yet present, until it doesn't improve compression overall.

Right now, de_DE is again the "fullest" build on trinket_m0.  (It's
reclaimed that spot from the ja translation somehow)  This change saves
104 bytes there, increasing free space about 6.8%.  In the larger
(but not critically full) pyportal build it saves 324 bytes.

The specific number of bigrams used (32) was chosen as it is the max
number that fit within the 0x80..0xbf range.  Larger tables would
require the use of 16 bit code points in the de_DE build, losing savings
overall.

(Side note: The most frequent letters in English have been said
to be: ETA OIN SHRDLU; but we have UAC EIL MOPRST in our corpus)
2020-09-01 17:12:22 -05:00
Jeff Epler
9bd2a61d8b supervisor: Always allocate at least a 1x1 terminal
Otherwise, out of range writes would occur in tilegrid_set_tile, causing a safe mode reset.
```
Hardware watchpoint 6: -location *stack_alloc->ptr

Old value = 24652061
New value = 24641565
0x000444f2 in common_hal_displayio_tilegrid_set_tile (self=0x200002c8 <supervisor_terminal_text_grid>, x=1, y=1, tile_index=0 '\000')
    at ../../shared-module/displayio/TileGrid.c:236
236	    if (!self->partial_change) {
(gdb)
```
2020-09-01 10:55:45 -05:00
Dan Halbert
6dbd369272 merge from upstream 2020-08-30 14:39:03 -04:00
Scott Shawcroft
767ca5c3dc
Merge remote-tracking branch 'adafruit/main' into native_wifi 2020-08-27 11:42:31 -07:00
Jeff Epler
2e0a109331
Merge pull request #3318 from jepler/interrupt-serial-rx
supervisor: check for interrupt during rx_chr
2020-08-25 21:01:33 -05:00
Scott Shawcroft
8b71e26abd
Merge remote-tracking branch 'adafruit/main' into native_wifi 2020-08-25 16:39:23 -07:00
Scott Shawcroft
2b470b1486
Fix RGB LED use 2020-08-24 18:29:50 -07:00
Jeff Epler
1033e89561 supervisor: use mp_handle_pending to check for exceptions 2020-08-23 09:12:01 -05:00
Jeff Epler
f8a9e11ff4 WIP supervisor: check for interrupt during rx_chr 2020-08-23 08:47:18 -05:00
Dan Halbert
f714f53552 Merge remote-tracking branch 'adafruit/main' into ble_hci 2020-08-21 10:45:05 -04:00
Dan Halbert
0e30dd8bcc merge from upstream; working; includes debug_out code for debugging via Saleae for posterity 2020-08-20 20:29:57 -04:00
Jeff Epler
23aefe9509 Add usb-endpoint-count checking
.. however, the number of endpoints is only set for SAMD (8).
Other ports need to set the value.  Otherwise, the build will show
the message
```
Unable to check whether maximum number of endpoints is respected
```
2020-08-19 16:47:40 -05:00
Scott Shawcroft
9602ee6265
Disable wifi debug logging and memory log 2020-08-19 14:23:28 -07:00
Scott Shawcroft
ddcff85fa2
Add debugging. Scanning doesn't crash but returns no results. Need to config station. 2020-08-19 14:22:12 -07:00
Scott Shawcroft
1a6f4e0fe0
Scanning WIP. Need to sort out supervisor memory 2020-08-19 14:22:12 -07:00
Scott Shawcroft
d01f5dc0bd
Turn off terminalio for ja and ko
The font is missing many characters and the build needs the space.
We can optimize font storage when we get a good font.

The serial output will work as usual.
2020-08-17 17:17:59 -07:00
Jeff Epler
759ded9c38 Fix build errors when SHARPDISPLAY && !RGBMATRIX 2020-08-12 07:39:12 -05:00
Jeff Epler
c1400bae9b sharpmemory: Implement support for Sharp Memory Displays in framebufferio 2020-08-12 07:32:18 -05:00
Scott Shawcroft
bbac68e77c
Merge pull request #3232 from hierophect/esp32-neopixel
ESP32-S2: Add Neopixel support
2020-08-11 11:04:39 -07:00
Lucian Copeland
4613b58a31 Add skip for rgb matrix exception handling 2020-08-10 18:00:50 -04:00
Lucian Copeland
d47bd5529c Fix neopixel macro issue, set default neopixel color 2020-08-10 13:16:20 -04:00
Lucian Copeland
78d049d0f1 Fix pwm reset spew, protect against null reference in led status 2020-08-05 14:05:53 -04:00
Lucian Copeland
14b3b51c58 Rework build flags, prevent idf errors 2020-08-04 18:40:24 -04:00
Jeff Epler
710c2dc54b safe_mode: Exclude NORDIC_SOFT_DEVICE_ASSERT str if possible 2020-08-04 14:45:45 -05:00
Dan Halbert
0a60aee3e4 wip: compiles 2020-08-02 11:36:38 -04:00
Jeff Epler
d4801b8c54
Merge pull request #3225 from hathach/improve-highspeed-usb
Improve highspeed usb
2020-07-30 07:15:20 -05:00
Scott Shawcroft
b76d37f24a
Merge pull request #3223 from dhalbert/unmount-before-reset
storage.erase_filesystem(): disconnect from USB and wait 1 second before resetting
2020-07-29 10:47:24 -07:00
hathach
1f4fcb399b
move CFG_TUSB_RHPORT0_MODE into generated header 2020-07-29 16:05:31 +07:00
hathach
d8fef207d2 remove obsolete CFG in tusb_config.h 2020-07-29 15:45:01 +07:00
hathach
6063828279 replace USB_MSC_MAX_PACKET_SIZE with USB_HIGHSPEED in descriptor gen tool 2020-07-29 15:38:55 +07:00
Dan Halbert
65c22aa434 storage.erase_filesystem(): unmount and wait 1 second before resetting 2020-07-28 17:52:56 -04:00
Scott Shawcroft
2bd6d05663
Add externs. GCC10 complains about duplicate defines 2020-07-22 16:26:46 -07:00
Jeff Epler
9fd10322fe supervisor: rename some locals for clarity
It's perfectly OK for these variables with static linkage to have the
same name, but it's inconvenient for humans like me.
2020-07-20 08:45:31 -05:00
Jeff Epler
db43c56f79 background callbacks: Clear any callbacks that were queued
Before this, a background callback that was on the list when
background_callback_reset was called could have ended up in a state
that made it "un-queueable": its "prev" pointer could have been non-NULL.
2020-07-20 08:44:39 -05:00
Jeff Epler
98eef79faa background_callback_gc_collect: We must traverse the whole list 2020-07-17 14:55:46 -05:00
Jeff Epler
a18a392109 background_callback: Add gc collect callback
A background callback must never outlive its related object.  By
collecting the head of the linked list of background tasks, this will
not happen.

One hypothetical case where this could happen is if an MP3Decoder is
deleted while its callback to fill its buffer is scheduled.
2020-07-17 08:36:26 -05:00
Jeff Epler
81105cb9ef supervisor: usb: note that it's unusual to need to call usb_background 2020-07-15 11:49:44 -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
Jeff Epler
36b4646516 background_callback: Avoid CALLBACK_CRITICAL_BEGIN with nothing to do
CALLBACK_CRITICAL_BEGIN is heavyweight, but we can be confident we do
not have work to do as long as callback_head is NULL.

This gives back performance on nRF.
2020-07-15 09:26:47 -05:00
Jeff Epler
8c4a9f6444 supervisor: tick: only run background tasks once per tick 2020-07-15 09:26:47 -05:00
Jeff Epler
1474fccd2f supervisor: Add a linked list of background callbacks
In time, we should transition interrupt driven background tasks out of the
overall run_background_tasks into distinct background callbacks,
so that the number of checks that occur with each tick is reduced.
2020-07-15 09:26:47 -05:00
Jeff Epler
51b9a1aeca tick.c: adjust whitespace 2020-07-15 09:26:47 -05:00
Dan Halbert
f6869c69c5 wip: advertising; not tested 2020-07-12 19:45:23 -04: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
1a0c10c328
Fix debug UART call 2020-06-29 17:15:01 -07:00
Dan Halbert
759929c24a hci early wip; refactor supervisor bluetooth.c for nrf: tested 2020-06-25 20:57:17 -04:00
Jeff Epler
076a96ccc6
Merge pull request #3046 from jepler/same51
Add basic SAM E54  support and SAM E54 Xplained board
2020-06-25 06:55:27 -05:00
Jeff Epler
87835c77e8
Merge pull request #3038 from jepler/compute-usb-devices
Compute USB_DEVICES instead of requiring it to be specified
2020-06-24 13:31:56 -05:00
Jeff Epler
bf460ddf25
supervisor.mk: Conditionally assign USB_DEVICES
This restores the ability to remove CDC and/or MSC, at the price of
giving up the new automatic check that USB_DEVICES is correct.
Since devices have to have CDC and MSC to be "CircuitPython",
this is not a facility that is going to be used by any in-tree drivers.
2020-06-24 09:44:45 -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
Scott Shawcroft
741e1d9828
Merge pull request #3043 from DavePutz/Issue-2865
Issue #2865 -Clean up after ctrl-c interrupt in sleep
2020-06-23 10:58:45 -07:00
DavePutz
b80abf1a90
Update handing of a CTRL-C exception 2020-06-23 12:15:01 -05:00
Jeff Epler
d5074220a8 atmel-samd: Add SAM E54 Xplained board
Few peripherals are actually tested.  However, USB, I2C and GPIO seem to work.

Most pins are silkscreened with the "PX00" style, so the board module
only includes the small number that are screened differently.

The default SPI, I2C, and UART are the ones on the EXT2 header.  This is
arbitrary, but the I2C on this connector is shared with the on-board I2C
devices and the PCC header, making it the most versatile.
2020-06-23 10:41:48 -05:00
DavePutz
65512cef1c
Update tick.c 2020-06-22 15:59:15 -05:00
Jeff Epler
de14b5b02f flash: Correctly signal error on invalid flash read
This logic was intended to mirror what is done for "write", but
the wrong variable name was repeated twice.
2020-06-22 10:24:21 -05:00
DavePutz
182a8733a4
Rework handling of ctrl-c interrupt 2020-06-21 13:28:26 -05:00
DavePutz
0b52359190
Generate stacktrace and reset exception for ctrl-c interrupt
Added code in mp_hal_delay_ms() to generate stacktrace and reset exception for ctrl-c interrupt
2020-06-19 19:02:43 -05:00
Jeff Epler
8bbd539031 supervisor.mk: Compute what USB_DEVICES should be, and check it against what it is 2020-06-15 19:14:57 -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
Scott Shawcroft
323cca8910
Merge remote-tracking branch 'adafruit/master' into wdt-nrf 2020-06-01 15:18:12 -07:00
Brian Dean
cf888dc02b .../devices.h: Add GigaDevices GD25S512MD 64 MiB flash chip support. 2020-05-29 15:40:56 -04:00
Scott Shawcroft
2fd7a43f2f
Merge remote-tracking branch 'adafruit/master' into wdt-nrf 2020-05-29 10:16:24 -07:00
Jeff Epler
d0f9b5901e translations: document the compressed format 2020-05-28 11:30:46 -05:00
Jeff Epler
fe3e8d1589 string compression: save a few bits per string
Length was stored as a 16-bit number always.  Most translations have
a max length far less.  For example, US English translation lengths
always fit in just 8 bits.  probably all languages fit in 9 bits.

This also has the side effect of reducing the alignment of
compressed_string_t from 2 bytes to 1.

testing performed: ran in german and english on pyruler, printed messages
looked right.

Firmware size, en_US
Before: 3044 bytes free in flash
After: 3408 bytes free in flash

Firmware size, de_DE (with #2967 merged to restore translations)
Before: 1236 bytes free in flash
After: 1600 bytes free in flash
2020-05-28 08:36:08 -05:00
Sean Cross
c7efc94a33 watchdog: move timeout exception to shared-bindings
Make this exception globally available to all platforms that have
enabled the watchdog timer.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-05-27 11:28:49 +08:00
Sean Cross
15530a69c7 supervisor: tick: check for watchdog exception if enabled
Check to see if the current exception is a Watchdog exception, if it's
enabled. This ensures we break out of the current sleep() if a watchdog
timeout hits.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-05-27 11:28:49 +08:00
Sean Cross
8c5df5f732 supervisor: add a new WATCHDOG_RESET safe mode reason
This mode will be used if the board is reset due to the watchdog
expiring.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-05-27 11:28:49 +08:00
Sean Cross
ec99dae953 tick: break on watchdog timeout exception
Signed-off-by: Sean Cross <sean@xobs.io>
2020-05-27 11:28:49 +08:00
Sean Cross
d1a7fdd9d4 supervisor: support debugging tinyusb
Allow for passing `-DCFG_TUSB_DEBUG=1` or `-DCFG_TUSB_DEBUG=2` on the
command line to enable debugging tinyusb within circuitpython.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-05-21 21:35:30 +08:00
Scott Shawcroft
916ca9f8a6
Merge pull request #2910 from tannewt/esp32s2
Add initial ESP32S2 support
2020-05-19 12:53:23 -07:00
Sean Cross
34f91f01c6 bleio: adapter: add advertising timeout and status
Add a field to allow specifying a timeout when initiating advertising.
As part of this, add a new property to determine if the device is still
advertising.

Additionally, have the `anonymous` property require a timeout, and set
the timeout to the maximum possible value if no timeout is specified.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-05-19 15:01:19 +08:00
Sean Cross
cfe65742a3 _bleio: support anonymous advertising
Add a new parameter to the `start_advertising()` function to enable
anonymous advertising.  This forces a call to `sd_ble_gap_privacy_set()`
with `privacy_mode` set to `BLE_GAP_PRIVACY_MODE_DEVICE_PRIVACY` and
`private_addr_type` set to
`BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE`.

With this, addresses will cycle at a predefined rate (currently once
every 15 minutes).

Signed-off-by: Sean Cross <sean@xobs.io>
2020-05-19 15:01:18 +08:00
Scott Shawcroft
2c2b53303d
Merge pull request #2837 from k0d/serial-debug
Add support for a debug console, such as ST-Link VCP.
2020-05-18 18:13:31 -07:00
Mark Olsson
007c92ee6a Enable showing the console on a debug uart 2020-05-19 02:02:52 +02:00
Scott Shawcroft
6aaab005c5
Initial ESP32S2 port.
Basic blinky works but doesn't check pins.
2020-05-15 15:36:16 -07:00
Max Holliday
964040b770 More erroneous else statements 2020-05-09 12:16:04 -07:00
Max Holliday
8b6587a0c6 Unified single_status_byte & no_reset_cmd behavior 2020-05-09 12:09:01 -07:00
Max Holliday
9e01bb2136 Removing erroneous else statements 2020-05-09 12:03:26 -07:00
Max Holliday
9ef28d8536 Replacing device that was accidentally deleted 2020-05-09 12:00:59 -07:00
Dan Halbert
c377d4bea7
Merge branch 'master' into non-standard-nvm 2020-05-04 16:08:45 -04:00
Brian Dean
28179a3aaf .../external_flash.c: Don't attempt to issue CMD_READ_STATUS2 for
devices with only a single_status_byte.
2020-05-03 18:33:01 -04:00
Max Holliday
cc290c50c6 fixing diff error 2020-04-28 18:15:38 -07:00
Max Holliday
6c4decd4e2 decoupling chip specific functions from EXTERNAL_FLASH_QSPI_SINGLE 2020-04-28 11:51:07 -07:00
Scott Shawcroft
755d404edf
Merge remote-tracking branch 'adafruit/master' into lower_power 2020-04-27 16:45:10 -07:00
Max Holliday
86943ca8a1 Merge remote-tracking branch 'adafruit/master' 2020-04-27 13:51:51 -07:00
Scott Shawcroft
9e4b94f466
Merge pull request #2805 from tannewt/update_tinyusb
Update tinyusb
2020-04-26 20:55:36 -07:00
Scott Shawcroft
dcb0e50f04
Fix USB midi and hid disable. 2020-04-21 14:15:44 -07:00
Sean Cross
05b5356acc external_flash: add support for mx25r1635f
This flash chip is used in Simmel.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-04-21 09:56:05 +08: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
Jeff Epler
5fcc6d6286 RGBMatrix: finish renaming from Protomatter
This gets all the purely internal references.  Some uses of
protomatter/Protomatter/PROTOMATTER remain, as they are references
to symbols in the Protomatter C library itself.
2020-04-17 18:44:07 -05:00
Scott Shawcroft
7e3d4c61b5
Update TinyUSB and add interrupt hooks. 2020-04-17 14:16:49 -07:00
Lucian Copeland
54abfc2e8b translations-merge 2020-04-15 10:29:05 -04:00
Scott Shawcroft
b580b34cbf
Merge remote-tracking branch 'adafruit/master' into lower_power 2020-04-14 17:14:44 -07:00
Jeff Epler
d8362ef654 displayio: swap colors in palettes too
.. change the in-rom palette to be in RGB565 order
2020-04-14 18:25:00 -05:00
Jeff Epler
1f3821220e fix build for non-displayio & non-protomatter targets 2020-04-14 18:24:58 -05: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
Lucian Copeland
5ac38c95cc Various requested fixes 2020-04-13 12:03:05 -04:00
Max Holliday
826837186c adds standard (non-queued) SPI support to QSPI for external flash 2020-04-07 18:17:25 -07:00
Scott Shawcroft
c0ba2a839f
Updates based on feedback from jepler 2020-04-06 16:03:31 -07:00
Scott Shawcroft
e99cf6e441
Rework sleep timing
It didn't account for background task time and could end up
sleeping for way longer than it should because the RTC compare time
had already passed.
2020-04-03 18:07:56 -07:00
Lucian Copeland
9761672d42 Linker file restructure, TCM and MPU additions 2020-04-03 16:33:18 -04:00
Scott Shawcroft
c248730bd1
Clean up 2020-04-02 17:36:09 -07:00
Lucian Copeland
2f764ded63 merge and docs 2020-04-01 13:52:53 -04:00
Lucian Copeland
a89928c13c Implement requested changes 2020-04-01 13:02:05 -04:00
Scott Shawcroft
8fe512c7e9
Merge remote-tracking branch 'adafruit/master' into lower_power 2020-03-31 15:13:58 -07:00
Sean Cross
1902579b46 supervisor: enable itcm memory region for fomu
Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-31 09:40:38 +08:00
Brian Dean
b1d83c3f5e supervisor/shared/external_flash/devices.h: Add MX25L51245G support.
Add external flash support for Macronix MX25L51245G 64MiB SPI flash.
2020-03-25 17:16:09 -04:00
Scott Shawcroft
2623022c84
Initial work for STM32. Need to fix us delay and PulseIn still. 2020-03-20 12:58:34 -07:00
Scott Shawcroft
612ba2f45d
Fix DotStar status LED init. 2020-03-17 12:11:11 -07:00
Scott Shawcroft
4297ae2d0b
Fix DotStar status LED init. 2020-03-17 12:10:12 -07:00
Scott Shawcroft
7100d5e485
Fix autoreload and ticks in general 2020-03-13 16:13:24 -07:00
Scott Shawcroft
ed5cdd7e09
Hopefully fix flash flush and hopefully audio as well. 2020-03-13 11:12:31 -07:00
Scott Shawcroft
418333979a
Fix autoreload, neopixel, monotonic_ns and sleep w/o SD 2020-03-13 11:12:31 -07:00
Scott Shawcroft
6f60afe8c5
First try at lowering the power consumption 2020-03-13 11:12:30 -07:00
Jeff Epler
415cb351c7
Merge pull request #2655 from jepler/thing51
samd51 thing plus: new port
2020-02-25 14:13:47 -06:00
jepler
f20255813f samd51 thing plus: new port
testing performed:
 * successfully store and retrieve a 500kB file on the flash
 * square wave output on each pin appears on o'scope
 * board.SPI(), board.SERIAL(), board.I2C() all construct
2020-02-25 11:52:23 -06:00
Scott Shawcroft
876c646d09
Fix Mac crash when waking up with an ejected CIRCUITPY
We now correctly set the reason for the unit not being ready and
always start the unit.

Fixes #2567
2020-02-24 15:40:52 -08:00
Scott Shawcroft
e8f7141564
Disable BLE file service for now
Fixes #2633
2020-02-20 12:15:56 -08:00
Scott Shawcroft
cde9b63eab
Merge pull request #2615 from mubes/label-drive
Allow drive name to be set per target
2020-02-12 10:43:04 -08:00
Dave Marples
bfca65d86f Allow drive name to be set per target, with fallback to pre-existing behaviour 2020-02-12 11:09:48 +00:00
Gadi Rotenberg
07708f1518 Added fix to allow remount when usb enabled but msc is ejected 2020-02-12 09:57:58 +02:00
Langston Nashold
76d8e5b399 Add support for external flash device Winbond.com W25Q80DV
Currently, we only support external flash device W25Q80DL. This
adds support for the W25Q80DL.

tweak
2020-02-06 16:46:43 -08:00
hierophect
898f4e1f72
Merge branch 'master' into stm32-meowbit 2020-01-29 16:32:08 -05:00
Lucian Copeland
3c86005546 Implement requested changes 2020-01-28 17:11:25 -05:00
Scott Shawcroft
b36b2493bc
Merge pull request #2532 from tannewt/teensy4-dev
Refine iMX RT memory layout and add three boards
2020-01-27 14:11:08 -08:00
Dan Halbert
6f13979c9b pygamer and pybadge boards were not resetting neopixels 2020-01-24 09:32:28 -05:00
Dan Halbert
68f9aee992 reset NeoPixels on CPB on soft reload 2020-01-23 20:16:31 -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
Hierophect
3f43155b63 Meowbit bus conflict WIP 2020-01-17 13:31:12 -05:00
Scott Shawcroft
5fc20145d1
Merge pull request #2390 from jepler/displayio-set-rotation
displayio: make 'rotation' property settable
2019-12-20 09:34:25 -08:00
Scott Shawcroft
561fdfb279
Improve USB eject by resetting on replug 2019-12-17 19:01:03 -08:00
Jeff Epler
a63da7a6c0 displayio: make 'rotation' property settable 2019-12-16 15:23:41 -06:00
Dan Halbert
ef2ef7a6b8 merge from master 2019-12-12 15:51:13 -05:00
Dan Halbert
1b3028bed1 make translate and remove backslash-r's 2019-12-12 14:51:50 -05:00
Dan Halbert
7889b999cc Fix flash write error handling; clean up safe mode message printing 2019-12-12 14:41:49 -05:00
Dan Halbert
8176325130 Merge remote-tracking branch 'adafruit/master' into ld-cleanup 2019-12-11 22:52:59 -05:00
Dan Halbert
68ae47907c merge from upstream 2019-12-10 21:04:46 -05:00
Dan Halbert
013c840862 working on all ports 2019-12-10 20:27:30 -05:00
Jeff Epler
f4a5c17b5e supervisor: external_flash: don't call m_free when it's bad
It's extremely dubious that we have these handles that we think
are to GC'd memory at a time when the gc pool may not be initialized.
Hopefully, they WERE valid GC memory and are undisturbed by the teardown
of the interpreter that can lead to this state.

In this case, don't try to m_free them, the memory will become free when
the GC heap is reinitialized.

Closes: #2338 (together with previous commit)
2019-12-10 17:07:20 -06:00
Jeff Epler
b22fbcd77d supervisor: external_flash: don't call m_malloc_maybe when it's bad 2019-12-10 17:06:09 -06:00
Scott Shawcroft
e8a54eacaa
Comment supervisor ble data arrays. 2019-12-06 11:13:22 -08:00
Dan Halbert
40434d6919 wip 2019-12-05 22:45:53 -05:00
Scott Shawcroft
17c8356b8c
Add connection interval and debugging
This also sets TinyUSB to master and to not include its submodules.

It also fixes an old displayio example comment and retries gattc
reads.
2019-12-04 14:39:02 -08:00
Scott Shawcroft
15886b1505
Merge pull request #2345 from jepler/compressed-unicode
translation: Compress as unicode, not bytes
2019-12-02 17:11:49 -08:00
Jeff Epler
e06a3bbceb translation: Compress as unicode, not bytes
By treating each unicode code-point as a single entity for huffman
compression, the overall compression rate can be somewhat improved
without changing the algorithm.  On the decompression side, when
compressed values above 127 are encountered, they need to be
converted from a 16-bit Unicode code point into a UTF-8 byte
sequence.

Doing this returns approximately 1.5kB of flash storage with the
zh_Latn_pinyin translation. (292 -> 1768 bytes remaining in my build
of trinket_m0)

Other "more ASCII" translations benefit less, and in fact
zh_Latn_pinyin is no longer the most constrained translation!
(de_DE 1156 -> 1384 bytes free in flash, I didn't check others
before pushing for CI)

English is slightly pessimized, 2840 -> 2788 bytes, probably mostly
because the "values" array was changed from uint8_t to uint16_t,
which is strictly not required for an all-ASCII translation.  This
could probably be avoided in this case, but as English is not the
most constrained translation it doesn't really matter.

Testing performed: built for feather nRF52840 express and trinket m0
in English and zh_Latn_pinyin; ran and verified the localized
messages such as
    Àn xià rènhé jiàn jìnrù REPL. Shǐyòng CTRL-D chóngxīn jiāzài.
and
    Press any key to enter the REPL. Use CTRL-D to reload.
were properly displayed.
2019-12-02 09:46:46 -06:00
Jeff Epler
95d9c49e43 Merge remote-tracking branch 'origin/master' into tick-refactor 2019-11-29 11:27:09 -06:00
Ayan Pahwa
718a28c886 update filesystem.c 2019-11-26 01:13:46 +05:30
Ayan Pahwa
5e1740d11f Not creating code.py file for non-express boards 2019-11-26 00:06:03 +05:30
Ayan Pahwa
9c6466cffb Fix build failure for boards with less memory 2019-11-25 22:31:01 +05:30
Ayan Pahwa
180b485f8b Enable creation of code.py only for full builds 2019-11-23 20:58:33 +05:30
Ayan Pahwa
262cfd4ea3 Passing address of char_written at f_write 2019-11-23 20:47:30 +05:30
Ayan Pahwa
5823f5ed04 Add \n to file end 2019-11-23 20:43:24 +05:30
Jeff Epler
46c5775ba4 supervisor: tick: add supervisor_fake_tick 2019-11-20 14:37:13 -06:00
Jeff Epler
a9baa0f954 supervisor: tick: document 2019-11-20 14:37:13 -06:00
Jeff Epler
70719597ab supervisor: tick: Rewrite without atomics 2019-11-20 14:37:13 -06:00
Ayan Pahwa
a0ef667a14 Supervisor: create code.py file with sample code 2019-11-19 01:59:29 +05:30
Jeff Epler
568636d562 run_background_tasks: Do nothing unless there has been a tick
This improves performance of running python code by 34%, based
on the "pystone" benchmark on metro m4 express at 5000 passes
(1127.65 -> 1521.6 passes/second).

In addition, by instrumenting the tick function and monitoring on an
oscilloscope, the time actually spent in run_background_tasks() on
the metro m4 decreases from average 43% to 0.5%. (however, there's
some additional overhead that is moved around and not accounted for
in that "0.5%" figure, each time supervisor_run_background_tasks_if_tick
is called but no tick has occurred)

On the CPB, it increases pystone from 633 to 769, a smaller percentage
increase of 21%.  I did not measure the time actually spent in
run_background_tasks() on CPB.

Testing performed: on metro m4 and cpb, run pystone adapted from python3.4
(change time.time to time.monotonic for sub-second resolution)

Besides running a 5000 pass test, I also ran a 50-pass test while
scoping how long an output pin was set.  Average: 34.59ms or 1445/s on m4,
67.61ms or 739/s on cbp, both matching the other pystone result reasonably
well.

import pystone
import board
import digitalio
import time

d = digitalio.DigitalInOut(board.D13)
d.direction = digitalio.Direction.OUTPUT

while True:
    d.value = 0
    time.sleep(.01)
    d.value = 1
    pystone.main(50)
2019-11-18 11:26:48 -06:00
Jeff Epler
7f744a2369 Supervisor: move most of systick to the supervisor
This code is shared by most parts, except where not all the #ifdefs
inside the tick function were present in all ports.  This mostly would
have broken gamepad tick support on non-samd ports.

The "ms32" and "ms64" variants of the tick functions are introduced
because there is no 64-bit atomic read.  Disabling interrupts avoids
a low probability bug where milliseconds could be off by ~49.5 days
once every ~49.5 days (2^32 ms).

Avoiding disabling interrupts when only the low 32 bits are needed is a minor
optimization.

Testing performed: on metro m4 express, USB still works and
time.monotonic_ns() still counts up
2019-11-18 11:01:23 -06:00
Hierophect
8ff1bc0132 add missing include 2019-11-15 12:49:47 -05:00
Hierophect
de5691acf5 Add never_reset and reset to pin common hal, adjust files 2019-11-15 12:47:00 -05:00
Thea Flowers
67ff1c92f0
Allow boards to change the "CircuitPython" text in their USB interface description.
In cases where more than one board is connected to a single computer it can become pretty hard to figure out which board you're actually talking to. For example, if you have several MIDI-compatible boards they all show up as "CircuitPython MIDI". This change allows boards to replace the "CircuitPython" part of their USB descriptors with more specific text, for example, "CircuitPython Feather" or just "Feather". This will let folks more easily tell boards apart.

The new option is named `USB_INTERFACE_NAME` and is available in `mkconfigboard.mk`. For example:

```
USB_INTERFACE_NAME = "Feather"
```
2019-11-12 13:29:35 -08:00
Thea Flowers
73989dbcaf Add board configuration for Winterbloom Sol 2019-11-04 23:11:42 -08:00
Dan Halbert
8cd2f87e99
Merge pull request #2236 from tannewt/bleio_tweaks
Refine _bleio
2019-11-04 22:27:54 -05:00
Scott Shawcroft
47e50e5659
Merge remote-tracking branch 'adafruit/master' into bleio_tweaks 2019-11-01 13:20:58 -07:00
Dan Halbert
99fe905039 Reduce DotStar status brightness; macros for status colors 2019-11-01 13:37:36 -04:00
Dan Halbert
ab6fd34828 add object types to rgb status objects;mark spi rgb objects as never_reset 2019-10-25 22:32:43 -04:00
Dan Halbert
cdeb0857a9 Initial Itsy nRF52840 defn 2019-10-25 11:15:34 -04:00
Scott Shawcroft
ece8352126
Fix build by removing unused vars 2019-10-22 17:24:04 -07:00
Scott Shawcroft
ae30a1e5aa
Refine _bleio
This PR refines the _bleio API. It was originally motivated by
the addition of a new CircuitPython service that enables reading
and modifying files on the device. Moving the BLE lifecycle outside
of the VM motivated a number of changes to remove heap allocations
in some APIs.

It also motivated unifying connection initiation to the Adapter class
rather than the Central and Peripheral classes which have been removed.
Adapter now handles the GAP portion of BLE including advertising, which
has moved but is largely unchanged, and scanning, which has been enhanced
to return an iterator of filtered results.

Once a connection is created (either by us (aka Central) or a remote
device (aka Peripheral)) it is represented by a new Connection class.
This class knows the current connection state and can discover and
instantiate remote Services along with their Characteristics and
Descriptors.

Relates to #586
2019-10-21 18:57:03 -07:00
Kamil Tomaszewski
f3151bb6c4 Use get top and limit stack functions 2019-10-18 11:05:08 +02:00
Kamil Tomaszewski
96756b3945 Add functions to get top and limit stack 2019-10-18 11:04:45 +02:00
Dan Halbert
be8136dc6d Merge remote-tracking branch 'adafruit/master' into bonding1 2019-10-15 15:55:21 -04:00
Scott Shawcroft
1a7c787d3c
Merge branch 'master' into master 2019-10-14 19:47:46 -07:00
arturo182
e0f60d0c17 Add IS25LP128F flash device definition 2019-10-14 23:42:53 +02:00
Cedar Grove Maker Studios
f1ab9aaa9c
add def for AT25SF161-SSHD-T 2MiB SPI flash chip 2019-10-14 11:58:14 -07:00
kamtom480
f6e553f89f
Merge branch 'master' into circuitpython-number-endpoint 2019-10-08 09:41:29 +02:00
Kamil Tomaszewski
29844db332 Use boolean type for renumber_endpoints 2019-10-08 09:26:02 +02:00
Kamil Tomaszewski
badf32e88d Add HID OUT 2019-10-07 13:40:44 +02:00
Kamil Tomaszewski
1205d3e305 Add validation 2019-10-07 12:31:42 +02:00
Kamil Tomaszewski
7aefcc449a Add an alternative way to number the USB endpoints
Two options available:
- relative numbering (USB_RELATIVE_EP_NUM = 1) - default
- absolute numbering (USB_RELATIVE_EP_NUM = 0) - new!
2019-10-07 12:31:42 +02:00
Dan Halbert
fc19e03128 WIP: bonding 2019-10-06 21:30:26 -04:00
Kamil Tomaszewski
ef42abb818 Add a way to change max packet size for MSC 2019-10-04 13:49:33 +02:00
Hierophect
eacdb1da6e Disable timeout, remove redundancy 2019-10-03 14:43:25 -04:00
Hierophect
8a4bbae077 Fix typo causing parsing error 2019-10-02 18:18:52 -04:00
Hierophect
9aa6d215fd Add some definitions for when F412 can be implemented 2019-10-02 16:03:22 -04:00
Dan Halbert
b8200d7295 fix atmel-samd filesystem_tick'ing; clear_temp_status() should check for status indicator in use 2019-09-09 23:17:52 -04:00
Dan Halbert
cf6fbcbf2d
Merge pull request #2123 from hierophect/stm32-flashstub-fix
Fix stm32f412zg compile warning
2019-09-06 14:56:24 -04:00
Hierophect
bc37649884 Remove unused static function 2019-09-06 11:06:02 -04:00
Dan Halbert
f3af2a6fb7 Merge remote-tracking branch 'adafruit/master' into choose-usb-devices-xac 2019-09-04 21:56:13 -04:00
Dan Halbert
195de97c67 use only one endpoint pair for MSC except on SAMD21 2019-09-04 21:45:16 -04:00
Dan Halbert
fca440fb66
Merge pull request #2113 from tannewt/displayio_hidden
Add .hidden to TileGrid and Group
2019-09-04 15:48:00 -04:00
Dan Halbert
b46c8dcc62
Merge pull request #2065 from hierophect/f411re-feature-buildout
F411re feature buildout
2019-09-04 15:45:54 -04:00
Hierophect
479b047618 Reverted descriptor changes pending HID restructuring 2019-09-04 13:58:18 -04:00
Dan Halbert
95a5a57f94 Merge remote-tracking branch 'adafruit/master' into choose-usb-devices-xac 2019-09-04 00:12:09 -04:00
Scott Shawcroft
949f8761b8
Add .hidden to TileGrid and Group
This allows for one to preserve ordering within a Group while
hiding something temporarily.

Fixes #1688
2019-09-03 16:15:27 -07:00
Dan Halbert
42f5edbd33 WIP 2019-09-03 14:44:46 -04:00
Dan Halbert
35c7646ee4
Make trivial change to redo GitHub Actions build.
The GitHub Actions build for this PR is failing for reasons that make no sense. Make a tiny commit change to see if it will refresh things and work again.
2019-09-03 08:52:21 -04:00
arturo182
12c97b42a4 Add GD25Q32C flash device definition 2019-09-02 23:22:52 +02:00
Dan Halbert
4b97ec9d23 Merge in 4.x status dotstar fix 2019-09-02 10:25:38 -04:00
Scott Shawcroft
0876d5c4ad
Disable bitbangio on Itsy M0
Also, switch CIRCUITPY_BITBANG_APA102 to makefile setting so it can alter included files
2019-08-27 15:21:47 -07:00
Scott Shawcroft
7324b70a7c
Rework based on Dan's review 2019-08-23 15:27:21 -07:00
Scott Shawcroft
9993a99906
Add initial Monster M4SK build 2019-08-22 14:24:32 -07:00
Scott Shawcroft
70680d5b22
EPaper displays work mostly. 2019-08-22 14:08:33 -07:00
Hierophect
e490e6361f Add warnings, cosmetic fixes, remove vestigial modules 2019-08-19 10:47:18 -04:00
Hierophect
7dbf1a8caa text fixes 2019-08-15 17:56:15 -04:00
Hierophect
1f42ce5f40 QOL fixes, compatibility fixes, attribution 2019-08-15 17:45:40 -04:00
Hierophect
bc7ba33892 Add uid fetch, revert USB hacks 2019-08-15 16:35:01 -04:00
Hierophect
a9d3ad86e5 Fix flash size, add filesystem disable flag 2019-08-15 15:55:33 -04:00
Hierophect
620d3d14dd Add conditional endpoints to descriptor script 2019-08-15 13:41:51 -04:00
Dan Halbert
243334da75 Merge remote-tracking branch 'adafruit/master' into ble-pairing 2019-08-05 23:06:24 -04:00
Scott Shawcroft
26f64dd8ec
Merge remote-tracking branch 'adafruit/4.1.x' into merge_in_410 2019-08-05 17:53:08 -07:00
Hierophect
a635d46b1a Fix merge related issues 2019-08-04 17:19:38 -04:00
Hierophect
0c43bae01d Merge branch 'master' into f411re-feature-buildout 2019-08-04 16:37:49 -04:00
Dan Halbert
ee518b9141 Merge remote-tracking branch 'adafruit/master' into ble-pairing 2019-07-31 11:22:48 -04:00
Dan Halbert
91d791afd0 cleanup adapter.address; add uniquish suffix to BLE device name 2019-07-31 00:30:24 -04:00
Hierophect
90b1701b6c Add CDC REPL access 2019-07-26 14:06:27 -04:00
Scott Shawcroft
af8cfbedfb
Add knobs for SSD1322 and two fixes.
* Fix terminal clear after first successful code.py run.
* Fix transmitting too many bytes for column constraint with single
  byte bounds.
2019-07-25 15:41:12 -07:00
Scott Shawcroft
8ec2d6ce49
Merge pull request #2007 from hierophect/F4xx-port-setup
Add STM32 Discovery F412ZG and F411RE support
2019-07-24 18:49:48 -07:00
Hierophect
981398406c Implement working (if useless) USB on F411 2019-07-24 16:23:35 -04:00
Hierophect
d66c9590af Merge tinyusb changes from upstream 2019-07-24 14:54:22 -04:00
hathach
5d03cda01a whitespace 2019-07-24 16:49:13 +07:00
hathach
c921f6637f update tinyusb lib to 0.5.x 2019-07-24 16:46:31 +07:00
Hierophect
267468834d Pin down some TUSB issues 2019-07-23 19:40:26 -04:00
Hierophect
a3673cc79b Set up for new tinyusb integration. Not yet functional. 2019-07-22 17:16:33 -04:00
Hierophect
f65404cc05 Cleanup missed items 2019-07-22 13:08:55 -04:00
Hierophect
58630a844a Add feature conditionals and clean up 2019-07-22 12:58:28 -04:00
Scott Shawcroft
6797ec6ed3
Add support for grayscale displays that are < 8 bit depth.
This also improves Palette so it stores the original RGB888 colors.

Lastly, it adds I2CDisplay as a display bus to talk over I2C. Particularly
useful for the SSD1306.

Fixes #1828. Fixes #1956
2019-07-19 16:06:11 -07:00
Scott Shawcroft
4a6bdb6fe4
Track a dirty area for in-memory bitmaps
This fixes the bug that bitmap changes do not cause screen updates
and optimizes the refresh when the bitmap is simply shown on the
screen. If the bitmap is used in tiles, then changing it will
cause all TileGrids using it to do a full refresh.

Fixes #1981
2019-07-18 16:47:28 -07:00
Hierophect
734012aa8b Makefile cleanup 2019-07-18 17:55:57 -04:00
Hierophect
755b86e38b Deinit-capable USB on 411 2019-07-18 17:17:46 -04:00
Hierophect
43e8a4110f Add missing files for DigitalIO 2019-07-17 14:18:01 -04:00
Scott Shawcroft
6fad383367
Merge pull request #1925 from C47D/rgb_status
Initial support for RGB led as Status indicator, fixes #1382
2019-07-09 10:31:34 -07:00
C47D
40fbac13cd [rgb status] Adjust to current brightness 2019-07-08 22:06:43 -05:00