ESP8266 Sans RF

mrburnette
Tue Apr 19, 2016 2:51 pm
20160507: Title changed after someone noticed I had mistyped as ESP8622 :oops:

I became obsessed last week with the thought that the very cheap ESP8622 could be useful if it did not have RF consuming so much power.

Crazy? Probably: but playing around with the idea and finding a very easy mechanism for disabling the RF section to drop the power consumption, I am now finding that a non-RF ESP8622-12E module in the NodeMCU form factor is only taking 20mA at 80MHz and under 40mA (30’ish) at 160MHz. That is pretty remarkable for the cost.

The specific unit I am using in my test is this one – excepting that I paid $3.11 with free shipping.

So what kind of performance does $3 and pennies provide? I am working on more examples, but I took an STM32duino example I ported from the 8-bit AVR world which was written by the renown Nick Gammon and I ported the STM32 port to ESP8266. Adding a single unsigned long var to time a single pass of the program, this is the results on the STM32duino Maple Mini with bootloader 2.0 and the power consumption was 40+mA
Prime Number Generator
Number of primes in prime table = 53
Last prime in table = 251
Calculating primes through 63001

Total microseconds = 199887 uS


martinayotte
Tue Apr 19, 2016 3:28 pm
That is strange !
With the Dhrystone benchmarks done last year, the ESP at 80MHz was about 10% slower than STM32F103 :
viewtopic.php?f=3&t=76&start=30#p5435

WereCatf
Tue Apr 19, 2016 3:29 pm
Why do you have a call to system_update_cpu_freq(FREQUENCY);

Slammer
Tue Apr 19, 2016 3:36 pm
ESP8266 is a special piece of hardware as CPU.
The core has 80KB DRAM (Data RAM) and 35KB IRAM (Instruction RAM).The DRAM and IRAM segments are separated (Harvard architecture).
Programs are stored in the flash memory and due to the fast interface (SPI-quad) instructions can be fetched and executed “in place”, in other words, without copying them to ram first. In some occasions you cannot execute your code from SPI flash memory directly, mostly because it needs to be maximum fast or because it handles the flash memory itself (e.g. writing to it). In that case, you can have some code, 32k in total, have copied from the flash at startup, to the IRAM. This code will run from IRAM, not from FLASH.
Unfortunately the IRAM space is mostly occupied by SDK code and not a lot left, from the 32k for your own application, about 2k, maybe 3k.
Even with the fast SPI the execution in flash is slow compared with normal flash (on cpu bus) of our stm32.
There are some compiler directives to force generated code to execute in IRAM but you have to respect the limits of the memory.
Something like this is used when we want something in IRAM

#define IRAM0 __attribute__((section(".iram0.text")))
void IRAM0 myfunc(void)
{
}


mrburnette
Tue Apr 19, 2016 3:42 pm
WereCatf wrote:Why do you have a call to system_update_cpu_freq(FREQUENCY);

mrburnette
Tue Apr 19, 2016 3:45 pm
Slammer wrote:ESP8266 is a special piece of hardware as CPU.
The core has 80KB DRAM (Data RAM) and 35KB IRAM (Instruction RAM).The DRAM and IRAM segments are separated (Harvard architecture).
Programs are stored in the flash memory and due to the fast interface (SPI-quad) instructions can be fetched and executed “in place”, in other words, without copying them to ram first. In some occasions you cannot execute your code from SPI flash memory directly, mostly because it needs to be maximum fast or because it handles the flash memory itself (e.g. writing to it). In that case, you can have some code, 32k in total, have copied from the flash at startup, to the IRAM. This code will run from IRAM, not from FLASH.<…>

WereCatf
Tue Apr 19, 2016 3:56 pm
This may sound stupid, but what does delay(0) exactly do? I would imagine passing a zero to a delay()-function would do absolutely nothing, but removing that line speeds things up considerably, so it is obviously doing something.

mrburnette
Tue Apr 19, 2016 3:59 pm
Slammer wrote:<…>
Something like this is used when we want something in IRAM

#define IRAM0 __attribute__((section(".iram0.text")))
void IRAM0 myfunc(void)
{
}


mrburnette
Tue Apr 19, 2016 4:01 pm
WereCatf wrote:…but what does delay(0) exactly do?<…>

WereCatf
Tue Apr 19, 2016 4:04 pm
mrburnette wrote:With the ESP8266, delay(0) is a synonym for yield();

mrburnette
Tue Apr 19, 2016 4:08 pm
WereCatf wrote:mrburnette wrote:With the ESP8266, delay(0) is a synonym for yield();

martinayotte
Tue Apr 19, 2016 4:14 pm
mrburnette wrote:Slammer wrote:<…>
Something like this is used when we want something in IRAM

#define IRAM0 __attribute__((section(".iram0.text")))
void IRAM0 myfunc(void)
{
}


WereCatf
Tue Apr 19, 2016 4:16 pm
mrburnette wrote:Yep. I was profiling some of this last week for my own curiosity. But, with Arduino, it is not an option if the loop() does not repeat every 30-50mS.

So benchmarks must include this rather nasty task switching time.


WereCatf
Tue Apr 19, 2016 4:17 pm
martinayotte wrote:It is the code from the loop() that should be placed in there, and the loop() will call myfunc() .

mrburnette
Tue Apr 19, 2016 4:22 pm
martinayotte wrote:mrburnette wrote:Slammer wrote:<…>
Something like this is used when we want something in IRAM

#define IRAM0 __attribute__((section(".iram0.text")))
void IRAM0 myfunc(void)
{
}


Slammer
Tue Apr 19, 2016 4:51 pm
Watch the program and data size, before/after the IRAM0 or ICACHE_RAM_ATTR if the function is really located in iram0
Maybe the linker script does not accept your function, as there are some limitations…. anyway I am a newbie with Esp8266, I am just blinking a led…. :roll:

mrburnette
Tue Apr 19, 2016 5:24 pm
WereCatf wrote:mrburnette wrote:
<…>
Hm, well, you’re not comparing CPU-speeds then,<…>

RogerClark
Tue Apr 19, 2016 9:41 pm
Lol…

I think the quality of the EPS8266 posting here, are far better than on esp8266.com ;-)

I think virtually all of us use the ESP8266 as well as the STM32.

I designed a PCB that has a Maple mini, ESP-12 as well as a ILI9341 and an nRF905, which I use for various projects ( though it was originally designed just as a display)

If the ESP8266 had better ADC, and USB i could have probably removed the STM32 from my design entirely.

But there are still some things like real time data collection that the ESP8266 is not ideally suited for.


martinayotte
Wed Apr 20, 2016 7:41 pm
Hi Ray,

I figured it out ! The macro should not be :

#define IRAM0 __attribute__((section(".iram0.text")))


mrburnette
Wed Apr 20, 2016 8:09 pm
martinayotte wrote:
<…>
#define IRAM0 __attribute__((section(".iram.text")))

mrburnette
Wed Apr 20, 2016 10:44 pm
I do believe that the 1st board I received a couple of weeks back is defective. It will program, it will run, but only if I use board type “generic”. The new board received yesterday programs perfectly every time as a “NodeMCU 1.0”.

More here: viewtopic.php?f=45&t=996&start=40#p12370

Summary…

The NodeMCU board is a good buy at $3.11 USD (a check today shows it at $3.22. At 160MHz with the RF section disabled, the board takes less than 40mA (that is, my meter shows it greater than 30mA but never 40mA.) OTOH, a Maple Mini is in the 40 – 49mA range (never lower than 40 but never showing 50mA on the display).

But… and this is a BIG BUT… the Maple Mini is significantly faster than the ESP8266 based NodeMCU. The small price difference of $4.00 – $3.22 (both free ship) is not enough in my opinion to select a NodeMCU as a replacement for the STM32F103 unless:

  • More than 20K RAM is required
  • More than 128K of flash is required
  • A flash-based internal filesystem is required, SPIFFS
  • CPU sheer speed is not a critical factor

Maybe a few of our members can add to the list. As a caveat, remember that during 1st power-up, the RF will energize and the power consumption will be a minimum of 0.1A and likely a bit higher as I’m using a USB meter and the display is not instantaneous.

Ray


RogerClark
Wed Apr 20, 2016 11:26 pm
Hi Ray

I hadn’t realized that the ESP8266 @ 80Mhz (or even 160Mhz) would be significantly slower.

I presume this is because of the instruction fetch time from the SPI Flash.


mrburnette
Thu Apr 21, 2016 12:38 am
RogerClark wrote:Hi Ray

I hadn’t realized that the ESP8266 @ 80Mhz (or even 160Mhz) would be significantly slower.

I presume this is because of the instruction fetch time from the SPI Flash.


WereCatf
Thu Apr 21, 2016 1:01 am
mrburnette wrote:I am uncertain as the numbers contradict some previous testing, see Martin’s link earlier in thread. So, it may be a “workload” issue with the prime number algorithm.

mrburnette
Thu Apr 21, 2016 1:49 am
WereCatf wrote:
<…>
Your test is measuring Arduino-implementation speed, not just CPU-speed, because <…>

RogerClark
Thu Apr 21, 2016 3:45 am
I think people would need to compare the speed when doing the actual task that is required.

I’d be surprised if the SPI flash has the same performance as internal flash, for a start it has to come in via single bit, so even if the SPI clock was 80Mhz, it would only come in at 10 Meg bytes per second.

We know from the GD32 that instruction load time makes a big difference, as the 72Mhz GD32 is definitely faster than a 72Mhz STM32 even on the simple benchmarks.

Additionally, the ESP8266 only has one ADC and it is 0 to 1V not 0 to 3.3V. I don’t know if the ADC has the same precision as the STM32 (seems unlikely), but I don’t know.


WereCatf
Thu Apr 21, 2016 8:10 am
RogerClark wrote:I’d be surprised if the SPI flash has the same performance as internal flash, for a start it has to come in via single bit, so even if the SPI clock was 80Mhz, it would only come in at 10 Meg bytes per second.

WereCatf
Thu Apr 21, 2016 8:54 am
Now that I think about it, how would one even go about testing internal flash-speed? You’d need some routing cached in IRAM, not calling any external functions so as not to trigger instruction-fetch during the testing..

Slammer
Thu Apr 21, 2016 9:18 am
WereCatf wrote:….not calling any external functions so as not to trigger instruction-fetch during the testing..

mrburnette
Thu Apr 21, 2016 1:02 pm
Slammer wrote:
<…>
Anyway the performance and the value of this tiny 2$ device is remarkable, for my point of view, the only real limitation is the number of IO/peripheral.

Slammer
Thu Apr 21, 2016 1:30 pm
If the price tag of upcoming ESP32 is around 4$ (as your preorder), then we will have a winner….and this will shake out the arduino world…
in a few months we will know…

RogerClark
Thu Apr 21, 2016 9:13 pm
I like the ESP8266 but there are a few niggles…

No matter what make USB to serial interface I use, I cant get reliable uploads any faster than 115200 :-(
Albeit I think the FT232 ones I have are probably clones….

And I still have to do the 2 button shuffle to put the device into upload mode.

It would be great if I could upload at the amazing speeds some people manage (900k or more), and if I didnt need to mess around with pressing buttons prior to uploading.


martinayotte
Thu Apr 21, 2016 9:18 pm
If in your sketch you simply add OTA library+handler, once you’ve upload your sketch, it is now easy to do upgrades quite quickly without any buttons to press of USB-TTL to attach … ;) (Of course this is NOT “Sans RF” … :geek: )

WereCatf
Thu Apr 21, 2016 9:46 pm
RogerClark wrote:No matter what make USB to serial interface I use, I cant get reliable uploads any faster than 115200 :-(
Albeit I think the FT232 ones I have are probably clones….

WereCatf
Thu Apr 21, 2016 9:48 pm
martinayotte wrote:If in your sketch you simply add OTA library+handler, once you’ve upload your sketch, it is now easy to do upgrades quite quickly without any buttons to press of USB-TTL to attach … ;) (Of course this is NOT “Sans RF” … :geek: )

RogerClark
Thu Apr 21, 2016 10:04 pm
I’ve tried using OTA from a remote web server, mainly as an experiment. However I don’t find it very reliable, even with the latest SDK.

Local OTA is not a lot of use to me, as a lot of the time the RF is running but the device is not signed into my network, as its just operating as an AP, so it would take a lot of messing around to switch the PC’s wifi to connect to the ESP8266’s AP etc.

Far simpler to use the direct serial connection.

I think I may have a CH340g based USB to Serial kicking around somewhere, but I mainly have Prolific CP21xx modules.

PS. I did try to use a Maple Mini as a USB to Serial, but it didnt seem to work with the ESP8266 at all :-(


WereCatf
Thu Apr 21, 2016 10:31 pm
RogerClark wrote:I think I may have a CH340g based USB to Serial kicking around somewhere, but I mainly have Prolific CP21xx modules.

PS. I did try to use a Maple Mini as a USB to Serial, but it didnt seem to work with the ESP8266 at all :-(


Slammer
Fri Apr 22, 2016 1:15 am
The NodeMCU circuit requires both RTS and DTR signals from Uart chip, which is not very common.
If you look at the end of the page that WereCatf linked, there is a link to :

http://www.jce.lu/blog/?p=143

There you can find a circuit that requires only DTR signal (like basic FTDI cable)
I haven’t check the circuit as I have only NodeMCUs.


WereCatf
Fri Apr 22, 2016 2:03 am
Slammer wrote:The NodeMCU circuit requires both RTS and DTR signals from Uart chip, which is not very common.
If you look at the end of the page that WereCatf linked, there is a link to :

http://www.jce.lu/blog/?p=143

There you can find a circuit that requires only DTR signal (like basic FTDI cable)
I haven’t check the circuit as I have only NodeMCUs.


mrburnette
Fri Apr 22, 2016 3:43 pm
mrburnette wrote:martinayotte wrote:
<…>
#define IRAM0 __attribute__((section(".iram.text")))

martinayotte
Fri Apr 22, 2016 3:57 pm
Yes ! Those results are similar with the ones I got.
The really small gain in the IRAM is probably a gain from the first iteration where the non-IRAM is bring into cache, all other iterations becomes identical, since both versions are already inside the IRAM.

mrburnette
Fri Apr 22, 2016 10:06 pm
martinayotte wrote:Yes ! Those results are similar with the ones I got.
The really small gain in the IRAM is probably a gain from the first iteration where the non-IRAM is bring into cache, all other iterations becomes identical, since both versions are already inside the IRAM.

rajdarge
Wed Apr 27, 2016 11:38 pm
RogerClark wrote:Lol…

I think the quality of the EPS8266 posting here, are far better than on esp8266.com ;-)

I think virtually all of us use the ESP8266 as well as the STM32.

I designed a PCB that has a Maple mini, ESP-12 as well as a ILI9341 and an nRF905, which I use for various projects ( though it was originally designed just as a display)


gbulmer
Thu Apr 28, 2016 6:58 pm
I apologise for harking back to this a week late.

I have no issue with the basic idea of trying to compare STM32F with non-RF ESP8266 using ports of the same program.

However, I am concerned there may be some young, impressionable, folks reading the site, who may misunderstand …

mrburnette wrote:
<…>

…. With RISC hardware, the system clock determines the MIPS (excepting cores with look-ahead and branch determination and cpu pre-cache.) But for most ARM inexpensive uC’s, the max clock is the determining factor; THEREFORE, 80MHz is faster than 72MHz… faster by 80/72 = 11.11%


RogerClark
Thu Apr 28, 2016 9:22 pm
@gbulmer

Thanks for your excellent post.

I totally agree, and have previously posted bits of similar information.

If the ESP8266 didn’t have wifi, people would dismiss it as an “also ran” in terms of its processing power and lack of normal peripherals found on normal MCUs.

But it has gained traction, and the production volumes allow its cost to be low.

Also it would not any where near as popular if Iggr had not done the Arduino port.
(I find the Open Source, non Arduino toolchain is a nightmare to install, and only seems to work on 32 bit linuxes)


mrburnette
Thu Apr 28, 2016 9:29 pm
gbulmer wrote:I apologise for harking back to this a week late.

I have no issue with the basic idea of trying to compare STM32F with non-RF ESP8266 using ports of the same program. However, I am concerned there may be some young, impressionable, folks reading the site, who may misunderstand …
<…>


simonf
Sat May 07, 2016 2:04 am
I thought my dyslexia had developed into dyscalculia then I realised it should be “ESP8266 Sans RF” a typo.

martinayotte
Sat May 07, 2016 1:17 pm
What do you mean ? “Sans” is the french word for “Without” …

WereCatf
Sat May 07, 2016 2:22 pm
martinayotte wrote:What do you mean ? “Sans” is the french word for “Without” …

martinayotte
Sat May 07, 2016 2:25 pm
I’m dyslexic too :D

WereCatf
Sat May 07, 2016 2:28 pm
martinayotte wrote:I’m dyslexic too :D

ahull
Sat May 07, 2016 3:14 pm
The scary thing is we got to five pages of replies before anybody actually noticed. :o

martinayotte
Sat May 07, 2016 5:22 pm
Maybe Mosanto introduced secretly something into the worldwide alimentation and we are now all affected by dyslexic disease … :lol:

mrburnette
Sat May 07, 2016 6:20 pm
:oops:
Renamed master record.

simonf
Sun May 08, 2016 10:17 pm
martinayotte wrote:Maybe Mosanto introduced secretly something into the worldwide alimentation and we are now all affected by dyslexic disease … :lol:

gbulmer
Mon May 09, 2016 12:53 am
I am ‘word blind’ (“can’t spell for toffy”, as my Mum would say), but I noticed the “ESP8622” (I recognise part numbers better than words’ spellings)

However, I had not visited for several days, and read the new thread after several days of posts, and assumed it was deliberate.

So I had wondered if there was some Machiavellian plot, like flying under the radar of Espressif? After all, it was an unflattering benchmark and some companies get very squiffy about that sort of thing. However, the first rule of Machiavellian-plot-club, is … ;)

Then again, I do love Ian Fleming’s books and movies, and I read some of Machiavelli’s “The Prince” when I was a youth :D

Anyway, it was an interesting experiment, which I’d still like to understand.

I am puzzled how the code-RAM-cache works, what algorithm does it use to load code?
Also, I’m impressed that it could be overclocked 2x and still read the QSPI memory. So I’d like to read the documentation.

Where are the English-translations of the peripheral interface programming manuals? I’ve had a noodle around, but failed to find them.


simonf
Mon May 09, 2016 5:11 am
gbulmer wrote:
However, I had not visited for several days, and read the title after several days of posts, and assumed it was deliberate.

stevech
Mon May 09, 2016 4:12 pm
Where is the American English translation of (as previously posted) squify :mrgreen:

and would there be two f’s ?


gbulmer
Tue May 10, 2016 6:25 pm
stevech wrote:Where is the American English translation of (as previously posted) squify :mrgreen:

and would there be two f’s ?


stevech
Tue May 10, 2016 8:06 pm
I wish American English had more of those kind of polite euphemisms.

ramimo
Fri May 19, 2017 8:35 am
Hi all,

I know, this thread is really, _really_ old. I found it while searching for some infos to switch of wifi on a ESP8266. Again, this board had the best result :) I am working on a kinda arty project, involving displays and cameras and whatnot – if I can get it all running.

The benchmark results baffled me. In my experience, the ESP8266 is not really that slow. The culprit is, as was stated more than once, that the watchdog timer wants to be fed time and again.

In my view, it is absolutely valid to fiddle with that beast. If I know that something needs some time without any risk to go fubar, I set the watchdog accordingly. With 10 seconds timeout (more than enough to calculate the prime numbers, I get thse result:

80 MHz, w/o IRAM: 797219 µs
80 MHz, with IRAM: 760123 µs
160 MHz, w/o IRAM: 398799 µs
160 MHz, with IRAM: 380203 µs

All I did was adding the line “ESP.wdtEnable(10000);” in setup() and disabling the delay(0). The numbers are definitely worse than with the litte STM32F103, but it’s just a factor of 2 or 4. I have not much code that is that speed sensitive, so it’s all about IO pins for me. If I need them, it is the STM32, but if I want to “install” a web server with a drop of hot glue, I take the ESP :)


Leave a Reply

Your email address will not be published. Required fields are marked *