OS: Windows 8.1
Setting Up The Environment
Follow the instruction in https://youtu.be/AEWoeL1hH2I (less detail but also covers the setup of ESP8266 SDK) or https://youtu.be/kYEzEFH5LiM (focus mainly on VirtualBox setup and with more detailed explanations of the procedure) to setup VirtualBox and install Ubuntu on the computer.
After VirtualBox is setup, issue the following command to add the necessary tools for doing software development using Ubuntu.
$ sudo apt-get install make unrar-free autoconf automake libtool gcc g++ gperf \
flex bison texinfo gawk ncurses-dev libexpat-dev python-dev python python-serial \
sed git unzip bash help2man wget bzip2
$ sudo apt-get install libtool-bin
Note,
- Remember to install openssh server by issuing "sudo apt-get install openssh-server"so that you could start Ubuntu in headless mode and use putty to login to do development work.
- To set Ubuntu to boot into text mode, follow the instruction at https://askubuntu.com/questions/16371/how-do-i-disable-x-at-boot-time-so-that-the-system-boots-in-text-mode.
- Use sudo apt-get upgrade to upgrade the system after first login.
Add Copy & Paste and Drag & Drop between VirtualBox and Windows
Add support for USB to UART Module
Follow the instruction in the link below to add support for USB to UART module.
https://stackoverflow.com/questions/20021300/usb-devices-are-not-recognized-in-virtualbox-linux-host
After the support is added, the support info. will be displayed in the USB window (see below pic.).
Plug in the USB to UART module, launch LinuxDev in Detachable Start mode, move mouse pointer to USB icon to show attached USB to UART module.
Follow the instruction in https://youtu.be/T-oSjMCmNYk to complete the setting of USB support and the SDK.
Check USB devices attached in Terminal
lsusb
Check kernel log
tail -f /var/log/kern.log
The kernel log output after plugging in the CP2102 USB to TTL module.
Check the device file
ls -al /dev/ttyUSB0
In order for a user to access /dev/ttyUSB0, the user needs to be a member of the dialout group. Issue the command sudo adduser user dialout (note, replace user with the login username, in my case, it's wei-hsiung").
Log out of LinuxDev, make sure the USB to UART module is plugged in, then log back in to LinuxDev again.
After logging back in, run lsusb to make sure the USB to UART module is correctly detected by the system.
Install Minicom
sudo apt-get install minicom
Run Minicom
minicom --device /dev/ttyUSB0
Download the SDK
- Create a directory to store the SDK. In my case, the directory is called ESP8266.
- Change directory to ESP8266
- Run git clone --recursive https://github.com/pfalcon/esp-open-sdk.git from within the ESP8266 directory. For more info., visit this site - https://github.com/pfalcon/esp-open-sdk.
Build the SDK
- Change working directory to where the downloaded esp-open-sdk is stored (in my case, it's /esp8266/esp-open-sdk).
- Run make.
Modify the login script to include the script for running the Xtensa toolchain
Below is the script needed to run the Xtensa toolchain
export PATH=/home/wei-hsiung/esp8266/esp-open-sdk/xtensa-lx106-elf/bin:$PATH
To add the script:
Check the existing login script
- Issue cd /home command to change the working directory to the home directory.
- Issue cat ~/.profile to check the login script.
Add the script for running the Xtensa toolchain to the existing login script
- Issue echo 'export PATH=/home/wei-hsiung/esp8266/esp-open-sdk/xtensa-lx106-elf/bin:$PATH' >> ~/.profile
- Check the login script by issuing cat ~/.profile again.
- Log out of the terminal then log back in again.
- Run echo $PATH to see if the new path has been added (note, indeed it's been added).
Build an example firmware
- Change working directory to ~/esp8266/esp-open-sdk/examples/blinky
- Run make to compile the firmware.
Testing out esptool.py
The tool for uploading firmware to ESP is esptool.py.
Issue "esptool.py --help" to find a list of available options.
Note that in order for esptool.py to function properly, the ESP module needs to be in flash mode. Otherwise, it will fail to function properly.
The photo below shows a fail attempt to get the chip id (before putting the ESP module in flash mode).
In the case of ESP-01, press and hold the FLASH button first then place and release the RESET button to put the ESP-01 module in flash mode (see below photo).
The photo below shows a successful attempt to get the chip id (after putting the ESP module in flash mode).
Upload the bin file to the ESP module
- Change directory to where blinky is located. In my case, it's located under ~/esp8266/esp-open-sdk/examples/blinky
- Put the ESP module in flash mode
- Issue the command "esptool.py --baud 57600 write_flash 0x00000 blinky-0x00000.bin 0x10000 blinky-0x10000.bin"
The firmware is now written to the flash and the LED on the ESP module is blinking..
P.S. To compile the firmware again, run make clean. It will remove all the files created by running make.
Note that the baud rate doesn't have to be fixed to 57600 or lower rate, it could be changed to 115200 for faster upload time (see below pic).
References:
ESP8266: Development Environment
how to program esp8266 using nonos sdk
AMMAURO #3 - ESP8266 IoT 2017, native C SDK Getting Started for Windows, Mac & Linux
https://www.youtube.com/watch?v=T-oSjMCmNYk
No comments:
Post a Comment