• Stars
    star
    112
  • Rank 312,240 (Top 7 %)
  • Language
    C
  • Created almost 5 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

ESP32 simulator for Linux

This repository contains ESP32 simulator for linux.

How does it work?

ESP-IDF contains small amount of hardware specific code, FreeRTOS and few multi-platform libraries.

This project uses FreeRTOS port for POSIX, LWIP for TCP/IP layer and mbedtls for cryptography functions.

In addition, several useful APIs from esp-idf are implemented eg. logging.

With this project you can write a program, which will be runnable and testable on Linux.

Running

Network

This project requires tun kernel module and configured tap0 interface to work. To configure tap0 run following commands:

sudo ip tuntap add dev tap0 mode tap user `whoami`
sudo ip link set tap0 up
sudo ip addr add 10.0.0.1/24 dev tap0
export PRECONFIGURED_TAPIF=tap0

Simulator can be connected to internet using masquerade. First we need to enable forwarding.

sudo echo 1 > /proc/sys/net/ipv4/ip_forward

Simple nftables forwarding rules:

#!/sbin/nft -f

flush ruleset


table inet filter {
	chain input {
		type filter hook input priority 0; policy drop;
		ct state invalid counter drop
		ct state {established, related} counter accept
		iif lo accept
		iif != lo ip daddr 127.0.0.1/8 counter drop
		iif != lo ip6 daddr ::1/128 counter drop
		ip protocol icmp counter accept
		ip6 nexthdr icmpv6 counter accept
		iifname tap0 accept
	}

	chain forward {
		type filter hook forward priority 0; policy accept;
	}

	chain output {
		type filter hook output priority 0; policy accept;
	}
}


table ip nat {
	chain input {
		type nat hook input priority 0; policy accept;
		ip protocol icmp accept
	}

	chain prerouting {
		type nat hook prerouting priority 0; policy accept;
	}

	chain postrouting {
		type nat hook postrouting priority 100; policy accept;
		ip daddr != 10.0.0.0/24 ip saddr 10.0.0.0/24 masquerade;
	}

	chain output {
		type nat hook output priority 0; policy accept;
	}
}

Using ubuntu

sudo apt install -y git wget flex bison gperf python3 python3-pip python3-setuptools python3-serial python3-click python3-cryptography python3-future python3-pyparsing python3-pyelftools cmake ninja-build ccache libffi-dev libssl-dev libusb-1.0-0
mkdir esp
cd esp
git clone -b release/v4.1 --recursive https://github.com/espressif/esp-idf.git
./esp-idf/install.sh
. ./esp-idf/export.sh
git clone https://github.com/mireq/esp32-simulator
cd simulator/example
idf.py build
./build/example

Inside docker

docker build -t esp32-simulator .
docker run --cap-add=NET_ADMIN --device /dev/net/tun:/dev/net/tun --name esp32-simulator -v `pwd`:/root/simulator -d esp32-simulator

docker exec -i -t esp32-simulator bash
cd ~/simulator/example
idf.build
./build/example

More Repositories

1

rEFInd-Catalina

Catalina theme ported from clover to rEFInd
Python
93
star
2

esp32-st7789-demo

ESP32 st7789 demo
C
66
star
3

luasnip-snippets

Vim-snippets (snipMate & UltiSnip Snippets) converted to native luasnip snippets
Lua
56
star
4

st7789-stm32-driver

ST7789 display driver for STM32F103C8 (blue pill)
C
42
star
5

dot-vim

My personal .vim directory
Vim Script
18
star
6

a13-olinuxino-autobuild

Scripts for automatic building buildroot-a13-olinuxino with ct-ng
Makefile
17
star
7

minetest-mapper-cpp

Port of minetest map generator.
C++
15
star
8

Shadertoy-renderer

Python
13
star
9

Qt-Quick-Keyboard

Simple virtual keyboard written in Qt Quick
C++
11
star
10

awesome-udisks2-mount

Automounter for awesome wm
Lua
8
star
11

esp32-internet-radio

C
7
star
12

large_file

Large file support for neovim
Lua
7
star
13

WeatherQML

Port of freebox-elixir weather to Qt/QML
QML
6
star
14

MiFitDataExport

Export gpx from mi fit app
Python
5
star
15

buildroot-a20-olinuxino

Makefile
5
star
16

a20-olinuxino-micro-autobuild

Makefile
4
star
17

Himawari-to-video

Make video from himawari satellite images
Python
4
star
18

audio-spectrogram

Audio spectrogram generator
Python
4
star
19

sega-generator

Fork of generator - sega genesis emulator
C
4
star
20

KOReader-kindle-start-x-app

Start X11 application using KOReader on Amazon Kindle
Lua
4
star
21

facedetect

Face detector
C++
4
star
22

pip-compile-universal

Compile requirements.in using pip-tools for multiple python versions to single requirements.txt file
Python
4
star
23

Git-watcher

gitwatcher
Python
3
star
24

django-geoposition-field

Geoposition field with OL widget
Python
3
star
25

QtXvWidget

Qt widget for X-Video Extension
C++
3
star
26

pyboincgui

Python Boinc GUI
Python
3
star
27

django-autoslugfield

Automatic slug field for django
Python
3
star
28

recordmydesktop-x264

Recordmydesktop with x264 support
C
3
star
29

reportlab-qr-code

QR code plugin for reportlab RML language
Python
3
star
30

android-camera-sensor-calibrate

Tols to calibrate android camera sensor
Python
2
star
31

django-pylibmc-threadsafe

Thread safe pylibmc cache backend for django
Python
2
star
32

QBoincGui

Boinc GUI
C++
2
star
33

KOReader-without-framework-support-for-Amazon-Kindle

Lua
2
star
34

django-email-log-backend

Advanced django email logging
Python
2
star
35

awesome-config

My awesome config
Lua
2
star
36

inkscape-export-selection-as-svg

Export selection from inkscape as svg
Python
2
star
37

awesome-wm-config

Lua
2
star
38

Experiment-blender-3d-serial-protocol

C++
2
star
39

Thinkpad-Fancontrol-C--

Script tp-fancontrol ported to C++
C++
2
star
40

django-simple-paginator

Simple paginator for django
Python
2
star
41

simunet

Computer network simulator
C++
2
star
42

libvdpau-sunxi-dump-player

Player for libvdpau-sunxi dump files
C
2
star
43

neovim-config

My neovim config
Lua
2
star
44

KOReader-usbnet-connect-to-calibre

Automatically connect KOReader to Calibre using USBNet on Kindle
Lua
2
star
45

django-attachments

Python
1
star
46

fakturuj

Stupid slovak invoice generator
Python
1
star
47

software-cursor

Software cursor rendering for screen recording
C
1
star
48

django-uwsgi-reloader

Efficient auto reloader for uwsgi
Python
1
star
49

ILI9481-esp32-driver

C
1
star
50

django-rss-reader

RSS reader in Django
Python
1
star
51

GraphLib

PHP Graphing Library
PHP
1
star
52

Mandelbrot

C++
1
star
53

django-sample-data-generator

Sample data generator for python models (with SK word database)
Python
1
star
54

ShakalQML

Shakal Qt UI
C++
1
star
55

kindle-pw2-buildroot-autobuild

Kindle paperwhite 2+ buildroot
Makefile
1
star
56

Shakal

Shakal CMS
PHP
1
star
57

django-assets-manager

Simple assets manager with dependency checking and sprites for django
Python
1
star
58

django-ajax-utils

Django ajax utils
JavaScript
1
star
59

when-i-work

Simple computer usage monitoring utility
JavaScript
1
star
60

NemocnicnySystem

Nemocničný systém (zadanie na UDS na ZU)
C++
1
star
61

Thinkpad-T420-kernel-config

1
star
62

scan2ocrpdf

Scan to PDF with OCR
Python
1
star
63

wisdomtech-blog

Wisdomtech blog
Python
1
star
64

django-ga4-serverside

Server side GA4 tracking for django without extra dependencies
Python
1
star