Skip to contentSkip to conversation

Introduce new SERIAL_CONSOLES to add multiple consoles for your MACHINE

PATCH Superseded Matthew McClintock 5 participants 12 messages Nov 4, 2011 – Nov 11, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Introduce new SERIAL_CONSOLES to add multiple consoles for your MACHINE

Just define additional serial consoles like so:

SERIAL_CONSOLES="115200;ttyS0 115200;ttyS1 ... 115200;ttySN"

Also be sure to remove SERIAL_CONSOLE (lacking the S) from your machine as they can conflict.

---
 .../sysvinit/sysvinit-inittab_2.88dsf.bb           |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
meta/recipes-core/sysvinit/sysvinit-inittab_2.88dsf.bb +10 -0
index ba60c74..3a716d7 100644
@@ -25,6 +25,16 @@ do_install() {
     if [ ! -z "${SERIAL_CONSOLE}" ]; then
         echo "S:2345:respawn:${base_sbindir}/getty ${SERIAL_CONSOLE}" >> ${D}${sysconfdir}/inittab
     fi
+
+    idx=0
+    tmp="${SERIAL_CONSOLES}"
+    for i in $tmp
+    do
+	j=`echo ${i} | sed s/\;/\ /g`
+        echo "${idx}:2345:respawn:${base_sbindir}/getty ${j}" >> ${D}${sysconfdir}/inittab
+	idx=`expr $idx + 1`
+    done
+
     if [ "${USE_VT}" = "1" ]; then
         cat <<EOF >>${D}${sysconfdir}/inittab
 # ${base_sbindir}/getty invocations for the runlevels.
Signature · 1 line
1.7.6.1
#1 lore raw

meta/recipes-core/sysvinit/sysvinit-inittab_2.88dsf.bb do_install() { · line 40

Quoted 12 lines · Matthew McClintock
meta/recipes-core/sysvinit/sysvinit-inittab_2.88dsf.bb +9 -0
+    idx=0
+    tmp="${SERIAL_CONSOLES}"
+    for i in $tmp
+    do
+	j=`echo ${i} | sed s/\;/\ /g`
+        echo "${idx}:2345:respawn:${base_sbindir}/getty ${j}" >> ${D}${sysconfdir}/inittab
+	idx=`expr $idx + 1`
+    done
+
     if [ "${USE_VT}" = "1" ]; then
         cat <<EOF >>${D}${sysconfdir}/inittab
 # ${base_sbindir}/getty invocations for the runlevels.

That looks like it will lose if ${SERIAL_CONSOLES} is not defined at all.

p.

#2 lore raw

PATCH v2 1/1 Introduce new SERIAL_CONSOLES to add multiple consoles for your MACHINE

Just define additional serial consoles like so:

SERIAL_CONSOLES="115200;ttyS0 115200;ttyS1 ... 115200;ttySN"

Also be sure to remove SERIAL_CONSOLE (lacking the S) from your machine as they can conflict.

---
v2: handle case where SERIAL_CONSOLES is not defined

 .../sysvinit/sysvinit-inittab_2.88dsf.bb           |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
meta/recipes-core/sysvinit/sysvinit-inittab_2.88dsf.bb +12 -0
index ba60c74..adab262 100644
@@ -25,6 +25,18 @@ do_install() {
     if [ ! -z "${SERIAL_CONSOLE}" ]; then
         echo "S:2345:respawn:${base_sbindir}/getty ${SERIAL_CONSOLE}" >> ${D}${sysconfdir}/inittab
     fi
+
+    idx=0
+    tmp="${SERIAL_CONSOLES}"
+    if [ "x" != "x$tmp" ]; then
+	for i in $tmp
+	do
+	    j=`echo ${i} | sed s/\;/\ /g`
+	    echo "${idx}:2345:respawn:${base_sbindir}/getty ${j}" >> ${D}${sysconfdir}/inittab
+	    idx=`expr $idx + 1`
+	done
+    fi
+
     if [ "${USE_VT}" = "1" ]; then
         cat <<EOF >>${D}${sysconfdir}/inittab
 # ${base_sbindir}/getty invocations for the runlevels.
Signature · 1 line
1.7.6.1
#3 lore raw
Quoted 15 lines · Matthew McClintock

v2: handle case where SERIAL_CONSOLES is not defined

 .../sysvinit/sysvinit-inittab_2.88dsf.bb           |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
meta/recipes-core/sysvinit/sysvinit-inittab_2.88dsf.bb +2 -0
index ba60c74..adab262 100644
@@ -25,6 +25,18 @@ do_install() {
     if [ ! -z "${SERIAL_CONSOLE}" ]; then
         echo "S:2345:respawn:${base_sbindir}/getty ${SERIAL_CONSOLE}" >> ${D}${sysconfdir}/inittab
     fi
+
+    idx=0

meta/recipes-core/sysvinit/sysvinit-inittab_2.88dsf.bb do_install() { · line 39

Quoted 10 lines
meta/recipes-core/sysvinit/sysvinit-inittab_2.88dsf.bb +10 -0
+    tmp="${SERIAL_CONSOLES}"
+    if [ "x" != "x$tmp" ]; then
+	for i in $tmp
+	do
+	    j=`echo ${i} | sed s/\;/\ /g`
+	    echo "${idx}:2345:respawn:${base_sbindir}/getty ${j}" >> ${D}${sysconfdir}/inittab
+	    idx=`expr $idx + 1`
+	done
+    fi
+

Did you test that this actually solves the problem? It looks to me as though it will still do the wrong thing if the variable is not defined at all (as opposed to being defined to the empty string). The added "if" statement doesn't actually achieve much since, if $tmp is the empty string, the for-loop wouldn't have executed anyway and there is no need for an extra guard.

Also, for what it's worth, the "x$tmp" idiom is unnecessary if you're going to quote the strings.

p.

#4 lore raw
Quoted 35 lines · On Nov 4, 2011 4:35 PM, "Phil Blundell" <[email protected]<mailto:[email protected]>>…
Quoted 15 lines · Matthew McClintock

v2: handle case where SERIAL_CONSOLES is not defined

 .../sysvinit/sysvinit-inittab_2.88dsf.bb<http://sysvinit-inittab_2.88dsf.bb>           |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
meta/recipes-core/sysvinit/sysvinit-inittab_2.88dsf.bb<http://sysvinit-inittab_2.88dsf.bb> +2 -0
index ba60c74..adab262 100644
@@ -25,6 +25,18 @@ do_install() {
     if [ ! -z "${SERIAL_CONSOLE}" ]; then
         echo "S:2345:respawn:${base_sbindir}/getty ${SERIAL_CONSOLE}" >> ${D}${sysconfdir}/inittab
     fi
+
+    idx=0

meta/recipes-core/sysvinit/sysvinit-inittab_2.88dsf.bb<http://sysvinit-inittab_2.88dsf.bb> do_install() { · line 39

Quoted 10 lines
meta/recipes-core/sysvinit/sysvinit-inittab_2.88dsf.bb<http://sysvinit-inittab_2.88dsf.bb> +10 -0
+    tmp="${SERIAL_CONSOLES}"
+    if [ "x" != "x$tmp" ]; then
+     for i in $tmp
+     do
+         j=`echo ${i} | sed s/\;/\ /g`
+         echo "${idx}:2345:respawn:${base_sbindir}/getty ${j}" >> ${D}${sysconfdir}/inittab
+         idx=`expr $idx + 1`
+     done
+    fi
+

Did you test that this actually solves the problem? It looks to me as though it will still do the wrong thing if the variable is not defined at all (as opposed to being defined to the empty string). The added "if" statement doesn't actually achieve much since, if $tmp is the empty string, the for-loop wouldn't have executed anyway and there is no need for an extra guard.

Quoted 6 lines

Also, for what it's worth, the "x$tmp" idiom is unnecessary if you're going to quote the strings.

p.

Thanks for the feedback. Ill look at this again when I'm fresh.

-M

Quoted 5 lines

_______________________________________________
Openembedded-core mailing list [email protected]<mailto:[email protected]>
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core

#5 lore raw
In reply to Phil Blundell
Quoted 26 lines · Phil Blundell
Quoted 8 lines
meta/recipes-core/sysvinit/sysvinit-inittab_2.88dsf.bb +0 -0
@@ -25,6 +25,18 @@ do_install() {

     if [ ! -z "${SERIAL_CONSOLE}" ]; then
         echo "S:2345:respawn:${base_sbindir}/getty ${SERIAL_CONSOLE}" >> ${D}${sysconfdir}/inittab fi

meta/recipes-core/sysvinit/sysvinit-inittab_2.88dsf.bb +2 -0
+
+    idx=0

meta/recipes-core/sysvinit/sysvinit-inittab_2.88dsf.bb do_install() { · line 39

Quoted 10 lines
meta/recipes-core/sysvinit/sysvinit-inittab_2.88dsf.bb +10 -0
+    tmp="${SERIAL_CONSOLES}"
+    if [ "x" != "x$tmp" ]; then
+     for i in $tmp
+     do
+         j=`echo ${i} | sed s/\;/\ /g`
+         echo "${idx}:2345:respawn:${base_sbindir}/getty ${j}" >> ${D}${sysconfdir}/inittab
+         idx=`expr $idx + 1`
+     done
+    fi
+

Did you test that this actually solves the problem?  It looks to me as though it will still do the wrong thing if the variable is not defined at all (as opposed to being defined to the empty string).  The added "if" statement doesn't actually achieve much since, if $tmp is the empty string, the for-loop wouldn't have executed anyway and there is no need for an extra guard.

Quoted 2 lines

Also, for what it's worth, the "x$tmp" idiom is unnecessary if you're going to quote the strings.

I don't get it. I think the first version was still OK. The first version is pasted below.

meta/recipes-core/sysvinit/sysvinit-inittab_2.88dsf.bb do_install() { · line 37

Quoted 8 lines
meta/recipes-core/sysvinit/sysvinit-inittab_2.88dsf.bb +8 -0
+    idx=0
+    tmp="${SERIAL_CONSOLES}" <- If it's not defined this will catch it.
+    for i in $tmp
+    do
+     j=`echo ${i} | sed s/\;/\ /g`
+        echo "${idx}:2345:respawn:${base_sbindir}/getty ${j}" >> ${D}${sysconfdir}/inittab
+     idx=`expr $idx + 1`
+    done

See my inline comment above, but if SERIAL_CONSOLES is not defined tmp="" and the for loop won't execute. Not sure if there is a more standard way to do this though.

-M

#6 lore raw
Quoted 12 lines · Matthew McClintock

I don't get it. I think the first version was still OK. The first version is pasted below.

Quoted 8 lines

+    idx=0
+    tmp="${SERIAL_CONSOLES}" <- If it's not defined this will catch it.
+    for i in $tmp
+    do
+     j=echo ${i} | sed s/\;/\ /g
+        echo "${idx}:2345:respawn:${base_sbindir}/getty ${j}" >> ${D}${sysconfdir}/inittab
+     idx=expr $idx + 1
+    done

Quoted 3 lines

See my inline comment above, but if SERIAL_CONSOLES is not defined tmp="" and the for loop won't execute. Not sure if there is a more standard way to do this though.

ping..

-M

#7 lore raw
Quoted 13 lines · On Tue, 2011-11-08 at 19:36 +0000, McClintock Matthew-B29882 wrote:
Quoted 12 lines · Matthew McClintock

I don't get it. I think the first version was still OK. The first version is pasted below.

Quoted 8 lines
meta/recipes-core/sysvinit/sysvinit-inittab_2.88dsf.bb +8 -0
+    idx=0
+    tmp="${SERIAL_CONSOLES}" <- If it's not defined this will catch it.
+    for i in $tmp
+    do
+     j=`echo ${i} | sed s/\;/\ /g`
+        echo "${idx}:2345:respawn:${base_sbindir}/getty ${j}" >> ${D}${sysconfdir}/inittab
+     idx=`expr $idx + 1`
+    done
Quoted 5 lines
Quoted 3 lines

See my inline comment above, but if SERIAL_CONSOLES is not defined tmp="" and the for loop won't execute. Not sure if there is a more standard way to do this though.

ping..

Yeah, now I look at this again I think it is probably OK. Bitbake won't expand ${SERIAL_CONSOLES} if it's unset, but the shell will and I think you probably will get the right results. Assuming you've actually tested that case and it does work, I think I'm happy with what you have above.

p.

#8 lore raw
Quoted 18 lines · Phil Blundell
Quoted 17 lines · On Tue, 2011-11-08 at 19:36 +0000, McClintock Matthew-B29882 wrote:
Quoted 15 lines · Matthew McClintock

I don't get it. I think the first version was still OK. The first version is pasted below.

Quoted 8 lines

+    idx=0
+    tmp="${SERIAL_CONSOLES}" <- If it's not defined this will catch it.
+    for i in $tmp
+    do
+     j=echo ${i} | sed s/\;/\ /g
+        echo "${idx}:2345:respawn:${base_sbindir}/getty ${j}" >> ${D}${sysconfdir}/inittab
+     idx=expr $idx + 1
+    done

See my inline comment above, but if SERIAL_CONSOLES is not defined tmp="" and the for loop won't execute. Not sure if there is a more standard way to do this though.

Quoted 7 lines
Quoted 1 line

ping..

Yeah, now I look at this again I think it is probably OK.  Bitbake won't expand ${SERIAL_CONSOLES} if it's unset, but the shell will and I think you probably will get the right results.  Assuming you've actually tested that case and it does work, I think I'm happy with what you have above.

Thanks Phil, I wanted to make sure I was not missing something obvious ;).

Maintainers, please consider v1 of this patch.

Thanks,
Matthew

#9 lore raw
Quoted 27 lines · On 11/08/2011 12:50 PM, McClintock Matthew-B29882 wrote:
Quoted 18 lines · Phil Blundell
Quoted 17 lines · On Tue, 2011-11-08 at 19:36 +0000, McClintock Matthew-B29882 wrote:
Quoted 15 lines · Matthew McClintock

I don't get it. I think the first version was still OK. The first version is pasted below.

meta/recipes-core/sysvinit/sysvinit-inittab_2.88dsf.bb do_install() { · line 37

Quoted 8 lines
meta/recipes-core/sysvinit/sysvinit-inittab_2.88dsf.bb +8 -0
+    idx=0
+    tmp="${SERIAL_CONSOLES}"<- If it's not defined this will catch it.
+    for i in $tmp
+    do
+     j=`echo ${i} | sed s/\;/\ /g`
+        echo "${idx}:2345:respawn:${base_sbindir}/getty ${j}">>  ${D}${sysconfdir}/inittab
+     idx=`expr $idx + 1`
+    done

See my inline comment above, but if SERIAL_CONSOLES is not defined tmp="" and the for loop won't execute. Not sure if there is a more standard way to do this though.

Quoted 7 lines
Quoted 1 line

ping..

Yeah, now I look at this again I think it is probably OK. Bitbake won't expand ${SERIAL_CONSOLES} if it's unset, but the shell will and I think you probably will get the right results. Assuming you've actually tested that case and it does work, I think I'm happy with what you have above.

Quoted 4 lines

Thanks Phil, I wanted to make sure I was not missing something obvious ;).

Maintainers, please consider v1 of this patch.

Just to follow up, this is now in my queue.

Sau!

Quoted 8 lines

Thanks,
Matthew

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

Applied
#11 lore raw
In reply to Matthew McClintock
Quoted 27 lines · Matthew McClintock

Just define additional serial consoles like so:

SERIAL_CONSOLES="115200;ttyS0 115200;ttyS1 ... 115200;ttySN"

Also be sure to remove SERIAL_CONSOLE (lacking the S) from your machine as they can conflict.

---
v2: handle case where SERIAL_CONSOLES is not defined

  .../sysvinit/sysvinit-inittab_2.88dsf.bb           |   12 ++++++++++++
  1 files changed, 12 insertions(+), 0 deletions(-)
meta/recipes-core/sysvinit/sysvinit-inittab_2.88dsf.bb +5 -0
index ba60c74..adab262 100644
@@ -25,6 +25,18 @@ do_install() {
      if [ ! -z "${SERIAL_CONSOLE}" ]; then
          echo "S:2345:respawn:${base_sbindir}/getty ${SERIAL_CONSOLE}">>  ${D}${sysconfdir}/inittab
      fi
+
+    idx=0
+    tmp="${SERIAL_CONSOLES}"
+    if [ "x" != "x$tmp" ]; then
+	for i in $tmp

meta/recipes-core/sysvinit/sysvinit-inittab_2.88dsf.bb do_install() { · line 42

Quoted 10 lines
meta/recipes-core/sysvinit/sysvinit-inittab_2.88dsf.bb +7 -0
+	do
+	    j=`echo ${i} | sed s/\;/\ /g`
+	    echo "${idx}:2345:respawn:${base_sbindir}/getty ${j}">>  ${D}${sysconfdir}/inittab
+	    idx=`expr $idx + 1`
+	done
+    fi
+
      if [ "${USE_VT}" = "1" ]; then
          cat<<EOF>>${D}${sysconfdir}/inittab
  # ${base_sbindir}/getty invocations for the runlevels.

Merged into OE-Core

Thanks
Sau!

#10 lore raw
In reply to McClintock Matthew-B29882
Quoted 21 lines · On Tue, Nov 8, 2011 at 1:50 PM, McClintock Matthew-B29882…
Quoted 20 lines · Phil Blundell
Quoted 18 lines · On Tue, 2011-11-08 at 19:36 +0000, McClintock Matthew-B29882 wrote:
Quoted 12 lines · Matthew McClintock

I don't get it. I think the first version was still OK. The first version is pasted below.

Quoted 8 lines

+    idx=0
+    tmp="${SERIAL_CONSOLES}" <- If it's not defined this will catch it.
+    for i in $tmp
+    do
+     j=echo ${i} | sed s/\;/\ /g
+        echo "${idx}:2345:respawn:${base_sbindir}/getty ${j}" >> ${D}${sysconfdir}/inittab
+     idx=expr $idx + 1
+    done

Quoted 3 lines

See my inline comment above, but if SERIAL_CONSOLES is not defined tmp="" and the for loop won't execute. Not sure if there is a more standard way to do this though.

ping..

Quoted 8 lines
Quoted 5 lines

Yeah, now I look at this again I think it is probably OK.  Bitbake won't expand ${SERIAL_CONSOLES} if it's unset, but the shell will and I think you probably will get the right results.  Assuming you've actually tested that case and it does work, I think I'm happy with what you have above.

Thanks Phil, I wanted to make sure I was not missing something obvious ;).

Note that one could always define SERIAL_CONSOLES ?= "" somewhere appropriate. Wouldn't hurt anything to define defaults for things we use. Maybe someday we can make referencing undefined variables raise an error rather than this whole 'if bitbake doesn't expand it, let the shell do it' behavior which is unintuitive. Not easily knowing when something will be evaluated is problematic.

Signature · 5 lines
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics