From f2454c07dde912248b1d6eaaab4b24e5143b9313 Mon Sep 17 00:00:00 2001 From: Valeriy Koval Date: Sun, 13 Nov 2016 21:51:15 +0200 Subject: [PATCH] Supplement examples with new boards --- examples/arduino-blink/README.rst | 4 +- examples/arduino-blink/platformio.ini | 10 +++ examples/arduino-wifiscan/README.rst | 4 +- examples/arduino-wifiscan/platformio.ini | 14 ++++- examples/arduino-wifiscan/src/WiFiScan.ino | 2 +- examples/espidf-hello-world/.gitignore | 3 + examples/espidf-hello-world/.travis.yml | 65 ++++++++++++++++++++ examples/espidf-hello-world/README.rst | 38 ++++++++++++ examples/espidf-hello-world/lib/readme.txt | 38 ++++++++++++ examples/espidf-hello-world/platformio.ini | 23 +++++++ examples/espidf-hello-world/src/main.c | 32 ++++++++++ examples/espidf-hello-world/src/sdkconfig.h | 53 ++++++++++++++++ examples/espidf-http-request/README.rst | 13 +++- examples/espidf-http-request/platformio.ini | 18 +++++- examples/espidf-http-request/src/sdkconfig.h | 51 +++++++++++++++ 15 files changed, 356 insertions(+), 12 deletions(-) create mode 100644 examples/espidf-hello-world/.gitignore create mode 100644 examples/espidf-hello-world/.travis.yml create mode 100644 examples/espidf-hello-world/README.rst create mode 100644 examples/espidf-hello-world/lib/readme.txt create mode 100644 examples/espidf-hello-world/platformio.ini create mode 100644 examples/espidf-hello-world/src/main.c create mode 100644 examples/espidf-hello-world/src/sdkconfig.h create mode 100644 examples/espidf-http-request/src/sdkconfig.h diff --git a/examples/arduino-blink/README.rst b/examples/arduino-blink/README.rst index 2bb346a..c455a2d 100644 --- a/examples/arduino-blink/README.rst +++ b/examples/arduino-blink/README.rst @@ -29,10 +29,10 @@ How to build PlatformIO based project > platformio run --target upload # Build specific environment - > platformio run -e nodemcuv2 + > platformio run -e esp32dev # Upload firmware for the specific environment - > platformio run -e nodemcuv2 --target upload + > platformio run -e esp32dev --target upload # Clean build files > platformio run --target clean diff --git a/examples/arduino-blink/platformio.ini b/examples/arduino-blink/platformio.ini index 42a8c81..9748671 100644 --- a/examples/arduino-blink/platformio.ini +++ b/examples/arduino-blink/platformio.ini @@ -11,3 +11,13 @@ platform = espressif32 framework = arduino board = esp32dev + +[env:quantum] +platform = espressif32 +framework = arduino +board = quantum + +[env:lolin32] +platform = espressif32 +framework = arduino +board = lolin32 diff --git a/examples/arduino-wifiscan/README.rst b/examples/arduino-wifiscan/README.rst index eb2609b..49dfa1a 100644 --- a/examples/arduino-wifiscan/README.rst +++ b/examples/arduino-wifiscan/README.rst @@ -29,10 +29,10 @@ How to build PlatformIO based project > platformio run --target upload # Build specific environment - > platformio run -e nodemcuv2 + > platformio run -e quantum # Upload firmware for the specific environment - > platformio run -e nodemcuv2 --target upload + > platformio run -e quantum --target upload # Clean build files > platformio run --target clean diff --git a/examples/arduino-wifiscan/platformio.ini b/examples/arduino-wifiscan/platformio.ini index 42a8c81..c359dfd 100644 --- a/examples/arduino-wifiscan/platformio.ini +++ b/examples/arduino-wifiscan/platformio.ini @@ -7,7 +7,17 @@ ; Please visit documentation for the other options and examples ; http://docs.platformio.org/en/stable/projectconf.html -[env:esp32dev] +[env:nano32] platform = espressif32 framework = arduino -board = esp32dev +board = nano32 + +[env:espea32] +platform = espressif32 +framework = arduino +board = espea32 + +[env:esp320] +platform = espressif32 +framework = arduino +board = esp320 diff --git a/examples/arduino-wifiscan/src/WiFiScan.ino b/examples/arduino-wifiscan/src/WiFiScan.ino index 5d11fbb..67ac308 100644 --- a/examples/arduino-wifiscan/src/WiFiScan.ino +++ b/examples/arduino-wifiscan/src/WiFiScan.ino @@ -45,4 +45,4 @@ void loop() // Wait a bit before scanning again delay(5000); -} +} \ No newline at end of file diff --git a/examples/espidf-hello-world/.gitignore b/examples/espidf-hello-world/.gitignore new file mode 100644 index 0000000..5402c18 --- /dev/null +++ b/examples/espidf-hello-world/.gitignore @@ -0,0 +1,3 @@ +.pioenvs +.clang_complete +.gcc-flags.json diff --git a/examples/espidf-hello-world/.travis.yml b/examples/espidf-hello-world/.travis.yml new file mode 100644 index 0000000..72c6e43 --- /dev/null +++ b/examples/espidf-hello-world/.travis.yml @@ -0,0 +1,65 @@ +# Continuous Integration (CI) is the practice, in software +# engineering, of merging all developer working copies with a shared mainline +# several times a day < http://docs.platformio.org/en/stable/ci/index.html > +# +# Documentation: +# +# * Travis CI Embedded Builds with PlatformIO +# < https://docs.travis-ci.com/user/integration/platformio/ > +# +# * PlatformIO integration with Travis CI +# < http://docs.platformio.org/en/stable/ci/travis.html > +# +# * User Guide for `platformio ci` command +# < http://docs.platformio.org/en/stable/userguide/cmd_ci.html > +# +# +# Please choice one of the following templates (proposed below) and uncomment +# it (remove "# " before each line) or use own configuration according to the +# Travis CI documentation (see above). +# + + +# +# Template #1: General project. Test it using existing `platformio.ini`. +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# install: +# - pip install -U platformio +# +# script: +# - platformio run + + +# +# Template #2: The project is intended to by used as a library with examples +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# env: +# - PLATFORMIO_CI_SRC=path/to/test/file.c +# - PLATFORMIO_CI_SRC=examples/file.ino +# - PLATFORMIO_CI_SRC=path/to/test/directory +# +# install: +# - pip install -U platformio +# +# script: +# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N diff --git a/examples/espidf-hello-world/README.rst b/examples/espidf-hello-world/README.rst new file mode 100644 index 0000000..a30e25c --- /dev/null +++ b/examples/espidf-hello-world/README.rst @@ -0,0 +1,38 @@ +.. Copyright 2014-present PlatformIO + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +How to build PlatformIO based project +===================================== + +1. `Install PlatformIO `_ +2. Download `development platform with examples `_ +3. Extract ZIP archive +4. Run these commands: + +.. code-block:: bash + + # Change directory to example + > cd platform-espressif32/examples/espidf-hello-world + + # Build project + > platformio run + + # Upload firmware + > platformio run --target upload + + # Build specific environment + > platformio run -e esp32dev + + # Upload firmware for the specific environment + > platformio run -e esp32dev --target upload + + # Clean build files + > platformio run --target clean diff --git a/examples/espidf-hello-world/lib/readme.txt b/examples/espidf-hello-world/lib/readme.txt new file mode 100644 index 0000000..a3271c7 --- /dev/null +++ b/examples/espidf-hello-world/lib/readme.txt @@ -0,0 +1,38 @@ + +This directory is intended for the project specific (private) libraries. +PlatformIO will compile them to static libraries and link to executable file. + +The source code of each library should be placed in separate directory, like +"lib/private_lib/[here are source files]". + +For example, see how can be organised `Foo` and `Bar` libraries: + +|--lib +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| |--Foo +| | |- Foo.c +| | |- Foo.h +| |- readme.txt --> THIS FILE +|- platformio.ini +|--src + |- main.c + +Then in `src/main.c` you should use: + +#include +#include + +// rest H/C/CPP code + +PlatformIO will find your libraries automatically, configure preprocessor's +include paths and build them. + +See additional options for PlatformIO Library Dependency Finder `lib_*`: + +http://docs.platformio.org/en/stable/projectconf.html#lib-install + diff --git a/examples/espidf-hello-world/platformio.ini b/examples/espidf-hello-world/platformio.ini new file mode 100644 index 0000000..b3b366a --- /dev/null +++ b/examples/espidf-hello-world/platformio.ini @@ -0,0 +1,23 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter, extra scripting +; Upload options: custom port, speed and extra flags +; Library options: dependencies, extra library storages +; +; Please visit documentation for the other options and examples +; http://docs.platformio.org/en/stable/projectconf.html + +[env:esp32dev] +platform = espressif32 +framework = espidf +board = esp32dev + +[env:quantum] +platform = espressif32 +framework = espidf +board = quantum + +[env:lolin32] +platform = espressif32 +framework = espidf +board = lolin32 diff --git a/examples/espidf-hello-world/src/main.c b/examples/espidf-hello-world/src/main.c new file mode 100644 index 0000000..0b37e55 --- /dev/null +++ b/examples/espidf-hello-world/src/main.c @@ -0,0 +1,32 @@ +/* Hello World Example + + This example code is in the Public Domain (or CC0 licensed, at your option.) + + Unless required by applicable law or agreed to in writing, this + software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + CONDITIONS OF ANY KIND, either express or implied. +*/ +#include +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include "esp_system.h" +#include "nvs_flash.h" + +void hello_task(void *pvParameter) +{ + printf("Hello world!\n"); + for (int i = 10; i >= 0; i--) { + printf("Restarting in %d seconds...\n", i); + vTaskDelay(1000 / portTICK_RATE_MS); + } + printf("Restarting now.\n"); + fflush(stdout); + system_restart(); +} + +void app_main() +{ + nvs_flash_init(); + system_init(); + xTaskCreate(&hello_task, "hello_task", 2048, NULL, 5, NULL); +} \ No newline at end of file diff --git a/examples/espidf-hello-world/src/sdkconfig.h b/examples/espidf-hello-world/src/sdkconfig.h new file mode 100644 index 0000000..1fd4b81 --- /dev/null +++ b/examples/espidf-hello-world/src/sdkconfig.h @@ -0,0 +1,53 @@ +/* + * + * Automatically generated file; DO NOT EDIT. + * Espressif IoT Development Framework Configuration + * + */ +#define CONFIG_TRACEMEM_RESERVE_DRAM 0x0 +#define CONFIG_FREERTOS_CHECK_STACKOVERFLOW_NONE 1 +#define CONFIG_ESPTOOLPY_FLASHFREQ "80m" +#define CONFIG_NEWLIB_STDOUT_ADDCR 1 +#define CONFIG_FREERTOS_PANIC_PRINT_REBOOT 1 +#define CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS 1 +#define CONFIG_LOG_DEFAULT_LEVEL_INFO 1 +#define CONFIG_BT_RESERVE_DRAM 0x0 +#define CONFIG_LWIP_MAX_SOCKETS 4 +#define CONFIG_ULP_COPROC_RESERVE_MEM 0 +#define CONFIG_ESPTOOLPY_BAUD 921600 +#define CONFIG_TOOLPREFIX "xtensa-esp32-elf-" +#define CONFIG_LWIP_THREAD_LOCAL_STORAGE_INDEX 0 +#define CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN 16384 +#define CONFIG_ESP32_ENABLE_STACK_WIFI 1 +#define CONFIG_LOG_BOOTLOADER_LEVEL_WARN 1 +#define CONFIG_MAIN_TASK_STACK_SIZE 4096 +#define CONFIG_ESPTOOLPY_FLASHMODE "dio" +#define CONFIG_LOG_DEFAULT_LEVEL 3 +#define CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION 1 +#define CONFIG_ESPTOOLPY_FLASHMODE_DIO 1 +#define CONFIG_PYTHON "python" +#define CONFIG_ESPTOOLPY_COMPRESSED 1 +#define CONFIG_PARTITION_TABLE_FILENAME "partitions_singleapp.csv" +#define CONFIG_WIFI_SSID "myssid" +#define CONFIG_PARTITION_TABLE_SINGLE_APP 1 +#define CONFIG_WIFI_ENABLED 1 +#define CONFIG_ESPTOOLPY_FLASHFREQ_80M 1 +#define CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE 2048 +#define CONFIG_PARTITION_TABLE_CUSTOM_APP_BIN_OFFSET 0x10000 +#define CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ 240 +#define CONFIG_FREERTOS_HZ 100 +#define CONFIG_LOG_COLORS 1 +#define CONFIG_FREERTOS_ASSERT_FAIL_ABORT 1 +#define CONFIG_LOG_BOOTLOADER_LEVEL 2 +#define CONFIG_ESPTOOLPY_BAUD_OTHER_VAL 115200 +#define CONFIG_ESP32_DEFAULT_CPU_FREQ_240 1 +#define CONFIG_FREERTOS_BREAK_ON_SCHEDULER_START_JTAG 1 +#define CONFIG_FREERTOS_CORETIMER_0 1 +#define CONFIG_PARTITION_TABLE_CUSTOM_FILENAME "partitions.csv" +#define CONFIG_FREERTOS_DEBUG_OCDAWARE 1 +#define CONFIG_WIFI_PASSWORD "myssid" +#define CONFIG_SYSTEM_EVENT_QUEUE_SIZE 32 +#define CONFIG_ESPTOOLPY_BAUD_921600B 1 +#define CONFIG_APP_OFFSET 0x10000 +#define CONFIG_MEMMAP_SMP 1 +#define CONFIG_ESPTOOLPY_PORT "/dev/ttyUSB0" diff --git a/examples/espidf-http-request/README.rst b/examples/espidf-http-request/README.rst index 939467a..c21cd89 100644 --- a/examples/espidf-http-request/README.rst +++ b/examples/espidf-http-request/README.rst @@ -20,10 +20,19 @@ How to build PlatformIO based project .. code-block:: bash # Change directory to example - > cd platform-espressif8266/examples/espidf-http-request + > cd platform-espressif32/examples/espidf-http-request - # Process example project + # Build project > platformio run # Upload firmware > platformio run --target upload + + # Build specific environment + > platformio run -e quantum + + # Upload firmware for the specific environment + > platformio run -e quantum --target upload + + # Clean build files + > platformio run --target clean diff --git a/examples/espidf-http-request/platformio.ini b/examples/espidf-http-request/platformio.ini index 2f9f3b2..ced207a 100644 --- a/examples/espidf-http-request/platformio.ini +++ b/examples/espidf-http-request/platformio.ini @@ -7,8 +7,20 @@ ; Please visit documentation for the other options and examples ; http://docs.platformio.org/en/stable/projectconf.html -[env:esp32dev] +[env:nano32] platform = espressif32 framework = espidf -board = esp32dev -build_flags = -DCONFIG_WIFI_SSID=\"ESP_AP\" -DCONFIG_WIFI_PASSWORD=\"MYPASS\" \ No newline at end of file +board = nano32 +build_flags = -DCONFIG_WIFI_SSID=\"ESP_AP\" -DCONFIG_WIFI_PASSWORD=\"MYPASS\" + +[env:espea32] +platform = espressif32 +framework = espidf +board = espea32 +build_flags = -DCONFIG_WIFI_SSID=\"ESP_AP\" -DCONFIG_WIFI_PASSWORD=\"MYPASS\" + +[env:esp320] +platform = espressif32 +framework = espidf +board = esp320 +build_flags = -DCONFIG_WIFI_SSID=\"ESP_AP\" -DCONFIG_WIFI_PASSWORD=\"MYPASS\" diff --git a/examples/espidf-http-request/src/sdkconfig.h b/examples/espidf-http-request/src/sdkconfig.h new file mode 100644 index 0000000..77f2a46 --- /dev/null +++ b/examples/espidf-http-request/src/sdkconfig.h @@ -0,0 +1,51 @@ +/* + * + * Automatically generated file; DO NOT EDIT. + * Espressif IoT Development Framework Configuration + * + */ +#define CONFIG_TRACEMEM_RESERVE_DRAM 0x0 +#define CONFIG_FREERTOS_CHECK_STACKOVERFLOW_NONE 1 +#define CONFIG_ESPTOOLPY_FLASHFREQ "80m" +#define CONFIG_NEWLIB_STDOUT_ADDCR 1 +#define CONFIG_FREERTOS_PANIC_PRINT_REBOOT 1 +#define CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS 1 +#define CONFIG_LOG_DEFAULT_LEVEL_INFO 1 +#define CONFIG_BT_RESERVE_DRAM 0x0 +#define CONFIG_LWIP_MAX_SOCKETS 4 +#define CONFIG_ULP_COPROC_RESERVE_MEM 0 +#define CONFIG_ESPTOOLPY_BAUD 921600 +#define CONFIG_TOOLPREFIX "xtensa-esp32-elf-" +#define CONFIG_LWIP_THREAD_LOCAL_STORAGE_INDEX 0 +#define CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN 16384 +#define CONFIG_ESP32_ENABLE_STACK_WIFI 1 +#define CONFIG_LOG_BOOTLOADER_LEVEL_WARN 1 +#define CONFIG_MAIN_TASK_STACK_SIZE 4096 +#define CONFIG_ESPTOOLPY_FLASHMODE "dio" +#define CONFIG_LOG_DEFAULT_LEVEL 3 +#define CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION 1 +#define CONFIG_ESPTOOLPY_FLASHMODE_DIO 1 +#define CONFIG_PYTHON "python" +#define CONFIG_ESPTOOLPY_COMPRESSED 1 +#define CONFIG_PARTITION_TABLE_FILENAME "partitions_singleapp.csv" +#define CONFIG_PARTITION_TABLE_SINGLE_APP 1 +#define CONFIG_WIFI_ENABLED 1 +#define CONFIG_ESPTOOLPY_FLASHFREQ_80M 1 +#define CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE 2048 +#define CONFIG_PARTITION_TABLE_CUSTOM_APP_BIN_OFFSET 0x10000 +#define CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ 240 +#define CONFIG_FREERTOS_HZ 100 +#define CONFIG_LOG_COLORS 1 +#define CONFIG_FREERTOS_ASSERT_FAIL_ABORT 1 +#define CONFIG_LOG_BOOTLOADER_LEVEL 2 +#define CONFIG_ESPTOOLPY_BAUD_OTHER_VAL 115200 +#define CONFIG_ESP32_DEFAULT_CPU_FREQ_240 1 +#define CONFIG_FREERTOS_BREAK_ON_SCHEDULER_START_JTAG 1 +#define CONFIG_FREERTOS_CORETIMER_0 1 +#define CONFIG_PARTITION_TABLE_CUSTOM_FILENAME "partitions.csv" +#define CONFIG_FREERTOS_DEBUG_OCDAWARE 1 +#define CONFIG_SYSTEM_EVENT_QUEUE_SIZE 32 +#define CONFIG_ESPTOOLPY_BAUD_921600B 1 +#define CONFIG_APP_OFFSET 0x10000 +#define CONFIG_MEMMAP_SMP 1 +#define CONFIG_ESPTOOLPY_PORT "/dev/ttyUSB0"