Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

USB Host + MSC#1196

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
rhapsodyv wants to merge8 commits intostm32duino:main
base:main
Choose a base branch
Loading
fromrhapsodyv:usb-host-msc
Open

Conversation

@rhapsodyv
Copy link

@rhapsodyvrhapsodyv commentedOct 4, 2020
edited
Loading

Pull Request template

Summary

This PR fixes/implements the followingbugs/features

  • USB Host
  • MSC for USB Host

It will allow STM users to use USB Host feature with MSC support.

I tried to follow the same development workflow from the usb device midleware. I created a foldercores/arduino/stm32/usb_host, and put the conf and the references to the middleware.

There's some work to do yet:

  • HCD shares a few definitions with PCD.
    For example, the PinMap_USB_OTG_FS in the PeripheralPins.c for each variant. Do we need update all variants to include a "or" in the#ifdef?
    Can HCD and PCD be enabled at same time? If so, we need to join IRQ handler.
  • Interface for USB Host Config + MSC operations. Right now, I'm just exposing the MSC interface from STM32 middleware.
  • Missing OTG HS
  • I didn't organize the comments, style and options in the files, yet.

It works if USBCON is disabled, and HAL_HCD_MODULE_ENABLED and USBHOST are enabled.

Sorry if I'm missing something. It's my first PR in this project, and it may take sometime to get everything as it should be.

Related to:#687

thisiskeithb, fvanroie, rtek1000, and quiret reacted with thumbs up emoji
@rhapsodyvrhapsodyv marked this pull request as draftOctober 4, 2020 01:32
@rhapsodyvrhapsodyvforce-pushed theusb-host-msc branch 2 times, most recently from14d21ef to4e4f213CompareOctober 4, 2020 03:04
@rhapsodyv
Copy link
Author

Usage:

Compile with:
-DHAL_HCD_MODULE_ENABLED -DUSBHOST -DHAL_PCD_MODULE_ENABLED

//includes#include"usbh_core.h"#include"usbh_msc.h"//handleUSBH_HandleTypeDef hUsbHostFS;//callbackstaticvoidUSBH_UserProcess  (USBH_HandleTypeDef *phost,uint8_t id){/* USER CODE BEGIN CALL_BACK_1*/switch(id)  {case HOST_USER_SELECT_CONFIGURATION:break;case HOST_USER_DISCONNECTION:break;case HOST_USER_CLASS_ACTIVE://ready!break;case HOST_USER_CONNECTION:break;default:break;  }}//init callsvoidmy_init_routine() {  ...USBH_Init(&hUsbHostFS, USBH_UserProcess, HOST_FS);USBH_RegisterClass(&hUsbHostFS, USBH_MSC_CLASS);USBH_Start(&hUsbHostFS);  ..}//loop callvoidloop() {  ..USBH_Process(&hUsbHostFS);  ..}//read sample: it will read (sectors_to_read) * (sector size) bytesUSBH_StatusTypeDef ret = USBH_MSC_Read(&hUsbHostFS, lun, sector_addr, buffer, sectors_to_read);

@rhapsodyvrhapsodyv mentioned this pull requestOct 4, 2020
8 tasks
@rhapsodyvrhapsodyv marked this pull request as ready for reviewOctober 4, 2020 03:54
@rhapsodyv
Copy link
Author

Tested with success in: STM32F407VET6, STM32F407IGT6 and STM32F407ZGT6.

thisiskeithb reacted with hooray emojifpistm reacted with heart emoji

@fpistmfpistm added enhancementNew feature or request New feature labelsOct 5, 2020
@fpistm
Copy link
Member

Hi@rhapsodyv

thanks a lot for this PR.
I will try to do a first review soon.

rhapsodyv, MS1987, and thisiskeithb reacted with thumbs up emoji

@MS1987
Copy link

@fpistm Can this PR be merged now?

@rhapsodyv
Copy link
Author

I think the only important question to merge it is:

HCD shares a few definitions with PCD.
For example, the PinMap_USB_OTG_FS in the PeripheralPins.c for each variant. Do we need update all variants to include a "or" in the #ifdef?
Can HCD and PCD be enabled at same time? If so, we need to join IRQ handler.

I'm currently enabling PCD just to use the pins definitions.
But maybe we need update the variants to handle HCD too.

And soon I will receive a board with two usb, so I will test it and join the pcd/hcs irq handler.

I can send all changes. I just need that@fpistm point the direction for me :-)

@fpistm
Copy link
Member

fpistm commentedOct 30, 2020
edited
Loading

For example, the PinMap_USB_OTG_FS in the PeripheralPins.c for each variant. Do we need update all variants to include a "or" in the #ifdef?
Can HCD and PCD be enabled at same time? If so, we need to join IRQ handler.

Yes the "or" have to be added. I'm currently updating the files generation, I will add the HCD.

Can HCD and PCD be enabled at same time? If so, we need to join IRQ handler.

I don't know but I think as a first step it should be better to handle one at a time.

@rhapsodyv
Copy link
Author

Can HCD and PCD be enabled at same time? If so, we need to join IRQ handler.

I don't know but I think as a first step it should be better to handle one at a time.

I'm about to receive a board that have two USB. One in OTG HS and other in OTG FS. The central idea is to use one to read a thumb drive (USB Host) and the other to connect to the computer and share the pendrive as mass storage.
I didn't tested it yet. But I can't see any reason for it not work.

But I really agree with you. For the first version, we must keep what is tested and working. As soon I test that dual mode on that board, I will let you know if it works.

Thanks.

@fpistm
Copy link
Member

I'm about to receive a board that have two USB. One in OTG HS and other in OTG FS. The central idea is to use one to read a thumb drive (USB Host) and the other to connect to the computer and share the pendrive as mass storage.
I didn't tested it yet. But I can't see any reason for it not work.

Main issue would be the USBD part as currently if we enable both FS and HS this will not work, I guess.

@rhapsodyv
Copy link
Author

Main issue would be the USBD part as currently if we enable both FS and HS this will not work, I guess.

Indeed. I don't know if it will work. I found some stm32 forum messages saying that it works. But only testing to confirm it or not.
I know that the code will need to be updated, so we can choose what enable in each mode. Today we just haveUSB_OTG_FS andUSB_OTG_HS. We may need a way to specify, for example, that we want FS in PCD and HS in HCD.

@fpistm
Copy link
Member

Today we just haveUSB_OTG_FS andUSB_OTG_HS. We may need a way to specify, for example, that we want FS in PCD and HS in HCD.

Right.

rhapsodyv reacted with thumbs up emoji

fpistm added a commit to fpistm/Arduino_Tools that referenced this pull requestOct 30, 2020
stm32duino/Arduino_Core_STM32#1196Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
@fpistmfpistm marked this pull request as draftNovember 6, 2020 14:33
@fpistmfpistm added the waiting feedbackFurther information is required labelNov 6, 2020
fpistm added a commit to fpistm/Arduino_Tools that referenced this pull requestNov 26, 2020
stm32duino/Arduino_Core_STM32#1196Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
@Bob-the-Kuhn
Copy link

GLad to see work in this area.

Does this replace PR#1088?

@rhapsodyv
Copy link
Author

GLad to see work in this area.

Does this replace PR#1088?

I think#1088 is for usb mode device (PCD). My work is for usb mode host (HCD). They are complementary.

BTW,@fpistm I just received a board to test PCD+HCD. Soon I will start to push new code here.

fpistm reacted with thumbs up emoji

@rhapsodyv
Copy link
Author

@fpistm I pushed a version that will allow PCD and HCD working together. To avoid conflict and to not break compatibility, I added a new config to select HS on HCD (USE_USBHOST_HS).

It easier to just show the possible combinations:

To use HCD on FS:

#defineHAL_HCD_MODULE_ENABLED#defineUSBHOST

To use HCD on HS:

#defineHAL_HCD_MODULE_ENABLED#defineUSBHOST#defineUSE_USBHOST_HS.// <<<--- new macro, to select HS on HCD

To use PCD on FS: (current code, just to illustrate)

#defineHAL_PCD_MODULE_ENABLED#defineUSBCON

To use PCD on HS: (current code, just to illustrate)

#defineHAL_PCD_MODULE_ENABLED#defineUSBCON#defineUSE_USB_HS

And we can to combine then:

HCD on FS + PCD on HS:

// HCD on FS#defineHAL_HCD_MODULE_ENABLED#defineUSBHOST// PCD on HS#defineHAL_PCD_MODULE_ENABLED#defineUSBCON #defineUSE_USB_HS

Or: HCD on HS + PCD on FS:

// HCD on HS#defineHAL_HCD_MODULE_ENABLED#defineUSBHOST#defineUSE_USBHOST_HS// PCD on FS#defineHAL_PCD_MODULE_ENABLED#defineUSBCON

@rhapsodyvrhapsodyv marked this pull request as ready for reviewDecember 10, 2020 04:50
@rhapsodyvrhapsodyv changed the title[WIP] USB Host + MSCUSB Host + MSCDec 10, 2020
@rhapsodyv
Copy link
Author

rhapsodyv commentedDec 11, 2020
edited
Loading

With this PR plus#1088 I'm able to use fully mix usb host / usb device mass storage.

Using OTG HS to host the thumb drive + using OTG FS to uses CDC + MSC, to share the thumb driver or the SD Card with the Computer.
Everything working together. The mount/unmont and media select work without any power cycle needed.

thisiskeithb, fpistm, fvanroie, and quiret reacted with thumbs up emoji

@fpistmfpistm added this to the2.x.x milestoneDec 14, 2020
fpistm added a commit to fpistm/Arduino_Tools that referenced this pull requestDec 22, 2020
stm32duino/Arduino_Core_STM32#1196Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
@fpistm
Copy link
Member

fpistm commentedMay 3, 2021
edited
Loading

hi@rhapsodyv
what is the status of this PR. I'm a bit lost when you said

With this PR plus#1088 I'm able to use fully mix usb host / usb device mass storage.

I though this one replace#1088 ?

Thanks

@rhapsodyv
Copy link
Author

This is exclusively to USB host: for example, enable a board to use a usb disk drive using OTG (hs or fs - hcd).

#1088 is to share the board media with a computer/using using usb OTG. For example: to share a board sd card with a windows computer as a mass storage.

I merged both PRs in a local branch, so we can, for example: allow the board access and share a usb disk drive with the computer.

We are actively using it on Marlin.

The only issue with 1088 is the name of the usb class... it should be renamed to something like "USBComposite", instead of only "USB".

fpistm reacted with thumbs up emoji

@rhapsodyv
Copy link
Author

It's even allow a mouse to be attached to a board heheheh:

IMG_0523.MOV
fpistm and rtek1000 reacted with thumbs up emoji

@gordo3di
Copy link

This is exclusively to USB host: for example, enable a board to use a usb disk drive using OTG (hs or fs - hcd).

#1088 is to share the board media with a computer/using using usb OTG. For example: to share a board sd card with a windows computer as a mass storage.

I merged both PRs in a local branch, so we can, for example: allow the board access and share a usb disk drive with the computer.

We are actively using it on Marlin.

The only issue with 1088 is the name of the usb class... it should be renamed to something like "USBComposite", instead of only "USB".

Well thats cool! I'm trying to implement this for the newer skr v2 board any tips? I've been looking through this thread and#1088 but I'm not sure how much has already been implemented since then. Thanks

@rhapsodyv
Copy link
Author

Well thats cool! I'm trying to implement this for the newer skr v2 board any tips? I've been looking through this thread and#1088 but I'm not sure how much has already been implemented since then. Thanks

It's already done on Marlin:MarlinFirmware/Marlin#22354

@gordo3di
Copy link

Well thats cool! I'm trying to implement this for the newer skr v2 board any tips? I've been looking through this thread and#1088 but I'm not sure how much has already been implemented since then. Thanks

It's already done on Marlin:MarlinFirmware/Marlin#22354

Interesting. Thank you. Now I have to figure out why it's not mounting for me.

@rtek1000
Copy link

rtek1000 commentedJan 17, 2022
edited
Loading

Hello,

Is USB HID Host (keyboard) working too?

Thank you.

@rhapsodyv
Copy link
Author

Hello,

Is USB HID Host (keyboard) working too?

Thank you.

Mouse is working, keyboard should work too:

#1196 (comment)

rtek1000 reacted with thumbs up emoji

@BennehBoy
Copy link
Contributor

Hello,

Is USB HID Host (keyboard) working too?

Thank you.

Very interesting, I'm just looking around to see how to build a USB keyboard to legacy machine adapter (Commodore 128D in this case), and this would be extremely useful - I don't think I have the energy to dive into using raw CubeMX for it.

So what's this waiting for in terms of being able to be merged, it looks like the PCD+HCD test was successful... I guess it's just down to time from@fpistm

fpistm reacted with thumbs up emoji

@rtek1000
Copy link

rtek1000 commentedJan 27, 2022
edited
Loading

Hello,
Is USB HID Host (keyboard) working too?
Thank you.

Very interesting, I'm just looking around to see how to build a USB keyboard to legacy machine adapter (Commodore 128D in this case), and this would be extremely useful - I don't think I have the energy to dive into using raw CubeMX for it.

So what's this waiting for in terms of being able to be merged, it looks like the PCD+HCD test was successful... I guess it's just down to time from@fpistm

Hello,

The USB Host library of the STM32 line is still very precarious, just didactic.

If you want something more fluid, check out this other alternative, which can accept the touchpad keyboard. Because it has the HUB part:

https://github.com/felis/UHS30

@quiret
Copy link

quiret commentedFeb 15, 2023
edited
Loading

I really wonder about the status of this PR since it has not been merged yet and there appear to be conflicts now. I would greatly appreciate any statement by participating parties. The features described in this PR seem amazing and worthwhile for the embedded world.

XavierBerger and 97nomad reacted with thumbs up emoji

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

enhancementNew feature or requestwaiting feedbackFurther information is required

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

8 participants

@rhapsodyv@fpistm@MS1987@Bob-the-Kuhn@gordo3di@rtek1000@BennehBoy@quiret

[8]ページ先頭

©2009-2025 Movatter.jp