diff --git a/Makefile b/Makefile
index 975bf67..6adf0b8 100644
--- a/Makefile
+++ b/Makefile
@@ -98,8 +98,14 @@ sunxi-fexc: fexc.h script.h script.c \
script_fex.h script_fex.c
LIBUSB = libusb-1.0
-LIBUSB_CFLAGS = `pkg-config --cflags $(LIBUSB)`
-LIBUSB_LIBS = `pkg-config --libs $(LIBUSB)`
+LIBUSB_CFLAGS ?= `pkg-config --cflags $(LIBUSB)`
+LIBUSB_LIBS ?= `pkg-config --libs $(LIBUSB)`
+ifeq ($(OS),Windows_NT)
+ # Windows lacks mman.h / mmap()
+ DEFINES += -DNO_MMAP
+ # portable_endian.h relies on winsock2
+ LIBS += -lws2_32
+endif
sunxi-fel: fel.c fel-to-spl-thunk.h progress.c progress.h
$(CC) $(CFLAGS) $(LIBUSB_CFLAGS) $(LDFLAGS) -o $@ $(filter %.c,$^) $(LIBS) $(LIBUSB_LIBS)
diff --git a/bootinfo.c b/bootinfo.c
index ea7d5e3..93b94d7 100644
--- a/bootinfo.c
+++ b/bootinfo.c
@@ -198,7 +198,7 @@ void print_boot_file_head(boot_file_head_t *hdr)
void print_boot_dram_para(boot_dram_para_t *dram)
{
- pprintf(&dram->dram_baseaddr, "DRAM base : %p\n", (void *)(long)dram->dram_baseaddr);
+ pprintf(&dram->dram_baseaddr, "DRAM base : %p\n", (void *)(uintptr_t)dram->dram_baseaddr);
pprintf(&dram->dram_clk, "DRAM clk : %d\n", dram->dram_clk);
pprintf(&dram->dram_type, "DRAM type : %d\n", dram->dram_type);
pprintf(&dram->dram_rank_num, "DRAM rank : %d\n", dram->dram_rank_num);
diff --git a/fel.c b/fel.c
index 5d8a382..8e617bd 100644
--- a/fel.c
+++ b/fel.c
@@ -15,6 +15,10 @@
* along with this program. If not, see .
*/
+#include "common.h"
+#include "portable_endian.h"
+#include "progress.h"
+
#include
#include
#include
@@ -28,10 +32,6 @@
#include
#include
-#include "common.h"
-#include "portable_endian.h"
-#include "progress.h"
-
static const uint16_t AW_USB_VENDOR_ID = 0x1F3A;
static const uint16_t AW_USB_PRODUCT_ID = 0xEFE8;
@@ -325,7 +325,7 @@ void hexdump(void *data, uint32_t offset, size_t size)
unsigned char *buf = data;
for (j = 0; j < size; j+=16) {
size_t i;
- printf("%08lx: ",(long int)offset + j);
+ printf("%08zx: ", offset + j);
for (i = 0; i < 16; i++) {
if (j + i < size)
printf("%02x ", buf[j+i]);
diff --git a/fexc.c b/fexc.c
index e90bd14..a1cc9cc 100644
--- a/fexc.c
+++ b/fexc.c
@@ -21,7 +21,9 @@
#include
#include
#include
-#include
+#ifndef NO_MMAP
+ #include
+#endif
#include
#include
#include
@@ -117,6 +119,7 @@ static inline int script_parse(enum script_format format,
pr_err("%s: %s: %s\n", filename,
"fstat", strerror(errno));
goto bin_close;
+#ifndef NO_MMAP
} else if (S_ISREG(sb.st_mode)) {
/* regular file, mmap it */
bin = mmap(0, sb.st_size, PROT_READ, MAP_SHARED, in, 0);
@@ -127,6 +130,7 @@ static inline int script_parse(enum script_format format,
}
bin_size = sb.st_size;
allocated = 0;
+#endif
} else {
/* something else... just read it all! */
bin = read_all(in, filename, &bin_size);
@@ -138,10 +142,12 @@ static inline int script_parse(enum script_format format,
ret = script_decompile_bin(bin, bin_size, filename, script);
if (allocated)
free(bin);
+#ifndef NO_MMAP
else if (munmap(bin, bin_size) == -1) {
pr_err("%s: %s: %s\n", filename,
"munmap", strerror(errno));
}
+#endif
bin_close:
close(in);
}; break;
diff --git a/meminfo.c b/meminfo.c
index 86b5c1e..0b0ff23 100644
--- a/meminfo.c
+++ b/meminfo.c
@@ -25,6 +25,8 @@
#include
#include
+#include "common.h"
+
typedef uint32_t u32;
/* from u-boot code: */
@@ -412,7 +414,7 @@ sun4i_dram_para_print_fex(struct sun4i_dram_para *dram_para)
static int
sun4i_dram_para_print(bool uboot)
{
- struct sun4i_dram_para dram_para = {0};
+ struct sun4i_dram_para dram_para = { .baseaddr = 0 };
int ret;
ret = sunxi_dram_clock_read(&dram_para.clock);
@@ -710,6 +712,7 @@ sun8i_dram_regs_print(void)
static void
print_usage(const char *name)
{
+ puts("sunxi-meminfo " VERSION "\n");
printf("Utility to retrieve DRAM information from registers on "
"Allwinner SoCs.\n");
printf("\n");
diff --git a/nand-image-builder.c b/nand-image-builder.c
index db42690..964a142 100644
--- a/nand-image-builder.c
+++ b/nand-image-builder.c
@@ -257,7 +257,7 @@ static void encode_bch(struct bch_control *bch, const uint8_t *data,
}
/* process first unaligned data bytes */
- m = ((unsigned long)data) & 3;
+ m = ((uintptr_t)data) & 3;
if (m) {
mlen = (len < (4-m)) ? len : 4-m;
encode_bch_unaligned(bch, data, mlen, bch->ecc_buf);
diff --git a/pio.c b/pio.c
index 3ecf912..4bcdc18 100644
--- a/pio.c
+++ b/pio.c
@@ -24,7 +24,9 @@
#include
#include
#include
-#include
+#ifndef NO_MMAP
+ #include
+#endif
#include
#include
#include
@@ -365,6 +367,10 @@ int main(int argc, char **argv)
if (!in_name && !do_mmap)
usage(1);
if (do_mmap) {
+#ifdef NO_MMAP
+ errno = ENOSYS; /* Function not implemented */
+ perror("mmap PIO");
+#else
int pagesize = sysconf(_SC_PAGESIZE);
int fd = open("/dev/mem",O_RDWR);
int addr = 0x01c20800 & ~(pagesize-1);
@@ -380,6 +386,7 @@ int main(int argc, char **argv)
}
close(fd);
buf += offset;
+#endif
}
if (in_name) {
if (strcmp(in_name, "-") == 0) {