-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Mediatek Audio DSPs: 8186/8188/8196 #81154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
38ecf3c
12f351f
c9d4de3
d492ad0
5d4a230
d8d1ba2
efaadf9
eb04c9a
378c817
3b53e71
23f4a57
bcda98a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,166 @@ | ||||||
| .. _boards-mtk_adsp: | ||||||
|
|
||||||
| Mediatek Audio DSPs | ||||||
| ################### | ||||||
|
|
||||||
|
Comment on lines
+1
to
+5
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will need some follow-up work as it's not really aligned with the rest of boards' docs. I appreciate you want some common doc bits across all similar boards, and it's fair to want to group everything right in the same file, but this top-level index.rst should really be for all Mediatek boards, whatever they might be (see index.rst files for all other vendors). Note that for this reason, the boards listed here lead nowhere for they appear to the documentation infrastructure as "doc-less".
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Heh. Well I do need to point out that when that patch was written, that directory was exclusively to Audio DSPs. :) But sure, will figure it out. Presumably I can have stub pages and link to the shared one or whatever. |
||||||
| Zephyr can be built and run on the Audio DSPs included in various | ||||||
| members of the Mediatek MT8xxx series of ARM SOCs used in Chromebooks | ||||||
| from various manufacturers. | ||||||
|
|
||||||
| Two of these DSPs are in the market already, implemented via the | ||||||
| MT8195 ("Kompanio 1380") and MT8186 ("Kompanio 520") SOCs. | ||||||
| Development has been done on and validation performed on at least | ||||||
| these devices, though more exist: | ||||||
|
|
||||||
| ====== ============= =================================== ================= | ||||||
| SOC Product Name Example Device ChromeOS Codename | ||||||
| ====== ============= =================================== ================= | ||||||
| MT8195 Kompanio 1380 HP Chromebook x360 13b dojo | ||||||
| MT8186 Kompanio 520 Lenovo 300e Yoga Chromebook Gen 4 steelix | ||||||
| ====== ============= =================================== ================= | ||||||
|
|
||||||
| Hardware | ||||||
| ******** | ||||||
|
|
||||||
| These devices are Xtensa DSP cores, very similar to the Intel ADSP | ||||||
| series in concept (with the notable difference that these are all | ||||||
| single-core devices, no parallel SMP is available, but at the same | ||||||
| time there are fewer worries about the incoherent cache). | ||||||
|
|
||||||
| Their memory space is split between dedicated, fast SRAM and ~16MB of | ||||||
| much slower system DRAM. Zephyr currently loads and links into the | ||||||
| DRAM area, a convention it inherits from SOF (these devices have | ||||||
| comparatively large caches which are used for all accesses, unlike | ||||||
| with intel_adsp). SRAM is used for interrupt vectors and stacks, | ||||||
| currently. | ||||||
|
|
||||||
| There is comparatively little on-device hardware. The architecture is | ||||||
| that interaction with the off-chip audio hardware (e.g. I2S codecs, | ||||||
| DMIC inputs, etc...) is managed by the host kernel. The DSP receives | ||||||
| its data via a single array of custom DMA controllers. | ||||||
|
|
||||||
| Beyond that the Zephyr-visible hardware is limited to a bounty of | ||||||
| timer devices (of which Zephyr uses two), and a "mailbox" | ||||||
| bidirectional interrupt source it uses to communicate with the host | ||||||
| kernel. | ||||||
|
|
||||||
| Programming and Debugging | ||||||
| ************************* | ||||||
|
|
||||||
| These devices work entirely in RAM, so there is no "flash" process as | ||||||
| such. Their memory state is initialized by the host Linux | ||||||
| environment. This process works under the control of a | ||||||
| ``mtk_adsp_load.py`` python script, which has no dependencies outside | ||||||
| the standard library and can be run (as root, of course) on any | ||||||
| reasonably compatible Linux environment with a Python 3.8 or later | ||||||
| interpreter. A chromebook in development mode with the dev packages | ||||||
| installed works great. See the ChromiumOS developer library for more | ||||||
| detail: | ||||||
|
|
||||||
| * `Developer mode <https://www.chromium.org/chromium-os/developer-library/guides/device/developer-mode/>`__ | ||||||
| * `Dev-Install: Installing Developer and Test packages onto a Chrome OS device <https://www.chromium.org/chromium-os/developer-library/guides/device/install-software-on-base-images/>`__ | ||||||
|
|
||||||
| Once you have the device set up, the process is as simple as copying | ||||||
| the ``zephyr.img`` file from the build directory to the device | ||||||
| (typically via ssh) and running it with the script. For example for | ||||||
| my mt8186 device named "steelix": | ||||||
|
|
||||||
| .. code-block:: console | ||||||
|
|
||||||
| user@dev_host:~$ west build -b mt8186//adsp samples/hello_world | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
nit/not a blocker, but is there an extra forward slash that crept in? |
||||||
| ... | ||||||
| ... # build output | ||||||
| ... | ||||||
| user@dev_host:~$ scp build/zephyr/zephyr.img root@steelix: | ||||||
| user@dev_host:~$ scp soc/mediatek/mt8xxx/mtk_adsp_load.py root@steelix: | ||||||
| user@dev_host:~$ ssh steelix | ||||||
|
|
||||||
| root@steelix:~ # ./mtk_adsp_load.py load zephyr.img | ||||||
| *** Booting Zephyr OS build v3.6.0-5820-gd2a89b3c089e *** | ||||||
| Hello World! mt8186_adsp/mt8186_adsp | ||||||
|
|
||||||
| Debugging | ||||||
| ========= | ||||||
|
|
||||||
| Given the limited I/O facilities, debugging support remains limited on | ||||||
| these platforms. Users with access to hardware-level debug and trace | ||||||
| tools (e.g. from Cadence) will be able to use them as-is. Zephyr | ||||||
| debugging itself is limited to printk/logging techniques at the | ||||||
| moment. In theory a bidirectional console like winstream can be used | ||||||
| with gdb_stub, which has support on Xtensa and via the SDK debuggers, | ||||||
| but this is still unintegrated. | ||||||
|
|
||||||
| Toolchains | ||||||
| ********** | ||||||
|
|
||||||
| The MT8195 toolchain is already part of the Zephyr SDK, so builds for | ||||||
| the ``mt8195//adsp`` board should work out of the box simply following | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
nit: As above, not a blocker, but has a double slash crept in?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nope, see above. :) That's the real name, it's shorthand for "mt8195/mt8195/adsp" |
||||||
| the generic Zephyr build instructions in the Getting Started guide. | ||||||
|
|
||||||
| The MT8186 toolchain is not, and given the proliferation of Xtensa | ||||||
| toolchains in the SDK may not be. The overlay files for the device | ||||||
| are maintained by the SOF project, however, and building a toolchain | ||||||
| yourself using crosstools-ng is not difficult or time-consuming. This | ||||||
| script should work for most users: | ||||||
|
|
||||||
| .. code-block:: shell | ||||||
|
|
||||||
| #!/bin/sh | ||||||
|
|
||||||
| TC=mtk_mt818x_adsp | ||||||
|
|
||||||
| # Grab source (these are small) | ||||||
| git clone https://github.com/crosstool-ng/crosstool-ng | ||||||
| git clone https://github.com/thesofproject/xtensa-overlay | ||||||
|
|
||||||
| # Build ct-ng itself | ||||||
| cd crosstool-ng | ||||||
| ./bootstrap | ||||||
| ./configure --enable-local | ||||||
| make -j$(nproc) | ||||||
|
|
||||||
| mkdir overlays | ||||||
| (cd overlays; ln -s ../../xtensa-overlay/xtensa_mt8186.tar.gz xtensa_${TC}.tar.gz) | ||||||
|
|
||||||
| # Construct a .config file | ||||||
| cat >.config <<EOF | ||||||
| CT_CONFIG_VERSION="3" | ||||||
| CT_EXPERIMENTAL=y | ||||||
| CT_OVERLAY_LOCATION="overlays" | ||||||
| CT_OVERLAY_NAME="${TC}" | ||||||
| CT_ARCH_XTENSA=y | ||||||
| CT_XTENSA_CUSTOM=y | ||||||
| CT_TARGET_VENDOR="${TC}_zephyr" | ||||||
| CT_TARGET_CFLAGS="-ftls-model=local-exec" | ||||||
| CT_CC_GCC_CONFIG_TLS=n | ||||||
| CT_GDB_CROSS_EXTRA_CONFIG_ARRAY="--enable-xtensa-use-target-regnum --disable-xtensa-remote-g-packet" | ||||||
| EOF | ||||||
|
|
||||||
| # Build | ||||||
| ./ct-ng olddefconfig | ||||||
| ./ct-ng build.$(nproc) | ||||||
|
|
||||||
| After this completes, you will find your toolchain in ``~/x-tools`` | ||||||
| and can use it to build by setting it as your Zephyr cross compiler: | ||||||
|
|
||||||
| .. code-block:: shell | ||||||
|
|
||||||
| export CROSS_COMPILE=$HOME/x-tools/xtensa-mtk_mt818x_adsp_zephyr-elf/bin/xtensa-mtk_mt818x_adsp_zephyr-elf- | ||||||
| export ZEPHYR_TOOLCHAIN_VARIANT=cross-compile | ||||||
|
|
||||||
| Closed-source Tools | ||||||
| =================== | ||||||
|
|
||||||
| Zephyr can also be built by the proprietary Cadence xcc and xt-clang | ||||||
| toolchains. Support for those tools is beyond the scope of this | ||||||
| document, but it works similarly, by specifying your toolchain and | ||||||
| core identities and paths via the environment, for example: | ||||||
|
|
||||||
| .. code-block:: shell | ||||||
|
|
||||||
| export XTENSA_TOOLS_ROOT=/path/to/XtDevTools | ||||||
| export XTENSA_CORE=hifi5_7stg_I64D128 | ||||||
| export TOOLCHAIN_VER=RI-2021.6-linux | ||||||
| export ZEPHYR_TOOLCHAIN_VARIANT=xt-clang | ||||||
| export XTENSA_TOOLCHAIN_PATH=$XTENSA_TOOLS_ROOT/install/tools | ||||||
| west build -b mt8186_adsp samples/hello_world | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # Copyright 2024 The ChromiumOS Authors | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| config BOARD_MT8186 | ||
| select SOC_MT8186 |
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,5 @@ | ||||||||
| boards: | ||||||||
| - name: mt8186 | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here and for other boards -- this will help boards show nicely under their commercial name in the board catalog I just linked before.
Suggested change
|
||||||||
| vendor: mediatek | ||||||||
| socs: | ||||||||
| - name: mt8186 | ||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| /* Copyright 2024 The ChromiumOS Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
| #include <mem.h> | ||
|
|
||
| /dts-v1/; | ||
| / { | ||
| #address-cells = <1>; | ||
| #size-cells = <1>; | ||
|
|
||
| sram0: memory@4e100000 { | ||
| device_type = "memory"; | ||
| compatible = "mmio-sram"; | ||
| reg = <0x4e100000 DT_SIZE_K(1024)>; | ||
| }; | ||
|
|
||
| dram0: memory@60000000 { | ||
| device_type = "memory"; | ||
| compatible = "mmio-sram"; | ||
| reg = <0x60000000 DT_SIZE_M(16)>; | ||
| }; | ||
|
|
||
| dram1: memory@61000000 { | ||
| device_type = "memory"; | ||
| compatible = "mmio-sram"; | ||
| reg = <0x61000000 DT_SIZE_K(1024)>; | ||
| }; | ||
|
|
||
| soc { | ||
| #address-cells = <1>; | ||
| #size-cells = <1>; | ||
|
|
||
| core_intc: core_intc@0 { | ||
| compatible = "cdns,xtensa-core-intc"; | ||
| reg = <0 4>; | ||
| interrupt-controller; | ||
| #interrupt-cells = <3>; | ||
| }; | ||
|
|
||
| intc2: intc@10680010 { | ||
| compatible = "mediatek,adsp_intc"; | ||
| interrupt-controller; | ||
| #interrupt-cells = <3>; | ||
| reg = <0x10680010 4>; | ||
| status-reg = <0x10680050>; | ||
| interrupts = <2 0 0>; | ||
| mask = <0x3f>; | ||
| interrupt-parent = <&core_intc>; | ||
| }; | ||
|
|
||
| ostimer64: ostimer64@10683080 { | ||
| compatible = "mediatek,ostimer64"; | ||
| reg = <0x10683080 28>; | ||
| }; | ||
|
|
||
| ostimer0: ostimer@10683000 { | ||
| compatible = "mediatek,ostimer"; | ||
| reg = <0x10683000 16>; | ||
| interrupt-parent = <&core_intc>; | ||
| interrupts = <18 0 0>; | ||
| }; | ||
|
|
||
| mbox0: mbox@10686100 { | ||
| compatible = "mediatek,mbox"; | ||
| reg = <0x10686100 16>; | ||
| interrupt-parent = <&intc2>; | ||
| interrupts = <1 0 0>; | ||
| }; | ||
|
|
||
| mbox1: mbox@10687100 { | ||
| compatible = "mediatek,mbox"; | ||
| reg = <0x10687100 16>; | ||
| interrupt-parent = <&intc2>; | ||
| interrupts = <2 0 0>; | ||
| }; | ||
| }; /* soc */ | ||
|
|
||
| chosen { }; | ||
| aliases { }; | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # Copyright 2024 The ChromiumOS Authors | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| config BOARD_MT8188 | ||
| select SOC_MT8188 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| boards: | ||
| - name: mt8188 | ||
| vendor: mediatek | ||
| socs: | ||
| - name: mt8188 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The side effect of this is that you can turn it off at build time, e.g.
west build, which I think is not quite the correct behavior. Maybe we can leave the other arch to select this kconfig. But for Xtensa, this is done in the SoC layer?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's sort of the point. Xtensa is the first arch to hit this edge case. What's happening here is that we have an architecture which can support nested interrupts, but an instantiation that doesn't actually have a high priority software interrupt set up that irq_offload() can use, so in practice we can't do it. That's likely to be a situation lots of devices could hit in practice.
Basically it was too hard-coded, and needs to be a little softer IMHO. And in any case irq_offload() really only exists for test purposes anyway.