Skip to content

Commit

Permalink
Merge pull request #796 from adafruit/update-bootloader-0.8.0
Browse files Browse the repository at this point in the history
Update bootloader 0.8.0, fix File namespace issue
  • Loading branch information
hathach authored Oct 16, 2023
2 parents bf50479 + 27981a3 commit 1e6cf80
Show file tree
Hide file tree
Showing 50 changed files with 50,757 additions and 51,430 deletions.

This file was deleted.

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.
11,716 changes: 11,716 additions & 0 deletions bootloader/clue_nrf52840/clue_nrf52840_bootloader-0.8.0_s140_6.1.1.hex

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.

Large diffs are not rendered by default.

Binary file not shown.

This file was deleted.

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.
11,717 changes: 11,717 additions & 0 deletions bootloader/ledglasses_nrf52840/ledglasses_nrf52840_bootloader-0.8.0_s140_6.1.1.hex

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion libraries/Adafruit_TinyUSB_Arduino
2 changes: 1 addition & 1 deletion libraries/Adafruit_nRFCrypto
31 changes: 17 additions & 14 deletions libraries/Bluefruit52Lib/src/utility/bonding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@
#include "bonding.h"
#include "bluefruit.h"

using namespace Adafruit_LittleFS_Namespace;
enum {
FO_READ = Adafruit_LittleFS_Namespace::FILE_O_READ,
FO_WRITE = Adafruit_LittleFS_Namespace::FILE_O_WRITE,
};

#define BOND_DEBUG 1

Expand All @@ -68,7 +71,7 @@ static void get_fname (char* fname, uint8_t role, uint8_t const mac[6])
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
}

static bool bdata_skip_field(File* file)
static bool bdata_skip_field(Adafruit_LittleFS_Namespace::File* file)
{
int len = file->read();
VERIFY(len > 0);
Expand All @@ -77,7 +80,7 @@ static bool bdata_skip_field(File* file)
return true;
}

static void bdata_write(File* file, void const* buffer, uint16_t bufsize)
static void bdata_write(Adafruit_LittleFS_Namespace::File* file, void const* buffer, uint16_t bufsize)
{
file->write( (uint8_t) bufsize );
file->write( (uint8_t const*) buffer, bufsize);
Expand Down Expand Up @@ -106,7 +109,7 @@ static void bond_save_keys_dfr (uint8_t role, uint16_t conn_hdl, bond_keys_t con
// delete if file already exists
if ( InternalFS.exists(filename) ) InternalFS.remove(filename);

File file(filename, FILE_O_WRITE, InternalFS);
Adafruit_LittleFS_Namespace::File file(filename, FO_WRITE, InternalFS);
VERIFY(file,);

//------------- save keys -------------//
Expand Down Expand Up @@ -150,8 +153,8 @@ bool bond_load_keys(uint8_t role, ble_gap_addr_t* addr, bond_keys_t* bkeys)
char filename[BOND_FNAME_LEN];
get_fname(filename, role, addr->addr);

File file(InternalFS);
if( file.open(filename, FILE_O_READ) )
Adafruit_LittleFS_Namespace::File file(InternalFS);
if( file.open(filename, FO_READ) )
{
int keylen = file.read();
if ( keylen > 0 )
Expand All @@ -172,10 +175,10 @@ bool bond_load_keys(uint8_t role, ble_gap_addr_t* addr, bond_keys_t* bkeys)
// Resolvable address, we have to go through the whole list to perform IRK Address matching

char const * dpath = (role == BLE_GAP_ROLE_PERIPH ? BOND_DIR_PRPH : BOND_DIR_CNTR);
File dir(dpath, FILE_O_READ, InternalFS);
File file(InternalFS);
Adafruit_LittleFS_Namespace::File dir(dpath, FO_READ, InternalFS);
Adafruit_LittleFS_Namespace::File file(InternalFS);

while ( !ret && (file = dir.openNextFile(FILE_O_READ)) )
while ( !ret && (file = dir.openNextFile(FO_READ)) )
{
int keylen = file.read();
if ( keylen == sizeof(bond_keys_t) )
Expand Down Expand Up @@ -217,7 +220,7 @@ static void bond_save_cccd_dfr (uint8_t role, uint16_t conn_hdl, ble_gap_addr_t
char filename[BOND_FNAME_LEN];
get_fname(filename, role, id_addr->addr);

File file(filename, FILE_O_WRITE, InternalFS);
Adafruit_LittleFS_Namespace::File file(filename, FO_WRITE, InternalFS);
VERIFY(file,);

file.seek(0); // write mode start at the end, seek to beginning
Expand Down Expand Up @@ -266,7 +269,7 @@ bool bond_load_cccd(uint8_t role, uint16_t conn_hdl, ble_gap_addr_t const* id_ad
char filename[BOND_FNAME_LEN];
get_fname(filename, role, id_addr->addr);

File file(filename, FILE_O_READ, InternalFS);
Adafruit_LittleFS_Namespace::File file(filename, FO_READ, InternalFS);
if ( file )
{
bdata_skip_field(&file); // skip key
Expand Down Expand Up @@ -298,10 +301,10 @@ void bond_print_list(uint8_t role)
{
char const * dpath = (role == BLE_GAP_ROLE_PERIPH ? BOND_DIR_PRPH : BOND_DIR_CNTR);

File dir(dpath, FILE_O_READ, InternalFS);
File file(InternalFS);
Adafruit_LittleFS_Namespace::File dir(dpath, FO_READ, InternalFS);
Adafruit_LittleFS_Namespace::File file(InternalFS);

while ( (file = dir.openNextFile(FILE_O_READ)) )
while ( (file = dir.openNextFile(FO_READ)) )
{
if ( !file.isDirectory() && bdata_skip_field(&file) ) // skip key
{
Expand Down
2 changes: 1 addition & 1 deletion platform.txt
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ tools.nrfutil.upload.pattern="{cmd}" {upload.verbose} dfu serial -pkg "{build.pa
# ---------------------------------------------------

# Bootloader version
tools.bootburn.bootloader.file={runtime.platform.path}/bootloader/{build.variant}/{build.variant}_bootloader-0.6.2_{build.sd_name}_{build.sd_version}
tools.bootburn.bootloader.file={runtime.platform.path}/bootloader/{build.variant}/{build.variant}_bootloader-0.8.0_{build.sd_name}_{build.sd_version}

tools.bootburn.bootloader.params.verbose=
tools.bootburn.bootloader.params.quiet=
Expand Down
48 changes: 29 additions & 19 deletions tools/update_bootloader.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import os
import shutil
import urllib.request
import zipfile
from multiprocessing import Pool

# Get all variants
all_variant = []
Expand All @@ -11,33 +10,44 @@
all_variant.sort()

# Detect version in platform.txt
version = '';
version = ''
with open('platform.txt') as pf:
platform_txt = pf.read()
e = '{build.variant}_bootloader-'
v1 = platform_txt.index(e) + len(e)
v2 = platform_txt.index('_', v1)
version = platform_txt[v1:v2]

print('version {}'.format(version))
print(f'version {version}')

for variant in all_variant:

# Download a variant's bootloader
def download_variant(variant):
# Download from bootloader release
name = '{}_bootloader-{}.zip'.format(variant, version)
url = 'https://github.com/adafruit/Adafruit_nRF52_Bootloader/releases/download/{}/{}'.format(version, name)
print("Downloading", name)
urllib.request.urlretrieve(url, name)
sd_version = '6.1.1'
sd_name = 's140'
if variant == 'feather_nrf52832':
sd_name = 's132'

# remove existing bootloader
shutil.rmtree('bootloader/{}'.format(variant), ignore_errors=True)
f_zip = f'{variant}_bootloader-{version}_{sd_name}_{sd_version}.zip'
f_hex = f'{variant}_bootloader-{version}_{sd_name}_{sd_version}.hex'
f_uf2 = f'update-{variant}_bootloader-{version}_nosd.uf2'
url_prefix = f'https://github.com/adafruit/Adafruit_nRF52_Bootloader/releases/download/{version}/'

# unzip
with zipfile.ZipFile(name, "r") as zip_ref:
zip_ref.extractall("bootloader/{}".format(variant))
# remove existing bootloader files
for item in os.listdir(f'bootloader/{variant}'):
os.remove(os.path.join(f'bootloader/{variant}', item))

# Remove update.uf2 for 832
if variant == 'feather_nrf52832':
os.remove("bootloader/{}/update-{}_nosd.uf2".format(variant, name[:-4]))
print(f"Downloading {f_zip}")
urllib.request.urlretrieve(url_prefix + f_zip, f'bootloader/{variant}/{f_zip}')

print(f"Downloading {f_hex}")
urllib.request.urlretrieve(url_prefix + f_hex, f'bootloader/{variant}/{f_hex}')

if sd_name != 's132':
print(f"Downloading {f_uf2}")
urllib.request.urlretrieve(url_prefix + f_uf2, f'bootloader/{variant}/{f_uf2}')

# remove zip file
os.remove(name)
if __name__ == "__main__":
with Pool() as p:
p.map(download_variant, all_variant)

0 comments on commit 1e6cf80

Please sign in to comment.