diff --git a/.gitignore b/.gitignore index 9b46ad2f..6955ac55 100644 --- a/.gitignore +++ b/.gitignore @@ -65,6 +65,10 @@ tools/keytools/x64 tools/keytools/Debug tools/keytools/Release +# delta binaries +tools/delta/bmdiff +tools/delta/bmpatch + # Vim swap files .*.swp diff --git a/Makefile b/Makefile index d02b654f..88581b05 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ include tools/config.mk ## Initializers WOLFBOOT_ROOT?=$(PWD) CFLAGS:=-D"__WOLFBOOT" -CFLAGS+=-Werror +CFLAGS+=-Werror -Wextra LSCRIPT:=config/target.ld LDFLAGS:= LD_START_GROUP:=-Wl,--start-group diff --git a/include/uart_drv.h b/include/uart_drv.h new file mode 100644 index 00000000..c250b499 --- /dev/null +++ b/include/uart_drv.h @@ -0,0 +1,32 @@ +/* uart_drv.h + * + * The HAL API definitions for UART driver extension. + * + * Copyright (C) 2021 wolfSSL Inc. + * + * This file is part of wolfBoot. + * + * wolfBoot is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * wolfBoot is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA + */ + +#ifndef H_HAL_UART_ +#define H_HAL_UART_ + +#include +int uart_tx(const uint8_t c); +int uart_rx(uint8_t *c); +int uart_init(uint32_t bitrate, uint8_t data, char parity, uint8_t stop); + +#endif /* H_HAL_UART_ */ diff --git a/include/uart_flash.h b/include/uart_flash.h index 566d16b5..11b38c55 100644 --- a/include/uart_flash.h +++ b/include/uart_flash.h @@ -31,15 +31,14 @@ #ifndef UART_FLASH_DRI_H #define UART_FLASH_DRI_H #include +#include "uart_drv.h" #ifdef UART_FLASH #ifndef UART_FLASH_BITRATE #define UART_FLASH_BITRATE 460800 #endif - int uart_init(uint32_t bitrate, uint8_t data, char parity, uint8_t stop); void uart_send_current_version(void); #else - #define uart_init(...) (-1) #define uart_send_current_version() do{}while(0) #endif /* UART_FLASH */ diff --git a/src/delta.c b/src/delta.c index 28f1400f..ad142aa4 100644 --- a/src/delta.c +++ b/src/delta.c @@ -171,7 +171,7 @@ int wb_diff(WB_DIFF_CTX *ctx, uint8_t *patch, uint32_t len) pa_start = (WOLFBOOT_SECTOR_SIZE + 1) * page_start; pa = ctx->src_a + pa_start; while (((uint32_t)(pa - ctx->src_a) < ctx->size_a ) && (p_off < len)) { - if ((ctx->size_a - (pa - ctx->src_a)) < BLOCK_HDR_SIZE) + if ((uint32_t)(ctx->size_a - (pa - ctx->src_a)) < BLOCK_HDR_SIZE) break; if ((ctx->size_b - ctx->off_b) < BLOCK_HDR_SIZE) break; @@ -214,7 +214,7 @@ int wb_diff(WB_DIFF_CTX *ctx, uint8_t *patch, uint32_t len) while (((uint32_t)(pb - ctx->src_b) < pb_end) && (p_off < len)) { if ((ctx->size_b - ctx->off_b) < BLOCK_HDR_SIZE) break; - if (ctx->size_b - (pb - ctx->src_b) < BLOCK_HDR_SIZE) + if ((uint32_t)(ctx->size_b - (pb - ctx->src_b)) < BLOCK_HDR_SIZE) break; if (WOLFBOOT_SECTOR_SIZE > (pb - ctx->src_b) - (page_start * WOLFBOOT_SECTOR_SIZE)) break; diff --git a/test-app/app_stm32wb.c b/test-app/app_stm32wb.c index b6cefbb8..753a8692 100644 --- a/test-app/app_stm32wb.c +++ b/test-app/app_stm32wb.c @@ -27,6 +27,7 @@ #include "led.h" #include "hal.h" #include "wolfboot/wolfboot.h" +#include "uart_drv.h" #ifdef PLATFORM_stm32wb char enc_key[] = "0123456789abcdef0123456789abcdef" /* ChaCha key (256 bit) */ diff --git a/tools/delta/Makefile b/tools/delta/Makefile index 0a2b0b56..e7c446a1 100644 --- a/tools/delta/Makefile +++ b/tools/delta/Makefile @@ -1,6 +1,5 @@ all: bmdiff bmpatch - - +CFLAGS+=-Wall -Werror -Wextra bmdiff: delta.o bmdiff.o gcc -o bmdiff delta.o bmdiff.o @@ -10,10 +9,10 @@ bmpatch: delta.o bmdiff.o lib: delta.o delta.o: - gcc -c -o delta.o ../../src/delta.c -I../../include -ggdb + gcc -c -o delta.o ../../src/delta.c -I../../include -ggdb $(CFLAGS) bmdiff.o: - gcc -c -o bmdiff.o bmdiff.c -I../../include -ggdb + gcc -c -o bmdiff.o bmdiff.c -I../../include -ggdb $(CFLAGS) clean: rm -f bmpatch bmdiff delta.o diff --git a/tools/delta/bmdiff.c b/tools/delta/bmdiff.c index e8ecec12..59e2e456 100644 --- a/tools/delta/bmdiff.c +++ b/tools/delta/bmdiff.c @@ -56,11 +56,12 @@ int main(int argc, char *argv[]) return 244; } if ((argc != 4) && (mode == MODE_DIFF)) { - printf("Usage: %s file1 file2 patch\n"); + printf("Usage: %s file1 file2 patch\n", argv[0]); exit(2); } if ((argc != 3) && (mode == MODE_PATCH)) { - printf("Usage: %s file patch (WARNING: patching is done in place and it will overwrite the original source.)\n"); + printf("Usage: %s file patch (WARNING: patching is done in place and it" + "will overwrite the original source.)\n", argv[0]); exit(2); } diff --git a/tools/keytools/Makefile b/tools/keytools/Makefile index 6e4854c0..12640cac 100644 --- a/tools/keytools/Makefile +++ b/tools/keytools/Makefile @@ -2,7 +2,8 @@ CC = gcc WOLFDIR = ../../lib/wolfssl/ -CFLAGS = -Wall -I. -DWOLFSSL_USER_SETTINGS -I$(WOLFDIR) -I../../include +CFLAGS = -Wall -Wextra -Werror +CFLAGS += -I. -DWOLFSSL_USER_SETTINGS -I$(WOLFDIR) -I../../include # option variables DEBUG_FLAGS = -g -DDEBUG -DDEBUG_SIGNTOOL -DDEBUG_WOLFSSL -DDEBUG_WOLFSSL_VERBOSE