config.sh 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. # Shared settings for the Orange Pi Zero (H2+, original version) build.
  2. # Sourced by the other scripts; override any of these from the environment.
  3. TOP="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
  4. # ---- versions ---------------------------------------------------------------
  5. : "${KERNEL_VERSION:=7.3.4}"
  6. : "${UBOOT_VERSION:=v2026.10}"
  7. # Out-of-tree XR819 Wi-Fi driver (not in mainline). Pinned commit; see README.
  8. : "${XRADIO_REPO:=fifteenhex/xradio}"
  9. : "${XRADIO_COMMIT:=3ce657ae533e2213f6fda2297da1598fa11d7a03}"
  10. # ---- toolchain --------------------------------------------------------------
  11. : "${CROSS_COMPILE:=armv7a-hardfloat-linux-gnueabi-}"
  12. : "${JOBS:=$(nproc)}"
  13. export ARCH=arm CROSS_COMPILE
  14. # ---- board ------------------------------------------------------------------
  15. UBOOT_DEFCONFIG=orangepi_zero_defconfig
  16. KERNEL_DTB=sun8i-h2-plus-orangepi-zero.dtb
  17. # sunxi boot ROM loads the SPL from 8 KiB on the card.
  18. UBOOT_SEEK_KIB=8
  19. # ---- extlinux.conf (install-kernel.sh) --------------------------------------
  20. # Device tree U-Boot hands to the kernel (built from files/dts/).
  21. : "${BOOT_DTB:=sun8i-h2-plus-orangepi-zero-radio.dtb}"
  22. # Extra overlays from boot/opi0/<release>/overlay/, space separated, no .dtbo.
  23. : "${BOOT_OVERLAYS:=}"
  24. # Kernel messages go to every console= listed, but only the LAST one becomes
  25. # /dev/console: init's output, systemd's emergency/rescue shell and the
  26. # "Give root password" prompt. The serial port goes last so it is a usable
  27. # emergency console when ssh is not (tty1, fbcon on the radio panel, has no
  28. # keyboard). install-kernel.sh moves a console=ttyS* entry to the end anyway.
  29. # The panel driver maps white to "pixel off" (the light background), so fbcon's
  30. # light-grey-on-black looks inverted there. This VT palette is the VGA one
  31. # inverted, with entry 0 (background) white and 7/15 (normal/bold text) black.
  32. # Only text VTs use it; radio-ui draws through DRM and is not affected.
  33. VT_PALETTE="vt.default_red=0xff,0x55,0xff,0x55,0xff,0x55,0xff,0x00,0xaa,0x00,0xaa,0x00,0xaa,0x00,0xaa,0x00"
  34. VT_PALETTE+=" vt.default_grn=0xff,0xff,0x55,0xaa,0xff,0xff,0x55,0x00,0xaa,0xaa,0x00,0x00,0xaa,0xaa,0x00,0x00"
  35. VT_PALETTE+=" vt.default_blu=0xff,0xff,0xff,0xff,0x55,0x55,0x55,0x00,0xaa,0xaa,0xaa,0xaa,0x00,0x00,0x00,0x00"
  36. : "${KERNEL_CONSOLE:=console=tty1 fbcon=font:6x8 $VT_PALETTE console=ttyS0,115200}"
  37. # usb-storage quirks carried over from the Armbian setup (armbianEnv.txt).
  38. : "${KERNEL_CMDLINE_EXTRA:=usb-storage.quirks=0x2537:0x1066:u,0x2537:0x1068:u}"
  39. # ---- directories ------------------------------------------------------------
  40. DL="$TOP/dl" # downloaded tarballs
  41. SRC="$TOP/src" # extracted sources
  42. OUT="$TOP/out" # build results
  43. FILES="$TOP/files" # config fragments, overlays, boot config templates
  44. PANEL_DIR="${PANEL_DIR:-/home/k4be/git/radio/s1d13700-tca}" # s1d13700-tca: panel driver, overlay
  45. KEYBOARD_DIR="${KEYBOARD_DIR:-/home/k4be/git/radio/radio-keyboard-tca}" # radio-keyboard-tca: key overlay
  46. KSRC="$SRC/linux-$KERNEL_VERSION"
  47. USRC="$SRC/u-boot-${UBOOT_VERSION#v}"
  48. XSRC="$SRC/xradio"
  49. KOUT="$OUT/kernel" # staging: boot/ and lib/modules/
  50. UOUT="$OUT/u-boot"
  51. die() { echo "ERROR: $*" >&2; exit 1; }
  52. info() { echo ">>> $*"; }
  53. # Fail early if a required program is missing; don't install anything.
  54. need_tools() {
  55. local t missing=()
  56. for t in "$@"; do command -v "$t" >/dev/null 2>&1 || missing+=("$t"); done
  57. [ ${#missing[@]} -eq 0 ] || die "missing tools: ${missing[*]} (install them and re-run)"
  58. }
  59. # check_fragment FRAGMENT DOTCONFIG
  60. # Every option in a config fragment must have survived olddefconfig; a renamed
  61. # symbol or a missing dependency silently drops options otherwise.
  62. check_fragment() {
  63. local frag="$1" dotconfig="$2" bad=0 line sym want have
  64. while IFS= read -r line; do
  65. case "$line" in
  66. CONFIG_*=*) sym="${line%%=*}"; want="${line#*=}" ;;
  67. "# CONFIG_"*" is not set") sym="${line#\# }"; sym="${sym%% *}"; want=n ;;
  68. *) continue ;;
  69. esac
  70. have="$(grep -E "^$sym=" "$dotconfig" | cut -d= -f2- || true)"
  71. [ -n "$have" ] || have=n
  72. if [ "$have" != "$want" ]; then
  73. echo " config: $sym wanted $want, got $have" >&2
  74. bad=1
  75. fi
  76. done < "$frag"
  77. [ $bad -eq 0 ] || die ".config does not match ${frag#"$TOP"/} (see above)"
  78. info "config check passed (${frag#"$TOP"/})"
  79. }
  80. # fetch URL DEST [fallback URL...]
  81. fetch() {
  82. local dest="$1"; shift
  83. [ -s "$dest" ] && return 0
  84. mkdir -p "$(dirname "$dest")"
  85. local url
  86. for url in "$@"; do
  87. info "downloading $url"
  88. if curl -fL --connect-timeout 20 --retry 2 -o "$dest.part" "$url"; then
  89. mv "$dest.part" "$dest"
  90. return 0
  91. fi
  92. done
  93. rm -f "$dest.part"
  94. die "could not download $(basename "$dest")"
  95. }