#circuitpython-dev

1 messages · Page 43 of 1

serene token
#

Alright, I can do that myself then. Thanks again!

onyx hinge
#

oh not sure if the guide mentions it but you have to make BOARD=... clean after changing .mk files, the changes are not automatically detected (or may be partially applied)

serene token
#

Oh, that makes sense. I'll remember that!

#

Ok, question:

https://github.com/adafruit/circuitpython/commit/c37f021791ec3d9afc8ba34445e9fb0d4eb4d211#diff-41abcabf710c7ca2d7aec7c1ad58e4bb1207f30dd57c255e83a260746ecf1432

A handful of the settings were removed in this commit. This includes the CIRCUITPY_ROTARYIO = 1. I've added it back and set it to 0, but that makes me think there are some kind of defaults not included in the file that might make it hard for me to know what I can remove. I don't know if you might know anything about this, but it's a point of confusion/concern for me.

slender iron
#

that way you can see what they are all set to

serene token
#

Oh cool! That definitely helps. Thanks!

stuck elbow
#

I'm trying to compile one of my own boards with some frozen py files, and I'm getting:

MKMANIFEST ../../frozen/circuitpython-stage/pewpew_pi
(cd build-ugame22/frozen_mpy && find * -name \*.py -exec printf 'freeze_as_mpy("frozen_mpy", "%s")\n' {} \; )> build-ugame22/manifest.py.tmp && mv -f build-ugame22/manifest.py.tmp build-ugame22/manifest.py
MPY pew.py
MPY stage.py
MPY ugame.py
GEN build-ugame22/frozen_content.c
build-ugame22/stage2.c:128:16: error: 'read_flash_sreg' defined but not used [-Werror=unused-function]
  128 | static uint8_t read_flash_sreg(uint8_t status_command) {
      |    

anybody has any idea what changed?

#

I never defined or used such a function in my code

onyx hinge
stuck elbow
#

that is after make clean

onyx hinge
#

what flash chip?

stuck elbow
#

W25Q16JVxM

onyx hinge
#

I bet there's a bug in stage2.c.jinja. the function read_flash_sreg shouldn't be generated if not quad_ok

stuck elbow
#

it is a qspi chip

onyx hinge
#

OK, just guessing here

stuck elbow
#

how do you update port's submodules again?

#

it's not showing in help

onyx hinge
#

I use git submodule update --recursive but I'm not sure if that's the official advice

#

can you post the full content of the generated stage2.c in the build directory?

stuck elbow
#

ah, fetch-port-submodules

onyx hinge
#

OK I do get that problem if I change the flash chip to W25Q16JVxM

stuck elbow
#

serves me right for not submitting that board definition

#

I thought this has something to do with my library called stage

onyx hinge
#

I think the template is concluding that there is no register to set to enable quad spi access, so it never uses that register read function, which causes the fatal error

#

so it would make sense to fix that, by NOT defining the functions if they are not used. but from what you said, it's not correct that this chip should be treated as not quad SPI

#

so there may be a bug in nvm.toml or cascadetoml?

stuck elbow
#

but the mini_sam_m4 and datalore_ip_m4 boards also use the same chip?

onyx hinge
#

this stage2.c.jinja thing is only for rp2040

#

it prepares the 256 bytes at the start of the flash chip that function as the 2nd stage bootloader. it configures the flash chip and XIP before starting the main application (circuitpython)

stuck elbow
#

The W25Q16JV supports Quad SPI operation when using instructions such as “Fast Read Quad Output
(6Bh)”, and “Fast Read Quad I/O (EBh). These instructions allow data to be transferred to or from the device
four to six times the rate of ordinary Serial Flash. When using Quad SPI instructions, the DI and DO pins
become bidirectional IO0 and IO1, with the additional I/O pins: IO2, IO3.

manic glacierBOT
#

This doesn't reset the current directory until code.py is run, after. The current directory should probably be reset for boot.py, safemode.py, and code.py. So I think it should be reset in start_mp(). Or should it not be reset between boot.py and code.py? That's something to ponder, about whether to make boot.py be able to change the current directory in a sticky way.

Also, if the filesystem is not working, I think chdir() may throw an error. Maybe better to check with ...

onyx hinge
#
diff --git a/ports/raspberrypi/stage2.c.jinja b/ports/raspberrypi/stage2.c.jinja
index 4c001525dc..ee6f3bac21 100644
--- a/ports/raspberrypi/stage2.c.jinja
+++ b/ports/raspberrypi/stage2.c.jinja
@@ -36,7 +36,10 @@
 
 #define SREG_DATA 0x02
 
+// If !quad_ok, these functions are not used.
+__attribute__((unused))
 static uint32_t wait_and_read(uint8_t);
+__attribute__((unused))
 static uint8_t read_flash_sreg(uint8_t status_command);
 
 // This function is use by the bootloader to enable the XIP flash. It is also
```Adding these tells the compiler it's OK if the functions are not used and lets compilation continue
stuck elbow
#

nothing about any registers, though

onyx hinge
#

@slender iron ^^^ do you have some wisdom about this? I know you had all this info in your head at one time

stuck elbow
#

I'm worried that they should be used, but the chip definition lacks the register number or something like that

onyx hinge
#
    quad_enable_bit_mask = all_match(flashes["nvm"], "quad_enable_bit_mask")
```there has to be a `quad_enable_status_byte` and `_bit_mask`.
stuck elbow
#

The Quad Enable (QE) bit is a non-volatile read/write bit in the status register (S9) that allows Quad SPI
operation. When the QE bit is set to a 0 state (factory default for part numbers with ordering options “IM”),
the /WP pin and /HOLD are enabled. When the QE bit is set to a 1(factory default for Quad Enabled part
numbers with ordering option “IQ”), the Quad IO2 and IO3 pins are enabled, and /WP and /HOLD functions
are disabled.

#

but I'm not sure what is the register number?

#

2?

onyx hinge
#
quad_enable_bit_mask = 0x02
```nvm.toml indeed lacks the register number.
stuck elbow
#

but it's there:

# Settings for the Winbond W25Q128JV-PM 16MiB SPI flash. Note that JV-IM has a different .memory_type (0x70)
# Datasheet: https://www.winbond.com/resource-files/w25q128jv%20revf%2003272018%20plus.pdf
total_size = 0x1000000 # 16 MiB
start_up_time_us = 5000
memory_type = 0x70
capacity = 0x18
max_clock_speed_mhz = 133
quad_enable_status_byte = 2
quad_enable_bit_mask = 0x02
write_status_register_split = true
01_continuous_status_write = true
6b_quad_read = true
32_qspi_write = true
#

ah, that's the 128. sorry

#

ok, adding quad_enable_status_byte = 2 makes it compile and work on my device

onyx hinge
#

at least that's good information that the correct value is probably 2.

onyx hinge
#

that 2nd PR could just be the one for adding the board, if you choose to do that.

manic glacierBOT
#

There is no way to change the directory before boot.py runs, so I don't think there is a need to reset it there. Also, start_mp only runs once at the beginning, but the nature of the problem comes from cwd persisting across reloads, not from the initial conditions.

I don't see the maybe_run_list function checking for the filesystem, so I assumed that by this point it has already been checked? I don't really have a way of testing this without a filesystem.

stuck elbow
#

shaves that yak

#

@onyx hinge thanks for help, I would have never found it myself

onyx hinge
#

you're quite welcome of course

manic glacierBOT
devout jolt
#

I have a socket question. In CPython, I can create a Multicast UDP sender or receiver by doing socket.setsockopt() , e.g. for a multicast receiver:

sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # UDP
ttl = 2
sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, ttl)
while True:
    sock.sendto(udp_message, (udp_host,udp_port) )
    time.sleep(1)

and then if that's invoked with a udp_host,udp_port=224.0.0.1,5000 I am sending on the LAN multicast net to multicast group 5000. (I put some simple working examples in CPython here: https://gist.github.com/todbot/375e539740cfb790e8c6296ca423ebfe)

This UDP receiver code is exactly the same as unicast UDP (which does work in CircuitPython), except for setsockopt.

So how do I do setsockopt equivalent in CircuitPython? I'm mostly concerned about ESP32-S{2,3} cores if that helps

onyx hinge
#

we do have setsockopt according to the docs: shared-bindings/socketpool/Socket.c://| def setsockopt(self, level: int, optname: int, value: int) -> None:
but the related constants are almost certainly not available.

#

it looks like from doing full text search that IPPROTO_IP is 0 (matches linux python) and IP_MULTICAST_TTL is 5 (linux python is 33)

tulip sleet
#

it does appear that Espressif will support multicast

manic glacierBOT
devout jolt
onyx hinge
#

adding more constants is not tough, so we can do that if they're useful

devout jolt
onyx hinge
#

ok cool!

manic glacierBOT
#

Symbols are an area which will require a top level choice and there will be consequences of that choice. This choice will likely involve some level of support by Adafruit. MicroPython currently is a fan of static symbols and management be provided by fork or firmware flavors. (Based on your quote.) This represents one choice. The RP2040 and SDK somewhat forces this.

This creates challenges for Adafruit. To avoid this Adafruit may decided to ban certain practices in native modules. This wi...

serene token
#

Ok, I've got things setup for compiling a custom CP for rotary trinkey, and I used the advice of @slender iron to get a list of the CIRCUITPY parameters. I have some questions about some of them. To start with:

I see that busio.SPI and busio.I2C are part of the default modules. The rotary trinkey doesn't have enough exposed pins to use either of those procols (well, I guess you could solder to the touchpad for the forth...). Is there some other reason to keep those, if I'm not going to use them?

devout jolt
tulip sleet
#

the writeup sounds more like any interference is an issue for multicast, not necessarily bad for ESP in paritcular

#

glad it works in general!

devout jolt
slender iron
serene token
#

Ah, that's the kind of thing I was looking for. I don't know if there is onboard flash, but I figured there might be something I hadn't thought of, that it needed for its own operations.

serene token
#

Well, it worked! My temperature sensor is definitely a thermistor, so now I have to build the voltage splitter and figure out how to do it on a tiny board. Turns out this board is perfect though, since I'll need the ground pad on the three rotary encoder pins for the voltage splitter. (I just set the other pin to high as a voltage source, but I'll have to measure the internal resistance to work out the numbers for calculating the temperature. That's the fun part though!...well somewhat fun.)

Anyhow, thanks! I now have a Rotary Trinkey build with analogio.

manic glacierBOT
manic glacierBOT
#

I'm not using sockets directly, just the webserver from adafruit (adafruit_httpserver). Any suggestions what a similar fix would be for http?

Code is based on https://learn.adafruit.com/pico-w-http-server-with-circuitpython/code-the-pico-w-http-server

Looks like you can change it. The default is 1024. See https://docs.circuitpython.org/projects/httpserver/en/latest/api.html#adafruit_httpserver.server.Server.request_buffer_size

So in your code you would have to add the reques...

buoyant lagoon
#

@patent peak when i run anything in the REPL on my zero, it just hangs and prints \n infinitely
i went into shared/runtime/pyexec.c and added prints until i could narrow down the cause:

        #if CIRCUITPY_ATEXIT
        mp_hal_stdout_tx_str("g\r\n");
        if (exec_flags & EXEC_FLAG_SOURCE_IS_ATEXIT) {
            atexit_callback_t *callback = (atexit_callback_t *)source;
            mp_call_function_n_kw(callback->func, callback->n_pos, callback->n_kw, callback->args);
        } else
        #endif
        {   
            mp_hal_stdout_tx_str("e\r\n");
            mp_call_function_0(module_fun);
            mp_hal_stdout_tx_str("c\r\n");
        }
        mp_hal_stdout_tx_str("f\r\n");

this just prints g&e, c&f never show up

#

ah, and on a second look, i now see a MICROPY_DEBUG_VERBOSE i could turn on....

#

/circuitpython/ports/broadcom/../../py/gc.c:124: undefined reference to `DEBUG_printf'

#

but that just breaks the build

#

forced that on, i now have debug!

#
gc_alloc(4 bytes -> 1 blocks)
gc_alloc(0x21f9240)
gc_alloc(2 bytes -> 1 blocks)
gc_alloc(0x21f9230)
0;�🐍REPL | 8.2.0-45-g75ba17e84-dirtygc_alloc(32 bytes -> 2 blocks)
gc_alloc(0x2c5900)

Adafruit CircuitPython 8.2.0-45-g75ba17e84-dirty on 2023-08-19; Raspberry Pi Zero with bcm2835
Type "help()" for more information.
>>> 
>>> 
#
gc_alloc(16 bytes -> 1 blocks)
gc_alloc(0x2c5ba0)
gc_alloc(33 bytes -> 3 blocks)
gc_alloc(0x2c5bb0)
gc_alloc(24 bytes -> 2 blocks)
gc_alloc(0x2c5be0)
gc_alloc(12 bytes -> 1 blocks)
gc_alloc(0x2c5c00)
#

it gets into a loop doing this, and doesnt seem to return

#
e
calling function 0x2c5940(n_args=0, n_kw=0, args=0x0)
#

call == 0x2a9c4

#
0002a9c4 <fun_bc_call>:
   2a9c4:       e92d4ff8        push    {r3, r4, r5, r6, r7, r8, r9, sl, fp, lr}
   2a9c8:       e1a05001        mov     r5, r1
#

fun_bc_call() doesnt seem to be printing its own debug properly

manic glacierBOT
#

I reworked the safe mode messages in #7577. I rewrote
"Crash into the HardFault_Handler." to be
"Fault detected by hardware.".

This turns out to be confusing, because it sounds like the hardware is failing. This PR changes it to
"Hard fault: memory access or instruction error."
which is the definition of hard fault on most CPU's.

I made this change in 8.2.x to get it into the next 8.2.x release, and it can be merged up into main.

manic glacierBOT
manic glacierBOT
manic glacierBOT
manic glacierBOT
tulip sleet
#

@buoyant lagoon Since I think the printing stuff used to work, doing a bisect or similar would narrow down what changed caused the problem. You could narrow down the version range manually with the builds archive: https://adafruit-circuit-python.s3.amazonaws.com/index.html?prefix=bin, and then do an actual bisect. Doing bisects across major version changes can be tricky.

buoyant lagoon
#

i did also find another issue

#

i think its calling fun_bc_call()

#

because in the mp_call_function_n_kw() area, that is what was in the call pointer

#

but the logs in fun_bc_call() never run

#

is the MMU in use at all?

tulip sleet
#

the cause may be some second-order bug. Not sure about the MMU, but there have been plenty of cache issues.

buoyant lagoon
#

fun_bc_call() also uses a different print function for its debug

tulip sleet
#

so I think a bisect may help narrow it down

#

also could be TInyUSB updates

buoyant lagoon
#

the tinyusb side appears to be working fully

#

when it crashes, its spamming \n's over the cdc uart!

#

so its still able to drive the usb device fully

#

and its spamming them to the framebuffer, and hw uart at the same time

#

so all of the IO seems to be working

tulip sleet
#

but that could be caused by some error in USB interrupt handling or something: repeatedly sending same buffer or someting

#

so I think bisecting will be your friend here

buoyant lagoon
#
gc_alloc(16 bytes -> 1 blocks)
gc_alloc(0x3c62a0)
gc_alloc(33 bytes -> 3 blocks)
gc_alloc(0x3c62b0)
gc_alloc(24 bytes -> 2 blocks)
gc_alloc(0x3c62e0)
gc_alloc(12 bytes -> 1 blocks)
gc_alloc(0x3c6300)

gc_alloc(16 bytes -> 1 blocks)
gc_alloc(0x3c6310)
gc_alloc(33 bytes -> 3 blocks)
gc_alloc(0x3c6320)
gc_alloc(24 bytes -> 2 blocks)
gc_alloc(0x3c6350)
gc_alloc(12 bytes -> 1 blocks)
gc_alloc(0x3c6370)

gc_alloc(16 bytes -> 1 blocks)
gc_alloc(0x3c6380)
gc_alloc(33 bytes -> 3 blocks)
gc_alloc(0x3c6390)
gc_alloc(24 bytes -> 2 blocks)
gc_alloc(0x3c63c0)
gc_alloc(12 bytes -> 1 blocks)
gc_alloc(0x3c63e0)
#

that doesnt explain it looping like this

tulip sleet
#

I almost always start with a bisect if it used to work, unless I have some confidence that a certain PR is involved

buoyant lagoon
#

tinyusb avoids malloc at all costs

#

let me plug the zero back in, and try to narrow it down some more...

tulip sleet
#

but the things that call tinyusb malloc, and if they are getting different or wrong info back from tinyusb...

buoyant lagoon
#

i think first, i should try to backtrace from gc_alloc

#

i'm expecting trouble from git bisect, because i modified the makefile some

#

DEBUG_printf("gc_alloc(" UINT_FMT " bytes -> " UINT_FMT " blocks) caller=%p\n", n_bytes, n_blocks, __builtin_return_address(0));

#
gc_alloc(16 bytes -> 1 blocks) caller=0x297b0
gc_alloc(0x3c5ba0)
gc_alloc(33 bytes -> 3 blocks) caller=0x297c8
gc_alloc(0x3c5bb0)
gc_alloc(24 bytes -> 2 blocks) caller=0x29864
gc_alloc(0x3c5be0)
gc_alloc(12 bytes -> 1 blocks) caller=0x29888
gc_alloc(0x3c5c00)
#

it now prints this while looping

tulip sleet
#

I'm saying try 7.3.3, then 8.0.0 final, etc., to see if you can get it narrowed to a version range. Then you can start with a bisect with a narrow range that doesn't span branch changes in a clean clone

buoyant lagoon
#
00029790 <mp_obj_new_exception_msg_vlist>:

   297ac:       ebff7aa6        bl      824c <m_malloc_maybe>
   297b0:       e1a04000        mov     r4, r0

...
#

that seems promising, if its in an infiniteloop, trying to build an exception

#

and then has an exception while building an exception!

tulip sleet
#

going afk for a while

buoyant lagoon
#

fmt: 0xc9b8c, caller: 0x29948

#

0002992c <mp_obj_new_exception_msg_varg>:

#

0001f840 <mp_raise_msg>:

#

msg: 0xc9ba4, caller: 0x1fa28

#
0001fa18 <mp_raise_RuntimeError>:
   1fa18:       e1a01000        mov     r1, r0
   1fa1c:       e92d4010        push    {r4, lr}
   1fa20:       e59f0000        ldr     r0, [pc]        ; 1fa28 <mp_raise_RuntimeError+0x10>
   1fa24:       ebffff85        bl      1f840 <mp_raise_msg>
   1fa28:       000c60e0        .word   0x000c60e0
#

msg: 0xc9ba4, caller: 0x21e4c

#
00021e40 <mp_raise_recursion_depth>:
   21e40:       e92d4010        push    {r4, lr}
   21e44:       e59f0000        ldr     r0, [pc]        ; 21e4c <mp_raise_recursion_depth+0xc>
   21e48:       ebfff6f2        bl      1fa18 <mp_raise_RuntimeError>
   21e4c:       000c9ba4        .word   0x000c9ba4
#

aha, recursion! while creating a exception about recursion! lol

#
#if MICROPY_STACK_CHECK || MICROPY_ENABLE_PYSTACK
NORETURN MP_COLD void mp_raise_recursion_depth(void) {
    mp_raise_RuntimeError(MP_ERROR_TEXT("maximum recursion depth exceeded"));
#

ah yep, that explains it perfectly

buoyant lagoon
#
fun_bc_call() before stack check
msg: 0xc9bec, caller: 0x21e4c
msg: 0xc9bec, caller: 0x1fa3c
fmt: 0xc9bec, caller: 0x1f878
fmt: 0xc9bec, caller: 0x299a4
#

yep, bingo

#

usage: -176121704, limit: 65712

#

@tulip sleet aha, i'm using negative 167mb of stack! lol

#
top: 0x2309734, current: 0xcaffe98
top: 0x2309734, current: 0xcaffe9c
usage: -176121704, limit: 65712
#

so, the top of the stack is at 35mb

#

but the sp is near 202mb

#
Press any key to enter the REPL. Use CTRL-D to reload.
mp_stack_set_top(0x2309734)
Initializing GC heap: 0x30a4f0..0x22f9270 = 33484160 bytes
GC layout:
#

so, i think we have 2 bugs

#

1: the top of the stack is wrong
2: it checks the stack limit, while complaining about a stack limit, and infinitely recurses

#
port has dynamic stack
stack top 0xcb00000
allocated stack at 0x305344, size = 66736
limit 0x22f9284, length 0x104b0
mp_stack_set_top(0x2309734)
mp_stack_set_top(0x2309734)
#

so first, it gets the size of the current stack
the it malloc()'s about 65kb, an extra EXCEPTION_STACK_SIZE bytes so it can report failure (which failing)
then it changes the stack top, but doesnt actually change the stack

#

#define MICROPY_STACK_CHECK 0 is also non-functional

#

i patched mp_stack_check() to just not check, and now it works

manic glacierBOT
#

Yes, I would like to investigate why natmods are failing, there's more than just the source files being missing. but if I can't get it sorted, I think the right thing to do is disable the related tests and move on. we can re-review what's up in/after the 1.20 merge.

I think the problem may be that we changed the bytecode format with MP_SCOPE_FLAG_ASYNC but did not make related changes in some related scripts...

py/runtime0.h:41:#define MP_SCOPE_FLAG_VIPERRELOC   (0x20) // used on...
buoyant lagoon
#

ok, lets see, where do i begin with displayio....

stuck elbow
#

was there any bug in 8.2.3 that would explain it not working on the PewPew M4? I compiled the latest source, and it works, so it must have been fixed in the mean time?

buoyant lagoon
#
[root@amd-nixos:/etc]# hexdump -C /dev/sdc
00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
000001c0  00 00 01 00 00 00 01 00  00 00 00 00 00 00 00 00  |................|
000001d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|
00000200

[root@amd-nixos:/etc]# fdisk -l /dev/sdc
Disk /dev/sdc: 512 B, 512 bytes, 1 sectors
Disk model: Zero
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00000000

Device     Boot Start End Sectors Size Id Type
/dev/sdc1           1   1       0   0B  1 FAT12
#

ah, thats why thats borked

#

its only a 512 byte disk drive!

#

supervisor_flash_get_block_count() claims its 0 blocks

#

ah, the partition loop code is rather dumb

#

if it encounters a 3rd or 4th partition, it uses none

tulip sleet
buoyant lagoon
#

@tulip sleet any tips on where i would start with implementing sprites with displayio? i know how the hw works, but not how circuitpython expects it to be exposed

stuck elbow
#

no screen

#

I didn't try jlink with it

tulip sleet
stuck elbow
#

I think it's the only samd51 board without external flash out there

buoyant lagoon
#

the issue, is that i believe the pi-zero currently lacks sprite/displayio support

#

and i wish to add it

tulip sleet
buoyant lagoon
#

yes, but that is not hardware sprites

#

so it takes a ton of cpu usage to do anything

#

even just scrolling the text console is cpu intensive

tulip sleet
#

does the broadcom chip have hw sprites?

buoyant lagoon
#

yes

#

this demo uses <1% cpu

#

the 2d pipeline on the SoC is sprite ONLY

#

the framebuffer CP is using, it just a static sprite

tulip sleet
#

you should talk to Scott about it, since he was directly inspired by sprites for TileGrid. Maybe he had possible hw in mind. But it was insspired by much less powerful machines without a lot of specialized display hw, e.g. old game consoles

buoyant lagoon
#

at the most basic level, you give the hardware a list of sprites

for each sprite, you define:

  • the addr in ram
  • the source width/height/stride
  • the x/y on the screen
  • the dest width/height
#

by using a width of 32 pixels, but a stride of 320 pixels, you can easily extract a tile from a tileset and draw it

tulip sleet
stuck elbow
#

the last version I tested is 8.0.0-beta.1

#

but since it works in the current version, I don't think it's important

tulip sleet
#

it's weird it broke and then started working again

stuck elbow
#

I was just asking out of curiosity

tulip sleet
#

I could probably try the pewpew build on a random SAMD51 board, since I'm just trying to see if it loads

stuck elbow
#

hmm, let me try with the "abosulte lates" build from the download, maybe it only works when I compile it myself

tulip sleet
#

and/or build 8.2.3 yourself and see

buoyant lagoon
tulip sleet
#

so is there something missing from the current TileGrid API?

buoyant lagoon
#

this was written entirely in C

#

each tile on here, is its own sprite

buoyant lagoon
stuck elbow
#

hmmm, adafruit-circuitpython-pewpew_m4-en_US-20230818-babd2de.uf2 also crashes

tulip sleet
#

TileGrid is is in shared-module: there are not port-specific impls for that kind of class in displayio

buoyant lagoon
#

where is the port specific code, for configuring hardware sprites?

#

or is it always cpu rendering?

tulip sleet
#

the only port-specific things in displayio are the kinds of buffers

#

there is none

buoyant lagoon
#

ahh, thats a much bigger task then

tulip sleet
#

because on boards up to now, the CPU had to drive the display anyway

#

you could just provide an alternate impl for TileGrid, but I'm not sure it's at the TIleGrid level -- it's in the display update code, maybe?

buoyant lagoon
#

@slender iron you got any thoughts?

stuck elbow
#

hmm, if I press reset to get into the safe mode, it doesn't crash

tulip sleet
#

i have seen that too, when loading a new UF2. I go into safe mode but a reset cures it

#

I am usually connected via serial so it's not surprising

#

I have been seeing this for a long time

stuck elbow
#

still no disk and no serial, but I can see the safe mode message on the screen

manic glacierBOT
#

I got the issue again. It happens if I am using my home wifi but not if I used my 4G portable router.

But then I did remember I am using a wifi repeater - and I tested that if CP board is configured to connect to home main router it works, but do not work if I connect to the wifi repeater network. Maybe something changed on the wifi repeater, as I didn't had this issue previously...

stuck elbow
#

if I press the rst just right, I get this, but no disk and no serial, otherwise it's just unitialized screen

#

lsusb doesn't show it either

#

I will connect a jlink to it tomorrow and see what it crashes on

tulip sleet
stuck elbow
#

thank you

#

hmm I use the same

tulip sleet
#

how about the bootloader version you are using?

#

I don't see why that should matter, but maybe..

stuck elbow
#

I just updated it to the latest from adafruit's repo

#

no change

tulip sleet
#

i tried loading PewPew M4 on a Metro M4: it loads but nothing happens

#

it does not go back to the bootloader

stuck elbow
#

no, it just hangs

#

if you press reset to get into safe mode, it will go into safe mode, but without usb

#

(I guess you won't see it wihout a screen)

tulip sleet
#

oh it is a 51g, I should try an itsy. I have to put some food in the oven, back in a bit

stuck elbow
#

I compiled 8.2.3 myself and it also crashes, I'm going to try earlier versions

onyx hinge
#

fwiw I was using up to date versions on a pygamer just this week, so it's not that all samd51 are broken.

stuck elbow
#

yeah, someone would have noticed I'm sure

#

why did I save those few cents on the flash chip

#

8.0.5 works, 8.1.0 crashes, I'm going to check the betas

tulip sleet
#

see if any changes to the samd-peripherals submodule

stuck elbow
#

I'm not updating the submodules, so it must be a change in the main code

tulip sleet
#

i was thinking maybe someone submitted a PR to samd-peripherals which we incorporated

stuck elbow
#

but 8.0.5 with samd-peripherals from 8.2.3 works

tulip sleet
#

and you're not updating tinyusb either?

stuck elbow
#

yeah, not updating submodules at all

#

8.1.0-beta.1 works, 8.1.0-beta.2 crashes

tulip sleet
#

itsy m4 8.2.3 on itsy works fine

#

I wonder if some part of flash is overflowing but it's not being checked properly. Could turn off some more modules and see.

stuck elbow
#

some of the crashing uf2s are actually smaller than the working ones

manic glacierBOT
tulip sleet
#

so i think a bisect is in order. it's a pretty narrow range, that's good

stuck elbow
#

it stops working on commit 66edcf5d034432519aac18690806adad2cacf2ac

stuck elbow
#

also a change in usb.c

tulip sleet
#

jsut initializing the identification, but you could turn off the usb identification too

#

@clever was poking around that stack code above

stuck elbow
#

works with displayio disabled

#

maybe it's because I disable the logo

buoyant lagoon
#

i have found circuitpython to be fragile in terms of config

#

there are a number of compile-time config options, that just break it

#

verbose debug logging fails to link

stuck elbow
#

it works with displayio enabled, but display init disabled in board.c

buoyant lagoon
#

removing the stack bounds checking fails to even compile

stuck elbow
#

yup, it's the ^&#$#&* logo, removing #define CIRCUITPY_REPL_LOGO 0 makes it work again

#

I think it's because of this?

#

changing it to

        #if CIRCUITPY_REPL_LOGO
        scroll_area->height_in_tiles -= 1;
        #else
        scroll_area->height_in_tiles -= 1;
        #endif
#

makes it work again, but why

#

ah, because the status bar is still there

manic glacierBOT
#

CircuitPython version

Adafruit CircuitPython 8.2.3 on 2023-08-11; Adafruit MatrixPortal S3 with ESP32S3
Board ID:adafruit_matrixportal_s3

Code/REPL

# SPDX-FileCopyrightText: 2020 Brent Rubell for Adafruit Industries
#
# SPDX-License-Identifier: MIT

import os
import ipaddress
import ssl
import wifi
import socketpool
import adafruit_requests

# URLs to fetch from
TEXT_URL = "http://wifitest.adafruit.com/testwifi/index.html"
JSON_QUOTES_URL = "h...
buoyant lagoon
manic glacierBOT
stuck elbow
buoyant lagoon
#

more a comment on the general codebase, those config flags need better testing

manic glacierBOT
buoyant lagoon
#

looks

#

i can confirm

#

changing CIRCUITPY_REPL_LOGO to 0 breaks the rpi-zero port too

#

so its not a samd problem

#

it enumerated over usb, then stopped responding

stuck elbow
#

thanks for confirmation

#

@tulip sleet thank you a lot for your help

buoyant lagoon
#

checking the source...

#

if the logo is on, blinka_bitmap_data and blinka_bitmap are declared as extern vars

stuck elbow
buoyant lagoon
#

ah, so the height was probably undefined

#

and then it went out of bounds on the framebuffer

stuck elbow
#

it was defined, but was too big together with the status bar

#

because CIRCUITPY_REPL_LOGO disables the logo, but the status bar is currently hardcoded

buoyant lagoon
#

and then because the height wasnt decreased, it went 1 tile past the end of the framebuffer?

stuck elbow
#

possibly

buoyant lagoon
#

id say thats a second bug

#

writes to the framebuffer should have bounds checks

stuck elbow
#

no it shouldn't, it slow enough as it is

buoyant lagoon
#

a debug only check then?

#

so when it does crash, you can turn that on, and instantly get an obvious error

stuck elbow
#

nobody ever enabled debug

tulip sleet
#

glad this is figured out

stuck elbow
#

@tulip sleet I'm still suspicious about what happens when the logo is bigger than the status bar

#

shouldn't then it do -2 or even more on the scroll area?

tulip sleet
#

maybe so -- I have a vague memory of using an emoji that just fits in the status bar, instead of the standalone logo?

stuck elbow
#

but the code clearly allows the logo to be bigger than the font

buoyant lagoon
stuck elbow
#

it's a compromise

buoyant lagoon
#

no matter what font your using, the terminal should be contained within the bounds of the display

stuck elbow
#

that's what happens when the code is correct

#

when it's not correct, run-time checks won't help with it

#

(though they may help pin-pointing the problem)

#

let's face it, the whole micropython is a huge hack, with a lot of very clever but fragile tricks

manic glacierBOT
stuck elbow
#

written in a language from the '70s

buoyant lagoon
#

one thing i could see more work being put into, is automated testing on real hardware

tulip sleet
#

we have worked on this on and off; I would like to. Scott originally did it with an RPi, and it was not reliable enough. A more capable test computer would be better. I have spare mini PC's.

buoyant lagoon
#

then all you need is a gpio pin to hard-reset the device when its crashed

manic glacierBOT
buoyant lagoon
#

the pi1/pi2/pi3/pi4 can network boot, so if you serve the above directory over tftp, you can repeat the same thing
(pi1/pi2 need bootcode.bin on an SD card to netboot)

#

that covers everything under ports/broadcom i think

#

ports/raspberrypi, either use 2 gpio, for bootsel+run, or 2 gpio for full SWD

if bootsel is pulled during boot, you can UF2 flash it over usb
if you use SWD, you can program it with an elf and openocd

manic glacierBOT
#

Here's a slimmer version that will fail gracefully during testing.

import os
import time
import ipaddress
import ssl
import wifi
import socketpool
import adafruit_requests

pool = socketpool.SocketPool(wifi.radio)

JSON_STARS_URL = "https://api.github.com/repos/adafruit/circuitpython"

# Connect to Wi-Fi
print("\n====== MatrixPortal S3 WebClient Test ======")
print("Connecting to WiFi...")
requests = adafruit_requests.Session(pool, ssl.create_default_context())
while...
tulip sleet
#

@stuck elbow weird build failure in the scheduler job in your PR. I am re-running just in case it is transient.

stuck elbow
#

the yaks just keep on coming ;-)

manic glacierBOT
tulip sleet
#

:🐃 💈

buoyant lagoon
#

@tulip sleet after thinking about it some, i can picture some ways you could take the broadcom SoC design, and apply it to things like the pico-dvi, to change up how sprites are handled, and potentially improve performance, and maybe even reduce ram usage

#

i assume that pico-dvi currently just has a standard framebuffer, for whatever the full resolution is, in ram at all times?

tulip sleet
#

yes

buoyant lagoon
#

and the dvi code is just converting it constantly

#

the sprite code then draws into that

tulip sleet
#

it is PIO

buoyant lagoon
#

yep

#

internally, the HVS on the rpi, will scan the sprite list, composite sprites on the fly, and fill a FIFO with pixels

#

and the HDMI block then converts that into HDMI/DVI

#

in theory, you could recreate that HVS on the pico, and just delete the framebuffer

tulip sleet
#

is the background a big "sprite"?

stuck elbow
#

you would basically need to rewrite displayio

#

with new and exciting bugs

buoyant lagoon
#

what i'm thinking, is that you have a FIFO between the new displayIO, and pico-dvi, that holds pixels

stuck elbow
#

plus there is stuff like the shapes

buoyant lagoon
#

and any time that FIFO has room, you scan the sprite list, fetch pixels from ram, and write to the FIFO

#

and as long as you can generate pixels at the pixel clock, and the FIFO eats any lag spikes, it works

stuck elbow
#

that's how displayio works on spi displays, roughly

buoyant lagoon
#

ah, so you already have that code

stuck elbow
#

it calculates the pixels on the fly

#

the problem is, it's slower than mass blits

buoyant lagoon
#

the rpi hardware is doing exactly the same thing on every frame

stuck elbow
#

it was inspired with how gameboy did it

buoyant lagoon
#

yeah, there is a trade-off, of time per pixel, constantly

vs time per draw operation

stuck elbow
#

it gets slower if you have many overlapping layers

#

so at some point you can no longer keep up

buoyant lagoon
#

in the broadcom implementation, the FIFO holds a couple scanlines
and rather then being a true FIFO, its just a block of ram, so you have a set of pointers defining where the new scanline is, and it draws the sprites into that region

buoyant lagoon
#

the glitching you see here, is when too many sprites overlap, and i underclocked it hard

#

i was mostly under-clocking it, to measure where the limit was

stuck elbow
#

wouldn't it make more sense to use the gpu?

buoyant lagoon
#

this is the gpu

stuck elbow
#

I mean the 3d one

buoyant lagoon
#

the rpi has a 2d only gpu, and a 3d gpu

#

page-flipping and double-buffering can only be done via sprites on the 2d core

buoyant lagoon
#

with this example screenshot...

#

i have a 9x9 grid of sprites, 81 sprites in total

#

i can repaint the entire map, by just doing 81 x 32bit writes to the display list

#

while with the 3d core...

#

i would need to update 4 vertices per sprite, each with a 32bit floating point X/Y

#

2592 bytes

#

then i have to run the 3d job, which will write the entire frame to ram
not a cpu task, but still eats up dram bandwidth

#

then i have to change out the image behind a 2d sprite, to make the 3d render visible

#

so, for a 2d job, the 2d core is far more light weight

stuck elbow
#

I know there are some python libs for rpi that use the 3d gpu for 2d sprites and they are pretty fast

#

faster than sdl anyways

buoyant lagoon
#

throw enough cpu at the problem, and you can mask the overhead from something taking over 8x the resources

tulip sleet
#

@stuck elbow because the build is only building your board, it appears SRC_SUPERVSIOR is not being set (I'm not sure why), but I think the fix would be to change if file in settings["SRC_SUPERVISOR"]: in tools/ci_set_matrix.py to if file in settings.get["SRC_SUPERVISOR", ""]. There are some similar examples in that script.

stuck elbow
#

get() not get[], I will add that

tulip sleet
#

it is working ok on 8.2.x?!

#

yes, sorry, copy/pasta

#

but WHY is a mystery, since you do need SRC_SUPERVISOR files

stuck elbow
#

I tested on that 8.0.1-beta-2, but there were no other changes in that code since

tulip sleet
#

yeah, I looked at blame

buoyant lagoon
stuck elbow
buoyant lagoon
#

yeah

stuck elbow
#

but of course if you are willing to do the work, that's great

buoyant lagoon
#

what does displayio have in terms of api?

stuck elbow
#

not that much really

buoyant lagoon
#

displayio.Colorspace, the rpi hardware allows each sprite to exist in its own colorspace, and supports a palette

#

are shapes rects or polygons?

stuck elbow
#

yeah, each bitmap or ondiskbitmap has its own palette

buoyant lagoon
#

rotation or just mirroring?

stuck elbow
#

they are are more complex, lines, circles, polygons, rectangles, rounded rectangles, ellipses, etc.

buoyant lagoon
#

ah, so you would need to use per-pixel alpha then

stuck elbow
#

rotation by 90° and mirroring

buoyant lagoon
#

rotation by 90° is the only part i havent figured out yet on the rpi

#

its an extra step

#

mirroring is just a 1bit flag, for each axis

stuck elbow
#

the way the shapes work, they calculate their pixels on the fly

buoyant lagoon
#

these are the pixel formats that sprites can be in, which look useful

stuck elbow
#

spi displays just use the RGB565

buoyant lagoon
#

1/3/6/7/13 all support per-pixel alpha

#

3 only has 1bit of alpha per pixel, so its only good for masking a shape off

#

the rest support varing amounts, from 4bit to 8bits of alpha, so they can blend

#

palette formats support 1/2/4/8 bits per pixel
and the palette is just an array of RGBA8888, so you have the full 8bits of range, for every color, and alpha

stuck elbow
#

perhaps you should start by writing your own graphics library first, and once you are familiar with it, come back to displayio

buoyant lagoon
#

i already have

stuck elbow
#

I made my own "stage" library that way

#

it's still faster than displayio

stuck elbow
#

(which is not hard)

buoyant lagoon
#

lines 33-49 will generate a sprite that is 32x34, and at the right coords on-screen

#

lines 51-55 will change the tile within the sprite

#

and this is the end result of that code

#

one option, would be to just port this to circuitpython, as its own api, and just ignore displayio temporarily

stuck elbow
#

that's what I meant

buoyant lagoon
#

yeah, i realized that after saying it

#

i could also slightly hijack display-io, and turn it into another sprite, so you can still see the old ui

#

this would be the standard terminal in little-kernel, it just uses memcpy() to scroll

stuck elbow
#

yeah, scrolling is something displayio struggles with

buoyant lagoon
#

and it scrolls slow enough that you can almost read it as it scrolls

#

this treats the framebuffer as a ringbuffer, and the write-ptr just wraps, and it never scrolls

buoyant lagoon
#

it then uses sprites to draw the 2 halves of the buffer

#

for debug, there is a seam in the framebuffer, which you can see on the final frame of the video

#

but i can just align things properly, and then its seamless

#

and it actually scrolls too fast, it updates multiple times within 1 vsync period, and overflows some hw buffers, lol

stuck elbow
#

I'm heading to bed, goodnight

buoyant lagoon
#

nn

manic glacierBOT
serene token
#

Fetching submodules:

Entering 'ports/espressif/esp-idf'
BUG: config.c:129: kvi should not be set while parsing a config source
error: path='ports/espressif/esp-idf'; git fetch --tags --depth 1 died of signal 6
fatal: run_command returned non-zero status for ports/espressif/esp-idf

Any ideas?

midnight ember
#

Well my bug hunting day is done. Found a big juicy one that affects any S2 or S3 module that is using adafruit_requests starting in 8.2.2

manic glacierBOT
manic glacierBOT
manic glacierBOT
#

CircuitPython version

Adafruit CircuitPython 8.2.3 on 2023-08-11; FeatherS2 with ESP32S2
Board ID:unexpectedmaker_feathers2

Code/REPL

import adafruit_dotstar

Behavior

Traceback (most recent call last):
File "", line 1, in
File "adafruit_dotstar.py", line 44, in
ImportError: no module named 'adafruit_pypixelbuf'

Description

Complains about missing adafruit_pypixelbuf. Tried replacing adafruit_dotstar.mpy with the .py version, as th...

manic glacierBOT
manic glacierBOT
manic glacierBOT
#

I imagine hard fault is a reference to the exception handler that caught it. I think that's a good thing to include. Might even be better to include the file & or memory address that failed? Copy/pasting the same "my board says it crashed into the hard fault handler" doesn't really give the devs much info to go on. Dan is right, with ""Fault detected by hardware."" can't tell you how many times in CP help channel a beginner gets that message and then immediately asks "Did I brick my board?"

onyx hinge
#

well that's a new wrinkle. If long ints aren't supported, only 14-bit(!) integer values can be frozen.

midnight ember
#

Showing 8.2.2 was released on July 31st but adafruit_requests last real commit was in June. That makes no sense to me. Is it possible the bug was introduced in 8.2.3 and then backported to 8.2.2? I have no clue how the backporting process works. Can't find a reason why things just magically broke in 8.2.2 on July 31st but everything works fine on 8.2.1 from July 25th.

#

July 20th was the TLS cert update for AdafruitIO. The timing is pretty close but the S2/S3 module shouldn't need that cert with Github for example.

manic glacierBOT
#

If it was possible to include this much info, it should probably be displayed in a seperate line / section.

But I am pretty sure CP has no idea about source files even when compiled with DEBUG=1.

It may be possible to capture the backtrace (addresses) though.
Not that it would be useful on a non-debug build.

Copy/pasting the same "my board says it crashed into the hard fault handler" doesn't really give the devs much info to go on.

Agreed. Then maybe we should add a link to a...

manic glacierBOT
manic glacierBOT
devout jolt
#

huffman module problems. again. Task: I want to build mpy-cross to make mpys with minimal fuss from a fresh circuitpython clone. What do I do? My options appear to be make fetch-all-submodules or make fetch-port-submodules.

So is the most expedient way to build mpy-cross doing this?

git clone https://github.com/adafruit/circuitpython/ 
cd circuitpython
(cd ports/atmel-samd && make fetch-port-submodules)
make -C mpy-cross
onyx hinge
#

It looks like the CI build uses a whole different thing, python3 tools/ci_fetch_deps.py mpy-cross.

tulip sleet
devout jolt
manic glacierBOT
devout jolt
manic glacierBOT
midnight ember
manic glacierBOT
#

I am using the one dated 20230815.

On Sun, Aug 20, 2023 at 8:46 PM DJDevon3 @.***> wrote:

The check for adafruit_pypixelbuf was removed in March of 2022
https://github.com/adafruit/Adafruit_CircuitPython_DotStar/commit/fdc63e80404e7405489ac5922addf06a92093aba.
You're using an outdated library bundle. Please grab a more recent Bundle
for Version 8.x https://circuitpython.org/libraries


Reply to this email directly, view it on GitHub
<https://github.com/a...

blissful pollen
midnight ember
#

So it's not frozen in and the library bundle should be used.

manic glacierBOT
#

In the meantime I flashed the prior version of CircuitPy (8.2.2) and the
problem was rectified. Same library bundle.

On Sun, Aug 20, 2023 at 9:15 PM DJDevon3 @.***> wrote:

Then it should be using the latest version of adafruit_dotstar
https://github.com/adafruit/Adafruit_CircuitPython_DotStar/blob/67f8c35e2ce4a8abc3cfb24ab5029b40a64857b8/adafruit_dotstar.py...
I would hope.


Reply to this email directly, view it on GitHub
<https://github.com/adafruit/circui...

blissful pollen
#

I was having some issue with the TinyS2 and dotstar too but didn't have time to investigate. I thought I had the latest but maybe there is something else out of date

manic glacierBOT
#

This was an otherwise new S2 I had in a drawer for a long time. I flashed
to 8.2.3 and it no longer ran the sample code that flashes the dotstar. At
this point /lib was empty, so I loaded the entire bundle into /lib. Still
broken at that point. You now have the entire history.

On Sun, Aug 20, 2023 at 9:18 PM DJDevon3 @.***> wrote:

If you perhaps had an adafruit_dotstar.py in the same /lib folder it would
override the adafruit_dotstar.mpy from the bundle.


Reply t...

midnight ember
#

It's been a while since I've done a fresh UM install but I believe there might be a dotstar function in the feathers2.py helper file included? I'm not sure if that file is included with a new Circuit Python install... I know it ships with it at least. Possible the helper file might be overriding something? Might be a difference in what ships with a UM Feather that you get in the mail.

blissful pollen
#

I'll try to load mine up quickly (i'm half asleep my results may vary ha)

manic glacierBOT
blissful pollen
# midnight ember It's been a while since I've done a fresh UM install but I believe there might b...

So there looks like an issue.

Adafruit CircuitPython 8.2.3 on 2023-08-11; FeatherS2 with ESP32S2
>>> 
>>> import board
>>> import adafruit_dotstar
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "adafruit_dotstar.py", line 44, in <module>
ImportError: no module named 'adafruit_pypixelbuf'```

I do not see any bundle library `adafruit_pypixelbuf`.  It looks like it was archived so maybe then it does not get included in the bundle?
manic glacierBOT
#

Yes, that's normally what I do. I was being lazy this time. Are you saying
this is what caused the issue? I did the same thing for 8.2.2 and there is
no issue with it.

On Sun, Aug 20, 2023 at 9:30 PM DJDevon3 @.***> wrote:

Only load libraries you currently need or actively use into /lib. The fact
that the UM Feather can store the entire bundle is a marvel in itself.
That's not what should be done for the bundle... normally. ;) It's
currently only one of very few board...

blissful pollen
#

Which 100% does not seem right looking at the dotstar module

#

Okay told you I was tired, I had an old dotstar version installed (oops) so on 8.2.3 with the latest library bundle download it works for me.

manic glacierBOT
midnight ember
#

@blissful pollen So you pretty much did exactly what they did step for step. That's a happy accident. Everything working as intended now on 8.2.3 with the dotstar?

midnight ember
#

Awesome

#

I've done it myself, it's easier to make that mistake with the UM boards for some reason.

blissful pollen
#

I'm trying to remember why I even had adafruit_dotstar.py on my drive (not even the mpy!)

midnight ember
#

I think it might actually ship that way, I could be wrong.

blissful pollen
#

Could be, been a while since I received this board

midnight ember
#

same and I don't think I have any brand new ones laying around to whip out.

#
Thanks for buying a FeatherS3!

Your board has been tested and here are the results for your reference.

Test Date & Time: 05/29/2022, 07:21:18 <- Australia
MAC Address: obfuscated

PSRAM: 8189552 bytes
FLASH: 12224512 KB
VBAT Sense Check: PASS
VBUS Sense Check: Pass
GPIO Test: PASS
WiFi Test: PASS
WiFi Connection Time: 3.998 secs

This board is good to ship! I hope you enjoy using it :)

Cheers,
Seon
Unexpected Maker
http://unexpectedmaker.com
``` this is the results.txt included on the board... the timestamp shown would make a lot of sense if he included a dotstar.py in the lib folder
#

I don't have it on this particular board because I already started customizing it for a project. My guess is a new board would likely have it.

#

It's in the root dir on my UM Feather S2... and the date.

#

boot_out.txt must be a message to myself from the future. Will definitely read in private.

#

Shipped with 8.0.5 pre-installed

#
Adafruit CircuitPython 8.0.5 on 2023-03-31; FeatherS2 with ESP32S2
Board ID:unexpectedmaker_feathers2
manic glacierBOT
#

Figured out you did nothing wrong. Unexpected Maker ships the board pre-installed with Circuit Python and an adafruit_dotstar.py in the root directory which will override any adafruit_dotstar.py or .mpy in the /lib folder. That's the issue.

Capture

Delete that file and upload a newer version from the 8.x bundle to /lib and should be good to go. Was unaware of this issue.. I'm sure we'll...

midnight ember
#

We might need to contact Unexpected Maker and see about using a different method as it's causing us some support issues. Might be time for him to use a frozen lib and let Circuit Python update the frozen lib?

#
"""
`adafruit_dotstar` - DotStar strip driver (for CircuitPython 5.0+ with _pixelbuf)
=================================================================================

* Author(s): Damien P. George, Limor Fried, Scott Shawcroft & Roy Hooper
"""

# pylint: disable=ungrouped-imports
import sys
import busio
import digitalio

if sys.implementation.version[0] < 5:
    import adafruit_pypixelbuf as _pixelbuf
else:
    try:
        import _pixelbuf
    except ImportError:
        import adafruit_pypixelbuf as _pixelbuf

__version__ = "0.0.0-auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_DotStar.git"
``` yup, the included dotstar.py is from early 2022.
#

That's just a snippet. I can post the whole contents but I'm sure it's unnecessary for the sake of solving this issue.

tulip sleet
manic glacierBOT
#

This was an otherwise new S2 I had in a drawer for a long time. I flashed to 8.2.3 and it no longer ran the sample code that flashes the dotstar. At this point /lib was empty, so I loaded the entire bundle into /lib. Still broken at that point. You now have the entire history.

Key point here is "had it for a long time" and now just re-flashed it. The shipping code that was on there was for a much older version of the files, and new shipping files are available (as always) from...

atomic summit
atomic summit
blissful pollen
atomic summit
#

I do freeze the Neopixel library in my newer boards, so I guess it's ok to do that now, so I'm happy to go back and freeze dotstar now as well, and stop adding it during my testjig process.

manic glacierBOT
#

I added the following print statement to the start_mp function:
mp_printf(&mp_plat_print, "%d, %d, %d\n", stack_bottom,stack_length,sizeof(uint32_t));
which printed 4, 524284, 4 on a zero2w and 35623556, 66736, 4 on a zerow.

I'm really not great at c data types and printing the pointer value of stack_bottom feels suspect to me, however..... based on the math being used to calculate the top of the stack, a "stack_bottom" of 35623556 looks like it will cause problems to me.

If...

midnight ember
atomic summit
midnight ember
#

You really wouldn’t even need to necessarily freeze it. Could just add a /lib folder with the .mpy version. That would allow for easy updates overwriting it with a newer version and the most minimal work on your end.

#

Just snag the .mpy out of the latest 8.x bundle, throw it in /lib and your all set to ship boards like that. Easiest way for you and us, to my knowledge.

#

Unless you’re doing something custom in the dotstar library? Seems the easiest way to me.

manic glacierBOT
#

@dhalbert PortA/PortB/PortC pins are available externally through 4-pin Molex connectors (5V, GND, plus the two pins of the port as per pins.h). The other pins I've defined, such as the internal SPI (pins 12, 13, 14), the additional SPI pins used by the e-ink display controller IT8951 (pins 15, 23, 27), or the MOSFET hookup pins for power control (pin 5 for controlling power to the external ports, pin 23 for controlling the MOSFET supplying power to the IT8951 chip which also acts as reset,...

thorny jay
#

No tagging because this is the night in the US and Scott is in vacations...
I tried to replicate the MIDI Host Synth from tannewt, but on a Feather RP2040 USB Host (with I2S output): https://github.com/adafruit/Adafruit_CircuitPython_USB_Host_MIDI but I get very bad result in receiving Midi message over USB (they come a lot of seconds late). I know it works for Scott on that huge imx board but maybe there are unfixed things in TinyUSB, fix from TinyUSB not included in CP yet?
Of course it could by my keyboard... but it works well with PC and is detected by CP.
No issue yet as I should build a version of CP with TinyUSB debug if I want to know more... or have some special hardware to sniff the USB. I will just try again later.

GitHub

CircuitPython USB host driver for MIDI devices. Contribute to adafruit/Adafruit_CircuitPython_USB_Host_MIDI development by creating an account on GitHub.

manic glacierBOT
#

I never looked in the top level. Duh. When I went to 8.2.2, I did an erase,
which must have eliminated the unwanted .py file, correcting the issue.

Thank you for your assistance.

On Mon, Aug 21, 2023 at 12:22 AM Unexpected Maker @.***>
wrote:

This was an otherwise new S2 I had in a drawer for a long time. I flashed
to 8.2.3 and it no longer ran the sample code that flashes the dotstar. At
this point /lib was empty, so I loaded the entire bundle into /lib. Still
bro...

manic glacierBOT
#

CircuitPython version

Working:
Adafruit CircuitPython 8.0.5 on 2023-03-31; Adafruit Grand Central M4 Express with samd51p20
Board ID:grandcentral_m4_express

Not working:
Adafruit CircuitPython 8.2.3 on 2023-08-11; Adafruit Grand Central M4 Express with samd51p20
Board ID:grandcentral_m4_express

Code/REPL

import displayio
import rgbmatrix
import board
import framebufferio
from adafruit_bitmap_font import bitmap_font
from adafruit_display_text.lab...
manic glacierBOT
onyx hinge
#

@tulip sleet you may have noticed but the merge PR is now green. I worked a bunch on it over the week-end.

tulip sleet
onyx hinge
#

I really don't know how to effectively review it 😕 I mean, we can't possibly review every change upstream made.

tulip sleet
#

I agree -- I mean would you take the time to go through each file to catch anything obvious, or it's not worth it.

#

I sort of did review the upstream changes, in the sense that I had to understand them and merge appropriately.

onyx hinge
#

do you have a scheme for making an adafruit_circuitpython_asyncio that can run on CP 8.x or 9.x?

tulip sleet
onyx hinge
tulip sleet
#

We can have the 9.0.0 builds point to a branch for now, as it does in the current PR

onyx hinge
#

yes though that doesn't help folks who use the bundle

tulip sleet
#

we don't have a 9.0.0 bundle anyway, or we can special-case something in the bundle code. I'm not even sure we should build 9.0.0 bundles until the mpy version is not going to change.

But I think it's worth testing the changed asyncio against 8.x.x.

onyx hinge
#

yes I'm doing sort-of that right now

#

testing it against current main, that is

tulip sleet
#

the changes were really all internal: the queue stuff was redone, but it's internally consistent. There aren't user API changes that I recall

onyx hinge
#
+  File "extmod/uasyncio_gather.py", line 55, in <module>
+  File "/home/jepler/src/cp-pristine/frozen/Adafruit_CircuitPython_asyncio/asyncio/core.py", line 303, in run
+  File "/home/jepler/src/cp-pristine/frozen/Adafruit_CircuitPython_asyncio/asyncio/core.py", line 214, in create_task
+AttributeError: 'TaskQueue' object has no attribute 'push'
```doesn't seem to work, sadly
tulip sleet
#

OK, this is due to _asyncio.TaskQueue native module differences. we could add compatibility code to check for . push() replaced push_head() and push_sorted() -- not sure why there were two.

onyx hinge
#

OK

#

similar with pop apparently

tulip sleet
#

I don't think we need to solve this problem yet. Let's get v1.20 merged, and use the branched asyncio for now, and include a warning to use the new branch version in the release notes.

This issue of needing incompatible library versions does keep coming up -- I have an issue in the bundle repo about it.

When we get closer to a 9.0.0 release, we can think about adding compatibility code.

onyx hinge
#

OK

tulip sleet
#

if we just turned off using _asyncio if the version was 8 or lower, that would work, later

onyx hinge
#

it looks like adding hasattr() based check would work too

tulip sleet
#

yes

#

but I don't think we need to mess with the main-line asyncio librarynow, it's too early to do that

#

pop_head() mapped to pop() is fine. I just don't know why push has sorted and head options.

manic glacierBOT
onyx hinge
#

so I don't KNOW the answer but I think that it was an optimization. Sometimes you know a task is immediately ready (like when it has awaited a read, and the thing has become readable), so you can push_head so that it goes to the front of the queue. Other times it is based on time, and push_sorted figures out where to insert it so that it is correctly ordered according to the time it's intended to happen.

But having push_head is just an optimization, because you could just push_sorted it and it will naturally sort to the front of the list.

#

apparently they decided the optimization was not important

#

all that said, even in 8.x / MP 1.18, they were the same implementation: ``` { MP_ROM_QSTR(MP_QSTR_push_sorted), MP_ROM_PTR(&task_queue_push_sorted_obj) },
{ MP_ROM_QSTR(MP_QSTR_push_head), MP_ROM_PTR(&task_queue_push_sorted_obj) },

tulip sleet
#

ha, so it would be easy to remap in the library

onyx hinge
#

yes it would be

tulip sleet
#

i don't know whether there are further changes upstream in v1.20 or later that would make a difference. At the rate we are going there may be a v1.21 soon.

#

it would be nice to pick up the "drop the u" changes before 9.0.0, for instance. That would clean up some things.

onyx hinge
#

yeah

#

so yeah I think I'd like us to support both the old & new names in the core during 9.x, and in the lib use the old names. Then once we drop 8 from the bundle, we can use the new names and once we use the new names we can drop the compatibility names in 10.x.

#

but let's just leave it as it is for right now

tulip sleet
#

leave the library as is or the class dictionaries in _asyncio?

manic glacierBOT
tulip sleet
#

@onyx hinge I'm taking a walk for a bit

lone axle
#

<@&356864093652516868> Reminder, the weekly meeting will be occuring here on Discord about 90 from now at 2pm Eastern / 11am pacific. The The notes Doc is here: https://docs.google.com/document/d/1DMsb91O4e6KFiV7sn0TroXW4g6Dr9yukYOOC_vaCMto/edit if you'd like to add your hug reports and / or status updates. We look forward to hearing from everyone!

manic glacierBOT
#

Shoot, I’m testing with those exact matrices, just a later production batch…but on a MatrixPortal M4.
I see this is on a Grand Central board. What’s being used as a go-between? Shield, or jumper wires? Something might be introducing just enough capacitance on the clock line to skew it a bit late. 8.2.3 really should have spot-on timing, I’ve really been obsessing over this with a logic analyzer. That it worked before may have been two wrongs (timing and wiring) making a right.

@dhalbert T...

#

Oh also @dhalbert one more question - since this device comes with some integrated features (display, touchscreen, BMS, SHT3x sensor set, RTC controller, etc.), including some that require mandatory pre-init (e.g. pulling up pin 2 on boot to enable the main power rails)... Is there a way in CircuitPython to make an abstract instance of these features available?

I'm guessing that I could make the power-related init sequences part of board_init(void), but how would I e.g. add a generic tou...

idle owl
#

@tulip sleet How would I go about checking to see if a file exists on storage? in CP. Same directory as code.py.

#

I assume os something or other, but I'm not sure what.

idle owl
#

Cheers!

tulip sleet
# idle owl Cheers!

You need to catch FileNotFoundError. You could also just try open()ing it and catch the failure in your program

#

you can also do os.listdir() and check for it in the list of files

lone axle
#

@onyx hinge are you available to read the core section of the state of CircuitPython for the meeting?

manic glacierBOT
#

For the onboard I2C devices like SHT, touch, RTC, is there a separate on-board I2C bus, or is it shared with external pins? You can make multiple I2C buses that appear in board. See separate board.I2C() and board.STEMMA_I2C() in say QT Py RP2040.

But we don't provide board. instances for specific I2C devices.

Some folks with highly integrated boards or educational boards add board-specific libraries, sometimes frozen, sometimes not. You could do that if you want. CPX is our only...

thorny jay
#

Sorry, missing the meeting and poor quality report... but I was asked to start a BBQ (and now I am eating the result of it).

onyx hinge
#

@lone axle yes I will read it!

lone axle
#

Thank you.

random junco
#

It's 10pm. Do you know where your engineers are? Last time we did a video, we were mucking about with trying to get Linux running on an ESP32-S3 by compiling the shell script provided over at https://gist.github.com/jcmvbkbc/316e6da728021c8ff670a24e674a35e6 - we tried a few methods, and it got quickly into a yak-shaving mess https://www.hanselma...

▶ Play video
midnight ember
#

Nice Todbot and Tyler!

onyx hinge
#

amazing @devout jolt seems to have written MicroOSC just yesterday, after mentioning something about it on CircuitPython day.

midnight ember
#

Watching FoamyGuy use the tileset program was really interesting.

buoyant lagoon
#

yeah, tiled saves so much time with tile based games

idle owl
stuck elbow
#

but xml :-(

devout jolt
#

oh yeah if other circuitpythonistas would like a gratis board from my Tindie, DM me your address and what you want 🙂

onyx hinge
#

I also meant to specifically thank those who had good questions when we moved into the Q&A segments of the streams.

idle owl
#

😂

midnight ember
#

You have to check every single silkscreen for the revision? oof.

idle owl
#

So, oof, yeah, but not as bad as it sounds.

midnight ember
#

Do they always update the images with new revs 100% though?

idle owl
#

95% of the time.

#

And the OSHWA submissions can be updated if needed. So it's not a huge deal if it's not quite right.

#

Most of what foamyguy is going through are the new products though, so there won't be new revs yet.

devout jolt
#

good sleuthing, @midnight ember on that adafruit_dotstar.py issue! I was following that and omg

midnight ember
#

I'd be really interested in learning the # of boards that bug will end up affecting.

#

Only tested on 3 boards with S2/S3 and it failed on 8.2.2 and 8.2.3 on all of them with the requests library.

silver tapir
#

bodge life ❤️

onyx hinge
#

@devout jolt ```py
import adafruit_ticks
from asyncio.core import SingletonGenerator
def deadline_ms(t, sgen=SingletonGenerator()):
"""Sleep until not ticks_less(t, ticks_ms())"""
assert sgen.state is None, "Check for a missing await in your code"
sgen.state = t
return sgen

import random
import time
import asyncio

async def periodic():
when = adafruit_ticks.ticks_ms()
i = 0
while True:
i += 1
await deadline_ms(when := adafruit_ticks.ticks_add(when, 500))
print(i, adafruit_ticks.ticks_ms())
await asyncio.core.sleep_ms(random.randint(10, 50))

asyncio.run(periodic())

silver tapir
#

On it.

midnight ember
#

yeah shoutout to JP for a really long day waking up early for everything.

onyx hinge
#

even though it waits a random amount from 10 to 50ms each time, it still starts at about the intended time, and it's not drifting compared to the ticks_ms clock.

#

(the random wait is to simulate doing a variable amount of work)

midnight ember
#

The pretty pins diagrams are so nice just to look at. Appropriately named.

#

The 3D parts for Melissa's message board were also noteworthy. Great job on the enclosure design.

onyx hinge
midnight ember
#

So pretty, well done.

idle owl
#

Also a sneak peek of the silk. The images in the shop are of the prototype. 😉

stuck elbow
#

cpython takes 4MB on startup

#

roughly

midnight ember
#

I do love the N16R8 variants. It's just the right amount for any requests projects I can throw at it.

devout jolt
#

For the MilkV boards, is there Arduino core yet? That could really help

lone axle
silver tapir
#

Makes sense, I'll try to run blinka on top and report back. Might be tight, and I also think that they are using linux as an example of what it could run. I am trying to compare it with an m7, but using linux directly might be easier.

And sure, let me know anyone who might be interested in playing with such a hardware. Thanks for the notes jeppler, todbod and dan.

stuck elbow
#

iirc the issue was that the dac wasn't supported in the idf yet

midnight ember
#

Ohh DAC's would become available on most ESP boards possibly?

devout jolt
tulip sleet
#

also the webpage says "RTOS", but I didn't see what they meant by that

#

which RTOS?

thorny jay
#

Do the library owner need to do something, like make a new release? Who/what does compile the new mpy version?

tulip sleet
midnight ember
#

Any kind of timeline left for 9? I still have a lot of requests libraries to update with settings.toml but currently can't do it with 8.2.3 until that bug gets fixed.

midnight ember
#

Wait for 8.2.4?

tidal kiln
#

thanks! yep, please keep the lib bundle version -to- CP version number mapping nice and simple (even if redundant, like 7 and 8 are same etc)

midnight ember
#

Thank you for hosting @lone axle with the numbers in the name.

thorny jay
#

Thanks

midnight ember
#

It's started off as a matrix portal bug then turned into an adafruit requests bug.

idle owl
#

@lone axle I'm good whenever. I assume you want to get the post-meeting bits done?

tulip sleet
thorny jay
lone axle
midnight ember
#

yeah fixed wrong one

midnight ember
#

yes ugh posted the wrong one again. it's 8299.

#

ohh you changed the name that's why i didn't recognize it. thank you for that. i was thinking of changing the name after it shifted to a broader issue.

tulip sleet
#

I think #8299 is some cert problem. Brent is looking at it. I have some testing in mind but may not have a chance to do it right away

#

I want to build a fresh set of certs and use those instead of the ones from NINA-FW 1.7.5.

midnight ember
#

it's a bug that potentially affects all S2/S3 boards running adafruit_requests on 8.2.2 and 8.2.3

buoyant lagoon
#

who might i talk to, for more information on how mp_stack_check() and allocate_stack() are meant to work?

midnight ember
#

i'm not sure it's a NINA issue unless NINA is pre-programmed on the non-coprocessor modules on feathers.

tulip sleet
tulip sleet
midnight ember
#

haven't tried with a board using a co-processor yet

tulip sleet
buoyant lagoon
#

ah

midnight ember
#

sorry that's above my head. i'm just good at breaking things.

tulip sleet
buoyant lagoon
#

i havent had a change to bisect yet, i justspammed printfs until i found the root cause

#

let me see what git history says for those 2 files...

midnight ember
#

yes bisected it to it beginning in 8.2.2

tulip sleet
#

8.2.2 is JUST cert changes

midnight ember
tulip sleet
#

deshipu narrowed down some other issues to this commit

#

too many @clever usernames

buoyant lagoon
#

dang, ~4 of em, no wonder i have 3 _'s on my name, lol

buoyant lagoon
tulip sleet
#

discord hasn't offered you a unique username yet, I guess 🙂

buoyant lagoon
#

but the problem i ran into, is that allocate_stack() allocates a whole new stack, sets the new bounds, then doesnt use it

#

and because the stack isnt within those bounds, i'm using -167mb of the stack

#

underflow!

tulip sleet
buoyant lagoon
#

i was also unable to disable stack protections

#

if i change MICROPY_STACK_CHECK in the config file, it fails to compile

#

something about a .x not existing

tulip sleet
#

@slender iron is the right person for that - the rest of us have little experience with the broadcom port

buoyant lagoon
#

the weird thing, is that the faulting code, is mostly shared, let me find the URL...

#

that looks like something that would run on many ports

#

gated only by port_has_fixed_stack()

#

atmel-samd, litex, nrf, rp2040, stm, all appear to have dynamic stacks

#

so i'm confused as to why only the broadcom port is breaking

still zephyr
buoyant lagoon
#

is there better documentation on how the stack is meant to be handled in general, like what allocate_stack() should be doing, and how it switches stacks?

#

less in the port specific stuff, and more how to make/maintain a port

tulip sleet
#

no real doc, no, just the examples of each and every port

#

is port_has_fixed_stack true or false?

buoyant lagoon
#

false on 32bit, true on 64bit

#

pi-zero is 32bit

#

changing it to always true breaks things differently

tulip sleet
#

maybe cpu_get_regs_and_sp() is returning an incorrect sp for some reason? I would just plow through the code, sorry.

buoyant lagoon
#

ports/broadcom/mphalport.c:mp_uint_t cpu_get_regs_and_sp(mp_uint_t *regs) {

#

oh, interesting

#

the broadcom port has its own implementation of that...

lone axle
#

Here is the notes document for next Monday’s CircuitPython Weekly meeting. It is at the normal time of 11am Pacific / 2pm Eastern here on Discord. Everyone is encouraged to attend! Please add your hug reports and status updates even if you’ll be attending the meeting - it’s super helpful! If you are unable to attend but would still like to include updates, feel free to include them in the notes and we’ll read them off during the meeting. Hope to see you there! <@&356864093652516868> https://docs.google.com/document/d/1j5Pv4_oJHyVMV9M9QQvvpCHj0E4yjOM3AaDDe58oDsU/edit?usp=sharing

buoyant lagoon
#

__asm__ ("mov %[out], sp" : [out] "=r" (sp));

buoyant lagoon
#

its just inline asm, fairly standard stuff, should just work

#

but this is only reading sp, it cant change the active stack

#

so i dont see how allocate_stack() could ever switch to it

tulip sleet
#

i don't think it is allocating a new stack to switch to, it is reserving a chunk of memory for the current stack, so that further allocations can be done below the "top" of the stack (going down)

#

no big switch to a new stack is going on. Stack just starts at a place in RAM and grows down, and we need other space too, so figure out how big the stack should be, set a limit on its size, and then use the rest of RAM below that for heap and other thigns

buoyant lagoon
#

ah, that would imply that in the "fixed" stack case, its just at a hard-coded location

but in the "dynamic" stack case, something in boot.S picked a value dynamically, and you have to figure out what, and mark it as used so the heap doesnt step on it

tulip sleet
#

yes, I think so

buoyant lagoon
#

so i was mis-understanding the code

tulip sleet
#

it is really "set limits on stack size"

buoyant lagoon
#

i'll take another stab at it, from that angle

lone axle
#

@idle owl okay, I am good to go any time.

buoyant lagoon
#

that implies that its just mis-detecting where the stack is

#

oh, but there is also a second kinda more major bug

#

it reserves some extra space for the exception stack

#

then recursively faults while throwing the exception

#

so it can never actually say it ran out of stack space

manic glacierBOT
#

@dhalbert the internal I2C bus is on pins sda:21 scl:22 - the external I2C is on pins sda:25 scl:32.

I've tried to be descriptive with the naming, as you can see GPIO25 is assigned to the PORTA_SDA name, and GPIO32 is to PORTA_SCL (and similarly the UART external port pins are named PORTC_RX and PORTC_TX).

For internals, I just relied on the standard naming of SDA and SCL for I2C, and MOSI, MISO, SCK for SPI (with the e-ink controller getting the IT8951_CS, `IT8...

idle owl
lone axle
manic glacierBOT
#
buoyant lagoon
#

@tulip sleet oh, i just found comments, in exactly the place i was going to add some!
https://github.com/adafruit/circuitpython/blob/main/supervisor/port.h

// Get stack limit address
uint32_t *port_stack_get_limit(void);

// Get stack top address
uint32_t *port_stack_get_top(void);

// True if stack is not located inside heap (at the top)
bool port_has_fixed_stack(void);

// Get heap bottom address
uint32_t *port_heap_get_bottom(void);

// Get heap top address
uint32_t *port_heap_get_top(void);
devout jolt
#

Python docstrings and readthedocs question: where do I find documentation on how to do more complicated docstrings for Python methods/classes? I'd like to describe some function args in more detail and I'd like more structure than just paragraphs of text. When I try to do things described here: https://dev.to/zenulabidin/sphinx-docstring-best-practices-2fca, sphinx errors out

tulip sleet
buoyant lagoon
#

and reading things closer, i can now see why aarch64 broadcom claims a "fixed" stack

#

the firmware loads the kernel8.img to 0x80000 (512kb) (i think, might be mis-remembering)

and rather then waste all the space below the kernel, circuitpython puts the stack in that hole!

#

but 32bit broadcom loads the kernel lower by default, so you instead put the stack at the top of ram

#

however, that is ignoring config.txt, and the fact that you can just load the kernel anywhere

#

with just 1 line in config.txt, i could have both 32bit and 64bit loading to 1mb (0x100000), and then just have a fixed stack below that, in every case

idle owl
devout jolt
tulip sleet
#

what's the erro

#

I just saw "sphinx errors out"

devout jolt
#

Here's an example:

def do_something(good_arg, better_arg):
    """Do something amazing with args

    Args should be:

    * pretty good
    * or better
    * but no bad args or excellent args

    :param string good_arg: the gooder arg, may not be bad
    :param string better_arg: the better arg, may not be excellent
    """
    pass

(the "errors" would be if I didn't use the exact right amount of whitespace between lines or at the beginning of lines, so not important, just frustrating). In this example, I would like the bullet list to render as a visible bullet list but instead it renders as paragraphs. The HTML appears to be appropriately <ul><li><ul> but no bullets. If I try to add bullets, sphinx just removes them

tulip sleet
devout jolt
#

weird so why does that render with bullet points but mine does not

#

but thank you, I'll investigate

idle owl
#

Whitespace.

devout jolt
#

ag;lgehg=afh3hgawheghag

idle owl
#

@devout jolt Sphinx is the worst about whitespace.

tulip sleet
#

or could be CSS when you're inside a Parameters list

idle owl
#

One space here, and suddenly it formats everything as code, or fails completely.

devout jolt
#

yep

#

I spend more time dealing with sphinx than writing the code lol

tulip sleet
#

in general parameters are not listed in an unordered list

devout jolt
tulip sleet
#

@onyx hinge I can do smoke tests on representative boards starting now, unless you have already done some

#

on all ports

buoyant lagoon
#

ah, found setup_mmu_flat_map(); in the port.c, that answers that question

#

but where is that defined?

#

ports/broadcom/peripherals/broadcom/mmu.c:STRICT_ALIGN void setup_mmu_flat_map(void) {

#

ah, git grep ignoring submodules as usual

#

and it works!

onyx hinge
#

I will push it to that PR branch if this looks like what we agreed on. I tested with main & with the 1.19 branch

#

and then I'll update the big PR too

tulip sleet
#

it looks good, exactly what we were thinking about. I just tested 4 boards, have 9 to go. It's very quick

onyx hinge
#

OK done

onyx hinge
devout jolt
onyx hinge
#

they have been making changes to their build process and requiring a lot more things to be explicit than before. so not that specifically but I guess I'm not surprised.

tulip sleet
#

did you pip3 install -r requirements-doc.txt

idle owl
onyx hinge
#

@devout jolt what were the socket constants that were needed for the UDP thing?

devout jolt
idle owl
#

No, I haven't run into that.

devout jolt
onyx hinge
#

@devout jolt and you were using which micro?

manic glacierBOT
#

while using circuitpython on a pi-zero, i discovered that the stack code code was broken
32bit was operating in dynamic stack mode, but reporting entirely wrong addresses for things
but i noticed, aarch64 on the broadcom port, puts the stack below the kernel load addr

so i just used kernel_address=0x100000 to change the load addr, for both 32bit and 64bit, raising it up a bit more
and made both 32bit and 64bit both have the stack below the kernel, allowing for the code to be simpler

buoyant lagoon
#

@tulip sleet and there is my initial fix, but i can see how its changing some files that people may not want to change...

tulip sleet
#

I will assign it to Scott to review

spice gate
buoyant lagoon
#

ive also only tested the build on a pi-zero, but i made changes that impact the pi3/pi4

manic glacierBOT
buoyant lagoon
#

i do have one of everything in the entire model range

tulip sleet
buoyant lagoon
#

youve also given me an idea on a further change to the makefiles

devout jolt
buoyant lagoon
#

its possible to make a single sd card image, that works on every pi model

#

shal i throw that into the same pr, or keep it for another pr?

tulip sleet
buoyant lagoon
#

now i need to find a better uSD for testing...

manic glacierBOT
#

This was verified by @todbot to work on esp32 s2 and s3; the constant should match any system that uses LWIP numbering.

It enables use of multicast UDP and gets rid of the need for this block in https://github.com/todbot/CircuitPython_MicroOSC/blob/main/microosc.py#L55:

if impl == "circuitpython":
    # these defines are not yet in CirPy socket, known to work for ESP32 native WiFI
    IPPROTO_IP = 0  # super secret from @jepler
    IP_MULTICAST_TTL = 5  # super secret from @jepl...
buoyant lagoon
#
root@d235fe3c2fdb:/circuitpython/ports/broadcom# for b in raspberrypi_pi4b raspberrypi_zero2w raspberrypi_zero_w; do make BOARD=$b ; done
Use make V=1, make V=2 or set BUILD_VERBOSE similarly in your environment to increase build verbosity.
QSTR not updated
Use make V=1, make V=2 or set BUILD_VERBOSE similarly in your environment to increase build verbosity.
QSTR not updated
Use make V=1, make V=2 or set BUILD_VERBOSE similarly in your environment to increase build verbosity.
QSTR not updated
root@d235fe3c2fdb:/circuitpython/ports/broadcom# ls */*.zip -lh
-rw-r--r-- 1 root root 13M Aug 21 21:07 build-raspberrypi_pi4b/firmware.disk.img.zip
-rw-r--r-- 1 root root 13M Aug 21 21:08 build-raspberrypi_zero2w/firmware.disk.img.zip
-rw-r--r-- 1 root root 13M Aug 21 21:08 build-raspberrypi_zero_w/firmware.disk.img.zip
#

these are the 3 main ones i can test

tulip sleet
#

@onyx hinge one odd build thing I noticed while testing is that some of the artifacts have all languages and some only have english. I know microdev set it to build only en_us, but it doesn't seem to be consistent. Not sure if that is new or not. It might be uf2 vs not, i haven't investigated yet

buoyant lagoon
#

ive written a dwc2 HCD in another kernel, so pi1b usb-host could be a future possibility

#

then you just plug in a usb keyb and go to work!

#

raspberrypi_zero2w is next, thats aarch64, so its covering what i didnt test, but is largely the same

tulip sleet
#

we are doing work in other ports on usb host, as you have probably seen

buoyant lagoon
#

yeah

#

i briefly tested the pio-usb on a pico

#

still need to investigate the double-setup issue tannet had

onyx hinge
tulip sleet
#

yes, and it is not uf2 vs bin

#

maybe it is initial push vs subsequent, but not sure that makes sense

onyx hinge
#

if you look at the log of an affected board does it build the translations?

tulip sleet
#

haven't looked yet; doing the last board and then I'll look

#

all boards test fine except Spresense, but there is some version skew with the bootloader, so I'm not sure it has anything to do with this.

buoyant lagoon
#
Adafruit CircuitPython 8.2.0-46-g01595c900-dirty on 2023-08-21; Raspberry Pi Zero 2W with bcm2837
>>> 
>>> help()
Welcome to Adafruit CircuitPython 8.2.0-46-g01595c900-dirty!

Visit circuitpython.org for more information.

To list built-in modules type `help("modules")`.
buoyant lagoon
#

@tulip sleet zero2w also works, so i expect pi3 to also work...

tulip sleet
buoyant lagoon
#

sorta, hdmi is blank

tulip sleet
#

as an example

onyx hinge
#

@tulip sleet there's some logic that leads to this: tools/build_release_files.py: print("Skipping languages")

#
            try:
                with open(
                    f"../ports/{board_info['port']}/{build_dir}/firmware.size.json", "r"
                ) as f:
                    firmware = json.load(f)
                    if firmware["used_flash"] + LANGUAGE_THRESHOLD < firmware["firmware_region"]:
                        print("Skipping languages")
                        break
manic glacierBOT
tulip sleet
#

oh, it skips big ones

onyx hinge
#

"if the build has plenty of room don't bother building other languages"

tulip sleet
#

ok never mind

buoyant lagoon
#
>>> ��Serial console setup
allocate_stack()
fixed stack
setting canary
allocate_stack() done
stack_init() done
Adafruit CircuitP
#

hangs mid-boot, but its not a supported model, so i can skip it for now

tulip sleet
#

i forgot about the conditionalizing about the builds, to catch overflows

buoyant lagoon
#

that just leaves the 4

tulip sleet
#

@onyx hinge Anyway, all boards are fine except spresense, so I'd say let's merge after any further updates

#

we would want the updated asyncio library submodule, that's it, I think

onyx hinge
#

OK! thanks so much for testing. sitting down and iterating through a bunch of boards is a discipline I just can't find on any given day.

buoyant lagoon
#

pi4 is failing

#

@tulip sleet pi4 boots and has a working repl on hw uart
but usb-device isnt working, dont think i did that

#

hdmi is also not working

manic glacierBOT
manic glacierBOT
tulip sleet
#

@onyx hinge - should we merge, or wait until some number of people try the artifacts?

idle owl
#

(I'm not the one you asked.)

tulip sleet
#

i understand your sentiments 🙂

idle owl
#

I mean, when it comes down to it, we're breaking things, and so on. We might as well get it out there and find out what else we broke.

#

Folks are far more likely to test main than a PR.

#

And it's already not even alpha. So we're not making any guarantees.

#

So, while I'm being silly about it, I do have reasons for the sentiment. 🙂

tulip sleet
#

@onyx hinge I'm happy to merge now - I agree a build in S3 is worth many in artifacts

manic glacierBOT
#

CircuitPython version

Any raspberry_pi_pico_dv_base firmware, including 8.2.3: adafruit-circuitpython-pimoroni_pico_dv_base-en_US-8.2.3.uf2
But also 8.1.0 and a few other (see below).

Code/REPL

none

Behavior

n/a

Description

I think there is something broken with the "Pico DV" (from Pimoroni) specific CP image (from https://circuitpython.org/board/pimoroni_pico_dv_base/ ).
I don't see the CIRCUITPY drive after flashing two of my Pico (not ...

onyx hinge
#

Merge!

manic glacierBOT
#

The issue on the Pimoroni forum was that the Pico W doesn't work without a bodge to CP, the Pico was working just fine last time I tested. I'll pull the latest bits and check it out.

Yes please, have a look... I am going crazy with this, I was planning a quick sound test before sleeping and fighted for more than 30 minutes.

Now checking Tod guide and pinout of the Pico DV Base... to at least have a beep. :-)

wraith crow
#

The DV Base uf2 you posted does boot up with DVI output for me. My build machine is fighting me so I haven't yet checked out the failing builds.

tulip sleet
#

I don't see any video on my 1920x1200 monitor with DVI, but I've never tried this before

#

oh, now it's working, some old code.py was making it not work

thorny jay
#

That was fast, now I have sound and image. I plan to play more synthio with that setup as my DIY solution is a bit fragile (and loud) with my speaker attached.

#

Time to sleep.

onyx hinge
#

my remark about other people testing meant I wanted it merged.

wraith crow
#

Did #7922 merge into a branch other than main and recently get moved? I could have sworn that I ran the DV base with a current build in late July, but #7922 was back in April. Just hoping for explanation other than losing my mind :/

#

Maybe I only attempted a Pico W build (which I didn't really expect to work anyway). I should probably try that built again now that this fix is known 😄

tulip sleet
#

maybe you were testing with manually created displays?

wraith crow
#

Not sure, maybe I had some stale code, but probably just never built the standard Pico version since the question came up about the W. Good news though, with your resolution fix, the Pimoroni base does seem to build for the Pico W now. I'm going to do some more testing and hopefully submit the PR 😄

#

Now I just have to remember how to create a CP branch in my MicroPython fork.... :/

onyx hinge
#

@tulip sleet I'll look into it.

#

@tulip sleet it's because of this line I added, which makes it try to "call into" esp-idf build routines when parsing Makefile ... PR builds didn't catch it because a change to a platform Makefile doesn't cause docs to be built.

Makefile: $(BUILD)/esp-idf/config/sdkconfig.h

tulip sleet
#

ye olde builds ? 🙂

#

missing "r" there

manic glacierBOT
onyx hinge
#

but of course this won't TEST doc building during the CI 😕 @tulip sleet if you tested doc building locally did you get the error?

tulip sleet
#

let me try again, I think it was fine

#

it was fine before i merged from upstream, I think I didn't have your change

#

fails in the same way make[1]: *** [Makefile:358: build-adafruit_feather_huzzah32/esp-idf/config/sdkconfig.h] Error 1 plus a lot of previous stuff

#

I think this is because esp-idf/export.sh was not run?

onyx hinge
#

it shouldn't have to be

tulip sleet
#

I need to clean this up a bit, brb

#

this multiple times:

raceback (most recent call last):
  File "/home/halbert/.local/lib/python3.10/site-packages/sphinx/config.py", line 354, in eval_config_file
    exec(code, namespace)  # NoQA: S102
  File "/home/halbert/repos/circuitpython/conf.py", line 54, in <module>
    modules_support_matrix = shared_bindings_matrix.support_matrix_by_board()
  File "/home/halbert/repos/circuitpython/docs/shared_bindings_matrix.py", line 378, in support_matrix_by_board
    [board for matrix in mapped_exec for board in matrix], key=lambda x: x[0]
  File "/home/halbert/repos/circuitpython/docs/shared_bindings_matrix.py", line 378, in <listcomp>
    [board for matrix in mapped_exec for board in matrix], key=lambda x: x[0]
  File "/usr/lib/python3.10/concurrent/futures/_base.py", line 621, in result_iterator
    yield _result_or_cancel(fs.pop())
  File "/usr/lib/python3.10/concurrent/futures/_base.py", line 319, in _result_or_cancel
    return fut.result(timeout)
  File "/usr/lib/python3.10/concurrent/futures/_base.py", line 458, in result
    return self.__get_result()
  File "/usr/lib/python3.10/concurrent/futures/_base.py", line 403, in __get_result
    raise self._exception
  File "/usr/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/halbert/repos/circuitpython/docs/shared_bindings_matrix.py", line 306, in support_matrix
    settings = get_settings_from_makefile(str(port_dir), entry.name)
  File "/home/halbert/repos/circuitpython/docs/shared_bindings_matrix.py", line 192, in get_settings_from_makefile
    raise RuntimeError(error_msg)
RuntimeError: Invoking 'make -C /home/halbert/repos/circuitpython/ports/espressif -f Makefile BOARD=adafruit_feather_huzzah32 print-CFLAGS print-CIRCUITPY_BUILD_EXTENSIONS print-FROZEN_MPY_DIRS print-SRC_PATTERNS' exited with 2: make[1]: warning: jobserver unavailable: using -j1.  Add '+' to parent make rule.
CMake Error at esp-idf/tools/cmake/project.cmake:296 (__project):
  The CMAKE_C_COMPILER:

    xtensa-esp32-elf-gcc

  is not a full path and was not found in the PATH.

  Tell CMake where to find the compiler by setting either the environment
  variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
  the compiler, or to the compiler name if it is in the PATH.
Call Stack (most recent call first):
  CMakeLists.txt:19 (project)

onyx hinge
#

or it may depend on whether the esp-idf submodule is populated

tulip sleet
#

it is populated in my tree

#

but it shouldn't have to be, to just build the docs

#

now I did esp-idf/export.sh, and it is running a zillion cmakes

#

well, 12

#

now make

#

it did a whole espressif build in the middle of building the docs

onyx hinge
#

It does invoke make a bunch of times, to get make's final idea of what the makefile variables are

#

but it shouldn't "do" anything like generate targtets; my hasty change cuased it to do that

tulip sleet
#

it took a long time to do that

onyx hinge
#

take a look at the PR I opened

#

yeah it's not fast even when it's not messed up. unfortunately.

tulip sleet
#

why do we need that?

#

or more precisely, why did we not need it before?

#

why is it descending into ports/espressif/Makefile at all?

onyx hinge
#

we did need it before. make is our configuration language for boards, so the only ultimately accurate way to get information about which modules are enabled is to invoke make and inspect its output (things like make -C ports/... BOARD=... print-CFLAGS

tulip sleet
#

so did it used to do this before, but more quickly?

onyx hinge
#

what I broke is that with my change in ports/espressif/Makefile, make print-CFLAGS caused a lot more work to be done, including work that required esp-idf environment to be set, ran cmake, etc.

tulip sleet
#

ah, ok, so it should be back to how it wsa before?

onyx hinge
#

this e.g., time make -C ports/atmel-samd/ BOARD=trinket_m0 print-CFLAGS is about 150ms, but when you multiply that by all the boards it is a substantial amount of work

tulip sleet
#

i have an old repo of adafruit/circuitpython from before this merge, I just did a time make html. Will do the same in your PR barnch.

onyx hinge
#

OK

tulip sleet
#

no problem: just about a minute for either old or the PR. So I'll approve the PR

onyx hinge
#

which just failed 😦 😦 ```
reading sources... [ 1%] BUILDING
reading sources... [ 1%] CODE_OF_CONDUCT
reading sources... [ 2%] CONTRIBUTING
reading sources... [ 3%] README

Traceback (most recent call last):
File "/home/docs/checkouts/readthedocs.org/user_builds/circuitpython/envs/latest/lib/python3.11/site-packages/sphinx/events.py", line 96, in emit
results.append(listener.handler(self.app, *args))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/docs/checkouts/readthedocs.org/user_builds/circuitpython/checkouts/latest/docs/rstjinja.py", line 13, in rstjinja
if "shared-bindings/support_matrix" not in docname:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: argument of type 'NoneType' is not iterable

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

tulip sleet
#

bleh

onyx hinge
#

OK I get that when upgrading to current sphinx. I previously had 6.2.1, current is 7.2.2.

manic glacierBOT
#

The following error would occur otherwise

Traceback (most recent call last):
  File "/home/docs/checkouts/readthedocs.org/user_builds/circuitpython/envs/latest/lib/python3.11/site-packages/sphinx/events.py", line 96, in emit
    results.append(listener.handler(self.app, *args))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/docs/checkouts/readthedocs.org/user_builds/circuitpython/checkouts/latest/docs/rstjinja.py", line 13, in rstjinja
    if "shared-bindings/su...
tulip sleet
#

was it returning "" before? I guess it's an easy fix.

onyx hinge
#

I'm not 100% sure

#

will want to fix this in 8.2.x as well, maybe don't merge that? but I'm done for the night.

#

in fact let's not use that fix

tulip sleet
#

I was just thinking that

#

we have a pile of stuff to merge up from 8.2.x to main anyway

onyx hinge
#

there are some conflicts including in this file.

tulip sleet
#

tomw I think I will do a little more asyncio testing with 8.2.x and the updated library

onyx hinge
#

in 8.2.x I added the ability to tag a doc file content to say "I want jinja templating to run on this file". The "check for substring of path" can be removed once we add that mark to shared_bindings_matrix.rst or whatever it's called.

#

origin/8.2.x:shared-bindings/busio/__init__.c://| .. jinja

manic glacierBOT
wraith crow
#

It looks to me like the micropython 1.19.1 merge may have applied some of the leading 'u' to module names. I don't seem to be able to import json anymore but ujson works.

manic glacierBOT
#

CircuitPython version

Adafruit CircuitPython 8.2.3 on 8/21/2023; DOIT ESP32 Development Board

Code/REPL

import analogio
from board import *

pin = analogio.AnalogIn(D32)
print(pin.value)
pin.deinit()

Behavior

Resulting value is always 2819, regardless of whether pin is floating or connected to a sensor, 3v3, or GND

Description

Tested on a few analog pins, all behave the same. Using pin D32 because no analog pins appear in dir(board)

#...

#

CircuitPython version

Adafruit CircuitPython 8.2.0-80-g282e93d3e3-dirty on 2023-08-22; Pimoroni Pico DV Base W with rp2040

Code/REPL

import json

Behavior

Traceback (most recent call last):
File "", line 1, in
ImportError: no module named 'json'

Description

Entering

import ujson

works fine

Additional information

I looked through the extmod directory and looked for other modules that might have the same issue and di...

manic glacierBOT
#

I ran into the same problem when writing some tutorials.

In order to display the degree character in builtin font, I wrote a small wrapper that tries to load the character from an external birmap font when the character is not found in builtin.

Then I extracted the degree glyph in FontForge from https://github.com/adafruit/circuitpython/blob/70ce576390c7b21007b1f75f16e6fc591c0f61d7/tools/fonts/ter-u12n.bdf and created tiny bdf file contains only that glyph.

import terminalio
fr...
manic glacierBOT
#

split from https://github.com/adafruit/circuitpython/issues/7919#issuecomment-1560795024

allow for arrays for pull and value_when_pressed -
so we can use the same object for all three buttons -
i came across this need for the Adafruit ESP32-S3 Reverse TFT Feather
as on these Button D0 is opposite to D1 & D2 for the sake of deep-sleep wake-up..

this is found on the following boards:

manic glacierBOT
manic glacierBOT
#

Brilliant, thanks @dhalbert. I'll be pushing the changes to reflect these details soon.

Also thanks for pointing me at the CPX/CPB boards, the way frozen libraries are handled is really straightforward now that I see an example. I think the best way forward would be to add the necessary drivers to a separate repo, and add that as a submodule, then finally add them as frozen modules to this board. I understand that this wouldn't necessarily be the preferred way of doing things, but since...

#

split from https://github.com/adafruit/circuitpython/issues/7919#issuecomment-1561834487

allow for digitalio.DigitalInOut, adafruit_tca8418.DigitalInOut, adafruit_74hc595.DigitalInOut and the like.
This way we can remove shift register scanner from keypad library altogether without losing shift register support and still gain support for shift register or mixed matrices.

usage idea - all these examples should work..

based on [tutorial one button](https://learn.adafruit.com/key-pad...

manic glacierBOT
manic glacierBOT
onyx hinge
#

@tulip sleet I notice that uncrustify.cfg changed, presmuably due to the 1.19 merge? ```diff
-sp_after_comma = ignore # ignore/add/remove/force
+sp_after_comma = add # ignore/add/remove/force

tulip sleet
#

must be - I didn't change that. That would explain all those changes. I prefer the 'add'

onyx hinge
#

I do too

tulip sleet
#

I am doing a lot of stuff to fix #8314, removing u a bunch of places, including in ports/unix tests and stuff. Also removing unused tests like usocket, etc. to reduce the number of skipped tests

onyx hinge
#

OK, that sounds good.

tulip sleet
#

it's jumping the gun a bit on what will be in v1.21. I am not renaming the files to drop the u. The merge can do that.

onyx hinge
#

there's supposed to be code in the import path that allows import json to pick up ujson, but it must not be working in cp; but we also want help() and import <tab> to work

#

that works in micropython-coverage but I guess not in circuitpython per the user report?

#
True
tulip sleet
#

I'm not sure where the extra module defs were, but just making (almost) everything not-u is working. There are testfile changes, but those will start matching micropython by v1.21

#

so coverage is not going to be special here either. We still need moduos for certain things

onyx hinge
#

what I'm saying is, in the testing environment import json works

#

so it's weird that it didn't work on devices

#

ah it's subject to #if MICROPY_MODULE_WEAK_LINKS

tulip sleet
#

aha, ok, well, I am removing import ujson as possible now, and changing the tests to match

onyx hinge
#

that's fine by me

manic glacierBOT
#

I think there are some good ideas here! Thank you for raising this feature request.

That said, I'd like to give some context on why this is implemented as it is.

It's worth acknowledging that the implementation that is ONLY compatible with a microcontroller.Pin object is certainly the easiest implementation! and that is no doubt part of why it's that way.

Another less obvious thing about keypad is that the scanning happens in what we call the "background task" context. At the mom...

#
  • Fixes #8314 and then some

There were some accidental reversions to u-prefixes due to MP_REGISTER_MODULE() changes. But some tests still depended on u prefixes. I took the leap of removing all the u prefixes, getting most of the way toward https://github.com/micropython/micropython/pull/9069, which does the same thing in MicroPython.

#

@jepler Thanks for the comments.

A few more comments:
keypad is implemented in C to do the background scanning and debouncing. The debouncing in particular requires low latency. For TouchIn, and maybe even shift registers, scanning could instead be done in CircuitPython code. Right now there isn't a clean way to do this, but if the EventQueue were made more general so that events could be added from Python, I think that would help. Then we could add keypad-style libraries coded in...