afnid / espsim

ESP8266 Simulator (Allows Native Code to Link/Run on Linux)
GNU General Public License v2.0
65 stars 12 forks source link

What does it do #1

Open tytower opened 9 years ago

tytower commented 9 years ago

I use Linux and I use ESP8266 modules so you heading attracted me . From that point however I have no idea what your program actually does and forgive me but your explanation needs a lot of work to make it understandable . I compile in Linux too and use gcc but I just have no idea what you are on about . Could you try afresh?

afnid commented 9 years ago

Sure, when you compile code for the esp8266 you are using the xtensa cross compiler to create an image that you flash to the esp8266 and run native on the processor.

What this library allows me to do is compile/link the same code creating a Linux 32-bit executable that I run on the Linux host computer independent of any esp8266 processor.

If your getting random crashes on the esp8266 it is likely because of overwriting or dereferencing or overwriting memory because of a bad pointer.

Running as a Linux executable you can run tools like gdb and valgrind, which will help you find memory errors much faster.

I have also been using the Linux executable to test protocols with an actual esp8266, which has worked well since I don't have to reflash unless I change the client side.

I use the rboot boot loader and I had to dummy up a header, but was even able to test my ota upgrade. Of course it can't execute the new code on Linux, but I could verify everything else up to that point.

tytower commented 9 years ago

Thats much more understandable . Thanks Mind if I post my question and your answer into the Forum? Or maybe you want to do it.? -----------------------------------------------------------------------On Thu, 13 Aug 2015 10:36:31 -0700 afnid notifications@github.com wrote:

Sure, when you compile code for the esp8266 you are using the xtensa cross compiler to create an image that you flash to the esp8266 and run native on the processor.

What this library allows me to do is compile/link the same code creating a Linux 32-bit executable that I run on the Linux host computer independent of any esp8266 processor.

If your getting random crashes on the esp8266 it is likely because of overwriting or dereferencing or overwriting memory because of a bad pointer.

Running as a Linux executable you can run tools like gdb and valgrind, which will help you find memory errors much faster.

I have also been using the Linux executable to test protocols with an actual esp8266, which has worked well since I don't have to reflash unless I change the client side.

I use the rboot boot loader and I had to dummy up a header, but was even able to test my ota upgrade. Of course it can't execute the new code on Linux, but I could verify everything else up to that point.


Reply to this email directly or view it on GitHub: https://github.com/afnid/espsim/issues/1#issuecomment-130773172

Yahoo tytower@yahoo.com

tytower commented 9 years ago

I guess you hav'nt seen the above yet. So OK I'm intrigued now. I have a program written in Arduino IDE that compiles and gives a hex file that is loaded to the chip. I take it that I grab that hex file and with your program I can make a binary file that I can then run on my 32 bit Linux machine and find problems more easily . OK so if I have it blinking an LED when it runs on Linux where would I see that blink if at all. I take it I can run that binary file step by step or put breakpoints in it to stop and step and thereby see any say array misread or such. Am I getting that understood properly?

afnid commented 9 years ago

I listed this for the SDK, as in the SDK provided directly by espressif, the Arduino IDE brings in a pretty substantial library that will be very dependent on actual hardware. Low-level hardware testing would require running an embedded debugger which I haven't seen available yet, and may not be able to keep your wifi connected while in a break-point.

I have a rapidly growing code base an when something went wrong I couldn't be sure if it was the runtime or my code causing an issue. I am now very confident that over 80% of my code has been run with valgrind and does not have issues, and was able to write a few unit/load tests. The other 20% is the hardware specific portion that includes i2c, etc which can only be tested on-chip.

Still not going to be helpful for Arduino code without quite a bit of work, probably not enough to be gained in doing so. If you aren't using third-party libraries, you may find that your using only a handful of Arduino specific api calls, but would only go through the effort if you have a lot of non-chip specific code.

matthewkleinmann commented 7 years ago

Can you run popular 8266 "flashes" on top of this sim, like nodemcu? Also, is there a way to set or monitor the status of the GPIO?