Raspberry BASIC > ScriptBasic

Pico

<< < (2/3) > >>

John Spikowski:
I was able to get the Hello World to work with my new DIYMall ESP32-PICO board. Setting this up was a job.


--- Code: C ---/* 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 <stdio.h>#include "sdkconfig.h"#include "freertos/FreeRTOS.h"#include "freertos/task.h"#include "esp_system.h"#include "esp_spi_flash.h" void app_main(void){    printf("Hello world!\n");     /* Print chip information */    esp_chip_info_t chip_info;    esp_chip_info(&chip_info);    printf("This is %s chip with %d CPU core(s), WiFi%s%s, ",            CONFIG_IDF_TARGET,            chip_info.cores,            (chip_info.features & CHIP_FEATURE_BT) ? "/BT" : "",            (chip_info.features & CHIP_FEATURE_BLE) ? "/BLE" : "");     printf("silicon revision %d, ", chip_info.revision);     printf("%dMB %s flash\n", spi_flash_get_chip_size() / (1024 * 1024),            (chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded" : "external");     printf("Minimum free heap size: %d bytes\n", esp_get_minimum_free_heap_size());     for (int i = 10; i >= 0; i--) {        printf("Restarting in %d seconds...\n", i);        vTaskDelay(1000 / portTICK_PERIOD_MS);    }    printf("Restarting now.\n");    fflush(stdout);    esp_restart();} 

pi@RPi3B:~/esp/hello_world $ idf.py -p /dev/ttyUSB0 monitor
WARNING: Support for Python 2 is deprecated and will be removed in future versions.
Executing action: monitor
Running idf_monitor in directory /home/pi/esp/hello_world
Executing "/home/pi/.espressif/python_env/idf4.4_py2.7_env/bin/python /home/pi/esp/esp-idf/tools/idf_monitor.py -p /dev/ttyUSB0 -b 115200 --toolchain-prefix xtensa-esp32-elf- /home/pi/esp/hello_world/build/hello-world.elf -m '/home/pi/.espressif/python_env/idf4.4_py2.7_env/bin/python' '/home/pi/esp/esp-idf/tools/idf.py' '-p' '/dev/ttyUSB0'"...
--- idf_monitor on /dev/ttyUSB0 115200 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
ets Jun  8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 188777542, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:6916
load:0x40078000,len:14336
ho 0 tail 12 room 4
load:0x40080400,len:3672
0x40080400: _init at ??:?

entry 0x40080678
I (29) boot: ESP-IDF v4.4-dev-4-g73db14240 2nd stage bootloader
I (30) boot: compile time 00:12:01
I (30) boot: chip revision: 1
I (34) boot_comm: chip revision: 1, min. bootloader chip revision: 0
I (41) boot.esp32: SPI Speed      : 40MHz
I (45) boot.esp32: SPI Mode       : DIO
I (50) boot.esp32: SPI Flash Size : 2MB
I (54) boot: Enabling RNG early entropy source...
I (60) boot: Partition Table:
I (63) boot: ## Label            Usage          Type ST Offset   Length
I (71) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (78) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (86) boot:  2 factory          factory app      00 00 00010000 00100000
I (93) boot: End of partition table
I (97) boot_comm: chip revision: 1, min. application chip revision: 0
I (104) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=05f24h ( 24356) map
I (122) esp_image: segment 1: paddr=00015f4c vaddr=3ffb0000 size=02880h ( 10368) load
I (126) esp_image: segment 2: paddr=000187d4 vaddr=40080000 size=07844h ( 30788) load
I (142) esp_image: segment 3: paddr=00020020 vaddr=400d0020 size=138e4h ( 80100) map
I (171) esp_image: segment 4: paddr=0003390c vaddr=40087844 size=032f0h ( 13040) load
I (182) boot: Loaded app from partition at offset 0x10000
I (182) boot: Disabling RNG early entropy source...
I (194) cpu_start: Pro cpu up.
I (194) cpu_start: Starting app cpu, entry point is 0x40080f30
0x40080f30: call_start_cpu1 at /home/pi/esp/esp-idf/components/esp_system/port/cpu_start.c:143

I (0) cpu_start: App cpu up.
I (208) cpu_start: Pro cpu start user code
I (208) cpu_start: cpu freq: 160000000
I (208) cpu_start: Application information:
I (213) cpu_start: Project name:     hello-world
I (218) cpu_start: App version:      1
I (223) cpu_start: Compile time:     Feb 27 2021 00:14:37
I (229) cpu_start: ELF file SHA256:  bd8ca58e2e4262a6...
I (235) cpu_start: ESP-IDF:          v4.4-dev-4-g73db14240
I (241) heap_init: Initializing. RAM available for dynamic allocation:
I (248) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (254) heap_init: At 3FFB30B8 len 0002CF48 (179 KiB): DRAM
I (260) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (267) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (273) heap_init: At 4008AB34 len 000154CC (85 KiB): IRAM
I (280) spi_flash: detected chip: gd
I (284) spi_flash: flash io: dio
W (288) spi_flash: Detected size(4096k) larger than the size in the binary image header(2048k). Using the size in the binary image header.
I (302) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
Hello world!
This is esp32 chip with 2 CPU core(s), WiFi/BT/BLE, silicon revision 1, 2MB embedded flash
Minimum free heap size: 291656 bytes
Restarting in 10 seconds...

John Spikowski:
I was able to get CBASIC working with the ESP32-PICO. This is an example of random number generation and calculating the mean value. This example shows using a separate C program as a component.


--- Code: C ---#include <stdio.h>#include "esp_system.h"#include "testable.h"#include "cbasic.h" SUB app_main(void)BEGIN_SUB  CONST int count = 32;  CONST int max = 100;  PRINT("In main application. Collecting %d random numbers from 1 to %d:\n", count, max);  DIM int AS PTR numbers = calloc(count, sizeof(numbers[0]));  DEF_FOR(int i = 0 TO i < count STEP INCR i)  BEGIN_FOR    numbers[i] = 1 + esp_random() MOD (max - 1);    PRINT("%4d ", numbers[i]);    IF ((i + 1) MOD 10 == 0) THEN      PRINT("\n");    END_IF  NEXT  DIM int AS mean = testable_mean(numbers, count);  PRINT ("\nMean: %d\n", mean);  free(numbers);END_SUB 
mean.c

--- Code: C ---#include "testable.h"#include "cbasic.h" FUNCTION int testable_mean(const int PTR values, int count)BEGIN_FUNCTION  IF (count == 0) THEN    RETURN_FUNCTION(0);  END_IF  DIM int AS sum = 0;  DEF_FOR (int i = 0 TO i < count STEP INCR i)  BEGIN_FOR     sum += values[i];  NEXT  RETURN_FUNCTION(sum / count);END_FUNCTION 
testable.h

--- Code: C ---#pragma once /** * @brief Calculate arithmetic mean of integer values * @param values  array of values * @param count   number of elements in the array * @return arithmetic mean of values, or zero count is zero */int testable_mean(const int* values, int count); 

pi@RPi3B:~/esp/unit_test $ idf.py -p /dev/ttyUSB0 monitor
WARNING: Python 3 versions older than 3.6 are not supported.
Executing action: monitor
Running idf_monitor in directory /home/pi/esp/unit_test
Executing "/home/pi/.espressif/python_env/idf4.4_py3.5_env/bin/python /home/pi/esp/esp-idf/tools/idf_monitor.py -p /dev/ttyUSB0 -b 115200 --toolchain-prefix xtensa-esp32-elf- /home/pi/esp/unit_test/build/unit_test.elf -m '/home/pi/.espressif/python_env/idf4.4_py3.5_env/bin/python' '/home/pi/esp/esp-idf/tools/idf.py' '-p' '/dev/ttyUSB0'"...
--- idf_monitor on /dev/ttyUSB0 115200 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
ets Jun  8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 188777542, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:6916
load:0x40078000,len:14336
ho 0 tail 12 room 4
load:0x40080400,len:3672
0x40080400: _init at ??:?

entry 0x40080678
I (30) boot: ESP-IDF v4.4-dev-4-g73db14240 2nd stage bootloader
I (30) boot: compile time 03:48:52
I (30) boot: chip revision: 1
I (34) boot_comm: chip revision: 1, min. bootloader chip revision: 0
I (41) boot.esp32: SPI Speed      : 40MHz
I (46) boot.esp32: SPI Mode       : DIO
I (50) boot.esp32: SPI Flash Size : 2MB
I (55) boot: Enabling RNG early entropy source...
I (60) boot: Partition Table:
I (64) boot: ## Label            Usage          Type ST Offset   Length
I (71) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (78) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (86) boot:  2 factory          factory app      00 00 00010000 00100000
I (93) boot: End of partition table
I (97) boot_comm: chip revision: 1, min. application chip revision: 0
I (105) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=05bbch ( 23484) map
I (121) esp_image: segment 1: paddr=00015be4 vaddr=3ffb0000 size=02860h ( 10336) load
I (126) esp_image: segment 2: paddr=0001844c vaddr=40080000 size=07bcch ( 31692) load
I (143) esp_image: segment 3: paddr=00020020 vaddr=400d0020 size=1337ch ( 78716) map
I (171) esp_image: segment 4: paddr=000333a4 vaddr=40087bcc size=02f6ch ( 12140) load
I (182) boot: Loaded app from partition at offset 0x10000
I (182) boot: Disabling RNG early entropy source...
I (194) cpu_start: Pro cpu up.
I (194) cpu_start: Starting app cpu, entry point is 0x40080f34
0x40080f34: call_start_cpu1 at /home/pi/esp/esp-idf/components/esp_system/port/cpu_start.c:143

I (0) cpu_start: App cpu up.
I (208) cpu_start: Pro cpu start user code
I (208) cpu_start: cpu freq: 160000000
I (208) cpu_start: Application information:
I (212) cpu_start: Project name:     unit_test
I (218) cpu_start: App version:      1
I (222) cpu_start: Compile time:     Feb 28 2021 03:51:29
I (228) cpu_start: ELF file SHA256:  39e44e816ec30d58...
I (234) cpu_start: ESP-IDF:          v4.4-dev-4-g73db14240
I (241) heap_init: Initializing. RAM available for dynamic allocation:
I (248) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (254) heap_init: At 3FFB3088 len 0002CF78 (179 KiB): DRAM
I (260) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (266) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (273) heap_init: At 4008AB38 len 000154C8 (85 KiB): IRAM
I (280) spi_flash: detected chip: gd
I (283) spi_flash: flash io: dio
W (287) spi_flash: Detected size(4096k) larger than the size in the binary image header(2048k). Using the size in the binary image header.
I (301) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
In main application. Collecting 32 random numbers from 1 to 100:
  76   26   40    9   74   28   37   19   78   66
  99   75   29   63   48   22    2    1   65   37
  54   63   25   24   20   75    4   31   32   75
  30   90
Mean: 44

pi@RPi3B:~/esp/unit_test $

John Spikowski:
The following a the ESP32-Pico application build process.


--- Code: Text ---pi@RPi3B:~/esp $ . $HOME/esp/esp-idf/export.shSetting IDF_PATH to '/home/pi/esp/esp-idf'Adding ESP-IDF tools to PATH...Using Python interpreter in /home/pi/.espressif/python_env/idf4.4_py3.5_env/bin/pythonChecking if Python packages are up to date...Python requirements from /home/pi/esp/esp-idf/requirements.txt are satisfied.Added the following directories to PATH:  /home/pi/esp/esp-idf/components/esptool_py/esptool  /home/pi/esp/esp-idf/components/espcoredump  /home/pi/esp/esp-idf/components/partition_table  /home/pi/esp/esp-idf/components/app_update  /home/pi/.espressif/tools/xtensa-esp32-elf/esp-2020r3-8.4.0/xtensa-esp32-elf/bin  /home/pi/.espressif/tools/xtensa-esp32s2-elf/esp-2020r3-8.4.0/xtensa-esp32s2-elf/bin  /home/pi/.espressif/tools/xtensa-esp32s3-elf/esp-2020r3-8.4.0/xtensa-esp32s3-elf/bin  /home/pi/.espressif/tools/riscv32-esp-elf/1.24.0.123_64eb9ff-8.4.0/riscv32-esp-elf/bin  /home/pi/.espressif/tools/esp32ulp-elf/2.28.51-esp-20191205/esp32ulp-elf-binutils/bin  /home/pi/.espressif/tools/esp32s2ulp-elf/2.28.51-esp-20191205/esp32s2ulp-elf-binutils/bin  /home/pi/.espressif/tools/openocd-esp32/v0.10.0-esp32-20200709/openocd-esp32/bin  /home/pi/.espressif/python_env/idf4.4_py3.5_env/bin  /home/pi/esp/esp-idf/toolsDone! You can now compile ESP-IDF projects.Go to the project directory and run:   idf.py build pi@RPi3B:~/esp $ cd unit_testpi@RPi3B:~/esp/unit_test $ idf.py buildWARNING: Python 3 versions older than 3.6 are not supported.Executing action: all (aliases: build)Running make in directory /home/pi/esp/unit_test/buildExecuting "make -j 6 all"...[  0%] Built target custom_bundle[  0%] Built target _project_elf_src[  0%] Built target partition_table_bin[  0%] Built target esp32_linker_script[  0%] Performing build step for 'bootloader'[  0%] Built target __idf_ulp[  0%] Built target __idf_esp_serial_slave_link[  1%] Built target _project_elf_src[  5%] Built target __idf_log[  1%] Built target __idf_sdmmc[ 10%] Built target __idf_esp_rom[  1%] Built target __idf_esp_https_ota[ 22%] Built target __idf_esp_hw_support[ 31%] Built target __idf_efuse[  2%] Built target __idf_esp_http_server[  2%] Built target __idf_esp_http_client[ 58%] Built target __idf_bootloader_support[  2%] Built target __idf_tcp_transport[ 61%] Built target __idf_spi_flash[ 63%] Built target __idf_micro-ecc[  3%] Built target __idf_esp-tls[ 89%] Built target __idf_soc[ 92%] Built target __idf_hal[  5%] Built target __idf_nghttp[ 95%] Built target __idf_main[  5%] Built target __idf_app_trace[ 98%] Built target bootloader.elf[  5%] Built target __idf_cxx[100%] Built target gen_project_binary[100%] Built target app[  6%] Built target __idf_newlib[  7%] No install step for 'bootloader'[  7%] Completed 'bootloader'[  9%] Built target __idf_freertos[  9%] Built target bootloader[  9%] Built target __idf_esp_timer[ 10%] Built target __idf_esp_common[ 11%] Built target __idf_esp32[ 11%] Built target __idf_perfmon[ 11%] Built target __idf_espcoredump[ 12%] Built target __idf_xtensa[ 16%] Built target __idf_driver[ 17%] Built target __idf_esp_ringbuf[ 18%] Built target __idf_esp_hw_support[ 20%] Built target __idf_soc[ 21%] Built target __idf_heap[ 21%] Built target __idf_log[ 30%] Built target __idf_lwip[ 31%] Built target __idf_esp_wifi[ 40%] Built target __idf_wpa_supplicant[ 41%] Built target __idf_esp_event[ 42%] Built target __idf_esp_netif[ 42%] Built target __idf_tcpip_adapter[ 43%] Built target __idf_esp_eth[ 44%] Built target __idf_vfs[ 48%] Built target __idf_hal[ 48%] Built target __idf_esp_rom[ 50%] Built target __idf_esp_system[ 50%] Built target __idf_esp_gdbstub[ 51%] Built target __idf_pthread[ 53%] Built target __idf_nvs_flash[ 55%] Built target __idf_spi_flash[ 56%] Built target __idf_esp_ipc[ 56%] Built target __idf_app_update[ 57%] Built target __idf_bootloader_support[ 57%] Built target __idf_efuse[ 58%] Built target mbedx509[ 59%] Built target mbedtls[ 67%] Built target mbedcrypto[ 68%] Built target __idf_mbedtls[ 68%] Built target __idf_esp_pmScanning dependencies of target __idf_testable[ 68%] Building C object esp-idf/testable/CMakeFiles/__idf_testable.dir/mean.c.obj[ 68%] Built target __idf_console[ 68%] Built target __idf_unity[ 69%] Built target __idf_asio[ 70%] Built target __idf_cbor[ 70%] Built target __idf_esp_adc_cal[ 71%] Built target __idf_esp_hid[ 71%] Built target __idf_protobuf-c[ 71%] Built target __idf_mdns[ 72%] Built target __idf_esp_websocket_client[ 75%] Built target __idf_coap[ 76%] Built target __idf_expat[ 76%] Built target __idf_wear_levelling[ 76%] Built target __idf_jsmn[ 76%] Built target __idf_json[ 77%] Built target __idf_mqtt[ 78%] Built target __idf_spiffs[ 79%] Linking C static library libtestable.a[ 80%] Built target __idf_openssl[ 80%] Built target __idf_cmock[ 84%] Built target __idf_freemodbus[ 85%] Built target __idf_protocomm[ 97%] Built target __idf_libsodium[ 97%] Built target __idf_testable[ 98%] Built target __idf_fatfs[ 98%] Built target __idf_esp_local_ctrl[ 99%] Built target __idf_wifi_provisioning[ 99%] Built target __idf_main[ 99%] Generating ld/esp32.project.ld[ 99%] Built target __ldgen_output_esp32.project.ld[100%] Linking CXX executable unit_test.elf[100%] Built target unit_test.elf[100%] Generating binary image from built executableesptool.py v3.1-devMerged 1 ELF sectionGenerated /home/pi/esp/unit_test/build/unit_test.bin[100%] Built target gen_project_binary[100%] Built target app Project build complete. To flash, run this command:/home/pi/.espressif/python_env/idf4.4_py3.5_env/bin/python ../esp-idf/components/esptool_py/esptool/esptool.py -p (PORT) -b 460800 --before default_reset --after hard_reset --chip esp32  write_flash --flash_mode dio --flash_size detect --flash_freq 40m 0x1000 build/bootloader/bootloader.bin 0x8000 build/partition_table/partition-table.bin 0x10000 build/unit_test.binor run 'idf.py -p (PORT) flash'pi@RPi3B:~/esp/unit_test $ idf.py -p /dev/ttyUSB0 flashWARNING: Python 3 versions older than 3.6 are not supported.Executing action: flashRunning make in directory /home/pi/esp/unit_test/buildExecuting "make -j 6 flash"...[  0%] Built target custom_bundle[  0%] Built target esp32_linker_script[  0%] Built target partition_table_bin[  0%] Built target _project_elf_src[  0%] Performing build step for 'bootloader'[  0%] Built target __idf_ulp[  0%] Built target __idf_esp_serial_slave_link[  1%] Built target _project_elf_src[  5%] Built target __idf_log[  1%] Built target __idf_sdmmc[ 10%] Built target __idf_esp_rom[  1%] Built target __idf_esp_https_ota[ 22%] Built target __idf_esp_hw_support[  2%] Built target __idf_esp_http_server[ 31%] Built target __idf_efuse[  2%] Built target __idf_esp_http_client[ 58%] Built target __idf_bootloader_support[  2%] Built target __idf_tcp_transport[ 61%] Built target __idf_spi_flash[ 63%] Built target __idf_micro-ecc[  3%] Built target __idf_esp-tls[ 89%] Built target __idf_soc[  5%] Built target __idf_nghttp[ 92%] Built target __idf_hal[  5%] Built target __idf_app_trace[ 95%] Built target __idf_main[ 98%] Built target bootloader.elf[  5%] Built target __idf_cxx[100%] Built target gen_project_binary[  6%] Built target __idf_newlib[100%] Built target app[  7%] No install step for 'bootloader'[  9%] Built target __idf_freertos[  9%] Completed 'bootloader'[  9%] Built target __idf_esp_timer[  9%] Built target bootloader[ 10%] Built target __idf_esp_common[ 11%] Built target __idf_esp32[ 11%] Built target __idf_perfmon[ 11%] Built target __idf_espcoredump[ 12%] Built target __idf_xtensa[ 16%] Built target __idf_driver[ 17%] Built target __idf_esp_ringbuf[ 18%] Built target __idf_esp_hw_support[ 20%] Built target __idf_soc[ 21%] Built target __idf_heap[ 21%] Built target __idf_log[ 30%] Built target __idf_lwip[ 31%] Built target __idf_esp_wifi[ 40%] Built target __idf_wpa_supplicant[ 41%] Built target __idf_esp_event[ 42%] Built target __idf_esp_netif[ 42%] Built target __idf_tcpip_adapter[ 43%] Built target __idf_esp_eth[ 44%] Built target __idf_vfs[ 48%] Built target __idf_hal[ 48%] Built target __idf_esp_rom[ 50%] Built target __idf_esp_system[ 50%] Built target __idf_esp_gdbstub[ 51%] Built target __idf_pthread[ 53%] Built target __idf_nvs_flash[ 55%] Built target __idf_spi_flash[ 56%] Built target __idf_esp_ipc[ 56%] Built target __idf_app_update[ 57%] Built target __idf_bootloader_support[ 57%] Built target __idf_efuse[ 58%] Built target mbedx509[ 59%] Built target mbedtls[ 67%] Built target mbedcrypto[ 68%] Built target __idf_mbedtls[ 68%] Built target __idf_esp_pm[ 69%] Built target __idf_testable[ 69%] Built target __idf_unity[ 69%] Built target __idf_console[ 70%] Built target __idf_cbor[ 70%] Built target __idf_esp_adc_cal[ 71%] Built target __idf_asio[ 71%] Built target __idf_protobuf-c[ 72%] Built target __idf_esp_hid[ 75%] Built target __idf_coap[ 76%] Built target __idf_expat[ 76%] Built target __idf_mdns[ 77%] Built target __idf_esp_websocket_client[ 77%] Built target __idf_wear_levelling[ 77%] Built target __idf_jsmn[ 77%] Built target __idf_json[ 78%] Built target __idf_openssl[ 79%] Built target __idf_mqtt[ 79%] Built target __idf_cmock[ 80%] Built target __idf_spiffs[ 91%] Built target __idf_freemodbus[ 96%] Built target __idf_libsodium[ 97%] Built target __idf_protocomm[ 98%] Built target __idf_fatfs[ 98%] Built target __idf_esp_local_ctrl[ 99%] Built target __idf_wifi_provisioning[ 99%] Built target __idf_main[ 99%] Built target __ldgen_output_esp32.project.ld[100%] Built target unit_test.elf[100%] Built target gen_project_binary[100%] Built target appesptool.py esp32 -p /dev/ttyUSB0 -b 460800 --before=default_reset --after=hard_reset write_flash --flash_mode dio --flash_freq 40m --flash_size 2MB 0x8000 partition_table/partition-table.bin 0x1000 bootloader/bootloader.bin 0x10000 unit_test.binesptool.py v3.1-devSerial port /dev/ttyUSB0Connecting....Chip is ESP32-PICO-D4 (revision 1)Features: WiFi, BT, Dual Core, 240MHz, Embedded Flash, VRef calibration in efuse, Coding Scheme NoneCrystal is 40MHzMAC: d8:a0:1d:5f:c1:54Uploading stub...Running stub...Stub running...Changing baud rate to 460800Changed.Configuring flash size...Compressed 3072 bytes to 103...Writing at 0x00008000... (100 %)Wrote 3072 bytes (103 compressed) at 0x00008000 in 0.1 seconds (effective 446.5 kbit/s)...Hash of data verified.Compressed 25008 bytes to 15398...Writing at 0x00001000... (100 %)Wrote 25008 bytes (15398 compressed) at 0x00001000 in 0.8 seconds (effective 264.9 kbit/s)...Hash of data verified.Compressed 156480 bytes to 82233...Writing at 0x00010000... (16 %)Writing at 0x0001a249... (33 %)Writing at 0x0001fbce... (50 %)Writing at 0x00025464... (66 %)Writing at 0x0002e9bc... (83 %)Writing at 0x000361ae... (100 %)Wrote 156480 bytes (82233 compressed) at 0x00010000 in 2.4 seconds (effective 529.1 kbit/s)...Hash of data verified. Leaving...Hard resetting via RTS pin...[100%] Built target flashDonepi@RPi3B:~/esp/unit_test $ idf.py -p /dev/ttyUSB0 monitorWARNING: Python 3 versions older than 3.6 are not supported.Executing action: monitorRunning idf_monitor in directory /home/pi/esp/unit_testExecuting "/home/pi/.espressif/python_env/idf4.4_py3.5_env/bin/python /home/pi/esp/esp-idf/tools/idf_monitor.py -p /dev/ttyUSB0 -b 115200 --toolchain-prefix xtensa-esp32-elf- /home/pi/esp/unit_test/build/unit_test.elf -m '/home/pi/.espressif/python_env/idf4.4_py3.5_env/bin/python' '/home/pi/esp/esp-idf/tools/idf.py' '-p' '/dev/ttyUSB0'"...--- idf_monitor on /dev/ttyUSB0 115200 ------ Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---ets Jun  8 2016 00:22:57 rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)configsip: 188777542, SPIWP:0xeeclk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00mode:DIO, clock div:2load:0x3fff0030,len:6916load:0x40078000,len:14336ho 0 tail 12 room 4load:0x40080400,len:36720x40080400: _init at ??:? entry 0x40080678I (30) boot: ESP-IDF v4.4-dev-4-g73db14240 2nd stage bootloaderI (30) boot: compile time 03:48:52I (30) boot: chip revision: 1I (34) boot_comm: chip revision: 1, min. bootloader chip revision: 0I (41) boot.esp32: SPI Speed      : 40MHzI (46) boot.esp32: SPI Mode       : DIOI (50) boot.esp32: SPI Flash Size : 2MBI (55) boot: Enabling RNG early entropy source...I (60) boot: Partition Table:I (64) boot: ## Label            Usage          Type ST Offset   LengthI (71) boot:  0 nvs              WiFi data        01 02 00009000 00006000I (78) boot:  1 phy_init         RF data          01 01 0000f000 00001000I (86) boot:  2 factory          factory app      00 00 00010000 00100000I (93) boot: End of partition tableI (97) boot_comm: chip revision: 1, min. application chip revision: 0I (105) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=05bbch ( 23484) mapI (121) esp_image: segment 1: paddr=00015be4 vaddr=3ffb0000 size=02860h ( 10336) loadI (126) esp_image: segment 2: paddr=0001844c vaddr=40080000 size=07bcch ( 31692) loadI (143) esp_image: segment 3: paddr=00020020 vaddr=400d0020 size=1337ch ( 78716) mapI (171) esp_image: segment 4: paddr=000333a4 vaddr=40087bcc size=02f6ch ( 12140) loadI (182) boot: Loaded app from partition at offset 0x10000I (182) boot: Disabling RNG early entropy source...I (194) cpu_start: Pro cpu up.I (194) cpu_start: Starting app cpu, entry point is 0x40080f340x40080f34: call_start_cpu1 at /home/pi/esp/esp-idf/components/esp_system/port/cpu_start.c:143 I (0) cpu_start: App cpu up.I (208) cpu_start: Pro cpu start user codeI (208) cpu_start: cpu freq: 160000000I (208) cpu_start: Application information:I (212) cpu_start: Project name:     unit_testI (218) cpu_start: App version:      1I (222) cpu_start: Compile time:     Feb 28 2021 03:51:29I (228) cpu_start: ELF file SHA256:  3807515689fe0775...I (234) cpu_start: ESP-IDF:          v4.4-dev-4-g73db14240I (241) heap_init: Initializing. RAM available for dynamic allocation:I (248) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAMI (254) heap_init: At 3FFB3088 len 0002CF78 (179 KiB): DRAMI (260) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAMI (266) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAMI (273) heap_init: At 4008AB38 len 000154C8 (85 KiB): IRAMI (280) spi_flash: detected chip: gdI (283) spi_flash: flash io: dioW (287) spi_flash: Detected size(4096k) larger than the size in the binary image header(2048k). Using the size in the binary image header.I (301) cpu_start: Starting scheduler on PRO CPU.I (0) cpu_start: Starting scheduler on APP CPU.In main application. Collecting 32 random numbers from 1 to 100:  26    6   30   38    4   34   39    9   57   99   49   75   73   80   96   94   16   46   94   73   30   42   86   90   30   41   99   95   23   45   75   51 Mean: 54 pi@RPi3B:~/esp/unit_test $  

John Spikowski:
This example uses the timer group driver to generate timer interrupts at two specified alarm intervals.

Functionality Overview
[*] Two timers are configured
[*] Each timer is set with some sample alarm interval
[*] On reaching the interval value each timer will generate an alarm
[*] One of the timers is configured to automatically reload it's counter value on the alarm
[*] The other timer is configured to keep incrementing and is reloaded by the application each time the alarm happens
[*] Alarms trigger subsequent interrupts, that is tracked with messages printed on the terminal:
[/list]


--- Code: C ---/* Timer group-hardware timer 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 <stdio.h>#include "esp_types.h"#include "freertos/FreeRTOS.h"#include "freertos/task.h"#include "freertos/queue.h"#include "driver/periph_ctrl.h"#include "driver/timer.h" #define TIMER_DIVIDER         16  //  Hardware timer clock divider#define TIMER_SCALE           (TIMER_BASE_CLK / TIMER_DIVIDER)  // convert counter value to seconds#define TIMER_INTERVAL0_SEC   (3.4179) // sample test interval for the first timer#define TIMER_INTERVAL1_SEC   (5.78)   // sample test interval for the second timer#define TEST_WITHOUT_RELOAD   0        // testing will be done without auto reload#define TEST_WITH_RELOAD      1        // testing will be done with auto reload /* * A sample structure to pass events * from the timer interrupt handler to the main program. */typedef struct {    int type;  // the type of timer's event    int timer_group;    int timer_idx;    uint64_t timer_counter_value;} timer_event_t; xQueueHandle timer_queue; /* * A simple helper function to print the raw timer counter value * and the counter value converted to seconds */static void inline print_timer_counter(uint64_t counter_value){    printf("Counter: 0x%08x%08x\n", (uint32_t) (counter_value >> 32),           (uint32_t) (counter_value));    printf("Time   : %.8f s\n", (double) counter_value / TIMER_SCALE);} /* * Timer group0 ISR handler * * Note: * We don't call the timer API here because they are not declared with IRAM_ATTR. * If we're okay with the timer irq not being serviced while SPI flash cache is disabled, * we can allocate this interrupt without the ESP_INTR_FLAG_IRAM flag and use the normal API. */void IRAM_ATTR timer_group0_isr(void *para){    timer_spinlock_take(TIMER_GROUP_0);    int timer_idx = (int) para;     /* Retrieve the interrupt status and the counter value       from the timer that reported the interrupt */    uint32_t timer_intr = timer_group_get_intr_status_in_isr(TIMER_GROUP_0);    uint64_t timer_counter_value = timer_group_get_counter_value_in_isr(TIMER_GROUP_0, timer_idx);     /* Prepare basic event data       that will be then sent back to the main program task */    timer_event_t evt;    evt.timer_group = 0;    evt.timer_idx = timer_idx;    evt.timer_counter_value = timer_counter_value;     /* Clear the interrupt       and update the alarm time for the timer with without reload */    if (timer_intr & TIMER_INTR_T0) {        evt.type = TEST_WITHOUT_RELOAD;        timer_group_clr_intr_status_in_isr(TIMER_GROUP_0, TIMER_0);        timer_counter_value += (uint64_t) (TIMER_INTERVAL0_SEC * TIMER_SCALE);        timer_group_set_alarm_value_in_isr(TIMER_GROUP_0, timer_idx, timer_counter_value);    } else if (timer_intr & TIMER_INTR_T1) {        evt.type = TEST_WITH_RELOAD;        timer_group_clr_intr_status_in_isr(TIMER_GROUP_0, TIMER_1);    } else {        evt.type = -1; // not supported even type    }     /* After the alarm has been triggered      we need enable it again, so it is triggered the next time */    timer_group_enable_alarm_in_isr(TIMER_GROUP_0, timer_idx);     /* Now just send the event data back to the main program task */    xQueueSendFromISR(timer_queue, &evt, NULL);    timer_spinlock_give(TIMER_GROUP_0);} /* * Initialize selected timer of the timer group 0 * * timer_idx - the timer number to initialize * auto_reload - should the timer auto reload on alarm? * timer_interval_sec - the interval of alarm to set */static void example_tg0_timer_init(int timer_idx,                                   bool auto_reload, double timer_interval_sec){    /* Select and initialize basic parameters of the timer */    timer_config_t config = {        .divider = TIMER_DIVIDER,        .counter_dir = TIMER_COUNT_UP,        .counter_en = TIMER_PAUSE,        .alarm_en = TIMER_ALARM_EN,        .auto_reload = auto_reload,    }; // default clock source is APB    timer_init(TIMER_GROUP_0, timer_idx, &config);     /* Timer's counter will initially start from value below.       Also, if auto_reload is set, this value will be automatically reload on alarm */    timer_set_counter_value(TIMER_GROUP_0, timer_idx, 0x00000000ULL);     /* Configure the alarm value and the interrupt on alarm. */    timer_set_alarm_value(TIMER_GROUP_0, timer_idx, timer_interval_sec * TIMER_SCALE);    timer_enable_intr(TIMER_GROUP_0, timer_idx);    timer_isr_register(TIMER_GROUP_0, timer_idx, timer_group0_isr,                       (void *) timer_idx, ESP_INTR_FLAG_IRAM, NULL);     timer_start(TIMER_GROUP_0, timer_idx);} /* * The main task of this example program */static void timer_example_evt_task(void *arg){    while (1) {        timer_event_t evt;        xQueueReceive(timer_queue, &evt, portMAX_DELAY);         /* Print information that the timer reported an event */        if (evt.type == TEST_WITHOUT_RELOAD) {            printf("\n    Example timer without reload\n");        } else if (evt.type == TEST_WITH_RELOAD) {            printf("\n    Example timer with auto reload\n");        } else {            printf("\n    UNKNOWN EVENT TYPE\n");        }        printf("Group[%d], timer[%d] alarm event\n", evt.timer_group, evt.timer_idx);         /* Print the timer values passed by event */        printf("------- EVENT TIME --------\n");        print_timer_counter(evt.timer_counter_value);         /* Print the timer values as visible by this task */        printf("-------- TASK TIME --------\n");        uint64_t task_counter_value;        timer_get_counter_value(evt.timer_group, evt.timer_idx, &task_counter_value);        print_timer_counter(task_counter_value);    }} /* * In this example, we will test hardware timer0 and timer1 of timer group0. */void app_main(void){    timer_queue = xQueueCreate(10, sizeof(timer_event_t));    example_tg0_timer_init(TIMER_0, TEST_WITHOUT_RELOAD, TIMER_INTERVAL0_SEC);    example_tg0_timer_init(TIMER_1, TEST_WITH_RELOAD,    TIMER_INTERVAL1_SEC);    xTaskCreate(timer_example_evt_task, "timer_evt_task", 2048, NULL, 5, NULL);} 

    Example timer without reload
Group[0], timer[0] alarm event
------- EVENT TIME --------
Counter: 0x000000000104c415
Time   : 3.41791140 s
-------- TASK TIME --------
Counter: 0x000000000105371b
Time   : 3.42380060 s

    Example timer with auto reload
Group[0], timer[1] alarm event
------- EVENT TIME --------
Counter: 0x0000000000000011
Time   : 0.00000340 s
-------- TASK TIME --------
Counter: 0x000000000000ab12
Time   : 0.00875880 s

    Example timer without reload
Group[0], timer[0] alarm event
------- EVENT TIME --------
Counter: 0x0000000002098802
Time   : 6.83581480 s
-------- TASK TIME --------
Counter: 0x00000000020a2039
Time   : 6.84360820 s

    Example timer without reload
Group[0], timer[0] alarm event
------- EVENT TIME --------
Counter: 0x00000000030e4bef
Time   : 10.25371820 s
-------- TASK TIME --------
Counter: 0x00000000030eacc4
Time   : 10.25867600 s

    Example timer with auto reload
Group[0], timer[1] alarm event
------- EVENT TIME --------
Counter: 0x0000000000000011
Time   : 0.00000340 s
-------- TASK TIME --------
Counter: 0x000000000000a94d
Time   : 0.00866820 s

    Example timer without reload
Group[0], timer[0] alarm event
------- EVENT TIME --------
Counter: 0x0000000004130fdc
Time   : 13.67162160 s
-------- TASK TIME --------
Counter: 0x000000000413997d
Time   : 13.67866820 s

John Spikowski:
Simple HTTPD Server Example

This example consists of HTTPD server demo using URI handling :
1. URI \hello for GET command returns "Hello World!" message
2. URI \echo for POST command echoes back the POSTed message

The ESP32-Pico HTTPD server is connected via WIFI to my router.


--- Code: C ---/* Simple HTTP Server 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 <esp_wifi.h>#include <esp_event.h>#include <esp_log.h>#include <esp_system.h>#include <nvs_flash.h>#include <sys/param.h>#include "nvs_flash.h"#include "esp_netif.h"#include "esp_eth.h"#include "protocol_examples_common.h" #include <esp_http_server.h> /* A simple example that demonstrates how to create GET and POST * handlers for the web server. */ static const char *TAG = "example"; /* An HTTP GET handler */static esp_err_t hello_get_handler(httpd_req_t *req){    char*  buf;    size_t buf_len;     /* Get header value string length and allocate memory for length + 1,     * extra byte for null termination */    buf_len = httpd_req_get_hdr_value_len(req, "Host") + 1;    if (buf_len > 1) {        buf = malloc(buf_len);        /* Copy null terminated value string into buffer */        if (httpd_req_get_hdr_value_str(req, "Host", buf, buf_len) == ESP_OK) {            ESP_LOGI(TAG, "Found header => Host: %s", buf);        }        free(buf);    }     buf_len = httpd_req_get_hdr_value_len(req, "Test-Header-2") + 1;    if (buf_len > 1) {        buf = malloc(buf_len);        if (httpd_req_get_hdr_value_str(req, "Test-Header-2", buf, buf_len) == ESP_OK) {            ESP_LOGI(TAG, "Found header => Test-Header-2: %s", buf);        }        free(buf);    }     buf_len = httpd_req_get_hdr_value_len(req, "Test-Header-1") + 1;    if (buf_len > 1) {        buf = malloc(buf_len);        if (httpd_req_get_hdr_value_str(req, "Test-Header-1", buf, buf_len) == ESP_OK) {            ESP_LOGI(TAG, "Found header => Test-Header-1: %s", buf);        }        free(buf);    }     /* Read URL query string length and allocate memory for length + 1,     * extra byte for null termination */    buf_len = httpd_req_get_url_query_len(req) + 1;    if (buf_len > 1) {        buf = malloc(buf_len);        if (httpd_req_get_url_query_str(req, buf, buf_len) == ESP_OK) {            ESP_LOGI(TAG, "Found URL query => %s", buf);            char param[32];            /* Get value of expected key from query string */            if (httpd_query_key_value(buf, "query1", param, sizeof(param)) == ESP_OK) {                ESP_LOGI(TAG, "Found URL query parameter => query1=%s", param);            }            if (httpd_query_key_value(buf, "query3", param, sizeof(param)) == ESP_OK) {                ESP_LOGI(TAG, "Found URL query parameter => query3=%s", param);            }            if (httpd_query_key_value(buf, "query2", param, sizeof(param)) == ESP_OK) {                ESP_LOGI(TAG, "Found URL query parameter => query2=%s", param);            }        }        free(buf);    }     /* Set some custom headers */    httpd_resp_set_hdr(req, "Custom-Header-1", "Custom-Value-1");    httpd_resp_set_hdr(req, "Custom-Header-2", "Custom-Value-2");     /* Send response with custom headers and body set as the     * string passed in user context*/    const char* resp_str = (const char*) req->user_ctx;    httpd_resp_send(req, resp_str, HTTPD_RESP_USE_STRLEN);     /* After sending the HTTP response the old HTTP request     * headers are lost. Check if HTTP request headers can be read now. */    if (httpd_req_get_hdr_value_len(req, "Host") == 0) {        ESP_LOGI(TAG, "Request headers lost");    }    return ESP_OK;} static const httpd_uri_t hello = {    .uri       = "/hello",    .method    = HTTP_GET,    .handler   = hello_get_handler,    /* Let's pass response string in user     * context to demonstrate it's usage */    .user_ctx  = "Hello World!"}; /* An HTTP POST handler */static esp_err_t echo_post_handler(httpd_req_t *req){    char buf[100];    int ret, remaining = req->content_len;     while (remaining > 0) {        /* Read the data for the request */        if ((ret = httpd_req_recv(req, buf,                        MIN(remaining, sizeof(buf)))) <= 0) {            if (ret == HTTPD_SOCK_ERR_TIMEOUT) {                /* Retry receiving if timeout occurred */                continue;            }            return ESP_FAIL;        }         /* Send back the same data */        httpd_resp_send_chunk(req, buf, ret);        remaining -= ret;         /* Log data received */        ESP_LOGI(TAG, "=========== RECEIVED DATA ==========");        ESP_LOGI(TAG, "%.*s", ret, buf);        ESP_LOGI(TAG, "====================================");    }     // End response    httpd_resp_send_chunk(req, NULL, 0);    return ESP_OK;} static const httpd_uri_t echo = {    .uri       = "/echo",    .method    = HTTP_POST,    .handler   = echo_post_handler,    .user_ctx  = NULL}; /* This handler allows the custom error handling functionality to be * tested from client side. For that, when a PUT request 0 is sent to * URI /ctrl, the /hello and /echo URIs are unregistered and following * custom error handler http_404_error_handler() is registered. * Afterwards, when /hello or /echo is requested, this custom error * handler is invoked which, after sending an error message to client, * either closes the underlying socket (when requested URI is /echo) * or keeps it open (when requested URI is /hello). This allows the * client to infer if the custom error handler is functioning as expected * by observing the socket state. */esp_err_t http_404_error_handler(httpd_req_t *req, httpd_err_code_t err){    if (strcmp("/hello", req->uri) == 0) {        httpd_resp_send_err(req, HTTPD_404_NOT_FOUND, "/hello URI is not available");        /* Return ESP_OK to keep underlying socket open */        return ESP_OK;    } else if (strcmp("/echo", req->uri) == 0) {        httpd_resp_send_err(req, HTTPD_404_NOT_FOUND, "/echo URI is not available");        /* Return ESP_FAIL to close underlying socket */        return ESP_FAIL;    }    /* For any other URI send 404 and close socket */    httpd_resp_send_err(req, HTTPD_404_NOT_FOUND, "Some 404 error message");    return ESP_FAIL;} /* An HTTP PUT handler. This demonstrates realtime * registration and deregistration of URI handlers */static esp_err_t ctrl_put_handler(httpd_req_t *req){    char buf;    int ret;     if ((ret = httpd_req_recv(req, &buf, 1)) <= 0) {        if (ret == HTTPD_SOCK_ERR_TIMEOUT) {            httpd_resp_send_408(req);        }        return ESP_FAIL;    }     if (buf == '0') {        /* URI handlers can be unregistered using the uri string */        ESP_LOGI(TAG, "Unregistering /hello and /echo URIs");        httpd_unregister_uri(req->handle, "/hello");        httpd_unregister_uri(req->handle, "/echo");        /* Register the custom error handler */        httpd_register_err_handler(req->handle, HTTPD_404_NOT_FOUND, http_404_error_handler);    }    else {        ESP_LOGI(TAG, "Registering /hello and /echo URIs");        httpd_register_uri_handler(req->handle, &hello);        httpd_register_uri_handler(req->handle, &echo);        /* Unregister custom error handler */        httpd_register_err_handler(req->handle, HTTPD_404_NOT_FOUND, NULL);    }     /* Respond with empty body */    httpd_resp_send(req, NULL, 0);    return ESP_OK;} static const httpd_uri_t ctrl = {    .uri       = "/ctrl",    .method    = HTTP_PUT,    .handler   = ctrl_put_handler,    .user_ctx  = NULL}; static httpd_handle_t start_webserver(void){    httpd_handle_t server = NULL;    httpd_config_t config = HTTPD_DEFAULT_CONFIG();    config.lru_purge_enable = true;     // Start the httpd server    ESP_LOGI(TAG, "Starting server on port: '%d'", config.server_port);    if (httpd_start(&server, &config) == ESP_OK) {        // Set URI handlers        ESP_LOGI(TAG, "Registering URI handlers");        httpd_register_uri_handler(server, &hello);        httpd_register_uri_handler(server, &echo);        httpd_register_uri_handler(server, &ctrl);        return server;    }     ESP_LOGI(TAG, "Error starting server!");    return NULL;} static void stop_webserver(httpd_handle_t server){    // Stop the httpd server    httpd_stop(server);} static void disconnect_handler(void* arg, esp_event_base_t event_base,                               int32_t event_id, void* event_data){    httpd_handle_t* server = (httpd_handle_t*) arg;    if (*server) {        ESP_LOGI(TAG, "Stopping webserver");        stop_webserver(*server);        *server = NULL;    }} static void connect_handler(void* arg, esp_event_base_t event_base,                            int32_t event_id, void* event_data){    httpd_handle_t* server = (httpd_handle_t*) arg;    if (*server == NULL) {        ESP_LOGI(TAG, "Starting webserver");        *server = start_webserver();    }}  void app_main(void){    static httpd_handle_t server = NULL;     ESP_ERROR_CHECK(nvs_flash_init());    ESP_ERROR_CHECK(esp_netif_init());    ESP_ERROR_CHECK(esp_event_loop_create_default());     /* This helper function configures Wi-Fi or Ethernet, as selected in menuconfig.     * Read "Establishing Wi-Fi or Ethernet Connection" section in     * examples/protocols/README.md for more information about this function.     */    ESP_ERROR_CHECK(example_connect());     /* Register event handlers to stop the server when Wi-Fi or Ethernet is disconnected,     * and re-start it upon connection.     */#ifdef CONFIG_EXAMPLE_CONNECT_WIFI    ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, IP_EVENT_STA_GOT_IP, &connect_handler, &server));    ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, WIFI_EVENT_STA_DISCONNECTED, &disconnect_handler, &server));#endif // CONFIG_EXAMPLE_CONNECT_WIFI#ifdef CONFIG_EXAMPLE_CONNECT_ETHERNET    ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, IP_EVENT_ETH_GOT_IP, &connect_handler, &server));    ESP_ERROR_CHECK(esp_event_handler_register(ETH_EVENT, ETHERNET_EVENT_DISCONNECTED, &disconnect_handler, &server));#endif // CONFIG_EXAMPLE_CONNECT_ETHERNET     /* Start the server for the first time */    server = start_webserver();} 
ESP32-Pico - Monitor - Webserver

pi@RPi3B:~/esp/simple $ idf.py -p /dev/ttyUSB0 monitor
WARNING: Python 3 versions older than 3.6 are not supported.
Executing action: monitor
Running idf_monitor in directory /home/pi/esp/simple
Executing "/home/pi/.espressif/python_env/idf4.4_py3.5_env/bin/python /home/pi/esp/esp-idf/tools/idf_monitor.py -p /dev/ttyUSB0 -b 115200 --toolchain-prefix xtensa-esp32-elf- /home/pi/esp/simple/build/simple.elf -m '/home/pi/.espressif/python_env/idf4.4_py3.5_env/bin/python' '/home/pi/esp/esp-idf/tools/idf.py' '-p' '/dev/ttyUSB0'"...
--- idf_monitor on /dev/ttyUSB0 115200 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
ets Jun  8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 188777542, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:6916
load:0x40078000,len:14336
ho 0 tail 12 room 4
load:0x40080400,len:3672
0x40080400: _init at ??:?

entry 0x40080678
I (29) boot: ESP-IDF v4.4-dev-4-g73db14240 2nd stage bootloader
I (30) boot: compile time 16:45:21
I (30) boot: chip revision: 1
I (34) boot_comm: chip revision: 1, min. bootloader chip revision: 0
I (41) boot.esp32: SPI Speed      : 40MHz
I (45) boot.esp32: SPI Mode       : DIO
I (50) boot.esp32: SPI Flash Size : 2MB
I (54) boot: Enabling RNG early entropy source...
I (60) boot: Partition Table:
I (63) boot: ## Label            Usage          Type ST Offset   Length
I (71) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (78) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (86) boot:  2 factory          factory app      00 00 00010000 00100000
I (93) boot: End of partition table
I (97) boot_comm: chip revision: 1, min. application chip revision: 0
I (104) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=18fc0h (102336) map
I (149) esp_image: segment 1: paddr=00028fe8 vaddr=3ffb0000 size=0424ch ( 16972) load
I (156) esp_image: segment 2: paddr=0002d23c vaddr=40080000 size=02ddch ( 11740) load
I (161) esp_image: segment 3: paddr=00030020 vaddr=400d0020 size=7c564h (509284) map
I (343) esp_image: segment 4: paddr=000ac58c vaddr=40082ddc size=12c54h ( 76884) load
I (386) boot: Loaded app from partition at offset 0x10000
I (386) boot: Disabling RNG early entropy source...
I (397) cpu_start: Pro cpu up.
I (397) cpu_start: Starting app cpu, entry point is 0x4008123c
0x4008123c: call_start_cpu1 at /home/pi/esp/esp-idf/components/esp_system/port/cpu_start.c:143

I (0) cpu_start: App cpu up.
I (412) cpu_start: Pro cpu start user code
I (412) cpu_start: cpu freq: 160000000
I (412) cpu_start: Application information:
I (416) cpu_start: Project name:     simple
I (421) cpu_start: App version:      1
I (425) cpu_start: Compile time:     Mar  1 2021 17:46:19
I (432) cpu_start: ELF file SHA256:  3f399528bea977d5...
I (437) cpu_start: ESP-IDF:          v4.4-dev-4-g73db14240
I (444) heap_init: Initializing. RAM available for dynamic allocation:
I (451) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (457) heap_init: At 3FFB7F98 len 00028068 (160 KiB): DRAM
I (463) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (470) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (476) heap_init: At 40095A30 len 0000A5D0 (41 KiB): IRAM
I (483) spi_flash: detected chip: gd
I (486) spi_flash: flash io: dio
W (490) spi_flash: Detected size(4096k) larger than the size in the binary image header(2048k). Using the size in the binary image header.
I (505) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
I (605) wifi:wifi driver task: 3ffc1688, prio:23, stack:6656, core=0
I (605) system_api: Base MAC address is not set
I (605) system_api: read default base MAC address from EFUSE
I (625) wifi:wifi firmware version: 6b2834e
I (625) wifi:wifi certification version: v7.0
I (625) wifi:config NVS flash: enabled
I (625) wifi:config nano formating: disabled
I (635) wifi:Init data frame dynamic rx buffer num: 32
I (635) wifi:Init management frame dynamic rx buffer num: 32
I (645) wifi:Init management short buffer num: 32
I (645) wifi:Init dynamic tx buffer num: 32
I (655) wifi:Init static rx buffer size: 1600
I (655) wifi:Init static rx buffer num: 10
I (655) wifi:Init dynamic rx buffer num: 32
I (665) wifi_init: rx ba win: 6
I (665) wifi_init: tcpip mbox: 32
I (675) wifi_init: udp mbox: 6
I (675) wifi_init: tcp mbox: 6
I (675) wifi_init: tcp tx win: 5744
I (685) wifi_init: tcp rx win: 5744
I (685) wifi_init: tcp mss: 1440
I (695) wifi_init: WiFi IRAM OP enabled
I (695) wifi_init: WiFi RX IRAM OP enabled
I (705) example_connect: Connecting to jrs...
I (705) phy_init: phy_version 4660,0162888,Dec 23 2020
I (805) wifi:mode : sta (d8:a0:1d:5f:c1:54)
I (805) wifi:enable tsf
I (815) example_connect: Waiting for IP(s)
I (1915) wifi:new:<10,0>, old:<1,0>, ap:<255,255>, sta:<10,0>, prof:1
I (2845) wifi:state: init -> auth (b0)
I (2855) wifi:state: auth -> assoc (0)
I (2855) wifi:state: assoc -> run (10)
I (2865) wifi:connected with jrs, aid = 7, channel 10, BW20, bssid = d8:07:b6:f8:b1:97
I (2865) wifi:security: WPA2-PSK, phy: bgn, rssi: -28
I (2865) wifi:pm start, type: 1

W (2885) wifi:<ba-add>idx:0 (ifx:0, d8:07:b6:f8:b1:97), tid:0, ssn:0, winSize:64
I (2935) wifi:AP's beacon interval = 102400 us, DTIM period = 1
I (3595) esp_netif_handlers: example_connect: sta ip: 192.168.0.246, mask: 255.255.255.0, gw: 192.168.0.1
I (3595) example_connect: Got IPv4 event: Interface "example_connect: sta" address: 192.168.0.246
I (3605) example_connect: Connected to example_connect: sta
I (3605) example_connect: - IPv4 address: 192.168.0.246
I (3615) example: Starting server on port: '80'
I (3625) example: Registering URI handlers
I (10935) example: Found header => Host: 192.168.0.246
I (10945) example: Request headers lost
I (360815) example: =========== RECEIVED DATA ==========
I (360815) example: Set ESP Environment:

. $HOME/esp/esp-idf/export.sh


Copy Project for build:

cd ~/esp
cp -r /home/
I (360825) example: ====================================
I (360825) example: =========== RECEIVED DATA ==========
I (360835) example: pi/esp/examples/get-started/hello_world .


Configure Project:

cd ~/esp/hello_world
idf.py set-targ
I (360845) example: ====================================
I (360855) example: =========== RECEIVED DATA ==========
I (360855) example: et esp32
idf.py menuconfig


Build Project:

idf.py build


Flash Project:

idf.py -p /dev/ttyUSB0 f
I (360865) example: ====================================
I (360875) example: =========== RECEIVED DATA ==========
I (360885) example: lash


Run / Monitor Project:

idf.py -p /dev/ttyUSB0 monitor

I (360885) example: ====================================


Second console executing Curl Commands to the ESP32-Pico HTTPD server

pi@RPi3B:~ $ curl 192.168.0.246:80/hello
Hello World!
pi@RPi3B:

pi@RPi3B:~/esp $ curl -X POST --data-binary @esp_usage.txt 192.168.0.246:80/echo > tmpfile
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   724    0   362  100   362    230    230  0:00:01  0:00:01 --:--:--   230
pi@RPi3B:
pi@RPi3B:~/esp $ cat tmpfile
Set ESP Environment:

. $HOME/esp/esp-idf/export.sh


Copy Project for build:

cd ~/esp
cp -r /home/pi/esp/examples/get-started/hello_world .


Configure Project:

cd ~/esp/hello_world
idf.py set-target esp32
idf.py menuconfig


Build Project:

idf.py build


Flash Project:

idf.py -p /dev/ttyUSB0 flash


Run / Monitor Project:

idf.py -p /dev/ttyUSB0 monitor
pi@RPi3B:~/esp $

pi@RPi3B:~/esp/simple $ curl -X POST --data-binary @hellostring 192.168.0.246:80/echo
Hello WIFI user.
This is the ESP32-PICO you're connected to.

pi@RPi3B:~/esp/simple $ cat hellostring
Hello WIFI user.
This is the ESP32-PICO you're connected to.

pi@RPi3B:~/esp/simple $



Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version