@wazir-dev/cli 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +111 -0
- package/CHANGELOG.md +14 -0
- package/CONTRIBUTING.md +101 -0
- package/LICENSE +21 -0
- package/README.md +314 -0
- package/assets/composition-engine.mmd +34 -0
- package/assets/demo-script.sh +17 -0
- package/assets/logo-dark.svg +14 -0
- package/assets/logo.svg +14 -0
- package/assets/pipeline.mmd +39 -0
- package/assets/record-demo.sh +51 -0
- package/docs/README.md +51 -0
- package/docs/adapters/context-mode.md +60 -0
- package/docs/concepts/architecture.md +87 -0
- package/docs/concepts/artifact-model.md +60 -0
- package/docs/concepts/composition-engine.md +36 -0
- package/docs/concepts/indexing-and-recall.md +160 -0
- package/docs/concepts/observability.md +41 -0
- package/docs/concepts/roles-and-workflows.md +59 -0
- package/docs/concepts/terminology-policy.md +27 -0
- package/docs/getting-started/01-installation.md +78 -0
- package/docs/getting-started/02-first-run.md +102 -0
- package/docs/getting-started/03-adding-to-project.md +15 -0
- package/docs/getting-started/04-host-setup.md +15 -0
- package/docs/guides/ci-integration.md +15 -0
- package/docs/guides/creating-skills.md +15 -0
- package/docs/guides/expertise-module-authoring.md +15 -0
- package/docs/guides/hook-development.md +15 -0
- package/docs/guides/memory-and-learnings.md +34 -0
- package/docs/guides/multi-host-export.md +15 -0
- package/docs/guides/troubleshooting.md +101 -0
- package/docs/guides/writing-custom-roles.md +15 -0
- package/docs/plans/2026-03-15-cli-pipeline-integration-design.md +592 -0
- package/docs/plans/2026-03-15-cli-pipeline-integration-plan.md +598 -0
- package/docs/plans/2026-03-15-docs-enforcement-plan.md +238 -0
- package/docs/readmes/INDEX.md +99 -0
- package/docs/readmes/features/expertise/README.md +171 -0
- package/docs/readmes/features/exports/README.md +222 -0
- package/docs/readmes/features/hooks/README.md +103 -0
- package/docs/readmes/features/hooks/loop-cap-guard.md +133 -0
- package/docs/readmes/features/hooks/post-tool-capture.md +121 -0
- package/docs/readmes/features/hooks/post-tool-lint.md +130 -0
- package/docs/readmes/features/hooks/pre-compact-summary.md +122 -0
- package/docs/readmes/features/hooks/pre-tool-capture-route.md +100 -0
- package/docs/readmes/features/hooks/protected-path-write-guard.md +128 -0
- package/docs/readmes/features/hooks/session-start.md +119 -0
- package/docs/readmes/features/hooks/stop-handoff-harvest.md +125 -0
- package/docs/readmes/features/roles/README.md +157 -0
- package/docs/readmes/features/roles/clarifier.md +152 -0
- package/docs/readmes/features/roles/content-author.md +190 -0
- package/docs/readmes/features/roles/designer.md +193 -0
- package/docs/readmes/features/roles/executor.md +184 -0
- package/docs/readmes/features/roles/learner.md +210 -0
- package/docs/readmes/features/roles/planner.md +182 -0
- package/docs/readmes/features/roles/researcher.md +164 -0
- package/docs/readmes/features/roles/reviewer.md +184 -0
- package/docs/readmes/features/roles/specifier.md +162 -0
- package/docs/readmes/features/roles/verifier.md +215 -0
- package/docs/readmes/features/schemas/README.md +178 -0
- package/docs/readmes/features/skills/README.md +63 -0
- package/docs/readmes/features/skills/brainstorming.md +96 -0
- package/docs/readmes/features/skills/debugging.md +148 -0
- package/docs/readmes/features/skills/design.md +120 -0
- package/docs/readmes/features/skills/prepare-next.md +109 -0
- package/docs/readmes/features/skills/run-audit.md +159 -0
- package/docs/readmes/features/skills/scan-project.md +109 -0
- package/docs/readmes/features/skills/self-audit.md +176 -0
- package/docs/readmes/features/skills/tdd.md +137 -0
- package/docs/readmes/features/skills/using-skills.md +92 -0
- package/docs/readmes/features/skills/verification.md +120 -0
- package/docs/readmes/features/skills/writing-plans.md +104 -0
- package/docs/readmes/features/tooling/README.md +320 -0
- package/docs/readmes/features/workflows/README.md +186 -0
- package/docs/readmes/features/workflows/author.md +181 -0
- package/docs/readmes/features/workflows/clarify.md +154 -0
- package/docs/readmes/features/workflows/design-review.md +171 -0
- package/docs/readmes/features/workflows/design.md +169 -0
- package/docs/readmes/features/workflows/discover.md +162 -0
- package/docs/readmes/features/workflows/execute.md +173 -0
- package/docs/readmes/features/workflows/learn.md +167 -0
- package/docs/readmes/features/workflows/plan-review.md +165 -0
- package/docs/readmes/features/workflows/plan.md +170 -0
- package/docs/readmes/features/workflows/prepare-next.md +167 -0
- package/docs/readmes/features/workflows/review.md +169 -0
- package/docs/readmes/features/workflows/run-audit.md +191 -0
- package/docs/readmes/features/workflows/spec-challenge.md +159 -0
- package/docs/readmes/features/workflows/specify.md +160 -0
- package/docs/readmes/features/workflows/verify.md +177 -0
- package/docs/readmes/packages/README.md +50 -0
- package/docs/readmes/packages/ajv.md +117 -0
- package/docs/readmes/packages/context-mode.md +118 -0
- package/docs/readmes/packages/gray-matter.md +116 -0
- package/docs/readmes/packages/node-test.md +137 -0
- package/docs/readmes/packages/yaml.md +112 -0
- package/docs/reference/configuration-reference.md +159 -0
- package/docs/reference/expertise-index.md +52 -0
- package/docs/reference/git-flow.md +43 -0
- package/docs/reference/hooks.md +87 -0
- package/docs/reference/host-exports.md +50 -0
- package/docs/reference/launch-checklist.md +172 -0
- package/docs/reference/marketplace-listings.md +76 -0
- package/docs/reference/release-process.md +34 -0
- package/docs/reference/roles-reference.md +77 -0
- package/docs/reference/skills.md +33 -0
- package/docs/reference/templates.md +29 -0
- package/docs/reference/tooling-cli.md +94 -0
- package/docs/truth-claims.yaml +222 -0
- package/expertise/PROGRESS.md +63 -0
- package/expertise/README.md +18 -0
- package/expertise/antipatterns/PROGRESS.md +56 -0
- package/expertise/antipatterns/backend/api-design-antipatterns.md +1271 -0
- package/expertise/antipatterns/backend/auth-antipatterns.md +1195 -0
- package/expertise/antipatterns/backend/caching-antipatterns.md +622 -0
- package/expertise/antipatterns/backend/database-antipatterns.md +1038 -0
- package/expertise/antipatterns/backend/index.md +24 -0
- package/expertise/antipatterns/backend/microservices-antipatterns.md +850 -0
- package/expertise/antipatterns/code/architecture-antipatterns.md +919 -0
- package/expertise/antipatterns/code/async-antipatterns.md +622 -0
- package/expertise/antipatterns/code/code-smells.md +1186 -0
- package/expertise/antipatterns/code/dependency-antipatterns.md +1209 -0
- package/expertise/antipatterns/code/error-handling-antipatterns.md +1360 -0
- package/expertise/antipatterns/code/index.md +27 -0
- package/expertise/antipatterns/code/naming-and-abstraction.md +1118 -0
- package/expertise/antipatterns/code/state-management-antipatterns.md +1076 -0
- package/expertise/antipatterns/code/testing-antipatterns.md +1053 -0
- package/expertise/antipatterns/design/accessibility-antipatterns.md +1136 -0
- package/expertise/antipatterns/design/dark-patterns.md +1121 -0
- package/expertise/antipatterns/design/index.md +22 -0
- package/expertise/antipatterns/design/ui-antipatterns.md +1202 -0
- package/expertise/antipatterns/design/ux-antipatterns.md +680 -0
- package/expertise/antipatterns/frontend/css-layout-antipatterns.md +691 -0
- package/expertise/antipatterns/frontend/flutter-antipatterns.md +1827 -0
- package/expertise/antipatterns/frontend/index.md +23 -0
- package/expertise/antipatterns/frontend/mobile-antipatterns.md +573 -0
- package/expertise/antipatterns/frontend/react-antipatterns.md +1128 -0
- package/expertise/antipatterns/frontend/spa-antipatterns.md +1235 -0
- package/expertise/antipatterns/index.md +31 -0
- package/expertise/antipatterns/performance/index.md +20 -0
- package/expertise/antipatterns/performance/performance-antipatterns.md +1013 -0
- package/expertise/antipatterns/performance/premature-optimization.md +623 -0
- package/expertise/antipatterns/performance/scaling-antipatterns.md +785 -0
- package/expertise/antipatterns/process/ai-coding-antipatterns.md +853 -0
- package/expertise/antipatterns/process/code-review-antipatterns.md +656 -0
- package/expertise/antipatterns/process/deployment-antipatterns.md +920 -0
- package/expertise/antipatterns/process/index.md +23 -0
- package/expertise/antipatterns/process/technical-debt-antipatterns.md +647 -0
- package/expertise/antipatterns/security/index.md +20 -0
- package/expertise/antipatterns/security/secrets-antipatterns.md +849 -0
- package/expertise/antipatterns/security/security-theater.md +843 -0
- package/expertise/antipatterns/security/vulnerability-patterns.md +801 -0
- package/expertise/architecture/PROGRESS.md +70 -0
- package/expertise/architecture/data/caching-architecture.md +671 -0
- package/expertise/architecture/data/data-consistency.md +574 -0
- package/expertise/architecture/data/data-modeling.md +536 -0
- package/expertise/architecture/data/event-streams-and-queues.md +634 -0
- package/expertise/architecture/data/index.md +25 -0
- package/expertise/architecture/data/search-architecture.md +663 -0
- package/expertise/architecture/data/sql-vs-nosql.md +708 -0
- package/expertise/architecture/decisions/architecture-decision-records.md +640 -0
- package/expertise/architecture/decisions/build-vs-buy.md +616 -0
- package/expertise/architecture/decisions/index.md +23 -0
- package/expertise/architecture/decisions/monolith-to-microservices.md +790 -0
- package/expertise/architecture/decisions/technology-selection.md +616 -0
- package/expertise/architecture/distributed/cap-theorem-and-tradeoffs.md +800 -0
- package/expertise/architecture/distributed/circuit-breaker-bulkhead.md +741 -0
- package/expertise/architecture/distributed/consensus-and-coordination.md +796 -0
- package/expertise/architecture/distributed/distributed-systems-fundamentals.md +564 -0
- package/expertise/architecture/distributed/idempotency-and-retry.md +796 -0
- package/expertise/architecture/distributed/index.md +25 -0
- package/expertise/architecture/distributed/saga-pattern.md +797 -0
- package/expertise/architecture/foundations/architectural-thinking.md +460 -0
- package/expertise/architecture/foundations/coupling-and-cohesion.md +770 -0
- package/expertise/architecture/foundations/design-principles-solid.md +649 -0
- package/expertise/architecture/foundations/domain-driven-design.md +719 -0
- package/expertise/architecture/foundations/index.md +25 -0
- package/expertise/architecture/foundations/separation-of-concerns.md +472 -0
- package/expertise/architecture/foundations/twelve-factor-app.md +797 -0
- package/expertise/architecture/index.md +34 -0
- package/expertise/architecture/integration/api-design-graphql.md +638 -0
- package/expertise/architecture/integration/api-design-grpc.md +804 -0
- package/expertise/architecture/integration/api-design-rest.md +892 -0
- package/expertise/architecture/integration/index.md +25 -0
- package/expertise/architecture/integration/third-party-integration.md +795 -0
- package/expertise/architecture/integration/webhooks-and-callbacks.md +1152 -0
- package/expertise/architecture/integration/websockets-realtime.md +791 -0
- package/expertise/architecture/mobile-architecture/index.md +22 -0
- package/expertise/architecture/mobile-architecture/mobile-app-architecture.md +780 -0
- package/expertise/architecture/mobile-architecture/mobile-backend-for-frontend.md +670 -0
- package/expertise/architecture/mobile-architecture/offline-first.md +719 -0
- package/expertise/architecture/mobile-architecture/push-and-sync.md +782 -0
- package/expertise/architecture/patterns/cqrs-event-sourcing.md +717 -0
- package/expertise/architecture/patterns/event-driven.md +797 -0
- package/expertise/architecture/patterns/hexagonal-clean-architecture.md +870 -0
- package/expertise/architecture/patterns/index.md +27 -0
- package/expertise/architecture/patterns/layered-architecture.md +736 -0
- package/expertise/architecture/patterns/microservices.md +753 -0
- package/expertise/architecture/patterns/modular-monolith.md +692 -0
- package/expertise/architecture/patterns/monolith.md +626 -0
- package/expertise/architecture/patterns/plugin-architecture.md +735 -0
- package/expertise/architecture/patterns/serverless.md +780 -0
- package/expertise/architecture/scaling/database-scaling.md +615 -0
- package/expertise/architecture/scaling/feature-flags-and-rollouts.md +757 -0
- package/expertise/architecture/scaling/horizontal-vs-vertical.md +606 -0
- package/expertise/architecture/scaling/index.md +24 -0
- package/expertise/architecture/scaling/multi-tenancy.md +800 -0
- package/expertise/architecture/scaling/stateless-design.md +787 -0
- package/expertise/backend/embedded-firmware.md +625 -0
- package/expertise/backend/go.md +853 -0
- package/expertise/backend/index.md +24 -0
- package/expertise/backend/java-spring.md +448 -0
- package/expertise/backend/node-typescript.md +625 -0
- package/expertise/backend/python-fastapi.md +724 -0
- package/expertise/backend/rust.md +458 -0
- package/expertise/backend/solidity.md +711 -0
- package/expertise/composition-map.yaml +443 -0
- package/expertise/content/foundations/content-modeling.md +395 -0
- package/expertise/content/foundations/editorial-standards.md +449 -0
- package/expertise/content/foundations/index.md +24 -0
- package/expertise/content/foundations/microcopy.md +455 -0
- package/expertise/content/foundations/terminology-governance.md +509 -0
- package/expertise/content/index.md +34 -0
- package/expertise/content/patterns/accessibility-copy.md +518 -0
- package/expertise/content/patterns/index.md +24 -0
- package/expertise/content/patterns/notification-content.md +433 -0
- package/expertise/content/patterns/sample-content.md +486 -0
- package/expertise/content/patterns/state-copy.md +439 -0
- package/expertise/design/PROGRESS.md +58 -0
- package/expertise/design/disciplines/dark-mode-theming.md +577 -0
- package/expertise/design/disciplines/design-systems.md +595 -0
- package/expertise/design/disciplines/index.md +25 -0
- package/expertise/design/disciplines/information-architecture.md +800 -0
- package/expertise/design/disciplines/interaction-design.md +788 -0
- package/expertise/design/disciplines/responsive-design.md +552 -0
- package/expertise/design/disciplines/usability-testing.md +516 -0
- package/expertise/design/disciplines/user-research.md +792 -0
- package/expertise/design/foundations/accessibility-design.md +796 -0
- package/expertise/design/foundations/color-theory.md +797 -0
- package/expertise/design/foundations/iconography.md +795 -0
- package/expertise/design/foundations/index.md +26 -0
- package/expertise/design/foundations/motion-and-animation.md +653 -0
- package/expertise/design/foundations/rtl-design.md +585 -0
- package/expertise/design/foundations/spacing-and-layout.md +607 -0
- package/expertise/design/foundations/typography.md +800 -0
- package/expertise/design/foundations/visual-hierarchy.md +761 -0
- package/expertise/design/index.md +32 -0
- package/expertise/design/patterns/authentication-flows.md +474 -0
- package/expertise/design/patterns/content-consumption.md +789 -0
- package/expertise/design/patterns/data-display.md +618 -0
- package/expertise/design/patterns/e-commerce.md +1494 -0
- package/expertise/design/patterns/feedback-and-states.md +642 -0
- package/expertise/design/patterns/forms-and-input.md +819 -0
- package/expertise/design/patterns/gamification.md +801 -0
- package/expertise/design/patterns/index.md +31 -0
- package/expertise/design/patterns/microinteractions.md +449 -0
- package/expertise/design/patterns/navigation.md +800 -0
- package/expertise/design/patterns/notifications.md +705 -0
- package/expertise/design/patterns/onboarding.md +700 -0
- package/expertise/design/patterns/search-and-filter.md +601 -0
- package/expertise/design/patterns/settings-and-preferences.md +768 -0
- package/expertise/design/patterns/social-and-community.md +748 -0
- package/expertise/design/platforms/desktop-native.md +612 -0
- package/expertise/design/platforms/index.md +25 -0
- package/expertise/design/platforms/mobile-android.md +825 -0
- package/expertise/design/platforms/mobile-cross-platform.md +983 -0
- package/expertise/design/platforms/mobile-ios.md +699 -0
- package/expertise/design/platforms/tablet.md +794 -0
- package/expertise/design/platforms/web-dashboard.md +790 -0
- package/expertise/design/platforms/web-responsive.md +550 -0
- package/expertise/design/psychology/behavioral-nudges.md +449 -0
- package/expertise/design/psychology/cognitive-load.md +1191 -0
- package/expertise/design/psychology/error-psychology.md +778 -0
- package/expertise/design/psychology/index.md +22 -0
- package/expertise/design/psychology/persuasive-design.md +736 -0
- package/expertise/design/psychology/user-mental-models.md +623 -0
- package/expertise/design/tooling/open-pencil.md +266 -0
- package/expertise/frontend/angular.md +1073 -0
- package/expertise/frontend/desktop-electron.md +546 -0
- package/expertise/frontend/flutter.md +782 -0
- package/expertise/frontend/index.md +27 -0
- package/expertise/frontend/native-android.md +409 -0
- package/expertise/frontend/native-ios.md +490 -0
- package/expertise/frontend/react-native.md +1160 -0
- package/expertise/frontend/react.md +808 -0
- package/expertise/frontend/vue.md +1089 -0
- package/expertise/humanize/domain-rules-code.md +79 -0
- package/expertise/humanize/domain-rules-content.md +67 -0
- package/expertise/humanize/domain-rules-technical-docs.md +56 -0
- package/expertise/humanize/index.md +35 -0
- package/expertise/humanize/self-audit-checklist.md +87 -0
- package/expertise/humanize/sentence-patterns.md +218 -0
- package/expertise/humanize/vocabulary-blacklist.md +105 -0
- package/expertise/i18n/PROGRESS.md +65 -0
- package/expertise/i18n/advanced/accessibility-and-i18n.md +28 -0
- package/expertise/i18n/advanced/bidirectional-text-algorithm.md +38 -0
- package/expertise/i18n/advanced/complex-scripts.md +30 -0
- package/expertise/i18n/advanced/performance-and-i18n.md +27 -0
- package/expertise/i18n/advanced/testing-i18n.md +28 -0
- package/expertise/i18n/content/content-adaptation.md +23 -0
- package/expertise/i18n/content/locale-specific-formatting.md +23 -0
- package/expertise/i18n/content/machine-translation-integration.md +28 -0
- package/expertise/i18n/content/translation-management.md +29 -0
- package/expertise/i18n/foundations/date-time-calendars.md +67 -0
- package/expertise/i18n/foundations/i18n-architecture.md +272 -0
- package/expertise/i18n/foundations/locale-and-language-tags.md +79 -0
- package/expertise/i18n/foundations/numbers-currency-units.md +61 -0
- package/expertise/i18n/foundations/pluralization-and-gender.md +109 -0
- package/expertise/i18n/foundations/string-externalization.md +236 -0
- package/expertise/i18n/foundations/text-direction-bidi.md +241 -0
- package/expertise/i18n/foundations/unicode-and-encoding.md +86 -0
- package/expertise/i18n/index.md +38 -0
- package/expertise/i18n/platform/backend-i18n.md +31 -0
- package/expertise/i18n/platform/flutter-i18n.md +148 -0
- package/expertise/i18n/platform/native-android-i18n.md +36 -0
- package/expertise/i18n/platform/native-ios-i18n.md +36 -0
- package/expertise/i18n/platform/react-i18n.md +103 -0
- package/expertise/i18n/platform/web-css-i18n.md +81 -0
- package/expertise/i18n/rtl/arabic-specific.md +175 -0
- package/expertise/i18n/rtl/hebrew-specific.md +149 -0
- package/expertise/i18n/rtl/rtl-animations-and-transitions.md +111 -0
- package/expertise/i18n/rtl/rtl-forms-and-input.md +161 -0
- package/expertise/i18n/rtl/rtl-fundamentals.md +211 -0
- package/expertise/i18n/rtl/rtl-icons-and-images.md +181 -0
- package/expertise/i18n/rtl/rtl-layout-mirroring.md +252 -0
- package/expertise/i18n/rtl/rtl-navigation-and-gestures.md +107 -0
- package/expertise/i18n/rtl/rtl-testing-and-qa.md +147 -0
- package/expertise/i18n/rtl/rtl-typography.md +160 -0
- package/expertise/index.md +113 -0
- package/expertise/index.yaml +216 -0
- package/expertise/infrastructure/cloud-aws.md +597 -0
- package/expertise/infrastructure/cloud-gcp.md +599 -0
- package/expertise/infrastructure/cybersecurity.md +816 -0
- package/expertise/infrastructure/database-mongodb.md +447 -0
- package/expertise/infrastructure/database-postgres.md +400 -0
- package/expertise/infrastructure/devops-cicd.md +787 -0
- package/expertise/infrastructure/index.md +27 -0
- package/expertise/performance/PROGRESS.md +50 -0
- package/expertise/performance/backend/api-latency.md +1204 -0
- package/expertise/performance/backend/background-jobs.md +506 -0
- package/expertise/performance/backend/connection-pooling.md +1209 -0
- package/expertise/performance/backend/database-query-optimization.md +515 -0
- package/expertise/performance/backend/index.md +23 -0
- package/expertise/performance/backend/rate-limiting-and-throttling.md +971 -0
- package/expertise/performance/foundations/algorithmic-complexity.md +954 -0
- package/expertise/performance/foundations/caching-strategies.md +489 -0
- package/expertise/performance/foundations/concurrency-and-parallelism.md +847 -0
- package/expertise/performance/foundations/index.md +24 -0
- package/expertise/performance/foundations/measuring-and-profiling.md +440 -0
- package/expertise/performance/foundations/memory-management.md +964 -0
- package/expertise/performance/foundations/performance-budgets.md +1314 -0
- package/expertise/performance/index.md +31 -0
- package/expertise/performance/infrastructure/auto-scaling.md +1059 -0
- package/expertise/performance/infrastructure/cdn-and-edge.md +1081 -0
- package/expertise/performance/infrastructure/index.md +22 -0
- package/expertise/performance/infrastructure/load-balancing.md +1081 -0
- package/expertise/performance/infrastructure/observability.md +1079 -0
- package/expertise/performance/mobile/index.md +23 -0
- package/expertise/performance/mobile/mobile-animations.md +544 -0
- package/expertise/performance/mobile/mobile-memory-battery.md +416 -0
- package/expertise/performance/mobile/mobile-network.md +452 -0
- package/expertise/performance/mobile/mobile-rendering.md +599 -0
- package/expertise/performance/mobile/mobile-startup-time.md +505 -0
- package/expertise/performance/platform-specific/flutter-performance.md +647 -0
- package/expertise/performance/platform-specific/index.md +22 -0
- package/expertise/performance/platform-specific/node-performance.md +1307 -0
- package/expertise/performance/platform-specific/postgres-performance.md +1366 -0
- package/expertise/performance/platform-specific/react-performance.md +1403 -0
- package/expertise/performance/web/bundle-optimization.md +1239 -0
- package/expertise/performance/web/image-and-media.md +636 -0
- package/expertise/performance/web/index.md +24 -0
- package/expertise/performance/web/network-optimization.md +1133 -0
- package/expertise/performance/web/rendering-performance.md +1098 -0
- package/expertise/performance/web/ssr-and-hydration.md +918 -0
- package/expertise/performance/web/web-vitals.md +1374 -0
- package/expertise/quality/accessibility.md +985 -0
- package/expertise/quality/evidence-based-verification.md +499 -0
- package/expertise/quality/index.md +24 -0
- package/expertise/quality/ml-model-audit.md +614 -0
- package/expertise/quality/performance.md +600 -0
- package/expertise/quality/testing-api.md +891 -0
- package/expertise/quality/testing-mobile.md +496 -0
- package/expertise/quality/testing-web.md +849 -0
- package/expertise/security/PROGRESS.md +54 -0
- package/expertise/security/agentic-identity.md +540 -0
- package/expertise/security/compliance-frameworks.md +601 -0
- package/expertise/security/data/data-encryption.md +364 -0
- package/expertise/security/data/data-privacy-gdpr.md +692 -0
- package/expertise/security/data/database-security.md +1171 -0
- package/expertise/security/data/index.md +22 -0
- package/expertise/security/data/pii-handling.md +531 -0
- package/expertise/security/foundations/authentication.md +1041 -0
- package/expertise/security/foundations/authorization.md +603 -0
- package/expertise/security/foundations/cryptography.md +1001 -0
- package/expertise/security/foundations/index.md +25 -0
- package/expertise/security/foundations/owasp-top-10.md +1354 -0
- package/expertise/security/foundations/secrets-management.md +1217 -0
- package/expertise/security/foundations/secure-sdlc.md +700 -0
- package/expertise/security/foundations/supply-chain-security.md +698 -0
- package/expertise/security/index.md +31 -0
- package/expertise/security/infrastructure/cloud-security-aws.md +1296 -0
- package/expertise/security/infrastructure/cloud-security-gcp.md +1376 -0
- package/expertise/security/infrastructure/container-security.md +721 -0
- package/expertise/security/infrastructure/incident-response.md +1295 -0
- package/expertise/security/infrastructure/index.md +24 -0
- package/expertise/security/infrastructure/logging-and-monitoring.md +1618 -0
- package/expertise/security/infrastructure/network-security.md +1337 -0
- package/expertise/security/mobile/index.md +23 -0
- package/expertise/security/mobile/mobile-android-security.md +1218 -0
- package/expertise/security/mobile/mobile-binary-protection.md +1229 -0
- package/expertise/security/mobile/mobile-data-storage.md +1265 -0
- package/expertise/security/mobile/mobile-ios-security.md +1401 -0
- package/expertise/security/mobile/mobile-network-security.md +1520 -0
- package/expertise/security/smart-contract-security.md +594 -0
- package/expertise/security/testing/index.md +22 -0
- package/expertise/security/testing/penetration-testing.md +1258 -0
- package/expertise/security/testing/security-code-review.md +1765 -0
- package/expertise/security/testing/threat-modeling.md +1074 -0
- package/expertise/security/testing/vulnerability-scanning.md +1062 -0
- package/expertise/security/web/api-security.md +586 -0
- package/expertise/security/web/cors-and-headers.md +433 -0
- package/expertise/security/web/csrf.md +562 -0
- package/expertise/security/web/file-upload.md +1477 -0
- package/expertise/security/web/index.md +25 -0
- package/expertise/security/web/injection.md +1375 -0
- package/expertise/security/web/session-management.md +1101 -0
- package/expertise/security/web/xss.md +1158 -0
- package/exports/README.md +17 -0
- package/exports/hosts/claude/.claude/agents/clarifier.md +42 -0
- package/exports/hosts/claude/.claude/agents/content-author.md +63 -0
- package/exports/hosts/claude/.claude/agents/designer.md +55 -0
- package/exports/hosts/claude/.claude/agents/executor.md +55 -0
- package/exports/hosts/claude/.claude/agents/learner.md +51 -0
- package/exports/hosts/claude/.claude/agents/planner.md +53 -0
- package/exports/hosts/claude/.claude/agents/researcher.md +43 -0
- package/exports/hosts/claude/.claude/agents/reviewer.md +54 -0
- package/exports/hosts/claude/.claude/agents/specifier.md +47 -0
- package/exports/hosts/claude/.claude/agents/verifier.md +71 -0
- package/exports/hosts/claude/.claude/commands/author.md +42 -0
- package/exports/hosts/claude/.claude/commands/clarify.md +38 -0
- package/exports/hosts/claude/.claude/commands/design-review.md +46 -0
- package/exports/hosts/claude/.claude/commands/design.md +44 -0
- package/exports/hosts/claude/.claude/commands/discover.md +37 -0
- package/exports/hosts/claude/.claude/commands/execute.md +48 -0
- package/exports/hosts/claude/.claude/commands/learn.md +38 -0
- package/exports/hosts/claude/.claude/commands/plan-review.md +42 -0
- package/exports/hosts/claude/.claude/commands/plan.md +39 -0
- package/exports/hosts/claude/.claude/commands/prepare-next.md +37 -0
- package/exports/hosts/claude/.claude/commands/review.md +40 -0
- package/exports/hosts/claude/.claude/commands/run-audit.md +41 -0
- package/exports/hosts/claude/.claude/commands/spec-challenge.md +41 -0
- package/exports/hosts/claude/.claude/commands/specify.md +38 -0
- package/exports/hosts/claude/.claude/commands/verify.md +37 -0
- package/exports/hosts/claude/.claude/settings.json +34 -0
- package/exports/hosts/claude/CLAUDE.md +19 -0
- package/exports/hosts/claude/export.manifest.json +38 -0
- package/exports/hosts/claude/host-package.json +67 -0
- package/exports/hosts/codex/AGENTS.md +19 -0
- package/exports/hosts/codex/export.manifest.json +38 -0
- package/exports/hosts/codex/host-package.json +41 -0
- package/exports/hosts/cursor/.cursor/hooks.json +16 -0
- package/exports/hosts/cursor/.cursor/rules/wazir-core.mdc +19 -0
- package/exports/hosts/cursor/export.manifest.json +38 -0
- package/exports/hosts/cursor/host-package.json +42 -0
- package/exports/hosts/gemini/GEMINI.md +19 -0
- package/exports/hosts/gemini/export.manifest.json +38 -0
- package/exports/hosts/gemini/host-package.json +41 -0
- package/hooks/README.md +18 -0
- package/hooks/definitions/loop_cap_guard.yaml +21 -0
- package/hooks/definitions/post_tool_capture.yaml +24 -0
- package/hooks/definitions/pre_compact_summary.yaml +19 -0
- package/hooks/definitions/pre_tool_capture_route.yaml +19 -0
- package/hooks/definitions/protected_path_write_guard.yaml +19 -0
- package/hooks/definitions/session_start.yaml +19 -0
- package/hooks/definitions/stop_handoff_harvest.yaml +20 -0
- package/hooks/loop-cap-guard +17 -0
- package/hooks/post-tool-lint +36 -0
- package/hooks/protected-path-write-guard +17 -0
- package/hooks/session-start +41 -0
- package/llms-full.txt +2355 -0
- package/llms.txt +43 -0
- package/package.json +79 -0
- package/roles/README.md +20 -0
- package/roles/clarifier.md +42 -0
- package/roles/content-author.md +63 -0
- package/roles/designer.md +55 -0
- package/roles/executor.md +55 -0
- package/roles/learner.md +51 -0
- package/roles/planner.md +53 -0
- package/roles/researcher.md +43 -0
- package/roles/reviewer.md +54 -0
- package/roles/specifier.md +47 -0
- package/roles/verifier.md +71 -0
- package/schemas/README.md +24 -0
- package/schemas/accepted-learning.schema.json +20 -0
- package/schemas/author-artifact.schema.json +156 -0
- package/schemas/clarification.schema.json +19 -0
- package/schemas/design-artifact.schema.json +80 -0
- package/schemas/docs-claim.schema.json +18 -0
- package/schemas/export-manifest.schema.json +20 -0
- package/schemas/hook.schema.json +67 -0
- package/schemas/host-export-package.schema.json +18 -0
- package/schemas/implementation-plan.schema.json +19 -0
- package/schemas/proposed-learning.schema.json +19 -0
- package/schemas/research.schema.json +18 -0
- package/schemas/review.schema.json +29 -0
- package/schemas/run-manifest.schema.json +18 -0
- package/schemas/spec-challenge.schema.json +18 -0
- package/schemas/spec.schema.json +20 -0
- package/schemas/usage.schema.json +102 -0
- package/schemas/verification-proof.schema.json +29 -0
- package/schemas/wazir-manifest.schema.json +173 -0
- package/skills/README.md +40 -0
- package/skills/brainstorming/SKILL.md +77 -0
- package/skills/debugging/SKILL.md +50 -0
- package/skills/design/SKILL.md +61 -0
- package/skills/dispatching-parallel-agents/SKILL.md +128 -0
- package/skills/executing-plans/SKILL.md +70 -0
- package/skills/finishing-a-development-branch/SKILL.md +169 -0
- package/skills/humanize/SKILL.md +123 -0
- package/skills/init-pipeline/SKILL.md +124 -0
- package/skills/prepare-next/SKILL.md +20 -0
- package/skills/receiving-code-review/SKILL.md +123 -0
- package/skills/requesting-code-review/SKILL.md +105 -0
- package/skills/requesting-code-review/code-reviewer.md +108 -0
- package/skills/run-audit/SKILL.md +197 -0
- package/skills/scan-project/SKILL.md +41 -0
- package/skills/self-audit/SKILL.md +153 -0
- package/skills/subagent-driven-development/SKILL.md +154 -0
- package/skills/subagent-driven-development/code-quality-reviewer-prompt.md +26 -0
- package/skills/subagent-driven-development/implementer-prompt.md +102 -0
- package/skills/subagent-driven-development/spec-reviewer-prompt.md +61 -0
- package/skills/tdd/SKILL.md +23 -0
- package/skills/using-git-worktrees/SKILL.md +163 -0
- package/skills/using-skills/SKILL.md +95 -0
- package/skills/verification/SKILL.md +22 -0
- package/skills/wazir/SKILL.md +463 -0
- package/skills/writing-plans/SKILL.md +30 -0
- package/skills/writing-skills/SKILL.md +157 -0
- package/skills/writing-skills/anthropic-best-practices.md +122 -0
- package/skills/writing-skills/persuasion-principles.md +50 -0
- package/templates/README.md +20 -0
- package/templates/artifacts/README.md +10 -0
- package/templates/artifacts/accepted-learning.md +19 -0
- package/templates/artifacts/accepted-learning.template.json +12 -0
- package/templates/artifacts/author.md +74 -0
- package/templates/artifacts/author.template.json +19 -0
- package/templates/artifacts/clarification.md +21 -0
- package/templates/artifacts/clarification.template.json +12 -0
- package/templates/artifacts/execute-notes.md +19 -0
- package/templates/artifacts/implementation-plan.md +21 -0
- package/templates/artifacts/implementation-plan.template.json +11 -0
- package/templates/artifacts/learning-proposal.md +19 -0
- package/templates/artifacts/next-run-handoff.md +21 -0
- package/templates/artifacts/plan-review.md +19 -0
- package/templates/artifacts/proposed-learning.template.json +12 -0
- package/templates/artifacts/research.md +21 -0
- package/templates/artifacts/research.template.json +12 -0
- package/templates/artifacts/review-findings.md +19 -0
- package/templates/artifacts/review.template.json +11 -0
- package/templates/artifacts/run-manifest.template.json +8 -0
- package/templates/artifacts/spec-challenge.md +19 -0
- package/templates/artifacts/spec-challenge.template.json +11 -0
- package/templates/artifacts/spec.md +21 -0
- package/templates/artifacts/spec.template.json +12 -0
- package/templates/artifacts/verification-proof.md +19 -0
- package/templates/artifacts/verification-proof.template.json +11 -0
- package/templates/examples/accepted-learning.example.json +14 -0
- package/templates/examples/author.example.json +152 -0
- package/templates/examples/clarification.example.json +15 -0
- package/templates/examples/docs-claim.example.json +8 -0
- package/templates/examples/export-manifest.example.json +7 -0
- package/templates/examples/host-export-package.example.json +11 -0
- package/templates/examples/implementation-plan.example.json +17 -0
- package/templates/examples/proposed-learning.example.json +13 -0
- package/templates/examples/research.example.json +15 -0
- package/templates/examples/research.example.md +6 -0
- package/templates/examples/review.example.json +17 -0
- package/templates/examples/run-manifest.example.json +9 -0
- package/templates/examples/spec-challenge.example.json +14 -0
- package/templates/examples/spec.example.json +21 -0
- package/templates/examples/verification-proof.example.json +21 -0
- package/templates/examples/wazir-manifest.example.yaml +65 -0
- package/templates/task-definition-schema.md +99 -0
- package/tooling/README.md +20 -0
- package/tooling/src/adapters/context-mode.js +50 -0
- package/tooling/src/capture/command.js +376 -0
- package/tooling/src/capture/store.js +99 -0
- package/tooling/src/capture/usage.js +270 -0
- package/tooling/src/checks/branches.js +50 -0
- package/tooling/src/checks/brand-truth.js +110 -0
- package/tooling/src/checks/changelog.js +231 -0
- package/tooling/src/checks/command-registry.js +36 -0
- package/tooling/src/checks/commits.js +102 -0
- package/tooling/src/checks/docs-drift.js +103 -0
- package/tooling/src/checks/docs-truth.js +201 -0
- package/tooling/src/checks/runtime-surface.js +156 -0
- package/tooling/src/cli.js +116 -0
- package/tooling/src/command-options.js +56 -0
- package/tooling/src/commands/validate.js +320 -0
- package/tooling/src/doctor/command.js +91 -0
- package/tooling/src/export/command.js +77 -0
- package/tooling/src/export/compiler.js +498 -0
- package/tooling/src/guards/loop-cap-guard.js +52 -0
- package/tooling/src/guards/protected-path-write-guard.js +67 -0
- package/tooling/src/index/command.js +152 -0
- package/tooling/src/index/storage.js +1061 -0
- package/tooling/src/index/summarizers.js +261 -0
- package/tooling/src/loaders.js +18 -0
- package/tooling/src/project-root.js +22 -0
- package/tooling/src/recall/command.js +225 -0
- package/tooling/src/schema-validator.js +30 -0
- package/tooling/src/state-root.js +40 -0
- package/tooling/src/status/command.js +71 -0
- package/wazir.manifest.yaml +135 -0
- package/workflows/README.md +19 -0
- package/workflows/author.md +42 -0
- package/workflows/clarify.md +38 -0
- package/workflows/design-review.md +46 -0
- package/workflows/design.md +44 -0
- package/workflows/discover.md +37 -0
- package/workflows/execute.md +48 -0
- package/workflows/learn.md +38 -0
- package/workflows/plan-review.md +42 -0
- package/workflows/plan.md +39 -0
- package/workflows/prepare-next.md +37 -0
- package/workflows/review.md +40 -0
- package/workflows/run-audit.md +41 -0
- package/workflows/spec-challenge.md +41 -0
- package/workflows/specify.md +38 -0
- package/workflows/verify.md +37 -0
|
@@ -0,0 +1,625 @@
|
|
|
1
|
+
# Embedded Firmware -- Expertise Module
|
|
2
|
+
|
|
3
|
+
> An embedded firmware developer builds safety-critical, resource-constrained software for microcontrollers and IoT devices -- from bare-metal register manipulation and RTOS task orchestration to OTA update systems and power-optimized communication stacks. The scope spans real-time scheduling, interrupt-safe programming, peripheral protocols, and field-deployed firmware that must run unattended for years without failure.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 1. Authority & Context
|
|
8
|
+
|
|
9
|
+
Embedded firmware runs on over 10 billion IoT devices deployed worldwide. The consequences of firmware failure are proven and severe:
|
|
10
|
+
|
|
11
|
+
- **Mirai botnet (2016)** -- compromised 600,000+ IoT devices via default credentials and absent update mechanisms, launching 1.2 Tbps DDoS attacks that took down major internet infrastructure.
|
|
12
|
+
- **Stuxnet (2010)** -- the first known firmware-targeted cyberweapon, reprogramming Siemens PLCs to destroy Iranian nuclear centrifuges while reporting normal operation to operators.
|
|
13
|
+
- **Jeep Cherokee remote hack (2015)** -- Miller and Valasek demonstrated full remote vehicle control through the infotainment system's cellular connection, exploiting firmware-level CAN bus access. Resulted in a 1.4 million vehicle recall.
|
|
14
|
+
|
|
15
|
+
| Standard | Domain | Key requirement |
|
|
16
|
+
|----------|--------|----------------|
|
|
17
|
+
| IEC 61508 | Industrial safety | Safety Integrity Levels (SIL 1-4), systematic fault avoidance |
|
|
18
|
+
| ISO 26262 | Automotive | ASIL A-D classification, MISRA C compliance |
|
|
19
|
+
| DO-178C | Avionics | Design Assurance Levels (DAL A-E), MC/DC coverage |
|
|
20
|
+
| MISRA C:2012 | All safety-critical | 175 rules restricting dangerous C constructs |
|
|
21
|
+
| CERT C | Security-critical | Secure coding rules eliminating undefined behavior |
|
|
22
|
+
| Barr Group Embedded C | General embedded | Naming, bracing, and defensive coding conventions |
|
|
23
|
+
|
|
24
|
+
**Rule:** If the device can injure someone, brick itself remotely, or join a botnet, you need a coding standard. Enforce it with static analysis -- not code review alone.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## 2. Platform Coverage
|
|
29
|
+
|
|
30
|
+
| Platform | Framework | CPU | RAM | Use Case |
|
|
31
|
+
|----------|-----------|-----|-----|----------|
|
|
32
|
+
| ESP32 | ESP-IDF 5.x | Xtensa/RISC-V 240MHz | 520KB | Wi-Fi/BLE IoT |
|
|
33
|
+
| STM32 | HAL/LL | Cortex-M0/M4/M7 | 16KB-1MB | Industrial, automotive |
|
|
34
|
+
| Nordic nRF52/53 | Zephyr/nRF Connect SDK | Cortex-M4/M33 | 256KB | BLE, ultra-low power |
|
|
35
|
+
| RP2040 | Pico SDK | Cortex-M0+ dual-core 133MHz | 264KB | Education, simple embedded |
|
|
36
|
+
| TI CC2652 | TI-RTOS/Zephyr | Cortex-M4F 48MHz | 80KB | Zigbee, Thread, multi-protocol |
|
|
37
|
+
| NXP i.MX RT | MCUXpresso SDK | Cortex-M7 600MHz | 1MB+ | High-perf embedded, HMI |
|
|
38
|
+
|
|
39
|
+
**Selection:** Battery BLE --> nRF52840. Wi-Fi home --> ESP32-S3. Automotive/CAN --> STM32. Prototyping --> RP2040.
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## 3. Build System & Toolchain
|
|
44
|
+
|
|
45
|
+
```cmake
|
|
46
|
+
cmake_minimum_required(VERSION 3.20)
|
|
47
|
+
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/arm-none-eabi.cmake)
|
|
48
|
+
project(sensor-node C ASM)
|
|
49
|
+
set(CMAKE_C_STANDARD 11)
|
|
50
|
+
set(CMAKE_C_STANDARD_REQUIRED ON)
|
|
51
|
+
|
|
52
|
+
add_executable(${PROJECT_NAME}
|
|
53
|
+
src/main.c src/sensor_task.c src/comms_task.c
|
|
54
|
+
startup/startup_stm32f407.s
|
|
55
|
+
)
|
|
56
|
+
target_compile_options(${PROJECT_NAME} PRIVATE
|
|
57
|
+
-mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard
|
|
58
|
+
-Wall -Wextra -Werror -Os
|
|
59
|
+
-ffunction-sections -fdata-sections
|
|
60
|
+
)
|
|
61
|
+
target_link_options(${PROJECT_NAME} PRIVATE
|
|
62
|
+
-T${CMAKE_SOURCE_DIR}/linker/STM32F407.ld
|
|
63
|
+
-Wl,--gc-sections -Wl,-Map=output.map
|
|
64
|
+
--specs=nano.specs
|
|
65
|
+
)
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Non-negotiable compiler warnings:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
-Wall -Wextra -Werror -Wshadow -Wdouble-promotion -Wformat=2
|
|
72
|
+
-Wformat-truncation -Wundef -fno-common -Wconversion
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## 4. RTOS Patterns (FreeRTOS)
|
|
78
|
+
|
|
79
|
+
### Task creation with static allocation
|
|
80
|
+
|
|
81
|
+
```c
|
|
82
|
+
static StaticTask_t sensor_tcb;
|
|
83
|
+
static StackType_t sensor_stack[SENSOR_STACK_SIZE];
|
|
84
|
+
|
|
85
|
+
TaskHandle_t sensor_handle = xTaskCreateStatic(
|
|
86
|
+
sensor_task_fn, "Sensor", SENSOR_STACK_SIZE, NULL,
|
|
87
|
+
PRIORITY_SENSOR, // tskIDLE_PRIORITY + 2
|
|
88
|
+
sensor_stack, &sensor_tcb
|
|
89
|
+
);
|
|
90
|
+
configASSERT(sensor_handle != NULL);
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Priority assignment
|
|
94
|
+
|
|
95
|
+
```c
|
|
96
|
+
#define PRIORITY_IDLE (tskIDLE_PRIORITY) // 0
|
|
97
|
+
#define PRIORITY_LOGGING (tskIDLE_PRIORITY + 1) // 1
|
|
98
|
+
#define PRIORITY_SENSOR (tskIDLE_PRIORITY + 2) // 2
|
|
99
|
+
#define PRIORITY_COMMS (tskIDLE_PRIORITY + 3) // 3
|
|
100
|
+
#define PRIORITY_SAFETY (tskIDLE_PRIORITY + 4) // 4
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
**Rule:** Assign by deadline urgency, not perceived importance.
|
|
104
|
+
|
|
105
|
+
### Queue-based inter-task communication
|
|
106
|
+
|
|
107
|
+
```c
|
|
108
|
+
static StaticQueue_t queue_tcb;
|
|
109
|
+
static uint8_t queue_storage[QUEUE_LEN * sizeof(sensor_reading_t)];
|
|
110
|
+
|
|
111
|
+
QueueHandle_t sensor_queue = xQueueCreateStatic(
|
|
112
|
+
QUEUE_LEN, sizeof(sensor_reading_t), queue_storage, &queue_tcb
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
// Producer:
|
|
116
|
+
if (xQueueSend(sensor_queue, &reading, pdMS_TO_TICKS(100)) != pdPASS) {
|
|
117
|
+
stats.dropped_readings++;
|
|
118
|
+
}
|
|
119
|
+
// Consumer:
|
|
120
|
+
if (xQueueReceive(sensor_queue, &reading, pdMS_TO_TICKS(1000)) == pdPASS) {
|
|
121
|
+
transmit_reading(&reading);
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Priority inversion prevention
|
|
126
|
+
|
|
127
|
+
```c
|
|
128
|
+
// Priority inheritance mutex -- NOT binary semaphore
|
|
129
|
+
SemaphoreHandle_t spi_mutex = xSemaphoreCreateMutex();
|
|
130
|
+
|
|
131
|
+
if (xSemaphoreTake(spi_mutex, pdMS_TO_TICKS(50)) == pdPASS) {
|
|
132
|
+
spi_transfer(data, len);
|
|
133
|
+
xSemaphoreGive(spi_mutex);
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Watchdog feeding from task heartbeats
|
|
138
|
+
|
|
139
|
+
```c
|
|
140
|
+
static volatile uint32_t task_heartbeats[TASK_COUNT];
|
|
141
|
+
|
|
142
|
+
void watchdog_task_fn(void *param) {
|
|
143
|
+
static uint32_t last[TASK_COUNT];
|
|
144
|
+
for (;;) {
|
|
145
|
+
bool all_alive = true;
|
|
146
|
+
for (int i = 0; i < TASK_COUNT; i++) {
|
|
147
|
+
if (task_heartbeats[i] == last[i]) { all_alive = false; }
|
|
148
|
+
last[i] = task_heartbeats[i];
|
|
149
|
+
}
|
|
150
|
+
if (all_alive) { HAL_IWDG_Refresh(&hiwdg); }
|
|
151
|
+
vTaskDelay(pdMS_TO_TICKS(WATCHDOG_CHECK_MS));
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## 5. Memory Discipline
|
|
159
|
+
|
|
160
|
+
Memory errors are the number one cause of firmware field failures. Heap fragmentation crashes devices after days of operation -- long after testing ends.
|
|
161
|
+
|
|
162
|
+
### NO malloc/free after initialization
|
|
163
|
+
|
|
164
|
+
```c
|
|
165
|
+
// CORRECT: static allocation
|
|
166
|
+
static uint8_t uart_rx_buffer[UART_RX_BUF_SIZE];
|
|
167
|
+
static sensor_reading_t reading_pool[MAX_READINGS];
|
|
168
|
+
|
|
169
|
+
// WRONG: runtime allocation -- fragmentation time bomb
|
|
170
|
+
void handle_message(void) {
|
|
171
|
+
char *buf = malloc(msg_len); // NEVER after init
|
|
172
|
+
free(buf);
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Set `configSUPPORT_DYNAMIC_ALLOCATION` to 0 in `FreeRTOSConfig.h` to enforce at compile time.
|
|
177
|
+
|
|
178
|
+
### Stack sizing
|
|
179
|
+
|
|
180
|
+
Measure with `uxTaskGetStackHighWaterMark()`, then set final size to (measured usage + 20% margin). Start with 2x expected during development.
|
|
181
|
+
|
|
182
|
+
### Fixed-size memory pool
|
|
183
|
+
|
|
184
|
+
```c
|
|
185
|
+
#define POOL_SIZE 32
|
|
186
|
+
#define BLOCK_SIZE 128
|
|
187
|
+
static uint8_t pool_storage[POOL_SIZE][BLOCK_SIZE];
|
|
188
|
+
static uint8_t pool_bitmap[POOL_SIZE];
|
|
189
|
+
|
|
190
|
+
void *pool_alloc(void) {
|
|
191
|
+
for (int i = 0; i < POOL_SIZE; i++) {
|
|
192
|
+
if (!pool_bitmap[i]) {
|
|
193
|
+
pool_bitmap[i] = 1;
|
|
194
|
+
return pool_storage[i];
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
return NULL; // Pool exhausted
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
void pool_free(void *block) {
|
|
201
|
+
if (!block) return;
|
|
202
|
+
ptrdiff_t idx = ((uint8_t *)block - (uint8_t *)pool_storage) / BLOCK_SIZE;
|
|
203
|
+
if (idx >= 0 && idx < POOL_SIZE) pool_bitmap[idx] = 0;
|
|
204
|
+
}
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
## 6. ISR (Interrupt Service Routine) Discipline
|
|
210
|
+
|
|
211
|
+
### Cardinal rules
|
|
212
|
+
|
|
213
|
+
1. ISRs MUST be minimal: set flag/semaphore, return immediately.
|
|
214
|
+
2. Never call blocking functions, `printf`, `malloc`, or mutex-acquiring functions from ISR.
|
|
215
|
+
3. Use `FromISR` variants of all FreeRTOS API calls.
|
|
216
|
+
4. Disable interrupts (not mutexes) for critical sections shared between ISR and task code.
|
|
217
|
+
5. Always clear the interrupt flag before returning.
|
|
218
|
+
|
|
219
|
+
### Correct: deferred processing
|
|
220
|
+
|
|
221
|
+
```c
|
|
222
|
+
void EXTI0_IRQHandler(void) {
|
|
223
|
+
if (__HAL_GPIO_EXTI_GET_IT(GPIO_PIN_0)) {
|
|
224
|
+
__HAL_GPIO_EXTI_CLEAR_IT(GPIO_PIN_0);
|
|
225
|
+
BaseType_t woken = pdFALSE;
|
|
226
|
+
xSemaphoreGiveFromISR(button_sem, &woken);
|
|
227
|
+
portYIELD_FROM_ISR(woken);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
void button_task_fn(void *param) {
|
|
232
|
+
for (;;) {
|
|
233
|
+
if (xSemaphoreTake(button_sem, portMAX_DELAY) == pdPASS) {
|
|
234
|
+
debounce_and_process_button();
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
### Wrong: work in ISR
|
|
241
|
+
|
|
242
|
+
```c
|
|
243
|
+
void EXTI0_IRQHandler(void) {
|
|
244
|
+
printf("Button pressed!\n"); // NEVER: blocking I/O
|
|
245
|
+
process_button_event(); // NEVER: complex logic
|
|
246
|
+
vTaskDelay(pdMS_TO_TICKS(100)); // NEVER: blocking call
|
|
247
|
+
xSemaphoreTake(mutex, portMAX_DELAY); // NEVER: mutex in ISR
|
|
248
|
+
}
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
### Volatile for ISR-shared data
|
|
252
|
+
|
|
253
|
+
```c
|
|
254
|
+
static volatile uint32_t isr_timestamp;
|
|
255
|
+
static volatile bool isr_event_pending;
|
|
256
|
+
|
|
257
|
+
// In task: read with interrupts disabled for multi-word atomicity
|
|
258
|
+
uint32_t read_isr_timestamp(void) {
|
|
259
|
+
taskENTER_CRITICAL();
|
|
260
|
+
uint32_t ts = isr_timestamp;
|
|
261
|
+
isr_event_pending = false;
|
|
262
|
+
taskEXIT_CRITICAL();
|
|
263
|
+
return ts;
|
|
264
|
+
}
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
---
|
|
268
|
+
|
|
269
|
+
## 7. Communication Protocols
|
|
270
|
+
|
|
271
|
+
### UART with DMA and ring buffer
|
|
272
|
+
|
|
273
|
+
```c
|
|
274
|
+
typedef struct {
|
|
275
|
+
uint8_t buffer[UART_BUF_SIZE];
|
|
276
|
+
volatile uint16_t head;
|
|
277
|
+
volatile uint16_t tail;
|
|
278
|
+
} ring_buffer_t;
|
|
279
|
+
|
|
280
|
+
void uart_init(UART_HandleTypeDef *huart) {
|
|
281
|
+
huart->Init.BaudRate = 115200;
|
|
282
|
+
huart->Init.WordLength = UART_WORDLENGTH_8B;
|
|
283
|
+
huart->Init.StopBits = UART_STOPBITS_1;
|
|
284
|
+
huart->Init.Parity = UART_PARITY_NONE;
|
|
285
|
+
HAL_UART_Init(huart);
|
|
286
|
+
HAL_UARTEx_ReceiveToIdle_DMA(huart, ring.buffer, UART_BUF_SIZE);
|
|
287
|
+
}
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
### SPI master with chip select
|
|
291
|
+
|
|
292
|
+
```c
|
|
293
|
+
HAL_StatusTypeDef spi_transfer(spi_device_t *dev, const uint8_t *tx,
|
|
294
|
+
uint8_t *rx, uint16_t len) {
|
|
295
|
+
HAL_GPIO_WritePin(dev->cs_port, dev->cs_pin, GPIO_PIN_RESET);
|
|
296
|
+
HAL_StatusTypeDef status = HAL_SPI_TransmitReceive(
|
|
297
|
+
dev->hspi, (uint8_t *)tx, rx, len, SPI_TIMEOUT_MS);
|
|
298
|
+
HAL_GPIO_WritePin(dev->cs_port, dev->cs_pin, GPIO_PIN_SET);
|
|
299
|
+
return status;
|
|
300
|
+
}
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
### I2C with error recovery
|
|
304
|
+
|
|
305
|
+
```c
|
|
306
|
+
HAL_StatusTypeDef i2c_read_reg(I2C_HandleTypeDef *hi2c, uint8_t addr,
|
|
307
|
+
uint8_t reg, uint8_t *data, uint16_t len) {
|
|
308
|
+
HAL_StatusTypeDef status = HAL_I2C_Mem_Read(
|
|
309
|
+
hi2c, addr << 1, reg, I2C_MEMADD_SIZE_8BIT, data, len, I2C_TIMEOUT_MS);
|
|
310
|
+
if (status != HAL_OK) {
|
|
311
|
+
i2c_bus_recovery(hi2c); // Toggle SCL 9x to release stuck SDA
|
|
312
|
+
status = HAL_I2C_Mem_Read(
|
|
313
|
+
hi2c, addr << 1, reg, I2C_MEMADD_SIZE_8BIT, data, len, I2C_TIMEOUT_MS);
|
|
314
|
+
}
|
|
315
|
+
return status;
|
|
316
|
+
}
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
### CAN bus with filtering
|
|
320
|
+
|
|
321
|
+
```c
|
|
322
|
+
void can_init(CAN_HandleTypeDef *hcan) {
|
|
323
|
+
hcan->Init.Prescaler = 6; // 500 kbit/s on 42MHz APB1
|
|
324
|
+
hcan->Init.Mode = CAN_MODE_NORMAL;
|
|
325
|
+
HAL_CAN_Init(hcan);
|
|
326
|
+
|
|
327
|
+
CAN_FilterTypeDef filter = {
|
|
328
|
+
.FilterIdHigh = 0x100 << 5,
|
|
329
|
+
.FilterMaskIdHigh = 0x700 << 5,
|
|
330
|
+
.FilterFIFOAssignment = CAN_FILTER_FIFO0,
|
|
331
|
+
.FilterActivation = ENABLE,
|
|
332
|
+
.FilterMode = CAN_FILTERMODE_IDMASK,
|
|
333
|
+
};
|
|
334
|
+
HAL_CAN_ConfigFilter(hcan, &filter);
|
|
335
|
+
HAL_CAN_Start(hcan);
|
|
336
|
+
HAL_CAN_ActivateNotification(hcan, CAN_IT_RX_FIFO0_MSG_PENDING);
|
|
337
|
+
}
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
### BLE (Zephyr)
|
|
341
|
+
|
|
342
|
+
```c
|
|
343
|
+
BT_GATT_SERVICE_DEFINE(sensor_svc,
|
|
344
|
+
BT_GATT_PRIMARY_SERVICE(BT_UUID_DECLARE_128(SENSOR_SERVICE_UUID)),
|
|
345
|
+
BT_GATT_CHARACTERISTIC(
|
|
346
|
+
BT_UUID_DECLARE_128(SENSOR_TEMP_UUID),
|
|
347
|
+
BT_GATT_CHRC_READ | BT_GATT_CHRC_NOTIFY,
|
|
348
|
+
BT_GATT_PERM_READ, read_temperature, NULL, ¤t_temp),
|
|
349
|
+
BT_GATT_CCC(temp_ccc_changed, BT_GATT_PERM_READ | BT_GATT_PERM_WRITE),
|
|
350
|
+
);
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
---
|
|
354
|
+
|
|
355
|
+
## 8. OTA Update Patterns
|
|
356
|
+
|
|
357
|
+
A failed OTA must never brick the device. Use A/B partitioning with cryptographic verification.
|
|
358
|
+
|
|
359
|
+
### Flash layout (dual-bank)
|
|
360
|
+
|
|
361
|
+
```
|
|
362
|
+
+------------------+ 0x08000000
|
|
363
|
+
| Bootloader (32K) | Verifies signature, selects active partition
|
|
364
|
+
+------------------+ 0x08008000
|
|
365
|
+
| Partition A (480K)| Active firmware
|
|
366
|
+
+------------------+ 0x08080000
|
|
367
|
+
| Partition B (480K)| OTA staging area
|
|
368
|
+
+------------------+ 0x080F8000
|
|
369
|
+
| Config (32K) | Boot flags, version, rollback counter
|
|
370
|
+
+------------------+
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
### OTA header with integrity verification
|
|
374
|
+
|
|
375
|
+
```c
|
|
376
|
+
typedef struct __attribute__((packed)) {
|
|
377
|
+
uint32_t magic; // 0xDEADBEEF
|
|
378
|
+
uint32_t header_version;
|
|
379
|
+
uint32_t fw_version; // Monotonic -- prevents downgrade
|
|
380
|
+
uint32_t image_size;
|
|
381
|
+
uint32_t hw_id; // Hardware compatibility
|
|
382
|
+
uint8_t sha256[32]; // SHA-256 of payload
|
|
383
|
+
uint8_t signature[64]; // Ed25519 over header + payload
|
|
384
|
+
uint8_t payload[];
|
|
385
|
+
} ota_header_t;
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
### Verification sequence
|
|
389
|
+
|
|
390
|
+
1. Check magic number (reject garbage fast).
|
|
391
|
+
2. Verify hardware compatibility (`hw_id`).
|
|
392
|
+
3. Reject downgrade (monotonic `fw_version`).
|
|
393
|
+
4. Compute and compare SHA-256 hash.
|
|
394
|
+
5. Verify Ed25519/ECDSA signature against embedded public key.
|
|
395
|
+
|
|
396
|
+
### Automatic rollback
|
|
397
|
+
|
|
398
|
+
```c
|
|
399
|
+
void bootloader_select_partition(void) {
|
|
400
|
+
boot_config_t cfg;
|
|
401
|
+
read_boot_config(&cfg);
|
|
402
|
+
if (cfg.state == BOOT_PENDING_VERIFY) {
|
|
403
|
+
cfg.boot_count++;
|
|
404
|
+
if (cfg.boot_count > MAX_BOOT_ATTEMPTS) {
|
|
405
|
+
cfg.active_partition ^= 1; // Swap back
|
|
406
|
+
cfg.state = BOOT_ROLLBACK;
|
|
407
|
+
cfg.boot_count = 0;
|
|
408
|
+
}
|
|
409
|
+
write_boot_config(&cfg);
|
|
410
|
+
}
|
|
411
|
+
jump_to_partition(cfg.active_partition);
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
// Application calls after successful boot + self-test
|
|
415
|
+
void ota_confirm_image(void) {
|
|
416
|
+
boot_config_t cfg;
|
|
417
|
+
read_boot_config(&cfg);
|
|
418
|
+
cfg.state = BOOT_OK;
|
|
419
|
+
cfg.boot_count = 0;
|
|
420
|
+
write_boot_config(&cfg);
|
|
421
|
+
}
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
---
|
|
425
|
+
|
|
426
|
+
## 9. Power Optimization
|
|
427
|
+
|
|
428
|
+
Battery life is a feature. A sensor node lasting 6 months instead of 2 years is a product failure.
|
|
429
|
+
|
|
430
|
+
### Current consumption budget
|
|
431
|
+
|
|
432
|
+
| State | ESP32 | nRF52840 | STM32L476 |
|
|
433
|
+
|-------|-------|----------|-----------|
|
|
434
|
+
| Active (CPU + radio) | 80-240 mA | 5-15 mA | 10-30 mA |
|
|
435
|
+
| Light sleep (RAM retained) | 0.8 mA | 1.5 uA | 2 uA |
|
|
436
|
+
| Deep sleep (RTC only) | 10 uA | 0.4 uA | 0.03 uA |
|
|
437
|
+
| Shutdown (wake via pin) | 5 uA | 0.3 uA | 0.01 uA |
|
|
438
|
+
|
|
439
|
+
### Duty cycling
|
|
440
|
+
|
|
441
|
+
```c
|
|
442
|
+
void low_power_task(void *param) {
|
|
443
|
+
for (;;) {
|
|
444
|
+
enable_sensor_power();
|
|
445
|
+
vTaskDelay(pdMS_TO_TICKS(10)); // Sensor startup
|
|
446
|
+
sensor_reading_t reading = sample_sensor();
|
|
447
|
+
disable_sensor_power();
|
|
448
|
+
|
|
449
|
+
if (reading_changed(&reading) || interval_elapsed()) {
|
|
450
|
+
enable_radio();
|
|
451
|
+
transmit_reading(&reading);
|
|
452
|
+
disable_radio();
|
|
453
|
+
}
|
|
454
|
+
enter_deep_sleep(SLEEP_DURATION_SEC);
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
### Peripheral power gating
|
|
460
|
+
|
|
461
|
+
```c
|
|
462
|
+
void power_optimize_peripherals(void) {
|
|
463
|
+
__HAL_RCC_GPIOB_CLK_DISABLE();
|
|
464
|
+
__HAL_RCC_SPI2_CLK_DISABLE();
|
|
465
|
+
__HAL_RCC_USART2_CLK_DISABLE();
|
|
466
|
+
// Configure unused pins as analog (lowest leakage)
|
|
467
|
+
GPIO_InitTypeDef gpio = {.Pin = GPIO_PIN_All, .Mode = GPIO_MODE_ANALOG};
|
|
468
|
+
HAL_GPIO_Init(GPIOB, &gpio);
|
|
469
|
+
}
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
---
|
|
473
|
+
|
|
474
|
+
## 10. Testing Strategy
|
|
475
|
+
|
|
476
|
+
### Unit testing on host
|
|
477
|
+
|
|
478
|
+
Run business logic tests on the development machine. No hardware needed.
|
|
479
|
+
|
|
480
|
+
```c
|
|
481
|
+
#include "unity.h"
|
|
482
|
+
#include "sensor_calibration.h"
|
|
483
|
+
|
|
484
|
+
void test_calibration_linear(void) {
|
|
485
|
+
calibration_t cal = {.offset = 100, .scale = 256};
|
|
486
|
+
TEST_ASSERT_EQUAL_INT32(2148, apply_calibration(&cal, 2048));
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
void test_calibration_clamps(void) {
|
|
490
|
+
calibration_t cal = {.offset = 0, .scale = 512};
|
|
491
|
+
TEST_ASSERT_EQUAL_INT32(SENSOR_MAX_VALUE, apply_calibration(&cal, 20000));
|
|
492
|
+
}
|
|
493
|
+
```
|
|
494
|
+
|
|
495
|
+
### Hardware-in-the-loop (HIL)
|
|
496
|
+
|
|
497
|
+
- Test jig with known stimulus (voltage source, signal generator).
|
|
498
|
+
- Automate with pytest + serial port.
|
|
499
|
+
- Assert on timing (logic analyzer), values (ADC readback), protocol correctness (bus sniffer).
|
|
500
|
+
|
|
501
|
+
### Static analysis
|
|
502
|
+
|
|
503
|
+
```bash
|
|
504
|
+
cppcheck --addon=misra --suppress=misra-c2012-3.1 src/ # MISRA
|
|
505
|
+
scan-build -o reports/ cmake --build build/ # Clang analyzer
|
|
506
|
+
pclp64 -w3 +misra(c2012) src/*.c # PC-lint Plus
|
|
507
|
+
```
|
|
508
|
+
|
|
509
|
+
---
|
|
510
|
+
|
|
511
|
+
## 11. Anti-Patterns & Pitfalls
|
|
512
|
+
|
|
513
|
+
### 1. Blocking in ISR
|
|
514
|
+
Delays, `printf`, or mutex locks block all lower-priority interrupts and RTOS scheduling. Causes HardFault or watchdog reset. **Fix:** Set flag/semaphore in ISR; process in task context.
|
|
515
|
+
|
|
516
|
+
### 2. Unbounded queues
|
|
517
|
+
Producer outpacing consumer exhausts heap after hours. **Fix:** Fixed-size static queues with explicit overflow handling.
|
|
518
|
+
|
|
519
|
+
### 3. Missing watchdog
|
|
520
|
+
Any hang (deadlock, infinite loop, corruption) bricks the device until power cycled. Remote deployment = truck roll. **Fix:** Hardware watchdog fed only when all tasks report healthy.
|
|
521
|
+
|
|
522
|
+
### 4. Dynamic memory after init
|
|
523
|
+
Without MMU, fragmentation is permanent. Allocations fail after days despite sufficient total free memory. **Fix:** Pre-allocate everything. `configSUPPORT_DYNAMIC_ALLOCATION = 0`.
|
|
524
|
+
|
|
525
|
+
### 5. Busy-wait polling
|
|
526
|
+
`while (!ready) {}` wastes 100% CPU, drains battery, starves lower-priority tasks. **Fix:** Interrupt-driven I/O with semaphores or event groups.
|
|
527
|
+
|
|
528
|
+
### 6. Printf debugging in production
|
|
529
|
+
UART printf takes milliseconds -- disrupts real-time behavior, masks or creates timing bugs. **Fix:** Buffered non-blocking logger with compile-time level filtering. Strip in release.
|
|
530
|
+
|
|
531
|
+
### 7. Hardcoded delays instead of events
|
|
532
|
+
`HAL_Delay(100)` assumes fixed timing. Temperature and voltage shift actual peripheral timing. **Fix:** Poll ready flag or use interrupt. If delay needed, use datasheet max + margin.
|
|
533
|
+
|
|
534
|
+
### 8. Unchecked error return values
|
|
535
|
+
`HAL_SPI_Transmit()` returns `HAL_OK/ERROR/BUSY/TIMEOUT`. Ignoring it means corrupted data flows silently. **Fix:** Check every HAL return. Log and handle each case.
|
|
536
|
+
|
|
537
|
+
### 9. Missing volatile on ISR-shared globals
|
|
538
|
+
Compiler caches variable in register; task never sees ISR update. Invisible in debug builds. **Fix:** `volatile` on all ISR-shared variables. Critical sections for multi-word access.
|
|
539
|
+
|
|
540
|
+
### 10. Recursive functions
|
|
541
|
+
Embedded stacks are 512B-8KB. Recursion overflows silently, corrupting adjacent memory. **Fix:** Iterative algorithms with bounded explicit stacks.
|
|
542
|
+
|
|
543
|
+
### 11. Clock configuration failure ignored
|
|
544
|
+
External crystal failure falls back to internal RC. UART baud drifts, protocols fail silently. **Fix:** Check `HAL_RCC_OscConfig()` return. Implement fallback or assert-and-reset.
|
|
545
|
+
|
|
546
|
+
### 12. Testing only under debugger
|
|
547
|
+
JTAG halts CPU on breakpoints, stopping interrupts and watchdogs. Timing bugs never reproduce. **Fix:** Test in release mode, disconnected. Use logic analyzers for observation.
|
|
548
|
+
|
|
549
|
+
---
|
|
550
|
+
|
|
551
|
+
## 12. Decision Trees
|
|
552
|
+
|
|
553
|
+
### Which RTOS?
|
|
554
|
+
|
|
555
|
+
```
|
|
556
|
+
Need an RTOS?
|
|
557
|
+
+-- Certification required (IEC 61508, DO-178C)?
|
|
558
|
+
| --> SafeRTOS or ThreadX (pre-certified)
|
|
559
|
+
+-- Nordic nRF or broad HW support?
|
|
560
|
+
| --> Zephyr (600+ boards, built-in BLE/networking)
|
|
561
|
+
+-- Simple, minimal, well-understood?
|
|
562
|
+
| --> FreeRTOS (largest community, AWS backing)
|
|
563
|
+
+-- Single control loop sufficient?
|
|
564
|
+
--> No RTOS -- super loop with timer interrupts
|
|
565
|
+
```
|
|
566
|
+
|
|
567
|
+
### Which protocol?
|
|
568
|
+
|
|
569
|
+
```
|
|
570
|
+
Communicating with another device?
|
|
571
|
+
+-- Same PCB?
|
|
572
|
+
| +-- High speed (>1 Mbps) --> SPI
|
|
573
|
+
| +-- Many devices, low pins --> I2C
|
|
574
|
+
| +-- Debug/logging --> UART
|
|
575
|
+
+-- Vehicle/machine ECUs? --> CAN bus
|
|
576
|
+
+-- Wireless short range?
|
|
577
|
+
| +-- Low power --> BLE
|
|
578
|
+
| +-- Mesh --> Zigbee/Thread
|
|
579
|
+
| +-- Throughput --> Wi-Fi
|
|
580
|
+
+-- Long range (>1km)? --> LoRa or LTE-M/NB-IoT
|
|
581
|
+
```
|
|
582
|
+
|
|
583
|
+
---
|
|
584
|
+
|
|
585
|
+
## 13. Project Structure
|
|
586
|
+
|
|
587
|
+
```
|
|
588
|
+
firmware-project/
|
|
589
|
+
CMakeLists.txt
|
|
590
|
+
cmake/
|
|
591
|
+
arm-none-eabi.cmake # Toolchain file
|
|
592
|
+
src/
|
|
593
|
+
main.c # System init, RTOS start
|
|
594
|
+
app/ # Business logic (portable)
|
|
595
|
+
sensor_task.c
|
|
596
|
+
comms_task.c
|
|
597
|
+
drivers/ # Hardware-specific drivers
|
|
598
|
+
spi_flash.c
|
|
599
|
+
sensor_bme280.c
|
|
600
|
+
hal/ # Abstraction layer (portability)
|
|
601
|
+
hal_gpio.h
|
|
602
|
+
hal_spi.h
|
|
603
|
+
include/
|
|
604
|
+
config/
|
|
605
|
+
FreeRTOSConfig.h
|
|
606
|
+
board_config.h # All pin assignments in one place
|
|
607
|
+
linker/
|
|
608
|
+
STM32F407.ld
|
|
609
|
+
startup/
|
|
610
|
+
startup_stm32f407.s
|
|
611
|
+
test/
|
|
612
|
+
test_sensor_calibration.c # Host-side unit tests
|
|
613
|
+
tools/
|
|
614
|
+
flash.sh # OpenOCD/J-Link flashing
|
|
615
|
+
```
|
|
616
|
+
|
|
617
|
+
**Key rules:**
|
|
618
|
+
- Separate `app/` (portable logic) from `drivers/` (hardware-specific).
|
|
619
|
+
- `hal/` layer allows swapping MCU families without rewriting app code.
|
|
620
|
+
- Tests compile and run on host -- no target hardware needed for unit tests.
|
|
621
|
+
- One `board_config.h` owns all pin assignments -- never scatter definitions.
|
|
622
|
+
|
|
623
|
+
---
|
|
624
|
+
|
|
625
|
+
*Researched: 2026-03-12 | Sources: [FreeRTOS Reference Manual](https://www.freertos.org/Documentation/RTOS_book.html), [MISRA C:2012 Guidelines](https://misra.org.uk/misra-c/), [CERT C Coding Standard](https://wiki.sei.cmu.edu/confluence/display/c), [Barr Group Embedded C Coding Standard](https://barrgroup.com/embedded-systems/books/embedded-c-coding-standard), [ESP-IDF Programming Guide](https://docs.espressif.com/projects/esp-idf/en/stable/), [Zephyr Project Documentation](https://docs.zephyrproject.org/latest/), [STM32 HAL Reference](https://www.st.com/resource/en/user_manual/um1725-description-of-stm32f4-hal-and-low-layer-drivers-stmicroelectronics.pdf), [ARM Cortex-M Programming Guide](https://developer.arm.com/documentation/dui0553/latest/), [IEC 61508 Functional Safety](https://www.iec.ch/functionalsafety), [ISO 26262 Road Vehicles Safety](https://www.iso.org/standard/68383.html), [Mirai Botnet Analysis (Cloudflare)](https://blog.cloudflare.com/inside-mirai-the-infamous-iot-botnet/), [Miller & Valasek Jeep Hack (2015)](https://illmatics.com/Remote%20Car%20Hacking.pdf), [Stuxnet Analysis (Symantec)](https://docs.broadcom.com/doc/security-response-w32-stuxnet-dossier-11-en)*
|