From 397c6df34a2215b1439eb92e4a1cff00a2acaba0 Mon Sep 17 00:00:00 2001 From: Piotr Dymacz Date: Sat, 10 Dec 2022 16:08:37 +0100 Subject: [PATCH] feeds: mcu: introduce 'mcu-firmware' package The new 'mcu-firmware' package will provide binary firmware dedicated for MCU embedded on Wi-Fi boards (and also standalone, e.g. USB based), supported by the OpenWrt/OpenWiFi projects. Currently, only Zephyr RTOS based sample firmware ('BLE HCI controller' and 'hello world') files are provided, for Wi-Fi boards and one standalone development module, listed below: - CIG WF-196 (Nordic nRF52833, UART bus) - EdgeCore EAP102 (Nordic nRF52840, USB bus) - Nordic nRF52840 Dongle (Nordic nRF52840, USB bus) Different firmware types planned in future include Nordic's nRF Connect SDK, OpenThread and others. The Zephyr based firmware comes from a custom fork available in GitLab: 'https://gitlab.com/pepe2k/zephyr' (firmware in this package were built from a v3.3.0 release based branch 'zephyr-v3.3.x__mcu-on-wifi-boards'). MCU firmware from this package is compatible only with OpenWrt/OpenWiFi generic MCU support stack which, among others, assumes availability of compatible bootloader (MCUboot is currently the only one supported) and e.g. multiple firmware slots. MCUboot fork development takes part in git repository hosted in GitLab: 'https://gitlab.com/pepe2k/mcuboot/'. Signed-off-by: Piotr Dymacz --- feeds/mcu/mcu-firmware/Makefile | 123 ++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 feeds/mcu/mcu-firmware/Makefile diff --git a/feeds/mcu/mcu-firmware/Makefile b/feeds/mcu/mcu-firmware/Makefile new file mode 100644 index 000000000..480448305 --- /dev/null +++ b/feeds/mcu/mcu-firmware/Makefile @@ -0,0 +1,123 @@ +# +# Copyright (C) 2023 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=mcu-firmware +PKG_VERSION:=2023-03-05 +PKG_RELEASE:=1 + +PKG_MAINTAINER:=Piotr Dymacz + +include $(INCLUDE_DIR)/package.mk + +define Package/mcu-fw-default + CATEGORY:=Firmware + SUBMENU:=MCU firmware + SECTION:=firmware + TITLE:=MCU firmware +endef + + +# Zephyr versions +# 4 fields separated with underscore: +# version-name_git-sha_pipeline-id_sha256-of-package +ZEPHYR_VERSIONS := \ + zephyr-v3.3.x_7055d10e538e_3877473859_321a0daf6328698a913c6504d19aa85a5170dfce6039b86d31d2e9162d34af7c + +ZEPHYR_FW_CI_URL := https://gitlab.com/pepe2k/zephyr/-/jobs/ + +# Zephyr 'hello_world' targets +ZEPHYR_HELLO_WORLD_TARGETS := \ + cig_wf196_nrf52833 \ + edgecore_eap102_nrf52840 \ + nrf52840dongle_nrf52840 + +# Zephyr 'hci_uart' targets +ZEPHYR_HCI_UART_TARGETS:= \ + cig_wf196_nrf52833 \ + edgecore_eap102_nrf52840 \ + nrf52840dongle_nrf52840 + +# Zephyr 'hci_usb' targets +ZEPHYR_HCI_USB_TARGETS := \ + edgecore_eap102_nrf52840 \ + nrf52840dongle_nrf52840 + +word-underscore = $(word $2,$(subst _, ,$1)) + +define Download/zephyr-fw + URL:=$(ZEPHYR_FW_CI_URL)$(call word-underscore,$(2),3)/ + URL_FILE:=artifacts/download?file_type=archive + FILE:=$(call word-underscore,$(2),1)-$(call word-underscore,$(2),2).zip + HASH:=$(call word-underscore,$(2),4) +endef +$(foreach FW,$(ZEPHYR_VERSIONS),$(eval $(call Download,zephyr-fw,$(FW)))) + +# $(1) version (e.g zephyr-v3.3.x) +# $(2) firmware name (e.g. hci_usb) +# $(3) target/board name (e.g. nrf52840dongle_nrf52840) +define zephyr-fw + define Package/$(1)-$(2)-$(3) + $(call Package/mcu-fw-default) + DEPENDS:=+mcu + TITLE:=Zephyr '$(2)' + endef + + define Package/$(1)-$(2)-$(3)/description + Zephyr '$(1)' based firmware '$(2)' for '$(3)' board + endef + + define Package/$(1)-$(2)-$(3)/install + $(INSTALL_DIR) $$(1)/lib/firmware/mcu/$(3)/$(1)__$(2) + $(INSTALL_DATA) $(PKG_BUILD_DIR)/$(1)/$(3)/$(1)__$(2)/*.bin \ + $$(1)/lib/firmware/mcu/$(3)/$(1)__$(2)/ + endef +endef + +define zephyr-fw-unzip + mkdir -p $(PKG_BUILD_DIR)/$(call word-underscore,$(1),1); \ + unzip -q -d $(PKG_BUILD_DIR)/$(call word-underscore,$(1),1) \ + $(DL_DIR)/$(call word-underscore,$(1),1)-$(call word-underscore,$(1),2).zip; \ + for fw in $(PKG_BUILD_DIR)/$(call word-underscore,$(1),1)/*.tar.gz; do \ + $(TAR) -C $(PKG_BUILD_DIR)/$(call word-underscore,$(1),1) --one-top-level -xzf $$$$fw; \ + rm -rf $$$$fw; \ + done; +endef + +define Build/Prepare + $(foreach FW,$(ZEPHYR_VERSIONS),$(call zephyr-fw-unzip,$(FW))) +endef + +define Build/Compile +endef + + +$(foreach VER,$(ZEPHYR_VERSIONS),\ + $(foreach TARGET,$(ZEPHYR_HELLO_WORLD_TARGETS),\ + $(eval $(call zephyr-fw,$(call word-underscore,$(VER),1),hello_world,$(TARGET))))) + +$(foreach VER,$(ZEPHYR_VERSIONS),\ + $(foreach TARGET,$(ZEPHYR_HCI_UART_TARGETS),\ + $(eval $(call zephyr-fw,$(call word-underscore,$(VER),1),hci_uart,$(TARGET))))) + +$(foreach VER,$(ZEPHYR_VERSIONS),\ + $(foreach TARGET,$(ZEPHYR_HCI_USB_TARGETS),\ + $(eval $(call zephyr-fw,$(call word-underscore,$(VER),1),hci_usb,$(TARGET))))) + + +$(foreach VER,$(ZEPHYR_VERSIONS),\ + $(foreach TARGET,$(ZEPHYR_HELLO_WORLD_TARGETS),\ + $(eval $(call BuildPackage,$(call word-underscore,$(VER),1)-hello_world-$(TARGET))))) + +$(foreach VER,$(ZEPHYR_VERSIONS),\ + $(foreach TARGET,$(ZEPHYR_HCI_UART_TARGETS),\ + $(eval $(call BuildPackage,$(call word-underscore,$(VER),1)-hci_uart-$(TARGET))))) + +$(foreach VER,$(ZEPHYR_VERSIONS),\ + $(foreach TARGET,$(ZEPHYR_HCI_USB_TARGETS),\ + $(eval $(call BuildPackage,$(call word-underscore,$(VER),1)-hci_usb-$(TARGET)))))