Update buildroot makefile to test for write access to $RISCV and remove separate sudo/no_sudo versions (just run the makefile as sudo if needed)

This commit is contained in:
Jordan Carlin 2024-07-24 00:22:28 -07:00
parent 676c6b88a0
commit a9cd457536
No known key found for this signature in database
2 changed files with 11 additions and 25 deletions

View File

@ -1,4 +1,3 @@
#BUILDROOT := ${RISCV}/buildroot-test
BUILDROOT := buildroot
IMAGES := ${BUILDROOT}/output/images
WALLY := $(shell dirname $(shell pwd))
@ -27,36 +26,29 @@ BINARIES := fw_jump.elf vmlinux busybox
OBJDUMPS := $(foreach name, $(BINARIES), $(basename $(name) .elf))
OBJDUMPS := $(foreach name, $(OBJDUMPS), $(DIS)/$(name).objdump)
.PHONY: all generate disassemble install clean cleanDTB cleanDriver test
.PHONY: all generate disassemble install clean cleanDTB cleanDriver check_write_permissions
all: clean download Image disassemble install dumptvs
all: check_write_permissions clean download Image disassemble install dumptvs
all_nosudo: clean download Image disassemble install_nosudo dumptvs_nosudo
check_write_permissions:
@mkdir -p $(RISCV)/.test || \
(echo "ERROR: Cannot write to '$(RISCV)'." \
"Make sure you have write permissions (you may need to run as sudo).'" \
&& exit 1)
@rm -r $(RISCV)/.test
Image:
bash -c "unset LD_LIBRARY_PATH; make -C $(BUILDROOT) --jobs ${shell nproc --ignore 1};"
$(MAKE) generate
install:
sudo rm -rf $(RISCV)/$(BUILDROOT)
sudo mv $(BUILDROOT) $(RISCV)/$(BUILDROOT)
install_nosudo:
install: check_write_permissions
rm -rf $(RISCV)/$(BUILDROOT)
mv $(BUILDROOT) $(RISCV)/$(BUILDROOT)
dumptvs:
sudo mkdir -p $(RISCV)/linux-testvectors
cd testvector-generation; sudo ./genInitMem.sh
dumptvs_nosudo:
dumptvs: check_write_permissions
mkdir -p $(RISCV)/linux-testvectors
cd testvector-generation; ./genInitMem.sh
# Temp rule for debugging
test:
echo $(shell find $(BUILDROOT)/output/build -maxdepth 2 -type d -regex ".*/linux-[0-9]+\.[0-9]+\.[0-9]+$$")
generate: $(DTB) $(IMAGES)
$(IMAGES)/%.dtb: ./devicetree/%.dts

View File

@ -7,7 +7,6 @@ ramFile="$tvDir/ram.bin"
rawBootmemFile="$tvDir/bootmemGDB.bin"
bootmemFile="$tvDir/bootmem.bin"
rawUntrimmedBootmemFile="$tvDir/untrimmedBootmemFileGDB.bin"
untrimmedBootmemFile="$tvDir/untrimmedBootmemFile.bin"
DEVICE_TREE=${imageDir}/wally-virt.dtb
if ! mkdir -p "$tvDir"; then
@ -24,6 +23,7 @@ if ! test -w "$tvDir"; then
exit 1
fi
fi
echo "Launching QEMU in replay mode!"
(qemu-system-riscv64 \
-M virt -m 256M -dtb $DEVICE_TREE \
@ -44,15 +44,10 @@ echo "Launching QEMU in replay mode!"
-ex "kill" \
-ex "q"
#-ex "printf \"Warning - please verify that the second half of $rawUntrimmedBootmemFile is all 0s\n\"" \
#-ex "printf \"Creating $rawUntrimmedBootmemFile\n\"" \
#-ex "dump binary memory $rawUntrimmedBootmemFile 0x1000 0x2fff" \
echo "Changing Endianness"
make fixBinMem
./fixBinMem "$rawRamFile" "$ramFile"
./fixBinMem "$rawBootmemFile" "$bootmemFile"
#./fixBinMem "$rawUntrimmedBootmemFile" "$untrimmedBootmemFile" # doesn't seem to be used for anything
rm -f "$rawRamFile" "$rawBootmemFile" "$rawUntrimmedBootmemFile"
echo "genInitMem.sh completed!"
@ -60,4 +55,3 @@ echo "You may want to restrict write access to $tvDir now and give cad ownership
echo "Run the following:"
echo " sudo chown -R cad:cad $tvDir"
echo " sudo chmod -R go-w $tvDir"