Skip to content
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

[FEATURE] add -D ARDUINO_PARTITION_xxx build flag to platform.txt #5804

Merged
merged 3 commits into from Nov 6, 2021

Conversation

tobozo
Copy link
Contributor

@tobozo tobozo commented Oct 25, 2021

Proposition: adding -DARDUINO_PARTITION_{build.partitions} flag to make the build partition information available at compile time.

Use case examples:

#if defined ARDUINO_PARTITION_default
  // prevent compilation
  #error "This sketch needs 'Minimal SPIFFS' partition scheme to compile" 
  // or disable sketch features that need flash space
  #define USE_HUGE_BITMAP_IMAGES false
#endif
#if !defined ARDUINO_PARTITION_default_ffat
  #error "This sketch needs 'Default 4MB with ffat (1.2MB APP/1.5MB FATFS)' partition scheme to compile" 
#endif

Proposition: adding `-DARDUINO_PARTITION_{build.partitions}` flag to make the build partition information available at compile time.

Use cas example:

```C
#if defined ARDUINO_PARTITION_default
  // prevent compilation
  #error "This sketch needs 'Minimal SPIFFS' partition scheme to compile" 
  // or disable sketch features that need flash space
  #define USE_HUGE_BITMAP_IMAGES false
#endif
```
@CLAassistant
Copy link

CLAassistant commented Oct 25, 2021

CLA assistant check
All committers have signed the CLA.

@me-no-dev
Copy link
Member

This feature should also be added to pio the scripts. For ESP32 that is here:https://github.com/espressif/arduino-esp32/blob/master/tools/platformio-build-esp32.py#L313

@tobozo
Copy link
Contributor Author

tobozo commented Nov 4, 2021

Does this seem correct?

    '\\"ARDUINO_PARTITION_%s\\"' % env.BoardConfig().get("build.partitions").replace('"', "")

@me-no-dev
Copy link
Member

maybe something like this? can you test it?

"ARDUINO_PARTITION_%s" % env.BoardConfig().get("build.partitions", "default.csv").replace('.csv', "")

@me-no-dev
Copy link
Member

@ivankravets @valeros could you propose what is correct here?

@valeros
Copy link
Contributor

valeros commented Nov 4, 2021

Hi guys, the variant @me-no-dev suggested looks good, so in the script it should look something like this:

env.Append(
    CPPDEFINES=[
       ...
       "ARDUINO_PARTITION_%s" % env.BoardConfig().get("build.partitions", "default.csv").replace(".csv", "")
   ]
)

@me-no-dev me-no-dev merged commit 674cf81 into espressif:master Nov 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants