Skip to content

Commit

Permalink
Remove kburn's dependency on dram
Browse files Browse the repository at this point in the history
  • Loading branch information
kendryte747 committed Sep 11, 2024
1 parent 900f23a commit 0773af5
Show file tree
Hide file tree
Showing 8 changed files with 254 additions and 1 deletion.
6 changes: 6 additions & 0 deletions arch/riscv/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions arch/riscv/dts/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
81 changes: 81 additions & 0 deletions arch/riscv/dts/k230_burntool.dts
Original file line number Diff line number Diff line change
@@ -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 <dt-bindings/pinctrl/k230-pinctrl.h>

#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<<SEL | 0<<SL | BANK_VOLTAGE_IO0_IO1 <<MSC | 0<<IE | 1<<OE | 1<<PU | 0<<PD | 2<<DS | 0<<ST )
// boot1
(IO1 ) ( 1<<SEL | 0<<SL | BANK_VOLTAGE_IO0_IO1 <<MSC | 0<<IE | 1<<OE | 1<<PU | 0<<PD | 2<<DS | 0<<ST )

// UART0_TXD
(IO38) ( 1<<SEL | 0<<SL | BANK_VOLTAGE_IO38_IO49<<MSC | 0<<IE | 1<<OE | 0<<PU | 0<<PD | 7<<DS | 1<<ST )
// UART0_RXD
(IO39) ( 1<<SEL | 0<<SL | BANK_VOLTAGE_IO38_IO49<<MSC | 1<<IE | 0<<OE | 0<<PU | 0<<PD | 7<<DS | 1<<ST )
>;
};
};
19 changes: 19 additions & 0 deletions board/kendryte/k230_burntool/Kconfig
Original file line number Diff line number Diff line change
@@ -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
29 changes: 29 additions & 0 deletions board/kendryte/k230_burntool/Makefile
Original file line number Diff line number Diff line change
@@ -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
36 changes: 36 additions & 0 deletions board/kendryte/k230_burntool/board.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include <asm/asm.h>
#include <asm/io.h>
#include <asm/spl.h>
#include <asm/types.h>
#include <command.h>
#include <common.h>
#include <cpu_func.h>
#include <dm.h>
#include <env_internal.h>
#include <image.h>
#include <linux/delay.h>
#include <linux/kernel.h>
#include <lmb.h>
#include <stdio.h>

#include <kendryte/k230_platform.h>

#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
80 changes: 80 additions & 0 deletions configs/k230_burntool_defconfig
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion include/kburn.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0773af5

Please sign in to comment.