thesofproject / sof-docs

Documentation for SOF
Other
16 stars 72 forks source link

docker build for imx8 not working out of the box #465

Closed eurofun closed 1 year ago

eurofun commented 1 year ago

The getting started nxp page mentions building inside a docker container as an option and refers to https://thesofproject.github.io/latest/getting_started/build-guide/build-with-docker.html Too bad that the container installed after following this page doesn't contain an aarch64 toolchain. sof branch is a one week old 'main'.

Inside the container I had to apt update && apt-get install gcc-aarch64-linux-gnu

and make the following changes after the toolchain install was committed to a new container 'mysof':

diff --git a/scripts/build-tools.sh b/scripts/build-tools.sh
index 49f0eeaa7..f9e0afed0 100755
--- a/scripts/build-tools.sh
+++ b/scripts/build-tools.sh
@@ -38,7 +38,7 @@ reconfigure_build()
         mkdir -p "$BUILD_TOOLS_DIR"

         ( cd "$BUILD_TOOLS_DIR"
-          cmake -GNinja -DCMAKE_BUILD_TYPE="$CMAKE_BUILD_TYPE" "${SOF_REPO}/tools"
+          cmake -DCMAKE_TOOLCHAIN_FILE=../scripts/cross-arch64.cmake -GNinja -DCMAKE_BUILD_TYPE="$CMAKE_BUILD_TYPE" "${SOF_REPO}/tools"
         )
 }

diff --git a/scripts/docker-run.sh b/scripts/docker-run.sh
index 29d7ebc0f..573bbc88a 100755
--- a/scripts/docker-run.sh
+++ b/scripts/docker-run.sh
@@ -44,4 +44,4 @@ docker run -i -v "${SOF_TOP}":/home/sof/work/sof.git \
        --env https_proxy="$https_proxy" \
        --user "$(id -u)" \
        $SOF_DOCKER_RUN \
-       thesofproject/sof "$@"
+       mysof "$@"
diff --git a/scripts/xtensa-build-all.sh b/scripts/xtensa-build-all.sh
index 05cb8f13d..233e32f4d 100755
--- a/scripts/xtensa-build-all.sh
+++ b/scripts/xtensa-build-all.sh
@@ -190,7 +190,7 @@ fi

 OLDPATH=$PATH
 CURDIR="$(pwd)"
-
+git config --global --add safe.directory /home/sof/work/sof.git
 # build platforms
 for platform in "${PLATFORMS[@]}"
 do

For the xtensa toolchain the docs say 'contact nxp support' but as far as I know everybody can download them directly from cadence (after some registration). So some installation instructions could be helpful - personally I don't care right now as gcc does its job sufficiently good.

Under https://thesofproject.github.io/latest/developer_guides/debugability/logger/index.html there are only instructions on how to disable suspend for intel (plus there is one tiny spelling error on this page: sof-loggerr ). For imx8mp this works: /sys/class/devlink/platform:power-domains:audiomix-pd--platform:3b6e8000.dsp/consumer/power# echo on>control

https://thesofproject.github.io/latest/developer_guides/topology/topology.html#debug-topology :

root@d73e8cbcbd51:~/work/sof.git/tools/topology/topology1# m4 -I m4 -I common -I platform/common --define=GRAPH sof-imx8-nocodec.m4 2> test.dot
root@d73e8cbcbd51:~/work/sof.git/tools/topology/topology1# cat test.dot 
"PCM0P"->"BUF1.0"
"BUF1.0"->"PGA1.0"
"PGA1.0"->"BUF1.1"
"BUF1.1"->"ESAI0.OUT"

dot -Tpng -o a.png tools/topology/topology1/test.dot
Error: tools/topology/topology1/test.dot: syntax error in line 1 near '"'

Isn't there a digraph G {} missing? At least I can't get dot to produce an image without that... I guess it's debatable whether this is a) related to the original topic of this issue (sorry) and b) should be fixed in the documentation or elsewhere.

dbaluta commented 1 year ago

@eurofun thanks for opening this issue.

1) it is not clear for me what is the docker problem. We use docker with CI to build SOF Firmware

https://github.com/thesofproject/sof/actions/runs/4857833763/jobs/8658689993?pr=7546

and all works well.

I guess your problem is that you cannot build the sof-logger for ARM64, right? Then yes, you are right the scripts are not customized for building ARM64 userspace.

2) For Xtensa toolchain. Yes, I think some part of the toolchain can be obtained from Xtensa but you still need IMX specific configuration files to have a build running on IMX8 DSP.

3)

For imx8mp this works: /sys/class/devlink/platform:power-domains:audiomix-pd--platform:3b6e8000.dsp/consumer/power# echo on>control

Do you suggest that we should add a chapter on how to disable suspend on IMX?

4) sof-imx8-nocodec.m4 is legacy stuff and we kind of skipped supporting it. But anyhow, if you want to draw the graph you can use:

https://github.com/thesofproject/sof-test/blob/main/tools/tplgtool2.py

./tplgtool2.py -d graph ~/work/repos/sof/tools/build_tools/topology/topology1/production/sof-imx8-nocodec.tplg

May I ask you what is the project you are working on? And what are you trying to achieve?

eurofun commented 1 year ago

@dbaluta thanks for the quick response!

  1. you are right, it's mainly about the logger / ctl tools. But also when building the fw itself I'm getting the following error without adding the git safe.directory to the build-all script. No big deal though...

    
    sudo ./scripts/docker-run.sh ./scripts/xtensa-build-all.sh imx8m
    REPOSITORY   TAG       DIGEST    IMAGE ID       CREATED        SIZE
    sof          latest    <none>    981e577a88a9   2 months ago   3.47GB
    REPOSITORY          TAG       DIGEST                                                                    IMAGE ID       CREATED        SIZE
    thesofproject/sof   latest    sha256:018912674fbae12df46581b5dd0d319c1d1191205f26eee03dce4c548e8dd05f   981e577a88a9   2 months ago   3.47GB
    Warning: this script should be run as user ID 1000 to match the container's account
    + id -u
    + docker run -i -v /media/dachb/sof:/home/sof/work/sof.git -v /media/dachb/sof:/home/sof/work/sof-bind-mount-DO-NOT-DELETE --env CMAKE_BUILD_TYPE --env PRIVATE_KEY_OPTION --env USE_XARGS --env NO_PROCESSORS --env VERBOSE --env http_proxy= --env https_proxy= --user 0 --tty thesofproject/sof ./scripts/xtensa-build-all.sh imx8m
    Build in build_imx8m_gcc
    PATH=/home/sof/work/sof.git/../xtensa-imx8m-elf/bin:/home/sof/work/xtensa-mt8195-elf/bin:/home/sof/work/xtensa-mt8186-elf/bin:/home/sof/work/xtensa-imx8ulp-elf/bin:/home/sof/work/xtensa-imx8m-elf/bin:/home/sof/work/xtensa-imx-elf/bin:/home/sof/work/xtensa-rmb-elf/bin:/home/sof/work/xtensa-rn-elf/bin:/home/sof/work/xtensa-cnl-elf/bin:/home/sof/work/xtensa-apl-elf/bin:/home/sof/work/xtensa-hsw-elf/bin:/home/sof/work/xtensa-byt-elf/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    + cmake -DTOOLCHAIN=xtensa-imx8m-elf -DROOT_DIR=/home/sof/work/sof.git/../xtensa-root/xtensa-imx8m-elf -DMEU_OPENSSL= '' '' -DINIT_CONFIG=imx8m_defconfig -DEXTRA_CFLAGS= /home/sof/work/sof.git
    -- Found Python3: /usr/bin/python3.8 (found version "3.8.10") found components: Interpreter 
    -- Preparing Xtensa toolchain
    -- The C compiler identification is GNU 10.2.0
    -- The ASM compiler identification is GNU
    -- Found assembler: /home/sof/work/xtensa-imx8m-elf/bin/xtensa-imx8m-elf-gcc
    -- Linking git pre-commit hook
    -- Linking git post-commit hook
    -- Found Git: /usr/bin/git (found version "2.25.1") 
    fatal: detected dubious ownership in repository at '/home/sof/work/sof.git'
    To add an exception for this directory, call:
    
    git config --global --add safe.directory /home/sof/work/sof.git
    CMake Error at scripts/cmake/git-submodules.cmake:25 (message):
    git submodule status --recursive failed, returned: 128

Call Stack (most recent call first): CMakeLists.txt:50 (include)

-- Configuring incomplete, errors occurred! See also "/home/sof/work/sof.git/build_imx8m_gcc/CMakeFiles/CMakeOutput.log". See also "/home/sof/work/sof.git/build_imx8m_gcc/CMakeFiles/CMakeError.log".



2. I'm referring to this page: https://tensilicatools.com/download/i-mx-8-hifi-4-sdk/
It has the tools and dsp config for linux. I didn't try it yet.

3. yes I'm suggesting to add some hint how to disable suspend on imx, otherwise the logger trace output is a bit confusing for beginners. I guess everybody will figure it out on their own but why not spare them this small effort...

4. thanks for the link to the python tool. Again, no big deal but the small things I tripped over keep adding up...
5. Yes, you may ask what I'm trying to achieve: 

A) the proximate goal is to have 8ch passthrough, sai2 and sai3 simultaneously, on imx8mp with the codecs as clk consumers and mclk output over clkout1, dsp_a tdm. I know that is not going to be plug&play and I already saw that for some reason there is only sai1 and 3 defined in the driver and the bclk divider is hardcoded but I'll keep that for a separate issue. What somehow fits the documentation topic: is there any .dts example of how to use the nocodec topologies on imx? I got errors when trying it, so now I'll dabble with the btsco simple-card way. 

B) the ultimate goal is to have these 16ch go through a proprietary processing component, similar to the google rtc processing. Worst case I could drastically compromise on the channel count that goes through this component (one in / one out). Does NXP have any plans on integrating some of their VIT/VoiceSeeker stuff into sof - if you can comment on that? Is there a timeline for migrating imx to topology2?
dbaluta commented 1 year ago

@eurofun

  1. Maybe this warning has something to do with it:
Warning: this script should be run as user ID 1000 to match the container's account
  1. Oh, all right. Didn't try it either.

  2. Care to send a patch? We use this: https://github.com/thesofproject/sof-docs. Otherwise, will add it on my to do list for next weeks.

  3. nocodec topologies were used few years ago when we started development and are not currently maintained. You can have a look for real hardware dts here:

https://github.com/nxp-imx/linux-imx/tree/lf-6.1.y/arch/arm64/boot/dts/freescale

Just grep for dts that contain SOF in name.

eurofun commented 1 year ago

@dbaluta

1. You are probably right. Maybe it is because I skipped the (optional) step in the docs about running docker as non-root user. I'm too lazy to figure out the exact reason, as it works well now as it is.

3. I did.

4. Thanks for the link to the dts files, I was using them already - otherwise I would never have figured out how to configure the dsp in my device tree.