#circuitpython-dev
1 messages ยท Page 64 of 1
Perfect that's exactly where to look. Thank you
it's making the build tool look for fake_bme280.py instead of fake_bme280/
actually thanks all ๐
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
I'd much rather that than none ๐
very helpful
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.
afaik it is always set to False at runtime, and is only used for static code analizers and whatnot
I don't think the TYPE_CHECKING if statement is needed for blinka
no idea how or why it works (or is needed/useful), but i think it "works" that way
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.
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.
as i just said... for some stuff that static analyzers (eg mypy) can use but the actual code would not
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
i removed it and it passed my local pylint.
it's there so we can run mypy and do type checking
(please ping if you do, i will be deep into VSCode for a while :P)
I will try it, but it'll be quite a while before I can build it. If you can share a magtag UF2 I'll be able to test it sooner.
Nope, still failed NameError: name 'WriteableBuffer' is not defined
is that code something you are writing from scratch or editing?
trying to add typing to the library, so both?
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
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.
@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
i get a million CRLF errors
then that is a git misconfig
you ran pre-commit install on that repo in your machine, right? CI is most likely doing the exact same checks defined in there
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
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
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
same theory i have, so there's that at least ๐
This is why I don't like pre-commit
WSL is your friend hehe (so is Git For Windows' setting about LF/CRLF)
this is because you checked out the file as CRLF, or your editor is doing that. It's a git issue.
the one file i'm working on i've converted to LF. it's only when running all files i get that
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
ohh i didn't do that for this library. i did that for adafruit_requests.
do you need help finding documentation on how to do that?
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
git can apply LF<->CRLF changes when you commit/pull code, and it wont matter what the actual file is on your drive, it matters how it looks on git's "database"
but pylint should be aware then that CRLF is OK
@spare jacinth except it DOES strongly matter, because tools like pylint check line endings in the working file
if the file is mixed, that's a problem
๐ 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.
i meant "does not matter" as in "you should not take that info as granted, since git tree != your drive"
of course it does matter as the tooling is complaining ๐
does our .pylintrc have expected-line-ending-format=LF??
@tulip sleet yes that's what gets cookie-cut: expected-line-ending-format=LF
ok, then people should NOT set core.autocrlf = true in their git config
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
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
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. ๐ฆ
what is in C:\Users\YOUR_USER_NAME\.gitconfig
https://github.com/desktop/desktop/issues/16522 is of interest. The .gitconfig in your home dir is "global"
as opposed to "system"
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
maybe the submodules are not fetched by branch/commit but by tags, and you need to fetch-tags?
i must say, i have no idea how submodules work in general, even less knowledge on how CircuitPy handles them
@midnight ember when installing Git for Windows (not GitHub Desktop):
:arm-twist: ๐
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true
[core]
autocrlf = input
``` plus my user creds
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.
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
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.
git status will tell you if it thinks a file has been changed
and it will be obvious in the PR
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.
In the Git for Windows shell there is a command dos2unix which will convert many files at once
assuming you install the msys2 shell
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
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
i wonder if notepad++ can be integrated with a batch script to do it.
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.
did you install Git for WindowS? https://gitforwindows.org/
i thought running 2 instances is a bad idea? github desktop and git?
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.
I think it's an issue with the spi flash not being one of the supported devices.. trying to cobble together a toml for it from the datasheet now
CP will start up without spi slash usually. The drive just won't work. Is the CP code stored on the flash too?
Seems like if you don't enable SPI Flash with STM devices it won't even compile.
it is not two isntances. It is complementary software. "Git for Windows" provides a shell environment that does git.
oh, wait.. i see you have to have ONE of spi or internal_flash_filesystem enabled..
i mistakenly assumed that setting spi_flash_filesystem to 0 would just default to internal flash
a debugger will really help you at this point
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.
Ive been up all night working on typing 2 files. My brain hurts. Will resume this tonight.
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
RAM is tight on the Matrix Portal, so this is a good idea.
... The github link is a 404 for me. Is it a private repo?
Sorry, should be public now
It is totally possible that MDNS on pico w isn't as reliable as ESP.
What OS are you running and what browser? (To know what is doing the mdns lookup for the browser.)
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
bstacksdkconfiguses 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...
I totally believe that it's working this way. :-) Figuring out why is the hard part. We have to do some tricky socket monitoring in a separate task that pokes CircuitPython.
Is MQTT using UDP?
We could make it super-simple and simply call
wifi.radio.connect(), noifs orwhiles 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...
- Addresses #9133.
@jzhvymetal
Looks like I was drunk and forgot to add "import usb_hid".
Sorry for the noise.
Thank you! Excited to see how it changes what I'm working on.
I am going to close this, but thank you for the report -- it helps us understand how much the change for 8.x to 9.x affected programs on small boards.
Please get a unique PID for this board instead of using the generic one. https://github.com/espressif/usb-pids
I'm sorry, but this is what appears when I follow the steps outlined here: https://superuser.com/questions/1106247/how-can-i-get-the-vendor-id-and-product-id-for -a-usb-device
I think this is something that Seeed Studio should address?
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
 and there is no plan for cross-version compatibility. (This was previously discussed & OK'd)
I think this is something that Seeed Studio should address?
Yes, we asked them for it on their forum, at https://forum.seeedstudio.com/t/usb-vid-pid-for-the-xiao-esp32-s3-and-xiao-esp32-s3-sense-for-circuitpython/272245/10 but either they don't understand, or they are not interested.
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
...
multitasking is so complicated
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
I have a new file server freenas.local. I can connect to it fine with Firefox and Chrome web browsers, but not with Safari browser. The server is announcing correctly on mDNS, as measured by Firefo...
To avoid issues with your internal corporate network, use a DNS name thatโs officially registered to your organization.
doesn't it work with cp-MAC.local but not circuitpython.local?
yes
and it works with espressif
timeouts and times-to-load vary between curl and safari, but results essentially similar
Moved from draft after creationid approved.
The storage module provides methods to enable or disable the usb drive, but there is nothing (that I can see) to query if it is already enabled or not. I'm trying to add a toggle for it, so knowing the state would be useful.
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.
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 ...
Also note:
https://esp32.com/viewtopic.php?t=30102#p104184
On the ESP32-S2 and newer chips, ADC can be used together with Wi-Fi, although usage by Wi-Fi has priority over the usage by software. So you may occasionally get an error code while getting an ADC sample, in which case you have to retry sampling.
Changes look fine. I did not test in any way.
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);
}
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?
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...
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 ...
@slender iron OrangeCrab port update: Board came yesterday. Today I mounted it to a universal plate for easier handling, did a smoke test, and started a github repo to document progress on my ECP5 RISC-V SoC quest. Repo is at https://github.com/samblenny/ocfpga
Yes I definitely got my arm twisted into installing git bash. OK OK it's installed.
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")
Nice!
Will look more tomorrow
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. :/
Having a string with "\r\n" is quite different than having an actual CRLF
In memory they would end up being
ord("\\"), ord("r")is something like33 45(2 bytes)ord("\r")would be a single one, lets say9
Or course i made up the numbers instead of looking at the ASCII table ๐
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.
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...
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.
Using ordinal values now, thank you.
Phone + video moving fast = no clue what you did
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
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.
Here's the final AutoLF.ps1 powershell script
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
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.
Re read my prev message and try to understand it, i guess
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?
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
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.
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
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.
No idea what you mean with format/powershell
But i hope you have a better understanding now ๐ค
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.
This is what i was replying to
Those scripts have something similar to this, dont they?
It's only the absolute basics at this point, but it does seem to successfully execute the test script on a device and report a Pass / Fail based on whether the output matches the expected results. https://github.com/FoamyGuy/CircuitPython_OnDevice_Testing
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.
Thanks! I'll merge this once Adafruit_Floppy sees the related PR merged, then I'll take care of the library third. I think that order makes more sense than anything else.
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...
looks cool, some feedback if you dont mind:
- could make
expectfileoptional and default it tof"{testfile}.exp" - dont mix the use of different logging utils (
printandclick.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
loggingto emit messages of different levels and filter them depending on how bad something has gone (...or some other utility that also provides such capability)
- i would probably use
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 ๐
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.
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
I definitely think some kind of summarized output would be necessary if it evolves to test multiple things.
or... could make the scriot stop as soon as a test fails, but i'd rather run everything and have full info
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.
f"{board}_{test}.err" sounds like a good idea for failing tests
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...
will try and do a couple things soon, dont start commiting changes ๐
I won't be touching anything on it until at least later tonight 8+ hrs likely.
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.nvmbut I know and usealarm.sleep_memory[0]as used in this project: https://learn.adafruit.com/adafruit-magtag-project-selectorSo 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
You can also check for a key being held down during reset rather than toggling
I do that too, but having a full on toggle like this is nice when I'm working on the firmware.
run_test looks pretty wild. I don't recognize any of that. Is that Python? Ahh requires discotool. Neat.
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 ๐
"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
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.
You are anything but lazy. ๐
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
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.
I usually just let it run automatically when I do a commit. It will check the changed files only.
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.
@slender iron https://github.com/adafruit/circuitpython/issues/8886 is on the 9.0.x. This is Have to Unplug / Re-Plug USB Host Keyboard. Are you awaiting something from TinyUSB? I'm not sure based on the comments. I could make a 9.0.3 - only fix is to nrf AnalogIn.
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.
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...
yes this is an irritation for me as well. Sometimes, if I get the same kinds of files in many repos, I'll add them to my personal, global gitignore files (editor backup files, for instance).
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.
my idea of doing a PR pretty much ended in a rewrite ๐
just run python ondevice_testing from root of the folder (note, havent tested it)
https://github.com/elpekenin/CircuitPython_OnDevice_Testing
TODO?: accept a single argument to point the code at another YAML file
A somewhat different testing thing I was working on but didn't take very far: https://github.com/dhalbert/Adafruit_CircuitPython_Port_Test
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.
that looks like some temporary problem
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.
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.
Ah, I do have git version 2.34.1 I'll try adding that ppa and update
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.
I just made an absolutely fresh clone of my repo and did make fetch-all-submodules, and it worked. hmm
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 ๐
are you using ssh or https for your fetches in general?
https I believe I clone the repo with a command like:
git clone https://github.com/adafruit/circuitpython.git
is there anything unusual in your ~/.gitconfig? Anything about protocol.file.allow?
https://www.githubstatus.com/ looks fine
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.
nothing about protocol.file.allow that I can tell:
โฏ cat ~/.gitconfig
[credential "https://github.com"]
helper =
helper = !/usr/bin/gh auth git-credential
[credential "https://gist.github.com"]
helper =
helper = !/usr/bin/gh auth git-credential
[user]
email = foamyguy@gmail.com
name = foamyguy
[core]
autocrlf = input
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.
I don't think hathach could reproduce it. I definitely still see it happening though
so maybe move to 9.x.x?
yup, that's fine
mine is pretty much a superset of that
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'
I don't have autocrlf = input, but that seems kinda irrelevant
is git-lfs installed?
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.
yep,
$ git-lfs --version
git-lfs/3.0.2 (GitHub; linux amd64; go 1.18.1)
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
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.
I have a ppa for that too
Ok, thanks for checking. Any idea if 8.x has the same issue?
I give out USB PIDs for open source software on third-party boards from https://pid.codes too. Make sure to link to your branch of CircuitPython with the changes.
we're definitely seeing a slight bug influx as folks move to 9
Is thonny started when this happens? Does it work ok with 8.2.x? Do you have anything else connected to the Pico W?
I agree, though I am seeing about half of them either be not an actual bug or not introduced in 9.0.x
I think that's a good thing. ๐
Ya, I think so too. I'm just thinking about my prioritization of work
Yeah a lot of user error reported issues out there ๐
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?
//| target_freq: Desired frequency for index.
//| """
//| ...
//|
STATIC mp_obj_t rp2clock_inputpin_make_new(const mp_obj_type_t *type, size_t n_args,
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.
//| def __init__(self) -> AuxSrc:
//| """Enum-like class to define the clock src."""
//| ...
//|
//| PLL_SYS: "AuxSrc Clock"
//| """Undivided PLL used to derive SYS clock."""
I think you can remove enable(), disable() and enabled too. Instead, folks can just use the constructor and deinit().
Two small doc fixes. (If I remember RST right.)
It isn't too bad to connect into CP internally. It should be doable.
It uses keypad demux to read the keyboard right?
Yeah that's it. I built a little table of all the possible keycodes.
You could make board_ variants of these weak functions: https://github.com/adafruit/circuitpython/blob/main/supervisor/shared/serial.c#L110-L131
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?
and then implement them in board.c
Oh I see what you mean.
keypad already works in the background. so you basically initialize it in board.c the same way you would from python
Um, what's the difference between port_serial_early_init and port_serial_init ?
I think early is before usb starts
So would I want to initialise it in the early version?
I'm a little worried if it's too early half the system will be in some kind of non-functional state.
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
No problem. I'll look through these shared bindings.
Is there possibly a preliminary sketch to look at regarding the INA228 library or learn guide?
@onyx hinge did you enable the panic handler in IRAM for protomatter?
that helped me debug protomatter
@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.
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
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?
yes, the constructor will construct the queue, as it would when invoked in CircuitPytyhon
Make weak versions in the file I linked to and a non-weak version in board.c
The board.c one will take precedence
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?
Correct. Add a board_ version just like there is a port_ version.
port_ is already used in esp for the internal usb to serial converter
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?
ya, you'll need to add it to serial_read (iirc) just like the port version
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.
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.
Draft competed. Ready for merge.
@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 ...
There is a flash make target you can use too
Make a PR. It is way easier to review
Fair enough. I'll probably submit the whole thing together. I'm getting any events yet though so still a WIP.
sounds good. if you have regular usb you can do mp_printf(&mp_plat_print, <format string>, <format arguments>) to print out stuff
Ah that might help.
you can also do a DEBUG=1 build and use a usb-to-serial converter on the output
that'll give you IDF logging
Is there any useful info in there?
only if you are interacting with the IDF or see other ESP_LOG statements you want to see
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?
You may need to prevent the pins from being reset
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
I'll give it a go.
I'm not sure when the reset happens. Is it after board/port_serial_init?
it does between every vm run
we're moving away from the bulk resets but not done yet
Doesn't seem to make much difference. I'll keep debugging I suppose.
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.
Ah, here it is:
https://github.com/adafruit/circuitpython/blob/50ad62d205c9f024ee037de48cb7110c47fe6260/main.c#L386
All keypads get deregistered at the end of a program. I'll have to add some kind of never_reset function.
Just having it on the pins doesn't help because the scanner is deregistered.
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.
Automated website update for release 9.0.3 by Blinka.
New boards:
- waveshare_rp2040_geek
Tried my best to combine them on latest commits.
Fixed on latest commit. Finaliser has to be forced with gc.collect() to free hardware resources.
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.
Instead of adding never_reset, the bulk reset should be removed and all of the keypads should have a finalizer to turn them off when the heap is deinit. It'll skip yours because it isn't on the heap.
- 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.
.deinit() is the way to turn it off immediately instead of waiting for the finalizer. Do you want to keep the pin "in use" even when it isn't active?
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...
Did you press reset when the neopixel is blinking blue? Or had you paired to the device already?
A couple functional questions. Thanks for cleaning this up!
This doesn't make sense to me. Shouldn't it be +?
I think you probably want to add these all together too because you can read them all.
Yes, I thought the second thing was a boolean, but it is not.
Aha, that makes sense -- I was not thinking of multiple available inputs.
Project idea: Build a Copilot key in CircuitPython (F23 seems supported... https://docs.circuitpython.org/projects/hid/en/5.1.1/api.html#adafruit_hid.keycode.Keycode.F23): https://arstechnica.com/gadgets/2024/04/shoehorned-windows-copilot-key-is-just-a-reprogrammable-macro-journalist-shows/
@tulip sleet trevor found a bug between uf2 0.8.2+ and cp
I think it impacts 8.2.x as well
This isn't a CP bug per se. It is an interaction between the nordic saved word code and the uf2 bootloader version 0.8.2+. 0.8.2 added a splash screen and it uses enough ram that it overwrites our uninitialized section.
@hathach We should coordinate a specific RAM address that the UF2 bootloader doesn't clear so that we can use it.
That's what a modern help button should do.
The project idea is for anybody to take, implement and document. I guess I know how to do it, but I have no clue how I would test that as I have no plan to use Copilote anytime soon. ๐
did you open an issue in the nrf5t2 bootloader or is that not necessary?
I didn't. I just pinged thach. For a moment I thought it'd only be a CP fix
In the next phase, I reduced the main() to basically this:
watchdog.timeout = ESTIMATED_RUN_TIME
watchdog.mode = WatchDogMode.RAISE
pixel = neopixel.NeoPixel(board.NEOPIXEL, 1)
logger.deb...
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. ...
@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.
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!
I'm not planning on doing reset/finalizers
I'm in the max3421 weeds now. it uses spi from an interrupt ๐
I'll start on the finalizers, not necessarily first thing. If I have questions I'll of course talk to you.
the mqtt while web workflow issue seems weird
Oddly I went to CP9 because I couldn't get it working with SSL and my MQTT server. Luckily though I backed up the board (yay esptool). I restored it and got it working with SSL and can say that no, using the WWF in CP8 does not display the same issue as CP9.
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.
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.
Ah crap... the _serial_bytes_available prototype just changed didn't it?
It is going to change in this PR: https://github.com/adafruit/circuitpython/pull/9141
Ah, that must of what I was thinking of.
Since the
commandpin can also be None and is not checked here, my understanding is that thecommon_hal_reset_pinwill 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.
checking for the interrupt char on, say, an ESP32, is done by scanning the UART interrupt fifo. See ports/espressif/supervisor/usb_serial_jtag.c. If it finds a char == mp_interrupt_char, it calls mp_sched_keyboard_interrupt().
maybe you could check for mp_interrupt_char in the routine that queues the keyboard presses for serial input?
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
you could conditionally compile something there for boards that are taking REPL input from a keypad. Or something could scan the event queue later, as the serial_jtag code I mentioned above does. It's not expensive to scan the keypad queue: it's not that long
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
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.
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...
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(...
๐ I wasn't complaining about the sleep, just explaining. I see what you mean about a callback now. I thought you meant a callback to Python, which is not a good idea in this context.
I didn't realize you had a PR open already. Thanks.
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.
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?
Okay, I did find this page: https://learn.adafruit.com/running-pyportal-code-on-blinka-with-displayio/running-examples that has displayio.FourWire in a code snippet. I did not think to seek out Blinka_DisplayIO guides seperately from core displayio ones when I went through learn guide code and pages recently so unless anyone else went through to update pages in guides for Blinka_DisplayIO there may be others that still have the old way showing.
Good point on .deinit(). Since it's a dedicated hardware pin, I think logically it should be use whether the clock is enabled or not. It's akin to driving a normal GPIO, you wouldn't want to release the object and create a new one just to change the value from low to high. The only difference is a high level puts out a clock.
Just curious, do all translations end up in every build regardless of the modules compiled in? I just assumed that these would only be pulled in when CIRCUITPY_RP2CLOCK=1. I can make the messages more generic to reuse them but we'd lose some information.
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?
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.
7" ESP32S3 Tablet. 16MB Flash, 8MB PSRAM. RGB565 Display, touch and SD card.
I promise this is my last Sunton ESP32 device for a while ๐
Please open an issue about this. It does sound like a bug.
sure, no problem. what's the proper repository to raise the issue?
https://github.com/adafruit/circuitpython because even though it fails in wiznet, I don't thin the library is the issue.
Supervisor changes look good! A couple other things. You can add a private API to keypad for other C modules to register callbacks if you like. That way you could map immediately and raise ctrl-c if needed.
You'll need this even if we switch keypads to finalizers because pins are still bulk reset.
@dhalbert Couldn't we switch this to using a finalizer instead?
Only translations for enabled modules are included. I assume we'll have RP2CLOCK enabled for all RP2040 boards where it'll fit. Striking the generic vs specific balance can be tricky.
Ok, then you can leave the .enabled property but make it writable instead of having enable() and disable() functions. I'll mark the spot with a pointer to an example.
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...
Make this settable instead of having enable() and disable().
Thanks for the responses. I've made more specific suggestions.
I'd suggest just using https://github.com/adafruit/circuitpython/blob/8027efe24575fd4cfce0409c890348580ea291d2/shared-bindings/microcontroller/Pin.h#L45 because the pin names will vary per-board and the pin number may not be obvious.
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...
As you mentioned, since displayio is a separate library with Blinka, they can just go back to a previous version. It's more integrated with CP, so that's a bit trickier.
@lone axle @tulip sleet, so, I think leaving the Blinka_Displayio lib as is for now is the correct move.
Debugging note: check tasks that are doing select on sockets
Research this in esp-idf issues. See if increasing our buffer size would help.
I don't have the hardware but did look over the schematics.
ugh, I don't have this review process down yet. I lost my comments..... :frowning: I'll post them again :/
Hopefully I don't loose them this time :grin:
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 ...
// I2S/Speaker (P6) pins
{ MP_ROM_QSTR(MP_QSTR_I2S_BIT_CLOCK), MP_ROM_PTR(&pin_GPIO0) },
{ MP_ROM_QSTR(MP_QSTR_I2S_WORD_SELECT), MP_ROM_PTR(&pin_GPIO18) },
{ MP_ROM_QSTR(MP_QSTR_I2S_DATA), MP_ROM_PTR(&pin_GPIO17) },
It looks like there is I2S audio support for connector P6 on thses pins.
I have added definitions for those pins for i2s usage. It doesn't appear as if the i2c touch sensor (the capacitive one, which I have) has any issue with utilizing pins 19/20. I agree that it looks like 17/18 would be good candidates for i2c, but attempting to use them results in an in use error, I'm guessing due to the i2s amplifier keeping them active.
ugh.. I've messed up the PR..
Second attempt. I'll try not to mess the PR up, this time.
Yea the USB conflict probably only affects the resisitve touch screen. The I2S conflict is a good guess for the the "use error" but I'd also be surprised if attempting to use the I2C bus over pins 19&20 worked, I'd expect some sort of resource in use error from that as well.
the resistive is spi, the capacitive (the one I have) uses i2c on 19/20 and it works as far as I can tell. touches register, no errors..
hmm, have you tested the touch detection in CircuitPython? I'm really shocked that it works.
I tested display, wifi, web workflow, and sd card. All looks good to me.
Note that I have created a fresh PR for this, as I merged things I shouldn't have mid PR.. Please continue the conversation over there
I tested display, wifi, web workflow, and sd card. All looks good to me.
Nice! If you have the capacitive touch, could you load these two files and try running the GT911Demo.py program?
https://github.com/RetiredWizard/PyDOS_virtkeyboard/blob/main/GT911demo.py
https://github.com/RetiredWizard/PyDOS_virtkeyboard/blob/main/lib/gt911_touch.py
Those two file are how I know it worked.
[{'id': 0, 'y': 320, 'x': 502}]
[{'id': 0, 'y': 299, 'x': 326}]
[{'id': 0, 'y': 89, 'x': 446}]
[{'id': 0, 'y': 235, 'x': 245}]
I don't understand how the touch screen is working but all's well I guess. I worked on the makerfabs tt7 display board which shared the USB pins with I2S audio and the pins gave resource errors unless the firmware was built with USB disabled.....
I don't have the hardware to test but I looked over the schematics and the only issue I saw doesn't appear to be a problem when tested on the hardware.
I may have to try building the makerfabs board with the I2S audio to see if it works now ๐คท
I guess that makes sense. I was able to implement this method, but there is a lot of repeated code for each argument. What would be an idiomatic approach for getting rid of the repetitions?
Ahh, You have CIRCUITPY_USB = 0 in mpconfigboard.mk. That's why you're not seeing the conflict. Wouldn't that shuts down the CIRCUITPY drive doesn't it? Does the device enumerate a USB port on the host machine?
The USB port is hooked to a USB TTL, not to the native USB pins on the S3. Seems an odd choice on the part of the manufacturer, but it is what it is.
Cool, so does the CIRCUITPY drive still work over USB TTL?
Unfortunately not, and as you said, you'd have a choice of either touch or usb drive.
Well now that there's Web Workflow it's actually not a terrible trade-off to get a few more GPIO pins :grin:. I wish Makerfabs had done that with their version....
A hew page in https://learn.adafruit.com/how-to-add-a-new-board-to-circuitpython about pin name conventions is in progress. Closing this as resolved by that.
Do you have a specific way of doing callbacks, or can I just pass a function pointer?
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...
I don't really understand how finalisers work, is there any example I could use?
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...
We merge regularly from MicroPython upstream, and plan to PR some internal changes upstream (which are mostly conveniences for the developers).
We have turned off threading and visible support for interrupts in Python, for reasons given here: https://learn.adafruit.com/cooperative-multitasking-in-circuitpython-with-asyncio#faq-3106700. However, the support is still latently there.
No special callback techniques. Just define a type for the callback and then declare the routine with it.
Thanks! The callback seems to be working now, Ctrl-C on the board's keypad can now interrupt a running program.
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.
All in the pull request. https://github.com/adafruit/circuitpython/pull/9145
Though it still seems to have a conflict with serial.c that I'm not sure how to resolve.
I guess that makes sense. I was able to implement this method, but there is a lot of repeated code for each argument. What would be an idiomatic approach for getting rid of the repetitions?
You could just factor the repeated code into a static helper routine that takes two arguments, the input name and where to put it.
I tried to do that, but failed. CircuitPython will always fall back to the default values. I guess something is wrong with all this pointer magic, but I have no clue how to properly debug the code.
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
I am recovering the ae9197b1604b6fc27b89f64e1f00cfb4c3f492c4 change before the refactoring I requested, and will try to fix this up on your fork branch.
The (first/) macOS 14.5 beta is out. I upgraded, and realized I should have taken a baseline before upgrading. @romkey have you tried that beta yet? Thanks.
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...
There aren't any artifacts for this (probably because of the rebasing conflict) but I manually merged the changes on a local build and it seems to be working well.
for newly merged Sunton 7" board.
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...
oh jeez.. now i've made work..
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? ...
Were the graphic displays you posted generated by CircuitPython code? If so, posting the actual CircuitPython code you used would be very helpful.
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...
I wonder if the issue is that yours, unlike mine, is coming up with the screen in portrait on boot, for some reason, but circuitpython is trying to talk to it in landscape. Hence why a 240x240 pixel portion of the screen works, where the real screen and virtual screen overlap
I had to add some of the board_ prototypes back in hopefully that settles it!
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.
There's probably a way to init the display with the correct init string using Python. So you would start by throwing away the board display (displayio.release_displays()) and then create a new display object using the displayio/fourwire builtin libraries.
I am only testing that for educational reasons as the $2 price might also draw others to the same deal . I will try to document what changes is done in each firmware stating with openHASP and tasmota .
I am now facing issues serial flashing the HW as my PC rebooted twice so might be a while but never the less i will keep trying
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...
Thank you guys , i will surly try whatever possible .
I have managed to setup the display correctly with openHASP using a bin marked ili9342 driver
Not sure there is CircuitPython ili9342 driver ( i see only ili9341 ) but i will try the command listed by @RetiredWizard with ili9341 and any other driver that is available
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.
- Fixed/Updated store URLs
- Updated info on Antennas
- Added more info for TinyWATCH S3
Interestingly, out of curiosity I set the init variable to an empty string "", and the display still came up fine after running my displayio.release_displays() script from above. I'm guessing that means the display doesn't reset it's initialization when the displayio.release_displays() command is executed.
@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 .
- 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
@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)
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...
if you have any idea on how to fix that also then please let me know
If you point me to where you found the LVGL_320_240.bmp file, I'll load it up and see if the colors look better.
I could not add it here but it is just a bmp ( 24 bit bitmap ) file i made with paint to calibrate the display , the same way worked with TTGO display
If you just load a picture with green , red and blue then that would do the same
This is a colourspace issue. Do:
display = adafruit_ili9341.ILI9341(bus,width=240,height=320,backlight_pin=board.LCD_BCKL, invert=True)
The invert=true should put you in the right colorspace.
Adding invert=true give me TypeError: unexpected keyword argument 'invert'
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...
Yes, it's something about being in BGR when it expects RGB, or vice versa. The reds are blues and the blues are reds.
Unfortunately, it looks to me like the colorspace that works on my version is RGB888 and for some reason there is no BGR888 :frowning_face:
You can change the BGR/RGB in, again, MADCTL, in the init sequence :D
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

@RetiredWizard sure i will try the new adafruit_ili9341.mpy
We should probably take this to the Discord Circuitpython help channel and create a thread though, I'm not sure how much noise this is going to generate for the Adafruit folks as an issue.
@proven garnet hi, could you add adabot as a maintainer to https://readthedocs.org/projects/circuitpython-nau7802/. Otherwise I can't add a readthedocs hook. Thanks. Not urgent.
@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...
Invitation sent!
thanks!
@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
USB-serial converters don't need to literally send XON/XOFF in-band, usually, because they are able just to stall the USB transfer to do flow control. However, that is apparently not enabled or something on these C3 builds. I haven't looked at the code yet.
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? ๐
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?
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.
Also, I keep wondering whether the operating system could simply reset itself upon encountering the internal watchdog timeout, like many conventional OSes do.
I've been using a SQFMI Watchy board for a while so I thought I might add CircuitPython support to it.
Website: https://watchy.sqfmi.com/
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"...
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. ๐
So does it have to be your project? Or can I request a VID and PID for this board I find myself with?
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.
No, it is a branded board with a website.
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.
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.
ohh I'm sorry I misunderstood.
It's an ESP32 with no extra digits, so no "native USB".
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.
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.
Is it documented in the "how to submit a new board" learn guide?
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.
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.
Yeah, so I will need to submit some kind of request for IDs to that repo.
Yep, should be straight forward.
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.
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.
So as far as I can tell I just have to add a pull request to that repo. Looks easy enough.
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.
Thank you for the assistance and the quick feedback on this PR!
Oh well, submitted a pull request. So if any maintainer asks where my ID numbers come from I'll just direct them there.
Thonny is started, Haven't tried it with 8.2x. It's a barebones Pico W. Only happens on startup, after the issue, when the repl starts CTRL+D or the run button on thonny works fine.
The creator/creation ID's are our own invention to distinguish boards that can't have unique USB VID/PIDs. If the mfr has their own USB VID, you can use that in the creator id. the creation id might be the part # or some other mnemonic number
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"
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...
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
#...
I was just scratching my head over this in 9.0.2 and was about to try 8.x then found this!
Digital inputs are kaput too https://github.com/adafruit/circuitpython/issues/9154
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..
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 ๐คฏ
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.
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
CircuitPython uses the float hardware at 32 bits. It just gets truncated when it gets stored back. Is it clear the Arduino program was using the floating-point hardware?
and CPy has all the interpretation overhead.
or were you using double in Arduino?
I tried float and double to see if it made a difference in execution time. It did not.
is your code available somewhere?
There's something really odd going on here. Use of a digital pin gives the expected values if it was not previously used as an analog pin. I'm looking into this.
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")```
The k += 1 is not needed. It's not messing up the loop, but it's not doing anything useful.
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.
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
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="")
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..
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)]".
I corrected the title, thanks.
Yes, I wasn't sure about that either, but I tested and k gets reset by the for.
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.
Ahh, I see this was discussed here: https://github.com/adafruit/circuitpython-build-tools/issues/28
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
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...
that is a great idea
Certainly, but is there other stuff first? Is the PR blocked if it's not a finalizer yet?
@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.
If I could get some advice on implementing one of these finalizers that would be great.
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...
over the weekend i noticed that bitmapfilter isn't available on the matrixportal s3. is that because it would make the build too big?
it might or might not. I think it was originally targeted for boards with cameras or that you might want to use with cameras. I will see if it was there and then removed.
... yes, it's added automatically for boards with cameras, and not otherwise. but you have a use for doing bitmapfilter on the matrix image?
@tulip sleet i'd been looking at todbot's generative graphics experiments (https://gist.github.com/todbot/5b649b0ff314f2e723b6dd68d36c05b5) and wanted to try them out on a matrix ๐บ
I haven't yet, but will eventually use it on devices without cameras as well. For processing bitmaps to show with displayio.
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
maybe any that have bitmaptools enabled is a good deleniation?
the matrixportal did have bitmaptools
i'm doing space-check builds now
that sounds like a good dependency
6.3k bytes
jpegio depends on bitmaptools
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?
we might have had one mfr not want that, I can't remember why, but we would strongly advise against it, since the display is very useful to show errors, etc.
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..
these are third-party boards?
I think it was @empty salmon because he didn't want his e-ink display to wear off by showing errors
yes, third party.. e-ink makes sense..
thanks for remembering that
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.
@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
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.
are they not in the CI log?
you should be able to run the tests locally. That would save a lot of pushing to github
I don't see them in there anywher. I added this commit with a print statement: https://github.com/adafruit/circup/pull/208/commits/30e80f34867a659ced2c0ea2477b51027fd04873 but I do not see any of it's outputs in this log: https://github.com/adafruit/circup/actions/runs/8602027315/job/23570604472 I even searched "checking dir" in the search logs input near the top right and it shows no results.
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
thanks!
bitmapfilter is useful for display output as well as for camera image processing. @BlitzCityDIY would like to try it on the Matrix Portal S3. @FoamyGuy suggested enabling it if bitmaptools is enabled. This PR does that.
FYI, in terms of space, bitmaptools takes about 12kB, and bitmapfilter takes about 6kB.
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 :/
does it make any sense to print to stderr?
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.
maybe this can help https://docs.pytest.org/en/stable/how-to/capture-warnings.html I just noticed it's linked in the output showing in the actions log.
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)
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.
@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.
yeah, read that backwards. oops
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 ๐
)
Note that the tests are being run with Python 3.7. If you are not using that locally there may be an environment mismatch
oof, that is definitely the case then. I am on py 3.10 locally.
some testing dependency is too old, etc.
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.
3.7 was chosen to help support old Macs or something. It reached end of life in june 2023
there is a tool i have barely used that lets you "run"(quoted as in: probably not 100% equivalent) github actions locally, its called act
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
๐ 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.
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
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.
doesn't seem likje you've change lib_dir either, which is pretty much the only thing happening there ๐ค
instead of printing you could raise exceptions or whatever the current test is doing and put some stuff in the exception messages
...maybe the self.dir string "template" is now looking at some other folder (due to some environment changes), which happens to exist
or maybe you created some folder that matches the outputs that you are getting from that template, also making the check return a True now
raising an exception instead of printing causes pylint to fail with "unreachable code" ๐ซ
I believe the Makerfabs 7" (and the ESP32-S3 Hacktablet) were test cases along with the Qualia board for "Dot Clock" displays. While the Qualia board doesn't have an attached display, I suspect that it was easier to test the other two from Python and no one ever got around to moving the display init to board.c when development finished.
There's no time like the present, if you have the hardware ๐
Neither has much of a user base, but I suppose they could serve as examples.
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.
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
yep, I'm thinking this is the case. I'm not sure why the difference in mine locally and the container. But I'm guessing something about one of the other mock.patch's used isn't having the same effect.
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.
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
I'm pretty sure it's trying to spoof the tag anyhow with this line https://github.com/FoamyGuy/circup/blob/refactoring_and_issue_fixes/tests/test_circup.py#L997 and 1008 a bit below here. So it should be using the fake tag which doesn't match any on the real repo.
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
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.
The Makerfabs_tft7 firmware actually supports two display options and probably isn't worth two versions of the firmware. I'll check it out on the hacktablet though ๐
It did indeed turn out that I just made a false assumption about the conditions which led to the print statements not executing... When they are moved into a branch of the logic that does execute they do in-fact get printed into the github actions log https://github.com/adafruit/circup/actions/runs/8603223248/job/23574622787#step:12:43 ๐คฆ At least now I know.
updates remaining action that needed update to Node.js 20. See https://github.com/peaceiris/actions-gh-pages/issues/1070.
<@&356864093652516868> Excited to see you all in an hour for our community meeting. Notes doc is here: https://docs.google.com/document/d/1_cpbdNujG6Gb6YB18n2v94Jqyz09h4yPsyiRRcy9tgk/edit?usp=sharing
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.
Have a good meeting โ Iโll be out for the eclipse. See you next week.
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.
Costa Rica as well, just partial here.
It's always a plus when you can see what you're soldering
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.
circuit jupyter would be so cool.
There is a playground note on connection manager from Justin.
Does watching NASA live stream count as an excuse?
always
is that a thing? link?
https://www.youtube.com/watch?v=2MJY_ptQW1o It's in total eclipse right now and there's a screaming crowd lol.
in dallas
Good to merge when the selections are finalized
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
Thanks for adding this! Just a few comments to address.
Please don't add more frozen libraries unless you need them to free up RAM. Libraries outside of the image are much easier to update.
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)
tested on matrixportal s3 and it is working ๐
Good to merge when the selections are finalized
@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
We are thinking about doing this internally. Will let you know.
This simply initializes the display on the HackTablet so it doesn't have to be done with python code.
I could not find 9.0.3 on the web. I tried latest 'Adafruit CircuitPython 9.1.0-beta.0-18-gf4dfd5f119 on 2024-04-08; M5Stack CoreS3 with ESP32S3', got the same error 'espidf.IDFError: Requested resource not found'.
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...
Saving RAM is the intent of freezing these libraries, I've only frozen fairly stable libraries required by the hardware; but if you require me to take out the frozen libraries I will.
I just added in a little extra code to get the OPT modifier on the keyboard to produce a unique keycode when pressed with another key.
FN, Shift, Ctrl, Opt, and Alt... they sure have a lot of modifiers for one little keyboard.
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
Please try call gc.collect(). MicroPython and CircuitPython use mark/sweep garbage collection, not reference counting like CPython. So no garbage is collected until a threshold is reached.
The REPL saves a small amount of command history. That will use up objects.
Are you comparing with what you saw in 8.x.x?
This board was added recently, only to main, so there is no 9.0.x release for it.
This problem may also affect ExFAT. See this discussion at AppleInsider: https://forums.appleinsider.com/discussion/235967
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. ๐ค
Are you saving ram preemptively or did you have demo code already need this? I'd rather only add it when it is needed.
@dhalbert sorry for the slow response, been deep in some other stuff. Comparing a 14.4.1 Mac with a 14.5 beta Mac, the 14.5 beta Mac is faster but still very slow (38 seconds to copy 24 files on 14.4.1, 18 seconds to copy the same files on 14.5 beta)
@tulip sleet the nrf bootloader only sets aside 32k for the SD
so it will use the RAM right after that for its own purposes, hunh? OK, then, I guess it's NO_INIT>
noinit is at the top of that 32k
ack, well, if you smash our SD RAM in the middle, does it matter, becuase you're going to the bootloader immediately?
that's what I'm thinking
is this to communicate to the bootloader, or the other way?
it's to communicate to ourselves on startup
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
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
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
testing it now
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.
Thanks! Glad there was a way out without any bootloader changes.
The last word on this is that it's turned on with boards with displayio and >4MB flash, more or less. Otherwise there are many boards it can't fit on. It is on for MatrixPortal S3.
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.
Fixes wo problems:
- SAADC input channels should be disconnected after SAADC is used, which fixes #9154.
- Regression in 9.0.3: SAADC may return (slightly) negative values when pin is at ground. I took out the logic for that in #9114, not realizing that the SAADC API returns an
int16_t, not auint16_t.
This means a 9.0.4 release will be done.
Should we backport this to 9.0.x? I am going to do a 9.0.4.
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:
...
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...
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...
What kind of host computer are you using and what is its version of its OS? There are issues with macOS Sonoma.
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...
I see -- so to send the coordinate 479 (= 0x1df) it is necessary to send 0x00 0x01 0x00 0xdf, with CS changes at various times? :exploding_head:
Yes. The two SPI4W_Write_Byte calls push the 2 bytes to the shift register which sends the 16-bit word to the chip. The actual display data is not mangled in this way.
Note: A0 pin on ItsyBitsyt M4 has a DAC, so no PWM is involved.
We use a TC timer internally to time the DAC conversions. That timer is not being released properly, because there is no finalizer that runs when the AudioOut is gc'd. This fix would be part of #8960.
In the meantime you should be able to work around this (if it's a blocker for you), by calling .deinit() on the AudioOut when the program finishes.
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.
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...
minimp3 is Creative Commons CC0. That is even more permissive than the MIT license we use.
- The CIRCUITPY drive becomes unresponsive, the board's USB breaks, it glitches other USB devices, etc.
This can happen if CP hangs and stops running the USB task. Definitely a severe bug.
Should we backport this to 9.0.x? I am going to do a 9.0.4.
Ya, I think it is easy enough to do.
are PR states only open, closed, and merged? are there other possible states, draft perhaps?
It is enabled on:
- SAMD51 boards with 1MB flash (SKU ending in 20A)
- Feather RP2040 DVI. Others have PIO usb host.
- All ESP32 boards.
- All nRF boards
Fixes #8676
- Fixes #9158.
Use finalizer for atmel-samd AudioOut objects. Move audioio_reset() logic to _deinit(). Also use existing routine to search for a free TC timer.
No other port supports audioio.AudioOut. There was an unused mention in the i.mX port.
Ya, I think that's enough reason.
Looks good. Will wait to hear if you want to freeze more.
Would it be possible to extend busio.UART with a read_until() method as provided by PySerial? Or simply add an optional separator argument to the readline() method?
In principle, it would not be too hard. However, it is pretty easily done in Python: https://github.com/pyserial/pyserial/blob/7aeea35429d15f3eefed10bbb659674638903e3a/serial/serialutil.py#L664. busio.UART exists even on the smallest boards, so adding more code uses up firmware space that we might use for functionality that cannot easily be done in Python.
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...
@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...
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. ๐
achievement unlocked
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.
The option to show whitespace works good for me
And git diff showing everything red helps too
This looks fine structurally. I didn't test with a MAX3421E. Thanks!
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.
The newest bundle release 20240411 is the first one built with the examples separated out into sub-directories for each library. ๐
Thank you @lone axle !
@tannewt Just a guess, but I am wondering if this is due to allocate_ram_cache() in supervisor/external_flash.c being unable to allocate cache space. There are fallback actions, but maybe something is not working right. I should spin up a debug build and see if I can catch the hang.
Since you setup the UART already, try setting CIRCUITPY_DEBUG_TINYUSB to 3. That will log USB activity from the device side.
@tulip sleet you should factor out that caching logic while you are in there ๐
maybe ๐ I just got it working with a minimal set of changes
my changes are in supervisor/shared right now anyway
๐
are blocks allocated by port_malloc zeroed out when allocated?
no, I don't think so
Sure thing, here's the output of the terminal with that option enabled. This one crashed real quick - usually it takes a couple seconds.
minicom.txt
Here's one that took an average amount of time:
minicom.txt
- 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...
@raquo Thank you very much for the "always fails" test program. That was very helpful in debugging and in testing my fixes.
@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.
Does anyone have a simpler reproduction case that involves just pasting into the REPL or similar, and not using a file manager? I tried pasting long lines, and they seem fine with 9.0.3 on the QT Py ESP32-S3.
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.
did you make a PR to the circuitpython-org repo?
Ah, no problem. Will do.
There is a guide for that: https://learn.adafruit.com/how-to-add-a-new-board-to-the-circuitpython-org-website
Did you mean ESP32-S3? I think this issue shows up on chips that don't support the Circuitpy drive, i.e. ESP32, ESP32-C3, ESP32-C6.
Did you mean ESP32-S3? I think this issue shows up on chips that don't support the Circuitpy drive, i.e. ESP32, ESP32-C3, ESP32-C6.
No, sorry, that was a typo, and is fixed to C3.
For me, plain ESP32 has been rock solid. I have only had issues on ESP-Cx.
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'...
The USB-serial-jtag peripheral on the C3/C6 seems to have almost no configurable options. The doc seems to imply it will do USB stalling until its FIFO is read: https://docs.espressif.com/projects/esp-idf/en/stable/esp32c3/api-guides/usb-serial-jtag-console.html#data-buffering. But that is a rather high-level description of what is going on.
@dhalbert My pleasure, thank you for the fixes! :)
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?
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.
Chapter 30 in https://www.espressif.com/sites/default/files/documentation/esp32-c3_technical_reference_manual_en.pdf describes the peripheral. It is fairly autonomous in what it does.
Hey folks - Question re the "Serial JTAG" speed of ESP32-C3 and C6 in CP. Is this set somewhere in code?
it's USB, so there's no "speed", right?. It delivers bytes on the internal side. It doesn't expose a UART-like thing on the internal side with speed considerations.
esp-idf/components/hal/esp32c3/include/hal/usb_serial_jtag_ll.h
Ok, so it's just running at max USB full speed? 12 Mbit ?
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.
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
Yeah, I found that in the datasheet, but I assume "download mode" on an S3 would be also using the serial jtag peripheral, and that can erase_flash WAY faster.
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.
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?
I'll give that a try. I've never really grok'd the no_stub thing tbh.
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
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.
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?
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 !
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
Nope! A fatal error occurred: ESP32-C3 ROM does not support function erase_flash.
I tried an Espressif C3 dev board, which has a USB-serial chip (! I guess for completeness so you can test the USB peripheral seprately). It appears to have 4MB flash, and took 22.5 secs to erase
so this seems inherent to the C3/C6
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.
I tried 921600 and the erase speed is just about the same
Yup, ok, so the speed is what it is! Thanks for testing this Dan, it's much appreciated.
loading circuitpython on that dev board at 921600 takes 24 seconds
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...
I shouldn't have put that there.
SW resets now started sending the board to tinyuf2.
I am not sure what change prompted this behavior.
Pressing BOOT to enter safe mode works fine.
Some boards have an RC circuit on a spare pin as a hardware double-tap detector. But not all do.
Thanks for the fix!
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?
no, you have to set up the ADC, etc. If the SDK (is this pico?) provides it, you could call a driver it provides. Or you could instantiate an AnalogIn object, fetch the value, and then deinit it.
Yes, RP2040. OK
simple ADC read in pico: https://github.com/raspberrypi/pico-examples/blob/master/adc/hello_adc/hello_adc.c
@tulip sleet - thanks! that was the pointer I hwas hoping for. Now I have found examples to work from.
pico-examples is a great repo to get started on things
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...
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?
@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.
thats what I thought.. thanks for the sanity check
Looks like the crash is in a similar place. Unfortunately it doesn't show exactly where. A debugger would allow to you to catch the hard fault and (hopefully) get a backtrace. It'll be hard for me to reproduce if it requires your specific kvm.
Looks good! Thanks!
Did you find this code in any ports//supervisor/internal_flash.c?
Did you find this code in any
ports/<port>/supervisor/internal_flash.c?
I didn't look. I will!
CircuitPython version
Adafruit CircuitPython 9.0.0 on 2024-03-19; Waveshare RP2040-Zero with rp2040
Code/REPL
import adafruit_tca9548a
import board
import busio ...
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...
@tulip sleet , @stuck elbow - circling back regarding the board detection solution.
- The voltage divider trick is working well to compute a value (0 .. 9)
- The code sample for adding a function to the board (eg board.FOO()) is working
- The user can get the value if they should want it. For most cases, the user doesn't care.
- 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!
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...
@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
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. ๐
Is it possible to include a FROZEN library (e.g. adafruit_bitmap_font) in firmware which is not currently in the $(TOP)/frozen/ folder?
@empty salmon no, any change to freeze in a new library would have to add the related submodule in frozen.
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.
Please submit bug reports here: https://github.com/adafruit/circuitpython/issues/new/choose Bug reports are definitely appreciated!
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...
anyone feeling generous, point me in the right direction... I was trying to get a debug build of main branch, for the adafruit_feather_esp32s2, but it's over max dram size, looks like it's included camera support, so can I turn that off and get past the error?
https://github.com/adafruit/circuitpython/actions/runs/8674507461/job/23786891435#step:10:1076
yes, turning off some features you don't need is usually the way to get a successful debug build. I'd write it in the board/<boardname>/mpconfig.mk, then make clean, then make. ulab is another one to turn off that uses quite a bit of flash.
can I do that with a build flag, I'm using the custom board build action in GH, so is it something like CIRCUITPY_CAMERA=0
yeah I'd try putting in that Flags: line
Hey folks,. I am getting a _bleio problem on HUZZA32 Feather board. Is there a workaround?
https://forums.adafruit.com/viewtopic.php?p=1011498#p1011498