|
1 | 1 |
|
2 | 2 | module_options+=( |
3 | 3 | ["manage_dtoverlays,author"]="@viraniac" |
4 | | -["manage_dtoverlays,maintainer"]="@igorpecovnik,@The-Going" |
| 4 | +["manage_dtoverlays,maintainer"]="@igorpecovnik,@The-going" |
5 | 5 | ["manage_dtoverlays,ref_link"]="" |
6 | 6 | ["manage_dtoverlays,feature"]="manage_dtoverlays" |
7 | 7 | ["manage_dtoverlays,desc"]="Enable/disable device tree overlays" |
@@ -33,48 +33,73 @@ function manage_dtoverlays () { |
33 | 33 |
|
34 | 34 | [[ ! -f "${overlayconf}" || ! -d "${overlaydir}" ]] && echo -e "Incompatible OS configuration\nArmbian device tree configuration files not found" | show_message && return 1 |
35 | 35 |
|
36 | | - # check /boot/boot.scr scenario ${overlay_prefix}-${overlay_name}.dtbo |
37 | | - # or ${overlay_name}.dtbo only |
| 36 | + # check /boot/boot.scr scenario overlay(s)/${overlay_prefix}-${overlay_name}.dtbo |
| 37 | + # or overlay(s)/${overlay_name}.dtbo. |
38 | 38 | # scenario: |
39 | 39 | # 00 - The /boot/boot.scr script cannot load the overlays provided by Armbian. |
40 | 40 | # 01 - It is possible to load only if the full name of the overlay is written. |
41 | 41 | # 10 - Loading is possible only if the overlay name is written without a prefix. |
42 | 42 | # 11 - Both spellings will be loaded. |
43 | 43 | scenario=$( |
44 | 44 | awk 'BEGIN{p=0;s=0} |
45 | | - /load.*overlay\/\${overlay_prefix}-\${overlay_file}.dtbo/{p=1} |
46 | | - /load.*overlay\/\${overlay_file}.dtbo/{s=1} |
47 | | - END{print p s} |
48 | | - ' /boot/boot.scr |
| 45 | + /load.*overlays?\/\${overlay_prefix}-\${overlay_file}.dtbo/{p=1} |
| 46 | + /load.*overlays?\/\${overlay_file}.dtbo/{s=1} |
| 47 | + END{print p s} |
| 48 | + ' /boot/boot.scr |
49 | 49 | ) |
50 | 50 |
|
51 | 51 | while true; do |
52 | 52 | local options=() |
53 | 53 | j=0 |
54 | 54 |
|
55 | | - # read overlays |
56 | | - available_overlays=$( |
57 | | - # Find the files that match the overlay prefix pattern. |
58 | | - # Remove the overlay prefix, file extension, and path |
59 | | - # in one pass. Sort it out. |
60 | | - find ${overlaydir}/ -name "$overlay_prefix"'*.dtbo' 2>/dev/null | \ |
61 | | - awk -F'/' -v p="${overlay_prefix}-" '{ |
62 | | - gsub(p, "", $0) |
63 | | - gsub(".dtbo", "", $0) |
64 | | - print $NF |
65 | | - }' | sort |
66 | | - ) |
| 55 | + if [[ "${scenario}" == "10" ]] || [[ "${scenario}" == "11" ]]; then |
| 56 | + # read overlays |
| 57 | + available_overlays=$( |
| 58 | + # Find the files that match the overlay prefix pattern. |
| 59 | + # Remove the overlay prefix, file extension, and path |
| 60 | + # in one pass. Sort it out. |
| 61 | + find "${overlaydir}"/ -name "$overlay_prefix"'*.dtbo' 2>/dev/null | \ |
| 62 | + awk -F'/' -v p="${overlay_prefix}-" '{ |
| 63 | + gsub(p, "", $NF) |
| 64 | + gsub(".dtbo", "", $NF) |
| 65 | + print $NF |
| 66 | + }' | sort |
| 67 | + ) |
| 68 | + fi |
67 | 69 |
|
68 | 70 | # Check the branch in case it is not available in /etc/armbian-release |
69 | 71 | update_kernel_env |
70 | 72 |
|
71 | 73 | # Add support for rk3588 vendor kernel overlays which don't have overlay prefix mostly |
72 | 74 | builtin_overlays="" |
73 | | - if [[ $BOARDFAMILY == "rockchip-rk3588" ]] && [[ $BRANCH == "vendor" ]]; then |
74 | | - builtin_overlays=$(ls -1 ${overlaydir}/*.dtbo | grep -v ${overlay_prefix} | sed 's#^'${overlaydir}'/##' | sed 's/.dtbo//g') |
| 75 | + if [[ "${scenario}" == "01" ]] || [[ "${scenario}" == "11" ]]; then |
| 76 | + |
| 77 | + if [[ $BOARDFAMILY == "rockchip-rk3588" ]] && [[ $BRANCH == "vendor" ]]; then |
| 78 | + builtin_overlays=$( |
| 79 | + find "${overlaydir}"/ -name '*.dtbo' ! -name "$overlay_prefix"'*.dtbo' 2>/dev/null | \ |
| 80 | + awk -F'/' -v p="${overlay_prefix}" '{ |
| 81 | + if ($0 !~ p) { |
| 82 | + gsub(".dtbo", "", $NF) |
| 83 | + print $NF |
| 84 | + } |
| 85 | + }' | sort |
| 86 | + ) |
| 87 | + fi |
| 88 | + fi |
| 89 | + |
| 90 | + if [[ "${scenario}" == "00" ]]; then |
| 91 | + $DIALOG --title " Manage devicetree overlays " \ |
| 92 | + --no-button "Cancel" \ |
| 93 | + --yes-button "Exit" \ |
| 94 | + --yesno " The overlays provided by Armbian cannot be loaded\n by /boot/boot.scr script.\n" 11 44 |
| 95 | + exit_status=$? |
| 96 | + if [ $exit_status == 0 ]; then |
| 97 | + exit 0 |
| 98 | + fi |
| 99 | + break |
75 | 100 | fi |
76 | 101 |
|
77 | | - for overlay in ${available_overlays}; do |
| 102 | + for overlay in ${available_overlays} ${builtin_overlays}; do |
78 | 103 | local status="OFF" |
79 | 104 | grep '^overlays' ${overlayconf} | grep -qw ${overlay} && status=ON |
80 | 105 | # Raspberry Pi |
|
0 commit comments