Hi all, there is a lot Arduino fans want to use ESP32 on FreeBSD but there is no solution now.
Today I installed ESP32 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 "ESP32 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/esp32 and there are a lot of files in it.
Because the ESP32 does not support FreeBSD you need to change get.py to download the xtensa tools chain to compile ESP32 project.
This step is downloading xtensa tools chain for linux64. If you use xtensa for linux64 you have to put
Modify tools/get.py
Run get.py to download the xtensa tools chain OR you also could use xtensa-esp32-elf package on FreeBSD
When you finish above steps you will see a directory in your /usr/local/arduino/hardware/espressif/esp32/tools/xtensa-esp32-elf/ there are some directory in it ( bin , lib , include etc...).
If you want to use xtensa-esp32-elf to compile esp32 rather than xtensa for linux64, just install devel/xtensa-esp32-elf package.
change this file :/usr/local/arduino/hardware/espressif/esp32/platform.txt
When you finish above steps. Congratulation you are almost done.
Now we must patch arduino-builder to compile esp32 project properly.
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.
This step is the most important, if you do not patch it you can't compile a library in your esp32 arduino project[/B]
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
Reboot you machine , and run arduino , you will see about esp32 board in you board menu, that mean you have installed successfully
Congratulation installation is done!
if you have install both openjdk8 and openjdk11 , you will get some problem to start arduino. or you could use SerialPort monitor you should do this.
edit your /usr/local/arduino/arduino files, add a line into it like below
#Note
1. There are some Arduino libraries which conflict with the esp32 library. You have to move /usr/local/arduino/libraries/Wifi and SD modules to /usr/local/arduino/hardware/arduino/avr/libraries
2. upload is ok , bug program is not running correctly
(1) choose incorrectly partition scheme, choose the first scheme is okay for standard esp32s board
(2) esptools version is too old. Use the latest esptools (esptools is upload tools for esp32, you can find it in /usr/local/arduino/hardware/espressif/esp32/tools)
3.esptools download link https://github.com/espressif/esptool
4.you need make link for python when you use FreeBSD13 , there is no python execution file in it , use "ln -s /usr/local/bin/python3.8 /usr/local/bin/python"
[update]
2021-02-11 fix configuration file incorrect to cause can't compile bug . (esptool.py)
2021-05-29 fix patch file incorrect and patch file in last thread
2021-08-17 fix a issuse when you install both openjdk8 and openjdk11 , you could run arduino properly.
Today I installed ESP32 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:
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/espressif/arduino-esp32.git esp32
cd esp32
git submodule update --init --recursive
When you finish above steps you can see a directory /usr/local/arduino/hardware/espressif/esp32 and there are a lot of files in it.
Because the ESP32 does not support FreeBSD you need to change get.py to download the xtensa tools chain to compile ESP32 project.
This step is downloading xtensa tools chain for linux64. If you use xtensa for linux64 you have to put
linux_load="YES"
in your /boot/loader.conf.Modify tools/get.py
Code:
add a line in get.py in 149 lines
def identify_platform():
147 arduino_platform_names = {'Darwin' : {32 : 'i386-apple-darwin', 64 : 'x86_64-apple-darwin'},
148 'Linux' : {32 : 'i686-pc-linux-gnu', 64 : 'x86_64-pc-linux-gnu'},
149 'FreeBSD' : {32 : 'i686-pc-linux-gnu', 64 : 'x86_64-pc-linux-gnu'},
150 'LinuxARM': {32 : 'arm-linux-gnueabihf', 64 : 'aarch64-linux-gnu'},
151 'Windows' : {32 : 'i686-mingw32', 64 : 'i686-mingw32'}}
Run get.py to download the xtensa tools chain OR you also could use xtensa-esp32-elf package on FreeBSD
Code:
cd /usr/local/arduino/hardware/espressif/esp32/tools
python get.py
When you finish above steps you will see a directory in your /usr/local/arduino/hardware/espressif/esp32/tools/xtensa-esp32-elf/ there are some directory in it ( bin , lib , include etc...).
If you want to use xtensa-esp32-elf to compile esp32 rather than xtensa for linux64, just install devel/xtensa-esp32-elf package.
Code:
pkg install xtensa-esp32-elf
cd /usr/local/arduino/hardware/espressif/esp32/tools
ln -s /usr/local/xtensa-esp32-elf .
change this file :/usr/local/arduino/hardware/espressif/esp32/platform.txt
Code:
change this line:
tools.esptool_py.cmd=esptool
to like this:
tools.esptool_py.cmd=esptool.py
When you finish above steps. Congratulation you are almost done.
Now we must patch arduino-builder to compile esp32 project properly.
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.
This step is the most important, if you do not patch it you can't compile a library in your esp32 arduino project[/B]
Code:
--- src/arduino.cc/builder/utils/utils.go.orig 2021-05-29 19:46:43.035414000 +0800
+++ src/arduino.cc/builder/utils/utils.go 2021-05-29 19:46:53.857019000 +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 py38-pyserial
Reboot you machine , and run arduino , you will see about esp32 board in you board menu, that mean you have installed successfully
Congratulation installation is done!
if you have install both openjdk8 and openjdk11 , you will get some problem to start arduino. or you could use SerialPort monitor you should do this.
edit your /usr/local/arduino/arduino files, add a line into it like below
Code:
#!/usr/bin/env bash
export JAVA_HOME=/usr/local/openjdk8 #### add this line
#Note
1. There are some Arduino libraries which conflict with the esp32 library. You have to move /usr/local/arduino/libraries/Wifi and SD modules to /usr/local/arduino/hardware/arduino/avr/libraries
2. upload is ok , bug program is not running correctly
(1) choose incorrectly partition scheme, choose the first scheme is okay for standard esp32s board
(2) esptools version is too old. Use the latest esptools (esptools is upload tools for esp32, you can find it in /usr/local/arduino/hardware/espressif/esp32/tools)
3.esptools download link https://github.com/espressif/esptool
4.you need make link for python when you use FreeBSD13 , there is no python execution file in it , use "ln -s /usr/local/bin/python3.8 /usr/local/bin/python"
[update]
2021-02-11 fix configuration file incorrect to cause can't compile bug . (esptool.py)
2021-05-29 fix patch file incorrect and patch file in last thread
2021-08-17 fix a issuse when you install both openjdk8 and openjdk11 , you could run arduino properly.
Last edited: