<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>7010</bug_id>
          
          <creation_ts>2014-12-02 13:42:59 +0000</creation_ts>
          <short_desc>systemd-serialgetty cannot create a serial-getty@.service that is not enabled</short_desc>
          <delta_ts>2022-01-07 20:38:33 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>7</classification_id>
          <classification>Build System, Metadata &amp; Runtime</classification>
          <product>OE-Core</product>
          <component>core</component>
          <version>1.7</version>
          <rep_platform>All</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WORKSFORME</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>3.3 M2</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Joe Balough">jbb5044</reporter>
          <assigned_to name="Joe Balough">jbb5044</assigned_to>
          <cc>liezhi.yang</cc>
    
    <cc>meta.mr.watcher</cc>
    
    <cc>meta.watcher</cc>
    
    <cc>randy.macleod</cc>
    
    <cc>sgw</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>Yes (doc changes required)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>47288</commentid>
    <comment_count>0</comment_count>
      <attachid>2270</attachid>
    <who name="Joe Balough">jbb5044</who>
    <bug_when>2014-12-02 13:42:59 +0000</bug_when>
    <thetext>Created attachment 2270
Patch to add support for creating serial-getty service files without enabling them

While setting up a commercial embedded system using yocto, we wanted the ability to start a serial-getty@.service unit when triggered with a special engineering-only mechanism, but not on a normal boot. We wanted the serial-getty@.service file to be created, but not enabled in systemd. Setting the SERIAL_CONSOLES line in the machine.conf to an empty string simply resulted in _no_ serial-getty@.service files being created. Looking at the systemd-serialgetty.bb file, I can see that the current do_install() does not have any means to specify only the bauderate of the serial port and not enable it by default.

I attached the solution I use. Allow the SERIAL_CONSOLES variable to be set to _just_ the bauderate. In systemd-serialgetty.bb, modify the sed command that extracts the serial port path so that it returns an empty string instead of the bauderate in this case, then add a simple if block to only enable the serial port if the serial path is not empty.

Attached patch is on top of the dizzy branch made with git format-patch.

If accepted, documentation for the SERIAL_CONSOLES would need to be updated.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>85443</commentid>
    <comment_count>1</comment_count>
    <who name="Chen Qi">Qi.Chen</who>
    <bug_when>2019-10-25 01:10:51 +0000</bug_when>
    <thetext>Does Jason&apos;s recent change to serialgetty solve such problem in another direction?

commit eddbd0c3145156559b9fe004508af6da27e379cb
Author: Jason Wessel &lt;jason.wessel@windriver.com&gt;
Date:   Thu Aug 29 07:00:31 2019 -0700

    serial-getty@.service: Allow device to fast fail if it does not exist
    
    Some BSPs use a USB serial port which may or may not actually be
    plugged all the time.  It is quite useful to have a USB serial port
    have a getty running but it does not make sense to wait for it for 90
    seconds before completing the system startup if it might never get
    plugged in.  The typical example is that a USB serial device might
    only need to be plugged in when debugging, upgrading, or initially
    configuring a device.
    
    This change is somewhat subtle.  Systemd uses the &quot;BindsTo&quot; directive
    to ensure existence of the device in order to start the service as
    well as to terminate the service if the device goes away.  The &quot;After&quot;
    directive makes that same relationship stronger.  When used together
    this has the undesired side effect that systemd will wait until its
    internal time out value of 90 seconds for the device to come on line
    before executing a fail operation or letting other tasks and groups
    continue.  This is certainly the kind of behavior we want for a disk,
    but not for serial ports in general.
    
    The &quot;BindsTo&quot; directive is replaced by the combination of the &quot;PartOf&quot;
    and the &quot;ConditionPathExists&quot; directives.  The &quot;After&quot; directive is
    unchanged because that will wait for the udev rules to process.  The
    &quot;PartOf&quot; directive will issue a stop to the getty service if the
    device goes away, similar to the &quot;BindsTo&quot; directive.  The
    &quot;ConditionPathExists&quot; is what allows the service to fail fast vs
    waiting for the timeout.  When a USB device is not plugged in at boot
    you would find a message in the system journal like:
    
        systemd[1]: Condition check resulted in Serial Getty on \
                     ttyUSB0 being skipped.
    
    If you want to observe the problem with qemu, it is easy to replicate.
    Simply add the following line to your local.conf for a x86-64 qemu
    build.
    
        SERIAL_CONSOLES=&quot;115200;ttyS0 115200;ttyUSB0&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88495</commentid>
    <comment_count>2</comment_count>
    <who name="Chen Qi">Qi.Chen</who>
    <bug_when>2020-10-27 00:32:45 +0000</bug_when>
    <thetext>
(In reply to comment #0)
&gt; Created attachment 2270 [details]
&gt; Patch to add support for creating serial-getty service files without
&gt; enabling them
&gt; 
&gt; While setting up a commercial embedded system using yocto, we wanted the
&gt; ability to start a serial-getty@.service unit when triggered with a special
&gt; engineering-only mechanism, but not on a normal boot. We wanted the
&gt; serial-getty@.service file to be created, but not enabled in systemd.
&gt; Setting the SERIAL_CONSOLES line in the machine.conf to an empty string
&gt; simply resulted in _no_ serial-getty@.service files being created. Looking
&gt; at the systemd-serialgetty.bb file, I can see that the current do_install()
&gt; does not have any means to specify only the bauderate of the serial port and
&gt; not enable it by default.
&gt; 
&gt; I attached the solution I use. Allow the SERIAL_CONSOLES variable to be set
&gt; to _just_ the bauderate. In systemd-serialgetty.bb, modify the sed command
&gt; that extracts the serial port path so that it returns an empty string
&gt; instead of the bauderate in this case, then add a simple if block to only
&gt; enable the serial port if the serial path is not empty.
&gt; 
&gt; Attached patch is on top of the dizzy branch made with git format-patch.
&gt; 
&gt; If accepted, documentation for the SERIAL_CONSOLES would need to be updated.

Hi Joe,

Please check if Jason&apos;s patch would solve your problem in another direction.
If not, you can send out patch to oe-core mailing list.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88497</commentid>
    <comment_count>3</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2020-10-27 07:58:59 +0000</bug_when>
    <thetext>Joe, Please comment on Jason&apos;s patch.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88656</commentid>
    <comment_count>4</comment_count>
    <who name="Joe Balough">jbb5044</who>
    <bug_when>2020-11-21 16:12:09 +0000</bug_when>
    <thetext>I unfortunately do not use Yocto on a day-to-day basis so this bug no longer affects me. Jason&apos;s patch would work for me.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>2270</attachid>
            <date>2014-12-02 13:42:59 +0000</date>
            <delta_ts>2014-12-02 13:42:59 +0000</delta_ts>
            <desc>Patch to add support for creating serial-getty service files without enabling them</desc>
            <filename>0001-systemd-serialgetty.bb-Allow-non-enabled-serial-gett.patch</filename>
            <type>text/plain</type>
            <size>3009</size>
            <attacher name="Joe Balough">jbb5044</attacher>
            
              <data encoding="base64">RnJvbSAwYjcxMTFlNjM4M2EzNjEzZDY3ZTc5YmQzYmIxNGVkMDI0YzFhYzk4IE1vbiBTZXAgMTcg
MDA6MDA6MDAgMjAwMQpGcm9tOiBKb2UgQmFsb3VnaCA8amJiNTA0NEBnbWFpbC5jb20+CkRhdGU6
IFR1ZSwgMiBEZWMgMjAxNCAwODozNjo1MyAtMDUwMApTdWJqZWN0OiBbUEFUQ0hdIHN5c3RlbWQt
c2VyaWFsZ2V0dHkuYmI6IEFsbG93IG5vbi1lbmFibGVkCiBzZXJpYWwtZ2V0dHlALnNlcnZpY2Ug
ZmlsZXMKClByZXZpb3VzIGltcGxlbWVudGF0aW9uIGF1dG9tYXRpY2FsbHkgZW5hYmxlZCBhbGwg
c2VyaWFsLWdldHR5QC5zZXJ2aWNlCmZpbGVzIGFzIHNwZWNpZmllZCBpbiB0aGUgU0VSSUFMX0NP
TlNPTEUgdmFyaWFibGUgd2l0aCBubyB3YXkgdG8gc2ltcGx5C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