AVR electronic hardware

Wireless Arduino thermometer with data logger

There is a bunch of stuff in my closet, so it requires only time and appropriate mood to build some hardware device. And there is a summer around and weather is rather hot, so it’s not a surprising idea to build a thermometer.
DS1820 is a great thermometer and I started with it, but I have a spare HDPM01 barometer module with built-in thermometer, so let’s use it.
rfm-hdpm01-pinout read more »

Lego soul

Nice birthday gift

It’s well known that I’m a Lego fan. So I’m very happy to add such a beautiful plane to my Lego collection.
20160710_165657
Read more to see functions animation. read more »

git linux

Space efficient source code storage

kernel-zip-src

During implementation of DistTest I faced with necessity of building a lot of different linux kernel versions. As a first solution I chose downloading archives from kernel.org for each used version. But I soon realized that about 1000 versions of sources with size 0.5-1GB each would consume a lot of disk space. It’s also impossible to build kernel with exact commit precision using this approach.
Set of base versions with corresponding patches can save disk space, but uses a lot of random I/O during applying patches, so it’s slow on HDD and consume finite rewrite resource of SSD. Temporary nature of sources leads to conclusion “use tmpfs”. But aufs offers much less RAM consuming method – store in RAM only diffs.

read more »

CPU hardware

Single threaded performance got stuck

I fell in love with md5 hash algorithm because it can detect some very interesting characteristics of system which I want to benchmark. Almost all computations which need to be performed during computation of md5 hash sum are lying in critical path. It means that it’s almost impossible to parallelize md5 hash sum computation. And I’m not talking about execution in multiple threads, but about instruction level parallelization(superscalar and vector computing). So this feature excluding any new modern tricks used in CPU cores(like out-of-order execution and specialized instruction sets) out of equation and makes it perfect single thread benchmark.
Let’s see some numbers:
Calculate md5(10GiB of zerroes) on i5-760(Turbo frequency: 3.33 GHz, launch date Q3’10)(with Ubuntu 14.04)

And then do the same on i7-6700(Turbo frequency: 4.0 GHz, launch date Q3’15)(with Ubuntu 15.10)

So we have 140 and 155 MB/s per GHz respectively. It is 10.7% performance boost after 5 years of CPU evolution. And it looks so frustrating.
p.s. Yep, I know that CPU now much smarter than 5 years ago and have rich set of specialized instruction sets(like AES-NI which is responsible for +2200% ghash calculation speed). But any software developer should be ready for that fact that unparallelizeable algorithms execution will not become faster for even a bit in near future.

perl programming

Selfmade dyndns

Dyn.com stopped providing free dyndns hosting some time ago. It were sad news.
However most necessary functionality can be implemented in 70 lines of code.
To dynamically update dns records we must find a way to:

  1. get current ip
  2. update DNS record
  3. schedule script for execution

1. Getting current ip address

Many ISP use NAT for security and money saving reasons. Also NAS used in routers. So, to get your IP address you need to ask your IP address from service located outside your network.
For example internet.yandex.ru web page ask resource http://ipv4.internet.yandex.ru/api/v0/ip to determine IP address. So, let’s use it.

2. Updating DNS record

Yandex provide API for DNS records management for domains parked in yandex. API reference should be located here but link is currently broken :-(. UPD: API reference.
In two words you should send POST request with token in header and data in request’s body to https://pddimp.yandex.ru/api2/admin/dns/edit url.
It should looks like following snippet:

3. Scheduling dns records updating

Use the cron, Luke 🙂 I mean that adding following line to cronjobs would be a simplies way to schedule updating of our dns records:

That’s all. Complete script on github.

CPU hardware power

Few words about power management

Not so long time ago I’ve faced with problem: on the same linux distributive some machines use Inte Turbo Boost but some others didn’t.
So… To investigate this problem I’ve read enough article about power management and want to summarize key aspects below.
Holy Grail of power management is ACPI(Advanced Configuration and Power Interface). It describes sleep(Sx), processor(Cx) and performace(Px) states.
Performance states came to replace legacy throtling(Tx) states.

  • S5(“Soft-Off”) All hardware is in off state.
  • S4(“Suspend to disk”) S5 + bootloader can determine this state + WOL available
  • S3(“Suspend to RAM”) RAM state preserved as well as S3 capable devices
  • S2(“Standby”) Almost the same as S3
  • S1(“Power On Suspend/Stopgrant”) All power on, but Hard Drives and not S1 capable devices is in off state, CPU is stopped.
  • S0 The system is turned on. Cx states is S0 substates
    • C3(“Sleep”) cache not preserved
    • C2(“Stop-Clock”) all preserved but clock is off
    • C1(“Halt”) all preserved but CPU do nothing
    • C0 is operating state. Px states is C0 substates
      • Pn Minimum frequency
      • P1 Maximum base frequency
      • P0 TurboBoost enabled

So… About TurboBoost issues solution. It was just a BIOS bug(or feature? Who knows?) that doesn’t moved cpu to P0 state on some boards and does on another.

programming

Buzz words collection

My collection of programmers buzz words. I think it will be useful for beginner programmers and Software Engineering students. Will be actively replenished.

Bumblebee_Man

Principles

  • Defensive programming
  • KISS – Keep it simple, stupid
  • DRY – Don’t repeat yourself
  • YAGNI – You Ain’t Gonna Need It
  • ACID – Atomicity Consistency Isolation Durability
  • Inversion of control
  • Uniform Access Principle
  • Law of Demeter
  • SOA – Service-oriented architecture
  • GRASP – General Responsibility Assignment Software Patterns
  • SOLID
    • Single responsibility principle
    • Open/closed principle
    • Liskov substitution principle
    • Interface segregation principle
    • Dependency inversion principle

read more »

linux

Yet another security note. Hardlinks.

Let’s imagine that you have a bunch of files(with default mode “rw-r–r–“) and you configured automatic or performed manual hardlink based backup of them.
Well…
Then you moved one of these files to “secured” folder, that have strict rights (“drwx——” for example).
Before adding some confidential information to this file it was good idea to change file permissions to more strict one. But it is not clear how important it is because no one but owner can access file located at “secured/file” when “secured” folder have “drwx——” rights.
Well… Let’s preserve old permissions if changing of them is not necessary.
But what about hardlink to file saved in usual folder? Oh yes, file located at “usual/file” still can be opened by everyone.
Conclusion:
– You must remember about all hardlinks of your files when you think about security.
– Creating hardlinks by inode and opening file by inode denied by security reasons.

programming

Some weekend’s madness

I’ve just tried to follow intellij idea’s manual and develop some useless plugin. And now my plugin can display “Hello world” program on perl.
Screenshot from 2013-08-19 00:05:08
You also can view this madness on github.
UPD1. Some new lexical constructions support added.
idea

AVR electronic

Implement CPU in FPGA. Core SomeAVR on verilog

In this article I try to talk about implementation part of CPU that can execute instructons subset of original AVR core. It’s only preview and can be use for academic using only. Because most useful programm that this CPU can execute is LED blinking 🙂 You can view this in following video:

Here right 8 LEDs indicate value of register R20. Left 8 LEDs – value of IP(PC). read more »