- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1.1k
Description
A call to cyw43_arch_init_with_country is failing.
My program is PicoBB. I am finding that for the Pico2 GUI build, which is using the ScanVideo library to produce VGA output on Core 1, and Core 0 running the BBC BASIC interpreter attempting to open a WiFi connection I am obtaining the following diagnostic messages:
[CYW43] core not in reset
[CYW43] core not in reset
[CYW43] core not in reset
[CYW43] core not in reset
[CYW43] core not up
[CYW43] HT not ready
and the WiFi is failing to connect.
Enabling all the diagnostics in the CYW43 driver, and comparing (diff -y) the failing case with a case in which Core 1 is idle gives the attached, where the failing case is on the left and the successful case is on the right.
Looking at the source file pico-sdk/lib/cyw43-driver/src/cyw43_ll.c I see the function device_core_is_up():
static void device_core_is_up(cyw43_int_t *self, int core_id) {
    uint32_t base = get_core_address(core_id);
    uint32_t reg = cyw43_read_backplane(self, base + AI_IOCTRL_OFFSET, 1);
    if ((reg & (SICF_FGC | SICF_CLOCK_EN)) != SICF_CLOCK_EN) {
        CYW43_WARN("core not up\n");
    }
    reg = cyw43_read_backplane(self, base + AI_RESETCTRL_OFFSET, 1);
    if (reg & AIRC_RESET) {
        CYW43_WARN("core not up\n");
    }
    // if we get here then the core is up
    CYW43_VDEBUG("core %d IS up\n", core_id);
}
This function seems to be testing for two possible failure conditions, but then does nothing about them other than issuing diagnostic messages. Surely it should be returning a true/false status so that subsequent code can handle any failures.
In the diagnostics attached, the following output can be seen:
cyw43_write_reg_u8 BACKPLANE_FUNCTION 0x1000b=0x1810		cyw43_write_reg_u8 BACKPLANE_FUNCTION 0x1000b=0x1810
cyw43_read_reg_u8 BACKPLANE_FUNCTION 0xb800=0x86010001	      |	cyw43_read_reg_u8 BACKPLANE_FUNCTION 0xb800=0x86010000
cyw43_write_reg_u8 BACKPLANE_FUNCTION 0x1000b=0x1800		cyw43_write_reg_u8 BACKPLANE_FUNCTION 0x1000b=0x1800
[CYW43] core not up					      <
core 1 IS up							core 1 IS up
So one of the tests is failing, but the code continues to execute as if nothing is wrong. The code eventually fails with the "HT not ready" error here.
I don't know enough about the CYW43 to interpret the error.
To produce the failing executable:
git clone --recurse-submodules https://github.com/Memotech-Bill/PicoBB.git
cd PicoBB/bin/pico
make BOARD=pico2_w ADDON=vgaboard_cut
Install the software on a Pico2 W on a VGA Demo Board with:
- VGA Monitor attached
- Keyboard on Pico USB connector
- Power applied to the VGA board USB connector
- Serial terminal (for diagnostics) to VGA board serial connections.
Load "bbcbasic+filesystem_gui_pico2_w_vgaboard_cut.uf2" into the pico2 W. To demonstrate failure, enter the following commands on the Keyboard attached to the pico2 W:
LOAD mysqldem
RUN
And to produce the functional executable:
cd PicoBB/console/pico
make BOARD=pico2_w
For this version no VGA board is required. Attach a USB console to the Pico2 W and run the same BASIC program.