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

How to extern PLL I2S audio clock on MCO2 pin at stm32_bringup() of NuttX

Basically I just this it:

...
#include "chip.h"
#include "stm32_gpio.h"
#include "stm32_rcc.h"
...

/* Extern PLLI2S clock on MCO2 (PC9) */

#define BOARD_CFGR_MC02_SOURCE         RCC_CFGR_MCO2_PLLI2S
#define BOARD_CFGR_MC02_DIVIDER        RCC_CFGR_MCO2PRE_NONE

#define GPIO_MCO2 (GPIO_MCO2_0|GPIO_SPEED_100MHz)

int stm32_bringup(void)
{
  int ret = OK;

  /* Extern I2S clock on MCO2 pin */

  stm32_configgpio(GPIO_MCO2);
  stm32_mco2config(BOARD_CFGR_MC02_SOURCE,
                   BOARD_CFGR_MC02_DIVIDER);

...
}

Using ZModem on NuttX to transfer files

On NuttX side run “rz” command to receive files:

nsh> rz
**B0900000000a87c
**B0800000000022d


On Linux side run:

$ stty 115200 cs8 -parenb -crtscts -F /dev/ttyACM0

$ sz –zmodem nuttx_logo.txt > /dev/ttyACM0 < /dev/ttyACM0

You will see:
Sending: nuttx_logo.txt
Bytes Sent: 1942 BPS:196

On NuttX side you can see the received file:

nsh> cd /tmp

nsh> ls/tmp:

nuttx_logo.txt

Why is Linux and open source in general in danger now?

If you’ve been in a cave the last few days, you probably missed the biggest security flaw in Linux history: Back Door XZ-Utils (CVE-2024-3094)!

Firstly, why is this so important? After all, backdoors come and go all the time, right?

Because of all the previously found BUGs in Linux, they were all the result of honest mistakes (real BUGs), but this backdoor, on the other hand, was inserted into xz-utils by a volunteer developer (named Jia Tan, probably a fake name) .

He worked on the project for about 3 years to gain the respect of the original maintainer and used social engineering by creating fake users to blame the original maintainer and force him to hand over/share control of the project. And the most important thing is that there is a high probability that this “attack” was financed by some nation-state.

Linux is supposed to be a relatively secure system with no known breaches inserted by governments. Unfortunately we can’t say the same for Windows (and it was recently discovered that Apple and Google allow the US government to access users’ notifications).

Remember the famous _NSAKEY case in Microsoft’s Windows 95/98 (later renamed to _KEY2 to avoid speculation)? Microsoft always said it was a conspiracy theory, until Edward Snowden showed documents proving it was real. There’s a cool video about it here: https://www.youtube.com/watch?v=x8JuUW41pbQ

So why are Linux and open source in danger now? Because all Linux systems are built on thousands of open source projects and something tells me this is just the first of thousands of attempted breaches that will occur over the next few years. And this is very serious, because many projects depend on just one single developer who is not paid to work on it and cannot work full time on his project.

Of course, this xkcd comics came to our mind: