summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Muellner <christoph.muellner@theobroma-systems.com>2019-09-26 18:23:46 +0200
committerChristoph Muellner <christoph.muellner@theobroma-systems.com>2019-09-27 13:48:26 +0200
commit6f532dc3ca0fc121af47907fa98026392815d8f9 (patch)
tree729ffc1b81b909fa4e62302ff91d78d97416cb93
parent71f5e4bde0cce645b61c85418f056c805149a124 (diff)
board: theobroma-systems: Streamline board files.
This patch streamlines the board files for theobroma-systems: * Rewrite boot.cmd in a more generic fashion * Move common code to generic/ * Add symlinks/calls to scripts in generic/ Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
-rw-r--r--board/theobroma-systems/generic/boot.cmd58
-rw-r--r--board/theobroma-systems/generic/genimage.cfg22
-rwxr-xr-xboard/theobroma-systems/generic/post-build.sh18
-rw-r--r--board/theobroma-systems/puma/boardEnv.txt6
l---------[-rw-r--r--]board/theobroma-systems/puma/boot.cmd69
-rw-r--r--board/theobroma-systems/puma/defaultEnv.txt6
l---------[-rw-r--r--]board/theobroma-systems/puma/genimage.cfg23
-rwxr-xr-xboard/theobroma-systems/puma/post-build.sh10
-rw-r--r--board/theobroma-systems/puma/userEnv.txt0
-rw-r--r--board/theobroma-systems/px30evb/boardEnv.txt5
l---------[-rw-r--r--]board/theobroma-systems/px30evb/boot.cmd55
-rw-r--r--board/theobroma-systems/px30evb/defaultEnv.txt6
l---------[-rw-r--r--]board/theobroma-systems/px30evb/genimage.cfg23
-rwxr-xr-xboard/theobroma-systems/px30evb/post-build.sh11
-rw-r--r--board/theobroma-systems/px30evb/userEnv.txt0
15 files changed, 127 insertions, 185 deletions
diff --git a/board/theobroma-systems/generic/boot.cmd b/board/theobroma-systems/generic/boot.cmd
new file mode 100644
index 0000000000..80dd7efa7a
--- /dev/null
+++ b/board/theobroma-systems/generic/boot.cmd
@@ -0,0 +1,58 @@
+echo "Boot script running from ${devtype} ${devnum}"
+echo "Starting boot script for board: ${board_name}"
+
+# This script assumes, that the following variables are set
+# in a (mandatory) file "boardEnv.txt" in the directory
+# /boot/ or /boot/${board_name}:
+# kernelfile...(mandatory) filename of the kernel image
+# fdtfile...(mandatory) filename of the device tree blob
+# initrdfile...(optional) filename of the ramdisk
+# extraargs...(optional) kernel commandline arguments
+# rootdev_mmc<N>...(mandatory) mapping from U-Boot's mmc devnum to kernel device
+#
+# Example:
+# kernelfile=Image
+# fdtfile=puma-linux.dtb
+# initrdfile=uInitrd
+# extraargs=loglevel=7
+# rootdev_mmc0=/dev/mmcblk2p1
+
+# Get load path (board-specific path is preferred)
+if test -e ${devtype} ${devnum} /boot/${board_name}/boardEnv.txt; then
+ setenv load_path "/boot/${board_name}"
+else
+ setenv load_path "/boot"
+fi
+
+# Load (and overwrite) board-specific variables
+load ${devtype} ${devnum} ${fdt_addr_r} ${load_path}/boardEnv.txt
+env import -t ${fdt_addr_r} ${filesize}
+
+# Map the U-Boot mmc devnum numbers to kernel root device nodes
+if test ${devtype} = "mmc" && test ${devnum} -eq 0; then
+ rootdevice=${rootdev_mmc0}
+elif test ${devtype} = "mmc" && test ${devnum} -eq 1; then
+ rootdevice=${rootdev_mmc1}
+elif test ${devtype} = "mmc" && test ${devnum} -eq 2; then
+ rootdevice=${rootdev_mmc2}
+elif test ${devtype} = "mmc" && test ${devnum} -eq 3; then
+ rootdevice=${rootdev_mmc3}
+fi
+
+setenv bootargs "root=${rootdevice} rw rootwait consoleblank=0 ${extraargs} ${kernelargs}"
+
+echo "Load devicetree from ${load_path}/${fdtfile}"
+load ${devtype} ${devnum} ${fdt_addr_r} ${load_path}/${fdtfile}
+fdt addr ${fdt_addr_r}
+fdt resize
+
+echo "Load kernel from ${load_path}/${kernelfile}"
+load ${devtype} ${devnum} ${kernel_addr_r} ${load_path}/${kernelfile}
+
+if load ${devtype} ${devnum} ${kernel_addr_r} ${load_path}/${initrdfile}; then
+ echo "Start Kernel with initrd"
+ booti ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r}
+else
+ echo "Start Kernel without initrd"
+ booti ${kernel_addr_r} - ${fdt_addr_r}
+fi
diff --git a/board/theobroma-systems/generic/genimage.cfg b/board/theobroma-systems/generic/genimage.cfg
new file mode 100644
index 0000000000..233bc4e2d2
--- /dev/null
+++ b/board/theobroma-systems/generic/genimage.cfg
@@ -0,0 +1,22 @@
+image sdcard.img {
+ hdimage {
+ }
+
+ partition spl {
+ in-partition-table = "no"
+ image = "spl_sd.img"
+ offset = 32K
+ }
+
+ partition u-boot {
+ in-partition-table = "no"
+ image = "u-boot.itb"
+ offset = 256K
+ }
+
+ partition rootfs {
+ partition-type = 0x83
+ offset = 2M
+ image = "rootfs.ext4"
+ }
+}
diff --git a/board/theobroma-systems/generic/post-build.sh b/board/theobroma-systems/generic/post-build.sh
new file mode 100755
index 0000000000..5098dc4a3f
--- /dev/null
+++ b/board/theobroma-systems/generic/post-build.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+# Generic post-build script:
+# * install boot script
+# * install board specific boot script environment
+
+set -x
+
+BOARD_DIR=$1
+BINARIES_DIR=$2
+TARGET_DIR=$3
+
+# Install boot script
+install -m 0644 -D $BINARIES_DIR/boot.scr $TARGET_DIR/boot/boot.scr
+
+# Install board-specific boot script environment
+install -m 0644 -D $BOARD_DIR/boardEnv.txt $TARGET_DIR/boot/boardEnv.txt
+
diff --git a/board/theobroma-systems/puma/boardEnv.txt b/board/theobroma-systems/puma/boardEnv.txt
new file mode 100644
index 0000000000..2a04650aa1
--- /dev/null
+++ b/board/theobroma-systems/puma/boardEnv.txt
@@ -0,0 +1,6 @@
+kernelfile=Image
+fdtfile=rk3399-puma.dtb
+initrdfile=uInitrd
+kernel_args=loglevel=7
+rootdev_mmc0=/dev/mmcblk1p1
+rootdev_mmc1=/dev/mmcblk0p1
diff --git a/board/theobroma-systems/puma/boot.cmd b/board/theobroma-systems/puma/boot.cmd
index 328b2a3906..63d7c90df1 100644..120000
--- a/board/theobroma-systems/puma/boot.cmd
+++ b/board/theobroma-systems/puma/boot.cmd
@@ -1,68 +1 @@
-# mkimage -C none -A arm -T script -d boot.cmd boot.scr
-
-# fallback default values
-load_addr=0x01000000
-fdtfile=dtb
-kernelfile=Image
-initrdfile=uInitrd
-rootdevice=/dev/mmcblk0p1
-rootdevice_flags=rw
-loglevel=7
-
-echo "Boot script running from ${devtype} ${devnum}"
-
-if test ${board_name} = "puma_rk3399"; then
- if test ${devtype} = "mmc" && test ${devnum} -eq 0;then
- rootdevice=/dev/mmcblk1p1
- elif test ${devtype} = "mmc" && test ${devnum} -eq 1;then
- rootdevice=/dev/mmcblk0p1
- fi
-fi
-
-if load ${devtype} ${devnum} ${fdt_addr_r} /boot/${board_name}/defaultEnv.txt; then
- setenv load_path "/boot/${board_name}"
- echo "Import default environment from /boot/${board_name}/defaultEnv.txt"
- env import -t ${fdt_addr_r} ${filesize}
-else
- if load ${devtype} ${devnum} ${fdt_addr_r} /boot/defaultEnv.txt; then
- setenv load_path "/boot"
- echo "Import default environment from /boot/defaultEnv.txt"
- env import -t ${fdt_addr_r} ${filesize}
- fi
-fi
-
-if load ${devtype} ${devnum} ${load_addr} ${load_path}/userEnv.txt; then
- echo "Import default environment from ${load_path}/userEnv.txt"
- env import -t ${load_addr} ${filesize}
-fi
-
-if test -n ${userscript}; then
- if load ${devtype} ${devnum} ${load_addr} ${load_path}/${userscript}; then
- echo "Running userscript from ${load_path}/${userscript}"
- source ${load_addr}
- fi
-fi
-
-setenv bootargs "root=${rootdevice} ${rootdevice_flags} rootwait ${console} consoleblank=0 loglevel=${loglevel} ${extraargs}"
-
-if load ${devtype} ${devnum} ${fdt_addr_r} ${load_path}/${fdtfile}; then
- echo "Load devicetree from ${load_path}/${fdtfile}"
-fi
-fdt addr ${fdt_addr_r}
-fdt resize
-
-for overlay_file in ${overlays}; do
- if load ${devtype} ${devnum} ${load_addr} ${load_path}/overlays/${overlay_file}; then
- echo "Apply devicetree overlay ${load_path}/overlays/${overlay_file}"
- fdt apply ${load_addr}
- fi
-done
-
-load ${devtype} ${devnum} ${kernel_addr_r} ${load_path}/${kernelfile}
-
-if load ${devtype} ${devnum} ${load_addr} ${load_path}/${initrdfile}; then
- booti ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r}
-else
- echo "Start Kernel without initrd"
- booti ${kernel_addr_r} - ${fdt_addr_r}
-fi
+../generic/boot.cmd \ No newline at end of file
diff --git a/board/theobroma-systems/puma/defaultEnv.txt b/board/theobroma-systems/puma/defaultEnv.txt
deleted file mode 100644
index 436e6b44cd..0000000000
--- a/board/theobroma-systems/puma/defaultEnv.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-load_addr=0x01000000
-kernelfile=Image
-fdtfile=rk3399-puma.dtb
-overlays=
-rootdevice_flags=rw
-loglevel=7
diff --git a/board/theobroma-systems/puma/genimage.cfg b/board/theobroma-systems/puma/genimage.cfg
index 233bc4e2d2..d3db2c2ad5 100644..120000
--- a/board/theobroma-systems/puma/genimage.cfg
+++ b/board/theobroma-systems/puma/genimage.cfg
@@ -1,22 +1 @@
-image sdcard.img {
- hdimage {
- }
-
- partition spl {
- in-partition-table = "no"
- image = "spl_sd.img"
- offset = 32K
- }
-
- partition u-boot {
- in-partition-table = "no"
- image = "u-boot.itb"
- offset = 256K
- }
-
- partition rootfs {
- partition-type = 0x83
- offset = 2M
- image = "rootfs.ext4"
- }
-}
+../generic/genimage.cfg \ No newline at end of file
diff --git a/board/theobroma-systems/puma/post-build.sh b/board/theobroma-systems/puma/post-build.sh
index 93fd341fc2..237ab977a5 100755
--- a/board/theobroma-systems/puma/post-build.sh
+++ b/board/theobroma-systems/puma/post-build.sh
@@ -1,12 +1,16 @@
#!/bin/sh
+# Board-specific post-build script:
+# * call generic post-build script
+# * generate bootloader image
+
set -x
MKIMAGE=$HOST_DIR/bin/mkimage
BOARD_DIR="$(dirname $0)"
-install -m 0644 -D $BINARIES_DIR/boot.scr $TARGET_DIR/boot/boot.scr
-install -m 0644 -D $BOARD_DIR/defaultEnv.txt $TARGET_DIR/boot/defaultEnv.txt
-install -m 0644 -D $BOARD_DIR/userEnv.txt $TARGET_DIR/boot/userEnv.txt
+# Call generic post-build script
+$BOARD_DIR/../generic/post-build.sh $BOARD_DIR $BINARIES_DIR $TARGET_DIR
+# Generate bootloader image
$MKIMAGE -n rk3399 -T rksd -d $BINARIES_DIR/u-boot-spl.bin ${BINARIES_DIR}/spl_sd.img
diff --git a/board/theobroma-systems/puma/userEnv.txt b/board/theobroma-systems/puma/userEnv.txt
deleted file mode 100644
index e69de29bb2..0000000000
--- a/board/theobroma-systems/puma/userEnv.txt
+++ /dev/null
diff --git a/board/theobroma-systems/px30evb/boardEnv.txt b/board/theobroma-systems/px30evb/boardEnv.txt
new file mode 100644
index 0000000000..05ed35e45f
--- /dev/null
+++ b/board/theobroma-systems/px30evb/boardEnv.txt
@@ -0,0 +1,5 @@
+kernelfile=Image
+fdtfile=px30-evb-ddr3-v10-linux.dtb
+initrdfile=uInitrd
+extraargs=loglevel=7
+rootdev_mmc0=/dev/mmcblk2p1
diff --git a/board/theobroma-systems/px30evb/boot.cmd b/board/theobroma-systems/px30evb/boot.cmd
index 61e0479675..63d7c90df1 100644..120000
--- a/board/theobroma-systems/px30evb/boot.cmd
+++ b/board/theobroma-systems/px30evb/boot.cmd
@@ -1,54 +1 @@
-# mkimage -C none -A arm -T script -d boot.cmd boot.scr
-
-# fallback default values
-load_addr=0x01000000
-fdtfile=dtb
-kernelfile=Image
-initrdfile=uInitrd
-rootdevice=/dev/mmcblk2p1
-rootdevice_flags=rw
-loglevel=7
-
-echo "Boot script running from ${devtype} ${devnum}"
-
-if load ${devtype} ${devnum} ${fdt_addr_r} /boot/defaultEnv.txt; then
- setenv load_path "/boot"
- echo "Import default environment from /boot/defaultEnv.txt"
- env import -t ${fdt_addr_r} ${filesize}
-fi
-
-if load ${devtype} ${devnum} ${load_addr} ${load_path}/userEnv.txt; then
- echo "Import default environment from ${load_path}/userEnv.txt"
- env import -t ${load_addr} ${filesize}
-fi
-
-if test -n ${userscript}; then
- if load ${devtype} ${devnum} ${load_addr} ${load_path}/${userscript}; then
- echo "Running userscript from ${load_path}/${userscript}"
- source ${load_addr}
- fi
-fi
-
-setenv bootargs "root=${rootdevice} ${rootdevice_flags} rootwait ${console} consoleblank=0 loglevel=${loglevel} ${extraargs}"
-
-if load ${devtype} ${devnum} ${fdt_addr_r} ${load_path}/${fdtfile}; then
- echo "Load devicetree from ${load_path}/${fdtfile}"
-fi
-fdt addr ${fdt_addr_r}
-fdt resize
-
-for overlay_file in ${overlays}; do
- if load ${devtype} ${devnum} ${load_addr} ${load_path}/overlays/${overlay_file}; then
- echo "Apply devicetree overlay ${load_path}/overlays/${overlay_file}"
- fdt apply ${load_addr}
- fi
-done
-
-load ${devtype} ${devnum} ${kernel_addr_r} ${load_path}/${kernelfile}
-
-if load ${devtype} ${devnum} ${load_addr} ${load_path}/${initrdfile}; then
- booti ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r}
-else
- echo "Start Kernel without initrd"
- booti ${kernel_addr_r} - ${fdt_addr_r}
-fi
+../generic/boot.cmd \ No newline at end of file
diff --git a/board/theobroma-systems/px30evb/defaultEnv.txt b/board/theobroma-systems/px30evb/defaultEnv.txt
deleted file mode 100644
index 9ff9ad311e..0000000000
--- a/board/theobroma-systems/px30evb/defaultEnv.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-load_addr=0x01000000
-kernelfile=Image
-fdtfile=px30-evb-ddr3-v10-linux.dtb
-overlays=
-rootdevice_flags=rw
-loglevel=7
diff --git a/board/theobroma-systems/px30evb/genimage.cfg b/board/theobroma-systems/px30evb/genimage.cfg
index 233bc4e2d2..d3db2c2ad5 100644..120000
--- a/board/theobroma-systems/px30evb/genimage.cfg
+++ b/board/theobroma-systems/px30evb/genimage.cfg
@@ -1,22 +1 @@
-image sdcard.img {
- hdimage {
- }
-
- partition spl {
- in-partition-table = "no"
- image = "spl_sd.img"
- offset = 32K
- }
-
- partition u-boot {
- in-partition-table = "no"
- image = "u-boot.itb"
- offset = 256K
- }
-
- partition rootfs {
- partition-type = 0x83
- offset = 2M
- image = "rootfs.ext4"
- }
-}
+../generic/genimage.cfg \ No newline at end of file
diff --git a/board/theobroma-systems/px30evb/post-build.sh b/board/theobroma-systems/px30evb/post-build.sh
index 8dec74ce7c..cd919747be 100755
--- a/board/theobroma-systems/px30evb/post-build.sh
+++ b/board/theobroma-systems/px30evb/post-build.sh
@@ -1,14 +1,17 @@
#!/bin/sh
+# Board-specific post-build script:
+# * call generic post-build script
+# * generate bootloader image
+
set -x
MKIMAGE=$HOST_DIR/bin/mkimage
BOARD_DIR="$(dirname $0)"
-install -m 0644 -D $BINARIES_DIR/boot.scr $TARGET_DIR/boot/boot.scr
-install -m 0644 -D $BOARD_DIR/defaultEnv.txt $TARGET_DIR/boot/defaultEnv.txt
-install -m 0644 -D $BOARD_DIR/userEnv.txt $TARGET_DIR/boot/userEnv.txt
+# Call generic post-build script
+$BOARD_DIR/../generic/post-build.sh $BOARD_DIR $BINARIES_DIR $TARGET_DIR
+# Generate bootloader image
$MKIMAGE -n px30 -T rksd -d $BINARIES_DIR/u-boot-tpl.bin $BINARIES_DIR/spl_sd.img
cat $BINARIES_DIR/u-boot-spl-dtb.bin >> $BINARIES_DIR/spl_sd.img
-
diff --git a/board/theobroma-systems/px30evb/userEnv.txt b/board/theobroma-systems/px30evb/userEnv.txt
deleted file mode 100644
index e69de29bb2..0000000000
--- a/board/theobroma-systems/px30evb/userEnv.txt
+++ /dev/null