platform.sh 1.3 KB

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