From 0773af5ae553d61d1f5deb63a60009a6235aa872 Mon Sep 17 00:00:00 2001 From: kendryte747 Date: Wed, 11 Sep 2024 09:30:03 +0800 Subject: [PATCH] Remove kburn's dependency on dram --- arch/riscv/Kconfig | 6 ++ arch/riscv/dts/Makefile | 2 + arch/riscv/dts/k230_burntool.dts | 81 +++++++++++++++++++++++++++ board/kendryte/k230_burntool/Kconfig | 19 +++++++ board/kendryte/k230_burntool/Makefile | 29 ++++++++++ board/kendryte/k230_burntool/board.c | 36 ++++++++++++ configs/k230_burntool_defconfig | 80 ++++++++++++++++++++++++++ include/kburn.h | 2 +- 8 files changed, 254 insertions(+), 1 deletion(-) create mode 100644 arch/riscv/dts/k230_burntool.dts create mode 100755 board/kendryte/k230_burntool/Kconfig create mode 100755 board/kendryte/k230_burntool/Makefile create mode 100644 board/kendryte/k230_burntool/board.c create mode 100755 configs/k230_burntool_defconfig diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 022737f3..552b43f1 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -51,6 +51,10 @@ config TARGET_K230_CANMV_DONGSHANPI bool "Support k230_CANMV(dongshanpi)" select SYS_CACHE_SHIFT_6 +config TARGET_K230_BURNTOOL + bool "Support k230 chip burn" + select SYS_CACHE_SHIFT_6 + endchoice config SYS_ICACHE_OFF @@ -85,6 +89,8 @@ source "board/sifive/unleashed/Kconfig" source "board/sifive/unmatched/Kconfig" source "board/openpiton/riscv64/Kconfig" source "board/sipeed/maix/Kconfig" + +source "board/kendryte/k230_burntool/Kconfig" source "board/kendryte/k230_canmv/Kconfig" source "board/kendryte/k230_canmv_01studio/Kconfig" source "board/kendryte/k230d_canmv_bpi_zero/Kconfig" diff --git a/arch/riscv/dts/Makefile b/arch/riscv/dts/Makefile index 062e84db..477b4844 100644 --- a/arch/riscv/dts/Makefile +++ b/arch/riscv/dts/Makefile @@ -8,6 +8,8 @@ dtb-$(CONFIG_TARGET_SIFIVE_UNLEASHED) += hifive-unleashed-a00.dtb dtb-$(CONFIG_TARGET_SIFIVE_UNMATCHED) += hifive-unmatched-a00.dtb dtb-$(CONFIG_TARGET_SIPEED_MAIX) += k210-maix-bit.dtb +dtb-$(CONFIG_TARGET_K230_BURNTOOL) += k230_burntool.dtb # just for burntool + dtb-$(CONFIG_TARGET_K230_CANMV) += k230_canmv.dtb dtb-$(CONFIG_TARGET_K230_CANMV_V3P0) += k230_canmv_v3p0.dtb dtb-$(CONFIG_TARGET_K230_CANMV_V3P0) += k230_canmv_lckfb.dtb # lckfb use same target. diff --git a/arch/riscv/dts/k230_burntool.dts b/arch/riscv/dts/k230_burntool.dts new file mode 100644 index 00000000..143511e2 --- /dev/null +++ b/arch/riscv/dts/k230_burntool.dts @@ -0,0 +1,81 @@ +/* Copyright (c) 2023, Canaan Bright Sight Co., Ltd + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +/dts-v1/; + +#include + +#define BANK_VOLTAGE_IO0_IO1 K230_MSC_1V8 // FIXED +#define BANK_VOLTAGE_IO2_IO13 K230_MSC_3V3 +#define BANK_VOLTAGE_IO14_IO25 K230_MSC_3V3 +#define BANK_VOLTAGE_IO26_IO37 K230_MSC_3V3 +#define BANK_VOLTAGE_IO38_IO49 K230_MSC_3V3 +#define BANK_VOLTAGE_IO50_IO61 K230_MSC_3V3 +#define BANK_VOLTAGE_IO62_IO63 K230_MSC_3V3 + +#include "k230.dtsi" + +/ { + model = "kendryte k230 burntool"; + compatible = "kendryte,k230_burntool"; + + memory@0x80200000 { + device_type = "memory"; + reg = <0x00000000 0x80200000 0x0 0x160000>; + }; +}; + +&mmc0 { + status = "okay"; +}; + +&mmc1 { + status = "okay"; +}; + +&usbotg0 { + status = "okay"; +}; + +&iomux { + pinctrl-names = "default"; + pinctrl-0 = <&pins>; + +// Please pay attention to the bank voltage! will damage the chip. + pins: iomux_pins { + u-boot,dm-pre-reloc; + pinctrl-single,pins = < + + // boot + (IO0 ) ( 1<; + }; +}; diff --git a/board/kendryte/k230_burntool/Kconfig b/board/kendryte/k230_burntool/Kconfig new file mode 100755 index 00000000..201ff12a --- /dev/null +++ b/board/kendryte/k230_burntool/Kconfig @@ -0,0 +1,19 @@ +if TARGET_K230_BURNTOOL + + config SYS_CPU + default "k230" + + config SYS_VENDOR + default "kendryte" + + config SYS_BOARD + default "k230_burntool" + + config SYS_CONFIG_NAME + default "k230_common" + + config BOARD_SPECIFIC_OPTIONS + def_bool y + select KENDRYTE_K230 + +endif diff --git a/board/kendryte/k230_burntool/Makefile b/board/kendryte/k230_burntool/Makefile new file mode 100755 index 00000000..08ce3724 --- /dev/null +++ b/board/kendryte/k230_burntool/Makefile @@ -0,0 +1,29 @@ +# /* Copyright (c) 2023, Canaan Bright Sight Co., Ltd +# * +# * Redistribution and use in source and binary forms, with or without +# * modification, are permitted provided that the following conditions are met: +# * 1. Redistributions of source code must retain the above copyright +# * notice, this list of conditions and the following disclaimer. +# * 2. Redistributions in binary form must reproduce the above copyright +# * notice, this list of conditions and the following disclaimer in the +# * documentation and/or other materials provided with the distribution. +# * +# * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +# * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +# * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# */ + +BOARD_COMMON_DIR = $(srctree)/board/$(VENDOR)/common +EXTRA_CFLAGS += -I$(BOARD_COMMON_DIR) + +obj-y += board.o diff --git a/board/kendryte/k230_burntool/board.c b/board/kendryte/k230_burntool/board.c new file mode 100644 index 00000000..aa221962 --- /dev/null +++ b/board/kendryte/k230_burntool/board.c @@ -0,0 +1,36 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "board_common.h" + +int board_early_init_f(void) { + return 0; +} + +#ifdef CONFIG_BOARD_LATE_INIT +int board_late_init(void) { +#define USB_IDPULLUP0 (1 << 4) +#define USB_DMPULLDOWN0 (1 << 8) +#define USB_DPPULLDOWN0 (1 << 9) + + u32 usb0_test_ctl3 = readl((void *)USB0_TEST_CTL3); + usb0_test_ctl3 |= USB_IDPULLUP0; + writel(usb0_test_ctl3, (void *)USB0_TEST_CTL3); + + return 0; +} +#endif diff --git a/configs/k230_burntool_defconfig b/configs/k230_burntool_defconfig new file mode 100755 index 00000000..8eddf73a --- /dev/null +++ b/configs/k230_burntool_defconfig @@ -0,0 +1,80 @@ +CONFIG_RISCV=y +CONFIG_SYS_TEXT_BASE=0x80360000 +CONFIG_SYS_MALLOC_LEN=0x80000 +CONFIG_NR_DRAM_BANKS=3 +CONFIG_ENV_SIZE=0x10000 +CONFIG_DEFAULT_DEVICE_TREE="k230_burntool" +CONFIG_SYS_PROMPT="K230# " +CONFIG_SYS_LOAD_ADDR=0x00000000 +CONFIG_BUILD_TARGET="u-boot.bin" +CONFIG_TARGET_K230_BURNTOOL=y +CONFIG_ARCH_RV64I=y +CONFIG_SHOW_REGS=y +CONFIG_CC_OPTIMIZE_FOR_DEBUG=y +CONFIG_DISTRO_DEFAULTS=y +CONFIG_FIT=y +CONFIG_TIMESTAMP=y +CONFIG_FIT_SIGNATURE=y +CONFIG_LEGACY_IMAGE_FORMAT=y +CONFIG_BOOTDELAY=0 +CONFIG_BOOTCOMMAND="kburn 0" +CONFIG_LOGLEVEL=7 +CONFIG_SYS_STDIO_DEREGISTER=y +# CONFIG_SYS_DEVICE_NULLDEV is not set +CONFIG_DISPLAY_CPUINFO=y +CONFIG_DISPLAY_BOARDINFO=y +CONFIG_BOARD_EARLY_INIT_F=y +CONFIG_BOARD_LATE_INIT=y +CONFIG_CMD_GPT=y +CONFIG_CMD_MMC=y +CONFIG_CMD_MTD=y +# CONFIG_CMD_PINMUX is not set +CONFIG_CMD_SF_TEST=y +CONFIG_CMD_USB=y +CONFIG_CMD_KBURN=y +CONFIG_PARTITION_TYPE_GUID=y +CONFIG_OF_EMBED=y +CONFIG_SYS_RELOC_GD_ENV_ADDR=y +# CONFIG_NET is not set +# CONFIG_INPUT is not set +CONFIG_KBURN_MMC=y +CONFIG_MMC=y +CONFIG_MMC_HS200_SUPPORT=y +CONFIG_MMC_DW=y +CONFIG_MMC_SDHCI=y +CONFIG_MMC_SDHCI_SDMA=y +CONFIG_MMC_SDHCI_SNPS=y +CONFIG_DM_MTD=y +CONFIG_MTD_SPI_NAND=y +CONFIG_SPI_FLASH_SFDP_SUPPORT=y +CONFIG_SPI_FLASH_SOFT_RESET=y +CONFIG_SPI_FLASH_SOFT_RESET_ON_BOOT=y +CONFIG_SPI_FLASH_GIGADEVICE=y +CONFIG_SPI_FLASH_WINBOND=y +# CONFIG_SPI_FLASH_USE_4K_SECTORS is not set +CONFIG_SPI_FLASH_MTD=y +CONFIG_PINCTRL=y +CONFIG_PINCTRL_SINGLE=y +CONFIG_SYS_NS16550=y +CONFIG_SPI=y +CONFIG_DESIGNWARE_SPI=y +CONFIG_USB=y +CONFIG_DM_USB_GADGET=y +CONFIG_USB_DWC2=y +CONFIG_USB_HOST_ETHER=y +CONFIG_USB_ETHER_ASIX=y +CONFIG_USB_ETHER_ASIX88179=y +CONFIG_USB_ETHER_MCS7830=y +CONFIG_USB_ETHER_RTL8152=y +CONFIG_USB_ETHER_SMSC95XX=y +CONFIG_USB_GADGET=y +CONFIG_USB_GADGET_MANUFACTURER="Kendryte" +CONFIG_USB_GADGET_VENDOR_NUM=0x29f1 +CONFIG_USB_GADGET_PRODUCT_NUM=0x0230 +CONFIG_USB_GADGET_DWC2_OTG=y +CONFIG_USB_GADGET_VBUS_DRAW=500 +CONFIG_USB_GADGET_DOWNLOAD=y +CONFIG_FAT_WRITE=y +CONFIG_REGEX=y +CONFIG_SPL_GZIP=y +# CONFIG_EFI_LOADER is not set diff --git a/include/kburn.h b/include/kburn.h index e13c60d7..5bf1ebb8 100644 --- a/include/kburn.h +++ b/include/kburn.h @@ -9,7 +9,7 @@ #define KBURN_USB_INTF_SUBCLASS (0x02) #define KBURN_USB_INTF_PROTOCOL (0x00) -#define KBURN_USB_EP_BUFFER_SZIE (512 * 1024) +#define KBURN_USB_EP_BUFFER_SZIE (128 * 1024) #define KBURN_USB_BUFFER_SIZE (KBURN_USB_EP_BUFFER_SZIE * 2) #endif