Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix FlipTDI and Mass Storage crashes #259

Draft
wants to merge 2 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions flip_tdi/.catalog/changelog.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
## 1.1
- Fixed crash when connecting to a USB charger instead of a PC
- Fixed crash when connecting to a PC with a companion app running

## 1.0
- Initial release
2 changes: 1 addition & 1 deletion flip_tdi/application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ App(
],
stack_size=2 * 1024,
fap_description="Flipper FTDI232H emulator.",
fap_version="1.0",
fap_version="1.1",
fap_icon="flip_tdi_icon_10px.png",
fap_category="USB",
fap_icon_assets="images",
Expand Down
9 changes: 2 additions & 7 deletions flip_tdi/helpers/ftdi_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,6 @@ static void ftdi_usb_deinit(usbd_device* dev) {
ftdi_usb->thread = NULL;

ftdi_free(ftdi_usb->ftdi);

free(ftdi_usb->usb.str_prod_descr);
ftdi_usb->usb.str_prod_descr = NULL;
free(ftdi_usb->usb.str_serial_descr);
ftdi_usb->usb.str_serial_descr = NULL;
free(ftdi_usb);
}

static void ftdi_usb_send(usbd_device* dev, uint8_t* buf, uint16_t len) {
Expand Down Expand Up @@ -495,7 +489,7 @@ FtdiUsb* ftdi_usb_start(void) {
ftdi_usb->usb.cfg_descr = (void*)&usb_ftdi_cfg_descr;

if(!furi_hal_usb_set_config(&ftdi_usb->usb, ftdi_usb)) {
FURI_LOG_E(TAG, "USB locked, cannot start Mass Storage");
FURI_LOG_E(TAG, "USB locked, cannot start FlipTDI");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Problem is still there:

  • start qflipper
  • open app
  • try to exit

Also if USB is locked we show notification and then exit app. See GPIO app for more details

free(ftdi_usb->usb.str_prod_descr);
free(ftdi_usb->usb.str_serial_descr);
free(ftdi_usb);
Expand All @@ -506,4 +500,5 @@ FtdiUsb* ftdi_usb_start(void) {

void ftdi_usb_stop(FtdiUsb* ftdi_usb) {
furi_hal_usb_set_config(ftdi_usb->usb_prev, NULL);
free(ftdi_usb);
}
3 changes: 3 additions & 0 deletions mass_storage/.catalog/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## v.1.5
Fixed crash when connected to a USB charger instead of a PC

## v.1.4
Removed call to legacy SDK API

Expand Down
2 changes: 1 addition & 1 deletion mass_storage/application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ App(
],
stack_size=2 * 1024,
fap_description="Implements a mass storage device over USB for disk images",
fap_version="1.4",
fap_version="1.5",
fap_icon="assets/mass_storage_10px.png",
fap_icon_assets="assets",
fap_category="USB",
Expand Down
12 changes: 6 additions & 6 deletions mass_storage/helpers/mass_storage_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,12 +297,6 @@ static void usb_deinit(usbd_device* dev) {
furi_thread_join(mass->thread);
furi_thread_free(mass->thread);
mass->thread = NULL;

free(mass->usb.str_prod_descr);
mass->usb.str_prod_descr = NULL;
free(mass->usb.str_serial_descr);
mass->usb.str_serial_descr = NULL;
free(mass);
}

static void usb_wakeup(usbd_device* dev) {
Expand Down Expand Up @@ -478,4 +472,10 @@ MassStorageUsb* mass_storage_usb_start(const char* filename, SCSIDeviceFunc fn)

void mass_storage_usb_stop(MassStorageUsb* mass) {
furi_hal_usb_set_config(mass->usb_prev, NULL);

free(mass->usb.str_prod_descr);
mass->usb.str_prod_descr = NULL;
free(mass->usb.str_serial_descr);
mass->usb.str_serial_descr = NULL;
free(mass);
}