Skip to content

Commit

Permalink
Merge pull request #219 from VisorFolks/bugfix/akashkollipara/218-mk-…
Browse files Browse the repository at this point in the history
…qemu-fix

<Make> Fix for failure of build resume and updates

Issue: #218
  • Loading branch information
akashkollipara authored Jan 30, 2023
2 parents 98665ba + 95087c9 commit 430bd42
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 16 deletions.
24 changes: 17 additions & 7 deletions mk/picotool.mk
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ SILENT_LOGS := > cbuild.log 2> /dev/null
endif

P_TARGETS += elf2uf2
T_ALLOWLIST += get_picotool pt_clean install_pt_dep
T_ALLOWLIST += get_picotool clean_picotool install_pt_dep

get_picotool: $(PICO_TOOL) $(ELF2UF2)

Expand All @@ -30,36 +30,46 @@ $(PICO_TOOL): $(PICO_TOOL_BUILD)
cp $(PICO_TOOL_PATH)/build/picotool $@

$(PICO_TOOL_BUILD): $(PICO_SDK_PATH) $(PICO_TOOL_PATH)
@echo "Building picotool ..."
@echo "< ! > Building picotool ..."
cd $(PICO_TOOL_PATH) && mkdir -p build && \
cd build && export PICO_SDK_PATH=$(PICO_SDK_PATH) && \
cmake ../ $(SILENT_LOGS) \
&& make $(SILENT_LOGS)
@echo "< / > Done!"

$(ELF2UF2): $(PICO_SDK_PATH)
@echo "Building elf2uf2 ..."
@echo "< ! > Building elf2uf2 ..."
mkdir -p $(MISC_TOOLS)/temp
cd $(MISC_TOOLS)/temp; \
cmake $(PICO_SDK_PATH)/tools/elf2uf2 2>/dev/null >/dev/null; \
make >/dev/null 2>/dev/null
cp $(MISC_TOOLS)/temp/elf2uf2 $@
rm -rf $(MISC_TOOLS)/temp
@echo "< ! > Cleaning up build space ..."
rm -rf $(PICO_SDK_PATH) $(PICO_TOOL_PATH)
@echo "< / > Done!"

elf2uf2: $(ELF2UF2) elf
@echo "Generating $(notdir $(ELF:.elf=.uf2)) ..."
$(ELF2UF2) $(ELF) $(ELF:.elf=.uf2)
@echo "< / > Done!"

$(PICO_SDK_PATH):
@echo "Fetching PICO SDK ..."
@echo "< ! > Fetching PICO SDK ..."
git clone $(PICO_SDK_GIT) --quiet $@
@echo "< / > Done!"

$(PICO_TOOL_PATH):
@echo "Fetching PICO Tool ..."
@echo "< ! > Fetching PICO Tool ..."
git clone $(PICO_TOOL_GIT) --quiet $@
@echo "< / > Done!"

install_pt_dep:
@echo "Installing Dependencies ..."
@echo "< ! > Installing Dependencies ..."
@sudo apt-get install build-essential pkg-config libusb-1.0-0-dev -y -qq > /dev/null
@echo "< / > Done!"

pt_clean:
clean_picotool:
@echo "< ! > Removing picotools ..."
rm -rf $(PICO_SDK_PATH) $(PICO_TOOL_PATH) $(PICO_TOOL) $(ELF2UF2)
@echo "< / > Done!"
32 changes: 23 additions & 9 deletions mk/qemu.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,38 @@
# Organisation : Cyancore Core-Team
#

T_ALLOWLIST += get_qemu
T_ALLOWLIST += get_qemu clean_qemu

get_qemu: | $(TOOLS_ROOT)/qemu/ $(TOOLS_ROOT)/qemu/build/
QEMU_CHECKOUT := v7.2.0
QEMU_PATH := $(TOOLS_ROOT)/qemu
QEMU_BUILD_PATH := $(QEMU_PATH)/build
QEMU_OUT_PATH := $(TOOLS_ROOT)/cc_qemu
QEMU_TLIST := avr-softmmu,arm-softmmu,riscv32-softmmu

$(TOOLS_ROOT)/qemu/:
get_qemu: $(QEMU_OUT_PATH)

$(TOOLS_ROOT)/qemu:
@echo "< ! > Using qemu version: $(QEMU_CHECKOUT)"
@echo "< ! > Fetching qemu ..."
mkdir -p $(TOOLS_ROOT)
cd $(TOOLS_ROOT); git clone https://gitlab.com/qemu-project/qemu.git;
cd $@; git submodule init; git submodule update --recursive
cd $(TOOLS_ROOT); git clone https://gitlab.com/qemu-project/qemu.git --quiet;
cd $@; git checkout -b $(QEMU_CHECKOUT) $(QEMU_CHECKOUT) 1> /dev/null 2> /dev/null
@echo "< / > Done !"

$(TOOLS_ROOT)/qemu/build/: $(TOOLS_ROOT)/qemu/

$(QEMU_OUT_PATH): $(QEMU_PATH)
@echo "< ! > Building qemu ..."
@echo "< ? > Please be patient as this might take a while ..."
cd $<; ./configure
make -j $(N_JOBS) -C $<
cd $<; ./configure --prefix=$(QEMU_OUT_PATH) --target-list=$(QEMU_TLIST) 2> /dev/null 1> /dev/null
make -j $(N_JOBS) -C $< install 2> /dev/null 1> /dev/null
@echo "< ! > Cleaning up build space ..."
rm -rf $(QEMU_PATH)
@echo "< ! > Adding load_qemu alias to bashrc ..."
@echo "< ! > run 'load_qemu' before trying to launch qemu!"
echo "alias load_qemu='export PATH=\"\$$PATH\":$@/build/'" >> ~/.bashrc
echo "alias load_qemu='export PATH=\"\$$PATH\":$@/bin/'" >> ~/.bashrc
@echo "< / > Done !"

clean_qemu:
@echo "< ! > Removing cc-qemu installation ..."
rm -rf $(QEMU_OUT_PATH) $(QEMU_PATH)
@echo "< / > Done!"

0 comments on commit 430bd42

Please sign in to comment.