Is there a esp8266 simulator for testing code written on Arduino IDE?
Asked Answered
F

3

13

Is there a good esp8266 simulator software that can be used to automate testing? Is it possible to get code written on Arduino IDE to run on these simulators?

Foxy answered 6/12, 2019 at 14:6 Comment(1)
I have made enough research before posting the question. I was not able to find any clear answer for this on the internet. None of my colleagues had a good answer for this.Foxy
G
2

As of Jan 2023...

The docs for the RIOT OS (an IoT OS) explain how to compile and use an ESP8266 version of QEMU for Xtensa. The docs contain the compile instructions:

cd /my/source/dir
git clone https://github.com/gschorcht/qemu-xtensa
cd qemu-xtensa/
git checkout xtensa-esp8266
export QEMU=/path/to/esp/qemu
./configure --prefix=$QEMU --target-list=xtensa-softmmu --disable-werror
make
make install

Actually, the gschorcht/qemu-xtensa repo (last updated 2018) is a fork of the original OSLL/qemu-xtensa project, so you could use the original repo:

cd /my/source/dir
git clone https://github.com/OSLL/qemu-xtensa
cd qemu-xtensa/
git checkout xtensa-esp8266
export QEMU=/path/to/esp/qemu
./configure --prefix=$QEMU --target-list=xtensa-softmmu --disable-werror
make
make install

Unfortunately, that branch hasn't been updated since 2019 so it may not compile on very recent OS versions. For instance, I got an error: expected unqualified-id error while trying to compile on macOS 12.14. So, someone probably needs to fix those compile errors.

Glycerite answered 23/1, 2023 at 11:44 Comment(3)
If somebody can try this on linux please let us know. If this works give us details of the OS and version of OS where it worked.Foxy
I succeeded in building the gschorcht clone on Linux Mint 20.2, kernel version 5.4.0-137 using the following configure command: configure --disable-werror --target-list=xtensa-softmmu --python=python2.7 --prefix=$QEMU.Ruche
The error: expected unqualified-id is a result of the case-insensitive file system that Mac OS uses by default. During compilation the version header file from the standard library should be included, but the VERSION file from the repo is in the way -.-. You can find a fix in a separate answer below.Coincide
E
8

I think that you could simulate esp8266 using the xtensa-esp8266 branch of OSLL/qemu-xtensa which you have to compile yourself.

Compiled binary can be called with the command:

qemu-system-xtensa -machine esp8266 -nographic -kernel <your-project>/sketch/app.out -S -s

Ellipsoid answered 18/12, 2019 at 19:58 Comment(4)
I am not sure how to do this. If someone in the community can check this out we can probably mark this as an answer for anybody who comes here with the same query.Foxy
@Foxy I tried to compile this but got an error, so it may need someone to fix the code so that it compiles on more recent OS versions. You could always try compiling yourself to see if it works on your OS. Good luck.Glycerite
@NickBolton the very reason I have not marked this as the answer. Thank you for trying. alfen Can you shed some light on it if you can.Foxy
I might fork the repo and see if I can get it to build, but depends how deep the rabbit hole goes.Glycerite
G
2

As of Jan 2023...

The docs for the RIOT OS (an IoT OS) explain how to compile and use an ESP8266 version of QEMU for Xtensa. The docs contain the compile instructions:

cd /my/source/dir
git clone https://github.com/gschorcht/qemu-xtensa
cd qemu-xtensa/
git checkout xtensa-esp8266
export QEMU=/path/to/esp/qemu
./configure --prefix=$QEMU --target-list=xtensa-softmmu --disable-werror
make
make install

Actually, the gschorcht/qemu-xtensa repo (last updated 2018) is a fork of the original OSLL/qemu-xtensa project, so you could use the original repo:

cd /my/source/dir
git clone https://github.com/OSLL/qemu-xtensa
cd qemu-xtensa/
git checkout xtensa-esp8266
export QEMU=/path/to/esp/qemu
./configure --prefix=$QEMU --target-list=xtensa-softmmu --disable-werror
make
make install

Unfortunately, that branch hasn't been updated since 2019 so it may not compile on very recent OS versions. For instance, I got an error: expected unqualified-id error while trying to compile on macOS 12.14. So, someone probably needs to fix those compile errors.

Glycerite answered 23/1, 2023 at 11:44 Comment(3)
If somebody can try this on linux please let us know. If this works give us details of the OS and version of OS where it worked.Foxy
I succeeded in building the gschorcht clone on Linux Mint 20.2, kernel version 5.4.0-137 using the following configure command: configure --disable-werror --target-list=xtensa-softmmu --python=python2.7 --prefix=$QEMU.Ruche
The error: expected unqualified-id is a result of the case-insensitive file system that Mac OS uses by default. During compilation the version header file from the standard library should be included, but the VERSION file from the repo is in the way -.-. You can find a fix in a separate answer below.Coincide
C
0

For those who like me came here and failed to install QEMU for ESP2866 on MacOS... I found the reason for error: expected unqualified-id and fixed it in my fork of the OSLL/qemu-xtensa repo. Simply follow the steps below:

# IMPORTANT:
# Make sure you have Python2.7 for Mac OS installed, downloadable from here:
# https://www.python.org/downloads/release/python-2718/

git clone http://github.com/weese/qemu-xtensa -b xtensa-esp8266 --depth 1
cd qemu-xtensa
export QEMU=/usr/local/qemu-esp8266

git submodule init dtc

git submodule update dtc
./configure --prefix=$QEMU --target-list=xtensa-softmmu --disable-werror --python=python2.7
make -j 8
sudo make install

Then you should be able to run:

/usr/local/qemu-esp8266/bin/qemu-system-xtensa
Coincide answered 3/1 at 19:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.