machdyne / musli

Müsli USB Pmod-compatible module
Other
11 stars 3 forks source link

default firmware #1

Open asyarifstudio opened 1 year ago

asyarifstudio commented 1 year ago

What is the default firmware out of the box? does this default firmware support USB Host mode? or do we need to flash a example host firmware available in this repository?

machdyne commented 1 year ago

Hi. The default firmware is usually test_gpio. I've just now added UF2 images for the other firmware examples.

If you hold the BOOTSEL button during power-up, it should show up as a mass storage device on the computer connected to USB via a male-male cable, and you can then drag-and-drop one of the UF2s to the device. This can also be done over the SWD interface.

Please let me know if you have any further questions.

asyarifstudio commented 1 year ago

hi

Thanks for answering the question. I have some follow question and confirmation

  1. in host_musli_kbd.uf2, does it use SPI to send data to the PMOD? if yes, I guess the PMOD SPI mapping follow the guideline in this repo, right?
  2. in host_musli.uf2, does it use UART to send data to the PMOD?, I guess the similar pin mapping also follow the guideline

just to share, I want to connect the MUSLI to Genesys 2 FPGA Board so I can communicate to Cinterion Modem Board over the USB. just in case if you some thought how to use the MUSLI properly for such usecase.

machdyne commented 1 year ago
  1. Yes, the SPI data is sent on the pins defined in the README:

https://github.com/machdyne/musli#12-pin-pmod-header

  1. I believe the host_musli example is identical to the cdc_msc_hid example from TinyUSB. It should print debug messages to the UART pins as defined in the README.

If the modem uses USB CDC then the task may be relatively simple:

I have just now added a host_musli_cdc source and firmware image, this is the TinyUSB example with only CDC enabled.

After programming that firmware, you will need to unplug the male-male USB cable and switch Musli to USB host mode (J1 open, J2 short). Then plug Musli into the FPGA board, which will provide power.

PMOD pin 1 is TX and pin 2 is RX.

You can then plug in a USB CDC device and Musli should act as a USB CDC <-> PMOD UART bridge.

Make sure to unplug the PMOD and switch back to stand-alone device mode if you need to program the firmware again over USB (this is less cumbersome when using SWD to program).

asyarifstudio commented 1 year ago

Hi

Thanks a lot for your prompt answer. I'm using Thales B80 and I'm not sure whether it's CDC enabled or not but certainly the device class is 0. Here is the full description of the modem.

  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0         8
  idVendor           0x0403 Future Technology Devices International, Ltd
  idProduct          0x6001 FT232 USB-Serial (UART) IC
  bcdDevice            6.00
  iManufacturer           1 
  iProduct                2 
  iSerial                 3 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           32
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0xa0
      (Bus Powered)
      Remote Wakeup
    MaxPower               90mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass    255 Vendor Specific Subclass
      bInterfaceProtocol    255 Vendor Specific Protocol
      iInterface              2 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0

I will try to use the cdc host firmware nevertheless and see how it goes.

asyarifstudio commented 1 year ago

Hi

One more thing

You can then plug in a USB CDC device and Musli should act as a USB CDC <-> PMOD UART bridge.

what would be the baudrate of the UART bridge? I need to set the UARTLite IP with correct baudrate, and I could not get any info from the code. does it use default 9600 baudrate? or is it set somewhere else?

I also cannot find the host_musli_cdc image in your latest commit

machdyne commented 1 year ago

The CDC baudrate is set in tusb_config.h and is 115200 by default.

If you plug the modem into a Linux computer, it will be /dev/ttyACMx if the device is CDC.

However, from the USB description it looks like it is not CDC, and may use a custom protocol that would require writing a specific driver.

That would be more complicated to implement, I believe the details of the protocol are available here:

https://github.com/torvalds/linux/blob/master/drivers/usb/serial/ftdi_sio.c