bpi-m2.sh 4.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. # Board type: Banana Pi M2 Berry / M2 Ultra (Allwinner V40 / R40), the two
  2. # Gentoo servers marlena (192.168.2.1, DT "M2-Ultra") and banana-backup
  3. # (192.168.2.150, DT "M2 Berry"). Most likely the same hardware: one kernel and
  4. # one U-Boot for both, one DTB per board until that is confirmed (see
  5. # BANANA-V40-notes.md). Sourced by config.sh; everything here can be overridden
  6. # from the environment.
  7. BOARD_NAME="Banana Pi M2 Berry/Ultra (Allwinner V40/R40)"
  8. # install-kernel.sh and write-uboot.sh refuse an ssh target whose
  9. # /proc/device-tree/compatible lacks this.
  10. BOARD_DT_COMPAT="allwinner,sun8i-r40"
  11. # ---- versions ---------------------------------------------------------------
  12. # udev from systemd-utils 260 needs >= 5.10 (>= 5.14 recommended).
  13. : "${KERNEL_VERSION:=7.3.4}"
  14. : "${UBOOT_VERSION:=v2026.10}"
  15. # ---- toolchain --------------------------------------------------------------
  16. # The CHOST of both boards after the Gentoo 23.0 migration.
  17. : "${CROSS_COMPILE:=armv7a-unknown-linux-gnueabihf-}"
  18. # ---- U-Boot -----------------------------------------------------------------
  19. # Berry and Ultra defconfigs differ only in the U-Boot DT and the eMMC slot
  20. # (MMC_SUNXI_SLOT_EXTRA=2): same DRAM settings. Neither board has eMMC (marlena's
  21. # mmc2 host finds no card), so the Berry one serves both.
  22. UBOOT_DEFCONFIG=bananapi_m2_berry_defconfig
  23. UBOOT_SEEK_KIB=8
  24. UBOOT_OLD_RAW_ENV_KIB=
  25. # The boot commands are a hand-written environment in uboot.env on the FAT
  26. # /boot partition (mmc 0:1). write-uboot.sh checks that the new U-Boot will
  27. # accept that file (size and CRC against CONFIG_ENV_SIZE) before writing.
  28. UBOOT_ENV_FAT=1
  29. UBOOT_ENV_FILE=uboot.env
  30. # ---- kernel -----------------------------------------------------------------
  31. # Legacy uImage, started by "bootm 0x47000000 - 0x43000000" from the
  32. # environment; the kernel runs at 0x40008000.
  33. KERNEL_IMAGE=uImage
  34. UIMAGE_LOADADDR=0x40008000
  35. # Our device trees from files/bpi-m2/dts/: mainline board file + DS1307 RTC,
  36. # rtc0 alias, LED triggers. Built with symbols (-@) for marlena's overlay.
  37. BOARD_DTBS="sun8i-r40-bananapi-m2-ultra-k4be.dtb sun8i-v40-bananapi-m2-berry-k4be.dtb"
  38. # ---- installation: U-Boot environment (lib/install-ubootenv.sh) --------------
  39. INSTALL_SCHEME=ubootenv
  40. # Every release is kept in /boot/bpi-m2/<release>/ (FAT); the one booted is
  41. # copied to the fixed names the environment loads (uImage, <dtb>).
  42. BOOT_SUBDIR=bpi-m2
  43. # Which of our DTBs replaces the file the target's environment loads
  44. # (load_dt): "pattern:our-dtb", first match wins. BOOT_DTB=<our dtb> overrides.
  45. BOOT_DTB_MAP="*m2-ultra*:sun8i-r40-bananapi-m2-ultra-k4be.dtb *m2-berry*:sun8i-v40-bananapi-m2-berry-k4be.dtb"
  46. : "${BOOT_DTB:=}"
  47. # Overlay sources (files/bpi-m2/overlay/*.dts) compiled into overlay/ and
  48. # test-applied to this DTB at build time: marlena's environment applies
  49. # sun8i-r40-bananapi-m2-ultra-led.dtbo, and a failing "fdt apply" can leave the
  50. # tree in memory broken.
  51. OVERLAY_TEST_DTB=sun8i-r40-bananapi-m2-ultra-k4be.dtb
  52. # =============================================================================
  53. # Hooks called by build-kernel.sh
  54. # =============================================================================
  55. # board_package BOOTDIR: extra files for boot/bpi-m2/<release>/
  56. board_package() {
  57. local boot="$1" d o
  58. need_tools fdtoverlay fdtget
  59. mkdir -p "$boot/overlay"
  60. for d in "$BFILES"/overlay/*.dts; do
  61. [ -e "$d" ] || continue
  62. o="$boot/overlay/$(basename "${d%.dts}").dtbo"
  63. dtc -q -@ -I dts -O dtb -o "$o" "$d"
  64. fdtoverlay -i "$boot/$OVERLAY_TEST_DTB" -o "$OUT/overlay-test.dtb" "$o" ||
  65. die "overlay $(basename "$o") does not apply to $OVERLAY_TEST_DTB"
  66. info "overlay $(basename "$o") applies to $OVERLAY_TEST_DTB"
  67. done
  68. rm -f "$OUT/overlay-test.dtb"
  69. # The DS1307 must be rtc0 (hwclock, RTC_HCTOSYS) in every DTB.
  70. for d in $BOARD_DTBS; do
  71. [ "$(fdtget -t s "$boot/$d" /aliases rtc0 2>/dev/null)" = /soc/i2c@1c2b400/rtc@68 ] ||
  72. die "$d: rtc0 alias does not point to the DS1307"
  73. done
  74. info "rtc0 is the DS1307 in all DTBs"
  75. # vdd-cpu must not start below the vendor's 1008 MHz voltage (see the dtsi).
  76. local p
  77. for d in $BOARD_DTBS; do
  78. p="$(fdtget -t s "$boot/$d" /__symbols__ reg_dcdc2)" || die "$d: no reg_dcdc2 symbol"
  79. [ "$(fdtget -t u "$boot/$d" "$p" regulator-min-microvolt)" = 1160000 ] ||
  80. die "$d: vdd-cpu minimum is not 1160000 uV"
  81. done
  82. info "vdd-cpu minimum is 1.16 V in all DTBs"
  83. ls -la "$boot/overlay"
  84. }