ESP32: A Fatal Error

September 1st, 2018

If you get this message when trying to flash an ESP32:

A fatal error occurred: Failed to connect to ESP32: Timed out waiting for packet header

You may need to reboot it while flashing so the computer will recognize it. You should be able to trigger a reboot into flashing mode by holding down the BOOT button and giving the EN button a press. Do this while the esptool is “Connecting…”, and it should connect and write with no issues. You may need to try this several times before the tool will see it and connect.

This is what a successful flash looks like:

# make -j flash
Python requirements are satisfied.
Flashing binaries to serial port /COM4 (app at offset 0x10000 )...
esptool.py v2.5.0
Serial port C:/msys32/COM4
Connecting........_
Chip is ESP32D0WDQ6 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse
MAC: xx:xx:xx:xx:xx:xx
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Auto-detected Flash size: 4MB
Flash params set to 0x0220
Compressed 21184 bytes to 12571...
Wrote 21184 bytes (12571 compressed) at 0x00001000 in 1.1 seconds (effective 151.3 kbit/s)...
Hash of data verified.
Compressed 138336 bytes to 68372...
Wrote 138336 bytes (68372 compressed) at 0x00010000 in 6.1 seconds (effective 181.4 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 103...
Wrote 3072 bytes (103 compressed) at 0x00008000 in 0.0 seconds (effective 1068.5 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...

Javascript HTML Fun

December 18th, 2013

Here are some useful Javascript snips for working with form data.

How to get the name of the HTML tag for an element:
[code]this.nodeName.toLowerCase()[/code]

This code will see if we have a map set of inputs (somename[]):
[code]// See if we have a map here
var mapFound = 0;
if (thisName.indexOf(‘[]’) != -1) {
mapFound = 1;
thisName = thisName.replace(/[\[\]’]+/g, ”);
}[/code]

How to take a map of inputs and turn them into a Javascript map type var, and toss the empty ones:
[code]var map = $(thisName).map(function(){
if (this.value != ”) {
return this.value;
} else {
return null;
}
}).get();[/code]

Fun With Automated GIF Generation

October 29th, 2013

Trolling around on the web, found a fun little process for generating animated GIFs: http://rarlindseysmash.com/posts/stupid-programmer-tricks-and-star-wars-gifs

Which Framework?

July 21st, 2013

Learning a framework is an investment of time. You have to work out how this one structures its files, wants you to template, what levers to pull.

This is why people build their own so often. At least then it works the way you want it to.

Globally Scoped

July 14th, 2013

Global variables are a code smell. This statement is both true and false. What is true is that they are a problem when they are no longer the right variables to be global.

Today I had to re-factor a function to be able to use multiple servers inside one script instance. Initially, the server connection was created and stored in one variable that was then referenced. This worked well, because the code that called this function didn’t have to worry about what server connection was involved.

Of course, the problem started when I added a second server into the mix. Now, this function had to be able to access either server, selected by the code in some of the places that called it. The easiest way to solve this would have been to keep the global and add a second optional parameter to override it, but that would not be as clean a fix as just fixing the global.

And so I re-factored the function call to pass in the server connection to use. This makes the function more flexible, because I can add new servers to the mix and just pass in the variable for the one I want to use. The other benefit is that in eliminating the global, this function is now finally completely self-contained, making it that much easier to test and fix.

Lesson Learned
Globals can be useful, but will make it harder to properly test a function, and complicates matters if the function that uses them is widely used and has to be changed.

Choose carefully how to use them.

WordPress - Entries (RSS) and Comments (RSS) - © 2011 Ben Dauphinee