Fix BLE workflow and add boot_out.txt UID

Fixes #6621
This commit is contained in:
Scott Shawcroft 2022-08-03 16:30:07 -07:00
parent 83cbbc9946
commit eb7ddf52e6
No known key found for this signature in database
GPG Key ID: 0DFD512649C052DA
3 changed files with 28 additions and 3 deletions

19
main.c
View File

@ -748,6 +748,8 @@ STATIC void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) {
if (ok_to_run) {
#ifdef CIRCUITPY_BOOT_OUTPUT_FILE
// Turn off title bar updates when writing out to boot_out.txt.
supervisor_title_bar_suspend();
vstr_t boot_text;
vstr_init(&boot_text, 512);
boot_output = &boot_text;
@ -755,6 +757,15 @@ STATIC void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) {
// Write version info
mp_printf(&mp_plat_print, "%s\nBoard ID:%s\n", MICROPY_FULL_VERSION_INFO, CIRCUITPY_BOARD_ID);
#if CIRCUITPY_MICROCONTROLLER && COMMON_HAL_MCU_PROCESSOR_UID_LENGTH > 0
uint8_t raw_id[COMMON_HAL_MCU_PROCESSOR_UID_LENGTH];
common_hal_mcu_processor_get_uid(raw_id);
mp_printf(&mp_plat_print, "UID:");
for (uint8_t i = 0; i < COMMON_HAL_MCU_PROCESSOR_UID_LENGTH; i++) {
mp_printf(&mp_plat_print, "%02X", raw_id[i]);
}
mp_printf(&mp_plat_print, "\n");
#endif
bool found_boot = maybe_run_list(boot_py_filenames);
(void)found_boot;
@ -766,6 +777,7 @@ STATIC void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) {
FATFS *fs = &vfs->fatfs;
boot_output = NULL;
supervisor_title_bar_resume();
bool write_boot_output = true;
FIL boot_output_file;
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) {
}
#endif
cleanup_after_vm(heap, MP_OBJ_SENTINEL);
// Also reset bleio. The above call omits it in case workflows should continue. In this case,
// we're switching straight to another VM so we want to reset.
#if CIRCUITPY_BLEIO
bleio_reset();
#endif
#if CIRCUITPY_STATUS_LED
status_led_init();
new_status_color(BLACK);

View File

@ -166,8 +166,6 @@ STATIC void supervisor_bluetooth_start_advertising(void) {
circuitpython_scan_response_data[1] = 0x9;
}
scan_response_len = circuitpython_scan_response_data[0] + 1;
assert(scan_response_len < 32);
mp_printf(&mp_plat_print, "sr len %d\n", scan_response_len);
_private_advertising = false;
}
uint32_t status = _common_hal_bleio_adapter_start_advertising(&common_hal_bleio_adapter_obj,
@ -282,6 +280,8 @@ void supervisor_bluetooth_background(void) {
if (!is_connected) {
supervisor_bluetooth_start_advertising();
return;
} else {
advertising = false;
}
#if CIRCUITPY_BLE_FILE_SERVICE
@ -293,7 +293,7 @@ void supervisor_bluetooth_background(void) {
void supervisor_start_bluetooth(void) {
#if CIRCUITPY_BLE_FILE_SERVICE || CIRCUITPY_SERIAL_BLE
if (workflow_state != WORKFLOW_ENABLED) {
if (workflow_state != WORKFLOW_ENABLED || ble_started) {
return;
}
@ -324,6 +324,8 @@ void supervisor_stop_bluetooth(void) {
return;
}
ble_started = false;
#if CIRCUITPY_SERIAL_BLE
supervisor_stop_bluetooth_serial();
#endif

View File

@ -49,6 +49,10 @@ void supervisor_title_bar_update(void) {
#if !CIRCUITPY_STATUS_BAR
return;
#endif
if (_suspended) {
supervisor_title_bar_request_update(true);
return;
}
_forced_dirty = false;
// Neighboring "" "" are concatenated by the compiler. Without this separation, the hex code
// doesn't get terminated after two following characters and the value is invalid.