Kacang Bawang

My First 5 Minutes on an OpenWRT Router

This article talks about the changes that I like to make away from default configuration on a new OpenWRT installation.

Read more »

Best New Router for OpenWRT ;)

A small note of triumph 🙂

For some time now I’ve been looking for a modern router. Yes, that WRT54G isn’t getting any younger 🙁 But few people are willing to “school” one on what’s the one to get these days (these days = May 2016). So after a long string of “google it” responses, I finally buckled down and did my own research. You wanna know the conclusion? 😉

Read more »

DSL provider blocks 3rd-party modems via MAC filter

About one week ago my internet provider started blocking 3rd-party/user-provided/own DSL modems. The symptom is that the router does not get an IP from the DSL modem, yet all the proper lights on the modem are on. I even called the main office and asked if the were blocking. They said no. But if you run OpenWRT, you can examine the PPPoE negotiation logs and will see that solicitations from the DSL modem are never answered.

One the other hand, if you plug in the provider’s router/DSL combo the connection is quickly established. Here it would be nice to get a wireshark dump of the negotiation, but let’s just check something first. What if we change the MAC address of our WAN interface to match that of the provider’s router? This can be easily done via

Let’s try connecting again. Sure enough, we’re in.

EEPROM for ESP8266

This article describes a small EEPROM emulation library that I wrote for ESP8266. It implements a very simple EEPROM emulation scheme that allows storing 16bit values. Each such 16bit value is found by its 16bit index.

Read more »

ESP8266 SDK: how to debug with gdb

Not long ago, to little fanfare, Espressif (the makers of ESP8266) released gdbstub – a library that allows use of gdb on ESP8266. It works with both non-OS and RTOS SDKs, and works over UART, not JTAG. You get 1 breakpoint for RAM and 1 breakpoint for FLASH. Is this awesome, or what!? Authorship is unattributed, but is believed to have been written by Sprite_tm.

In this post, I will show you how to add gdb support to your project. This example will use the RTOS SDK, but applies just the same to the non-OS SDK.

Read more »

Which allocation scheme does ESP8266 RTOS SDK use?

I wanted to know which memory allocation scheme (heap_1.c, heap_2.c, heap_3.c, heap_4.c or heap_5.c) was used in the ESP8266 RTOS SDK. This is not mentioned anywhere in the docs (I’ve looked as of 1/12/16). What to do?

Let’s just take a look at what is compiled in then.

Actually, this works even with a regular ‘nm’, hehe.

What do we see?

Aha! heap_4.o means heap_4.c was used. ‘T’ means that this symbol is exported.

OpenHAB2 binding architecture

In this article I will walk the reader through the inner workings of an OpenHAB2 binding. It is meant to answer the question of “who calls who and when?”, which invariably arises when one starts working with a new framework. It is a summary of what I had learned while writing the binding for my smart switch. If you are thinking about writing a custom binding from scratch, then this article is for you!

Read more »

ESP8266 512k flash: compiling using RTOS SDK 1.3

Since update from version 1.2 to 1.3 of Espressif’s RTOS SDK, if you try to compile anything targeting a 512kB flash device you get this message:

In this post I will show you how to organize and compile a project to using the RTOS SDK and how to solve the above problem. This post builds on this one, review as necessary.

Read more »

ESP8266 SDK: os_printf() prints garbage, uart_init() doesn’t work…

Espressif SDK provides a function os_printf() for printing to the debug uart. However, when used out of the box it prints garbage. What gives?

Consider a default project with the following in user_main.c.

Compile, run, what do you see? That’s right – garbage. Well, it’s not really garbage, it’s actually outputting “hello world” at the default (non standard) baud rate. Ok, easy enough – we’ll just set the baud rate using uart_init() function from the SDK! Oh, wait… that function is not defined in any header that comes with the SDK… Paging Espressif, please pick up the white courtesy telephone!

That’s ok, there’s an easier way – we will use uart_div_modify() to achieve the same result. Change the hello world to this and try again:

Much better! Hat tip to unfoundbug at this reddit thread.

Old School Methods: Transformer-less Power Supplies

If you’ve read my previous posts you may be aware that I am in the process of trying to build an electronic device in Indonesia. To this end, I’ve tried to find some local talent to help me. I’ve interviewed a couple of people affiliated with an Indonesian appliance manufacturer who has a factory nearby. Ultimately, none of the candidates were a good fit, but I did learn something new, about which I would like to tell you today.

It turns out that it is possible to transform 110/220 VAC to 5 VDC really, really cheaply and without the use of a transformer. Don’t get too excited though – this method is more of a clever hack and is rather unsafe. It is presented here for educational purposes only.

Read more »