Skip to content

Commit 9dba4be

Browse files
docs: Improve documentation organization and readability
- Add consistent structure across all docs - Improve visual formatting with tables and diagrams - Enhance code examples and configuration sections - Add cross-references between related documents - Fix formatting and organization Co-Authored-By: [email protected] <[email protected]>
1 parent 71346b8 commit 9dba4be

22 files changed

+3603
-2229
lines changed

docs/API.md

Lines changed: 79 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,105 @@
1-
# Application interface for interactions with the bootloader
1+
# Application Interface for wolfBoot
22

3-
wolfBoot offers a small interface to interact with the images stored in the partition,
4-
explicitly initiate an update and confirm the success of a previously scheduled update.
3+
wolfBoot provides an API through libwolfboot that allows applications to:
4+
- Query firmware versions in both BOOT and UPDATE partitions
5+
- Initiate firmware updates
6+
- Confirm successful firmware boots
7+
- Access partition states
58

6-
## Compiling and linking with libwolfboot
9+
## Compiling and Linking with libwolfboot
710

8-
An application that requires interactions with wolfBoot must include the header file:
11+
Applications using wolfBoot functionality must:
912

10-
`#include <wolfboot/wolfboot.h>`
13+
1. Include the wolfBoot header:
14+
```c
15+
#include <wolfboot/wolfboot.h>`
16+
```
1117

12-
This exports the API function declarations, and the predefined values for the flags
13-
and tags stored together with the firmware images in the two partitions.
18+
2. Link against libwolfboot library
1419

15-
For more information about flash partitions, flags and states see [Flash partitions](flash_partitions.md).
20+
The header provides:
21+
- API function declarations
22+
- Predefined partition flag values
23+
- Image tag definitions
24+
- Partition state constants
1625

17-
## API
26+
For details about flash partitions, flags and states see [Flash partitions](flash_partitions.md).
1827

19-
libwolfboot provides low-level access interface to flash partition states. The state
20-
of each partition can be retrieved and altered by the application.
28+
## Core API Functions
2129

22-
Basic interaction from the application is provided via the following high-level function calls:
30+
libwolfboot provides both high-level and low-level interfaces to manage firmware updates:
2331

24-
`uint32_t wolfBoot_get_image_version(uint8_t part)`
32+
### High-Level Functions
2533

26-
`void wolfBoot_update_trigger(void)`
34+
```c
35+
uint32_t wolfBoot_get_image_version(uint8_t part)
36+
void wolfBoot_update_trigger(void)
37+
void wolfBoot_success(void)
38+
```
2739
28-
`void wolfBoot_success(void)`
40+
### Version Management Functions
2941
30-
### Firmware version
42+
#### Get Image Version
43+
```c
44+
uint32_t wolfBoot_get_image_version(uint8_t part)
45+
```
46+
Retrieves the version number of the firmware in the specified partition.
3147

32-
Current (boot) firmware and update firmware versions can be retrieved from the application using:
48+
Parameters:
49+
- `part`: Partition ID (PART_BOOT or PART_UPDATE)
3350

34-
`uint32_t wolfBoot_get_image_version(uint8_t part)`
51+
Returns:
52+
- Version number of the firmware in the specified partition
53+
- 0 if no valid firmware exists in the partition
3554

36-
Or via the shortcut macros:
55+
#### Convenience Macros
56+
```c
57+
wolfBoot_current_firmware_version() // Get version of firmware in BOOT partition
58+
wolfBoot_update_firmware_version() // Get version of firmware in UPDATE partition
59+
```
3760

38-
`wolfBoot_current_firmware_version()`
61+
### Update Management Functions
3962

40-
and
63+
#### Trigger Update
64+
```c
65+
void wolfBoot_update_trigger(void)
66+
```
67+
Initiates the firmware update process for the next boot.
4168
42-
`wolfBoot_update_firmware_version()`
69+
Operation:
70+
1. Sets UPDATE partition state to `STATE_UPDATING`
71+
2. On next boot, wolfBoot will:
72+
- Verify the update image signature
73+
- Swap BOOT and UPDATE partition contents using SWAP space
74+
- Set new firmware state to `STATE_TESTING`
75+
- Boot into new firmware
4376
44-
### Trigger an update
77+
Note: The update image must be stored in the UPDATE partition before calling this function.
4578
46-
- `wolfBoot_update_trigger()` is used to trigger an update upon the next reboot, and it is normally used by
47-
an update application that has retrieved a new version of the running firmware, and has
48-
stored it in the UPDATE partition on the flash. This function will set the state of the UPDATE partition
49-
to `STATE_UPDATING`, instructing the bootloader to perform the update upon the next execution (after reboot).
79+
### Boot Confirmation Functions
5080
51-
wolfBoot update process swaps the contents of the UPDATE and the BOOT partitions, using a temporary
52-
single-block SWAP space.
81+
#### Confirm Successful Boot
82+
```c
83+
void wolfBoot_success(void)
84+
```
85+
Confirms successful boot of the current firmware.
5386

54-
### Confirm current image
87+
Operation:
88+
1. Marks current firmware in BOOT partition as `STATE_SUCCESS`
89+
2. Prevents automatic rollback on next boot
5590

56-
- `wolfBoot_success()` indicates a successful boot of a new firmware. This can be called by the application
57-
at any time, but it will only be effective to mark the current firmware (in the BOOT partition) with the state
58-
`STATE_SUCCESS`, indicating that no roll-back is required. An application should typically call `wolfBoot_success()`
59-
only after verifying that the basic system features are up and running, including the possibility to retrieve
60-
a new firmware for the next upgrade.
91+
Important:
92+
- Should be called only after verifying critical system functionality
93+
- Recommended to verify:
94+
- Core system features work correctly
95+
- Update capability is functional
96+
- Any required peripherals are accessible
6197

62-
If after an upgrade and reboot wolfBoot detects that the active firmware is still in `STATE_TESTING` state, it means that
63-
a successful boot has not been confirmed for the application, and will attempt to revert the update by swapping
64-
the two images again.
98+
Rollback Behavior:
99+
- If firmware remains in `STATE_TESTING` state after reboot
100+
- wolfBoot will automatically rollback to previous version
101+
- Accomplished by re-swapping BOOT and UPDATE partitions
65102

66-
For more information about the update process, see [Firmware Update](firmware_update.md)
67-
68-
For the image format, see [Firmware Image](firmware_image.md)
103+
Related Documentation:
104+
- [Firmware Update Process](firmware_update.md)
105+
- [Firmware Image Format](firmware_image.md)

0 commit comments

Comments
 (0)