Some time ago I passed comment in here about converting an ESP-01 to 32Mb (or 4MB). And here it is in the flesh – a 32Mb ESP-01 – and also – at last – Sonoff Upgrades.
Now, why would you want to do all of that? I would suggest only if you happen to have lots of ESP-01 units lying around – and I’ll bet quiet a lot of you do. As for the Sonoffs – well, put it this way, I just ordered another 10 chips!
I stopped using the ESP-01 a while ago because the standard 4Mb (512K) of FLASH was simply no longer good enough. Richard of RBOOT fame set me using using his RBOOT program so I could easily flash my home control code (see Home Control 2016 and Blowing the Home Control 2016 Code). Partly because I keep adding new stuff and partly because of the size of the Espressif SDK, Although my code will still run in an ESP-01, it certainly won’t OTA (remote over the air programming). And so my little ESP-01 boards have been sitting gathering cobwebs. The Sonoff mains controllers on the other hand are VERY useful but it annoys the hell out of my that my software is now too big for the limited FLASH in these units – at least, for doing OTA remote updating anyway. All of that, for me, is now history.
A few weeks ago I noticed the Flash chips available for very little money and thought “go on then, why not” despite never having thought of updating Sonoffs – well, today, weeks later, they arrived, all five of them. I mean, at £1.86 for 5, or 37p each – you have to give it a go.
I got my fine soldering iron out (who’s bit is so fine it looks like it will last all of a week) and opened up the package.
The first thing I noticed is that these chips are slightly wider than the one in my little ESP-01 – chips shown side by side in the photo above. To remove the originals, I took my tweezers, put the side of the bit along the side of the chip – and when the solder melted, just lifted the chip a little – then did the other side. Came off a treat.
What to do about this width problem…, I decided to hold the new chip and flatten the leads on either side (vertically) by merely pushing against my desk. You’ll see in the photo on the right – which shows an un-adulterated chip (the upper, larger one), the lower right photo showing in the middle, the one who’s leads I flattened – and the original chip from the ESP-01, lying on it’s back.
Doing that added very little to the height but positioned the leads smack in the middle of the surface mount tracks. With a fine soldering bit and fine solder it really was a doddle to re-solder the new chip back onto the board. I’d say total time to remove the original and put the new chip on – something like a minute.
And here it is – the ESP-01 is shown here mounted on one of a little adaptor board to allow 5v operation and standard FTDI connector etc. As you can see in the picture, the FLASH chip is a tad higher than before – but only by 1mm, it works a TREAT, flashed first time and my test function shows it as a 32Mbit chip.
flashsize=Manuf ID= 239, Type ID= 64, Size=4194304
And on power cycle, works a treat. Ok, yes, only worth it if you fancy a soldering challenge and you happen to have a load of otherwise useless ESP-01 boards – but hey, that’s what hobbies are all about.
ESP Starting…
GPIO4 and 5 are outputs.
Current web programming pin: 2
GPIO13 is an indicator.
Software version 1.4.2Use the {debug} command for more information.
STATION mode
Web page control enabled
Waiting for Access Point wififorus
Connected as 192:168:1:34
MQTT connecting
MQTT Broker connected
Device ID is modified
Item published
Time is 10:48:01 06/07/2016
Ok
Tick
Just to prove to myself this was not a fluke, I modified a second board – worked a treat (well, programmed a treat but would not work then I noted I’d shorted pins 3 and 4 together – fixed that – immediately worked a treat). Yes, I’d say total conversion time around a minute or so. Of course now I don’t know what to call them – ESP-01+ maybe!!
Just earlier after I wrote the blog – and LOTS of people took an interest, I received a comment to ask if it was possible to upgrade the Sonoff.
Well, there’s only one way to find these things out – so back to the soldering iron and yes, not QUITE so easy to get the iron in there – but yes, I now have a working 32Mbit Sonoff – this changes a lot and THAT is why I’ve just ordered another 10 chips.
The Sonoff chip is the EXACT size of the new chips I bought so no bending of leads. Just a VERY careful soldering job – you HAVE to have a pointed fine tip to do this – your dad’s Antex bit will not do it – but – I would say maybe 5 minutes this time being careful not to melt the stand-up LED? I will update my other Sonoff boards now but I’ll have to wait for more chips to arrive – whoever thought it would be this easy. See my original blog on the subject for programming.
Hello,
Thanks for the great post, i really love it!.
My question is: wil this chip work for the modification ?
100 stks W25X40CLSNIG W25X40CL SPI FALSH SOP8 4 Mbit Winbond W25X40 W25X40BVSNIG
https://nl.aliexpress.com/item/10pcs-lot-Free-shipping-W25X40BVSNIG-W25X40BVNIG-4Mbit-flash/32692899720.html?spm=a2g0z.search0104.8.65.5b83e883c7CtXF&priceBeautifyAB=3
Greet Davo
I have found that other units like, NodeMcu and home brew boards with ESP-12 all OTA just fine. It looks like I have 15 sonoffs with faulty flash chips. I sourced them from 2 different suppliers and I am fairly experienced with the soldering iron. What a pain…..
So the other day I was flashing a board and it simply would not flash properly – constant reboots – or it would get so far and the watchdog timer would trigger… I just don’t get this so decided to investigate further. It would flash ok, just not run. I checked the power from the FTDI – output was 3.9v. Should have been 4.x – I simply put an external supply to the board and voila – perfect. Moral – never assume your FTDI is putting enough power out.
so flashing a sonoff with a upgraded memory module OTA.. have u ever encountered this issue of not enough power????
Yes, I have. Absolutely.
I have 15 upgraded sonoffs with various versions of firmware and with flash upgrades chips from 2 different sources. Just recently I tried to do an Mqtt otaupdate which claimed to have completed but on running ver? it reported no change. I then connected serially and ran the otaupdate again. This showed
OTA succeeded to Rom1
Rom 1 is bad
booting Rom0
None of my units will update. Does this mean that I have got 2 bad batches?
BTW I uploaded an Arduino test sketch which reported that the chips were OK with a size of 4194304
Hi John
Well I’ve just been doing some OTA updates – I noticed that once in a blue moon the OTA fails (and the software sticks with the current version so no harm done) – try again and it is fine – I’m wondering if speed of connection is important here… slow download? Certainly I don’t perceive any real problem with the OTA. I’m actually using it for development (on a version you don’t have access to yet which only works with 4MB boards – I’m abandoning support for unmodified ESP-01 boards)…. and rather than plug in the serial connection etc I’m using OTA – over and over again – most of the time it is absolutely fine…. incidentally I’m modifying the start up message to make a it clearer which ROM block you’re using. That 4194304 – I hope that’s bytes and not bits – because if that is 512K BYTES you can’t OTA at all.
Thanks for the idea, the write-up and the ebay URL. I changed the chip on my old ESP-01 in about 5 minutes and it works like a charm! Probably I’m going to upgrade my Sonoffs as well.
I tried to find the chips at my local supplier Farnell but they did not stock it.
I could imagine Farnell charging WAY over the top….
Of course! But sometimes you need stuff the next day instead of 3 weeks, so it has its place.
Of course though in my case in a matter of hours I will be in Spain for the next 6 months and that line becomes blurred. A week or so with stupid postage costs from the UK or 2 weeks and no postage from Spain.
I found your blog via SuperHouse.TV
I am just getting started, and received 4 Sonoffs this week. Upgrading this chip seems to be fundamental; I appreciate your sharing. I do not know what the replacement chip is called so that I can search and find a source here in the US. What do I need to know?
Thanks
Jerry
Hi Jerry – if you use THIS software – https://github.com/arendst/Sonoff-MQTT-OTA-Arduino you don’t need to upgrade the chips on the Sonoffs.
Hi,
I really admire your work here.
It is just a pingback from here:
http://pakahuszar.blogspot.hu/2016/10/esp-01-surgery.html
SUF
Yup – ESP01s are easy to update – some others for mechanical reasons are more tricky… thin tracks etc…
Looks like there is a new ESP8266 product entry in pre-order from Itead: https://www.itead.cc/sonoff-dual.html
I can’t see what ESP8266 they went with, but the product images look like the mcu on on a daughter card. Can anyone else discern the mcu used by this schematic: https://www.itead.cc/wiki/images/1/1d/Sonoff_Dual_View.pdf
I’ve asked them to ship a sample so I can review it.
hmm i must have busted something. its strange that when i put the original flash chip back on it boots the firmware that was on (or goes into bootloader mode if jumpered that way) it but i still can’t flash it.
i’ve tried 2 flash chips and i’m pretty sure i haven’t left any solder bridges anywhere
update!
I tried the same thing with a new ESP-01 and a new flash chip (and a little less solder paste…) and it worked!
Thanks for the info Pete!
I have tried to flash but nothing is able to connect. Flashing firmware files via ESPTool fails saying unable to connect. Same for flashing via Arduino IDE and from Eclipse using the SDK.
What options did you need to select when flashing? QIO/DIO/etc?
Rather than mess with settings, using the standard Arduino flashing setup should work as is – if not – I guess that leaves one of three options, bad chip, wrong chip or bad connections. Have you had a good close look? Are all the pins REALLY connected to the board? Right way up? It should just work.
Hey Pete,
I got some new flash chips in the mail today and swapped over an ESP-01. Plug it in and run ESP Tool to check connection and i get nothing…
I checked all the solder connections and couldn’t see anything wrong so I swapped back to the original flash chip and still nothing in ESP Tool 🙁
It does work though! I can see bootloader messages displayed and it can boot the firmware that was on the chip originally, but I can’t get ESP Tool or the Arduino IDE to talk to the chip at all.
Did you have to initialise anything to get the new flash to show up in ESP Tool?
Thanks
Hi there
I’m looking at your comment and not seeing anything about you actually FLASHING the unit. If you put a new chip in there, you won’t get anything until you actually flash something – like my software, or BASIC, or the AT software or LUA etc.
Hi pete i have just updated an ESP01 to 4K. followed your instructions and all went smoothly. I have lots of 01’s that i bought in the early days before i started following your blog. i also have lots of pcb’s that i bought around the same time that have a switching regulator and a couple of mosfets connected to gpio 0 & 2. They originally ran a bit of LUA that allowed you to drive two Led strips via Domontiz and MQTT as i remember…but was so flakey that i just gave up on the wifi idea of home automation and went back to arduino with ethernet shield until i found you!
So i now have Home Control on one of these boards and was wondering if it would be possable to do PWM out on GPIO 0,2 or both ?
Thanks
Hi there Chris – not something I’d want to do – having firmly moved away from ESP-01 because of lack of Ports – I’ve realised that using GPIO0 as any kind of output is not really a good idea… as it is used for programming and therefore does not like being pulled down on powerup. Also to save on pins I’m standardizing on using the same input (GPIO0) to set up web programming. I also use GPIO2 as a general purpose input and temperature sensor.
So – given the source code there is nothing to stop you from going into the PWM code and changing 2 of the 3 PWM pins to 0 and 2 – and disabling 2 as an input. And no doubt it would work just fine – but I don’t want to put that into the code we’re using here for the reasons mentioned above.
So yes it is possible but you’ll have to take that on – easy enough if you can compile the code.
Any one had problems with flash upgrade. I got 5 from the source mentioned above and have soldered 3 of them to 2 x ESP01s and a Sonoff. All three refuse to accept firmware. I am happy with the solder job and now suspect that I have got a bad batch?
thanks
John
All three refuse to accept WHICH software. If mine – you really need to flash THREE files as detailed elsewhere… the one at the very top contains Espressif info…. more details – you you have a fresh board – what are you trying to flash and how.
Sorry not enough detail:
The devices will not now accept any firmware, even a simple “blink” example from the Arduino IDE. Using the flash programmer the process seems to start but then fails every time. It is almost undoubtedly my soldering or dodgy chips.
I am fairly experienced at soldering small components and have done it often.
hi
i had no problems, replaced the flash chip (the right way round ) and then used ESP8266 Flasher with the 3 bin files from peter. worked first time!
the only thing i do different is I have modified my FTDI’s as i normally use them to power all when experimenting, and the 3V3 from these is generated in the chip and i dont think/trust the amount of current it can provide. So i tack a LM1117 between the USB 5v and the 3v3 out on my FTDI.
That is an absolutely sensible thing to do. I would not recommend this to anyone because everyone’s setup is different – personally all my boards have 5v regulators and hence I use the FTDI in 5v mode. Clearly the output from the ESP works perfectly input to the FTDI – one could argue that you should not feed the output of a 5v FTDI serial out into an ESP – in practice I do – always have and have in my years of programming chips only ever taken one out – last week for unrelated reasons. But as I say, everyone’s setup is different. When you put the LM1117 across the FTDI – do you use any caps or just the chip- I’m sure others would like to see a picture?
Hi Peter,
There is a new item on itead https://www.itead.cc/sonoff-th.html. If you receive samples please send informations about differences between models and available pins. I can see free holes on PCB but I’m not sure that are conected to ESP
I received a smart socket – https://www.itead.cc/smart-home/smart-socket-eu.html , the PCB is similar to sonoff, but the design is much better.
Best regards
Ion
Ok, it is starting to sink in here – lets see if I can explain what I think I understand – and maybe others can fill in (large) gaps – so even more people can then get to grips with this.
So the ESP8266 is 32 bits – which means it can address 16 blocks of 268Mbytes (not talking about flash here – the processor.
I would appear that the top 9 blocks are not of much use – that leaves 7 blocks of 268Mbytes (0x1000-0000). Lets call them blocks 0-7.
In block 4 near the bottom (0x4020-0000) there is a 1Mbyte window where a part of the FLASH can be mapped in… so no matter how big the FLASH we can only see a 1 meg window of it. There is a register which determines which bit… and that can change – hence the OTA – just update the register.
BUT despite being able only to see part of it – we can apparently ACCESS all of the FLASH through functions and indeed all of the 32bit memory map through C pointers???
That leaves a brain-teaser… some people put non-vol info in 0x3c000 and others in 0x79000 (I use the latter). But what does that mean and how big can that area be – I know that when 3c000 is used, 3c000 and 3d000 contain 2 copies of the data and 3e000 contains a number stating which of the two is the current one. In this case 3e000 goes unused. Seems a waste.
How wide could this be – could we have MORE than 4K user Flash data? More importantly, just what IS 3c000 – is it a location in the 32 bit space, or is it 192K from the bottom of flash – in which case when we use 2 1-meg blocks in a 4Mbyte chip are we using the second and third block? Somewhere there has to be a simple explanation of this?? or does it vary in different installations and if so where is the info stored to figure this out?
BTW I am talking about slots here, please note I mean address mapping slots. Rboot can make use of more slots, if properly re-linked images are used.
Peter, each flash sector is 4k (4096 bytes). Multiply it by 4096 and you will have the actual start address of the sector. If you’re using the read_flash/write_flash interface, the address is exactly the same as where you write it (for instance with esptool).
If you’re using low level read/write instructions (have the processor read/write the code/data directly), you’re bound to the current slot (0-3, if you’re using 32 Mbit flash). Each slot will appear at 0x40202010 onwards (although I’m not 100% sure of the exact address, you might want to try 0x40202000 and 0x40200000 as well).
The ESP can address 4 slots of 1 Mbyte (= 8 Mbits) each at a time. So if you’re going to use it for code, you’re out of luck, 32 Mbits max (8 Mbits per slot). But I could imagine that the read_flash/write_flash interface will happily address all of the 128 Mbits of such a large flash chip, so it could be used for data.
That is exactly what I plan to do – but to do that I need to know where my 2 1-meg slots are, where the user data blocks are (starting at sector 0x79 apparently) and where any other stuff of Espressifs is – so I know where I can have a clean shot at writing and reading data without over-writing anything.
Hi peter
I was read that esp8266 ic that support max 128mb flash ic. Tech from esp say 128mb is max. So any of you have trying it. Before i going try it. Plan try grab esp-01 change to 128mb. But first i find out from anyone 🙂
You must have a storage use for that Flash because you’re not going to be using it for programs 🙂 As I understand it you can access for general programs, 1Mbyte max… hence I use 2 1Mbyte slots for OTA… still struggling with where visually my user data currently sitting at sector 7900 is.. getting a mental picture of the 4Mbyte block is not proving as easy as I’d hoped. I’m counting on Richard enlightening me when he’s back.
Using the “read write flash” api you can address the complete flash address space linearly. As soon as you’re going to address it directly, you’ll be confined to the 8 mbit slot you’re currently in.
Much related useful stuff (not necessarily only related to the use of rboot) can be found here
http://richard.burtons.org/2015/05/18/rboot-a-new-boot-loader-for-esp8266/ and here
https://github.com/raburton/rboot/blob/master/readme.txt
Nice autocorrect…
reboot = rboot
slip = slot
I’ve been doing this for some time. When you’re using reboot for OTA flashing, rboot/esp8266 has a nice surprise. If you use 32 mbit flash, you can have 4 slips of 8 most that can run *exactly* the same code. No need for location 1,2,3,4 images compiled for different addresses, the esp8266 can map them in hardware. Likewise two slots for 16 mbit will give you two slots (which I think is sufficient).
Any Winbond W25Q16 series flash seems to work, I haven’t had issues.
NOTE: depending on what sub-series you choose, various sizes (capacity) and footprints are available. I’ve found 32 mbit is only available as 208 mil soic, whilst 16 mbit is generally available as both 150 mil and 208 mil soic. So I’d propose to just use the one you need instead of winging it. Also note: ESP-01 can have both sizes, depending on the date of fabrication so be aware. Also the ESP-201 uses 150 mil, something one might not expect.
Also note eBay offers only a very limited choice of (only somewhat outdated) Winbond flash chips. I had to turn to aliexpress for some models (which all went well in the end)
Useful knowledge indeed – thanks for that….
I’m still struggling with the question of whether or not I can read any arbitrary location in the entire Flash… I keep thinking that as my code uses <1 meg times 2 for OTA - there is 2 meg sitting there doing absolutely nothing. Using it as a disk could be good for storing temperature info.
my struggle right now – I’m using 2, 1Mbyte slots and a slot for user data at sector 0x7900… I want to visualise where these are in the 4Mbyte flash and what areas are available for general use – clearly there will be many locations somewhere for things like registers and stuff used by Espressif. The memory maps out there are conflicting.
Peter have you tryed 128mb ic chip. What i have found from esp tech say “No programm rom in chip, user codes are strored in spi flash. Take 4Mbit spi flash as example,the current available program area is <64KB.
The maximum size of flash that ESP8266 support can be up to 128Mbit" so i just pass on. Before i but esp 01 try grab 128mb flash chip but like hear anyone did pass use 128mb???
Jason – not understanding the above very well – maximum space usable directly for programs on ESP8266 is 1 meg, not 64k – my own code is now something like 700K. I would imagine that if you put a larger chip in then it can be used in 1 meg blocks – as I’ve said elsewhere – I have a perfect use for 2 * 1 Meg but I’m struggling to get my head around using the other 2 meg effectively. Just talking about that tonight – if that can be written to in reasonably small ram-buffered blocks and read back 32 bits at a time directly, one could envisage stored 8 bit speech or sound effects for example.
Hi Pete. What adaptor is that? The one you mounted the ESP on. Thanks
It’s an old design I came up with ages ago and Aidan did the board layout for – we sent off to China and got I think maybe 20 boards made. Basically just a 3v3 reg and a few pullups and decoupling caps.
I made one myself with an universal PCB, but yours looks much better 🙂
http://i65.tinypic.com/eq4exg.jpg
Here is my Homemade ESP-01 breadboard adapter:
https://www.wifi4things.com/squonks-dyi-esp-01-wifi-module-breadboard-adapter/
Hi Squonk – none of the images on that wifi4things site work – and on both mobile and PC, dire warnings about going to the site…
It’s the self-signed certificate… Here is the plain http version that should work:
http://www.wifi4things.com/squonks-dyi-esp-01-wifi-module-breadboard-adapter/
ordered, my boards will soon be able to take even my horribly inefficient code!
+1 for the suggestion of drag soldering….. definitely the way to do this.
Part number (and source if possible) for the FLASH chips?
There’s a link in the post. Near the top where is says “A few weeks ago I noticed the Flash chips available for very little money”
P.
Use solder wick to desolder the existing chip cleanly, or cut the pins and desolder the individual pins if you don’t care about the chip.
Use a flux pen to solder the new chip. The flux is magic, as the solder paste will ruch onto the pins and avoid shorts, even if you put a large blog of it, you don’t even need a fine point soldering iron!
Super tip Squonk! thanks ?
Here is a drag soldering video:
Agree that solder paste is by far the best option. Killed an ESP-01 when trying to upgrade using conventional core resin solder but then successfully replaced a dead 32Mbit chip on an ESP-12 using solder paste.
Fantastic work Pete, have ordered a load for myself, got a load of Esp01’s to mod!
Hi Pete
I’m new to esp
in other blog post : it’s a 128Mb module on esp-03 : http://www.instructables.com/id/ESP-03-Upgrade-Flash-Memory-to-128-M-Bit/?ALLSTEPS
Is it possible with other module like esp-12 family?
Regards
Robert
Ok Pete,
Great work. What do you have as a smd soldering iron. As i have 15 sonoff’s to update.
Regards
Paul
I have a bog standard thermostatically controlled Antex here – but I stuck on a copper bit that slowly comes to a fine point…. the normal flat-head type I would normally use would just end up in a load of shorts… so just a cheap copper fine point tip… and thin multicore solder (not that lead-free horrible stuff)….
Hi Pete,
Would this also work in the sonoff devices ?
Regards
Paul
Refresh your browser for the answer – which is …. yes. Good timing – the iron was still warm.