Skip to content

Commit f7d1e24

Browse files
dgarskedanielinux
authored andcommitted
Fixed issue with hal/library.c around NO_FILESYSTEM.
1 parent a24a52f commit f7d1e24

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

config/examples/library.config

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ SIGN?=ED25519
77
HASH?=SHA256
88
IMAGE_HEADER_SIZE?=256
99
DEBUG=0
10-
SPMATH=0
10+
SPMATH?=0
11+
SPMATHALL?=0
1112
WOLFBOOT_NO_PARTITIONS=1
1213

1314
# Required to build keytools

hal/library.c

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@
4141
#include "image.h"
4242
#include "printf.h"
4343

44+
/* force off NO_FILESYSTEM coming from include/user_settings.h */
45+
#ifdef PRINTF_ENABLED
46+
#undef NO_FILESYSTEM
47+
#endif
48+
4449
/* HAL Stubs */
4550
void hal_init(void)
4651
{
@@ -152,8 +157,12 @@ int main(int argc, const char* argv[])
152157
gImage = (uintptr_t)test_img;
153158
#else
154159
if (argc > 1) {
155-
size_t sz = 0;
160+
size_t sz = 0, bread;
156161
FILE* img = fopen(argv[1], "rb");
162+
if (img == NULL) {
163+
wolfBoot_printf("failed to open %s!\n", argv[1]);
164+
return -3;
165+
}
157166
fseek(img, 0, SEEK_END);
158167
sz = ftell(img);
159168
fseek(img, 0, SEEK_SET);
@@ -164,22 +173,24 @@ int main(int argc, const char* argv[])
164173
ret = -1;
165174
}
166175

167-
size_t bread = fread((void*)gImage, 1, sz, img);
176+
bread = fread((void*)gImage, 1, sz, img);
168177
if (bread != sz) {
169178
ret = -2;
170179
wolfBoot_printf("read %zu of %zu bytes from %s\n", bread, sz, argv[1]);
171180
}
172181
fclose(img);
173182
} else {
174183
wolfBoot_printf("usage: %s image_file.bin\n", argv[0]);
175-
return 255;
184+
ret = 255;
176185
}
177186
#endif
178-
179-
ret = wolfBoot_start();
187+
if (ret == 0) {
188+
ret = wolfBoot_start();
189+
}
180190

181191
#ifndef NO_FILESYSTEM
182-
free((void*)gImage);
192+
if ((void*)gImage != NULL)
193+
free((void*)gImage);
183194
#endif
184195
return ret;
185196
}

0 commit comments

Comments
 (0)