November 23, 2017

Flashing NodeMCU Firmware

Filed under: Electronics, Microcontroller, Software Development, Uncategorized — fandigunawan @ 4:27 am

After compiling the firmware, I need to upload the firmware manually. The tool required to flash the board (on Windows) can be obtained here, and then select Download.


You will need WinRAR or 7-Zip (free) to extract the rar archive. Double click the exe file and select ESP8266 Download Tool


You need to set the correct Crystal Freq, SPI Speed, SPI Mode and Flash Size (please check the datasheet of your board). The default setting Crytal Freq 26Mhz, SPI Speed 40Mhz, SPI Mode DIO and Flash Size 32 Mbit is just fine on my board. The next is to select the firmware and set the address to 0x0. The COM port needs to be selected as well, if you have not installed the USB to Serial driver please check the manufacturer website or download the driver manually. I found out that there are several variants of USB to Serial chip : CH340, CP2102 and FTDI. Well, you can google it to download the driver.

Then, press start to download the firmware and voila, you get yourself new updated firmware



Espressif ESP8266 Compiler on Windows 10 for NodeMCU

Filed under: Electronics, Microcontroller, Software Development, Uncategorized — Tags: , , , , — fandigunawan @ 3:59 am

I got a new board to play with, it is a WiFi board that is programmable so that I will not need extra Arduino or other development board that will increase complexity or cost. The WiFi board is NodeMCU, it has GPIO, SPI, I2C, ADC and many more features on it. As the board is open sourced both in hardware and software terms, you may visit their github page to see the whole development package. The board’s price is quite cheap, well in Indonesia I got it for about 5USD.


NodeMCU board is preloaded with default firmware where you can code directly using Lua script. For Lua documentation of the board please visit user manual page  or clone the firmware source code and read the documentation.

The problem arose when actually not all of the modules was built into default firmware (besides, the firmware is pretty old 1.4 compared to the current version 2.1). Therefore, I need to compile the firmware by myself. There are several ways to compile the firmware :

  1. Online build service (easiest) where you can choose which modules to be embedded into the firmware and then after the build process is completed the link to the firmware will be emailed back to you
  2. Linux Docker Image
  3. Linux build environment which requires you full fledged Linux OS
  4. Linux on Windows (which will be covered here)

To be able install Linux subsystem on Windows there are several prerequisite :

  1. Windows 10 version 16215 or higher
  2. x64 machine

Go to Run and type Appwiz.cpl select Turn on Windows features on or off. Check Windows Subsystem for Linux


Then reboot the computer

Afterward, go to Microsoft Store and search Ubuntu


Select Ubuntu and InstallCaptureMSUbuntu

Then find the Ubuntu menu on your start menu.


Execute the following lines:

sudo apt–get update

sudo apt-get install  build-essential zip gdb git vim make unrar autoconf automake
bison texinfo libtool gcc g++ gperf libc-dbg ncurses-dev expat flex help2man
lua5.1 lua5.1-doc luarocks srecord python2.7

for m in bitlib luafilesystem md5 luaposix luasocket; do sudo luarocks install $m; done

git clone

You need to change your directory to your firmware source code in my case nodemcu-firmware-2.1.0-master_20170824

cd nodemcu-firmware-2.1.0-master_20170824

After cloning the latest firmware you need to setup the compiler

luarocks install luafilesystem

tar -Jxvf tools/esp-open-sdk.tar.xz

export PATH=$PATH:$PWD/esp-open-sdk/xtensa-lx106-elf/bin

lua tools/cross-lua.lua || exit 1

To select which modules to be selected or deselected, you can change app/include/user_modules.h files. Uncomment the module if you think it is not necessary.

To enable TLS support check app/include/user_config.h and uncomment CLIENT_SSL_ENABLE

There are 2 version of firmware, one with floating number support and one with integer number. If you are dealing with floating number the float firmware is the correct choice.

Then you may compile the firmware using the following command

Float firmware

export PATH=$PATH:$PWD/esp-open-sdk/xtensa-lx106-elf/bin

export BUILD_DATE=$(date +%Y%m%d)

make clean


cd bin/

srec_cat -output nodemcu_float_$BUILD_DATE.bin -binary 0x00000.bin -binary -fill 0xff 0x00000 0x10000 0x10000.bin -binary -offset 0x10000

The build result will be in bin/nodemcu_float_$BUILD_DATE.bin

Integer firmware

export PATH=$PATH:$PWD/esp-open-sdk/xtensa-lx106-elf/bin

export BUILD_DATE=$(date +%Y%m%d)

make clean


cd bin/

srec_cat -output nodemcu_integer_$BUILD_DATE.bin -binary 0x00000.bin -binary -fill 0xff 0x00000 0x10000 0x10000.bin -binary -offset 0x10000

The build result will be in bin/nodemcu_integer_$BUILD_DATE.bin

There you go the firmware that you need (integer firmware)


I will post further about how to flash and create the first “hello world”program

Further readings:

September 22, 2009

Panduan Menggunakan JTAG Debugger untuk Atmel AVR

Filed under: Microcontroller — Tags: , , , — fandigunawan @ 7:03 am
Ditautkan dari laman asli :

June 18, 2008

HD44780’s stdio bind for WinAVR

Last time I found out that stdio.h functions is very useful but then it is lack in interfacing. Therefore while I’m doing my project with HD44780 (LCD with 16×2 characters) it is necessary to bind the LCD functions to stdio.h such as printf() function.

The result of an example : printf(“Line1\nLine2”);

Download the code here :

LCD Nokia 3310 (PCD8544) Driver in WinAVR(avr-gcc)

LCD Nokia 3310 is widely known to be monochrome graphic LCD targeted for embedded devices. It is a 84×48 pixels LCD that can be interfaced trough SPI protocol. This is the detail of the LCD’s pins configuration.

Taken from :

The driver is targeted for avr-gcc or WinAVR.

In case you need to recompile to suit your need, please download the following tools :

This design is targeted to be clocked at 4 Mhz, you may change it by modifying makefile or change the configuration of clock in AVR Studio. You can use avrprog or Pony Prog to program your fuse bits (CKSEL) or you may recompile the code to suit your clock speed.

New version :

0.2.6 rev 1 (new)

A silly mistake I made in header file. Please update your version 0.2.6 to 0.2.6 rev 1.

* + Header file (pcd8544.h) PIN definition fixed

0.2.6 (dont use this)

* + Optimization using Memset and Memcpy
* + Bug fix and sample program reviewed
* + Commented <stdio.h>

Many thanks for Jakub Lasinski for code review and suggestions.


Changelog from version 0.2.4

* Version 0.2.5 ( December 25, 2008 ) x-mas version
* + Boundary check is added ( reported by starlino on Dec 20, 2008 )
* + Return value is added, it will definitely useful for error checking

0.2.4 rev 1

Changelog from version 0.2.4 :

* Version 0.2.4 revision 1 ( December 25, 2008 )
* + Some of boundary checking added (reported by starlino) and this is actually as a part of version
* 0.2.5 but I think i need to add it to this version also.

Old version

Note : If you find out my code working in your design please let me know about it.


Generating hex from BMP using BMP2HEX by Jakub Lasinski :

You will need .NET framework 2.0 to use this application.


As a request from AGA33, I have posted the picture of the project, schematic as well as the project source code of my thesis (yes, my thesis using old version driver).

The project was clocked using internal oscillator at 4 Mhz, see AVR datasheet regarding to internal clock setting.

The corresponded source code of my thesis.

[Updated May 3, 2009]


Many thanks to : for awesome PCD8544 picture. Thanks for visitor who told me about this picture credit. Actually I don’t remember actually where I picked the picture since it has been more than a year ago and I used Google image search engine. Actually I don’t remember removing the label from the image but it is fine for me. If you have any problem with my post or project please kindly tell me, I can’t do anything right without your feedback. Thanks.


January 16, 2008

My Favorite Compiler and Programming Language for Microcontroller

This is the list of my favorite compilers and its language for microcontroller programming.

AT89x51 (8051 family)



Microchip PIC




Atmel AVR




Since I don’t really like BASIC, so I did not mention any BASIC compiler for microcontroller.

My favorite microcontroller is Atmel AVR. It is pretty cheap for hobbyist like me and it has massive features.

Freeware   Freeware

Best choice  Fandi’s best choice

Search for reference:

Atmel AVR
AVR C Compiler
Buy Microchip PIC
Microchip PIC C Compiler
Microchip PIC Assembler
Atmel 8051
8051 C Compiler
8051 Assembler

Cryptography in Microcontroller

Filed under: Microcontroller, Security — Tags: , , — fandigunawan @ 8:21 am

One of my junior at President University, Edi Permadi finally released his works on the net about en/decryption and hashing method for PIC16F84. I personally like cryptography as well as its implementation in hardware (microcontroller or IC design). His works which already published are :



Implementing Simplified DES using PIC16F84

Direct file download :

Implementing MD5 using PIC16F84

Direct download:

Implementing Simplified DES using EEPROM

Direct download

Simplified DES Simulator

Direct download :

To open files above you will need WinRAR or  7-ZIP (recommended)

My comment :

It is a very interesting implementation, however NIST has chosen Rijndael to replace DES. I hope in the future he will be able to implement Rijndael in microcontroller or FPGA.

MD5 is no longer secure, it has collision. SHA1 is much better.

Links :

December 28, 2007

Idnaf.AVRdude.FE : Free AVRdude Front End

Filed under: Microcontroller, Software Development — Tags: — fandigunawan @ 8:54 am

During developing hardware for my thesis, I found out that Pony Prog is wasting my time (it does not support profile keeping and I need to reconfigure device every time I use this application). So I use AVRdude to flash and to read my Atmel AVR microcontroller. Since AVRdude is CUI, I need to make a better GUI for it and providing mostly needed feature: profile. This application will display itself in the right-corner tray and easily used. Try it.

Screenshot :

Option box

When right-click in the tray

This application was completely written in C# (Visual Studio 2005) and you will  need .NET framework 2.0 to run the application.

System requirement :

  • GiveIO.sys (included) for LPT access

License : please see licensing page

In the following link I uploaded also the source code + binary.

Version 0.2.1 [Please upgrade to this version]

Source Code :
Dependency files (Lib-USB, GiveOI.sys and AVRdude):

Version 0.2.0

Source Code :

Version 0.1.0

Source Code :

Links :

December 2, 2007

Code Optimization for Your Program

Filed under: Microcontroller, Misc, Software Development — Tags: — fandigunawan @ 6:57 am

A few weeks a go, I tried  to make a program in WinAVR for AVR ATMega8 for driving Nokia 3310 LCD (pcd8554). The driver which I wrote is actually big (what the heck) 28% of 8kb. This is only for the driver without other functions that I will implement soon. Hmm I need something to get rid that fatty code. The thing that I always remember is knowing your compiler and source code written. The PDF I read was taken from Even this PDF discussing about source code optimization for PC, IMHO both PC or microcontroller is the same thing except its circumstances.

IMHO, compiler will do their best part of creating a program (binary), however the other part is programmer himself. The quality of a code will directly impact to program performance and size.

There are two things which could be optimized:

  • Speed
  • Size

For example, in my case I need a medium performance but with very best code size. Actually, I could optimize the code by putting parameter into compiler. However, it is not good enough for the program. So, code optimization is the thing that I really should do.


June 14, 2007

MUTEX is Finally Finished

Filed under: Microcontroller, Project — fandigunawan @ 8:44 am

MUTEX is my project for Embedded System Design, it stands for Multipurpose Temperature Controlled System. The final report can be found here.

Blog at