diff mbox series

[v2,07/11] riscv: Add initial Sipeed Maix support

Message ID 4c9aa605-013e-a32d-6d90-97286a0080dc@gmail.com
State New
Headers show
Series riscv: Add Sipeed Maix support | expand

Commit Message

Sean Anderson Jan. 15, 2020, 11:04 p.m. UTC
The Sipeed Maix series is a collection of boards built around the RISC-V
Kendryte K210 processor. This processor contains several peripherals to
accelerate neural network processing and other "ai" tasks. This includes a "KPU"
neural network processor, an audio processor supporting beamforming reception,
and a digital video port supporting capture and output at VGA resolution. Other
peripherals include 8M of sram (accessible with and without caching);
remappable pins, including 40 GPIOs; AES, FFT, and SHA256 accelerators; a DMA
controller; and I2C, I2S, and SPI controllers. Maix peripherals vary, but
include spi flash; on-board usb-serial bridges; ports for cameras, displays, and
sd cards; and ESP32 chips. Currently, only the Sipeed Maix Bit V2.0 (bitm) is
supported, but the boards are fairly similar.

Documentation for Maix boards is located at <http://dl.sipeed.com/MAIX/HDK/>.
Documentation for the Kendryte K210 is located at
<https://kendryte.com/downloads/>. However, hardware details are rather lacking,
so most technical reference has been taken from the standalone sdk located at
<https://github.com/kendryte/kendryte-standalone-sdk>.

Signed-off-by: Sean Anderson <seanga2 at gmail.com>
---
Changes for v2:
  Select CONFIG_SYS_RISCV_NOCOUNTER.
  Imply CONFIG_CLK_K210.
  Remove spurious references to CONFIG_ARCH_K210.
  Remove many configs from defconfig where the defaults were fine.
  Add a few "not set" lines to suppress unneeded defaults.
  Reduce pre-reloc malloc space, now that clocks initialization happens
  later.
  
 arch/riscv/Kconfig                 |  4 ++
 board/sipeed/maix/Kconfig          | 41 +++++++++++++
 board/sipeed/maix/MAINTAINERS      | 13 +++++
 board/sipeed/maix/Makefile         |  5 ++
 board/sipeed/maix/maix.c           |  9 +++
 configs/sipeed_maix_bitm_defconfig | 93 ++++++++++++++++++++++++++++++
 include/configs/sipeed-maix.h      | 19 ++++++
 7 files changed, 184 insertions(+)
 create mode 100644 board/sipeed/maix/Kconfig
 create mode 100644 board/sipeed/maix/MAINTAINERS
 create mode 100644 board/sipeed/maix/Makefile
 create mode 100644 board/sipeed/maix/maix.c
 create mode 100644 configs/sipeed_maix_bitm_defconfig
 create mode 100644 include/configs/sipeed-maix.h

Comments

Lukas Auer Jan. 26, 2020, 10:17 p.m. UTC | #1
Hi Sean,


On Wed, 2020-01-15 at 18:04 -0500, Sean Anderson wrote:
> The Sipeed Maix series is a collection of boards built around the RISC-V
> Kendryte K210 processor. This processor contains several peripherals to
> accelerate neural network processing and other "ai" tasks. This includes a "KPU"
> neural network processor, an audio processor supporting beamforming reception,
> and a digital video port supporting capture and output at VGA resolution. Other
> peripherals include 8M of sram (accessible with and without caching);
> remappable pins, including 40 GPIOs; AES, FFT, and SHA256 accelerators; a DMA
> controller; and I2C, I2S, and SPI controllers. Maix peripherals vary, but
> include spi flash; on-board usb-serial bridges; ports for cameras, displays, and
> sd cards; and ESP32 chips. Currently, only the Sipeed Maix Bit V2.0 (bitm) is
> supported, but the boards are fairly similar.
> 
> Documentation for Maix boards is located at <http://dl.sipeed.com/MAIX/HDK/>;.
> Documentation for the Kendryte K210 is located at
> <https://kendryte.com/downloads/>;. However, hardware details are rather lacking,
> so most technical reference has been taken from the standalone sdk located at
> <https://github.com/kendryte/kendryte-standalone-sdk>;.
> 
> Signed-off-by: Sean Anderson <seanga2 at gmail.com>

This patch should be the last in the patch series, because it requires
all other patches in the series.

> ---
> Changes for v2:
>   Select CONFIG_SYS_RISCV_NOCOUNTER.
>   Imply CONFIG_CLK_K210.
>   Remove spurious references to CONFIG_ARCH_K210.
>   Remove many configs from defconfig where the defaults were fine.
>   Add a few "not set" lines to suppress unneeded defaults.
>   Reduce pre-reloc malloc space, now that clocks initialization happens
>   later.
>   
>  arch/riscv/Kconfig                 |  4 ++
>  board/sipeed/maix/Kconfig          | 41 +++++++++++++
>  board/sipeed/maix/MAINTAINERS      | 13 +++++
>  board/sipeed/maix/Makefile         |  5 ++
>  board/sipeed/maix/maix.c           |  9 +++
>  configs/sipeed_maix_bitm_defconfig | 93 ++++++++++++++++++++++++++++++
>  include/configs/sipeed-maix.h      | 19 ++++++
>  7 files changed, 184 insertions(+)
>  create mode 100644 board/sipeed/maix/Kconfig
>  create mode 100644 board/sipeed/maix/MAINTAINERS
>  create mode 100644 board/sipeed/maix/Makefile
>  create mode 100644 board/sipeed/maix/maix.c
>  create mode 100644 configs/sipeed_maix_bitm_defconfig
>  create mode 100644 include/configs/sipeed-maix.h
> 
> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> index 4f8c62dcff..4c62b8dd77 100644
> --- a/arch/riscv/Kconfig
> +++ b/arch/riscv/Kconfig
> @@ -20,6 +20,9 @@ config TARGET_QEMU_VIRT
>  config TARGET_SIFIVE_FU540
>  	bool "Support SiFive FU540 Board"
>  
> +config TARGET_SIPEED_MAIX
> +	bool "Support Sipeed Maix Board"
> +
>  endchoice
>  
>  config SYS_ICACHE_OFF
> @@ -53,6 +56,7 @@ source "board/AndesTech/ax25-ae350/Kconfig"
>  source "board/emulation/qemu-riscv/Kconfig"
>  source "board/microchip/mpfs_icicle/Kconfig"
>  source "board/sifive/fu540/Kconfig"
> +source "board/sipeed/maix/Kconfig"
>  
>  # platform-specific options below
>  source "arch/riscv/cpu/ax25/Kconfig"
> diff --git a/board/sipeed/maix/Kconfig b/board/sipeed/maix/Kconfig
> new file mode 100644
> index 0000000000..9259eb34aa
> --- /dev/null
> +++ b/board/sipeed/maix/Kconfig
> @@ -0,0 +1,41 @@
> +# SPDX-License-Identifier: GPL-2.0+
> +# Copyright (C) 2019 Sean Anderson <seanga2 at gmail.com>
> +
> +if TARGET_SIPEED_MAIX
> +
> +config SYS_BOARD
> +	default "maix"
> +
> +config SYS_VENDOR
> +	default "sipeed"
> +
> +config SYS_CPU
> +	default "generic"
> +
> +config SYS_CONFIG_NAME
> +	default "sipeed-maix"
> +
> +config SYS_TEXT_BASE
> +	default 0x80000000
> +
> +config NR_CPUS
> +	default 2
> +
> +config NR_DRAM_BANKS
> +	default 2
> +
> +config BOARD_SPECIFIC_OPTIONS
> +	def_bool y
> +	select GENERIC_RISCV
> +	select DM_SERIAL
> +	select SIFIVE_SERIAL
> +	select ARCH_DEFAULT_RV64I
> +	select ENV_IS_NOWHERE

ENV_IS_NOWHERE is automatically selected if no other environment
provider is available, so no need to include it here.
Also, why are you not using the SD card to store the environment?

> +	select SYS_RISCV_NOCOUNTER
> +	imply SIFIVE_CLINT
> +	imply SPI
> +	imply DM_GPIO
> +	imply CMD_GPIO
> +	imply SYS_NS16550
> +	imply SYS_MALLOC_F
> +endif
> diff --git a/board/sipeed/maix/MAINTAINERS b/board/sipeed/maix/MAINTAINERS
> new file mode 100644
> index 0000000000..217de45970
> --- /dev/null
> +++ b/board/sipeed/maix/MAINTAINERS
> @@ -0,0 +1,13 @@
> +Sipeed Maix BOARD
> +M:	Sean Anderson <seanga2 at gmail.com>
> +S:	Maintained
> +F:	arch/riscv/dts/k210.dtsi
> +F:	arch/riscv/dts/k210-maix-bit.dts
> +F:	arch/riscv/include/asm/k210_sysctl.h
> +F:	arch/riscv/lib/k210_sysctl.c
> +F:	board/sipeed/maix/
> +F:	configs/sipeed_maix_defconfig
> +F:	drivers/clk/kendryte/
> +F:	include/configs/sipeed-maix.h
> +F:	include/dt-bindings/clock/k210-sysctl.h
> +F:	include/dt-bindings/reset/k210-sysctl.h
> diff --git a/board/sipeed/maix/Makefile b/board/sipeed/maix/Makefile
> new file mode 100644
> index 0000000000..4acff5b31e
> --- /dev/null
> +++ b/board/sipeed/maix/Makefile
> @@ -0,0 +1,5 @@
> +# SPDX-License-Identifier: GPL-2.0+
> +#
> +# Copyright (c) 2019 Western Digital Corporation or its affiliates.
> +
> +obj-y += maix.o
> diff --git a/board/sipeed/maix/maix.c b/board/sipeed/maix/maix.c
> new file mode 100644
> index 0000000000..f8e773acf7
> --- /dev/null
> +++ b/board/sipeed/maix/maix.c
> @@ -0,0 +1,9 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Copyright (C) 2019 Sean Anderson <seanga2 at gmail.com>
> + */
> +
> +int board_init(void)
> +{
> +	return 0;
> +}
> diff --git a/configs/sipeed_maix_bitm_defconfig b/configs/sipeed_maix_bitm_defconfig
> new file mode 100644
> index 0000000000..f062cc8c58
> --- /dev/null
> +++ b/configs/sipeed_maix_bitm_defconfig
> @@ -0,0 +1,93 @@
> +# SPDX-License-Identifier: GPL-2.0+
> +# Copyright (C) 2019 Sean Anderson <seanga2 at gmail.com>
> +CONFIG_CREATE_ARCH_SYMLINK=y
> +CONFIG_RISCV=y
> +CONFIG_SYS_ARCH="riscv"
> +CONFIG_SYS_CPU="generic"
> +CONFIG_SYS_VENDOR="sipeed"
> +CONFIG_SYS_BOARD="maix"
> +CONFIG_SYS_CONFIG_NAME="sipeed-maix"
> +CONFIG_SPL_LDSCRIPT="arch/riscv/cpu/u-boot-spl.lds"
> +CONFIG_SYS_TEXT_BASE=0x80000000
> +CONFIG_SYS_MALLOC_F_LEN=0x1000
> +CONFIG_BOARD_SPECIFIC_OPTIONS=y
> +CONFIG_NR_DRAM_BANKS=2
> +CONFIG_BOOTSTAGE_STASH_ADDR=0
> +CONFIG_64BIT=y
> +CONFIG_TARGET_SIPEED_MAIX=y
> +CONFIG_NR_CPUS=2
> +CONFIG_GENERIC_RISCV=y
> +CONFIG_ARCH_DEFAULT_RV64I=y
> +CONFIG_ARCH_RV64I=y
> +CONFIG_CMODEL_MEDLOW=y
> +CONFIG_RISCV_MMODE=y
> +CONFIG_RISCV_ISA_C=y
> +CONFIG_RISCV_ISA_A=y
> +CONFIG_SIFIVE_CLINT=y
> +CONFIG_K210_SYSCTL=y
> +CONFIG_SYS_RISCV_NOCOUNTER=y
> +CONFIG_ARCH_K210=y
> +CONFIG_CC_OPTIMIZE_FOR_SIZE=y
> +CONFIG_SYS_MALLOC_F=y
> +CONFIG_PHYS_64BIT=y
> +# CONFIG_ANDROID_BOOT_IMAGE is not set
> +# CONFIG_FIT is not set
> +# CONFIG_LEGACY_IMAGE_FORMAT is not set
> +CONFIG_LOG=y
> +CONFIG_ARCH_EARLY_INIT_R=y
> +CONFIG_CMDLINE=y
> +CONFIG_CMD_ENV_EXISTS=y
> +CONFIG_CMD_FLASH=y
> +CONFIG_CMD_SF=y
> +CONFIG_CMD_LOG=y
> +# CONFIG_AUTOBOOT is not set
> +# CONFIG_CMD_BDI is not set
> +# CONFIG_CMD_CONSOLE is not set
> +# CONFIG_CMD_BOOTD is not set
> +# CONFIG_CMD_BOOTM is not set
> +# CONFIG_CMD_BOOTZ is not set
> +CONFIG_CMD_BOOTI=y
> +CONFIG_BOOTM_LINUX=y
> +# CONFIG_CMD_ELF is not set
> +CONFIG_CMD_FDT=y
> +CONFIG_SUPPORT_OF_CONTROL=y
> +CONFIG_DTC=y
> +CONFIG_OF_CONTROL=y
> +CONFIG_OF_SEPARATE=y
> +CONFIG_ENV_IS_NOWHERE=y
> +# CONFIG_NET is not set
> +CONFIG_DM=y
> +CONFIG_REGMAP=y
> +CONFIG_SYSCON=y
> +CONFIG_SIMPLE_BUS=y
> +CONFIG_OF_TRANSLATE=y
> +CONFIG_CLK=y
> +CONFIG_CLK_CCF=y
> +CONFIG_CLK_COMPOSITE_CCF=y
> +CONFIG_CPU=y
> +CONFIG_CPU_RISCV=y
> +CONFIG_MMC=y
> +# CONFIG_INPUT is not set
> +CONFIG_DM_MMC=y
> +CONFIG_MMC_SPI=y
> +CONFIG_MMC_QUIRKS=y
> +CONFIG_MTD=y
> +CONFIG_DM_MTD=y
> +CONFIG_DM_SPI_FLASH=y
> +CONFIG_SPI_FLASH=y
> +CONFIG_SPI_FLASH_GIGADEVICE=y
> +# CONFIG_DM_ETH is not set
> +# CONFIG_PCI is not set
> +CONFIG_BAUDRATE=115200
> +CONFIG_SERIAL_PRESENT=y
> +CONFIG_DM_SERIAL=y
> +CONFIG_SIFIVE_SERIAL=y
> +CONFIG_SPI=y
> +CONFIG_DM_SPI=y
> +CONFIG_SPI_MEM=y
> +CONFIG_DESIGNWARE_SPI=y
> +CONFIG_TIMER=y
> +CONFIG_RISCV_TIMER=y
> +CONFIG_PANIC_HANG=y
> +CONFIG_OF_LIBFDT=y
> +# CONFIG_EFI_LOADER is not set

Please use make savedefconfig to generate the defconfig.

> diff --git a/include/configs/sipeed-maix.h b/include/configs/sipeed-maix.h
> new file mode 100644
> index 0000000000..598f7dfdd0
> --- /dev/null
> +++ b/include/configs/sipeed-maix.h
> @@ -0,0 +1,19 @@
> +/* SPDX-License-Identifier: GPL-2.0+ */
> +/*
> + * Copyright (C) 2019 Sean Anderson <seanga2 at gmail.com>
> + */
> +
> +#ifndef CONFIGS_SIPEED_MAIX_H
> +#define CONFIGS_SIPEED_MAIX_H
> +
> +#include <linux/sizes.h>
> +
> +#define CONFIG_SYS_LOAD_ADDR 0x80000000
> +#define CONFIG_SYS_SDRAM_BASE CONFIG_SYS_LOAD_ADDR
> +#define CONFIG_SYS_SDRAM_SIZE SZ_8M
> +/* Start just below AI memory */
> +#define CONFIG_SYS_INIT_SP_ADDR 0x805FFFFF
> +#define CONFIG_SYS_MALLOC_LEN SZ_1K
> +#define CONFIG_SYS_CACHELINE_SIZE 64
> +
> +#endif /* CONFIGS_SIPEED_MAIX_H */

How are you booting images? It would be great to include a default boot
command.
Please also add a short description on the board and how to use U-Boot
with it to the documentation.

Thanks,
Lukas
Sean Anderson Jan. 27, 2020, 1:09 a.m. UTC | #2
On 1/26/20 5:17 PM, Lukas Auer wrote:
> Hi Sean,
> 
> 
> On Wed, 2020-01-15 at 18:04 -0500, Sean Anderson wrote:
>> The Sipeed Maix series is a collection of boards built around the RISC-V
>> Kendryte K210 processor. This processor contains several peripherals to
>> accelerate neural network processing and other "ai" tasks. This includes a "KPU"
>> neural network processor, an audio processor supporting beamforming reception,
>> and a digital video port supporting capture and output at VGA resolution. Other
>> peripherals include 8M of sram (accessible with and without caching);
>> remappable pins, including 40 GPIOs; AES, FFT, and SHA256 accelerators; a DMA
>> controller; and I2C, I2S, and SPI controllers. Maix peripherals vary, but
>> include spi flash; on-board usb-serial bridges; ports for cameras, displays, and
>> sd cards; and ESP32 chips. Currently, only the Sipeed Maix Bit V2.0 (bitm) is
>> supported, but the boards are fairly similar.
>>
>> Documentation for Maix boards is located at <http://dl.sipeed.com/MAIX/HDK/>;.
>> Documentation for the Kendryte K210 is located at
>> <https://kendryte.com/downloads/>;. However, hardware details are rather lacking,
>> so most technical reference has been taken from the standalone sdk located at
>> <https://github.com/kendryte/kendryte-standalone-sdk>;.
>>
>> Signed-off-by: Sean Anderson <seanga2 at gmail.com>
> 
> This patch should be the last in the patch series, because it requires
> all other patches in the series.

Ok, will reorder it for v3.

>> ---
>> Changes for v2:
>>   Select CONFIG_SYS_RISCV_NOCOUNTER.
>>   Imply CONFIG_CLK_K210.
>>   Remove spurious references to CONFIG_ARCH_K210.
>>   Remove many configs from defconfig where the defaults were fine.
>>   Add a few "not set" lines to suppress unneeded defaults.
>>   Reduce pre-reloc malloc space, now that clocks initialization happens
>>   later.
>>   
>>  arch/riscv/Kconfig                 |  4 ++
>>  board/sipeed/maix/Kconfig          | 41 +++++++++++++
>>  board/sipeed/maix/MAINTAINERS      | 13 +++++
>>  board/sipeed/maix/Makefile         |  5 ++
>>  board/sipeed/maix/maix.c           |  9 +++
>>  configs/sipeed_maix_bitm_defconfig | 93 ++++++++++++++++++++++++++++++
>>  include/configs/sipeed-maix.h      | 19 ++++++
>>  7 files changed, 184 insertions(+)
>>  create mode 100644 board/sipeed/maix/Kconfig
>>  create mode 100644 board/sipeed/maix/MAINTAINERS
>>  create mode 100644 board/sipeed/maix/Makefile
>>  create mode 100644 board/sipeed/maix/maix.c
>>  create mode 100644 configs/sipeed_maix_bitm_defconfig
>>  create mode 100644 include/configs/sipeed-maix.h
>>
>> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
>> index 4f8c62dcff..4c62b8dd77 100644
>> --- a/arch/riscv/Kconfig
>> +++ b/arch/riscv/Kconfig
>> @@ -20,6 +20,9 @@ config TARGET_QEMU_VIRT
>>  config TARGET_SIFIVE_FU540
>>  	bool "Support SiFive FU540 Board"
>>  
>> +config TARGET_SIPEED_MAIX
>> +	bool "Support Sipeed Maix Board"
>> +
>>  endchoice
>>  
>>  config SYS_ICACHE_OFF
>> @@ -53,6 +56,7 @@ source "board/AndesTech/ax25-ae350/Kconfig"
>>  source "board/emulation/qemu-riscv/Kconfig"
>>  source "board/microchip/mpfs_icicle/Kconfig"
>>  source "board/sifive/fu540/Kconfig"
>> +source "board/sipeed/maix/Kconfig"
>>  
>>  # platform-specific options below
>>  source "arch/riscv/cpu/ax25/Kconfig"
>> diff --git a/board/sipeed/maix/Kconfig b/board/sipeed/maix/Kconfig
>> new file mode 100644
>> index 0000000000..9259eb34aa
>> --- /dev/null
>> +++ b/board/sipeed/maix/Kconfig
>> @@ -0,0 +1,41 @@
>> +# SPDX-License-Identifier: GPL-2.0+
>> +# Copyright (C) 2019 Sean Anderson <seanga2 at gmail.com>
>> +
>> +if TARGET_SIPEED_MAIX
>> +
>> +config SYS_BOARD
>> +	default "maix"
>> +
>> +config SYS_VENDOR
>> +	default "sipeed"
>> +
>> +config SYS_CPU
>> +	default "generic"
>> +
>> +config SYS_CONFIG_NAME
>> +	default "sipeed-maix"
>> +
>> +config SYS_TEXT_BASE
>> +	default 0x80000000
>> +
>> +config NR_CPUS
>> +	default 2
>> +
>> +config NR_DRAM_BANKS
>> +	default 2
>> +
>> +config BOARD_SPECIFIC_OPTIONS
>> +	def_bool y
>> +	select GENERIC_RISCV
>> +	select DM_SERIAL
>> +	select SIFIVE_SERIAL
>> +	select ARCH_DEFAULT_RV64I
>> +	select ENV_IS_NOWHERE
> 
> ENV_IS_NOWHERE is automatically selected if no other environment
> provider is available, so no need to include it here.

Ok, I will remove that in v3. As a general rule, what sort of things
should be in Kconfig vs in the default config? I initially thought that
all dependencies should be in Kconfig, but "imply" just seems to set the
default, which means it won't be changed if you pick another board and
then pick this one.

> Also, why are you not using the SD card to store the environment?

I haven't managed to get my SD card working yet. I think it may be too
big (it's 32G), so I am planning to find a smaller one. 

>> +	select SYS_RISCV_NOCOUNTER
>> +	imply SIFIVE_CLINT
>> +	imply SPI
>> +	imply DM_GPIO
>> +	imply CMD_GPIO
>> +	imply SYS_NS16550
>> +	imply SYS_MALLOC_F
>> +endif
>> diff --git a/board/sipeed/maix/MAINTAINERS b/board/sipeed/maix/MAINTAINERS
>> new file mode 100644
>> index 0000000000..217de45970
>> --- /dev/null
>> +++ b/board/sipeed/maix/MAINTAINERS
>> @@ -0,0 +1,13 @@
>> +Sipeed Maix BOARD
>> +M:	Sean Anderson <seanga2 at gmail.com>
>> +S:	Maintained
>> +F:	arch/riscv/dts/k210.dtsi
>> +F:	arch/riscv/dts/k210-maix-bit.dts
>> +F:	arch/riscv/include/asm/k210_sysctl.h
>> +F:	arch/riscv/lib/k210_sysctl.c
>> +F:	board/sipeed/maix/
>> +F:	configs/sipeed_maix_defconfig
>> +F:	drivers/clk/kendryte/
>> +F:	include/configs/sipeed-maix.h
>> +F:	include/dt-bindings/clock/k210-sysctl.h
>> +F:	include/dt-bindings/reset/k210-sysctl.h
>> diff --git a/board/sipeed/maix/Makefile b/board/sipeed/maix/Makefile
>> new file mode 100644
>> index 0000000000..4acff5b31e
>> --- /dev/null
>> +++ b/board/sipeed/maix/Makefile
>> @@ -0,0 +1,5 @@
>> +# SPDX-License-Identifier: GPL-2.0+
>> +#
>> +# Copyright (c) 2019 Western Digital Corporation or its affiliates.
>> +
>> +obj-y += maix.o
>> diff --git a/board/sipeed/maix/maix.c b/board/sipeed/maix/maix.c
>> new file mode 100644
>> index 0000000000..f8e773acf7
>> --- /dev/null
>> +++ b/board/sipeed/maix/maix.c
>> @@ -0,0 +1,9 @@
>> +// SPDX-License-Identifier: GPL-2.0+
>> +/*
>> + * Copyright (C) 2019 Sean Anderson <seanga2 at gmail.com>
>> + */
>> +
>> +int board_init(void)
>> +{
>> +	return 0;
>> +}
>> diff --git a/configs/sipeed_maix_bitm_defconfig b/configs/sipeed_maix_bitm_defconfig
>> new file mode 100644
>> index 0000000000..f062cc8c58
>> --- /dev/null
>> +++ b/configs/sipeed_maix_bitm_defconfig
>> @@ -0,0 +1,93 @@
>> +# SPDX-License-Identifier: GPL-2.0+
>> +# Copyright (C) 2019 Sean Anderson <seanga2 at gmail.com>
>> +CONFIG_CREATE_ARCH_SYMLINK=y
>> +CONFIG_RISCV=y
>> +CONFIG_SYS_ARCH="riscv"
>> +CONFIG_SYS_CPU="generic"
>> +CONFIG_SYS_VENDOR="sipeed"
>> +CONFIG_SYS_BOARD="maix"
>> +CONFIG_SYS_CONFIG_NAME="sipeed-maix"
>> +CONFIG_SPL_LDSCRIPT="arch/riscv/cpu/u-boot-spl.lds"
>> +CONFIG_SYS_TEXT_BASE=0x80000000
>> +CONFIG_SYS_MALLOC_F_LEN=0x1000
>> +CONFIG_BOARD_SPECIFIC_OPTIONS=y
>> +CONFIG_NR_DRAM_BANKS=2
>> +CONFIG_BOOTSTAGE_STASH_ADDR=0
>> +CONFIG_64BIT=y
>> +CONFIG_TARGET_SIPEED_MAIX=y
>> +CONFIG_NR_CPUS=2
>> +CONFIG_GENERIC_RISCV=y
>> +CONFIG_ARCH_DEFAULT_RV64I=y
>> +CONFIG_ARCH_RV64I=y
>> +CONFIG_CMODEL_MEDLOW=y
>> +CONFIG_RISCV_MMODE=y
>> +CONFIG_RISCV_ISA_C=y
>> +CONFIG_RISCV_ISA_A=y
>> +CONFIG_SIFIVE_CLINT=y
>> +CONFIG_K210_SYSCTL=y
>> +CONFIG_SYS_RISCV_NOCOUNTER=y
>> +CONFIG_ARCH_K210=y
>> +CONFIG_CC_OPTIMIZE_FOR_SIZE=y
>> +CONFIG_SYS_MALLOC_F=y
>> +CONFIG_PHYS_64BIT=y
>> +# CONFIG_ANDROID_BOOT_IMAGE is not set
>> +# CONFIG_FIT is not set
>> +# CONFIG_LEGACY_IMAGE_FORMAT is not set
>> +CONFIG_LOG=y
>> +CONFIG_ARCH_EARLY_INIT_R=y
>> +CONFIG_CMDLINE=y
>> +CONFIG_CMD_ENV_EXISTS=y
>> +CONFIG_CMD_FLASH=y
>> +CONFIG_CMD_SF=y
>> +CONFIG_CMD_LOG=y
>> +# CONFIG_AUTOBOOT is not set
>> +# CONFIG_CMD_BDI is not set
>> +# CONFIG_CMD_CONSOLE is not set
>> +# CONFIG_CMD_BOOTD is not set
>> +# CONFIG_CMD_BOOTM is not set
>> +# CONFIG_CMD_BOOTZ is not set
>> +CONFIG_CMD_BOOTI=y
>> +CONFIG_BOOTM_LINUX=y
>> +# CONFIG_CMD_ELF is not set
>> +CONFIG_CMD_FDT=y
>> +CONFIG_SUPPORT_OF_CONTROL=y
>> +CONFIG_DTC=y
>> +CONFIG_OF_CONTROL=y
>> +CONFIG_OF_SEPARATE=y
>> +CONFIG_ENV_IS_NOWHERE=y
>> +# CONFIG_NET is not set
>> +CONFIG_DM=y
>> +CONFIG_REGMAP=y
>> +CONFIG_SYSCON=y
>> +CONFIG_SIMPLE_BUS=y
>> +CONFIG_OF_TRANSLATE=y
>> +CONFIG_CLK=y
>> +CONFIG_CLK_CCF=y
>> +CONFIG_CLK_COMPOSITE_CCF=y
>> +CONFIG_CPU=y
>> +CONFIG_CPU_RISCV=y
>> +CONFIG_MMC=y
>> +# CONFIG_INPUT is not set
>> +CONFIG_DM_MMC=y
>> +CONFIG_MMC_SPI=y
>> +CONFIG_MMC_QUIRKS=y
>> +CONFIG_MTD=y
>> +CONFIG_DM_MTD=y
>> +CONFIG_DM_SPI_FLASH=y
>> +CONFIG_SPI_FLASH=y
>> +CONFIG_SPI_FLASH_GIGADEVICE=y
>> +# CONFIG_DM_ETH is not set
>> +# CONFIG_PCI is not set
>> +CONFIG_BAUDRATE=115200
>> +CONFIG_SERIAL_PRESENT=y
>> +CONFIG_DM_SERIAL=y
>> +CONFIG_SIFIVE_SERIAL=y
>> +CONFIG_SPI=y
>> +CONFIG_DM_SPI=y
>> +CONFIG_SPI_MEM=y
>> +CONFIG_DESIGNWARE_SPI=y
>> +CONFIG_TIMER=y
>> +CONFIG_RISCV_TIMER=y
>> +CONFIG_PANIC_HANG=y
>> +CONFIG_OF_LIBFDT=y
>> +# CONFIG_EFI_LOADER is not set
> 
> Please use make savedefconfig to generate the defconfig.

Ah, I wasn't aware that that was the preferred way.

>> diff --git a/include/configs/sipeed-maix.h b/include/configs/sipeed-maix.h
>> new file mode 100644
>> index 0000000000..598f7dfdd0
>> --- /dev/null
>> +++ b/include/configs/sipeed-maix.h
>> @@ -0,0 +1,19 @@
>> +/* SPDX-License-Identifier: GPL-2.0+ */
>> +/*
>> + * Copyright (C) 2019 Sean Anderson <seanga2 at gmail.com>
>> + */
>> +
>> +#ifndef CONFIGS_SIPEED_MAIX_H
>> +#define CONFIGS_SIPEED_MAIX_H
>> +
>> +#include <linux/sizes.h>
>> +
>> +#define CONFIG_SYS_LOAD_ADDR 0x80000000
>> +#define CONFIG_SYS_SDRAM_BASE CONFIG_SYS_LOAD_ADDR
>> +#define CONFIG_SYS_SDRAM_SIZE SZ_8M
>> +/* Start just below AI memory */
>> +#define CONFIG_SYS_INIT_SP_ADDR 0x805FFFFF
>> +#define CONFIG_SYS_MALLOC_LEN SZ_1K
>> +#define CONFIG_SYS_CACHELINE_SIZE 64
>> +
>> +#endif /* CONFIGS_SIPEED_MAIX_H */
> 
> How are you booting images? It would be great to include a default boot
> command.

The board I am using has some serial issues which makes it difficult to
flash any large images. I can get u-boot to flash after several
attempts, but something like the linux kernel is far too unreliable to
test regularly. I'm going to see if I can get my hands on another k210
board which hopefully doesn't have these issues.

> Please also add a short description on the board and how to use U-Boot
> with it to the documentation.

Will something like the commit message work?

> 
> Thanks,
> Lukas
>
Lukas Auer Jan. 30, 2020, 10:21 p.m. UTC | #3
On Sun, 2020-01-26 at 20:09 -0500, Sean Anderson wrote:
> On 1/26/20 5:17 PM, Lukas Auer wrote:
> > Hi Sean,
> > 
> > 
> > On Wed, 2020-01-15 at 18:04 -0500, Sean Anderson wrote:
> > > The Sipeed Maix series is a collection of boards built around the RISC-V
> > > Kendryte K210 processor. This processor contains several peripherals to
> > > accelerate neural network processing and other "ai" tasks. This includes a "KPU"
> > > neural network processor, an audio processor supporting beamforming reception,
> > > and a digital video port supporting capture and output at VGA resolution. Other
> > > peripherals include 8M of sram (accessible with and without caching);
> > > remappable pins, including 40 GPIOs; AES, FFT, and SHA256 accelerators; a DMA
> > > controller; and I2C, I2S, and SPI controllers. Maix peripherals vary, but
> > > include spi flash; on-board usb-serial bridges; ports for cameras, displays, and
> > > sd cards; and ESP32 chips. Currently, only the Sipeed Maix Bit V2.0 (bitm) is
> > > supported, but the boards are fairly similar.
> > > 
> > > Documentation for Maix boards is located at <http://dl.sipeed.com/MAIX/HDK/>;;.
> > > Documentation for the Kendryte K210 is located at
> > > <https://kendryte.com/downloads/>;;. However, hardware details are rather lacking,
> > > so most technical reference has been taken from the standalone sdk located at
> > > <https://github.com/kendryte/kendryte-standalone-sdk>;;.
> > > 
> > > Signed-off-by: Sean Anderson <seanga2 at gmail.com>
> > 
> > This patch should be the last in the patch series, because it requires
> > all other patches in the series.
> 
> Ok, will reorder it for v3.
> 
> > > ---
> > > Changes for v2:
> > >   Select CONFIG_SYS_RISCV_NOCOUNTER.
> > >   Imply CONFIG_CLK_K210.
> > >   Remove spurious references to CONFIG_ARCH_K210.
> > >   Remove many configs from defconfig where the defaults were fine.
> > >   Add a few "not set" lines to suppress unneeded defaults.
> > >   Reduce pre-reloc malloc space, now that clocks initialization happens
> > >   later.
> > >   
> > >  arch/riscv/Kconfig                 |  4 ++
> > >  board/sipeed/maix/Kconfig          | 41 +++++++++++++
> > >  board/sipeed/maix/MAINTAINERS      | 13 +++++
> > >  board/sipeed/maix/Makefile         |  5 ++
> > >  board/sipeed/maix/maix.c           |  9 +++
> > >  configs/sipeed_maix_bitm_defconfig | 93 ++++++++++++++++++++++++++++++
> > >  include/configs/sipeed-maix.h      | 19 ++++++
> > >  7 files changed, 184 insertions(+)
> > >  create mode 100644 board/sipeed/maix/Kconfig
> > >  create mode 100644 board/sipeed/maix/MAINTAINERS
> > >  create mode 100644 board/sipeed/maix/Makefile
> > >  create mode 100644 board/sipeed/maix/maix.c
> > >  create mode 100644 configs/sipeed_maix_bitm_defconfig
> > >  create mode 100644 include/configs/sipeed-maix.h
> > > 
> > > diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> > > index 4f8c62dcff..4c62b8dd77 100644
> > > --- a/arch/riscv/Kconfig
> > > +++ b/arch/riscv/Kconfig
> > > @@ -20,6 +20,9 @@ config TARGET_QEMU_VIRT
> > >  config TARGET_SIFIVE_FU540
> > >  	bool "Support SiFive FU540 Board"
> > >  
> > > +config TARGET_SIPEED_MAIX
> > > +	bool "Support Sipeed Maix Board"
> > > +
> > >  endchoice
> > >  
> > >  config SYS_ICACHE_OFF
> > > @@ -53,6 +56,7 @@ source "board/AndesTech/ax25-ae350/Kconfig"
> > >  source "board/emulation/qemu-riscv/Kconfig"
> > >  source "board/microchip/mpfs_icicle/Kconfig"
> > >  source "board/sifive/fu540/Kconfig"
> > > +source "board/sipeed/maix/Kconfig"
> > >  
> > >  # platform-specific options below
> > >  source "arch/riscv/cpu/ax25/Kconfig"
> > > diff --git a/board/sipeed/maix/Kconfig b/board/sipeed/maix/Kconfig
> > > new file mode 100644
> > > index 0000000000..9259eb34aa
> > > --- /dev/null
> > > +++ b/board/sipeed/maix/Kconfig
> > > @@ -0,0 +1,41 @@
> > > +# SPDX-License-Identifier: GPL-2.0+
> > > +# Copyright (C) 2019 Sean Anderson <seanga2 at gmail.com>
> > > +
> > > +if TARGET_SIPEED_MAIX
> > > +
> > > +config SYS_BOARD
> > > +	default "maix"
> > > +
> > > +config SYS_VENDOR
> > > +	default "sipeed"
> > > +
> > > +config SYS_CPU
> > > +	default "generic"
> > > +
> > > +config SYS_CONFIG_NAME
> > > +	default "sipeed-maix"
> > > +
> > > +config SYS_TEXT_BASE
> > > +	default 0x80000000
> > > +
> > > +config NR_CPUS
> > > +	default 2
> > > +
> > > +config NR_DRAM_BANKS
> > > +	default 2
> > > +
> > > +config BOARD_SPECIFIC_OPTIONS
> > > +	def_bool y
> > > +	select GENERIC_RISCV
> > > +	select DM_SERIAL
> > > +	select SIFIVE_SERIAL
> > > +	select ARCH_DEFAULT_RV64I
> > > +	select ENV_IS_NOWHERE
> > 
> > ENV_IS_NOWHERE is automatically selected if no other environment
> > provider is available, so no need to include it here.
> 
> Ok, I will remove that in v3. As a general rule, what sort of things
> should be in Kconfig vs in the default config? I initially thought that
> all dependencies should be in Kconfig, but "imply" just seems to set the
> default, which means it won't be changed if you pick another board and
> then pick this one.
> 

The Kconfig forms the base configuration, which will be shared by all
defconfig variations of the board. So yes, you are correct, it should
include all its dependencies such as the peripheral drivers, but also
commands that use the peripherals. In the SiFive FU540 configuration,
for example, we imply the peripheral drivers (clock, serial, etc.),
enable filesystem related options since we have storage, and enable
relevant commands.

Not everybody will want or need all configuration options. We therefore
try to imply as many of the options as possible, so that they can be
deselected as required in the defconfig. They should all be picked up,
if you apply different boards. Perhaps you did not run make distclean?

> > Also, why are you not using the SD card to store the environment?
> 
> I haven't managed to get my SD card working yet. I think it may be too
> big (it's 32G), so I am planning to find a smaller one. 
> 

Interesting, I thought all SD cards support SPI mode.

> > > +	select SYS_RISCV_NOCOUNTER
> > > +	imply SIFIVE_CLINT
> > > +	imply SPI
> > > +	imply DM_GPIO
> > > +	imply CMD_GPIO
> > > +	imply SYS_NS16550
> > > +	imply SYS_MALLOC_F
> > > +endif
> > > diff --git a/board/sipeed/maix/MAINTAINERS b/board/sipeed/maix/MAINTAINERS
> > > new file mode 100644
> > > index 0000000000..217de45970
> > > --- /dev/null
> > > +++ b/board/sipeed/maix/MAINTAINERS
> > > @@ -0,0 +1,13 @@
> > > +Sipeed Maix BOARD
> > > +M:	Sean Anderson <seanga2 at gmail.com>
> > > +S:	Maintained
> > > +F:	arch/riscv/dts/k210.dtsi
> > > +F:	arch/riscv/dts/k210-maix-bit.dts
> > > +F:	arch/riscv/include/asm/k210_sysctl.h
> > > +F:	arch/riscv/lib/k210_sysctl.c
> > > +F:	board/sipeed/maix/
> > > +F:	configs/sipeed_maix_defconfig
> > > +F:	drivers/clk/kendryte/
> > > +F:	include/configs/sipeed-maix.h
> > > +F:	include/dt-bindings/clock/k210-sysctl.h
> > > +F:	include/dt-bindings/reset/k210-sysctl.h
> > > diff --git a/board/sipeed/maix/Makefile b/board/sipeed/maix/Makefile
> > > new file mode 100644
> > > index 0000000000..4acff5b31e
> > > --- /dev/null
> > > +++ b/board/sipeed/maix/Makefile
> > > @@ -0,0 +1,5 @@
> > > +# SPDX-License-Identifier: GPL-2.0+
> > > +#
> > > +# Copyright (c) 2019 Western Digital Corporation or its affiliates.
> > > +
> > > +obj-y += maix.o
> > > diff --git a/board/sipeed/maix/maix.c b/board/sipeed/maix/maix.c
> > > new file mode 100644
> > > index 0000000000..f8e773acf7
> > > --- /dev/null
> > > +++ b/board/sipeed/maix/maix.c
> > > @@ -0,0 +1,9 @@
> > > +// SPDX-License-Identifier: GPL-2.0+
> > > +/*
> > > + * Copyright (C) 2019 Sean Anderson <seanga2 at gmail.com>
> > > + */
> > > +
> > > +int board_init(void)
> > > +{
> > > +	return 0;
> > > +}
> > > diff --git a/configs/sipeed_maix_bitm_defconfig b/configs/sipeed_maix_bitm_defconfig
> > > new file mode 100644
> > > index 0000000000..f062cc8c58
> > > --- /dev/null
> > > +++ b/configs/sipeed_maix_bitm_defconfig
> > > @@ -0,0 +1,93 @@
> > > +# SPDX-License-Identifier: GPL-2.0+
> > > +# Copyright (C) 2019 Sean Anderson <seanga2 at gmail.com>
> > > +CONFIG_CREATE_ARCH_SYMLINK=y
> > > +CONFIG_RISCV=y
> > > +CONFIG_SYS_ARCH="riscv"
> > > +CONFIG_SYS_CPU="generic"
> > > +CONFIG_SYS_VENDOR="sipeed"
> > > +CONFIG_SYS_BOARD="maix"
> > > +CONFIG_SYS_CONFIG_NAME="sipeed-maix"
> > > +CONFIG_SPL_LDSCRIPT="arch/riscv/cpu/u-boot-spl.lds"
> > > +CONFIG_SYS_TEXT_BASE=0x80000000
> > > +CONFIG_SYS_MALLOC_F_LEN=0x1000
> > > +CONFIG_BOARD_SPECIFIC_OPTIONS=y
> > > +CONFIG_NR_DRAM_BANKS=2
> > > +CONFIG_BOOTSTAGE_STASH_ADDR=0
> > > +CONFIG_64BIT=y
> > > +CONFIG_TARGET_SIPEED_MAIX=y
> > > +CONFIG_NR_CPUS=2
> > > +CONFIG_GENERIC_RISCV=y
> > > +CONFIG_ARCH_DEFAULT_RV64I=y
> > > +CONFIG_ARCH_RV64I=y
> > > +CONFIG_CMODEL_MEDLOW=y
> > > +CONFIG_RISCV_MMODE=y
> > > +CONFIG_RISCV_ISA_C=y
> > > +CONFIG_RISCV_ISA_A=y
> > > +CONFIG_SIFIVE_CLINT=y
> > > +CONFIG_K210_SYSCTL=y
> > > +CONFIG_SYS_RISCV_NOCOUNTER=y
> > > +CONFIG_ARCH_K210=y
> > > +CONFIG_CC_OPTIMIZE_FOR_SIZE=y
> > > +CONFIG_SYS_MALLOC_F=y
> > > +CONFIG_PHYS_64BIT=y
> > > +# CONFIG_ANDROID_BOOT_IMAGE is not set
> > > +# CONFIG_FIT is not set
> > > +# CONFIG_LEGACY_IMAGE_FORMAT is not set
> > > +CONFIG_LOG=y
> > > +CONFIG_ARCH_EARLY_INIT_R=y
> > > +CONFIG_CMDLINE=y
> > > +CONFIG_CMD_ENV_EXISTS=y
> > > +CONFIG_CMD_FLASH=y
> > > +CONFIG_CMD_SF=y
> > > +CONFIG_CMD_LOG=y
> > > +# CONFIG_AUTOBOOT is not set
> > > +# CONFIG_CMD_BDI is not set
> > > +# CONFIG_CMD_CONSOLE is not set
> > > +# CONFIG_CMD_BOOTD is not set
> > > +# CONFIG_CMD_BOOTM is not set
> > > +# CONFIG_CMD_BOOTZ is not set
> > > +CONFIG_CMD_BOOTI=y
> > > +CONFIG_BOOTM_LINUX=y
> > > +# CONFIG_CMD_ELF is not set
> > > +CONFIG_CMD_FDT=y
> > > +CONFIG_SUPPORT_OF_CONTROL=y
> > > +CONFIG_DTC=y
> > > +CONFIG_OF_CONTROL=y
> > > +CONFIG_OF_SEPARATE=y
> > > +CONFIG_ENV_IS_NOWHERE=y
> > > +# CONFIG_NET is not set
> > > +CONFIG_DM=y
> > > +CONFIG_REGMAP=y
> > > +CONFIG_SYSCON=y
> > > +CONFIG_SIMPLE_BUS=y
> > > +CONFIG_OF_TRANSLATE=y
> > > +CONFIG_CLK=y
> > > +CONFIG_CLK_CCF=y
> > > +CONFIG_CLK_COMPOSITE_CCF=y
> > > +CONFIG_CPU=y
> > > +CONFIG_CPU_RISCV=y
> > > +CONFIG_MMC=y
> > > +# CONFIG_INPUT is not set
> > > +CONFIG_DM_MMC=y
> > > +CONFIG_MMC_SPI=y
> > > +CONFIG_MMC_QUIRKS=y
> > > +CONFIG_MTD=y
> > > +CONFIG_DM_MTD=y
> > > +CONFIG_DM_SPI_FLASH=y
> > > +CONFIG_SPI_FLASH=y
> > > +CONFIG_SPI_FLASH_GIGADEVICE=y
> > > +# CONFIG_DM_ETH is not set
> > > +# CONFIG_PCI is not set
> > > +CONFIG_BAUDRATE=115200
> > > +CONFIG_SERIAL_PRESENT=y
> > > +CONFIG_DM_SERIAL=y
> > > +CONFIG_SIFIVE_SERIAL=y
> > > +CONFIG_SPI=y
> > > +CONFIG_DM_SPI=y
> > > +CONFIG_SPI_MEM=y
> > > +CONFIG_DESIGNWARE_SPI=y
> > > +CONFIG_TIMER=y
> > > +CONFIG_RISCV_TIMER=y
> > > +CONFIG_PANIC_HANG=y
> > > +CONFIG_OF_LIBFDT=y
> > > +# CONFIG_EFI_LOADER is not set
> > 
> > Please use make savedefconfig to generate the defconfig.
> 
> Ah, I wasn't aware that that was the preferred way.
> 

No problem, makes it much easier as well. :)

> > > diff --git a/include/configs/sipeed-maix.h b/include/configs/sipeed-maix.h
> > > new file mode 100644
> > > index 0000000000..598f7dfdd0
> > > --- /dev/null
> > > +++ b/include/configs/sipeed-maix.h
> > > @@ -0,0 +1,19 @@
> > > +/* SPDX-License-Identifier: GPL-2.0+ */
> > > +/*
> > > + * Copyright (C) 2019 Sean Anderson <seanga2 at gmail.com>
> > > + */
> > > +
> > > +#ifndef CONFIGS_SIPEED_MAIX_H
> > > +#define CONFIGS_SIPEED_MAIX_H
> > > +
> > > +#include <linux/sizes.h>
> > > +
> > > +#define CONFIG_SYS_LOAD_ADDR 0x80000000
> > > +#define CONFIG_SYS_SDRAM_BASE CONFIG_SYS_LOAD_ADDR
> > > +#define CONFIG_SYS_SDRAM_SIZE SZ_8M
> > > +/* Start just below AI memory */
> > > +#define CONFIG_SYS_INIT_SP_ADDR 0x805FFFFF
> > > +#define CONFIG_SYS_MALLOC_LEN SZ_1K
> > > +#define CONFIG_SYS_CACHELINE_SIZE 64
> > > +
> > > +#endif /* CONFIGS_SIPEED_MAIX_H */
> > 
> > How are you booting images? It would be great to include a default boot
> > command.
> 
> The board I am using has some serial issues which makes it difficult to
> flash any large images. I can get u-boot to flash after several
> attempts, but something like the linux kernel is far too unreliable to
> test regularly. I'm going to see if I can get my hands on another k210
> board which hopefully doesn't have these issues.
> 

Ah ok, that's unfortunate. Thank you for your efforts!

> > Please also add a short description on the board and how to use U-Boot
> > with it to the documentation.
> 
> Will something like the commit message work?
> 

Yes definitely. Just add a short description on how to build U-Boot and
flash it onto the board. That makes it a lot easier for new users to
get started with the board.

Thanks,
Lukas
diff mbox series

Patch

diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 4f8c62dcff..4c62b8dd77 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -20,6 +20,9 @@  config TARGET_QEMU_VIRT
 config TARGET_SIFIVE_FU540
 	bool "Support SiFive FU540 Board"
 
+config TARGET_SIPEED_MAIX
+	bool "Support Sipeed Maix Board"
+
 endchoice
 
 config SYS_ICACHE_OFF
@@ -53,6 +56,7 @@  source "board/AndesTech/ax25-ae350/Kconfig"
 source "board/emulation/qemu-riscv/Kconfig"
 source "board/microchip/mpfs_icicle/Kconfig"
 source "board/sifive/fu540/Kconfig"
+source "board/sipeed/maix/Kconfig"
 
 # platform-specific options below
 source "arch/riscv/cpu/ax25/Kconfig"
diff --git a/board/sipeed/maix/Kconfig b/board/sipeed/maix/Kconfig
new file mode 100644
index 0000000000..9259eb34aa
--- /dev/null
+++ b/board/sipeed/maix/Kconfig
@@ -0,0 +1,41 @@ 
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (C) 2019 Sean Anderson <seanga2 at gmail.com>
+
+if TARGET_SIPEED_MAIX
+
+config SYS_BOARD
+	default "maix"
+
+config SYS_VENDOR
+	default "sipeed"
+
+config SYS_CPU
+	default "generic"
+
+config SYS_CONFIG_NAME
+	default "sipeed-maix"
+
+config SYS_TEXT_BASE
+	default 0x80000000
+
+config NR_CPUS
+	default 2
+
+config NR_DRAM_BANKS
+	default 2
+
+config BOARD_SPECIFIC_OPTIONS
+	def_bool y
+	select GENERIC_RISCV
+	select DM_SERIAL
+	select SIFIVE_SERIAL
+	select ARCH_DEFAULT_RV64I
+	select ENV_IS_NOWHERE
+	select SYS_RISCV_NOCOUNTER
+	imply SIFIVE_CLINT
+	imply SPI
+	imply DM_GPIO
+	imply CMD_GPIO
+	imply SYS_NS16550
+	imply SYS_MALLOC_F
+endif
diff --git a/board/sipeed/maix/MAINTAINERS b/board/sipeed/maix/MAINTAINERS
new file mode 100644
index 0000000000..217de45970
--- /dev/null
+++ b/board/sipeed/maix/MAINTAINERS
@@ -0,0 +1,13 @@ 
+Sipeed Maix BOARD
+M:	Sean Anderson <seanga2 at gmail.com>
+S:	Maintained
+F:	arch/riscv/dts/k210.dtsi
+F:	arch/riscv/dts/k210-maix-bit.dts
+F:	arch/riscv/include/asm/k210_sysctl.h
+F:	arch/riscv/lib/k210_sysctl.c
+F:	board/sipeed/maix/
+F:	configs/sipeed_maix_defconfig
+F:	drivers/clk/kendryte/
+F:	include/configs/sipeed-maix.h
+F:	include/dt-bindings/clock/k210-sysctl.h
+F:	include/dt-bindings/reset/k210-sysctl.h
diff --git a/board/sipeed/maix/Makefile b/board/sipeed/maix/Makefile
new file mode 100644
index 0000000000..4acff5b31e
--- /dev/null
+++ b/board/sipeed/maix/Makefile
@@ -0,0 +1,5 @@ 
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright (c) 2019 Western Digital Corporation or its affiliates.
+
+obj-y += maix.o
diff --git a/board/sipeed/maix/maix.c b/board/sipeed/maix/maix.c
new file mode 100644
index 0000000000..f8e773acf7
--- /dev/null
+++ b/board/sipeed/maix/maix.c
@@ -0,0 +1,9 @@ 
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2019 Sean Anderson <seanga2 at gmail.com>
+ */
+
+int board_init(void)
+{
+	return 0;
+}
diff --git a/configs/sipeed_maix_bitm_defconfig b/configs/sipeed_maix_bitm_defconfig
new file mode 100644
index 0000000000..f062cc8c58
--- /dev/null
+++ b/configs/sipeed_maix_bitm_defconfig
@@ -0,0 +1,93 @@ 
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (C) 2019 Sean Anderson <seanga2 at gmail.com>
+CONFIG_CREATE_ARCH_SYMLINK=y
+CONFIG_RISCV=y
+CONFIG_SYS_ARCH="riscv"
+CONFIG_SYS_CPU="generic"
+CONFIG_SYS_VENDOR="sipeed"
+CONFIG_SYS_BOARD="maix"
+CONFIG_SYS_CONFIG_NAME="sipeed-maix"
+CONFIG_SPL_LDSCRIPT="arch/riscv/cpu/u-boot-spl.lds"
+CONFIG_SYS_TEXT_BASE=0x80000000
+CONFIG_SYS_MALLOC_F_LEN=0x1000
+CONFIG_BOARD_SPECIFIC_OPTIONS=y
+CONFIG_NR_DRAM_BANKS=2
+CONFIG_BOOTSTAGE_STASH_ADDR=0
+CONFIG_64BIT=y
+CONFIG_TARGET_SIPEED_MAIX=y
+CONFIG_NR_CPUS=2
+CONFIG_GENERIC_RISCV=y
+CONFIG_ARCH_DEFAULT_RV64I=y
+CONFIG_ARCH_RV64I=y
+CONFIG_CMODEL_MEDLOW=y
+CONFIG_RISCV_MMODE=y
+CONFIG_RISCV_ISA_C=y
+CONFIG_RISCV_ISA_A=y
+CONFIG_SIFIVE_CLINT=y
+CONFIG_K210_SYSCTL=y
+CONFIG_SYS_RISCV_NOCOUNTER=y
+CONFIG_ARCH_K210=y
+CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+CONFIG_SYS_MALLOC_F=y
+CONFIG_PHYS_64BIT=y
+# CONFIG_ANDROID_BOOT_IMAGE is not set
+# CONFIG_FIT is not set
+# CONFIG_LEGACY_IMAGE_FORMAT is not set
+CONFIG_LOG=y
+CONFIG_ARCH_EARLY_INIT_R=y
+CONFIG_CMDLINE=y
+CONFIG_CMD_ENV_EXISTS=y
+CONFIG_CMD_FLASH=y
+CONFIG_CMD_SF=y
+CONFIG_CMD_LOG=y
+# CONFIG_AUTOBOOT is not set
+# CONFIG_CMD_BDI is not set
+# CONFIG_CMD_CONSOLE is not set
+# CONFIG_CMD_BOOTD is not set
+# CONFIG_CMD_BOOTM is not set
+# CONFIG_CMD_BOOTZ is not set
+CONFIG_CMD_BOOTI=y
+CONFIG_BOOTM_LINUX=y
+# CONFIG_CMD_ELF is not set
+CONFIG_CMD_FDT=y
+CONFIG_SUPPORT_OF_CONTROL=y
+CONFIG_DTC=y
+CONFIG_OF_CONTROL=y
+CONFIG_OF_SEPARATE=y
+CONFIG_ENV_IS_NOWHERE=y
+# CONFIG_NET is not set
+CONFIG_DM=y
+CONFIG_REGMAP=y
+CONFIG_SYSCON=y
+CONFIG_SIMPLE_BUS=y
+CONFIG_OF_TRANSLATE=y
+CONFIG_CLK=y
+CONFIG_CLK_CCF=y
+CONFIG_CLK_COMPOSITE_CCF=y
+CONFIG_CPU=y
+CONFIG_CPU_RISCV=y
+CONFIG_MMC=y
+# CONFIG_INPUT is not set
+CONFIG_DM_MMC=y
+CONFIG_MMC_SPI=y
+CONFIG_MMC_QUIRKS=y
+CONFIG_MTD=y
+CONFIG_DM_MTD=y
+CONFIG_DM_SPI_FLASH=y
+CONFIG_SPI_FLASH=y
+CONFIG_SPI_FLASH_GIGADEVICE=y
+# CONFIG_DM_ETH is not set
+# CONFIG_PCI is not set
+CONFIG_BAUDRATE=115200
+CONFIG_SERIAL_PRESENT=y
+CONFIG_DM_SERIAL=y
+CONFIG_SIFIVE_SERIAL=y
+CONFIG_SPI=y
+CONFIG_DM_SPI=y
+CONFIG_SPI_MEM=y
+CONFIG_DESIGNWARE_SPI=y
+CONFIG_TIMER=y
+CONFIG_RISCV_TIMER=y
+CONFIG_PANIC_HANG=y
+CONFIG_OF_LIBFDT=y
+# CONFIG_EFI_LOADER is not set
diff --git a/include/configs/sipeed-maix.h b/include/configs/sipeed-maix.h
new file mode 100644
index 0000000000..598f7dfdd0
--- /dev/null
+++ b/include/configs/sipeed-maix.h
@@ -0,0 +1,19 @@ 
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2019 Sean Anderson <seanga2 at gmail.com>
+ */
+
+#ifndef CONFIGS_SIPEED_MAIX_H
+#define CONFIGS_SIPEED_MAIX_H
+
+#include <linux/sizes.h>
+
+#define CONFIG_SYS_LOAD_ADDR 0x80000000
+#define CONFIG_SYS_SDRAM_BASE CONFIG_SYS_LOAD_ADDR
+#define CONFIG_SYS_SDRAM_SIZE SZ_8M
+/* Start just below AI memory */
+#define CONFIG_SYS_INIT_SP_ADDR 0x805FFFFF
+#define CONFIG_SYS_MALLOC_LEN SZ_1K
+#define CONFIG_SYS_CACHELINE_SIZE 64
+
+#endif /* CONFIGS_SIPEED_MAIX_H */