Banner

Banner
Ramast
Linux Developer

Wednesday, September 25, 2013

Running MK802 as linux server

The goal:

Installing linux distro on MK802 and it has to
  • Be very light weight
  • Support most USB devices that I might need (Webcam, bluetooth dongle, ...) plus internal wireless lan and video card
  • Support iptables
  • Be easy to install and maintain
  • Has right package repository

First I found this page that offer wide selection of linux distros
http://liliputing.com/2012/07/linux-distributions-that-can-run-on-an-mk802-mini-pc.html

Puppy Linux 

Is very lightweight and can work from memory
That means it won't need to constantly writing on the SD Card which will extend its life.
Also means it will be very fast.
However when I clicked on the link I found that its development has been discontinued.

Miniand Lubuntu 12.04

was my choice  because Ubuntu has very good support for different devices and with Lubuntu I get a light version too.

Turns out Lubuntu didn't support my webcam, I had to download & compile the corresponding kernel modules manually for it to work

After that I found it doesn't support iptables because of missing kernel modules
This time compiling the corresponding modules wasn't enough.
I had to compile the kernel itself. and no matter what I do any kernel I compile fails to boot.

Debian Server


Was my next distro, I downloaded it from this link
http://romanrm.ru/en/a10
and it was really amazing.
extremely lightweight, not so many services, no X11 not even vim!
iptables and my webcam were working like a charm.

only one problem though, I couldn't see anything!
The server doesn't support any graphics card so even installing X11 didn't help. xorg won't start.

I contacted the developer "Roman Mamedov" and explained the problem to him and his answer was:

This is because the image uses a kernel which disables all graphic components
to save RAM (about 100 MB). If you want Mali, you need to replace the kernel
with a Desktop or Video variant from http://romanrm.ru/en/a10/kernel 
 
I followed that link, there you will find two other kernels along with their installation instructions.
I installed the Desktop kernel and now everything is working perfectly fine.

Thank you  Roman Mamedov for this great distro

Emulator  for MK802


The next thing I needed is an emulator to run the debian image on, install all development stuff plus kernel source to compile any extra drivers I might be missing.

For that I found qemu very handy
I followed the guide here
http://romanrm.ru/en/a10/qemu

Basically you need to download kernel files
initrd.img-3.2.0-4-vexpress


linux-image-3.2.0-4-vexpress_3.2.35-2_armhf.deb


vmlinuz-3.2.0-4-vexpress


from http://romanrm.ru/dl/a10/kernels/qemu/

Then run quemu
qemu-system-arm \
  -M vexpress-a9 \
  -kernel vmlinuz-3.2.0-4-vexpress -initrd initrd.img-3.2.0-4-vexpress \
  -append root=/dev/mmcblk0p2 \
  -drive if=sd,cache=unsafe,file=image.im

Saturday, August 31, 2013

Calling Paypal API

I have had this terrible experience with paypal trying doing something simple like doing an API call.

In my opinion Paypal has the worst nightmare for any developer unlike for example stripe which is a peace of cake compared to it.

Anyway after search many websites excluding developers.paypal.com I found this great page
http://coding.smashingmagazine.com/2011/09/05/getting-started-with-the-paypal-api/

In a nutshell the page present a very simple code for calling any paypal api method.

class Paypal {
   /**
    * Last error message(s)
    * @var array
    */
   protected $_errors = array();

   /**
    * API Credentials
    * Use the correct credentials for the environment in use (Live / Sandbox)
    * @var array
    */
   protected $_credentials = array(
      'USER' => 'seller_1297608781_biz_api1.lionite.com',
      'PWD' => '1297608792',
      'SIGNATURE' => 'A3g66.FS3NAf4mkHn3BDQdpo6JD.ACcPc4wMrInvUEqO3Uapovity47p',
   );

   /**
    * API endpoint
    * Live - https://api-3t.paypal.com/nvp
    * Sandbox - https://api-3t.sandbox.paypal.com/nvp
    * @var string
    */
   protected $_endPoint = 'https://api-3t.sandbox.paypal.com/nvp';

   /**
    * API Version
    * @var string
    */
   protected $_version = '74.0';

   /**
    * Make API request
    *
    * @param string $method string API method to request
    * @param array $params Additional request parameters
    * @return array / boolean Response array / boolean false on failure
    */
   public function request($method,$params = array()) {
      $this -> _errors = array();
      if( empty($method) ) { //Check if API method is not empty
         $this -> _errors = array('API method is missing');
         return false;
      }

      //Our request parameters
      $requestParams = array(
         'METHOD' => $method,
         'VERSION' => $this -> _version
      ) + $this -> _credentials;

      //Building our NVP string
      $request = http_build_query($requestParams + $params);

      //cURL settings
      $curlOptions = array (
         CURLOPT_URL => $this -> _endPoint,
         CURLOPT_VERBOSE => 1,
         //I (ramast) commented the following 3 lines for the sake of simplicity
         //CURLOPT_SSL_VERIFYPEER => true, 
         //CURLOPT_SSL_VERIFYHOST => 2,
         //CURLOPT_CAINFO => dirname(__FILE__) . '/cacert.pem', //CA cert file
         CURLOPT_RETURNTRANSFER => 1,
         CURLOPT_POST => 1,
         CURLOPT_POSTFIELDS => $request
      );

      $ch = curl_init();
      curl_setopt_array($ch,$curlOptions);

      //Sending our request - $response will hold the API response
      $response = curl_exec($ch);

      //Checking for cURL errors
      if (curl_errno($ch)) {
         $this -> _errors = curl_error($ch);
         curl_close($ch);
         return false;
         //Handle errors
      } else  {
         curl_close($ch);
         $responseArray = array();
         parse_str($response,$responseArray); // Break the NVP string to an array
         return $responseArray;
      }
   }
}

After that you can go to https://developer.paypal.com/webapps/developer/docs/classic/api/ find the call you want (make sure you click on NVP not SOAP) Then you can make a call like this
$paypal = new PayPal();
$response = $paypal->request("DoCapture", Array(
        "AUTHORIZATIONID" => "61P02217YA6177331",
        "AMT" => "10.92",
        "COMPLETETYPE" => "Complete",
        "NOTE" => "Thank you for buying from us"));
echo json_encode($response);

Friday, August 9, 2013

avrdude: stk500_recv(): programmer is not responding

I was happily playing with me new arduino uno3 board until they error started to appear and I was unable to upload any more programs to the board

I spent long time searching for a solution or at least understanding what is the problem and in this blog post I will post summary of what I have learned so far

avrdude: stk500_recv(): programmer is not responding error basically means the computer is unable to communicate with the board.

If this is your first try to upload something then there is a possibility you have software issues or problem with drivers.
I am not going to cover this case instead I will assume your board was working fine and suddenly stopped

Why?

  • Bad usb cable
  • Something is connected to pins 0,1 (serial pins)
  • Micro controller chip is fried (atmega328)
  • The chip responsible for communication between the board and PC is fried (ATmega16U2)
  • Something else (use your imagination)

How to determine the cause?


Connect pin 0 with pin 1 on your board
Start the serial monitor window
Type anything and hit enter, did what you type appear in the output box?
If Yes, then the ATmega16U2 is working and its either the cable or the atmega328

Push the reset button, do u see the L led flashing ? If yes then the atmega328 is also fine.

Cable is cheap so u can always try another cable to verify if the cable is fine or not.

How to Fix?

You can replace the atmega328 with a new one (make sure it comes with Uno bootloader)
Like this one
You can also replace your usb cable
I am not sure if its possible to replace the ATmega16U2 IC though

Monday, August 5, 2013

Online electronic shops in Egypt (Review)

This review is about shops selling electronic components like resistors, capacitors up to arduino boards



I

hate shopping in Cairo because of the transportation hell and because of the fact that I don't live in Cairo anymore.
So when electronic fever hit me I started to look for online stores that offer shipping.
And here is my feedback about the ones I found



Future electronics

http://store.fut-electronics.com/index.php

Great online store for beginners.
It explain in details each component and its uses and some possible use cases along with the datasheet and even sometimes some tutorials

The online shop is big with really great varieties  also I like the option of payment upon delivery (so I only pay when the items reach my door)

Its also relatively cheap most components are cheap but also shipping to any place in Cairo (20le) or any place in Egypt (around 45le)

They are official reseller of Sparkfun.com

First Personal experience
I made my first order with them when I was in Cairo in short vacation.
To make the story really short they didn't deliver anything
When I called to ask for the reason of the delay he told me some of the components I ordered is currently not available (damn me!).
Why didn't you call me then? no answer.
being one day before going back home, I had to go myself to their shop and get my stuff.

Important thing to say: He charged me more for at least one component than the price indicated on the website so I would say these online prices are not very reliable.

Second Personal experience
Tried to order from them again (why again? because its cheap) but this time I wanted the items to be shipped to where I live (South Sinai)
I called asking about shipping cost to south sinai he told me it will be estimated and someone will call me to confirm it.
No body called (As expected) and no one answer my calls, emails.
I was making a 500le order so I was expecting some attention but got nothing.
I asked the order be canceled (got no response either).


RAM Electronics

https://ram-e-shop.com

The online shop is also big (bigger than Future Electronics) the option of payment upon delivery is also available

The website is not as beginners friendly as the former one.
Here they are expecting that you know what you are doing also the larger selection makes it harder for a beginner like me to decide which to buy.

You may find some datasheets but in general the website is not very beginner friendly

Prices are expensive either same item in Future Electronics can cost here any thing between 100-200% and sometimes more

Shipping is also more expensive (57le for a less than 1kg shipment to South Sinai compared to 45 in Fut-E)

This shop is also an official distributor for Sparkfun.com

First Personal experience
I knew from the first look this shop is more expensive than FutE and so I have only ordered few things from there that I didn't find in the other store.

After making online order someone called to confirm then I got an SMS few hours later confirming shipment of my items by Fedex, I received my items the next day morning.
(so it was less than 24 hour between submitting the order and receiving it)
Their prices were expensive but accurate, I payed what I expected to pay

Although that experience was good but it doesn't count because I ordered only very few things

Second Personal experience
When FutE turned me down the second time I ordered everything from RAM Electronics .. I found every thing I needed and even many things that I didn't find in FutE all for higher price of course.
Just like first time I got confirmation call from them, then another call informing me one of the items I requested is not available giving me the option to ship without this item or wait until tomorrow and ship everything

the company they use for shipping is egyptexpress/fedex which has a terrible (or rather no) customer support they never picked up the phone when I called.

Despite that the package arrived within two days as promised.
I will definitely order from them again

ElGammal Electronics


http://elgammalelectronics.com/

This shop is direct competitor fo E-Ram, it has lot of components and can be cheaper sometimes than E-Ram. Only down side is that their delivery is very expensive compared to e-ram.


Deal Extreme

Deal Extreme (or dx for short) is general electronic shop not specialized like the previous two but still you could find some electronics in dx and not in the other sites.

Dx is a Chinese so you will only find there things made in China.
Its prices are generally more expensive than those two websites mentioned above but it offer FREE shipping

First Personal experienceI ordered a few items from there to test if its gonna work or will face problem with customs and delivery.
Order was placed 24th of July
Shipped 25th of July (just one day after making the order)
Received 29th of August.

Customs charge was 50% (6$ for my 12$ order)

Monday, June 3, 2013

Xen support for sysrescuecd

In this article I will explain how you can customize sysrescuecd in a way that make it run on xen.

Here goes the steps

1. Download, extract, patch the kernel

Best way to do that is to follow this guide

2. Make menuconfig

From "Processor type and features" go to "Paravirtualized guest support " then select xen

Note:If you can't see xen and you are compiling x86 kernel then you need to disable support for High Memory Support (from Processor type and features)

From "General Setup" set "Kernel compression mode" to gzip instead of XZ (Xen doesn't recognize XZ compression)

Carry on and compile/install the kernel as explained in the guide above

2. Recompile initramfs

Now you need to include the new xen modules to your initramfs file
the guide explain how to do that, follow it but please consider those two notes

In the line that says
cp -a /lib/modules/your-kernel-modules /usr/src/initramfs/lib/modules/
This is how it should look like
mkdir /usr/src/initramfs/lib/modules/
cp -a /lib/modules/<kernel version>/ /usr/src/initramfs/lib/modules/

Also in the line that says
find . | cpio -H newc -o | xz --check=crc32 --x86 --lzma2 > /usr/src/initram.igz
Change it to be
find . | cpio -H newc -o | gzip > /usr/src/initram.igz
Because again xen doesn't recognize xz compression

3. Remaster the cd with the new kernel / initramfs.igz file


Hope that helps

Friday, December 28, 2012

5 Reasons to submit your real estate in DahabRE.com


0. Its FREE!!

We don't take any kind of fees or commissions whatsoever

1. Make it easy for people to find it

DahabRE give its visitors the chance to filter their search based on many criteria like Location, Price, features (like AC, Pet friendly, ...) and more.

That save them lot of time looking for the "right" place, and also save u the time for answering the same questions again and again

2.Make your real estate appear in Google


We spend a lot of time trying to get Google know about all the new pages we get.
a simple Google search may show your real estate like this one.


3. Make posting your real estate on Facebook easier


If you like to post your real estate in Facebook groups, then you know  the deal
You create an album, upload your real estate pictures in it, post description then copy and paste this description and link to photos on facebook groups
Wouldn't it be easier to post a single link and get the rest done for you?


In the picture above I only had to post the link

 4. Make sure your clients can reach you

Lets face it Facebook messaging system is not so reliable, how many times a client sent you a message and you saw it months after?
In DahabRE you are able to provide more reliable contact methods like email or even mobile number!

5. Keep track of your reservations in a central place

If you are responsible for many real estates sometimes u can't keep track of which real estate is rented until when.
In DahabRE you can store this information and it remain hidden from visitors
although any visitor viewing your real estate page while its rented will be informed that its not available at the moment

For any questions/suggestions visit our facebook page http://facebook.com/dahabre

Thursday, August 2, 2012

Scabies ... Survival guide!

Scabies ... Survival guide!

Warning: the information presented here was made available at the hope it will be useful but without any warranty of any kind it is always recommended to consult a doctor if u can.
author is not responsible for any health damage or death caused directly or indirectly by following the tips presented in this article


What are scabies?

  • scabies are some kind of mites that live underneath skin, causing rash
  • scabies are very tiny insects that usually can not be seen by naked eye
  • scabies do not go away without medication, but its treatment is very easy
  • scabies are highly contagious and that's what is really bad about it

How do I know I am infected?

  • The most common symptom of scabies is an intense itch (especially at night) and a rash that affects a great deal of the body.
  • Its very common to see rashes on wrist (like in top picture)
  • Even though it might look like insect bites at the beginning, u can tell its scabies when it doesn't fad away within few days

I have Scabies, what do I do now?

To recover from scabies infection you need to both treat your body (or more precisely your skin) and also everything you came in touch with
I will describe how in the next questions

How do I treat my skin?

  • Most effective treatment is permethrin 5%, here in Egypt it is sold under the name "Ectomethrin 5 ointment".
  • Best time for treatment is before sleeping
  • Cover your whole body (starting from your neck and down to your feet toes)
  • If you can make your AC a little bit colder that would be better since permethrin perform better in colder temperature (but if you can't still it will be ok)
  • Even though most articles say scabies don't infect the area above your neck (head and scalp) I say be safe and put some in your head too
  • Treatment is usually done only once, u should start getting better from next day after treatment
  • sun light can neutralize the effect of  permethrin, stay away from the sun light during treatment (or have the treatment before sleeping time)
  • if you are in a place that doesn't offer any kind of medication, a very hot water on the skin can kill the mites (and hurt you) that may help a little but its neither practical nor very efficient

I came in contact with (touched) some people, but they are OK

If someone has been infected for the first time, he may not has any symptoms for 2-6 weeks so really if u had direct contact with someone he also must do same treatment described above even if he looks fine

 How do I make sure my home is scabies free?

  • Good news is, Scabies mites can't survive without a human host for 24 to 36 hours (source wikipedia ) so simply leaving a room closed for two days makes it scabies free
  • Clean your cloths/bedding with hot water
  • The sun is deadly for mites (esp. the sun of Egypt in the summer) leave anything infected in the direct sun light for couple of hours and all mites will die

I took the medication but still having rash and itching

The itching from scabies is actually an allergic reaction to the mites and their excrement, so itching may continue even after the mites are destroyed. If you are still suffering symptoms 2-3 weeks after treatment, you may need to be treated a second time.

Then, how do I know I have recovered?

In my case my skin returned back to its normal state after 3 days but as u saw in previous question this might not always be the case
So I can't give u definite answer to this question, but based on the information I gathered I would say if rash still increases at night then probably u r still infected (or re-infected)

I have just touched someone who has scabies

Always be safe and do the treatment described above, mites can walk on the skin and move from one part to another quickly
Soap, Ditol, water are all ineffective

Further reading

http://www.scribd.com/doc/59906567/How-to-Get-Rid-of-Scabies