diff --git a/configs/AM62DX/AM62DX_linux_toc.txt b/configs/AM62DX/AM62DX_linux_toc.txt index ca085abdf..d84069088 100644 --- a/configs/AM62DX/AM62DX_linux_toc.txt +++ b/configs/AM62DX/AM62DX_linux_toc.txt @@ -34,7 +34,7 @@ linux/Foundational_Components/U-Boot/BG-Environment-K3 linux/Foundational_Components/U-Boot/BG-Ram-Device-Trees-K3 linux/Foundational_Components/U-Boot/UG-DFU linux/Foundational_Components/U-Boot/UG-Memory-K3 -#linux/Foundational_Components/U-Boot/UG-QSPI +linux/Foundational_Components/U-Boot/UG-QSPI linux/Foundational_Components/U-Boot/UG-UART linux/Foundational_Components/U-Boot/Applications @@ -43,14 +43,14 @@ linux/Foundational_Components/U-Boot/Apps-SPL-Debug-OpenOCD linux/Foundational_Components_Kernel linux/Foundational_Components_Kernel_Drivers linux/Foundational_Components/Kernel/Kernel_Drivers/Audio -#linux/Foundational_Components/Kernel/Kernel_Drivers/EQEP +linux/Foundational_Components/Kernel/Kernel_Drivers/EQEP linux/Foundational_Components/Kernel/Kernel_Drivers/GPIO linux/Foundational_Components/Kernel/Kernel_Drivers/I2C -#linux/Foundational_Components/Kernel/Kernel_Drivers/MCAN +linux/Foundational_Components/Kernel/Kernel_Drivers/MCAN linux/Foundational_Components/Kernel/Kernel_Drivers/Network/CPSW-Ethernet -#linux/Foundational_Components/Kernel/Kernel_Drivers/PWM -#linux/Foundational_Components/Kernel/Kernel_Drivers/SPI -#linux/Foundational_Components/Kernel/Kernel_Drivers/QSPI +linux/Foundational_Components/Kernel/Kernel_Drivers/PWM +linux/Foundational_Components/Kernel/Kernel_Drivers/SPI +linux/Foundational_Components/Kernel/Kernel_Drivers/QSPI linux/Foundational_Components/Kernel/Kernel_Drivers/Storage/MMC-SD #linux/Foundational_Components/Kernel/Kernel_Drivers/Storage/NAND linux/Foundational_Components/Kernel/Kernel_Drivers/UART @@ -62,8 +62,8 @@ linux/Foundational_Components/Kernel/Kernel_Drivers/Watchdog linux/Foundational_Components_Kernel_Users_Guide linux/Foundational_Components_Kernel_LTP-DDT_Validation -#linux/Foundational_Components_Security -#linux/Foundational_Components/System_Security/Auth_boot +linux/Foundational_Components_Security +linux/Foundational_Components/System_Security/Auth_boot linux/Foundational_Components_Filesystem linux/Foundational_Components_Tools linux/Foundational_Components/Tools/Development_Tools @@ -86,5 +86,6 @@ linux/How_to_Guides/Hardware_Setup_with_CCS/AM62Dx_EVM_Hardware_Setup linux/Demo_User_Guides/index_Demos linux/Demo_User_Guides/AM62D_Dsp_Offload_User_Guide +linux/Demo_User_Guides/AM62D_2DFFT_User_Guide linux/Documentation_Tarball diff --git a/source/images/AM62D_2DFFT_DSP_offload_Demo.png b/source/images/AM62D_2DFFT_DSP_offload_Demo.png new file mode 100644 index 000000000..ee34f47b3 Binary files /dev/null and b/source/images/AM62D_2DFFT_DSP_offload_Demo.png differ diff --git a/source/images/AM62D_evm_setup.png b/source/images/AM62D_evm_setup.png index 829f071c9..4d69d4a83 100644 Binary files a/source/images/AM62D_evm_setup.png and b/source/images/AM62D_evm_setup.png differ diff --git a/source/images/fft_2d_signal_chain.png b/source/images/fft_2d_signal_chain.png new file mode 100644 index 000000000..de165ae85 Binary files /dev/null and b/source/images/fft_2d_signal_chain.png differ diff --git a/source/linux/Demo_User_Guides/AM62D_2DFFT_User_Guide.rst b/source/linux/Demo_User_Guides/AM62D_2DFFT_User_Guide.rst new file mode 100644 index 000000000..2ac56e756 --- /dev/null +++ b/source/linux/Demo_User_Guides/AM62D_2DFFT_User_Guide.rst @@ -0,0 +1,256 @@ +.. _AM62D-2dfft-dsp-offload-from-linux-user-guide: + +################################### +AM62D 2D FFT DSP offload from Linux +################################### + +******** +Overview +******** + +This guide describes how to set up, build, and run the 2D Fast Fourier Transform (FFT) +Digital Signal Processing (DSP) offload example by using the Texas Instruments +Audio AM62D evaluation module (EVM). This demo example shows how to offload 2D +Fast Fourier Transform (FFT) computation to the C7x DSP from Linux user-space. +The input is a 128x128 complex matrix, and the output is the 2D FFT transformed +data in the same format. + +Below figure shows how this demo works: + +.. figure:: /images/AM62D_2DFFT_DSP_offload_Demo.png + :height: 450 + :width: 1000 + +- Step 1: Read test data + - The 2D FFT offload example application reads the 128x128 matrix binary + test data from SD card. + +- Step 2: Copy data to shared Direct Memory Access (DMA) Buffer (DDR) + - Copies input data to a shared DMA buffer located in DDR memory. + +- Step 3: Notify DSP using RPMsg (IPC) + - A53 sends a control message via RPMsg (Remote Processor Messaging) to + the C7x core. This message informs the C7x that 2D FFT test input data + is available for processing in the shared DDR buffer. + +- Step 4: C7x reads from shared DMA Buffer into L2 Static Random Access Memory (SRAM) + - The C7x DSP copies the input data from the DMA buffer (DDR) into its local + L2 SRAM for processing. This operation minimizes access latency compared + to reading directly from DDR and performs 2D FFT computation on C7x. + +- Step 5:2D FFT computation on DSP + - Below figure shows 2D FFT computation on C7x. + + .. figure:: /images/fft_2d_signal_chain.png + :height: 140 + :width: 1000 + + - 1D Batched FFT: C7x performs the first 1D FFT on the rows. + - Matrix Transpose: The system transposes the data matrix to convert columns to + rows and vice versa. Because as per design, FFTLIB libraries to perform FFT + on 1D data in rows format. + - 1D Batched FFT: C7x performs the second 1D FFT on the column data. + - During processing, the C7x moves data between L2SRAM (lower latency, lower + capacity) and DDR (higher capacity, higher latency) to use memory efficiently. + +- Step 6: Processed data copied back to shared DMA Buffer (DDR) + - Once DSP processing is complete, the C7x copies the output (2D FFT transformed data) + back into the shared DMA buffer. + - C7x sends a control message via RPMsg to the A53 core, informing it that + processed output data is available in the shared DDR buffer. + +- Step 7: A53 reads back processed data from DMA buffer + - A53 copies the processed data from the shared buffer for validation. + +- Step 8: Validation and Performance Reporting + - The application compares the output data against expected results to verify correctness. + - The system displays performance metrics: + - DSP Load (%) + - Cycle Count + - DDR Throughput (MB/s) + +********************** +Hardware prerequisites +********************** + +- `AM62D-EVM `__ +- Secure Digital (SD) card (minimum 16GB) +- Universal Serial Bus (USB) Type-C 20W power supply (make sure to use type-C to type-C cable) +- USB to Universal asynchronous receiver-transmitter (UART) cable for console access +- PC (Windows or Linux) to flash image onto an SD Card +- Host PC Requirements: + + - Operating system: + + - Windows: |__WINDOWS_SUPPORTED_LONG__| + - Ubuntu: |__LINUX_UBUNTU_VERSION_LONG__| + + - Memory: Minimum 4GB RAM (8GB or more recommended) + - Storage: At least 10GB of free space + +****************** +Software and tools +****************** + +- TI Processor SDK Linux RT (AM62Dx) +- MCU+SDK for AM62Dx +- `C7000-CGT `__ compiler +- `Code Composer Studio `__ +- `TI Clang Compiler Toolchain `__ +- CMake, GCC, make, git, scp, minicom +- `rpmsg-dma library `__ + +********* +EVM setup +********* + +#. Cable Connections + + - The figure below shows some important cable connections, ports and switches. + - Take note of the location of the "BOOTMODE" switch for SD card boot mode. + + .. figure:: /images/AM62D_evm_setup.png + :height: 600 + :width: 1000 + +#. Setup UART Terminal + + - First identify the UART port as enumerated on the host machine. + - Connect the EVM and UART cable to the UART to USB port as shown in cable + connections. + - In Windows, you can use the "Device Manager" to see the detected UART ports: + + - Search "Device Manager" in Windows Search Box in the Windows taskbar. + + - If you do not see any USB serial ports listed in "Device Manager" under + "Ports (COM & LPT)", then make sure you have installed the UART to USB + driver from `FTDI `__. + - For A53 Linux console, select UART boot port (ex: COM34 in below screenshot), + keep other options to default and set 115200 baud rate. + +#. Setup SD card Boot Mode + + - EVM SD card boot mode setting: + + - BOOTMODE [ 8 : 15 ] (SW3) = 0100 0000 + - BOOTMODE [ 0 : 7 ] (SW2) = 1100 0010 + +***************************************** +Steps to validate 2D FFT DSP offload demo +***************************************** + +#. Flash an SD card with the :file:`tisdk-default-image-rt-am62dxx-evm.rootfs.wic.xz` + image and follow the instructions provided at :ref:`Create SD Card ` guide. + +#. Insert the flashed SD card into the `AUDIO-AM62D-EVM `__ + and power on the TI AUDIO-AM62D-EVM. + +#. Make sure the EVM boot mode switches are positioned for SD card boot as + described earlier. + +#. Connect the USB-C cable from the power adapter to one of the two USB-C + ports on the EVM. + +#. The EVM should boot and the booting progress should display in the serial + port console. At the end of booting, the Arago login prompt will appear. + Just enter "root" to log in. + +#. Run the 2D FFT DSP offload demo application from the console: + + .. code-block:: console + + root@am62dxx-evm:~# rpmsg_2dfft_example + +#. The application will execute and display the results: + + .. code-block:: console + + RPMsg based 2D FFT Offload Example + + ***************************************** + ***************************************** + + C7x 2DFFT Test PASSED + C7x Load: 1% + C7x Cycle Count: 327000 + C7x DDR Throughput: 0.801656 MB/s + + ***************************************** + ***************************************** + +.. note:: + + The test reports "PASSED" if the computed 2D FFT output matches the + expected results within tolerance (0.01), otherwise it reports "FAILED". + +Demo output interpretation +========================== + +The demo provides the following performance metrics: + +- **Test Result**: PASSED or FAILED based on output validation +- **C7x Load**: DSP utilization percentage during FFT computation +- **C7x Cycle Count**: Number of DSP cycles consumed for the operation +- **C7x DDR Throughput**: Data transfer rate to/from DDR memory in MB/s + +************************************ +How to build 2D FFT DSP offload demo +************************************ + +Building 2D FFT DSP offload image from yocto +============================================ + +- To build the 2D FFT DSP offload image, refer :ref:`Processor SDK - Building the SDK with Yocto ` + +Building the linux demo binary from sources +=========================================== + +#. The source code for the 2D FFT DSP offload demo is available as part of + the `rpmsg-dma `__. + + .. code-block:: console + + host# git clone https://github.com/TexasInstruments/rpmsg-dma.git -b scarthgap + +#. Download and Install the AM62D Linux SDK from |__SDK_DOWNLOAD_URL__| following + the steps mentioned at :ref:`Download and Install the SDK `. + +#. Prepare the environment for cross compilation. + + .. code-block:: console + + host# source /linux-devkit/environment-setup + +#. Compile the source: + + .. code-block:: console + + [linux-devkit]:> cd + [linux-devkit]:> cmake -S . -B build; cmake --build build + + - This command builds: + + - The example application :file:`rpmsg_2dfft_example` + + - Transfer the generated files to SD card: + + - The example binary :file:`rpmsg_2dfft_example` to :file:`/usr/bin` + - The test input data file :file:`2dfft_input_data.bin` to :file:`/usr/share/2dfft_test_data/` + - The expected output data file :file:`2dfft_expected_output_data.bin` to :file:`/usr/share/2dfft_test_data/` + - The C7 DSP firmware file :file:`fft2d_linux_dsp_offload_example.c75ss0-0.release.strip.out` to :file:`/lib/firmware/` + + - Optional: + + - To build only the library or only the example, use: + + .. code-block:: console + + cmake -S . -B build -DBUILD_LIB=OFF # disables library build + cmake -S . -B build -DBUILD_AUDIO_OFFLOAD_EXAMPLE=OFF # disables audio_offload example build + cmake -S . -B build -DBUILD_2DFFT_OFFLOAD_EXAMPLE=OFF # disables 2dfft_offload example build + +Building the C7 firmware from sources +===================================== + +- Refer to the `MCU+ SDK Documentation `__ +- Refer to the `C7x TISP Linux 2D FFT Offload Example `__ diff --git a/source/linux/Demo_User_Guides/AM62D_Dsp_Offload_User_Guide.rst b/source/linux/Demo_User_Guides/AM62D_Dsp_Offload_User_Guide.rst index a3ef7e67a..94a7c0142 100644 --- a/source/linux/Demo_User_Guides/AM62D_Dsp_Offload_User_Guide.rst +++ b/source/linux/Demo_User_Guides/AM62D_Dsp_Offload_User_Guide.rst @@ -1,10 +1,12 @@ .. _AM62D-dsp-offload-from-linux-user-guide: +######################################### AM62D DSP offload from Linux - User Guide -========================================= +######################################### +******** Overview --------- +******** This guide describes how to set up, build, and run audio DSP offload example by using the Texas Instruments AM62D audio evaluation module (EVM). This demo example shows how to offload 8ch audio filtering to C7x from Linux, input is 8-channel, 256 block size audio data in channel interleaved form. @@ -61,8 +63,9 @@ Below figure shows how this demo works: - ON/OFF control for filters. - DSP/CPU load monitoring. +********************** Hardware Prerequisites ----------------------- +********************** - `AM62D-EVM `__ @@ -92,8 +95,9 @@ Hardware Prerequisites - Storage: At least 10GB of free space +****************** Software and Tools ------------------- +****************** - TI Processor SDK Linux RT (AM62Dx) @@ -109,9 +113,9 @@ Software and Tools - `rpmsg-dma library `__ - +********* EVM Setup ---------- +********* #. Cable Connections @@ -144,9 +148,9 @@ EVM Setup - BOOTMODE [ 0 : 7 ] (SW2) = 1100 0010 - +**************************************** Steps to validate audio DSP offload demo ----------------------------------------- +**************************************** #. Flash an SD card with the :file:`tisdk-default-image-rt-am62dxx-evm.rootfs.wic.xz` image and follow the instructions provided at :ref:`Create SD Card ` guide. @@ -224,17 +228,17 @@ Below is sample snapshot: - For more information on demo application and configuration, refer: `DSP Offload Example `__. - +*********************************** How to build audio DSP offload demo -==================================== +*********************************** Building audio DSP offload image from Yocto ------------------------------------------------ +=========================================== - To build the Audio DSP offload image, refer :ref:`Processor SDK - Building the SDK with Yocto ` Building the Linux demo binary from sources -------------------------------------------- +=========================================== #. The source code for Audio DSP offload demo is available as part of the `rpmsg-dma `__. @@ -278,11 +282,12 @@ Building the Linux demo binary from sources .. code-block:: console cmake -S . -B build -DBUILD_LIB=OFF # disables library build - cmake -S . -B build -DBUILD_EXAMPLE=OFF # disables example build + cmake -S . -B build -DBUILD_AUDIO_OFFLOAD_EXAMPLE=OFF # disables audio_offload example build + cmake -S . -B build -DBUILD_2DFFT_OFFLOAD_EXAMPLE=OFF # disables 2dfft_offload example build Building the c7 firmware from sources --------------------------------------- +===================================== -- Refer to the `MCU+ SDK Documentation `__ -- Refer to the `C7 Demo Firmware `__ +- Refer to the `MCU+ SDK Documentation `__ +- Refer to the `C7 Demo Firmware `__ diff --git a/source/linux/Demo_User_Guides/index_Demos.rst b/source/linux/Demo_User_Guides/index_Demos.rst index b31fd7f5d..593ca1ed3 100644 --- a/source/linux/Demo_User_Guides/index_Demos.rst +++ b/source/linux/Demo_User_Guides/index_Demos.rst @@ -17,6 +17,7 @@ The SDK supports the following Out-Of-Box demo-applications Display_Cluster_User_Guide TI_LVGL_Demo_User_Guide AM62D_Dsp_Offload_User_Guide.rst + AM62D_2DFFT_User_Guide.rst .. ifconfig:: CONFIG_sdk in ('j7_foundational') diff --git a/source/linux/Foundational_Components/Kernel/Kernel_Drivers/Audio.rst b/source/linux/Foundational_Components/Kernel/Kernel_Drivers/Audio.rst index 4b1738767..97b13f7e0 100644 --- a/source/linux/Foundational_Components/Kernel/Kernel_Drivers/Audio.rst +++ b/source/linux/Foundational_Components/Kernel/Kernel_Drivers/Audio.rst @@ -37,13 +37,6 @@ instances to a codec or an HDMI bridge. Generic commands and instructions ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -.. ifconfig:: CONFIG_part_variant in ('AM62DX') - - .. note:: - - Only Audio playback with static DAC confgiuration is supported. - Recording feature is not supported. - Most of the boards have simple audio setup which means we have one sound card with one playback and one capture PCM. To list the available sound cards and PCMs for playback: @@ -584,7 +577,6 @@ Board-specific instructions .. rubric:: User space :name: user-space-9 -.. _hdmi_audio: The hardware defaults are correct for audio playback, the routing is OK and the volume is 'adequate' but in case the volume is not correct: @@ -603,6 +595,112 @@ Board-specific instructions To switch to using HDMI for playback you can refer to: :ref:`hdmi-audio`. +.. ifconfig:: CONFIG_part_variant in ('AM62DX') + + The board uses four **TAD52512 DAC** and two **PCM6240 ADC** connected through + **McASP2 [AXR0,1,3 and 4 for playback, AXR14 for Capture]** for audio. + The board features eight TRS 3.5mm jack, that can be used for + simultaneous 8 channel playback and 4 channel recording. + + The AM62D2-EVM audio subsystem provides comprehensive playback and recording + capabilities through dedicated DACs and ADCs. Use the following command to list + available playback devices: + + .. code-block:: console + + root@am62dxx-evm:/opt/ltp# aplay -l + **** List of PLAYBACK Hardware Devices **** + card 0: AM62D2EVM [AM62D2-EVM], device 0: davinci-mcasp.0-pcmdevice-codec pcmdevice-codec-0 [davinci-mcasp.0-pcmdevice-codec pcmdevice-codec-0] + Subdevices: 1/1 + Subdevice #0: subdevice #0 + card 0: AM62D2EVM [AM62D2-EVM], device 1: davinci-mcasp.0-tad5x1x-hifi-50 tad5x1x-hifi-50-1 [davinci-mcasp.0-tad5x1x-hifi-50 tad5x1x-hifi-50-1] + Subdevices: 1/1 + Subdevice #0: subdevice #0 + card 0: AM62D2EVM [AM62D2-EVM], device 2: davinci-mcasp.0-tad5x1x-hifi-51 tad5x1x-hifi-51-2 [davinci-mcasp.0-tad5x1x-hifi-51 tad5x1x-hifi-51-2] + Subdevices: 1/1 + Subdevice #0: subdevice #0 + card 0: AM62D2EVM [AM62D2-EVM], device 3: davinci-mcasp.0-tad5x1x-hifi-52 tad5x1x-hifi-52-3 [davinci-mcasp.0-tad5x1x-hifi-52 tad5x1x-hifi-52-3] + Subdevices: 1/1 + Subdevice #0: subdevice #0 + card 0: AM62D2EVM [AM62D2-EVM], device 4: davinci-mcasp.0-tad5x1x-hifi-53 tad5x1x-hifi-53-4 [davinci-mcasp.0-tad5x1x-hifi-53 tad5x1x-hifi-53-4] + Subdevices: 1/1 + Subdevice #0: subdevice #0 + + Audio playback is handled by four TAD5212 codec devices. These devices provide + multi-channel audio output capabilities through the davinci-mcasp interface. + Audio recording is managed by two PCM6240 ADC devices. Each PCM6240 ADC + supports four channel audio input with configurable profiles for different + I2C addresses. + + **Playback Subsystem** + + The TAD5212 driver is located in the kernel configuration at: + + .. code-block:: text + + -> Device Drivers + -> Sound card support (SOUND [=y]) + -> Advanced Linux Sound Architecture (SND [=y]) + -> ALSA for SoC audio support (SND_SOC [=y]) + -> CODEC drivers + -> Texas Instruments TAC5X1X family driver based on I2C (SND_SOC_TAC5X1X_I2C [=m]) + + To play audio on the AM62D2-EVM, use the aplay command. + Audio playback is available through connectors J3 and J4. + + Example playback command: + + .. code-block:: console + + root@am62dxx-evm:~# aplay audio_file.wav + + **Recording Subsystem** + + Audio recording is performed through connectors J1 and J2. The two PCM6240 + devices corresponding to different I2C addresses. + + The PCM6240 driver is located in the kernel configuration at: + + .. code-block:: text + + -> Device Drivers + -> Sound card support (SOUND [=y]) + -> Advanced Linux Sound Architecture (SND [=y]) + -> ALSA for SoC audio support (SND_SOC [=y]) + -> CODEC drivers + -> Texas Instruments PCM6240 Family Audio chips based on I2C (SND_SOC_PCM6240 [=m]) + + Choose active device between two PCM6240 ADC devices: + + .. code-block:: text + + Device 0: PCM6240 at I2C address 0x48 (Connector-J2) + Device 1: PCM6240 at I2C address 0x49 (Connector-J1) + + To select Device 0 (I2C address 0x48) as an active device: + + .. code-block:: console + + root@am62dxx-evm:~# amixer cset name='pcm6240-2dev-reg PCM6240 i2c1 Profile id' 0 + numid=17,iface=MIXER,name='pcm6240-2dev-reg PCM6240 i2c1 Profile id' + type=INTEGER,access=rw------,values=1,min=0,max=3,step=0 + values=0 + + To select Device 1 (I2C address 0x49) as an active device: + + .. code-block:: console + + root@am62dxx-evm:~# amixer cset name='pcm6240-2dev-reg PCM6240 i2c1 Profile id' 1 + numid=17,iface=MIXER,name='pcm6240-2dev-reg PCM6240 i2c1 Profile id' + type=INTEGER,access=rw------,values=1,min=0,max=3,step=0 + values=1 + + To record 4-channel audio at 48kHz sample rate with 32-bit depth: + + .. code-block:: console + + root@am62dxx-evm:~# arecord -c 4 -r 48000 -f S32_LE test.wav + Potential issues ^^^^^^^^^^^^^^^^ @@ -622,6 +720,15 @@ Potential issues - Try to use application which uses threads for interacting with ALSA and with the filesystem +.. ifconfig:: CONFIG_part_variant in ('AM62DX') + + Following additional issues were observed for AM62D2-EVM in this release: + + - The device requires a restart if audio is missing or plays through + only one channel during simultaneous playback and recording. + - Starting playback while recording is active introduces a small glitch + in the recording. + Additional Information ^^^^^^^^^^^^^^^^^^^^^^ @@ -677,3 +784,5 @@ Additional Information #. `TAD52512 - High-performance stereo audio DAC `__ + #. `PCM6240 - Automotive, 4-channel audio ADC + `__