base-uboot.jinja2 9.68 KB
Newer Older
Matt Hart's avatar
Matt Hart committed
1
2
{% extends 'base.jinja2' %}

Matt Hart's avatar
Matt Hart committed
3
{% set base_high_limits = base_high_limits|default(true) %}
4
5
6
7
8
9
10
11
12
13
{% set base_uboot_commands = ["setenv autoload no"] -%}
{% set base_uboot_high_limits = [
    "setenv initrd_high " + uboot_initrd_high|default('0xffffffff'),
    "setenv fdt_high "    + uboot_fdt_high|default('0xffffffff')]
-%}

{% set base_uboot_dhcp_command = [
    uboot_ipaddr_cmd|default('dhcp'),
    "setenv serverip {SERVER_IP}" ]
-%}
Matt Hart's avatar
Matt Hart committed
14

15
{% if append_dtb %}
16
  {% set uboot_load_fdt = [] %}
17
{% else %}
18
  {% set uboot_load_fdt = [uboot_load_fdt|default("tftp {DTB_ADDR} {DTB}")] %}
19
20
{% endif %}

21
22
23
24
25
{% set base_uboot_tftp_commands = uboot_tftp_commands|default([
    "tftp {KERNEL_ADDR} {KERNEL}",
    "tftp {RAMDISK_ADDR} {RAMDISK}",
    "setenv initrd_size ${filesize}"] + uboot_load_fdt)
-%}
Matt Hart's avatar
Matt Hart committed
26

27
{% set base_uboot_bootcmd = uboot_bootcmd|default(uboot_bootx_cmd|default('{BOOTX}')) -%}
Matt Hart's avatar
Matt Hart committed
28

29
30
31
32
33
34
{% set base_uboot_nbd_bootcmd = [
    "setenv loadnbd 'setenv serverip {SERVER_IP}; run loadkernel; run loadfdt; run loadinitrd';",
    "setenv verify no"
    "setenv bootcmd 'dhcp; run loadnbd; printenv; {BOOTX}'"
    "run bootcmd"]
-%}
Matt Hart's avatar
Matt Hart committed
35

36
{% set base_uboot_usb_commands = uboot_usb_commands|default(["usb start"]) -%}
Matt Hart's avatar
Matt Hart committed
37
38
39
40
41

{% set uboot_needs_usb = uboot_needs_usb|default(false) %}

{% set usb_uuid = usb_uuid|default('') %}
{% set usb_device_id = usb_device_id|default(0) %}
Matt Hart's avatar
Matt Hart committed
42

Dave Pigott's avatar
Dave Pigott committed
43
{% set uboot_mac_addr = uboot_mac_addr|default('') %}
44
45
{% set base_uboot_set_mac = ["setenv ethaddr"] -%}
{% if uboot_mac_addr %}
46
  {% set base_uboot_set_mac = ["setenv ethaddr " + uboot_mac_addr] -%}
47
{% endif %}
Dave Pigott's avatar
Dave Pigott committed
48
49
50

{% set uboot_set_mac = uboot_set_mac|default(false) %}

51
52
{% set uboot_common_cmds = [] %}
{% if uboot_needs_usb %}
53
  {% set uboot_common_cmds = uboot_common_cmds + base_uboot_usb_commands %}
54
55
56
{% endif %}
{% set uboot_common_cmds = uboot_common_cmds + base_uboot_commands %}
{% if base_high_limits %}
57
  {% set uboot_common_cmds = uboot_common_cmds + base_uboot_high_limits %}
58
59
{% endif %}
{% if uboot_set_mac %}
60
  {% set uboot_common_cmds = uboot_common_cmds + base_uboot_set_mac %}
61
62
63
{% endif %}
{% set uboot_common_cmds = uboot_common_cmds + base_uboot_dhcp_command  + base_uboot_tftp_commands %}

Matt Hart's avatar
Matt Hart committed
64
65
{# adds the parameters: top level block #}
{% block vland %}
66
{{ super() }}
Matt Hart's avatar
Matt Hart committed
67
{% if text_offset %}
68
  text_offset: '{{text_offset}}'
Matt Hart's avatar
Matt Hart committed
69
70
{% endif %}
{% if booti_kernel_addr %}
Matt Hart's avatar
Matt Hart committed
71
  image:
Matt Hart's avatar
Matt Hart committed
72
73
74
75
76
77
78
79
80
    kernel: '{{ booti_kernel_addr|default('0x80000000') }}'
    ramdisk: '{{ booti_ramdisk_addr|default('0x82000000') }}'
    dtb: '{{ booti_dtb_addr|default('0x81000000') }}'
  booti:
    kernel: '{{ booti_kernel_addr|default('0x80000000') }}'
    ramdisk: '{{ booti_ramdisk_addr|default('0x82000000') }}'
    dtb: '{{ booti_dtb_addr|default('0x81000000') }}'
{% endif %}
{% if bootm_kernel_addr %}
Matt Hart's avatar
Matt Hart committed
81
  uimage:
Matt Hart's avatar
Matt Hart committed
82
83
84
85
86
87
88
89
90
    kernel: '{{ bootm_kernel_addr|default('0x80000000') }}'
    ramdisk: '{{ bootm_ramdisk_addr|default('0x82000000') }}'
    dtb: '{{ bootm_dtb_addr|default('0x81000000') }}'
  bootm:
    kernel: '{{ bootm_kernel_addr|default('0x80000000') }}'
    ramdisk: '{{ bootm_ramdisk_addr|default('0x82000000') }}'
    dtb: '{{ bootm_dtb_addr|default('0x81000000') }}'
{% endif %}
{% if bootz_kernel_addr %}
Matt Hart's avatar
Matt Hart committed
91
  zimage:
Matt Hart's avatar
Matt Hart committed
92
93
94
95
96
97
98
99
    kernel: '{{ bootz_kernel_addr|default('0x80000000') }}'
    ramdisk: '{{ bootz_ramdisk_addr|default('0x82000000') }}'
    dtb: '{{ bootz_dtb_addr|default('0x81000000') }}'
  bootz:
    kernel: '{{ bootz_kernel_addr|default('0x80000000') }}'
    ramdisk: '{{ bootz_ramdisk_addr|default('0x82000000') }}'
    dtb: '{{ bootz_dtb_addr|default('0x81000000') }}'
{% endif %}
100
{% endblock vland %}
101
102

{% block body %}
103

104
{% if console_device %}
105
106
107
108
  {% set console_device = "console=" + console_device + "," %}
  {% set parity = console_parity|default('n') %}
  {% set databits = console_databits|default('8') %}
  {% set baud_rate = baud_rate | default(115200)|string + parity + databits %}
109
{% endif %}
110
111
112
{% set base_kernel_args = extra_kernel_args | default(base_kernel_args) %}
{% set action_timeout_bootloader_commands = action_timeout_bootloader_commands | default(3) %}
{% set connection_timeout_bootloader_commands = connection_timeout_bootloader_commands | default(30) %}
Matt Hart's avatar
Matt Hart committed
113

114
{% if fastboot_deploy_uboot_commands %}
115
116
adb_serial_number: "{{ adb_serial_number|default('0000000000') }}"
fastboot_serial_number: "{{ fastboot_serial_number|default('0000000000') }}"
117
118
119
120
121
122
fastboot_options: {{ fastboot_options|default([]) }}
# This attribute identifies whether a device should get into fastboot mode by
# interrupting uboot and issuing commands at the bootloader prompt.
fastboot_via_uboot: True
{% endif %}

Matt Hart's avatar
Matt Hart committed
123
124
125
126
127
actions:
  deploy:
    parameters:
      add_header: u-boot
      mkimage_arch: {{ uboot_mkimage_arch|default('arm64') }} # string to pass to mkimage -A when adding UBoot headers
128
129
      append_dtb: {{ append_dtb|default(false) }}
      use_xip: {{ use_xip|default(false) }}
130
131
    connections:
      lxc:
132
      fastboot:
133
      serial:
Matt Hart's avatar
Matt Hart committed
134
    methods:
Matt Hart's avatar
Matt Hart committed
135
136
{% if uboot_ums_flash %}
      u-boot-ums:
137
138
139
140
{% endif %}
{% if flasher_deploy_commands %}
      flasher:
        commands: {{ flasher_deploy_commands }}
Matt Hart's avatar
Matt Hart committed
141
{% endif %}
142
      image:
143
      lxc:
144
      overlay:
145
      usb:
Matt Hart's avatar
Matt Hart committed
146
      tftp:
147
      nbd:
Matt Hart's avatar
Matt Hart committed
148
149
150
      ssh:
        options:
{{ ssh_options }}
151
        host: "{{ ssh_host|default('') }}"
Rémi Duraffort's avatar
Rémi Duraffort committed
152
        port: {{ ssh_port|default(22) }}
153
154
        user: "{{ ssh_user|default('root') }}"
        identity_file: "{{ ssh_identity_file }}"
155
156
157
158
159
160
161
162
163
164
165
{% if recovery_mode %}
{{ recovery_mode }}
          recovery_mode:
{% for url in recovery_mode_command %}
          - {{ url }}
{% endfor %}
          recovery_exit:
{% for url in recovery_exit_command %}
          - {{ url }}
{% endfor %}
{% endif %}
166
{% if fastboot_deploy_uboot_commands %}
167
      fastboot:
168
169
170
171
172
173
174
175
176
      u-boot:
        parameters:
          bootloader_prompt: "{{ bootloader_prompt }}"
          interrupt_prompt: "{{ interrupt_prompt }}"
          interrupt_char: "{{ interrupt_char }}"
          send_char: False
          fastboot:
            commands:
{% for command in fastboot_deploy_uboot_commands %}              - {{ command }}{% endfor %}
177
178
{{- fastboot_interrupt_params }}
{% endif %}
Matt Hart's avatar
Matt Hart committed
179
180
181

  boot:
    connections:
182
      lxc:
183
      fastboot:
Matt Hart's avatar
Matt Hart committed
184
185
      serial:
    methods:
186
      minimal:
Matt Hart's avatar
Matt Hart committed
187
      ssh:
188
189
190
191
192
      dfu:
        implementation: u-boot
        reset_works: False
        parameters:
          enter-commands:
193
194
195
{% for command in deploy_dfu_commands %}
            - {{ command }}
{% endfor %}
196
          command: dfu-util
197
198
199
{% if fastboot_boot_uboot %}
      fastboot: {{ fastboot_sequence }}
{% endif %}
Matt Hart's avatar
Matt Hart committed
200
201
      u-boot:
        parameters:
Matt Hart's avatar
Matt Hart committed
202
203
          mkimage_arch: {{ uboot_mkimage_arch|default('arm') }}
          bootloader_prompt: {{ bootloader_prompt|default('=>') }}
Matt Hart's avatar
Matt Hart committed
204
          interrupt_prompt: {{ interrupt_prompt|default('Hit any key to stop autoboot') }}
Matt Hart's avatar
Matt Hart committed
205
          interrupt_char: "{{ interrupt_char|default('') }}"
206
          needs_interrupt: {{ uboot_needs_interrupt|default(True) }}
Matt Hart's avatar
Matt Hart committed
207
208
209
210
{% if uboot_ums_flash %}
          uboot_ums_flash: {{ uboot_ums_flash }}
          uboot_mass_storage_device: {{ uboot_mass_storage_device|default(None) }}
{% endif %}
211
212
213
214
{% if fastboot_boot_uboot %}
{{- fastboot_boot_uboot }}
{{- fastboot_boot_grub }}
{% endif %}
215
        # method specific stanza
Matt Hart's avatar
Matt Hart committed
216
217
        ums:
          commands:
218
          - "{{ ums_command|default('ums 0 mmc 0')}}"
219
220
221
{% if uboot_method_fit %}
        fit:
          commands:
222
223
          - "{{ (base_uboot_commands + base_uboot_dhcp_command)|join('"\n          - "') }}"
          - "tftp {KERNEL_ADDR} {KERNEL}"
224
          - "setenv bootargs '{{ console_device }}{{ baud_rate }} rootfstype=ramfs {{ base_kernel_args }}'"
225
          - "bootm {KERNEL_ADDR}#conf@{{ bootm_device_tree_config }}"
226
{% endif %}
Matt Hart's avatar
Matt Hart committed
227
228
        nfs:
          commands:
229
          - "{{ uboot_common_cmds|join('"\n          - "') }}"
Matt Hart's avatar
Matt Hart committed
230
          # Always quote the entire string if the command includes a colon to support correct YAML.
231
          - "setenv bootargs '{{ console_device }}{{ baud_rate }} root=/dev/nfs rw {{ base_nfsroot_args }} {{ base_kernel_args }} {{ base_ip_args }}'"
232
          - "{{ base_uboot_bootcmd }}"
233
234
        nbd:
          commands:
235
          - "{{ uboot_common_cmds|join('"\n          - "') }}"
236
          # Always quote the entire string if the command includes a colon to support correct YAML.
237
          - "setenv bootargs '{{ console_device }}{{ baud_rate }} rw {{ base_nbdroot_args }} {{ base_kernel_args }} {{ base_ip_args }} verbose earlyprintk systemd.log_color=false ${extraargs} rw'"
238
          - "{{ base_uboot_bootcmd }}"
Matt Hart's avatar
Matt Hart committed
239
240
        ramdisk:
          commands:
241
          - "{{ uboot_common_cmds|join('"\n          - "') }}"
242
          - "setenv bootargs '{{ console_device }}{{ baud_rate }} root=/dev/ram0 {{ base_kernel_args }} {{ base_ip_args }}'"
243
          - "{{ base_uboot_bootcmd }}"
Matt Hart's avatar
Matt Hart committed
244
245
        usb:
          commands:
246
          - "{{ (base_uboot_usb_commands + base_uboot_commands)|join('"\n          - "') }}"
247
248
249
250
251
          - "load usb {{ usb_device_id }}:{ROOT_PART} {KERNEL_ADDR} {KERNEL}"
          - "load usb {{ usb_device_id }}:{ROOT_PART} {RAMDISK_ADDR} {RAMDISK}"
          - "setenv initrd_size ${filesize}"
          - "load usb {{ usb_device_id }}:{ROOT_PART} {DTB_ADDR} {DTB}"
          - "{{ console_device }}{{ baud_rate }} root={ROOT} {{ base_kernel_args }} {{ base_ip_args }}"
252
          - "{{ base_uboot_bootcmd }}"
Matt Hart's avatar
Matt Hart committed
253
254
        sata:
          commands:
255
256
          - "scsi scan"
          - "{{ base_uboot_commands|join('"\n          - "') }}"
257
258
259
260
          - "load scsi {ROOT_PART} {KERNEL_ADDR} {KERNEL}"
          - "load scsi {ROOT_PART} {RAMDISK_ADDR} {RAMDISK}; setenv initrd_size ${filesize}"
          - "load scsi {ROOT_PART} {DTB_ADDR} {DTB}"
          - "setenv bootargs '{{ console_device }}{{ baud_rate }} root={ROOT} {{ base_kernel_args }} {{ base_ip_args }}'"
261
          - "{{ base_uboot_bootcmd }}"
Thomas Mahe's avatar
Thomas Mahe committed
262
263
      uuu:
        options:
264
          usb_otg_path: "{{ uuu_usb_otg_path }}"
Thomas Mahe's avatar
Thomas Mahe committed
265
266
267
          corrupt_boot_media_command: {{ uuu_corrupt_boot_media_command }}


268
{% endblock body %}