Skip to contentSkip to conversation

uboot-extlinux-config.bbclass: add support for timeout & default

PATCH Superseded Dalon Westergreen 2 participants 3 messages Feb 9, 2017

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 uboot-extlinux-config.bbclass: add support for timeout & default

When multible targets are defined it is useful to allow for a default target along with a timeout. After timeout, the default target will be selected.

---
 meta/classes/uboot-extlinux-config.bbclass | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
meta/classes/uboot-extlinux-config.bbclass +18 -0
index ec5fffb..96b5a2e 100644
@@ -16,6 +16,10 @@
 #                                    concatenate and use as an initrd (optional).
 # UBOOT_EXTLINUX_MENU_DESCRIPTION  - Name to use as description.
 # UBOOT_EXTLINUX_ROOT              - Root kernel cmdline.
+# UBOOT_EXTLINUX_TIMEOUT           - Timeout before DEFAULT selection is made.
+#                                    Measured in 1/10 of a second.
+# UBOOT_EXTLINUX_DEFAULT_LABEL     - Target to be selected by default after
+#                                    the timeout period
 #
 # If there's only one label system will boot automatically and menu won't be
 # created. If you want to use more than one labels, e.g linux and alternate,
@@ -25,6 +29,9 @@
 #
 # UBOOT_EXTLINUX_LABELS ??= "default fallback"
 #
+# UBOOT_EXTLINUX_DEFAULT_LABEL ??= "Linux Default"
+# UBOOT_EXTLINUX_TIMEOUT ??= "30"
+#
 # UBOOT_EXTLINUX_KERNEL_IMAGE_default ??= "../zImage"
 # UBOOT_EXTLINUX_MENU_DESCRIPTION_default ??= "Linux Default"
 #
@@ -34,6 +41,8 @@
 # Results:
 #
 # menu title Select the boot mode
+# TIMEOUT 30
+# DEFAULT Linux Default
 # LABEL Linux Default
 #   KERNEL ../zImage
 #   FDTDIR ../
@@ -82,6 +91,15 @@ python create_extlinux_config() {
             if len(labels.split()) > 1:
                 cfgfile.write('menu title Select the boot mode\n')
 
+            timeout =  localdata.getVar('UBOOT_EXTLINUX_TIMEOUT')
+            if timeout:
+                cfgfile.write('TIMEOUT %s\n' % (timeout))
+
+            if len(labels.split()) > 1:
+                default = localdata.getVar('UBOOT_EXTLINUX_DEFAULT_LABEL')
+                if default:
+                    cfgfile.write('DEFAULT %s\n' % (default))
+                    
             for label in labels.split():
                 localdata = bb.data.createCopy(d)
 
Signature · 1 line
2.7.4
#1 lore raw

I get this error:

Exception: UnboundLocalError: local variable 'localdata' referenced before assignment

You are using localdata.getVar('UBOOT_EXTLINUX_TIMEOUT') before localdata = bb.data.createCopy(d).

Quoted 75 lines · Dalon Westergreen

When multible targets are defined it is useful to allow for a default target along with a timeout. After timeout, the default target will be selected.

---
 meta/classes/uboot-extlinux-config.bbclass | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
meta/classes/uboot-extlinux-config.bbclass +0 -0
index ec5fffb..96b5a2e 100644
@@ -16,6 +16,10 @@
 #                                    concatenate and use as an initrd

(optional).

 # UBOOT_EXTLINUX_MENU_DESCRIPTION  - Name to use as description.
 # UBOOT_EXTLINUX_ROOT              - Root kernel cmdline.
+# UBOOT_EXTLINUX_TIMEOUT           - Timeout before DEFAULT selection is

made.

meta/classes/uboot-extlinux-config.bbclass +2 -0
+#                                    Measured in 1/10 of a second.
+# UBOOT_EXTLINUX_DEFAULT_LABEL     - Target to be selected by default

after
+# the timeout period
#
# If there's only one label system will boot automatically and menu won't
be

 # created. If you want to use more than one labels, e.g linux and
alternate,
meta/classes/uboot-extlinux-config.bbclass +14 -1
@@ -25,6 +29,9 @@
 #
 # UBOOT_EXTLINUX_LABELS ??= "default fallback"
 #
+# UBOOT_EXTLINUX_DEFAULT_LABEL ??= "Linux Default"
+# UBOOT_EXTLINUX_TIMEOUT ??= "30"
+#
 # UBOOT_EXTLINUX_KERNEL_IMAGE_default ??= "../zImage"
 # UBOOT_EXTLINUX_MENU_DESCRIPTION_default ??= "Linux Default"
 #
@@ -34,6 +41,8 @@
 # Results:
 #
 # menu title Select the boot mode
+# TIMEOUT 30
+# DEFAULT Linux Default
 # LABEL Linux Default
 #   KERNEL ../zImage
 #   FDTDIR ../
@@ -82,6 +91,15 @@ python create_extlinux_config() {
             if len(labels.split()) > 1:
                 cfgfile.write('menu title Select the boot mode\n')
 
+            timeout =  localdata.getVar('UBOOT_EXTLINUX_TIMEOUT')
+            if timeout:
+                cfgfile.write('TIMEOUT %s\n' % (timeout))
+
+            if len(labels.split()) > 1:
+                default = localdata.getVar('UBOOT_
 EXTLINUX_DEFAULT_LABEL')
+                if default:
+                    cfgfile.write('DEFAULT %s\n' % (default))
+
             for label in labels.split():
                 localdata = bb.data.createCopy(d)
 
--

2.7.4

--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

#2 lore raw
Quoted 8 lines · Fabio Berton

I get this error:

Exception: UnboundLocalError: local variable 'localdata' referenced before assignment

You are using localdata.getVar('UBOOT_EXTLINUX_TIMEOUT') before localdata = bb.data.createCopy(d).

thanks.

Quoted 75 lines · Dalon Westergreen
Quoted 73 lines

When multible targets are defined it is useful to allow for a default target along with a timeout.  After timeout, the default target will be selected.

---
 meta/classes/uboot-extlinux-config.bbclass | 18 ++++++++++++++++++

 1 file changed, 18 insertions(+)
meta/classes/uboot-extlinux-config.bbclass +0 -0
index ec5fffb..96b5a2e 100644
@@ -16,6 +16,10 @@
  #                                    concatenate and use as an initrd

(optional).
 # UBOOT_EXTLINUX_MENU_DESCRIPTION  - Name to use as description. # UBOOT_EXTLINUX_ROOT              - Root kernel cmdline.
+# UBOOT_EXTLINUX_TIMEOUT           - Timeout before DEFAULT selection is made.

meta/classes/uboot-extlinux-config.bbclass +3 -0
+#                                    Measured in 1/10 of a second.
+# UBOOT_EXTLINUX_DEFAULT_LABEL     - Target to be selected by default after
+#                                    the timeout period

 #
 # If there's only one label system will boot automatically and menu won't be

 # created. If you want to use more than one labels, e.g linux and
alternate,
meta/classes/uboot-extlinux-config.bbclass +5 -0
@@ -25,6 +29,9 @@
  #
  # UBOOT_EXTLINUX_LABELS ??= "default fallback"
  #
+# UBOOT_EXTLINUX_DEFAULT_LABEL ??= "Linux Default"
+# UBOOT_EXTLINUX_TIMEOUT ??= "30"
+#
  # UBOOT_EXTLINUX_KERNEL_IMAGE_default ??= "../zImage"
  # UBOOT_EXTLINUX_MENU_DESCRIPTION_default ??= "Linux Default"
  #
@@ -34,6 +41,8 @@
  # Results:
  #
  # menu title Select the boot mode
+# TIMEOUT 30
+# DEFAULT Linux Default
  # LABEL Linux Default
  #   KERNEL ../zImage
  #   FDTDIR ../
@@ -82,6 +91,15 @@ python create_extlinux_config() {

             if len(labels.split()) > 1:
                 cfgfile.write('menu title Select the boot mode\n')

+            timeout =  localdata.getVar('UBOOT_EXTLINUX_TIMEOUT') +            if timeout:
+                cfgfile.write('TIMEOUT %s\n' % (timeout))

meta/classes/uboot-extlinux-config.bbclass +6 -0
+
+            if len(labels.split()) > 1:
+                default = localdata.getVar('UBOOT_EXTLINUX_DEFAULT_LABEL')
+                if default:
+                    cfgfile.write('DEFAULT %s\n' % (default))
+

             for label in labels.split():
                 localdata = bb.data.createCopy(d)

--
2.7.4

--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core