Skip to contentSkip to conversation

genimage.sh: fix calling from BR2_ROOTFS_POST_IMAGE_SCRIPT

PATCH Superseded Abhimanyu Vishwakarma 3 participants 5 messages Apr 21, 2017 – Apr 23, 2017

v9 of 10 Superseded Latest is v10 →

lore
Share & tools
lore
#0 lore raw

PATCH v9 1/2 genimage.sh: fix calling from BR2_ROOTFS_POST_IMAGE_SCRIPT

From: Abhimanyu Vishwakarma <[email protected]>

When called from BR2_ROOTFS_POST_IMAGE_SCRIPT, this script ends up with following error:

Error: Missing argument

This is because, extra positional argument is also passed along with BR2_ROOTFS_POST_SCRIPT_ARGS. genimage.sh didnt had support to parse positional and optional argument together.

---
Changes v7->v8
- New file
Changes v8->v9
- Fix indentation
- Use bash basename as script name instead hardcoding

 support/scripts/genimage.sh | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)
support/scripts/genimage.sh +16 -7
index 0ed0e8bcc..a2309e224 100755
@@ -1,17 +1,26 @@
 #!/bin/bash
 
 die() {
-  echo "Error: $@" >&2
-  exit 1
+	echo "Error: $@" >&2
+	exit 1
 }
 
+# Parse arguments and put into argument list of the script
+opts="$(getopt -n "${0##*/}" -o c: -- "$@")" || exit $?
+eval set -- "$opts"
+
 GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp"
 
-while getopts c: OPT ; do
-	case "${OPT}" in
-	c) GENIMAGE_CFG="${OPTARG}";;
-	:) die "option '${OPTARG}' expects a mandatory argument\n";;
-	\?) die "unknown option '${OPTARG}'\n";;
+while true ; do
+	case "$1" in
+		-c)
+			GENIMAGE_CFG="${2}";
+			shift 2 ;;
+		--) # Discard all non-option parameters
+			shift 1;
+			break ;;
+		*)
+			die "unknown option '${1}'" ;;
 	esac
 done
 
Signature · 1 line
2.11.0
#1 lore raw

PATCH v9 2/2 Add defconfig for MIPS Creator ci40

From: Abhimanyu Vishwakarma <[email protected]>

---
Changes v1->v2
- No change
Changes v2->v3 (Suggested by Arnout)
- Remove uImage and add fitImage generation
- Tidy readme.txt
- Tidy ci40_defconfig, remove custom toolchain and add wifi helper packages Some changes are not done:
- Using git-helper:
- Custom kernel doesnt provide tar file, so it didnt work for me
Changes v3->v4 (Suggested by Arnout)
- Use github helper for getting kernel/u-boot
- rename fitImage.its -> fitImage.its.in to reflect as template file, remove hardcoded dtb filename
- Find dtb file in output/images directory and use first dtb in fitImage
- Remove image size from genimage.cfg
- Tidy readme.txt and add section to explain how to stop u-boot autoboot, how to make it persistent, and other grammar
Changes v4->v5 (Suggested by Thomas)
- Use fixed kernel entry addr
- Generate vmlinux.bin.gz from generate vmlinux.bin
- Remove generating uImage (not required for anything now)
Changes v5->v6
- Use kernel generate fitimage
- bump up u-boot version
- Change emailid from imgtec.com -> personal id
Changes v6->v7 (Suggested by Thomas)
- Use genimage.sh script
- Improve and fix grammer in readme.txt
Changes v7->v8 (Suggested by Arnout)
- Use genimage.sh script from POST_IMAGE_SCRIPT
- Use uboot kconfig base config
- Remove dts config from defconfig
- Some other small cleanup
- rebase on master
Changes v8->v9 (Suggested by Arnout)
- Use sh instead of bash where bash feature is not needed
- Use sudo for command run on user PC
- Update bootloader flashing help text in readme.txt

 board/ci40/genimage.cfg  | 12 +++++++++
 board/ci40/post-build.sh |  4 +++
 board/ci40/readme.txt    | 65 ++++++++++++++++++++++++++++++++++++++++++++++++
 configs/ci40_defconfig   | 48 +++++++++++++++++++++++++++++++++++
 4 files changed, 129 insertions(+)
 create mode 100644 board/ci40/genimage.cfg
 create mode 100755 board/ci40/post-build.sh
 create mode 100644 board/ci40/readme.txt
 create mode 100644 configs/ci40_defconfig
board/ci40/genimage.cfg new file +12 -0
new file mode 100644
index 000000000..0ffc91ce8
@@ -0,0 +1,12 @@
+# Minimal SD card image
+#
+
+image sdcard.img {
+  hdimage {
+  }
+
+  partition rootfs {
+    partition-type = 0x83
+    image = "rootfs.ext4"
+  }
+}
board/ci40/post-build.sh new file +4 -0
new file mode 100755
index 000000000..9af74c7a7
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+# Copy to target
+cp ${BINARIES_DIR}/vmlinux.gz.itb ${TARGET_DIR}/fitImage
board/ci40/readme.txt new file +65 -0

65 lines not on this page · raw message

configs/ci40_defconfig new file +48 -0

48 lines not on this page · raw message

Signature · 1 line
2.11.0
#2 lore raw

PATCH v9 2/2 Add defconfig for MIPS Creator ci40

Hello,

Quoted 45 lines · Abhimanyu Vishwakarma

From: Abhimanyu Vishwakarma <[email protected]>

---
Changes v1->v2
- No change
Changes v2->v3 (Suggested by Arnout)
- Remove uImage and add fitImage generation
- Tidy readme.txt
- Tidy ci40_defconfig, remove custom toolchain and add wifi helper packages Some changes are not done:
- Using git-helper:
- Custom kernel doesnt provide tar file, so it didnt work for me
Changes v3->v4 (Suggested by Arnout)
- Use github helper for getting kernel/u-boot
- rename fitImage.its -> fitImage.its.in to reflect as template file, remove hardcoded dtb filename
- Find dtb file in output/images directory and use first dtb in fitImage
- Remove image size from genimage.cfg
- Tidy readme.txt and add section to explain how to stop u-boot autoboot, how to make it persistent, and other grammar
Changes v4->v5 (Suggested by Thomas)
- Use fixed kernel entry addr
- Generate vmlinux.bin.gz from generate vmlinux.bin
- Remove generating uImage (not required for anything now)
Changes v5->v6
- Use kernel generate fitimage
- bump up u-boot version
- Change emailid from imgtec.com -> personal id
Changes v6->v7 (Suggested by Thomas)
- Use genimage.sh script
- Improve and fix grammer in readme.txt
Changes v7->v8 (Suggested by Arnout)
- Use genimage.sh script from POST_IMAGE_SCRIPT
- Use uboot kconfig base config
- Remove dts config from defconfig
- Some other small cleanup
- rebase on master
Changes v8->v9 (Suggested by Arnout)
- Use sh instead of bash where bash feature is not needed
- Use sudo for command run on user PC
- Update bootloader flashing help text in readme.txt

Quoted 9 lines
 board/ci40/genimage.cfg  | 12 +++++++++
 board/ci40/post-build.sh |  4 +++
 board/ci40/readme.txt    | 65 ++++++++++++++++++++++++++++++++++++++++++++++++
 configs/ci40_defconfig   | 48 +++++++++++++++++++++++++++++++++++
 4 files changed, 129 insertions(+)
 create mode 100644 board/ci40/genimage.cfg
 create mode 100755 board/ci40/post-build.sh
 create mode 100644 board/ci40/readme.txt
 create mode 100644 configs/ci40_defconfig

Tried usbboot, Ci40 successfully booted using generated sdcard.img.

Thanks,
Rahul

#3 lore raw

PATCH v9 1/2 genimage.sh: fix calling from BR2_ROOTFS_POST_IMAGE_SCRIPT

In reply to Abhimanyu Vishwakarma

Hello,

Quoted 20 lines · Abhimanyu Vishwakarma

From: Abhimanyu Vishwakarma <[email protected]>

When called from BR2_ROOTFS_POST_IMAGE_SCRIPT, this script ends up with following error:

Error: Missing argument

This is because, extra positional argument is also passed along with BR2_ROOTFS_POST_SCRIPT_ARGS. genimage.sh didnt had support to parse positional and optional argument together.

---
Changes v7->v8
- New file
Changes v8->v9
- Fix indentation
- Use bash basename as script name instead hardcoding

Quoted 3 lines
 support/scripts/genimage.sh | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

genimage.sh generated sdcard.img with Ci40 defconfig without any errors.

Thanks,
Rahul

#4 lore raw

PATCH v9 1/2 genimage.sh: fix calling from BR2_ROOTFS_POST_IMAGE_SCRIPT

In reply to Abhimanyu Vishwakarma
Quoted 8 lines · Abhimanyu Vishwakarma

From: Abhimanyu Vishwakarma <[email protected]>

When called from BR2_ROOTFS_POST_IMAGE_SCRIPT, this script ends up with following error:

Error: Missing argument

This is because, extra positional argument is also passed

                   ^an
Quoted 1 line

along with BR2_ROOTFS_POST_SCRIPT_ARGS. genimage.sh didnt

                                                          ^'
Quoted 1 line

had support to parse positional and optional argument

^ve ^s

Quoted 18 lines

together.

---
Changes v7->v8
- New file
Changes v8->v9
- Fix indentation
- Use bash basename as script name instead hardcoding

 support/scripts/genimage.sh | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)
support/scripts/genimage.sh +0 -0
index 0ed0e8bcc..a2309e224 100755

support/scripts/genimage.sh line 5

Quoted 7 lines
support/scripts/genimage.sh +2 -2
@@ -1,17 +1,26 @@
 #!/bin/bash
 
 die() {
-  echo "Error: $@" >&2
-  exit 1
+	echo "Error: $@" >&2
+	exit 1

Avoid mixing whitespace fixes with other fixes in the same patch. I.e., split
this up in a separate patch (fixing indentation all over).

Quoted 6 lines
support/scripts/genimage.sh +4 -0
 }
 
+# Parse arguments and put into argument list of the script
+opts="$(getopt -n "${0##*/}" -o c: -- "$@")" || exit $?
+eval set -- "$opts"
+

support/scripts/genimage.sh line 16

Quoted 10 lines
support/scripts/genimage.sh +3 -5
 GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp"
 
-while getopts c: OPT ; do
-	case "${OPT}" in
-	c) GENIMAGE_CFG="${OPTARG}";;
-	:) die "option '${OPTARG}' expects a mandatory argument\n";;
-	\?) die "unknown option '${OPTARG}'\n";;
+while true ; do
+	case "$1" in
+		-c)

We sometimes do and sometimes don't indent inside a case statement in shell
scripts. Annoying inconsistency. However, this file _didn't_ indent, so stick to that coding style.

But all this is just minor things, so

(if you resubmit, make sure you copy the above Reviewed-by, except when you make changes not mentioned in my review).

Regards,
Arnout

Quoted 11 lines
support/scripts/genimage.sh +7 -0
+			GENIMAGE_CFG="${2}";
+			shift 2 ;;
+		--) # Discard all non-option parameters
+			shift 1;
+			break ;;
+		*)
+			die "unknown option '${1}'" ;;
 	esac
 done
 
Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF