Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generic esp8266 board: Use flash mode DOUT by default, in place of QIO #5601

Merged
merged 9 commits into from
Jan 15, 2019

Conversation

d-a-v
Copy link
Collaborator

@d-a-v d-a-v commented Jan 8, 2019

No description provided.

@d-a-v d-a-v requested a review from igrr January 8, 2019 02:31
@igrr
Copy link
Member

igrr commented Jan 8, 2019

@d-a-v Which issue does this fix?

@d-a-v
Copy link
Collaborator Author

d-a-v commented Jan 8, 2019

https://gitter.im/esp8266/Arduino?at=5c33150782a6c30b9099abb3
@Makuna

This idea is that more and more boards only works in DOUT flash mode, even esp8266.
edit: Even @wemos and @4dsystems (#4616) changed their board definitions to DIO ±recently (what's the difference between DIO and DOUT?)

DOUT is slower, but I remember you said once this should not be noticeable on esp8266.
Changing default to DOUT, while still being selectable, will solve a number of user headaches.

@igrr
Copy link
Member

igrr commented Jan 8, 2019

Okay, I think this is fine, if prominently mentioned in the release notes.

@igrr
Copy link
Member

igrr commented Jan 8, 2019

Side note, does the new menu item order DOUT - QIO - QOUT - DIO look logical? Maybe DOUT - DIO - QOUT - QIO? Or DOUT - QOUT - DIO - QIO?

@d-a-v
Copy link
Collaborator Author

d-a-v commented Jan 8, 2019

Side note, does the new menu item order DOUT - QIO - QOUT - DIO look logical? Maybe DOUT - DIO - QOUT - QIO? Or DOUT - QOUT - DIO - QIO?

TBH I don't know.
The most compatible is DOUT, position 1, purpose of this PR.
Previous first, the most simultaneously common and fastest is QIO, position 2 ?

We can also add comments in menus with those options, could be

1- DOUT: most compatible
2- DIO: ????
4- QOUT: ????
3- QIO: fastest

This PR is not mandatory and does not fix anything apart from common user error when using the generic board. It arose from the above link when it comes to sonoff devices, and they seem to not be alone, which seem to have only two wires between esp8266 and flash chip (or using a specific flash chip, I don't know).

We can also add defines that can be checked in sketches and #warn if configuration does not match something (when sketch can be matched to specific hardware).

#ifndef FLASH_MODE_DOUT
#error Please use DOUT flash mode with the hardware this sketch is designed for
#endif 

edit: @earlephilhower Did you measure the overall speed impact from QIO to DOUT or DIO ?

I'm open for updates, or closing.

@d-a-v d-a-v requested review from devyte and Makuna January 8, 2019 09:59
@earlephilhower
Copy link
Collaborator

earlephilhower commented Jan 8, 2019

@d-a-v, sorry but I don't have measured numbers, and it depends on the cache hit ratio. Assuming the cache line is 32bytes, though, the time to do a cache fill is going to be very roughly (I'm not looking at a datasheet now or factoring protocol overhead):

DOUT: (write addr) 24clks (read 32*8bits @ 2-bits/clk) 128clks = 152 Flash Clocks @ 40MHz = 3800 ns
DIO: (write addr) 12 clks (read 32*8bits @ 2-bits/clk) 128 clks = 140 Flash Clocks @ 40MHz = 3500 ns
QOUT: write(addr) 24clks (read 32*8bits @ 4bits/clk) 64 clks = 88 Flash Clocks @ 40MHz = 2200 ns
QIO: (write addr) 6 clks (read 32*8 @ 4clks/bit) 64 clks = 70 Flash Clocks @ 40MHz = 1750 ns

Straight-line code in this case (not in cache yet) would end up almost 50% slower on DOUT vs QIO.

That said, though, if you're using "generic" as the board then I'm all for a safe (but slow) default. You can change it to QIO/etc. manually if you know enough about the board (or add it to boards.py).

tools/boards.txt.py Outdated Show resolved Hide resolved
@d-a-v
Copy link
Collaborator Author

d-a-v commented Jan 9, 2019

flashmode

Copy link
Collaborator

@devyte devyte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with @earlephilhower about order

@d-a-v d-a-v merged commit cef5dee into esp8266:master Jan 15, 2019
@d-a-v d-a-v deleted the doutfirst branch February 6, 2019 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants