Skip to contentSkip to conversation

use single variable to set baud rate

PATCH In review Chong Lu 1 participant 5 messages Dec 10, 2014 – Dec 19, 2014

lore
Share & tools
lore

Chong Lu

author
#0 lore raw

v3 cover use single variable to set baud rate

Change since V2:
don't change SERIAL_CONSOLE default value and add console.bbclass to get port, tty and baud rate from SERIAL_CONSOLE.

The following changes since commit ec6377bcf52d105cd23ac6bbbeddd38fee9337e4:

bitbake: bitbake-user-manual-metadata.xml: Updated do_package_write example (2014-12-09 22:25:36 +0000)

are available in the git repository at:

git://git.pokylinux.org/poky-contrib chonglu/baudrate
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=chonglu/baudrate

Chong Lu (3):
console.bbclass: add class which can be used to set serial console and
baud rate
syslinux.bbclass: use single variable to set baud rate grub-efi.bbclass: use single variable to set baud rate

 meta/classes/console.bbclass  | 23 +++++++++++++++++++++++
 meta/classes/grub-efi.bbclass |  5 +++--
 meta/classes/syslinux.bbclass |  5 +++--
 3 files changed, 29 insertions(+), 4 deletions(-)
 create mode 100644 meta/classes/console.bbclass
Signature · 1 line
1.9.1
author
#1 lore raw

PATCH v3 1/3 console.bbclass: add class which can be used to set serial console and baud rate

Use a single method set serial console and baud rate by SERIAL_CONSOLE variable. Defind three function, we can get port, tty and baud rate of the console. they can be used by syslinux, grub, qemu and so on.

[YOCTO #6331]

---
 meta/classes/console.bbclass | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
 create mode 100644 meta/classes/console.bbclass
meta/classes/console.bbclass new file +23 -0
new file mode 100644
index 0000000..b01ffef
@@ -0,0 +1,23 @@
+def console_tty(d):
+    serial_console = d.getVar('SERIAL_CONSOLE', True).split()
+    if serial_console:
+        tty = d.getVar('SERIAL_CONSOLE', True).split()[1]
+    else:
+        tty = "ttyS0"
+    return tty
+
+def console_baudrate(d):
+    serial_console = d.getVar('SERIAL_CONSOLE', True).split()
+    if serial_console:
+        baudrate = d.getVar('SERIAL_CONSOLE', True).split()[0]
+    else:
+        baudrate = "115200"
+    return baudrate
+
+def console_port(d):
+    serial_console = d.getVar('SERIAL_CONSOLE', True).split()
+    if serial_console:
+        port = filter(str.isdigit, d.getVar('SERIAL_CONSOLE', True).split()[1])
+    else:
+        port = "0"
+    return port
Signature · 1 line
1.9.1
author
#2 lore raw

PATCH v3 2/3 syslinux.bbclass: use single variable to set baud rate

In reply to Chong Lu

Use SERIAL_CONSOLE to set baud rate in syslinux.cfg file.

[YOCTO #6331]

---
 meta/classes/syslinux.bbclass | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
meta/classes/syslinux.bbclass +3 -2
index d6498d9..8629bb1 100644
@@ -26,9 +26,10 @@ ISOLINUXDIR = "/isolinux"
 SYSLINUXDIR = "/"
 # The kernel has an internal default console, which you can override with
 # a console=...some_tty...
+inherit console
 SYSLINUX_DEFAULT_CONSOLE ?= ""
-SYSLINUX_SERIAL ?= "0 115200"
-SYSLINUX_SERIAL_TTY ?= "console=ttyS0,115200"
+SYSLINUX_SERIAL ?= "${@console_port(d)} ${@console_baudrate(d)}"
+SYSLINUX_SERIAL_TTY ?= "console=${@console_tty(d)},${@console_baudrate(d)}"
 ISO_BOOTIMG = "isolinux/isolinux.bin"
 ISO_BOOTCAT = "isolinux/boot.cat"
 MKISOFS_OPTIONS = "-no-emul-boot -boot-load-size 4 -boot-info-table"
Signature · 1 line
1.9.1
author
#3 lore raw

PATCH v3 3/3 grub-efi.bbclass: use single variable to set baud rate

In reply to Chong Lu

Use SERIAL_CONSOLE to set baud rate in grub.cfg file.

[YOCTO #6331]

---
 meta/classes/grub-efi.bbclass | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
meta/classes/grub-efi.bbclass +3 -2
index 47bd35e..18ae261 100644
@@ -18,11 +18,12 @@
 do_bootimg[depends] += "${MLPREFIX}grub-efi:do_deploy"
 do_bootdirectdisk[depends] += "${MLPREFIX}grub-efi:do_deploy"
 
-GRUB_SERIAL ?= "console=ttyS0,115200"
+inherit console
+GRUB_SERIAL ?= "console=${@console_tty(d)},${@console_baudrate(d)}"
 GRUBCFG = "${S}/grub.cfg"
 GRUB_TIMEOUT ?= "10"
 #FIXME: build this from the machine config
-GRUB_OPTS ?= "serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1"
+GRUB_OPTS ?= "serial --unit=${@console_port(d)} --speed=${@console_baudrate(d)} --word=8 --parity=no --stop=1"
 
 EFIDIR = "/EFI/BOOT"
 
Signature · 1 line
1.9.1
author
#4 lore raw
In reply to Chong Lu

ping

Quoted 25 lines · Chong Lu

Change since V2:
don't change SERIAL_CONSOLE default value and add console.bbclass to get port, tty and baud rate from SERIAL_CONSOLE.

The following changes since commit ec6377bcf52d105cd23ac6bbbeddd38fee9337e4:

   bitbake: bitbake-user-manual-metadata.xml: Updated do_package_write example (2014-12-09 22:25:36 +0000)

are available in the git repository at:

git://git.pokylinux.org/poky-contrib chonglu/baudrate
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=chonglu/baudrate

Chong Lu (3):
console.bbclass: add class which can be used to set serial console and
baud rate
syslinux.bbclass: use single variable to set baud rate grub-efi.bbclass: use single variable to set baud rate

  meta/classes/console.bbclass  | 23 +++++++++++++++++++++++
  meta/classes/grub-efi.bbclass |  5 +++--
  meta/classes/syslinux.bbclass |  5 +++--
  3 files changed, 29 insertions(+), 4 deletions(-)

create mode 100644 meta/classes/console.bbclass