Skip to content

Commit eb7ddf5

Browse files
committed
Fix BLE workflow and add boot_out.txt UID
Fixes #6621
1 parent 83cbbc9 commit eb7ddf5

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

main.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,13 +748,24 @@ STATIC void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) {
748748

749749
if (ok_to_run) {
750750
#ifdef CIRCUITPY_BOOT_OUTPUT_FILE
751+
// Turn off title bar updates when writing out to boot_out.txt.
752+
supervisor_title_bar_suspend();
751753
vstr_t boot_text;
752754
vstr_init(&boot_text, 512);
753755
boot_output = &boot_text;
754756
#endif
755757

756758
// Write version info
757759
mp_printf(&mp_plat_print, "%s\nBoard ID:%s\n", MICROPY_FULL_VERSION_INFO, CIRCUITPY_BOARD_ID);
760+
#if CIRCUITPY_MICROCONTROLLER && COMMON_HAL_MCU_PROCESSOR_UID_LENGTH > 0
761+
uint8_t raw_id[COMMON_HAL_MCU_PROCESSOR_UID_LENGTH];
762+
common_hal_mcu_processor_get_uid(raw_id);
763+
mp_printf(&mp_plat_print, "UID:");
764+
for (uint8_t i = 0; i < COMMON_HAL_MCU_PROCESSOR_UID_LENGTH; i++) {
765+
mp_printf(&mp_plat_print, "%02X", raw_id[i]);
766+
}
767+
mp_printf(&mp_plat_print, "\n");
768+
#endif
758769

759770
bool found_boot = maybe_run_list(boot_py_filenames);
760771
(void)found_boot;
@@ -766,6 +777,7 @@ STATIC void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) {
766777
FATFS *fs = &vfs->fatfs;
767778

768779
boot_output = NULL;
780+
supervisor_title_bar_resume();
769781
bool write_boot_output = true;
770782
FIL boot_output_file;
771783
if (f_open(fs, &boot_output_file, CIRCUITPY_BOOT_OUTPUT_FILE, FA_READ) == FR_OK) {
@@ -855,6 +867,13 @@ STATIC int run_repl(bool first_run) {
855867
}
856868
#endif
857869
cleanup_after_vm(heap, MP_OBJ_SENTINEL);
870+
871+
// Also reset bleio. The above call omits it in case workflows should continue. In this case,
872+
// we're switching straight to another VM so we want to reset.
873+
#if CIRCUITPY_BLEIO
874+
bleio_reset();
875+
#endif
876+
858877
#if CIRCUITPY_STATUS_LED
859878
status_led_init();
860879
new_status_color(BLACK);

supervisor/shared/bluetooth/bluetooth.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,6 @@ STATIC void supervisor_bluetooth_start_advertising(void) {
166166
circuitpython_scan_response_data[1] = 0x9;
167167
}
168168
scan_response_len = circuitpython_scan_response_data[0] + 1;
169-
assert(scan_response_len < 32);
170-
mp_printf(&mp_plat_print, "sr len %d\n", scan_response_len);
171169
_private_advertising = false;
172170
}
173171
uint32_t status = _common_hal_bleio_adapter_start_advertising(&common_hal_bleio_adapter_obj,
@@ -282,6 +280,8 @@ void supervisor_bluetooth_background(void) {
282280
if (!is_connected) {
283281
supervisor_bluetooth_start_advertising();
284282
return;
283+
} else {
284+
advertising = false;
285285
}
286286

287287
#if CIRCUITPY_BLE_FILE_SERVICE
@@ -293,7 +293,7 @@ void supervisor_bluetooth_background(void) {
293293
void supervisor_start_bluetooth(void) {
294294
#if CIRCUITPY_BLE_FILE_SERVICE || CIRCUITPY_SERIAL_BLE
295295

296-
if (workflow_state != WORKFLOW_ENABLED) {
296+
if (workflow_state != WORKFLOW_ENABLED || ble_started) {
297297
return;
298298
}
299299

@@ -324,6 +324,8 @@ void supervisor_stop_bluetooth(void) {
324324
return;
325325
}
326326

327+
ble_started = false;
328+
327329
#if CIRCUITPY_SERIAL_BLE
328330
supervisor_stop_bluetooth_serial();
329331
#endif

supervisor/shared/title_bar.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ void supervisor_title_bar_update(void) {
4949
#if !CIRCUITPY_STATUS_BAR
5050
return;
5151
#endif
52+
if (_suspended) {
53+
supervisor_title_bar_request_update(true);
54+
return;
55+
}
5256
_forced_dirty = false;
5357
// Neighboring "" "" are concatenated by the compiler. Without this separation, the hex code
5458
// doesn't get terminated after two following characters and the value is invalid.

0 commit comments

Comments
 (0)