diff --git a/Makefile b/Makefile
index aa5a061..5cc5985 100644
--- a/Makefile
+++ b/Makefile
@@ -1,8 +1,8 @@
# makefile to fail if any command in pipe is failed.
SHELL = /bin/bash -o pipefail
-# using gcc version 7.5.0 (Linaro GCC 7.5-2019.12)
-BASE = arm-linux-gnueabihf
+# using gcc version 10.2.1
+BASE = arm-none-linux-gnueabihf
CC = $(BASE)-gcc
LD = $(BASE)-ld
@@ -30,9 +30,9 @@ 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) \
+ $(wildcard ./lib/lzma/*.c) \
+ $(wildcard ./lib/flac/src/*.c) \
+ $(wildcard ./lib/libchdr/*.c) \
lib/libco/arm.c
CPP_SRC = $(wildcard *.cpp) \
@@ -47,7 +47,7 @@ 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\" -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) -Wall -Wextra -Wno-strict-aliasing -Wno-format-truncation -Wno-psabi -c -O3
+CFLAGS = $(DFLAGS) -Wall -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
$(PRJ): $(OBJ)
@@ -56,30 +56,27 @@ $(PRJ): $(OBJ)
$(Q)cp $@ $@.elf
$(Q)$(STRIP) $@
+.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 {} \;
-cleanall:
- $(Q)rm -rf *.o *.d *.elf *.map *.lst *.bak *.rej *.org *.user *~ $(PRJ)
- $(Q)rm -rf obj DTAR* x64
- $(Q)find . -name '*.o' -delete
- $(Q)find . -name '*.d' -delete
-
%.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 -o $@ -c $< 2>&1 | sed -e 's/\(.[a-zA-Z]\+\):\([0-9]\+\):\([0-9]\+\):/\1(\2,\ \3):/g'
+ $(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'
diff --git a/MiSTer.vcxproj b/MiSTer.vcxproj
index 8de9bdc..f556f2b 100644
--- a/MiSTer.vcxproj
+++ b/MiSTer.vcxproj
@@ -26,9 +26,9 @@
- git.lnk ./build.sh
+ %systemroot%\sysnative\windowspowershell\v1.0\powershell.exe wsl bash -lic ./build.sh
MiSTer
- git.lnk ./clean.sh
+ %systemroot%\sysnative\windowspowershell\v1.0\powershell.exe wsl bash -lic ./clean.sh
__arm__;__GNUC__;__USE_GNU ;_GNU_SOURCE;VDATE="000000";_FILE_OFFSET_BITS=64;_LARGEFILE64_SOURCE;$(NMakePreprocessorDefinitions)
c:\Work\Git\opt\gcc75\arm-linux-gnueabihf\libc\usr\include;c:\Work\Git\opt\gcc75\lib\gcc\arm-linux-gnueabihf\7.5.0\include;c:\Work\Git\opt\gcc75\arm-linux-gnueabihf\include\c++\7.5.0;c:\Work\Git\opt\gcc75\arm-linux-gnueabihf\include\c++\7.5.0\arm-linux-gnueabihf;$(NMakeIncludeSearchPath);lib\libco;lib\miniz;lib\lodepng;lib\libchdr\include;lib\bluetooth
$(TEMP)
diff --git a/audio.cpp b/audio.cpp
index d1e7575..bd0c1e1 100644
--- a/audio.cpp
+++ b/audio.cpp
@@ -33,7 +33,7 @@ static void setFilter()
has_filter = spi_uio_cmd(UIO_SET_AFILTER);
if (!has_filter) return;
- sprintf(filter_cfg_path, AFILTER_DIR"/%s", filter_cfg + 1);
+ snprintf(filter_cfg_path, sizeof(filter_cfg_path), AFILTER_DIR"/%s", filter_cfg + 1);
if(filter_cfg[0]) printf("\nLoading audio filter: %s\n", filter_cfg_path);
if (filter_cfg[0] && FileOpen(&f, filter_cfg_path))
diff --git a/build.sh b/build.sh
index 6c63593..8efd5fa 100644
--- a/build.sh
+++ b/build.sh
@@ -1,5 +1,7 @@
#!/bin/bash
+echo "Start building..."
+
# create simple text file named 'host' in this folder with IP address of your MiSTer.
HOST=192.168.1.75
@@ -12,14 +14,15 @@ set -o pipefail
make
set +e
-plink root@$HOST -pw 1 'killall MiSTer'
+plink root@$HOST -pw 1 -batch 'killall MiSTer'
set -e
ftp -n </dev/ttyS0 2>/dev/ttyS0 /dev/ttyS0 2>/dev/ttyS0 sizeof(curdir) - 1) len = sizeof(curdir) - 1;
- strncpy(curdir, p+1, len);
+ strncpy(curdir, p + 1, sizeof(curdir) - 1);
}
else
{
- uint32_t len = strlen(selPath);
- if (len > sizeof(curdir) - 1) len = sizeof(curdir) - 1;
- strncpy(curdir, selPath, len);
+ strncpy(curdir, selPath, sizeof(curdir) - 1);
selPath[0] = 0;
}
}
@@ -6217,7 +6213,7 @@ void HandleUI(void)
if (btimeout > 0)
{
OsdWrite(12, "\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81");
- sprintf(str, " Bootcore -> %s", bootcoretype);
+ snprintf(str, sizeof(str), " Bootcore -> %s", bootcoretype);
OsdWrite(13, str, 0, 0);
strcpy(straux, cfg.bootcore);
sprintf(str, " %s", get_rbf_name_bootcore(straux));
diff --git a/recent.cpp b/recent.cpp
index 8aaa09a..f9ba8dd 100644
--- a/recent.cpp
+++ b/recent.cpp
@@ -254,9 +254,9 @@ void recent_update(char* dir, char* path, char* label, int idx)
// update the selection
int indexToErase = RECENT_MAX - 1;
recent_rec_t rec = {};
- strncpy(rec.dir, dir, sizeof(rec.dir));
- strncpy(rec.name, name, sizeof(rec.name));
- strncpy(rec.label, label ? label : name, sizeof(rec.label));
+ strncpy(rec.dir, dir, sizeof(rec.dir)-1);
+ strncpy(rec.name, name, sizeof(rec.name)-1);
+ strncpy(rec.label, label ? label : name, sizeof(rec.label)-1);
for (unsigned i = 0; i < sizeof(recents)/sizeof(recents[0]); i++)
{
diff --git a/support/arcade/mra_loader.cpp b/support/arcade/mra_loader.cpp
index 3f578a8..582d482 100644
--- a/support/arcade/mra_loader.cpp
+++ b/support/arcade/mra_loader.cpp
@@ -179,7 +179,7 @@ static const char *get_arcade_root(int rbf)
static char path[kBigTextSize];
if (!rbf) strcpy(path, mame_root);
- else sprintf(path, "%s/cores", arcade_root);
+ else snprintf(path, sizeof(path), "%s/cores", arcade_root);
return path;
}
@@ -1149,7 +1149,7 @@ static const char *get_rbf(const char *xml)
}
}
- if (lastfound[0]) sprintf(rbfname, "%s/%s", dirname, lastfound);
+ if (lastfound[0]) snprintf(rbfname, sizeof(rbfname), "%s/%s", dirname, lastfound);
closedir(dir);
return lastfound[0] ? rbfname : NULL;
@@ -1161,7 +1161,7 @@ int arcade_load(const char *xml)
static char path[kBigTextSize];
if(xml[0] == '/') strcpy(path, xml);
- else sprintf(path, "%s/%s", getRootDir(), xml);
+ else snprintf(path, sizeof(path), "%s/%s", getRootDir(), xml);
set_arcade_root(path);
printf("arcade_load [%s]\n", path);
diff --git a/support/minimig/minimig_config.cpp b/support/minimig/minimig_config.cpp
index bdb2f77..ddafce8 100644
--- a/support/minimig/minimig_config.cpp
+++ b/support/minimig/minimig_config.cpp
@@ -453,7 +453,8 @@ int minimig_cfg_load(int num)
if (strcmp(tmpconf.kickstart, minimig_config.kickstart) != 0) {
updatekickstart = true;
}
- memcpy((void*)&minimig_config, (void*)&tmpconf, sizeof(minimig_config));
+ memset((void*)&minimig_config, 0, sizeof(minimig_config));
+ memcpy((void*)&minimig_config, (void*)&tmpconf, sizeof(tmpconf));
minimig_config.cpu = tmpconf.cpu;
minimig_config.autofire = tmpconf.autofire;
memset(&minimig_config.hardfile[2], 0, sizeof(minimig_config.hardfile[2]));
@@ -473,7 +474,7 @@ int minimig_cfg_load(int num)
BootPrint("Setting config defaults\n");
// set default configuration
memset((void*)&minimig_config, 0, sizeof(minimig_config)); // Finally found default config bug - params were reversed!
- strncpy(minimig_config.id, config_id, sizeof(minimig_config.id));
+ memcpy(minimig_config.id, config_id, sizeof(minimig_config.id));
snprintf(minimig_config.kickstart, 1024, "%s/%s", HomeDir(), "KICK.ROM");
minimig_config.memory = 0x11;
minimig_config.cpu = 0;
diff --git a/user_io.cpp b/user_io.cpp
index e90a71e..a7fc5d8 100644
--- a/user_io.cpp
+++ b/user_io.cpp
@@ -409,7 +409,7 @@ static void parse_config()
do {
p = user_io_get_confstr(i);
- printf("get cfgstring %d = %s\n", i, p);
+ printf("get cfgstring %d = %s\n", i, p ? p : "NULL");
if (!i)
{
OsdCoreNameSet((p && p[0]) ? p : "CORE");
diff --git a/video.cpp b/video.cpp
index 21b0d8f..f5ae798 100644
--- a/video.cpp
+++ b/video.cpp
@@ -232,7 +232,7 @@ static void setScaler()
new_scaler = 1;
spi8(scaler_flt_cfg[0]);
DisableIO();
- sprintf(filename, COEFF_DIR"/%s", scaler_flt_cfg + 1);
+ snprintf(filename, sizeof(filename), COEFF_DIR"/%s", scaler_flt_cfg + 1);
if (FileOpen(&f, filename))
{
@@ -342,7 +342,7 @@ static void setGamma()
has_gamma = 1;
spi8(0);
DisableIO();
- sprintf(filename, GAMMA_DIR"/%s", gamma_cfg + 1);
+ snprintf(filename, sizeof(filename), GAMMA_DIR"/%s", gamma_cfg + 1);
if (FileOpen(&f, filename))
{
@@ -1105,7 +1105,7 @@ static char *get_file_fromdir(const char* dir, int num, int *count)
if (de)
{
- sprintf(name, "%s/%s", dir, de->d_name);
+ snprintf(name, sizeof(name), "%s/%s", dir, de->d_name);
}
closedir(d);
if(count) *count = cnt;