venerdì 1 marzo 2019

Toolchain per ESP32 su Linux

Post per impostare l'ambiente di sviluppo esp32-idf su Debian 9

si installano i pacchetti

apt-get install gcc git wget make libncurses-dev flex bison gperf python python-pip python-setuptools python-serial python-cryptography python-future python-pyparsing

e successivamente
mkdir esp
cd ~/esp 
git clone -b v3.1.3 --recursive
cd esp-idf
export IDF_PATH=~/esp/esp-idf 

si scarica il compilatore e lo si decomprime

tar -xzf ~/Downloads/xtensa-esp32-elf-linux64-1.22.0-80-g6c4433a-5.2.0.tar.gz
si inserisce l'ambiente di sviluppo in Path

export PATH="$HOME/esp/xtensa-esp32-elf/bin:$PATH"
se tutto e' andato bene si puo' andare in $HOME/esp/esp-idf/examples/get-started/hello_world e digitare make per vedere se il progetto si compila (viene generato il bootloader all'indirizzo 0x10000 oltre al programma vero e proprio all'inidirizzo 0x8000). Al termine si puo' digitare

make flash 

per copiarlo sulla scheda (questi i messaggi)

Flashing binaries to serial port /dev/ttyUSB0 (app at offset 0x10000 )... v2.6
Serial port /dev/ttyUSB0
Chip is ESP32D0WDQ6 (revision 0)
Features: WiFi, BT, Dual Core, Coding Scheme None
MAC: 24:0a:c4:05:df:5c
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Auto-detected Flash size: 4MB
Flash params set to 0x0220
Compressed 21184 bytes to 12506...
Wrote 21184 bytes (12506 compressed) at 0x00001000 in 1.1 seconds (effective 153.7 kbit/s)...
Hash of data verified.
Compressed 144080 bytes to 68379...
Wrote 144080 bytes (68379 compressed) at 0x00010000 in 6.0 seconds (effective 190.8 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 103...
Wrote 3072 bytes (103 compressed) at 0x00008000 in 0.0 seconds (effective 1843.8 kbit/s)...
Hash of data verified.

Hard resetting via RTS pin...

Collegandosi con minicom alla /dev/ttyUSB0 si ottengono le seguenti stringhe
rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)                          
configsip: 0, SPIWP:0xee                                                        
mode:DIO, clock div:2                                                           
entry 0x4008032c                                                                
I (29) boot: ESP-IDF v3.1.3 2nd stage bootloader                                
I (29) boot: compile time 11:25:47                                              
I (29) boot: Enabling RNG early entropy source...                               
I (34) boot: SPI Speed      : 40MHz                                             
I (38) boot: SPI Mode       : DIO                                               
I (42) boot: SPI Flash Size : 4MB                                               
I (46) boot: Partition Table:                                                   
I (49) boot: ## Label            Usage          Type ST Offset   Length         
I (57) boot:  0 nvs              WiFi data        01 02 00009000 00006000       
I (64) boot:  1 phy_init         RF data          01 01 0000f000 00001000       
I (72) boot:  2 factory          factory app      00 00 00010000 00100000       
I (79) boot: End of partition table                                             
I (83) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x07180 ( 2p
I (102) esp_image: segment 1: paddr=0x000171a8 vaddr=0x3ffb0000 size=0x022a0 ( d
I (106) esp_image: segment 2: paddr=0x00019450 vaddr=0x40080000 size=0x00400 ( d
I (110) esp_image: segment 3: paddr=0x00019858 vaddr=0x40080400 size=0x067b8 ( d
I (130) esp_image: segment 4: paddr=0x00020018 vaddr=0x400d0018 size=0x11150 ( p
I (155) esp_image: segment 5: paddr=0x00031170 vaddr=0x40086bb8 size=0x02130 ( d
I (164) boot: Loaded app from partition at offset 0x10000                       
I (164) boot: Disabling RNG early entropy source...                             
I (166) cpu_start: Pro cpu up.                                                  
I (170) cpu_start: Starting app cpu, entry point is 0x40080e74                  
I (162) cpu_start: App cpu up.                                                  
I (181) heap_init: Initializing. RAM available for dynamic allocation:          
I (187) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM                       
I (193) heap_init: At 3FFB32F8 len 0002CD08 (179 KiB): DRAM                     
I (200) heap_init: At 3FFE0440 len 00003BC0 (14 KiB): D/IRAM                    
I (206) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM                   
I (213) heap_init: At 40088CE8 len 00017318 (92 KiB): IRAM                      
I (219) cpu_start: Pro cpu start user code                                      
I (237) 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 cores, WiFi/BT/BLE, silicon revision 0, 4MB exterh
Restarting in 10 seconds...                                                     
Restarting in 9 seconds...                                                      
Restarting in 8 seconds...                                                      
Restarting in 7 seconds...                                                      
Restarting in 6 seconds...                                                      
Restarting in 5 seconds...                                                      
Restarting in 4 seconds...                                                      
Restarting in 3 seconds...                                                      
Restarting in 2 seconds...                                                      
Restarting in 1 seconds...                                                      
Restarting in 0 seconds...                                                      
Restarting now.

Questo comportamento e' coerente con il programma hello_world.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 "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_system.h"
#include "esp_spi_flash.h"

void app_main()
    printf("Hello world!\n");

    /* Print chip information */
    esp_chip_info_t chip_info;
    printf("This is ESP32 chip with %d CPU cores, WiFi%s%s, ",
            (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");

    for (int i = 10; i >= 0; i--) {
        printf("Restarting in %d seconds...\n", i);
        vTaskDelay(1000 / portTICK_PERIOD_MS);
    printf("Restarting now.\n");

In conclusione l'ambiente di sviluppo e' funzionante

Nessun commento:

Posta un commento