mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [RFC] omap3evm: Set preliminary environment
@ 2012-02-09 18:24 Sanjeev Premi
  2012-02-10 12:23 ` Sascha Hauer
  0 siblings, 1 reply; 4+ messages in thread
From: Sanjeev Premi @ 2012-02-09 18:24 UTC (permalink / raw)
  To: barebox

This is still work-in-progress, but wanted to
share them early for any feedback.

Signed-off-by: Sanjeev Premi <premi@ti.com>
---
 I have made offline edits on these scripts before making
 this patch. There is a possibility of run-time failure.

 You will also observe many TODOs. Hope to get them sorted
 tomorrow - for a patch worthy of applying on the tree.

 arch/arm/boards/omap3evm/env/bin/boot          |   27 ++++++++++
 arch/arm/boards/omap3evm/env/bin/init          |   27 ++++++++++
 arch/arm/boards/omap3evm/env/bin/set-local-env |   66 ++++++++++++++++++++++++
 arch/arm/boards/omap3evm/env/config            |   52 +++++++++++++++++++
 4 files changed, 172 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/boards/omap3evm/env/bin/boot
 create mode 100644 arch/arm/boards/omap3evm/env/bin/init
 create mode 100644 arch/arm/boards/omap3evm/env/bin/set-local-env
 create mode 100644 arch/arm/boards/omap3evm/env/config

diff --git a/arch/arm/boards/omap3evm/env/bin/boot b/arch/arm/boards/omap3evm/env/bin/boot
new file mode 100644
index 0000000..58e950a
--- /dev/null
+++ b/arch/arm/boards/omap3evm/env/bin/boot
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+if [ "$boot_method" = "disk" ]; then
+	#
+	# Mount the partition containing kernel image
+	#
+	mkdir /boot
+
+	echo mount /dev/$kernel_part fat /boot
+	mount /dev/$kernel_part fat /boot
+#
+#	TODO: This (and similar variations of the check) cause exceptions
+#	      Keep commented for now.
+#	if [ "$?" != "0" ]; then
+# 		echo ":: Couldn't mount the MMC/SD card"
+# 		exit 1
+# 	fi
+
+	bootm -c -v /boot/uImage
+else
+	#
+	# TODO: Boot from tftp + nfs
+	#
+fi
+
+echo ":: Unable to boot. Check environment variables."
+echo "::"
diff --git a/arch/arm/boards/omap3evm/env/bin/init b/arch/arm/boards/omap3evm/env/bin/init
new file mode 100644
index 0000000..3bded32
--- /dev/null
+++ b/arch/arm/boards/omap3evm/env/bin/init
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+export PATH=/env/bin
+
+#
+# Source generic configuration
+#
+. /env/config
+
+#
+# Populate environment based on config params
+#
+. /env/bin/set-local-env
+
+echo ""
+echo -n ":: Press any key to stop autoboot: "
+timeout -a $autoboot_timeout
+if [ $? != 0 ]; then
+	exit
+fi
+
+echo ""
+
+#
+# Proceed to boot
+#
+. /env/bin/boot
diff --git a/arch/arm/boards/omap3evm/env/bin/set-local-env b/arch/arm/boards/omap3evm/env/bin/set-local-env
new file mode 100644
index 0000000..b92f037
--- /dev/null
+++ b/arch/arm/boards/omap3evm/env/bin/set-local-env
@@ -0,0 +1,66 @@
+#!/bin/sh
+
+#
+# Set the IP address
+# TODO: Update for DHCP when booting via tftp
+#
+if [ "$ip_method" = "static" ]; then
+	eth0.ipaddr=$evm_ipaddr
+	eth0.gateway=$evm_gateway
+	eth0.netmask=$evm_netmask
+fi
+
+#
+# Select the location of kernel and root filesystem based on boot method
+#
+echo "::"
+
+if [ -n "$boot_method" ]; then
+	echo " : No boot method specified. Using 'disk'..."
+	boot_method=disk
+fi
+
+if [ "$boot_method" = "disk"  ]; then
+	echo ":: Booting from 'disk' ..."
+	rootfs_loc=disk
+	kernel_loc=disk
+
+	# Location of kernel image (for Barebox)
+	kernel_part=disk0.0
+
+	# Location of root filesystem (for Linux)
+	rootfs_part=mmcblk0p2
+elif [ "$boot_method" = "net"  ]; then
+	echo ":: Booting from 'net' ..."
+	rootfs_loc=net
+	kernel_loc=net
+
+	nfsroot="$nfs_server:$nfs_path"
+else
+	echo ":: Unknown boot method - $boot_method"
+	exit 1
+fi
+
+echo "::"
+
+#
+# Bootargs: Append root filesystem info
+#
+if [ "$rootfs_loc" = "disk" ]; then
+	bootargs="$bootargs noinitrd root=/dev/$rootfs_part rw rootfstype=$rootfs_type"
+elif [ "$rootfs_loc" = "net" ]; then
+	bootargs="$bootargs noinitrd root=/dev/nfs nfsroot=$nfsroot,tcp"
+elif [ "$rootfs_loc" = "initrd" ]; then
+	bootargs="$bootargs root=/dev/ram0 rdinit=/sbin/init"
+fi
+
+#
+# Bootargs: Append network info
+#
+if [ "$ip_method" = "dhcp" ]; then
+	bootargs="$bootargs ip=dhcp"
+elif [ "$ip_method" = "static" ]; then
+	bootargs="$bootargs ip=$eth0.ipaddr::$eth0.gateway:$eth0.netmask:::"
+else
+	bootargs="$bootargs ip=none"
+fi
diff --git a/arch/arm/boards/omap3evm/env/config b/arch/arm/boards/omap3evm/env/config
new file mode 100644
index 0000000..3525e40
--- /dev/null
+++ b/arch/arm/boards/omap3evm/env/config
@@ -0,0 +1,52 @@
+#!/bin/sh
+
+#
+# Timeout for automatic boot
+#
+autoboot_timeout=2
+
+#
+# Basic bootargs
+#
+bootargs="console=tty02,115200n8 mem=256M earlyprintk=serial,ttyO2,115200"
+#
+# Set fancy prompt (if CONFIG_HUSH_FANCY_PROMPT was selected)
+#
+PS1="\e[1;32m[\w] \e[1;31m #\e[0m "
+
+#
+# Boot method
+# Use one of: tftp / nand / disk
+#
+boot_method=disk
+
+#
+# Format of root filesystem
+# Use one of: ext2/ ext3 (depends on the medium)
+#
+rootfs_type=ext3
+
+#
+# Method for getting the IP address
+# Use one of: none / static / dhcp
+#
+ip_method=dhcp
+
+#
+# IP address of the NFS server
+# (Used only if the filesystem is mounted over NFS)
+#
+nfs_server=192.168.1.1
+
+#
+# Path (on NFS server) to be mounted
+#
+nfs_path=/home/user/nfs-export
+
+#
+# Static IP configuration
+# (Used only if static IP is used)
+#
+evm_ipaddr=192.168.1.10
+evm_gateway=192.168.1.10
+evm_netmask=192.168.1.10
-- 
1.7.0.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC] omap3evm: Set preliminary environment
  2012-02-09 18:24 [RFC] omap3evm: Set preliminary environment Sanjeev Premi
@ 2012-02-10 12:23 ` Sascha Hauer
  2012-02-13 10:16   ` Premi, Sanjeev
  0 siblings, 1 reply; 4+ messages in thread
From: Sascha Hauer @ 2012-02-10 12:23 UTC (permalink / raw)
  To: Sanjeev Premi; +Cc: barebox

On Thu, Feb 09, 2012 at 11:54:28PM +0530, Sanjeev Premi wrote:
> This is still work-in-progress, but wanted to
> share them early for any feedback.
> 
> Signed-off-by: Sanjeev Premi <premi@ti.com>
> ---
>  I have made offline edits on these scripts before making
>  this patch. There is a possibility of run-time failure.
> 
>  You will also observe many TODOs. Hope to get them sorted
>  tomorrow - for a patch worthy of applying on the tree.

You are rewriting what we already have in form of the generic
environment. You shouldn't do this, we've been there before.
Before there was the generic environment every board had its
own set of environment scripts. This resulted in tons of
board specific scripts in slightly different states.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [RFC] omap3evm: Set preliminary environment
  2012-02-10 12:23 ` Sascha Hauer
@ 2012-02-13 10:16   ` Premi, Sanjeev
  2012-02-14 11:11     ` Sascha Hauer
  0 siblings, 1 reply; 4+ messages in thread
From: Premi, Sanjeev @ 2012-02-13 10:16 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

> -----Original Message-----
> From: Sascha Hauer [mailto:s.hauer@pengutronix.de] 
> Sent: Friday, February 10, 2012 5:54 PM
> To: Premi, Sanjeev
> Cc: barebox@lists.infradead.org
> Subject: Re: [RFC] omap3evm: Set preliminary environment
> 
> On Thu, Feb 09, 2012 at 11:54:28PM +0530, Sanjeev Premi wrote:
> > This is still work-in-progress, but wanted to
> > share them early for any feedback.
> > 
> > Signed-off-by: Sanjeev Premi <premi@ti.com>
> > ---
> >  I have made offline edits on these scripts before making
> >  this patch. There is a possibility of run-time failure.
> > 
> >  You will also observe many TODOs. Hope to get them sorted
> >  tomorrow - for a patch worthy of applying on the tree.
> 
> You are rewriting what we already have in form of the generic
> environment. You shouldn't do this, we've been there before.
> Before there was the generic environment every board had its
> own set of environment scripts. This resulted in tons of
> board specific scripts in slightly different states.

Agree. I didn't want duplication - but was swayed by "FIXME"s
the barebox/defaultenv and scripts in some of the boards that
I saw.

It is possible to override selective variables? e.g.

machine=FIXME
bootargs="console=ttyFIXME,115200"
kernel_part=disk0.2

Is there an example to refer?

~sanjev

> 
> Sascha
> 
> -- 
> Pengutronix e.K.                           |                  
>            |
> Industrial Linux Solutions                 | 
> http://www.pengutronix.de/  |
> Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: 
> +49-5121-206917-0    |
> Amtsgericht Hildesheim, HRA 2686           | Fax:   
> +49-5121-206917-5555 |
> 
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC] omap3evm: Set preliminary environment
  2012-02-13 10:16   ` Premi, Sanjeev
@ 2012-02-14 11:11     ` Sascha Hauer
  0 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2012-02-14 11:11 UTC (permalink / raw)
  To: Premi, Sanjeev; +Cc: barebox

On Mon, Feb 13, 2012 at 10:16:13AM +0000, Premi, Sanjeev wrote:
> > -----Original Message-----
> > From: Sascha Hauer [mailto:s.hauer@pengutronix.de] 
> > Sent: Friday, February 10, 2012 5:54 PM
> > To: Premi, Sanjeev
> > Cc: barebox@lists.infradead.org
> > Subject: Re: [RFC] omap3evm: Set preliminary environment
> > 
> > On Thu, Feb 09, 2012 at 11:54:28PM +0530, Sanjeev Premi wrote:
> > > This is still work-in-progress, but wanted to
> > > share them early for any feedback.
> > > 
> > > Signed-off-by: Sanjeev Premi <premi@ti.com>
> > > ---
> > >  I have made offline edits on these scripts before making
> > >  this patch. There is a possibility of run-time failure.
> > > 
> > >  You will also observe many TODOs. Hope to get them sorted
> > >  tomorrow - for a patch worthy of applying on the tree.
> > 
> > You are rewriting what we already have in form of the generic
> > environment. You shouldn't do this, we've been there before.
> > Before there was the generic environment every board had its
> > own set of environment scripts. This resulted in tons of
> > board specific scripts in slightly different states.
> 
> Agree. I didn't want duplication - but was swayed by "FIXME"s
> the barebox/defaultenv and scripts in some of the boards that
> I saw.
> 
> It is possible to override selective variables? e.g.
> 
> machine=FIXME
> bootargs="console=ttyFIXME,115200"
> kernel_part=disk0.2
> 
> Is there an example to refer?

The idea is to just overwrite env/config and keeping the rest from the
default env. There currently is no way to overwrite only single variables.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-02-14 11:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-09 18:24 [RFC] omap3evm: Set preliminary environment Sanjeev Premi
2012-02-10 12:23 ` Sascha Hauer
2012-02-13 10:16   ` Premi, Sanjeev
2012-02-14 11:11     ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox