How to create my own ESP32 bootloader partition?

Basically you need to create a CSV with the partition information and run a python script to build the binary partition:

python3 gen_esp32part.py partitions.csv binary_partitions.bin

This is the gen_esp32part.py :

#!/usr/bin/env python
#
# ESP32 partition table generation tool
#
# Converts partition tables to/from CSV and binary formats.
#
# See https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/partition-tables.html
# for explanation of partition table structure and uses.
#
# SPDX-FileCopyrightText: 2016-2021 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0

from __future__ import division, print_function, unicode_literals

import argparse
import binascii
import errno
import hashlib
import os
import re
import struct
import sys

MAX_PARTITION_LENGTH = 0xC00   # 3K for partition data (96 entries) leaves 1K in a 4K sector for signature
MD5_PARTITION_BEGIN = b'\xEB\xEB' + b'\xFF' * 14  # The first 2 bytes are like magic numbers for MD5 sum
PARTITION_TABLE_SIZE  = 0x1000  # Size of partition table

MIN_PARTITION_SUBTYPE_APP_OTA = 0x10
NUM_PARTITION_SUBTYPE_APP_OTA = 16

__version__ = '1.2'

APP_TYPE = 0x00
DATA_TYPE = 0x01

TYPES = {
    'app': APP_TYPE,
    'data': DATA_TYPE,
}


def get_ptype_as_int(ptype):
    """ Convert a string which might be numeric or the name of a partition type to an integer """
    try:
        return TYPES[ptype]
    except KeyError:
        try:
            return int(ptype, 0)
        except TypeError:
            return ptype


# Keep this map in sync with esp_partition_subtype_t enum in esp_partition.h
SUBTYPES = {
    APP_TYPE: {
        'factory': 0x00,
        'test': 0x20,
    },
    DATA_TYPE: {
        'ota': 0x00,
        'phy': 0x01,
        'nvs': 0x02,
        'coredump': 0x03,
        'nvs_keys': 0x04,
        'efuse': 0x05,
        'undefined': 0x06,
        'esphttpd': 0x80,
        'fat': 0x81,
        'spiffs': 0x82,
    },
}


def get_subtype_as_int(ptype, subtype):
    """ Convert a string which might be numeric or the name of a partition subtype to an integer """
    try:
        return SUBTYPES[get_ptype_as_int(ptype)][subtype]
    except KeyError:
        try:
            return int(subtype, 0)
        except TypeError:
            return subtype


ALIGNMENT = {
    APP_TYPE: 0x10000,
    DATA_TYPE: 0x1000,
}


def get_alignment_for_type(ptype):
    return ALIGNMENT.get(ptype, ALIGNMENT[DATA_TYPE])


def get_partition_type(ptype):
    if ptype == 'app':
        return APP_TYPE
    if ptype == 'data':
        return DATA_TYPE
    raise InputError('Invalid partition type')


def add_extra_subtypes(csv):
    for line_no in csv:
        try:
            fields = [line.strip() for line in line_no.split(',')]
            for subtype, subtype_values in SUBTYPES.items():
                if (int(fields[2], 16) in subtype_values.values() and subtype == get_partition_type(fields[0])):
                    raise ValueError('Found duplicate value in partition subtype')
            SUBTYPES[TYPES[fields[0]]][fields[1]] = int(fields[2], 16)
        except InputError as err:
            raise InputError('Error parsing custom subtypes: %s' % err)


quiet = False
md5sum = True
secure = False
offset_part_table = 0


def status(msg):
    """ Print status message to stderr """
    if not quiet:
        critical(msg)


def critical(msg):
    """ Print critical message to stderr """
    sys.stderr.write(msg)
    sys.stderr.write('\n')


class PartitionTable(list):
    def __init__(self):
        super(PartitionTable, self).__init__(self)

    @classmethod
    def from_file(cls, f):
        data = f.read()
        data_is_binary = data[0:2] == PartitionDefinition.MAGIC_BYTES
        if data_is_binary:
            status('Parsing binary partition input...')
            return cls.from_binary(data), True

        data = data.decode()
        status('Parsing CSV input...')
        return cls.from_csv(data), False

    @classmethod
    def from_csv(cls, csv_contents):
        res = PartitionTable()
        lines = csv_contents.splitlines()

        def expand_vars(f):
            f = os.path.expandvars(f)
            m = re.match(r'(?<!\\)\$([A-Za-z_][A-Za-z0-9_]*)', f)
            if m:
                raise InputError("unknown variable '%s'" % m.group(1))
            return f

        for line_no in range(len(lines)):
            line = expand_vars(lines[line_no]).strip()
            if line.startswith('#') or len(line) == 0:
                continue
            try:
                res.append(PartitionDefinition.from_csv(line, line_no + 1))
            except InputError as err:
                raise InputError('Error at line %d: %s\nPlease check extra_partition_subtypes.inc file in build/config directory' % (line_no + 1, err))
            except Exception:
                critical('Unexpected error parsing CSV line %d: %s' % (line_no + 1, line))
                raise

        # fix up missing offsets & negative sizes
        last_end = offset_part_table + PARTITION_TABLE_SIZE  # first offset after partition table
        for e in res:
            if e.offset is not None and e.offset < last_end:
                if e == res[0]:
                    raise InputError('CSV Error at line %d: Partitions overlap. Partition sets offset 0x%x. '
                                     'But partition table occupies the whole sector 0x%x. '
                                     'Use a free offset 0x%x or higher.'
                                     % (e.line_no, e.offset, offset_part_table, last_end))
                else:
                    raise InputError('CSV Error at line %d: Partitions overlap. Partition sets offset 0x%x. Previous partition ends 0x%x'
                                     % (e.line_no, e.offset, last_end))
            if e.offset is None:
                pad_to = get_alignment_for_type(e.type)
                if last_end % pad_to != 0:
                    last_end += pad_to - (last_end % pad_to)
                e.offset = last_end
            if e.size < 0:
                e.size = -e.size - e.offset
            last_end = e.offset + e.size

        return res

    def __getitem__(self, item):
        """ Allow partition table access via name as well as by
        numeric index. """
        if isinstance(item, str):
            for x in self:
                if x.name == item:
                    return x
            raise ValueError("No partition entry named '%s'" % item)
        else:
            return super(PartitionTable, self).__getitem__(item)

    def find_by_type(self, ptype, subtype):
        """ Return a partition by type & subtype, returns
        None if not found """
        # convert ptype & subtypes names (if supplied this way) to integer values
        ptype = get_ptype_as_int(ptype)
        subtype = get_subtype_as_int(ptype, subtype)

        for p in self:
            if p.type == ptype and p.subtype == subtype:
                yield p
        return

    def find_by_name(self, name):
        for p in self:
            if p.name == name:
                return p
        return None

    def verify(self):
        # verify each partition individually
        for p in self:
            p.verify()

        # check on duplicate name
        names = [p.name for p in self]
        duplicates = set(n for n in names if names.count(n) > 1)

        # print sorted duplicate partitions by name
        if len(duplicates) != 0:
            critical('A list of partitions that have the same name:')
            for p in sorted(self, key=lambda x:x.name):
                if len(duplicates.intersection([p.name])) != 0:
                    critical('%s' % (p.to_csv()))
            raise InputError('Partition names must be unique')

        # check for overlaps
        last = None
        for p in sorted(self, key=lambda x:x.offset):
            if p.offset < offset_part_table + PARTITION_TABLE_SIZE:
                raise InputError('Partition offset 0x%x is below 0x%x' % (p.offset, offset_part_table + PARTITION_TABLE_SIZE))
            if last is not None and p.offset < last.offset + last.size:
                raise InputError('Partition at 0x%x overlaps 0x%x-0x%x' % (p.offset, last.offset, last.offset + last.size - 1))
            last = p

        # check that otadata should be unique
        otadata_duplicates = [p for p in self if p.type == TYPES['data'] and p.subtype == SUBTYPES[DATA_TYPE]['ota']]
        if len(otadata_duplicates) > 1:
            for p in otadata_duplicates:
                critical('%s' % (p.to_csv()))
            raise InputError('Found multiple otadata partitions. Only one partition can be defined with type="data"(1) and subtype="ota"(0).')

        if len(otadata_duplicates) == 1 and otadata_duplicates[0].size != 0x2000:
            p = otadata_duplicates[0]
            critical('%s' % (p.to_csv()))
            raise InputError('otadata partition must have size = 0x2000')

    def flash_size(self):
        """ Return the size that partitions will occupy in flash
            (ie the offset the last partition ends at)
        """
        try:
            last = sorted(self, reverse=True)[0]
        except IndexError:
            return 0  # empty table!
        return last.offset + last.size

    def verify_size_fits(self, flash_size_bytes: int) -> None:
        """ Check that partition table fits into the given flash size.
            Raises InputError otherwise.
        """
        table_size = self.flash_size()
        if flash_size_bytes < table_size:
            mb = 1024 * 1024
            raise InputError('Partitions tables occupies %.1fMB of flash (%d bytes) which does not fit in configured '
                             "flash size %dMB. Change the flash size in menuconfig under the 'Serial Flasher Config' menu." %
                             (table_size / mb, table_size, flash_size_bytes / mb))

    @classmethod
    def from_binary(cls, b):
        md5 = hashlib.md5()
        result = cls()
        for o in range(0,len(b),32):
            data = b[o:o + 32]
            if len(data) != 32:
                raise InputError('Partition table length must be a multiple of 32 bytes')
            if data == b'\xFF' * 32:
                return result  # got end marker
            if md5sum and data[:2] == MD5_PARTITION_BEGIN[:2]:  # check only the magic number part
                if data[16:] == md5.digest():
                    continue  # the next iteration will check for the end marker
                else:
                    raise InputError("MD5 checksums don't match! (computed: 0x%s, parsed: 0x%s)" % (md5.hexdigest(), binascii.hexlify(data[16:])))
            else:
                md5.update(data)
            result.append(PartitionDefinition.from_binary(data))
        raise InputError('Partition table is missing an end-of-table marker')

    def to_binary(self):
        result = b''.join(e.to_binary() for e in self)
        if md5sum:
            result += MD5_PARTITION_BEGIN + hashlib.md5(result).digest()
        if len(result) >= MAX_PARTITION_LENGTH:
            raise InputError('Binary partition table length (%d) longer than max' % len(result))
        result += b'\xFF' * (MAX_PARTITION_LENGTH - len(result))  # pad the sector, for signing
        return result

    def to_csv(self, simple_formatting=False):
        rows = ['# ESP-IDF Partition Table',
                '# Name, Type, SubType, Offset, Size, Flags']
        rows += [x.to_csv(simple_formatting) for x in self]
        return '\n'.join(rows) + '\n'


class PartitionDefinition(object):
    MAGIC_BYTES = b'\xAA\x50'

    # dictionary maps flag name (as used in CSV flags list, property name)
    # to bit set in flags words in binary format
    FLAGS = {
        'encrypted': 0
    }

    # add subtypes for the 16 OTA slot values ("ota_XX, etc.")
    for ota_slot in range(NUM_PARTITION_SUBTYPE_APP_OTA):
        SUBTYPES[TYPES['app']]['ota_%d' % ota_slot] = MIN_PARTITION_SUBTYPE_APP_OTA + ota_slot

    def __init__(self):
        self.name = ''
        self.type = None
        self.subtype = None
        self.offset = None
        self.size = None
        self.encrypted = False

    @classmethod
    def from_csv(cls, line, line_no):
        """ Parse a line from the CSV """
        line_w_defaults = line + ',,,,'  # lazy way to support default fields
        fields = [f.strip() for f in line_w_defaults.split(',')]

        res = PartitionDefinition()
        res.line_no = line_no
        res.name = fields[0]
        res.type = res.parse_type(fields[1])
        res.subtype = res.parse_subtype(fields[2])
        res.offset = res.parse_address(fields[3])
        res.size = res.parse_address(fields[4])
        if res.size is None:
            raise InputError("Size field can't be empty")

        flags = fields[5].split(':')
        for flag in flags:
            if flag in cls.FLAGS:
                setattr(res, flag, True)
            elif len(flag) > 0:
                raise InputError("CSV flag column contains unknown flag '%s'" % (flag))

        return res

    def __eq__(self, other):
        return self.name == other.name and self.type == other.type \
            and self.subtype == other.subtype and self.offset == other.offset \
            and self.size == other.size

    def __repr__(self):
        def maybe_hex(x):
            return '0x%x' % x if x is not None else 'None'
        return "PartitionDefinition('%s', 0x%x, 0x%x, %s, %s)" % (self.name, self.type, self.subtype or 0,
                                                                  maybe_hex(self.offset), maybe_hex(self.size))

    def __str__(self):
        return "Part '%s' %d/%d @ 0x%x size 0x%x" % (self.name, self.type, self.subtype, self.offset or -1, self.size or -1)

    def __cmp__(self, other):
        return self.offset - other.offset

    def __lt__(self, other):
        return self.offset < other.offset

    def __gt__(self, other):
        return self.offset > other.offset

    def __le__(self, other):
        return self.offset <= other.offset

    def __ge__(self, other):
        return self.offset >= other.offset

    def parse_type(self, strval):
        if strval == '':
            raise InputError("Field 'type' can't be left empty.")
        return parse_int(strval, TYPES)

    def parse_subtype(self, strval):
        if strval == '':
            if self.type == TYPES['app']:
                raise InputError('App partition cannot have an empty subtype')
            return SUBTYPES[DATA_TYPE]['undefined']
        return parse_int(strval, SUBTYPES.get(self.type, {}))

    def parse_address(self, strval):
        if strval == '':
            return None  # PartitionTable will fill in default
        return parse_int(strval)

    def verify(self):
        if self.type is None:
            raise ValidationError(self, 'Type field is not set')
        if self.subtype is None:
            raise ValidationError(self, 'Subtype field is not set')
        if self.offset is None:
            raise ValidationError(self, 'Offset field is not set')
        align = get_alignment_for_type(self.type)
        if self.offset % align:
            raise ValidationError(self, 'Offset 0x%x is not aligned to 0x%x' % (self.offset, align))
        if self.size % align and secure and self.type == APP_TYPE:
            raise ValidationError(self, 'Size 0x%x is not aligned to 0x%x' % (self.size, align))
        if self.size is None:
            raise ValidationError(self, 'Size field is not set')

        if self.name in TYPES and TYPES.get(self.name, '') != self.type:
            critical("WARNING: Partition has name '%s' which is a partition type, but does not match this partition's "
                     'type (0x%x). Mistake in partition table?' % (self.name, self.type))
        all_subtype_names = []
        for names in (t.keys() for t in SUBTYPES.values()):
            all_subtype_names += names
        if self.name in all_subtype_names and SUBTYPES.get(self.type, {}).get(self.name, '') != self.subtype:
            critical("WARNING: Partition has name '%s' which is a partition subtype, but this partition has "
                     'non-matching type 0x%x and subtype 0x%x. Mistake in partition table?' % (self.name, self.type, self.subtype))

    STRUCT_FORMAT = b'<2sBBLL16sL'

    @classmethod
    def from_binary(cls, b):
        if len(b) != 32:
            raise InputError('Partition definition length must be exactly 32 bytes. Got %d bytes.' % len(b))
        res = cls()
        (magic, res.type, res.subtype, res.offset,
         res.size, res.name, flags) = struct.unpack(cls.STRUCT_FORMAT, b)
        if b'\x00' in res.name:  # strip null byte padding from name string
            res.name = res.name[:res.name.index(b'\x00')]
        res.name = res.name.decode()
        if magic != cls.MAGIC_BYTES:
            raise InputError('Invalid magic bytes (%r) for partition definition' % magic)
        for flag,bit in cls.FLAGS.items():
            if flags & (1 << bit):
                setattr(res, flag, True)
                flags &= ~(1 << bit)
        if flags != 0:
            critical('WARNING: Partition definition had unknown flag(s) 0x%08x. Newer binary format?' % flags)
        return res

    def get_flags_list(self):
        return [flag for flag in self.FLAGS.keys() if getattr(self, flag)]

    def to_binary(self):
        flags = sum((1 << self.FLAGS[flag]) for flag in self.get_flags_list())
        return struct.pack(self.STRUCT_FORMAT,
                           self.MAGIC_BYTES,
                           self.type, self.subtype,
                           self.offset, self.size,
                           self.name.encode(),
                           flags)

    def to_csv(self, simple_formatting=False):
        def addr_format(a, include_sizes):
            if not simple_formatting and include_sizes:
                for (val, suffix) in [(0x100000, 'M'), (0x400, 'K')]:
                    if a % val == 0:
                        return '%d%s' % (a // val, suffix)
            return '0x%x' % a

        def lookup_keyword(t, keywords):
            for k,v in keywords.items():
                if simple_formatting is False and t == v:
                    return k
            return '%d' % t

        def generate_text_flags():
            """ colon-delimited list of flags """
            return ':'.join(self.get_flags_list())

        return ','.join([self.name,
                         lookup_keyword(self.type, TYPES),
                         lookup_keyword(self.subtype, SUBTYPES.get(self.type, {})),
                         addr_format(self.offset, False),
                         addr_format(self.size, True),
                         generate_text_flags()])


def parse_int(v, keywords={}):
    """Generic parser for integer fields - int(x,0) with provision for
    k/m/K/M suffixes and 'keyword' value lookup.
    """
    try:
        for letter, multiplier in [('k', 1024), ('m', 1024 * 1024)]:
            if v.lower().endswith(letter):
                return parse_int(v[:-1], keywords) * multiplier
        return int(v, 0)
    except ValueError:
        if len(keywords) == 0:
            raise InputError('Invalid field value %s' % v)
        try:
            return keywords[v.lower()]
        except KeyError:
            raise InputError("Value '%s' is not valid. Known keywords: %s" % (v, ', '.join(keywords)))


def main():
    global quiet
    global md5sum
    global offset_part_table
    global secure
    parser = argparse.ArgumentParser(description='ESP32 partition table utility')

    parser.add_argument('--flash-size', help='Optional flash size limit, checks partition table fits in flash',
                        nargs='?', choices=['1MB', '2MB', '4MB', '8MB', '16MB', '32MB', '64MB', '128MB'])
    parser.add_argument('--disable-md5sum', help='Disable md5 checksum for the partition table', default=False, action='store_true')
    parser.add_argument('--no-verify', help="Don't verify partition table fields", action='store_true')
    parser.add_argument('--verify', '-v', help='Verify partition table fields (deprecated, this behaviour is '
                                               'enabled by default and this flag does nothing.', action='store_true')
    parser.add_argument('--quiet', '-q', help="Don't print non-critical status messages to stderr", action='store_true')
    parser.add_argument('--offset', '-o', help='Set offset partition table', default='0x8000')
    parser.add_argument('--secure', help='Require app partitions to be suitable for secure boot', action='store_true')
    parser.add_argument('--extra-partition-subtypes', help='Extra partition subtype entries', nargs='*')
    parser.add_argument('input', help='Path to CSV or binary file to parse.', type=argparse.FileType('rb'))
    parser.add_argument('output', help='Path to output converted binary or CSV file. Will use stdout if omitted.',
                        nargs='?', default='-')

    args = parser.parse_args()

    quiet = args.quiet
    md5sum = not args.disable_md5sum
    secure = args.secure
    offset_part_table = int(args.offset, 0)
    if args.extra_partition_subtypes:
        add_extra_subtypes(args.extra_partition_subtypes)

    table, input_is_binary = PartitionTable.from_file(args.input)

    if not args.no_verify:
        status('Verifying table...')
        table.verify()

    if args.flash_size:
        size_mb = int(args.flash_size.replace('MB', ''))
        table.verify_size_fits(size_mb * 1024 * 1024)

    # Make sure that the output directory is created
    output_dir = os.path.abspath(os.path.dirname(args.output))

    if not os.path.exists(output_dir):
        try:
            os.makedirs(output_dir)
        except OSError as exc:
            if exc.errno != errno.EEXIST:
                raise

    if input_is_binary:
        output = table.to_csv()
        with sys.stdout if args.output == '-' else open(args.output, 'w') as f:
            f.write(output)
    else:
        output = table.to_binary()
        try:
            stdout_binary = sys.stdout.buffer  # Python 3
        except AttributeError:
            stdout_binary = sys.stdout
        with stdout_binary if args.output == '-' else open(args.output, 'wb') as f:
            f.write(output)


class InputError(RuntimeError):
    def __init__(self, e):
        super(InputError, self).__init__(e)


class ValidationError(InputError):
    def __init__(self, partition, message):
        super(ValidationError, self).__init__(
            'Partition %s invalid: %s' % (partition.name, message))


if __name__ == '__main__':
    try:
        main()
    except InputError as e:
        print(e, file=sys.stderr)
        sys.exit(2)

This is the partitions.csv

# ESP-IDF Partition Table
# Name,   Type, SubType, Offset,   Size, Flags
nvs,      data, nvs,     0x9000,   0x6000,
phy_init, data, phy,     0xf000,   0x1000,
factory,  app,  factory, 0x10000,  0x170000,
storage,  data, nvs,     0x180000, 0x10000,
wifidata, data, nvs,     0x190000, 0x260000

How to fix: esptool.py not found

I was getting this error while compiling NuttX for an ESP32 board:

LD: nuttx
CP: nuttx.hex
MKIMAGE: ESP32 binary

esptool.py not found.  Please run: "pip install esptool"

Run make again to create the nuttx.bin image.
make: *** [tools/Unix.mk:553: nuttx] Error 1

Even after running “pip install esptool” the error still happening.

The solution that worked for me was install it as root:

$ sudo pip install esptool

Bluetooth Audio choking/cutting on Ubuntu 22.04

Since I installed Ubuntu 22.04 I noticed that my Bluetooth Headset audio was really bad, cutting all the time.

Then I searched in many places how to improve it, but nothing worked.

The suggestion to use BT Classic only (ControllerMode = bredr) and increase tha latency from 0ms to 50ms improved it a little bit:

$ pactl list | grep -Pzo '.*bluez_card(.*\n)*'
	Name: bluez_card.90_7A_58_D3_13_9D
	Driver: module-bluez5-device.c
	Owner Module: 30
	Properties:
		device.description = "WH-XB910N"
		device.string = "90:7A:58:D3:13:9D"
		device.api = "bluez"
		device.class = "sound"
		device.bus = "bluetooth"
		device.form_factor = "headset"
		bluez.path = "/org/bluez/hci0/dev_90_7A_58_D3_13_9D"
		bluez.class = "0x240404"
		bluez.alias = "WH-XB910N"
		bluetooth.battery = "60%"
		device.icon_name = "audio-headset-bluetooth"
		device.intended_roles = "phone"
		bluetooth.codec = "mSBC"
	Profiles:
		a2dp_sink: High Fidelity Playback (A2DP Sink) (sinks: 1, sources: 0, priority: 40, available: yes)
		handsfree_head_unit: Handsfree Head Unit (HFP) (sinks: 1, sources: 1, priority: 30, available: yes)
		off: Off (sinks: 0, sources: 0, priority: 0, available: yes)
	Active Profile: handsfree_head_unit
	Ports:
		headset-output: Headset (type: Headset, priority: 0, latency offset: 50000 usec, available)
			Part of profile(s): a2dp_sink, handsfree_head_unit
		headset-input: Headset (type: Headset, priority: 0, latency offset: 0 usec, available)
			Part of profile(s): handsfree_head_unit

Then I changed it to 50ms:

$ pactl set-port-latency-offset bluez_card.90_7A_58_D3_13_9D headset-output 50000

And restarted the Bluetooth:

$ sudo service bluetooth restart

Note: as explained here https://askubuntu.com/questions/475987/a2dp-on-pulseaudio-terrible-choppy-skipping-audio you can use PulseAudio Volume Control to do it, but you need to install it first:

$ sudo apt install pavucontrol

The setup the audio output from your headset to desired latency to increase the buffer audio :

These modification helped to improve it a little bit, but the audio still cutting.

The only fixing was using HFP (Hands-Free Protocol) instead of A2DP at System Settings -> Sound -> Output -> Configuration!

Step by step debugging NuttX on STM32F7 with OpenOCD

First remember to enable debug symbols on your firmware, otherwise GDB will not find the function names:

$ make menuconfig
Build Setup  --->
    Debug Options  --->
        [*] Generate Debug Symbols

Now you can compile normally.

Inside your nuttx/ root directory run OpenOCD (I’m using STLINK-V3SET) passing these parameters:

$ openocd -f interface/stlink.cfg -f target/stm32f7x.cfg

Show you see something like:

Open On-Chip Debugger 0.11.0
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "hla_swd". To override use 'transport select <transport>'.
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : clock speed 2000 kHz
Info : STLINK V3J8M3B5S1 (API v3) VID:PID 0483:374F
Info : Target voltage: 3.211155
Info : stm32f7x.cpu: hardware has 8 breakpoints, 4 watchpoints
Info : starting gdb server for stm32f7x.cpu on 3333
Info : Listening on port 3333 for gdb connections

Open another terminal and enter inside that same nuttx/ root directory and run:

$ gdb-multiarch nuttx

In the “(gdb)” prompt type the command to connect to the OpenOCD server:

(gdb) target remote :3333
Remote debugging using :3333
up_idle () at common/arm_idle.c:63
63	}
(gdb)

You can put a breakpoint at the function you want to stop:

(gdb) b stm32_dmasetup
Breakpoint 1 at 0x8008de4: file chip/stm32_dma.c, line 593.
Note: automatically using hardware breakpoints for read-only addresses.
(gdb)

You can reset the CPU using this command:

(gdb) mon reset halt
Unable to match requested speed 2000 kHz, using 1000 kHz
Unable to match requested speed 2000 kHz, using 1000 kH
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x080001f8 msp: 0x20021ce0
(gdb)

Finally to type “c” to continue the executing from start:

(gdb) c
Continuing.

When your code reach that function you will see something like this:

Breakpoint 1, stm32_dmasetup (handle=0x200201f0 <g_dma+196>, paddr=1073756172, maddr=536871016, ntransfers=2128, scr=scr@entry=11328) at chip/stm32_dma.c:593
593	  dmainfo("paddr: %08" PRIx32 " maddr: %08" PRIx32
(gdb)

And to see the backtrace run “bt”

(gdb) bt
#0  stm32_dmasetup (handle=0x200201f0 <g_dma+196>, paddr=1073756172, 
    maddr=536871016, ntransfers=2128, scr=scr@entry=11328)
    at chip/stm32_dma.c:593
#1  0x08008166 in i2s_txdma_setup (priv=0x2007da20) at chip/stm32_i2s.c:1436
#2  i2s_txdma_setup (priv=priv@entry=0x2007da20) at chip/stm32_i2s.c:1382
#3  0x08008392 in stm32_i2s_send (dev=0x2007da20, apb=<optimized out>, 
    callback=0x80041a1 <cs4344_senddone>, arg=0x2007dcc0, timeout=55)
    at chip/stm32_i2s.c:2140
#4  0x080044d6 in cs4344_sendbuffer (priv=priv@entry=0x2007dcc0)
    at audio/cs4344.c:856
#5  0x0800459a in cs4344_workerthread (pvarg=0x2007dcc0, 
    pvarg@entry=<error reading variable: value has been optimized out>)
    at audio/cs4344.c:1300
#6  0x080063a4 in pthread_startup (entry=<optimized out>, arg=<optimized out>)
    at pthread/pthread_create.c:59
#7  0x08017b28 in pthread_start () at pthread/pthread_create.c:140
#8  0x00000000 in ?? ()
(gdb)

STM32F7 OpenOCD and GDB debugging

(gdb) mon reset halt
Unable to match requested speed 2000 kHz, using 1000 kHz
Unable to match requested speed 2000 kHz, using 1000 kHz
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x080001f8 msp: 0x20021ce0
(gdb) b stm32_dmasetup
Breakpoint 1 at 0x8008de4: file chip/stm32_dma.c, line 593.
Note: automatically using hardware breakpoints for read-only addresses.
(gdb) c
Continuing.

Breakpoint 1, stm32_dmasetup (handle=0x200201f0 <g_dma+196>, paddr=1073756172, maddr=536871016, ntransfers=2128, scr=scr@entry=11328) at chip/stm32_dma.c:593
593	  dmainfo("paddr: %08" PRIx32 " maddr: %08" PRIx32
(gdb) bt
#0  stm32_dmasetup (handle=0x200201f0 <g_dma+196>, paddr=1073756172, 
    maddr=536871016, ntransfers=2128, scr=scr@entry=11328)
    at chip/stm32_dma.c:593
#1  0x08008166 in i2s_txdma_setup (priv=0x2007da20) at chip/stm32_i2s.c:1436
#2  i2s_txdma_setup (priv=priv@entry=0x2007da20) at chip/stm32_i2s.c:1382
#3  0x08008392 in stm32_i2s_send (dev=0x2007da20, apb=<optimized out>, 
    callback=0x80041a1 <cs4344_senddone>, arg=0x2007dcc0, timeout=55)
    at chip/stm32_i2s.c:2140
#4  0x080044d6 in cs4344_sendbuffer (priv=priv@entry=0x2007dcc0)
    at audio/cs4344.c:856
#5  0x0800459a in cs4344_workerthread (pvarg=0x2007dcc0, 
    pvarg@entry=<error reading variable: value has been optimized out>)
    at audio/cs4344.c:1300
#6  0x080063a4 in pthread_startup (entry=<optimized out>, arg=<optimized out>)
    at pthread/pthread_create.c:59
#7  0x08017b28 in pthread_start () at pthread/pthread_create.c:140
#8  0x00000000 in ?? ()
(gdb) s
halted: PC: 0x08008de8
halted: PC: 0x08008dea
halted: PC: 0x08008dec
halted: PC: 0x08008dee
halted: PC: 0x08008df0
halted: PC: 0x08008df2
halted: PC: 0x08008df4
halted: PC: 0x08008df6
halted: PC: 0x08008df8
halted: PC: 0x08008dfa
halted: PC: 0x08008dfe
halted: PC: 0x08008e00
halted: PC: 0x08008e02
halted: PC: 0x080073a8
syslog (priority=priority@entry=6, fmt=0x8020d21 "%s: apb=%p nbytes=%d arg=%p timeout=%ld\n") at syslog/lib_syslog.c:99
99	  va_start(ap, fmt);
(gdb) n
halted: PC: 0x080073aa
halted: PC: 0x080073ac
halted: PC: 0x080073ae
halted: PC: 0x080073b2
halted: PC: 0x080073b4
100	  vsyslog(priority, fmt, ap);
(gdb) 
halted: PC: 0x08007388
101	  va_end(ap);
(gdb) 
halted: PC: 0x080073ba
halted: PC: 0x080073be
halted: PC: 0x080073c0
halted: PC: 0x08008e06
stm32_dmasetup (handle=0x200201f0 <g_dma+196>, paddr=1073756172, maddr=536871016, ntransfers=2128, scr=scr@entry=11328) at chip/stm32_dma.c:622
622	  if ((dmast_getreg(dmast, STM32_DMA_SCR_OFFSET) & DMA_SCR_EN) != 0)
(gdb) n
halted: PC: 0x08008e08
halted: PC: 0x08008e0a
halted: PC: 0x08008e0c
halted: PC: 0x08008e0e
650	  if (dmast->stream < 4)
(gdb) 
halted: PC: 0x08008e10
halted: PC: 0x08008e12
halted: PC: 0x08008e14
halted: PC: 0x08008e18
halted: PC: 0x08008e1c
659	  dmabase_putreg(dmast, regoffset, (DMA_STREAM_MASK << dmast->shift));
(gdb) 
halted: PC: 0x08008e1e
halted: PC: 0x08008e20
halted: PC: 0x08008e22
halted: PC: 0x08008e24
halted: PC: 0x08008e28
halted: PC: 0x08008e2c
halted: PC: 0x08008e2e
245	  putreg32(value, dmast->base + offset);
(gdb) 
halted: PC: 0x08008e30
666	  dmast_putreg(dmast, STM32_DMA_SPAR_OFFSET, paddr);
(gdb) 
halted: PC: 0x08008e32
halted: PC: 0x08008e36
675	  dmast_putreg(dmast, STM32_DMA_SM0AR_OFFSET, maddr);
(gdb) 
halted: PC: 0x08008e38
halted: PC: 0x08008e3a
676	  if (scr & DMA_SCR_DBM)
(gdb) 
halted: PC: 0x08008e42
691	  dmast_putreg(dmast, STM32_DMA_SNDTR_OFFSET, ntransfers);
(gdb) 
halted: PC: 0x08008e44
halted: PC: 0x08008e46
237	  return getreg32(dmast->base + offset);
(gdb) 
halted: PC: 0x08008e4a
700	  regval  = dmast_getreg(dmast, STM32_DMA_SCR_OFFSET);
(gdb) 
halted: PC: 0x08008e4c
halted: PC: 0x08008e4e
halted: PC: 0x08008e50
701	  regval &= ~(DMA_SCR_PL_MASK | DMA_SCR_CHSEL_MASK);
(gdb) 
halted: PC: 0x08008e54
halted: PC: 0x08008e58
halted: PC: 0x08008e5c
703	  regval |= (uint32_t)dmast->channel << DMA_SCR_CHSEL_SHIFT;
(gdb) 
halted: PC: 0x08008e5e
704	  dmast_putreg(dmast, STM32_DMA_SCR_OFFSET, regval);
(gdb) 
halted: PC: 0x08008e60
237	  return getreg32(dmast->base + offset);
(gdb) 
halted: PC: 0x08008e64
728	  regval  = dmast_getreg(dmast, STM32_DMA_SFCR_OFFSET);
(gdb) 
halted: PC: 0x08008e66
halted: PC: 0x08008e6a
halted: PC: 0x08008e6c
729	  regval &= ~(DMA_SFCR_FTH_MASK | DMA_SFCR_FS_MASK | DMA_SFCR_FEIE);
(gdb) 
halted: PC: 0x08008e70
733	      regval |= (DMA_SFCR_FTH_FULL | DMA_SFCR_DMDIS);
(gdb) 
halted: PC: 0x08008e72
halted: PC: 0x08008e76
736	  dmast_putreg(dmast, STM32_DMA_SFCR_OFFSET, regval);
(gdb) 
halted: PC: 0x08008e78
745	  regval  = dmast_getreg(dmast, STM32_DMA_SCR_OFFSET);
(gdb) 
halted: PC: 0x08008e7a
halted: PC: 0x08008e7c
halted: PC: 0x08008e7e
746	  regval &= ~(DMA_SCR_PFCTRL | DMA_SCR_DIR_MASK | DMA_SCR_PINC |
(gdb) 
halted: PC: 0x08008e80
754	  regval |= scr;
(gdb) 
halted: PC: 0x08008e82
halted: PC: 0x08008e84
halted: PC: 0x08008e86
755	  dmast_putreg(dmast, STM32_DMA_SCR_OFFSET, regval);
(gdb) 
halted: PC: 0x08008e88
halted: PC: 0x08008e8a
halted: PC: 0x08008166
i2s_txdma_setup (priv=0x2007da20) at chip/stm32_i2s.c:1441
1441	      if (bfcontainer->timeout > 0)
(gdb) 
halted: PC: 0x08008168
halted: PC: 0x0800816a
halted: PC: 0x0800816c
1452	      sq_addlast((sq_entry_t *)bfcontainer, &priv->tx.act);
(gdb) 
halted: PC: 0x0800816e
halted: PC: 0x08008170
halted: PC: 0x08008174
halted: PC: 0x08008176
halted: PC: 0x08008178
1462	  i2s_txdma_sample(priv, DMA_AFTER_SETUP);
(gdb) 
halted: PC: 0x08008ef4
1466	  stm32_dmastart(priv->tx.dma, i2s_txdma_callback, priv, true);
(gdb) 
halted: PC: 0x0800817e
halted: PC: 0x08008180
halted: PC: 0x08008182
halted: PC: 0x08008184
halted: PC: 0x08008ec0
1468	  i2s_txdma_sample(priv, DMA_AFTER_START);
(gdb) 
halted: PC: 0x0800818c
halted: PC: 0x0800818e
halted: PC: 0x08008ef4
1473	             i2s_getreg(priv, STM32_SPI_CR2_OFFSET) | SPI_CR2_TXDMAEN);
(gdb) 
halted: PC: 0x08008194
halted: PC: 0x08008196
halted: PC: 0x08008198
587	  return regval;
(gdb) 
halted: PC: 0x0800819c
1472	  i2s_putreg(priv, STM32_SPI_CR2_OFFSET,
(gdb) 
halted: PC: 0x0800819e
1477	  if (!notimeout)
(gdb) 
halted: PC: 0x080081a0
1479	      ret = wd_start(&priv->tx.dog, timeout,
(gdb) 
halted: PC: 0x080081a2
halted: PC: 0x080081a4
halted: PC: 0x080081a6
halted: PC: 0x080081aa
halted: PC: 0x08003b88
1488	      if (ret < 0)
(gdb) 
halted: PC: 0x080081b0
halted: PC: 0x080081c8
halted: PC: 0x080081ca
halted: PC: 0x08008392
stm32_i2s_send (dev=0x2007da20, apb=<optimized out>, callback=0x80041a1 <cs4344_senddone>, arg=0x2007dcc0, timeout=55) at chip/stm32_i2s.c:2142
2142	  leave_critical_section(flags);
(gdb) 
halted: PC: 0x08008396
halted: PC: 0x08008398
halted: PC: 0x0800839a
2143	  nxmutex_unlock(&priv->lock);
(gdb) 
halted: PC: 0x0800839c
halted: PC: 0x0800839e
halted: PC: 0x080062d2
2144	  return OK;
(gdb) 
halted: PC: 0x080083a4
halted: PC: 0x080083a6
halted: PC: 0x080044d6
cs4344_sendbuffer (priv=priv@entry=0x2007dcc0) at audio/cs4344.c:857
857	      if (ret < 0)
(gdb) bt
#0  cs4344_sendbuffer (priv=priv@entry=0x2007dcc0) at audio/cs4344.c:857
#1  0x0800459a in cs4344_workerthread (pvarg=0x2007dcc0, 
    pvarg@entry=<error reading variable: value has been optimized out>)
    at audio/cs4344.c:1300
#2  0x080063a4 in pthread_startup (entry=<optimized out>, arg=<optimized out>)
    at pthread/pthread_create.c:59
#3  0x08017b28 in pthread_start () at pthread/pthread_create.c:140
#4  0x00000000 in ?? ()
(gdb) n
halted: PC: 0x080044d8
halted: PC: 0x0800443e
812	         dq_peek(&priv->pendq) != NULL && !priv->paused)
(gdb) 
halted: PC: 0x08004442
halted: PC: 0x08004444
halted: PC: 0x08004446
halted: PC: 0x08004448
halted: PC: 0x0800444a
halted: PC: 0x080044e4
864	  nxmutex_unlock(&priv->pendlock);
(gdb) 
halted: PC: 0x080044e6
halted: PC: 0x080044e8
halted: PC: 0x080044ec
halted: PC: 0x080062d2
nxmutex_unlock (mutex=mutex@entry=0x2007dd08) at misc/lib_mutex.c:57
57	  return mutex->holder == NXMUTEX_RESET;
(gdb) 
halted: PC: 0x080062d4
halted: PC: 0x080062d6
halted: PC: 0x080062d8
halted: PC: 0x080062da
halted: PC: 0x080062dc
240	int nxmutex_unlock(FAR mutex_t *mutex);
(gdb) 
halted: PC: 0x080062e0
halted: PC: 0x080062e2
halted: PC: 0x08002fec
halted: PC: 0x080062e8
halted: PC: 0x080062f0
halted: PC: 0x080062f2
halted: PC: 0x0800459a
cs4344_workerthread (pvarg=0x2007dcc0, pvarg@entry=<error reading variable: value has been optimized out>) at audio/cs4344.c:1305
1305	      msglen = file_mq_receive(&priv->mq, (FAR char *)&msg,
(gdb) s
halted: PC: 0x0800459c
halted: PC: 0x0800459e
halted: PC: 0x080045a2
halted: PC: 0x080045a6
halted: PC: 0x0801789c
file_mq_receive (mq=mq@entry=0x2007dce0, msg=msg@entry=0x2007fdd8 "", msglen=msglen@entry=8, prio=prio@entry=0x2007fdd4) at mqueue/mq_receive.c:75
75	{
(gdb) 
halted: PC: 0x080178a0
halted: PC: 0x080178a2
halted: PC: 0x080178a4
87	  ret = nxmq_verify_receive(mq, msg, msglen);
(gdb) 
halted: PC: 0x080178a6
halted: PC: 0x0801791a
nxmq_verify_receive (mq=mq@entry=0x2007dce0, msg=msg@entry=0x2007fdd8 "", msglen=msglen@entry=8) at mqueue/mq_rcvinternal.c:75
75	  FAR struct inode *inode = mq->f_inode;
(gdb) 
halted: PC: 0x0801791c
78	  if (inode == NULL)
(gdb) 
halted: PC: 0x0801791e
83	  msgq = inode->i_private;
(gdb) 
halted: PC: 0x08017920
87	  if (!msg || !msgq)
(gdb) 
halted: PC: 0x08017922
halted: PC: 0x08017924
92	  if ((mq->f_oflags & O_RDOK) == 0)
(gdb) 
halted: PC: 0x08017926
halted: PC: 0x08017928
halted: PC: 0x0801792a
97	  if (msglen < (size_t)msgq->maxmsgsize)
(gdb) 
halted: PC: 0x0801792e
halted: PC: 0x08017930
halted: PC: 0x08017932
halted: PC: 0x08017934
halted: PC: 0x08017938
halted: PC: 0x080178aa
file_mq_receive (mq=mq@entry=0x2007dce0, msg=msg@entry=0x2007fdd8 "", msglen=msglen@entry=8, prio=prio@entry=0x2007fdd4) at mqueue/mq_receive.c:88
88	  if (ret < 0)
(gdb) 
halted: PC: 0x080178ac
halted: PC: 0x080178ae
615	ssize_t file_mq_receive(FAR struct file *mq, FAR char *msg, size_t msglen,
(gdb) 
file_mq_receive (msglen=8, prio=0x2007fdd4, msg=0x2007fdd8 "", mq=0x2007dce0)
    at mqueue/mq_receive.c:93
93	  msgq = mq->f_inode->i_private;
(gdb) 
halted: PC: 0x080178b0
halted: PC: 0x080178b2
99	  flags = enter_critical_section();
(gdb) 
up_irq_save () at /home/alan/nuttxspace/nuttx/include/arch/armv7-m/irq.h:416
416	  __asm__ __volatile__
(gdb) n
halted: PC: 0x080178b6
halted: PC: 0x080178b8
file_mq_receive (msglen=8, prio=0x2007fdd4, msg=0x2007fdd8 "", mq=0x2007dce0) at mqueue/mq_receive.c:103
103	  ret = nxmq_wait_receive(msgq, mq->f_oflags, &mqmsg);
(gdb) 
halted: PC: 0x080178ba
halted: PC: 0x080178bc
halted: PC: 0x080178be
halted: PC: 0x08017948
112	  if (ret == OK)
(gdb) p /x ret
$1 = 0x0
(gdb) n
halted: PC: 0x080178c4
114	      ret = nxmq_do_receive(msgq, mqmsg, msg, prio);
(gdb) 
halted: PC: 0x080178c6
halted: PC: 0x080178c8
halted: PC: 0x080178ca
halted: PC: 0x080178cc
halted: PC: 0x080179e8
117	  leave_critical_section(flags);
(gdb) 
halted: PC: 0x080178d4
halted: PC: 0x080178d6
halted: PC: 0x080178d8
file_mq_receive (mq=mq@entry=0x2007dce0, msg=msg@entry=0x2007fdd8 "\b", msglen=msglen@entry=8, prio=prio@entry=0x2007fdd4) at mqueue/mq_receive.c:119
119	  return ret;
(gdb) 
halted: PC: 0x080178da
halted: PC: 0x080045aa
halted: PC: 0x080045ac
halted: PC: 0x080045ae
cs4344_workerthread (pvarg=0x2007dcc0, pvarg@entry=<error reading variable: value has been optimized out>) at audio/cs4344.c:1310
1310	      if (msglen < sizeof(struct audio_msg_s))
(gdb) 
halted: PC: 0x080045bc
1318	      switch (msg.msg_id)
(gdb) 
halted: PC: 0x080045c0
halted: PC: 0x080045c2
halted: PC: 0x080045c4
halted: PC: 0x080045c6
halted: PC: 0x08004604
1351	            audinfo("AUDIO_MSG_COMPLETE\n");
(gdb) 
halted: PC: 0x08004606
halted: PC: 0x08004608
halted: PC: 0x0800460a
halted: PC: 0x080073a8
1352	            cs4344_returnbuffers(priv);
(gdb) 
halted: PC: 0x08004610
halted: PC: 0x08004340
1353	            break;
(gdb) 
halted: PC: 0x080045ec
1283	  while (priv->running || priv->inflight > 0)
(gdb) 
halted: PC: 0x080045f0
halted: PC: 0x080045f2
halted: PC: 0x0800452e
1290	      if (priv->terminating && priv->inflight <= 0)
(gdb) 
halted: PC: 0x08004532
halted: PC: 0x08004534
halted: PC: 0x08004538
halted: PC: 0x0800453a
1363	  cs4344_reset(priv);
(gdb) bt
#0  cs4344_workerthread (pvarg=0x2007dcc0, 
    pvarg@entry=<error reading variable: value has been optimized out>)
    at audio/cs4344.c:1363
#1  0x080063a4 in pthread_startup (entry=<optimized out>, arg=<optimized out>)
    at pthread/pthread_create.c:59
#2  0x08017b28 in pthread_start () at pthread/pthread_create.c:140
#3  0x00000000 in ?? ()
(gdb) n
halted: PC: 0x0800453e
halted: PC: 0x08004540
halted: PC: 0x08004544
halted: PC: 0x08004048
1367	  nxmutex_lock(&priv->pendlock);
(gdb) 
halted: PC: 0x0800454a
halted: PC: 0x080062ae
1368	  while ((apb = (FAR struct ap_buffer_s *)dq_remfirst(&priv->pendq)) != NULL)
(gdb) 
halted: PC: 0x08004550
halted: PC: 0x0800644a
halted: PC: 0x08004556
halted: PC: 0x08004558
halted: PC: 0x0800455a
1383	  nxmutex_unlock(&priv->pendlock);
(gdb) 
halted: PC: 0x0800455c
halted: PC: 0x080062d2
1387	  cs4344_returnbuffers(priv);
(gdb) 
halted: PC: 0x08004562
halted: PC: 0x08004340
1391	  file_mq_close(&priv->mq);
(gdb) 
halted: PC: 0x0800456a
halted: PC: 0x08010778
1392	  file_mq_unlink(priv->mqname);
(gdb) 
halted: PC: 0x08004572
halted: PC: 0x08010780
1399	  priv->dev.upper(priv->dev.priv, AUDIO_CALLBACK_COMPLETE, NULL, OK);
(gdb) 
halted: PC: 0x08004578
halted: PC: 0x0800457a
halted: PC: 0x0800457c
halted: PC: 0x0800457e
halted: PC: 0x08004580
halted: PC: 0x08016b0e
1402	  audinfo("Exit\n");
(gdb) b i2s_txdma_sampledone
Breakpoint 2 at 0x80081fe: file chip/stm32_i2s.c, line 879.
(gdb) mon reset halt
Unable to match requested speed 2000 kHz, using 1000 kHz
Unable to match requested speed 2000 kHz, using 1000 kHz
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x080001f8 msp: 0x20021ce0
(gdb) c
Continuing.

Breakpoint 1, stm32_dmasetup (handle=0x200201f0 <g_dma+196>, paddr=1073756172, maddr=536871016, ntransfers=2128, scr=scr@entry=11328) at chip/stm32_dma.c:593
593	  dmainfo("paddr: %08" PRIx32 " maddr: %08" PRIx32
(gdb) c
Continuing.
halted: PC: 0x08008de8

Breakpoint 2, i2s_txdma_sampledone (result=-110, priv=0x2007da20) at chip/stm32_i2s.c:879
879	  i2sinfo("result: %d\n", result);
(gdb) bt
#0  i2s_txdma_sampledone (result=-110, priv=0x2007da20) at chip/stm32_i2s.c:879
#1  i2s_tx_worker (arg=0x2007da20) at chip/stm32_i2s.c:1550
#2  0x080025dc in work_thread (argc=<optimized out>, argv=<optimized out>)
    at wqueue/kwork_thread.c:186
#3  0x080022a4 in nxtask_start () at task/task_start.c:107
#4  0x00000000 in ?? ()
(gdb)

From minicom nsh side:

A�DE                                                                            
board_cs4344_initialize: minor 1                                                
stm32_i2sbus_initialize: port: 2                                                
i2s_dump_regs: I2S2: After initialization                                       
i2s_dump_regs:     CR1:0000    CR2:0700     SR:0002      DR:0000                
i2s_dump_regs:     I2SCFGR:0000    I2SPR:0002                                   
i2s_dump_regs:     PLLI2SCFGR:44013000                                          
cs4344_reset: WARNING: MCLK could not be set on lower half                      
i2s_mckdivider: Entry                                                           
i2s_dump_regs: I2S2: After i2s_mckdivider                                       
i2s_dump_regs:     CR1:0000    CR2:0700     SR:0002      DR:0000                
i2s_dump_regs:     I2SCFGR:0e00    I2SPR:020d                                   
i2s_dump_regs:     PLLI2SCFGR:20003540                                          
cs4344_setbitrate: sample rate=16000 nchannels=1 bpsamp=16                      
audio_register: Registering /dev/audio/pcm1                                     
                                                                                
NuttShell (NSH) NuttX-12.5.1                                                    
nsh> upload                                                                     
Registering romdisk at /dev/ram0                                                
Mounting ROMFS filesystem at target=/data with source=/dev/ram0                 
nsh> nxplayer                                                                   
NxPlayer version 1.05                                                           
h for commands, q to exit                                                       
                                                                                
nxplayer> play /data/yes.wav                                                    
nxplayer_playinternal: ==============================                           
nxplayer_playinternal: Playing file /data/yes.wav                               
nxplayer_playinternal: ==============================                           
audio_open: crefs: 0                                                            
audio_ioctl: cmd: 4097 arg: 537390872                                           
audio_ioctl: AUDIOIOC_GETCAPS: Device=0                                         
cs4344_getcaps: type=0 ac_type=0                                                
audio_ioctl: cmd: 4098 arg: 0                                                   
audio_ioctl: AUDIOIOC_RESERVE                                                   
pcm_reserve: Defer to lower reserve                                             
audio_ioctl: cmd: 4097 arg: 537390872                                           
audio_ioctl: AUDIOIOC_GETCAPS: Device=2                                         
cs4344_getcaps: type=2 ac_type=2                                                
audio_ioctl: cmd: 4106 arg: 537390840                                           
audio_ioctl: Forwarding unrecognized cmd: 4106 arg: 537390840                   
pcm_ioctl: Defer to lower ioctl, cmd=4106 arg=537390840                         
cs4344_ioctl: Ignored                                                           
audio_ioctl: cmd: 4110 arg: 4                                                   
audio_ioctl: AUDIOIOC_REGISTERMQ                                                
nxplayer_playthread: Entry                                                      
audio_ioctl: cmd: 4106 arg: 537393600                                           
audio_ioctl: Forwarding unrecognized cmd: 4106 arg: 537393600                   
pcm_ioctl: Defer to lower ioctl, cmd=4106 arg=537393600                         
cs4344_ioctl: Ignored                                                           
audio_ioctl: cmd: 4107 arg: 537393616                                           
audio_ioctl: AUDIOIOC_ALLOCBUFFER                                               
audio_ioctl: cmd: 4107 arg: 537393616                                           
audio_ioctl: AUDIOIOC_ALLOCBUFFER                                               
nxplayer_fill_common: Closing audio file, nbytes=4300 errcode=25                
audio_ioctl: cmd: 4109 arg: 537393568                                           
audio_ioctl: AUDIOIOC_ENQUEUEBUFFER                                             
pcm_enqueuebuffer: Received buffer 0x20000010, streaming=0                      
pcm_enqueuebuffer: curbyte=0 nbytes=4300 nmaxbytes=8192 bytesleft=4300          
pcm_dump: Wave file header                                                      
pcm_dump:   Header Chunk:                                                       
pcm_dump:     Chunk ID:        0x46464952                                       
pcm_dump:     Chunk Size:      4292                                             
pcm_dump:     Format:          0x45564157                                       
pcm_dump:   Format Chunk:                                                       
pcm_dump:     Chunk ID:        0x20746d66                                       
pcm_dump:     Chunk Size:      16                                               
pcm_dump:     Audio Format:    0x0001                                           
pcm_dump:     Num. Channels:   1                                                
pcm_dump:     Sample Rate:     8000                                             
pcm_dump:     Byte Rate:       16000                                            
pcm_dump:     Block Align:     2                                                
pcm_dump:     Bits Per Sample: 16                                               
pcm_dump:   Data Chunk:                                                         
pcm_dump:     Chunk ID:        0x61746164                                       
pcm_dump:     Chunk Size:      4256                                             
cs4344_configure: ac_type: 2                                                    
cs4344_configure:   AUDIO_TYPE_OUTPUT:                                          
cs4344_configure:     Number of channels: 1                                     
cs4344_configure:     Sample rate:        8000                                  
cs4344_configure:     Sample width:       16                                    
cs4344_configure: ERROR: Unsupported combination of sample rate anddata width   
stm32_i2s_txdatawidth: Data width bits of tx = 16                               
i2s_mckdivider: Entry                                                           
i2s_dump_regs: I2S2: After i2s_mckdivider                                       
i2s_dump_regs:     CR1:0000    CR2:0700     SR:0002      DR:0000                
i2s_dump_regs:     I2SCFGR:0e00    I2SPR:021a                                   
i2s_dump_regs:     PLLI2SCFGR:20003540                                          
cs4344_setbitrate: sample rate=8000 nchannels=1 bpsamp=16                       
pcm_enqueuebuffer: Begin streaming: apb=0x20000010 curbyte=44 nbytes=4300       
pcm_enqueuebuffer: Pass to lower enqueuebuffer: apb=0x20000010 curbyte=44 nbyte0
cs4344_enqueuebuffer: Enqueueing: apb=0x20000010 curbyte=44 nbytes=4300 flags=08
nxplayer_playthread: 2 buffers queued, running=1 streaming=0                    
audio_ioctl: cmd: 4102 arg: 0                                                   
audio_ioctl: AUDIOIOC_START                                                     
pcm_start: Defer to lower start                                                 
cs4344_start: Entry                                                             
cs4344_start: Starting worker thread                                            
cs4344_workerthread: Entry                                                      
cs4344_sendbuffer: Sending apb=0x20000010, size=4300 inflight=0                 
stm32_i2s_send: apb=0x20000010 nbytes=4256 arg=0x2007dcc0 timeout=55            
stm32_dmasetup: paddr: 4000380c maddr: 20000068 ntransfers: 2128 scr: 00002c40  
cs4344_start: Created worker thread                                             
nxplayer_playthread: Playing...                                                 
nxplayer> i2s_tx_worker: tx.act.head=0 tx.done.head=0x2007dca4 

More I2S debugging

nsh> nxplayer                                                                                                                                                                            
NxPlayer version 1.05                                                                                                                                                                    
h for commands, q to exit                                                                                                                                                                
                                                                                                                                                                                         
nxplayer> play /data/yes.wav                                                                                                                                                             
nxplayer_playinternal: ==============================                                                                                                                                    
nxplayer_playinternal: Playing file /data/yes.wav                                                                                                                                        
nxplayer_playinternal: ==============================                                                                                                                                    
audio_open: crefs: 0                                                                                                                                                                     
audio_ioctl: cmd: 4097 arg: 537390872                                                                                                                                                    
audio_ioctl: AUDIOIOC_GETCAPS: Device=0                                                                                                                                                  
cs4344_getcaps: type=0 ac_type=0                                                                                                                                                         
audio_ioctl: cmd: 4098 arg: 0                                                                                                                                                            
audio_ioctl: AUDIOIOC_RESERVE                                                                                                                                                            
pcm_reserve: Defer to lower reserve                                                                                                                                                      
audio_ioctl: cmd: 4097 arg: 537390872                                                                                                                                                    
audio_ioctl: AUDIOIOC_GETCAPS: Device=2                                                                                                                                                  
cs4344_getcaps: type=2 ac_type=2                                                                                                                                                         
audio_ioctl: cmd: 4106 arg: 537390840                                                                                                                                                    
audio_ioctl: Forwarding unrecognized cmd: 4106 arg: 537390840                                                                                                                            
pcm_ioctl: Defer to lower ioctl, cmd=4106 arg=537390840                                                                                                                                  
cs4344_ioctl: Ignored                                                                                                                                                                    
audio_ioctl: cmd: 4110 arg: 4                                                                                                                                                            
audio_ioctl: AUDIOIOC_REGISTERMQ                                                                                                                                                         
nxplayer_playthread: Entry                                                                                                                                                               
audio_ioctl: cmd: 4106 arg: 537393600                                                                                                                                                    
audio_ioctl: Forwarding unrecognized cmd: 4106 arg: 537393600                                                                                                                            
pcm_ioctl: Defer to lower ioctl, cmd=4106 arg=537393600                                                                                                                                  
cs4344_ioctl: Ignored                                                                                                                                                                    
audio_ioctl: cmd: 4107 arg: 537393616                                                                                                                                                    
audio_ioctl: AUDIOIOC_ALLOCBUFFER                                                                                                                                                        
audio_ioctl: cmd: 4107 arg: 537393616                                                                                                                                                    
audio_ioctl: AUDIOIOC_ALLOCBUFFER                                                                                                                                                        
nxplayer_fill_common: Closing audio file, nbytes=4300 errcode=25                                                                                                                         
audio_ioctl: cmd: 4109 arg: 537393568                                                                                                                                                    
audio_ioctl: AUDIOIOC_ENQUEUEBUFFER                                                                                                                                                      
pcm_enqueuebuffer: Received buffer 0x20000010, streaming=0                                                                                                                               
pcm_enqueuebuffer: curbyte=0 nbytes=4300 nmaxbytes=8192 bytesleft=4300                                                                                                                   
pcm_dump: Wave file header                                                                                                                                                               
pcm_dump:   Header Chunk:                                                                                                                                                                
pcm_dump:     Chunk ID:        0x46464952                                                                                                                                                
pcm_dump:     Chunk Size:      4292                                                                                                                                                      
pcm_dump:     Format:          0x45564157                                                                                                                                                
pcm_dump:   Format Chunk:                                                                                                                                                                
pcm_dump:     Chunk ID:        0x20746d66                                                                                                                                                
pcm_dump:     Chunk Size:      16                                                                                                                                                        
pcm_dump:     Audio Format:    0x0001                                                                                                                                                    
pcm_dump:     Num. Channels:   1                                                                                                                                                         
pcm_dump:     Sample Rate:     8000                                                                                                                                                      
pcm_dump:     Byte Rate:       16000                                                                                                                                                     
pcm_dump:     Block Align:     2                                                                                                                                                         
pcm_dump:     Bits Per Sample: 16                                                                                                                                                        
pcm_dump:   Data Chunk:                                                                                                                                                                  
pcm_dump:     Chunk ID:        0x61746164                                                                                                                                                
pcm_dump:     Chunk Size:      4256                                                                                                                                                      
cs4344_configure: ac_type: 2                                                                                                                                                             
cs4344_configure:   AUDIO_TYPE_OUTPUT:                                                                                                                                                   
cs4344_configure:     Number of channels: 1                                                                                                                                              
cs4344_configure:     Sample rate:        8000                                                                                                                                           
cs4344_configure:     Sample width:       16                                                                                                                                             
cs4344_configure: ERROR: Unsupported combination of sample rate anddata width                                                                                                            
stm32_i2s_txdatawidth: Data width bits of tx = 16                                                                                                                                        
i2s_mckdivider: Entry                                                                                                                                                                    
i2s_dump_regs: I2S2: After i2s_mckdivider                                                                                                                                                
i2s_dump_regs:     CR1:0000    CR2:0700     SR:0002      DR:0000                                                                                                                         
i2s_dump_regs:     I2SCFGR:0e00    I2SPR:021a                                                                                                                                            
i2s_dump_regs:     PLLI2SCFGR:20003540                                                                                                                                                   
cs4344_setbitrate: sample rate=8000 nchannels=1 bpsamp=16                                                                                                                                
pcm_enqueuebuffer: Begin streaming: apb=0x20000010 curbyte=44 nbytes=4300                                                                                                                
pcm_enqueuebuffer: Pass to lower enqueuebuffer: apb=0x20000010 curbyte=44 nbytes=4300                                                                                                    
cs4344_enqueuebuffer: Enqueueing: apb=0x20000010 curbyte=44 nbytes=4300 flags=0008                                                                                                       
nxplayer_playthread: 2 buffers queued, running=1 streaming=0                                                                                                                             
audio_ioctl: cmd: 4102 arg: 0                                                                                                                                                            
audio_ioctl: AUDIOIOC_START                                                                                                                                                              
pcm_start: Defer to lower start                                                                                                                                                          
cs4344_start: Entry                                                                                                                                                                      
cs4344_start: Starting worker thread                                                                                                                                                     
cs4344_workerthread: Entry                                                                                                                                                               
cs4344_sendbuffer: Sending apb=0x20000010, size=4300 inflight=0                                                                                                                          
stm32_i2s_send: apb=0x20000010 nbytes=4256 arg=0x2007dcc0 timeout=55                                                                                                                     
stm32_dmasetup: paddr: 4000380c maddr: 20000068 ntransfers: 2128 scr: 00002c40                                                                                                           
cs4344_start: Created worker thread                                                                                                                                                      
nxplayer_playthread: Playing...                                                                                                                                                          
nxplayer> i2s_tx_worker: tx.act.head=0 tx.done.head=0x2007dca4                                                                                                                           
i2s_txdma_sampledone: result: -110                                                                                                                                                       
stm32_dmadump: DMA Registers: TX: Initial Registers                                                                                                                                      
stm32_dmadump:    LISR[40026000]: 00000000                                                                                                                                               
stm32_dmadump:    HISR[40026004]: 00000000                                                                                                                                               
stm32_dmadump:     SCR[400260b8]: 00000000                                                                                                                                               
stm32_dmadump:   SNDTR[400260bc]: 00000000                                                                                                                                               
stm32_dmadump:    SPAR[400260c0]: 00000000                                                                                                                                               
stm32_dmadump:   SM0AR[400260c4]: 00000000                                                                                                                                               
stm32_dmadump:   SM1AR[400260c8]: 00000000                                                                                                                                               
stm32_dmadump:    SFCR[400260cc]: 00000021                                                                                                                                               
stm32_dmadump: DMA Registers: TX: After DMA Setup                                                                                                                                        
stm32_dmadump:    LISR[40026000]: 00000000                                                                                                                                               
stm32_dmadump:    HISR[40026004]: 00000000                                                                                                                                               
stm32_dmadump:     SCR[400260b8]: 00002c40                                                                                                                                               
stm32_dmadump:   SNDTR[400260bc]: 00000850                                                                                                                                               
stm32_dmadump:    SPAR[400260c0]: 4000380c                                                                                                                                               
stm32_dmadump:   SM0AR[400260c4]: 20000068                                                                                                                                               
stm32_dmadump:   SM1AR[400260c8]: 00000000                                                                                                                                               
stm32_dmadump:    SFCR[400260cc]: 00000027                                                                                                                                               
stm32_dmadump: DMA Registers: TX: After DMA Start                                                                                                                                        
stm32_dmadump:    LISR[40026000]: 00000000                                                                                                                                               
stm32_dmadump:    HISR[40026004]: 00000000                                                                                                                                               
stm32_dmadump:     SCR[400260b8]: 00002c4d                                                                                                                                               
stm32_dmadump:   SNDTR[400260bc]: 00000850                                                                                                                                               
stm32_dmadump:    SPAR[400260c0]: 4000380c                                                                                                                                               
stm32_dmadump:   SM0AR[400260c4]: 20000068                                                                                                                                               
stm32_dmadump:   SM1AR[400260c8]: 00000000                                                                                                                                               
stm32_dmadump:    SFCR[400260cc]: 0000002f                                                                                                                                               
stm32_dmadump: DMA Registers: TX: At DMA timeout                                                                                                                                         
stm32_dmadump:    LISR[40026000]: 00000000                                                                                                                                               
stm32_dmadump:    HISR[40026004]: 00000000                                                                                                                                               
stm32_dmadump:     SCR[400260b8]: 00002c4d                                                                                                                                               
stm32_dmadump:   SNDTR[400260bc]: 00000850                                                                                                                                               
stm32_dmadump:    SPAR[400260c0]: 4000380c                                                                                                                                               
stm32_dmadump:   SM0AR[400260c4]: 20000068                                                                                                                                               
stm32_dmadump:   SM1AR[400260c8]: 00000000                                                                                                                                               
stm32_dmadump:    SFCR[400260cc]: 0000002f                                                                                                                                               
stm32_dmadump: DMA Registers: TX: At End-of-Transfer                                                                                                                                     
stm32_dmadump:    LISR[40026000]: 00000000                                                                                                                                               
stm32_dmadump:    HISR[40026004]: 00000000                                                                                                                                               
stm32_dmadump:     SCR[400260b8]: 00002c40                                                                                                                                               
stm32_dmadump:   SNDTR[400260bc]: 00000850                                                                                                                                               
stm32_dmadump:    SPAR[400260c0]: 4000380c                                                                                                                                               
stm32_dmadump:   SM0AR[400260c4]: 20000068                                                                                                                                               
stm32_dmadump:   SM1AR[400260c8]: 00000000                                                                                                                                               
stm32_dmadump:    SFCR[400260cc]: 00000027                                                                                                                                               
i2s_dump_regs: I2S2: TX: At End-of-Transfer                                                                                                                                              
i2s_dump_regs:     CR1:0000    CR2:0702     SR:0002      DR:0000                                                                                                                         
i2s_dump_regs:     I2SCFGR:0e00    I2SPR:021a                                                                                                                                            
i2s_dump_regs:     PLLI2SCFGR:20003540                                                                                                                                                   
cs4344_senddone: apb=0x20000010 inflight=1 result=-110                                                                                                                                   
cs4344_workerthread: AUDIO_MSG_COMPLETE                                                                                                                                                  
cs4344_returnbuffers: Returning: apb=0x20000010 curbyte=44 nbytes=4300 flags=0009                                                                                                        
cs4344_returnbuffers: Terminating                                                                                                                                                        
audio_callback: Entry                                                                                                                                                                    
audio_dequeuebuffer: Entry                                                                                                                                                               
cs4344_reset: WARNING: MCLK could not be set on lower half                                                                                                                               
i2s_mckdivider: Entry                                                                                                                                                                    
i2s_dump_regs: I2S2: After i2s_mckdivider                                                                                                                                                
i2s_dump_regs:     CR1:0000    CR2:0702     SR:0002      DR:0000                                                                                                                         
i2s_dump_regs:     I2SCFGR:0e00    I2SPR:020d                                                                                                                                            
i2s_dump_regs:     PLLI2SCFGR:20003540                                                                                                                                                   
cs4344_setbitrate: sample rate=16000 nchannels=1 bpsamp=16                                                                                                                               
audio_callback: Entry                                                                                                                                                                    
audio_complete: Entry                                                                                                                                                                    
cs4344_workerthread: Exit                                                                                                                                                                
_assert: Current Version: NuttX  12.5.1 675153a502-dirty Apr 21 2024 18:38:16 arm                                                                                                        
_assert: Assertion failed panic: at file: :0 task: �q process: nxplayer 0x25d3bbc9                                                                                                       
up_dump_register: R0: 00000000 R1: 00000000 R2: ffffffff  R3: 00000000                                                                                                                   
up_dump_register: R4: 00000000 R5: 2007fa18 R6: fffffffd  FP: 00000000                                                                                                                   
up_dump_register: R8: 00000000 SB: 00000000 SL: 00000000 R11: 00000000                                                                                                                   
up_dump_register: IP: 08016811 SP: 2007fda8 LR: 08002b01  PC: 08002b00                                                                                                                   
up_dump_register: xPSR: 61000000 PRIMASK: 00000000 CONTROL: 00000000                                                                                                                     
up_dump_register: EXC_RETURN: ffffffe9                                                                                                                                                   
dump_stack: User Stack:                                                                                                                                                                  
dump_stack:   base: 0x801f8d9                                                                                                                                                            
dump_stack:   size: 537394384                                                                                                                                                            
dump_stack:     sp: 0x2007fda8                                                                                                                                                           
stack_dump: 0x2007fd88: 00000000 3f800000 3f000000 3c83126f 4665d400 00003975 80000010 00000000                                                                                          
stack_dump: 0x2007fda8: fffffffd 00000000 ffffffff 00000000 2007fa18 00000000 00000000 00000000                                                                                          
stack_dump: 0x2007fdc8: 00000000 00000000 00000000 08017bf3 ffffffff ffffffff 2007fce0 00000000                                                                                          
stack_dump: 0x2007fde8: 00000000 08006323 0000000a 080062f5 080062e9 08017a49 00000000 00000000                                                                                          
stack_dump: 0x2007fe08: d4798546 000001f0 20021d68 20021d58 01ab9e80 aa572601 9bfbef83 2c75b8ed                                                                                          
stack_dump: 0x2007fe28: d57ea463 753eacde 98eb19a7 0534183e 0dbd934f dc110850 2eaecc36 60542e0a                                                                                          
stack_dump: 0x2007fe48: 9c02e44a 382b0479 7cf68387 3d42240b 6d2b5b78 0a791433 27938d88 8ba5e5e4                                                                                          
stack_dump: 0x2007fe68: fe1a709d af5cd05d d7a1cb33 331116b3 fcfcd873 ef9fe37a b863c749 46812f2a                                                                                          
stack_dump: 0x2007fe88: 24caa347 9f490180 7c4f971e 52d3e9d8 646caae6 fe93632d 9fdfe969 ee710855                                                                                          
stack_dump: 0x2007fea8: 976f33ca c58c400f cfdc18fc 2b2690f9 cce87bc7 4697e746 fc0de49c 9903a531                                                                                          
stack_dump: 0x2007fec8: e563ca10 060dccb8 320a4410 bd381aa0 65ea5e81 7c104bfc 83dd1b4f 0df9ae5f                                                                                          
stack_dump: 0x2007fee8: cdfdcf72 c7a4068e a7bd12fd 8b63d8b1 7ce125c5 075690c7 0cd91c18 2540f998                                                                                          
stack_dump: 0x2007ff08: 349fc61a 134794ea cbf5dfb0 af9ff7a1 a978dd1e 16c11628 1f9d9bc6 68170219                                                                                          
stack_dump: 0x2007ff28: f0dd7fb6 a78212d5 fea773a6 726d5a2f d3bc7a2b 3f004c23 1cdb3f95 e335cac1                                                                                          
stack_dump: 0x2007ff48: a7397d2a aa400d13 ef1cc8b1 5a550e12 afb19eba 42014fe3 affeb985 8c3b461d                                                                                          
stack_dump: 0x2007ff68: 6ba5f506 82efea86 9f7762b5 624bd795 dd7e4e49 c541308a feca4530 97039105                                                                                          
stack_dump: 0x2007ff88: cefc4f6b 5f9737fe 9f87f77f 19ee1a42 afb0cdab 232856c1 8a7e6e1e b462946f                                                                                          
stack_dump: 0x2007ffa8: 60adbdf8 9017240d b0e682ea 018328c6 7cc61fa2 1e027493 bd45ac68 ab82210c                                                                                          
stack_dump: 0x2007ffc8: 8a69bfd8 86798e5e ddda6b5c 0cdffcc6 3b6a8f5a 13f0c450 0db3f357 2930725f                                                                                          



Still debugging youuuu! Yep, still figuring out how to get I2S audio working on STM32F7

More debugging… I was out of luck because nxplayer just blocks when I tried to play some audio, so I modified nxplayer_main.c to just read the argument from argv[1] and play it. This way I could start up nxplayer in background and run dmesg to see what is happening:

NuttShell (NSH) NuttX-12.5.1                                                    
nsh> mount -t tmpfs /tmp                                                        
nsh> rz                                                                         
**B0800000000022d                                                               
nsh> ls /tmp                                                                    
/tmp:                                                                           
 yes.wav                                                                        
nsh> dmesg                                                                      
board_cs4344_initialize: minor 0                                                
stm32_i2sbus_initialize: port: 2                                                
i2s_dump_regs: I2S2: After initialization                                       
i2s_dump_regs:     CR1:0000    CR2:0700     SR:0002      DR:0000                
i2s_dump_regs:     I2SCFGR:0000    I2SPR:0002                                   
i2s_dump_regs:     PLLI2SCFGR:44013000                                          
cs4344_reset: WARNING: MCLK could not be set on lower half                      
i2s_mckdivider: Entry                                                           
i2s_dump_regs: I2S2: After i2s_mckdivider                                       
i2s_dump_regs:     CR1:0000    CR2:0700     SR:0002      DR:0000                
i2s_dump_regs:     I2SCFGR:0e00    I2SPR:020d                                   
i2s_dump_regs:     PLLI2SCFGR:20003540                                          
cs4344_setbitrate: sample rate=16000 nchannels=1 bpsamp=16                      
audio_register: Registering /dev/audio/pcm0                                     
nsh> nxplayer /tmp/yes.wav &                                                    
nxplayer [10:100]                                                               
nsh> NxPlayer version 1.05                                                      
h for commands, q to exit                                                       
                                                                                
                                                                                
nsh> dmesg                                                                      
   0x46464952                                                                   
pcm_dump:     Chunk Size:      4292                                             
pcm_dump:     Format:          0x45564157                                       
pcm_dump:   Format Chunk:                                                       
pcm_dump:     Chunk ID:        0x20746d66                                       
pcm_dump:     Chunk Size:      16                                               
pcm_dump:     Audio Format:    0x0001                                           
pcm_dump:     Num. Channels:   1                                                
pcm_dump:     Sample Rate:     8000                                             
pcm_dump:     Byte Rate:       16000                                            
pcm_dump:     Block Align:     2                                                
pcm_dump:     Bits Per Sample: 16                                               
pcm_dump:   Data Chunk:                                                         
pcm_dump:     Chunk ID:        0x61746164                                       
pcm_dump:     Chunk Size:      4256                                             
cs4344_configure: ac_type: 2                                                    
cs4344_configure:   AUDIO_TYPE_OUTPUT:                                          
cs4344_configure:     Number of channels: 1                                     
cs4344_configure:     Sample rate:        8000                                  
cs4344_configure:     Sample width:       16                                    
cs4344_configure: ERROR: Unsupported combination of sample rate anddata width   
pcm_enqueuebuffer: ERROR: Failed to set PCM configuration: -22                  
nxplayer_enqueuebuffer: ERROR: AUDIOIOC_ENQUEUEBUFFER ioctl failed: 22          
nxplayer_playthread: 0 buffers queued, running=1 streaming=0                    
nxplayer_playthread: Playing...                                                 
nsh>

Debugging the STM32 I2S driver of NuttX to see how it works

I’m porting the I2S driver from STM32F4 to STM32F7 and decided to see how things work on STM32F4Discovery board. Now I can compare it with my driver for STM32F7:

nxplayer> play /tmp/yes.wav
nxplayer_playinternal: ==============================
nxplayer_playinternal: Playing file /tmp/yes.wav
nxplayer_playinternal: ==============================
audio_open: crefs: 0
audio_ioctl: cmd: 4097 arg: 536894112
audio_ioctl: AUDIOIOC_GETCAPS: Device=0
cs43l22_getcaps: type=0 ac_type=0
audio_ioctl: cmd: 4098 arg: 0
audio_ioctl: AUDIOIOC_RESERVE
pcm_reserve: Defer to lower reserve
audio_ioctl: cmd: 4097 arg: 536894112
audio_ioctl: AUDIOIOC_GETCAPS: Device=2
cs43l22_getcaps: type=2 ac_type=2
audio_ioctl: cmd: 4106 arg: 536894080
audio_ioctl: Forwarding unrecognized cmd: 4106 arg: 536894080
pcm_ioctl: Defer to lower ioctl, cmd=4106 arg=536894080
cs43l22_ioctl: Ignored
audio_ioctl: cmd: 4110 arg: 4
audio_ioctl: AUDIOIOC_REGISTERMQ
nxplayer_playthread: Entry
audio_ioctl: cmd: 4106 arg: 536896832
audio_ioctl: Forwarding unrecognized cmd: 4106 arg: 536896832
pcm_ioctl: Defer to lower ioctl, cmd=4106 arg=536896832
cs43l22_ioctl: Ignored
audio_ioctl: cmd: 4107 arg: 536896848
audio_ioctl: AUDIOIOC_ALLOCBUFFER
audio_ioctl: cmd: 4107 arg: 536896848
audio_ioctl: AUDIOIOC_ALLOCBUFFER
audio_ioctl: cmd: 4109 arg: 536896808
audio_ioctl: AUDIOIOC_ENQUEUEBUFFER
pcm_enqueuebuffer: Received buffer 0x200103f8, streaming=0
pcm_enqueuebuffer: curbyte=0 nbytes=8192 nmaxbytes=8192 bytesleft=8192
pcm_dump: Wave file header
pcm_dump:   Header Chunk:
pcm_dump:     Chunk ID:        0x46464952
pcm_dump:     Chunk Size:      39094
pcm_dump:     Format:          0x45564157
pcm_dump:   Format Chunk:
pcm_dump:     Chunk ID:        0x20746d66
pcm_dump:     Chunk Size:      16
pcm_dump:     Audio Format:    0x0001
pcm_dump:     Num. Channels:   1
pcm_dump:     Sample Rate:     8000
pcm_dump:     Byte Rate:       16000
pcm_dump:     Block Align:     2
pcm_dump:     Bits Per Sample: 16
pcm_dump:   Data Chunk:
pcm_dump:     Chunk ID:        0x61746164
pcm_dump:     Chunk Size:      39058
cs43l22_configure: ac_type: 2
cs43l22_configure:   AUDIO_TYPE_OUTPUT:
cs43l22_configure:     Number of channels: 1
cs43l22_configure:     Sample rate:        8000
cs43l22_configure:     Sample width:       16
stm32_i2s_txdatawidth: Data width bits of tx = 16
cs43l22_setbitrate: sample rate=8000 nchannels=1 bpsamp=16
pcm_enqueuebuffer: Begin streaming: apb=0x200103f8 curbyte=44 nbytes=8192
pcm_enqueuebuffer: Pass to lower enqueuebuffer: apb=0x200103f8 curbyte=44 nbytes=8192
cs43l22_enqueuebuffer: Enqueueing: apb=0x200103f8 curbyte=44 nbytes=8192 flags=0000
audio_ioctl: cmd: 4109 arg: 536896808
audio_ioctl: AUDIOIOC_ENQUEUEBUFFER
pcm_enqueuebuffer: Received buffer 0x20012428, streaming=1
pcm_enqueuebuffer: Received: apb=0x20012428 curbyte=0 nbytes=8192 flags=0000
pcm_enqueuebuffer: Pass to lower enqueuebuffer: apb=0x20012428 curbyte=0 nbytes=8192
cs43l22_enqueuebuffer: Enqueueing: apb=0x20012428 curbyte=0 nbytes=8192 flags=0000
nxplayer_playthread: 2 buffers queued, running=1 streaming=1
audio_ioctl: cmd: 4102 arg: 0
audio_ioctl: AUDIOIOC_START
pcm_start: Defer to lower start
cs43l22_start: Entry
cs43l22_start: Starting worker thread
cs43l22_workerthread: Entry
cs43l22_setvolume: volume=250 mute=0
cs43l22_writereg: Write: 20 <- 13
cs43l22_writereg: Write: 21 <- 13
cs43l22_readreg: Read: 0f -> 00
cs43l22_writereg: Write: 0f <- 00
cs43l22_sendbuffer: Sending apb=0x200103f8, size=8192 inflight=0
stm32_i2s_send: apb=0x200103f8 nbytes=8148 arg=0x20004798 timeout=105
stm32_dmasetup: paddr: 40003c0c maddr: 20010450 ntransfers: 4074 scr: 00012c40
cs43l22_sendbuffer: Sending apb=0x20012428, size=8192 inflight=1
stm32_i2s_send: apb=0x20012428 nbytes=8192 arg=0x20004798 timeout=105
cs43l22_start: Created worker thread
audio_ioctl: cmd: 4100 arg: 536896792
audio_ioctl: AUDIOIOC_INITIALIZE: Device=16
pcm_configure: Defer to lower configure
cs43l22_configure: ac_type: 16
cs43l22_configure:   AUDIO_TYPE_FEATURE
cs43l22_configure:     Volume: 400
cs43l22_setvolume: volume=147 mute=0
cs43l22_writereg: Write: 20 <- ac
cs43l22_writereg: Write: 21 <- ac
cs43l22_readreg: Read: 0f -> 00
cs43l22_writereg: Write: 0f <- 00
audio_ioctl: cmd: 4100 arg: 536896792
audio_ioctl: AUDIOIOC_INITIALIZE: Device=16
pcm_configure: Defer to lower configure
cs43l22_configure: ac_type: 16
cs43l22_configure:   AUDIO_TYPE_FEATURE
cs43l22_configure:     Balance: 500
cs43l22_setvolume: volume=102 mute=0
cs43l22_writereg: Write: 20 <- 7f
cs43l22_writereg: Write: 21 <- 7f
cs43l22_readreg: Read: 0f -> 00
cs43l22_writereg: Write: 0f <- 00
nxplayer_playthread: Playing...
nxplayer> i2s_tx_worker: tx.act.head=0 tx.done.head=0x2000477c
i2s_txdma_sampledone: result: 16
stm32_dmadump: DMA Registers: TX: Initial Registers
stm32_dmadump:    LISR[40026000]: 00000000
stm32_dmadump:    HISR[40026004]: 00000000
stm32_dmadump:     SCR[400260b8]: 00000000
stm32_dmadump:   SNDTR[400260bc]: 00000000
stm32_dmadump:    SPAR[400260c0]: 00000000
stm32_dmadump:   SM0AR[400260c4]: 00000000
stm32_dmadump:   SM1AR[400260c8]: 00000000
stm32_dmadump:    SFCR[400260cc]: 00000021
stm32_dmadump: DMA Registers: TX: After DMA Setup
stm32_dmadump:    LISR[40026000]: 00000000
stm32_dmadump:    HISR[40026004]: 00000000
stm32_dmadump:     SCR[400260b8]: 00012c40
stm32_dmadump:   SNDTR[400260bc]: 00000fea
stm32_dmadump:    SPAR[400260c0]: 40003c0c
stm32_dmadump:   SM0AR[400260c4]: 20010450
stm32_dmadump:   SM1AR[400260c8]: 00000000
stm32_dmadump:    SFCR[400260cc]: 00000027
stm32_dmadump: DMA Registers: TX: After DMA Start
stm32_dmadump:    LISR[40026000]: 00000000
stm32_dmadump:    HISR[40026004]: 00000000
stm32_dmadump:     SCR[400260b8]: 00012c4d
stm32_dmadump:   SNDTR[400260bc]: 00000fea
stm32_dmadump:    SPAR[400260c0]: 40003c0c
stm32_dmadump:   SM0AR[400260c4]: 20010450
stm32_dmadump:   SM1AR[400260c8]: 00000000
stm32_dmadump:    SFCR[400260cc]: 0000002f
stm32_dmadump: DMA Registers: TX: At DMA callback
stm32_dmadump:    LISR[40026000]: 00000000
stm32_dmadump:    HISR[40026004]: 00000000
stm32_dmadump:     SCR[400260b8]: 00012c4d
stm32_dmadump:   SNDTR[400260bc]: 000007f5
stm32_dmadump:    SPAR[400260c0]: 40003c0c
stm32_dmadump:   SM0AR[400260c4]: 20010450
stm32_dmadump:   SM1AR[400260c8]: 00000000
stm32_dmadump:    SFCR[400260cc]: 0000000f
stm32_dmadump: DMA Registers: TX: At End-of-Transfer
stm32_dmadump:    LISR[40026000]: 00000000
stm32_dmadump:    HISR[40026004]: 00000000
stm32_dmadump:     SCR[400260b8]: 00012c4d
stm32_dmadump:   SNDTR[400260bc]: 00000770
stm32_dmadump:    SPAR[400260c0]: 40003c0c
stm32_dmadump:   SM0AR[400260c4]: 20010450
stm32_dmadump:   SM1AR[400260c8]: 00000000
stm32_dmadump:    SFCR[400260cc]: 0000001f
i2s_dump_regs: I2S3: TX: At End-of-Transfer
i2s_dump_regs:     CR1:0000    CR2:0002     SR:0002      DR:0000
i2s_dump_regs:     I2SCFGR:0e00    I2SPR:021a
stm32_dmasetup: paddr: 40003c0c maddr: 20012454 ntransfers: 4096 scr: 00012c40
cs43l22_senddone: apb=0x200103f8 inflight=2 result=16
cs43l22_workerthread: AUDIO_MSG_COMPLETE
cs43l22_returnbuffers: Returning: apb=0x200103f8 curbyte=44 nbytes=8192 flags=0001
audio_callback: Entry
audio_dequeuebuffer: Entry
audio_ioctl: cmd: 4109 arg: 536896808
audio_ioctl: AUDIOIOC_ENQUEUEBUFFER
pcm_enqueuebuffer: Received buffer 0x200103f8, streaming=1
pcm_enqueuebuffer: Received: apb=0x200103f8 curbyte=0 nbytes=8192 flags=0000
pcm_enqueuebuffer: Pass to lower enqueuebuffer: apb=0x200103f8 curbyte=0 nbytes=8192
cs43l22_enqueuebuffer: Enqueueing: apb=0x200103f8 curbyte=0 nbytes=8192 flags=0000
cs43l22_workerthread: AUDIO_MSG_ENQUEUE
cs43l22_sendbuffer: Sending apb=0x200103f8, size=8192 inflight=1
stm32_i2s_send: apb=0x200103f8 nbytes=8192 arg=0x20004798 timeout=105
i2s_tx_worker: tx.act.head=0 tx.done.head=0x20004764
i2s_txdma_sampledone: result: 17
stm32_dmadump: DMA Registers: TX: Initial Registers
stm32_dmadump:    LISR[40026000]: 00000000
stm32_dmadump:    HISR[40026004]: 08000000
stm32_dmadump:     SCR[400260b8]: 00012c4c
stm32_dmadump:   SNDTR[400260bc]: 00000000
stm32_dmadump:    SPAR[400260c0]: 40003c0c
stm32_dmadump:   SM0AR[400260c4]: 20010450
stm32_dmadump:   SM1AR[400260c8]: 00000000
stm32_dmadump:    SFCR[400260cc]: 00000027
stm32_dmadump: DMA Registers: TX: After DMA Setup
stm32_dmadump:    LISR[40026000]: 00000000
stm32_dmadump:    HISR[40026004]: 00000000
stm32_dmadump:     SCR[400260b8]: 00012c4c
stm32_dmadump:   SNDTR[400260bc]: 00001000
stm32_dmadump:    SPAR[400260c0]: 40003c0c
stm32_dmadump:   SM0AR[400260c4]: 20012454
stm32_dmadump:   SM1AR[400260c8]: 00000000
stm32_dmadump:    SFCR[400260cc]: 00000027
stm32_dmadump: DMA Registers: TX: After DMA Start
stm32_dmadump:    LISR[40026000]: 00000000
stm32_dmadump:    HISR[40026004]: 00400000
stm32_dmadump:     SCR[400260b8]: 00012c4d
stm32_dmadump:   SNDTR[400260bc]: 00000fff
stm32_dmadump:    SPAR[400260c0]: 40003c0c
stm32_dmadump:   SM0AR[400260c4]: 20012454
stm32_dmadump:   SM1AR[400260c8]: 00000000
stm32_dmadump:    SFCR[400260cc]: 0000001f
stm32_dmadump: DMA Registers: TX: At DMA callback
stm32_dmadump:    LISR[40026000]: 00000000
stm32_dmadump:    HISR[40026004]: 00000000
stm32_dmadump:     SCR[400260b8]: 00012c4d
stm32_dmadump:   SNDTR[400260bc]: 00000800
stm32_dmadump:    SPAR[400260c0]: 40003c0c
stm32_dmadump:   SM0AR[400260c4]: 20012454
stm32_dmadump:   SM1AR[400260c8]: 00000000
stm32_dmadump:    SFCR[400260cc]: 0000002f
stm32_dmadump: DMA Registers: TX: At End-of-Transfer
stm32_dmadump:    LISR[40026000]: 00000000
stm32_dmadump:    HISR[40026004]: 00000000
stm32_dmadump:     SCR[400260b8]: 00012c4d
stm32_dmadump:   SNDTR[400260bc]: 0000077b
stm32_dmadump:    SPAR[400260c0]: 40003c0c
stm32_dmadump:   SM0AR[400260c4]: 20012454
stm32_dmadump:   SM1AR[400260c8]: 00000000
stm32_dmadump:    SFCR[400260cc]: 0000000f
i2s_dump_regs: I2S3: TX: At End-of-Transfer
i2s_dump_regs:     CR1:0000    CR2:0002     SR:0002      DR:ffbd
i2s_dump_regs:     I2SCFGR:0e00    I2SPR:021a
stm32_dmasetup: paddr: 40003c0c maddr: 20010424 ntransfers: 4096 scr: 00012c40
cs43l22_senddone: apb=0x20012428 inflight=2 result=17
cs43l22_workerthread: AUDIO_MSG_COMPLETE
cs43l22_returnbuffers: Returning: apb=0x20012428 curbyte=0 nbytes=8192 flags=0001
audio_callback: Entry
audio_dequeuebuffer: Entry
audio_ioctl: cmd: 4109 arg: 536896808
audio_ioctl: AUDIOIOC_ENQUEUEBUFFER
pcm_enqueuebuffer: Received buffer 0x20012428, streaming=1
pcm_enqueuebuffer: Received: apb=0x20012428 curbyte=0 nbytes=8192 flags=0000
pcm_enqueuebuffer: Pass to lower enqueuebuffer: apb=0x20012428 curbyte=0 nbytes=8192
cs43l22_enqueuebuffer: Enqueueing: apb=0x20012428 curbyte=0 nbytes=8192 flags=0000
cs43l22_workerthread: AUDIO_MSG_ENQUEUE
cs43l22_sendbuffer: Sending apb=0x20012428, size=8192 inflight=1
stm32_i2s_send: apb=0x20012428 nbytes=8192 arg=0x20004798 timeout=105
i2s_tx_worker: tx.act.head=0 tx.done.head=0x2000474c
i2s_txdma_sampledone: result: 17
stm32_dmadump: DMA Registers: TX: Initial Registers
stm32_dmadump:    LISR[40026000]: 00000000
stm32_dmadump:    HISR[40026004]: 08000000
stm32_dmadump:     SCR[400260b8]: 00012c4c
stm32_dmadump:   SNDTR[400260bc]: 00000000
stm32_dmadump:    SPAR[400260c0]: 40003c0c
stm32_dmadump:   SM0AR[400260c4]: 20012454
stm32_dmadump:   SM1AR[400260c8]: 00000000
stm32_dmadump:    SFCR[400260cc]: 00000027
stm32_dmadump: DMA Registers: TX: After DMA Setup
stm32_dmadump:    LISR[40026000]: 00000000
stm32_dmadump:    HISR[40026004]: 00000000
stm32_dmadump:     SCR[400260b8]: 00012c4c
stm32_dmadump:   SNDTR[400260bc]: 00001000
stm32_dmadump:    SPAR[400260c0]: 40003c0c
stm32_dmadump:   SM0AR[400260c4]: 20010424
stm32_dmadump:   SM1AR[400260c8]: 00000000
stm32_dmadump:    SFCR[400260cc]: 00000027
stm32_dmadump: DMA Registers: TX: After DMA Start
stm32_dmadump:    LISR[40026000]: 00000000
stm32_dmadump:    HISR[40026004]: 00400000
stm32_dmadump:     SCR[400260b8]: 00012c4d
stm32_dmadump:   SNDTR[400260bc]: 00000fff
stm32_dmadump:    SPAR[400260c0]: 40003c0c
stm32_dmadump:   SM0AR[400260c4]: 20010424
stm32_dmadump:   SM1AR[400260c8]: 00000000
stm32_dmadump:    SFCR[400260cc]: 0000001f
stm32_dmadump: DMA Registers: TX: At DMA callback
stm32_dmadump:    LISR[40026000]: 00000000
stm32_dmadump:    HISR[40026004]: 00000000
stm32_dmadump:     SCR[400260b8]: 00012c4d
stm32_dmadump:   SNDTR[400260bc]: 00000800
stm32_dmadump:    SPAR[400260c0]: 40003c0c
stm32_dmadump:   SM0AR[400260c4]: 20010424
stm32_dmadump:   SM1AR[400260c8]: 00000000
stm32_dmadump:    SFCR[400260cc]: 0000002f
stm32_dmadump: DMA Registers: TX: At End-of-Transfer
stm32_dmadump:    LISR[40026000]: 00000000
stm32_dmadump:    HISR[40026004]: 00000000
stm32_dmadump:     SCR[400260b8]: 00012c4d
stm32_dmadump:   SNDTR[400260bc]: 0000077b
stm32_dmadump:    SPAR[400260c0]: 40003c0c
stm32_dmadump:   SM0AR[400260c4]: 20010424
stm32_dmadump:   SM1AR[400260c8]: 00000000
stm32_dmadump:    SFCR[400260cc]: 0000000f
i2s_dump_regs: I2S3: TX: At End-of-Transfer
i2s_dump_regs:     CR1:0000    CR2:0002     SR:0002      DR:0000
i2s_dump_regs:     I2SCFGR:0e00    I2SPR:021a
stm32_dmasetup: paddr: 40003c0c maddr: 20012454 ntransfers: 4096 scr: 00012c40
cs43l22_senddone: apb=0x200103f8 inflight=2 result=17
cs43l22_workerthread: AUDIO_MSG_COMPLETE
cs43l22_returnbuffers: Returning: apb=0x200103f8 curbyte=0 nbytes=8192 flags=0001
audio_callback: Entry
audio_dequeuebuffer: Entry
nxplayer_fill_common: Closing audio file, nbytes=6334 errcode=25
audio_ioctl: cmd: 4109 arg: 536896808
audio_ioctl: AUDIOIOC_ENQUEUEBUFFER
pcm_enqueuebuffer: Received buffer 0x200103f8, streaming=1
pcm_enqueuebuffer: Received: apb=0x200103f8 curbyte=0 nbytes=6334 flags=0008
pcm_enqueuebuffer: Pass to lower enqueuebuffer: apb=0x200103f8 curbyte=0 nbytes=6334
cs43l22_enqueuebuffer: Enqueueing: apb=0x200103f8 curbyte=0 nbytes=6334 flags=0008
cs43l22_workerthread: AUDIO_MSG_ENQUEUE
cs43l22_sendbuffer: Sending apb=0x200103f8, size=6334 inflight=1
stm32_i2s_send: apb=0x200103f8 nbytes=6334 arg=0x20004798 timeout=81
i2s_tx_worker: tx.act.head=0 tx.done.head=0x2000477c
i2s_txdma_sampledone: result: 17
stm32_dmadump: DMA Registers: TX: Initial Registers
stm32_dmadump:    LISR[40026000]: 00000000
stm32_dmadump:    HISR[40026004]: 08000000
stm32_dmadump:     SCR[400260b8]: 00012c4c
stm32_dmadump:   SNDTR[400260bc]: 00000000
stm32_dmadump:    SPAR[400260c0]: 40003c0c
stm32_dmadump:   SM0AR[400260c4]: 20010424
stm32_dmadump:   SM1AR[400260c8]: 00000000
stm32_dmadump:    SFCR[400260cc]: 00000027
stm32_dmadump: DMA Registers: TX: After DMA Setup
stm32_dmadump:    LISR[40026000]: 00000000
stm32_dmadump:    HISR[40026004]: 00000000
stm32_dmadump:     SCR[400260b8]: 00012c4c
stm32_dmadump:   SNDTR[400260bc]: 00001000
stm32_dmadump:    SPAR[400260c0]: 40003c0c
stm32_dmadump:   SM0AR[400260c4]: 20012454
stm32_dmadump:   SM1AR[400260c8]: 00000000
stm32_dmadump:    SFCR[400260cc]: 00000027
stm32_dmadump: DMA Registers: TX: After DMA Start
stm32_dmadump:    LISR[40026000]: 00000000
stm32_dmadump:    HISR[40026004]: 00400000
stm32_dmadump:     SCR[400260b8]: 00012c4d
stm32_dmadump:   SNDTR[400260bc]: 00000fff
stm32_dmadump:    SPAR[400260c0]: 40003c0c
stm32_dmadump:   SM0AR[400260c4]: 20012454
stm32_dmadump:   SM1AR[400260c8]: 00000000
stm32_dmadump:    SFCR[400260cc]: 0000001f
stm32_dmadump: DMA Registers: TX: At DMA callback
stm32_dmadump:    LISR[40026000]: 00000000
stm32_dmadump:    HISR[40026004]: 00000000
stm32_dmadump:     SCR[400260b8]: 00012c4d
stm32_dmadump:   SNDTR[400260bc]: 00000800
stm32_dmadump:    SPAR[400260c0]: 40003c0c
stm32_dmadump:   SM0AR[400260c4]: 20012454
stm32_dmadump:   SM1AR[400260c8]: 00000000
stm32_dmadump:    SFCR[400260cc]: 0000002f
stm32_dmadump: DMA Registers: TX: At End-of-Transfer
stm32_dmadump:    LISR[40026000]: 00000000
stm32_dmadump:    HISR[40026004]: 00000000
stm32_dmadump:     SCR[400260b8]: 00012c4d
stm32_dmadump:   SNDTR[400260bc]: 0000077b
stm32_dmadump:    SPAR[400260c0]: 40003c0c
stm32_dmadump:   SM0AR[400260c4]: 20012454
stm32_dmadump:   SM1AR[400260c8]: 00000000
stm32_dmadump:    SFCR[400260cc]: 0000000f
i2s_dump_regs: I2S3: TX: At End-of-Transfer
i2s_dump_regs:     CR1:0000    CR2:0002     SR:0002      DR:0000
i2s_dump_regs:     I2SCFGR:0e00    I2SPR:021a
stm32_dmasetup: paddr: 40003c0c maddr: 20010424 ntransfers: 3167 scr: 00012c40
cs43l22_senddone: apb=0x20012428 inflight=2 result=17
cs43l22_workerthread: AUDIO_MSG_COMPLETE
cs43l22_returnbuffers: Returning: apb=0x20012428 curbyte=0 nbytes=8192 flags=0001
audio_callback: Entry
audio_dequeuebuffer: Entry
i2s_tx_worker: tx.act.head=0 tx.done.head=0x20004764
i2s_txdma_sampledone: result: 17
stm32_dmadump: DMA Registers: TX: Initial Registers
stm32_dmadump:    LISR[40026000]: 00000000
stm32_dmadump:    HISR[40026004]: 08000000
stm32_dmadump:     SCR[400260b8]: 00012c4c
stm32_dmadump:   SNDTR[400260bc]: 00000000
stm32_dmadump:    SPAR[400260c0]: 40003c0c
stm32_dmadump:   SM0AR[400260c4]: 20012454
stm32_dmadump:   SM1AR[400260c8]: 00000000
stm32_dmadump:    SFCR[400260cc]: 00000027
stm32_dmadump: DMA Registers: TX: After DMA Setup
stm32_dmadump:    LISR[40026000]: 00000000
stm32_dmadump:    HISR[40026004]: 00000000
stm32_dmadump:     SCR[400260b8]: 00012c4c
stm32_dmadump:   SNDTR[400260bc]: 00000c5f
stm32_dmadump:    SPAR[400260c0]: 40003c0c
stm32_dmadump:   SM0AR[400260c4]: 20010424
stm32_dmadump:   SM1AR[400260c8]: 00000000
stm32_dmadump:    SFCR[400260cc]: 00000027
stm32_dmadump: DMA Registers: TX: After DMA Start
stm32_dmadump:    LISR[40026000]: 00000000
stm32_dmadump:    HISR[40026004]: 00400000
stm32_dmadump:     SCR[400260b8]: 00012c4d
stm32_dmadump:   SNDTR[400260bc]: 00000c5e
stm32_dmadump:    SPAR[400260c0]: 40003c0c
stm32_dmadump:   SM0AR[400260c4]: 20010424
stm32_dmadump:   SM1AR[400260c8]: 00000000
stm32_dmadump:    SFCR[400260cc]: 0000001f
stm32_dmadump: DMA Registers: TX: At DMA callback
stm32_dmadump:    LISR[40026000]: 00000000
stm32_dmadump:    HISR[40026004]: 00000000
stm32_dmadump:     SCR[400260b8]: 00012c4d
stm32_dmadump:   SNDTR[400260bc]: 0000062f
stm32_dmadump:    SPAR[400260c0]: 40003c0c
stm32_dmadump:   SM0AR[400260c4]: 20010424
stm32_dmadump:   SM1AR[400260c8]: 00000000
stm32_dmadump:    SFCR[400260cc]: 0000002f
stm32_dmadump: DMA Registers: TX: At End-of-Transfer
stm32_dmadump:    LISR[40026000]: 00000000
stm32_dmadump:    HISR[40026004]: 00000000
stm32_dmadump:     SCR[400260b8]: 00012c4d
stm32_dmadump:   SNDTR[400260bc]: 000005aa
stm32_dmadump:    SPAR[400260c0]: 40003c0c
stm32_dmadump:   SM0AR[400260c4]: 20010424
stm32_dmadump:   SM1AR[400260c8]: 00000000
stm32_dmadump:    SFCR[400260cc]: 0000000f
i2s_dump_regs: I2S3: TX: At End-of-Transfer
i2s_dump_regs:     CR1:0000    CR2:0002     SR:0006      DR:0000
i2s_dump_regs:     I2SCFGR:0e00    I2SPR:021a
cs43l22_senddone: apb=0x200103f8 inflight=1 result=17
cs43l22_workerthread: AUDIO_MSG_COMPLETE
cs43l22_returnbuffers: Returning: apb=0x200103f8 curbyte=0 nbytes=6334 flags=0009
cs43l22_returnbuffers: Terminating
audio_callback: Entry
audio_dequeuebuffer: Entry
cs43l22_writereg: Write: 02 <- 01
cs43l22_writereg: Write: 04 <- af
cs43l22_writereg: Write: 05 <- 81
cs43l22_writereg: Write: 06 <- 04
cs43l22_writereg: Write: 02 <- 9e
cs43l22_writereg: Write: 0a <- 00
cs43l22_writereg: Write: 0e <- 04
cs43l22_writereg: Write: 27 <- 00
cs43l22_writereg: Write: 1f <- 0f
cs43l22_writereg: Write: 1a <- 0a
cs43l22_writereg: Write: 1b <- 0a
stm32_i2s_txdatawidth: Data width bits of tx = 16
cs43l22_setvolume: volume=250 mute=0
cs43l22_writereg: Write: 20 <- 13
cs43l22_writereg: Write: 21 <- 13
cs43l22_readreg: Read: 0f -> 00
cs43l22_writereg: Write: 0f <- 00
cs43l22_setbitrate: sample rate=11025 nchannels=1 bpsamp=16
audio_callback: Entry
audio_complete: Entry
cs43l22_workerthread: Exit
nxplayer_playthread: Play complete.  outstanding=0
nxplayer_playthread: Clean-up and exit
nxplayer_playthread: Freeing buffers
audio_ioctl: cmd: 4108 arg: 536896848
audio_ioctl: AUDIOIOC_FREEBUFFER
audio_ioctl: cmd: 4108 arg: 536896848
audio_ioctl: AUDIOIOC_FREEBUFFER
apb_free: Freeing 0x20012428
audio_ioctl: cmd: 4111 arg: 4
audio_ioctl: AUDIOIOC_UNREGISTERMQ
audio_ioctl: cmd: 4099 arg: 0
audio_ioctl: AUDIOIOC_RELEASE
pcm_release: Defer to lower release
audio_close: crefs: 1
audio_close: calling shutdown
pcm_shutdown: Defer to lower shutdown
cs43l22_writereg: Write: 02 <- 01
cs43l22_writereg: Write: 04 <- af
cs43l22_writereg: Write: 05 <- 81
cs43l22_writereg: Write: 06 <- 04
cs43l22_writereg: Write: 02 <- 9e
cs43l22_writereg: Write: 0a <- 00
cs43l22_writereg: Write: 0e <- 04
cs43l22_writereg: Write: 27 <- 00
cs43l22_writereg: Write: 1f <- 0f
cs43l22_writereg: Write: 1a <- 0a
cs43l22_writereg: Write: 1b <- 0a
stm32_i2s_txdatawidth: Data width bits of tx = 16
cs43l22_setvolume: volume=250 mute=0
cs43l22_writereg: Write: 20 <- 13
cs43l22_writereg: Write: 21 <- 13
cs43l22_readreg: Read: 0f -> 00
cs43l22_writereg: Write: 0f <- 00
cs43l22_setbitrate: sample rate=11025 nchannels=1 bpsamp=16
nxplayer_playthread: Exit
apb_free: Freeing 0x200103f8
q
nsh>

Testing NuttX RTOS on QEMU for SMP ARM 64-bit

Compilitation:

$ make distclean -j
$ ./tools/configure.sh -l qemu-armv8a:nsh_smp
$ make -j

Running:

$ qemu-system-aarch64 -cpu cortex-a53 -smp 4 -nographic -machine virt,virtualization=on,gic-version=3 -net none -chardev stdio,id=con,mux=on -serial chardev:con -mon chardev=con,mode=readline -kernel ./nuttx