Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
750a4fe
usb/ehci: adapt to hcd_info_t struct change
adamgreloch Nov 20, 2024
b5cacd3
usb/ehci: adapt ehci to work on ia32
adamgreloch Nov 20, 2024
b7c83fb
usb/ehci: rename per-subfamily phy src to per-family-subfamily
adamgreloch Oct 28, 2024
d62a69b
usb/ehci: adapt hcd driver to ia32 hw
adamgreloch Dec 20, 2024
912cca6
storage/umass: implement ext2 mounting
adamgreloch Oct 18, 2024
d918ee6
storage/umass: use new procDrvRun API
adamgreloch Nov 6, 2024
82cb3c5
storage/umass: refactor to compile driver as static-lib
adamgreloch Nov 13, 2024
c899245
storage/umass: misra
adamgreloch Dec 2, 2024
866d409
tty/usbacm: adapt to new usb API
adamgreloch Nov 29, 2024
86dc342
tty/usbacm: fix device insertion/deletion race conditions
adamgreloch Nov 29, 2024
0cd6d62
_targets/imx*: build usb drivers in lib versions
adamgreloch Nov 18, 2024
4370ca4
storage/umass: handle quirky usb sticks
adamgreloch Jan 10, 2025
39e405a
umass: adapt to events API
adamgreloch Mar 27, 2025
21b10c9
usbacm: adapt to events API
adamgreloch Apr 18, 2025
8636b22
usbacm: set line coding on device insertion
adamgreloch Apr 18, 2025
3e421fb
umass: fix incorrect error handling and a resulting deadlock on devic…
adamgreloch Apr 25, 2025
903ed0e
usbacm: check condCreate return value
adamgreloch Apr 25, 2025
b23e7ca
umass: fix snprintf not being checked for truncation
adamgreloch Apr 29, 2025
fe39c3a
usbacm: remove unused drvport, rename usbacm_freeAll to _usbacm_freeAll
adamgreloch Jun 6, 2025
2314fe6
usbacm: use idtree for device id allocation
adamgreloch Jun 6, 2025
da9949f
umass: decrease number of worker threads and make it configurable
adamgreloch Jun 6, 2025
c4ac24a
umass/srv: wait for rootfs instead of console
adamgreloch Jun 6, 2025
238bec0
umass: fix umass_mountFromDev error paths
adamgreloch Jun 6, 2025
c410748
umass: remove intermediate buffer
adamgreloch Jun 6, 2025
f020e89
umass: use strncpy
adamgreloch Jun 6, 2025
acd436b
umass: access requests in FIFO order
adamgreloch Jun 6, 2025
f84e1bb
usbacm: fix use-after-free due to incorrect idtree_alloc error value …
adamgreloch Jun 18, 2025
55db5c3
usbacm: update the dev refcnt on failure
adamgreloch Jun 18, 2025
178e75c
usbacm: suppress snprintf format warning
adamgreloch Jun 18, 2025
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
2 changes: 1 addition & 1 deletion _targets/Makefile.armv7a7-imx6ull
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ DEFAULT_COMPONENTS += libusbclient cdc-demo
DEFAULT_COMPONENTS += imx6ull-uart imx6ull-otp
DEFAULT_COMPONENTS += imx6ull-wdg imx6ull-i2c imx6ull-sdio

DEFAULT_COMPONENTS += libusbehci umass usbacm
DEFAULT_COMPONENTS += libusbehci umass libusbdrv-umass usbacm libusbdrv-usbacm
DEFAULT_COMPONENTS += libsensors sensors
4 changes: 2 additions & 2 deletions _targets/Makefile.armv7m7-imxrt106x
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
DEFAULT_COMPONENTS := imxrt-multi

ifneq (, $(findstring 117, $(TARGET)))
DEFAULT_COMPONENTS += libusbclient imxrt-flash cdc-demo imxrt117x-otp libusbehci umass usbacm
DEFAULT_COMPONENTS += libusbclient imxrt-flash cdc-demo imxrt117x-otp libusbehci umass libusbdrv-umass usbacm libusbdrv-usbacm
else ifneq (, $(findstring 105, $(TARGET)))
# placeholder
else ifneq (, $(findstring 106, $(TARGET)))
DEFAULT_COMPONENTS += libusbclient imxrt-flash cdc-demo libimxrt-edma libusbehci umass usbacm
DEFAULT_COMPONENTS += libusbclient imxrt-flash cdc-demo libimxrt-edma libusbehci umass libusbdrv-umass usbacm libusbdrv-usbacm
endif
2 changes: 1 addition & 1 deletion _targets/Makefile.ia32-generic
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
# Copyright 2019 Phoenix Systems
#

DEFAULT_COMPONENTS := pc-tty uart16550 pc-ata
DEFAULT_COMPONENTS := pc-tty uart16550 pc-ata libusbehci umass libusbdrv-umass
16 changes: 13 additions & 3 deletions storage/umass/Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
#
# Makefile for Phoenix-RTOS USB Mass Storage driver
#
# Copyright 2020 Phoenix Systems
# Copyright 2020, 2024 Phoenix Systems
#

NAME := umass
ifeq ($(TARGET_FAMILY),ia32)
UMASS_LIBS := libext2
UMASS_CFLAGS := -DUMASS_MOUNT_EXT2
endif

NAME := libusbdrv-umass
LOCAL_SRCS := umass.c
LIBS := libusb
LOCAL_CFLAGS += $(UMASS_CFLAGS)
include $(static-lib.mk)

NAME := umass
LOCAL_SRCS := umass.c srv.c
LIBS := libusb $(UMASS_LIBS)
LOCAL_CFLAGS += $(UMASS_CFLAGS)
include $(binary.mk)
63 changes: 63 additions & 0 deletions storage/umass/scsi.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Phoenix-RTOS
*
* USB Mass Storage class driver
*
* SCSI transparent command set definitions header
*
* Copyright 2024 Phoenix Systems
* Author: Adam Greloch
*
* %LICENSE%
*/


#ifndef _SCSI_H_
#define _SCSI_H_

#include <unistd.h>


/* Opcodes */
#define SCSI_REQUEST_SENSE 0x03
#define SCSI_INQUIRY 0x12


typedef struct {
uint8_t opcode;
uint8_t action_misc0; /* [8:3] action, [3:0] misc0 */
uint32_t lba;
uint8_t misc1;
uint16_t length;
uint8_t control;
} __attribute__((packed)) scsi_cdb10_t;


typedef struct {
uint8_t opcode;
uint8_t misc0[3];
uint8_t length;
uint8_t control;
} __attribute__((packed)) scsi_cdb6_t;


typedef struct {
uint8_t errorcode;
uint8_t segnum;
uint8_t misc0_sensekey; /* [8:4] misc0, [4:0] sensekey */
uint8_t misc[17];
} __attribute__((packed)) scsi_sense_t;


typedef struct {
uint8_t qualifier_devicetype; /* [8:5] qualifier, [5:0] devicetype */
uint8_t misc0;
uint8_t version;
uint8_t misc1[5];
char vendorid[8];
char productid[16];
uint8_t misc[4];
} __attribute__((packed)) scsi_inquiry_t;


#endif
72 changes: 72 additions & 0 deletions storage/umass/srv.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* Phoenix-RTOS
*
* USB Mass Storage class driver
*
* Device driver server
*
* Copyright 2024 Phoenix Systems
* Author: Adam Greloch
*
* This file is part of Phoenix-RTOS.
*
* %LICENSE%
*/

#include "umass.h"
#include <usbprocdriver.h>


static void printHelp(const char *name)
{
fprintf(stderr,
"Usage: %s [opts]\n"
" -r Mount as rootfs\n"
" -h Print this help\n",
name);
}


int main(int argc, char *argv[])
{
int ret;
char c;
oid_t oid;
umass_args_t umass_args = { .mount_root = false };
usb_driver_t *driver = usb_registeredDriverPop();

if (driver == NULL) {
fprintf(stderr, "umass: no driver registered!");
return 1;
}

if (argc > 1) {
/* Process command line options */
for (;;) {
c = getopt(argc, argv, "hr");
if (c == -1) {
break;
}
switch (c) {
case 'r':
umass_args.mount_root = true;
break;
case 'h':
default:
printHelp(argv[0]);
return 0;
}
}
}

if (!umass_args.mount_root) {
/* Wait for root filesystem if not responsible for mounting it */
while (lookup("/", NULL, &oid) < 0) {
usleep(10000);
}
}

ret = usb_driverProcRun(driver, &umass_args);

return ret == 0 ? 0 : 1;
}
Loading