Skip to contentSkip to conversation

csky: Add new architecture

PATCH New Guo Ren 3 participants 7 messages Mar 1, 2017 – Mar 2, 2017 C-sky architecture

lore
Share & tools
lore

Guo Ren

author
#0 lore raw

PATCH 1/1 csky: Add new architecture

C-SKY is a CPU architecture from http://en.c-sky.com

1. This commit has been tested by C-SKY.

2. All changes in this commit are related for building csky dev board.

3. We currently use pre-build-toolchain from url. and csky-toolchain opensource is on going.

4. See more info in board/csky/readme.txt

---
 arch/Config.in                          |  12 +
 arch/Config.in.csky                     |  57 ++++
 board/csky/gx6605s/gdbinit              |  25 ++
 board/csky/gx6605s/gx6605s.dts          |  56 ++++
 board/csky/gx6605s/gx6622.dts           |  56 ++++
 board/csky/gx6605s/gx66xx_defconfig     | 525 +++++++++++++++++++++++++++++++
 board/csky/post-image.sh                |   4 +
 board/csky/readme.txt                   | 113 +++++++
 board/csky/sc8925/gdbinit               |  15 +
 board/csky/sc8925/sc8925.dts            |  57 ++++
 board/csky/sc8925/sc8925_defconfig      | 541 ++++++++++++++++++++++++++++++++
 configs/csky_gx6605s_defconfig          |  26 ++
 configs/csky_sc8925_defconfig           |  27 ++
 linux/Config.ext.in                     |  75 +++++
 linux/linux-ext-csky-addons.mk          |  12 +
 linux/linux-ext-csky-arch.mk            |  12 +
 package/Config.in                       |   2 +
 package/csky-addons/Config.in           |  12 +
 package/csky-addons/csky-addons.mk      |  15 +
 package/csky-arch/Config.in             |  12 +
 package/csky-arch/csky-arch.mk          |  15 +
 toolchain/toolchain-buildroot/Config.in |   2 +-
 22 files changed, 1670 insertions(+), 1 deletion(-)
 create mode 100644 arch/Config.in.csky
 create mode 100644 board/csky/gx6605s/gdbinit
 create mode 100644 board/csky/gx6605s/gx6605s.dts
 create mode 100644 board/csky/gx6605s/gx6622.dts
 create mode 100644 board/csky/gx6605s/gx66xx_defconfig
 create mode 100755 board/csky/post-image.sh
 create mode 100644 board/csky/readme.txt
 create mode 100644 board/csky/sc8925/gdbinit
 create mode 100644 board/csky/sc8925/sc8925.dts
 create mode 100644 board/csky/sc8925/sc8925_defconfig
 create mode 100644 configs/csky_gx6605s_defconfig
 create mode 100644 configs/csky_sc8925_defconfig
 create mode 100644 linux/linux-ext-csky-addons.mk
 create mode 100644 linux/linux-ext-csky-arch.mk
 create mode 100644 package/csky-addons/Config.in
 create mode 100644 package/csky-addons/csky-addons.mk
 create mode 100644 package/csky-arch/Config.in
 create mode 100644 package/csky-arch/csky-arch.mk
arch/Config.in +12 -0
index 7149b2c..ea81c4c 100644
@@ -240,6 +240,14 @@ config BR2_xtensa
 	  http://en.wikipedia.org/wiki/Xtensa
 	  http://www.tensilica.com/
 
+config BR2_csky
+	bool "csky"
+	select BR2_ARCH_HAS_MMU_MANDATORY
+	help
+	  csky is processor IP from china.
+	  http://www.c-sky.com/
+	  http://www.github.com/c-sky
+
 endchoice
 
 # The following string values are defined by the individual
@@ -409,4 +417,8 @@ if BR2_xtensa
 source "arch/Config.in.xtensa"
 endif
 
+if BR2_csky
+source "arch/Config.in.csky"
+endif
+
 endmenu # Target options
arch/Config.in.csky new file +57 -0

57 lines not on this page · raw message

board/csky/gx6605s/gdbinit new file +25 -0
new file mode 100644
index 0000000..0a6d8ab
@@ -0,0 +1,25 @@
+tar jtag jtag://127.0.0.1:1025
+reset
+
+# setup CCR (Cache Config Reg)
+# 0-1:MP,2:IE,3:DE,4:WB,5:RS,6:Z,7:BE 
+set $cr18 = 0x7d
+
+# vendor custom setup, double cache line & preload
+set $cr30 = 0xc
+
+# pin mux for serial8250
+set *(unsigned int *) 0xa030a14c |= (1 << 22) | (1 << 23)
+
+# pass devicetree blob
+# r2 is magic
+# r3 is address
+set $r2 = 0x20150401
+set $r3 = 0x92000000
+restore gx6605s.dtb binary 0x92000000
+
+# flush cache
+set $cr17 = 0x33
+
+load
+
board/csky/gx6605s/gx6605s.dts new file +56 -0

56 lines not on this page · raw message

board/csky/gx6605s/gx6622.dts new file +56 -0

56 lines not on this page · raw message

board/csky/gx6605s/gx66xx_defconfig new file +525 -0

525 lines not on this page · raw message

board/csky/post-image.sh new file +4 -0
new file mode 100755
index 0000000..7bead4f
@@ -0,0 +1,4 @@
+#!/bin/sh
+# copy board/csky/xxx/gdbinit to images/.gdbinit for
+BOARD_DIR="$(dirname $0)"
+cp -af $BOARD_DIR/${2}/gdbinit $BINARIES_DIR/.gdbinit
board/csky/readme.txt new file +113 -0

113 lines not on this page · raw message

board/csky/sc8925/gdbinit new file +15 -0
new file mode 100644
index 0000000..a97eefc
@@ -0,0 +1,15 @@
+tar jtag jtag://127.0.0.1:1025
+
+set $cr18=0x7d
+# pass devicetree blob
+# r2 is magic
+# r3 is address
+set $r0 = 0x20150401
+set $r1 = 0x82000000
+restore sc8925.dtb binary 0x82000000
+
+# flush cache
+set $cr17 = 0x33
+
+load
+
board/csky/sc8925/sc8925.dts new file +57 -0

57 lines not on this page · raw message

board/csky/sc8925/sc8925_defconfig new file +541 -0

541 lines not on this page · raw message

configs/csky_gx6605s_defconfig new file +26 -0
new file mode 100644
index 0000000..75226a5
@@ -0,0 +1,26 @@
+BR2_csky=y
+BR2_ck610=y
+BR2_OPTIMIZE_2=y
+BR2_SHARED_STATIC_LIBS=y
+# BR2_COMPILER_PARANOID_UNSAFE_PATH is not set
+BR2_TOOLCHAIN_EXTERNAL=y
+BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y
+BR2_TOOLCHAIN_EXTERNAL_URL="https://github.com/c-sky/tools/raw/master/csky-linux-tools-x86_64-glibc-linux-4.9.2-20170227.tar.gz"
+BR2_TOOLCHAIN_EXTERNAL_CUSTOM_PREFIX="csky-linux"
+BR2_TOOLCHAIN_EXTERNAL_GCC_4_5=y
+BR2_TOOLCHAIN_EXTERNAL_HEADERS_4_9=y
+BR2_TOOLCHAIN_EXTERNAL_CUSTOM_GLIBC=y
+BR2_TOOLCHAIN_EXTERNAL_CXX=y
+BR2_TARGET_GENERIC_GETTY_PORT="ttyS0"
+BR2_SYSTEM_DHCP="eth0"
+BR2_ROOTFS_POST_IMAGE_SCRIPT="board/csky/post-image.sh"
+BR2_ROOTFS_POST_SCRIPT_ARGS="gx6605s"
+BR2_LINUX_KERNEL=y
+BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
+BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/csky/gx6605s/gx66xx_defconfig"
+BR2_LINUX_KERNEL_DTS_SUPPORT=y
+BR2_LINUX_KERNEL_USE_CUSTOM_DTS=y
+BR2_LINUX_KERNEL_CUSTOM_DTS_PATH="board/csky/gx6605s/gx6605s.dts"
+BR2_LINUX_KERNEL_EXT_CSKY_ARCH=y
+BR2_LINUX_KERNEL_EXT_CSKY_ADDONS=y
+BR2_PACKAGE_HOST_MKE2IMG=y
configs/csky_sc8925_defconfig new file +27 -0
new file mode 100644
index 0000000..08f0550
@@ -0,0 +1,27 @@
+BR2_csky=y
+BR2_OPTIMIZE_2=y
+BR2_SHARED_STATIC_LIBS=y
+# BR2_COMPILER_PARANOID_UNSAFE_PATH is not set
+BR2_TOOLCHAIN_EXTERNAL=y
+BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y
+BR2_TOOLCHAIN_EXTERNAL_URL="https://github.com/c-sky/tools/raw/master/csky-abiv2-linux-tools-x86_64-glibc-linux-4.9.2-20170228.tar.gz"
+BR2_TOOLCHAIN_EXTERNAL_CUSTOM_PREFIX="csky-abiv2-linux"
+BR2_TOOLCHAIN_EXTERNAL_GCC_4_5=y
+BR2_TOOLCHAIN_EXTERNAL_HEADERS_4_9=y
+BR2_TOOLCHAIN_EXTERNAL_CUSTOM_GLIBC=y
+BR2_TOOLCHAIN_EXTERNAL_CXX=y
+BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
+BR2_SYSTEM_DHCP="eth0"
+BR2_ROOTFS_POST_IMAGE_SCRIPT="board/csky/post-image.sh"
+BR2_ROOTFS_POST_SCRIPT_ARGS="sc8925"
+BR2_LINUX_KERNEL=y
+BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
+BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/csky/sc8925/sc8925_defconfig"
+BR2_LINUX_KERNEL_DTS_SUPPORT=y
+BR2_LINUX_KERNEL_USE_CUSTOM_DTS=y
+BR2_LINUX_KERNEL_CUSTOM_DTS_PATH="board/csky/sc8925/sc8925.dts"
+BR2_LINUX_KERNEL_EXT_CSKY_ARCH=y
+BR2_LINUX_KERNEL_EXT_CSKY_ADDONS=y
+BR2_LINUX_KERNEL_EXT_CSKY_ADDONS_GIT=y
+BR2_LINUX_KERNEL_EXT_CSKY_ADDONS_GIT_URL="git at git.coding.net:c-sky/addons-linux.git"
+BR2_PACKAGE_HOST_MKE2IMG=y
linux/Config.ext.in +75 -0

79 lines not on this page · raw message

linux/linux-ext-csky-addons.mk new file +12 -0
new file mode 100644
index 0000000..9ee1ac6
@@ -0,0 +1,12 @@
+################################################################################
+#
+# Linux kernel csky addons
+#
+################################################################################
+
+LINUX_EXTENSIONS += csky-addons
+
+define CSKY_ADDONS_PREPARE_KERNEL
+	cp -raf $(CSKY_ADDONS_DIR) $(LINUX_DIR)/addons
+endef
+
linux/linux-ext-csky-arch.mk new file +12 -0
new file mode 100644
index 0000000..1b95bdb
@@ -0,0 +1,12 @@
+################################################################################
+#
+# Linux kernel csky arch
+#
+################################################################################
+
+LINUX_EXTENSIONS += csky-arch
+
+define CSKY_ARCH_PREPARE_KERNEL
+	cp -raf $(CSKY_ARCH_DIR)/arch/csky $(LINUX_DIR)/arch/
+endef
+
package/Config.in +2 -0
index deff0fe..83cc390 100644
@@ -374,6 +374,8 @@ endmenu
 	source "package/eeprog/Config.in"
 	source "package/eudev/Config.in"
 	source "package/ev3dev-linux-drivers/Config.in"
+	source "package/csky-arch/Config.in"
+	source "package/csky-addons/Config.in"
 	source "package/evemu/Config.in"
 	source "package/evtest/Config.in"
 	source "package/fan-ctrl/Config.in"
package/csky-addons/Config.in new file +12 -0
new file mode 100644
index 0000000..5f94c56
@@ -0,0 +1,12 @@
+# Prompt-less option, because this package is not doing anything except
+# downloading source. The real work is done by a Linux
+# extension.
+config BR2_PACKAGE_CSKY_ADDONS
+	bool
+	depends on BR2_LINUX_KERNEL
+	help
+	  Linux addons for C-CSKY CPU
+
+	  This is only the download helper for the kernel patch.
+
+	  https://github.com/c-sky/addons-linux
package/csky-addons/csky-addons.mk new file +15 -0
new file mode 100644
index 0000000..64db15a
@@ -0,0 +1,15 @@
+################################################################################
+#
+# csky addons
+#
+################################################################################
+
+CSKY_ADDONS_VERSION = $(BR2_LINUX_KERNEL_EXT_CSKY_ADDONS_VERSION)
+ifeq ($(BR2_LINUX_KERNEL_EXT_CSKY_ADDONS_GITHUB),y)
+CSKY_ADDONS_SITE = $(call github,c-sky,addons-linux,$(CSKY_ADDONS_VERSION))
+else
+CSKY_ADDONS_SITE = $(BR2_LINUX_KERNEL_EXT_CSKY_ADDONS_GIT_URL)
+CSKY_ADDONS_SITE_METHOD = git
+endif
+
+$(eval $(generic-package))
package/csky-arch/Config.in new file +12 -0
new file mode 100644
index 0000000..0f47c98
@@ -0,0 +1,12 @@
+# Prompt-less option, because this package is not doing anything except
+# downloading source. The real work is done by a Linux
+# extension.
+config BR2_PACKAGE_CSKY_ARCH
+	bool
+	depends on BR2_LINUX_KERNEL
+	help
+	  Linux arch for C-CSKY CPU
+
+	  This is only the download helper for the kernel patch.
+
+	  https://github.com/c-sky/csky-linux
package/csky-arch/csky-arch.mk new file +15 -0
new file mode 100644
index 0000000..72efbc1
@@ -0,0 +1,15 @@
+################################################################################
+#
+# csky arch
+#
+################################################################################
+
+CSKY_ARCH_VERSION = $(BR2_LINUX_KERNEL_EXT_CSKY_ARCH_VERSION)
+ifeq ($(BR2_LINUX_KERNEL_EXT_CSKY_ARCH_GITHUB),y)
+CSKY_ARCH_SITE = $(call github,c-sky,csky-linux,$(CSKY_ARCH_VERSION))
+else
+CSKY_ARCH_SITE = $(BR2_LINUX_KERNEL_EXT_CSKY_ARCH_GIT_URL)
+CSKY_ARCH_SITE_METHOD = git
+endif
+
+$(eval $(generic-package))
toolchain/toolchain-buildroot/Config.in +1 -1
index 91cddc2..db073a6 100644
@@ -47,7 +47,7 @@ config BR2_TOOLCHAIN_BUILDROOT_GLIBC
 		   BR2_mipsel      || BR2_mips64     || BR2_mips64el|| \
 		   BR2_powerpc     || BR2_powerpc64  || BR2_powerpc64le || \
 		   BR2_sh          || BR2_sparc64    || BR2_x86_64 || \
-		   BR2_microblaze || BR2_nios2
+		   BR2_microblaze || BR2_nios2 || BR2_csky
 	depends on BR2_USE_MMU
 	depends on !BR2_STATIC_LIBS
 	depends on !BR2_powerpc_SPE
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/1 csky: Add new architecture

Hello,

Quoted 4 lines · Guo Ren

C-SKY is a CPU architecture from http://en.c-sky.com

1. This commit has been tested by C-SKY.

Quoted 8 lines

2. All changes in this commit are related for building csky dev board.

3. We currently use pre-build-toolchain from url. and csky-toolchain opensource is on going.

4. See more info in board/csky/readme.txt

Thanks for submitting the support for this new architecture. I'll review your patch below. However, I have one question: if you add a new architecture like this in Buildroot, then we will need your help to fix the build issues that will arise on this architecture. Indeed, the Buildroot community does a significant build testing effort (see
http://autobuild.buildroot.org). Can you comment on whether you will have some time to investigate and fix the build issues that will occur on this CPU architecture ?

Could you summarize the upstreaming status of the binutils, gcc, glibc and Linux kernel support for csky ?

Quoted 5 lines
arch/Config.in +0 -0
index 7149b2c..ea81c4c 100644

arch/Config.in config BR2_xtensa · line 249

Quoted 10 lines
arch/Config.in +7 -0
@@ -240,6 +240,14 @@ config BR2_xtensa
 	  http://en.wikipedia.org/wiki/Xtensa
 	  http://www.tensilica.com/
 
+config BR2_csky
+	bool "csky"
+	select BR2_ARCH_HAS_MMU_MANDATORY
+	help
+	  csky is processor IP from china.
+	  http://www.c-sky.com/
+	  http://www.github.com/c-sky

Please keep this file sorted alphabetically.

arch/Config.in if BR2_xtensa · line 422

Quoted 8 lines
arch/Config.in +3 -0
 # The following string values are defined by the individual
@@ -409,4 +417,8 @@ if BR2_xtensa
 source "arch/Config.in.xtensa"
 endif
 
+if BR2_csky
+source "arch/Config.in.csky"
+endif

Same, please keep the includes alphabetically sorted.

arch/Config.in.csky line 3

Quoted 9 lines
arch/Config.in.csky new file +3 -0
new file mode 100644
index 0000000..f400388
@@ -0,0 +1,57 @@
+choice
+	prompt "Target Architecture Variant"
+	depends on BR2_csky

This "depends on" is not needed, as the file is anyway only included when BR2_csky=y.

arch/Config.in.csky line 13

Quoted 10 lines
arch/Config.in.csky new file +10 -0
+	default BR2_ck810
+	help
+	  Specific CPU variant to use
+
+config BR2_ck810
+	bool "ck810"
+config BR2_ck807
+	bool "ck807"
+config BR2_ck610
+	bool "ck610"

Any reason to not sort them by order of increasing numbers? 610, then 807, then 810 ?

arch/Config.in.csky line 19

Quoted 4 lines
arch/Config.in.csky new file +4 -0
+config BR2_CSKY_FPU
+	bool "Enable FPU coprocessor"
+	depends on BR2_ck810 || BR2_ck807
+	default n

"default n" not needed: being not selected is the default for an option.

arch/Config.in.csky line 28

Quoted 9 lines
arch/Config.in.csky new file +9 -0
+	help
+	  You can say N here if you C-SKY CPU don't have Floating-Point Coprocessor
+	  or the user program need not to support FPU.
+
+	  You'll have say N here if you C-SKY CPU have Floating-Point Coprocessor
+	  and the user program need to support FPU. Floating-Point Coprocessor (FPC)
+	  is a coprocessor of CK serial processor. The function of FPC is to provide
+	  low-cost high-speed float point computation, which is full compliance with
+	  ANSI/IEEE Std 754, IEEE Standard for Binary Floating-Point Arithmetic.

Lines are too long, please wrap at 72 characters.

arch/Config.in.csky line 33

Quoted 4 lines
arch/Config.in.csky new file +4 -0
+config BR2_CSKY_DSP
+	bool "CPU support DSP enhanced instruction"
+	depends on BR2_ck810 || BR2_ck807
+	default n

"default n" not needed. To be more consistent with the FPU option, please use something like:

"Enable DSP enhance instructions"

as the option prompt.

arch/Config.in.csky line 35

Quoted 1 line
arch/Config.in.csky new file +1 -0
+# From Config.in requirement

Comment not really useful.

arch/Config.in.csky line 45

Quoted 10 lines
arch/Config.in.csky new file +10 -0
+config BR2_ARCH
+	default "csky"
+
+config BR2_ENDIAN
+	default "LITTLE"
+
+config BR2_GCC_TARGET_ARCH
+	default "ck610"	if BR2_ck610
+	default "ck807"	if BR2_ck807
+	default "ck810"	if BR2_ck810

Since you're setting BR2_GCC_TARGET_CPU below, I believe this BR2_GCC_TARGET_ARCH is useless. Indeed, when you pass -mcpu to gcc, gcc can automatically derive the corresponding -march.

board/csky/gx6605s/gdbinit

Quoted 16 lines
arch/Config.in.csky new file +11 -0
+config BR2_GCC_TARGET_CPU
+	default "ck610"		if (BR2_ck610 && !BR2_CSKY_FPU && !BR2_CSKY_DSP)
+	default "ck807"		if (BR2_ck807 && !BR2_CSKY_FPU && !BR2_CSKY_DSP)
+	default "ck807e"	if (BR2_ck807 && !BR2_CSKY_FPU &&  BR2_CSKY_DSP)
+	default "ck807f"	if (BR2_ck807 &&  BR2_CSKY_FPU && !BR2_CSKY_DSP)
+	default "ck807ef"	if (BR2_ck807 &&  BR2_CSKY_FPU &&  BR2_CSKY_DSP)
+	default "ck810"		if (BR2_ck810 && !BR2_CSKY_FPU && !BR2_CSKY_DSP)
+	default "ck810e"	if (BR2_ck810 && !BR2_CSKY_FPU &&  BR2_CSKY_DSP)
+	default "ck810f"	if (BR2_ck810 &&  BR2_CSKY_FPU && !BR2_CSKY_DSP)
+	default "ck810ef"	if (BR2_ck810 &&  BR2_CSKY_FPU &&  BR2_CSKY_DSP)
+
board/csky/gx6605s/gdbinit new file +0 -0
new file mode 100644
index 0000000..0a6d8ab

This file should be part of a separate patch, adding support for c-sky boards. Indeed, we want one patch adding the architecture support itself, and then other patches for the boards.

board/csky/gx6605s/gx6605s.dts

Quoted 5 lines
board/csky/gx6605s/gx6605s.dts new file +0 -0
new file mode 100644
index 0000000..195b0df

Could you please put this in your Linux kernel repository instead? We really don't want to keep complete Device Tree files in Buildroot.

board/csky/gx6605s/gx66xx_defconfig

Quoted 5 lines
board/csky/gx6605s/gx66xx_defconfig new file +0 -0
new file mode 100644
index 0000000..94eac2c

Could you instead add a defconfig in your Linux kernel repository, so that we don't have to keep this one in Buildroot? Especially one per board seems very excessive.

board/csky/post-image.sh line 4

Quoted 10 lines
board/csky/post-image.sh new file +4 -0
new file mode 100755
index 0000000..7bead4f
@@ -0,0 +1,4 @@
+#!/bin/sh
+# copy board/csky/xxx/gdbinit to images/.gdbinit for
+BOARD_DIR="$(dirname $0)"
+cp -af $BOARD_DIR/${2}/gdbinit $BINARIES_DIR/.gdbinit

Please move this to the patch adding support for the board.

configs/csky_gx6605s_defconfig line 3

Quoted 9 lines
configs/csky_gx6605s_defconfig new file +3 -0
new file mode 100644
index 0000000..75226a5
@@ -0,0 +1,26 @@
+BR2_csky=y
+BR2_ck610=y
+BR2_OPTIMIZE_2=y

Please leave the default optimization level.

configs/csky_gx6605s_defconfig line 4

Quoted 1 line
configs/csky_gx6605s_defconfig new file +1 -0
+BR2_SHARED_STATIC_LIBS=y

Please keep the default option here as well.

configs/csky_gx6605s_defconfig line 5

Quoted 1 line
configs/csky_gx6605s_defconfig new file +1 -0
+# BR2_COMPILER_PARANOID_UNSAFE_PATH is not set

And here as well.

Quoted 11 lines
configs/csky_gx6605s_defconfig new file +11 -0
+BR2_TOOLCHAIN_EXTERNAL=y
+BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y
+BR2_TOOLCHAIN_EXTERNAL_URL="https://github.com/c-sky/tools/raw/master/csky-linux-tools-x86_64-glibc-linux-4.9.2-20170227.tar.gz"
+BR2_TOOLCHAIN_EXTERNAL_CUSTOM_PREFIX="csky-linux"
+BR2_TOOLCHAIN_EXTERNAL_GCC_4_5=y
+BR2_TOOLCHAIN_EXTERNAL_HEADERS_4_9=y
+BR2_TOOLCHAIN_EXTERNAL_CUSTOM_GLIBC=y
+BR2_TOOLCHAIN_EXTERNAL_CXX=y
+BR2_TARGET_GENERIC_GETTY_PORT="ttyS0"
+BR2_SYSTEM_DHCP="eth0"
+BR2_ROOTFS_POST_IMAGE_SCRIPT="board/csky/post-image.sh"

configs/csky_gx6605s_defconfig line 26

Quoted 10 lines
configs/csky_gx6605s_defconfig new file +10 -0
+BR2_ROOTFS_POST_SCRIPT_ARGS="gx6605s"
+BR2_LINUX_KERNEL=y
+BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
+BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/csky/gx6605s/gx66xx_defconfig"
+BR2_LINUX_KERNEL_DTS_SUPPORT=y
+BR2_LINUX_KERNEL_USE_CUSTOM_DTS=y
+BR2_LINUX_KERNEL_CUSTOM_DTS_PATH="board/csky/gx6605s/gx6605s.dts"
+BR2_LINUX_KERNEL_EXT_CSKY_ARCH=y
+BR2_LINUX_KERNEL_EXT_CSKY_ADDONS=y
+BR2_PACKAGE_HOST_MKE2IMG=y

Why do you need mke2img ?

linux/Config.ext.in

Quoted 4 lines
linux/Config.ext.in +0 -0
index 011dffb..3729849 100644

Your whole kernel handling is way too complicated ad completely not standard. So instead of having your csky-linux repository with just arch/csky, and your csky-addons repository with the SoC drivers, please put on Github a regular Linux kernel repository with the csky architecture support.

This will be beneficial for multiple reasons:

1. That is how everybody expects the kernel source tree to be versioned control, so it will help new developers arriving on your new architecture.

2. This is how all build systems expect the kernel source code to be organized.

So please remove package/csky-addons, package/csky-arch and your changes to the linux/ package, and use a regular Linux kernel tree.

toolchain/toolchain-buildroot/Config.in config BR2_TOOLCHAIN_BUILDROOT_GLIBC · line 50

Quoted 10 lines
toolchain/toolchain-buildroot/Config.in +1 -1
index 91cddc2..db073a6 100644
@@ -47,7 +47,7 @@ config BR2_TOOLCHAIN_BUILDROOT_GLIBC
 		   BR2_mipsel      || BR2_mips64     || BR2_mips64el|| \
 		   BR2_powerpc     || BR2_powerpc64  || BR2_powerpc64le || \
 		   BR2_sh          || BR2_sparc64    || BR2_x86_64 || \
-		   BR2_microblaze || BR2_nios2
+		   BR2_microblaze || BR2_nios2 || BR2_csky

If you do this, then you allow people to build a toolchain for csky using Buildroot. Do you really have upstream support in binutils, gcc and glibc ?

If not, then this chunk shouldn't be here.

Best regards,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
author
#2 lore raw

PATCH 1/1 csky: Add new architecture

Thx, Thomas

Quoted 8 lines

Thanks for submitting the support for this new architecture. I'll review your patch below. However, I have one question: if you add a new architecture like this in Buildroot, then we will need your help to fix the build issues that will arise on this architecture. Indeed, the Buildroot community does a significant build testing effort (see
http://autobuild.buildroot.org). Can you comment on whether you will have some time to investigate and fix the build issues that will occur on this CPU architecture ?

Yes, I will help to fix the build issues in autobuild as soon as possible. I'm preparing my next patch-mail under your guidance and try my best to test it.

Quoted 2 lines

Could you summarize the upstreaming status of the binutils, gcc, glibc and Linux kernel support for csky ?

I just put a prebuild toolchain on the https://github.com/c-sky/tools, this has been tested by ourserlf.

binutils: current is 2.20 and we are preparing 2.27
gcc: current is 4.5.1 and we are preparing 6.3
glibc: current is 2.17 and we also plan to update it
kernel: current is 4.9.13 and it can be built with the last stable version, I will update it as soon as possible.

All of above source code will be put on the https://github.com/c-sky first, and next we will merge them into their own organizations' repo.

Quoted 8 lines
Quoted 8 lines
arch/Config.in +0 -0
index 7149b2c..ea81c4c 100644
@@ -240,6 +240,14 @@ config BR2_xtensa
  	  http://en.wikipedia.org/wiki/Xtensa
  	  http://www.tensilica.com/
 
Quoted 8 lines

arch/Config.in config BR2_xtensa · line 249

Quoted 7 lines
arch/Config.in +7 -0
+config BR2_csky
+	bool "csky"
+	select BR2_ARCH_HAS_MMU_MANDATORY
+	help
+	  csky is processor IP from china.
+	  http://www.c-sky.com/
+	  http://www.github.com/c-sky

Please keep this file sorted alphabetically.

OK, I will fix it

Quoted 9 lines

arch/Config.in if BR2_xtensa · line 422

Quoted 8 lines
arch/Config.in +3 -0
  # The following string values are defined by the individual
@@ -409,4 +417,8 @@ if BR2_xtensa
  source "arch/Config.in.xtensa"
  endif
 
+if BR2_csky
+source "arch/Config.in.csky"
+endif

Same, please keep the includes alphabetically sorted.

ok

Quoted 11 lines

arch/Config.in.csky line 3

Quoted 9 lines
arch/Config.in.csky new file +3 -0
new file mode 100644
index 0000000..f400388
@@ -0,0 +1,57 @@
+choice
+	prompt "Target Architecture Variant"
+	depends on BR2_csky

This "depends on" is not needed, as the file is anyway only included when BR2_csky=y.

ok

Quoted 4 lines
Quoted 4 lines
arch/Config.in.csky new file +4 -0
+	default BR2_ck810
+	help
+	  Specific CPU variant to use
+
Quoted 8 lines

arch/Config.in.csky line 13

Quoted 6 lines
arch/Config.in.csky new file +6 -0
+config BR2_ck810
+	bool "ck810"
+config BR2_ck807
+	bool "ck807"
+config BR2_ck610
+	bool "ck610"

Any reason to not sort them by order of increasing numbers? 610, then 807, then 810 ?

ok, Very strict

Quoted 5 lines

arch/Config.in.csky line 19

Quoted 4 lines
arch/Config.in.csky new file +4 -0
+config BR2_CSKY_FPU
+	bool "Enable FPU coprocessor"
+	depends on BR2_ck810 || BR2_ck807
+	default n

"default n" not needed: being not selected is the default for an option.

ok

Quoted 10 lines

arch/Config.in.csky line 28

Quoted 9 lines
arch/Config.in.csky new file +9 -0
+	help
+	  You can say N here if you C-SKY CPU don't have Floating-Point Coprocessor
+	  or the user program need not to support FPU.
+
+	  You'll have say N here if you C-SKY CPU have Floating-Point Coprocessor
+	  and the user program need to support FPU. Floating-Point Coprocessor (FPC)
+	  is a coprocessor of CK serial processor. The function of FPC is to provide
+	  low-cost high-speed float point computation, which is full compliance with
+	  ANSI/IEEE Std 754, IEEE Standard for Binary Floating-Point Arithmetic.

Lines are too long, please wrap at 72 characters.

ok

Quoted 10 lines

arch/Config.in.csky line 33

Quoted 4 lines
arch/Config.in.csky new file +4 -0
+config BR2_CSKY_DSP
+	bool "CPU support DSP enhanced instruction"
+	depends on BR2_ck810 || BR2_ck807
+	default n

"default n" not needed. To be more consistent with the FPU option, please use something like:

"Enable DSP enhance instructions"

as the option prompt.

ok, good option prompt.

Quoted 2 lines

arch/Config.in.csky line 35

Quoted 1 line
arch/Config.in.csky new file +1 -0
+# From Config.in requirement

Comment not really useful.

ok

Quoted 5 lines
Quoted 5 lines
arch/Config.in.csky new file +5 -0
+config BR2_ARCH
+	default "csky"
+
+config BR2_ENDIAN
+	default "LITTLE"
Quoted 8 lines

arch/Config.in.csky line 45

Quoted 5 lines
arch/Config.in.csky new file +5 -0
+
+config BR2_GCC_TARGET_ARCH
+	default "ck610"	if BR2_ck610
+	default "ck807"	if BR2_ck807
+	default "ck810"	if BR2_ck810

Since you're setting BR2_GCC_TARGET_CPU below, I believe this BR2_GCC_TARGET_ARCH is useless. Indeed, when you pass -mcpu to gcc, gcc can automatically derive the corresponding -march.

ok, and I've confirmed with our toolchain team that you are right.

Quoted 11 lines
Quoted 11 lines
arch/Config.in.csky new file +11 -0
+config BR2_GCC_TARGET_CPU
+	default "ck610"		if (BR2_ck610 && !BR2_CSKY_FPU && !BR2_CSKY_DSP)
+	default "ck807"		if (BR2_ck807 && !BR2_CSKY_FPU && !BR2_CSKY_DSP)
+	default "ck807e"	if (BR2_ck807 && !BR2_CSKY_FPU &&  BR2_CSKY_DSP)
+	default "ck807f"	if (BR2_ck807 &&  BR2_CSKY_FPU && !BR2_CSKY_DSP)
+	default "ck807ef"	if (BR2_ck807 &&  BR2_CSKY_FPU &&  BR2_CSKY_DSP)
+	default "ck810"		if (BR2_ck810 && !BR2_CSKY_FPU && !BR2_CSKY_DSP)
+	default "ck810e"	if (BR2_ck810 && !BR2_CSKY_FPU &&  BR2_CSKY_DSP)
+	default "ck810f"	if (BR2_ck810 &&  BR2_CSKY_FPU && !BR2_CSKY_DSP)
+	default "ck810ef"	if (BR2_ck810 &&  BR2_CSKY_FPU &&  BR2_CSKY_DSP)
+
Quoted 8 lines

board/csky/gx6605s/gdbinit

Quoted 5 lines
board/csky/gx6605s/gdbinit new file +0 -0
new file mode 100644
index 0000000..0a6d8ab

This file should be part of a separate patch, adding support for c-sky boards. Indeed, we want one patch adding the architecture support itself, and then other patches for the boards.

ok, I will separate it into arch-patch and board-patch.

Quoted 7 lines

board/csky/gx6605s/gx6605s.dts

Quoted 5 lines
board/csky/gx6605s/gx6605s.dts new file +0 -0
new file mode 100644
index 0000000..195b0df

Could you please put this in your Linux kernel repository instead? We really don't want to keep complete Device Tree files in Buildroot.

ok, no problem.

Quoted 8 lines

board/csky/gx6605s/gx66xx_defconfig

Quoted 5 lines
board/csky/gx6605s/gx66xx_defconfig new file +0 -0
new file mode 100644
index 0000000..94eac2c

Could you instead add a defconfig in your Linux kernel repository, so that we don't have to keep this one in Buildroot? Especially one per board seems very excessive.

ok.

Quoted 12 lines

board/csky/post-image.sh line 4

Quoted 10 lines
board/csky/post-image.sh new file +4 -0
new file mode 100755
index 0000000..7bead4f
@@ -0,0 +1,4 @@
+#!/bin/sh
+# copy board/csky/xxx/gdbinit to images/.gdbinit for
+BOARD_DIR="$(dirname $0)"
+cp -af $BOARD_DIR/${2}/gdbinit $BINARIES_DIR/.gdbinit

Please move this to the patch adding support for the board.

ok

Quoted 10 lines

configs/csky_gx6605s_defconfig line 3

Quoted 9 lines
configs/csky_gx6605s_defconfig new file +3 -0
new file mode 100644
index 0000000..75226a5
@@ -0,0 +1,26 @@
+BR2_csky=y
+BR2_ck610=y
+BR2_OPTIMIZE_2=y

Please leave the default optimization level.

ok, thx

Quoted 2 lines

configs/csky_gx6605s_defconfig line 4

Quoted 1 line
configs/csky_gx6605s_defconfig new file +1 -0
+BR2_SHARED_STATIC_LIBS=y

Please keep the default option here as well.

ok, use default.

Quoted 2 lines

configs/csky_gx6605s_defconfig line 5

Quoted 1 line
configs/csky_gx6605s_defconfig new file +1 -0
+# BR2_COMPILER_PARANOID_UNSAFE_PATH is not set

And here as well.

ok as well.

Quoted 14 lines
Quoted 14 lines
configs/csky_gx6605s_defconfig new file +14 -0
+BR2_TOOLCHAIN_EXTERNAL=y
+BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y
+BR2_TOOLCHAIN_EXTERNAL_URL="https://github.com/c-sky/tools/raw/master/csky-linux-tools-x86_64-glibc-linux-4.9.2-20170227.tar.gz"
+BR2_TOOLCHAIN_EXTERNAL_CUSTOM_PREFIX="csky-linux"
+BR2_TOOLCHAIN_EXTERNAL_GCC_4_5=y
+BR2_TOOLCHAIN_EXTERNAL_HEADERS_4_9=y
+BR2_TOOLCHAIN_EXTERNAL_CUSTOM_GLIBC=y
+BR2_TOOLCHAIN_EXTERNAL_CXX=y
+BR2_TARGET_GENERIC_GETTY_PORT="ttyS0"
+BR2_SYSTEM_DHCP="eth0"
+BR2_ROOTFS_POST_IMAGE_SCRIPT="board/csky/post-image.sh"
+BR2_ROOTFS_POST_SCRIPT_ARGS="gx6605s"
+BR2_LINUX_KERNEL=y
+BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
Quoted 8 lines

configs/csky_gx6605s_defconfig line 26

Quoted 7 lines
configs/csky_gx6605s_defconfig new file +7 -0
+BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/csky/gx6605s/gx66xx_defconfig"
+BR2_LINUX_KERNEL_DTS_SUPPORT=y
+BR2_LINUX_KERNEL_USE_CUSTOM_DTS=y
+BR2_LINUX_KERNEL_CUSTOM_DTS_PATH="board/csky/gx6605s/gx6605s.dts"
+BR2_LINUX_KERNEL_EXT_CSKY_ARCH=y
+BR2_LINUX_KERNEL_EXT_CSKY_ADDONS=y
+BR2_PACKAGE_HOST_MKE2IMG=y

Why do you need mke2img ?

I don't need it, my bug.

Quoted 17 lines

linux/Config.ext.in

Quoted 5 lines
linux/Config.ext.in +0 -0
index 011dffb..3729849 100644

Your whole kernel handling is way too complicated ad completely not standard. So instead of having your csky-linux repository with just arch/csky, and your csky-addons repository with the SoC drivers, please put on Github a regular Linux kernel repository with the csky architecture support.

This will be beneficial for multiple reasons:

1. That is how everybody expects the kernel source tree to be versioned control, so it will help new developers arriving on your new architecture.

Quoted 5 lines

2. This is how all build systems expect the kernel source code to be organized.

So please remove package/csky-addons, package/csky-arch and your changes to the linux/ package, and use a regular Linux kernel tree.

ok, remove them.

Quoted 14 lines

toolchain/toolchain-buildroot/Config.in config BR2_TOOLCHAIN_BUILDROOT_GLIBC · line 50

Quoted 10 lines
toolchain/toolchain-buildroot/Config.in +1 -1
index 91cddc2..db073a6 100644
@@ -47,7 +47,7 @@ config BR2_TOOLCHAIN_BUILDROOT_GLIBC
  		   BR2_mipsel      || BR2_mips64     || BR2_mips64el|| \
  		   BR2_powerpc     || BR2_powerpc64  || BR2_powerpc64le || \
  		   BR2_sh          || BR2_sparc64    || BR2_x86_64 || \
-		   BR2_microblaze || BR2_nios2
+		   BR2_microblaze || BR2_nios2 || BR2_csky

If you do this, then you allow people to build a toolchain for csky using Buildroot. Do you really have upstream support in binutils, gcc and glibc ?

Quoted 1 line

If not, then this chunk shouldn't be here.

ok, it's unnecessary and ? finished the build without this.

Quoted 3 lines

Best regards,

Thomas

#3 lore raw

PATCH 1/1 csky: Add new architecture

Hello,

Quoted 9 lines · ren_guo
Quoted 8 lines

Thanks for submitting the support for this new architecture. I'll review your patch below. However, I have one question: if you add a new architecture like this in Buildroot, then we will need your help to fix the build issues that will arise on this architecture. Indeed, the Buildroot community does a significant build testing effort (see
http://autobuild.buildroot.org). Can you comment on whether you will have some time to investigate and fix the build issues that will occur on this CPU architecture ?

Quoted 3 lines

Yes, I will help to fix the build issues in autobuild as soon as possible. I'm preparing my next patch-mail under your guidance and try my best to test it.

Great. Then please add an entry for yourself in the DEVELOPERS file, like:

N:      ren_guo <[email protected]>
F:      arch/Config.in.csky

You can also add other F: entries for files that you contributed. But the arch/Config.in.csky is particularly important: by assigning this file to yourself, you will receive e-mail notifications when there are build failures for your architecture.

One package that contains architecture-specific code and that often causes problems is libffi. So if you haven't yet looked at implementing support for csky in libffi, I would recommend you to have a look.

Quoted 11 lines
Quoted 2 lines

Could you summarize the upstreaming status of the binutils, gcc, glibc and Linux kernel support for csky ?

I just put a prebuild toolchain on the https://github.com/c-sky/tools, this has been tested by ourserlf.

binutils: current is 2.20 and we are preparing 2.27
gcc: current is 4.5.1 and we are preparing 6.3
glibc: current is 2.17 and we also plan to update it
kernel: current is 4.9.13 and it can be built with the last stable version, I will update it as soon as possible.

OK, thanks.

Quoted 2 lines

All of above source code will be put on the https://github.com/c-sky first, and next we will merge them into their own organizations' repo.

Good.

Quoted 14 lines
Quoted 14 lines

toolchain/toolchain-buildroot/Config.in config BR2_TOOLCHAIN_BUILDROOT_GLIBC · line 50

Quoted 10 lines
toolchain/toolchain-buildroot/Config.in +1 -1
index 91cddc2..db073a6 100644
@@ -47,7 +47,7 @@ config BR2_TOOLCHAIN_BUILDROOT_GLIBC
  		   BR2_mipsel      || BR2_mips64     || BR2_mips64el|| \
  		   BR2_powerpc     || BR2_powerpc64  || BR2_powerpc64le || \
  		   BR2_sh          || BR2_sparc64    || BR2_x86_64 || \
-		   BR2_microblaze || BR2_nios2
+		   BR2_microblaze || BR2_nios2 || BR2_csky  

If you do this, then you allow people to build a toolchain for csky using Buildroot. Do you really have upstream support in binutils, gcc and glibc ?

Quoted 3 lines
Quoted 1 line

If not, then this chunk shouldn't be here.

ok, it's unnecessary and ? finished the build without this.

However, since initially you will not support the "internal toolchain backend" (i.e when Buildroot builds the toolchain from scratch), then you should change the definition of BR2_TOOLCHAIN_BUILDROOT with:

depends on !BR2_csky

So that on the csky architecture, only the external toolchain option is available.

Thanks,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
author
#4 lore raw

PATCH 1/1 csky: Add new architecture

hi, Thomas

Quoted 6 lines

Great. Then please add an entry for yourself in the DEVELOPERS file, like:

N:      ren_guo <[email protected]>
F:      arch/Config.in.csky
Quoted 9 lines

You can also add other F: entries for files that you contributed. But the arch/Config.in.csky is particularly important: by assigning this file to yourself, you will receive e-mail notifications when there are build failures for your architecture.

One package that contains architecture-specific code and that often causes problems is libffi. So if you haven't yet looked at implementing support for csky in libffi, I would recommend you to have a look.

ok, got it.

Quoted 8 lines

However, since initially you will not support the "internal toolchain backend" (i.e when Buildroot builds the toolchain from scratch), then you should change the definition of BR2_TOOLCHAIN_BUILDROOT with:

depends on !BR2_csky

So that on the csky architecture, only the external toolchain option is available.

ok, I will be care of it.

Best Regards

guoren

#5 lore raw

PATCH 1/1 csky: Add new architecture

In reply to Guo Ren
Quoted 8 lines · Thomas Petazzoni

However, since initially you will not support the "internal toolchain backend" (i.e when Buildroot builds the toolchain from scratch), then you should change the definition of BR2_TOOLCHAIN_BUILDROOT with:

depends on !BR2_csky

So that on the csky architecture, only the external toolchain option is available.

If the toolchain you pull from github is more or less stable, you could also
opt to add it to toolchain/toolchain-external, so it is easier to fetch it.

BTW, note that you will need to depend on BR2_HOSTARCH = "x86_64" for these
external toolchains.

Regards,
Arnout

Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
author
#6 lore raw

PATCH 1/1 csky: Add new architecture

hi, Arnout

Quoted 2 lines

If the toolchain you pull from github is more or less stable, you could also
opt to add it to toolchain/toolchain-external, so it is easier to fetch it.

Currently I just use BR2_TOOLCHAIN_EXTERNAL_URL, and I will do this next time.

Quoted 2 lines

BTW, note that you will need to depend on BR2_HOSTARCH = "x86_64" for these
external toolchains.

BR2_HOSTARCH is important for me, thx :)

BTW, I've changed gcc PKGVERSION to match the regax in helper.mk, it solved :)

Best Regards

guoren