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

RP2040 MIDI host #1605

Closed
wants to merge 35 commits into from
Closed

RP2040 MIDI host #1605

wants to merge 35 commits into from

Conversation

atoktoto
Copy link

Describe the PR
This PR adds MIDI host support for RP2040 boards based on work done by @rppicomidi in #1219 and @Skyler84 in #1434. I rebased all changed on top of master and fixed some compilation errors.

MIDI controller (behringer x-touch mini) enumerates and the data is received.

Creating this pull request as a draft for comments. I'm very new at this and I'm kind of surprised that it works :D

Skyler84 and others added 30 commits August 14, 2022 20:47
Added descriptive strings for edpt_dir and edpt_type
Added support for allocating hw_endpoints for non-interrupt endpoints.
Allow endpoints to be used in either direction by updating bit checks.
Comment out usbh_edpt_force_last_buffer for now
Change usbh_edpt_open to tuh_edpt_open
@atoktoto atoktoto changed the title Midihost atoktoto RP2040 MIDI host Aug 16, 2022
@todbot
Copy link
Contributor

todbot commented Aug 26, 2022

Hi!
I'm very excited for this functionality. But I'm getting compile errors when I try this out. The process I'm using:

git clone https://github.com/atoktoto/tinyusb tinyusb-atoktoto
cd tinyusb-atoktoto
git checkout midihost-atoktoto
git submodule update --init lib
cd examples/host/midi
make BOARD=raspberry_pi_pico get-deps
make BOARD=raspberry_pi_pico all

And I get the error:

[...]/tinyusb-atoktoto/examples/host/midi/src/midi_app.c:195:16: error: unused variable 'bytes_read' [-Werror=unused-variable]
  195 |       uint32_t bytes_read = tuh_midi_stream_read(dev_addr, &cable_num, buffer, sizeof(buffer));
compilation terminated due to -Wfatal-errors.
cc1: all warnings being treated as errors

Okay, perhaps you're assuming you must have LOG set, so I clean and build with:

make BOARD=raspberry_pi_pico LOG=2 all

and now the error I get is:

<command-line>: error: "CFG_TUSB_DEBUG" redefined [-Werror]

Well, I can go back to doing a normal build and just insert a (void)bytes_read; on line 196, after the offending line, to get the compiler warning to go away. But then when I compile I get this error:

[...]/tinyusb-atoktoto/src/host/usbh.c: In function 'tuh_task_ext.part.0':
[...]/tinyusb-atoktoto/src/host/usbh.c:478:41: error: array subscript 1 is above array bounds of 'uint8_t[1][2]' {aka 'unsigned char[1][2]'} [-Werror=array-bounds]
  478 |             uint8_t drv_id = dev->ep2drv[epnum][ep_dir];
      |                              ~~~~~~~~~~~^~~~~~~

Am I doing something wrong? Can you please share the build steps you're using?

@atoktoto
Copy link
Author

atoktoto commented Aug 27, 2022

Not sure if that's the source of the problem but the way I have it set up is the same as described by the original author of this merge request: https://github.com/rppicomidi/midi2usbhost ( "Using the forked tinyusb library" )

The top level directory for me is pico-examples. The CMakeLists.txt there adds the examples from tinyusb.

I will test starting from empty directory later today.

@atoktoto
Copy link
Author

atoktoto commented Aug 30, 2022

Here is a stripped down project created from the example: https://github.com/atoktoto/pico-midi-host

@rppicomidi
Copy link
Contributor

@atoktoto In case you are interested, my fork of this project has a new branch pio-midihost that supports the Pico-PIO-USB as a host. I have a demo project pico-usb-midi-filter that passes MIDI data between the built-in USB configured as a device and a new USB Host port created from PIO. I suspect I duplicated some of your work in this pull request in my fork.

@atoktoto
Copy link
Author

atoktoto commented Sep 4, 2022

@rppicomidi Is the Pico-PIO-USB a way to go over the dedicated hardware? Why?

I've used the branch you mentioned, applied #1434 and it seems to work without PIO. I think I will re-create this merge request with your changes and #1434.

@rppicomidi
Copy link
Contributor

@atoktoto I agree #1434 seems to work. I am not arguing against your pull request. Thank you for doing the work. The pico-usb-midi-filter project uses a single Pico board to implement a bi-directional MIDI filter between a MIDI USB host (which I implemented using PIO from the Pico-PIO-USB project) and a MIDI USB device (which I implemented using the Pico's dedicated USB hardware). My comment was only wishing I had looked here before I did a lot of the same work you did.

@atoktoto atoktoto mentioned this pull request Sep 7, 2022
@atoktoto atoktoto closed this Sep 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants