#### 问题一

1、问题描述

`libffi_3.3.bb`配置错误：

```
 configure: error: "libffi has not been ported to csky-oe-linux-gnu."
   WARNING: /home/lqg/al_yocto/temp/riscv_yocto/thead-build/ice-base/tmp-glibc/work/csky32-oe-linux/libffi/3.3-r0/temp/run.do_configure.25572:301 exit 1 from 'exit 1
```

2、解决方法

原因：`libffi`源码没有`C-SKY`平台处理代码

修改内容：

1）使用`buildroot`版本的`libffi`对应的代码

2）修改`configure.hos`t文件，添加`C-SKY`的架构

` meta-csky/recipes-support/libffi/libffi_3.3.bbappend`内容如下：

```
  FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
  
  SRC_URI_append_csky = "file://csky/ffi.c \
                         file://csky/ffitarget.h  \
                         file://csky/sysv.S \
                         file://configure.host \
                         "
  
  do_configure_prepend_csky() {
        echo "THISDIR= ${THISDIR}/${PN}"
        echo "PN=${PN}"
        echo "PV=${PV}"
        if [ -d "${WORKDIR}/csky" -a -d "${WORKDIR}/${PN}-${PV}/src" ]; then
            cp -rf ${WORKDIR}/csky ${WORKDIR}/${PN}-${PV}/src
        fi
        if [ -f "${WORKDIR}/configure.host" -a -d "${WORKDIR}/${PN}-${PV}" ]; then
            cp -rf ${WORKDIR}/configure.host ${WORKDIR}/${PN}-${PV}
        fi
 }
```

#### 问题二

1、问题描述

`libgcc-external.bb`编译错误，信息如下：

```
ERROR: libgcc-external-6.3.0-r0 do_package: Error executing a python function in exec_python_func() autogenerated:
Exception: FileExistsError: [Errno 17] File exists: './../../lib/gcc/csky-linux-gnuabiv2/6.3.0/crtn.o' -> 
'/home/lqg/al_yocto/temp/riscv_yocto/thead-build/ice-base/tmp-glibc/work/csky32-oe-linux/libgcc-external/6.3.0-r0/packages-split/libgcc-external-dev/
./../../lib/gcc/csky-linux-gnuabiv2/6.3.0/crtn.o'
```

2、解决方法

修改代码仓：

```
openembedded-core
```

提交`commit ID`:

```
2ec67c069fe5f5b953456aa938bc5244d98ee0d6
```

#### 问题三

1、问题描述
`dpkg`配置错误：

```
| checking dpkg architecture name... configure: error: cannot determine host dpkg architecture
```

2、解决方法

原因：`dpkg_1.20.5`针对`C-SKY`的架构没有对应。

解决方法：

修改`git/data/cputable`文件，追加`C-SKY`平台对应表，修改文件 `meta-csky/recipes-devtools/dpkg/dpkg_1.20.5.bbappend`

```
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
SRC_URI_append_csky = "file://data/cputable \           "
S = "${WORKDIR}/git"
do_configure_prepend_csky() {
    if [ -d "${WORKDIR}/data" -a -d "${S}" ]; then
        cp -rf ${WORKDIR}/data ${S}/
    fi
}
```

#### 问题四

1、问题描述

`xorgproto`编译错误，信息如下：

```
    ERROR: Unknown CPU family csky, see https://wiki.yoctoproject.org/wiki/Meson/UnknownCPU for directions.
    | WARNING: /home/lqg/al_yocto/temp/riscv_yocto/thead-build/ice-base/tmp-glibc/work/csky32-oe-linux/xorgproto/2020.1-r0/temp/run.do_configure.19148:173 exit 1 from 'exit 1'
```

2、解决方法

原因: `meson`中缺少对`C-SKY`平台支持。
解决方法: 修改`envconfig.py`文件，适配`C-SKY`平台，修改文件`meta-csky/recipes-devtools/meson/meson_0.55.1.bbappend`:

```
HOMEPAGE = "http://mesonbuild.com"
SUMMARY = "A high performance build system"

FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"

SRC_URI_append = "file://envconfig.py \
                 "
do_configure() {
    if [ -f "${WORKDIR}/envconfig.py" -a -d "${WORKDIR}/meson-${PV}/mesonbuild" ]; then
        cp -rf ${WORKDIR}/envconfig.py ${WORKDIR}/meson-${PV}/mesonbuild
    fi
}
```

#### 问题五

1、问题描述

`glibc-external.bb`执行`do_package_qa`错误如下：

```
ERROR: glibc-external-2.28.9000-r0 do_package_qa: QA Issue: /usr/bin/ldd contained in package ldd requires /tools/csky/csky-test/systools/CentOS-4.9-x86_64/bin/sh, but no providers found in RDEPENDS_ldd? [file-rdeps]
ERROR: glibc-external-2.28.9000-r0 do_package_qa: QA Issue: /usr/bin/tzselect contained in package tzcode requires /tools/csky/csky-test/systools/CentOS-4.9-x86_64/bin/sh, but no providers found in RDEPENDS_tzcode? [file-rdeps]
```

2、解决方法

原因：工具链制作问题，`/tools/csky/csky-test/systools/CentOS-4.9-x86_64/bin/sh`解释器路径在工具链中固定配置，正确的是：`/bin/sh`
修改方法：批量修改工具链相关文件，修改如下：

```
grep -rni "systools" ~/.thead/csky-linux
sed -i "s|/tools/csky/csky-test/systools/CentOS-4.9-x86_64||g" `grep -rni "systools" ~/.thead/csky-linux | cut -d':' -f1` 
```

#### 问题六

1、问题描述

`openocd`构建错误：`COMPATIBLE_HOST`不支持`C-SKY`平台。

2、解决方法

修改`dynamic-layers/openembedded-layer/recipes-devtools/openocd/openocd_csky.bb`如下：

```
COMPATIBLE_HOST = "(x86_64.*|i.86.*|csky).*-linux"
```


