Skip to content

Commit 3f7341b

Browse files
committed
reorganization of files
1 parent 17ade83 commit 3f7341b

File tree

12 files changed

+46
-24
lines changed

12 files changed

+46
-24
lines changed

README.md

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
# bpatch
2-
Application to generate a patch between two binary files without compression. The algorithm is based on the bash command DIFF.
3-
It is available a Python application to encode (generate the patch)and decode (rebuild the new firmware) options. The decode is based on a C code.
42

5-
**NOTE**: the os system command **diff** must be present, the python script work only on Linux
3+
## overview
4+
Application to generate a patch between two binary files without compression. The differential algorithm is based on the bash command DIFF.
5+
It is available a Python application to encode (generate the patch) and decode (rebuild the new firmware) options. The decode is based on a C code.
66

7-
## How to configure
8-
It is available a script to build the C code for CPU and configure the Python script
7+
## prerequisite
8+
The application works only on Linux operating system
9+
10+
## how to configure
11+
It is available a script to build and configure the Python script
912

1013
sh configure.sh
1114

@@ -16,7 +19,7 @@ It is available a script to build the C code for CPU and configure the Python sc
1619

1720
options:
1821

19-
-v : verify che correctness of the patch
22+
-v : verify che correctness of the patch
2023
-V : verify che correctness of the txt patch
2124
-t FILENAME: write the patch in txt format
2225
-b FILENAME: write the patch in binary format
@@ -34,18 +37,6 @@ It is available a script to build the C code for CPU and configure the Python sc
3437
-p SIZE: set the patch buffer size
3538

3639

37-
38-
## How to use C code
39-
- usage for CPU
40-
41-
./bpatch <old_firmware> <patch> <new_firmware> <read_buffer_size> <patch_buffer_size>
42-
43-
- usage for MCU
44-
45-
- copy *bpatch.c* and *bpatch.h*
46-
- add definition of memory functions and log function
47-
- remove define **TEST_PATCH**
48-
4940
## bpatch structure
5041
Are present two instructions: **CPY** to copy bytes from the old firmware, **ADD** to add new bytes. To save the bit to indicate the command in final patch it is assumed that the first instruction is a **CPY** then there is an alternance between **ADD** and **CPY**
5142

@@ -162,6 +153,8 @@ In *bpatch.c*
162153

163154
- define *write_header*: function to re-built header for correspondent bytes from the patch
164155

156+
In the repository is present as example a custum header for SBSFU expansion for STM32, detailed [here](https://www.st.com/en/embedded-software/x-cube-sbsfu.html)
157+
165158

166159
## CSV report format
167160

@@ -175,4 +168,9 @@ Fields of CSV report:
175168
- **OVER_NBD**: number of bit necessary to NBD field compared to the total number new bytes in percentage
176169
- **OVER_NBC**: number of bit necessary to NBC field compared to the total number new bytes in percentage
177170
- **OVER_NBA**: number of bit necessary to NBA field compared to the total number new bytes in percentage
178-
- **OVER_TOT**: number of bit necessary to NBD, NBC, NBA fields compared to the total number new bytes in percentage
171+
- **OVER_TOT**: number of bit necessary to NBD, NBC, NBA fields compared to the total number new bytes in percentage
172+
173+
174+
## Test environment
175+
176+
It is present a **test** folder when the application can be tested and assessed on firmwares

bpatch.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
from path_bpatch import path_patch_exec
77

88
# enable custom header
9-
header_custom = True
10-
from header_sbsfu import header_fw_size, header_patch_size, header_lines, write_header_custom
9+
header_custom = False
10+
# from custom_header.header_sbsfu import header_fw_size, header_patch_size, header_lines, write_header_custom
1111

1212
""" Custom Header definition start """
1313
if not header_custom:
File renamed without changes.

c/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
C source code to apply the patch and reconstruct the new firmware. The application read and write from generic flash memory, it is possible to define the read/write functions.
2+
To test the code it is created a wrapper where the memory region is mapped on the stack, firmwares and patch are passed as files. To enable the wrapper you have to
3+
enable the MACRO **TEST_PATCH**
4+
5+
## How to use
6+
7+
- usage when macro **TEST_PATCH** is enabled
8+
9+
./bpatch <old_firmware> <patch> <new_firmware> <read_buffer_size> <patch_buffer_size>
10+
11+
- usage for MCU or generic porcessor
12+
13+
- copy *bpatch.c* and *bpatch.h*
14+
- add definition of memory functions and log function
15+
- add memory address of old firmware slot, new firmware slot and pacth slot
16+
- remove define **TEST_PATCH**
17+
- use with:
18+
19+
bpatch();
20+
21+
## Custom header
22+
23+
In *header_sbsfu.c* and *header_sbsfu.h* are present an example of custom header function and defines based on SBSFU expansion packet for STM32 detailed [here](https://www.st.com/en/embedded-software/x-cube-sbsfu.html)
File renamed without changes.

bpatch.h renamed to c/bpatch.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#define TEST_PATCH
1616
/* define to indicate the presence of custom header of the firmware */
1717
//#define HEADER_PATCH
18-
#define HEADER_SBSFU
18+
//#define HEADER_SBSFU
1919

2020
#ifdef TEST_PATCH
2121
/* addresses of the slots */
File renamed without changes.
File renamed without changes.

main.c renamed to c/main.c

File renamed without changes.

main.h renamed to c/main.h

File renamed without changes.

0 commit comments

Comments
 (0)