Skip to content

Commit cc267ab

Browse files
donghengdongheng
dongheng
authored and
dongheng
committed
feat(hello_world): add example hello_world from esp-idf and modify it for ESP8266
Commit ID: b0456cc9
1 parent 0193d06 commit cc267ab

File tree

30 files changed

+113
-120
lines changed

30 files changed

+113
-120
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export IDF_PATH=~/esp/ESP8266_RTOS_SDK
7171
```
7272

7373
## Start a Project
74-
Now you are ready to prepare your application for ESP8266. To start off quickly, we can use `examples/get-started/project_template` project from `examples` directory in SDK.
74+
Now you are ready to prepare your application for ESP8266. To start off quickly, we can use `examples/get-started/hello_world` project from `examples` directory in SDK.
7575

7676
Once you've found the project you want to work with, change to its directory and you can configure and build it.
7777

@@ -81,10 +81,10 @@ You are almost there. To be able to proceed further, connect ESP8266 board to PC
8181

8282
## Configuring the Project
8383

84-
Being in terminal window, go to directory of `project_template` application by typing `cd ~/esp/ESP8266_RTOS_SDK/examples/get-started/project_template`. Then start project configuration utility `menuconfig`:
84+
Being in terminal window, go to directory of `hello_world` application by typing `cd ~/esp/ESP8266_RTOS_SDK/examples/get-started/hello_world`. Then start project configuration utility `menuconfig`:
8585

8686
```
87-
cd ~/esp/ESP8266_RTOS_SDK/examples/get-started/project_template
87+
cd ~/esp/ESP8266_RTOS_SDK/examples/get-started/hello_world
8888
make menuconfig
8989
```
9090

docs/en/api-guides/build-system.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ concept of "components"
77
Read this document if you want to know how to organise a new ESP8266\_RTOS\
88
-SDK (ESP-IDF Style) project.
99

10-
We recommend using the project_template project at directory of examples/get-started as a starting point for your project.
10+
We recommend using the hello_world project at directory of examples/get-started as a starting point for your project.
1111

1212
Using the Build System
1313
======================

docs/en/api-guides/fota-from-old-new.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ Configure the flash size according to your actual development board's flash.
111111
(mypassword) WiFi Password
112112
(192.168.0.3) HTTP Server IP
113113
(8070)HTTP Server Port
114-
(/project_template.ota.bin) HTTP GET Filename
114+
(/hello_world.ota.bin) HTTP GET Filename
115115

116116
- WiFi SSID: Wi-Fi SSID of router
117117
- WiFi Password: Wi-Fi password of router

docs/en/get-started/index.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,12 @@ Python packages required by ESP8266\_RTOS\_SDK are located in the ``$IDF_PATH/re
144144
Start a Project
145145
===============
146146

147-
Now you are ready to prepare your application for ESP8266. To start off quickly, we will use :example:`get-started/project_template` project from :idf:`examples` directory in IDF.
147+
Now you are ready to prepare your application for ESP8266. To start off quickly, we will use :example:`get-started/hello_world` project from :idf:`examples` directory in IDF.
148148

149-
Copy :example:`get-started/project_template` to ``~/esp`` directory::
149+
Copy :example:`get-started/hello_world` to ``~/esp`` directory::
150150

151151
cd ~/esp
152-
cp -r $IDF_PATH/examples/get-started/project_template .
152+
cp -r $IDF_PATH/examples/get-started/hello_world .
153153

154154
You can also find a range of example projects under the :idf:`examples` directory in ESP-IDF. These example project directories can be copied in the same way as presented above, to begin your own projects.
155155

@@ -171,9 +171,9 @@ You are almost there. To be able to proceed further, connect ESP8266 board to PC
171171
Configure
172172
=========
173173

174-
Being in terminal window, go to directory of ``project_template`` application by typing ``cd ~/esp/project_template``. Then start project configuration utility ``menuconfig``::
174+
Being in terminal window, go to directory of ``hello_world`` application by typing ``cd ~/esp/hello_world``. Then start project configuration utility ``menuconfig``::
175175

176-
cd ~/esp/project_template
176+
cd ~/esp/hello_world
177177
make menuconfig
178178

179179
If previous steps have been done correctly, the following menu will be displayed:
@@ -245,7 +245,7 @@ This will compile the application and all the ESP8266\_RTOS\_SDK components, gen
245245
Leaving...
246246
Hard resetting via RTS pin...
247247

248-
If there are no issues, at the end of build process, you should see messages describing progress of loading process. Finally, the end module will be reset and "project_template" application will start.
248+
If there are no issues, at the end of build process, you should see messages describing progress of loading process. Finally, the end module will be reset and "hello_world" application will start.
249249

250250
If you'd like to use the Eclipse IDE instead of running ``make``, check out the :doc:`Eclipse guide <eclipse-setup>`.
251251

@@ -255,7 +255,7 @@ If you'd like to use the Eclipse IDE instead of running ``make``, check out the
255255
Monitor
256256
=======
257257

258-
To see if "project_template" application is indeed running, type ``make monitor``.
258+
To see if "hello_world" application is indeed running, type ``make monitor``.
259259

260260
$ make monitor
261261
MONITOR

examples/README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Examples
2+
3+
This directory contains a range of example ESP8266_RTOS_SDK projects. These are intended to demonstrate parts of ESP8266_RTOS_SDK functionality, and to provide code that you can copy and adapt into your own projects.
4+
5+
# Example Layout
6+
7+
The examples are grouped into subdirectories by category. Each category directory contains one or more example projects:
8+
9+
* `get-started` contains some very simple examples with minimal functionality.
10+
* `peripherals` contains examples showing driver functionality for the various onboard ESP8266 peripherals.
11+
* `protocols` contains examples showing network protocol interactions.
12+
* `provisioning` contains examples showing how to configurate target AP information to ESP8266.
13+
* `storage` contains examples showing data storage methods using SPI flash.
14+
* `system` contains examples which demonstrate some debugging, factory-test and OTA.
15+
* `wifi` contains examples of advanced Wi-Fi features. (For network protocol examples, see `protocols` instead.)
16+
17+
# Using Examples
18+
19+
Building an example is the same as building any other project:
20+
21+
* Follow the Getting Started instructions which include building the "Hello World" example.
22+
* Change into the directory of the new example you'd like to build.
23+
* Run `make menuconfig` to open the project configuration menu. Most examples have a project-specific "Example Configuration" section here (for example, to set the WiFi SSID & password to use).
24+
* `make` to build the example.
25+
* Follow the printed instructions to flash, or run `make flash`.
26+
27+
# Copying Examples
28+
29+
Each example is a standalone project. The examples *do not have to be inside the SDK directory*. You can copy an example directory to anywhere on your computer in order to make a copy that you can modify and work with.
30+
31+
The `IDF_PATH` environment variable is the only thing that connects the example to the rest of ESP8266_RTOS_SDK.
32+
33+
If you're looking for a more bare-bones project to start from, try [esp-idf-template](https://github.com/espressif/esp-idf-template).
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# The following lines of boilerplate have to be in your project's
2+
# CMakeLists in this exact order for cmake to work correctly
3+
cmake_minimum_required(VERSION 3.5)
4+
5+
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
6+
project(hello-world)

examples/get-started/project_template/Makefile renamed to examples/get-started/hello_world/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# project subdirectory.
44
#
55

6-
PROJECT_NAME := project_template
6+
PROJECT_NAME := hello-world
77

88
include $(IDF_PATH)/make/project.mk
99

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Hello World Example
2+
3+
Starts a FreeRTOS task to print "Hello World"
4+
5+
See the README.md file in the upper level 'examples' directory for more information about examples.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
idf_component_register(SRCS "hello_world_main.c"
2+
INCLUDE_DIRS "")
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/* Hello World Example
2+
3+
This example code is in the Public Domain (or CC0 licensed, at your option.)
4+
5+
Unless required by applicable law or agreed to in writing, this
6+
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
7+
CONDITIONS OF ANY KIND, either express or implied.
8+
*/
9+
#include <stdio.h>
10+
#include "freertos/FreeRTOS.h"
11+
#include "freertos/task.h"
12+
#include "esp_system.h"
13+
#include "esp_spi_flash.h"
14+
15+
16+
void app_main()
17+
{
18+
printf("Hello world!\n");
19+
20+
/* Print chip information */
21+
esp_chip_info_t chip_info;
22+
esp_chip_info(&chip_info);
23+
printf("This is ESP8266 chip with %d CPU cores, WiFi, ",
24+
chip_info.cores);
25+
26+
printf("silicon revision %d, ", chip_info.revision);
27+
28+
printf("%dMB %s flash\n", spi_flash_get_chip_size() / (1024 * 1024),
29+
(chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded" : "external");
30+
31+
for (int i = 10; i >= 0; i--) {
32+
printf("Restarting in %d seconds...\n", i);
33+
vTaskDelay(1000 / portTICK_PERIOD_MS);
34+
}
35+
printf("Restarting now.\n");
36+
fflush(stdout);
37+
esp_restart();
38+
}

examples/get-started/project_template/CMakeLists.txt

Lines changed: 0 additions & 6 deletions
This file was deleted.

examples/get-started/project_template/components/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

examples/get-started/project_template/components/component.mk

Lines changed: 0 additions & 1 deletion
This file was deleted.

examples/get-started/project_template/components/folder1/file1.c

Whitespace-only changes.

examples/get-started/project_template/components/folder2/file2.c

Whitespace-only changes.

examples/get-started/project_template/main/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

examples/get-started/project_template/main/user_main.c

Lines changed: 0 additions & 22 deletions
This file was deleted.

examples/get-started/project_template/readme.txt

Lines changed: 0 additions & 56 deletions
This file was deleted.

examples/system/ota/native_ota/1MB_flash/new_to_new_no_old/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ When the example starts up, it will print "ota: Starting OTA example..." then:
136136

137137
* Check whether your PC can ping the ESP8266 at its IP, and make sure that the IP, AP and other configuration settings are correct in menuconfig.
138138
* Check if there is any firewall software on the PC that prevents incoming connections.
139-
* Check whether you can see the configured file (default project_template.ota.bin) when browsing the file listing at http://127.0.0.1/
139+
* Check whether you can see the configured file (default hello_world.ota.bin) when browsing the file listing at http://127.0.0.1/
140140
* If you have another PC or a phone, try viewing the file listing from the separate host.
141141

142142
## Error "ota_begin error err=0x104"

examples/system/ota/native_ota/1MB_flash/new_to_new_no_old/main/Kconfig.projbuild

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ config SERVER_PORT
3232

3333
config EXAMPLE_FILENAME
3434
string "HTTP GET Filename"
35-
default "/project_template.bin"
35+
default "/hello_world.bin"
3636
help
3737
Filename of the app image file to download for
3838
the OTA update.

examples/system/ota/native_ota/1MB_flash/new_to_new_no_old_copy/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ When the example starts up, it will print "ota: Starting OTA example..." then:
146146

147147
* Check whether your PC can ping the ESP8266 at its IP, and make sure that the IP, AP and other configuration settings are correct in menuconfig.
148148
* Check if there is any firewall software on the PC that prevents incoming connections.
149-
* Check whether you can see the configured file (default project_template.ota.bin) when browsing the file listing at http://127.0.0.1/
149+
* Check whether you can see the configured file (default hello_world.ota.bin) when browsing the file listing at http://127.0.0.1/
150150
* If you have another PC or a phone, try viewing the file listing from the separate host.
151151

152152
## Error "ota_begin error err=0x104"

examples/system/ota/native_ota/1MB_flash/new_to_new_no_old_copy/main/Kconfig.projbuild

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ config SERVER_PORT
3232

3333
config EXAMPLE_FILENAME
3434
string "HTTP GET Filename"
35-
default "/project_template.bin"
35+
default "/hello_world.bin"
3636
help
3737
Filename of the app image file to download for
3838
the OTA update.

examples/system/ota/native_ota/1MB_flash/new_to_new_with_old/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ When the example starts up, it will print "ota: Starting OTA example..." then:
159159

160160
* Check whether your PC can ping the ESP8266 at its IP, and make sure that the IP, AP and other configuration settings are correct in menuconfig.
161161
* Check if there is any firewall software on the PC that prevents incoming connections.
162-
* Check whether you can see the configured file (default project_template.ota.bin) when browsing the file listing at http://127.0.0.1/
162+
* Check whether you can see the configured file (default hello_world.ota.bin) when browsing the file listing at http://127.0.0.1/
163163
* If you have another PC or a phone, try viewing the file listing from the separate host.
164164

165165
## Error "ota_begin error err=0x104"

examples/system/ota/native_ota/1MB_flash/new_to_new_with_old/main/Kconfig.projbuild

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ config SERVER_PORT
4040

4141
config EXAMPLE_FILENAME
4242
string "HTTP GET Filename"
43-
default "/project_template.ota.bin"
43+
default "/hello_world.ota.bin"
4444
help
4545
Filename of the app image file to download for
4646
the OTA update.

examples/system/ota/native_ota/2+MB_flash/new_to_new_no_old/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ When the example starts up, it will print "ota: Starting OTA example..." then:
127127

128128
* Check whether your PC can ping the ESP8266 at its IP, and make sure that the IP, AP and other configuration settings are correct in menuconfig.
129129
* Check if there is any firewall software on the PC that prevents incoming connections.
130-
* Check whether you can see the configured file (default project_template.ota.bin) when browsing the file listing at http://127.0.0.1/
130+
* Check whether you can see the configured file (default hello_world.ota.bin) when browsing the file listing at http://127.0.0.1/
131131
* If you have another PC or a phone, try viewing the file listing from the separate host.
132132

133133
## Error "ota_begin error err=0x104"

examples/system/ota/native_ota/2+MB_flash/new_to_new_no_old/main/Kconfig.projbuild

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ config SERVER_PORT
3232

3333
config EXAMPLE_FILENAME
3434
string "HTTP GET Filename"
35-
default "/project_template.bin"
35+
default "/hello_world.bin"
3636
help
3737
Filename of the app image file to download for
3838
the OTA update.

examples/system/ota/native_ota/2+MB_flash/new_to_new_with_old/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ When the example starts up, it will print "ota: Starting OTA example..." then:
151151

152152
* Check whether your PC can ping the ESP8266 at its IP, and make sure that the IP, AP and other configuration settings are correct in menuconfig.
153153
* Check if there is any firewall software on the PC that prevents incoming connections.
154-
* Check whether you can see the configured file (default project_template.ota.bin) when browsing the file listing at http://127.0.0.1/
154+
* Check whether you can see the configured file (default hello_world.ota.bin) when browsing the file listing at http://127.0.0.1/
155155
* If you have another PC or a phone, try viewing the file listing from the separate host.
156156

157157
## Error "ota_begin error err=0x104"

examples/system/ota/native_ota/2+MB_flash/new_to_new_with_old/main/Kconfig.projbuild

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ config SERVER_PORT
4040

4141
config EXAMPLE_FILENAME
4242
string "HTTP GET Filename"
43-
default "/project_template.ota.bin"
43+
default "/hello_world.ota.bin"
4444
help
4545
Filename of the app image file to download for
4646
the OTA update.

0 commit comments

Comments
 (0)