1.. _docs-release-notes-2022-jan: 2 3=================================== 4Pigweed: What's New in January 2022 5=================================== 6Happy new year from the Pigweed team! We’re excited to share what we’ve been up 7to this month and we’re really looking forward to what 2022 will bring to the 8Pigweed community. 9 10:ref:`Pigweed<docs-root>` is a collection of libraries and tools for building 11robust embedded software, efficiently. Pigweed allows you to write code that 12runs transparently on both your host machine and tiny 32-bit microcontrollers 13like those in the :ref:`STM32<target-stm32f429i-disc1>` and 14:ref:`Arduino<target-arduino>` families, while giving you the comforts of modern 15software development traditionally lacking in embedded systems, like 16:ref:`easy unit testing<module-pw_unit_test>`, 17:ref:`powerful build systems<docs-build-system>`, 18:ref:`flexible logging<module-pw_log>`, and 19:ref:`reliable communication<module-pw_rpc>`. 20 21.. admonition:: Note 22 :class: warning 23 24 Many Pigweed modules are already shipping in commercial products, but it is 25 still an early access project. Find out if 26 :ref:`Pigweed is right for you<docs-concepts-right-for-my-project>`. 27 28Pigweed is a free and open source project and we welcome contributions! Join us 29on `Discord <https://discord.gg/M9NSeTA>`_ to share feedback, ask questions, and 30get involved with the Pigweed community! 31 32------------------------------ 33Experimental Pigweed framework 34------------------------------ 35.. admonition:: tl;dr 36 :class: checkmark 37 38 We’re starting the “whole OS” framework version of Pigweed! It’s not ready 39 for use yet but you might want to take a peek. 40 41Pigweed is designed to be highly modular—you can use as many or as few of the 42Pigweed modules as you need for your project, and those modules will work 43flexibly in any project structure. This works great when you want to add Pigweed 44super powers like hybrid host/target unit testing or RPC communication to an 45existing project. While Pigweed gives you nearly all of the tools you need to 46efficiently build a robust, reliable embedded project, until now we haven’t had 47a great solution for building a new project on Pigweed. 48 49The Pigweed framework assembles an opinionated project structure, build system, 50and development environment that does three key things: 51 52* Takes care of difficult but unproductive project plumbing issues like setting 53 up a target toolchain and providing support for 54 :ref:`OS abstractions<docs-os_abstraction_layers>`. 55 56* Configures Pigweed module backends that give you logging, asserts, threads, 57 dynamic memory allocation, and more, that work transparently both on host and 58 on target 59 60* Sets up a productive development environment with rich code analysis and 61 powerful device interaction tools 62 63You can experiment with this right now by checking out the ``pw_system`` 64:ref:`documentation<module-pw_system>`. The experimental configuration leverages 65FreeRTOS and runs on the STM32F429I Discovery board. With a 66:ref:`few simple commands<target-stm32f429i-disc1-stm32cube>`, you can have a 67complete embedded development environment set up and focus on building your 68product. 69 70.. warning:: 71 72 The Pigweed framework is still in very active development and you should 73 expect breaking changes in the future. If you’re experimenting with it, we 74 would love to hear from you! Join us on 75 `Discord <https://discord.gg/M9NSeTA>`_! 76 77------------------------------------- 78Support for plugins in ``pw_console`` 79------------------------------------- 80Teams that use Pigweed quickly come to rely on the 81:ref:`console<module-pw_console>` as a vital tool for interacting with their 82devices via RPC. It’s now possible to tailor the console to meet your project’s 83specific needs through a new :ref:`plugin interface<module-pw_console-plugins>`. 84You can build your own menus, window panes, keybindings, and clickable buttons 85to truly make ``pw_console`` your own. 86 87How are you using the Pigweed console in your project? Let us know on 88`Discord <https://discord.gg/M9NSeTA>`_! 89 90------------------------------------ 91Expanded support for Bazel and CMake 92------------------------------------ 93Pigweed’s primary build system is 94`GN (Generate Ninja) <https://gn.googlesource.com/gn>`_, but to make it easier 95to use Pigweed modules in existing projects, we have been expanding support for 96the `Bazel <https://bazel.build/>`_ and `CMake <https://cmake.org/>`_ build 97systems. Right now, the best way to determine which build systems a module 98supports is to look out for ``BUILD.gn``, ``BUILD.bazel`` and ``CMakeLists.txt`` 99files (respectively) in module directories. While we work on improving build 100system support and documentation, check out the 101:ref:`build system documentation<docs-build-system>` for more detailed 102information and join us on Discord for support. 103 104---------------------------------------- 105Changes to the RPC ``ChannelOutput`` API 106---------------------------------------- 107RPC endpoints use :ref:`ChannelOutput<module-pw_rpc-ChannelOutput>` instances to 108send packets encoding RPC data. To send an encoded RPC packet, we need a buffer 109containing the packet’s data. In the past, we could request a buffer by doing 110something like this: 111 112.. code-block:: cpp 113 114 auto buffer = pw::rpc::ChannelOutput::AcquireBuffer(buffer_size) 115 // fill in the buffer here 116 pw::rpc::ChannelOutput::SendAndReleaseBuffer(buffer) 117 118The ``ChannelOutput::AcquireBuffer`` and ``ChannelOutput::SendAndReleaseBuffer`` 119methods are no longer part of ``ChannelOutput``’s public API, making its 120internal buffer private. Now, we create our own buffer and ``ChannelOutput`` is 121simply responsible for sending it: 122 123.. code-block:: cpp 124 125 auto buffer = ... // create your own local buffer with RPC packet data 126 pw::rpc::ChannelOutput::Send(buffer) 127 128This approach avoids several tricky concurrency issues related to buffer 129lifetimes, and simplifies the ``ChannelOutput`` API. It also opens up the 130possibility of projects managing RPC buffers in more flexible ways, e.g. via 131dynamically-allocated memory or separate shared memory mechanisms. 132 133.. warning:: 134 135 This is a breaking change if you update pw_rpc, but one that can be fixed 136 quickly. 137 138We’re actively reviewing the RPC API with a view towards significantly improving 139it in the future. Share your input with us on 140`Discord <https://discord.gg/M9NSeTA>`_! 141 142------------ 143More Updates 144------------ 145* It’s now possible to generate a token database from a list of strings in a 146 JSON file for ``pw_tokenizer``. This can be useful when you need to tokenize 147 strings that can’t be parsed from compiled binaries. 148 149* ``pw_assert``‘s new ``pw_assert_tokenized`` backend provides a much more 150 space-efficient implementation compared to using ``pw_assert_log`` with 151 ``pw_log_tokenized``. However, there are trade offs to consider, so check out 152 the :ref:`documentation<module-pw_assert_tokenized>`. 153 154* CMake builds now support compile-time module configuration similar to GN 155 through the use of the ``pw_add_module_config`` and ``pw_set_module_config`` 156 functions. 157 158* In ``pw_build``, it is now possible to set a specific working directory for 159 :ref:`pw_exec<module-pw_build-pw_exec>` actions. 160 161* ``pw_cpu_exception`` now supports the ARMv8M Mainline architecture in 162 ``pw_cpu_exception_cortex_m``. This allows us to take advantage of stack limit 163 boundary features in microcontrollers using that architecture, like Cortex M33 164 and M35P. 165 166------------ 167Get Involved 168------------ 169.. tip:: 170 171 We welcome contributions from the community! Here are just a few 172 opportunities to get involved. 173 174* Pigweed now includes GN build files for 175 `TinyUSB <https://github.com/hathach/tinyusb>`_, a popular USB library for 176 embedded systems. Projects can now include it by cloning the TinyUSB 177 repository and configuring GN to build it. But right now, we lack interfaces 178 between TinyUSB and Pigweed abstractions like pw_stream. This is a great 179 opportunity to help get very useful functionality across the finish line. 180 181* We’re very interested in supporting the 182 `Raspberry Pi Pico <https://www.raspberrypi.com/products/raspberry-pi-pico/>`_ 183 and the ecosystem of devices using the RP2040 microcontroller. We will be 184 working in earnest on this in the coming months and welcome anyone who wants 185 to lend a helping hand! 186 187* Evolving the Pigweed framework from its current experimental state to a 188 relatively complete embedded project platform is one of our major focuses this 189 year, and we want your help. That help can range from providing input on what 190 you’re looking for in a framework, to building small projects with it and 191 providing feedback, up to contributing directly to its development. Join us to 192 talk about it on `Discord <https://discord.gg/M9NSeTA>`_! 193