-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
58 lines (49 loc) · 2.11 KB
/
Makefile
File metadata and controls
58 lines (49 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
DTS_FILE := adlink-pps-in
DEFAULT_LABEL := $(shell grep "^DEFAULT" /boot/extlinux/extlinux.conf | awk '{print $$2}')
$(warning DEFAULT_LABEL=$(DEFAULT_LABEL))
OVERLAY := $(shell grep "^LABEL $(DEFAULT_LABEL)" -A6 /boot/extlinux/extlinux.conf | grep OVERLAY | awk '{print $$2}')
$(warning CURRENT_OVERLAY=$(OVERLAY))
.PHONY: all dtbo install
all: dtbo install
dtbo:
# compile dts to dtbo
dtc -O dtb -o $(DTS_FILE).dtbo -@ $(DTS_FILE).dts
install: dtbo
# copy dtbo to /boot directory
sudo cp $(DTS_FILE).dtbo /boot/
# update extlinux.conf based on current OVERLAY status
ifeq ($(OVERLAY),)
# OVERLAY is empty, use jetson-io config tool
@echo "OVERLAY is empty, configuring with jetson-io..."
sudo cp /boot/extlinux/extlinux.conf /boot/extlinux/extlinux.conf.backup
sudo /opt/nvidia/jetson-io/config-by-hardware.py -n 1='ADLINK GPIO for PPS_IN Device Tree Overlay'
else
# OVERLAY is not empty, check if our dtbo is already included
@echo "Current OVERLAY: $(OVERLAY)"
@if echo "$(OVERLAY)" | grep -q "adlink-pps-in.dtbo"; then \
echo "adlink-pps-in.dtbo already exists in OVERLAY, nothing to do."; \
else \
echo "Adding adlink-pps-in.dtbo to existing OVERLAY..."; \
NEW_OVERLAY="$(OVERLAY),/boot/adlink-pps-in.dtbo"; \
echo "New OVERLAY will be: $$NEW_OVERLAY"; \
sudo cp /boot/extlinux/extlinux.conf /boot/extlinux/extlinux.conf.backup; \
sudo sed -i "/^LABEL $(DEFAULT_LABEL)/,/^LABEL\|^$$/{s|^[[:space:]]*OVERLAY[[:space:]]*.*| OVERLAYS $$NEW_OVERLAY|}" /boot/extlinux/extlinux.conf; \
echo "extlinux.conf updated successfully."; \
fi
endif
clean:
rm -f $(DTS_FILE).dtbo
backup-extlinux:
sudo cp /boot/extlinux/extlinux.conf /boot/extlinux/extlinux.conf.backup.$(shell date +%Y%m%d_%H%M%S)
restore:
@if [ -f /boot/extlinux/extlinux.conf.backup ]; then \
sudo cp /boot/extlinux/extlinux.conf.backup /boot/extlinux/extlinux.conf; \
echo "extlinux.conf restored from backup."; \
else \
echo "No backup file found."; \
fi
show-config:
@echo "Current configuration:"
@echo "DEFAULT_LABEL: $(DEFAULT_LABEL)"
@echo "CURRENT_OVERLAY: $(OVERLAY)"
@grep "^LABEL $(DEFAULT_LABEL)" -A6 /boot/extlinux/extlinux.conf