Skip to content

Commit

Permalink
make it compile on the raspberry Pi zero
Browse files Browse the repository at this point in the history
  • Loading branch information
hansfbaier committed Oct 20, 2023
1 parent 903142b commit ffbde69
Show file tree
Hide file tree
Showing 17 changed files with 108 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ host
*.user
.vs
MiSTer
arm-buildroot-linux-gnueabihf_sdk-buildroot/
99 changes: 99 additions & 0 deletions Makefile.arm
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# makefile to fail if any command in pipe is failed.
SHELL = /bin/bash -o pipefail

BASE = ./arm-buildroot-linux-gnueabihf_sdk-buildroot/bin/arm-buildroot-linux-gnueabihf

CC = $(BASE)-gcc
LD = $(BASE)-ld
STRIP = $(BASE)-strip

ifeq ($(V),1)
Q :=
else
Q := @
endif

SDK_SYSROOT = arm-buildroot-linux-gnueabihf_sdk-buildroot/arm-buildroot-linux-gnueabihf/sysroot/
SDK_LIB = $(SDK_SYSROOT)/usr/lib

INCLUDE = -I./
INCLUDE += -I./lib/libco
INCLUDE += -I./lib/miniz
INCLUDE += -I./lib/md5
INCLUDE += -I./lib/lzma
INCLUDE += -I./lib/gpiod/
INCLUDE += -I./lib/libchdr/include
INCLUDE += -I./lib/flac/include
INCLUDE += -I./lib/flac/src/include
INCLUDE += -I./lib/bluetooth
INCLUDE += -I./lib/serial_server/library

PRJ = MiSTer
C_SRC = $(wildcard *.c) \
$(wildcard ./lib/miniz/*.c) \
$(wildcard ./lib/md5/*.c) \
$(wildcard ./lib/lzma/*.c) \
$(wildcard ./lib/flac/src/*.c) \
$(wildcard ./lib/libchdr/*.c) \
lib/libco/arm.c

CPP_SRC = $(wildcard *.cpp) \
arm/scheduler.cpp \
$(wildcard ./lib/serial_server/library/*.cpp) \
$(wildcard ./support/*/*.cpp)

IMG = $(wildcard *.png)

IMLIB2_LIB = -L$(SDK_LIB) -lfreetype -lbz2 -lpng16 -lz -lImlib2 -lgpiod

OBJ = $(C_SRC:.c=.c.o) $(CPP_SRC:.cpp=.cpp.o) $(IMG:.png=.png.o)
DEP = $(C_SRC:.c=.c.d) $(CPP_SRC:.cpp=.cpp.d)

DFLAGS = $(INCLUDE) -D_7ZIP_ST -DPACKAGE_VERSION=\"1.3.3\" -DRASPBERRY_PI -DUSE_SCHEDULER -DFLAC_API_EXPORTS -DFLAC__HAS_OGG=0 -DHAVE_LROUND -DHAVE_STDINT_H -DHAVE_STDLIB_H -DHAVE_SYS_PARAM_H -DENABLE_64_BIT_WORDS=0 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -DVDATE=\"`date +"%y%m%d"`\"
CFLAGS = $(DFLAGS) -w -Wextra -Wno-strict-aliasing -Wno-stringop-overflow -Wno-stringop-truncation -Wno-format-truncation -Wno-psabi -Wno-restrict -c -O3
LFLAGS = -lc -lstdc++ -lm -lrt $(IMLIB2_LIB) -Llib/bluetooth -lbluetooth -lpthread

ifeq ($(PROFILING),1)
DFLAGS += -DPROFILING
endif

$(PRJ): $(OBJ)
$(Q)$(info $@)
$(Q)$(CC) -o $@ $+ $(LFLAGS)
$(Q)cp $@ [email protected]
$(Q)$(STRIP) $@

.PHONY: sdk
sdk:
tar xzf ../MiSTeX-buildroot/rpi-zero/buildroot/output/images/arm-buildroot-linux-gnueabihf_sdk-buildroot.tar.gz

.PHONY: clean
clean:
$(Q)rm -f *.elf *.map *.lst *.user *~ $(PRJ)
$(Q)rm -rf obj DTAR* x64
$(Q)find . \( -name '*.o' -o -name '*.d' -o -name '*.bak' -o -name '*.rej' -o -name '*.org' \) -exec rm -f {} \;

%.c.o: %.c
$(Q)$(info $<)
$(Q)$(CC) $(CFLAGS) -std=gnu99 -o $@ -c $< 2>&1 | sed -e 's/\(.[a-zA-Z]\+\):\([0-9]\+\):\([0-9]\+\):/\1(\2,\ \3):/g'

%.cpp.o: %.cpp
$(Q)$(info $<)
$(Q)$(CC) $(CFLAGS) -std=gnu++14 -Wno-class-memaccess -o $@ -c $< 2>&1 | sed -e 's/\(.[a-zA-Z]\+\):\([0-9]\+\):\([0-9]\+\):/\1(\2,\ \3):/g'

%.png.o: %.png
$(Q)$(info $<)
$(Q)$(LD) -r -b binary -o $@ $< 2>&1 | sed -e 's/\(.[a-zA-Z]\+\):\([0-9]\+\):\([0-9]\+\):/\1(\2,\ \3):/g'


ifneq ($(MAKECMDGOALS), clean)
-include $(DEP)
endif
%.c.d: %.c
$(Q)$(CC) $(DFLAGS) -MM $< -MT $@ -MT $*.c.o -MF $@ 2>&1 | sed -e 's/\(.[a-zA-Z]\+\):\([0-9]\+\):\([0-9]\+\):/\1(\2,\ \3):/g'

%.cpp.d: %.cpp
$(Q)$(CC) $(DFLAGS) -MM $< -MT $@ -MT $*.cpp.o -MF $@ 2>&1 | sed -e 's/\(.[a-zA-Z]\+\):\([0-9]\+\):\([0-9]\+\):/\1(\2,\ \3):/g'

# Ensure correct time stamp
main.cpp.o: $(filter-out main.cpp.o, $(OBJ))
File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions fpga_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,18 @@
#define fatal(x) /*munmap((void*)map_base, FPGA_REG_SIZE);*/ close(fd); exit(x)

static const char *gpio_chip_name = "gpiochip0";
#ifdef RASPBERRY_PI
#define GPIIO_PIN_FPGA_RESET 22
#define GPIIO_PIN_FPGA_EN 23
#define GPIIO_PIN_OSD_EN 24
#define GPIIO_PIN_IO_EN 25
#else // Sipeed Lichee RV
#define GPIIO_PIN_FPGA_RESET 102
#define GPIIO_PIN_FPGA_EN 103
#define GPIIO_PIN_OSD_EN 104
#define GPIIO_PIN_IO_EN 105
#endif

static struct gpiod_chip *gpio_chip;
static struct gpiod_line *gpio_line_fpga_reset;
static struct gpiod_line *gpio_line_fpga_en;
Expand Down
Binary file removed lib/bluetooth/libbluetooth.so
Binary file not shown.
Binary file removed lib/gpiod/riscv/libgpiod.so
Binary file not shown.
Binary file removed lib/imlib2/arm/libImlib2.so
Binary file not shown.
Binary file removed lib/imlib2/arm/libbz2.so
Binary file not shown.
Binary file removed lib/imlib2/arm/libfreetype.so
Binary file not shown.
Binary file removed lib/imlib2/arm/libpng16.so
Binary file not shown.
Binary file removed lib/imlib2/arm/libz.so
Binary file not shown.
Binary file removed lib/imlib2/riscv/libImlib2.so
Binary file not shown.
Binary file removed lib/imlib2/riscv/libbz2.so
Binary file not shown.
Binary file removed lib/imlib2/riscv/libfreetype.so
Binary file not shown.
Binary file removed lib/imlib2/riscv/libpng16.so
Binary file not shown.
Binary file removed lib/imlib2/riscv/libz.so
Binary file not shown.

0 comments on commit ffbde69

Please sign in to comment.