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.
Upgrading spresense board flash memory
-
Hi I am in the process of (physically) upgrading the QSPI Flash with a pin compatible device that will boost the flash from 8MBytes to 256MByte(I believe this is the maximum allowable in the CPU memory map). It will probably be ready next week and will keep you guys posted how it goes.
-
Physically upgrading the Flash will not work because Secure CPU defined fixed size of partitions, for SPK area and User area.
So even if you re-worked SPI Flash, it is the same size on software side. -
@CamilaSouza oh phew so someone in the spresense design team decided to lock this to just 8M . I understand why from security perspective . Perhaps they try to keep the cost of the board down by keeping it to 8M? (a bit of "waste"-just like Raspi 4 which apparently could have had more memory, Well I guess they have done some "market research".
The rework was done by a professional (photo attached). I am trying to flash the bootloader with no success. so far
./tools/flash.sh -l /home/ucuma/spresense/firmware/spresense -c COM8
the QSPI commands are not 100% compatible but the basic command should be compatible. I have no idea however which commands are used by the flasher..
Here's the original 8MB (Macronix)
https://www.digikey.com/en/products/detail/macronix/MX25U6435FZNI-10G/3886217This is the 256MB (Winbond)
https://www.digikey.jp/ja/products/detail/winbond-electronics/W25M02GWZEIG/12143325The package is slightly bigger hence wires had to be used
-
@maxieaussie-0 it's also interesting that in the boards.txt (Arduino board definition) these numbers are specified.
First they don't seems to be related to the physical sizes? Second it sort of implied the flash and the RAM are of the same size? (I am not too familiar with Arduino actually)"spresense.upload.maximum_size=786432
spresense.upload.maximum_data_size=786432" -
@maxieaussie-0 btw recovery tools does not seems to work either :-).
-
Hi @maxieaussie-0!
The Arduino documentation explains a little bit about these two parameters on the boards.txt
https://arduino.github.io/arduino-cli/0.29/platform-specification/#recipes-to-compute-binary-sketch-sizeTwo properties can be used to define the total available memory: {upload.maximum_size}: available program storage space {upload.maximum_data_size}: available dynamic memory for global variables If the binary sketch size exceeds the value of these properties, the compilation process fails.
You choose this parameter in the Arduino IDE by going to Tools -> Memory.
The default is 768 KB, so that's why yours looks like that. -
I used the recovery tool last week and it worked for me.
Can you describe what happened? -
@maxieaussie-0
Let me investigate this about the commands that are used by the flasher and get back to you. -
This post is deleted! -
@CamilaSouza said in Upgrading spresense board flash memory:
I used the recovery tool last week and it worked for me.
Can you describe what happened?the incrementing dots just stopped a some point (after pressing those buttons in the correct sequence/way). It seems that I now have a "bricked" spresense board lol (I have 2 other ones though).
-
@CamilaSouza I attached below the content of the boards.txt file found in
C:\Users<myusername>\AppData\Local\Arduino15\packages\SPRESENSE\hardware\spresense\2.6.0
(again I am not really familiar with Arduino, usually just use "normal" embedded programming ).
line 48-59 are most likely that gives the options of "Memory size" in the IDE (it corresponds to those).If you scroll down further to line 61-85 these seems to specify the flash size and RAM size
The question remains is that why the maximum Flash size specified (1536 KB/ 1572864-I think they have taken in to account bootloader size, etc) seems to be the same as RAM size?
I am assuming Flash size is specified by "upload.maximum_size" and RAM is specified by "upload.maximum_data_size"- by looking at other "boards.txt" from other Arduino boards
(UNO Mini, Leonardo, Micro, Nano)Perhaps Sony team who wrote spresense board definition could shed some light?
Thanksmenu.Debug=Debug menu.Core=Core menu.Memory=Memory menu.UploadSpeed=UploadSpeed ############## Spresense BOARD ############## spresense.name=Spresense spresense.vid.0=0x10C4 spresense.pid.0=0xEA60 spresense.upload.tool=spresense-tools spresense.upload.speed=115200 spresense.upload.resetmethod=ck spresense.upload.maximum_size=786432 spresense.upload.maximum_data_size=786432 spresense.upload.wait_for_upload_port=true spresense.serial.disableDTR=false spresense.serial.disableRTS=true spresense.bootloader.tool=spresense-tools spresense.build.mcu=spresense spresense.build.f_cpu=156000000L spresense.build.board=spresense_ast spresense.build.core=spresense spresense.menu.Core.Main=MainCore spresense.menu.Core.Sub1=SubCore 1 spresense.menu.Core.Sub2=SubCore 2 spresense.menu.Core.Sub3=SubCore 3 spresense.menu.Core.Sub4=SubCore 4 spresense.menu.Core.Sub5=SubCore 5 spresense.menu.Core.Sub1.index=1 spresense.menu.Core.Sub2.index=2 spresense.menu.Core.Sub3.index=3 spresense.menu.Core.Sub4.index=4 spresense.menu.Core.Sub5.index=5 spresense.menu.Core.Main.build.flash_name=nuttx spresense.menu.Core.Sub1.build.flash_name=sub1 spresense.menu.Core.Sub2.build.flash_name=sub2 spresense.menu.Core.Sub3.build.flash_name=sub3 spresense.menu.Core.Sub4.build.flash_name=sub4 spresense.menu.Core.Sub5.build.flash_name=sub5 spresense.menu.Memory.768= 768 KB (Default) spresense.menu.Memory.128= 128 KB spresense.menu.Memory.256= 256 KB spresense.menu.Memory.384= 384 KB spresense.menu.Memory.512= 512 KB spresense.menu.Memory.640= 640 KB spresense.menu.Memory.896= 896 KB spresense.menu.Memory.1024=1024 KB spresense.menu.Memory.1152=1152 KB spresense.menu.Memory.1280=1280 KB spresense.menu.Memory.1408=1408 KB spresense.menu.Memory.1536=1536 KB spresense.menu.Memory.128.upload.maximum_size=131072 spresense.menu.Memory.256.upload.maximum_size=262144 spresense.menu.Memory.384.upload.maximum_size=393216 spresense.menu.Memory.512.upload.maximum_size=524288 spresense.menu.Memory.640.upload.maximum_size=655360 spresense.menu.Memory.768.upload.maximum_size=786432 spresense.menu.Memory.896.upload.maximum_size=917504 spresense.menu.Memory.1024.upload.maximum_size=1048576 spresense.menu.Memory.1152.upload.maximum_size=1179648 spresense.menu.Memory.1280.upload.maximum_size=1310720 spresense.menu.Memory.1408.upload.maximum_size=1441792 spresense.menu.Memory.1536.upload.maximum_size=1572864 spresense.menu.Memory.128.upload.maximum_data_size=131072 spresense.menu.Memory.256.upload.maximum_data_size=262144 spresense.menu.Memory.384.upload.maximum_data_size=393216 spresense.menu.Memory.512.upload.maximum_data_size=524288 spresense.menu.Memory.640.upload.maximum_data_size=655360 spresense.menu.Memory.768.upload.maximum_data_size=786432 spresense.menu.Memory.896.upload.maximum_data_size=917504 spresense.menu.Memory.1024.upload.maximum_data_size=1048576 spresense.menu.Memory.1152.upload.maximum_data_size=1179648 spresense.menu.Memory.1280.upload.maximum_data_size=1310720 spresense.menu.Memory.1408.upload.maximum_data_size=1441792 spresense.menu.Memory.1536.upload.maximum_data_size=1572864 spresense.menu.Core.Main.build.extra_flags= spresense.menu.Core.Sub1.build.extra_flags=-DSUBCORE=1 spresense.menu.Core.Sub2.build.extra_flags=-DSUBCORE=2 spresense.menu.Core.Sub3.build.extra_flags=-DSUBCORE=3 spresense.menu.Core.Sub4.build.extra_flags=-DSUBCORE=4 spresense.menu.Core.Sub5.build.extra_flags=-DSUBCORE=5 spresense.menu.Core.Main.build.type_prefix= spresense.menu.Core.Sub1.build.type_prefix=subcore- spresense.menu.Core.Sub2.build.type_prefix=subcore- spresense.menu.Core.Sub3.build.type_prefix=subcore- spresense.menu.Core.Sub4.build.type_prefix=subcore- spresense.menu.Core.Sub5.build.type_prefix=subcore- spresense.menu.Core.Main.build.variant=spresense spresense.menu.Core.Sub1.build.variant=spresense_sub spresense.menu.Core.Sub2.build.variant=spresense_sub spresense.menu.Core.Sub3.build.variant=spresense_sub spresense.menu.Core.Sub4.build.variant=spresense_sub spresense.menu.Core.Sub5.build.variant=spresense_sub spresense.menu.Core.Main.build.stack=-Wl,--defsym,__reserved_ramsize=1572864-{upload.maximum_size} spresense.menu.Core.Sub1.build.stack= spresense.menu.Core.Sub2.build.stack= spresense.menu.Core.Sub3.build.stack= spresense.menu.Core.Sub4.build.stack= spresense.menu.Core.Sub5.build.stack= spresense.menu.Core.Main.build.libs="{build.libpath}/libapps.a" "{build.libpath}/libarch.a" "{build.libpath}/libarm_cortexM4lf_math.a" "{build.libpath}/libaudio.a" "{build.libpath}/libbinfmt.a" "{build.libpath}/libboard.a" "{build.libpath}/libboards.a" "{build.libpath}/libc.a" "{build.libpath}/libcmsis_nn.a" "{build.libpath}/libdrivers.a" "{build.libpath}/libfs.a" "{build.libpath}/libmm.a" "{build.libpath}/libnet.a" "{build.libpath}/libnnablart.a" "{build.libpath}/libsched.a" "{build.libpath}/libsslutils.a" "{build.libpath}/libxx.a" spresense.menu.Core.Sub1.build.libs="{build.libpath}/libapps.a" "{build.libpath}/libarch.a" "{build.libpath}/libarm_cortexM4lf_math.a" "{build.libpath}/libbinfmt.a" "{build.libpath}/libboard.a" "{build.libpath}/libboards.a" "{build.libpath}/libc.a" "{build.libpath}/libcmsis_nn.a" "{build.libpath}/libdrivers.a" "{build.libpath}/libfs.a" "{build.libpath}/libmm.a" "{build.libpath}/libsched.a" "{build.libpath}/libxx.a" spresense.menu.Core.Sub2.build.libs="{build.libpath}/libapps.a" "{build.libpath}/libarch.a" "{build.libpath}/libarm_cortexM4lf_math.a" "{build.libpath}/libbinfmt.a" "{build.libpath}/libboard.a" "{build.libpath}/libboards.a" "{build.libpath}/libc.a" "{build.libpath}/libcmsis_nn.a" "{build.libpath}/libdrivers.a" "{build.libpath}/libfs.a" "{build.libpath}/libmm.a" "{build.libpath}/libsched.a" "{build.libpath}/libxx.a" spresense.menu.Core.Sub3.build.libs="{build.libpath}/libapps.a" "{build.libpath}/libarch.a" "{build.libpath}/libarm_cortexM4lf_math.a" "{build.libpath}/libbinfmt.a" "{build.libpath}/libboard.a" "{build.libpath}/libboards.a" "{build.libpath}/libc.a" "{build.libpath}/libcmsis_nn.a" "{build.libpath}/libdrivers.a" "{build.libpath}/libfs.a" "{build.libpath}/libmm.a" "{build.libpath}/libsched.a" "{build.libpath}/libxx.a" spresense.menu.Core.Sub4.build.libs="{build.libpath}/libapps.a" "{build.libpath}/libarch.a" "{build.libpath}/libarm_cortexM4lf_math.a" "{build.libpath}/libbinfmt.a" "{build.libpath}/libboard.a" "{build.libpath}/libboards.a" "{build.libpath}/libc.a" "{build.libpath}/libcmsis_nn.a" "{build.libpath}/libdrivers.a" "{build.libpath}/libfs.a" "{build.libpath}/libmm.a" "{build.libpath}/libsched.a" "{build.libpath}/libxx.a" spresense.menu.Core.Sub5.build.libs="{build.libpath}/libapps.a" "{build.libpath}/libarch.a" "{build.libpath}/libarm_cortexM4lf_math.a" "{build.libpath}/libbinfmt.a" "{build.libpath}/libboard.a" "{build.libpath}/libboards.a" "{build.libpath}/libc.a" "{build.libpath}/libcmsis_nn.a" "{build.libpath}/libdrivers.a" "{build.libpath}/libfs.a" "{build.libpath}/libmm.a" "{build.libpath}/libsched.a" "{build.libpath}/libxx.a" ### without SYSBUS spresense.build.ldscript=-T{variant.path}/ramconfig.ld ### with SYSBUS #spresense.build.ldscript=-T{variant.path}/ramconfig-new.ld spresense.build.root={runtime.tools.spresense-sdk.path}/spresense spresense.build.kernel={build.root}/{build.type} spresense.build.libpath={build.kernel}/nuttx/libs spresense.menu.Debug.Disabled=Disabled spresense.menu.Debug.Disabled.build.debug= spresense.menu.Debug.Disabled.build.type={build.type_prefix}release spresense.menu.Debug.Enabled=Enabled spresense.menu.Debug.Enabled.build.debug=-DBRD_DEBUG spresense.menu.Debug.Enabled.build.type={build.type_prefix}debug spresense.menu.UploadSpeed.115200=115200 spresense.menu.UploadSpeed.115200.upload.speed= spresense.menu.UploadSpeed.230400=230400 spresense.menu.UploadSpeed.230400.upload.speed=-b 230400 spresense.menu.UploadSpeed.460800=460800 spresense.menu.UploadSpeed.460800.upload.speed=-b 460800 spresense.menu.UploadSpeed.500000=500000 spresense.menu.UploadSpeed.500000.upload.speed=-b 500000 spresense.menu.UploadSpeed.576000=576000 spresense.menu.UploadSpeed.576000.upload.speed=-b 576000 spresense.menu.UploadSpeed.921600=921600 spresense.menu.UploadSpeed.921600.upload.speed=-b 921600 spresense.menu.UploadSpeed.1000000=1000000 spresense.menu.UploadSpeed.1000000.upload.speed=-b 1000000 spresense.menu.UploadSpeed.1152000=1152000 spresense.menu.UploadSpeed.1152000.upload.speed=-b 1152000
-
Hm... You're the second user to report this issue. But I haven't been able to reproduce it.
Let me ask you, what is the operating system you used with the recovery tool? -
@maxieaussie-0
I am not with the Sony team but I can point you to the fact that the Spresense bootloader takes the uploaded binary, copies it to RAM and executes the code from RAM. The Flash is connected via a system MCU. You cannot access flash directly from the application cores. There is no code execution from Flash memory. All your code ends up in the RAM effectively reducing the memory for stack & heap memory. So the maximum for your Arduino application is in fact 1536KB.
See the line below. The setting is used to configure how much memory you will reserve for the sub cores. Second usage is the check if your program fits into memory.-Wl,--defsym,__reserved_ramsize=1572864-{upload.maximum_size}
May I ask what is the reason for the QSPI Flash upgrade?
-
@jens6151-0-1-1 Hi Jens. Ouch! Thanks for clarifying this. I was hoping to store my tflite model which is not so lite :-)-tried all conversion options with no luck . Converted to const it ended up around 56,172,546 I think I might have to change to a Renesas RZ/V2L MCUs! (I am not into Coral Boards and alikes). I was only using Arduino for a quick check but yes even with any other option there is no way the model would fit!
-
Exactly, @jens6151-0-1-1
Thanks for the answer. -
@maxieaussie-0 said in Upgrading spresense board flash memory:
@jens6151-0-1-1 Hi Jens. Ouch! Thanks for clarifying this. I was hoping to store my tflite model which is not so lite :-)-tried all conversion options with no luck . Converted to const it ended up around 56,172,546 I think I might have to change to a Renesas RZ/V2L MCUs! (I am not into Coral Boards and alikes). I was only using Arduino for a quick check but yes even with any other option there is no way the model would fit!
Yes, this is the major defect with the SPRESENSE. You do not have XIP so in practice the maximum model size is much less than 8MiB, and that needs to be fixed on the edge impulse site otherwise people will try to use large models.
-
I see your point.
We are always trying to improve our documentation and all feedback is valuable.
I'll share your feedback with the responsible parties.