subghz rx with external CC1101 (device 1) over USB CLI hangs the Flipper
Describe the bug.
When I run subghz rx 433920000 1 from the USB CLI with an external CC1101 plugged in, the Flipper freezes right away. It prints the two Load_keystore lines and then nothing, never gets to "Listening at...". The USB serial port dies with it (Windows says the device isn't functioning) and the only way out is holding Left+Back to reboot.
Same module works fine from the Sub-GHz app itself (radio set to External, Ext Module Power 5V = OFF). And subghz rx 433920000 0 with the internal radio works fine over the same cable, so it's not the USB connection or the CLI in general.
I had a look at subghz_cli.c and I think this is the cause: subghz_cli_command_get_device() calls subghz_cli_radio_device_power_on() for device 1, which turns on OTG unconditionally and ignores the Ext Module Power setting. When the Flipper is on USB there's already VBUS there, so enabling the boost on top of it seems like the likely thing that kills the USB link. I haven't measured anything, so it's a guess, but it would explain why the app works and the CLI doesn't.
https://github.com/DarkFlippers/unleashed-firmware/blob/unlshd-093/applications/main/subghz/subghz_cli.c#L40-L53 https://github.com/DarkFlippers/unleashed-firmware/blob/unlshd-093/applications/main/subghz/subghz_cli.c#L162-L166
For comparison, the official firmware's subghz_cli.c goes through the Power service (power_enable_otg(power, true)) instead of calling furi_hal_power_enable_otg() directly in a retry loop, so maybe that's where the difference is. I haven't tried official fw with this module though.
Reproduction
- Plug in an external CC1101 board (mine is a 3-in-1 "AIO Board V1.4" with an EBYTE E07-433M20S, runs fine on 3.3V).
- Leave Sub-GHz -> Radio Settings -> Ext Module Power 5V on OFF.
- Connect the Flipper to a PC over USB and open the CLI.
- Run
subghz rx 433920000 1. - Flipper hangs, serial port is gone until you reboot it.
Did it multiple times, happens every time. Also happened on unlshd-089e before I updated.
Found in version
unlshd-093
Logs
Nothing useful, the CLI stops responding before it prints anything else:
>: subghz rx 433920000 1
Load_keystore keeloq_mfcodes OK
Load_keystore keeloq_mfcodes_user AbsentAnything else?
Maybe the CLI could respect the Ext Module Power setting like the app does, or at least skip enabling OTG when USB power is present. Happy to test a build if that helps.
Source: DarkFlippers/unleashed-firmware