Skip to content

Instantly share code, notes, and snippets.

@amirgon
Last active October 29, 2015 21:58
Show Gist options
  • Save amirgon/8ff36d4703e0f1042a70 to your computer and use it in GitHub Desktop.
Save amirgon/8ff36d4703e0f1042a70 to your computer and use it in GitHub Desktop.
ESP8266 Deveopment on Linux VirtualBox

Backgroud

I'll summarize the list of steps I've taken to prepare a Linux VirtualBox on Windows as a development environment for ESP8266 . Prerequisites

  • Laptop with Windows (mine with with Windows 8.1)
  • ESP-12 module, this with it's "IO adapter plate Expansion" can fit nicely on two connected breadboards
  • Any USB to Serial / TTL Converter, like this one.
  • I'm not going to cover ESP wiring in this wirting.

Steps:

  • Download and Install VirtualBox 5.0.0
  • Install Ubuntu 14.04 from an ISO image
  • Install Guest Additions for Ubuntu. I did it from an ISO image.
    • This fixes the screen resolution problem. After the installation you can resize to any dimension.
  • Install esp-open-sdk. Follow the instructions there for Ubuntu 14.04, for installing dependencies, cloning git repository and building.
    I installed the SDK under /home/amirg/projects/esp-open-sdk
    • I chose to build it in "separate" mode - make STANDALONE=y.
  • Clone the esp-source-code-examples
  • Since the open-sdk based Makefiles expect the Espressif toolchain to be under /opt/Espressif, I created these symbolic links: /opt/Espressif/ESP8266_SDK -> /home/amirg/projects/esp-open-sdk/sdk /opt/Espressif/crosstool-NG/builds/xtensa-lx106-elf -> /home/amirg/projects/esp-open-sdk/xtensa-lx106-elf/ Of course I had to create the sub directories where I put these links in.
  • make on source-code-examples/blinky directory should pass smoothly now, generating 0x00000.bin and 0x40000.bin under firmware/
  • Add USB filter on the VM --> settings --> USB menu. If the FTDI drivers were installed on Windows, you can just select FTDI FT232R USB UART. Unfortunately, this doesn't work out of the box and require some hassle:
    • Follow the procedure described here to fix the VirtualBox USB filter driver installation. Yes... edit registery, reboot etc.
    • At this point the USB driver should work. Check it by running lsusb on the Linux console. You should get something like:
      Bus 001 Device 007: ID 0403:6001 Future Technology Devices International, Ltd FT232 USB-Serial (UART) IC
  • How to set baud rate??? Currently I use the spd_cust divisor of setserial. It's a trick to set a custom baud rate of the serial port when connecting to it with the 38400 baud rate. For example:
    sudo setserial -v /dev/ttyUSB0 spd_cust divisor $((24000000/74880)) would set the serial port to 74880. Then connect with PuTTY setting the Serial Line to /dev/ttyUSB0 and Speed to 38400. 38400 just tells the serial driver to use the custom speed.
    • 74880 is the default when in boot mode:(3,7). See more details here.
    • Need to change the Makefile to set the 38400 baud rate:
      $(ESPTOOL) -b 38400
  • make flash should work smoothly now. I was able to flash with baud rate up to 460800. Higher rates such as 921600 didn't work for me.

Serial Console

With screen utility:

sudo setserial -v /dev/ttyUSB0 spd_cust divisor $((24000000/74880))
screen /dev/ttyUSB0 38400

Escape key is CTRL-a, exiting: CTRL-a \

Using the SDK to compile a project

So it seems Espressif makefile expects very specific directory structure. Described here:

  • /home/my_at
    • --at .......... copy from SDK/examples
    • Makefile ....... copy or link from SDK/, this is the master makefile
    • include ........ link to SDK/include
    • ld ............. link to SDK/ld
    • tools .......... link to SDK/tools
    • bin ............ create empty, output will be placed here
    • --upgrade ..... create empty

Flashing image

/opt/esp-open-sdk/esptool/esptool.py --port /dev/ttyUSB0 write_flash 0x00000 ../bin/eagle.flash.bin 0x40000 ../bin/eagle.irom0text.bin

Written with StackEdit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment