#circuitpython-dev

1 messages Β· Page 72 of 1

lone axle
#

One "gotcha" that I remember from when we did it the first time to watch out for is make sure that mpy-cross is works with any typing syntax that you end up adding. In the past there were some situations where some syntax was supported in CPython but not by mpy-cross so we had to leave it out of the circuitpython libraries at the time. I know we've updated mpy versions a few times since then though.

spare jacinth
#

Im trying to use from __future__ import annotations and if TYPE_CHECKING where/when posible, so im hoping it wont break anything (or very little)

manic glacierBOT
#

Is that correct?

Yup!

However it does sound like quite an effort to implement. I assume the alarm module would have to know about wifi, ble, SPI, I2C, ... and determine which of these are active and which are not.

It isn't easy to implement but gives a consistent API across all ports. I'd ignore this complexity first though and just make sure you are getting the power savings you are hoping for. Once you confirm that, then add in things like wifi and ble.

You'll probably want ...

spare jacinth
#

ran into another typing problem now, mypy complains about doing len(ReadableBuffer) because the TypeAlias does not "implement"(no idea what's the set-theory term) Sized...

im no typing expert, but this seems to do the trick:

ReadableBuffer: TypeAlias = TypeVar(
    "ReadableBuffer",
    Sized,
    bound=Union[
        array.array,
        bytearray,
        bytes,
        memoryview,
        "rgbmatrix.RGBMatrix",
        "ulab.numpy.ndarray",
    ],
)
```it currently is defined as: ```py
ReadableBuffer: TypeAlias = Union[
    array.array,
    bytearray,
    bytes,
    memoryview,
    "rgbmatrix.RGBMatrix",
    "ulab.numpy.ndarray",
]

... and same treatment would go for WritableBuffer i guess

#

can anyone confirm whether that looks right, before i open a PR for it? πŸ˜„

steady mulch
#

Hi, I was wondering about unloading modules to reclaim RAM. Deleting from sys.modules does seem to work to some extent, but isn't a supported API, and doesn't work for modules in a package that's otherwise still in use. Has there been any discussion about this?

slender iron
#

I wouldn't do it. you can reset the VM instead

steady mulch
#

We can't do that because of wanting to maintain other hardware state

slender iron
#

unloading isn't really a thing

steady mulch
#

It's not really a thing in desktop Python either but would have uses for embedded

#

Though I can understand if it's architecturally impractical

#

Or maybe it would be micropython's business

manic glacierBOT
#

Draft because I will be fixing anything else I find while i working on Adafruit_CircuitPython_BLE's type hints

I just found out this because mypy complained that add_to_service was missing a positional arg (self and service were expected based on comment, but it really is a classmethod and only service has to be passed in)

This also lead me to seeing __init__ is not defined... Does that mean that trying to run Characteristic() will raise? If so, should we perhaps change ...

slender iron
#

I think it will save some memory but not all

#

interned strings will still be kept for example

brazen hatch
#

It wont work for libraries really though.

#

You can of course rewrite em to work with this method if you want though.

#

Ah also did I forget to mention it's slow? Like really slow?

#

Nope, espcamera upsteam is still using old adc api, so it's not happening yet. Imma shelve the code.

#

Me: Misclicks in S3 artifacts
The circuitpython build:

#

Actually, why am I not using the pirate version for everything?

spare jacinth
#

down to from 184 to 67, it has been an exhausting evening πŸ€“

manic glacierBOT
#

nrf52832

I guess the only thing i've been able to find is the following
https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v15.0.0%2Fhardware_driver_gpiote.html

High accuracy: An independent GPIOTE event is used to detect changes on the pin. If a pin is configured to be controlled in this mode, a high frequency clock is required.
Low accuracy/low power: A PORT event senses level changes on the pin. One PORT event can be used for multiple pins....

manic glacierBOT
#

CircuitPython version

Adafruit CircuitPython 9.2.0-alpha.2350-19-gc53a0cb864 on 2024-08-19; Raspberry Pi Pico 2 with rp2350a

Code/REPL

import time, board, touchio
touchin = touchio.TouchIn( board.GP2 )
while True:
    print( touchin.value )
    time.sleep(0.1)

Behavior

Pin GP2 has a 1M resistor going to GND.

code.py output:
Traceback (most recent call last):
  File "code.py", line 2, in 
ValueError: No pulldown on pin; 1Mohm recommen...
manic glacierBOT
#

@todbot and @tyeth do you have wifi credentials in settings.toml? Dan repro'd this using a manual import wifi after USB comes up instead of settings.toml.

I've spent all day debugging this with little progress. The USB interrupt fires, enqueues the event but the tinyusb task never runs to pull from the queue. This happens after esp_wifi_start() is called.

#

I'm having a very similar issue with I2C on QT-PY-ESP32-S2. I've come at it all kinds of ways, with one or multiple I2C devices and varying the I2C bus speed from 10_000 to 400_000.

With these i2c devices:

  • adafruit_ssd1306
    
  • adafruit_seesaw (rotaryio: product number 4991)
    

When I do a i2c.scan() it never shows any devices, but I can "speak" to the rotaryio. When I enable the ssd1306, I get:

main.py output:
sys.implementation=(name='circuitpython', versi...
manic glacierBOT
manic glacierBOT
devout jolt
#

If I wanted to do some "printf debugging" out a UART on the raspberrypi and espressif ports, what's the magic make incantation? (if there is one, maybe I'm mis-remembering)

manic glacierBOT
#

@todbot and @tyeth do you have wifi credentials in settings.toml?

In my test two weeks ago, I did not have a settings.toml file. Nor did I test WiFi, just if the board came up on USB. I just now created a settings.toml on the FunHouse with that firmware, giving a proper CIRCUITPY_WIFI_SSID &CIRCUITPY_WIFI_PASSWORD and the device appeared to immediately reset and disappear off USB. The FunHouse display does come up and says "Wi-Fi: No Ip" but is otherwise a brick.

spare jacinth
#

If former, i would guess it is just something like DEBUG=1

manic glacierBOT
spare jacinth
#

Oh, a 3rd idea... Print yourself from C code into UART?

#

πŸ™ƒπŸ™ƒ

devout jolt
spare jacinth
#

Yeah, didnt mean it as an actual answer, but trying to specify what the question meant

devout jolt
alpine holly
#

Has anyone else noticed that SSL (loading web pages) works on esp32-c3 and s2 etc, but not on generic esp32 ?

manic glacierBOT
#

@dave4jr I did perform some more tests, force-feeding watchdog, so we get no watchdog resets, only to get a hang.
(Where the watchdog does not save us from.)
I cannot get a crash dump, so I cannot debug this any further.

The only workarounds currently confirmed working are:

  • Having bluetooth paired.
  • Configuring CONFIG_FREERTOS_UNICORE at compile time.

Notes inside my head that could prove useful:

  • IDF5.3 fixed the similar temperature bug, perhaps tracking back the commit wi...
tulip sleet
manic glacierBOT
#

CircuitPython version

Adafruit CircuitPython 9.1.0 on 2024-07-10; Waveshare RP2040-Zero with rp2040

Code/REPL

import sys
help(sys.stdout)

Behavior

object is of type FileIO

Description

Docstring for stdio indicates "FileIO", which is a binary IO stream. As detailed in #553, stdio is not binary by design; its docstring should indicate "StringIO".

Additional information

No response

slender iron
slender iron
#

@tulip sleet are you going to get the MP merge out for review today?

manic glacierBOT
#

@dave4jr , as @bill88t mentioned, this was never resolved unfortunately. In the meantime I have reluctantly been trying out DS18b20 "1 -Wire" bus temperature sensors which work well enough but they come with their own set of inconveniences and problems not present when using a simple thermistor (which mean extra coding just to try and protect against these added problems). My preference would be to go back to my thermistor setup but this ADC bug makes that impossible on S3 modules when also u...

tulip sleet
#

I spent a long time on a test failure that was a double bug and was ultimately unimportant.

slender iron
#

Go ahead and undraft. I'll look today. Not sure how much I'll be around later in the week

#

I'd like to get it merged since its been pending for a while

tulip sleet
#

me too!

slender iron
#

we can bug fix after

manic glacierBOT
#

[also put in OP]

Update: out of draft mode.

Everything builds except for two too-large builds, which I will fix soon, either here or in a later PR. Smoke tests work.

manic glacierBOT
slender iron
#

@tulip sleet I figured out the funhouse bug!

#

deleting a semaphore I held

manic glacierBOT
slender iron
#

should I back port the fix to 9.1.x instead?

tiny peak
#

@slender iron I'm looking for advice on general approach to tracking down USB stack bugs... I'm having trouble with writing USB gamepad drivers where stuff that works in PyUSB on Debian doesn't work with usb.core + max3421e.Max3421E on ESP32-S3. I'm seeing 0 or None Python values that make me suspect unhandled error conditions somewhere in C-land.

Context: I've had good luck with reading button press reports from an 8BitDo SN30 Pro USB gamepad (wired version) on CircuitPython. But, when I try to talk to an 8BitDo Universal Wireless Adapter 2, various weird stuff happens. For example, sometimes core.find(idVendor=0x045e, idProduct=0x028e) will give me a device, but then when I try to read the .idVendor or .idProduct, they come back as 0. Or, sometimes I will catch a usb.core.USBError that has an empty description string and None for its .errno.

From Wireshark captures, I know that this wireless adapter does stuff that might exercise the Max3421E or usb.core error handling. For example, it changes its vid:pid abruptly when a bluetooth gamepad connects. Also, when polling for gamepad button reports, the first read always gives an error (on debian PyUSB, it's errno 75, "Overflow"), but a second read immediately following that error usually works. When I try the double-read approach in CircuitPython, it never works.

To me, this smells like certain USB error conditions, perhaps at the max3421e.Max3421E level, or maybe higher up in usb.core, are not getting handled. Since the Max3421E has an interrupt pin, I worry maybe there's some complex stuff going on at the IDF level. Or, maybe it's an easy fix. I'm interested in looking into this (maybe a PR if I can figure it out?), but I'm not sure where to start looking. Do you have any advice on a general approach to tracking this down?

slender iron
#

You can try replicating it from tinyusb code without circuitpython

tiny peak
slender iron
#

for that issue

tiny peak
#

Will a CI build for that turn up automatically if I wait a day or two?

slender iron
#

what board are you on? I can build it for you

tiny peak
#

oh wow, thanks. there's no rush. but, I'm using Feather TFT ESP32-S3

#

it's one of the 4MB flash ones where the .BIN file works, but the .UF2 method has trouble because there's not enough space on the CIRCUITPY drive for the firmware file

tulip sleet
slender iron
tulip sleet
#

excellent

slender iron
tiny peak
#

oh wow, cool! I'll try the .bin file. Thanks!

slender iron
#

I was thinking plain C. There is an examples folder in the repo

tiny peak
slender iron
#

or you could print from within circuitpython too

tiny peak
#

do you have any guesses about which part of the Max3421E or usb.core code might be doing something weird if it happens to be the case that there's some kind of unhandled error condition around reading from an endpoint on a device that's been configured okay?

slender iron
tiny peak
#

the pattern to a lot of this stuff is that something weird happens on the first try, but then it behaves better if you repeat the request

manic glacierBOT
slender iron
tiny peak
#

With some consistency, I can get to the point where the device is configured and I can read from the endpoint, but then I get weird exceptions with no error message string

slender iron
#

the Device.c code I linked to doesn't do much error checking

tiny peak
slender iron
#

I think you need to set the uart console too

#

because you don't want it going out usb

tiny peak
#

okay. I can work with that. I'll try that build you sent me and see if I can get any interesting debug messages from tinyusb. Thanks!

slender iron
#

you'll need your own build to enable the debug message stuff

tiny peak
#

okay... I figured out how to do that for some of the SAMD boards a while back, so hopefully I'll be able to figure it out for espressif.

#

I'll give it a try

slender iron
#

the building circuitpython guide has instructions for esp too

#

esp-idf is a bit different from samd

tiny peak
#

are they current? seems like I recall discussions here about all the docs being wrong?

slender iron
tiny peak
#

oh, okay, fabulous

#

thanks again. I'm gonna stop here to copy some of these notes out into a non-scrolling-away-by-the-minute document, then try some of your suggestions.

slender iron
#

np πŸ™‚

manic glacierBOT
fading stirrup
#

Hey, @slender iron pointed me here. i have a P4 devkit and would like to start trying to port CircuitPython over to it. I've gotten to the point where it builds, but it's not running yet (invalid header on boot, I think it's the flash setup). I have the fork here. I'll keep working on it, but should I post this as a WIP PR? Does anyone else here have the P4 devkit and want to pitch in ? https://github.com/adafruit/circuitpython/compare/main...bwhitman:circuitpython:main

manic glacierBOT
tiny peak
manic glacierBOT
manic glacierBOT
spare jacinth
# manic glacier

Ideas about the __init__ question i posted in the PR's description? πŸ˜…

manic glacierBOT
#

Thanks for workign on this.

This also lead me to seeing __init__ is not defined... Does that mean that trying to run Characteristic() will raise? If so, should we perhaps change the type hint from -> None to -> NoReturn or the like?

Yes, calling the constructor raises an exception:

>>> from _bleio import Characteristic
>>> c = Characteristic()
Traceback (most recent call last):
  File "", line 1, in 
TypeError: cannot create 'Characteristic' instances

The `...

manic glacierBOT
#

My concern was not really showing vs not showing the __init__ signature on the docs/stubs, but being able to type-hint it correctly.

Skipping it on the doc-comment, {MyPy/Intellisense/whatever} would assume we have a "default" def __init__(self) -> None signature, which is valid to call, while having it marked as -> NoReturn would explicitly mark it is a forbidden operation....

However, i've been testing locally for a bit and can't find a way to "describe" this behavior su...

manic glacierBOT
manic glacierBOT
#

Im not sure about this, but i think that adding -> None is required for type checkers to "look into" your function's body. Without the explicit typing (and given the lack of typed arguments), tooling will/could say "oh, this function is yet to be typed, im not running any analysis on its body"; so, even if if is not required, i think it is nice to add.

The idea for NoReturn (or Never) is to represent a function that never has an actual return endless loop, sys.exit killing the ...

slender iron
tulip sleet
#

@spare jacinth oh never mind, it is already -> None! I was misremembering.

#

you can't call the constructor directly, but I wonder if you can call __init__() on an already-constructed Characteristic directly.

#

it's a bit confusing because the signature is being overloaded with the constructor arguments

spare jacinth
#

yeah, and the problem is that, since ClassName() is (internally):

class_name = ClassName.__new__(*, **)
class_name.__init__(*, **)
``` we apparently can't tell (and it is reasonable, because this is not happening on a Python, but C level) the type system that the second part of that will fail (but first one wont, as we can instantiate by other means)
.... or something like that 🀣
tulip sleet
#

anyway, I think it's fine to leave it alone as None

spare jacinth
#

so, as said... leaving it be, no red underline when (if) user mistakenly does a ClassName() and they will simply crash at runtime

tulip sleet
#

there is no pure python analog to what we are doing

#

yes, so I don't see how to mark it as an error

spare jacinth
tulip sleet
#

ok, so I will go ahead and approve the PR, unless you want to do anything else

spare jacinth
#

is good for me, worst case i can always open a second one

spare jacinth
#

dang, i just found another one 🀣

manic glacierBOT
spare jacinth
#

Here, prefixes is definitely not a ScanEntry (or is it? πŸ€” ) but what is a mp_buffer_info_t

  • ReadableBuffer
  • Iterable[ReadableBuffer]
  • else
//| class ScanEntry:
//|     """Encapsulates information about a device that was received during scanning. It can be
//|     advertisement or scan response data. This object may only be created by a `_bleio.ScanResults`:
//|     it has no user-visible constructor."""
//|

//|     def __init__(self) -> None:
//|         """Cannot be instantiated directly. Use `_bleio.Adapter.start_scan`."""
//|         ...
//|
//|     def matches(self, prefixes: ScanEntry, *, match_all: bool = True) -> bool:
//|         """Returns True if the ScanEntry matches all prefixes when ``match_all`` is True. This is stricter
//|         than the scan filtering which accepts any advertisements that match any of the prefixes
//|         where ``match_all`` is False."""
//|         ...
static mp_obj_t bleio_scanentry_matches(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
    bleio_scanentry_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);

    enum { ARG_prefixes, ARG_match_all };
    static const mp_arg_t allowed_args[] = {
        { MP_QSTR_prefixes, MP_ARG_OBJ | MP_ARG_REQUIRED },
        { MP_QSTR_match_all, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = true} },
    };

    mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
    mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);

    bool match_all = args[ARG_match_all].u_bool;

    mp_buffer_info_t bufinfo;
    mp_get_buffer_raise(args[ARG_prefixes].u_obj, &bufinfo, MP_BUFFER_READ);
    return mp_obj_new_bool(common_hal_bleio_scanentry_matches(self, bufinfo.buf, bufinfo.len, match_all));
}
static MP_DEFINE_CONST_FUN_OBJ_KW(bleio_scanentry_matches_obj, 1, bleio_scanentry_matches);
tulip sleet
#

it is a readable buffer. It's usually a bytes or bytearray

spare jacinth
#

mypy says: adafruit_ble/advertising/__init__.py:353: error: Argument 1 to "matches" of "ScanEntry" has incompatible type "bytes"; expected "ScanEntry" [arg-type]

spare jacinth
#

that did the trick, nice

spare jacinth
#

lets not merge this one until i have everything solved locally πŸ˜›

manic glacierBOT
#
[adafruit/circuitpython] New tag created: 9.1.2
orchid basinBOT
random junco
manic glacierBOT
spare jacinth
#

there are a couple of places with typing hard/imposible (at least with my knowledge) to represent....
however, i didnt feel like breaking API and just made a couple of hacks to (eg if TYPE_CHECKING: @overload blocks, assert, and a couple of type: ignore), but it's hopefully not too gross for a merge πŸ˜…

tulip sleet
#

https://blog.adafruit.com/2024/08/22/circuitpython-9-1-2-released/
Highlights of this release

  • Fix Adafruit FunHouse build, which was not working.
  • Correct pins for Adafruit Feather ESP32-C6.
  • Allow wider range of counts for Counter, FrequencyIn, and IncrementalEncoder.
  • Prevent crash or hang on nRF boards when stopping VM and BLE is not running.
Adafruit Industries - Makers, hackers, artists, designers and engineers!

From the GitHub release page: This is CircuitPython 9.1.2, the latest bugfix revision of CircuitPython, and is a new stable release. WARNING for nRF52 boards only: If your board has an nRF52 UF2 bo…

manic glacierBOT
#
[adafruit/circuitpython] New tag created: 9.2.0-alpha.2351
orchid basinBOT
manic glacierBOT
tulip sleet
#

https://blog.adafruit.com/2024/08/22/circuitpython-9-2-0-alpha-2351-released/
Highlights of this release

  • Fix Adafruit FunHouse build, which was not - working.
  • Correct pins for Adafruit Feather ESP32-C6.
  • Prevent crash or hang on nRF boards when stopping VM and BLE is not running.
  • Many new RP2350 boards.
  • Update to Espressif ESP-IDF V5.3.
  • Merge MicroPython updates from v1.22.2.
Adafruit Industries - Makers, hackers, artists, designers and engineers!

From the GitHub release page: This is CircuitPython 9.2.0-alpha.2351, an alpha release for 9.2.0. It has significant known bugs, and will have further additions and fixes before the final release o…

spare jacinth
#

only this is left to finish my PR fixing typing```
adafruit_ble/services/nordic.py:82: error: "Characteristic" has no attribute "read" [attr-defined]
adafruit_ble/services/nordic.py:94: error: "Characteristic" has no attribute "readinto" [attr-defined]
adafruit_ble/services/nordic.py:103: error: "Characteristic" has no attribute "readline" [attr-defined]
adafruit_ble/services/nordic.py:108: error: "Characteristic" has no attribute "in_waiting" [attr-defined]
adafruit_ble/services/nordic.py:112: error: "Characteristic" has no attribute "reset_input_buffer" [attr-defined]
adafruit_ble/services/nordic.py:116: error: "Characteristic" has no attribute "write" [attr-defined]

as far as i can tell, the problem is here: (removed some useless details)```py
class UARTService(adafruit_ble.services.Service):
    _server_tx = StreamOut()
    _server_rx = StreamIn()
    # FYI: these two classes inherit from ComplexCharacteristic

    def __init__(self, service: Optional[_bleio.Service] = None) -> None:
        super().__init__(service=service)  # <--- there's some magic here with getattr and settatr
        self._rx = self._server_rx
        self._tx = self._server_tx

sorry for the ping @slender iron but the magic code there is (at least partially) yours, and it is better and faster to ask than trying to understand what is going on there...

can you confirm whether that code does some things that are not obvious, and _rx and _tx end up being CharacteristicBuffer's? (i think that's the actual type because of the methods being called on them, but im not too positive on that either).

instead of reading/understanding, may as well just run an example and call type(uart._tx) but i dont have any hw to do so 😦

manic glacierBOT
#

CircuitPython version

Adafruit CircuitPython 9.1.2 on 2024-08-22; Adafruit Feather ESP32-C6 4MB Flash No PSRAM with ESP32C6

Code/REPL

import board
from digitalio import DigitalInOut, Direction, Pull

pwr = DigitalInOut(board.NEOPIXEL_I2C_POWER)
pwr.direction = Direction.OUTPUT
print(pwr.value)
pwr.value = True
print(pwr.value)

Behavior

Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
code.py output:...
orchid basinBOT
#

Bumps rexml from 3.3.3 to 3.3.6.

Release notes
Sourced from rexml's releases.

REXML 3.3.6 - 2024-08-22
Improvements

Removed duplicated entity expansions for performance.

GH-194
Patch by Viktor Ivarsson.

Improved namespace conflicted attribute check performance. It was
too slow for deep elements.

Reported by l33thaxor.

Fixes

Fixed a bug that default entity expansions are counted for
security check. Default entity expansions should not be counted
b...

spare jacinth
slender iron
spare jacinth
#

only this one left πŸ™‚ adafruit_ble/services/nordic.py:119: error: "CharacteristicBuffer" has no attribute "write" [attr-defined]

slender iron
#

Buffer is only for rx

#

Tx is probably a normal characteristic

spare jacinth
#

by the way, for the readinto(buffer, nbytes) syntax to work i had to tweak comments once again (commit) but there's a comment:

static const mp_stream_p_t characteristic_buffer_stream_p = {
    .read = bleio_characteristic_buffer_read,
    .write = bleio_characteristic_buffer_write,
    .ioctl = bleio_characteristic_buffer_ioctl,
    .is_text = false,
    // Disallow readinto() size parameter.
    .pyserial_readinto_compatibility = true,
};
#

but... looking for pyserial_readinto_compatibility (or even readinto_compatibility) i only see it on the typedef struct declaration, and some objects setting the flag to true... is it not accessed anywhere? πŸ€”

spare jacinth
#

descriptors are really a pain to reason about, they are very cool and come handy, but once there's a non-trivial usage of them.... my brain leaves the room

spare jacinth
manic glacierBOT
manic glacierBOT
manic glacierBOT
#

CircuitPython version

n/a

Code/REPL

n/a

Behavior

n/a

Description

I'm trying to set up an Espressif build environment from scratch, and I hit a couple documentation snags.

  1. Looking at the main CircuitPython README, I had a hard time locating where I should start looking for build documentation. Eventually I realized there's a BUILDING.md file, which was helpful, but that file is hard to notice amidst many other top level files. Before t...
manic glacierBOT
manic glacierBOT
manic glacierBOT
#
  • Fixes #9551

espressif_board_reset_pin_number() was being used on many boards to set certain pins high or low on startup. However, it was using basic gpio functions without ensuring that the IOMUX for pin was set to GPIO. This meant the GPIO settings were not necessarily taking effect. This may have caused issues on other boards we didn't know about besides the Feather C6 from #9551.

I added a helper routine to ensure that gpio_config() was called before setting the pin level. ...

manic glacierBOT
manic glacierBOT
manic glacierBOT
manic glacierBOT
manic glacierBOT
orchid basinBOT
manic glacierBOT
#

actually experiencing this issue,
i was trying some stemma qt boards and i noticed they are not automatically Powered ON in circuit python.
i need to manually turn it on, but i believe this shouldn't be needed:

import digitalio
digitalio.DigitalInOut(board.NEOPIXEL_I2C_POWER).switch_to_output(value=True)
# using board.STEMMA_I2C() or board.I2C() apparently doesn't matter in this board as they are the same pins

spare jacinth
#

while testing my changes to doc-comments, i've run make stubs and noticed that within its output there were several warnings for some untyped stuff, and im trying to get those sorted

on this function am i understanding correctly that it modifies the bitmap in place, and also returns a reference to it? in other words... should should it be -> displayio.Bitmap, -> None, else?

midnight ember
#

attempted to submit an api example to adafruit_requests and getting a new ruff error never encountered before. any ideas?

spare jacinth
#

not that im a ruff expert, but to me that sounds like a warning similar to:

hey, you've told me to run the check named "PLC2401", but i'm not running it because that's an experimental(preview) feature and you haven't enabled the preview mode
... or something similar

#

(and same for the other code names, of course)

manic glacierBOT
#

Currently only merged PR's to main are uploaded to https://adafruit-circuit-python.s3.amazonaws.com/index.html?prefix=bin. This is an attempt to upload merges for all branches ending in .x, so 9.1.x, etc.

The string operations available in if statements in the CI yaml files are limited. There are ways to do regexp, etc., that involve generating a result and then using it, but it's clumsier. However, I think doing it for *.x branches is probably good enough.

Only way to test this...

#

In-case it can be useful, I put together a small reproducer that shows the glitchy qualia screen.

import time

import board
from adafruit_qualia import Qualia
from adafruit_qualia.graphics import Displays
import adafruit_imageload
import displayio

# Create the Qualia object for the 240x960 display PID 5799
qualia = Qualia(Displays.BAR240X960)

# OR create the Qualia object for the 320x960 display PID 5805
# qualia = Qualia(Displays.BAR320X960)

display = qualia.display

...
lone axle
thorny jay
#

I wannabe a deepdiver @slender iron
(I saw a YT notification, so I have no excuse)

midnight ember
#

yeah i tried that and failed with the same message. i just sync'd my repo with requests. posted the file in there manually in my github website repo and it went through.

#

i'm running a custom pre-commit with powershell so my guess is i need to change something with it. :/

spare jacinth
midnight ember
spare jacinth
#

yeah, i remember reading some of the messages back then... my point being that if your windows is recent enough to be compatible with WSL (thus the "i dont know your setup" part), i would use it (it's a builtin Linux "virtual machine") rather than messing with Windows<->Linux conversion issues running stuff on cmd/powershell

midnight ember
#

I know ruff is a recent addition and likely what is throwing off my script since I'm not accounting for ruff.

#

i tried WSL and it presented issues of its own. i'd rather just use windows.

spare jacinth
#

im now curious what those were 🀣
and they might have been easier to solve than the powershell hackaround

anyway, i dont see anything that looks wrong on your previous message, with regards to pre-commit's output

#

as foamyguy said, the pre-commit check "failed" because ruff-format introduced changes (aka: reformated some of your files)
unless those changes were some CRLF/LF changes, you just git add the files (or maybe they already get added after being format, idk) + try and commit again?

manic glacierBOT
#

I was trying to use the stemma pins on some feather or qt py adafruit boards without using i2c (using other interfaces or simply the underlying gpios)
and i noticed that there is no easy way to identify these pins without consulting code, datasheets or other resources...

while one can use board.STEMMA_i2C to create the i2c interface, i believe there should be a way to use these pins with other interfaces.

example1:

import board
import digitalio
led1 = digitalio.DigitalInO...
manic glacierBOT
#

Follows up on the conversation in https://github.com/adafruit/circuitpython/issues/9463 and in Discord.

Draft PR, should be working but not tested in every possible way, posting for discussion purposes.

What this patch does:

  • On ports without native USB, don't consider the console connected once there have been no new bytes for a while
  • Configure UART wakeup(Note: the initial few bytes will always be lost with the hardware UART in sleep)
  • Enables tickless idle but does not actua...
manic glacierBOT
#

A small update: here are two scope traces of this code:

import time, board, touchio
while True:
    try:
        touchin = touchio.TouchIn(board.GP5)
        touchin.deinit()
    except ValueError as e:
        pass

The first one (RP2040 Pico) shows what I would expect: signal goes high for 10 us, then nice exponential decay to ground. The second one (RP2350 Pico2) shows the weirdness. After the 10us wait, it holds at ~2.2V until the pin is deinited.
![rp2040_touchio](...

manic glacierBOT
spare jacinth
#

@tulip sleet the typing PRs i've made to main won't get punlished on PyPi right? not even when doing $ pip install --pre circuitpython-stubs
which branch should i target instead? 9.1.x? do i open a cherry-picking PR after the 2nd set of improvements gets merged?

tulip sleet
#

I don't think it's that critical to have the stubs fixed for 9.1.x. You may disagree, if you use them!

spare jacinth
#

follow-up PRs to libraries will have to be held back for a bit, then πŸ†—

tulip sleet
#

We try not to churn the stable release too much.

spare jacinth
#

by the way, i added the missing hint for codeop.compile_command's return value as -> "code" because the type doesnt seem to be exposed to Python (or at least, i couldnt find where)
CI failed because it's not an actual thing, unsure what to do

tulip sleet
#

you could make it Any

spare jacinth
spare jacinth
#

no idea which tool is used for that 🀣

tulip sleet
#

see circuitpython/Makefile stubs: target. It runs some scripts

#

in particular tools/extra_pyi.py, which uses ast

spare jacinth
#

as far as i can tell, the codeop.compile_command function is a tiny wrapper for mp_builtin_compile_obj, whose return seems to be of type mp_type_code.... and im guessing all C/Py types should be somehow import-able from Python level, right?

spare jacinth
#

Anyway, i will just omit proper typing

tulip sleet
#

Well, there is such a type:

dafruit CircuitPython 9.0.5 on 2024-05-22; Adafruit Circuit Playground Bluefruit with nRF52840
>>> import codeop
>>> c = codeop.compile_command("1+2")
>>> type(c)
<class 'code'>
spare jacinth
#

yeah, i've gotten that far on my REPL too, but dont know where code can be imported from

tulip sleet
#

you can't import it, any more than you can import int

spare jacinth
#

was not in the "implicit namespace" (whatever the proper naming is), nor in builtins

tulip sleet
#

It's not visible in CPython either:

ython 3.12.3 (main, Jul 31 2024, 17:43:48) [GCC 13.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import codeop
>>> c = codeop.compile_command("1+2")
>>> type(c)
<class 'code'>
>>> code
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'code' is not defined. Did you mean: 'codeop'? Or did you forget to import 'code'?
>>> 
spare jacinth
#

so, Any it is

tulip sleet
#

I don't see any type annotations that use code in CPython either

#

nobody seems to have bothered to write type annotations for the builtin functions/modules

#

or at least they are not in the documentation

spare jacinth
#

PR ready to go from my end, lets see if CI is happy as well

#

time for me to go bed, 4AM already here (:

#

and thx for the feedback!

tulip sleet
spare jacinth
#

is there a reason not to generate stubs for the micropython module? namely: prevent typing issues with from micropython import const, but there might be other types/functions in there that im not aware of and would also be nice to stub

#

ok, i think i've answered myself

  • it comes from py/ not shared-bindings/ (i first thought it was a CP-specific extension to access MP things)
  • micropython doesn't add comments to document the python-exposed API
  • adding them would (probably) cause merge conflicts
  • ...and keeping a separate .pyi file doesn't sound like the best of ideas, as it could easily end up out of sync
    any ideas on how (if) to handle this?
onyx hinge
#

@spare jacinth @tulip sleet ```>>> c = codeop.compile_command("1+2")

isinstance(c, types.CodeType)
True

#

I think the correct annotation is CodeType

tulip sleet
#

is that in CPython?

onyx hinge
#

yes

tulip sleet
#

sounds good

spare jacinth
#

Nice, thanks

#

I thought types wasnt in CircuitPy and didnt even check it, should have done it

#

Though it doesnt even matter as the import is on a pyi file which CircuitPython wont ever see πŸ€¦β€β™‚οΈ

tulip sleet
#

right, since CircuitPython totally ignores all the annotations

manic glacierBOT
#

Makes sense πŸ‘

One last thought: While this ensures a consistent API, the actual power consumption achieved by light sleep would become somewhat inconsistent (entering light sleep at different points in the code might result in different power consumptions). And forgetting to deinit a certain peripheral could result in an unexpected higher power consumption. Debugging this could become rather challenging.
But this issue could maybe be solved by adding a new optional flag argument to `light...

manic glacierBOT
#

... so I figured that making a subclass of DemuxKeyMatrix is a bit of a pain and instead just made a cardputer_keyboard module.
The module exposes the KEYBOARD object as well as the functions detach_serial, attach_serial and key_to_char.

As previously, the board starts with the serial "attached". If the user does not need it, they can do something like:

import cardputer_keyboard
cardputer_keyboard.detach_serial()

...
event = cardputer_keyboard.KEYBOARD.events.get()
...
clear halo
# spare jacinth is there a reason *not* to generate stubs for the micropython module? namely: pr...

Just FYI, there's the micropython-stubber project:

https://github.com/Josverl/micropython-stubber/

And some relevant discussion of documenting more of MicroPython inline:

https://github.com/orgs/micropython/discussions/15463

GitHub

Generate and maintain stubs for different MicroPython ports to use with VSCode and Pylance, PyRight, Thonny, PyCharm or MyPy - Josverl/micropython-stubber

GitHub

Introduction and Motivation: This proposal is to change the way that the documentation for the MicroPython library is maintained. Currently all documentation is manually created in .rST format, whi...

wary talon
#

Hello everyone, I'm so glad to join you all. Excuse my ignorance at this point. I have spent last 48hs studying and making tests with my CLUE devide. I have managed to use several of the examples and do some changes. But now, I'm was trying to use the adafruit_ble_broadcastnet to broadcast the pressure. I managed to broadcast but there's no sense in the hexadecimal values I get from the Bluefruit Connect App. I should be receiving something like 1030.98 hPA in hexa, but I'm unable to find how to convert it. I know that 2208 0303 0002 0A0A is all part of the manufacturer data and company, but, after that I do get 54 E0 80 44. 4 octetcs that should represent my flot of the preassure. And I'm struggling so hard because I make no sense of it. Would you be so kind as to give me some tips?
I did resolve this with a Govee devide with no problems, but with this Adafruit CLUE it feels I know nothing 😦

stuck elbow
spare jacinth
wary talon
manic glacierBOT
manic glacierBOT
manic glacierBOT
#

But for that drive-strength setting in DigitalInOut.c, why is it this:

    hw_write_masked(&pads_bank0_hw->io[pin],
        PADS_BANK0_GPIO0_DRIVE_VALUE_12MA << PADS_BANK0_GPIO0_DRIVE_LSB,
            PADS_BANK0_GPIO0_DRIVE_BITS);

and not:

gpio_set_drive_strength(pin, GPIO_DRIVE_STRENGTH_12MA);

as described in the Pico-SDK docs?

I think that API might not have been present in early versions of pico-sdk. I'm preparing a PR ...

manic glacierBOT
tiny peak
#

@tulip sleet Last night I managed to get make working for the espressif port. Was able to successfully build and flash a firmware image for Feather TFT ESP32-S3 with your 9.2.0 alpha stuff. Only other documentation glitch I encountered was that the esp-idf/install.sh fights with pip3 install --upgrade -r ../../requirements-dev.txt over the version of setuptools. ESP-IDF wants version 71.0.0, but pip upgraded to version 73.0.1. Once I re-ran the install script, it was fine.

#

So, the procedure that worked for me was: 1) run install.sh, 2) run the pip install stuff, 3) run install.sh again

manic glacierBOT
#

I am not sure that the erratum RP2350-E9 is the cause of this after all, even though we are seeing the 2.1V "stuck" value.
TouchIn doesn't use the internal pulldown at all. Yet I am seeing stuckness even on simple DigitalInOut:

On RP2350:

    [attach jumper between A0 and 3.3V]
>>> import digitalio, board
>>> a0 = digitalio.DigitalInOut(board.A0)
>>> a0.value
True
    [remove jumper]
>>> a0.value
True

RP2040 does not show this.

There is a fundamental differenc...

manic glacierBOT
manic glacierBOT
#

I am seeing this 2.2V latchup (actually 2.4V here) with the pulls not set at all, ever, and even with a 1M pull-down on the pin. I am testing with GP0 on the Tiny2350 instead of A0, which has the ADC attached and might have different reset characteristics.

Example:
Create a DigitalInOut on GP0.
GP0.value is False.
Pull GP0 high with a jumper direct to 3.3V, or a 1M resistor to 3.3V
GP0.value is True.
Remove jumper. GP0.value remains True, even if 1M resistor is then co...

tulip sleet
tiny peak
#

I initially assumed that I would need to make my own venv as is often the case with other stuff, but that didn't work. So, then I read more closely and figured out esp-idf has its own thing in $HOME/.espressif

onyx hinge
#

@lone axle @slender iron let me know if you'll be able to read your usual parts in the State of CircuitPython section today.

slender iron
#

@onyx hinge I'll be missing the meeting because I have family in town.

onyx hinge
#

@slender iron OK, got it. @tulip sleet let me know if you can read the state of the core section today!

onyx hinge
#

thank you!

tulip sleet
brazen hatch
#

I'd say idf5.3 is stable

onyx hinge
#

howdy all and in particular <@&356864093652516868> -- I'm back and I'll be running the weekly meeting in a little under 30 minutes! Please add your notes at https://docs.google.com/document/d/1AlQdjcpzMwWRF_2UsoXykCqwJVCPx5kSR14VG4ozEOo/edit?usp=sharing and just leave a little note if you need me to read them out for you. TTY soon

tulip sleet
#

@spare jacinth is your contribution in "In the Weeds" meant to go in "Status Updates"?

spare jacinth
#

yeah, oops

#

moved, thx
wrote it on auto-mode a while ago πŸ™ƒ

lone axle
manic glacierBOT
tulip sleet
#

@spare jacinth mic sounded crackly and went in and out, like a bad connection

spare jacinth
#

rebooting the headset now

gilded cradle
#

Thanks

lone axle
#

Thanks for hosting Jeff. Have a great week everyone!

manic glacierBOT
manic glacierBOT
#

I'm having a very similar issue with I2C on QT-PY-ESP32-S2. I've come at it all kinds of ways, with one or multiple I2C devices and varying the I2C bus speed from 10_000 to 400_000.

With these i2c devices:

  • adafruit_ssd1306
    
  • adafruit_seesaw (rotaryio: product number 4991)
    

When I do a i2c.scan() it never shows any devices, but I can "speak" to the rotaryio. When I enable the ssd1306, I get:

main.py output:
sys.implementation=(name='circuitpython', versi...
#

I tested with a seesaw board on an ESP32-S3. I get ETIMEDOUT starting at CircuitPython 9.0.0. It works in 8.2.10. There have been no significant changes to ports/espressif/common-hal/busio/I2C.c for several years, so I think it's an ESP-IDF upgrade issue. I also rebuilt 9.1.2 with

-CONFIG_FREERTOS_HZ=1000
+CONFIG_FREERTOS_HZ=100

and it still fails. CONFIG_FREERTOS_HZ was changed to 1000 post 9.0.0 anyway.

onyx hinge
#

Here is the notes document for next Monday’s CircuitPython Weekly Meeting. It is at the normal time of 11am Pacific / 2pm US Eastern here on Discord. Add your hug reports and status updates to the document before the meeting. If you are unable to attend but would still like to contribute, feel free to add your notes and we’ll read them off during the meeting. Hope to see you there! <@&356864093652516868> https://docs.google.com/document/d/1BXYMbOxPWUug-6WwltLdcvqv7i_de3059noqBx0Sn-M/edit?usp=sharing

manic glacierBOT
manic glacierBOT
#

Early on, we considered MTP. But there is no MTP support for macOS, sadly.

Is your concern about FAT that you are doing local writes in CircuitPython code to the filesystem, or that writes from the host might be interrupted?

CircuitPython has chosen FAT because it makes the workflow easy: no extra programs are required on the host computer. We prevent some problems by making the filesystem readonly to the CircuiPython code but not to the host, or vice versa. When MicroPython used FAT mo...

manic glacierBOT
#

There is already a 2432S028C board, which is very similar.

Be aware of the battery charging chip: this is a chip targeted at power-banks. It will kill smaller LiPos, since it uses 1A for charging. Also, sleep-modes won't work because this chip will cut power if the current is too low. And since the USB-power is also routed via this chip, this not only affects battery, but also normal plugged operation.

Now I don't own this board, but I own two very similar boards so I just assume it is ...

#

github codespaces are a proprietary development environment hosted in the cloud with free access limited based on hours per month. This feature seems to be something that a user can run locally on their own hardware. These can both be important considerations for developers.

If both are ultimately "made of" docker images, it would be nice if the code for creating the development environment could be shared between them, but I don't know enough to say how feasible this is.

#

The reported code used an invalid sample rate. This improves the error message so that it is not a generic IDFError.

The new error message says:

ValueError: sample_rate must be 20000-2000000

I verified at a sample rate of 20000 that I could read both 0 and 65535 using a jumper wire to another GPIO pin configured as a digital output.

My test code, run on a feather esp32 v2:

import digitalio, board, analogbufio, array

N = 30
rate = 20000

buffer = array.array("H"...
manic glacierBOT
#

My point is a bit different: the scripts in .devcontainer are just simple shell scripts. When you create a docker-container, you can run anything. That is what is going on behind the scenes of Github codespaces.

So the question is if the existing scripts can be modified in a way that allows them to run outside of the Github codespace environment in your own docker containers. I think only a few changes should be necessary (e.g. the scripts currently hardcode REPO_ROOT but they could be...

#

Ah, I thought there might be a catch! Apple compatibility issues always seem to cause trouble!

My big concern is that any application that periodically writes to flash will wear much faster than it needs to, and not have any power failure tolerance.

It seems like Dhara's checkpointing features would at least partially fix the power fail issues though, as long as there's not too many writes in between closing or syncing a file.

I assume FatFS probably syncs at smart times as one would expe...

#

In practice, we have not had reports of flash wearing out. People who are doing a lot of logging and the like tend to use SD cards.

I had not heard of dhara before, and found it here: https://github.com/dlbeer/dhara. Thanks for the pointer. I don't know if it is still being maintained.

I assume FatFS probably syncs at smart times as one would expect, not in the middle of metadata operations.

I'm not sure what you mean here. The writes to flash are cached in RAM and are done periodi...

#

Ah, I thought there might be a catch! Apple compatibility issues always seem to cause trouble!

They didn't want MTP because it allowed support of competitors to iPod. I think it's a dead issue now but they have no incentive to implement MTP now because it's not used very much, but that's partly a chicken-and-egg problem. We'd love to be able use a higher-level transactional filesystem on the host side.

#

I'm not sure what you mean here. The writes to flash are cached in RAM and are done periodically. FatFS itself does not do the writes. There's code in supervisor/shared that handles that.

I just found Dhara in a comment earlier up in the thread, but it seems to have some limited atomic transaction support.

So if you create a new checkpoint every time FatFS issues a sync ioctl, and you don't do too much in between syncs(It automatically makes its own checkpoints periodically), then ...

#

The problems we see with corrupted filesystems are mostly due to:

  • User presses reset when the host is writing or there's a write happening on the board side.
  • User unplugs (same issues)
  • Host delays writes for a lengthy period of time.
    • This was a big problem with Windows a long time ago, and supposedly was fixed in Windows 10 not too long ago (a year or two or three?). In particular, FAT12 had much longer write delays than larger FAT formats, which may have been left over from the...
manic glacierBOT
#

Linux has modest delays, but waiting a few seconds or typing sync or the equivalent fixes the issue.

@dhalbert : the simplest solution is to mount the CIRCUITPY-drive with mount -o sync .... There will be no OS-level buffering anymore and once the file is closed it is on the drive. This also fixes problems with editors not doing the flush().

manic glacierBOT
manic glacierBOT
#

My big concern is that any application that periodically writes to flash will wear much faster than it needs to, and not have any power failure tolerance.

What devices are you interested in using? We could switch all non-native USB devices over to littlefs on a major version boundary. Only USB MSC exposes the block level to an external computer. Without it, we could switch to littlefs.

#

Thanks for this. One spelling typo only. I'm also interested in Scott's opinion about what should be in these files.

Stuff in the repo should be things we want the community to be able to contribute to. The espressif port is mainly maintained by us (Adafruit folks) so we can slim it down and link out if we like. Other ports may have more details here if they were added by other folks.

I'd only use Learn for Adafruit maintained things.

#

And forgetting to deinit a certain peripheral could result in an unexpected higher power consumption. Debugging this could become rather challenging.

Ya, I think this is a good point. However, I'm not exactly sure how to define when to raise an exception or warning. I always think that folks optimizing power should use a PPK2 to check they are getting the consumption they need. Lots of things on a board (like neopixels) can have a big impact too.

Maybe we could add an attribute of "ex...

manic glacierBOT
#

I'm not exactly sure what would need to disable it, but I think it should
be handled already by the ESP-IDF's wake locks API, the ESP won't sleep if
one of those is held

On Tue, Aug 27, 2024, 2:56β€―PM Scott Shawcroft @.***>
wrote:

@.**** requested changes on this pull request.

Thanks for the initial PR!

Any idea of what functionality will need to disable this light sleep and
can you add the "disable" calls for that? Adding it here will make it
easier wh...

brazen hatch
#

Oh.. I got very weird idf breakage.
Under Beryllium OS, specifically on the cardputer, when the wifi is not connected, the standalone tty (kb input, display output) hangs on artifact PR9526 (idf pr) while it does not on the one before..
Furthermore, it's undebuggable, cause the moment I attach usb or another serial (uart or telnet) it immediately fixes itself..
Why does it always have to be I find the weird bugs..

#

I'll nuke usb serial and send stuff out with print() I guess

onyx hinge
#

oh that reminds me, there was a question around how to declare the type of the __init__ of a class that can't be constructed. It can be typing.NoReturn or typing.Never. This passes mypy --strict: ```import typing
class K:
def init(self) -> typing.Never:
raise RuntimeError("Cannot construct K instances")

#

NoReturn is probably better, as it is in 3.6; Never was added in in 3.11.

spare jacinth
#

i tried several things and none seemed to integrate nicely with both mypy and vscode's intellisense

#

maybe i did something wrong though

onyx hinge
#

yeah I only tested mypy

spare jacinth
#

also, from my understanding of the documentation, even though they both mean the same "do not do it, you will blow up", seems like Never is more for attributes/arguments, and NoReturn should be used for funcs

#

i even recall seeing some example as in def func(args: Never) -> None to mark that you should never fed arguments into the function... which is quite a weird syntax imo

onyx hinge
#
def never_call_me(arg: Never) -> None:
    pass```it's true that there's an argument of type Never shown in the Python documentation. (https://docs.python.org/3/library/typing.html#typing.Never)
spare jacinth
#

yeah, and i can't see how that differs from def never_call_me() -> NoReturn which looks a lot more obvious

onyx hinge
#

I think that's just some type theory stuff, I can't see why it's useful. (because once you take away the int and str type possibilities from the type annotation int | str you have an empty range of type possibilities, or the so called "bottom type")

#

never_call_me does always return None, though.

spare jacinth
#

yeah, but hinted as "never call me" perhaps means that "function" is not real code but a stub (.pyi) and needed some "fake" body for being valid syntax (pass)

#

anyway, i guess both ways get the thing done... no big deal
but i really didnt like how NoReturn/Never integrated with __init__ and left it as is πŸ™ƒ

onyx hinge
#

a lot of type annotations are very practical. the Never argument type seems much less so, but clearly important to theoreticians. https://en.wikipedia.org/wiki/Bottom_type πŸ’€ 😴

In type theory, a theory within mathematical logic, the bottom type of a type system is the type that is a subtype of all other types.
Where such a type exists, it is often represented with the up tack (βŠ₯) symbol.

#

When the bottom type is uninhabited, a function whose return type is bottom cannot return any value, not even the lone value of a unit type

spare jacinth
#

brain boom right here

stuck elbow
#

that's quite irrelevant for python, though, because python's type system is not consistent or sound anyways

#

so you can't really reason about it using the category theory

manic glacierBOT
slender iron
#

@onyx hinge were you looking at that bug too?

onyx hinge
#

@slender iron That's the one I'd intended to look at first (I think I said rgbmatrix in the internal meeting but that's the issue I meant) but I grabbed that analog sampling one first so I had not spent much time on it. Toe status: absolutely not stepped on.

slender iron
#

I didn't read the meeting notes....

#

Glad we sorted it out

blissful pollen
#

@onyx hinge Quick question, I'm looking at synthio for a random idea and general learning and wondering if you had any references for the direct digital synthesis it uses? If you don't have anything handy don't worry.

manic glacierBOT
onyx hinge
#

@blissful pollen "direct digital synthesis" is just a fancy word for how synthio generates frequencies that don't exactly divide the sample rate. I don't have a good reference about it offhand

#

say you are at 44.1kHz sample rate, and you want to generate a 440Hz note with a square waveform made up of 2 data points in the sample. Each output sample you need to advance by 440*2/44100 ~= .01995... input samples. If you scale this by some convenient factor like 65536 and then round it, you find you need to advance by 1308/65536 samples.

Then each time you want to generate an output sample, you just add 1308 to an accumulator, subtract off any excess part of the number, and divide by 65536 to find out which input sample to use. (which is a bit shift so it's quick to do)

#
blissful pollen
#

Oh cool thanks. That makes sense. I kept seeing many DDS example all with sine waves but that is basically the waveform in synthio (by default the square wave). That helps a lot!

onyx hinge
#

the rate calculation is dds_rate = (sample_rate / 2 + ((uint64_t)(base_freq * waveform_length) << (SYNTHIO_FREQUENCY_SHIFT - 10 + octave))) / sample_rate; on line 180

#

which today-me is glad that it was yesterday-me who figured THAT line out.

blissful pollen
#

Coincidentally that is the line I have opened and highlighted in my editor now trying to wrap my head around all this!

onyx hinge
#

(for MIDI note numbers; synthio_frequency_convert_scaled_to_dds is called for Note objects)

#

do you have a goal or project with this beyond better understanding?

blissful pollen
#

I have been thinking if it would be possible to do more reverb/echo effects, but that requires buffering more of the output to feed back into the loop. The 2350 may have the power to pull it off

onyx hinge
#

that would be cool. It would probably be a post processing step similar to the rudimentary IIR digital filtering, I'm imagining.

#

you might also look whether audiomixer could do it, especially since timchinowsky has contributed some work towards real time audio processing. if it doesn't have to be limited to synthio but could be done with mp3 files, sampled audio, etc., it could be pretty versatile

#
GitHub

This PR contains part of the changes necessary to implement the processing of live sampled audio as described in #2676. Here audiocore.RawSample is changed so that the sample can present itself ei...

GitHub

This PR contains part of the changes necessary to implement the processing of live sampled audio as described in #2676. Here analogbufio.BufferedIn is modified to add a loop keyword argument to Bu...

blissful pollen
#

Hmm I had not thought about that. I was poking through that code to see how the whole audio train of components works and makes sense.

Doing it on a per channel in synth would be nice but nothing lost to try a more general cause in mixer and then it could be used for any audio played that way too.

brazen hatch
#

Print output buffer gets stuck when usb is not attached

#

No wdt, just waits

#

resumes instantly when plugged

#

This is on repl so I should be able to replicate on a feather with just this for loop

#

imma make the bug report

#

Huh, no it doesn't happen on the feather..

#

Weird, maybe the cardputer keyboard thing is confusing it?

manic glacierBOT
#

CircuitPython version

Adafruit CircuitPython 8.2.7 on 2023-10-19; Adafruit QT Py ESP32-S3 4MB Flash 2MB PSRAM with ESP32S3

vs.

Adafruit CircuitPython 9.1.2 on 2024-08-22; Adafruit QT Py ESP32-S3 4MB Flash 2MB PSRAM with ESP32S3
Adafruit CircuitPython 9.2.0-alpha.2351 on 2024-08-22; Adafruit QT Py ESP32-S3 4MB Flash 2MB PSRAM with ESP32S3

Code/REPL

# Adafruit CircuitPython 8.2.7 on 2023-10-19; Adafruit QT Py ESP32-S3 4MB Flash 2MB PSRAM with ESP32S3
...
manic glacierBOT
#
[adafruit/circuitpython] New tag created: v1.22.0
#
[adafruit/circuitpython] New tag created: v1.22.1
#
[adafruit/circuitpython] New tag created: v1.22.2
manic glacierBOT
manic glacierBOT
#

CircuitPython version

Attempted update from 8.0.4 to 9.1.2.

Code/REPL

C:\Users\Devon\Downloads>esptool.py --chip esp32s3 erase_flash
esptool.py v4.6.2
Found 2 serial ports
Serial port COM3
Connecting...
Chip is ESP32-S3 (revision v0.1)
Features: WiFi, BLE
Crystal is 40MHz
MAC: xxx
Uploading stub...
Running stub...
Stub running...
Erasing flash (this may take a while)...
Chip erase completed successfully in 19.4s
Hard resetting via RTS pin...
...
manic glacierBOT
#

There could be a verbose/debug bool option that before actually entering sleep lists the things that will be disabled and the estimated current use.

alarms.suspend_until(alarms=myalarm, verbose=True)
I2C: suspended
Wi-Fi: powered off
spi: state stored
usb: cannot be suspended

Estimated microcontroller draw: 14mA

Entering sleep..

But it would be a bit of a pain to estimate the draw of each thing.
I think the checklist would be good enough, since it'd tell the user what...

manic glacierBOT
manic glacierBOT
#

Now, try_lock (SPI & I2C) & begin_transaction (display bus core) will check that the related objects are still valid first; if they are not, the lock/begin transaction will fail by returning false, rather than "other things" such as raising a Python exception where it is not permitted, accessing invalid memory, etc.

I tested by running a version of the #9426 reproducer on a Raspberry Pi Pico. It was able to complete & soft reset multiple times with no error. I also made sure that basic dis...

onyx hinge
#

I hope that works .. that was an annoying bug and it'd be nice to lay it to rest.

tulip sleet
#

@onyx hinge @slender iron should we maybe have an issue triage and assignment meeting today or soon?

onyx hinge
#

I'm out a chunk of the afternoon to catch up with a friend but I should be back by 1h before the evening meeting

lone axle
wraith crow
brazen hatch
manic glacierBOT
#

Oh yeah, KeyboardInterrupt (ctrl+c) and ReloadException are exceptions, so this code with a bare except is functioning exactly as standard Python. So this is likely not a fixable bug, it's just part of how ReloadException works. However, maybe there's a spot in the documentation where this could be better explained -- https://docs.circuitpython.org/en/latest/docs/library/builtins.html#builtins.ReloadException doesn't directly mention anything for example.

One (probably not particularly...

slender iron
manic glacierBOT
#

Okay.... If I'm remembering properly, I originally thought the issue was tightly associated with the auto-reload but then I thought I re-created it with auto-reload disabled so I was just using the auto-reload as an easy trigger to reproduce the error. When I get a chance to dig back into this, I'll have confirm the problem happens with auto-reload disabled and then see if an auto-reload is somehow being triggered even though they've been disabled or if there's another path to hanging the dis...

lone axle
#

@gilded cradle do you know if there is a known issue that leads to this error when attempting to select the host folder on the beta code.circuitpython.org site?

Also I started working on a fix for the duplicate serial messages after disconnect/reconnect multiple times and think I found a solution. But didn't notice until after I started working that there are both main and beta branches. Which one is the preferred one to submit PRs against?

manic glacierBOT
#

CircuitPython version

CircuitPython 9.2.0-alpha.2351

Code/REPL

No code executed

Behavior

[13:24:07.365] Connected to /dev/ttyACM0
I (623) esp_image: segment 0: paddr=00010020 vaddr=3c150020 size=3acc0h (240832) map
I (660) esp_image: segment 1: paddr=0004ace8 vaddr=3fc9f200 size=05330h ( 21296) load
I (664) esp_image: segment 2: paddr=00050020 vaddr=42000020 size=14718ch (1339788) map
I (869) esp_image: segment 3: paddr=001971b4 vaddr=3fca4...

manic glacierBOT
manic glacierBOT
#

@occasional-contributor Let me know if you have a discord handle, I'd rather talk there than a closed issue :/

Is there any chance you could post the identifying string from the back side of your board? After applying this PR, my display is rotated 270 degrees in a portrait mode, just like your "Before" photo so it appears our two devices have different rotation requirements.

If the ID on your board is the same as mine, I'll just submit a PR that adds a comment to the board.c file indi...

manic glacierBOT
manic glacierBOT
#

Thanks for the discussion! When I wrote this I wanted to make a tool that (1) exemplified and expanded on the published build procedure while making it easier and (2) provided an example of how Docker can be used to make all sorts of jobs like this less painful (at least if you run Linux). I looked at the CI scripts and decided that something simpler might be more helpful to others.

manic glacierBOT
#

Commenting out these two lines from mpconfigboard.h

#define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO43)
#define CIRCUITPY_CONSOLE_UART_RX (&pin_GPIO44)

and these lines from sdkconfig

CONFIG_ESP_CONSOLE_UART_CUSTOM=y
CONFIG_ESP_CONSOLE_UART=y
CONFIG_ESP_CONSOLE_UART_CUSTOM_NUM_0=y
CONFIG_ESP_CONSOLE_UART_NUM=0
CONFIG_ESP_CONSOLE_UART_TX_GPIO=43
CONFIG_ESP_CONSOLE_UART_RX_GPIO=44
CONFIG_ESP_CONSOLE_UART_BAUDRATE=115200

prevents the boot loop on the Makerfabs board. Is...

manic glacierBOT
manic glacierBOT
#

The difference I see is that the original one I configured only has the one
usb port and this one, with the same model number, has both micro and type
c, and also a differently configured LCD, apparently.

On Wed, Aug 28, 2024, 7:35β€―p.m. Occasional Contributor <
@.***> wrote:

PXL_20240828_223158275.2.jpg (view on web)
https://github.com/user-attachments/assets/f29d5b7c-f6b1-4e3f-9a91-add8185cd312

β€”
Reply to this email directly, view it on GitHub
<https://githu...

manic glacierBOT
orchid basinBOT
manic glacierBOT
#

I don't think it's worth trying to set up different firmware variants for these CYD boards that have the same silk screened model number. They appear to be cloned left and right and who knows what other differences may show up. The screen orientation can probably be dealt with in software by releasing the board.DISPLAY object and re-initializing the display with the proper rotation.

manic glacierBOT
#

CircuitPython version

Adafruit CircuitPython 9.1.1 on 2024-07-23; FeatherS3 with ESP32S3
Board ID:unexpectedmaker_feathers3
UID:0740D1DA1CCA

Code/REPL

import board
from adafruit_ble import BLERadio
from adafruit_ble.advertising.standard import ProvideServicesAdvertisement
from adafruit_ble.services.nordic import UARTService
import neopixel
import time

def monitor():
    ble = BLERadio()
    #uart = UARTService()
    #advertisement = ProvideServ...
orchid basinBOT
orchid basinBOT
manic glacierBOT
manic glacierBOT
#

CircuitPython version

Adafruit CircuitPython 9.2.0-alpha.2351 on 2024-08-22; Raspberry Pi Pico 2 with rp2350a

Code/REPL

import board
import time
import board
from digitalio import DigitalInOut, Direction, Pull

tasterSchwarz = DigitalInOut(board.GP28)
tasterSchwarz.direction = Direction.INPUT
tasterSchwarz.pull = Pull.DOWN

while True:
        if tasterSchwarz.value == 1:
            print("key down")

Behavior

The state of the pin does...

#

This is a hardware bug in the RP2350, unfortunately. See #9541 and https://github.com/raspberrypi/pico-feedback/issues/401. Also see https://forums.raspberrypi.com/viewtopic.php?t=375631. We are awaiting further information for Raspberry Pi about their path forward on this.

Closing this in favor of #9541, but thank you for reporting, so that we know that typical users are hitting this problem as well. Multiple people and companies are encountering

manic glacierBOT
#

CircuitPython version

Adafruit CircuitPython 9.1.2 on 2024-08-22; Raspberry Pi Pico W with rp2040

Code/REPL

Sourcecode for Python is in my public repository at 

https://github.com/watermark-woods/GateController/blob/main/code.py

It relies on a Google Apps helper script to pull and format a Google calendar for schedule.
https://github.com/watermark-woods/GateController/blob/main/googlecloudcode.js

You can watch the test harness after power on at ht...
manic glacierBOT
#

I reproduced this once on an Adafruit Feather ESP32-S3 TFT and 9.2.0-alpha.2351-7-g19e5cf3d8f using a very simple test program that eliminates adafruit_httpserver:

import errno
import wifi
import socketpool

def wrap_accept(s):
    try:
        return s.accept()
    except OSError as e:
        if e.errno == errno.EAGAIN:
            return None, ("", 0)
        raise

socket = socketpool.SocketPool(wifi.radio)
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
...
manic glacierBOT
onyx hinge
#

Darn, my #9460 reproducer has still not reproduced a 2nd time. There must still be an unknown factor.

manic glacierBOT
#

I did eventually get a 2nd crash with just about the same code. That run took almost 1 hour to crash.

<details>

[11:44:01] Traceback (most recent call last):
[11:44:01]   File "code.py", line 1
[11:44:01] SyntaxError: invalid syntax
[11:44:01] 
[11:44:01] Code done running.

[11:44:01] Press any key to enter the REPL. Use CTRL-D to reload.
[11:44:02] 
[11:44:02] Adafruit CircuitPython 9.2.0-alpha.2351-7-g19e5cf3d8f on 2024-08-28; Adafruit Feather ESP32-S3 TFT with ESP32S3
...
onyx hinge
#

it did finally crash again but this time with hard fault, not wdt

slender iron
#

looks like the docs build is broken under 3.12

slender iron
#

I'm looking into the RTD issue

#

looks like an autoapi update that broke us

#

it removes stdlib methods

manic glacierBOT
#
[adafruit/circuitpython] New branch created: test-push-1724958041009
manic glacierBOT
tulip sleet
#

@slender iron so autoapi change is a big one?

slender iron
#

not big. just breaks us

tulip sleet
#

Maybe merge to 9.1.x and then we'll merge to main. I have another thing from 9.1.x too

slender iron
#

kk, lemme switch it

tulip sleet
#

I am about to make a fix for ESP32-C6 UART for 9.1.x.

slender iron
#

πŸ‘

#

k, updated

manic glacierBOT
#
  • Fixes #9577.

  • ESP32-C6 and ESP32-P4 have a new "low-power" UART, which has less functionality and only works on certain pins. It is in the regular UART numbering scheme. Don't use it, at least for now (it has some wake-up ability for sleep, so it might be interesting in the long run).

  • UART() constructor was not cleaning up when uart_set_pin() failed.

  • Also removed redundant CIRCUITPY_ESP_USB_SERIAL_JTAG = 1 from a C6 board. It's already set by default. (I had removed that lin...

tulip sleet
#

@slender iron github is having issues. The "Actions" item has disappeared from the horizontal list of things at the top, at least for me. For you, too? https://www.githubstatus.com/ is reporting problems

slender iron
#

yup. I just noticed that too

#

looks like actions was disabled on the repo

tulip sleet
#

ack, I was trying to disable actions on MY repo.

#

my fault

#

i was getting spurious micropython builds

slender iron
#

πŸ‘

tulip sleet
#

i wonder how we can trigger them again for the PR's

#

I amended my last commit, just changing the message slightly, and the push -f

slender iron
#

@tulip sleet this usb issue is in tinyusb. think I should switch us to a fixed repo or just wait for thach to merge in the fix? it is simply turning on an interrupt on resume

tulip sleet
slender iron
#

ya, as long as he's working it should be an easy merge

tulip sleet
#

is it something that should go in 9.1.x?

slender iron
tulip sleet
#

i would put that in 9.1.x since it's a significant regression: might break macropad, etc, Is it just Espressif?

manic glacierBOT
tulip sleet
#

@slender iron I think only q is whether there are other changes we should know about that we would pick up with an update to master that includes this

#

is it a regression in TinyUSB or did it never actually work?

slender iron
#

a few but probably not many

#

I don't think it ever worked

tulip sleet
#

ok, so then I wouldn't worry for 9.1.x after all

slender iron
tulip sleet
#

9.1.x fixes are for significant bugs, especially regresions, or new boards that need a stable release, etc. -- that's been my thinking

manic glacierBOT
manic glacierBOT
manic glacierBOT
#
[adafruit/circuitpython] New tag created: 9.1.3
tulip sleet
#

@slender iron rtd jobs are still failing (maybe in a different way) in 9.1.x builds; it's confusing to me whether it's just failing because it's failing to fetch the badge?? WARNING: Could not fetch remote image: https://readthedocs.org/projects/circuitpython/badge/?version=latest [502]. That is actually fetchable when I try

#

not holding me up

orchid basinBOT
tulip sleet
#

https://blog.adafruit.com/2024/08/29/circuitpython-9-1-3-released/
Highlights of this release

  • Fix Espressif ESP32-C6 UART creation.
  • Adafruit Qualia ESP32-S3 RGB666: fix display tearing.
  • Pull request merge builds for stable branches, not just the main branch, are now uploaded to AWS S3.
  • Fix Espressif board-specific pin initialization. This fixes board.NEOPIXEL_I2C_POWER initialization on the Adafruit Feather C6.
Adafruit Industries - Makers, hackers, artists, designers and engineers!

From the GitHub release page: This is CircuitPython 9.1.3, the latest bugfix release of CircuitPython, and is a new stable release. WARNING for nRF52 boards only: If your board has an nRF52 UF2 boo…

sturdy crest
lone sandalBOT
manic glacierBOT
manic glacierBOT
manic glacierBOT
#

The good news is, your last push did resolve the pre-commit problem during CI.

The failure was in building the documentation, which is not due to your PR. It can be ignored. (should be fixed by #9580)

The other problem that needs to be fixed is that your latest change also changes the Pico-PIO-USB submodule. Using git add . or git commit -a (rather than individually choosing each file to commit in a program like git gui) is very prone to including more than you intended to change, e...

onyx hinge
#

oh git & github, it's so easy to not get everything exactly right.

tulip sleet
manic glacierBOT
#

The "posix port" aims to enable compile-time tests that we currently do with the "unix port", but with a build that uses as much of the CircuitPython shared-bindings & supervisor as possible. Once we have to stop maintaining changes within micropython's unix port, this removes one of the hassles of merging micropython changes into circuitpython. It may also enable testing new parts of the shared-modules libraries (for instance, gifio has become testable though this change)

Locally this tes...

onyx hinge
#

not getting very far on #9460 -- haven't actually had any crashes so far today.

I tried to determine whether it's a problem up in Python object land or down in lwip internals land. For instance, I totally bypassed actually calling lwip_accept and got 0 crashes in 1 hour. But since then I've gotten 0 crashes in about 3 hours with the original code. so it's not a conclusive test.

blissful pollen
#

I think I have figured this out but if someone knows to confirm, for audio buffers if it is stereo the buffer object is LRLRLR... vs mono would just be MMMMM? Then I2S can just take L/R to transmit of double M to MM to transmit out both channels?

stuck elbow
#

the chip I use lets you pick which channel to use

onyx hinge
#

@blissful pollen roughly yes, I think "standard" I2S always has to transmit 2 channels, so one way to deal with a mono sample is to just replicate it before outputting. the C function audiosample_convert_u16m_s16s does this and is used e.g., on espressif when plaing a mono stream on i2s. I don't see where rp2040 does this.

blissful pollen
#

Been trying to think through how audio effects could be built to work for any type of audio channel. So if I want reverb could add it to a mixer or synth channel or wav, etc. Have a long drive this weekend to think about it more

onyx hinge
#

oh yeah that data replication feature would do it

manic glacierBOT
manic glacierBOT
#

This fixes #9569 boot loop for the Hacktablet and Makerfabs 7" TFT ESP32-S3 666 Dotclock display boards.

It looks to me like in addition to the Hacktablet and Makerfabs TFT 7" boards, the Espressif ESP32S3_LCD_EV and possibly (I don't know if non-S3 boards are affected) the Lilygo twatch_2020_v3 may be affected by this issue. I don't have either of those devices to test with but could add the same sdkconfig changes for those boards if that makes sense?

manic glacierBOT
manic glacierBOT
#

Converting to draft for now. The latest commit has started refactoring these to be module functions instead of class functions on Circle and Rectangle, that will ultimately lead to de-duplication of this logic.

As of now only the new implementations are added, the old class functions are not removed yet. Once I do remove them and any other requisite changes I'll mark this ready.

manic glacierBOT
#

CircuitPython version

Adafruit CircuitPython 9.1.3 on 2024-08-29; Seeed XIAO nRF52840 Sense with nRF52840
Adafruit CircuitPython 9.1.2 on 2024-08-22; Seeed XIAO nRF52840 Sense with nRF52840
Adafruit CircuitPython 9.1.0 on 2024-07-10; Seeed XIAO nRF52840 Sense with nRF52840
Adafruit CircuitPython 9.0.5 on 2024-05-22; Seeed XIAO nRF52840 Sense with nRF52840

Code/REPL

import microcontroller
microcontroller.on_next_reset(microcontroller.RunMode.BOOTLOADER)
...
manic glacierBOT
#

Or may an "active power users" list.

This sounds pretty straightforward. Essentially this would be a python API that internally just accesses the bitmap used in prevent_light_sleep() that you mentioned earlier.

Yes, all we'd really need is some attr bools in the alarm module to implement this.
alarm.will_suspend_xxxx or alarm.will_suspend.xxxx

I'm not sure I understand the idea. To me, e.g. alarms.will_suspend.wifi sounds like a constant, that indicates whether wifi would be...

manic glacierBOT
manic glacierBOT
nimble sparrow
#

Has anyone ever broached adding the ability to redirect sys.stdout to a valid alternative stream?

#

Just skimming back through I don't see a discussion, though I'm sure it'll be somewhere buried.

stuck elbow
nimble sparrow
#

To redirect stdout?

stuck elbow
#

to use it in place of stdout

#

you don't get the repl and error messages on it too, so it's easier to handle

nimble sparrow
#

Ah, right I see what you mean - no, I specifically want to redirect the repl. exec() by longstanding and perfectly sensible design doesn't return output like eval(). In CPython you can redirect stdout to any valid stream (for example, a file, or an arbitrary serial object).

stuck elbow
#

hmm, webrepl does it, but it's C

nimble sparrow
#

Yeah, I imagine it would be relatively straightforward under the hood in the firmware and I expect it's far less simple at the higher level

tulip sleet
nimble sparrow
#

Can't blame you for streamlining, my use case is undoubtedly niche

tulip sleet
#

there are ways to redirect it to a UART in addition via compilation options

nimble sparrow
#

Most of the time when you want to view the REPL other than via web or cdc you can just use terminalio

nimble sparrow
tulip sleet
nimble sparrow
#

I may have misread the active PRs and Issues, thought there were issues being worked out for Espressif BLE

tulip sleet
#

that is true, I think, but it was working for nordic

#

i have forgotten which apps or browser apps support BLE REPL, if any

#

but I haven't tried it

nimble sparrow
#

Righto, no worries - and certainly not worth contemplating unearthing a crusty bit of MP/CPython

manic glacierBOT
manic glacierBOT
nimble sparrow
# manic glacier

This was a terrifying find, very grateful to @brazen hatch for clocking the minor difference in reg values!

manic glacierBOT
manic glacierBOT
manic glacierBOT
brazen hatch
#

If anyone here knows battery chemistry please let me know. I can set it to charge all the way up to 4.2V, stopping only when there 0mA current draw from the cell.
But this means imperfect readings could charge the battery to 4.21V.
Should I set it to charge to 4.2 or 4.185 like I have it with the 25mA stop limit?

#

Do batteries even have an acceptable tolerance at 4.2V?

orchid basinBOT
manic glacierBOT
#

As of #9164 (MAX3421E support), SPI.deinit(), only on Espressif, waits for the lock to be unlocked before proceeding with the deinit(). If there is nothing else that is going to unlock the lock, CircuitPython hangs and cannot be interrupted.

    // Wait for any other users of this to finish.
    while (!common_hal_busio_spi_try_lock(self)) {
        RUN_BACKGROUND_TASKS;
    }

This caused adafruit_dotstar.DotStar.deinit() to hang forever. DotStar grabs the lock when cons...

manic glacierBOT
#

CircuitPython version

Adafruit CircuitPython 9.1.3 on 2024-08-29; Adafruit Feather ESP32-S3 TFT with ESP32S3

Code/REPL

# Packages (adafruit_imageload and adafruit_st7789) came from:
#  https://github.com/adafruit/Adafruit_CircuitPython_Bundle/releases/download/20240827/adafruit-circuitpython-bundle-9.x-mpy-20240827.zip
from board import SPI, TFT_CS, TFT_DC
from displayio import (Bitmap, Group, Palette, TileGrid, release_displays)
from fourwire import Fo...
nimble sparrow
brazen hatch
#

PR is good to go.

wraith crow
#

I probably missed this when the pico2 first came out but when I build the pico2 firmware locally my device doesn't boot, no serial device, no CIRCUITPY drive. If I grab the "absolute newest" from circuitpython.org the device boots normally, I've been building espressif boards without issue but it's been a while since I've built an RP2040 board, is there a raspberry SDK update I have to do locally or something?

tulip sleet
stuck elbow
wraith crow
#

I did a make remove-all-submodules and then make fetch-all-submodules again just to make sure, the firmware builds but doesn't boot. I did download the absolute newest from the board page and that works fine. My gcc version is 11.4.0.

tulip sleet
#

we are using gcc 13.2rel1

wraith crow
#

okay, I'll try getting that updated 😁

wraith crow
#

okay, it has been a long time since I looked back at the learn guides 😁

wraith crow
#

@danh @stuck elbow That did it! Thanks πŸŽ†

tulip sleet
wraith crow
#

I was actually using version 10.3 of the cross compiler, 11.4 was the native gcc....

#

I guess it's really been a while since I've built raspberry images 😁

tranquil ether
#

hello! I'm pretty far along on a big project and I would like to add some error logging. Sometimes I get hangs/crashes after long run times and I thought if I periodically log to file, I could investigate the crashes. SO, I looked at the website and they show that you need to change the file IO to (a) PC can write files to (b) CircuitPython can write files. And their recommendation is is to use hardware pin and some code in boot.py. I don't like the idea of adding a pin-read. Has anyone actually worked with this file switcheroo functionality?

#

Actually, I could use the push button that is already on the system. boot.py would read only on start-up, so my procedure would be to hold that button down on boot. Still I would really like to hear if someone has worked with this functionality

spare jacinth
#

i dont think anything would be more convenient than the button, but you could eg store a bit on nvm that controls whether computer or circuitpython gets access to the filesystem (being toggled on each boot)

tranquil ether
#

I already have an NVM read on boot and it has been working reliably for months now. I quite like it

spare jacinth
#

if the PCB was designed that way, you could perhaps check whether power comes from USB port (likely PC, but might be some other thing with a USB cable in it), or from some other input... to then configure filesystem accordingly

#

but yet again, and specially when you already have a button, i think that's the best solution

#

that's just my personal preference, ofc

tranquil ether
#

yeah, I think you are right. Thatnks for kicking this around a bit. I think I have a good way forward now

manic glacierBOT
#

I wanted to try using a Pico2 with a piCowbell DVI or a Pimoroni Pico DV base so I built a Pico2 firmware with picodvi enabled. I'm guessing that the Framebuffer_RP2350 routine has been updated to support HSTX and dedicated(?) pins associated with that peripheral since it kicks out the PIO pins used by the older Pico DV devices as invalid.

This may only be a short term issue until new HSTX versions of these devices become available but it would be nice if there was some legacy support to r...

manic glacierBOT
#

One other thing maybe worth changing for the challenger_rp2350_wifi6_ble: board.ESP_RXD is actually the TX-pin (from the perspective of the MCU). Same with board.ESP_TXD, which is the RX-pin. The very similar challenger_rp2040_wifi_ble has this right (but using the pin-names board.ESP_RX, board.ESP_TX).

I would also keep the pin-names in sync. I assume there will be users upgrading from the rp2040_wifi_ble and they will certainly be more happy if they don't need to change their pro...

manic glacierBOT
lofty terrace
#

I was told that I should at least mention my CP issue here, since it "might be a regression in the socket code" (I hope those words mean something) from 9.05 to 9.1.0. The linked post includes code to duplicate the problem.

#help-with-circuitpython message

onyx hinge
lone axle
# tranquil ether hello! I'm pretty far along on a big project and I would like to add some error ...

I've used a digital pin to enable / disable writable mode for a handful of projects on several different micro-controllers and never had any issues.

I suppose if it lost power while circuitpython was trying to write it might lead to the drive being in a corrupted state though. Maybe best not to do it on a battery powered project unless you also have active battery monitoring and can disable "risky" behaviors like writing when the power is low.

Truthfully though if you can work in an SDCard to the circuit then it's more convenient than writing to CIRCUITPY drive IMO. You get way more capacity and don't risk corrupting the microcontroller storage + you don't have to set up and use the pin to switch states during boot since your SDCard can just always be writable.

tranquil ether
# lone axle I've used a digital pin to enable / disable writable mode for a handful of proje...

Thanks for the response. Just what I wanted to hear was someone's experience over multiple projects. I'll keep the SD card in mind. Many of my projects are on the larger side and adding features that are for ME and for development just make sense. I had a great big push button in the project and so now I'm reading that during startup. So, to go into dat-logging and error-loggin mode, I just hold down the button during power-on. Seems to be working ok (<24 hrs)

#

How about the reset signal? as soon as I screw the enclosure shut, I seem to need to do a hard reset. Do you have experience using a reset button? perhaps less of an issue now that I'm using a powered USB hub with a push-on/off button.

manic glacierBOT
lone axle
# tranquil ether How about the reset signal? as soon as I screw the enclosure shut, I seem to nee...

Some microcontrollers expose the reset pin on a header that you could then extend out to the outside of your case if you needed. The raspberry pi pico famously does not have an on-board reset button so if you want to reset it you must either attach your own to the exposed pin or just use a jumping wire to connect it to GND.

I use reset buttons frequently, but don't use enclosures that much, and when I do I typically end up with ones that leave the on-board reset pin exposed either on an edge or with a hole cutout to poke it with something skinny.

manic glacierBOT
midnight ember
#

@tranquil ether When wiring up an enclosure external reset switch, for microcontrollers that only have a reset button and no GPIO reset (such as the QT Py) you can bodge some wire to the physical reset button. It won't be pretty but it will work. Any Feather is super easy in comparison as Feathers have 2 GPIO for hard reset (RST to GND or EN to GND).

manic glacierBOT
#

It's difficult to report detailed error information from the constructor of a PWMOut object, because the constructor is designed to never throw an exception; instead, it can return one of a small number of generic failure reasons.

It was written this way so that the code could safely be called outside the VM, specifically so that LCD backlight objects could be created at board initialization time.

As for why it fails now and did not in the past, it is probably due to changes in esp-idf ...

onyx hinge
# midnight ember <@1112401636166488165> When wiring up an enclosure external reset switch, for mi...

@tranquil ether in addition to that, many Adafruit boards have undocumented test points for reset & boot mode that can be seen on the PCB designs. these are used for factory test. For instance, qt py esp32-s2 has SWC1 for rset and SWC2 for BOOT0. It is tricky but you can solder fine wire to these pads and bring it out to a physical button. There's no silk for these pads so you'll want to import the design files into an eagle-compatible PCB editor so you can locate it. https://learn.adafruit.com/adafruit-qt-py-esp32-s2/downloads

manic glacierBOT
#
  • Didn't this configuration work once upon a time?

Yes it did, the boot loop didn't occur in 9.1.2/9.1.3.

  • Does removing the sdk uart configuration have any downsides, like preventing visibility of early boot messages?

On the two boards I have/tested, I was still able to connect to the REPL over the UART but you are right, the early boot messages are no longer visible :cry:

  • I found 4 boards with CONFIG_ESP_CONSOLE_UART=y in sdkconfig but this PR changes 2. Any reason to l...
manic glacierBOT
#

I would prefer these be suppressed for ordinary use.

Okay, but remember that at least on the boards I'm testing, their are two USB connectors, for ordinary use you would connect to the connector labeled USB which brings up the CIRCUITPY drive and shows up as /dev/ttyACM0, that connection doesn't show the early boot messages anyway. If you're connecting to the UART connector /dev/ttyUSB0 you don't get the CIRCUITPY drive and you're probably doing some debugging. That's the connection that...

tulip sleet
manic glacierBOT
manic glacierBOT
lone axle
#
The MagPi magazine
  • Pico 2. Raspberry Pi’s latest microcontroller board is the ideal engineering and education platform. It brings the brand new RP2350 processor into a hackable, makable board with GPIO input and output pins. We’ve secured interviews with the engineering team about this electronic marvel.

  • RP2350. With its higher clock speed, double the...

lone axle
slender iron
#

(was just going to ask about the merge) πŸ˜„

onyx hinge
#

πŸ‘‹

lone axle
#

Thanks for hosting Dan. Have a great week everyone.

slender iron
#

@tulip sleet need any help/assistance on the 1.23 merge? It'd be good to have that in 9.2

manic glacierBOT
tulip sleet
#

Here is the notes document for next Monday’s CircuitPython Weekly Meeting. It is at the normal time of 11am Pacific / 2pm US Eastern here on Discord. Add your hug reports and status updates to the document before the meeting. If you are unable to attend but would still like to contribute, feel free to add your notes and we’ll read them off during the meeting. Hope to see you there! <@&356864093652516868>
https://docs.google.com/document/d/13FWJDCzuchjYlYK_5Q_3zCgKl5-x6oX0YLFo-AkJMJM/edit?usp=sharing

manic glacierBOT
wanton dirge
#

Getting our young port up and running for the first time...the MSC device mounts correctly but shows up as a USB drive (not "CIRCUITPY"). Windows wants to format it before I can use it...I'm doubting that's advised as I can't see that anywhere in documentation. Is there anything special I have to do for Windows to recognize the filesystem properly?

slender iron
#

@wanton dirge I suspect the formatting code that CP is doing isn't working

#

how are you storing the filesystem? CP has an "internal" mechanic or an "external" one

wanton dirge
#

Internal currently, but wanted to get the REPL up before I was really able to test my internal_flash.c/.h. It is totally possible that my flash FS driver is the culprit.

slender iron
#

do you have a way to do debug printing? you could dump the first few bytes of every read and write

#

to make sure the subsequent reads match what was written

wanton dirge
#

At this point I have the USB-CDC, so I could try dumping to that with mp_printf?

slender iron
#

that'll only work once USB is going

wanton dirge
#

Ah, right

slender iron
#

and the flash formatting happens before that. have you done busio.UART yet?

#

(you could also use your own uart code)

wanton dirge
#

Doesn't get set up until after boot, right. No haven't done busio.UART but I'm not too far off; I did add in a serial.c for the supervisor at least which I can perhaps mangle into that module.

slender iron
#

what does your current serial do?

#

busio.UART just means the standard "CONSOLE_UART" stuff will work

wanton dirge
#

Nothing in particular, I had it as a placeholder to test out after getting the REPL up. That happened about 30 minutes ago πŸ™‚

#

Was intending to perhaps use it as a debug UART for me to develop with

slender iron
#

it may be quicker to just init a sdk UART for debug prints

#

busio.UART may get you into pin mapping earlier than you want to

wanton dirge
#

I do have a lot of the preliminary pin scaffolding done, but I think using a simple debug UART to debug the FS stuff should be pretty simple. Thanks, I'll give that a shot!

slender iron
#

πŸ‘ good luck!

#

I think your error is "usb is working ok but the MSC bytes back don't have a file system"

wanton dirge
#

Yep, that sounds about right. Just wanted to make sure that was the right path before diving in again

tulip sleet
# wanton dirge Ah, right

there is normally a "safe mode" message that says "CIRCUITPY drive could not be found or created." which should show up in the REPL when you press reset.

blissful pollen
#

Making sure this makes sense, after doing some research and testing with audio effects best bet to make an issue to track my ideas? There is one (https://github.com/adafruit/circuitpython/issues/8974) but is specific to AudioMixer and I have an idea that may work more generic. Probably better this way to discuss any API issues before a draft PR?

slender iron
blissful pollen
manic glacierBOT
manic glacierBOT
#

This is a breaking change to the API. The API is _eve, not eve, so is this somehow considered an internal change, hidden by some library? You are the original submitter of _eve, so you're the expert on this.

I don't really have any idea what the client base of _eve is in CircuitPython.

We generally make breaking changes on a major-version boundary, in this case 10.0, which is not imminent by any means. We often try to make the intermediate versions handle both cases for a whil...

manic glacierBOT
#

I took a quick peek at the make stubs you mentioned and it seems I'd need more than 20 minutes to figure out what exactly needs to be done. So far I haven't found that extra time :)

I'd probably prefer merging this now as-is and looking into how to generate the documentation a bit later, to avoid this hanging for uncomfortably long (e.g. I'm probably too busy this weekend to take a look).

manic glacierBOT
#

I wanted to add effects on synth channels and saw this issue also about adding audio effects. After some discussion on discord and looking through the code and some other audio libraries I see all the audio code uses get ..._get_buffer_structure and ..._get_buffer to pass information from one to another. In this way audio components can be chained together. E.g. synthio.Synthesizer can play into audiomixer.Mixer which can play into audiobusio.I2SOut to get to the speaker.

My idea...

lone sandalBOT
manic glacierBOT
#

MicroPython probably has this issue as well. This is code from them.

@tannewt Thanks for the pointer; I just had PR micropython#15708 approved for this, and there were a few recommendations that I'd like to bring back here. I have a branch ready for PR, but I want to check my approach.

I've just cherry-picked from to my mp branch to a cp branch. This double-upstream scenario is new to me, though; is there a preferred way to bring changes down from mp?

manic glacierBOT
manic glacierBOT
#

I tested the camera with CircuitPython 9.1.3 and it works. Here a snippet to test it:

import board
import displayio
import struct
import cores3
import adafruit_ticks

cam = cores3.camera(framebuffer_count=2)
display = board.DISPLAY
display_bus = display.bus

display.auto_refresh = False

display_bus.send(42, struct.pack(">hh", 0, 319))
display_bus.send(43, struct.pack(">hh", 0, 239))
t0 = adafruit_ticks.ticks_ms()
while True:
    frame = cam.take(1)
    if isins...
onyx hinge
#

I noticed that this message is printed during a failed build. ```common-hal/rp2pio/StateMachine.c: In function 'common_hal_rp2pio_statemachine_get_pc':
common-hal/rp2pio/StateMachine.c:1102:13: error: unused variable 'offset' [-Werror=unused-variable]
1102 | uint8_t offset = _current_program_offset[pio_index][sm];
| ^~~~~~
cc1: all warnings being treated as errors
-e See https://github.com/micropython/micropython/wiki/Build-Troubleshooting

../../py/mkrules.mk:14:HELP_BUILD_ERROR ?= "See \033[1;31mhttps://github.com/micropython/micropython/wiki/Build-Troubleshooting\033[0m"

tulip sleet
#

I think it snuck in, in the v1.22 merge

onyx hinge
#
-e whatever
```system that use dash as /bin/sh may print the -e because it's not a recognized flag by the built in echo command.
#

@tulip sleet thanks

tulip sleet
#

I'm not sure it's all that helpful a message even if we pointed it to, say, the Learn Guide

manic glacierBOT
slender iron
tulip sleet
slender iron
#

@onyx hinge if you are in PIO land, you could look at the new additions in the rp2350

onyx hinge
#

@slender iron good idea. I'm also a bit interested in doing ps2io in pio, I don't think we have it on rp2xxx yet.

manic glacierBOT
manic glacierBOT
lone sandalBOT
uncut nexus
#

@onyx hinge What day(s) are planning to be at the Vintage Computer Festival? We'll be going up on Saturday, I think

onyx hinge
#

@uncut nexus I'm planning to be there both days, driving in from Nebraska friday & driving home monday.

uncut nexus
#

@onyx hinge OK - I'll be the tall old guy saying things like "haven't we got one of those in the basement?"

onyx hinge
#

I'd be happy to meet you. I think I'll mostly be wandering around seeing what people have at their exhibition tables.

uncut nexus
#

Us too. I'll keep an eye out for you. Hard to meet up with so many folks around

manic glacierBOT
onyx hinge
#

my hair has mostly faded/grown out since pycon

stuck elbow
#

oh well

manic glacierBOT
manic glacierBOT
#

The _eve implementation now works in legacy mode by default. This preserves the existing behavior.

When switched into "new" mode it accepts the new argument formats. It wasn't much more code to handle this.

I've added coverage in my test cases for both modes, and it passes on rp2040.

(Note that I had to turn off _eve for the metro_m4_airlift_lite board, as it overflowed the flash. I don't think anyone is using _eve on this tiny board.)

#

The _eve implementation now works in legacy mode by default. This preserves the existing behavior.

When switched into "new" mode it accepts the new argument formats

So, just to clarify my understanding: is the 2-ints-vs-1-float difference a difference in the eve displays themselves, from older to newer versions, or do they all have the same firmware?

I was thinking you could decide which computation to do based on the number of args to each transform function: if two args (in...

manic glacierBOT
#

So, just to clarify my understanding: is the 2-ints-vs-1-float difference a difference in the eve displays themselves, from older to newer versions, or do they all have the same firmware?

This is an EVE hardware function, and it works in fixed-point coordinates. What this change is doing is hiding the fixed-point math, so the user code can use floats.

I was thinking you could decide which computation to do based on the number of args to each transform function: if two args (in...

crimson ferry
#

uh oh... simply adding import wifi to a <200 line code.py running Adafruit CircuitPython 9.1.3 on 2024-08-30; FeatherS2 with ESP32S2 causes it to crash/hang (but no safemode) ...I'll see if I can narrow it down

manic glacierBOT
manic glacierBOT
#

@dhalbert sorry for late response. This does not ring any bell to me, I am not quite sure, but I remember to see this randomly (not very often). The flow would be around CPY is_writable_cb() usage

  • when is_writable = false tinyusb will reject WRITE_10 command
  • host will send TEST_UNIT_READY/REQUEST_SENSE for previous failed reason, currently is SCSI_SENSE_DATA_PROTECT
  • normally host will attempt to re-write again later

not sure what went wrong, maybe we could use a not sense such as ...

manic glacierBOT
#

@todbot Addressing the original issue: I was able to implement TouchIn using a 1M pull-up instead of a pull-down, testing on an RP2040. The sense code just pulls the pin down instead of up and then measures the time to flip from logical low to high. The code changes are simple. The calibration may need to change due to the transition voltage not being exactly in the middle, but in principle it works.

However, this method doesn't yet work on RP2350 because of the latch-up. I need to impl...

slender iron
#

@fading stirrup how'd the P4 work go? I've got a devkit coming tomorrow

wanton dirge
#

Hey folks, I'm checking in again on the FS component for my young port: FS is mountable -- proper drive name and all! I can't write to it from the OS at the moment, but working on that.

  • CIRCUITPY drive mounts, and includes a bout_out.txt and an empty code.py. REPL works and I don't get any safe mode messages in REPL or boot_out.txt, even after pressing reset.
  • Quite a lot of FS artifacts seem to be in "CIRCUITPY:" on first startup...is this okay, or does it indicate some error condition I should be concerned about?
  • I'm having issues writing files to the drive. For example if I try to modify code.py, the OS errors out and says it cannot be written. Seems to break the REPL once I do this. It comes back if I press RST though. Is there something about the workflow I may be missing when the OS tries to write this back to the CIRCUITPY drive?
manic glacierBOT
#

CircuitPython version

Adafruit CircuitPython 9.1.3 on 2024-08-29; Adafruit Feather ESP32-C6 4MB Flash No PSRAM with ESP32C6

Code/REPL

import time
import board
import digitalio

led = digitalio.DigitalInOut(board.LED)
led.direction = digitalio.Direction.OUTPUT

while True:
    led.value = True
    time.sleep(0.5)
    led.value = False
    time.sleep(0.5)

Behavior

When running the blink code above, I try to initiate a connection with htt...

tulip sleet
#

Might the .tmp files be being created by your editor or by some utility program on your host computer?

wanton dirge
tulip sleet
wanton dirge
#

Okay, that did the trick; thanks very much for linking that article. I do get one strange error when trying to run code.py...I'm not trying to import anything and I don't see code.py files usually including any if " __name__ == '__main__' or similar. Is this something that should resolve as I add more modules?

tulip sleet
#

we don't need to use if __name__ == "__main__" generally, because code.py just runs. I'm not sure about your error, I don't see the underscores, and there are a lot of extra spaces.

#
Adafruit CircuitPython 9.1.3 on 2024-08-29; Adafruit Metro ESP32S3 with ESP32S3
>>> 
>>> __name__
'__main__'
>>> 
wanton dirge
#

Hmmm okay, I will try and dig in on it a bit more then on my end. I get the same output for the __name__ variable as above.

tulip sleet
#

could you upload your code file using the + to the left. Also here is how to paste code: #welcome message

wanton dirge
#

As in my code.py? Here...

a = 5
b = 10
c = a + b
#

I tried a print("hello") as well but got the same issue.

tulip sleet
#

I don't know where the name ' ' is not defined is coming from

wanton dirge
#

No worries, I will try and inspect it a little more. Thanks for the help in any case!

glass light
#

MOVED TO HELP-WITH-CIRCUITPYTHON: Is there anywhere I can look to find information on how to connect BMP390 sensor with circuitpython to adafruit io? Thanks!

slender iron
#

nice work @wanton dirge !

wanton dirge
#

thanks @slender iron!

slender iron
#

@tulip sleet you around?

tulip sleet
#

i have a mtg in 45 mins

slender iron
#

the rp2350 issue looks like clock startup delay issue again

#

just wondering if you have any context on the 64 setting

#

it makes no sense to me that it uses the xosc to count the delay

tulip sleet
#

did you already set the MULTIPLIER
I tried several multipliers and 64 seemed safe. 32 was too low

#

i'll look at pico-sdk...

slender iron
#

I accidentally broke the setting mechanic

#

lemme make a PR

tulip sleet
#

i think a q is what's different about our component choices? do the other RP2350 boards use the MULTIPLIER?

manic glacierBOT
tulip sleet
#

I made a minimal change to their logic and delay computation to be able to lengthen it by a lot. That was how I did my initial PR to pico-sdk

slender iron
#

the code now relies on the xosc peripheral to time the delay

#

based on the xosc input!

tulip sleet
#

all I did was include the multiplier in here: #define STARTUP_DELAY ((((XOSC_HZ / KHZ) + 128) / 256) * PICO_XOSC_STARTUP_DELAY_MULTIPLIER)

slender iron
#

my change set the multiplier back to 1 for everything

#

I see it wait 57 ms or so now

tulip sleet
#

that sounds about right. yes, it does count cycles. The original idea was to let the amplitude go up. What I saw was that it was oscillating at a higher frequency than the 12MHz, or was jittering. So I made it count a lot more cycles.

#

The XOSC is not immediately usable because it takes time for the
oscillations to build to sufficient amplitude.

slender iron
#

yup, that's what I'm seeing too. it is counting too fast during start up

tulip sleet
#

I saw that on the Saleae and/or an oscilloscope

#

we are not using the specified crystal

#

most other people are

wanton dirge
#

All good now though. Thanks again for the help folks!

tulip sleet
#

@slender iron I will shoot for another alpha release tomorrow after I fix the board overflow in #9598 and maybe see about #9583. I'm just starting to work on getting the V1.23 merge to compile, but no big stumbling blocks. There are some calls I have to change pervasively due to signature changes or newly available obj creation routines.

#

after the merge we can move to a beta.0, I guess

slender iron
#

Sounds good!

manic glacierBOT
manic glacierBOT