Tag Archives: ESP8266 FLASH ISSUES

Update: You’ll see from the original article before the break, I was having serious problems with ESP-01 versus ESP-12 etc where code running in the 12 would simply not work on the ESP-01. Well, it turns out none of this was helped by the MAKEFILE..

You’ll often see references to files at 00000 and 40000 (hex) and like me probably wondered what’s happening with all that space in the middle. Turns out much of it is thrown away. I’ll soon put the new Makefile up that we’re using but perhaps the mere fact of this email will help some. You don’t have to have config information stored at 3c000 and you don’t have to have your code at 40000 either!

Thanks to reader Richard Burton who clearly knows more about Makefiles than I do, we’re now compiling our code starting at 20000. It turns out that 7c000 is used by SDK – but 78000 is available and that is exactly where I am now storing non-volatile information (and this works equally well on the ESP-01, ESP-07 and ESP-12 boards and means we can now code from all the way down at 20000 continuously upwards through to 78000). Whereas before my code was up to 73000 it now goes from 20000 to 53000 leaving a TON of room for more FLASH code. It has to be said however that I’d not realised how close to the wind I was sailing with RAM and the outcome of that is – wherever at all possible add the ICACHE_FLASH_ATTR to your C code so that the code runs from FLASH rather than being permanently cached in RAM.

So..

If you have the start of a function like this..

LOCAL void temperature_cb(void *arg)

Just amend like this..

LOCAL ICACHE_FLASH_ATTR void temperature_cb(void *arg)

The only place I’ve found I could NOT use this was a couple of small, tight routines to handle WS2812B LEDS where time was of the essense (microsecond or so).

Shortly I’ll update this and put a link to the Makefile so you can compare with what you are using. I still don’t entirely understand the Makefile but I’m slowly getting there. Just a tad short of blogging time as we’re in the process of kitting out a house and we’re on a deadline but I plan a LOT more on this subject in the coming months as everything is starting to come together.

Below, the original article where you can see I was getting quite frustrated.

----------------------

For now, I am defeated and I’m hoping one of you readers is a step ahead of me.

For a while now, we’ve had an issue blowing ESP-01 with my code which is based on TuanPMs MQTT code but just keeps getting bigger and bigger. I’d have no problems blowing an ESP12 but once we got past API 0.96, ESP-01s would not work – then I hit on the idea of reversing the order of the two files I was blowing. That worked for a while.

Now the code goes all the way from 0 to 73000…. so the solution to get ESP-01s working is to use an option you see in some ECLIPSE setups for Windows – the Makefile there is a FLASHONEFILE option… this makes a single file that goes all the way up to 0x73000. LOVELY… except – TUAN stores his variables like API and password at 3c000… so this gets wiped every time.

I thought I was being really clever by moving his pointer to 7c – so that must-keep variables would be stored at 7c000 – WELL above my code.

Nope… turn the thing off and on and the variables are remembered no problem. Update the code with FLASHONEFILE – and BANG! Variables gone, defaults loaded. I have ABSOLUTELY no idea why this is happening.

Any thoughts

Pete.

Welcome

Hi - I'm Pete and this is my technology blog. It is BIG. Use the search box below or check out the archives and other links below - be sure to SHARE what you like using the social media buttons and please subscribe to my YouTube channel http://www.youtube.com/PeterScargill

Please register or log in - the top menu changes a lot when you are part of the party... and once in, don't forget to tick the box so you will get email follow-ups to comments.

I am tied to no organisation - I do this for the joy of learning. Maintaining a blog of this size takes a lot of work and I hope you find my contributions useful - if you want to help fund my gadget habit or buy me a coffee - here is a link.

Disclaimer: Because I have no idea of your level of technical skill or the requirements of your country laws in terms of electricity supply etc., I accept no responsibility for any damage caused through following advice in these pages. When dealing with mains voltages you should satisfy yourself that whatever you are doing is safe and if unsure, seek advice from someone who is sure.

Notice: I'm always happy to offer advice on stuff I've written - and indeed take advice. If I can help in any way just let me know but PLEASE don't ask me how to program in C/PASCAL/NODE/etc. There are many resources out there - if you want to program and can't - there's always Google.

Newsletter

The blog will send you occasional emails containing links to recent posts. No ads and your email will not be given to third parties. There's an un-subscribe link on each email. Invalid names will be deleted.

Links

EE Times | Electronic Engineering TimesEE Times connects the global electronics community through news, analysis, education, and peer-to-peer discussion around technology, business, products and design