Krzysztof Skrzynecki пре 2 недеља
родитељ
комит
a1e67cfd04

+ 1 - 2
projects/riscv_usb/Makefile

@@ -1,7 +1,7 @@
 # Project config
 PROJ = riscv_usb
 
-PROJ_DEPS := no2usb no2misc no2ice40
+PROJ_DEPS := no2misc no2ice40
 PROJ_RTL_SRCS := $(addprefix rtl/, \
 	dfu_helper.v \
 	picorv32.v \
@@ -10,7 +10,6 @@ PROJ_RTL_SRCS := $(addprefix rtl/, \
 	soc_picorv32_base.v \
 	soc_picorv32_bridge.v \
 	soc_spram.v \
-	soc_usb.v \
 	sysmgr.v \
 	3signal.v \
 	mailbox_wb.v \

+ 5 - 11
projects/riscv_usb/fw/Makefile

@@ -8,10 +8,6 @@ DFU_UTIL = dfu-util
 BOARD_DEFINE=BOARD_$(shell echo $(BOARD) | tr a-z\- A-Z_)
 CFLAGS=-Wall -Os -march=rv32i -mabi=ilp32 -ffreestanding -flto -nostartfiles -fomit-frame-pointer -Wl,--gc-section -D$(BOARD_DEFINE) -I.
 
-NO2USB_FW_VERSION=0
-include ../../../cores/no2usb/fw/fw.mk
-CFLAGS += $(INC_no2usb)
-
 HEADERS_common=\
 	config.h \
 	console.h \
@@ -19,8 +15,7 @@ HEADERS_common=\
 	mini-printf.h \
 	spi.h \
 	utils.h \
-	registers.h \
-	$(HEADERS_no2usb)
+	registers.h
 
 SOURCES_common=\
 	start.S \
@@ -29,16 +24,15 @@ SOURCES_common=\
 	mini-printf.c  \
 	spi.c \
 	utils.c \
-	registers.c \
-	$(SOURCES_no2usb)
+	registers.c
 
 HEADERS_app=\
-	usb_str_app.gen.h \
+	#usb_str_app.gen.h \
 	$(NULL)
 
 SOURCES_app=\
 	fw_app.c \
-	usb_desc_app.c \
+	#usb_desc_app.c \
 	$(NULL)
 
 
@@ -53,7 +47,7 @@ fw_app.elf: lnk-app.lds $(HEADERS_app) $(SOURCES_app) $(HEADERS_common) $(SOURCE
 
 
 %.hex: %.bin
-	./bin2hex.py $< $@
+	python ./bin2hex.py $< $@
 
 %.bin: %.elf
 	$(OBJCOPY) -O binary $< $@

+ 2 - 2
projects/riscv_usb/fw/config.h

@@ -26,6 +26,6 @@
 #define UART_BASE	0x81000000
 #define SPI_BASE	0x82000000
 #define LED_BASE	0x83000000
-#define USB_CORE_BASE	0x84000000
-#define USB_DATA_BASE	0x85000000
+//#define USB_CORE_BASE	0x84000000
+//#define USB_DATA_BASE	0x85000000
 #define MAILBOX_BASE 0x86000000

+ 3 - 32
projects/riscv_usb/fw/fw_app.c

@@ -29,14 +29,9 @@
 #include "led.h"
 #include "mini-printf.h"
 #include "spi.h"
-#include <no2usb/usb.h>
-#include <no2usb/usb_dfu_rt.h>
 #include "utils.h"
 #include "registers.h"
 
-
-extern const struct usb_stack_descriptors app_stack_desc;
-
 /*
 double dupa;
 float kupa;
@@ -46,8 +41,8 @@ static void
 serial_no_init()
 {
 	uint8_t buf[8];
-	char *id, *desc;
-	int i;
+	//char *id, *desc;
+	//int i;
 
 	flash_manuf_id(buf);
 	printf("Flash Manufacturer : %s\n", hexstr(buf, 3, true));
@@ -85,16 +80,9 @@ serial_no_init()
 
     printf("Pi * e: %.3f\n", dupa);
     */
-
-	/* Overwrite descriptor string */
-	/* In theory in rodata ... but nothing is ro here */
-	id = hexstr(buf, 8, false);
-	desc = (char*)app_stack_desc.str[1];
-	for (i=0; i<16; i++)
-		desc[2 + (i << 1)] = id[i];
 }
 
-static char _printf_buf[128];
+//static char _printf_buf[128];
 
 static void write_period1()
 {
@@ -160,9 +148,6 @@ static void clear_delay1()
 static void
 boot_dfu(void)
 {
-	/* Force re-enumeration */
-	usb_disconnect();
-
 	/* Boot firmware */
 	volatile uint32_t *boot = (void*)0x80000000;
 	*boot = (1 << 2) | (1 << 0);
@@ -194,8 +179,6 @@ void main()
 
 	/* Enable USB directly */
 	serial_no_init();
-	usb_init(&app_stack_desc);
-	usb_dfu_rt_init();
 
 	/* Main loop */
 	while (1)
@@ -216,18 +199,9 @@ void main()
 
 			switch (cmd)
 			{
-			case 'p':
-				usb_debug_print();
-				break;
 			case 'b':
 				boot_dfu();
 				break;
-			case 'c':
-				usb_connect();
-				break;
-			case 'd':
-				usb_disconnect();
-				break;
             case 'w':
                 write_period1();
                 break;
@@ -250,8 +224,5 @@ void main()
 				break;
 			}
 		}
-
-		/* USB poll */
-		usb_poll();
 	}
 }

+ 0 - 182
projects/riscv_usb/fw/usb_desc_app.c

@@ -1,182 +0,0 @@
-/*
- * usb_desc_app.c
- *
- * Copyright (C) 2019 Sylvain Munaut
- * All rights reserved.
- *
- * LGPL v3+, see LICENSE.lgpl3
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#include <no2usb/usb_proto.h>
-#include <no2usb/usb_cdc_proto.h>
-#include <no2usb/usb_dfu_proto.h>
-#include <no2usb/usb.h>
-
-
-static const struct {
-	/* Configuration */
-	struct usb_conf_desc conf;
-
-	/* CDC */
-	struct {
-		struct usb_intf_desc intf_ctl;
-		struct usb_cdc_hdr_desc cdc_hdr;
-		struct usb_cdc_acm_desc cdc_acm;
-		struct usb_cdc_union_desc cdc_union;
-		uint8_t cdc_union_slave;
-		struct usb_ep_desc ep_ctl;
-		struct usb_intf_desc intf_data;
-		struct usb_ep_desc ep_data_out;
-		struct usb_ep_desc ep_data_in;
-	} __attribute__ ((packed)) cdc;
-
-	/* DFU Runtime */
-	struct {
-		struct usb_intf_desc intf;
-		struct usb_dfu_func_desc func;
-	} __attribute__ ((packed)) dfu;
-} __attribute__ ((packed)) _app_conf_desc = {
-	.conf = {
-		.bLength                = sizeof(struct usb_conf_desc),
-		.bDescriptorType        = USB_DT_CONF,
-		.wTotalLength           = sizeof(_app_conf_desc),
-		.bNumInterfaces         = 3,
-		.bConfigurationValue    = 1,
-		.iConfiguration         = 4,
-		.bmAttributes           = 0x80,
-		.bMaxPower              = 0x32, /* 100 mA */
-	},
-	.cdc = {
-		.intf_ctl = {
-			.bLength		= sizeof(struct usb_intf_desc),
-			.bDescriptorType	= USB_DT_INTF,
-			.bInterfaceNumber	= 0,
-			.bAlternateSetting	= 0,
-			.bNumEndpoints		= 1,
-			.bInterfaceClass	= USB_CLS_CDC_CONTROL,
-			.bInterfaceSubClass	= USB_CDC_SCLS_ACM,
-			.bInterfaceProtocol	= 0x00,
-			.iInterface		= 5,
-		},
-		.cdc_hdr = {
-			.bLength		= sizeof(struct usb_cdc_hdr_desc),
-			.bDescriptorType	= USB_CS_DT_INTF,
-			.bDescriptorsubtype	= USB_CDC_DST_HEADER,
-			.bcdCDC			= 0x0110,
-		},
-		.cdc_acm = {
-			.bLength		= sizeof(struct usb_cdc_acm_desc),
-			.bDescriptorType	= USB_CS_DT_INTF,
-			.bDescriptorsubtype	= USB_CDC_DST_ACM,
-			.bmCapabilities		= 0x02,
-		},
-		.cdc_union = {
-			.bLength		= sizeof(struct usb_cdc_union_desc) + 1,
-			.bDescriptorType	= USB_CS_DT_INTF,
-			.bDescriptorsubtype	= USB_CDC_DST_UNION,
-			.bMasterInterface	= 0,
-		},
-		.cdc_union_slave = 1,
-		.ep_ctl = {
-			.bLength		= sizeof(struct usb_ep_desc),
-			.bDescriptorType	= USB_DT_EP,
-			.bEndpointAddress	= 0x84,
-			.bmAttributes		= 0x03,
-			.wMaxPacketSize		= 64,
-			.bInterval		= 0x40,
-		},
-		.intf_data = {
-			.bLength		= sizeof(struct usb_intf_desc),
-			.bDescriptorType	= USB_DT_INTF,
-			.bInterfaceNumber	= 1,
-			.bAlternateSetting	= 0,
-			.bNumEndpoints		= 2,
-			.bInterfaceClass	= USB_CLS_CDC_DATA,
-			.bInterfaceSubClass	= 0x00,
-			.bInterfaceProtocol	= 0x00,
-			.iInterface		= 6,
-		},
-		.ep_data_out = {
-			.bLength		= sizeof(struct usb_ep_desc),
-			.bDescriptorType	= USB_DT_EP,
-			.bEndpointAddress	= 0x05,
-			.bmAttributes		= 0x02,
-			.wMaxPacketSize		= 64,
-			.bInterval		= 0x00,
-		},
-		.ep_data_in = {
-			.bLength		= sizeof(struct usb_ep_desc),
-			.bDescriptorType	= USB_DT_EP,
-			.bEndpointAddress	= 0x85,
-			.bmAttributes		= 0x02,
-			.wMaxPacketSize		= 64,
-			.bInterval		= 0x00,
-		},
-	},
-	.dfu = {
-		.intf = {
-			.bLength		= sizeof(struct usb_intf_desc),
-			.bDescriptorType	= USB_DT_INTF,
-			.bInterfaceNumber	= 2,
-			.bAlternateSetting	= 0,
-			.bNumEndpoints		= 0,
-			.bInterfaceClass	= USB_CLS_APP_SPECIFIC,
-			.bInterfaceSubClass	= 0x01,
-			.bInterfaceProtocol	= 0x01,
-			.iInterface		= 7,
-		},
-		.func = {
-			.bLength		= sizeof(struct usb_dfu_func_desc),
-			.bDescriptorType	= USB_DFU_DT_FUNC,
-			.bmAttributes		= 0x0d,
-			.wDetachTimeOut		= 0,
-			.wTransferSize		= 4096,
-			.bcdDFUVersion		= 0x0101,
-		},
-	},
-};
-
-static const struct usb_conf_desc * const _conf_desc_array[] = {
-	&_app_conf_desc.conf,
-};
-
-static const struct usb_dev_desc _dev_desc = {
-	.bLength		= sizeof(struct usb_dev_desc),
-	.bDescriptorType	= USB_DT_DEV,
-	.bcdUSB			= 0x0200,
-	.bDeviceClass		= 0,
-	.bDeviceSubClass	= 0,
-	.bDeviceProtocol	= 0,
-	.bMaxPacketSize0	= 64,
-	.idVendor		= 0x1d50,
-	.idProduct		= 0x6147,
-	.bcdDevice		= 0x0001,	/* v0.1 */
-	.iManufacturer		= 2,
-	.iProduct		= 3,
-	.iSerialNumber		= 1,
-	.bNumConfigurations	= num_elem(_conf_desc_array),
-};
-
-#include "usb_str_app.gen.h"
-
-const struct usb_stack_descriptors app_stack_desc = {
-	.dev = &_dev_desc,
-	.conf = _conf_desc_array,
-	.n_conf = num_elem(_conf_desc_array),
-	.str = _str_desc_array,
-	.n_str = num_elem(_str_desc_array),
-};

+ 0 - 7
projects/riscv_usb/fw/usb_str_app.txt

@@ -1,7 +0,0 @@
-0000000000000000
-osmocom
-!{"bitsy-v0": "iCEBreaker bitsy v0.x", "bitsy-v1": "iCEBreaker bitsy v1.x", "icebreaker": "iCEBreaker", "": "iCE40 USB Demo"}
-Main
-Console (control)
-Console (data)
-DFU runtime

+ 6 - 2
projects/riscv_usb/rtl/top.v

@@ -200,7 +200,7 @@ module top (
 	// USB [4 & 5]
 	// ---
 
-	soc_usb #(
+	/*soc_usb #(
 		.DW(WB_DW)
 	) usb_I (
 		.usb_dp   (usb_dp),
@@ -215,7 +215,11 @@ module top (
 		.clk_sys  (clk_24m),
 		.clk_48m  (clk_48m),
 		.rst      (rst)
-	);
+	);*/
+
+
+	assign wb_rdata[4] = 0;
+	assign wb_ack[5:4] = wb_cyc[5:4];
 
 	assign wb_rdata[5] = 0;