HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux ip-172-31-42-149 5.15.0-1084-aws #91~20.04.1-Ubuntu SMP Fri May 2 07:00:04 UTC 2025 aarch64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: //etc/flash-kernel/bootscript/bootscr.rpi
# Ubuntu Classic RPi U-Boot script (for armhf and arm64)

# Expects to be called with the following environment variables set:
#
#  devtype              e.g. mmc/scsi etc
#  devnum               The device number of the given type
#  distro_bootpart      The partition containing the boot files
#                       (introduced in u-boot mainline 2016.01)
#  prefix               Prefix within the boot partiion to the boot files
#  kernel_addr_r        Address to load the kernel to
#  fdt_addr_r           Address to load the FDT to
#  ramdisk_addr_r       Address to load the initrd to.

# Take fdt addr from the prior stage boot loader, if available
if test -n "$fdt_addr"; then
  fdt addr ${fdt_addr}
  fdt move ${fdt_addr} ${fdt_addr_r}  # implicitly sets fdt active
else
  fdt addr ${fdt_addr_r}
fi
fdt get value bootargs /chosen bootargs

setenv bootargs "@@LINUX_KERNEL_CMDLINE_DEFAULTS@@ ${bootargs} @@LINUX_KERNEL_CMDLINE@@"
@@UBOOT_ENV_EXTRA@@

@@UBOOT_PREBOOT_EXTRA@@

setenv kernel_filename vmlinuz
setenv core_state "/uboot/ubuntu/boot.sel"
setenv kernel_bootpart ${distro_bootpart}

if test -z "${fk_image_locations}"; then
  setenv fk_image_locations ${prefix}
fi

for pathprefix in ${fk_image_locations}; do
  if load ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr_r} ${pathprefix}${core_state}; then
    # Core image; set defaults for core's state then import from the first
    # boot.sel file. Then load the mutable boot.sel file from the next
    # partition
    setenv kernel_filename kernel.img
    setenv kernel_vars "snap_kernel snap_try_kernel kernel_status"
    setenv recovery_vars "snapd_recovery_mode snapd_recovery_system snapd_recovery_kernel"
    setenv snapd_recovery_mode "install"
    setenv snapd_standard_params "panic=-1"

    env import -c ${kernel_addr_r} ${filesize} ${recovery_vars}
    setenv bootargs "${bootargs} snapd_recovery_mode=${snapd_recovery_mode} snapd_recovery_system=${snapd_recovery_system} ${snapd_standard_params}"

    if test "${snapd_recovery_mode}" = "run"; then
      setexpr kernel_bootpart ${distro_bootpart} + 1
      load ${devtype} ${devnum}:${kernel_bootpart} ${kernel_addr_r} ${pathprefix}${core_state}
      env import -c ${kernel_addr_r} ${filesize} ${kernel_vars}
      setenv kernel_name "${snap_kernel}"

      if test -n "${kernel_status}"; then
        if test "${kernel_status}" = "try"; then
          if test -n "${snap_try_kernel}"; then
            setenv kernel_status trying
            setenv kernel_name "${snap_try_kernel}"
          fi
        elif test "${kernel_status}" = "trying"; then
          setenv kernel_status ""
        fi
        env export -c ${kernel_addr_r} ${kernel_vars}
        save ${devtype} ${devnum}:${kernel_bootpart} ${kernel_addr_r} ${pathprefix}${core_state} ${filesize}
      fi
      setenv kernel_prefix "${pathprefix}uboot/ubuntu/${kernel_name}/"
    else
      setenv kernel_prefix "${pathprefix}systems/${snapd_recovery_system}/kernel/"
    fi
  else
    # Classic image; the kernel prefix is unchanged, nothing special to do
    setenv kernel_prefix "${pathprefix}"
  fi

  # Store the gzip header (1f 8b) in the kernel area for comparison to the
  # header of the image we load. Load "$kernel_filename" into the portion of
  # memory for the RAM disk (because we want to uncompress to the kernel area
  # if it's compressed) and compare the word at the start
  mw.w ${kernel_addr_r} 0x8b1f  # little endian
  if load ${devtype} ${devnum}:${kernel_bootpart} ${ramdisk_addr_r} ${kernel_prefix}${kernel_filename}; then
    kernel_size=${filesize}
    if cmp.w ${kernel_addr_r} ${ramdisk_addr_r} 1; then
      # gzip compressed image (NOTE: *not* a self-extracting gzip compressed
      # kernel, just a kernel image that has been gzip'd)
      echo "Decompressing kernel..."
      unzip ${ramdisk_addr_r} ${kernel_addr_r}
      setenv kernel_size ${filesize}
      setenv try_boot "booti"
    else
      # Possibly self-extracting or uncompressed; copy data into the kernel area
      # and attempt launch with bootz then booti
      echo "Copying kernel..."
      cp.b ${ramdisk_addr_r} ${kernel_addr_r} ${kernel_size}
      setenv try_boot "bootz booti"
    fi

    if load ${devtype} ${devnum}:${kernel_bootpart} ${ramdisk_addr_r} ${kernel_prefix}initrd.img; then
      setenv ramdisk_param "${ramdisk_addr_r}:${filesize}"
    else
      setenv ramdisk_param "-"
    fi
    for cmd in ${try_boot}; do
        echo "Booting Ubuntu (with ${cmd}) from ${devtype} ${devnum}:${partition}..."
        ${cmd} ${kernel_addr_r} ${ramdisk_param} ${fdt_addr_r}
    done
  fi
done