Skip to content

Commit aad6cb4

Browse files
author
mean
committed
[esp32] example
1 parent d00f1e3 commit aad6cb4

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed

example/esp32/CMakeLists.txt

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
######################################
2+
#
3+
# Hello world for ESP32/Cmake
4+
#
5+
######################################
6+
cmake_minimum_required(VERSION 3.0)
7+
#--------------------------------------------------------------------------------------
8+
# Select platform
9+
SET(PLATFORM_ARCHITECTURE "ESP32")
10+
# and installation for extra arduino files AND toolchain (compiler...)
11+
# Path to the toolchain, must contain arm-none-eabi-gcc,-g++ and friends
12+
SET(PLATFORM_TOOLCHAIN_PATH "/home/fx/Arduino/hardware/espressif/esp32/tools/xtensa-esp32-elf/bin/")
13+
# Path to the platform folder
14+
# You can download it from https://github.com/rogerclarkmelbourne/Arduino_STM32.git
15+
# ***** The last folder ** MUST BE *** arduino *****
16+
SET(PLATFORM_PATH "/home/fx/Arduino/hardware/espressif/esp32")
17+
# and here we go
18+
SET(CMAKE_TOOLCHAIN_FILE cmake/ArduinoToolchain.cmake)
19+
MESSAGE(STATUS "Starting hello-esp32")
20+
#
21+
#
22+
#
23+
Project("Hello_esp32" C CXX ASM) # ASM must be present !
24+
MESSAGE(STATUS "Dumping board")
25+
print_board_list()
26+
#
27+
# that changes the way the binary is linked, better to use DFU in all cases !
28+
SET(ARDUINO_UPLOAD_METHOD DFUUpload)
29+
30+
#
31+
set(ARDUINO_DEFAULT_BOARD esp32) # Default Board ID, when not specified
32+
#set(ARDUINO_DEFAULT_PORT ttyACM0) # Default Port, when not specified
33+
#set(ARDUINO_CPU STM32F103C8)
34+
#
35+
generate_arduino_firmware(GetChipID
36+
SKETCH GetChipID.ino # Folder to get the .ino from, must follow DIR_NAME/DIR_NAME.ino patten !
37+
PORT ${ARDUINO_DEFAULT_PORT}
38+
)
39+
#--------------------------------------------------------------------------------------

example/esp32/GetChipID.ino

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include "stdint.h"
2+
uint64_t chipid;
3+
4+
void setup() {
5+
Serial.begin(115200);
6+
}
7+
8+
void loop() {
9+
chipid=ESP.getEfuseMac();//The chip ID is essentially its MAC address(length: 6 bytes).
10+
Serial.printf("ESP32 Chip ID = %04X",(uint16_t)(chipid>>32));//print High 2 bytes
11+
Serial.printf("%08X\n",(uint32_t)chipid);//print Low 4bytes.
12+
13+
delay(3000);
14+
15+
}

example/esp32/cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/home/fx/Arduino_esp32/GetId/cmake/example/esp32/../..

0 commit comments

Comments
 (0)