How can I solve this error message? " The generated code exceeds the available memory on the processor. It uses 12.1% of available program memory and 186.6% of available Data memory."
Show older comments
We are doing the simulink with arduino and chage the fft. Our simulink cording is this photo.
But When we start Simulink We can't solve this error message " The generated code exceeds the available memory on the processor. It uses 12.1% of available program memory and 186.6% of available Data memory."
Please...
3 Comments
Walter Roberson
on 10 May 2016
The image was not included.
Guillaume
on 10 May 2016
I don't know anything about simulink or arduino but the error message seems clear to me.
You have a finite amount of memory available on your arduino and the code generated by your model needs nearly twice as much memory as available to do its processing.
The only way you're going to solve this is by either reducing the amount of memory required (by processing half as much data maybe? or changing your algorithm so it doesn't need as much memory) or doubling the amount of memory available (which probably requires a different board).
Walter Roberson
on 2 Aug 2019
Also there are potentially some compiler switches that could be used to optimize for size instead of for speed. However, typically those do not account for an extra 86% memory use -- if the over-run on data was more than roughly 10% then I probably would not bother trying to pack it all in using just compiler switches.
In cases where you have large variables, then sometimes you encounter situations where you create a large variable, create a second large variable derived from it, and work with that second variable, and then loop back again. In such a case, after the second large variable is created you might not need the first one hanging around in memory, and it can sometimes make sense to assign [] to it or clear it.
Answers (4)
nimrah aftab
on 30 Nov 2019
0 votes
i am using arduino board and getting the get error while simulating basic radar model.
did you find any solution
error:
The following error occurred during deployment to your hardware board: The generated code exceeds the available memory on the processor. It uses 32.8% of available program memory and 431.4% of available Data memory.
2 Comments
Walter Roberson
on 30 Nov 2019
Your program uses arrays that are too large for Arduino. Only one of the Arduino boards created so far has more than 32 kilobytes of working memory. At the very least you will need to redesign your algorithm, but you should also consider the possibility that you are trying to do something that is too large of a problem for the Arduino.
Walter Roberson
on 9 Jan 2025
These days there are additional boards with more than 32 Kilobyte:
- Nicla Sense ME: 64 Kb (Harvard)
- Nano RP2040 Connect: 264 Kb (Von Neumann)
- Nano 33 BLE: 256 Kb (Harvard)
- Nano 33 BLE Sense: 256 Kb (Harvard)
Mohammad Zaki Patel
on 13 Nov 2022
0 votes
I was having the problem with Arduino Leonardo. I was able to fix the problem by clearing the Arduino EEPROM memory. There is some useful information on this page: How to Clear Arduino Memory Guide for Beginners (solderingironguide.com). There is a sample code available in Arduino IDE in examples to clear EEPROM memory.
1 Comment
paolo dini
on 23 Jan 2023
Edited: paolo dini
on 23 Jan 2023
I face the same issue.
Onestly the work-around of using the eeprom_clear example it doesn't works.
In any case i noticed that the problem is present only if i want use arduino in "preocessor-in-the-loop" , but if the code is directly deployed from simulink there is no issues.
So the problem is interaction with the simulation environment, not the memory footprint of the program itself (in arduino ide something like send & receive CAN-messages is very light!).
Nils
on 14 Jan 2024
0 votes
Buy a better Microcontroller, worked for me, switched from Arduino Uno to Arduino MEga 2560
16 Comments
The Tran
on 31 May 2024
I am facing the same problem while using fuzzy controller for arduino mega.Can you help me.
The following error occurred during deployment to your hardware board: The generated code exceeds the available memory on the processor. It uses 19.7% of available program memory and 261.1% of available Data memory.
Walter Roberson
on 5 Jun 2024
The maximum SRAM for Arduino is 32 kilobytes (less on some systems), except for the Arduino Due (96 kilobytes) and the Arduino GIGA R1 (1056 kilobytes)
However, your model needs about 83 kilobytes. You will need to use an Arduino Due or GIGA R1.
Pablo
on 9 Jan 2025
Hi, I'm facing the same issue but in my case the difference is huge it uses 253.2% of available program memory and 1715.8% of available data memory. GIGA R1 supports my program? I haven't found that model on the hardware board drop-down list. I have arduino uno.
Thank you!
Walter Roberson
on 9 Jan 2025
If that was "1715.8%" of 32 Kb, then Yes, in theory the GIGA R1 WiFi would support the model. https://docs.arduino.cc/resources/datasheets/ABX00063-datasheet.pdf -- STM32H747XI, 1 megabyte of RAM, 2 megabytes of flash.
Unfortunately.... the GIGA R1 is not one of the boards supported by the MATLAB Support Package for Arduino.
The largest supported board is probably the Arduino Nano 33 BLE Sense which supports 256 Kb. Which appears to be less than half of what you require.
In some cases you can reduce memory use by turning vectorized operations into double loops that update memory in-place
%not
A = A + B;
%instead
for K = 1 : size(A,2)
for J = 1 : size(A,2)
A(J,K) = A(J,K) + B(J,K);
end
end
but it is doubtful that you would be able to recover nearly enough memory in this way.
Perhaps you should consider using Raspberry Pi instead of Arduino; the Raspberry Pi 4 and 5 are each available with up to 8 gigabytes of memory.
Pablo
on 9 Jan 2025
Hi Walter, thank you for your answer I'm checking on Simulink and Raspberry Pi Pico and Pico W are the only available options on simulink. I need to send some PWM signals to. Is there any way to make it work with raspberry pi 4? I saw that model has PWM, I'd need to add a disipator to it should it work.
Thank you again!
Pablo
on 9 Jan 2025
this is what i can purchase asap if it works, is way cheaper than the arduino model you mentioned before.
Walter Roberson
on 9 Jan 2025
Pi 4 Model B (default) | Model B Rev1 | Model B Rev2 | Model B+ | Pi 2 Model B | Pi 3 Model B | Pi 3 Model B+ | Pi Zero W | Compute Module 4 | Pi Zero 2 W | Pi 5 Model
The 4B should do fine.
Pablo
on 9 Jan 2025
Hi Walter, I've just purchased the one I shares on Saturday it'll be here. So fingers crossed it will do. I need to add it a micro SD right? I've also purchased the dissipators.
Regards and thank you for your support. I'm really bad at this.
Pablo
on 9 Jan 2025
I've purchased it with 4 GB of ram
Walter Roberson
on 9 Jan 2025
Edited: Walter Roberson
on 9 Jan 2025
You will likely need a microSD.
4 GB of ram sounds like more than enough for your purposes.
Pablo
on 9 Jan 2025
righty. Just purchsed it. This work is for my thesis on my master's degree then I have to invest more money T.T
Pablo
on 9 Jan 2025
UHS-I will do? I don't know what speeds does it manage I can maybe purchase a good one to have a Linux computer later lol
Walter Roberson
on 10 Jan 2025
UHS-I will probably do. You can get a 64 gigabyte UHS-I card for roughly $US15 -- SanDisk Extreme or SanDisk Ultra.
Pablo
on 10 Jan 2025
Yep purchased sandisk extreme. But in Argentina it's extremely expensive. Purchased a 128 gb for 41 USD almost as expensive as the raspberry lol.
Pablo
on 12 Jan 2025
Well, after working a lot of hours and proofing the processing resources are enough for my application I see there's no way to interact with the model during runtime. Is there any way to enable that functionality? I.e with arduino I have several slider-gains to tune my model, but with the raspberry pi all of them are grayed out T.T
Pablo
on 20 Jan 2025
I finally fixed it under optimization under code generation turning the default parameter behaviour into Tunable.
Categories
Find more on MATLAB Support Package for Arduino Hardware in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!