1.. _target-stm32f429i-disc1-stm32cube: 2 3=========================== 4stm32f429i-disc1: STM32Cube 5=========================== 6 7.. warning:: 8 9 This target is in a very preliminary state and is under active development. 10 This demo gives a preview of the direction we are heading with 11 :ref:`pw_system<module-pw_system>`, but it is not yet ready for production 12 use. 13 14The STMicroelectronics STM32F429I-DISC1 development board is currently Pigweed's 15primary target for on-device testing and development. This target configuration 16uses :ref:`pw_system<module-pw_system>` on top of FreeRTOS and the STM32Cube HAL 17rather than a from-the-ground-up baremetal approach. 18 19----- 20Setup 21----- 22To use this target, Pigweed must be set up to use FreeRTOS and the STM32Cube HAL 23for the STM32F4 series. The supported repositories can be downloaded via 24``pw package``, and then the build must be manually configured to point to the 25locations the repositories were downloaded to. 26 27.. code-block:: sh 28 29 pw package install nanopb 30 pw package install freertos 31 pw package install stm32cube_f4 32 33 gn gen out --export-compile-commands --args=" 34 dir_pw_third_party_nanopb=\"$PW_PROJECT_ROOT/environment/packages/nanopb\" 35 dir_pw_third_party_freertos=\"$PW_PROJECT_ROOT/environment/packages/freertos\" 36 dir_pw_third_party_stm32cube_f4=\"$PW_PROJECT_ROOT/environment/packages/stm32cube_f4\" 37 " 38 39.. tip:: 40 41 Instead of the ``gn gen out`` with args set on the command line above you can 42 run: 43 44 .. code-block:: sh 45 46 gn args out 47 48 Then add the following lines to that text file: 49 50 .. code-block:: 51 52 dir_pw_third_party_nanopb = getenv("PW_PACKAGE_ROOT") + "/nanopb" 53 dir_pw_third_party_freertos = getenv("PW_PACKAGE_ROOT") + "/freertos" 54 dir_pw_third_party_stm32cube_f4 = getenv("PW_PACKAGE_ROOT") + "/stm32cube_f4" 55 56----------------------------- 57Building and Running the Demo 58----------------------------- 59This target has an associated demo application that can be built and then 60flashed to a device with the following commands: 61 62.. code-block:: sh 63 64 ninja -C out pw_system_demo 65 66.. code-block:: sh 67 68 openocd -f targets/stm32f429i_disc1/py/stm32f429i_disc1_utils/openocd_stm32f4xx.cfg \ 69 -c "program out/stm32f429i_disc1_stm32cube.size_optimized/obj/pw_system/bin/system_example.elf reset exit" 70 71Once the board has been flashed, you can connect to it and send RPC commands 72via the Pigweed console: 73 74.. code-block:: sh 75 76 pw-system-console -d /dev/{ttyX} -b 115200 \ 77 --proto-globs pw_rpc/echo.proto \ 78 --token-databases \ 79 out/stm32f429i_disc1_stm32cube.size_optimized/obj/pw_system/bin/system_example.elf 80 81Replace ``{ttyX}`` with the appropriate device on your machine. On Linux this 82may look like ``ttyACM0``, and on a Mac it may look like ``cu.usbmodem***``. 83 84When the console opens, try sending an Echo RPC request. You should get back 85the same message you sent to the device. 86 87.. code-block:: pycon 88 89 >>> device.rpcs.pw.rpc.EchoService.Echo(msg="Hello, Pigweed!") 90 (Status.OK, pw.rpc.EchoMessage(msg='Hello, Pigweed!')) 91 92You can also try out our thread snapshot RPC service, which should return a 93stack usage overview of all running threads on the device in Host Logs. 94 95.. code-block:: pycon 96 97 >>> device.snapshot_peak_stack_usage() 98 99Example output: 100 101.. code-block:: 102 103 20220826 09:47:22 INF PendingRpc(channel=1, method=pw.thread.ThreadSnapshotService.GetPeakStackUsage) completed: Status.OK 104 20220826 09:47:22 INF Thread State 105 20220826 09:47:22 INF 5 threads running. 106 20220826 09:47:22 INF 107 20220826 09:47:22 INF Thread (UNKNOWN): IDLE 108 20220826 09:47:22 INF Est CPU usage: unknown 109 20220826 09:47:22 INF Stack info 110 20220826 09:47:22 INF Current usage: 0x20002da0 - 0x???????? (size unknown) 111 20220826 09:47:22 INF Est peak usage: 390 bytes, 76.77% 112 20220826 09:47:22 INF Stack limits: 0x20002da0 - 0x20002ba4 (508 bytes) 113 20220826 09:47:22 INF 114 20220826 09:47:22 INF ... 115 116You are now up and running! 117 118.. seealso:: 119 120 The :ref:`module-pw_console` 121 :bdg-ref-primary-line:`module-pw_console-user_guide` for more info on using 122 the the pw_console UI. 123