Upcoming maintenance
Dear Customers and Partners.
This website will be undergoing scheduled maintenance on June 14, 2023. Please be aware there may be disruption to the developer portal website and associated services during the scheduled maintenance period.
This upgrade is essential to ensure the continued performance, reliability, and security of Developer World.
We apologize for any inconvenience.
Where can I find the media_recorder_obj.cpp file under Arduino development environment?
-
Hi All, I modify the built-in audio fft function for developing a project. The original sampling rate is 48000. I hope to modify it to 8000. After running, the board has the following errors.
I faced the same issue before when developing under the SDK / Linux environment:https://forum.developer.sony.com/topic/614/audio-recorder-example-not-working-under-8000-and-16000-sample-rate?_=1657255949814
The media_recorder_obj.cpp is easily found under the SDK environment:
However, I cannot find this file when I developed under Arduino. I search the whole PC and cannot even find it. Would someone kindly tell me where can I find this file so that I can modify the sampling rate when developing by using Arduino?
Thank you in advance for any help.
Best,
Larry
-
@Larry Is there a 'go-to definition' function by using Arduino IDE (same function by using VSCode SDK)?
-
I had a look in the past, but I cannot find it inside Arduino SDK. I assume it gets pre-compiled when you build the Arduino SDK.
If you only need the file for reference, I would suggest you install the Arduino plugin for VS code. I am using that. It works well. I use it in combination with the Arduino CLI. It "feels" also faster than the Arduino GUI.
If you add the Spresense-SDK files folder to your project. VS Code can jump to the files with Go to Definition.However if you modify them I assume that you need to apply these steps
https://developer.sony.com/develop/spresense/docs/arduino_set_up_en.html#_how_to_create_spresense_arduino_customized_package -
Update
The output.map file in the Arduino output folder tells you where it is:
precompiled inside
<Arduino Library Folder>/Arduino15/packages/SPRESENSE_local/tools/spresense-sdk/2.5.2/spresense/release/nuttx/libs/libapps.a -
@jens6151-0-1-1 Thank you for your kind reply. Developing under VS code is indeed a good suggestion.
-
@jens6151-0-1-1 Would you please provide a screenshot for this? I still do not understand how to check the output folder by using the libapps.a file. Thank you in advance for any help.
-
You mean to find the location of the media_recorder_obj.cpp
Above shows the content of the ArduinoOutput folder
How to set or find the output folder
It is specified in the arduino.json
Content of the output folder
(base) Mini-2:ArduinoOutput jens$ ls -l total 21744 -rw-r--r-- 1 jens staff 848 Jul 16 13:18 build.options.json -rw-r--r-- 1 jens staff 1723580 Jul 16 13:19 compile_commands.json drwxr-xr-x 2 jens staff 64 Jul 16 13:19 core -rw-r--r-- 1 jens staff 59690 Jul 16 13:19 includes.cache drwxr-xr-x 31 jens staff 992 Jul 16 13:19 libraries -rwxr-xr-x 1 jens staff 4664112 Jul 16 13:19 main.ino.elf -rw-r--r-- 1 jens staff 476816 Jul 16 13:19 main.ino.spk -rw-r--r-- 1 jens staff 4195871 Jul 16 13:19 output.map drwxr-xr-x 3 jens staff 96 Jul 16 13:19 preproc drwxr-xr-x 109 jens staff 3488 Jul 16 13:19 sketch
I searched the map file for "media_recorder_obj". There you can read libapps.a
(base) Mini-2:ArduinoOutput jens$ grep media_recorder_obj output.map | head -n1 /Users/jens/Library/Arduino15/packages/SPRESENSE_local/tools/spresense-sdk/2.5.2/spresense/release/nuttx/libs/libapps.a(modules-media_recorder_obj.Users.jens.work.mcu_prj.prj.spresense.references.spresense-sdk.spresense.sdk.modules.audio.o)
Opening libapps.a in a text editor does not make much sense because it is binary (except you see the strings of the symbols in this file)
If you need to dig deeper, you can have a look at the tools- objdump
- dwarfdump
- readelf
However I am no expert in reverse engineering. I would just dump as much as possible information and try to make sense by searching for keywords in the output.
In our case the source code is inside the Spresense SDK.
-
@jens6151-0-1-1 Hi Jens, Thank you for your kind reply. I misunderstood before. I thought that by opening the libapps.a file, there listed where the source file is located. Thanks again for your detailed explanation.
-
@jens6151-0-1-1 Hi Jens, I just noticed a issue. After installing the Arduino plugin for VS Code, I do not know where can I flash applications for subcores. The same issue exists in Arduino RC2.0. Do you have any ideas on this? Thank you in advance for any help.
-
VS Code
Open the commands (Ctrl+Shift+P) and find Board Config. There is also Select Sketch to choose the .ino file for the sub core.
There is also the bottom bar you can click for various actions and selections
Arduino IDE
Sorry, I am using 1.8.16.I noticed that switching cores and sketches in VSCode triggers a Verify automatically which can be tedious. It is possible to have both VSCode and Arduino IDE open. I have one for Main and one for Sub open. You just need to make sure not to block the other one by leaving the Serial Monitor open or try to flash in parallel. I read that you can open multiple instances of Arduino for each sub core (!! Arduino instances, not multiple sketches inside one Arduino instance)
-
@jens6151-0-1-1 Hi Jens, Thank you for your kind reply. Yes, If I do not open multiple Arduino instances, changing the configuration for one core will affect applications on other cores. I also use Arduino 1.8.19. I just noticed that there is a recent release called Arduino 2.0RC which has some improvements that the current Arduino IDE. While it has some compatible issues when running multicore programs.
Eventually, would you please tell me how you debug under the Arduino environment right now? Currently, I just use printf statement for debugging. Do you use other tools or a debugger when debugging?
Thank you in advance for your reply.
Best,
Larry
-
I believe debugging under Arduino is not possible.
I soldered the connector for SWD onto the extension board, but I have no idea how to attach the debugger. VS Code activates the Spresense SDK extension.Nevertheless there is hope. I did not investigate deelpy and a quick google search e.g. gives this page https://devblogs.microsoft.com/iotdev/debug-your-arduino-code-with-visual-studio-code/
In any case you need to do apply these instructions depending on your hardware
- https://developer.sony.com/develop/spresense/docs/hw_docs_lte_en.html#_how_to_use_the_jtag_debugger
- https://developer.sony.com/develop/spresense/docs/hw_docs_en.html#_HOW_TO_USE_JTAG_DEBUGGER
You also need special hardware. A debugger that supports Arm Cortex-M4.
-
OK it is more complex than I thought.
I only have a jlink device and no cmsis-dap device. So I am stuck. I will put this topic aside for now. Please let me know if you have more luck.For your reference
https://developer.sony.com/develop/spresense/docs/sdk_set_up_ide_en.html#_ice_debuggingThe configuration needs to be modified to work with Arduino. The instructions are only for the Spresense SDK.