#circuitpython-dev

1 messages ยท Page 64 of 1

tulip sleet
#

ok, three answers at once ๐Ÿ™‚

prime flower
#

Perfect that's exactly where to look. Thank you

lone axle
#

it's making the build tool look for fake_bme280.py instead of fake_bme280/

prime flower
#

actually thanks all ๐Ÿ™‚

midnight ember
#

is there a better example that doesn't assume we're working in blinka?

#
# imports
import math
import time
from micropython import const

from adafruit_bus_device.i2c_device import I2CDevice

import busio

try:
    from typing import TYPE_CHECKING, List, Tuple, Optional, Iterable
    from PIL import Image

    if TYPE_CHECKING:
        from circuitpython_typing import ReadableBuffer, WriteableBuffer
except ImportError as e:
    pass
prime flower
#

very helpful

midnight ember
#

I'm hesitant to remove TYPE_CHECKING because I don't know if that's needed by Blinka. I'd rather not hack a script designed for Blinka to pieces and break their compatibility for microcontrollers sake.

spare jacinth
lone axle
#

I don't think the TYPE_CHECKING if statement is needed for blinka

spare jacinth
prime flower
#

I'm not sure that's required for Blinka, I've been pretty deep in the blinka codebase this past week and haven't seen it utilized.

midnight ember
#

then why is it there? actually i'm probably the one that put it there to begin with by unknowingly copying it from a script designed for blinka.

spare jacinth
#

i guess it is useful for scenarios where file.pyi with type annotations exist, but there is not an equivalent file.py or file/__init__.py that the runtime could use

#

and there are probably some other cases where it is useful (?) but im not much of a type-checking guy, i just write my type hints and hear PyLint about obvious issues lmao

midnight ember
#

i removed it and it passed my local pylint.

tulip sleet
#

it's there so we can run mypy and do type checking

spare jacinth
#

(please ping if you do, i will be deep into VSCode for a while :P)

lone axle
midnight ember
#

Nope, still failed NameError: name 'WriteableBuffer' is not defined

spare jacinth
midnight ember
#

trying to add typing to the library, so both?

spare jacinth
#

i guess a possible issue is that, since you have a huge try/except for everything, maybe some other import is failing (eg micro-controller specific stuff, that is not available on the computer), and is preventing the circuitpython_typing import to get evaluated

#

looking at the code it seems like Image is required for the code to work, so i would def. not have that import on a try/except block

#

and you should probably have 2 different try/except for the typing and circuitpython_typing imports, and maybe a print("Could import ...) comes handy on the except branches

midnight ember
#

It passes on my local pylint

#
C:\Users\Devon\Documents\GitHub\Adafruit_CircuitPython_IS31FL3731\adafruit_is31fl3731>black __init__.py
reformatted __init__.py

All done! โœจ ๐Ÿฐ โœจ
1 file reformatted.

C:\Users\Devon\Documents\GitHub\Adafruit_CircuitPython_IS31FL3731\adafruit_is31fl3731>pylint __init__.py

-------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 2.41/10, +7.59)
#

but fails in adafruit actions pylint

#

I keep submitting it because on my end it says everything is good. I am trying different changes and syntax, going to be a hundred commits before I get it right.

tulip sleet
#

@midnight ember did you try to use pre-commit for all the changes you were testing

#

If it's working locally but not on CI, then we need to fix the inconsistency.

#

i mean pre-commit, not using pylint manually

midnight ember
#

i get a million CRLF errors

tulip sleet
#

then that is a git misconfig

spare jacinth
midnight ember
#
C:\Users\Devon\Documents\GitHub\Adafruit_CircuitPython_IS31FL3731\adafruit_is31fl3731>pre-commit run --files __init__.py
black....................................................................Passed
reuse....................................................................Passed
check yaml...........................................(no files to check)Skipped
fix end of files.........................................................Passed
trim trailing whitespace.................................................Passed
pylint (library code)....................................................Passed
pylint (example code)................................(no files to check)Skipped
pylint (test code)...................................(no files to check)Skipped
tulip sleet
#

do pre-commit run --all at first, and then just run it without the --files arg and it will test the files that have changed

onyx hinge
#
    import typing
    import this_import_fails
    import typing.Union
except ImportError:
    pass

def f(x: Union[list, str]) -> int:
    return len(x)
```this also gets a pylint error about `Union` being undefined, because the ImportError fires for `import this_import_fails` and the third import never occurs. This may be happening for the from PIL import line.
#

pre-commit run --files __init__.py didn't do what you wanted, because pre-commit files lists are relative to the top of the repository, not the current directory.

#

so the problem could be that in the pre-commit pylint environment, PIL or circuitpython_typing, either one, is not actually available to import.

#

but I am really entering the realm of speculation at this point

spare jacinth
midnight ember
#

This is why I don't like pre-commit

spare jacinth
#

WSL is your friend hehe (so is Git For Windows' setting about LF/CRLF)

tulip sleet
midnight ember
#

the one file i'm working on i've converted to LF. it's only when running all files i get that

onyx hinge
#

We strongly STRONGLY recommend changing your git configuration so that all files are checked out with pure LF line endings.

#

many of our tools only work when your environment is configured in this way

midnight ember
#

ohh i didn't do that for this library. i did that for adafruit_requests.

onyx hinge
#

do you need help finding documentation on how to do that?

tulip sleet
#

really, yes, using native Windows as a dev environment causes problems. If you can use WSL or a VM or a Linux machine, you will have an easier time.

#

It should be a global git setting

spare jacinth
tulip sleet
#

but pylint should be aware then that CRLF is OK

onyx hinge
#

@spare jacinth except it DOES strongly matter, because tools like pylint check line endings in the working file

tulip sleet
#

if the file is mixed, that's a problem

midnight ember
#

๐Ÿ˜… i like point and click environment. yes i've done that for my requests repo should be able to manage for this one

#

peer pressure, mom i'm being peer pressured into using Linux.

spare jacinth
tulip sleet
#

does our .pylintrc have expected-line-ending-format=LF??

onyx hinge
#

@tulip sleet yes that's what gets cookie-cut: expected-line-ending-format=LF

tulip sleet
#

ok, then people should NOT set core.autocrlf = true in their git config

midnight ember
#

it's in the .pylintrc in my repo

#
# Expected format of line ending, e.g. empty (any line ending), LF or CRLF.
# expected-line-ending-format=
expected-line-ending-format=LF
tulip sleet
#

it explains the options. It does not suggest what to do with our .pylintrc

#

@midnight ember what editor are you using?

#

have you installed both Git for Windows and GitHub DesktoP/

#

I will see what the default option settings are

midnight ember
#

Mu and Notepad++

#

I use the device with Mu and then transfer working code to github directories via copy/paste with Notepad++. I can see the line endings in Notepad++ so that I know they're LF.

#

yeah gotta be Github Desktop doing it when I clone a repo. I swear I thought I fixed that using a global config. ๐Ÿ˜ฆ

tulip sleet
#

what is in C:\Users\YOUR_USER_NAME\.gitconfig

#

as opposed to "system"

lone axle
#

I seem to be getting this error consistently when I try to run make fetch-all-submodules in a fresh clone of the main repo. Is there some change that I need to make on my end somewhere to get it to be able to complete the fetch?

โฏ make fetch-all-submodules 
python3 tools/ci_fetch_deps.py all
::group::Sync submodule URLs
git submodule sync --quiet (in /home/timc/repos/circuitpython/circuitpython_copy/circuitpython)
::endgroup::
Duration: 0.6285505659998307
Target: all
Submodules: . frozen
::group::Init submodules (using depth)
git submodule update --init --depth 1 . frozen (in /home/timc/repos/circuitpython/circuitpython_copy/circuitpython)
remote: Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
fatal: transport 'file' not allowed
fatal: Fetched in submodule path 'extmod/ulab', but it did not contain eacb0c9af47f85f5d4864b721c3b28661364e8e3. Direct fetching of that commit failed.
fatal: 
::endgroup::
Duration: 0.47614098000121885
Traceback (most recent call last):
  File "/home/timc/repos/circuitpython/circuitpython_copy/circuitpython/tools/ci_fetch_deps.py", line 237, in <module>
    main(target)
  File "/home/timc/repos/circuitpython/circuitpython_copy/circuitpython/tools/ci_fetch_deps.py", line 219, in main
    fetch(submodules)
  File "/home/timc/repos/circuitpython/circuitpython_copy/circuitpython/tools/ci_fetch_deps.py", line 133, in fetch
    run(
  File "/home/timc/repos/circuitpython/circuitpython_copy/circuitpython/tools/ci_fetch_deps.py", line 109, in run
    subprocess.run(shlex.split(command), stderr=subprocess.STDOUT, check=True, cwd=cwd)
  File "/usr/lib/python3.10/subprocess.py", line 526, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['git', 'submodule', 'update', '--init', '--depth', '1', '.', 'frozen']' returned non-zero exit status 128.
make: *** [Makefile:341: fetch-all-submodules] Error 1
spare jacinth
#

i must say, i have no idea how submodules work in general, even less knowledge on how CircuitPy handles them

tulip sleet
#

@midnight ember when installing Git for Windows (not GitHub Desktop):

#

:arm-twist: ๐Ÿ™‚

midnight ember
#

that's what i "thought" fixed it last time but apparently not. the library i'm working with is a recent checkout after i configured that too.

tulip sleet
#

hmm, so somehow the LF input file got converted to CRLF's. If Mu didn't do that, not sure what did. I think Notepad++ has a conversion function

midnight ember
#

yes i've been using notepad++ conversion but if i do it to every file i'm afraid it's going to commit every file.

tulip sleet
#

git status will tell you if it thinks a file has been changed

#

and it will be obvious in the PR

midnight ember
#

actually when i only change the line endings git says there's no change. so might be able to get away with it. that's a lot of manual work though, depending on how many files are in a library.

tulip sleet
#

In the Git for Windows shell there is a command dos2unix which will convert many files at once

#

assuming you install the msys2 shell

midnight ember
#

after manually converting every library file and example file it works as intended

#
C:\Users\Devon\Documents\GitHub\Adafruit_CircuitPython_IS31FL3731\adafruit_is31fl3731>pre-commit run --all
black....................................................................Passed
reuse....................................................................Passed
check yaml...............................................................Passed
fix end of files.........................................................Passed
trim trailing whitespace.................................................Passed
pylint (library code)....................................................Passed
pylint (example code)....................................................Passed
pylint (test code)...................................(no files to check)Skipped
```  yes i was just thinking i need to find a way to automate this
tulip sleet
#

In linux you can assume there exists some command-line command to do something like this, and then you find out what it is

#

because you are not the first person with this (or some other) problem and someone wrote a command for it

midnight ember
#

i wonder if notepad++ can be integrated with a batch script to do it.

tulip sleet
#

dos2unix will work! Do you have a git shell icon?

midnight ember
#

judging from the outcry of CRLF issues filed with Github Desktop and them ignoring it year after year yeah.

#

i don't know ๐Ÿ˜…

#

i don't think so, only thing in apps is github desktop.

tulip sleet
midnight ember
#

i thought running 2 instances is a bad idea? github desktop and git?

slender iron
#

It is implied by CIRCUITPY_USB in mpconfigport.mk. You'll want to set CIRCUITPY_CONSOLE_UART_TX and CIRCUITPY_CONSOLE_UART_RX in mpconfigboard.h to connect serial to the CP input.

#

A debugger link a jlink or stlink can be used to see what the CPU is running. You can also add code to turn on an LED from CP to see if it starts up.

fringe yarrow
slender iron
#

CP will start up without spi slash usually. The drive just won't work. Is the CP code stored on the flash too?

fringe yarrow
#

Seems like if you don't enable SPI Flash with STM devices it won't even compile.

tulip sleet
fringe yarrow
#

i mistakenly assumed that setting spi_flash_filesystem to 0 would just default to internal flash

slender iron
#

a debugger will really help you at this point

fringe yarrow
#

Yeah, I agree.. there's not realyl anywhere to PUT it unless I want to tack it to the smd pins on the mcu..

#

its a silly project anyway.. i'll probably be done with it if i get no results before lunch ๐Ÿ˜„

#

I've added some blink code to the board.c and it's not running it.. I have flashed basic sketches from the arduino ide and gotten expected results, so I know it works like a normal dev board at least in some instances.

midnight ember
#

Ive been up all night working on typing 2 files. My brain hurts. Will resume this tonight.

proven relic
#

Don't know if this needed reporting, but I was running res = network.fetch("http://worldtimeapi.org/api/timezone/"+tz) in a loop 6 iterations long. This rarely (one in such loops or so) caused MemoryError: memory allocation failed, allocating 472 bytes. gc.collect() before each iteration solved the problem.
Before gc.collect(). The number after the "Retrieving data..." is gc.mem_free()

Retrieving data...4768
Retrieving data...2272
Retrieving data...1360
Retrieving data...10624
Retrieving data...1008
Retrieving data...Traceback (most recent call last):
  File "code.py", line 246, in <module>
MemoryError: memory allocation failed, allocating 472 bytes

After gc.collect() before network.fetch:

Retrieving data...12512
Retrieving data...12512
Retrieving data...12160
Retrieving data...11968
Retrieving data...11888

CircuitPython 8.2.10 on 2024-02-14; Adafruit Matrix Portal M4 with samd51j19

Code at https://github.com/iebgener/matrixworldclock

tulip sleet
proven relic
#

Sorry, should be public now

manic glacierBOT
#

Requesting more descriptive error for TLS buffer limit reached (if possible).

It isn't very easy to do because the underlying ESP_ERR_NO_MEM is generated by the IDF. We don't know how big the allocation was or what it was for because we didn't attempt it ourselves. That's why it is espidf.MemoryError vs the built in MemoryError which usually includes the size that failed to allocate.

#

In ESP_IDF, CONFIG_FREERTOS_HZ is the tick rate at which FreeRTOS does preemptive context switching. Currently we have CONFIG_FREERTOS_HZ = 100 (10 msecs), which is the default. However, it's very often set to 1000 (1 msec):

  • Many examples in ESP-IDF use 1000.
  • MicroPython's bstack sdkconfig uses 1000.
  • ESP-IDF Arduino uses 1000, to allow delay() to be more accurate for small values.
  • People who want faster HID need to change this to achieve faster output. This is also rel...
manic glacierBOT
#

We could make it super-simple and simply call wifi.radio.connect(), no ifs or whiles even needed. .connect() is virtually a NOP if already connected, there is very little overhead to the internal check (~1ms or less). Though it is useful for users to soon learn how to detect if the connection is lost and can't be made, and how to recover.

This is my preference. I don't want to require connection manager for simple examples. Instead, maybe the examples need to set the timeout expl...

manic glacierBOT
#

Running a netstat on the server - seeing only TCP for both ports 8883 and 1883

ntynen-pi@mosquitopi:~ $ netstat -ntuap
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN -
tcp 0...

#

This is more idea than a reference implementation but maybe if waveforms had some indication of whether they are normally used as repeating waveforms could provide a hint on how to turn them into one shot waveforms?

https://gist.github.com/kevinjwalters/ff004b1b1acab9f70b9d237765acb3b3

The output from this set is shown below

https://gist.github.com/kevinjwalters/f0f7028c4b88dab56cf218ccbe0382b6

![pythonw_4GHWiI9C3v](https://github.com/adafruit/circuitpython/assets/6851309/884dd9ff...

manic glacierBOT
manic glacierBOT
#

To remove the browser from the equation:
curl (macOS 14.4.1)...

Running web workflow on:
Adafruit CircuitPython 9.1.0-beta.0 on 2024-03-28; Raspberry Pi Pico W with rp2040

% curl -iL --compressed "http://192.168.6.198"
returns immediately:

HTTP/1.1 200 OK
Content-Encoding: gzip
Content-Length: 644
Content-Type: text/html
# etc...

% curl -iL --compressed "http://cpy-redact.local"
returns after about 5 seconds:

HTTP/1.1 200 OK
Content-Encoding: gzip
...
slender iron
#

multitasking is so complicated

onyx hinge
#

seems like maybe safari doesn't support mdns names, but who knows why. I found various references to this, like this unanswered stackexchange .. https://apple.stackexchange.com/questions/396073/why-cant-safari-connect-to-server-local-when-firefox-and-chrome-can-is-mdns and this unhelpful document https://support.apple.com/en-us/101903

slender iron
crimson ferry
#

and it works with espressif

#

timeouts and times-to-load vary between curl and safari, but results essentially similar

manic glacierBOT
manic glacierBOT
#

You have to do the enabling/disabling in boot.py, which runs only after a hard reset, and before USB is set up. You cannot use it in code.py. So there is no state to check, since a hard reset resets everything.

You can remember states in, say microcontroller.nvm, or in the file system, if you want to remember the state past a hard-reset or power-cycle.

manic glacierBOT
#

OK, this is a hardware issue, specific to the ESP32. The ESP32 has two ADC's, ADC1 and ADC2. Only ADC2 is connectable to pins. But it is also used when WiFi is in use. So really, you can only use ADC2 when WiFi is off.

Quoting from https://www.espressif.com/sites/default/files/documentation/esp32_technical_reference_manual_en.pdf, section 29.3.1

... If Wi-Fi module is using the SAR ADC2, users can not measure the analog signal from the pins using SAR ADC2. After SAR ADC2 is released by ...

manic glacierBOT
#

Thanks for the update. One more place to test if chip_select pin is set or not:

void common_hal_fourwire_fourwire_deinit(fourwire_fourwire_obj_t *self) {
    if (self->bus == &self->inline_bus) {
        common_hal_busio_spi_deinit(self->bus);
    }

    common_hal_reset_pin(self->command.pin);
    common_hal_reset_pin(self->chip_select.pin);     //// *************
    common_hal_reset_pin(self->reset.pin);
}
lone axle
#

When was the most recent mpy format change? circup currently reports this:

The following modules are out of date or probably need an update.
Major Updates may include breaking changes. Review before updating.
MPY Format changes from Circuitpython 6 to 7 require an update.

I'm in there doing some refactoring, I could change the versions listed here to be more relevant. Was 8 to 9 the last one that required an update?

manic glacierBOT
#

CircuitPython version

* Tested on 9.0.2 and 8.2.0 (Bootloader 3.15.0)
* Tested on two different ItsyBitsy M4 boards, two different SD cards (formatted with official SD formatting tool), and two different SD card readers, on breadboard, and on a PCB.

Code/REPL

# this is code.py

import digitalio
import board
import busio
import sdcardio
import storage
import os
import time

ledPin: digitalio.DigitalInOut = digitalio.DigitalInOut(board.D13)
ledPin...
manic glacierBOT
#

I just found a way to fix the problem without flush()-ing:

I needed to use the VFS object's open method: vfs.open("FILE1.TXT") instead of the global open("/sd/FILE1.TXT"). Then it seems to work fine, no crash.

This doc page says:

You can only have either your computer edit the CIRCUITPY drive files, or CircuitPython. You cannot have both write to the drive at the same time. (Bad Things Will Happen ...

tiny peak
midnight ember
#

I also came up with a powershell script that replaces \r\n with \n in every .py file in a directory (and child directories). All you have to do is name the file AutoLF.ps1 ```

Option 1: Run in the same directory as this file (drag and drop)

$folderPath = $PSScriptRoot

Option 2: Set the folder path manually

$username = $env:USERNAME
$folderPath = "C:\Users$username\Downloads\AutoLF_Test"

Get a list of .py files in the folder and its subdirectories

$pyFiles = Get-ChildItem -Path $folderPath -Filter *.py -Recurse

Write-Host "Converts line endings from CRLF to LF so pre-commit will not throw thousands of errors"
Write-Host "-------------------------------------------------------------------------------------"

Loop through each .py file

foreach ($file in $pyFiles) {
# Read the content of the file
$content = Get-Content -Path $file.FullName -Raw

# Replace CRLF line endings with LF
$content = $content -replace "`r`n", "`n"

# Write the modified content back to the file
Set-Content -Path $file.FullName -Value $content

Write-Host "Line endings converted to LF for $($file.FullName)"

}

Keep the PowerShell window open (remove the entire section below to automatically close the window instead)

Write-Host "Press any key to exit..."
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")

slender iron
#

Will look more tomorrow

midnight ember
#

The bad thing about this method is it will replace all instances of \r\n which I think the RFM library and others have hard coded into their examples for newlines in a send/receive bytearray. :/

spare jacinth
#

In memory they would end up being

  • ord("\\"), ord("r") is something like 33 45 (2 bytes)
  • ord("\r") would be a single one, lets say 9
#

Or course i made up the numbers instead of looking at the ASCII table ๐Ÿ‘

manic glacierBOT
#

Hi @dhalbert

Thanks for the update. One more place to test if chip_select pin is set or not:

Since the command pin can also be None and is not checked here, my understanding is that the common_hal_reset_pin will check if the pin is None:

void common_hal_reset_pin(const mcu_pin_obj_t *pin) {
    if (pin == NULL) {
        return;
    }
    reset_pin_number(pin->port, pin->number);
}

But maybe there is an oversight on the command pin as well.

manic glacierBOT
#

CircuitPython version

Adafruit CircuitPython 9.0.2 on 2024-03-28; Raspberry Pi Pico W with rp2040

Code/REPL

import os
import time
import ipaddress
import wifi
import socketpool
import board
import microcontroller
from digitalio import DigitalInOut, Direction
from adafruit_httpserver import Server, Request, Response, POST
import adafruit_requests
import sys

ctrlc = 0

connection = None

ssid = os.getenv('CIRCUITPY_WIFI_SSID')
passwd = os.ge...
manic glacierBOT
#

Ah ok, good to know.

I'd like to hide the device by default, but press a button to show it. If that requires a reboot that's fine, but I'd need to store some state that I can read in boot.py to not run storage.disable_usb_drive().

I guess I'll read up on the documentation some more, closing this issue.

If you do however have an example of storing state like this I'd appreciate it.

spare jacinth
#

I didnt mean you should use ord, but that you didnt need to change anything

#

Code looking for "\r\n" wont get reformatted by LF vs CRLF utilities

midnight ember
#

One can hope. Yeah on a mobile device it's probably not going to show up as well. It's a powershell script that installs pre-commit to a local github repo (will not install if already installed), then formats every .py file in the directory and child directories (such as \examples), then runs black on every file, the runs pre-commit --all-files on the main directory. This is a workaround for Github Desktop converting all files to CRLF on checkout. Run once on a directory and I'm all set to go.

#

It prevents this situation in Windows where Github Desktop checks out every file with CRLF line endings which fails horribly with pre-commit. I won't have to deal with this situation again.

spare jacinth
#

Yeah, but my understanding was that you were worried about code using "\r\n" to check for new lines in UART messages or the like

#

And i explained why that wouldnt get changed

midnight ember
#

yes, i only thought about that after I'd run it a couple time and then remembered that it might be hardcoded into some scripts.

#

i misunderstood you. :/ welp it's using ASCII.GetBytes now.

spare jacinth
#

Re read my prev message and try to understand it, i guess

midnight ember
#

it would not work with the pure ordinal values, powershell did not like that format. ended up having to go with different formatting.

#

i tried a lot of different variations and while \r\n was definitely easiest the way you phrased it I thought it might not be checking for actual CRLF. It's my understanding that CRLF is just \r\n anyway?

spare jacinth
#

My whole point is that a CRLF in a file (two invisible chars) is different than a string with \r\n (4 visible chars)

#

And that, if you had code like
while "\r\n" not in read_data()
It wouldnt get reformatted

midnight ember
#

I'm not even sure how it would know the difference though. I'm not seeing any logic that is checking for the last characters in a line. It seems just to check for any instance of \r\n.

#

Yeah I honestly don't know how it can see that they're the EOL characters but it does work, as far as I can tell. I haven't done extensive testing on it yet.

spare jacinth
#

The actual CRLF, in disk, would be two bytes (what i showed with ord, you can run that in python to see the actual values), so something like 8, 9

#

The string looking for them would be 4 bytes (slash, r, slash, n), so something like 20, 45, 20, 10

#

The utility looking for CRLF (8,9) would not change the (20, 45, 20, 10) strings

#

Again, i made the numbers up

midnight ember
#

I tried that formatting and powershell didn't like it. I can try again later. Will look into it.

#

yeah i get what you're saying.

spare jacinth
#

No idea what you mean with format/powershell

#

But i hope you have a better understanding now ๐Ÿค“

midnight ember
#

I appreciate your advice!

#

The way the script looks for .py files recursively is done through windows itself using powershell, not python. so the way powershell interprets line endings might be different.

#

the script kind of weaves in and out of powershell and python scripting for different things.

spare jacinth
lone axle
manic glacierBOT
#

The usual technique is to check the state of a button during boot.py. ISo you can hold down the button while pressing reset to avoid the disable code. Here's a discussion: https://learn.adafruit.com/customizing-usb-devices-in-circuitpython/circuitpy-midi-serial#dont-lock-yourself-out-3096636.

Exactly the guide I was trying to locate and the current recommended way to do that.
With the added difficulties that on some hardware, we only have one user button that is also the boot button fro...

spare jacinth
# lone axle It's only the absolute basics at this point, but it does seem to successfully ex...

looks cool, some feedback if you dont mind:

  • could make expectfile optional and default it to f"{testfile}.exp"
  • dont mix the use of different logging utils (print and click.echo), always use the same so you dont get the chance to output those into different streams and cause yourself some confusion
    • i would probably use logging to emit messages of different levels and filter them depending on how bad something has gone (...or some other utility that also provides such capability)
#

and you probably thought about that too, but a yaml/json/whatever listing board_name: [tests_to_run_on_it] + parsing thru it sounds like a good idea moving forward ๐Ÿ˜„

lone axle
#

PR's welcome ๐Ÿ™‚ Defaulting sounds nice just a QoL feature I didn't make at first and didn't get to. Print vs. echo there are still some strewn about inconsistently because I was having a hard time figuring out why the test was failing when the output looked identical visible, it turns out echo does some additional processing and print allowed me to see "real" values that helped me fix it, I just didn't go back and change everything yet.

logging I'm not opposed to, I just don't tend to gravitate towards it by default when I write.

spare jacinth
#

given this is a test suite, it probably makes sense to print everything unconditionally, but it could become difficult parsing through the log to see exactly which test failed and/or where

lone axle
#

I definitely think some kind of summarized output would be necessary if it evolves to test multiple things.

spare jacinth
#

or... could make the scriot stop as soon as a test fails, but i'd rather run everything and have full info

lone axle
#

I've already noticed that printing the actual and expected values makes it scroll kind of far to where you may not still see the pass fail indicator line without scrolling back. I'll probably still manipulate the way it outputs quite a bit this is definitely just first draft that I got working last night and this morning.

spare jacinth
#

f"{board}_{test}.err" sounds like a good idea for failing tests

manic glacierBOT
#

I prefer not to have the drive connected at all times, instead only when I need it.

In boot.py I have this:

import storage
import microcontroller

if microcontroller.nvm[0] == 1:
  storage.enable_usb_drive() # probably redundant
else:
  storage.disable_usb_drive()

Then in code.py I have something that will trigger this function:

def toggle_mount():
  import microcontroller
  microcontroller.nvm[0] = int(not microcontroller.nvm[0])
  microcontr...
spare jacinth
lone axle
#

I won't be touching anything on it until at least later tonight 8+ hrs likely.

manic glacierBOT
#

My exact usecase is that I use CircuitPython as the firmware for a keyboard, and I have a key combination to trigger that function.

You can also check for a key being held down during reset rather than toggling. You can't use keypad to do that, since the key will not transition during boot.py unless you added a delay to monitor it. If it's a key matrix it's a bit tricky: you'll need to make the row be an output or and column be in input, or vice versa, depending on the diodes and how i...

#

I don't know/use microcontroller.nvm but I know and use alarm.sleep_memory[0] as used in this project: https://learn.adafruit.com/adafruit-magtag-project-selector

So if the guide could be updated with your knowledge/solution, that would be really helpful.

sleep memory does not survive a power-cycle. microntroller.nvm stores bytes in flash. t's pretty easy to use: https://docs.circuitpython.org/en/latest/shared-bindings/nvm/index.html

manic glacierBOT
midnight ember
lone axle
# midnight ember run_test looks pretty wild. I don't recognize any of that. Is that Python? Ahh ...

yes everything except click is "vanilla" python i.e. modules built-in to CPython. click is a command line interface helper library that does a bunch of nifty helpful stuff if you're making a CLI.

and yep, discotool was the quickest / easiest way I could think of to find the attached devices file location and serial port. Possibly it could be integrated at the python level instead of using subproccess to run it as a command but this was definitely quick and easy ๐Ÿ˜„

midnight ember
#

"easy"

#

easy is relative. what takes you an hour would probably take me months.

#

Submitted a new API PR. Good excuse to try out my new formatting tool in a real world use. It worked great! Too great. Pre-commit ran on the entire repo which I wasn't expecting. It didn't do just child directories it went recursively up parent directories too. That would have been really really bad if it was a larger library. Still threw thousands of CRLF errors for files I didn't want it to check. :/

#

I guess that's how pre-commit on an entire repo is supposed to work? Even though I ran it in /examples/wifi/expanded.

#

Might be because I'm used to doing pre-commit run --files filename instead of pre-commit run --all-files

lone axle
#

That is true, perhaps 'lazy' would have been a better word than easy. I just meant I didn't want to write the code that figures out the differences between Windows, Linux, and Mac to find the CIRCUITPY drive location and serial port. Discotool has already done that hard work so I opted for the lazy approach of just use it from there.

"Easy" is interesting and relative like that though, which I find fascinating. I've been programming as a full time job for a decade (๐Ÿ˜ฌ) and I've definitely spent many months in that time grinding away at stuff. Even with that there are plenty of folks both in and outside of the community that make plenty of other things look easy that would no doubt take me months or longer. There are so many things out there and so little time to learn about them.

midnight ember
#

You are anything but lazy. ๐Ÿ˜‰

lone axle
#

I'm not sure about pre-commit on specific files, I've always done pre-commit run -a or --all-files I do think it's primarily intended to operate on the whole repo, but there may be more percise controls available

midnight ember
#

I started running it only on the file I was working with in an effort to surpress a lot of the EOL errors. Probably where that stemmed from. Now I can focus on maybe doing everything the right way. Github Desktop does kind of throw a unique wrench into the workflow compared to any other GIT tool out there. Just gotta roll with the punches.

#

I did install Git for Windows (GIT SCM) so maybe I can start to transition to a different GIT tool and slowly learn Git CLI stuff.

lone sandalBOT
tulip sleet
lone axle
#

I tried like that with pre-commit install before but something about the way it integrated into my commit workflow bothered me and I ended up just building the habbit to run it manually. I should give it another try though, I don't even recall the specifics about it.

tulip sleet
lone axle
#

It's not directly related, but I wish there was a way we could make reuse enforced on files that are actually checked in to the repo. I find myself with other files in my local copy that aren't checked in but cause pre-commit to fail from reuse. It then succeeds in the github actions since those files aren't checked in.

manic glacierBOT
#

This looks like a real bug that we should fix.

My gut tells me that it has something to do with attempting to "finalize" all objects when the VM shuts down, which works on objects in an unpredictable order, so for instance it could be the case that the mounted filesystem object has been finalized and then the file object is finalized, leading to an error because it's no longer valid to make calls related to the filesystem object...

The vfs.open workaround is interesting, I wonder why it...

onyx hinge
lone axle
#

Ahh, I forget about that global gitignore. Maybe I can commit to using a naming prefix convention for my non-added files that is ignored by that global file.

spare jacinth
tulip sleet
manic glacierBOT
lone axle
#

Is there something extra needed to fetch submodules now? I'm testing in a fresh clone fully updated and this error prevents make fetch-all-submodules from completing successfully:

git submodule update --init --depth 1 . frozen (in /home/timc/repos/circuitpython/circuitpython_copy/circuitpython)
remote: Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
fatal: transport 'file' not allowed
fatal: Fetched in submodule path 'extmod/ulab', but it did not contain eacb0c9af47f85f5d4864b721c3b28661364e8e3. Direct fetching of that commit failed.
fatal: 
::endgroup::
Duration: 0.34272488499846077

It seems like something to do with a specific commit from ulab failing to be fetched.

tulip sleet
#

I would recommend that you add the git PPA if you are using ubuntu, as that will bring in more modern versions of git, including "partial clones", which are easier to deal with.

lone axle
#

I've had it consistently since yesterday. I've tried pulling to make sure everything is up to date and remove-all-submodules + re fetch again a few times as well and always same result so far.

tulip sleet
#

i'll try it locally

lone axle
#

Ah, I do have git version 2.34.1 I'll try adding that ppa and update

lone axle
#

updated to 2.43.2 removed all again and re-fetching now ๐Ÿคž. I wonder if something could have changed with the repose or submodules that could cause this newer version to be a requirement instead of a recomendation. I know I was able to fetch them successfully even fairly recently but all the sudden it started getting stuck there.

#

On this version it got a similar looking error, but this time referencing a different one of the submodules not ulab:

fatal: transport 'file' not allowed
fatal: Fetched in submodule path 'ports/broadcom/firmware', but it did not contain bf96d0eda5952595d717fedb797aeb168483e9fa. Direct fetching of that commit failed.
::endgroup::
Duration: 96.18597572200088
Traceback (most recent call last):
  File "/home/timc/repos/circuitpython/circuitpython_copy/circuitpython/tools/ci_fetch_deps.py", line 237, in <module>
    main(target)
  File "/home/timc/repos/circuitpython/circuitpython_copy/circuitpython/tools/ci_fetch_deps.py", line 219, in main
    fetch(submodules)
  File "/home/timc/repos/circuitpython/circuitpython_copy/circuitpython/tools/ci_fetch_deps.py", line 127, in fetch
    run(
  File "/home/timc/repos/circuitpython/circuitpython_copy/circuitpython/tools/ci_fetch_deps.py", line 109, in run
    subprocess.run(shlex.split(command), stderr=subprocess.STDOUT, check=True, cwd=cwd)
  File "/usr/lib/python3.10/subprocess.py", line 526, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['git', 'submodule', 'update', '--init', '--filter=blob:none', '.', 'frozen']' returned non-zero exit status 128.
make: *** [Makefile:341: fetch-all-submodules] Error 1
#

I'll try a completely fresh clone with this new version of git. I'm still on the one that I cloned yesterday with the old version.

tulip sleet
lone axle
#

completely fresh clone for me fails with another similar error but on another different one of the submodules:

Submodule path 'ports/atmel-samd/peripherals': checked out '82e514b6e0d1a2b09dc73be9973663b6b837a817'
fatal: transport 'file' not allowed
fatal: Fetched in submodule path 'ports/broadcom/firmware', but it did not contain bf96d0eda5952595d717fedb797aeb168483e9fa. Direct fetching of that commit failed.
::endgroup::
Duration: 89.00782027999958

Well thats no good I wonder what is broken inside of my environment ๐Ÿ˜Ÿ

tulip sleet
lone axle
#

https I believe I clone the repo with a command like:

git clone https://github.com/adafruit/circuitpython.git
tulip sleet
#

is there anything unusual in your ~/.gitconfig? Anything about protocol.file.allow?

lone axle
#

I started trying to run the command that subprocess is reporting as failing directly instead of via make. I found that adding a --remote to the command so it's:

git submodule update --init --filter=blob:none --remote . frozen

seems to allow it to at least git farther than before, it's still running now. I found this here: https://stackoverflow.com/a/56621295/507810 but don't fully understand it honestly.

lone axle
#

maybe the gh utility messed it up somehow. I have that installed and use it for PR reviews. Not really with fetching submodules or anything but maybe it's interfering or something.

slender iron
slender iron
#

yup, that's fine

tulip sleet
lone axle
#

after adding the --remote it did make it much farther and now has a different error:

โฏ git submodule update --init --filter=blob:none --remote . frozen
fatal: Unable to find refs/remotes/origin/v4.2.1 revision in submodule path 'ports/silabs/gecko_sdk'
tulip sleet
#

I don't have autocrlf = input, but that seems kinda irrelevant

#

is git-lfs installed?

lone axle
#

I don't think I've ever used silabs port, I'm not sure which hardware that is. If that is truely the only thing I'm missing now though I probably don't need it.

lone axle
tulip sleet
#

go ahead and install it, it doesn't hurt

#

i have the same versions as you

#

how old is your gh?

#

i have 2.46.0

lone axle
#

Got to head out for now though. I'll attempt a build with this one later.

$ gh --version
gh version 2.25.1 (2023-03-21)
https://github.com/cli/cli/releases/tag/v2.25.1

oof looks like I'm behind a decent ways, I'll update that too.

tulip sleet
#

I have a ppa for that too

slender iron
#

we're definitely seeing a slight bug influx as folks move to 9

manic glacierBOT
tulip sleet
midnight ember
slender iron
#

Ya, I think so too. I'm just thinking about my prioritization of work

midnight ember
bright robin
#

So, I've been playing around with the Cardputer keyboard (M5Stack Card Computer).
#help-with-circuitpython message
I was thinking of trying to get the keyboard working in the built in REPL
I'd be perfectly happy to write the code but I'm not sure whether it's practically possible or within the scope of the project (I haven't heard of any similar boards.).
Is this a feature that could be realistically implemented?

manic glacierBOT
#

Thanks for continuing to refine this! It is getting better and better.

You can test the docs locally with make html from the root circuitpython directory. I suspect you are missing ... function bodies that are used in Python stub files as placeholders.

One comment on enabled and friends and I'd like to hear your thoughts about reducing the number of new error messages. They take up firmware space for everyone.

slender iron
#

It uses keypad demux to read the keyboard right?

bright robin
#

Yeah that's it. I built a little table of all the possible keycodes.

slender iron
bright robin
#

Well that raises a lot of questions. How would I go about getting keyboard scanning to happening in the background? How do keystrokes get passed to CircuitPython's internals?

slender iron
#

and then implement them in board.c

bright robin
#

Oh I see what you mean.

slender iron
#

keypad already works in the background. so you basically initialize it in board.c the same way you would from python

bright robin
#

Um, what's the difference between port_serial_early_init and port_serial_init ?

slender iron
#

I think early is before usb starts

bright robin
#

So would I want to initialise it in the early version?

bright robin
#

I'm a little worried if it's too early half the system will be in some kind of non-functional state.

slender iron
#

serial_workflow_start() calls serial_init()

#

ya, I'd wait in case you want to add a configuration knob into boot.py

#

walk time. back in a bit

bright robin
#

No problem. I'll look through these shared bindings.

forest badge
#

Is there possibly a preliminary sketch to look at regarding the INA228 library or learn guide?

slender iron
#

@onyx hinge did you enable the panic handler in IRAM for protomatter?

#

that helped me debug protomatter

onyx hinge
#

@slender iron this is about Arduino so, probably no

#

I found documentation on setting debug level and that's it. I think it's just the IDF debug level but not sure.

slender iron
#

kk

#

I don't know what IDF settings they use for arduino

#

I had issues with the gptimer being when IRAM is set

#

but I suppose you aren't writing to flash anyway

bright robin
#

So if I'm getting this right I can just define board_serial_read in the board code and that will be called automatically?

And am I correct in assuming that all the background work like creating queues will be automatically done if I call common_hal_keypad_demux_demuxkeymatrix_construct and I can just check the keypad queues whenever a read is requested?
https://github.com/adafruit/circuitpython/blob/436f9829f85e19019b7a51a3bfe849fabf1b29a7/shared-bindings/keypad_demux/DemuxKeyMatrix.h#L35C6-L35C54

Or is there something else that needs doing?

tulip sleet
slender iron
#

Make weak versions in the file I linked to and a non-weak version in board.c

#

The board.c one will take precedence

bright robin
#

So you're saying I just need to define a non-weak version with the same name in the relevant board.c file?
So the name should actually be port_serial_read then and not board_serial_read?

slender iron
#

port_ is already used in esp for the internal usb to serial converter

bright robin
#

Yeah, no problem then.
So will the internal usb to serial converter still work if I define board_serial_read ?
Will my code need to handle that somehow?

slender iron
#

ya, you'll need to add it to serial_read (iirc) just like the port version

bright robin
#

Now possible a silly question, but what what the correct way to write the new firmware to the device again?
Would this work for the ESP32S3?
(assume the port is correct)
esptool.py -p /dev/ttyACM0 write_flash 0x1000 build-m5stack_cardputer/firmware.bin

#

Ah, nevermind. Works now I just have the offset wrong.

bright robin
#

Would this new version of 'supervisor/shared/serial.c' be okay? I've basically added board_ versions of all the port_ prototypes and duplicated all the calls to port_ functions (header changes are also made). I haven't actually modified any internals before and I don't want to cause any issues.

orchid basinBOT
manic glacierBOT
#

@jepler Sorry, I think I was wrong about vfs.open working.

It seemed to have fixed the issue, but now I'm trying it again now, and it's freezing the same as the global open. I probably didn't set up the test correctly yesterday.

--

Thanks for the with suggestion. Just to add a bit of context: the file I'm writing is a log file. I'm keeping it perpetually open, and I write() ~30 bytes to it several times per second, and then flush() the file every few seconds. I figured ...

slender iron
slender iron
bright robin
slender iron
#

sounds good. if you have regular usb you can do mp_printf(&mp_plat_print, <format string>, <format arguments>) to print out stuff

bright robin
#

Ah that might help.

slender iron
#

you can also do a DEBUG=1 build and use a usb-to-serial converter on the output

#

that'll give you IDF logging

bright robin
#

Is there any useful info in there?

slender iron
#

only if you are interacting with the IDF or see other ESP_LOG statements you want to see

bright robin
#

So I made this constructor for keypad_demux:

    common_hal_keypad_demux_demuxkeymatrix_construct(
            &keyboard, // self
            3, // num_row_addr_pins
            row_addr_pins, // row_addr_pins
            7, // num_column_pins
            column_pins, // column_pins
            0.01, // interval
            20, // max_events
            1 // debounce_threshold
            );

And later check if with:

common_hal_keypad_eventqueue_get_into(keyboard.events, &event)```
But there's no events at all (returns false), when it works perfectly fine with CircuitPython code:
```python
kbd = keypad_demux.DemuxKeyMatrix(
    row_addr_pins = (board.KB_A_0, board.KB_A_1, board.KB_A_2),
    column_pins = (board.KB_COL_0, board.KB_COL_1, board.KB_COL_2, board.KB_COL_3, board.KB_COL_4, board.KB_COL_5, board.KB_COL_6)

Is there something I need to do to... tell it I want events, beyond just constructing an object?

slender iron
#

either from calling a never_reset function or adding a board reset function that doesn't change the specific pins

#

you can comment out the pin reset in port_reset in supervisor/port.c to see if that's the issue

bright robin
#

I'll give it a go.

#

I'm not sure when the reset happens. Is it after board/port_serial_init?

slender iron
#

it does between every vm run

#

we're moving away from the bulk resets but not done yet

bright robin
#

Doesn't seem to make much difference. I'll keep debugging I suppose.

bright robin
#

Okay, I took another look and it seem that the device stops working as soon as the default program ends. So I'm guessing the supervisor is doing a deinit on it to clean up after running the program? I'm not sure how to prevent that from happening.

bright robin
#

Just having it on the pins doesn't help because the scanner is deregistered.

bright robin
#

Alright, the Cardputer's built in keyboard is now working fine after some modifications to the board and matrix code. Control keys, shift, alt, arrow keys, etc. Nice little portable terminal now.

manic glacierBOT
#
[adafruit/circuitpython] New tag created: 9.0.3
orchid basinBOT
tulip sleet
#

https://blog.adafruit.com/2024/04/04/circuitpython-9-0-3-released/
The only changes to 9.0.3 from 9.0.2 are a fix for AnalogIn on Nordic nRF boards, and the addition of the Waveshare RP2040-GEEK board.

Adafruit Industries - Makers, hackers, artists, designers and engineers!

From the GitHub release page: This is CircuitPython 9.0.3, the latest bugfix release of CircuitPython, and is a new stable release. The only changes to 9.0.3 from 9.0.2 are a fix for AnalogIn on Noโ€ฆ

slender iron
manic glacierBOT
#
  • Fixes #9031.

Change supervisor.Runtime.serial_bytes_available to return the number of available bytes instead of just a True or False. Since 0 is False-y, this works in the common case of if supervisor.runtime.serial_bytes_available:.

I looked in the Learn Guides and I only found one use of .serial_bytes_available, and it's exactly as above.

This was a much larger change than one might think because I did a refactor to reduce a bunch of identical common-hal/supervisor...

#

There are use cases where you'd want to create an external pin object and then enable/disable the clock at runtime. For instance when putting the external chip in low power mode you shouldn't drive the clock to it. My use case actually requires this. This is compounded by the current issue where resources aren't released until garbage collection is called. My opinion is the functionality is required.

#

CircuitPython version

CLUE nRF52840 Express with CircuitPython 9.0.3

Code/REPL

import time
import board
from rainbowio import colorwheel
import neopixel

pixels = neopixel.NeoPixel(board.NEOPIXEL, 10, brightness=0.2, auto_write=False)
rainbow_cycle_demo = 1


def rainbow_cycle(wait):
    for j in range(255):
        for i in range(10):
            rc_index = (i * 256 // 10) + j * 5
            pixels[i] = colorwheel(rc_index & 255)
        pix...
slender iron
#

@tulip sleet trevor found a bug between uf2 0.8.2+ and cp

#

I think it impacts 8.2.x as well

manic glacierBOT
midnight ember
thorny jay
tulip sleet
slender iron
manic glacierBOT
manic glacierBOT
#

One of the many uses of async coroutines is waiting for user input while completing background tasks.
There are examples for buttons, but digitalIO.value wasn't a blocking function anyway so polling it is trivial.

My issue is that I am trying to use the serial console to interact with the device, and input() is most definitely a blocking function.
The implementations I've found seem to be platform-dependent, communicating with a separate UI thread or relying on non-standard libraries. ...

tulip sleet
#

@slender iron I'm choosing what to work on next in the 9.x.x issues list. Are you planning to do the reset/finalizers stuff, or do you want to pass that off? Also this socket timeout issue maybe should be addressed: https://github.com/adafruit/circuitpython/issues/8266

#

I am less confident about all the storage/sd-card issues.

manic glacierBOT
#

Interesting. So if I only have single-byte characters, I can use the count from usb_cdc like so:

async def ainput():
    usb_cdc.console.timeout = 0
    x = ""
    while(True):
        n = usb_cdc.console.in_waiting
        x += sys.stdin.read(n)
        if('\n' in x):
            return x
        await asyncio.sleep(0.1)

But then it breaks if I press a "delete" character. Also interesting is that the input isn't echoed back this way.
It will do for now, thank you!

slender iron
#

I'm not planning on doing reset/finalizers

#

I'm in the max3421 weeds now. it uses spi from an interrupt ๐Ÿ˜•

tulip sleet
#

I'll start on the finalizers, not necessarily first thing. If I have questions I'll of course talk to you.

slender iron
#

the mqtt while web workflow issue seems weird

manic glacierBOT
#

Added support for using the built-in keyboard for serial input to the M5Stack Card Computer board.
Some modifications were made to the serial input code to allow a per-board serial input source rather than just per port.
The scanner deinitialisation code was also modified to allow the never reset functionality on scanners in order prevent the keyboard from being deinitialised after a program finishes.

bright robin
#

Hopefully that covers everything!

#

I might want to do a bit more work later on getting the ^C key working. At the moment it is working in REPL, but it won't actually stop a running program unless it is waiting on user input.

#

Anyone know how the serial port input does this? I'm still figuring it out.

#

On another note it might be good to have an option to run a callback function from the keypad scanner when new events become available.
At the moment I'm just calling my function to process key events from board_serial_read or board_serial_bytes_available when they are called.

bright robin
#

Ah crap... the _serial_bytes_available prototype just changed didn't it?

bright robin
#

Ah, that must of what I was thinking of.

manic glacierBOT
#

Since the command pin can also be None and is not checked here, my understanding is that the common_hal_reset_pin will check if the pin is None:

This depends on self->chip_select being initialized to zero, so self->chip_select.pin will be NULL (zero) at first. I was worried about that at first, but I cannot think of a situation where the pin might be set to a non-NULL value and then later the chip_select type was set to NoneType, so I think it is ok.

tulip sleet
#

maybe you could check for mp_interrupt_char in the routine that queues the keyboard presses for serial input?

bright robin
# tulip sleet maybe you could check for `mp_interrupt_char` in the routine that queues the key...

The problem is I don't get any kind of callback when an event is put in the event queue.

I'm just processing the events to generate keystrokes when the system requests input through board_serial_read.

So it's pointless to look for mp_interrupt_char if the character isn't read until input is requested.

What I was thinking of was to have the keypad scanner call a previously given processing function after it detects changes.
Maybe putting something here:
https://github.com/adafruit/circuitpython/blob/50ad62d205c9f024ee037de48cb7110c47fe6260/shared-module/keypad_demux/DemuxKeyMatrix.c#L151

tulip sleet
#

could be scanned by a background task. I haven't been following this that closely. I have to sign off to sleep. I'm too tired to think hard about this. If you put your code in a repo, we can look later

bright robin
#

I'd probably still want it to have a callback link back to the board file as there would still need to be some kind of keypad specific processing done to generate the keystrokes - what event sequence actually corresponds to mp_interrupt_char depends of the keypad. Sorry to keep you up so late.

manic glacierBOT
#

This pull request should solve the issues described in #4191 by introducing 4 new methods to the usb_midi module that allow to customize the MIDI streaming interface, audio control interface, MIDI IN jack, and MIDI OUT jack names.

As suggested by @dhalbert I took a look at #8989 and basically just copied the code and adapted it to usb_midi. Since I have like zero experience in C programming I would be glad to get some feedback on the code. I feel like there are some unnecessary repetit...

manic glacierBOT
#

Thanks for working on this!

Instead of four different routines, how about a single routine with optional arguments? Here is the signature:

usb_midi.set_names(self, *, streaming_interface_name = None, audio_control_interface_name = None, in_jack_name = None, out_jack_name = None)

They will be MP_ARG_KEY_ONLY, and won't change if the arg is the default None. There are a lot of examples of this kind of thing in constructors, and also in .configureinbusio.SPI.configure(...

tulip sleet
lone axle
#

Should Blinka_Displayio get backwards compatibility for displayio.FourWire added back to it? I think right now we are in a state where displayio.FourWire does work on CircuitPython core (without the warning message as well now). But that does not work on Blinka_Displayio and it looks like fourwire.FourWire must be used there.

tulip sleet
# lone axle Should Blinka_Displayio get backwards compatibility for `displayio.FourWire` add...

We discussed that briefly in the PR: https://github.com/adafruit/Adafruit_Blinka_Displayio/pull/131. If the Learn Guides describe the new API, then I think an abrupt change is OK. I am not sure in general whether the major versions in Blinka should follow the "old - old&new - new" pattern of introducing an incompatible API that we use in CircuitPython core. It is not so hard to backtrack to a previous version with pip. @gilded cradle do you have an opinion?

lone axle
manic glacierBOT
misty garnet
#

I have a W550-EVB-PICO publishing a MQTT message to an rasppi5 broker once every second. It plugs away happily for hours/days at a time. However, if I ssh to the rasppi5, open minicom so I can see the pub messages that are printed to the REPL, and then close minicom or just terminate the ssh session, the PICO stops publishing after a few seconds. If I open up minicom again shortly after, it will resume MQTT publishing. If I wait a bit longer (~minute-ish) it won't resume publishing, and if I interrupt with a Ctrl-C, it shows it stuck here: File "/lib/adafruit_wiznet5k/adafruit_wiznet5k.py", line 532, in socket_available. Is there something about connecting/disconnecting from the serial that interferes with socket operations?

manic glacierBOT
fringe yarrow
#

I promise this is my last Sunton ESP32 device for a while ๐Ÿ˜„

tulip sleet
misty garnet
tulip sleet
manic glacierBOT
#

If there's anything I can do to help just ask!

On Fri, Apr 5, 2024, 09:48 Scott Shawcroft @.***> wrote:

Thanks for the info! CP8 -> CP9 is a pretty big change for networking.
It's probably a tricky problem to run down. I'm working on other stuff at
the moment but appreciate the detailed report.

โ€”
Reply to this email directly, view it on GitHub
https://github.com/adafruit/circuitpython/issues/9123#issuecomment-2040251257,
or unsubscribe
<https://gith...

manic glacierBOT
#

espidf.IDFError is a subclass of OSError, which is a subclass of Exception. raise_esp_error() is a general routine that is used to check ESP-IDF error codes and raise espidf.IDFError with an appropriate message.

There are a number of non-ESP-specific contexts in which this error is raised, such as AnalogIn, neopixel_write, PulseOut, etc. where something like RuntimeError would be more appropriate, because the error is something that doesn't need to be designated as ESP-ID...

gilded cradle
#

@lone axle @tulip sleet, so, I think leaving the Blinka_Displayio lib as is for now is the correct move.

manic glacierBOT
#

I believe GPIO 18 and 19 are used by ESPRESSIF chips for USB D+/D- and CircuitPython doesn't share them very well (you can use them with Arduino code). I believe the Resistive Touch version of this board will have problems using the Touch Screen in CircuitPython. Do you think 17 & 18 would be a better choice for the board's generic I2C bus and pins 19 & 20 would be better named TOUCH_SCL & TOUCH_SDA? I know the touch I2C pins are broken out on P3 but given the USB conflict and that P4 and P5 ...

manic glacierBOT
wraith crow
manic glacierBOT
bright robin
manic glacierBOT
#

CircuitPython version

Adafruit CircuitPython 9.0.0-rc.0 on 2024-03-08; W5500-EVB-Pico with rp2040

Code/REPL

import asyncio
import collections
import supervisor
import mqtt
import ntp as my_ntp
from sensor import Sensor

supervisor.runtime.autoreload = False


class Stop:
    def __init__(self):
        self.value = False


async def proc_cmds(cmd_queue, stop):
    while not stop.value:
        while len(cmd_queue):
            cmd = cmd_qu...
bright robin
manic glacierBOT
#

I realize there has been a lot of discussion on this, but I wanted to throw in my two cents anyway.

I would be happy enough with programming the second core in C, or even having a fixed set of computation-intensive tasks (for example, FFTs, tensors, cryptographic functions, image processing).
The trouble with running circuitpython on both cores is that it only doubles the computation power at best. I don't need python running on two cores if it's unsatisfactory on one. When I'm writin...

manic glacierBOT
tulip sleet
bright robin
#

I've also replaced my custom circular buffer with ringbuf as you wanted, and modified my board_serial_bytes_available to return uint32_t in line with the new API changes.

#

Though it still seems to have a conflict with serial.c that I'm not sure how to resolve.

manic glacierBOT
manic glacierBOT
midnight ember
#

There seems to be circuit python support for the C3 and C6 now. Time to update the product listings? For example, as of the time of this writing, there is no CircuitPython support - only Arduino and ESP IDF! https://www.adafruit.com/product/5337

manic glacierBOT
manic glacierBOT
manic glacierBOT
#

I touched up the last commit so it works, touch up the documentation, and also fixed a build overflow problem.

test boot.py:

import usb_midi
usb_midi.set_names(streaming_interface_name="new_streaming_interface_name", audio_control_interface_name="new_audio_control_interface_name", in_jack_name="new_in_jack_name", out_jack_name="new_out_jack_name")

Testing the name setting:

$ sudo lsusb -vd 239a:80f2 | egrep 'iJack|iInterface'
      iInterface              4 Circui...
manic glacierBOT
orchid basinBOT
manic glacierBOT
#

CircuitPython version

CircuitPython 9.1.0-beta.0

Code/REPL

not sure

Behavior

not sure

Description

I got a great deal on alie ( not sure now it is that great ) for $2 esp32 with sunton_esp32_2432S028
https://www.aliexpress.com/item/1005006470918908.html
Using CircuitPython 9.1.0-beta.0 on sunton_esp32_2432S028 the display is not working
as expected . It is the same HW listed here but with addional usb type-c
https://github.com/witnes...

fringe yarrow
#

oh jeez.. now i've made work..

manic glacierBOT
#

the ILI9341 and ST7789 are virtually the same driver, and will work with the same init string (primarily what the driver provides). The only difference is that the ILI9341 has options for setting more finely tuned gamma settings. That looks like an offset error, but since the display is 320x240, which is the full capacity of that controller chip, there is no offset to change, to my understanding.

Are you releasing the display and then attempting to initialize it yourself with a driver? ...

#

I used CircuitPython with ttgo display and it worked as expected out of the box . In the case of sunton_esp32_2432S028 i used the default with the bin from here https://circuitpython.org/board/sunton_esp32_2432S028/
The text does not work as in the pic , the code i used for Bitmap is copy paste from the site

import board
import displayio
import time
import pulseio

board.DISPLAY.brightness = 0
splash = displayio.Group()
board.DISPLAY.root_group = splash

odb = displayio.OnDis...

manic glacierBOT
#

I am suspecting an issue with the driver as with openHASP i kinda faced the same issue until i changed it . I am wondering if the HW listed here https://circuitpython.org/board/sunton_esp32_2432S028/ is the one without usb type-c and hence my board is a new version . I wanted to keep CircuitPython if any info is needed but i will try to go back to openHASP and get as much details as possible of how did the display worked as expected and then try to apply the same changes to CircuitPytho...

#

Yes, the one the CircuitPython definition is based on is the version without the USB-C port. Makes me wonder what else they changed between revisions. I suspect the issue lies in the MADCTL command of the init sequence sent to the LCD. While mine starts up with a widescreen rotation with the provided settings, yours is starting up in portrait with a mismatch in the display object size to LCD dimensions. I'm not sure there's an easy answer, without someone having both versions to test.

#

These commands will manually build the display on the Micro USB display version:

import fourwire
import board
import microcontroller
import displayio
import adafruit_ili9341

displayio.release_displays()
bus = fourwire.FourWire(spi,command=microcontroller.pin.GPIO2,chip_select=microcontroller.pin.GPIO15)
import adafruit_ili9341
display = adafruit_ili9341.ILI9341(bus,width=320,height=240,backlight_pin=board.LCD_BCKL)

The adafruit_ili9341 library doesn't do anything excep...

manic glacierBOT
#

I did get the displayio.Display call to work with this command:
display = displayio.Display(bus,init,width=320,height=240,backlight_pin=board.LCD_BCKL)
I filled the init variable with the init sequence from
https://github.com/adafruit/Adafruit_CircuitPython_ILI9341/blob/main/adafruit_ili9341.py

That should give you everything you need to try modified init_sequences on your device.

orchid basinBOT
manic glacierBOT
manic glacierBOT
#

@RetiredWizard Thank you very much for the help
Not sure what happened now but tried your commands and facing issues with the board disconcerting from PC with serial ( I faced this even before ) and also facing network timeout . I would have to use another laptop shortly and possibly reboot the test
router as this board is rebooting my PC for some reason .

Just to double check with you meanwhile the needed changes for adding the ILI9341 driver .

  1. Copy adafruit_ili9341.mpy & adafr...
#

You only need the .mpy they are both the same library, the .mpy has just been pre-compiled so it's a bit more efficient and takes up less memory/space.

If you use the adafruit_ili9341 library you don't need to set the _INIT_SEQUENCE, the library defines the _INIT_SEQUENCE internally.

If you want to experiment with different _INIT_SEQUENCES, then you won't use the adafruit_ili9341 library, you'll create the display object using displayio.Display instead.

The ESP32 board is a bit diffi...

#

If I'm not mistaken, the serial comms bug you refer to affects the C3 and C6 but not the ESP32-D0WD, right? Regardless, the main issue I had with this board seeming to be unstable was a power related issue. When the screen intializes, it's a thirsty board, and most USB ports lack the amperage to keep the board stable. To that end, while working on it, I've hooked it up to external 5v using the included JST connector as well as the USB port to the computer. With the board in question here, w...

#

The larger buffer may help, but it looks to me like there's an XOFF/XON functionality missing. Once the buffer is full, the data seems to continue to flow and just get lost.

I was trying to paste code into the REPL (after pressing CTRL-E) on an ESP32 Sunton board today and had to break the copy/pastes into smaller blocks because attempting to copy the whole file, about 24 lines of code, didn't work. The first few lines seem to paste fine but then some of the characters were dropped from th...

#

Thank you guys , I feel good to know that it is not only me with this board ( I honestly now know why it was only $2 ) . I am using a laptop now to experiment further which i will continue to do . I will post here if I get somewhere but I do wish to warn others that you do get what you paid for with this board as wiring an external display to a bare esp32 might not be a bad idea given the shortcoming I could see

manic glacierBOT
#

@RetiredWizard It is working now ( at least the size ) , color are still off but text and pics fits now , I used your commands with only width=240,height=320 swapped

display = adafruit_ili9341.ILI9341(bus,width=240,height=320,backlight_pin=board.LCD_BCKL)
image

I will continue to experiment to fix the colors mismatch which i assume is okay with your board , appreciate th...

#

It took me a bit to track down the JST connector that came with the board, it's a size I don't have stocked :grin: but adding the supplemental power didn't seem to change anything for me. The board is drinking about 150mA from the second supply so I bet some USB ports would have problems.

The C3/C6 bug might be something slightly different than the ESP32 paste bug but there's definitely an issue with the ESP32 as well. I just tried the same large paste on an ItsyBitsy ESP32 and it behaves...

manic glacierBOT
manic glacierBOT
#

I suspect the invert keyword goes somewhere else, but I can't find it in the documentation, Sean may come up with it.

I don't know if this is the right approach but you could try using the built in color spaces and see if any of them work for you:

face = displayio.TileGrid(odb,pixel_shader=displayio.ColorConverter(input_colorspace=displayio.Colorspace.RGB565_SWAPPED))

The builtin color spaces are:

RGB888: Colorspaceยถ
The standard 24-bit colorspace. Bits 0-7 are blue, 8-1...
#

RGB555_SWAPPED seems very close ( not 100 % ) but I suspect that may also have to do with the pictures i am using which i have to change in any case due to size . I will try to load new pictures with reduced size and see the effect of changing color spaces .

I can close this if you wish ( i do want to keep it open as much as possible to pick your brain :) )

I also see invert=true in the doc with other drivers
![image](https://github.com/adafruit/circuitpython/assets/87589371/aab1d996-...

#

I did join the discord today looking for info on that board , i only came to gh because i am just experimenting with CircuitPython and used the installer with other boards like the TTGO which worked out of the box so thought that the beta testing report would help ( granted the board listed here https://circuitpython.org/board/sunton_esp32_2432S028/ is not the exact one I have )
@RetiredWizard sure i will try the new adafruit_ili9341.mpy

tulip sleet
manic glacierBOT
#

@RetiredWizard The new driver seems to work ( the display rotated for some reason with bgr=True so i tried to adjust it )
display = adafruit_ili9341.ILI9341(bus,width=240,height=320,backlight_pin=board.LCD_BCKL,bgr=True,rotation=270)

Sure i will close this as the display is kinda working ( I prefer if it is closed by someone else ) , appreciate the help really , i unfortunately past my allocated time and cant be on discord for this small thing until i do a bit of homework on Circui...

tulip sleet
tulip sleet
#

@lone axle @proven garnet @gilded cradle I just made a manual pass through all the webhooks for the CircuitPython libraries. I had discovered several that had not been updated with "secrets" for ReadTheDocs. I added secrets as necessary (maybe about 10% needed it). A few had multiple RTD webhooks, maybe from failed attempts. A few had the wrong repo (someone's personal repo). I had to re-create the subjprojects and added " x" to their name, because the name couldn't be the same.
A few projects have the wrong formatting style. I should have written those down, but I didn't.@gilded cradle that was true of a few blinka libraries, and in some, the "Download" links were pointing to nonexistent repo URLs, like Adafruit_CircuitPython_Blinka_something. So maybe worth looking at the RTD set up files for the blinka repos.

#

also there were some dead travis webhooks, etc. I deleted

manic glacierBOT
bright robin
#

Is there anything that needs to happen to my keyboard pull request (9145) before it can be merged? I'm genuinely not sure. Or do I just need to show a little patience? ๐Ÿ˜†

bright robin
#

Hmm, I'm getting some error when I try to build a new ESP32 board frozen modules:

-- Configuring done
-- Generating done
-- Build files have been written to: /home/joshua/src/circuitpython-watchy/ports/espressif/build-sqfmi_watchy/esp-idf
QSTR not updated
Module registrations not updated
Root pointer registrations not updated
In file included from ../../py/reader.h:29,
                 from ../../py/lexer.h:33,
                 from ../../py/parsenum.h:30,
                 from ../../py/runtime.c:34:
../../py/runtime.c: In function 'mp_init':
../../py/runtime.c:153:53: error: 'MP_QSTR__dot_frozen' undeclared (first use in this function); did you mean 'MP_QSTR_root_group'?
  153 |     mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR__dot_frozen));
      |                                                     ^~~~~~~~~~~~~~~~~~~
../../py/obj.h:221:56: note: in definition of macro 'MP_OBJ_NEW_QSTR'
  221 | #define MP_OBJ_NEW_QSTR(qst) ((mp_obj_t)((((mp_uint_t)(qst)) << 4) | 0x00000006))
      |                                                        ^~~
../../py/runtime.c:153:53: note: each undeclared identifier is reported only once for each function it appears in
  153 |     mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR__dot_frozen));
      |                                                     ^~~~~~~~~~~~~~~~~~~
../../py/obj.h:221:56: note: in definition of macro 'MP_OBJ_NEW_QSTR'
  221 | #define MP_OBJ_NEW_QSTR(qst) ((mp_obj_t)((((mp_uint_t)(qst)) << 4) | 0x00000006))
      |                                                        ^~~
make: *** [../../py/mkrules.mk:85: build-sqfmi_watchy/py/runtime.o] Error 1

My build it working fine otherwise.

#

I added the modules to the frozen modules directory with Git and to my FROZEN_MPY_DIRS variable in mpconfigboard.mk.
Was there something else I was suppose to do?

bright robin
#

Ah, actually I have another problem.
It seems that for the new board I need a 'CIRCUITPY_CREATOR_ID' and 'CIRCUITPY_CREATION_ID' to be defined.
The board will not build without one, I put in the USB ID but it seems that's not enough anymore.
In the test builds for the Watchy I originally just put in a random number to get rid of the error, but I don't think I can actually put that into production.
So... do I have to define one? And if so how can I obtain an ID? It's not my board of course. It's from SQFMI.

manic glacierBOT
manic glacierBOT
manic glacierBOT
#

yep that's the way to do it. There was no argument for invert. First time I've seen a BGR argument, didn't know that was a thing, very cool! There will be more driver options like this going into 9.0. This format makes it much easier to add optional init sequence arguments.

    def __init__(self, bus: FourWire, *, bgr: bool = False, invert: bool = False, **kwargs: Any):
        init_sequence = _INIT_SEQUENCE
        if bgr:
            init_sequence += (
                b"...
midnight ember
# bright robin Ah, actually I have another problem. It seems that for the new board I need a '...

https://pid.codes/howto/ free to open source developers created and maintained by one of our circuit python developers. the application process is pretty straight forward with a PR. Here's an article by Hackaday that covers the gist of the pid.codes project. https://hackaday.com/2015/04/03/usb-pids-for-all/ So far there are 472 contributors to the repo and a VID has 65,000 PID's available.. a long way to go before this method might not be viable. ๐Ÿ˜‰

bright robin
#

So does it have to be your project? Or can I request a VID and PID for this board I find myself with?

midnight ember
#

That's a great question. Most people have developed their own boards that apply. If it's not your board then I'm going to guess it's an unbranded aliexpress board that you have little to no hope of finding the real PID for (if it has one)?

#

I don't know the answer to that question but there are people here that can chime in later to give you a better answer.

bright robin
#

No, it is a branded board with a website.

midnight ember
#

OK try to contact the manufacturer and ask for their VID & PID? That might be a speedbump in your project but it's better to use the real PID if possible.

bright robin
#

The USB VID and PID? Well I already have that if I plug it in.

#

But obvious that's non-unique. It's just the ID of the USB interface chip used.

midnight ember
#

ohh I'm sorry I misunderstood.

bright robin
#

It's an ESP32 with no extra digits, so no "native USB".

midnight ember
#

This is the first time I've heard of creator_id and creation_id... I haven't submitted a board in a while though. Yeah someone will be along to answer your question better sorry about that.

bright robin
#

Yeah, it wouldn't let me build an ESP32 project without it... the other one I'm working on uses an ESP32S3 so that's no problem.

#

Well I might have to see how other people solved this problem. There must be lots of them.

midnight ember
#

Is it documented in the "how to submit a new board" learn guide?

bright robin
#

Well kinda, it is a little vague. It just says you can use USB IDs if you have native USB, otherwise you'll need a creator ID.

midnight ember
#
For boards that don't have native USB, there is still a way to identify your board uniquely. You will see mentions of CIRCUITPY_CREATOR_ID and CIRCUITPY_CREATION_ID in their mpconfigboard.mk files. You can register new Creator and Creation IDs at https://github.com/creationid/creators.```
#

Seems as if they're board porting ids not necessarily submitted by the manufacturer.

#

Yeah and they're mostly for non-native USB chips like the original ESP32.

bright robin
#

Yeah, so I will need to submit some kind of request for IDs to that repo.

midnight ember
#

Yep, should be straight forward.

bright robin
#

With a few legacy exceptions, each different hardware product that runs CircuitPython needs a different unique identifier.
Oh... right. That's how the old boards don't need them. They have some kind of hard coded exception.

midnight ember
#

Neat, didn't know that. My guess is these projects were born from a necessity to make the whole porting process easier for other developers.

bright robin
#

So as far as I can tell I just have to add a pull request to that repo. Looks easy enough.

midnight ember
#

If it's anything like pid.codes then yes. I have one registered and it was just a simple PR using other submissions as a template. Swap in the correct info, get the code, and plug it into the make.

#

I think my PR took a couple of weeks to get approved so it might not be a quick process.

manic glacierBOT
bright robin
#

Oh well, submitted a pull request. So if any maintainer asks where my ID numbers come from I'll just direct them there.

manic glacierBOT
tulip sleet
onyx hinge
#

hm I discovered something interesting while working on the POSIX port: some stuff, like entering safe mode, can happen before starting the VM for the first time. This will print a compressed message. Compressed messages can refer to qstrs, but the root qstr pool is not initialized this early. So, you can get a crash this way. I wonder why we didn't see this before, or maybe we didn't understand it.

Program received signal SIGSEGV, Segmentation fault.
0x0000555555579fe5 in find_qstr (q=q@entry=0x7fffffffd628) at ../../py/qstr.c:142
142        while (*q < pool->total_prev_len) {
(gdb) where
#0  0x0000555555579fe5 in find_qstr (q=q@entry=0x7fffffffd628) at ../../py/qstr.c:142
#1  0x000055555557a2e0 in qstr_str (q=<optimized out>) at ../../py/qstr.c:290
#2  0x00005555555b9c9f in decompress_vstr (
    compressed=compressed@entry=0x555555617c9d <translation59>, 
    decompressed=decompressed@entry=0x7fffffffd690)
    at ../../supervisor/shared/translate/translate.c:138
#3  0x00005555555b9d15 in decompress (
    compressed=compressed@entry=0x555555617c9d <translation59>, 
    decompressed=decompressed@entry=0x7fffffffd6d0 "CircuitPython core ")
    at ../../supervisor/shared/translate/translate.c:149
(gdb) p MP_STATE_VM(last_pool)
$1 = (qstr_pool_t *) 0x0
#

maybe something's different about how I set things up with the "commandline workflow"

manic glacierBOT
#

For reference:

https://docs.python.org/3/library/socket.html#socket.socket.settimeout

socket.settimeout(value)
Set a timeout on blocking socket operations. The value argument can be a nonnegative floating point number expressing seconds, or None. If a non-zero value is given, subsequent socket operations will raise a timeout exception if the timeout period value has elapsed before the operation has completed. If zero...

manic glacierBOT
#

CircuitPython version

Adafruit CircuitPython 9.0.3 on 2024-04-04; Adafruit CLUE nRF52840 Express with nRF52840

Code/REPL

Adafruit CircuitPython 9.0.3 on 2024-04-04; Adafruit CLUE nRF52840 Express with nRF52840
>>> import board
>>> import digitalio
>>> import analogio
>>> p0_analogue = analogio.AnalogIn(board.P0)
>>> p0_analogue.value
65523
>>> p0_analogue.deinit()
>>> p0_digital = digitalio.DigitalInOut(board.P0)
>>> p0_digital.value
False

#...

fringe yarrow
#

So here's something interesting.. I wrote two simple programs for the same ESP32S3, one in Circuit Python, one in Arduino C, to calculate Pi to a large number of decimal points (more than is actually stored, I suspect) and return the time it took to do so.. Both used the Baileyโ€“Borweinโ€“Plouffe formula in exactly the same way.. Against all expectations, the Arduino code was 25% slower than the Circuit Python code.. I would have expected the interpreted nature and overhead of Circuit Python would cause it to be at least somewhat slower to execute the same task..

spare jacinth
#

did they have the same precision tho?

#

perhaps circuitpy was faster as it was working on less "resolution" and could gain some extra speed from optimizations or some tradeoff on math operations

#

if values are somewhat close, im also quite surprised of the speed ๐Ÿคฏ

fringe yarrow
#

They were both going through the motions of calculating to 600,000 places, though I don't know if the float type in arduino is the same precision as a float in circuit Python.

#

I only put it to that many places to make it a significant enough amount of time to get a good comparison.

#

I should write it again in espidf for a comparison.

spare jacinth
# fringe yarrow They were both going through the motions of calculating to 600,000 places, thou...

what i mean is that on float maths there is plenty of space for size vs precision vs speed tradeoffs, depending on how the compilation is setup (optimization flags) or some other "environment" things like eg CircuitPy using lets say 25 instead of 32 bits of precision for floats (and doings some clever tricks based on that), maybe you indeed get faster speed (trading off so much speed that you overcome Py's overheads) but at the cost of numbers being off

tulip sleet
#

and CPy has all the interpretation overhead.

#

or were you using double in Arduino?

fringe yarrow
#

I tried float and double to see if it made a difference in execution time. It did not.

tulip sleet
#

is your code available somewhere?

manic glacierBOT
fringe yarrow
#

float calculate_pi(unsigned long n) {
  float pi = 0.0;
  int k;

  for (k = 0; k <= n; ++k) {
    pi += (1.0 / pow(16, k)) * ( 4.0 / (8 * k + 1) - 2.0 / (8 * k + 4) - 1.0 / (8 * k + 5) - 1.0 / (8 * k + 6));
  }

    return pi;
}

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);

  int start_time = millis();
  float pi = calculate_pi(600000);
  int end_time = millis();

  Serial.print("Pi: ");
  Serial.println(pi);
  Serial.print("Execution time: ");
  Serial.print(end_time - start_time);
  Serial.println("ms");

}

void loop() {
    // Nothing to do here
}
#

def calculate_pi(n):
    pi = 0
    k = 0
    for k in range(n):
        pi += (1 / 16.**k) * ((4 / (8 * k + 1)) - (2 / (8 * k + 4)) - (1 / (8 * k + 5)) - (1 / (8 * k + 6)))
        k += 1
    return pi

start_time = ticks_ms()
pi = calculate_pi(600000)
end_time = ticks_ms()

print("Pi: ",pi)
print("Execution time:", (end_time - start_time), "ms")```
tulip sleet
#

I would check to see if Arduino is compiling to hw floating point or not. There may be some flags for that in the dropdowns.

#

I looked up about when conversions to floats happen. In C I believe the inside 8 * k + <n> operations will still be done as ints (unlike in Fortran). Same in Python.

manic glacierBOT
#

Agreed, I hit reset on CLUE and had a play with P1 (was using P0 before).

Adafruit CircuitPython 9.0.3 on 2024-04-04; Adafruit CLUE nRF52840 Express with nRF52840
>>>
>>>
>>> import board
>>> import digitalio
>>> p1_digital = digitalio.DigitalInOut(board.P1)
>>> p1_digital.value  ### connected to 3V
True
>>> p1_digital.value  ### over to GND
False
>>> p1_digital.value  ### back to 3V
True
onyx hinge
#

speaking of "generating pi", the programs from this page tend to run on Python: https://www.gavalas.dev/blog/spigot-algorithms-for-pi-in-python/ but I tried the "gospers_pi" variant and it got through 2 80x25 screens (about 4000 digits) of pi and started to markedly slow down. This program is carefully written to work in python integers, which can contain a number of digits limited only by usable memory.

As the precision of a Python float is about 6 to 7 digits, I'm not sure doing a summation of 600,000 items from the BBF formula is usable (3 + 16**-6 == 3 is True in circuitpython arithmetic, i.e., they are exactly the same number, so I'm not sure anything past the first 5 hex digits is actually contributing to the final sum!)

def gospers_pi():
    q,r,t,n,i = 1,0,1,8,1
    while True:
        if n == (q*(675*i-216)+125*r)//(125*t):
            yield n
            q,r = 10*q,10*r-10*n*t
        else:
            q,r,t,i = i*(2*i-1)*q,3*(3*i+1)*(3*i+2)*((5*i-2)*q+r),3*(3*i+1)*(3*i+2)*t,i+1
        n = (q*(27*i-12)+5*r) // (5*t)

print(end="3.")

def rest(seq):
    next(seq)
    yield from seq
for digit in rest(gospers_pi()): print(digit, end="")
fringe yarrow
#

I doubt it is contributing anything, least of all to 600,000 digits. It was purely an exercise to take up time to gauge how fast different environments would do it.

#

Also with that += 1 in the for loop in python, it would be incrementing k twice each loop, so its actually only doing 300,000 iterations, leading to a lower total time, i bet.

#

wait, no it's not.. k isn't a counter, it's a temporary variable set to the next item in range(n) regardless of what it's value is by the end of the loop

#

i'll try that other one that gradually calcualtes it out..

thorny jay
#

The title is suspicious. I don't remember what it usually look like, but it is the first time I notice this title: "Copy of TEMPLATE ONLY -- CircuitPython Weekly Meeting for [DATE (TEMPLATE ONLY)]".

onyx hinge
#

I corrected the title, thanks.

tulip sleet
lone axle
#

Would there be any interest in, or resistence to changing circuitpython-build-tools to generate library subfolders within the examples/ that get put in the bundles that are built? Right now we end up with 1 folder containing all examples (prefixed with library name, which is helpful). But subdirectories that happen to exist in any repo's examples dir also get put in there, and they don't always have specific names. So some are like: bmps, camera, cave, cellular etc.. it's unclear at first glance what library they would belong to.

If we had library level subdirectories within examples/ then each library could have it's own directory for examples and it will be very clear which one they belong to.

midnight ember
#

yes that's very confusing. i rarely look through the examples bundle... and perhaps that's precisely why. all of the directories in /examples should be in library named folders. cave and cellular aren't libraries that i know of and even if they were i probably would end up looking them up on github instead of the examples folder. yes i'm in favor of a complete restructuring with actual library names in /examples bundle.

#

it's a hot mess in there

manic glacierBOT
#

It appears that using a pin as an AnalogIn messes up any later use as a DigitalInOut input. Not only that, but this error is also present in 8.2.10, so it may have been present for quite a while. It is just very rare to switch pin modes like this.

So this is not quite so urgent. Nevertheless, it needs fixing. I did notice in the course of testing that sometimes AnalogIn still returns 0 when it should not, but that may be a manifestation of this problem as well.

Test program, tes...

tiny peak
#

@slender iron I got the orangecrab-examples for riscv/blink and riscv/button to build and load on my 85F using the Embecosm Ubuntu RISCV Embedded Stable (gcc 13) toolchain. Needed Makefile modifications to get things working with the proper USB vendor:product IDs and a gcc13 compiler flag change. Nothing major. All the notes are in my ocfpga repo. This gets me pretty close to the point where I can try the litex + circuitpython example.

manic glacierBOT
#

CircuitPython version

Adafruit CircuitPython 9.1.0-beta.0 on 2024-03-28; M5Stack CoreS3 with ESP32S3

Code/REPL

import board
import espcamera

cam = espcamera.Camera(
    data_pins=board.CAMERA_DATA,
    external_clock_pin=board.CAMERA_XCLK,
    pixel_clock_pin=board.CAMERA_PCLK,
    vsync_pin=board.CAMERA_VSYNC,
    href_pin=board.CAMERA_HREF,
    pixel_format=espcamera.PixelFormat.JPEG,
    frame_size=espcamera.FrameSize.QQVGA,
    i2c=board.I2C...
candid sun
#

over the weekend i noticed that bitmapfilter isn't available on the matrixportal s3. is that because it would make the build too big?

tulip sleet
#

... yes, it's added automatically for boards with cameras, and not otherwise. but you have a use for doing bitmapfilter on the matrix image?

candid sun
lone axle
#

I haven't yet, but will eventually use it on devices without cameras as well. For processing bitmaps to show with displayio.

tulip sleet
#

I can give you a test build. If we were to turn it on more generally, it could be for any board with displayio, but that might be a squeeze on some boards

#

I don't know how much space it takes, but it wouldn't be hard to find out

lone axle
#

maybe any that have bitmaptools enabled is a good deleniation?

candid sun
#

the matrixportal did have bitmaptools

tulip sleet
#

i'm doing space-check builds now

tulip sleet
#

6.3k bytes

#

jpegio depends on bitmaptools

fringe yarrow
#

Is there a benefit to a supported board with built-in display NOT having the display initalized, defined and presented to the user as board.DISPLAY?

tulip sleet
fringe yarrow
#

I just have noticed, in my efforts to add support for the devices I had on hand, that there's a fair number like that..

tulip sleet
#

these are third-party boards?

stuck elbow
fringe yarrow
#

yes, third party.. e-ink makes sense..

tulip sleet
#

thanks for remembering that

fringe yarrow
#

I'm looking at things like the Waveshare rp2040 Touch LCD and the Makerfab 7".. those have pins defined for LCD functionality, but nothing in board.c to make it work without the user initializing the bus and display.

tulip sleet
#

@lone axle @candid sun bitmaptools is about 12k of code, bitmapfilter is about 6k of code

#

so I will propose a PR to link them, as you suggested

#

jepler is afk today, I would have him comment

lone axle
#

Is there any way I can see the output of print() statements that result from a test run inside of an action? I'm running into a problem in circup where I'm able to run the tests locally and they all pass, but 2 of them are failing when they run in the actions container. I'm trying to troubleshoot why they are failing but have thus far not found any way to see any kind of output so I am limited to just making a guess, changing something, pushing, then waiting for the pass / fail, but can't see any kind of debugging information about the value of variables during the test.

tulip sleet
#

you should be able to run the tests locally. That would save a lot of pushing to github

lone axle
#

I can run them and they all pass locally

#

I did that before I ever started pushing.

lone axle
#

when I run them locally I have to add -rP or -rx for it to print the output of passed and failed tests respectively. So I guess I could try modifying the actions with that flag

manic glacierBOT
lone axle
#

No luck unfortunately. I even tried adding a new command to the actions build.yml file that runs a command to execute a single test with the -rx flag since it's failing in actions. when I run this command locally (with the flag swapped to -rP since it passes locally for me) I see the print outs. But I still don't find them in the log. It seems like actions is vacuuming up the stdout :/

tulip sleet
lone axle
#

I am not sure, but I'm willing to try anything at this point. Making my best guess changes in the dark is getting me no where so I really need to be able to see something in order to solve this I think.

spare jacinth
#

error reads (as far as i can tell) that you expected the mocker logger to have called logger.error once, but that didn't happen (on test_ensure_latest_bundle_bad_bundle_data)

#

why the logger.error didnt happen? beyond my knowledge :p

#

and welp, circup.command_utils.get_bundle didnt get executed either (on test_ensure_latest_bundle_no_update)

lone axle
#

test_ensure_latest_bundle_no_update is the one I'm focused on ATM.

#

and my understanding is that the test is attempting to ensure that get_bundle does not get called. The fact that it is being called is what causes the test to fail.

empty salmon
#

@tulip sleet / @stuck elbow - I cannot find the context for the tag but the consensus from y'all was that errors on the board.DISPLAY - regardless of the type - was intentional for CircuitPython.
As such, I accept that original decision and documented it for users.

spare jacinth
lone axle
#

I believe that something about the way os.path.isdir is being mock patched is the root cause. but I have very little experience with this (prior work in circup is my only experience using these things ๐Ÿ˜… )

tulip sleet
lone axle
#

oof, that is definitely the case then. I am on py 3.10 locally.

tulip sleet
#

some testing dependency is too old, etc.

lone axle
#

I'm not sure if I am ready for the deep dive into it, but it would be nice to document a process that could be used with docker or whatever to allow running the actions tests locally in as close to an identical environment as we can get.

tulip sleet
#

3.7 was chosen to help support old Macs or something. It reached end of life in june 2023

spare jacinth
#

cool it just does this for me ๐Ÿ™ƒ ```
...
[Build CI/test] โ— ::error::Version 3.7 with arch x64 not found%0AAvailable versions:%0A%0A
[Build CI/test] โŒ Failure - Main Set up Python 3.7

lone axle
#

๐Ÿ˜Ÿ I am at a loss on the outputing. warnings.warn in the code when run locally does output into the ==warnings summary== section. But the same thing inside actions just does not output the messages into that section.

spare jacinth
#

anyway, get_bundle is only called from a single place: ensure_latest_bundle
and that call is behind a if do_update: check, so seems like you have somehow made that variable change from False to True in the test case

lone axle
#

Right, I think I understood that far...

#

and I'm trying to figure out why it's the opposite value by adding print statements to check the value of variables internally.

spare jacinth
#

doesn't seem likje you've change lib_dir either, which is pretty much the only thing happening there ๐Ÿค”

tulip sleet
#

instead of printing you could raise exceptions or whatever the current test is doing and put some stuff in the exception messages

spare jacinth
lone axle
#

raising an exception instead of printing causes pylint to fail with "unreachable code" ๐Ÿซ 

wraith crow
fringe yarrow
#

There's no time like the present, if you have the hardware ๐Ÿ˜‰

wraith crow
#

Neither has much of a user base, but I suppose they could serve as examples.

lone axle
#

okay, very strange. I added the exception raising: https://github.com/adafruit/circup/pull/208/commits/53541551136f5ac3743889724ddf4be438c54b38#diff-d3f87283746c1f8ed3d8fa8a6b567932fb878810935c95cadb28e6ca6142454dR116 but the test still fails with the same assertion error and doesn't mention anything about the RuntimeError that was raised. https://github.com/adafruit/circup/actions/runs/8602788106/job/23573140295#step:12:42 So maybe there is some other logical error or incorrect assumption on my part and it could actually print, but in this case something is causing it not to get to that branch of code.

I must take a break from this for a bit. But I have a new direction to look (validating any assumption I've made about control flow), and a new thing to try: putting prints or other outputs in higher level code that runs without conditions to see whether it does come through to the actions log.

spare jacinth
#

perhaps you are running directly to the else: update = True?

#

aka: tag != bundle.current_tag

#

i would print self.url to see if it is checking releases against your fork (origin of PR) or adafruit repo (target of PR), as a starting point

lone axle
#

I will probably also look into upgrading to a newer python inside of the actions container. Using something newer would be nice for consistency, and especially if 3.7 is past EoL.

spare jacinth
#

perhaps it runs against your fork on local, but against adafruit repo on the PR, which would explain why tag names (or whatever else that depends on github's account/repo) are changing and thus going thru other parts of the code flow

lone axle
spare jacinth
#

oh yeah, i didn't look at the test code... because! ๐Ÿ™ƒ

#

are you sure you fixed the patch's paths correctly when moving code?

#

eg: maybe you patched circup.bundle.Bundle and it had to be circup.Bundle or the like

#

that kind of stuff can be much of a PITA

#

nvm, that would also fail locally, wouldnt it? :p

lone axle
#

I'm not really sure of anything related to the mock patch's tbh. It's pretty likely I've done it wrong somehow but just don't recognize how. And something about the difference in my environment and the actions container is causing it to fail in the container, but suceed for me locally.

#

Ideally I'd like to make another pass through the tests (after getting them passing and setting this down to work on other stuff for a bit). With an eye towards trying to remove as much of the mock patching as possible. In many cases I think these are used in spots where we could also just have hardcoded files / values in the mock_device that exists for testing and read "real" values out of those files instead of mock.patching things like json.loads and file opens etc.

#

we could similarly check in a mock_bundle that has whatever necessary files it needs to look real enough for testing.

wraith crow
lone axle
slender iron
lone axle
#

Alright, I've finally got all tests and other checks passing โœ… . The root of the remaining issues were due to the way json was being mock patched. That seems to behave differently for me locally (parhaps result of py3.10 vs. py3.7). I was able to change the tests to mock something other the json module while still validating intended thing within the test.

solar whale
#

Have a good meeting โ€” Iโ€™ll be out for the eclipse. See you next week.

midnight ember
#

P4 no wifi but will likely be coupled to C6 for wifi. C6 airlift coming for the P4?

#

I saw their new video today too. The marketing isn't clear enough that the P4 does not have radio and needs to be used with a C3, C6, (or H6) i think.

silver tapir
#

Costa Rica as well, just partial here.

midnight ember
#

It's always a plus when you can see what you're soldering

thorny jay
#

Maybe the guide can explain the difference?

#

I assumed there is "the guide" on the topic. ๐Ÿ˜‰

#

Especially with the connection manager and other new changes in that topic... so a guide would be welcome so that I can catchup or re-learn.

silver tapir
#

circuit jupyter would be so cool.

midnight ember
#

There is a playground note on connection manager from Justin.

thorny jay
#

Does watching NASA live stream count as an excuse?

midnight ember
#

always

#

is that a thing? link?

#

in dallas

manic glacierBOT
slender iron
#

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/1qribXknsk4RKNPSjjIPpvTiuhSzboGrLf4m8cRLw9JI/edit

lone axle
#

Making some progress on getting examples into their own subdirs in the bundle build tool ๐ŸŽ‰ (I've modified my local bundle to only include 4 libraries during testing)

short tendon
#

@tulip sleet missed the meeting today (spring break), but would be happy to put together a playground note for networking if that would be helpful

tulip sleet
manic glacierBOT
manic glacierBOT
manic glacierBOT
#

CircuitPython version

Adafruit CircuitPython 9.0.2 on Adafruit ItsyBitsy M4 board

Code/REPL

import audioio
import board
import time

time.sleep(1)

print("INIT")

audio = audioio.AudioOut(left_channel=board.A0)

print("DONE!")

Behavior

To trigger the bug, load the provided code.py code onto the board, and reload it 4 times (e.g. using Ctrl+D in Mu), letting it the code execute to completion each time. On the fourth reload, the boa...

manic glacierBOT
manic glacierBOT
#

CircuitPython version

Adafruit CircuitPython 9.0.3 on 2024-04-04; Teensy 4.1 with IMXRT1062DVJ6A

Code/REPL

>>> import gc
>>> gc.mem_free()
941152
>>> gc.mem_free()
940832
>>> gc.mem_free()
940576
>>> gc.mem_free()
940320
>>> gc.mem_free()
940064

Behavior

Every time you call gc.mem_free(), another 256 bytes get lost

Description

No response

Additional information

No response

manic glacierBOT
midnight ember
#

Thank you @slender iron for giving me homework on context managers. There's a lot more you can do with with than I realized. Learned a lot today. Hope you feel better today. ๐Ÿค—

slender iron
#

@tulip sleet the nrf bootloader only sets aside 32k for the SD

tulip sleet
#

so it will use the RAM right after that for its own purposes, hunh? OK, then, I guess it's NO_INIT>

slender iron
#

noinit is at the top of that 32k

tulip sleet
#

ack, well, if you smash our SD RAM in the middle, does it matter, becuase you're going to the bootloader immediately?

slender iron
#

that's what I'm thinking

tulip sleet
#

is this to communicate to the bootloader, or the other way?

slender iron
#

it's to communicate to ourselves on startup

tulip sleet
#

or it's just for us to stash a state?

#

ok got it

#

I did look for some place to put this info, but couldn't find something like a persistent reg. You said there were a couple of bytes?

#

if you check it before the sd is set up at all, maybe it will be ok

slender iron
#

ya, I think it'll be fine

#

the two gregrets are 8 bits a piece

#

the first is already used for resetting into the bootloader

tulip sleet
#

do we do a hard reset to go into the bootloader?

#

i was thinking about some state in some peripheral, but that would be reset. Anyway, I think you have the solution

slender iron
#

testing it now

manic glacierBOT
#

Instead of putting it in our uninit section, we need to ensure it is also uninit by the UF2 bootloader. We both leave at least the first 32k of RAM for the soft device, so place our word just before the end of 32k. This is ok because we only use it before the SD is started.

Fixes #9143 and doesn't require a bootloader change.

manic glacierBOT
manic glacierBOT
#

Mostly from practical testing. I have had this firmware for some time and just decided to update it to CP 9 and commit.
Originally I didn't freeze anything, but by the time I added all the hardware libraries, ePaper display driver, graphics libraries and a bitmap for the watch face it was starting to run low on memory. The perils of ESP32 without PSRAM I suppose. I'll let you be the judge on whether this is sufficient justification to add frozen libraries.

manic glacierBOT
manic glacierBOT
#

CircuitPython version

Adafruit CircuitPython 9.0.2 on Adafruit ItsyBitsy M4 (tested on two boards)

Code/REPL

import gc

mem_blocks = []

for i in range(0, 1):
    mem_blocks.append(bytearray(10_000))
    print("FREE MEM after BIG block {}: {}".format(i, gc.mem_free()))

for i in range(0, 70):
    mem_blocks.append(bytearray(1_000))
    print("FREE MEM after block {}: {}".format(i, gc.mem_free()))

print("INIT DONE")

ix = 0

while True:
   ...
manic glacierBOT
#

I tried to create a CircuitPython driver for this display: https://www.waveshare.com/wiki/Pico-ResTouch-LCD-3.5

This is a 480x320 display with an ILI9488 driver-chip. The display uses a 16-bit parallel interface and the SPI of the Pico is connected via two chained 8-bit SIPO shift registers. This converts 2x 8-bit SPI to 16-bit parallel.

The problem: this does not work with the current displayio implementation, since the interface always needs 16-bit sized data (8-bits for commands is f...

manic glacierBOT
#

There seems to be some kind of support for 16 bit coordinates, it may be called "ram width" / "ram height". This is in bus_core.c:

    if (self->ram_width < 0x100) {
        data[data_length++] = x1;
        data[data_length++] = x2;
    } else {
        if (self->address_little_endian) {
            x1 = __builtin_bswap16(x1);
            x2 = __builtin_bswap16(x2);
        }
        data[data_length++] = x1 >> 8;
        data[data_length++] = x1 & 0xff;
        data[data_le...
manic glacierBOT
#

I initially also thought that would be the way to go, but it is not. The C-driver code of Waveshare does:

        //set the X coordinates
        LCD_WriteReg(0x2A);
        LCD_WriteData(Xstart >> 8);             //Set the horizontal starting point to the high octet
        LCD_WriteData(Xstart & 0xff);           //Set the horizontal starting point to the low octet
        LCD_WriteData((Xend - 1) >> 8);         //Set the horizontal end to the high octet
        LCD_WriteData((X...
manic glacierBOT
#

I'm hoping that this lack of MP3 support in CP for the ESP32S3 can be sorted out in a future release of CP. It's very unfortunate that CP supports the S3 so well overall, and yet there is this gaping hole regarding audiomp3 support. MP3 playback is used for so many things (gaming, general audio, AI applications etc.) that not having this does limit the value of CP with respect to using it with ESP32s. I understand this is due to the lack of an xtensa assembly, so that this is just the way ...

#

It's not that it can't be resolved, but we have to find a new implementation of the MP3 decoder. minimp3 appears to be Creative Commons CC0, though the flow3r licensing is GPL, it appears.

We did not do much here other than a couple convenience functions. We were forced into GPL unfortunately due to other dependencies and not wanting to overcomplicate things. Not sure how much of what we wrote for the Python side would be directly usable for CPY anyway.

Though I have some time open up...

#

Hi dhalbert and timonsku:

Thanks for the update. So that means that there is at least some potential for this to be resolved in the future if the technical
challenges of implementing minimp3 could be worked out , but that the a more serious roadblock is licensing constraints. I guess this cant just be reverse engineered, Halt and Catch Fire style, ha ha. Would be amazing if it made it onto a todo list. The CP support for S3 works great. So close to perfection...

manic glacierBOT
midnight ember
#

are PR states only open, closed, and merged? are there other possible states, draft perhaps?

crimson ferry
#

yes, there is a Draft state

#

right column, in the Reviewers section

manic glacierBOT
manic glacierBOT
manic glacierBOT
manic glacierBOT
#

CircuitPython version

Adafruit CircuitPython 9.0.3-dirty on 2024-04-10; SparkFun Pro Micro RP2040 with rp2040

Code/REPL

# code.py:

import board
import keypad
import busio
import usb_hid
from adafruit_hid.keyboard import Keyboard
from adafruit_hid.keycode import Keycode

#
# matrix/keymap setup
#
cols = [board.A1, board.A0, board.SCK, board.D20, board.D23, board.D21]
rows = [board.D5, board.D6, board.D7, board.D8, board.D9]
rowcol_map = {}
la...
manic glacierBOT
#

@dhalbert Originally I tested this on MacOS Monterey 12.7.4 on an 2018 Intel Mac Mini.

To be sure, I've just reproduced this on Windows 10 Home (running natively on a 2012 Intel Macbook Pro, not virtualized), and the bug triggers the same there, with all the same symptoms including the code failing to upload and the CIRCUITPY drive going unresponsive. The only apparent difference is that other USB devices (e.g. mouse) don't glitch when this happens, I guess this computer might have...

midnight ember
#

Had the chance to push a new PR and try out my new powershell script for pre-commit. It worked perfectly. Updated PIP and then ran pre-commit without a single CRLF error. Super happy. ๐Ÿ™Œ

onyx hinge
#

achievement unlocked

bright robin
#

Good stuff, I've been meaning to get an extension for VSCode that highlights all your blank lines and whatever else. I remember an extension existed but I can't quite remember what it was called. This automated whitespace nitpicking is starting to annoy me.

spare jacinth
#

The option to show whitespace works good for me

#

And git diff showing everything red helps too

manic glacierBOT
#

Cherry-picked from https://github.com/adafruit/circuitpython/pull/9160/commits/bcae6ae5cfc989b4c518d98ca2d49961746efb42

From #9160:

Instead of putting it in our uninit section, we need to ensure it is also uninit by the UF2 bootloader. We both leave at least the first 32k of RAM for the soft device, so place our word just before the end of 32k. This is ok because we only use it before the SD is started.

Fixes #9143 and doesn't require a bootloader change.

lone axle
#

The newest bundle release 20240411 is the first one built with the examples separated out into sub-directories for each library. ๐ŸŽ‰

tulip sleet
#

Thank you @lone axle !

manic glacierBOT
slender iron
#

@tulip sleet you should factor out that caching logic while you are in there ๐Ÿ˜‰

tulip sleet
#

my changes are in supervisor/shared right now anyway

slender iron
#

๐Ÿ‘

tulip sleet
slender iron
#

no, I don't think so

manic glacierBOT
manic glacierBOT
#
  • Fixes #9162

There were problems when the flash_cache_table entries could not be completely allocated. That code was made simpler. In addition there were some missing guards handling the case when the flash_cache_table itself could not be allocated.

I made some #defines that simplified some size values that were used multiple places.

release_ram_cache() was moved up in declaration order so it could be newly called from another routine. It now handles cleanup of an only par...

midnight ember
#

@crimson ferry I appreciate you and @short tendon advice on the PR. The examples might be tucked away now but they might become more used in the future. Anything to make them easier to use for people of all skill levels I'm all for.

manic glacierBOT
bright robin
#

Ah so it looks like my PR for SQFMI Watchy was merged.

#

When does it appear on the website? I haven't actually added a board from scratch before.

tulip sleet
bright robin
#

Ah, no problem. Will do.

manic glacierBOT
manic glacierBOT
#

I've tried with both a QTPY Esp32-C3 and a SeeedXIAO-ESP32C3 to paste directly into the REPL after pressing CTRL-E, and the smaller pastes ~1.5k surprised me by working fine. When I tried pasting a larger python script (about 12.5k) the paste failed and left the board in a weird state. It didn't recognize Control keys and each key press seemed to process a bit of the paste buffer.

I also tried an ItsyBitsy ESP32 and the paste into the REPL (CTRL-E) failed on the smaller 1.5K file but didn'...

#

Does the USB-to-Serial bridge chip mentioned here refer to a chip on these development boards?

This is in contrast to using a USB-to-Serial (UART) bridge chip, which always ingests the bytes and sends them to a (possibly not listening) ESP32-C3.

If so, is this saying there is no flow control between these chips and the C3?

There are no external chips. The Serial JTAG bridge is inside the C3/C6. It's a native peripheral.

atomic summit
#

Hey folks - Question re the "Serial JTAG" speed of ESP32-C3 and C6 in CP. Is this set somewhere in code?

tulip sleet
#

esp-idf/components/hal/esp32c3/include/hal/usb_serial_jtag_ll.h

atomic summit
tulip sleet
#

Note that while the USB Serial/JTAG device is a USB 2.0 device, it only supports Full-speed (12 Mbps) and not the High-speed (480 Mbps) mode the USB2.0 standard introduced.

atomic summit
#

Because I feel like my transfer speeds are much slower than that.

Even just doing an esptool erase_flash (nothing to do with CP) seems to take WAY longer than the same thing on an S3 with the same amount of flash

atomic summit
#

The erase_flash thing rules out any CP settings.. but it's just weird - as I'm also seeing slow sending of data/files to the C6, and have that same RAW repl paste issue others have seen in that githb issue.

tulip sleet
#

the CDC-ACM part of the peripheral delivers 64-byte chunks. I think the slowness may be due to the ROM bootloader or what the stub is doing. If you use no_stub, does that make any difference?

atomic summit
#

I'll give that a try. I've never really grok'd the no_stub thing tbh.

tulip sleet
#

erase_flash doesn't need any data, so I'm at a loss to explain why that's slower

#

The stub might be quite different, especially since this is a RISC CPU, not xtensa

atomic summit
#

27 seconds to erase_flash my TinyC6 8MB of Flash with CP on it. 8 seconds to erase_flash my TinyS3 with CP on it, also 8MB.

tulip sleet
#

i would have thought erase_flash was just a small command to the stub do do the erase.

#

maybe there is no stub! Does it say it's loading a stub?

atomic summit
#

I'll have to pull out a test jig and have a look - I'll do that today and report back!

#

Thanks for the info and place to look @tulip sleet ๐Ÿ™‚

#

This has all come about because a TinyC6 takes 85-90 seconds to go through a testjig cycle (which tests and loads CP + shipping files) - and all of my S3 boards, including ones with 16MB of Flash take under 45 seconds, and I have narrowed it all down to flashing and file copying times.

#

A TinyPICO which I still ship with MP, takes 27 seconds.

#

But the TP doesn't need to wait for the board to "mount" before I can start copying files to it.

#

Which on the rPI4 can take up to 7 seconds, and up to 17 seconds on a rPI 5 !

tulip sleet
#
 esptool.py --port /dev/ttyACM0 erase_flash
esptool.py v4.7.0
Serial port /dev/ttyACM0
Connecting...
Detecting chip type... ESP32-C3
Chip is ESP32-C3 (QFN32) (revision v0.3)
Features: WiFi, BLE, Embedded Flash 4MB (XMC)
Crystal is 40MHz
MAC: 10:91:a8:32:27:d8
Uploading stub...
Running stub...
Stub running...
Erasing flash (this may take a while)...
Chip erase completed successfully in 16.3s
Hard resetting via RTS pin...
#

ok, there is a stub, and erase took 16.3 seconds with a QT PY ESP32-C3

atomic summit
#

Ok, so half the time, for half the flash size.

#

Can you erase without the stub?

tulip sleet
#

Nope! A fatal error occurred: ESP32-C3 ROM does not support function erase_flash.

atomic summit
#

Ok, bummer.

#

So I'll just have to live with the test times ๐Ÿ™‚

tulip sleet
#

so this seems inherent to the C3/C6

atomic summit
#

But the onboard Serial2UART will be baudrate specific - and will default to 115200

#

You should be able to push that to 2000000, or at least 1200000

#

Though I guess that wont change the "erase speed" - just the comms back and forward.

tulip sleet
#

I tried 921600 and the erase speed is just about the same

atomic summit
#

Yup, ok, so the speed is what it is! Thanks for testing this Dan, it's much appreciated.

tulip sleet
#

loading circuitpython on that dev board at 921600 takes 24 seconds

manic glacierBOT
#

I did some research on this:

lwip_connect() does not implement SO_CONTIMEO, and thus. This is a well-known issue with lwip. Our code actually sets the socket to be blocking temporarily to do connect(), and thus gets the default, unchangeable, 30-second timeout.

There are some code samples that make the socket be non-blocking and do their own timeout handling:
https://github.com/micropython/micropython/pull/12923/files
https://github.com/espressif/esp-idf/blob/0c7204e934b8abda433...

manic glacierBOT
empty salmon
#

In my board.c, I understand how to setup a gpio pin for digital output and set it.

gpio_init(pin);
gpio_set_dir(pin, GPIO_OUT);
gpio_put(pin, 1);

I can not seem to find an example of an anlog pin ... and specifically, reading the pin value.
Is there something akin to gpio_get_analog() for reading a raw value?

tulip sleet
empty salmon
#

Yes, RP2040. OK

empty salmon
#

@tulip sleet - thanks! that was the pointer I hwas hoping for. Now I have found examples to work from.

tulip sleet
#

pico-examples is a great repo to get started on things

manic glacierBOT
#

CircuitPython version

9.0.3 and 9.1.0-beta.0 on Unexpected Maker FeatherS2 Neo and Adafruit Feather ESP32-S2 Reverse TFT

Code/REPL

import board
import digitalio
import microcontroller
import time
import watchdog 
import wifi

#print(f"Start ({microcontroller.cpu.reset_reason})")
print(f"IP address: {wifi.radio.ipv4_address}")

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

# Watchdog
dog = microcontr...
fringe yarrow
#

If I have a new board (ESP32s3), with a USB UART schematic that looks like this, should I be able to get it working with the CIRCUITPY drive?

onyx hinge
#

@fringe yarrow no, for the CIRCUITPY drive (& USB HID, etc) the USB signal pins would need to connect to the esp32s3's USB pins. Based on that schematic the only USB functionality will be USB serial via the CH343P chip.

fringe yarrow
#

thats what I thought.. thanks for the sanity check

manic glacierBOT
manic glacierBOT
manic glacierBOT
#

CircuitPython version

Adafruit CircuitPython 9.0.3 on 2024-04-04; Waveshare ESP32-S3-Zero with ESP32S3
Board ID:waveshare_esp32_s3_zero
UID:437BAD95F6CC

Libraries updated to adafruit-circuitpython-bundle-9.x-mpy-20240411.zip. Plus async_button library from https://github.com/furbrain/CircuitPython_async_button/releases/download/1.2.3/circuitpython-async-button-py-1.2.3.zip

Code/REPL

import time
import board
import busio
import supervisor
from digit...
empty salmon
#

@tulip sleet , @stuck elbow - circling back regarding the board detection solution.

  1. The voltage divider trick is working well to compute a value (0 .. 9)
  2. The code sample for adding a function to the board (eg board.FOO()) is working
  3. The user can get the value if they should want it. For most cases, the user doesn't care.
  4. Internally, the computed value is used to determine which unit sequence is needed for the display.

So, a round of applause for you. Please take a bow!

manic glacierBOT
#
Breakpoint 5, HardFault_Handler () at supervisor/port.c:321
321         if (get_core_num() == 0) {
(gdb) backtrace
#0  HardFault_Handler () at supervisor/port.c:321
#1  <signal handler called>
#2  0x1003059a in tud_hid_set_report_cb (itf=itf@entry=0 '\000', 
    report_id=report_id@entry=0 '\000', 
    report_type=report_type@entry=HID_REPORT_TYPE_INVALID, 
    buffer=0x200097b9 <_hidd_itf+73> "", buffer@entry=0x200097b8 <_hidd_itf+72> "", 
    bufsize=63) at ../../shared-module...
tiny peak
#

@slender iron I made you a gist to demonstrate the idea I mentioned this afternoon during your deep dive stream. It's all python, and the config data is mostly in dictionary literals at the top of the file. The main exception is some stuff for conditionally modifying the ARM mcpu stuff once all the dictionary lookups have completed. Main possible benefit of this approach is that it could cut down on a lot of boilerplate. Perhaps there will be some useful ideas, but if not, no worries. This is the gist: https://gist.github.com/samblenny/a0128b49033ed6a70903243a9bf7e5c0

Gist

Example config builder using Python dictionary literals - config_builder.py

lone sandalBOT
neon cape
#

To who it might consern ๐Ÿ™‚ SSL not working when importing Adafruit-azureiot on a rpPico W, I get this error when I try to reach a HTTPS-site. When I comment out "from adafruit_azureiot import IoTCentralDevice" it is working. It is also working if I get HTTP-site. This is the errormessage:

Fetching text from https://minip.no/
x509-crt-bundle:PK verify failed with error FFFFBD70
x509-crt-bundle:Failed to verify certificate
Traceback (most recent call last):
File "adafruit_connection_manager.py", line 271, in get_socket
OSError: (-12288, 'MBEDTLS_ERR_X509_FATAL_ERROR')

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "code.py", line 80, in <module>
File "adafruit_requests.py", line 591, in get
File "adafruit_requests.py", line 525, in request
File "adafruit_connection_manager.py", line 282, in get_socket
RuntimeError: Error connecting socket: (-12288, 'MBEDTLS_ERR_X509_FATAL_ERROR')

Not a big problem for me since I can use HTTP, but might be a problem someone wants to look at, when I googled it I found very little. ๐Ÿ™‚

empty salmon
#

Is it possible to include a FROZEN library (e.g. adafruit_bitmap_font) in firmware which is not currently in the $(TOP)/frozen/ folder?

onyx hinge
#

@empty salmon no, any change to freeze in a new library would have to add the related submodule in frozen.

empty salmon
#

I found some instructions ( https://learn.adafruit.com/building-circuitpython/adding-frozen-modules\ ) which imply it is possible to add a new module. But, after following the steps, I still get an error when building my board that there is no rule to make target. (One step in the instructions does not work: ``make update-frozen-modules)

What I am a bit apprehensive about is how to commit this change.

midnight ember
manic glacierBOT
#

CircuitPython version

Adafruit CircuitPython 9.0.3 on 2024-04-04; Raspberry Pi Pico W with rp2040
Board ID:raspberry_pi_pico_w

Code/REPL

import os
import time
import adafruit_ntp
import rtc
import ipaddress
import ssl
import wifi
import socketpool
import adafruit_requests
import board
import busio
import terminalio
import displayio
from adafruit_display_text import label
from adafruit_st7735r import ST7735R
from adafruit_azureiot import IoTC...
willow totem
onyx hinge
willow totem
onyx hinge
#

yeah I'd try putting in that Flags: line

manic glacierBOT