Fixed after review comments

pull/125/head
Daniele Lacamera 2021-08-20 10:08:28 +02:00
parent 7e93921396
commit 012bba3ce3
9 changed files with 49 additions and 12 deletions

4
.gitignore vendored
View File

@ -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

View File

@ -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

32
include/uart_drv.h 100644
View File

@ -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 <stdint.h>
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_ */

View File

@ -31,15 +31,14 @@
#ifndef UART_FLASH_DRI_H
#define UART_FLASH_DRI_H
#include <stdint.h>
#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 */

View File

@ -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;

View File

@ -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) */

View File

@ -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

View File

@ -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);
}

View File

@ -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