Combined sleep fixes #3127
No reviewers
Labels
No labels
bazel
bluetooth
board settings
boot_stage2
bug
build
c++
can't reproduce
clang
clib-interface
cmsis
code cleanliness
code size
compiler version issues
cyw43_driver
debug
discussion
documentation
duplicate
dynamic_clock
elf2uf2
enhancement
errata
filesystem
flash layout
floating point
FreeRTOS
hardware_adc
hardware_claim
hardware_clocks
hardware_dma
hardware_exception
hardware_flash
hardware_gpio
hardware_i2c
hardware_irq
hardware_pio
hardware_pwm
hardware_rcp
hardware_rtc
hardware_spi
hardware_sync
hardware_uart
hardware_vreg
hardware_watchdog
hardware_xosc
help wanted
host
IAR
installation
invalid
linker scripts
lto
lwip
mbedtls
missing API
needs reporter detail
networking
newlib
newlib-multicore
non-c
non-cmake
non-gcc
openocd
orphan PR
OS integration
pico_async_context
pico_base
pico_binary_info
pico_flash
picolibc
pico_lwip
pico_malloc
pico_multicore
pico_printf
pico_runtime
pico_stdio
pico_stdio_usb
pico_sync
pico_time
pico_util
pioasm
port
question
review
review2
rtos interop
runtime init
static library
svd
test
tinyusb
vscode
wifi integration
wontfix
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-raspberrypi/pico-sdk!3127
Loading…
Reference in a new issue
No description provided.
Delete branch "combined-sleep-fixes"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Against usual tradition, this is worth landing as individual commits, however keeping here for review.
@Wren6991 please pile any (we expect comment only) changes in a new PR on top
@ -18,6 +18,11 @@#include "pico/config_autogen.h"// PICO_CONFIG: PICO_PLATFORM_STRING, Name of platform as a string; defaulted to "unknown" if the build does not set it, group=pico_baseThe code in
tools/extract_configs.pywill assume that anyPICO_CONFIG:without an explicittype=, is of typeint. I guess I ought to add support fortype=string?Hmm, looks like
PICO_CONFIG: PICO_CONFIG_RTOS_ADAPTER_HEADERbelow should also betype=string🙂Is it worth adding a
PICO_ARCH_STRING, or is that not needed? (because it can be inferred fromPICO_PLATFORM_STRING?)No, we don't really want people decoding strings at runtime to infer booleans.
PICO_PLATFORM_STRINGlooks to me to be a human-readable convenience and we shouldn't make it (ugh) load-bearingYeah, I think I kind of meant "inferred by the human reading the logfile output", rather than "inferred by code at runtime". Maybe.
In case it clarifies things, I was referring specifically to this part of the diff:
I was wondering if somebody might want the ability to do e.g,
yeah tbc - this is PICO_PLATFORM as a string... note i thought there were already some string PICO_CONFIGS?
@ -18,6 +18,11 @@#include "pico/config_autogen.h"// PICO_CONFIG: PICO_PLATFORM_STRING, Name of platform as a string; defaulted to "unknown" if the build does not set it, group=pico_baseThat one looks to me like it's a bare macro that gets expanded and stringified by the preprocessor, not a C string. So:
yields:
This isn't the same thing as a C string literal. Maybe we shouldn't infer
intfor configs with unspecified types.@ -18,6 +18,11 @@#include "pico/config_autogen.h"// PICO_CONFIG: PICO_PLATFORM_STRING, Name of platform as a string; defaulted to "unknown" if the build does not set it, group=pico_baseI'd be more than happy to modify my config-extraction scripts to insist that a
type=is always present, but note thatgit grep "PICO_CONFIG:" | grep -v "type=" | wc -lreports that there are currently 88 such instances.Okay, so could you suggest a suitable
type=to be used in this instance?"cannot block": is this true? IRQs are enabled inside of the
spin_unlock. An interrupt could be immediately taken, and consume the event before the WFE executes. Should this instead be:It's probably safe on Armv8-M because it sets the event register on return from any non-fault exception, but on Hazard3 it's only set by
__h3_unblock()(including from the same core due to external loopback).@ -18,6 +18,11 @@#include "pico/config_autogen.h"// PICO_CONFIG: PICO_PLATFORM_STRING, Name of platform as a string; defaulted to "unknown" if the build does not set it, group=pico_baseMy point is there is not always a suitable type, and plastering
inton things with unspecified types doesn't help.@ -13,6 +13,15 @@const absolute_time_t ABSOLUTE_TIME_INITIALIZED_VAR(nil_time, 0);Already pointed this out in another comment, but Claude was wrong here: it can be consumed by an IRQ on RISC-V. (I'm going to strip out all the slop comments, but pointing out the issue before I do.)
@ -18,6 +18,11 @@#include "pico/config_autogen.h"// PICO_CONFIG: PICO_PLATFORM_STRING, Name of platform as a string; defaulted to "unknown" if the build does not set it, group=pico_basefilenameorpathwould work here but it's not really general.Fixed by 971351f, which just swaps the
__wfe()with the precedingcsrs mstatus/msr PRIMASK.To hit this in practice you'd have to have a
h3.blockinside an IRQ handler (or in a switched-to context), which would be odd, but anyway I'm pretty sure it was a bug.@ -269,4 +329,4 @@}index = next;}}Potentially a regression here: The negative target forced us to continue looping, but that is no longer the case. If multiple alarms are deleted, and there are other entries with target times earlier than the deleted alarms' target times, then the non-deleted alarms can get stranded.
Potential fix is to force the loop to continue while there are deleted entries at the head:
@ -269,4 +329,4 @@}index = next;}}Resolved by
f2fc82b, which pushes the deleted entries straight to the free list instead of doing the weird shuffle-to-front.@ -0,0 +35,4 @@* distinguish the two. A wait that really blocks takes 1-5 iterations; a busy-poll runs to* thousands.** NOTE: keep these in step with mutex.c, as pico_sync_test.c already has to.This test uses a copy/pasted version of the
mutexprimitive. It doesn't cover the version in the SDK that people actually use. The comment here in the test will be missed by anyone who changes the SDK implementation. The implementation has a comment pointing topico_sync_test, a different test which also now has a copy/pastedmutex.Maybe this instrumentation should be added to the SDK implementation (either guarded by or injected through macros) rather than hoping things will stay in sync.
@ -190,6 +190,100 @@ static const test_t tests[] = {},I think this should be deleted. It's "testing" a fact about the hardware that we simply know to be true. The fact Claude wanted to confirm it while debugging does not make it a meaningful test we should carry forward in the SDK. Also this part:
...is simply false, and we shouldn't leave something misleading like that lying around.
@ -264,2 +265,3 @@picotest_error_code |= issue_2148_test();issue_2186_test();picotest_error_code |= issue_2186_test();"the scan" here refers to the two-pass deletion code that was removed in the same batch of commits, so I don't think this is useful context to anyone reading this file in the future.
@ -190,6 +190,100 @@ static const test_t tests[] = {},Probably just revert or rebase out the commit that added this:
27aa1bd96Claude's commit message for that commit is also false. AMOs do take reservations.
I think the functional changes as of
f2fc82bare all correct, and fix some severe bugs.The copy/pasted mutex implementations in the new sync tests should ideally be linked to the actual SDK implementations, and I think it's worth cleaning up the things I flagged in the tests that will confuse us when we read them later.
Other than that LGTM.
@ -190,6 +190,100 @@ static const test_t tests[] = {},i think i'm gonna keep it because it is verifying a fact about the SDK define being set correctly, but i will fix the other issues