Monday, June 24, 2019

Doom on the NanoPI



For one of my products I'm working with the NanoPI which is very similar to Raspberry PI but more powerful. It is developed by FriendlyElec and has a large family of boards. My board has the following specifications




  • CPU: Allwinner H3, Quad-core Cortex-A7@1.2GHz
  • GPU: Mali400MP2@600MHz,Supports OpenGL ES2.0
  • DDR3 RAM: 1GB
  • eMMC: 8GB
  • Wireless: 802.11 b/g/n
  • Bluetooth: 4.0 dual mode
  • Antenna Interface: Shared by WiFi and Bluetooth, IPX interface
  • Connectivity: 10/100/1000M Ethernet
  • Audio: 3.5mm jack/Via HDMI
  • Microphone: onboard microphone
  • IR: onboard IR receiver
  • USB Host: USB 2.0 x 3, 2 x USB Type A and 1 x 2.54mm pitch pin-header
  • MicroSD Slot: x1
  • MicroUSB: power input and data transmission, OTG
  • Audio Output: HDMI 1.4 1080P, CVBS
  • DVP Camera Interface: 24pin, 0.5mm pitch FPC seat
  • Serial Debug Port: 4Pin, 2.54mm pitch pin-header
  • GPIO: 40pin, 2.54mm pitch pin-header, compatible with RasberryPi 2's GPIO. It contains UART, SPI, I2C, I2S/PCM, SPDIF-OUT and IO
  • User Button: 1 x Power Button and 1 x Reset Button
  • LED: 1 x Power LED and 1 x System Status LED
  • PCB Dimension: 64 x 60 mm, ENIG
  • Power Supply: DC 5V/2A
  • OS/Software: u-boot, Debian, Ubuntu-MATE, Ubuntu-Core

Interestingly today the Raspberry Foundation announced the more powerful RaspberryPI 4 model B. It has some powerful features along with multiple RAM versions, the cost is similar to existing model. The base model costs $35 and upwards based on more RAM. Some of the new features include different RAM versions (LPDDR4) (1-4GB options), 4K video display over 2 micro hdmi slots, BT 5.0, 2 x USB 3.0 ports and USB type C power port.  It has the following specifications:


DOOM On NanoPI


NanoPI has a small form factor and is pretty fast. I've been running different experiments with it but one thing that I completely missed was to run Doom on it! So here are the steps if you want to run Doom on NanoPi 

Step 1: Install Dependencies 

 sudo apt-get install libsdl-mixer1.2-dev libsdl-net1.2-dev python-imaging

Step 2: Download Doom
wget https://www.chocolate-doom.org/downloads/2.2.1/chocolate-doom-2.2.1.tar.gz

Step 3: Extract Downloaded file

tar xzf chocolate-doom-2.2.1.tar.gz

Step 4: Configure and Make
cd chocolate-doom-2.2.1
./configure
make

Step 5: Install (This will take a few minutes)
sudo make install

Step 6: Download Doom Data WAD File
wget http://www.doomworld.com/3ddownloads/ports/shareware_doom_iwad.zip

Step 7: Unzip WAD

unzip shareware_doom-iwad.zip
In case you don't have unzip install it using:
sudo apt-get install unzip

Step 8: Run Doom Setup:

chocolate-doom-setup

Step 9: Run and Enjoy!
chocolate-doom -iwad DOOM1.WAD



Reference:
This post used content from https://www.makeuseof.com/tag/run-doom-raspberry-pi/

Thursday, June 13, 2019

Physical Port access for NanoPi using Python on Debian


There are two ways to access GPIOs easily on NanoPi.


  1. In C language using WiringNP which is a port of the WiringPi library written for the Raspberry PI's BCM2835. 
  2. In Python using RPi.GPIO_NP which is a port of the RPi.GPIO library for the Raspberry PI. The problem is that this python distribution is only integrated in the FriendlyCore OS images and is not available to be installed directly for python in other images like Debian using pip or pip3. So in order to run RPi.GPIO_NP library for debian distro for NanoPi here are the following steps:


Step 1: Download 

  • git clone https://github.com/chainsx/RPi.GPIO.NP
Step 2: Installation
  • sudo apt-get update
  • sudo apt-get install python-dev
  • cd RPi.GPIO.NP
  • python setup.py install
  • sudo python setup.py install
Step 3: Restart NanoPi

Step 4: Test
  • type python to open the CLI for python
  • >> import RPi.GPIO
  • >>
  • If there is no import error, the library has been successfully installed
Step 5: Test Program

#!/usr/bin/env python
import RPi.GPIO as GPIO
import time
PIN_NUM = 7
 
GPIO.setmode(GPIO.BOARD)
GPIO.setup(PIN_NUM,GPIO.OUT)
while True:
        GPIO.output(PIN_NUM,True)
        time.sleep(1)
        GPIO.output(PIN_NUM,False)
        time.sleep(1)

Pictures:





Links:
https://github.com/chainsx/RPi.GPIO.NP
https://github.com/auto3000/RPi.GPIO_NP


Tuesday, May 21, 2019

Python and Pygame on Nano PI


NanoPI is an Arm based single based computer that can run Debian Linux, Ubuntu Core and Android. It is based on the same design as the Raspberry PI but is more powerful. In this post I'm installing Pygame with Python to run some graphics apps and games for testing. 

For Python
Step 1: Install Python Dependencies:
  • sudo apt-get build-dep python-pygame
Step 2: Install Python:
  • sudo apt-get install python-pygame
Installing Pygame Zero
  • pip install pgzero


For Python3
Step 1: Install Python3 Dependencies
  • $ sudo apt-get install python3-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev libsdl1.2-dev libsmpeg-dev python-numpy subversion libportmidi-dev libswscale-dev libavformat-dev libavcodec-dev
Step 2: Install Python3 
  • python3 -m pip install -U pygame
Installing Pygame Zero
  • pip3 install pgzero
Running an example from the Wireframe Magazine Issue 13
  • Download stars.py from github.com/Wireframe-Magazine/Wireframe-13
  • type pgzrun stars.py

Tuesday, March 26, 2019

Best day so far!

This MIT Bootcamp has been one of the best experiences of my life! Alhamdulillah (All praise is for Allah, the Rab of the heavens). The bootcamp has been going on since last Saturday and I plan to write one post about my experience as a whole, but today was special! Today there was a lecture by Joi Ito the director for Media Lab at MIT. It was a fascinating lecture where he touched on how technology is affecting the world and what will be the future of AI. He touched on very interesting points of how we should control AI. I noted down some interesting quotes from his talk..

"Usually history is repeating itself until it doesn't!"
"We have to reinvent Democracy because it's broken"
"We should fix capitalism"

He touched on a very interesting point about this notion of screen time for kids. He said this is mostly an elitist stigma that screen time is bad for kids. He argued that for the kid of a working mother, the screen was a window to the outside world! Limiting screen time is just stupid! I asked him a question "How can developing countries leverage current and upcoming technologies to skip decades of development and join the first world?" for which the answer is embedded in the video below!


Friday, March 22, 2019

I've finally made it to Tokyo

This MIT Bootcamp journey has been a topsy turvy from the start, but I've finally made it to Tokyo! First it was the visa process, then it was the flights! Due to the ongoing crisis between Pakistan and India, both countries have closed their airspaces for each other. Due to this, the load on all flights going out of Pakistan has increased a lot, which meant that I had a really hard time finding a flight on such short notice to Tokyo. Even business class (which I was never planning on buying) was fully booked as well. But finally my travel agency found a flight for me that was economy but pretty expensive and it was via Karachi! So I had to take a 2.5 hour flight to Karachi (via AirBlue), then wait around 5 hours at the airport, took a flight to Doha (Qatar Airways), waited around 2 hours there and finally took a 9.5 hour flight from Doha to Tokyo (Qatar Airways). So in total my journey lasted around 25 hours. I checked in to my hotel last night around 1.30 am and today was my first day in Tokyo! Since I have to complete a few prerequisite MOOCS before the bootcamp starts, my plan was to spend the day finishing those, no sight seeing for now! However my laptop charger didn't match the 2 pin sockets that are common here. I tried finding a converter at a local convenience store nearby but they didn't have it. Ultimately I had to go to Akhihabara, which, I've already planned on going to. Fortunately it's just a 20 minute walk from my hotel, so that's what I did. I walked to Akhihabara, bought the converted and then wasted an hour there... It was hard to bring myself back but I eventually did. I spent the next 4.5 hours doing the MOOCs and then I joined some of the bootcampers who have all converged on Tokyo from around the globe for dinner. The bootcamp officially starts tomorrow at 4 so I've got to complete the remaining MOOCs. Here are some cool pictures from day 1. 









Monday, March 18, 2019

Good News!


I've got my visa! In the last few posts I wrote about going to attend MIT bootcamp on Technology and Innovation! Well the great news is my visa to Japan has been issued! In recent years I've had a lot of trouble with my visa applications, so obviously I was very skeptical if I would get my visa! In fact, the visa pick up time at the embassy was at 2.30 and I had to wait one hour before my passport was returned to me with the visa! That was one tense hour! Even though I'm pretty used to picking myself back up from rejections and failures, but it's still disappointing to miss out on great opportunities! Due to my visa issues, I haven't been able to visit Silicon Valley, haven't been able to participate in CERN's humanitarian hackathon at Geneva, Switzerland, missed out representing my company at BETT show recently! Anyway I hope these issues eventually go away! Interestingly I am an invited speaker at Fireside Summit in the UK this September! Let's see if I'm able to go there and speak! I guess this Japanese visa and my MIT experience will certainly help! 

Here is an interesting fact! I am the only Pakistani attending this bootcamp! There could be two reasons for that! Probably no one else from Pakistan applied or I'm a Genius ;) :) :). So now the excitement starts! I have a couple of days to get my hotel bookings and flight reservations done. Planning to fly out on Thursday as the bootcamp starts Saturday! And I have to re-plan how I utilize the extra days I have post bootcamp! Some of the things that I'm looking forward to seeing the cherry blossoms! This is the time of the year to visit! I'm also planning on visiting Akihabara Market which is one of the coolest places for a geek like me! Really looking forward to having a cool time in Tokyo and learning a lot at the bootcamp! I'm planning on blogging throughout my trip, but like previous times I have a feeling, this will remain a plan only! 

Image taken from: https://www.womanandhome.com/travel/best-time-to-visit-japan-55928/ 

Tuesday, March 12, 2019

Fixed my Nintendo Switch for less than $10


Last year I bought a Nintendo Switch. I'm a big fan of handheld gaming consoles. Before the switch I had a PSP which I used to play during my graduate studies. After giving it away to my nephew and becoming a Teacher, I had no money to buy another one. Only last year after starting full time at LearnOBots could I finally afford to buy another one so I bought a switch. After playing it for a few months the left analog stick started degrading and finally made it impossible to play any game. It kept moving upwards. I thought my 2.5 year old hyper active kid 

was responsible for this as whenever I'm not home, he goes after it playing it until the battery dies. Anyway after looking online to find a solution for it I found out that this is a manufacturing fault and almost all users have faced the same problem. I had two options now. Either buy a new pair of joy cons which is quite expensive or try to figure out how to get it fixed. Since the Switch is not sold officially in Pakistan and I bought it in Doha, I was pretty sure, I couldn't get it fixed from Nintendo, so I checked if I could find a replacement part from AliExpress and lo and behold! I found a set of replacement joycons and some tools as well for less than $10. Ordered the set with free shipping, had it delivered in around 20 days. And then I did the fix which seemed pretty simple. You can check out the video below!





Tuesday, March 5, 2019

Visa submitted!


In my last post I shared my experience about visiting the Japanese Embassy for applying the visa. Well today I submitted my visa application. Now I'm hoping and praying I get my visa soon In sha Allah. Don't want to get too excited as disappointments are exponential compared to the excitement one feels. Anyway last weekend I also managed to finish reading the book Made to stick. I think it's a good book, I won't categorize it as one of the best, however it does have excellent  ideas on how to make ideas stick. But it also has some interesting lessons, like one idea that stuck with me is the Commanders Intent, which I've already started using in my conversations at my company. I've also started helping my co-founder in improving his communication and making his ideas stick with the our team. Commander's intent comes from Military terminology where the commander ensures his junior colleagues understand of what he wants to achieve. Then everyone in the chain of command understands his or her role in achieving that goal. The commander's planning is more abstract whereas the soldier's decisions would be practical and more action oriented. Anyway I'll try to write a review of my lessons learned from the book and there are two reasons for that. One, anyone wanting to pick up a copy can read my take on it and perhaps it'll let them decide whether to read it or not, and second, summarizing it will help me retain the major lessons I've learnt from the book and it'll be my ready reference. Ok enough about this book. Now I need to get started on another one and finish around 4 MOOCS before March 15th! Blog later!

Image Courtesy of LonelyPlanet.com 

Tuesday, February 26, 2019

Oh the Japanese!

In my last post I mentioned about going to MIT's Technology and Innovation Bootcamp to Tokyo, Japan. Well my biggest challenge was not to get admitted to MIT, but my biggest challenge has been getting admitted to countries! I've had some terrible luck with my visa applications. Today I went to apply for my Japanese Visa. My long standing impression of Japanese being a very organized nation who are meticulous about everything shattered big time! The visa application submission time is from 9-11 am. Having to use the Shuttle bus (Another Angry Blog post coming soon) I reached the embassy around 9.20 am. It was a rainy day today and fortunately I had my umbrella with me (very unlike me, I'm not a very organized person). At the entrance we were about 10 people who were made to wait outside in the rain with very little space to save ourselves from the rain. Every 10 minutes one person was called inside. I thought the Japanese had some respect for other people but I guess they do not. After around 1 hour of waiting in the rain, I managed to go inside. Expecting to see someone or some reception where I could understand the process, I was greeted by another group of confused applicants. Someone from somewhere told me to give my receipt, which I was given during my security check, to a window in the center of the room, which was covered in a way, that I couldn't see on the other side. My receipt mysteriously disappeared and I was asked to sit down like everyone else. I was once again very confused, there was no announcement system, no queueing system, just one black window, from where someone in a very low voice called out names! So much for the organized Japanese myth! I had to wait another hour before my name was called. This mysterious person behind the window was the slowest guy I've ever (not) seen. Now I understand why South Korean companies have have overtaken  Japanese Snails like Sony and Panasonic. 

After waiting for almost 2 hours my name was called. Guess what, I was told I don't have complete papers, even though I have an admission letter from MIT! I wanted to just bang my head on that Stupid black window! Anyway after wasting half my day, I came back (via that stupid Shuttle). If you know Urdu you will understand the next proverb that I write.

            کھائا پیا کچھ نحیں گلاس توڑا ۱۰۴۰رپے کا

I had to pay 1000 for the executive shuttle bus service. The economy one runs every one hour! Just missed it by 2 minutes, as at the entrance I was asked to submit a copy of my passport for SECURITY reasons (Head banging again). I paid 20 rupees for a single photo copy and 20 rupees to park my  car. So spent half a day and Rs 1040 with no outcome! And now I have to do it all over again twice! Once to go re-submit my application and then to go and pick up my passport when the visa hopefully InShaAllah arrives. 

Sunday, February 17, 2019

Going to MIT

Haven't had the time to update my blog in quite a while. But I guess this has been the pattern of my blogging career since the start! Write a post once a few months then there is a long hiatus! And I also don't have many readers so no one is really looking forward to reading my blog, which makes it easier for me to not write anything and get away with it! A lot has happened since my last post but another blog post for that! In this one I want to focus on some exciting news! I have been admitted to MIT's Technology and Innovation Bootcamp Tokyo next month. This is exciting for me for two or perhaps three reasons. First it's MIT! Second it's Tokyo, Japan, always wanted to visit Tokyo, having missed out on the opportunity to visit while studying in Seoul. Third, the bootcamp is about technology and innovation, two things I've been interested in since I was a kid. Through these series of blog posts I'd like to document my journey of the bootcamp since the day I got accepted, through the experience and ultimately what I gain out of it. Hopefully someone somewhere in the world will find these useful. 

The process for applying the bootcamp included submitting an application by filling in a form and submitting a small introductory video of myself. Once that part was reviewed I was invited to take an online video interview. And finally in the first week of Feb I was accepted to the program! One of the most interesting things about the program is that as soon as I accepted the offer, I was given assignments. So now I have to complete 4 MOOCS, read 4 books before attending the bootcamp, all in about a months time. Anyway I really like this challenge and I've already started on one of the books titled "Made to Stick". So far it has been fun and I hope it continues to do so... More updates later..