Today I will tell you how to install ESP8266 with Arduino on FreeBSD. It works very well. Ok let's start the guide.
You need to compile arduino18 from ports devel/arduino18
Keep the following patch files in /usr/ports/devel/arduino18/files directory and delete the other files:
When you finish installing arduino18package port. you need to download "ESP8266 for Arduino" package. Do the following commands with root or use sudo:
When you finish above steps you can see a directory /usr/local/arduino/hardware/espressif/esp8266 and there are a lot of files in it.
Because the ESP8266 does not support FreeBSD you need to change get.py to download the xtensa tools chain to compile ESP8266 project.
This step is downloading xtensa tools chain for linux64 , so you have to put
Modify tools/get.py
add a line in get.py in 104 lines
set permission for esp8266 directory
Run get.py to download the xtensa tools chain
Install esptools
When you finish above steps you will see a directory in your /usr/local/arduino/hardware/espressif/esp8266/tools/xtensa-lx106-elf there are some directory in it ( bin , lib , include etc...).
Now we must patch arduino-builder to compile esp8266 project properly . the arduino 1.8.5 use arduino-builder to build arduino project ,there is a bug ,so you have to fix it with the patch
Compile arduino-builder from ports before do it you need create a patch file in /usr/ports/devel/arduino-builder/files, the filename is patch-src_arduino_cc_builder_utils_utils.go.
Compile arduino-builder
For use serial port to download program to esp board , you need add serial port driver into kernel
put these into /boot/loader.conf
Install python serial library
Make a python3 soft link in /usr/local/arduino/hardware/espressif/esp8266/tools/python3
Reboot you machine and run arduino, you will see about esp8266 board in your board menu (NODE Mcu , ES8266 Gerneric etc...), that means you have installed successfully.
Congratulation installation is done!
Now you can compile esp8266 example in arduino
#Note
1. There are some Arduino libraries which conflict with the esp8266 library. You have to move /usr/local/arduino/libraries/Wifi and SD modules to /usr/local/arduino/hardware/arduino/avr/libraries
2.esptools download link https://github.com/espressif/esptool
3.all steps need superuser to do that or use sudo
You need to compile arduino18 from ports devel/arduino18
Keep the following patch files in /usr/ports/devel/arduino18/files directory and delete the other files:
Code:
patch-arduino-core_src_cc_arduino_contributions_packages_ContributionInstaller.java
patch-arduino-core_src_cc_arduino_contributions_packages_ContributionsIndexer.java
patch-arduino-core_src_cc_arduino_contributions_packages_HostDependentDownloadableContribution.java
patch-arduino-core_src_processing_app_BaseNoGui.java
patch-arduino-core_src_processing_app_SerialPortList.java
patch-build_build.xml
Code:
cd /usr/ports/devel/arduino18/
make clean all install or make clean reinstall (when you have already installed arduino18 package)
When you finish installing arduino18
Code:
cd /usr/local/arduino/hardware
mkdir -p espressif
cd /usr/local/arduino/hardware/espressif
git clone https://github.com/esp8266/Arduino.git esp8266
cd esp8266
git submodule update --init --recursive
When you finish above steps you can see a directory /usr/local/arduino/hardware/espressif/esp8266 and there are a lot of files in it.
Because the ESP8266 does not support FreeBSD you need to change get.py to download the xtensa tools chain to compile ESP8266 project.
This step is downloading xtensa tools chain for linux64 , so you have to put
linux_load="YES"
in your /boot/loader.conf to enable linux ELF file supportModify tools/get.py
add a line in get.py in 104 lines
Code:
100
101 def identify_platform():
102 arduino_platform_names = {'Darwin' : {32 : 'i386-apple-darwin', 64 : 'x86_64-apple-darwin'},
103 'Linux' : {32 : 'i686-pc-linux-gnu', 64 : 'x86_64-pc-linux-gnu'},
104 'FreeBSD' : {32 : 'i686-pc-linux-gnu', 64 : 'x86_64-pc-linux-gnu'},
105 'LinuxARM': {32 : 'arm-linux-gnueabihf', 64 : 'aarch64-linux-gnu'},
106 'Windows' : {32 : 'i686-mingw32', 64 : 'x86_64-mingw32'}}
set permission for esp8266 directory
Code:
chmod -R 755 /usr/local/arduino/hardware/espressif/esp8266
Run get.py to download the xtensa tools chain
Code:
cd /usr/local/arduino/hardware/espressif/esp8266/tools
python get.py
Install esptools
Code:
cd /usr/local/arduino/hardware/espressif/esp8266/tools
rm -r esptool
git clone https://github.com/espressif/esptool.git esptool
When you finish above steps you will see a directory in your /usr/local/arduino/hardware/espressif/esp8266/tools/xtensa-lx106-elf there are some directory in it ( bin , lib , include etc...).
Now we must patch arduino-builder to compile esp8266 project properly . the arduino 1.8.5 use arduino-builder to build arduino project ,there is a bug ,so you have to fix it with the patch
Compile arduino-builder from ports before do it you need create a patch file in /usr/ports/devel/arduino-builder/files, the filename is patch-src_arduino_cc_builder_utils_utils.go.
Code:
--- src/arduino.cc/builder/utils/utils.go.orig 2021-01-13 22:48:24.097459000 +0800
+++ src/arduino.cc/builder/utils/utils.go 2021-01-13 22:49:18.264758000 +0800
@@ -404,7 +404,7 @@ func NULLFile() string {
if runtime.GOOS == "windows" {
return "nul"
}
- return "/dev/null"
+ return "/tmp/null"
}
func MD5Sum(data []byte) string {
Compile arduino-builder
Code:
cd /usr/ports/devel/arduino-builder
make clean install
For use serial port to download program to esp board , you need add serial port driver into kernel
put these into /boot/loader.conf
Code:
uftdi_load="YES"
uchcom_load="YES"
uslcom_load="YES"
uarduno_load="YES"
Install python serial library
Code:
pkg install py27-pyserial
pkg install py37-pyserial
Make a python3 soft link in /usr/local/arduino/hardware/espressif/esp8266/tools/python3
Code:
cd /usr/local/arduino/hardware/espressif/esp8266/tools
mkdir -p python3
cd python3
ln -s /usr/local/bin/python3.6 python3
Congratulation installation is done!
Now you can compile esp8266 example in arduino
#Note
1. There are some Arduino libraries which conflict with the esp8266 library. You have to move /usr/local/arduino/libraries/Wifi and SD modules to /usr/local/arduino/hardware/arduino/avr/libraries
2.esptools download link https://github.com/espressif/esptool
3.all steps need superuser to do that or use sudo