mirror of https://github.com/wolfSSL/wolfBoot.git
Fixed after review comments
parent
7e93921396
commit
012bba3ce3
|
@ -65,6 +65,10 @@ tools/keytools/x64
|
||||||
tools/keytools/Debug
|
tools/keytools/Debug
|
||||||
tools/keytools/Release
|
tools/keytools/Release
|
||||||
|
|
||||||
|
# delta binaries
|
||||||
|
tools/delta/bmdiff
|
||||||
|
tools/delta/bmpatch
|
||||||
|
|
||||||
# Vim swap files
|
# Vim swap files
|
||||||
.*.swp
|
.*.swp
|
||||||
|
|
||||||
|
|
2
Makefile
2
Makefile
|
@ -10,7 +10,7 @@ include tools/config.mk
|
||||||
## Initializers
|
## Initializers
|
||||||
WOLFBOOT_ROOT?=$(PWD)
|
WOLFBOOT_ROOT?=$(PWD)
|
||||||
CFLAGS:=-D"__WOLFBOOT"
|
CFLAGS:=-D"__WOLFBOOT"
|
||||||
CFLAGS+=-Werror
|
CFLAGS+=-Werror -Wextra
|
||||||
LSCRIPT:=config/target.ld
|
LSCRIPT:=config/target.ld
|
||||||
LDFLAGS:=
|
LDFLAGS:=
|
||||||
LD_START_GROUP:=-Wl,--start-group
|
LD_START_GROUP:=-Wl,--start-group
|
||||||
|
|
|
@ -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_ */
|
|
@ -31,15 +31,14 @@
|
||||||
#ifndef UART_FLASH_DRI_H
|
#ifndef UART_FLASH_DRI_H
|
||||||
#define UART_FLASH_DRI_H
|
#define UART_FLASH_DRI_H
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include "uart_drv.h"
|
||||||
|
|
||||||
#ifdef UART_FLASH
|
#ifdef UART_FLASH
|
||||||
#ifndef UART_FLASH_BITRATE
|
#ifndef UART_FLASH_BITRATE
|
||||||
#define UART_FLASH_BITRATE 460800
|
#define UART_FLASH_BITRATE 460800
|
||||||
#endif
|
#endif
|
||||||
int uart_init(uint32_t bitrate, uint8_t data, char parity, uint8_t stop);
|
|
||||||
void uart_send_current_version(void);
|
void uart_send_current_version(void);
|
||||||
#else
|
#else
|
||||||
#define uart_init(...) (-1)
|
|
||||||
#define uart_send_current_version() do{}while(0)
|
#define uart_send_current_version() do{}while(0)
|
||||||
#endif /* UART_FLASH */
|
#endif /* UART_FLASH */
|
||||||
|
|
||||||
|
|
|
@ -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_start = (WOLFBOOT_SECTOR_SIZE + 1) * page_start;
|
||||||
pa = ctx->src_a + pa_start;
|
pa = ctx->src_a + pa_start;
|
||||||
while (((uint32_t)(pa - ctx->src_a) < ctx->size_a ) && (p_off < len)) {
|
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;
|
break;
|
||||||
if ((ctx->size_b - ctx->off_b) < BLOCK_HDR_SIZE)
|
if ((ctx->size_b - ctx->off_b) < BLOCK_HDR_SIZE)
|
||||||
break;
|
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)) {
|
while (((uint32_t)(pb - ctx->src_b) < pb_end) && (p_off < len)) {
|
||||||
if ((ctx->size_b - ctx->off_b) < BLOCK_HDR_SIZE)
|
if ((ctx->size_b - ctx->off_b) < BLOCK_HDR_SIZE)
|
||||||
break;
|
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;
|
break;
|
||||||
if (WOLFBOOT_SECTOR_SIZE > (pb - ctx->src_b) - (page_start * WOLFBOOT_SECTOR_SIZE))
|
if (WOLFBOOT_SECTOR_SIZE > (pb - ctx->src_b) - (page_start * WOLFBOOT_SECTOR_SIZE))
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include "led.h"
|
#include "led.h"
|
||||||
#include "hal.h"
|
#include "hal.h"
|
||||||
#include "wolfboot/wolfboot.h"
|
#include "wolfboot/wolfboot.h"
|
||||||
|
#include "uart_drv.h"
|
||||||
|
|
||||||
#ifdef PLATFORM_stm32wb
|
#ifdef PLATFORM_stm32wb
|
||||||
char enc_key[] = "0123456789abcdef0123456789abcdef" /* ChaCha key (256 bit) */
|
char enc_key[] = "0123456789abcdef0123456789abcdef" /* ChaCha key (256 bit) */
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
all: bmdiff bmpatch
|
all: bmdiff bmpatch
|
||||||
|
CFLAGS+=-Wall -Werror -Wextra
|
||||||
|
|
||||||
bmdiff: delta.o bmdiff.o
|
bmdiff: delta.o bmdiff.o
|
||||||
gcc -o bmdiff delta.o bmdiff.o
|
gcc -o bmdiff delta.o bmdiff.o
|
||||||
|
|
||||||
|
@ -10,10 +9,10 @@ bmpatch: delta.o bmdiff.o
|
||||||
lib: delta.o
|
lib: delta.o
|
||||||
|
|
||||||
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:
|
bmdiff.o:
|
||||||
gcc -c -o bmdiff.o bmdiff.c -I../../include -ggdb
|
gcc -c -o bmdiff.o bmdiff.c -I../../include -ggdb $(CFLAGS)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f bmpatch bmdiff delta.o
|
rm -f bmpatch bmdiff delta.o
|
||||||
|
|
|
@ -56,11 +56,12 @@ int main(int argc, char *argv[])
|
||||||
return 244;
|
return 244;
|
||||||
}
|
}
|
||||||
if ((argc != 4) && (mode == MODE_DIFF)) {
|
if ((argc != 4) && (mode == MODE_DIFF)) {
|
||||||
printf("Usage: %s file1 file2 patch\n");
|
printf("Usage: %s file1 file2 patch\n", argv[0]);
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
if ((argc != 3) && (mode == MODE_PATCH)) {
|
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);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
|
|
||||||
CC = gcc
|
CC = gcc
|
||||||
WOLFDIR = ../../lib/wolfssl/
|
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
|
# option variables
|
||||||
DEBUG_FLAGS = -g -DDEBUG -DDEBUG_SIGNTOOL -DDEBUG_WOLFSSL -DDEBUG_WOLFSSL_VERBOSE
|
DEBUG_FLAGS = -g -DDEBUG -DDEBUG_SIGNTOOL -DDEBUG_WOLFSSL -DDEBUG_WOLFSSL_VERBOSE
|
||||||
|
|
Loading…
Reference in New Issue