[OpenWrt-Devel] [PATCH 1/4] omap: add sdcard creation script

Alexander Couzens lynxis at fe80.eu
Mon Apr 25 21:17:22 EDT 2016


Signed-off-by: Alexander Couzens <lynxis at fe80.eu>
---
 target/linux/omap/image/Config.in              |  5 ++++
 target/linux/omap/image/Makefile               | 34 +++++++++++++++++++++++++-
 target/linux/omap/image/gen_omap_sdcard_img.sh | 33 +++++++++++++++++++++++++
 target/linux/omap/image/uEnv.txt               |  6 +++++
 tools/Makefile                                 |  2 +-
 5 files changed, 78 insertions(+), 2 deletions(-)
 create mode 100644 target/linux/omap/image/Config.in
 create mode 100755 target/linux/omap/image/gen_omap_sdcard_img.sh
 create mode 100644 target/linux/omap/image/uEnv.txt

diff --git a/target/linux/omap/image/Config.in b/target/linux/omap/image/Config.in
new file mode 100644
index 0000000..08b88eb
--- /dev/null
+++ b/target/linux/omap/image/Config.in
@@ -0,0 +1,5 @@
+config OMAP_SD_BOOT_PARTSIZE
+	int "Boot (SD Card) filesystem partition size (in MB)"
+	depends on TARGET_omap
+	default 20
+
diff --git a/target/linux/omap/image/Makefile b/target/linux/omap/image/Makefile
index 3fa2848..10b07a7 100644
--- a/target/linux/omap/image/Makefile
+++ b/target/linux/omap/image/Makefile
@@ -6,12 +6,43 @@
 #
 include $(TOPDIR)/rules.mk
 include $(INCLUDE_DIR)/image.mk
+include $(INCLUDE_DIR)/host.mk
+
+FAT32_BLOCK_SIZE=1024
+FAT32_BLOCKS=$(shell echo $$(($(CONFIG_OMAP_SD_BOOT_PARTSIZE)*1024*1024/$(FAT32_BLOCK_SIZE))))
 
 UBIFS_OPTS = -F -m 2048 -e 124KiB -c 4096 -U
 UBI_OPTS = -m 2048 -p 128KiB -s 512 -O 2048
 
+# $1 - name of bootloader directory under BIN_DIR
+# $2 - output filename part
+define Image/Build/SDCard
+	rm -f $(KDIR)/boot-$(2).img
+	mkdosfs $(KDIR)/boot-$(2).img -C $(FAT32_BLOCKS)
+	mcopy -i $(KDIR)/boot-$(2).img $(BIN_DIR)/uboot-omap-$(1)/MLO ::MLO
+	mcopy -i $(KDIR)/boot-$(2).img $(BIN_DIR)/uboot-omap-$(1)/u-boot.img ::u-boot.img
+	mcopy -i $(KDIR)/boot-$(2).img -s $(BIN_DIR)/dtbs/ ::dtbs
+	mcopy -i $(KDIR)/boot-$(2).img $(KDIR)/zImage ::zImage
+	mcopy -i $(KDIR)/boot-$(2).img $(KDIR)/uImage ::uImage
+	mcopy -i $(KDIR)/boot-$(2).img ./uEnv.txt ::uEnv.txt
+	chmod 755 ./gen_omap_sdcard_img.sh
+	./gen_omap_sdcard_img.sh \
+		$(BIN_DIR)/$(IMG_PREFIX)-$(2)-sdcard-vfat-$(1).img \
+		$(KDIR)/boot-$(2).img \
+		$(KDIR)/root.ext4 \
+		$(CONFIG_OMAP_SD_BOOT_PARTSIZE) \
+		$(CONFIG_TARGET_ROOTFS_PARTSIZE)
+endef
+
 define Image/BuildKernel
+	mkimage -A arm -O linux -T kernel -C none \
+		-a 0x40008000 -e 0x40008000 \
+		-n 'ARM OpenWrt Linux-$(LINUX_VERSION)' \
+		-d $(KDIR)/zImage $(KDIR)/uImage
+
 	$(CP) $(KDIR)/zImage $(BIN_DIR)/$(IMG_PREFIX)-zImage
+	$(CP) $(KDIR)/uImage $(BIN_DIR)/$(IMG_PREFIX)-uImage
+
  ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
 	$(CP) $(KDIR)/zImage-initramfs $(BIN_DIR)/$(IMG_PREFIX)-zImage-initramfs
  endif
@@ -26,7 +57,7 @@ define Image/BuildKernel
 	$(CP) $(DTS_DIR)/omap3*.dtb $(TARGET_DIR)/boot/
 	$(CP) $(DTS_DIR)/omap4*.dtb $(TARGET_DIR)/boot/
  endif
-	-mkdir $(BIN_DIR)/dtbs
+	-mkdir -p $(BIN_DIR)/dtbs
 	-$(CP) $(DTS_DIR)/am335x*.dtb $(BIN_DIR)/dtbs/
 	-$(CP) $(DTS_DIR)/omap3*.dtb $(BIN_DIR)/dtbs/
 	-$(CP) $(DTS_DIR)/omap4*.dtb $(BIN_DIR)/dtbs/
@@ -34,6 +65,7 @@ endef
 
 define Image/Build
 	$(call Image/Build/$(1),$(1))
+	$(call Image/Build/SDCard,am335x_evm,beagleboneblack)
 endef
 
 define Image/Build/jffs2-64k
diff --git a/target/linux/omap/image/gen_omap_sdcard_img.sh b/target/linux/omap/image/gen_omap_sdcard_img.sh
new file mode 100755
index 0000000..c2f2aad
--- /dev/null
+++ b/target/linux/omap/image/gen_omap_sdcard_img.sh
@@ -0,0 +1,33 @@
+#!/usr/bin/env bash
+
+#
+# Copyright (C) 2013 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+set -x
+[ $# -eq 5 ] || {
+    echo "SYNTAX: $0 <file> <bootfs image> <rootfs image> <bootfs size> <rootfs size>"
+    exit 1
+}
+
+OUTPUT="$1"
+BOOTFS="$2"
+ROOTFS="$3"
+BOOTFSSIZE="$4"
+ROOTFSSIZE="$5"
+
+head=4
+sect=63
+
+set `ptgen -o $OUTPUT -h $head -s $sect -l 1024 -t c -p ${BOOTFSSIZE}M -t 83 -p ${ROOTFSSIZE}M`
+
+BOOTOFFSET="$(($1 / 512))"
+BOOTSIZE="$(($2 / 512))"
+ROOTFSOFFSET="$(($3 / 512))"
+ROOTFSSIZE="$(($4 / 512))"
+
+dd bs=512 if="$BOOTFS" of="$OUTPUT" seek="$BOOTOFFSET" conv=notrunc
+dd bs=512 if="$ROOTFS" of="$OUTPUT" seek="$ROOTFSOFFSET" conv=notrunc
diff --git a/target/linux/omap/image/uEnv.txt b/target/linux/omap/image/uEnv.txt
new file mode 100644
index 0000000..9776ab5
--- /dev/null
+++ b/target/linux/omap/image/uEnv.txt
@@ -0,0 +1,6 @@
+bootdir=/
+fdtdir=/dtbs
+uenvcmd=setenv bootpart ${mmcdev}:1 ; run loadfdt; run loadimage; run mmcargs;  bootz ${loadaddr} - ${fdtaddr}
+mmcargs=setenv bootargs console=${console} root=/dev/mmcblk0p2 rootdelay=10
+
+loadfdt=load mmc ${bootpart} ${fdtaddr} ${fdtdir}/${fdtfile}
diff --git a/tools/Makefile b/tools/Makefile
index 187655e..85a7124 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -36,7 +36,7 @@ tools-$(CONFIG_TARGET_orion_generic) += wrt350nv2-builder upslug2
 tools-$(CONFIG_powerpc) += upx
 tools-$(CONFIG_TARGET_x86) += qemu
 tools-$(CONFIG_TARGET_mxs) += elftosb sdimage
-tools-$(CONFIG_TARGET_brcm2708)$(CONFIG_TARGET_sunxi)$(CONFIG_TARGET_mxs) += mtools dosfstools
+tools-$(CONFIG_TARGET_brcm2708)$(CONFIG_TARGET_omap)$(CONFIG_TARGET_sunxi)$(CONFIG_TARGET_mxs) += mtools dosfstools
 tools-$(CONFIG_TARGET_ar71xx) += lzma-old squashfs
 tools-y += lzma squashfs4
 tools-$(BUILD_B43_TOOLS) += b43-tools
-- 
2.8.0
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list