Showing posts with label firmware. Show all posts
Showing posts with label firmware. Show all posts

Saturday, October 24, 2015

One minute tutorial: Getting started with a fresh NodeMCU ESP8266 (direct from eBay)

The NodeMCU / ESP8266 is a ridiculously cheap ($2) micro-controller that can talk to an 802.11N wireless network. This device is the herald of the "Internet of Things."

If you buy one on eBay, chances are it will NOT be flashed with NodeMCU firmware (it speaks Lua). This understandably confused the crap out of me. So, this serves as a guide to those running Manjaro (Arch) Linux:

  1. Download NodeMCU firmware
    "integer" versions will NOT understand floating point arithmetic, but save on system resources.
  2. Install minicom
    pacman -Ss minicom
  3. Install esptool from the AUR:
    yaourt esptool-git
  4. Make sure your Linux box recognizes the device
    tail -f /var/log/messages.log
  5. Plug in the NodeMCU device. You should see:
    kernel: usb whatever: ch341-uart converter now attached to ttyUSBX

    ch341-uart converter detected

    If this didn't happen, you cannot proceed and must troubleshoot.
  6. Flash the firmware. Make sure you have permission to read and write to the device in the command below. When in doubt, run as root:
    esptool.py --port /dev/ttyUSBX write_flash 0x00000 nodemcu_whatever.bin
    where:
    X corresponds to the device from the log file above, and
    nodemcu_whatever.bin corresponds to the firmware file in step 1.
  7. Unplug the USB cable after the flash command from the previous step is completed, and plug it back in.
  8. Fire up minicom, and talk to the board at 9600 baud:
    minicom -D /dev/ttyUSBX -b 9600
  9. Press the "enter" key a few times. In response, you should see:
    >
    >
  10. Try "hello world":
    > print ("hello world")
    hello world
    >

  11. Now you can configure wireless:
    > wifi.setmode(wifi.STATION)

    > wifi.sta.config("SSID", "PASSWORD")

    > ip, nm, gw=wifi.sta.getip()

    > print (ip, nm, gw)
    this   is   amazing
  12. Do some interesting things!

Monday, December 9, 2013

Creating USB disk images from .iso images in order to update firmware on old devices

I recently needed to update the firmware on an older Seagate hard drive. Seagate only offered a .iso image for me; however, I don't have a CD-ROM available.

Upon examination of the contents of the files stored inside of the .iso disk image, I didn't find anything that looked like a DOS executable; however, I did find an .ima file -- several megabytes in size.

This .ima file turned out to be another disk image that Seagate loaded using a tool called "Bootable CD Wizard" (or BCDW). I deduced that the El Torito bootable image in the .iso was using BCDW to load the .ima file into memory and "chain-load" the .ima file.

In order to make my bootable flash disk, I downloaded a FreeDos 1.1 image, and copied it directly to my USB device using the Unix dd command (note that my USB flash device is /dev/sdb). Don't accidentally overwrite something important by making a typo!
dd if=FreeDOS-1.1-memstick-2-256M.img of=/dev/sdb bs=1M
I then unplugged and plugged in the USB disk, and extracted the contents of the .iso file into my USB stick's FreeDOS partition with the Gnome Archive Manager (aka file-roller). This left the .ima file on the root directory of my USB stick's filesystem.

The trick was to figure out how to "chain-load" the .ima file, and I accomplished that by editing FreeDOS' syslinux.cfg file. Here's a snippet from the configuration file with the apropos section highlighted:

say Press ENTER to boot FreeDOS, or choose from these alternatives:
say ---------------------------------------------------------------
say :    fdos :: FreeDOS 1.1
say :    odin :: Boot ODIN 0.6 floppy disk image (tiny FreeDOS)
say : memtest :: Run Memtest86+ 4.20
say :      di :: Upgrade
say ---------------------------------------------------------------
say Example: To boot Memtest86+, type "memtest" and hit Enter.



label di
    menu label di upgrade
    linux /img/memdisk
    initrd /HE-CC35.ima


label fdos
    menu label fdos - Load FreeDOS 1.1 from USB flash drive
    com32 /fdos/bin/chain.c32
    append freedos=/fdos/bin/kernel.sys
In the boldfaced "di" (short for disk image, you can choose any word as the label) entry above, I instructed syslinux to load memdisk, which is a utility for booting floppy images. The initrd command tells syslinux to load a disk image into RAM.

Saving my work, I plugged the flash drive into the system that needed the firmware upgrade, and typed in di at the syslinux prompt in order to execute the corresponding menu entry.

Hopefully this is enough to help those of us with Seagate drives to get things working!