JOSH ESP32 Building Instructions (Linux host) - JOSH-VM/JOSHVM GitHub Wiki
1. Setup ESP32 building environment
1.1 Linux setup
JOSH ESP32 could be built in Linux host (Windows building is also possible and instruction will be updated later). All the building instructions below has been tested on Ubuntu Linux 16.04 LTS 64-bit Desktop. Firstly, according to ESP32 official guide, we need to use Python3.6 and later version to install ESP32 toolchain. Because Ubuntu Linux 16.04 LTS doesn't install the new version of Python, so we need to install required Python version manually. We use 3.9.9 currently:
sudo apt-get update
cd ~
wget https://www.python.org/ftp/python/3.9.9/Python-3.9.9.tgz
tar xzvf Python-3.9.9.tgz
cd Python-3.9.9
./configure
make
sudo make install
Then fix the Python symbolic links correctly:
sudo rm /usr/bin/python
sudo rm /usr/bin/python3
ln -s /usr/local/bin/python3.9 /usr/bin/python3
ln -s /usr/bin/python3 /usr/bin/python
According to ESP32 official guide, firstly need to update and install ESP32 toolchain dependent packages:
sudo apt-get install git wget flex bison gperf cmake ninja-build ccache libffi-dev libssl-dev
sudo apt-get install libncurses5-dev
Because JOSH building needs Linux GNU 32bit toolchain as well, libg++-multilib is required:
sudo apt-get install g++-multilib
Note: Permission issues /dev/ttyUSB0. With some Linux distributions you may get the Failed to open port /dev/ttyUSB0 error message when flashing the ESP32. This can be solved by adding the current user to the dialout group, please refer to: https://docs.espressif.com/projects/esp-idf/en/stable/get-started/establish-serial-connection.html#linux-dialout-group
1.2 Install ESP32-IDF & cross-compiling toolchain
NOTE: If you ONLY want to build JOSH for ESP32-LyraT-Mini development board, you can now skip this section (1.2) and directly go to section 1.3. If you do need to build JOSH for ESP32-WROVERKIT board, please go ahead.
JOSH ESP32 building will keep updating with recent release of ESP32-IDF (currently v4.0), use below instructions to get the source:
cd ~
git clone https://github.com/espressif/esp-idf.git esp-idf_v4.0
cd esp-idf_v4.3.1
git checkout release/v4.3.1
git submodule update --init --recursive
Now run install.sh to install target toolchain:
./install.sh
1.3 Install ESP32-ADF & toolchain
NOTE: If you DON'T need to build JOSH for ESP32-LyraT-Mini development board, you can now skip this section (1.3) and directly go to section 1.4. If you do need to build JOSH for ESP32-LyraT-Mini board, please go ahead.
JOSH ESP32 support both ESP32-WROVERKIT and ESP32-LyraT-Mini board, which the later one support Audio recording and playing. To support Audio functions, you will need ESP32-LyraT-Mini board and ESP-ADF installed on your building host. Furthermore, you will find that you have to install different version of target toolchain from ESP-IDF building.
cd ~
git clone https://github.com/ruitaomu/esp-adf_JOSHVM.git esp-adf_JOSHVM
cd esp-adf_JOSHVM
git checkout esp-adf_JOSHVM_beta2
git submodule update --init --recursive
This is a patched version of ADF for JOSHVM building. Because ADF must building with lower version of compiler, a older toolchain should be installed.
cd ~
wget https://dl.espressif.com/dl/xtensa-esp32-elf-linux64-1.22.0-80-g6c4433a-5.2.0.tar.gz
tar xzvf xtensa-esp32-elf-linux64-1.22.0-80-g6c4433a-5.2.0.tar.gz
1.4 Download JDK
Building JOSH requires JDK installed. Download JDK 7 from java.net:
cd ~
wget https://download.java.net/openjdk/jdk7u75/ri/openjdk-7u75-b13-linux-x64-18_dec_2014.tar.gz
tar xzvf openjdk-7u75-b13-linux-x64-18_dec_2014.tar.gz
The openjdk should be found in ~/java-se-7u75-ri
2. Get JOSHVM source code:
cd ~
git clone https://github.com/JOSH-VM/JOSHVM.git
3. Build JOSHVM ESP32 for WROVERKIT board
NOTE: If you only want to build JOSH ESP32 for LyraT-Mini board, just skip this step and go to Section 4
3.1 Build JOSHVM libraries for WROVERKIT board
Firstly, set the building environment variables and cross-compiling tools path:
export IDF_PATH=~/esp-idf_v4.0
source ~/esp-idf_v4.0/export.sh
To confirm the correct version of toolchain is using, type:
xtensa-esp32-elf-gcc -v
At the bottom of output it should be shown as: gcc version 8.2.0 (crosstool-NG esp-2019r2) Then build JOSHVM:
cd ~/JOSHVM
Use your text editor to open build-esp32-linux.sh, find the two lines like this:
TARGET_BOARD=ESP_WROVER
#TARGET_BOARD=ESP_MINI
To build JOSHVM for WROVERKIT, the two line should be like above, to make it select ESP_WROVER building. Then save it. Now we start building JOSHVM:
cd ~/JOSHVM
./build-esp32-linux.sh -J ~/java-se-7u75-ri -C -I
3.2 Build JOSHVM ESP32 WROVERKIT binary image
cd ~/JOSHVM/build_ext/board/esp32_WROVER/joshvm
Connect WROVERKIT development board to you Linux USB port, you should see the port /dev/ttyUSB1. That's the port to be flashed. Then download JOSH image to the board by:
make flash
If you have met permission problem to access this port, please refer to the link in section 1.1 to resolve it. If make complains that it can't find /dev/ttyUSB1, please use
ls /dev/ttyUSB*
to ensure if it's there. If not, try to unplug and plug the board again to USB port. Or, it may happen to be shown as other ttyUSBx port. In this case you will need to reconfig USB port name by:
make menuconfig
Find Serial flasher config ---> Default serial port, to change it to the correct port name.
If everthing OK, the JOSH image should now already been flashed to the board. The next step is to verify and try JOSH application programming in JOSHVMStudio IDE (https://github.com/JOSH-VM/JOSHVM/wiki/ESP32-JOSH-Application-Development-Guide).
4. Build JOSHVM ESP32 for LyraT-Mini board
4.1 Build JOSHVM libraries for LyraT-Mini board
Firstly, set the building environment variables and cross-compiling tools path:
export PATH=~/xtensa-esp32-elf/bin:$PATH
export IDF_PATH=~/esp-adf_JOSHVM/esp-idf
export ADF_PATH=~/esp-adf_JOSHVM
To confirm the correct version of toolchain is using, type:
xtensa-esp32-elf-gcc -v
At the bottom of output it should be shown as:
gcc version 5.2.0
Then build JOSHVM:
cd ~/JOSHVM
Use your text editor to open build-esp32-linux.sh, find the two lines like this:
#TARGET_BOARD=ESP_WROVER
TARGET_BOARD=ESP_MINI
To build JOSHVM for LyraT-Mini, the two line should be like above, to make it select ESP_MINI building. Then save it.
Now let's start building JOSHVM:
cd ~/JOSHVM
./build-esp32-linux.sh -J ~/java-se-7u75-ri -C -I
4.2 Build JOSHVM ESP32 LyraT-Mini binary image
cd ~/JOSHVM/build_ext/board/esp32_MINI/joshvm
Connect LyraT-Mini development board to you Linux USB port, you should see the port /dev/ttyUSB1. That's the port to be flashed. Then download JOSH image to the board by:
make flash
If you have met permission problem to access this port, please refer to the link in section 1.1 to resolve it. If make complains that it can't find /dev/ttyUSB1, please use
ls /dev/ttyUSB*
to ensure if it's there. If not, try to unplug and plug the board again to USB port. Or, it may happen to be shown as other ttyUSBx port. In this case you will need to reconfig USB port name by:
make menuconfig
Find Serial flasher config ---> Default serial port, to change it to the correct port name.
If everthing OK, the JOSH image should now already been flashed to the board. The next step is to verify and try JOSH application programming in JOSHVMStudio IDE (https://github.com/JOSH-VM/JOSHVM/wiki/ESP32-JOSH-Application-Development-Guide).