platform.sh 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # SPDX-License-Identifier: GPL-2.0-only
  2. #
  3. # Copyright (C) 2017 OpenWrt.org
  4. RAMFS_COPY_BIN='fw_printenv fw_setenv dmesg'
  5. RAMFS_COPY_DATA="/etc/fw_env.config"
  6. REQUIRE_IMAGE_METADATA=0
  7. platform_check_image()
  8. {
  9. local board=$(board_name)
  10. nand_do_platform_check $board $1
  11. return $?
  12. }
  13. platform_do_upgrade() {
  14. # TODO no need to switch to ramfs with dual partitions in
  15. # fact we don't even want to reboot as part of seamless
  16. # upgrades. Instead just upgrade opposite partition and mark
  17. # the next reboot to boot from that partition. Could just call
  18. # stage2 directly but need to refactor nand_upgrade_success
  19. # for this to work.
  20. # Also the nand functions don't allow url to be used
  21. local board=$(board_name)
  22. case "$board" in
  23. img,pistachio-marduk)
  24. local boot_partition=$(dmesg | grep "ubi0: attached.*" | sed "s/^.*\(firmware[0-1]\).*/\1/g")
  25. echo "Current boot partiton $boot_partition (/dev/mtd$(find_mtd_index $boot_partition))"
  26. mkdir -p /var/lock
  27. if [ "$boot_partition" == "firmware0" ]; then
  28. CI_UBIPART="firmware1"
  29. fw_setenv boot_partition 1 || exit 1
  30. else
  31. CI_UBIPART="firmware0"
  32. fw_setenv boot_partition 0 || exit 1
  33. fi
  34. echo "Upgrading partition $CI_UBIPART (/dev/mtd$(find_mtd_index $CI_UBIPART))"
  35. ;;
  36. esac
  37. nand_do_upgrade $1
  38. }