CMake + atom + .clang_complete

A few months ago I moved from emacs to atom that looked like a more modern replacement. Most important for me – it had awesome CMake code completion that was very good. I soon made use of automplete and lint with clang. Both were good, but needed a .clang_autocomplete in your project root to work properly. Apparently if your project file get a bunch of compiler flags from the build-system managing this file by hand is not something I wanted, so I ended up with this snipplet in CMake that gets the job done:

message(STATUS "Generarating ${CMAKE_SOURCE_DIR}/.clang_complete")
get_property(dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
file(WRITE ${CMAKE_SOURCE_DIR}/.clang_complete "")
foreach(dir ${dirs})
  file(APPEND ${CMAKE_SOURCE_DIR}/.clang_complete "-I${dir}\n")
endforeach()
string(REPLACE "'" "" CMAKE_C_FLAGS_SPLIT ${CMAKE_C_FLAGS})
string(REPLACE " " ";" CMAKE_C_FLAGS_SPLIT ${CMAKE_C_FLAGS_SPLIT})
foreach(flag ${CMAKE_C_FLAGS_SPLIT})
  file(APPEND ${CMAKE_SOURCE_DIR}/.clang_complete "${flag}\n")
endforeach()

If you use C++ in your project you need to use the CMAKE_CXX_FLAGS variable. This code also has the obvious limitation: If you pass via -D directive options that have spaces – this won’t quite work (e.g. -DRELEASE_CODENAME=”Black Burned Cookies”)

Fun with PCB stencils

When you’re assembling just one or two pieces of your homebrew electronic stuff you never think about how fast the process is. But then comes a moment when you need to assemble 10 or 15 pieces, and it’s still cheaper to do it at home. The process quickly becomes dull as hell, and the brain starts to think of all the ways to speed up the process.

IMG_2531 Continue reading “Fun with PCB stencils”

Doxygen && gh-pages

Github has a cool feature – it allows you to attach html pages to your repo. And if the web pages designer that brings memories of early 00s is somewhat useless – storing doxygen html docs there is a very cool feature.

However we can’t store any history in gh-pages branch. It would be utterly useless and may heavily bloat the repo (especially if you generate a plenty of diagrams with graphviz). So ideally we should:

  • Make a clean branch each time, commit all the docs we’ve generated
  • Do –force push, so that we’d drop everything on the remote side
  • Do it from our development branch, without switching to gh-pages
  • Potentially integrate with CI/Jenkins: Build succeded, unit-tests passed, static analysis okay – bump the docs!

Can be achieved easier than it sounds. Here’s my quick sniplet for this hackery in GNU/Make:

doxygen: 
	-rm -Rfv doxygen/
	( cat Doxyfile ; echo "PROJECT_NUMBER=0.1" ) | doxygen 
	cd doxygen/html;\
	rm -Rfv .git;\
	git init .; git checkout --orphan gh-pages;\
	git add *;\
	git commit -m "documentation-for-gh-pages";\
	git remote add origin git@github.com:MY_GITHUB_USERNAME/MY_GITHUB_PROJECT.git;\
	git push -u -f origin gh-pages

D-Link DNS-327L NAS now mainlined

Achievement

Yep, something like that. Despite huge amounts of rush at work these days I managed to push both patches into mainline linux, so starting from 4.1 and on you can just grab kernel from kernel.org, compile and boot it on the NAS (Yappee!!)

Just make sure you disable cpuidle ‘deep idle’ state. It causes NAS to hang once every few hours and is likely a problem with either hardware or the bootloader (I’m still too lazy to try out mainline u-boot)

echo 1 > /sys/devices/system/cpu/cpu0/cpuidle/state1/disable

//Template for that achivement logo borrowed from here

Pssst, dude! Wanna some secondhand chips?

There are many wonders in electronics land. Even more await an engineer that stocks up at aliexpress to save a bit on his hobbies. Well, I needed a few RTC chips for some prototype hardware, so I picked DS1307. As usual, placed an order at aliexpress. once in a while shit happens .

No, this time they didn’t write ‘sex toy – 3$” on the customs declaration sticker, as they did on a parcel with a dozen of TRIACs a few weeks ago (Or, did I use TRIACs wrong my whole life! Should have asked them for instructions!)

Anyways this time I received some second-hand chips. Packed in a plastic tube, no flux whatsoever, but small solder blobbies are all over the pins. Without unpacking, I’ve made a few pics. Sorry for the quality, but I put my USB microscope somewhere far and my usual camera doesn’t handle focusing on something that close well.

IMG_2508

Continue reading “Pssst, dude! Wanna some secondhand chips?”

How do I ‘cost-optimize’ nRF24L01P ?

I recently got a nice batch of nrf24l01 modules dirt cheap (~55 cent per module). If anybody wondered if you could cost-optimize these modules even more… Well, turns out you can. They won’t be quite working, but who cares? A detailed analysis of what those folks actually ‘optimized out’ is just under the cut.

1100101426251536961

Continue reading “How do I ‘cost-optimize’ nRF24L01P ?”

Debian @ Dlink DNS-327L: The guide

If you’re following my blog, you might’ve read my post about Dlink’s substandard engineering, and how I’ve got debian running on the damn thing. Well, since that time I’ve made a few improvements, namely:

  • Power button’s now correctly rigged as well as the rest of the buttons.
  • Upstream 3.18, 3.19 kernels now works flawlessly and don’t ever freeze. I update kernels with each new kernel release
  • Goodies like Marvell’s DMA engine, mv_xor, watchdog and mv_cesa are all enabled for the win and are working awesomely
  • There’s now a huge guide about ‘cooking’ the damned thing into a useable state in five easy steps. And you are reading it.
  • Power measurements are all there as well!

BIG FAT WARNING: I take no whatsoever responsibility if you screw up your device following these instructions. Proceed at your own risk, use your own head. This will also void warranty, btw.

IMG_20150215_141546

Continue reading “Debian @ Dlink DNS-327L: The guide”

ESP8266: Say ‘hello’ to Frankenstein

Since I’ve got some homebrew development boards ready, it’s time to get hacking.
I stocked on coffee and gave esp8266 SDK a deep dive this weekend. The code is really weird, lots of things are unknown, API is shitty, blobs all around the place. First of all, to make things clear – I’m not going to fix or do anything with AT-command firmware. It sucks. Period. Sucks so much it can’t even prove useful as a reference most of the times. So… we need a replacement.

This is what I’m working on and that is now, after a weekend of hacking is in early alpha stage.

Say hello to Frankenstein Firmware for ESP8266.

Continue reading “ESP8266: Say ‘hello’ to Frankenstein”

ESP8266 and PL2303HX-gpio adventures.

As you might have seen, I’ve made a few projects with PL2303HX, namely that little nifty esp8266 developer board. I plan to dive in esp8266 firmware development soon and my goal will be a nifty mysql client, so that I can run mysql queries via UART! The only bad thing (apart from eeprom never working, and occasional freezes that I’ve later fixed with a 10uF SMD capacitor) – I had to press the buttons to reset the ESP8266 module to bootloader mode. So I’ve made a ‘dark green evil sister’ twin of that red board with a little bit updated schematics:

  • GP0 and GP1 lines are now rigged to reset and bootloader buttons respectively, resistors protect those against logic level conflict.
  • I’ve ditched EEPROM. It doesn’t work anyway. Screw that!
  • Proper decoupling – no more freezes!
  • SMD LEDs on GP0 and GP1.
  • Nice dark greenish design and clear urethane coating FTW!

IMG_2486

Continue reading “ESP8266 and PL2303HX-gpio adventures.”