-
Notifications
You must be signed in to change notification settings - Fork 5
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
Improve memory footprint for C6 builds #2
Comments
This check in simplefoc/Arduino-FOC#285 should help reduce the memory size by ~270 bytes (haven't tested it, just base on the sin table size reduction |
Now with current_sense mostly working:
Is there even a slightest chance to make this (dev) repo here running on a 32k GD32F130 ??? |
@RoboDurden very unlikely we'll ever be able to reduce the code by more than 25% to squeeze from ~42k to 32k. When I looked at this, there was no obvious candidate for reduction. So it will be mostly a matter of small, surgical optimizations of few tens or hundreds bytes here or there. Which are unlikely to ever add up to >10k bytes |
Yes i also fear that this will be impossible. Yet @Candas1 just found out (#6 (comment) ) that only replacing the mathematical pow function will reduce the code size by 11%:
And i would be willing to strip functionality like current_sensing andOr FOC for those boards only having the 32k MCU. |
I already opened an issue to simplefoc about this, I see no reason they will not accept as it's also impacting stm32, at least it terms of flash usage. It's going in the right direction. I think your formula is wrong by the way, this should be good enough |
Yes my formula is wrong. But also because the usage of |
Yes and with 12 bit, the max adc value is |
That's not what is written on the screenshot. But anyway that's a detail. |
I only mentioned the missing -1 in lines 24 and 27 of I think your screenshot is wrong :-) For 12 bit i just stumbled over these lines in the Gen2 firmware confirming the 4095 = 2^n-1:
|
This discussion is all over the internet. So this improvement will reduce impact of on the flash usage. Because this library let's you use features on the fly like SinePWM or SVPWM, it uses memory even if finaly you are using only SVPWM. |
When i delete all unneccessary Simple_FOC and Simple_FOC_drivers libray files i get a bit less memory usage:
When i continue to delete the Simple FOC\src\drivers\hardware_specific\xy foldes with only GD32 remaining, i get the compiler errors:
Any ideas which files is including stm32 and esp32 stuff ??? |
@RoboDurden I'm not sure I understand the logic of deleting files... Even if the compiler has to compile a few unused extra files, the linker will only add the code actually used. There's no way to reduce the memory footprint by deleting files. Your before and after might be different due to other code changes that you introduced while deleting the files. But unless there's something really weird in your configuration, deleting files should make no difference. |
This is a work item and a memory reminder.
Low hanging fruits are debug messages and the SIN/COS tables. The SimpleFOC team is also implementing a more efficient set of functions using smaller tables, so before optimizing the existing code we should wait for the new code (https://community.simplefoc.com/t/embedded-world-2023-stm32-cordic-co-processor/3107/81)
At the beginning, I think it would be more productive to use C8 processors which have more than enough FLASH for anything. Once the code is closer to being final, we can look for ways to optimize size. Optimizing heavily now will result in a lot of wasted time optimizing things that will change
The text was updated successfully, but these errors were encountered: