Check out the new blog at http://linuxehacking.ovh , this one will no longer be updated

martedì 18 agosto 2015

Calibrating YIHUA 898D soldering station

When you buy an 898D soldering station there's a very high chance that it is completely uncalibrated, leading to burnt/damaged parts and other kinds of problems since most of the times it is calibrated to give much higher temperature.

For that procedure you are going to need:


  • A cross-head screwdriver to open the 898D
  • A flat-head screwdriver at most 2 mm wide to rotate the potentiometers
  • A thermocouple thermometer
  • An IR thermometer
First of all , set both temperatures at 230 C° and disconnect the power cord because part of the board is directly connected to mains
To open the soldering station , remove the four screws around the front panel
Once removed the front panel you should have a board like the one below:
That board has two trimmers, one is to adjust smd rework gun , the other one is to adjust soldering iron temperature.


First start with hot air gun, after you made sure that no metal is touching the board and you are not touching the board, plug the power again, and heat a piece of paper with the hot air gun.
Place on one side of the paper the hot air gun, on the other side an IR thermometer.
If you read 220-235 C° it's ok, if you read temperatures like 260 or 280 C° or 200 C° you definetely need to adjust it.
To do that take a small flathead screwdriver and with the soldering station disconnected from mains if the air is hotter than it should be , rotate like 1-2 turns the potentiometer counter-clockwise, otherwise rotate it of the same amount clockwise, and plug again the power and check if the temperature is in an acceptable range, if not repeat the above step with smaller adjustements.

When you have done with hot air gun start working on the soldering iron, place some excess solder on it's tip and put it in contact of a shielded thermocouple


Let it stay like 3-4 mins and then check the temperature reading of the thermocouple, if it is less than 210 C° or more than 240 C° you need to calibrate that too, proceed as follows:
  1. If temperature is higher than it should be, rotate like 1/4 of turn the soldering iron potentiometer clockwise ( contrary to the hot air gun one ), you should do that with the power connected so BE VERY CAREFUL to not touch any part on the board except the potentiometer with the screwdriver when doing that.
    If the temperature is lower than it rotate it 1/4 of turn counter-clockwise.
  2. If temperature was higher than needed, blow some air at the thermocouple+soldering iron tip to lower the temperature and wait for it to rise
  3. After like 2 minutes, check if temperature still needs adjustement, if yes repeat from step1 with smaller rotations.


I'm using a pid controller as a thermometer because it's the only thermocouple based thermometer that i have at the moment

After that reassemble everything and you are done.


mercoledì 22 luglio 2015

How to easily test an N-CHANNEL or P-CHANNEL MOSFET using just a multimeter

You should have noticed that most multimeters come with a function to test BJT transistors, but none has a function to test the today's more common MOSFETs

Here are the steps to test an N-CHANNEL mosfet with just a multimeter ( applies to P-CHANNEL too, just swap + and - ), of course the MOSFET has to be disconnected completely.


  1. Make sure you are not wearing shoes and so that you don't have any electrostatic charge, FETs are very delicate to ESD.
  2. Now touch with your finger both Gate and Source terminals, this will make sure that the gate is uncharged
  3. Put your multimeter in diode/continuity test mode ( beep mode )
  4. Touch with the negative lead the source pin, and with positive lead the drain, it should not beep and show > 999 ohm, if there's current flowing, after making sure again that gate is discharged, the MOSFET is damaged.
  5. Touch with the negative lead the source pin and with positive lead the gate pin, no current should flow, if current flows it means that the oxide layer between gate and substrate or N junctions has been broken by a gate-source overvoltage or ESD, trash the mosfet if that is the case.
  6. Now WITHOUT touching the gate terminal at all, touch the drain pin with positive lead and source pin with negative lead, you should get the multimeter to beep and a very low resistance reading
Finally, before trashing any mosfets, make sure that the method works with most of them using your multimeter ( there may be some multimeters that use too low voltage in continuity test mode and thus not reaching Vt threshold of the mosfet ).
To avoid ESD damage always store your MOSFETS with all pins joined together using aluminum foil or copper strands.

mercoledì 15 luglio 2015

Installing OpenWRT on SITECOM WL-326

The SITECOM WL-326 is an ethernet+3g router featuring 300 Mbps wireless and an usb port to connect a 3G modem.

This device is not officially supported by OpenWRT and not very common, so there's basically zero info on it at the moment.



First thing is to find out which SoC it uses, since it is covered by an heat spreader, best idea that does not involve the risk of destroying the board is connecting an USB-TTL adapter to the serial port which is visible on the photos.



Luckly contrary to most cases, the PCB has already written on it which pins are RX,TX,GND, so it's just matter of soldering a female o male strip header, and connect it to the adapter.

Serial port settings are 57600 8N1, and when connecting the power to the device, it's immediately visible that it is a rebrand of another device, the ESR-6670 http://wiki.openwrt.org/toh/engenius/esr6670.
Still no luck, it's not supported either, but at least now we know what SoC it uses, which is Ralink 3052.



Now the tricky part, bootloader only shows one option, contrary to most supported routers

Board: Ralink APSoC DRAM:  32 MB  1*32 MB
============================================ 
ASIC 3052_MP2 (Port5<->None)
Product Name: ESR-6670
SDRAM CAS = 3(d1835272) 
============================================ 

Please choose the operation: 
   1: Load system code to SDRAM via TFTP. 

So the only option is just to try it, worst case scenario if it goes wrong we'll have to reverse engineer the (likely) jtag connector visible on the photo.

This command will ask you some parameters, first one is the router IP, just hit enter ( leaving it as it is )
second one is the TFTP server IP, a default one will be shown.

Board: Ralink APSoC DRAM:  32 MB  1*32 MB
============================================
ASIC 3052_MP2 (Port5<->None)
Product Name: ESR-6670
SDRAM CAS = 3(d1835272)
============================================

Please choose the operation:
   1: Load system code to SDRAM via TFTP.

1: System Load Linux to SDRAM via TFTP.
 Please Input new ones /or Ctrl-C to discard
        Input device IP (192.168.99.9) ==:

        Input server IP (192.168.99.8) ==:

        Input Linux Kernel filename (40.7z) ==:rd.bin
Using Eth0  device
TFTP from server 192.168.99.8; our IP address is 192.168.99.9
Filename 'a.dlf'.
Loading: *
ArpTimeoutCheck
Got ARP REPLY, set server/gtwy eth addr (54:42:49:5f:d3:1b)
Got it
T #
 first block received

Now connect an ethernet cable between a LAN port and your machine and ifconfig it to the router ip address

ifconfig eth0 up 192.168.99.8

or something like that.

Now you can hit enter, and then it will ask the linux kernel filename, which is WRONG, that's not the linux kernel filename but the uImage filename.

Now the hard choice, finding a similiar enough device to flash this one with, and cross finger that it does not blow up, i've choosen the wr512 because it has too an usb port and an ethernet so, it's worth trying.

So download http://downloads.openwrt.org/chaos_calmer/15.05-rc2/ramips/rt305x/openwrt-15.05-rc2-ramips-rt305x-wr512-3ng-4M-initramfs-uImage.bin and rename it to something sane, like /home/dev/rd.bin

Now, start a tftp server, quickiest way without spending 15 mins configuring with xinetd or crap like that is


dnsmasq --enable-tftp --tftp-root=/home/dev -d

If it fails because of port already in use, append -p 3244

If it started succesfully, enter the choosen filename ( rd.bin or whatever it is ) on the serial console and hit enter, now it should flash it and reboot, but you are not done yet, because this is an image designed to work only on RAM , so any config change will NOT be saved.

But since you should have an openwrt console now and the LAN ports configured to 192.168.1.1, ifconfig your machine's interface to 192.168.1.2.

Download http://downloads.openwrt.org/chaos_calmer/15.05-rc2/ramips/rt305x/openwrt-15.05-rc2-ramips-rt305x-wr512-3ng-4M-squashfs-sysupgrade.bin


Notice that now the downloaded file has "sysupgrade" in it and not initramfs-uImage.

Now from the serial console do

scp yourmachineuser@192.168.1.2:/home/youruser/openwrt-15.05-rc2-ramips-rt305x-wr512-3ng-4M-squashfs-sysupgrade.bin /tmp/

Once done ( and completed succesfully of course ), do

sysupgrade -v /tmp/openwrt-15.05-rc2-ramips-rt305x-wr512-3ng-4M-squashfs-sysupgrade.bin

It will take like a min or two and then reboot automatically, after the reboot you will have the router at 192.168.1.1 again.

Now login to LuCI interface, go to Network->Switch and you should see two vlans configured , vlan1 which is lan configured with the first port untagged and vlan2 which is wan configured to some other port untagged.

Now change on vlan1 the first port ( left to right ) , to off , and on vlan2 the first port ( same as vlan1 ) to untagged, and click save & apply.
That's because the router of which we flashed the firmware has the switch connected differently.



That's it now you are done , you can configure wireless and other stuff, just forget about 3G unless you replace flash memory, because it is likely that there's not enough space on flash ( unless you build a version without LuCI and with 3g and then configure with CLI ).

Update: It's possible to install 3g packages and still have 52 kbytes free, not tested because i don't have an USB 3g modem handy

domenica 28 giugno 2015

Converting movies to 60 fps on linux ( with wine )

You may have heard of SVP project , if not visit their website http://www.svp-team.com/ .

SVP in a first pass calculates the motion vectors for the frame ( the direction and velocity that every object in the video has moved with ), and then on the second pass it generates intermediate frames.
With that technique it can generate the intermediate frames between each frame of the original video, like when going from 24fps to 60fps.

As you have seen SVP is only for windows and there's not any guide to easily use it under Linux, but it can be used under linux too and it's not much difficult.


!!!IMPORTANT : The method shown here does not work with ubuntu because of some unknown wine build bug 

First of all, download the archive here https://tizbac.ovh/owncloud/index.php/s/RS28NIrJVIR4zfo , install wine and ffmpeg.

Unpack the archive in your home directory , i.e you should have at the end /home/yourusername/60fps

then do

wine wineboot
ln -sf $HOME/60fps $HOME/.wine/drive_c/60fps
wine AviSynth.exe

Follow the instructions of the installer( just click next ,next... finish)

Then edit script.avs and change FFMpegSource2 filename to your source movie if you want to specify a path outside drive_c , /a/b/c becomes Z:\a\b\c and save it.


Now you can launch x264:


wine x264.exe --preset veryfast --bitrate 3500 --zones 290367,290367,q=40  --sar 1:1 --output "Z:\the\destination\path" "C:\60fps\script.avs

If you need to , adjust bitrate and preset to suit your needs.

Now it should start interpolating and reeencoding the video, it will take a lot of time if you don't have an highend machine, but x264 is heavy, nothing can be done about it.

After that command you should end up with the interpolated video without sound, to re-add sound you can use ffmpeg

ffmpeg -i x264output.mp4 -itsoffset 0.4 -i originalfile.mp4 -c:v copy -c:a aac -strict -2 -map 0:v:0 -map 1:a:0 outputfilewithsound.mp4

There too, if needed, adjust itoffset ( audio delay offset , interpolation seems to add a delay , still have to figure out why ).

After that you should have the movie with audio and 60 fps, have fun!

domenica 8 marzo 2015

A very simple internet of things system to control lights and other stuff

In these days i've worked on how to create a system that allows me to turn on and off lights or appliances at home with minimal cost and complexity, and there it is: https://github.com/tizbac/IoTManager



Each node (ESP-01 ESP8266) with nodemcu firmware and the init.lua script from esp8266 folder of my repository has two outputs and can control two appliances.
A node has commands to retrieve name , unique identifier and current state, and to set the state, all that happens via UDP packet.

At first i tried, especially for discovery purposes to use UDP broadcast packets, but it seems that the module has some bug that makes the reception of broadcasts very unreliable, so at last i resorted to try to send a command to query status for each ip address specified in the subnet, like for 192.168.1.0/24, it would be 192.168.1.1 to 192.168.1.254.

The server which runs on an ARM board like a raspberry or a beaglebone takes care of the authentication of the clients from the internet ( the ESP8266 modules have no authentication , they rely on the safety of the network, so avoid passwords like "password" or "0123456789" ).

When first started the server creates a self signed certificate to use with HTTPS and a random password, then when the user connects to the webserver from a local ip address a qrcode is displayed to configure the android application.

The QR Code contains the public ip address , the port , the password and the sha1 fingerprint of the certificate, so that even if it is self-signed, it can be verified by the application to prevent man in the middle attacks.

The servers also takes care of enforcing state on the nodes, especially when a packet is lost or when the node for some reason loses power, at each discovery the state is compared and if not equal it will be resent again until the node status matches.

That's it, with barely 200 lines of python and a trivial android app you can safely control your house from where you want.


giovedì 18 dicembre 2014

Asus eeePC 1005PE LVDS Cable pinout

I'm posting this pinout, because it can't be easily found, and using a multimeter it takes a lot to figure out, like it did for me


MB Connector Panel back connector Description
1 2 3.3VDD
2 4 EDID eeprom power ( 3.3V)
3 6 EDID eeprom CLK
4 7 EDID eeprom DATA
5 28 VDD_EN ( Active high, 3.3v)
6 30 VLED_EN (Active high, 3.3v)
7 22 GND
8 8 LVDS Channel 0 -
9 9 LVDS Channel 0 +
10 11 LVDS Channel 1 -
11 12 LVDS Channel 1 +
12 14 LVDS Channel 2 -
13 15 LVDS Channel 2 +
14 22 GND
15 17 LVDS Clock -
16 18 LVDS Clock +
17 1 GND
18 5 Backlight PWM ADJ
19 25 Led VCC ( 5V )
20 24 Led VCC ( 5V )


If you are planning to reuse the panel with an MT6820 board, set the panel voltage to 3.3volts , connect 3.3VDD and VDD_EN together, and connect all the gnd pins to gnd too.
About the backlight, for me it worked leaving VLED_EN open ( unconnected ) and ADJ connected to the BL pin of the mt6820 ( brightness , unless i've swapped for error the pins , does not seem to work )

The whole thing will draw about 1A @ 5V, so if you get an Y cable with a switch ( to prevent the mt6820 from powering on too early ), you can run it from two usb ports

The correct jumper configuration for the board is with only A closed , and all other open

venerdì 19 settembre 2014

How to do transparent bridging / repeater on OpenWRT with an Atheros card

What you need

  • An access point running OpenWRT and supporting 4 address mode ( WDS )
  • Another access point running OpenWRT and supporting both multi-ssid and 4 address mode ( or only 4 address mode if you want wifi->ethernet bridge )

Setting up the main access point

First of all , you need to setup the main access point , to do that , once openwrt is up and running, login to the web interface and go to "Wifi" section



Then , on the Wifi page , if needed remove any existing SSID and then add a new one
Once you have done here, click save and apply to create the new access point

Setting up the repeater

As with the main access point , login and go to Wifi section, remove any existing SSIDs / Client and then click "Scan"
Once you get the scan results( it can take up to 45 secs ) , select the network you are interested in , and click "Join network"
Once done click submit
When done with changing to client (WDS) and if needed setting up security , click "Save" , not save and apply , not yet
Now you have to create an access point ssid , to do that repeat the steps on the main access point , but when selecting the network , instead of choosing lan , choose repeater or whatever you entered when creating WDS Client interface , and the click Save and Apply and enjoy your openwrt based repeater