[OpenWrt-Devel] [PATCH 4/7] uboot-tegra: add U-Boot for tegra boards

Tomasz Maciej Nowak tomek_n at o2.pl
Mon Mar 4 13:53:23 EST 2019


Add U-Boot for NVIDIA Tegra based boards, with the first being CompuLab
TrimSlice. This is part of initial support for this board.

Signed-off-by: Tomasz Maciej Nowak <tomek_n at o2.pl>
---
 package/boot/uboot-tegra/Makefile             | 59 +++++++++++++++++++
 .../tegra/base-files/lib/upgrade/platform.sh  |  2 +
 target/linux/tegra/image/Makefile             |  4 +-
 3 files changed, 64 insertions(+), 1 deletion(-)
 create mode 100644 package/boot/uboot-tegra/Makefile

diff --git a/package/boot/uboot-tegra/Makefile b/package/boot/uboot-tegra/Makefile
new file mode 100644
index 0000000000..60d1b02a60
--- /dev/null
+++ b/package/boot/uboot-tegra/Makefile
@@ -0,0 +1,59 @@
+#
+# Copyright (C) 2017-2019 Tomasz Maciej Nowak <tomek_n at o2.pl>
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+include $(TOPDIR)/rules.mk
+
+PKG_VERSION := 2019.01
+PKG_RELEASE := 1
+
+PKG_HASH := 50bd7e5a466ab828914d080d5f6a432345b500e8fba1ad3b7b61e95e60d51c22
+
+PKG_MAINTAINER := Tomasz Maciej Nowak <tomek_n at o2.pl>
+
+include $(INCLUDE_DIR)/u-boot.mk
+include $(INCLUDE_DIR)/package.mk
+
+define U-Boot/Default
+  BUILD_TARGET := tegra
+  HIDDEN := y
+endef
+
+define U-Boot/trimslice
+  NAME := CompuLab TrimSlice
+  BUILD_DEVICES := trimslice
+  UBOOT_IMAGE := trimslice-mmc.img trimslice-spi.img
+  SOC := tegra20
+  VENDOR := compulab
+endef
+
+UBOOT_TARGETS := trimslice
+
+define Build/bct-image
+	$(CP) $(PKG_BUILD_DIR)/u-boot-dtb-tegra.bin $(PKG_BUILD_DIR)/u-boot.bin
+	$(foreach bct,$(basename $(UBOOT_IMAGE)), \
+		cd $(PKG_BUILD_DIR); \
+		cbootimage -s $(SOC) -gbct \
+			$(STAGING_DIR_HOST)/share/cbootimage-configs/$(SOC)/$(VENDOR)/$(VARIANT)/$(bct).bct.cfg \
+			$(bct).bct; \
+		cbootimage -s $(SOC) \
+			$(STAGING_DIR_HOST)/share/cbootimage-configs/$(SOC)/$(VENDOR)/$(VARIANT)/$(bct).img.cfg \
+			$(PKG_BUILD_DIR)/$(bct).img; \
+		rm -f $(bct).bct; \
+	)
+endef
+
+define Build/Compile
+	$(call Build/Compile/U-Boot)
+	$(call Build/bct-image)
+endef
+
+define Build/InstallDev
+	$(INSTALL_DIR) $(STAGING_DIR_IMAGE)
+	$(foreach img,$(UBOOT_IMAGE), \
+		$(CP) $(PKG_BUILD_DIR)/$(img) $(STAGING_DIR_IMAGE)/;)
+endef
+
+$(eval $(call BuildPackage/U-Boot))
diff --git a/target/linux/tegra/base-files/lib/upgrade/platform.sh b/target/linux/tegra/base-files/lib/upgrade/platform.sh
index be453bdf9f..97dd381041 100644
--- a/target/linux/tegra/base-files/lib/upgrade/platform.sh
+++ b/target/linux/tegra/base-files/lib/upgrade/platform.sh
@@ -87,6 +87,8 @@ platform_do_upgrade() {
 		return 0
 	fi
 
+	#write uboot image
+	get_image "$@" | dd of="$diskdev" bs=512 skip=1 seek=1 count=4097 conv=fsync,notrunc
 	#iterate over each partition from the image and write it to the boot disk
 	while read part start size; do
 		if export_partdevice partdev $part; then
diff --git a/target/linux/tegra/image/Makefile b/target/linux/tegra/image/Makefile
index 757e5b823f..5e3427ad27 100644
--- a/target/linux/tegra/image/Makefile
+++ b/target/linux/tegra/image/Makefile
@@ -32,9 +32,11 @@ define Build/tegra-sdcard
 		$(CONFIG_TARGET_KERNEL_PARTSIZE) $@.boot \
 		$(CONFIG_TARGET_ROOTFS_PARTSIZE) $(IMAGE_ROOTFS) \
 		2048
+
+	$(if $(UBOOT),dd if=$(STAGING_DIR_IMAGE)/$(UBOOT).img of=$@ bs=512 skip=1 seek=1 conv=notrunc)
 endef
 
-DEVICE_VARS += BOOT_SCRIPT
+DEVICE_VARS += BOOT_SCRIPT UBOOT
 define Device/Default
   BOOT_SCRIPT := generic-bootscript
   IMAGES := sdcard.img.gz
-- 
2.21.0


_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list