Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
zynqmp_pmufw: Re-add the PMU FW Makefile
The PMU FW Makefile was somehow lost, this patch restores the Makefile so that the PMU FW can be built. See CR: http://jira.xilinx.com/browse/CR-989408 Signed-off-by: Alistair Francis <alistair.francis@xilinx.com> Acked-by: Will Wong <willw@xilinx.com>
- Loading branch information
1 parent
5304be8
commit 547f457
Showing
7 changed files
with
291 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pm_binding.gcno | ||
build | ||
.Xil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,177 @@ | ||
include util.mk | ||
|
||
SRCDIR = src/ | ||
BUILDDIR ?= build/ | ||
BSPSRCDIR = bsp/ | ||
BSPBUILDDIR = ${BUILDDIR}/bsp/ | ||
MAKE_FLAGS = -rR | ||
PROCESSOR ?= psu_pmu_0 | ||
|
||
CROSS_COMPILE ?= mb- | ||
CC = $(CROSS_COMPILE)gcc | ||
CXX = $(CROSS_COMPILE)g++ | ||
AS = $(CC) | ||
LD = $(CROSS_COMPILE)gcc | ||
SIZE = $(CROSS_COMPILE)size | ||
NM = $(CROSS_COMPILE)nm | ||
OBJCOPY = $(CROSS_COMPILE)objcopy | ||
OBJDUMP = $(CROSS_COMPILE)objdump | ||
HEXDUMP ?= hexdump | ||
HSM ?= hsi | ||
HSM_FLAGS = -mode tcl -nojournal -nolog | ||
|
||
CFLAGS += -Wall -Wextra -Werror -Wno-unused-parameter -Os -g3 | ||
CFLAGS += -fmessage-length=0 | ||
CFLAGS += -I$(BSPBUILDDIR)$(PROCESSOR)/include | ||
CFLAGS += -I$(BUILDDIR)include | ||
CFLAGS += -mlittle-endian -mxl-barrel-shift -mxl-pattern-compare | ||
CFLAGS += -mcpu=v9.2 -mxl-soft-mul | ||
CFLAGS += -Wl,--no-relax | ||
CFLAGS += -ftest-coverage | ||
CFLAGS += -MMD -MP | ||
CFLAGS += -fdiagnostics-color=auto | ||
CFLAGS += -flto | ||
CFLAGS += $(ECFLAGS) | ||
|
||
CPPFLAGS += -Iinclude | ||
|
||
ASFLAGS += $(CFLAGS) | ||
ASFLAGS += -D__ASSEMBLY__ | ||
|
||
LDSCRIPT = $(SRCDIR)lscript.ld | ||
|
||
LDFLAGS += $(CFLAGS) | ||
LDFLAGS += -Wl,--fatal-warnings | ||
LDFLAGS += -nostartfiles | ||
LDFLAGS += -Wl,-T$(LDSCRIPT) | ||
LDFLAGS += -L$(BSPBUILDDIR)$(PROCESSOR)/lib | ||
LDFLAGS += -Wl,--no-relax | ||
|
||
LDLIBS = -Wl,--start-group,-lxil,-lgcc,-lc,-lxilfpga,-lxilsecure,--end-group | ||
|
||
HDF ?= $(realpath bsp/pmu.hdf) | ||
ifeq (${USE_UART1},1) | ||
UART=psu_uart_1 | ||
else | ||
UART=psu_uart_0 | ||
endif | ||
|
||
PMU_FW_C_SRCS = $(notdir $(shell [ -d $(SRCDIR) ] && find $(SRCDIR) -maxdepth 1 -name \*.c)) | ||
PMU_FW_S_SRCS = $(notdir $(shell [ -d $(SRCDIR) ] && find $(SRCDIR) -maxdepth 1 -name \*.S)) | ||
PMU_FW_s_SRCS = $(notdir $(shell [ -d $(SRCDIR) ] && find $(SRCDIR) -maxdepth 1 -name \*.s)) | ||
PMU_FW_OBJS = $(PMU_FW_C_SRCS:.c=.o) | ||
PMU_FW_OBJS += $(PMU_FW_S_SRCS:.S=.o) | ||
PMU_FW_OBJS += $(PMU_FW_s_SRCS:.s=.o) | ||
|
||
S_OBJS = $(PMU_FW_OBJS) | ||
|
||
OBJS = $(addprefix $(BUILDDIR), $(S_OBJS)) | ||
|
||
TARGET = $(BUILDDIR)xpfw.elf | ||
TARGET_BIN = $(TARGET:.elf=.bin) | ||
HELPER_TCL = tools/xpfw_loader/$(notdir $(TARGET:.elf=_loader.tcl)) | ||
HELPER_C = tools/xpfw_loader/$(notdir $(TARGET:.elf=_loader_inc.c)) | ||
|
||
# Create the dirs. | ||
CREATE_BUILDDIRS = $(shell mkdir -p $(BUILDDIR)include ${BSPBUILDDIR}) | ||
|
||
all: $(CREATE_BUILDDIRS) helpers | ||
|
||
-include $(OBJS:.o=.d) | ||
|
||
define filechk_version.h | ||
echo -e "#ifndef ZYNQMP_XPFW_VERSION__H_\n\ | ||
#define ZYNQMP_XPFW_VERSION__H_\n\ | ||
#define ZYNQMP_XPFW_VERSION \"`./scripts/setlocalversion 2>/dev/null`\"\n\ | ||
#endif" | ||
endef | ||
|
||
$(BUILDDIR)include/xpfw_version.h: FORCE | ||
$(call filechk,version.h) | ||
|
||
$(BUILDDIR)%.o: $(SRCDIR)%.c | $(BUILDDIR)include/xpfw_version.h $(BSPBUILDDIR)$(PROCESSOR)/lib/libxil.a | ||
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ | ||
|
||
$(BUILDDIR)%.o: $(SRCDIR)%.S | $(BSPBUILDDIR)$(PROCESSOR)/lib/libxil.a | ||
$(CC) $(ASFLAGS) $(CPPFLAGS) -c $< -o $@ | ||
|
||
$(BUILDDIR)%.o: $(SRCDIR)%.s | ||
$(CC) $(ASFLAGS) -c $< -o $@ | ||
|
||
$(TARGET): $(BSPBUILDDIR)$(PROCESSOR)/lib/libxil.a $(LDSCRIPT) $(OBJS) | ||
$(LD) $(OBJS) $(LDFLAGS) $(LDLIBS) -o $@ | ||
|
||
$(TARGET_BIN): $(TARGET) | ||
$(OBJCOPY) -O binary $< $@ | ||
|
||
FIX_XIL_PRINTF__H = '\ | ||
if (/xil_printf\s*\(.*\)/) { \ | ||
unless (/attribute/) { \ | ||
$$_ =~ s/;\s*$$/ __attribute__\(\(format\(printf, 1, 2\)\)\);\n/; \ | ||
} \ | ||
}' | ||
|
||
$(BSPBUILDDIR)$(PROCESSOR)/lib/libxil.a: ${HDF} | ||
echo -e "\ | ||
if {[info exists ::env(HSI_REPO_PATH)]} {\\n \ | ||
set_repo_path $$::env(HSI_REPO_PATH)\\n \ | ||
}\\n\ | ||
open_hw_design $(HDF)\\n \ | ||
set swdsgn [create_sw_design -os standalone -proc $(PROCESSOR) bsp]\\n \ | ||
add_library xilfpga\\n \ | ||
add_library xilsecure\\n \ | ||
set_property CONFIG.STDIN $(UART) [get_os]\\n \ | ||
set_property CONFIG.STDOUT $(UART) [get_os]\\n \ | ||
set_property -name {CONFIG.extra_compiler_flags} -value {-Os -flto -ffat-lto-objects} -objects [get_sw_processor]\\n \ | ||
set_property -name {APP_COMPILER_FLAGS} -value {-Os -flto -ffat-lto-objects} -objects [current_sw_design]\\n \ | ||
generate_bsp -sw \$$swdsgn -compile -dir $(BSPBUILDDIR)\\n \ | ||
quit" | MAKEFLAGS="-rRj 1" $(HSM) $(HSM_FLAGS) | ||
find $(BSPBUILDDIR) -type f -name xil_printf.h -exec perl -i -n -p -e $(FIX_XIL_PRINTF__H) '{}' ';' | ||
|
||
size: $(TARGET) | ||
$(SIZE) $(TARGET) | ||
|
||
.PHONY: tags | ||
tags: | ||
ctags -R $(SRCDIR) | ||
ctags --append --exclude=Makefile --exclude=*.make -R $(BSPBUILDDIR)$(PROCESSOR) | ||
|
||
# Generate files to help us in downloading PMU FW on to RAM | ||
# Output can be found in build/ directory | ||
# TCL: ELFNAME_loader.tcl can be used from XMD on EP | ||
# C: ELFNAME_loader.c - A standalone app that loads PMU FW | ||
$(HELPER_TCL): $(TARGET_BIN) | ||
@echo "generating $@ from $<" | ||
@echo -e "## AUTOGENERATED FILE ##\n\ | ||
puts \"Downloading FW...\"\n\ | ||
mwr -f 0xffd80000 0x00000000\n\ | ||
mwr -f 0xff310000 0x00010000\n\ | ||
after 1000\n" > $@ | ||
@$(HEXDUMP) -e '"mwr -f 0xffdc%04_ax 0x%08x \n"' -v $< | tac >> $@ | ||
@echo -e "mwr -f 0xffd80000 0x00000001\n\ | ||
puts \"Done.\"\n\ | ||
## EOF ##" >> $@ | ||
|
||
$(HELPER_C): $(TARGET_BIN) | ||
$(HEXDUMP) -e '"Xil_Out32(""0xffdc%04_ax" ", " "0x%08x"");\n"' -v $< | tac > $@ | ||
|
||
helpers: $(HELPER_TCL) $(HELPER_C) | ||
|
||
.PHONY: cscope | ||
cscope: | ||
find ${CURDIR} -type f -name "*.[chsS]" > cscope.files | ||
cscope -b -q -k | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -rf $(TARGET) $(OBJS) $(OBJS:.o=.d) *.log *.jou \ | ||
$(BUILDDIR)/* $(BUILDDIR)include/xpfw_version.h $(HELPER_TCL) $(HELPER_C) \ | ||
design_1.hwh design_1_bd.tcl hwdef.xml psu_clock_registers.log | ||
make $(MAKE_FLAGS) -C $(BSPBUILDDIR) $@ | ||
|
||
.PHONY: distclean | ||
distclean: clean | ||
rm -rf $(BUILDDIR) $(BSPBUILDDIR) tags cscope.* | ||
|
||
.PHONY: FORCE | ||
FORCE: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
design_1.hwh | ||
design_1_bd.tcl | ||
hwdef.xml |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
xpfw_loader.tcl | ||
xpfw_loader_inc.c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
#include "xil_printf.h" | ||
#include "xstatus.h" | ||
#include "xil_io.h" | ||
#include "ipi.h" | ||
#include "pmu_global.h" | ||
|
||
extern void outbyte(char c); | ||
extern char inbyte(); | ||
|
||
void load_pmufw(void); | ||
void ipi_a53(void); | ||
|
||
int main(void) | ||
{ | ||
xil_printf("PMU Firmware Loader\n"); | ||
xil_printf("L - Load PMUFW\n"); | ||
xil_printf("T - Run Test IPI Case\n"); | ||
|
||
while (1) { | ||
char c; | ||
|
||
c = inbyte(); | ||
|
||
if (c == '\r') { | ||
outbyte('\n'); | ||
} | ||
if ((c == 'l') || (c == 'L')) { | ||
load_pmufw(); | ||
} | ||
if ((c == 't') || (c == 'T')) { | ||
ipi_a53(); | ||
} | ||
|
||
outbyte(c); | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
void ipi_a53(void) | ||
{ | ||
xil_printf("#############################################\n"); | ||
xil_printf("##### APU-->PMU IPI-1 PM Request Test #######\n"); | ||
xil_printf("#############################################\n"); | ||
|
||
xil_printf("A53_0: Requesting USB0 Power Up via IPI-1\n"); | ||
Xil_Out32(PMU_GLOBAL_GLOBAL_GEN_STORAGE1, 0xD003111B); | ||
Xil_Out32(IPI_APU_TRIG, IPI_APU_TRIG_PMU_1_MASK); | ||
|
||
while (((Xil_In32(IPI_APU_OBS)) & IPI_APU_OBS_PMU_1_MASK) != 0) | ||
; | ||
xil_printf("A53_0: Request has been Acknowledged by PMU\n"); | ||
|
||
xil_printf("===========================================\n"); | ||
|
||
xil_printf("A53_0: Requesting USB0 Power Down via IPI-1\n"); | ||
Xil_Out32(PMU_GLOBAL_GLOBAL_GEN_STORAGE1, 0xD001111D); | ||
Xil_Out32(IPI_APU_TRIG, IPI_APU_TRIG_PMU_1_MASK); | ||
while (((Xil_In32(IPI_APU_OBS)) & IPI_APU_OBS_PMU_1_MASK) != 0) | ||
; | ||
xil_printf("A53_0: Request has been Acknowledged by PMU\n"); | ||
|
||
xil_printf("================Test Done==================\n"); | ||
xil_printf("================ PASS ==================\n"); | ||
} | ||
|
||
void load_pmufw(void) | ||
{ | ||
int i = 0; | ||
|
||
xil_printf("Downloading FW...\n"); | ||
Xil_Out32(PMU_GLOBAL_GLOBAL_CNTRL, 0x0U); | ||
Xil_Out32(IPI_APU_TRIG, IPI_APU_TRIG_PMU_0_MASK); | ||
for (i = 0; i < 1000; i++) | ||
; | ||
|
||
#include "xpfw_loader_inc.c" | ||
|
||
Xil_Out32(PMU_GLOBAL_GLOBAL_CNTRL, 0x01U); | ||
xil_printf("Done\n"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
### | ||
# filechk is used to check if the content of a generated file is updated. | ||
# Sample usage: | ||
# define filechk_sample | ||
# echo $KERNELRELEASE | ||
# endef | ||
# version.h : Makefile | ||
# $(call filechk,sample) | ||
# The rule defined shall write to stdout the content of the new file. | ||
# The existing file will be compared with the new one. | ||
# - If no file exist it is created | ||
# - If the content differ the new file is used | ||
# - If they are equal no change, and no timestamp update | ||
define filechk | ||
@set -e; \ | ||
echo ' CHK $@'; \ | ||
mkdir -p $(dir $@); \ | ||
$(filechk_$(1)) > $@.tmp; \ | ||
if [ -r $@ ] && cmp -s $@ $@.tmp; then \ | ||
rm -f $@.tmp; \ | ||
else \ | ||
echo ' UPD $@'; \ | ||
mv -f $@.tmp $@; \ | ||
fi | ||
endef |