Переглянути джерело

projects/riscv_usb: Remove all DFU bootloader code

This is now in a separate project no2bootloader

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Sylvain Munaut 4 роки тому
батько
коміт
1a0f4858e8

+ 3 - 8
projects/riscv_usb/Makefile

@@ -23,7 +23,6 @@ PROJ_TOP_SRC := rtl/top.v
 PROJ_TOP_MOD := top
 
 # Target config
-BOOT_CODE ?= app
 BOARD ?= icebreaker
 DEVICE = up5k
 PACKAGE = sg48
@@ -34,12 +33,8 @@ NEXTPNR_ARGS = --pre-pack data/clocks.py --seed 2
 include ../../build/project-rules.mk
 
 # Custom rules
-ifeq ($(BOOT_CODE),dfu)
-YOSYS_READ_ARGS += -DDFU=1
-endif
+fw/boot.hex:
+	make -C fw boot.hex
 
-fw/boot_$(BOOT_CODE).hex:
-	make -C fw boot_$(BOOT_CODE).hex
-
-$(BUILD_TMP)/boot.hex: fw/boot_$(BOOT_CODE).hex
+$(BUILD_TMP)/boot.hex: fw/boot.hex
 	cp $< $@

+ 5 - 22
projects/riscv_usb/fw/Makefile

@@ -30,14 +30,6 @@ SOURCES_common=\
 	utils.c \
 	$(SOURCES_no2usb)
 
-HEADERS_dfu=\
-	usb_str_dfu.gen.h
-
-SOURCES_dfu=\
-	fw_dfu.c \
-	usb_desc_dfu.c \
-	$(NULL)
-
 HEADERS_app=\
 	usb_str_app.gen.h \
 	$(NULL)
@@ -48,18 +40,12 @@ SOURCES_app=\
 	$(NULL)
 
 
-all: boot_dfu.hex boot_app.hex fw_dfu.bin fw_app.bin
+all: boot.hex fw_app.bin
 
 
-boot_dfu.elf: lnk-boot.lds boot.S
-	$(CC) $(CFLAGS) -Wl,-Bstatic,-T,lnk-boot.lds,--strip-debug -DFLASH_APP_ADDR=0x00060000 -o $@ boot.S
-
-boot_app.elf: lnk-boot.lds boot.S
+boot.elf: lnk-boot.lds boot.S
 	$(CC) $(CFLAGS) -Wl,-Bstatic,-T,lnk-boot.lds,--strip-debug -DFLASH_APP_ADDR=0x000a0000 -o $@ boot.S
 
-fw_dfu.elf: lnk-app.lds $(HEADERS_dfu) $(SOURCES_dfu) $(HEADERS_common) $(SOURCES_common)
-	$(CC) $(CFLAGS) -Wl,-Bstatic,-T,lnk-app.lds,--strip-debug -o $@ $(SOURCES_common) $(SOURCES_dfu)
-
 fw_app.elf: lnk-app.lds $(HEADERS_app) $(SOURCES_app) $(HEADERS_common) $(SOURCES_common)
 	$(CC) $(CFLAGS) -Wl,-Bstatic,-T,lnk-app.lds,--strip-debug -o $@ $(SOURCES_common) $(SOURCES_app)
 
@@ -71,13 +57,10 @@ fw_app.elf: lnk-app.lds $(HEADERS_app) $(SOURCES_app) $(HEADERS_common) $(SOURCE
 	$(OBJCOPY) -O binary $< $@
 
 
-prog_dfu: fw_dfu.bin
-	$(ICEPROG) -o 384k $<
-
-prog_app: fw_app.bin
+prog: fw_app.bin
 	$(ICEPROG) -o 640k $<
 
-dfuprog_app: fw_app.bin
+dfuprog: fw_app.bin
 ifeq ($(DFU_SERIAL),)
 	@echo "[!] DFU_SERIAL not defined"
 else
@@ -88,4 +71,4 @@ endif
 clean:
 	rm -f *.bin *.hex *.elf *.o *.gen.h
 
-.PHONY: prog_dfu prog_app clean
+.PHONY: prog_app clean

+ 0 - 140
projects/riscv_usb/fw/fw_dfu.c

@@ -1,140 +0,0 @@
-/*
- * fw_dfu.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 <stdint.h>
-#include <stdbool.h>
-#include <string.h>
-
-#include "console.h"
-#include "led.h"
-#include "mini-printf.h"
-#include "spi.h"
-#include <no2usb/usb.h>
-#include <no2usb/usb_dfu.h>
-#include "utils.h"
-
-
-extern const struct usb_stack_descriptors dfu_stack_desc;
-
-static void
-serial_no_init()
-{
-	uint8_t buf[8];
-	char *id, *desc;
-	int i;
-
-	flash_manuf_id(buf);
-	printf("Flash Manufacturer : %s\n", hexstr(buf, 3, true));
-
-	flash_unique_id(buf);
-	printf("Flash Unique ID    : %s\n", hexstr(buf, 8, true));
-
-	/* Overwrite descriptor string */
-		/* In theory in rodata ... but nothing is ro here */
-	id = hexstr(buf, 8, false);
-	desc = (char*)dfu_stack_desc.str[1];
-	for (i=0; i<16; i++)
-		desc[2 + (i << 1)] = id[i];
-}
-
-static void
-boot_app(void)
-{
-	/* Force re-enumeration */
-	usb_disconnect();
-
-	/* Boot firmware */
-	volatile uint32_t *boot = (void*)0x80000000;
-	*boot = (1 << 2) | (2 << 0);
-}
-
-void
-usb_dfu_cb_reboot(void)
-{
-	boot_app();
-}
-
-void main()
-{
-	int cmd = 0;
-
-	/* Init console IO */
-	console_init();
-	puts("Booting DFU image..\n");
-
-	/* LED */
-	led_init();
-	led_color(72, 64, 0);
-	led_blink(true, 150, 150);
-	led_breathe(true, 50, 100);
-	led_state(true);
-
-	/* SPI */
-	spi_init();
-
-	/* Enable USB directly */
-	serial_no_init();
-	usb_init(&dfu_stack_desc);
-	usb_dfu_init();
-	usb_connect();
-
-	/* Main loop */
-	while (1)
-	{
-		/* Prompt ? */
-		if (cmd >= 0)
-			printf("Command> ");
-
-		/* Poll for command */
-		cmd = getchar_nowait();
-
-		if (cmd >= 0) {
-			if (cmd > 32 && cmd < 127) {
-				putchar(cmd);
-				putchar('\r');
-				putchar('\n');
-			}
-
-			switch (cmd)
-			{
-			case 'p':
-				usb_debug_print();
-				break;
-			case 'c':
-				usb_connect();
-				break;
-			case 'd':
-				usb_disconnect();
-				break;
-			case 'b':
-				boot_app();
-				break;
-			default:
-				break;
-			}
-		}
-
-		/* USB poll */
-		usb_poll();
-	}
-}

+ 0 - 128
projects/riscv_usb/fw/usb_desc_dfu.c

@@ -1,128 +0,0 @@
-/*
- * usb_desc_dfu.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.h>
-
-#define NULL ((void*)0)
-#define num_elem(a) (sizeof(a) / sizeof(a[0]))
-
-
-static const struct {
-	struct usb_conf_desc conf;
-	struct usb_intf_desc if_fpga;
-	struct usb_dfu_desc dfu_fpga;
-	struct usb_intf_desc if_riscv;
-	struct usb_dfu_desc dfu_riscv;
-} __attribute__ ((packed)) _dfu_conf_desc = {
-	.conf = {
-		.bLength                = sizeof(struct usb_conf_desc),
-		.bDescriptorType        = USB_DT_CONF,
-		.wTotalLength           = sizeof(_dfu_conf_desc),
-		.bNumInterfaces         = 1,
-		.bConfigurationValue    = 1,
-		.iConfiguration         = 4,
-		.bmAttributes           = 0x80,
-		.bMaxPower              = 0x32, /* 100 mA */
-	},
-	.if_fpga = {
-		.bLength		= sizeof(struct usb_intf_desc),
-		.bDescriptorType	= USB_DT_INTF,
-		.bInterfaceNumber	= 0,
-		.bAlternateSetting	= 0,
-		.bNumEndpoints		= 0,
-		.bInterfaceClass	= 0xfe,
-		.bInterfaceSubClass	= 0x01,
-		.bInterfaceProtocol	= 0x02,
-		.iInterface		= 5,
-	},
-	.dfu_fpga = {
-		.bLength		= sizeof(struct usb_dfu_desc),
-		.bDescriptorType	= USB_DT_DFU,
-		.bmAttributes		= 0x0d,
-		.wDetachTimeOut		= 1000,
-		.wTransferSize		= 4096,
-		.bcdDFUVersion		= 0x0101,
-	},
-	.if_riscv = {
-		.bLength		= sizeof(struct usb_intf_desc),
-		.bDescriptorType	= USB_DT_INTF,
-		.bInterfaceNumber	= 0,
-		.bAlternateSetting	= 1,
-		.bNumEndpoints		= 0,
-		.bInterfaceClass	= 0xfe,
-		.bInterfaceSubClass	= 0x01,
-		.bInterfaceProtocol	= 0x02,
-		.iInterface		= 6,
-	},
-	.dfu_riscv = {
-		.bLength		= sizeof(struct usb_dfu_desc),
-		.bDescriptorType	= USB_DT_DFU,
-		.bmAttributes		= 0x0d,
-		.wDetachTimeOut		= 1000,
-		.wTransferSize		= 4096,
-		.bcdDFUVersion		= 0x0101,
-	},
-};
-
-static const struct usb_conf_desc * const _conf_desc_array[] = {
-	&_dfu_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,
-#if defined(BOARD_ICE1USB)
-	.idVendor		= 0x1d50,
-	.idProduct		= 0x6144,
-#elif defined(BOARD_ICEPICK)
-	.idVendor		= 0x1d50,
-	.idProduct		= 0x6148,
-#elif defined(BOARD_E1TRACER)
-	.idVendor		= 0x1d50,
-	.idProduct		= 0x6150,
-#else
-	.idVendor		= 0x1d50,
-	.idProduct		= 0x6146,
-#endif
-	.bcdDevice		= 0x0004,	/* v0.4 */
-	.iManufacturer		= 2,
-	.iProduct		= 3,
-	.iSerialNumber		= 1,
-	.bNumConfigurations	= num_elem(_conf_desc_array),
-};
-
-#include "usb_str_dfu.gen.h"
-
-const struct usb_stack_descriptors dfu_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 - 6
projects/riscv_usb/fw/usb_str_dfu.txt

@@ -1,6 +0,0 @@
-0000000000000000
-osmocom
-!{"bitsy-v0": "iCEBreaker bitsy v0.x (DFU)", "bitsy-v1": "iCEBreaker bitsy v1.x (DFU)", "e1tracer": "E1 tracer (DFU)", "ice1usb": "icE1usb (DFU)", "icebreaker": "iCEBreaker (DFU)", "icepick": "iCEpick (DFU)", "": "iCE40 USB Device (DFU)"}
-DFU
-iCE40 bitstream
-RISC-V firmware

+ 0 - 4
projects/riscv_usb/rtl/top.v

@@ -519,11 +519,7 @@ module top (
 	dfu_helper #(
 		.TIMER_WIDTH(24),
 		.BTN_MODE(3),
-`ifdef DFU
-		.DFU_MODE(1)
-`else
 		.DFU_MODE(0)
-`endif
 	) dfu_helper_I (
 		.boot_now(boot_now),
 		.boot_sel(boot_sel),