• Stars
    star
    235
  • Rank 171,079 (Top 4 %)
  • Language
    C
  • License
    MIT License
  • Created about 8 years ago
  • Updated over 1 year ago

Reviews

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

Repository Details

Trying to make ESP8266 projects without a big SDK.

nosdk8266

First of all, I want to make it clear that even though this project is a fork of nosdk8266, my goal is not to make small images, my goal is to get the maximum speed out of the ESP8266.

There is an awesome little $2 processor called an "ESP8266." It's the definitive chip that is bringing the internet of things to life. Ever wonder what the ESP8266 can do without wifi? Well, this project is it! No longer shackled by an SDK that takes up 200 kB of flash, and tons of RAM, you're free to experiment and do so quickly. Little did we realize how limited the clocks were and just how fast this chip can be once unleashed.

This is a working ESP8266/ESP8285 minimial, non-SDK application. It can optionally use the ROM functions to deal with I/O, interrupts, printf'ing, etc.

If you don't need to access FLASH at all after booting, that frees up some of those GPIOs attached to the flash chip, provided you disable its CS line.

Desired Frequency I2S Size (in bytes) Size, without I2S bus Remarks Peripheral Bus Clock Voids Warranty
52 MHz Unavailable 131+0 No PLL, No overclocking, Default behavior 52 MHz N
80 MHz 356+24 188+0 PLL, Normal speed. 80 MHz N
115 MHz 356+24 188+0 Overclock peripheral bus. (Voids warranty, may not work) 115.5 MHz Y
160 MHz 372+24 204+0 PLL, Normal "overclock" mode 80 MHz ?
173 MHz 356+24 188+0 Needs >.2s reset to boot. 173 MHz Y
189 MHz 356+24 188+0 Frequently will not boot. ~189 MHz YES
231 MHz 372+24 204+0 Overclock peripheral bus. (Voids warranty, may not work) 115.5 MHz Y
320 MHz 372+24 204+0 Needs >.2s reset to boot. 80 MHz Y
346 MHz 372+24 204+0 Needs >.2s reset to boot. 173 MHz Y

Interestingly, you might notice that the way this works is with a 1040 MHz high speed PLL clock and divides from that. When the clock rate is very high, i.e. 189/378 MHz, the PLL may or may not lock if the processor boots at all. I found that my clock was wandering around when operating up there.

PLL Valid Values

This table represents each possible value for the function rom_i2c_writeReg (103, 4, 1, 0xVAL), (you need replace "VAL" with the desired register, for example if in "VAL" you put 0xF9, you should expect the PLL running at 52 MHz) "ERR" means that the ESP8266 won't boot All frequencies are in MHz.

0 1 2 3 4 5 6 7 8 9 A B C D E F
0 45 45 45 45 45 45 45 46 45 46 45 46 45 46 46 45
1 46 46 46 46 45 45 45 46 45 46 46 46 46 45 46 45
2 46 46 46 45 45 45 45 46 45 45 45 46 45 46 45 46
3 46 46 46 45 46 44 46 45 46 46 45 46 45 42 41 39
4 92 92 92 92 92 92 92 92 92 92 92 92 92 92 92 92
5 92 92 92 92 92 92 92 92 92 92 92 92 92 92 92 92
6 46 92 92 92 92 92 92 91 90 92 92 93 91 86 82 78
7 92 89 84 76 73 68 64 59 57 50 51 48 46 43 42 39
8 45 184 183 183 183 184 184 183 184 183 183 184 183 183 183 184
9 45 184 183 184 183 183 183 183 183 184 184 184 184 184 184 184
A 46 178 170 155 147 136 129 120 114 106 102 95 91 86 83 78
B 46 89 85 78 74 68 65 60 58 54 51 48 46 43 42 40
C 46 ERR ERR ERR ERR ERR ERR ERR ERR ERR ERR ERR ERR ERR ERR ERR
D 46 ERR ERR ERR ERR ERR ERR ERR ERR ERR ERR ERR ERR ERR ERR ERR
E 45 176 167 153 145 134 127 118 112 105 100 94 90 85 81 77
F 48 88 84 77 73 67 64 59 56 52 50 47 45 42 41 38

Benchmark

To perform this benchmark I used this function, basically what I wanted to measure was the time that the ESP8266 took to define what numbers if the numbers from 0 to 100000 are prime.

I use this function on a for loop:

int is_prime(unsigned int n) {
   	if (n <= 1) {
   		return 0; // zero and one are not prime
   	}
   	unsigned int i = 0;
   	for (i = 2; i * i <= n; i++) {
       	if (n % i == 0) {
       		return 0;
       	}
    }
    return 1;
} 

(ofc all the other code was commented and we was just running this function)

The result of calculate 100k prime numbers was:

Frequency Required Time
52 MHz 5055 ms
80 MHz 3281 ms
115 MHz 2298 ms
160 MHz 1634 ms
173 MHz 1540 ms
189 MHz 1400 ms
231 MHz 1170 ms
320 MHz 841 ms
346 MHz 750 ms

Prerequisites and Building

You'll need the xtensa compiler and a copy of esptool.py.

See https://github.com/espressif/esptool/releases/ for the last release of esptool.py and https://docs.espressif.com/projects/esp8266-rtos-sdk/en/latest/get-started/linux-setup.html for xtensa-lx106 compiler (Remember that you just need the compiler, so just download and uncompress the compressed file depending on your system and edit the makefile)

I strongly recommend using a Linux system. Follow the information on Espressif docs site for more details and lists of Linux package prerequisites.

Altering the Makefile

The makefile has some defaults, however, you will likely need to modify the ESP_OPEN_SDK parameter to compile on your system, so they point to your esp open sdk.

ESPTOOL:=/.../esptool.py
GCC_FOLDER:=/.../xtensa-lx106-elf

Once done, save your Makefile and type:

make clean all burn

Cleaning, building and burning should only take about two seconds. Yes, that means you can comfortably run through about 10 development cycles per minute. Let's call this your DCPM rate. Remember kids, always find ways of maximizing your DCPM rate.

Additional Remarks

All PLL settings are hard-coded for a 26 MHz external crystal. This is probaly okay because almost everyone uses this. However, it does mean you cannot use this project with any other crystals that are compatible with the ESP (i.e. 40 MHz crystals).

Credits

A large portion of figuring out what's what was done by @pvvx, over at his esp8266web repository. Additionally, some of the header files are still licensed Espressif. So, don't let the MIT license on the overarching project confuse you.

Tips I Learned

  1. GCC Xtensa will create smaller code if you have volatile pointers to arrays, rather than setting absolute memory addresses. Indirect accessing isn't slower, and it makes smaller code. Additionally, if you just store the pointer to the base of an array, like the IO MUX register, and you index into it multiple times, it doesn't need to take up prescious space holding that.

  2. Avoid using macro's to do pointer arithmatic. Also, try to find out where you are or'ing masks, etc. where you don't need to be.

  3. Always make sure to have your function declarations available when used. Failure to do this gimps -flto's ability to inline functions.

  4. Compile with -g to make the assembly listing much easier to read.

I'm sure there's more...

Todo

  • Figure out how to get rid of the prologue to main(). Even though it's marked as noreturn, GCC is doing stuff with the stack, etc.

  • Add Sleep feature.

  • Figure out why power consumption is higher than I would expect.

More Repositories

1

rawdrawandroid

Build android apps without any java, entirely in C and Make
C
3,408
star
2

espusb

Software-only ESP8266 USB Device
C
1,452
star
3

mini-rv32ima

A tiny C header-only risc-v emulator.
C
1,410
star
4

channel3

ESP8266 Analog Broadcast Television Interface
C
1,277
star
5

ch32v003fun

An open source software development stack for the CH32V003, a 10Β’ 48 MHz RISC-V Microcontroller
C
674
star
6

colorchord

Chromatic Sound to Light Conversion System
C
663
star
7

noeuclid

Non-euclidean GPU Raytraced Game
C
647
star
8

esp8266ws2812i2s

ESP8266-based I2S-output WS2812(B) Driver
C
536
star
9

avrcraft

Minecraft server optimized for 8-bit devices.
C
435
star
10

rv003usb

CH32V003 RISC-V Pure Software USB Controller
C
328
star
11

ws2812esp8266

DEPRECATED. Please use esp8266ws2812i2s. No really, stop forking and starring this.
C
298
star
12

esp82xx

Useful ESP8266 C Environment
C
289
star
13

espthernet

ESP8266 10-Base-T Ethernet Driver
C
246
star
14

esp8266rawpackets

Raw Packet Experiments on the ESP8266
JavaScript
148
star
15

fx3fun

Treat your Cypress FX3 a little like a logic analyzer or software defined bus.
C
147
star
16

epaper_projects

C
145
star
17

voxeltastic

View 3D Volume with Translucency in WebGL
JavaScript
143
star
18

shadertrixx

CNLohr's repo for his Unity assets and other shader notes.
ShaderLab
137
star
19

cnovr

CNLohr's OpenVR Misadventures
C
128
star
20

ethertiny

A firmware-only half-duplex 10Base-T implementation for AVRs
PostScript
121
star
21

cnixxi

My experiment with nixie tubes.
C
112
star
22

wiflier

ESP8266-based Quadcopter Brain
KiCad Layout
93
star
23

embeddedDOOM

"emdoom" - a port of DOOM targeted for memory-strapped systems.
C
90
star
24

espwebc3

An in-browser integrated development platform for the ESP32-C3
HTML
84
star
25

esplocalizer

ESP8266 with IMU, Barometer and Battery
C++
83
star
26

esp8266oddclock

What happens when you rip the ESP8266's stable clock source out from under it's feet?
C
81
star
27

esptracker

Lighthouse-based tracker using the TS4231
C
60
star
28

rawdrawandroidexample

Example app using rawdrawandroid as a submodule.
C
59
star
29

wifirxpower

Linux-based WiFi RX Power Grapher
C
59
star
30

pylotron

Embedded VNC-based FPS.
C
58
star
31

esp32s2-cookbook

Low-level tests with the ESP32-S2
C
48
star
32

androidusbtest

Access external devices from Android apps directly in C.
C
46
star
33

superlongexposure

FFMPEG-based tool for non-linear compositing video into long exposures.
C
41
star
34

tplink-raw-wifi

Test using tp-links to do raw wifi.
C
41
star
35

pi_tpi

Using a Raspberry Pi to program an ATTiny10 9 5 or 4
C
39
star
36

what_im_up_to

Just my dumping ground for ideas.
37
star
37

tsopenxr

Single-file header for simple OpenXR Framework use with C
C
36
star
38

t85loudspeaker

ATTiny85 Sound Output
C
35
star
39

avr_vhf

Channel 3 VHF Broadcasting with an AVR
C++
34
star
40

esp8266_dmx_explorer

C
32
star
41

esp8266duplexi2s

Generic duplex communication on the I2S bus in the ESP8266.
C
31
star
42

lamenet

A way of making a really awful network connection.
C
31
star
43

dumbcraft8266

My first stab at a Minecraft-enabled firmware for the ESP8266
C
30
star
44

swadges2017

MAGFest Swag Badges 2017 Firmware
C
29
star
45

cnballpit-vrc

C#
28
star
46

cnhardware

C
28
star
47

esp8266_link_test

Test link between an ESP8266 and a base station or another ESP8266 easily.
KiCad Layout
26
star
48

brokeredupdateandsync

CN's VRC Tools and Prefabs
C#
26
star
49

tinycc-win64-installer

A quick way to use tinyCC on Windows.
NSIS
25
star
50

wificompositer

Various tools I used to collect and composite data from a wifi device into an image.
C
24
star
51

miniosc

Single-file-header OSC library for C (includes platform-independent sockets)
C
21
star
52

esp32-cnlohr-demo

My always-incomplete ESP32 fun zone
C
20
star
53

spreadgine

An OpenGL ES engine with WebGL Output.
C
19
star
54

slapsplat

GLSL
19
star
55

oledscope

Playing around with a 128x128 OLED module
C
19
star
56

cnlohr_social_media_tools

Various social media interface tools.
C
18
star
57

assembly-notes

My repo for a guide to and notes on assembly lagnuage, inling, etc.
18
star
58

usb2812

ATMega32u2 USB driver for WS2812 LEDs.
C
18
star
59

x11framegrab

Small static program for taking screenshots of x11 screens and saving/streaming as a variety of formats.
C
18
star
60

esp8266lighthouse

DO NOT USE THIS PROJECT - WILL BE SUPERCEDED
C
17
star
61

wasm_integrated

An example of how you can fully integrate wasm into a webpage. No need for fetching or any of that jazz.
HTML
17
star
62

swadge-vrchat-bridge

C
16
star
63

magfestbadges

The codebase, schematics, etc. of the MAGFest Badges.
C
16
star
64

cntools

Incomplete-ish C "libraries"
C
16
star
65

wi07clight

Using the wi07c's ESP8266 to control a desk light.
C
16
star
66

avrjslinux

JSLinux Running on an AVR with I/O Port Remapping
JavaScript
14
star
67

tinyispterm

An SPI terminal for USB Tiny ISP compatible AVR prorgammers.
Python
14
star
68

esp32-c3-cntest

C
13
star
69

h264fun

Fun with h264 (mostly encoding)
C
13
star
70

tensigral_lamp

My PCB Tensegrity structure lamp.
C
12
star
71

addressable_leds

Charles's list of addressable LEDs
12
star
72

kelvindmmwifi

Adding some sweet wifis to a kelvin multimeter.
KiCad Layout
11
star
73

attiny85_tb

ATTiny85 Test Bench Tool with Screw Terminals
Eagle
10
star
74

voxeltastic-vrc

Voxel Tracing Shader for VRChat
ShaderLab
10
star
75

esp32s2_dmx512_usb

C
10
star
76

rawdrawwasm

My stab at rawdraw on wasm.
HTML
10
star
77

swadgeguide

My guide for making swadges.
HTML
9
star
78

terriblewordsearch

A C tool for making terrible word searches.
C
9
star
79

cndvr

Assembly
9
star
80

flexcrt

A header for CRTs to allow for scattered writes.
HLSL
8
star
81

swadge2019

the repo for the 2019 swadge
C
8
star
82

espbadapple

Bad Apple in 62kB or bust.
C
8
star
83

donut

MAGFest /is/ a donut.
C
8
star
84

minimal_stm32f407

STM32F407 Minimal self-contained Makefile-based build environment (Plus printf!)
C
8
star
85

esp8266irxmit

ESP8266 IR Transmistter
C
7
star
86

minimal_stm32f303

STM32F303 Minimal self-contained Makefile-based build environment (Plus printf!)
C
7
star
87

netlink_without_libnl

Testing using the kernel's netlink, more specifically nl80211 without libnl or genl
C
7
star
88

wxrchat

Distributed WebXR Chat Application
C
6
star
89

esp32_ethernet_test

My Ethernet on the ESP32 Test (incomplete!)
C
6
star
90

tinyisp-micro

My USBTinyISP (with an ATTiny44)
KiCad Layout
6
star
91

esp_network_rgb

JavaScript
6
star
92

charlesvideotools

Linux Video Creation Notes and Tools
C
5
star
93

esp_nonos_sdk

Patchwork of various esp_nonos_sdk subsystems.
C
5
star
94

in99

Gain a superficial of topics in 99 seconds.
5
star
95

shader_perf_grass_comparison

Fake test for checking perf of different shader types.
ShaderLab
5
star
96

stm32f042_fun

My fun repo for the STM32f042
C
4
star
97

bridgesim

Project abandoned. Library code probably has problems.
C
4
star
98

avr_ledprojector

Using an AVR with an mlx90614 to project temperatures!
KiCad Layout
4
star
99

esp8266_32x32panel

An attempt at driving 32x32 panels with an ESP8266.
KiCad Layout
4
star
100

sk6812rgbyspectraldata

Just an email I got from Andrew Sowa
4
star