-->
Page 1 of 1

Determine chosen flash size at compile time?

PostPosted: Tue Sep 29, 2015 8:49 am
by mvdbro
Is there a way to determine the chosen flash size so you can use it as a compiler directive in the code?

Something like:

#if (ESP_FLASH_SIZE > 512)
< include extra goodies that will not fit the smaller versions...>
#endif

Re: Determine chosen flash size at compile time?

PostPosted: Tue Sep 29, 2015 9:41 am
by martinayotte
There no such mechanism already present for that.
You would need to add it yourself in platform.txt (and maybe elsewhere) a bit like it has been done for the F_CPU flag.

Re: Determine chosen flash size at compile time?

PostPosted: Tue Sep 29, 2015 11:02 am
by mvdbro
Ok, so that would mean that we have to provide our 'users' with a custom platform.txt file. Would probably raise more issues than we try to solve...

Can we make a feature request for this, so this will be maintained at the right place?

Re: Determine chosen flash size at compile time?

PostPosted: Tue Sep 29, 2015 12:51 pm
by martinayotte
I don't think it can become a priority for IGRR and other maintainers, since it has not been requested before.
But it should not be too risky to add it in platform.txt, especially if you do it yourself and do proper testing, since it is only adding a define nearby F_CPU such as :

Code: Select all-DF_CPU={build.f_cpu} -DESP_FLASH_SIZE={build.flash_size}


But be aware that the vulue of {build.flash_size} has currently some suffixes : 512K, 1M, 4M, so "greater than", like in your example, comparisons won't work ...