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/