Pi Pico support #193

Merged
peri4 merged 58 commits from pico_sdk into master 2026-09-05 23:13:14 +03:00
Owner
No description provided.
andrey added 2 commits 2025-10-18 11:21:10 +03:00
andrey added 1 commit 2026-01-02 20:48:41 +03:00
andrey added 3 commits 2026-03-29 19:48:38 +03:00
andrey added 3 commits 2026-08-11 14:36:50 +03:00
Replace monolithic MICRO_PIP/PIP_MICRO with granular flags:

Feature flags (CMake options + platform auto-detection):
- PIP_NO_FILESYSTEM, PIP_NO_THREADS, PIP_NO_SOCKET
- PIP_NO_PROCESS, PIP_NO_DYNLIB, PIP_NO_FFT, PIP_NO_SERIAL

Embedded optimization flag:
- PIP_EMBEDDED (auto-set for Pico SDK and FreeRTOS)
  Controls buffer sizes, time stubs, terminal fallback, init stubs

Platform blocks in CMakeLists.txt:
- Pico SDK: auto-disables FS, PROCESS, DYNLIB, FFT, SERIAL;
  conditionally disables THREADS (no FreeRTOS) and SOCKET (no LWIP)
- FreeRTOS: auto-disables FS, PROCESS, DYNLIB, FFT, SERIAL;
  conditionally disables SOCKET (no LWIP)
- Android: auto-disables PROCESS, DYNLIB, FFT

Updated 96 files across libs/, utils/, tests/, and CMakeLists.txt.
Builds verified for Linux (547 tests pass) and Pico SDK (100%).
Removed all MICRO_PIP and PIP_MICRO references (0 remaining).
andrey added 2 commits 2026-08-11 16:14:12 +03:00
- piconditionvar.h: remove phantom wait(lk, timeout) stubs not in real class
- pithread.h: remove duplicate #ifndef PIP_NO_THREADS guard
- piscreendrawer/tile/tiles.cpp: remove duplicate #if !defined(PICO_SDK)
- cmake/FindPIP.cmake: replace PIP_MICRO with PIP_EMBEDDED
peri4 marked the pull request as ready for review 2026-08-11 17:39:41 +03:00
andrey marked the pull request as work in progress 2026-08-11 18:53:54 +03:00
andrey added 1 commit 2026-08-11 18:54:15 +03:00
andrey added 1 commit 2026-08-11 20:10:25 +03:00
All feature flags now use positive naming (enabled by default):
- PIP_HAS_FILESYSTEM, PIP_HAS_THREADS, PIP_HAS_SOCKET
- PIP_HAS_PROCESS, PIP_HAS_DYNLIB, PIP_HAS_FFT, PIP_HAS_SERIAL

Preprocessor guards inverted:
- #ifndef PIP_NO_X → #ifdef PIP_HAS_X
- #ifdef PIP_NO_X → #ifndef PIP_HAS_X

CMake options default ON instead of OFF.
Platform blocks set flags OFF to disable features.

85 files transformed via Python script + 2 manual fixes.
andrey added 2 commits 2026-08-11 22:56:12 +03:00
andrey added 1 commit 2026-08-12 14:04:54 +03:00
andrey added 1 commit 2026-08-12 17:04:19 +03:00
andrey added 1 commit 2026-08-12 18:23:57 +03:00
andrey added 1 commit 2026-08-12 18:54:35 +03:00
andrey added 14 commits 2026-08-23 09:25:53 +03:00
- invert friend block in piobject.h (friends needed when introspection
  is enabled) and remove dead friend PIObjectManager
- guard PIObject::dump()/dumpApplication()/dumpApplicationToFile()
  declarations and definitions by PIP_INTROSPECTION
  (dumpApplicationToFile additionally requires PIP_HAS_FILESYSTEM)
- guard dumpApplicationToFile() call in __sighandler__ by
  PIP_INTROSPECTION && PIP_HAS_FILESYSTEM
- replace '#if defined(PIP_INTROSPECTION) && !defined(PIP_FORCE_NO_PIINTROSPECTION)'
  with plain '#ifdef PIP_INTROSPECTION' everywhere, remove PIP_FORCE_NO_PIINTROSPECTION
- fix broken PIINTROSPECTION_CONTAINER_ALLOC(T, (as - ...)) in
  pideque.h/pivector.h ('as' no longer exists, use new_rsize)
The stub member definitions lived in the header and were picked up by
every TU including piinit.h, causing multiple-definition link errors in
embedded (PIP_EMBEDDED) builds. Definitions now live only in piinit.cpp;
the stub implementation is compiled in the '#else' branch guarded by
PIP_HAS_THREADS (no-PIInit builds are unchanged).
- pistatemachine_base.h checked non-existent macros __GXX_RTTI__/__RTTI__,
  so on GCC/Clang desktop builds formatHash() always returned 0 and the
  guard signature check in testGuard() never fired (UB on incompatible
  signatures). Now the real PIP_HAS_RTTI (pibase_macros.h) is used.
- no-RTTI fallback: each Function<Args...> instantiation takes a unique
  hash from a process-wide counter (a per-instantiation counter would
  give every signature the same hash on first call).
- __pip_typename__ primary template: replace hard static_assert with a
  generic fallback; containers/stream operators instantiate it for
  arbitrary T in no-RTTI builds (Pico/arm-none-eabi has no RTTI), so the
  assert made any no-RTTI build impossible. Explicit
  __PIP_TYPENAME_DECLARE specializations still take precedence.
- drop the ANDROID_PLATFORM block forcing PROCESS/DYNLIB/FFT off:
  Android has /proc and dlopen and these features worked there in master
- __sighandler__: wrap PIProcess::currentPID() by PIP_HAS_PROCESS (0
  fallback), the dumpApplicationToFile() call itself is already guarded
  by PIP_INTROSPECTION && PIP_HAS_FILESYSTEM
- PISystemMonitor: guard /proc-related members (proc_dir/file/filem) and
  code paths (startOnProcess, run() non-Windows part, gatherThread /proc
  reader) by PIP_HAS_PROCESS/PIP_HAS_FILESYSTEM so the file compiles for
  any flag combination, e.g. -DPIP_HAS_PROCESS=OFF -DPIP_HAS_FILESYSTEM=OFF
- merge the PICO_BOARD and PIP_FREERTOS blocks (90% duplicate) into one
  embedded block; Pico+PICO_FREERTOS now adds -DPIP_FREERTOS so
  pithread.cpp takes the FreeRTOS path instead of POSIX pthreads;
  restore set(ICU OFF)/set(LOCAL ON) for FreeRTOS/embedded targets
- auto-disable dependent flags when PIP_HAS_THREADS=OFF:
  PIP_HAS_PROCESS, PIP_HAS_SERIAL (PIProcess derives from PIThread,
  PISerial/PIIODevice use PIThread) and INTROSPECTION (walks threads)
- LIBS_MAIN: link dl only with PIP_HAS_DYNLIB, pthread/util/rt only with
  PIP_HAS_THREADS (rt was never linked on APPLE), socket on QNX_HOST only
  with PIP_HAS_SOCKET; WIN32 list untouched - arm-none-eabi has no
  libdl/libpthread/librt so Pico firmware links again
- collapse repeated 'NOT DEFINED PICO_SDK_PATH' utils checks into
  _PIP_HOST_TOOLS variable
- FindPIP.cmake: check PIP_FREERTOS instead of the never-set
  PIP_EMBEDDED CMake variable (as in master)
- drop unused set(PIP_MICRO ON) from esp-pip
- wrap PIGrabberBase/PIPipelineThread in #ifdef PIP_HAS_THREADS like
  pithread.h so 'pip.h' compiles in no-threads builds
Declarations of PIConfig(PIString, DeviceMode), PIConfig(PIString,
PIStringList) and open(PIString, DeviceMode) now match their
filesystem-guarded definitions in piconfig.cpp (link error otherwise);
the path constructor definition is guarded as well since it calls the
guarded open(). String/device based overloads stay unguarded.
- pifile.cpp: drop '|| !defined(PIP_HAS_FILESYSTEM)' from the
  _fopen_call_ condition and the redundant inner
  '#ifdef PIP_HAS_FILESYSTEM' - the whole file is already inside
  PIP_HAS_FILESYSTEM
- remove PISERIAL_NO_PINS (piplatform.h, piserial.cpp): the whole
  piserial.cpp is inside PIP_HAS_SERIAL which is forced OFF for
  Pico/FREERTOS, so the macro could never be active where it mattered;
  keep the Windows/POSIX branches as-is
Found while verifying -DPIP_HAS_THREADS=OFF / -DPIP_HAS_FILESYSTEM=OFF
smoke builds (pre-existing gaps of the branch):

- piinit.cpp: full implementation now requires PIP_HAS_THREADS as well
  (the PIInit class is declared in piinit.h only with threads; without
  threads PIInit is absent altogether, stub/absent branches unchanged)
- PIWaitEvent: drop the PIP_HAS_THREADS guard - it is a plain
  pipe/select/WaitForMultipleObjects wrapper with no thread usage
  (master had no guard), restores unistd.h include for PICAN etc.
- PIEthernet: guard server_thread_ member, server_func(), threaded
  listen/stop parts and writeThreaded() calls by PIP_HAS_THREADS
- PIPeer: guard class/impl by PIP_HAS_THREADS (uses PIThread/PITimer/
  PIDiagnostics), openDevice() /etc/pip.conf read by PIP_HAS_FILESYSTEM
- PIBinaryLog::restart(): guard threaded-read restart by PIP_HAS_THREADS
- PIIODevice::configure(config_file,...), PIConnection::configureFromConfig,
  PIConfig include resolution: guard path-based bodies by PIP_HAS_FILESYSTEM
- PISerial::availableDevicesInfo(): guard /dev and /proc/tty scan by
  PIP_HAS_FILESYSTEM
- PIHIDevice impl: requires filesystem (sysfs scan) in addition to threads
- PIPluginLoader::pluginsDirectories/findLibrary: guard PIFile/PIDir use
  by PIP_HAS_FILESYSTEM (fallback: empty list / path as-is)
- guard console subsystem (PIScreen/PIScreenTile/tiles/PITerminal/
  PIKbdListener) by PIP_HAS_THREADS plus a TTY or Windows console
  (new PIP_HAS_TTY platform macro) - termios is not available on
  bare-metal newlib
- guard cloud subsystem (PICloudBase/Client/Server/TCP) by
  PIP_HAS_SOCKET and PIP_HAS_THREADS
- add PIP_BUILD_CONSOLE/PIP_BUILD_CLOUD to the auto-disable flag
  dependencies in CMake
- PIP_CAN (SocketCAN) is Linux-only, exclude other platforms
- on Pico keep sockets/MQTT off by default: pico-sdk lwip provides
  only a partial POSIX socket layer (no netinet/in.h, poll.h)
- PITranslator: inline no-op definitions when PIP_HAS_FILESYSTEM is
  off so the _tr literal links
- PIIODevice: guard read_func/write_func EVENT_HANDLERs (no-threads)
- piwaitevent_p.cpp: drop unused sys/ioctl.h include (missing on
  arm-none-eabi, broke Pico builds)
- CMake: disable thread/socket-dependent modules (http_client, mqtt_client,
  client_server) and fftw when the required feature flags are off;
  client_server/cloud no longer tied to the crypt option
- host utils gated on filesystem and the modules they need
- Pico keeps the minimal set; generic FreeRTOS (ESP32) keeps filesystem,
  sockets and serial as in master, module set limited to crypt/compress/io_utils
- PICAN, PIBroadcast, PIPackedTCP vanish without socket+threads
- PISerial: restore PISERIAL_NO_PINS (auto-enabled on PIP_EMBEDDED)
- PIFile: FREERTOS uses fopen/stat (no fopen64 in ESP-IDF newlib)
- drop invalid PICout buffer guards, guard PIObject::deleteLater,
  remove (void)destroying hack, fake PIHIDevice non-Linux stub and the
  redundant PICO_SDK guard in code_model_generator
- move __PIP_TYPENAME_DECLARE() calls inside PIP_HAS_* guards so -fno-rtti
  builds compile with arbitrary reduced flag combinations
- guard PISerial declaration by PIP_HAS_SERIAL like other feature-gated classes
- reduce threaded read buffers to 1 KiB on embedded targets (PIIODevice,
  PIPacketExtractor, PIEthernet)
andrey added 1 commit 2026-08-23 17:19:42 +03:00
andrey marked the pull request as ready for review 2026-08-23 17:20:08 +03:00
andrey added 1 commit 2026-08-24 19:37:39 +03:00
- Rename __PIP_TYPENAME_DECLARE to PIP_REGISTER_TYPENAME across all headers
- Add PIP_DECLARE_TYPENAME(name) macro for in-class type name declaration
- Replace all static const char * __pip_typename__() member functions with PIP_DECLARE_TYPENAME
andrey added 2 commits 2026-08-25 15:04:48 +03:00
Replace the ad-hoc if-blocks with a PIP_HAS_DEPS_<feature> dependency table
(analogous to __deps_* module dependencies in FindPIP.cmake) resolved to a
fixpoint. The table now also covers http_server (threads+socket) and fftw
(has_fft), and adds the hard client_server/cloud -> io_utils module
dependency. Restore client_server/cloud under the sodium_FOUND guard, put
-ftemplate-depth-32 back before the CMAKE_C_FLAGS copy, and fix the console
block indentation.
Guard PIConnection, thread primitives, PICodeParser and other feature
code behind PIP_HAS_THREADS/PIP_HAS_FILESYSTEM. In CMake generate the
feature flags summary from the single PIP_HAS_FLAGS list (used by the
add_definitions loop as well), default ICU to OFF and make introspection
also require PIP_HAS_SOCKET. Build system/thread test suites only when
the corresponding feature flags are enabled.
andrey added 1 commit 2026-08-25 16:57:29 +03:00
- drop INTROSPECTION conjunctions (CMake dep table already forces THREADS+SOCKET)
- remove whole-file guards in client_server/process tests (CMake only compiles them when flags are ON)
- normalize single-flag '#if defined(PIP_HAS_X)' to '#ifdef PIP_HAS_X'
andrey added 1 commit 2026-08-25 17:21:09 +03:00
Merge consecutive #ifdef PIP_HAS_FILESYSTEM / PIP_INTROSPECTION / PIP_CAN
blocks that had no code between them into a single guarded block.
andrey added 3 commits 2026-08-27 12:33:39 +03:00
andrey added 1 commit 2026-08-27 15:16:26 +03:00
andrey added 2 commits 2026-08-28 21:22:34 +03:00
andrey added 2 commits 2026-08-31 14:15:11 +03:00
# Conflicts:
#	libs/main/io_devices/pidir.cpp
#	libs/main/io_devices/pifile.cpp
#	libs/main/thread/pithread.cpp
andrey added 8 commits 2026-08-31 22:09:19 +03:00
- CMake: drop PIP_HAS_SERIAL -> PIP_HAS_THREADS dependency and the forced
  PIP_HAS_SERIAL=OFF for PICO_BOARD, so serial can be built on Pico
- piserial.cpp: guard termios/stty code (tcgetattr/tcsetattr/tcflush/tcdrain,
  TIOCSBRK/TIOCCBRK, TIOCMBIS/TIOCMBIC/TIOCMGET, termios members, sys/ioctl.h
  and termios.h includes) with PIP_HAS_TTY; O_NOCTTY replaced by
  PISERIAL_NOCTTY (0 on no-TTY targets)
- add missing #ifndef fallbacks for B110..B115200 used by convertSpeed()
  when termios.h is absent
- guard thread-only PIIODevice API calls (isThreadedRead/stopThreadedRead)
  with PIP_HAS_THREADS in closeDevice/readDevice
- gate the availableDevicesInfo() test loop with PIP_HAS_FILESYSTEM||WINDOWS
  (device enumeration is a filesystem feature)
- AGENTS.md: note that clang-format-18 is applied automatically on file edits
Replace scattered option() calls, PIP_HAS_DEPS_* variables, and while-loop
resolver with pip_feature_flag() function and pip_resolve_feature_flags()
macro. Dependencies are declared inline and resolved in a single pass.
The operator<< / operator>> templates for MessageConst / MessageMutable
added in 4d8b7430 have no users in the tree (libs, tests, utils, main).
Drop them along with the pibinarystream.h include they required; the
binary-stream fallback static_assert in pibinarystream.h already gives a
clear compile error if external code ever streams an MQTT message.
andrey added 1 commit 2026-09-01 13:01:35 +03:00
peri4 added 1 commit 2026-09-05 23:09:40 +03:00
Introspection - revert *_p files, because they are external API for introspection, not internal
peri4 added 1 commit 2026-09-05 23:12:59 +03:00
try to release with features
peri4 merged commit 43e7c8de0d into master 2026-09-05 23:13:14 +03:00
Sign in to join this conversation.