Skip to content

Commit

Permalink
Update version to 1.0.1
Browse files Browse the repository at this point in the history
Add doc about the generation of the version bitmap
  • Loading branch information
JF002 committed Sep 4, 2024
1 parent b6b8d4d commit ae02f94
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 27 deletions.
47 changes: 47 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,53 @@ The goal of this firmware is to provide a mean for the user to OTA a new firmwar
- Configure mynewt : `newt upgrade`
- Build : `scripts/nrf52/build-boot.sh`. The firmware is generated in `bin/targets/nrf52_boot/app/@mcuboot/boot/mynewt/mynewt.elf` and the DFU file for the reloader : `reloader/build-pinetime/reloader-mcuboot.zip`

### Bitmap generation

This project uses 2 bitmaps (defined in [graphic.h](libs/pinetime_boot/src/graphic.h)) :
- the Pine logo
- the version indicator

To reduce the amount of flash memory needed to store them, they are compressed using a simple [RLE encoding](https://en.wikipedia.org/wiki/Run-length_encoding).

Use the tool [rle_encode.py](tools/rle_encode.py) to convert a png file into a RLE encoded buffer:

```shell
python tools/rle_encode.py --c libs/pinetime_boot/src/version-1.0.1.png
```

Here is the corresponding output :

```
// 1-bit RLE, generated from libs/pinetime_boot/src/version-1.0.1.png, 269 bytes
static const uint8_t version-1.0.1[] = {
0x59, 0x56, 0x2, 0x56, 0x2, 0x56, 0x2, 0x56, 0x2, 0x2, 0x2, 0xd,
0x2, 0x5, 0x4, 0x15, 0x5, 0x12, 0x4, 0xa, 0x2, 0x3, 0x2, 0xb,
0x2, 0x4, 0x6, 0x13, 0x9, 0xe, 0x6, 0xa, 0x2, 0x3, 0x2, 0xb,
0x2, 0x4, 0x2, 0x2, 0x2, 0x13, 0x2, 0x5, 0x2, 0xe, 0x2, 0x2,
0x2, 0xa, 0x2, 0x3, 0x3, 0x9, 0x3, 0x8, 0x2, 0x12, 0x2, 0x7,
0x2, 0x11, 0x2, 0xa, 0x2, 0x4, 0x2, 0x9, 0x2, 0x9, 0x2, 0x12,
0x2, 0x7, 0x2, 0x11, 0x2, 0xa, 0x2, 0x4, 0x2, 0x9, 0x2, 0x9,
0x2, 0x11, 0x2, 0x9, 0x2, 0x10, 0x2, 0xa, 0x2, 0x5, 0x2, 0x7,
0x2, 0xa, 0x2, 0x11, 0x2, 0x9, 0x2, 0x10, 0x2, 0xa, 0x2, 0x5,
0x2, 0x7, 0x2, 0xa, 0x2, 0x11, 0x2, 0x9, 0x2, 0x10, 0x2, 0xa,
0x2, 0x5, 0x3, 0x5, 0x3, 0xa, 0x2, 0x11, 0x2, 0x9, 0x2, 0x10,
0x2, 0xa, 0x2, 0x6, 0x2, 0x5, 0x2, 0xb, 0x2, 0x11, 0x2, 0x9,
0x2, 0x10, 0x2, 0xa, 0x2, 0x6, 0x2, 0x5, 0x2, 0xb, 0x2, 0x11,
0x2, 0x9, 0x2, 0x10, 0x2, 0xa, 0x2, 0x7, 0x2, 0x3, 0x2, 0xc,
0x2, 0x11, 0x2, 0x9, 0x2, 0x10, 0x2, 0xa, 0x2, 0x7, 0x2, 0x3,
0x2, 0xc, 0x2, 0x11, 0x2, 0x9, 0x2, 0x10, 0x2, 0xa, 0x2, 0x7,
0x2, 0x3, 0x2, 0xc, 0x2, 0x12, 0x2, 0x7, 0x2, 0x11, 0x2, 0xa,
0x2, 0x8, 0x2, 0x1, 0x2, 0xd, 0x2, 0x12, 0x2, 0x7, 0x2, 0x11,
0x2, 0xa, 0x2, 0x8, 0x2, 0x1, 0x2, 0xd, 0x2, 0xa, 0x2, 0x7,
0x2, 0x5, 0x2, 0x6, 0x2, 0xa, 0x2, 0xa, 0x2, 0x8, 0x5, 0x9,
0xa, 0x6, 0x2, 0x7, 0x9, 0x6, 0x2, 0x6, 0xa, 0x6, 0x2, 0x9,
0x3, 0xa, 0xa, 0x6, 0x2, 0x9, 0x5, 0x8, 0x2, 0x6, 0xa, 0x6,
0x2, 0x56, 0x2, 0x56, 0x59,
};
```

You can then copy/paste this C array to the corresponding definition in [graphic.h](libs/pinetime_boot/src/graphic.h).

## About the code

This project is based on MyNEWT RTOS and MCUBoot bootloader. The specific code for the PineTime is located in `libs/pinetime_boot`.
Expand Down
2 changes: 1 addition & 1 deletion libs/pinetime_boot/include/pinetime_boot/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#define PINETIME_BOOTLOADER_VERSION_MAJOR 1u
#define PINETIME_BOOTLOADER_VERSION_MINOR 0u
#define PINETIME_BOOTLOADER_VERSION_PATCH 0u
#define PINETIME_BOOTLOADER_VERSION_PATCH 1u
#define PINETIME_BOOTLOADER_VERSION ((PINETIME_BOOTLOADER_VERSION_MAJOR << 16u) | (PINETIME_BOOTLOADER_VERSION_MINOR << 8u) | (PINETIME_BOOTLOADER_VERSION_PATCH))

void pinetime_set_version(void);
Expand Down
49 changes: 23 additions & 26 deletions libs/pinetime_boot/src/graphic.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,32 +113,29 @@ struct imgInfo bootLogoInfo = {
// /home/jf/nrf52/Pinetime/tools/rle_encode.py /home/jf/nrf52/pinetime-rust-mynewt/libs/pinetime_boot/src/version-0.0.1.png --c
static const uint8_t versionRle[] = {
0x59, 0x56, 0x2, 0x56, 0x2, 0x56, 0x2, 0x56, 0x2, 0x2, 0x2, 0xd,
0x2, 0x5, 0x4, 0x15, 0x5, 0x13, 0x5, 0x8, 0x2, 0x3, 0x2, 0xb,
0x2, 0x4, 0x6, 0x13, 0x9, 0xf, 0x9, 0x6, 0x2, 0x3, 0x2, 0xb,
0x2, 0x4, 0x2, 0x2, 0x2, 0x13, 0x2, 0x5, 0x2, 0xf, 0x2, 0x5,
0x2, 0x6, 0x2, 0x3, 0x3, 0x9, 0x3, 0x8, 0x2, 0x12, 0x2, 0x7,
0x2, 0xd, 0x2, 0x7, 0x2, 0x5, 0x2, 0x4, 0x2, 0x9, 0x2, 0x9,
0x2, 0x12, 0x2, 0x7, 0x2, 0xd, 0x2, 0x7, 0x2, 0x5, 0x2, 0x4,
0x2, 0x9, 0x2, 0x9, 0x2, 0x11, 0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2, 0xa, 0x2, 0x8, 0x2, 0x1, 0x2, 0xd, 0x2, 0xa, 0x2, 0x7,
0x2, 0x5, 0x2, 0x6, 0x2, 0xa, 0x2, 0xa, 0x2, 0x8, 0x5, 0x9,
0xa, 0x6, 0x2, 0x7, 0x9, 0x6, 0x2, 0x6, 0xa, 0x6, 0x2, 0x9,
0x3, 0xa, 0xa, 0x6, 0x2, 0x9, 0x5, 0x8, 0x2, 0x6, 0xa, 0x6,
0x2, 0x56, 0x2, 0x56, 0x59,
};

struct imgInfo versionInfo = {
88,
Expand Down
Binary file removed libs/pinetime_boot/src/version-1.0.0.png
Binary file not shown.
Binary file added libs/pinetime_boot/src/version-1.0.1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.

0 comments on commit ae02f94

Please sign in to comment.