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

USB serial appears in OS but doesn't respond to anything on ECP5/Orangecrab #20

Open
LithosphereRocketry opened this issue Jul 7, 2024 · 0 comments

Comments

@LithosphereRocketry
Copy link

I'm trying to run this code on an Orangecrab-25F (ECP5 core). I've made a few modifications to the example code to get it compatible with my setup, but nothing really significant: I am getting the 48MHz clock natively instead of from a PLL, and I removed the PipeSpec layer from the ECP5 interface because it seems to depend on some other piece of Verilog which I don't have in my setup. Here are my top-level file as well as the modified ECP5 interface:
Top level:

module orangecrab_core(
        input clk48,
        
        inout usb_d_p,
        inout usb_d_n,
        output usb_pullup,

        output rst_n,
        input usr_btn,

        output rgb_led0_r,
        output rgb_led0_g,
        output rgb_led0_b
        
    );

    orangecrab_reset reset_instance(
		.clk(clk48),
		.do_reset(~usr_btn),
		.nreset_out(rst_n)
	);


    // Generate reset signal
    reg [5:0] reset_cnt = 0;
    wire usb_rst = ~reset_cnt[5];
    always @(posedge clk48)
        reset_cnt <= reset_cnt + usb_rst;

    wire [7:0] uart_d;
    wire uart_ready;
    wire uart_valid;

    usb_uart uart(
        .clk_48mhz(clk48),
        .reset(usb_rst),

        .pin_usb_n(usb_d_n),
        .pin_usb_p(usb_d_p),

        // uart pipeline in
        .uart_in_data( uart_d ),
        .uart_in_valid( uart_valid ),
        .uart_in_ready( uart_ready ),

        .uart_out_data( uart_d ),
        .uart_out_valid( uart_valid ),
        .uart_out_ready( uart_ready )
    );
    assign usb_pullup = 1'b1;
    assign rgb_led0_r = 1'b1;
    assign rgb_led0_g = ~uart_valid;
    assign rgb_led0_b = 1'b1;

endmodule

Modified ECP5 layer:

module usb_uart (
  input  clk_48mhz,
  input reset,

  // USB pins
  inout  pin_usb_p,
  inout  pin_usb_n,

  // uart pipeline in (out of the device, into the host)
  input [7:0] uart_in_data,
  input       uart_in_valid,
  output      uart_in_ready,

  // uart pipeline out (into the device, out of the host)
  output [7:0] uart_out_data,
  output       uart_out_valid,
  input        uart_out_ready,

  output [11:0] debug
);

    wire usb_p_tx;
    wire usb_n_tx;
    wire usb_p_rx;
    wire usb_n_rx;
    wire usb_tx_en;

    // wire [11:0] debug_dum;

    usb_uart_core uart (
        .clk_48mhz  (clk_48mhz),
        .reset      (reset),

        // pins - these must be connected properly to the outside world.  See below.
        .usb_p_tx(usb_p_tx),
        .usb_n_tx(usb_n_tx),
        .usb_p_rx(usb_p_rx),
        .usb_n_rx(usb_n_rx),
        .usb_tx_en(usb_tx_en),

        // uart pipeline in
        .uart_in_data( uart_in_data ),
        .uart_in_valid( uart_in_valid ),
        .uart_in_ready( uart_in_ready ),

        // uart pipeline out
        .uart_out_data( uart_out_data ),
        .uart_out_valid( uart_out_valid ),
        .uart_out_ready( uart_out_ready ),

        .debug( debug )
    );

    wire usb_p_in;
    wire usb_n_in;

    assign usb_p_rx = usb_tx_en ? 1'b1 : usb_p_in;
    assign usb_n_rx = usb_tx_en ? 1'b0 : usb_n_in;

	// T = TRISTATE (not transmit)
	BB io_p( .I( usb_p_tx ), .T( !usb_tx_en ), .O( usb_p_in ), .B( pin_usb_p ) );
	BB io_n( .I( usb_n_tx ), .T( !usb_tx_en ), .O( usb_n_in ), .B( pin_usb_n ) );

endmodule

When I run this code, the device appears on my (Ubuntu 22.04) system as a device under lsusb and also appears as /dev/ttyACM0 as it should; however, any attempt to interact with it (via a terminal program or directly) crashes with an I/O error after about 10 seconds. Upon plugging it in, I see a bunch of concerning stuff in dmesg:

[ 3297.766279] usb 1-5: new full-speed USB device number 24 using xhci_hcd
[ 3297.923093] usb 1-5: New USB device found, idVendor=1209, idProduct=5af0, bcdDevice= 1.01
[ 3297.923110] usb 1-5: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 3297.923116] usb 1-5: Product: OrangeCrab r0.2 DFU Bootloader v3.1
[ 3297.923121] usb 1-5: Manufacturer: GsD
[ 3319.011295] usb 1-5: USB disconnect, device number 24
[ 3319.337786] usb 1-5: new full-speed USB device number 25 using xhci_hcd
[ 3319.486432] usb 1-5: New USB device found, idVendor=1d50, idProduct=6130, bcdDevice= 0.00
[ 3319.486447] usb 1-5: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[ 3319.489034] cdc_acm 1-5:1.0: ttyACM0: USB ACM device
[ 3336.197566] usb 1-5: reset full-speed USB device number 25 using xhci_hcd
[ 3336.325363] usb 1-5: device descriptor read/64, error -71
[ 3336.561351] usb 1-5: device descriptor read/64, error -71
[ 3336.797376] usb 1-5: reset full-speed USB device number 25 using xhci_hcd
[ 3336.925507] usb 1-5: device descriptor read/64, error -71
[ 3337.161369] usb 1-5: device descriptor read/64, error -71
[ 3337.397446] usb 1-5: reset full-speed USB device number 25 using xhci_hcd
[ 3337.397630] usb 1-5: Device not responding to setup address.
[ 3337.605588] usb 1-5: Device not responding to setup address.
[ 3337.813253] usb 1-5: device not accepting address 25, error -71
[ 3337.941240] usb 1-5: reset full-speed USB device number 25 using xhci_hcd
[ 3337.941342] usb 1-5: Device not responding to setup address.
[ 3338.149329] usb 1-5: Device not responding to setup address.
[ 3338.357223] usb 1-5: device not accepting address 25, error -71
[ 3338.357296] usb 1-5: USB disconnect, device number 25
[ 3338.485226] usb 1-5: new full-speed USB device number 26 using xhci_hcd
[ 3338.613232] usb 1-5: device descriptor read/64, error -71
[ 3338.857233] usb 1-5: device descriptor read/64, error -71
[ 3339.101325] usb 1-5: new full-speed USB device number 27 using xhci_hcd
[ 3339.233362] usb 1-5: device descriptor read/64, error -71
[ 3339.469269] usb 1-5: device descriptor read/64, error -71
[ 3339.577385] usb usb1-port5: attempt power cycle
[ 3339.993290] usb 1-5: new full-speed USB device number 28 using xhci_hcd
[ 3339.993472] usb 1-5: Device not responding to setup address.
[ 3340.201437] usb 1-5: Device not responding to setup address.
[ 3340.413279] usb 1-5: device not accepting address 28, error -71
[ 3340.549274] usb 1-5: new full-speed USB device number 29 using xhci_hcd
[ 3340.549444] usb 1-5: Device not responding to setup address.
[ 3340.757405] usb 1-5: Device not responding to setup address.
[ 3340.965239] usb 1-5: device not accepting address 29, error -71
[ 3340.965366] usb usb1-port5: unable to enumerate USB device
[ 3634.454077] usb 1-5: new full-speed USB device number 30 using xhci_hcd
[ 3634.606991] usb 1-5: New USB device found, idVendor=1d50, idProduct=6130, bcdDevice= 0.00
[ 3634.607006] usb 1-5: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[ 3634.609605] cdc_acm 1-5:1.0: ttyACM0: USB ACM device

Are there any known fixes for this type of issue?

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

No branches or pull requests

1 participant