From 6baf6568d2cb5e4f6b7fb7d414d0021f73c3478a Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 10 Feb 2016 22:58:12 +0200 Subject: [PATCH] Add "board_f_flash" option to Project Configuration File // Resolve #501 --- HISTORY.rst | 6 +++- docs/platforms/espressif_extra.rst | 43 ++++++++++++++++++------- docs/projectconf.rst | 11 +++++++ platformio/__init__.py | 2 +- platformio/boards/espressif.json | 11 +++++++ platformio/builder/main.py | 1 + platformio/builder/scripts/espressif.py | 12 +++---- 7 files changed, 67 insertions(+), 19 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 5ea55d36..d2a35725 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -7,6 +7,10 @@ PlatformIO 2.0 2.8.4 (2016-02-??) ~~~~~~~~~~~~~~~~~~ +* Added ``board_f_flash`` option to `Project Configuration File platformio.ini `__ + which allows to specify `custom flash frequency `_ + for Espressif development platform + (`issue #501 `_) * Fixed issue with ``CPPDEFINES`` which contain space and break PlatformIO IDE Linter (`IDE issue #34 `_) @@ -46,7 +50,7 @@ PlatformIO 2.0 * Added SPL-Framework support for Nucleo F401RE board (`issue #453 `_) * Added ``upload_resetmethod`` option to `Project Configuration File platformio.ini `__ - and allowed to `change default upload reset method `_ + which allows to specify `custom upload reset method `_ for Espressif development platform (`issue #444 `_) * Allowed to force output of color ANSI-codes or to disable progress bar even diff --git a/docs/platforms/espressif_extra.rst b/docs/platforms/espressif_extra.rst index 2b6d3c88..066ed842 100644 --- a/docs/platforms/espressif_extra.rst +++ b/docs/platforms/espressif_extra.rst @@ -9,19 +9,33 @@ See the License for the specific language governing permissions and limitations under the License. -Custom CPU Frequency or Upload Speed ------------------------------------- +Custom CPU Frequency +-------------------- -See :ref:`projectconf_board_f_cpu` and :ref:`projectconf_upload_speed` options -from :ref:`projectconf` +See :ref:`projectconf_board_f_cpu` option from :ref:`projectconf` .. code-block:: ini [env:myenv] - # set frequency to 40MHz - board_f_cpu = 40000000L + # set frequency to 160MHz + board_f_cpu = 160000000L - upload_speed = 9600 +Custom FLASH Frequency +---------------------- + +See :ref:`projectconf_board_f_flash` option from :ref:`projectconf`. Possible +values: + +* 20000000L +* 26000000L +* 40000000L +* 80000000L + +.. code-block:: ini + + [env:myenv] + # set frequency to 80MHz + board_f_flash = 80000000L Custom Reset Method ------------------- @@ -30,10 +44,7 @@ See :ref:`projectconf_upload_resetmethod` option from :ref:`projectconf` .. code-block:: ini - [env:esp12e] - platform = espressif - framework = arduino - board = esp12e + [env:myenv] upload_resetmethod = ck .. _platform_espressif_customflash: @@ -66,6 +77,16 @@ To override default LD script please use :ref:`projectconf_build_flags` from [env:myenv] build_flags = -Wl,-Tesp8266.flash.4m.ld +Custom Upload Speed +------------------- + +See :ref:`projectconf_upload_speed` option from :ref:`projectconf` + +.. code-block:: ini + + [env:myenv] + upload_speed = 9600 + .. _platform_espressif_uploadfs: Uploading files to file system SPIFFS diff --git a/docs/projectconf.rst b/docs/projectconf.rst index 93aeabc4..f6d92c3b 100644 --- a/docs/projectconf.rst +++ b/docs/projectconf.rst @@ -208,6 +208,17 @@ The full list of ``board_f_cpu`` for the popular embedded platforms you can find in *Boards* section of :ref:`platforms`. See "Frequency" column. You can overclock a board by specifying a ``board_f_cpu`` value other than the default. +.. _projectconf_board_f_flash: + +``board_f_flash`` +^^^^^^^^^^^^^^^^^ + +An option ``board_f_flash`` is used to define FLASH chip frequency (Hertz, Clock). A +format of this option is ``C-like long integer`` value with ``L`` suffix. The +1 Hertz is equal to ``1L``, then 40 Mhz (Mega Hertz) is equal to ``40000000L``. + +This option isn't available for the all development platforms. The only +:ref:`platform_espressif` supports it. Building options ~~~~~~~~~~~~~~~~ diff --git a/platformio/__init__.py b/platformio/__init__.py index bdb19b19..bf4a5d10 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (2, 8, "4.dev0") +VERSION = (2, 8, "4.dev1") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/boards/espressif.json b/platformio/boards/espressif.json index 63a250eb..8fb9617e 100644 --- a/platformio/boards/espressif.json +++ b/platformio/boards/espressif.json @@ -4,6 +4,7 @@ "core": "esp8266", "extra_flags": "-DESP8266 -DARDUINO_ARCH_ESP8266 -DARDUINO_ESP8266_ESP01", "f_cpu": "80000000L", + "f_flash": "40000000L", "ldscript": "esp8266.flash.512k64.ld", "mcu": "esp8266", "variant": "generic" @@ -27,6 +28,7 @@ "core": "esp8266", "extra_flags": "-DESP8266 -DARDUINO_ARCH_ESP8266 -DARDUINO_ESP8266_ESP01", "f_cpu": "80000000L", + "f_flash": "40000000L", "ldscript": "esp8266.flash.1m256.ld", "mcu": "esp8266", "variant": "generic" @@ -50,6 +52,7 @@ "core": "esp8266", "extra_flags": "-DESP8266 -DARDUINO_ARCH_ESP8266 -DARDUINO_ESP8266_ESP12", "f_cpu": "80000000L", + "f_flash": "40000000L", "ldscript": "esp8266.flash.4m1m.ld", "mcu": "esp8266", "variant": "nodemcu" @@ -73,6 +76,7 @@ "core": "esp8266", "extra_flags": "-DESP8266 -DARDUINO_ARCH_ESP8266 -DARDUINO_ESP8266_ESP12", "f_cpu": "80000000L", + "f_flash": "40000000L", "ldscript": "esp8266.flash.4m1m.ld", "mcu": "esp8266", "variant": "nodemcu" @@ -96,6 +100,7 @@ "core": "esp8266", "extra_flags": "-DESP8266 -DARDUINO_ARCH_ESP8266 -DARDUINO_ESP8266_ESP12", "f_cpu": "80000000L", + "f_flash": "40000000L", "ldscript": "esp8266.flash.4m1m.ld", "mcu": "esp8266", "variant": "adafruit" @@ -119,6 +124,7 @@ "core": "esp8266", "extra_flags": "-DESP8266 -DARDUINO_ARCH_ESP8266 -DARDUINO_MOD_WIFI_ESP8266", "f_cpu": "80000000L", + "f_flash": "40000000L", "ldscript": "esp8266.flash.2m.ld", "mcu": "esp8266", "variant": "generic" @@ -142,6 +148,7 @@ "core": "esp8266", "extra_flags": "-DESP8266 -DARDUINO_ARCH_ESP8266 -DARDUINO_ESP8266_THING", "f_cpu": "80000000L", + "f_flash": "40000000L", "ldscript": "esp8266.flash.512k64.ld", "mcu": "esp8266", "variant": "thing" @@ -165,6 +172,7 @@ "core": "esp8266", "extra_flags": "-DESP8266 -DARDUINO_ARCH_ESP8266 -DARDUINO_ESP8266_ESP210", "f_cpu": "80000000L", + "f_flash": "40000000L", "ldscript": "esp8266.flash.4m1m.ld", "mcu": "esp8266", "variant": "generic" @@ -188,6 +196,7 @@ "core": "esp8266", "extra_flags": "-DESP8266 -DARDUINO_ARCH_ESP8266 -DARDUINO_ESP8266_ESP12", "f_cpu": "80000000L", + "f_flash": "40000000L", "ldscript": "esp8266.flash.4m1m.ld", "mcu": "esp8266", "variant": "d1" @@ -211,6 +220,7 @@ "core": "esp8266", "extra_flags": "-DESP8266 -DARDUINO_ARCH_ESP8266 -DARDUINO_ESP8266_ESP12", "f_cpu": "80000000L", + "f_flash": "40000000L", "ldscript": "esp8266.flash.4m1m.ld", "mcu": "esp8266", "variant": "d1_mini" @@ -234,6 +244,7 @@ "core": "esp8266", "extra_flags": "-DESP8266 -DARDUINO_ARCH_ESP8266 -DARDUINO_ESP8266_ESP12", "f_cpu": "80000000L", + "f_flash": "40000000L", "ldscript": "esp8266.flash.4m1m.ld", "mcu": "esp8266", "variant": "espino" diff --git a/platformio/builder/main.py b/platformio/builder/main.py index 96428dbd..7b325287 100644 --- a/platformio/builder/main.py +++ b/platformio/builder/main.py @@ -51,6 +51,7 @@ commonvars.AddVariables( ("BOARD",), ("BOARD_MCU",), ("BOARD_F_CPU",), + ("BOARD_F_FLASH",), # upload options ("UPLOAD_PORT",), diff --git a/platformio/builder/scripts/espressif.py b/platformio/builder/scripts/espressif.py index 80f1574f..590f8d6a 100644 --- a/platformio/builder/scripts/espressif.py +++ b/platformio/builder/scripts/espressif.py @@ -42,17 +42,17 @@ def _get_flash_size(env): else "%dM" % (board_max_size / 1048576)) -def _get_board_f_cpu(env): - f_cpu = env.subst("$BOARD_F_CPU") - f_cpu = str(f_cpu).replace("L", "") - return int(int(f_cpu) / 1000000) +def _get_board_f_flash(env): + frequency = env.subst("$BOARD_F_FLASH") + frequency = str(frequency).replace("L", "") + return int(int(frequency) / 1000000) env = DefaultEnvironment() env.Replace( __get_flash_size=_get_flash_size, - __get_board_f_cpu=_get_board_f_cpu, + __get_board_f_flash=_get_board_f_flash, AR="xtensa-lx106-elf-ar", AS="xtensa-lx106-elf-as", @@ -150,7 +150,7 @@ env.Append( "eboot", "eboot.elf"), "-bo", "$TARGET", "-bm", "dio", - "-bf", "${__get_board_f_cpu(__env__)}", + "-bf", "${__get_board_f_flash(__env__)}", "-bz", "${__get_flash_size(__env__)}", "-bs", ".text", "-bp", "4096",