How can I halt a boot over serial when a prompt is displayed?












0














I have a computer that I'm connected to via serial. I want to stop it as it boots up as part of a bash script. The computer issues a prompt along with a short time window to push a key to halt the boot process and go to a uboot command line.



My current solution is to read lines from the serial device and stop reading when the prompt is displayed. I then echo a single character to the device like this.



prompt="any key to stop autoboot"
prompted=false
fline=""
while [ "$prompted" == "false" ] && read fline
do
echo $fline
if [[ "$fline" =~ "$prompt" ]]
then
prompted=true
fi
done < /dev/ttyUSB0

echo a > /dev/ttyUSB0


But when I use minicom to serial back in, I am unable to see the prompt or issue commands, and the computer boots anyway. I know the loop ends when the prompt is displayed as well, as the prompt is the last line displayed. If I start the whole process from a minicom terminal and respond to the prompt manually, then the boot stops and I can see the prompt and issue commands.



I have a workaround via the following code, but this isn't a very precise solution.



# start computer, then do
for i in `seq 1 1000`
do
echo hi > /dev/ttyUSB0
usleep 10000
done


But upon completion I can use minicom to see the uboot prompt and issue commands. I can also issue commands by echoing bytes to the serial device, and their results appear in my minicom session. So this approach proves I can halt the boot by echoing bytes to the serial device.



So how can I stop the boot when the prompt is displayed?









share



























    0














    I have a computer that I'm connected to via serial. I want to stop it as it boots up as part of a bash script. The computer issues a prompt along with a short time window to push a key to halt the boot process and go to a uboot command line.



    My current solution is to read lines from the serial device and stop reading when the prompt is displayed. I then echo a single character to the device like this.



    prompt="any key to stop autoboot"
    prompted=false
    fline=""
    while [ "$prompted" == "false" ] && read fline
    do
    echo $fline
    if [[ "$fline" =~ "$prompt" ]]
    then
    prompted=true
    fi
    done < /dev/ttyUSB0

    echo a > /dev/ttyUSB0


    But when I use minicom to serial back in, I am unable to see the prompt or issue commands, and the computer boots anyway. I know the loop ends when the prompt is displayed as well, as the prompt is the last line displayed. If I start the whole process from a minicom terminal and respond to the prompt manually, then the boot stops and I can see the prompt and issue commands.



    I have a workaround via the following code, but this isn't a very precise solution.



    # start computer, then do
    for i in `seq 1 1000`
    do
    echo hi > /dev/ttyUSB0
    usleep 10000
    done


    But upon completion I can use minicom to see the uboot prompt and issue commands. I can also issue commands by echoing bytes to the serial device, and their results appear in my minicom session. So this approach proves I can halt the boot by echoing bytes to the serial device.



    So how can I stop the boot when the prompt is displayed?









    share

























      0












      0








      0







      I have a computer that I'm connected to via serial. I want to stop it as it boots up as part of a bash script. The computer issues a prompt along with a short time window to push a key to halt the boot process and go to a uboot command line.



      My current solution is to read lines from the serial device and stop reading when the prompt is displayed. I then echo a single character to the device like this.



      prompt="any key to stop autoboot"
      prompted=false
      fline=""
      while [ "$prompted" == "false" ] && read fline
      do
      echo $fline
      if [[ "$fline" =~ "$prompt" ]]
      then
      prompted=true
      fi
      done < /dev/ttyUSB0

      echo a > /dev/ttyUSB0


      But when I use minicom to serial back in, I am unable to see the prompt or issue commands, and the computer boots anyway. I know the loop ends when the prompt is displayed as well, as the prompt is the last line displayed. If I start the whole process from a minicom terminal and respond to the prompt manually, then the boot stops and I can see the prompt and issue commands.



      I have a workaround via the following code, but this isn't a very precise solution.



      # start computer, then do
      for i in `seq 1 1000`
      do
      echo hi > /dev/ttyUSB0
      usleep 10000
      done


      But upon completion I can use minicom to see the uboot prompt and issue commands. I can also issue commands by echoing bytes to the serial device, and their results appear in my minicom session. So this approach proves I can halt the boot by echoing bytes to the serial device.



      So how can I stop the boot when the prompt is displayed?









      share













      I have a computer that I'm connected to via serial. I want to stop it as it boots up as part of a bash script. The computer issues a prompt along with a short time window to push a key to halt the boot process and go to a uboot command line.



      My current solution is to read lines from the serial device and stop reading when the prompt is displayed. I then echo a single character to the device like this.



      prompt="any key to stop autoboot"
      prompted=false
      fline=""
      while [ "$prompted" == "false" ] && read fline
      do
      echo $fline
      if [[ "$fline" =~ "$prompt" ]]
      then
      prompted=true
      fi
      done < /dev/ttyUSB0

      echo a > /dev/ttyUSB0


      But when I use minicom to serial back in, I am unable to see the prompt or issue commands, and the computer boots anyway. I know the loop ends when the prompt is displayed as well, as the prompt is the last line displayed. If I start the whole process from a minicom terminal and respond to the prompt manually, then the boot stops and I can see the prompt and issue commands.



      I have a workaround via the following code, but this isn't a very precise solution.



      # start computer, then do
      for i in `seq 1 1000`
      do
      echo hi > /dev/ttyUSB0
      usleep 10000
      done


      But upon completion I can use minicom to see the uboot prompt and issue commands. I can also issue commands by echoing bytes to the serial device, and their results appear in my minicom session. So this approach proves I can halt the boot by echoing bytes to the serial device.



      So how can I stop the boot when the prompt is displayed?







      serial-console minicom





      share












      share










      share



      share










      asked 2 mins ago









      DeepDeadpool

      275211




      275211



























          active

          oldest

          votes











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "106"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f491070%2fhow-can-i-halt-a-boot-over-serial-when-a-prompt-is-displayed%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Unix & Linux Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f491070%2fhow-can-i-halt-a-boot-over-serial-when-a-prompt-is-displayed%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Accessing regular linux commands in Huawei's Dopra Linux

          Can't connect RFCOMM socket: Host is down

          Kernel panic - not syncing: Fatal Exception in Interrupt