{% extends 'base.jinja2' %}

# This imx6guf device class uses the u-boot boot strategy, even though the
# devices do not use u-boot as a bootloader. Future changes of the u-boot
# strategy might lead to problems concerning this workaround.
# Furthermore we don't use the deployment action but install the OS during the
# bootloader action instead. This might cause problems in the future as well.

# Default values for devices connected via UDO
{% if udo_ip_address %}
  {% set connection_command = connection_command|default('udo ' + udo_ip_address + ' console') %}
  {% set power_on_command = power_on_command|default('udo ' + udo_ip_address + ' on') %}
  {% set power_off_command = power_off_command|default('udo ' + udo_ip_address + ' off') %}
  {% set hard_reset_command = hard_reset_command|default(power_off_command + '; sleep 1; ' + power_on_command) %}
{% endif %}

# Copy of the constants block from the base class in order to overwrite error messages
{% block constants %}
constants:
  u-boot:
    interrupt-prompt: ' '
    interrupt-character: ' '
    error-messages:
      - 'syntax error: '
      - 'ERROR: '
    final-message: 'Restarting system.'
  shutdown-message: '{{ shutdown_message | default("The system is going down for reboot NOW") }}'
  kernel-start-message: '{{ kernel_start_message | default('Linux version [0-9]') }}'
  default-shell-prompt: '{{ default_shell_prompt | default("lava-test: # ") }}'
{% endblock constants -%}

{% block body %}
device_type: {{ device_type|default('imx6guf') }}

actions:
  deploy:
    connections:
      lxc:
      serial:
    methods:
      lxc:
      tftp:
      ssh:
        options:
{{ ssh_options }}
        host: {{ ssh_host|default('') }}
        port: {{ ssh_port|default(22) }}
        user: {{ ssh_user|default('root') }}
        identity_file: {{ ssh_identity_file }}

  boot:
    connections:
      lxc:
      serial:
    methods:
      minimal:
      ssh:
      u-boot:
        parameters:
          bootloader_prompt: {{ bootloader_prompt|default('FLASH-N-GO:/') }}
          needs_interrupt: False
        # This command sequence installs an OS using the FNG install script
        # provided in the variable "fng_install_url".
        fng-install:
          commands:
          - udhcpc
          - FNGINSTALL={{ fng_install_url }}
          - export TFTP=$(dirname $FNGINSTALL)
          - curl ${FNGINSTALL} | sh -s -- {{ fng_install_args|default('') }}
          - bootselect oneshot
          - reboot
        # This command sequence does not install an OS, but boots an existing
        # one from the eMMC instead.
        preinstalled:
          commands:
          - bootselect oneshot
          - reboot
{% endblock body %}
