-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add wasp-reloader as a git submodule.
Convert the .bin file in hex and then in .h file for the reloader. Build the reloader to generate the DFU file that will allow to upgrade the bootloader on a PineTime
- Loading branch information
Showing
5 changed files
with
66 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,3 +47,5 @@ libftdi1*.bz2 | |
libusb*/ | ||
hidapi*/ | ||
.idea/* | ||
|
||
/reloader/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "reloader"] | ||
path = reloader | ||
url = [email protected]:daniel-thompson/wasp-reloader.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# SPDX-License-Identifier: LGPL-3.0-or-later | ||
# Copyright (C) 2020 Daniel Thompson | ||
|
||
import binascii | ||
import intelhex | ||
import sys | ||
|
||
def generate_c(ihex): | ||
print('/* this file is auto-generated - DO NOT EDIT */') | ||
print() | ||
print('#include <stdint.h>') | ||
print() | ||
print('struct segment {') | ||
print(' uint32_t start;'); | ||
print(' uint32_t end;'); | ||
print(' uint32_t crc32;') | ||
print(' const uint8_t *data;') | ||
print('};') | ||
print() | ||
|
||
segments = [] | ||
chunk = 32 * 1024 | ||
for (start, end) in ihex.segments(): | ||
while start + chunk < end: | ||
segments.append((start, start + chunk)) | ||
start += chunk | ||
if start < end: | ||
segments.append((start, end)) | ||
|
||
for i, segment in enumerate(segments): | ||
print(f'static const uint8_t segment{i}[] = {{', end='') | ||
|
||
for j in range(segment[0], segment[1]): | ||
if 0 == j % 12: | ||
print('\n ', end='') | ||
print(f' 0x{ihex[j]:02x},', end='') | ||
|
||
print('\n};\n') | ||
print(f'const struct segment segments[] = {{') | ||
for i, segment in enumerate(segments): | ||
sg = ihex.tobinarray(start=segment[0], end=segment[1]-1) | ||
crc = binascii.crc32(sg) | ||
print(f' 0x{segment[0]:08x}, 0x{segment[1]:08x}, 0x{crc:08x}, segment{i},') | ||
print('};') | ||
|
||
ihex = intelhex.IntelHex() | ||
ihex.loadhex(sys.argv[1]) | ||
generate_c(ihex) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters