diff mbox series

[v4,1/3] package/milkv-duo-libraries: new package

Message ID tencent_8285BE4A2D0B360BFED14B9C383000EA8C09@qq.com
State New
Headers show
Series [v4,1/3] package/milkv-duo-libraries: new package | expand

Commit Message

Hanyuan Zhao Feb. 7, 2024, 7:49 a.m. UTC
This commit adds the libraries for RISC-V dev board
milk-v duo, containing board-specific firmware and
hardware tools.

https://github.com/milkv-duo/milkv-duo-buildroot-libraries

Co-authored-by: Emil S <emil.soltys@outlook.com>
Signed-off-by: Hanyuan Zhao <hanyuan-z@qq.com>

---
Changes v3 -> v4:
  - Update the info in help section
  - Provide more info about ION (camera memory use)

Changes v2 -> v3:
  - Update the desc's repo url

Changes v1 -> v2:
  - Lint the code
  - Refactor the select and depend logic
---
 package/Config.in                             |  1 +
 package/milkv-duo-libraries/Config.in         | 63 +++++++++++++++++++
 .../milkv-duo-libraries.mk                    | 51 +++++++++++++++
 3 files changed, 115 insertions(+)
 create mode 100644 package/milkv-duo-libraries/Config.in
 create mode 100644 package/milkv-duo-libraries/milkv-duo-libraries.mk

Comments

Giulio Benetti Feb. 7, 2024, 11:31 a.m. UTC | #1
Hi Hanyuan,

On 07/02/24 08:49, Hanyuan Zhao wrote:
> This commit adds the libraries for RISC-V dev board
> milk-v duo, containing board-specific firmware and
> hardware tools.
> 
> https://github.com/milkv-duo/milkv-duo-buildroot-libraries
> 
> Co-authored-by: Emil S <emil.soltys@outlook.com>
> Signed-off-by: Hanyuan Zhao <hanyuan-z@qq.com>

It looks good to me:
Reviewed-by: Giulio Benetti <giulio.benetti@benettiengineering.com>

Best regards
diff mbox series

Patch

diff --git a/package/Config.in b/package/Config.in
index 047877c960..322aba90b8 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -564,6 +564,7 @@  endmenu
 	source "package/memtester/Config.in"
 	source "package/memtool/Config.in"
 	source "package/mhz/Config.in"
+	source "package/milkv-duo-libraries/Config.in"
 	source "package/minicom/Config.in"
 	source "package/msr-tools/Config.in"
 	source "package/nanocom/Config.in"
diff --git a/package/milkv-duo-libraries/Config.in b/package/milkv-duo-libraries/Config.in
new file mode 100644
index 0000000000..047b78fb7b
--- /dev/null
+++ b/package/milkv-duo-libraries/Config.in
@@ -0,0 +1,63 @@ 
+config BR2_PACKAGE_MILKV_DUO_LIBRARIES
+	bool "milk-v duo libraries"
+	depends on BR2_riscv
+	help
+	  Package providing board-specific firmware and hardware tools
+	  for Milk-V Duo platform.
+
+	  https://github.com/milkv-duo/milkv-duo-buildroot-libraries
+
+if BR2_PACKAGE_MILKV_DUO_LIBRARIES
+
+config BR2_PACKAGE_MILKV_DUO_FIRMWARE_FSBL
+	bool "milkv-duo-firmware-fsbl"
+	select BR2_PACKAGE_HOST_MTOOLS
+	help
+	  This package is obtained from
+	  https://github.com/milkv-duo/duo-buildroot-sdk,
+	  from which we download the first stage bootloader source and
+	  compile it, generating the ATF bl2.bin. At the mean time, we
+	  will use the fiptool.py in this package to create the binary
+	  file fip.bin to pack the opensbi, u-boot and so on.
+
+	  If you intend to generate the whole sdcard image or the
+	  fip.bin for milk-v duo, you must say Y to this package!
+
+config BR2_PACKAGE_MILKV_DUO_FIRMWARE_FSBL_64MB
+	bool "64 MiB free ram"
+	default n
+	depends on BR2_PACKAGE_MILKV_DUO_FIRMWARE_FSBL
+	help
+	  Say Y to this will disable the ION (Camera Algorithm Memory)
+	  in order to have the all 64MiB Free memory.
+
+config BR2_PACKAGE_MILKV_DUO_PINMUX
+	bool "duo-pinmux tool"
+	default n
+	help
+	  Say Y to this will compile the duo-pinmux, which can
+	  get or set function of any Milk-V Duo GPIO Pin. More info at
+
+	  https://milkv.io/docs/duo/application-development/pinmux
+
+config BR2_PACKAGE_MILKV_DUO_FEATURES
+	bool "duo usb features"
+	default n
+	select BR2_PACKAGE_DHCPCD
+	select BR2_PACKAGE_DNSMASQ
+	select BR2_PACKAGE_DROPBEAR
+	select BR2_PACKAGE_LRZSZ
+	select BR2_PACKAGE_HTOP
+	help
+	  Say Y to this will copy the cvitek usb shell scripts to have
+	  the USB features. The role could be configured at
+
+	  /etc/milkv-duo.conf
+
+	  Supported usb functions are rndis, host and mass-storage.
+	  By default Duo has the LED blinking. It could be configured
+	  in that conf file as well. Say Y to this will also select
+	  some packages automatically, to have the same experience
+	  with the official release.
+
+endif
diff --git a/package/milkv-duo-libraries/milkv-duo-libraries.mk b/package/milkv-duo-libraries/milkv-duo-libraries.mk
new file mode 100644
index 0000000000..a5cf40a764
--- /dev/null
+++ b/package/milkv-duo-libraries/milkv-duo-libraries.mk
@@ -0,0 +1,51 @@ 
+################################################################################
+#
+# milkv-duo-libraries
+#
+################################################################################
+
+MILKV_DUO_LIBRARIES_VERSION = f359994bd497f942bb67734280d81f6640c7c168
+MILKV_DUO_LIBRARIES_SITE = $(call github,milkv-duo,milkv-duo-buildroot-libraries,$(MILKV_DUO_LIBRARIES_VERSION))
+MILKV_DUO_LIBRARIES_INSTALL_STAGING = YES
+MILKV_DUO_LIBRARIES_DEPENDENCIES = host-python3 host-mtools
+MILKV_DUO_LIBRARIES_FSBL_64MB = ION
+
+ifeq ($(BR2_PACKAGE_MILKV_DUO_FIRMWARE_FSBL_64MB),y)
+MILKV_DUO_LIBRARIES_FSBL_64MB = 64MB
+endif
+
+define MILKV_DUO_LIBRARIES_BUILD_CMDS
+	if [ $(BR2_PACKAGE_MILKV_DUO_FIRMWARE_FSBL) = y ]; then \
+		$(MAKE) -C $(@D)/firmware \
+		ARCH=riscv BOOT_CPU=riscv CHIP_ARCH=cv180x \
+		PROJECT_FULLNAME=cv1800b_milkv_duo_sd \
+		CROSS_COMPILE=$(TARGET_CROSS) \
+		FREE_RAM_SIZE=$(MILKV_DUO_LIBRARIES_FSBL_64MB) \
+		bl2; \
+	fi
+
+	if [ $(BR2_PACKAGE_MILKV_DUO_PINMUX) = y ]; then \
+		$(TARGET_MAKE_ENV) $(TARGET_CC) $(TARGET_CFLAGS) $(TARGET_LDFLAGS) \
+		-I $(@D)/pinmux/include $(@D)/pinmux/src/*.c -o $(@D)/pinmux/duo-pinmux; \
+	fi
+endef
+
+define MILKV_DUO_LIBRARIES_INSTALL_STAGING_CMDS
+	if [ $(BR2_PACKAGE_MILKV_DUO_FIRMWARE_FSBL) = y ]; then \
+		$(INSTALL) -D -m 0755 $(@D)/firmware/build/cv180x/bl2.bin $(BINARIES_DIR)/bl2.bin; \
+		$(INSTALL) -D -m 0755 $(@D)/firmware/plat/cv180x/chip_conf.bin $(BINARIES_DIR)/chip_conf.bin; \
+		$(INSTALL) -D -m 0755 $(@D)/firmware/plat/cv180x/fiptool.py $(BINARIES_DIR)/fiptool.py; \
+		$(INSTALL) -D -m 0644 $(@D)/firmware/plat/cv180x/multi.its $(BINARIES_DIR)/multi.its; \
+		$(INSTALL) -D -m 0755 $(@D)/firmware/test/cv181x/ddr_param.bin $(BINARIES_DIR)/ddr_param.bin; \
+	fi
+
+	if [ $(BR2_PACKAGE_MILKV_DUO_PINMUX) = y ]; then \
+		$(INSTALL) -D -m 0755 $(@D)/pinmux/duo-pinmux $(TARGET_DIR)/usr/bin/; \
+	fi
+
+	if [ $(BR2_PACKAGE_MILKV_DUO_FEATURES) = y ]; then \
+		cp $(@D)/overlay/* -r $(TARGET_DIR); \
+	fi
+endef
+
+$(eval $(generic-package))