roll: pigweed pw_log_android: Make PW_LOG_LEVEL_FATAL fatal again Since https://pwrev.dev/295040, invoking PW_HANDLE_LOG(PW_LOG_LEVEL_FATAL, ...) would no longer abort the process, and would continue executing. Making matters even worse, the pw_assert_log implementation of PW_HANDLE_CRASH() follows that up with a dubious PW_UNREACHABLE, which means that the compiler likely stopped emitting code at that point (in the branch or function). As a result, execution continues at whatever arbitrary code happens to follow! If you're lucky, this results in a SIGSEGV. This corrects the problem by routing PW_LOG_LEVEL_FATAL to __android_log_assert() which properly aborts (and is even annotated as noreturn). This also replaces the constexpr convert_pigweed_to_android_log_level() function with a 'static inline' function, since PW_LOG should be usable in C. In the common case of a constant log level, the compiler should still be able to optimize it away. Finally, ths changes the conversion default from ANDROID_LOG_DEBUG to ANDROID_LOG_WARN. This should never be used since we handle all current PW_LOG_LEVEL_* values, but ensures that such a log is visible in case a different level is added. Test: Verified (`logcat -s DEBUG`) that processes now crash with SIGABRT at the intended location. Original-Bug: 543566936 Original-Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/452252 Original-Revision: 9bc095e8efdfc81b2cf721b05789dc01a00957fd Rolled-Repo: https://pigweed.googlesource.com/pigweed/pigweed Rolled-Commits: 33efd737cc1ffc..9bc095e8efdfc8 Roll-Count: 1 Roller-URL: https://cr-buildbucket.appspot.com/build/8673614251748091921 GitWatcher: ignore CQ-Do-Not-Cancel-Tryjobs: true Change-Id: I72bcecf227d79ae8f901fa78c9601c8a253c1dc8 Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/quickstart/bazel/+/454445
This repository contains a minimal example of a Bazel-based Pigweed project. It is a LED-blinking service (featuring RPC control!) for the Raspberry Pi Pico. It can also be run on any computer using the included simulator.
git clone https://pigweed.googlesource.com/pigweed/quickstart/bazel pw_bazel_quickstart cd pw_bazel_quickstart
The only dependency that must be installed is Bazelisk.
Bazelisk is a launcher for the Bazel build system that allows for easy management of multiple Bazel versions.
Instructions for installing Bazelisk can be found here.
To run the simulator, type: bazelisk run //apps/blinky:simulator_blinky Then, in a new console, connect to the simulator using: bazelisk run //apps/blinky:simulator_console
To start, connect a Raspberry Pi Pico, Pico 2, or debug probe via USB.
To run on the Raspberry Pi Pico, type: bazelisk run //apps/blinky:flash_rp2040 Then, in a new console, connect to the device using: bazelisk run //apps/blinky:rp2040_console
Once connected with a console, RPCs can be sent to control the LED. Try running:
device.set_led(True) device.set_led(False) device.toggle_led() device.blink(blink_count=3)
bazelisk test //... will run the unit tests defined in this project, such as the ones in modules/blinky/blinky_test.cc.
bazelisk run @pigweed//targets/rp2040/py:unit_test_server in one console followed by bazelisk test //... --config=rp2040 will also allow running the unit tests on-device.
Try poking around the codebase for inspiration about how Pigweed projects can be organized. Most of the relevant code in this quickstart (including RPC definitions) is inside modules/blinky, with some client-side Python code in tools/console.py.