1、 2023 The Zephyr Project Content made available under CC BY-SA 4.0.Practical Tips to Boost Your Productivity When Using ZephyrBenjamin Cabbenjaminzephyrproject.orgkartben 2023 The Zephyr Project Content made available under CC BY-SA 4.0.$whoamiDeveloper Advocate at The Linux FoundationOpen Source&Ti
2、nyML enthusiastkartben 2023 The Zephyr Project Content made available under CC BY-SA 4.0.DisclaimerA lot of the tips,tricks,and tools demonstrated in this talk will be targeting Zephyr RTOS,but are probably useful regardless of your RTOS of choice!2023 The Zephyr Project Content made available under
3、 CC BY-SA 4.0.Embedded development pain pointsHardware can be a pain(also,silicon shortage)Limited resources(memory,processing power,)Software engineering practices can sometimes be lagging behind(CI/CD,automated testing,)Software supply chain management is cumbersomeSecurity is often an afterthough
4、t 2023 The Zephyr Project Content made available under CC BY-SA 4.0.2023 The Zephyr Project Content made available under CC BY-SA 4.0.2023 The Zephyr Project Content made available under CC BY-SA 4.0.2023 The Zephyr Project Content made available under CC BY-SA 4.0.2023 The Zephyr Project Content ma
5、de available under CC BY-SA 4.0.Emulate/simulate when you can 2023 The Zephyr Project Content made available under CC BY-SA 4.0.2023 The Zephyr Project Content made available under CC BY-SA 4.0.Wokwi demohttps:/ Firmware and Start Simulation”zephyr_esp32-blinky-pwm.elf 2023 The Zephyr Project Conten
6、t made available under CC BY-SA 4.0.2023 The Zephyr Project Content made available under CC BY-SA 4.0.Arm Virtual Hardware 2023 The Zephyr Project Content made available under CC BY-SA 4.0.Embedded resources are limitedHow much RAM/Flash is my app using?Would it fit on a smaller MCU and save me some
7、$?Are my threads stacks sized properly?2023 The Zephyr Project Content made available under CC BY-SA 4.0.Footprint and Memory Usage analysishttps:/ C/C+binaries for code size,static variables and stack usages.Creates a report with disassembler&call-stack analysis per directory,file,or function.2023
8、The Zephyr Project Content made available under CC BY-SA 4.0.Zephyr+puncoverwest build-b my_board samples/hello_world -DCONFIG_STACK_USAGE=ywest build-t puncover 2023 The Zephyr Project Content made available under CC BY-SA 4.0.Footprint and Memory Usage analysisDemo 2023 The Zephyr Project Content
9、made available under CC BY-SA 4.0.How much RAM/Flash is my app using?west build-t ram_reportwest build-t rom_report 2023 The Zephyr Project Content made available under CC BY-SA 4.0.Thread analysisProblem:How to allocate the right amount of memory to my threads?See:https:/docs.zephyrproject.org/late
10、st/services/debugging/thread-analyzer.html 2023 The Zephyr Project Content made available under CC BY-SA 4.0.Mastering the Zephyr shell 2023 The Zephyr Project Content made available under CC BY-SA 4.0.The Zephyr shell is your friendDebug I2C,SPI,municationsGet sensor dataFilesystemWi-Fi,Networking,
11、Logging 2023 The Zephyr Project Content made available under CC BY-SA 4.0.Modern CI/CDIts not because its embedded code that you cant have proper CI/CD,unit testing,etc.https:/ 2023 The Zephyr Project Content made available under CC BY-SA 4.0.Manage your software supply chainZephyr ships an SBOM(Sof
12、tware Bill of Materials)with each releaseDownstream consumers can leverage built-in tools to,in turn,generate source&build SBOMs for their deliverablesSPDXVersion:SPDX-2.3.FileName:./arch/arm/core/aarch32/thread.cSPDXID:SPDXRef-b23458478775dd015ecfea152abfe251FileChecksum:SHA1:756a574b6ed67c04857092
13、9fccf149e984b0f8c1LicenseConcluded:NOASSERTIONLicenseInfoInFile:Apache-2.0FileCopyrightText:Copyright(c)2013-2014 Wind River Systems,Inc.FileName:./zephyr/zephyr.elfSPDXID:SPDXRef-File-zephyr.elfFileChecksum:SHA1:e74cebcac51dabd799957ac51e4edcd32541103d.Relationship:SPDXRef-File-zephyr.elf GENERATED
14、_FROM SPDXRef-File-dev-handles.cRelationship:SPDXRef-File-zephyr.elf GENERATED_FROM SPDXRef-File-isr-tables.cRelationship:SPDXRef-File-zephyr.elf STATIC_LINK SPDXRef-File-libapp.aRelationship:SPDXRef-File-zephyr.elf STATIC_LINK SPDXRef-File-libzephyr.aRelationship:SPDXRef-File-zephyr.elf STATIC_LINK
15、 SPDXRef-File-libisr-tables.aRelationship:SPDXRef-File-zephyr.elf STATIC_LINK SPDXRef-File-libkernel.a.2023 The Zephyr Project Content made available under CC BY-SA 4.0.Generating SBOM with Zephyrwest spdx-init-d BUILD_DIRwest build-d BUILD_DIR.west spdx-d BUILD_DIRhttps:/docs.zephyrproject.org/late
16、st/develop/west/zephyr-cmds.html#software-bill-of-materials-west-spdx 2023 The Zephyr Project Content made available under CC BY-SA 4.0.The S in IoT stands for SecurityHow can I harden my Zephyr app to make it more secure?Disable all the features and compilation flags that might contribute to increa
17、sing the vulnerability surface(ex.turn off log traces)Enable all the(often optional,and sometimes well-hidden)features that can improve overall security(ex.hardware-enforced stack protection).2023 The Zephyr Project Content made available under CC BY-SA 4.0.Zephyr Hardening Toolwest build-t hardenco
18、nfig name|current|recommended|check result=CONFIG_BOOT_BANNER|y|n|FAILCONFIG_BUILD_OUTPUT_STRIPPED|n|y|FAILCONFIG_FAULT_DUMP|2|0|FAILCONFIG_HW_STACK_PROTECTION|n|y|FAILCONFIG_MPU_STACK_GUARD|n|y|FAILCONFIG_OVERRIDE_FRAME_POINTER_DEFAULT|n|y|FAILCONFIG_STACK_SENTINEL|n|y|FAILCONFIG_EARLY_CONSOLE|y|n|FAILCONFIG_PRINTK|y|n|FAIL 2023 The Zephyr Project Content made available under CC BY-SA 4.0.Thanks!Resources:https:/ https:/chat.zephyrproject.orghttps:/zephyrproject.org Contact:benjaminzephyrproject.orgkartbenmastodon.social