Wednesday, August 9, 2017

How to unbrick Arduino Pro Micro 3v3 8MHz version

Recently a made a project with 3v3 version of arduino  pro micro. And accidentally uploaded sketch for arduino Micro. After that I got bricked arduino board. It was not recognized by windows, there was problems with usb enumeration(also "device descriptor request failed", "unrecognized device" etc.).
It seems that problem was with wrong bootloader, so I took my USBasp, connected it to arduino board. From arduino IDE selected right board - "SparkFun Pro Micro", selected processor Atmega32U4 (3.3V 8MHz) and tried to burn bootloader. Got an error - "verification error, first mismatch at byte 0x0000 0xce != 0xfe".
Then I tried to flash bootloader from 5V 16Mhz version, and it was uploaded successfully, but surely because of wrong crystal settings board was still bricked("usb enumeration problems").
So, solution for this is very easy, all you need is swap 3v3 and 5v bootloaders and load bootloader as it was 5v version.

To do this go to:
c:\Users\<username>\AppData\Roaming\Arduino15\packages\SparkFun\hardware\avr\1.1.6\bootloaders\caterina\

and find files Caterina-promicro8.hex and  Caterina-promicro16.hex then rename these files so Caterina-promicro8 -> Caterina-promicro16,  
Caterina-promicro16 -> Caterina-promicro8

after that go to arduino IDE, select SparkFun Pro Micro board,
select Processor Atmega32U4 (5V 16MHz),
select programmer "USBasp",
connect board to programmer and hit "Burn bootloader"

After that board was functional again.
Do not forget to rename bootloader files back to original.
If you do not have USBasp you can use another arduino board as programmer,but do not forget that levels must be the same 5v or 3v3 or use level shifters.

Tuesday, February 21, 2017

Fixed names for usb devices in linux

usb devices appear as /dev/ttyUSB<somenumber> devices. When you plug it to another USB port <somenumber> is unpredictable and you always wasting time to figure out what is the right port number for your device.
To fix this, you can create "udev" rules, so every time you plug in your device there will be the same sym link created for that particular device.

Check vendor and product id with lsusb command:

~# lsusb
Bus 001 Device 011: ID 0403:6001 FTDI FT232 USB-Serial (UART) IC 
Bus 001 Device 010: ID 0403:6001 FTDI FT232 USB-Serial (UART) IC 

ok, we have 2 FTDI chips and we can't distinguish which chip is from what device.
Let's check device serial number(we know that it is connected to ttyUSB0):

~# udevadm info -a -n /dev/ttyUSB0 | grep '{serial}'
 ATTRS{serial}=="0000:00:14.0"

Then go to /etc/udev/rules.d and create file 99-usb-serial.rules
~#sudo touch 99-usb-serial.rules

open file for edit and add these line:

SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{serial}=="0000:00:14.0", SYMLINK+="arduino"

Now everytime when you plug in your board it will be accesible via symlink /dev/arduino

~# ls -l /dev/arduino 
lrwxrwxrwx 1 root root 7 Nov 15 20:11 /dev/arduino -> ttyUSB0

~# ls -l /dev/ttyUSB0
crw-rw---- 1 root uucp 188, 0 Nov 15 20:11 /dev/ttyUSB1

Wednesday, October 19, 2016

Ubuntu. Cannot upgrade because of full /boot partition. Freeing some space

If you try to upgrade linux distribution (for example from 14.04 to 16.04) sometimes upgrade fail because of no free space at /boot partition. This happens because there are old kernel installed that are no longer needed. To remove old kernel you shoul issue command like this:

sudo apt-get purge linux-image-x.x.x-xx-generic

where "x" are numbers. so you remove all kernels except one that is used. ( check it with uname -r command). Usually in /boot partition there are many of kernels, so removing them one by one is time consuming operation. To make it more convenient use that crazy long command and wait :)

sudo apt-get purge $(dpkg -l linux-{image,headers}-"[0-9]*" | awk '/ii/{print $2}' | grep -ve "$(uname -r | sed -r 's/-[a-z]+//')")

 It remove all unused kernels from your /boot partition.

Thursday, October 13, 2016

How to check your "external" ip from command line.

Sometimes when you are behind the NAT you need to know what is your "external" IP address.
You can check it from browser(for ex. http://whatismyip.org), but what if you have only command line? Just type in these lines:

nslookup myip.opendns.com. resolver1.opendns.com

do not forget dot "." after first host.

Thursday, October 6, 2016

Install x11vnc on xubuntu 16.04 for remote access

Tight VNC server opens new session, but if you need to connect to active session(like in teamviewer when user see what you are doing) I suggest to install x11vnc.
Installation process as follows:

sudo apt-get install x11vnc -y

next - specify password for remote connections:

sudo x11vnc -storepasswd /etc/x11vnc.pass

now create service unit file:

sudo touch /lib/systemd/system/x11vnc.service

and open it in editor:

sudo nano /lib/systemd/system/x11vnc.service

paste to file:

[Unit] 
Description=Start x11vnc at startup. 
After=multi-user.target
[Service] 
Type=simple 
ExecStart=/usr/bin/x11vnc -auth guess -forever -loop -noxdamage -repeat -rfbauth /etc/x11vnc.pass -rfbport 5900 -shared 
[Install] 
WantedBy=multi-user.target

 now configure service:

sudo systemctl enable x11vnc.service  
sudo systemctl daemon-reload

now reboot and try to connect to x11vnc.

Wednesday, September 28, 2016

How to change product key in Office 2016.

There is no option to change product key in "Add/Remove programs" trough control panel.
Instead of using Control Panel, run command prompt with administrative privileges and run following commands:

to check key status:

For Office 2016 32bit on 32bit version of Windows
cscript "C:\Program Files\Microsoft Office\Office16\OSPP.VBS" /dstatus

For Office 2016 32bit on 64bit version of Windows
cscript "C:\Program Files (x86)\Microsoft Office\Office16\OSPP.VBS" /dstatus 

For Office 2016 64bit on 64bit version of Windows
cscript "C:\Program Files\Microsoft Office\Office16\OSPP.VBS" /dstatus

you'll get installed license details and last 5 character of Product Key.

you can change product key by entering command /inpkey:value for example:

cscript "C:\Program Files\Microsoft Office\Office16\OSPP.VBS" /inpkey:XXXXX-XXXXX-XXXXX-XXXXX-XXXXX

Friday, September 23, 2016

Exchange 2013. Got error 500 when try to login to ECP.

Problem: when trying to access exchange control panel, after entering credentials server returns error 500. If you look to event viewer you find the errors like this:

System.InvalidOperationException: Cannot load Counter Name data because an invalid index 'W3SVC_W3WP' was read from the registry.

Login to OWA is working normally.

Solution: On server run command prompt with administrative privilegies and run command:

lodctr /R

If you get an error, try to run again. After it finished with success,  restart IIS with command

iisrestart

After that try to login to ECP.