Showing posts with label raspberry pi. Show all posts
Showing posts with label raspberry pi. Show all posts

This Week I Learned - 2017 Week 35

Last week post or revisit some old archived posts.

Long holidays and I finally have extra time to clear off some of those pesky and pending to-do list. Learned quite a lot this week, especially from different electronic devices and computer hardware.

Software development 450 words per minute. (via Reddit / HN). Be grateful. That's probably takeaway from the article itself. I was wondering how it going to affect your hearing if you keep listen to the headphone non-stop for more than 8 hours per day?

Good post on introduction to mechanical key switches, specifically Cherry MX family. For a non-gamer but mostly using your keyboard for typing, Cherry MX Brown and Cherry MX Blue would be the preferred keyboard switch for a mechanical keyboard. The Brown switch was originally developed for Kinesis Keyboard. Yes, that company that created the ergonomic contoured keyboard. Meanwhile, the Blue switch, have same tactile feeling and clicking sound to IBM Model M but less activation force. Does mechanical keyboard worth it? Yes, only if you play lots of games, build a Battlestation, a mechanical keyboard enthusiast, or have extra money to burn.

Buying an air purifier? Fview YouTube channel is probably the best I've watched so far. Honest opinions with lots of satirical remarks in between. Just like taking an advice from a trustworthy friend. So which air purifier to buy? From the result and price point, just get Xiaomi Air Purifier even through you have to tolerate the high fan noise. I was surprised that few European brands are so expensive but the filtering output was mediocre. Most likely you're paying premium to the quality material and long term reliability. One thing I've learned from electronic devices made in China or electronic devices in general these days. There are not built for reliability. a throwaway device that only serve a purpose for a short period.

Yeah, the bokeh, colour, and contrast is phenomenal and surely will make you mouth-watering.  Just make sure you watch the YouTube video in highest resolution. The most important criteria is the colour (in JPEG) format shows the actual colour and contrast representative of what we saw with the reviewer eyes. Be warned, both Sony A9 and Voigtlander 50 Heliar V4 will cost you around MYR 21k. Definitely not worth it unless you have extra cash to burn. Even so, still not worth it.

More lesson regarding ConTeXt. Want to use Times New Roman, make sure you've installed the Tex Gyre package where it includes the Termes aka Times New Roman font.

Installation of more PWM casing fans. The motherboard seemed quite sensitive and there are numerous times I can't get to the POST screen. Reading through the POST troubleshooting steps, manage to boot up the machine again. Suspect loosen power wires, memory slot, or bended CPU pins were likely the contributing causes.

Fan speeds seems to be at an accepted range. There is an increase of volume heard but I like the white noise.
$ sensors | grep fan
fan1:         1704 RPM  (min = 1577 RPM, div = 8)
fan2:         1875 RPM  (min =  784 RPM, div = 8)
fan3:         1577 RPM  (min =  685 RPM, div = 8)
fan4:            0 RPM  (min = 3515 RPM, div = 128)  ALARM
fan5:            0 RPM  (min =  703 RPM, div = 128)  ALARM

Hardware UART in MSP430. I have no idea this is possible. Mainly because I have no idea what and how UART works anyway. And, I also found out that there is a UniFlash, which is the Universal Flash Programmer for all Texas Instruments devices. Seems to support MSP430 and GNU/Linux but I haven't try it out yet.

I was looking for a DAC and my research indicated that using Raspberry Pi with HiFiBerry would be a good choice. Maybe that could put my shelved Pi into good use?

Running Docker on Fedora host but have permission error with mounted volume?
$ docker run -it -v /home/ang/project:/export tts:latest bash

[email protected]:/export# ls -l                
ls: cannot open directory '.': Permission denied

To resolve this properly, since this is a SELinux permission issue (reason why you should always test your stuff in Fedora/Red Hat/CentOS distros), you can append extra `z` or `Z` character to the mounted volume option `(-v)` as shown below.

-v /home/ang/project:/export:z

Meanwhile, setting up Docker in Fedora to support non-root user. (Yes, there are many security concerns).
$ sudo groupadd docker && sudo gpasswd -a ${USER} docker && sudo systemctl restart docker
$ newgrp docker

Readjustment of my night computing usage. Turned on Gnome's Night Light. This is to reduce the effect of blue light affecting the body melatonic production.

This Week I Learned - 2017 Week 12

Last week post or you can read the whole series.

9 hours of writing and only 3 pages done.

#1 The important of morning rituals in developing a system (install a habit) to achieve your life goals. Is good to be morning person as you can achieve quite a lot when your mind is fresh. There are these 7 morning rituals which I will slowly introduce to my daily life. These are:
  1. Plan a day before. I've been slowly adopting this habit by going through the list of items in my bag and write down what I need to do tomorrow. Not consistent though as for some day I failed to plan for anything.
  2. Wake up early. Either from 4:30 AM till 6:30 AM. This is doable provided that you sleep quite early on the previous day. According to this sleep calculator, these are the corresponding time you should sleep if you want to wake up at a particular hours.
    1. 04:30 AM - 7:30 PM or 9:00 PM or 10:30 PM or 12:00 AM
    2. 05:30 AM - 8:30 PM or 10:00 PM or 11:30 PM or 1:00 AM
    3. 06:30 AM - 9:30 PM or 11:00 PM or 12:30 AM or 2:00 AM
  3. Start the day with exercise.
  4. Do your highest priority projects. Study in the morning and reviewing again in the evening before bedtime. This is good for learning as you can recall and rethink what you've learned in the morning. Also? Before even you start your journey to work, you've already accomplished so much for the day.
  5. Work on your side projects. Definitely need to try this. Do not work on your side projects late at night. Do it in the morning.
  6. Have a uninterrupted conversation with your partner. Do we actually having any serious and uninterrupted conversation with our partner, even for just two minutes? Doubt so.
  7. Meditate. I've been doing this since the moment I woke up in the morning. Although for just a mere 10 seconds, slowly but surely I can really concentrate on it.
#2 Beautiful SICP. There is another Python version as well. The discussion is always revolves whether it's good or not. I haven't yet finish the damn book since I bought it 20 years ago. Is this year the year for me to finish it? Doubt so. Even though I placed the book next to my work place and look at it on daily basis. Also, SICP is also the recommended book (debatable) on the subject on programming in Teach Yourself CS. (via HN) While we on that, someone should start another list on Teach Yourself SE. My personal experiences is that Software Engineering knowledge far outweight the Computer Science knowledge.

Since we can all access good quality CS education through the Internet, does local CS degree still relevant today? Or does this means that universities or colleges have been rendered to just another platform for face-to-face socializing instead of gaining knowledge?

#3 Almost 15 years of Design by Contract. I can relate to the author experience and still is a firm believer of Design by Contract (DbC). Bertrand Meyer still have a huge influence on me. Like most things in life, moderation is the key. Use DbC only when necessary.

#4 Real-time LED strip visualization (see Gif animation below) using ESP8266 or Raspberry Pi. Not only the project was interesting, the detail documentation by the developer was impressive. Definitely one of the most solid Github project I've encountered.

#5 Alone in the Wilderness. (via Reddit) A documentary (search YouTube for the video) about Richard Proenneke, who upon his retirement at age of 51 years, build an ultimate man cave to live a life of solitude in Aslaka. Carpentry is such a underestimate skill a man could have.

#6 Interesting Git graph generated by Bit-Booster, the offline commit graph drawing tool from one of my personal Git repository. I'm not sure how to interpret the relationship of my commits, seems somehow broken?

This Week I Learned - 2016 Week 09

Last week post.

#1 Goals vs. Systems. Before pursuing any goals, make sure you're making an informed and educated decision. The strategy is to use knowledge instead of willpower to pursuit your goals. For example, as not all carbohydrate foods are equal, you can lose weight easier if you pick the right food choice by knowing its Glycemic Index, which have an effect on a person's blood sugar.

#2 Raspberry Pi 3 is out. (HN discussion) The built-in onboard Wifi and Bluetooth as well as 64 bits support are welcoming feature. Unfortunately, local Element14 still awaiting stock. Heck, I can't even procure a Pi Zero till today. Not sure if the specs boost is worth the upgrade, however, some review claimed this release it's a worthy desktop replacement. If you never own a Pi before and itchy get on the single-board computer bandwagon, then you should get a Pi 3. As for me, will skip this as I'm saving money to get a SSD drive which definitely help with my testing of containers.

#3 Git rebase and the golden rule explained. Detailed explanation on Git rebase. If you want to stick to the Subversion's model of a single linear tree, then Git rebasing is the preferred choice. The only caveat is you may need to force-push if you rebase already commits that have been shared.

#4 Prevalence of Healthy Sleep Duration among Adults — United States. (Reddit discussion) Seriously, sleeping less than 7 hours per day may increase your chances of mortality. Rest people, rest.

#5 Using Make with Django. Lots of people (especially those from non-Unix background) overlook or underestimate the useful of GNU Make to manage tasks with your software project.

#6 How do you remember what you read? It will take times to internalised or digest the information but memorization is the initial step. If you can't retain the information within your brain, you can't analyze it. Retention is useful to verify your understanding if you just follow the these steps.
  1. Read a paragraph.
  2. Close the book.
  3. Write down what you remember.
  4. Re-read the paragraph and check.

This Week I Learned - 2016 Week 00

Happy new year, 2016!

Inspired by Christian Neukirchen's blog, Trivium, where he curated interesting stuff about technology, mostly related to programming. I will start something similar but not limited just to programming. Instead of storing all those things I've stumbled upon as bookmark, in Google Plus' collection, or in my paper journal, why not turn it into an "essayish content"?

I didn't blog that much in 2015. Comparing to the previous years, which I vowed to write on a near daily basis, I blogged sporadically without any specific topics. Just mindless ramblings following the current technology fad, mostly those in Hacker News. Also, my writing style change. I tends to write longer post these days or rather, I've become wordy. Maybe the migration from Google Plus to Blogger caused that. It feels weird to write short blog post in Blogger. Contrary to what they said, especially in photography, the tool is as important as the doer.

A weekly post sounds reasonable. Most probably on every Saturday. Or Sunday if something come up a day before. That means I should have a minimum 52 posts by the end of year 2016. And additional few posts in between. A good baseline figure to motivate yourself to write even more. When comes to writing or reading, quantity always triumph quality. You always need more deliberate practices and discipline to master any skills.

Or maybe because I miss Memepool?

Without further ado, I present you the first post of this week I learned.

#1 Scott Meyers, the foremost expert on C++ programming language, announced that he is retiring from it after 25 years of involvement. Quarter-century is a very long period for anyone to just focus on one particular programming language. Especially to resist all the temptation of chasing the latest technology fad. The discussion at r/programming regarding his retirement is both funny and interesting. Some speculated that his next step. Maybe he is moving to Golang (due to title of the blog post), Ceylon (from his past posts), Node.js (I doubt so), Swift (possible), or Rust (another possible candidate)? Nevertheless, C++ always remains one of the item in my someday list (to-do list for procrastinator).

Some interesting tidbits about him. He has a consistent and unique hairstyle. There is even a poll on his hairstyle resemblance to famous people. The funny thing is I always mistaken him for Bertrand Meyer, the creator of Eiffel. Also, besides Philip Greenspun, he is the second technical people I'm aware of who seems to have a deep connection to their pet dog.

#2 Matt Might blog post on 12 resolutions for programmer should be reread annually during new year. I've covered this in the past, around 2013. Rereading his post and comparing to what I've done for the past two years, it seems that I didn't manage to pull through of the resolutions. Something I learned last year, discipline and persistency always outweigh passion. Also one mistake I've made was that you can't multitask your goals. As stated in his blog post, this is a "twelve month-size resolutions". Meaning that you should carry out one resolution at a month. This is akin to changing a habit, one at a time, for one at a month. Sometimes you've to slow down in order to move faster. One issue still remains, which can be summarized from HN discussion, sedentary life style is a huge health risk for IT jobs like programmer and system administrator.

#3 There are 64 GNU/Linux or Android friendly Single-board Computers(SBCs). Overwhelmed by the number of choices? As shown in the survey results, you can't go wrong with Raspberry Pi for its software support and community ecosystem even though it has lower hardware specification. For my case, the main reason is the pricing as I can procure both SBCs from the local element14 (electronic components distributor) site. For other SBCs, the shipping fees, tax, and delivery time does not justify it. Otherwise, I would have go for Odroid especially Odroid-C1 and Odroid-XU4. Adapteva's Parallella, marketed as mini supercomputer, caught my attention but the price and its usage, again, does not worth it.

Neglected Raspberry Pi

"A bunch of nerds could order one, then wait six months for it to arrive. They could install a version of Linux on it, play around with it for about 20 minutes, and then talk about how maybe they'll use it for XMBC. Then they could just let it gather dust on some shelf until it gets thrown away in a few years."
-- kamapuaa, emphasis added
My sentiment exactly. Especially regarding Raspberry Pi or similar devices. Due to the low spec, slow updates from distro, and lack of an optimized GPU support, you can't do much with the tiny devices unless you want to learn more about electronic. Must figure out a way to do with the abandon Pi at home, maybe I can turn it into a wireless print server instead.

Shopping List for Raspberry Pi

Decide what you want to do with this machine. Is this a media player, cluster computing, hardware hacking, or just another toy ? Then only you proceed with the purchase.

1. Raspberry Pi, Model B, 512MB RAM, MYR 111.00
Required. You can get this from both RS Component or Element 14. I prefer to shop from Element 14, better service and order page.

2. Scandisk SD Card Class 4 4GB, MYR 16.00
Required. If you want to setup a torrent client, get the 32GB version. If you want to test out different images (e.g. Openelec or XMBC) but lazy to reburn images or setup cluster computing, buy a few 4GB.

3. Power Adapter, MYR 19 - 50
Required. Be extra careful with selecting power adapter. I bought a brand-less traveller charges which can't seems to power up the Pi (there are no lights). Either you use your own smart phone charges or get the Vztec power adapter.

4. Keyboard, MYR 15.00 - 100.00
Required. We need to type and setup the machine, especially the SSH and VNC so that later we can connect remotely from our laptop.

5. Multicomp MC-RP001-CLR Clear Case, MYR 28.70
Optional. Is better to get a enclosure to protect the board. Furthermore, is kinda of scary to touch the board while plugging the power adapter. I didn't get one though and will definitely buy one.

6. HDMI-to-DVI adapter, MYR 29.00
Optional. If you have an existing LCD/LED monitor with DVI output. Get this cable.

7. HDMI-to-VGA adapter, MYR 40 - 100
Optional. Own a monitor with only VGA output? Expect to pay more for an HDMI-to-VGA adapter. Due to limitation of digital to analog conversion, you can't just do a HDMI-DVI-VGA conversion, unless you buy a special designed HDMI-to-VGA adapter for Pi from Adafruit , Element 14, or Neewer.

Note that I am still looking for a cheaper way to get this to work.

8. HDMI cable, MYR 20 - 50
Optional. If you own a LCD/LED tv, you can simply use the default HDMI cable.

9. TP-LINK TP-725N / EDIMAX EW-7811Un, MYR 26.00 - 33.00
Optional. Both work out of the box. For TP-725N, you will need to upgrade the Linux Kernel to version 3.6.x.

10. HP 19”W1972A (LED VGA/DVI), MYR 235.00 
Optional. Unless you've a LCD/LED tv, otherwise you will still need a display. Monitor that support HDMI connection are expensive and the preferable choice is to get an monitor that support DVI connection and use a HDMI-to-DVI adapter.

Raspberry Pi Setup - Part 2

Continue with my journey of setting this machine up. Since I misplaced my Edimax EW-7811UN wifi adapter, which will work seamlessly without any compilation, I had to buy another one. However, I can't find the exact brand and model and I ended up with TP-LINK TL-WN725N, which according to wiki [2], will work out of the box using the build-in USB port. However, you will need to upgrade the kernel from 3.2.x to 3.6.x.

1. First let's find out the current kernel version.
$ uname -a
Linux raspberrypi 3.2.27+ #250 PREEMPT Thu Oct 18 19:03:02 BST 2012 armv6l GNU/Linux

2. Yesterday, I made a mistake by not expanding the rootfs. Hence, firmware upgrade failed due to lack of disk space. To fix that, run the initial configuration tool when we first boot up the image.
$ sudo raspi-config

Select expand_rootfs option to expand root partition (/) to use up all the remaining space in the SD card (mine is 16GB). Save the settings and reboot. New filesystem layout as follows:
$ df -h
Filesystem           Size   Used Avail   Use% Mounted on
rootfs               15G    1.8G   13G    13% /
/dev/root            15G    1.8G   13G    13% /
devtmpfs             93M       0   93M     0% /dev
tmpfs                19M    232K   19M     2% /run
tmpfs                5.0M      0  5.0M     0% /run/lock
tmpfs                37M       0   37M     0% /run/shm
/dev/mmcblk0p1       56M     17M   40M    30% /boot
tmpfs                7M       0    37M     0% /tmp

3. Update the Raspberry Pi's firmware using Hexxeh's rpi-updater tool.
$ sudo apt-get install git-core ca-certificates
$ sudo wget -O /usr/bin/rpi-update
$ cd /usr/bin
$ sudo chmod +x /usr/bin/rpi-update
$ sudo ./rpi-update

Let's check the kernel version again. And yes, we have upgraded to kernel 3.6.X.
$ uname -a
Linux raspberrypi 3.6.11+ #362 PREEMPT Tue Jan 22 14:52:21 GMT 2013 armv6l GNU/Linux

4. Type these commands to verify that the Wifi adapter is working.
$ lsusb | grep 8188
Bus 001 Device 004: ID 0bda:8176 Realtek Semiconductor Corp. RTL8188CUS 802.11n WLAN Adapter

$ lsmod | grep 8192
8192cu   489381  0

$ iwconfig wlan0

5. I am lazy to configure Wifi in the console, let's try using GUI way. You can read console config method here. However, I lost my mouse and have to resort to remote GUI using VNC. Following the instruction in the wiki.

In the Raspberry machine, to setup a VNC server.
$ sudo apt-get install tightvncserver
$ tightvncserver # set password
$ vncserver :0 -geometry 1920x1080 -depth 24

6. In my Ubuntu machine, install the VNC client viewer and connect to the server. See sceenshot.
$ sudo apt-get install xtightvncviewer
$ xtightvncviewer

7. In the VNC viewer, double-click the WiFi Config -> Scan -> Select Connection -> Right Click to add -> Type password.

8. Reboot the machine
$ sudo reboot

Raspberry Pi Setup and Installation

Few months ago, I bought a Raspberry Pi computer from element14, the electronic distributor shop. Although I had watched some You Tube videos of the computer, still very surprised with this business-card sized machine. Went to bought some extra parts (SD card, power supply, and HDMI cable) before configuration. Installation steps are based on the Embedded Linux Wiki with my own comments.

0. Download the image file from official site. Do the checksum verification so that the downloaded file is not corrupted.
$ sha1sum

1. Uncompress the file.
$ unzip 
inflating: 2012-12-16-wheezy-raspbian.img

2. Put in the SD card and use the disk free (df) command to find the device name. Our device name is NOT /dev/mmcblk0p1, that is the first partition, hence p1. The actual device name is /dev/mmcblk0.
$ df -h
Filesystem             Size  Used Avail Use% Mounted on
/dev/mmcblk0p1         15G   32K   15G  1%    /media/kianmeng/3265-3765

3. Unmount the device before we can write the image to the SD card.
$ umount /dev/mmcblk0

4. According to the wiki, there are two command line ways to write the image, namely using disk dump (dd) or enhanced disk dump (dcfldd). I had tried both ways and prefer disk dump (dd) program as you can see more information shown below. Image writing roughly took 646 seconds which is around 10 minutes.

4a. Using enhanced disk dump (dcfldd)
$ sudo apt-get install dcfldd
$ sudo dcfldd bs=4M if=2012-12-16-wheezy-raspbian.img of=/dev/mmcblk0
256 blocks (1024Mb) written.
462+1 records in
462+1 records out

4b. Using plain old disk dump (dd)
$ sudo dd bs=4M if=2012-12-16-wheezy-raspbian.img of=/dev/mmcblk0                                                                   
462+1 records in
462+1 records out
1939865600 bytes (1.9 GB) copied, 646.172 s, 3.0 MB/s

5. Make sure everything is written to the SD card.
$ sudo sync

6. To view the file system layout of the image, we will install the graphical partition editor. You can use this program to create the new /data partition to utilize the free space in the card.
$ sudo apt-get install gparted
$ sudo gparted /dev/mmcblk0

7. We will follow command line method to create a extra /data partition.
$ sudo apt-get install parted
$ sudo parted /dev/mmcblk0
GNU Parted 2.3
Using /dev/mmcblk0
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) unit chs                                                         
(parted) print                                                            
Model: SD SU16G (sd/mmc)
Disk /dev/mmcblk0: 1936,229,20
Sector size (logical/physical): 512B/512B
BIOS cylinder,head,sector geometry: 1936,255,63.  Each cylinder is 8225kB.
Partition Table: msdos

Number  Start     End         Type     File system  Flags
 1      0,130,2   7,165,29    primary  fat16        lba
 2      7,165,30  235,214,42  primary  ext4

7a. Contrary to the wiki instruction, we will not round up the chs (cylinders, head, sector) addressing.
(parted) mkpart primary 235,214,43 1936,229,20
(parted) print                                                            
Model: SD SU16G (sd/mmc)
Disk /dev/mmcblk0: 1936,229,20
Sector size (logical/physical): 512B/512B
BIOS cylinder,head,sector geometry: 1936,255,63.  Each cylinder is 8225kB.
Partition Table: msdos

Number  Start       End          Type     File system  Flags
 1      0,130,2     7,165,29     primary  fat16        lba
 2      7,165,30    235,214,42   primary  ext4
 3      235,214,43  1936,229,20  primary

7b. Rounding of chs value will cause incorrectly partition alignment. See example below.
(parted) mkpart primary 236,0,0 1936,229,20                               
Warning: The resulting partition is not properly aligned for best performance.

8. Quit parted program, format and label the partition. See the partition layout after this step using gparted program.
$ sudo mkfs.ext4 /dev/mmcblk0p3
$ sudo e2label /dev/mmcblk0p3 data

9. To make sure we can automount the /data partition in the SD card, add this line to the file system table (/etc/fstab) file.
$ vi /etc/fstab
/dev/mmcblk0p3  /media/pi  ext4  defaults   1   2

10. Mount the new partition and see the content. You should obtain below result.
$ sudo mkdir /media/pi
$ sudo mount /media/pi
$ cd /media/pi
$ ls