Skip to content

Commit c4c786d

Browse files
authored
Merge pull request #49 from dgarske/winfixes
Fixes for building C signing tools on Windows (Cygwin/MinGW).
2 parents d43be42 + 5a8032d commit c4c786d

4 files changed

Lines changed: 43 additions & 33 deletions

File tree

Makefile

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -204,32 +204,32 @@ wolfboot.bin: wolfboot.elf
204204
align: wolfboot-align.bin
205205

206206
.bootloader-partition-size:
207-
@printf "%d" $(WOLFBOOT_PARTITION_BOOT_ADDRESS) > .wolfboot-offset
208-
@printf "%d" $(ARCH_FLASH_OFFSET) > .wolfboot-arch-offset
209-
@expr `cat .wolfboot-offset` - `cat .wolfboot-arch-offset` > .bootloader-partition-size
210-
@rm -f .wolfboot-offset .wolfboot-arch-offset
207+
$(Q)printf "%d" $(WOLFBOOT_PARTITION_BOOT_ADDRESS) > .wolfboot-offset
208+
$(Q)printf "%d" $(ARCH_FLASH_OFFSET) > .wolfboot-arch-offset
209+
$(Q)expr `cat .wolfboot-offset` - `cat .wolfboot-arch-offset` > .bootloader-partition-size
210+
$(Q)rm -f .wolfboot-offset .wolfboot-arch-offset
211211

212212
wolfboot-align.bin: .bootloader-partition-size wolfboot.bin
213-
@dd if=/dev/zero bs=`cat .bootloader-partition-size` count=1 2>/dev/null | tr "\000" "\377" > $(@)
214-
@dd if=wolfboot.bin of=$(@) conv=notrunc 2>/dev/null
213+
$(Q)dd if=/dev/zero bs=`cat .bootloader-partition-size` count=1 2>/dev/null | tr "\000" "\377" > $(@)
214+
$(Q)dd if=wolfboot.bin of=$(@) conv=notrunc 2>/dev/null
215215
@echo
216216
@echo "\t[SIZE]"
217-
@$(SIZE) wolfboot.elf
217+
$(Q)$(SIZE) wolfboot.elf
218218
@echo
219219

220220
test-app/image.bin: wolfboot-align.bin
221-
@make -C test-app WOLFBOOT_ROOT=$(WOLFBOOT_ROOT)
222-
@rm -f src/*.o hal/*.o
223-
@$(SIZE) test-app/image.elf
221+
$(Q)make -C test-app WOLFBOOT_ROOT=$(WOLFBOOT_ROOT)
222+
$(Q)rm -f src/*.o hal/*.o
223+
$(Q)$(SIZE) test-app/image.elf
224224

225225
standalone:
226-
@make -C test-app TARGET=$(TARGET) EXT_FLASH=$(EXT_FLASH) SPI_FLASH=$(SPI_FLASH) ARCH=$(ARCH) \
226+
$(Q)make -C test-app TARGET=$(TARGET) EXT_FLASH=$(EXT_FLASH) SPI_FLASH=$(SPI_FLASH) ARCH=$(ARCH) \
227227
NO_XIP=$(NO_XIP) V=$(V) RAM_CODE=$(RAM_CODE) WOLFBOOT_VERSION=$(WOLFBOOT_VERSION)\
228228
MCUXPRESSO=$(MCUXPRESSO) MCUXPRESSO_CPU=$(MCUXPRESSO_CPU) MCUXPRESSO_DRIVERS=$(MCUXPRESSO_DRIVERS) \
229229
MCUXPRESSO_CMSIS=$(MCUXPRESSO_CMSIS) NVM_FLASH_WRITEONCE=$(NVM_FLASH_WRITEONCE) \
230230
FREEDOM_E_SDK=$(FREEDOM_E_SDK) standalone
231231
$(Q)$(OBJCOPY) -O binary test-app/image.elf standalone.bin
232-
@$(SIZE) test-app/image.elf
232+
$(Q)$(SIZE) test-app/image.elf
233233

234234
include tools/test.mk
235235

tools/keytools/keygen.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@
2626
/* Must also define DEBUG_WOLFSSL in user_settings.h */
2727
//#define DEBUG_SIGNTOOL
2828

29+
#include <stdio.h>
30+
#include <stdarg.h>
31+
#include <stdlib.h>
32+
#include <string.h>
33+
#include <limits.h>
34+
#include <sys/stat.h>
35+
#include <sys/types.h>
36+
#include <errno.h>
37+
2938
#include <wolfssl/wolfcrypt/settings.h>
3039
#ifndef NO_RSA
3140
#include <wolfssl/wolfcrypt/rsa.h>
@@ -45,15 +54,7 @@
4554
#include <wolfssl/wolfcrypt/logging.h>
4655
#endif
4756

48-
#include <stdio.h>
49-
#include <stdlib.h>
50-
#include <string.h>
51-
#include <limits.h>
52-
#include <sys/stat.h>
53-
#include <sys/types.h>
54-
#include <errno.h>
55-
56-
#ifdef _WIN32
57+
#if defined(_WIN32) && !defined(PATH_MAX)
5758
#define PATH_MAX 256
5859
#endif
5960

@@ -252,8 +253,8 @@ int main(int argc, char** argv)
252253
{
253254
int i;
254255
int force = 0;
255-
int keytype;
256-
const char *kfilename;
256+
int keytype = 0;
257+
const char *kfilename = NULL;
257258
char *output_pubkey_file;
258259
WC_RNG rng;
259260
FILE *f;

tools/keytools/sign.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@
2626
/* Must also define DEBUG_WOLFSSL in user_settings.h */
2727
//#define DEBUG_SIGNTOOL
2828

29+
#include <stdio.h>
30+
#include <stdarg.h>
31+
#include <stdlib.h>
32+
#include <string.h>
33+
#include <limits.h>
34+
#include <sys/stat.h>
35+
#include <sys/types.h>
36+
2937
#include <wolfssl/wolfcrypt/settings.h>
3038
#ifndef NO_RSA
3139
#include <wolfssl/wolfcrypt/rsa.h>
@@ -48,14 +56,7 @@
4856
#include <wolfssl/wolfcrypt/logging.h>
4957
#endif
5058

51-
#include <stdio.h>
52-
#include <stdlib.h>
53-
#include <string.h>
54-
#include <limits.h>
55-
#include <sys/stat.h>
56-
#include <sys/types.h>
57-
58-
#ifdef _WIN32
59+
#if defined(_WIN32) && !defined(PATH_MAX)
5960
#define PATH_MAX 256
6061
#endif
6162

tools/test.mk

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,21 @@ SIGN_ARGS=
88
ifneq ("$(wildcard ./tools/keytools/keygen)","")
99
KEYGEN_TOOL=./tools/keytools/keygen
1010
else
11-
KEYGEN_TOOL=python3 ./tools/keytools/keygen.py
11+
ifneq ("$(wildcard ./tools/keytools/keygen.exe)","")
12+
KEYGEN_TOOL=./tools/keytools/keygen.exe
13+
else
14+
KEYGEN_TOOL=python3 ./tools/keytools/keygen.py
15+
endif
1216
endif
1317

1418
ifneq ("$(wildcard ./tools/keytools/sign)","")
1519
SIGN_TOOL=./tools/keytools/sign
1620
else
17-
SIGN_TOOL=python3 ./tools/keytools/sign.py
21+
ifneq ("$(wildcard ./tools/keytools/sign.exe)","")
22+
SIGN_TOOL=./tools/keytools/sign.exe
23+
else
24+
SIGN_TOOL=python3 ./tools/keytools/sign.py
25+
endif
1826
endif
1927

2028
ifeq ($(SIGN),ED25519)

0 commit comments

Comments
 (0)