Skip to content

Conversation

@sever-sever
Copy link
Member

@sever-sever sever-sever commented Dec 24, 2025

Change summary

Add support AMA console for ARM devices

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes)
  • Migration from an old Vyatta component to vyos-1x, please link to related PR inside obsoleted component
  • Other (please describe):

Related Task(s)

Related PR(s)

How to test / Smoketest result

DEBUG - Welcome to VyOS - vyos ttyAMA0
DEBUG - 
DEBUG - vyos login: vyos
DEBUG - vyos
DEBUG - Password: vyos
DEBUG - 
DEBUG - Welcome to VyOS!
DEBUG - 
DEBUG -    ┌── ┐
DEBUG -    . VyOS 999.202512241417
DEBUG -    └ ──┘  current
DEBUG - 
DEBUG -  * Documentation:  https://docs.vyos.io/en/latest
DEBUG -  * Project news:   https://blog.vyos.io/
DEBUG -  * Bug reports:    https://vyos.dev/
DEBUG - 
DEBUG - You can change this banner using "set system login banner post-login" command.
DEBUG - 
DEBUG - VyOS is a free software distribution that includes multiple components,
DEBUG - you can check individual component licenses under /usr/share/doc/*/copyright
DEBUG - 
DEBUG - ---
DEBUG - WARNING: This VyOS system is not a stable long-term support version and
DEBUG -          is not intended for production use.
DEBUG - 
 INFO - Logged in!
DEBUG - vyos@vyos:~$ sudo modprobe mac80211_hwsim
DEBUG - sudo modprobe mac80211_hwsim
DEBUG - vyos@vyos:~$ touch /tmp/vyos.smoketests.hint
DEBUG - touch /tmp/vyos.smoketests.hint
DEBUG - vyos@vyos:~$ sudo systemctl restart vyos-configd.service &> /dev/null
DEBUG - sudo systemctl restart vyos-configd.service &> /dev/null
 INFO - Basic CLI configuration mode test
DEBUG - vyos@vyos:~$ configure
DEBUG - configure
DEBUG - [edit]
DEBUG - vyos@vyos# exit
DEBUG - exit
DEBUG - exit
DEBUG - vyos@vyos:~$ show version
DEBUG - show version
DEBUG - 
Version:          VyOS 999.202512241417
DEBUG - Release train:    current
DEBUG - Release flavor:   generic-arm64
DEBUG - 
DEBUG - Built by:         root@0bc660be4ca6
DEBUG - qemu
ERROR - Timeout waiting for VyOS system
ERROR - Traceback (most recent call last):
  File "/__w/vyos-build-arm64/vyos-build-arm64/vyos-build/scripts/check-qemu-install", line 626, in <module>
    c.expect('kvm')
  File "/usr/lib/python3/dist-packages/pexpect/spawnbase.py", line 343, in expect
    return self.expect_list(compiled_pattern_list,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/pexpect/spawnbase.py", line 372, in expect_list
    return exp.expect_loop(timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/pexpect/expect.py", line 181, in expect_loop
    return self.timeout(e)
           ^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/pexpect/expect.py", line 144, in timeout
    raise exc
pexpect.exceptions.TIMEOUT: Timeout exceeded.
<pexpect.pty_spawn.spawn object at 0xff4ed322e1d0>
command: /usr/bin/qemu-system-aarch64
args: ['/usr/bin/qemu-system-aarch64', '-name', 'VyOS-QEMU-UEFI', '-smp', '2,sockets=1,cores=2,threads=1', '-cpu', 'cortex-a53', '-machine', 'virt', '-bios', '/usr/share/qemu-efi-aarch64/QEMU_EFI.fd', '-m', '2G', '-vga', 'none', '-nographic', '-vga', 'none', '-uuid', 'f48b60b2-e6ad-49ef-9d09-4245d0585e52', '-monitor', 'unix:/tmp/qemu-monitor-socket-testinstall-20251224-142546-74cc.img,server,nowait', '-netdev', 'user,id=n0,net=192.0.2.0/24,dhcpstart=192.0.2.101,dns=192.0.2.10', '-device', 'virtio-net-pci,netdev=n0,mac=00:00:5E:00:53:00,romfile=,host_mtu=1500', '-netdev', 'user,id=n1', '-device', 'virtio-net-pci,netdev=n1,mac=00:00:5E:00:53:01,romfile=,host_mtu=1500', '-netdev', 'user,id=n2', '-device', 'virtio-net-pci,netdev=n2,mac=00:00:5E:00:53:02,romfile=,host_mtu=1500', '-netdev', 'user,id=n3', '-device', 'virtio-net-pci,netdev=n3,mac=00:00:5E:00:53:03,romfile=,host_mtu=1500', '-netdev', 'user,id=n4', '-device', 'virtio-net-pci,netdev=n4,mac=00:00:5E:00:53:04,romfile=', '-netdev', 'user,id=n5', '-device',
buffer (last 100 chars): b' systemd-detect-virt\r\r\nqemu\r\r\nvyos@vyos:~$ '
before (last 100 chars): b' systemd-detect-virt\r\r\nqemu\r\r\nvyos@vyos:~$ '
after: <class 'pexpect.exceptions.TIMEOUT'>
match: None
match_index: None
exitstatus: None
flag_eof: False
pid: 105249
child_fd: 5
closed: False
timeout: 60
delimiter: <class 'pexpect.exceptions.EOF'>
logfile: <__main__.StreamToLogger object at 0xff4ed32496d0>
logfile_read: None
logfile_send: None
maxread: 2000
ignorecase: False
searchwindowsize: None
delaybeforesend: 0.05
delayafterclose: 0.1
delayafterterminate: 0.1
searcher: searcher_re:
    0: re.compile(b'kvm')
 INFO - Cleaning up
 INFO - Removing disk file: testinstall-20251224-142546-74cc.img
ERROR - Hmm... system got an exception while processing.
ERROR - The ISO image is not considered usable!
Error: Process completed with exit code 1.

Checklist:

  • I have read the CONTRIBUTING document
  • I have linked this PR to one or more Phabricator Task(s)
  • I have run the components SMOKETESTS if applicable
  • My commit headlines contain a valid Task id
  • My change requires a change to the documentation
  • I have updated the documentation accordingly

@sever-sever sever-sever requested review from c-po and jestabro December 24, 2025 13:37
@github-actions
Copy link

github-actions bot commented Dec 24, 2025

👍
No issues in PR Title / Commit Title

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for ARM Advanced Microcontroller Bus Architecture (AMBA) PL011 serial console devices (ttyAMA) to VyOS, extending the existing console options beyond KVM (graphical) and standard serial (ttyS) consoles.

Key Changes:

  • Adds 'A' (ARM serial) as a console type option during image installation
  • Extends GRUB configuration to support ttyAMA console devices
  • Updates system console XML schema to validate ttyAMA device names

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/op_mode/image_installer.py Adds 'A' option for ARM serial console selection and ttyAMA0 detection in console_hint() function
interface-definitions/system_console.xml.in Adds ttyAMA validation pattern and documentation for ARM serial ports
data/templates/grub/grub_vyos_version.j2 Adds conditional logic for ttyAMA console options in kernel command line
data/templates/grub/grub_options.j2 Adds ttyAMA menu entry in GRUB boot options
data/templates/grub/grub_compat.j2 Adds console name and options macros for ARM serial console compatibility
data/templates/grub/grub_common.j2 Implements serial_pl011 initialization for ARM UART devices

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

data/templates/grub/grub_compat.j2:47

  • The serial port initialization section (lines 39-47) does not handle ttyAMA console type. While ttyAMA is handled in the console_name and console_opts macros, this section that sets up the GRUB serial console is missing a case for ttyAMA. This should include a check for console_type == 'ttyAMA' similar to the existing ttyS handling to ensure proper serial port initialization.
{% if console_type == 'ttyS' %}
{%     if console_num == '0' %}
serial --unit=0 --speed={{ console_speed }}
{%     else %}
serial --unit={{ console_num }} --speed=115200
{%     endif %}
{% else %}
serial --unit=0 --speed={{ console_speed }}
{% endif %}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (3)

src/system/grub_update.py:89

  • The arch template variable is added to vars but not passed to the grub_options template. Change the empty dict {} to vars so the architecture information is available in the template: render(grub_cfg_options, grub.TMPL_GRUB_OPTS, vars)
    render(grub_cfg_options, grub.TMPL_GRUB_OPTS, {})

interface-definitions/system_console.xml.in:15

  • The completion script should be updated to include ttyAMA devices: <script>ls -1 /dev | grep -e ttyS -e ttyAMA -e hvc</script>
                <script>ls -1 /dev | grep -e ttyS -e hvc</script>

interface-definitions/system_console.xml.in:21

  • Add a valueHelp entry for ttyAMA devices to provide documentation for users. Insert after line 21: <valueHelp><format>ttyAMAN</format><description>ARM Advanced AMBA serial port</description></valueHelp>
              <valueHelp>
                <format>ttySN</format>
                <description>TTY device name, regular serial port</description>
              </valueHelp>

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (1)

data/templates/grub/grub_options.j2:49

  • The GRUB menuentry "Enter console number" reads console_num directly from the user and then passes it to setup_serial and later into the kernel boot options without validation. By entering a value containing shell metacharacters or additional arguments (e.g. 0; linux /boot/vmlinuz init=/bin/sh; boot or 0 init=/bin/sh), an attacker with boot-console access can inject arbitrary GRUB commands or kernel parameters and boot into a root shell bypassing normal authentication. Restrict console_num to a strict numeric pattern (digits only) and/or sanitize it before using it in GRUB commands and when constructing console_opts.
        read console_num
        export console_num
        setup_serial

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@zdc zdc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should find all places where we have a call to set_console_type(), and add S/AMA detection there.

They seem to be:

Also add AMA here: https://github.com/vyos/vyos-1x/blob/current/src/op_mode/image_manager.py#L36

Comment on lines 30 to 44
{% if arch == 'aarch64' %}
menuentry "ttyAMA (serial)" {
set console_type="ttyAMA"
export console_type
setup_serial
configfile ${prefix}/grub.cfg.d/*vyos-menu*.cfg
}
{% else %}
menuentry "ttyS (serial)" {
set console_type="ttyS"
export console_type
setup_serial
configfile ${prefix}/grub.cfg.d/*vyos-menu*.cfg
}
{% endif %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to branch the whole section? The difference is only in two lines.

And, actually, I want to offer considering renaming options to simply Graphical and Serial. Then, there will be no need to add any logic here at all. Instead, I would recommend considering using https://www.gnu.org/software/grub/manual/grub/html_node/grub_005fcpu.html to find a proper console name.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, re-check please

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

data/templates/grub/grub_compat.j2:47

  • The serial console setup only checks for 'ttyS' but should also handle 'ttyAMA' to properly configure serial console parameters for ARM devices. The condition should be {% if console_type == 'ttyS' or console_type == 'ttyAMA' %} to match the pattern used in other updated templates.
{% if console_type == 'ttyS' %}
{%     if console_num == '0' %}
serial --unit=0 --speed={{ console_speed }}
{%     else %}
serial --unit={{ console_num }} --speed=115200
{%     endif %}
{% else %}
serial --unit=0 --speed={{ console_speed }}
{% endif %}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@sever-sever sever-sever requested a review from zdc January 20, 2026 11:00
Copy link
Member

@c-po c-po left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All requested changes and CoPilot findings adressed.

Not manually tested but implementarion looks good to go!

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

menuentry "{{ version_name }}" --id {{ version_uuid }} {
set boot_opts="{{ boot_opts_rendered }}"
if [ "${console_type}" == "ttyS" ]; then
if [ "${console_type}" = "ttyS" -o "${console_type}" = "ttyAMA" ]; then
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent operator usage in GRUB shell script. The code mixes '==' (line 11, 20, 23, 25) and '=' (line 14) for string comparisons. While both work in GRUB, consider using '==' consistently throughout the file for better code consistency. The existing code already uses '==' for similar string comparisons.

Suggested change
if [ "${console_type}" = "ttyS" -o "${console_type}" = "ttyAMA" ]; then
if [ "${console_type}" == "ttyS" -o "${console_type}" == "ttyAMA" ]; then

Copilot uses AI. Check for mistakes.
Comment on lines 30 to +36
menuentry "ttyS (serial)" {
set console_type="ttyS"
if [ "${grub_cpu}" = "arm64" ]; then
set serial_console="ttyAMA"
else
set serial_console="ttyS"
fi
set console_type="$serial_console"
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The menu entry label "ttyS (serial)" is misleading on ARM platforms where it actually sets the console to "ttyAMA". Consider updating the label to be more generic, such as "Serial console" or making it architecture-aware to improve user clarity.

Copilot uses AI. Check for mistakes.
@github-actions
Copy link

CI integration 👍 passed!

Details

CI logs

  • CLI Smoketests 👍 passed
  • CLI Smoketests (interfaces only) 👍 passed
  • Config tests 👍 passed
  • RAID1 tests 👍 passed
  • CLI Smoketests VPP 👍 passed
  • Config tests VPP 👍 passed
  • TPM tests 👍 passed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

3 participants