How to change baud rate in Sony's Spresense

Question/Issue: Hello World, I have some problem for my Edge Impulse project in Spresense. The firmware what Edge Impulse build have 921600 (baud rate), but my device, Spresense have 115200 (baud rate). So, I want to change this boud rate in firmware to 115200, is this OK? If not, what can I do to fix it? Because, I think that is reason for my problem (image 2).

Thanks

image

Project ID: 229697

Context/Use case:

Hi @nntruyen ,

the initial connection with the deamon is always done at 115200.
The baud in the Device info is the maximum one which is used during streaming of the camera or when sending data to studio during ingestion, and for the Spresense is 921600.
As I said in the other topic, your problem is probably related to the model which is too big. I will try to have a look at it.

regards,
fv

I understand. But, What should I do to fix it? How to reduce the model?

If you make your EI project public I can clone it and try it on my Spresense.

2 Likes

I have make my project public, you can clone it now

I am getting the same results as you using the EI ready-to-go binary…investigating now…

I hope you find the cause and solution soon. it takes a lot of my time and I can’t continue my project.

@mmajchrzycki the Spresense firmware SDK release 09 May 2023 seems to have broken the ready-to-go binary.

  • I duplicated @nntruyen deployed version has the issue he described.
  • I get the same error when deploying a known good EI Impulse that previously worked on the Spresense, aka re-built the Model in the Studio and deployed via flash_windows.bat. I also tried in Ubuntu using ./flash_linux.sh
  • I did a make flash using an older version of the EI Spresense SDK and the edge-impulse-run-impulse worked as desired. I have no idea what version of the EI Spresense SDK I have in that project folder but it works. Is there a way to tell what version it is? Then, I could do a code diff to try and find the issue.
  • I tried a different Impulse that is an image classification, 160x160, RGB and get the same error nntruyen described.

Please advise.

1 Like

@Rocksetta or @louis when either of you get time could you take a known-good working image Impulse and re-deploy it using the latest version of the Studio to a Sony Spresense. I would like to get verification that the Edge Impulse Sony Spresense ready-to-go binary has a bug in it causing the Failed to allocate snapshot buffer error.

@nntruyen I am still trying to figure this out…

Hi @MMarcial
I’ll give a look at Sony, thx for reporting.

fv

1 Like

Hi @MMarcial
I tested the Beers vs Can project Beer vs. cans FOMO - Dashboard - Edge Impulse and it works - input image size is 96x96.
The error regarding the snapshot buffer is due that there is not enough RAM to allocate memory for the image - with an input image size of 160x160 the RAM required by the model is doubled and there is not enough free.
When you say

I get the same error when deploying a known good EI Impulse that previously worked on the Spresense

do you refer to an object detection model ? 96x96 or 160x160?

@nntruyen can you try to set the input image to 96x96 ?

fv

Hi @ei_francesco. I tried with 96x96 before, but the result is still the same.

Did you try to change model architecture ?
You can try different architecture with lower RAM requirement but with less accuracy.

@ei_francesco The @nntruyen project uses Sample images that are 28x28 pixels. The smallest image size for x-fer learning using Edge Impulse if 96x96. So I suspect there is an error when the Samples are upsized from 28x28 to 96x96.

The Beer FOMO does work as you said. My personal project that does image classification with images at 96x96 does work. The nntruyen image classification project with 28x28 images does not work.

Please advise.

@ei_francesco I verified this issue has todo with small Sample images, in this case 28x28 pixels.

BACKGROUND:

  • I exported data from my test project #134024 that has Sample images 320x240 captured by the Spresense in grayscale.
  • I reduced the size of the Sample images using a Python script that implemented
    • cv2.resize(img, (28, 28), interpolation = cv2.INTER_AREA).
  • I created a new EI Studio project
    • imported my small images and
    • setup the project #236133 with the same settings as project #134024.
    • The deployed EI ready-to-go binary and ran edge-impulse-run impulse that resulted in
ERR: Failed to allocate snapshot buffer!
Trying to allocate 57600!

Both of my projects use a 96x96 Image Data block in the Impulse design.

@nntruyen Form now, try increasing the size of your images.

With the latest update we increased the RAM consumption to support the streaming, see here firmware-sony-spresense/ei_camera_driver_sony.cpp at bb93749d2e94b2bdf3878b69e7c392b0ea99465d · edgeimpulse/firmware-sony-spresense · GitHub
I’ll try to reduce the number of buffer used for the video streaming mode.

But again, the error about the failed allocation it’s because the model is too big - an option is to change the architecture of the network as MobileNet v2 is pretty expensive in terms of RAM usage.

@MMarcial your project that works on 96x96 which architecture uses ?

@ei_francesco By architecture I assume you mean “what Impulse Learning Block” am I using. I am usin gthe Transfer Learning (Images) Impulse Learning Block.

image

I resized nntruyen digit data to 96x96 and 320x240 (outside of the Studio) and still got the buffer allocation issue. So I do not know what the issue is.

@nntruyen I recommend creating a new dataset by collecting data with the Sony Spresense camera.