New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add x_nucleo_cca02m1 microphone shield #17140
Conversation
065d01e
to
8b14543
Compare
All checks are passing now. Review history of this comment for details about previous failed status. |
8b14543
to
aaff822
Compare
@erwango |
148449f
to
ce81d52
Compare
coupon boards such as STEVAL-MKI129Vx and STEVAL-MKI155Vx. | ||
|
||
The X-NUCLEO-CCA02M1 allows synchronized acquisition and streaming of up to 4 | ||
microphones through I²S, SPI or DFSDM peripherals. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Recommend using I2S
instead, so searching for the term is possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, sorry.
I knew it, as you told me last time, but I forgot to apply it on this doc as well.
@@ -0,0 +1,56 @@ | |||
.. _x-nucleo-cca02m1: | |||
|
|||
X-NUCLEO-CCA02M1: Digital MEMS microphones SHIELD for STM32 Nucleo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SHIELD
should not be capitalized (it's not an acronym or legal name), change to shield
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ack
- RoHS compliant | ||
|
||
|
||
More information about X-NUCLEO-IKS01A1 can be found here: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reads better as:
For more information about this shield, see the `X-NUCLEO-IKS01A1 data brief`_.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
Programming | ||
*********** | ||
|
||
The X-NUCLEO-CCA02M1 can be connected to the SoC through I²S, SPI or DFSDM peripherals. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to:
The X-NUCLEO-CCA02M1 can be connected to the SoC through I2S, SPI, or DFSDM peripherals,
but only I2S has been tested in Zephyr using a nucleo_f411re board.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
Provide definition files and simple documentation for x-nucleo-cca02m1 microphone shield. Signed-off-by: Armando Visconti <armando.visconti@st.com>
This commit is provided to make the sample working, but should be somehow replaced. Signed-off-by: Armando Visconti <armando.visconti@st.com>
ce81d52
to
130611f
Compare
{STM32_PIN_PA7, STM32F4_PINMUX_FUNC_PA7_I2S1_SD}, | ||
#endif /* CONFIG_I2S_1 */ | ||
/* TBD ???? */ | ||
{STM32_PIN_PB4, (STM32_PINMUX_ALT_FUNC_2 | STM32_PUSHPULL_NOPULL | STM32_OSPEEDR_VERY_HIGH_SPEED)}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are you trying to do here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@erwango
You touched the point. As I highlighted in the notes this changes to the board are not
proper and must be fixed. But I prepared the PR anyway so that it is evident what is my
intention.
Basically, to make the x_nucleo_cca02m1 shield working fine (and in both mono and
stereo mode) there are few things that must be configured, but the only way I found
was in the board itself, which is not proper.
The shield needs:
- I2S configuration (PLL and so on)
- DMA configuration
- timer configuration for proper microphone clocking in stereo mode (timer generates clock which
goes out on pins)
In this file the PB4 and PB5 are the pins where a 2x clock is generated using timer as explained
in AN5027.
I guess this part should be either in board/sheilds or in sample/shields.
Or maybe here under ifdef. Any suggestion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any suggestion?
What about using gpio map and do this configuration inside the sample code?
define in dts:
gpio-d2 = <&arduino_header 7 0>;
Then, in sample code, use gpio-d2 generated define to do the gpio configuration?
This is basically what is done for cs-gpio for SPI controllers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@avisconti , did you checked above proposal?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@erwango, no, not yet.
I did try to understand the steps to do that looking at the example, but stopped after few
doubts. I'll be back on this later on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First review attempt
config I2S_1 | ||
default y | ||
|
||
config USE_STM32_LL_TIM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If required, this should not be there.
A path like boards/shields/wnc_m14a2a/boards/frdm_k64f.conf
would be best suited
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess you mean something like that:
CONFIG_I2S_STM32=y
CONFIG_I2S_STM32_USE_PLLI2S_ENABLE=y
CONFIG_I2S_STM32_PLLI2S_PLLM=8
CONFIG_I2S_STM32_PLLI2S_PLLN=192
CONFIG_I2S_STM32_PLLI2S_PLLR=3
CONFIG_I2S_1=y
CONFIG_USE_STM32_LL_TIM=y
CONFIG_DMA_STM32F4X=y
I tried but there is one problem, i.e. CONFIG_USE_STM32_LL_TIM is a symbole with no
prompt, which means that can be set ONLY in a defconfig file. But I think that in shield it is not
possible to have defconfig, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As reported in sample file, main issue is that code proposed in sample is not using zephyr API and tries to access directly cube HAL.
Otherwise, most of this should be done in shield Kconfig.defconfig (which misses today and should be re-instantiated)
@avisconti , you mentionned in a related issue the following:
Can you elaborate? |
*/ | ||
static int AUDIO_IN_Timer_Init(void) | ||
{ | ||
TIM_TypeDef *tim3 = (TIM_TypeDef *)DT_TIM_STM32_3_BASE_ADDRESS; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it is acceptable to propose in upstream a sample that bypass zephyr APIs.
If some HW functionality is required for the sample it should be accessed via a generic zephyr API.
If missing, such API should be proposed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see your point. I'll try to elaborate more on this.
config I2S_1 | ||
default y | ||
|
||
config USE_STM32_LL_TIM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As reported in sample file, main issue is that code proposed in sample is not using zephyr API and tries to access directly cube HAL.
Otherwise, most of this should be done in shield Kconfig.defconfig (which misses today and should be re-instantiated)
In nucleo_f411re.dts I had to define following things:
arduino_i2s is similar to arduino_i2c and arduino_spi, and it doesn't seem to be a big issue. I'm more concerned about defining timers3, which is required by the shield, but not by the nucleo itself. So, I would like to move this in the shield code, but I'm not sure if I can do it in the overlay file. |
Sure, you can safely put this in nucleo dts file. This is part of board configuration. This is not related to this specific shield.
As mentioned in other comment, IMHO, what you actually need is a timer functionality that should be provided by a zephyr driver through a dedicated zephyr API. Once available, it shouldn't be complex to configure a matching device in dts. |
shields | ||
|
||
This sample provides an example of how to acquire audio through | ||
the two digital MEMS microphones on X-NUCLEO-CCA02M1 sheild. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the two digital MEMS microphones on X-NUCLEO-CCA02M1 sheild. | |
the two digital MEMS microphones on X-NUCLEO-CCA02M1 shield. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ooops. thx!
Sample Output | ||
============= | ||
|
||
The example acquires 1s of audio and prints out the PCM stream on COM port. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The would read better spelled out:
The example acquires 1s of audio and prints out the PCM stream on COM port. | |
The example acquires one second of audio and prints out the PCM stream on COM port. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ack
The microphone PDM requested clock should lead the MP34DT05 driver to select an | ||
oversampling/decimation factor to result in approximately a 2MHz bit clock. | ||
|
||
See pcm and pdm configuration in file :zephyr_file:`samples/shields/x_nucleo_cca02m1/src/main.c`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See pcm and pdm configuration in file :zephyr_file:`samples/shields/x_nucleo_cca02m1/src/main.c`. | |
See PCM and PDM configuration in file :zephyr_file:`samples/shields/x_nucleo_cca02m1/src/main.c`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Acronyms always upper case, right?
ok, thx.
.. note:: It is possible to change the AUDIO_FREQ to 32000 acquiring only 500 ms. | ||
|
||
At the end of the acquisition the PCM data will be printed on the terminal | ||
emulator in either binary or ASCII format. The output is controlled by |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would read better as:
The output is controlled by the
:c:macro:`PCM_OUTPUT_IN_ASCII` macro, off by default, in
:zephyr_file:`samples/shields/x_nucleo_cca02m1/src/main.c`.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ack
Binary PCM Output | ||
----------------- | ||
|
||
The nucleo F411RE board presents itself as USB CDC class to host, which will so use the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's change this to:
The Nucleo F411RE board presents itself to the host
as a USB CDC class, and will use ``/dev/ttyACM0``
device for communication. The ``/dev/ttyACM0`` port
must be configured in raw mode to avoid having
special characters (such as :kbd:`CNTL-Z` or kbd:`CNTL-D`)
processed or 'cooked' out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it sounds better, ok.
:align: center | ||
:alt: audio_import | ||
|
||
After file is imported you can analyze and play the 1s audio file: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After file is imported you can analyze and play the 1s audio file: | |
After the file is imported you can analyze and play the one second audio file: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ack
This sample is made to demonstrate use of shield x-nucleo-cca02m1. It uses the default shield soldering configuration, which means both microphones in stereo mode. It has been tested using nucleo F411RE board. Signed-off-by: Armando Visconti <armando.visconti@st.com>
130611f
to
618c8d3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doc changes LGTM, thanks!
@avisconti what's the status here? |
Status is that to make it working I had to hack the board bsp (see 6d76af3), which is of course not a good way. I would like to bring all that work inside the shield, but I didn't find it easy and probably it requires some time and more thinking on it. What should I do? Close it and re-open it later on? |
@galak, @avisconti, IMO, this is not the only point blocking here. |
Yes, I forgot this point highlighted by you some time ago. The timer part is more tricky. |
Closing this and will let @avisconti re-open when things are ready to re-submit. |
Add the support for the x_nucleo_cca02m1 microphone shield with a sample to test it.
This sample is making use of both the 2 x MP34DT01 on-board microphones in stereo mode.
To achieve this result the sample is using AN5027 suggestion (paragraph 2.1.2) to use a timer
to provide a clock which runs at double the frequency of I2S sampling time.
NOTES (IMPORTANT):: (see #15429)
To make the sample working I had to make customization to Nucleo F411 re files
(boards/arm/nucleo_f411re/), which I think it is NOT the correct way. I'm asking the support
of someone to explain how to move those info in the shield part.
In more details:
in nucleo_f411re/Kconfig.defconfig I defined the I2S part, especially the I2S PLL configuration.
Also TIM and DMA.
The right place should be in the shield definition I guess, or in sample.
In nucleo_f411re/nucleo_f411re.dts I defined arduino_i2s and timer3.
time3 should be moved in shield or in sample.
In nucleo_f411re/pinmux.c I defined I2S and timer clock pinmuxing.
Again this should be provided in shield or sample.
Can #14057 help us here?