config.sh 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. KSRC="$SRC/linux-$KERNEL_VERSION"
  46. USRC="$SRC/u-boot-${UBOOT_VERSION#v}"
  47. XSRC="$SRC/xradio"
  48. KOUT="$OUT/kernel" # staging: boot/ and lib/modules/
  49. UOUT="$OUT/u-boot"
  50. die() { echo "ERROR: $*" >&2; exit 1; }
  51. info() { echo ">>> $*"; }
  52. # Fail early if a required program is missing; don't install anything.
  53. need_tools() {
  54. local t missing=()
  55. for t in "$@"; do command -v "$t" >/dev/null 2>&1 || missing+=("$t"); done
  56. [ ${#missing[@]} -eq 0 ] || die "missing tools: ${missing[*]} (install them and re-run)"
  57. }
  58. # check_fragment FRAGMENT DOTCONFIG
  59. # Every option in a config fragment must have survived olddefconfig; a renamed
  60. # symbol or a missing dependency silently drops options otherwise.
  61. check_fragment() {
  62. local frag="$1" dotconfig="$2" bad=0 line sym want have
  63. while IFS= read -r line; do
  64. case "$line" in
  65. CONFIG_*=*) sym="${line%%=*}"; want="${line#*=}" ;;
  66. "# CONFIG_"*" is not set") sym="${line#\# }"; sym="${sym%% *}"; want=n ;;
  67. *) continue ;;
  68. esac
  69. have="$(grep -E "^$sym=" "$dotconfig" | cut -d= -f2- || true)"
  70. [ -n "$have" ] || have=n
  71. if [ "$have" != "$want" ]; then
  72. echo " config: $sym wanted $want, got $have" >&2
  73. bad=1
  74. fi
  75. done < "$frag"
  76. [ $bad -eq 0 ] || die ".config does not match ${frag#"$TOP"/} (see above)"
  77. info "config check passed (${frag#"$TOP"/})"
  78. }
  79. # fetch URL DEST [fallback URL...]
  80. fetch() {
  81. local dest="$1"; shift
  82. [ -s "$dest" ] && return 0
  83. mkdir -p "$(dirname "$dest")"
  84. local url
  85. for url in "$@"; do
  86. info "downloading $url"
  87. if curl -fL --connect-timeout 20 --retry 2 -o "$dest.part" "$url"; then
  88. mv "$dest.part" "$dest"
  89. return 0
  90. fi
  91. done
  92. rm -f "$dest.part"
  93. die "could not download $(basename "$dest")"
  94. }