September 25, 2013

A New Year, A New Language

At the end of August, I started my second year at Rochester Institute of Technology as a Computer Engineer.


Until now, all of my programming experience has been with high-level, object-oriented languages. This semester, however, I will be learning assembly language (specifically for the Freescale HCS12)!


So far, I have only written one program in assembly, just a short program to evaluate the following expression:

(-45)+6+(13*2)-(7*4)-65+33


Assembly is a bit different, as it is not an object oriented language, and commands are 1:1, meaning that each command does exactly one thing. For example, the following code:

ldaa #55
ldab #55
aba
staa someVar
END

... loads the number 55 into register A, then loads the number 55 into register B, adds B to A, and then stores the contents of A in a variable called someVar (which will have been defined previously in the file as a variable with a length of 1 byte).

Eventually I'll be working on device programming and rudimentary object manipulation. This will eventually get to be harder, but I like a challenge!

July 23, 2013

Summer

As is evident by my complete lack of posting, summer is a busy time for me.


I plan on updating more frequently when school rolls around in August, assuming that my workload isn't too insane.



In the meantime, I can give a rough idea of what's been going on.
  • Starting in late May, I started a job at a local company working in the software release services group. One of the assignments I've had is to try to update a Microsoft Sharepoint list from *nix machine. (There will eventually be a post about this.)
  • I did finally get Arch working on my laptop. (There might be a post about this, I haven't decided.)
  • I am currently exploring using playonlinux to play games designed for Windows on Linux.
  • Also, I am slowly learning HTML so that my code formatting will be less atrocious.

For anyone interested in short stories, I found two very interesting stories:
  • Tyro, a story about a true artificial intelligence.
  • Ra, a series about magic as a science. (I highly suggest this one, as it is an ongoing series.)

May 15, 2013

Interesting Little Project

So for calc this quarter we had to do a project. The project revolved around using game theory (specifically the game Prisoner's Dilemma) to analyze how cooperation became an evolutionary viable trait. This project focused on a community of 10,001 people playing games against each other. In order to simplify the problem, we split the players into people playing two strategies: Permanent Retaliation (PR) and Always Exploit (AE). Players playing PR cooperate with the other player until exploited, and players playing AE always exploit the other player. Some more terminology that I'll be using is:
- Turn: One interaction between two players.
- Game: A set of turns between two players.
- Round: A set of games in which every player plays every other player.
In the calc project, each round was viewed as a new generation of 10,001 players, where players that were successful from the previous generation were duplicated and players that were unsuccessful were eliminated. This allowed us to create a simple system which we could model with series.

Because this project interested me, I decided to model it in python. If you're interested, the project is on GitHub*. Oddly enough, it actually simplified the project to not create entirely new generations between rounds, instead pruning the lowest scoring players and replacing them with players of the same type as the top scoring players. To prune the lowest-scoring players, I found the average of all of the points earned, and pruned all of the players below 1.5 times the standard deviation. In addition, each PR player maintains a history of the players that have exploited them.

Please, feel free to take a look and/or contribute to the project!

*This is an ongoing project - I intend on making the program multithreaded to speed up runtimes (it currently slows down significantly with any number of players over 150).

April 24, 2013

Reinstalling Arch.

Recently I decided to reinstall Arch Linux on my laptop because why not? Everything is working, with the major exception of wireless. As you may recall, Arch Linux does not play nice with Broadcom wireless chips.


For those that don't keep up with Arch Linux changes, in late 2012/early 2013 (I don't actually recall which) they switched from init scripts to systemd for system start up. Well, now (in April 2013) they have made the switch from the old network connection manager called netcfg to a new network manager called netctl. One of the primary reasons for this move is that netctl has better integration with systemd.


This [of course] breaks everything network-related. In the past 36 hours, I have spent absurd amounts of time attempting to connect to my school's WAP2-Enterprise network, all to no avail. Network Manager (included with the GNOME3 group in the arch repositories) has been my favorite network manager to date, but it seems to not currently work with netcfg OR netctl. Getting annoyed with network manager caused me to decide to try connecting with wicd, which I have heard wonderful things about but have never tried. After attempting to get a connection up using wicd and netctl, I got tired and decided to go to bed.


Cue today. I figured that if wicd wouldn't connect with netctl, I'd give it a shot with netcfg. I haven't started yet, and I think at this point that I'm just going to wait until tomorrow or Monday (I'm gone all weekend) because it's been a pretty decent day and I don't feel like getting frustrated [again].


Long story short, I'm not entirely sure that netctl currently supports WPA2-Enterprise connections and the current documentation says nothing about any kind of WPA2 encryption. Assuming netcfg works, I'm just going to assume this is the case, because the other option is that my wireless card is borked (which wouldn't necessarily be a bad thing).


TL;DR: netctl says nope, gonna try netcfg.

March 19, 2013

Android, Bootloaders, and Innovation.

Since getting my first android phone in May 2011, I have been extremely into rooting and flashing ROMs onto my phone. My first phone, the HTC Droid Incredible 2, was easy, due to it's unencrypted bootloader. This makes root (superuser) exploits easy, as well as the installation of custom recoveries and ROMs. The bootloader on my current phone (the Motorola Droid Razr) is encrypted. This makes gaining root, installing custom recoveries and ROMs significantly harder.

A bootloader, at it's most basic does nothing but load an OS. However, a bootloader can be used to verify software and things like that.

In terms of android, the bootloader checks the signatures of the files being loaded. If a signature fails the check, the phone doesn't boot. Often, people confuse the difference between "locked" and "encrypted" bootloaders. A locked bootloader is something every phone has out of the factory. An encrypted bootloader a locked bootloader with a layer of encryption that prevents you unlocking the bootloader.

***NOTE*** from here on out, a "locked" bootloader will refer to an encryped bootloader, unless explicitly stated.

Many phones have unencrypted or lightly encrypted bootloaders that are easy to crack. Yet other phones have factory-sanctioned unlocks, allowing the end-user to decrypt and unlock the bootloader.

As of late, there has been some major discussion in the developer community about the future of bootloaders. Most people argue that having a locked bootloader restricts what can be done with a phone. This is where my phone (and previous Motorola phones) comes in. Every android Motorola phone has had a locked bootloader. This has not stopped a select few brilliant devs working on porting ROMs and creating custom recoveries. Some of the things they have come up with just blow me away.

For example, the recovery solution that the developers have come up with is phenomenal. It is called safestrap, and in safestrap 2, one was able to dual-boot one custom ROM alongside the Stock ROM. Well, in safestrap 3 (which is all touch), you can now have 4 custom ROMs alongside the stock ROM.

Another exciting development is the use of a KEXEC (Kay- eksek) kernel. KEXEC is not particularly new to Linux, but to the android community, it is fairly new. This allows developers to make kernels for each ROM, without having to flash a new kernel (which has the potential to brick your phone).

The point is: is having a locked bootloader really all that bad? Yes, it does adversely impact the initial ability to develop for the phone, including rooting. However, having a locked bootloader requires innovation on the part of the non-OEM developers. In any industry, innovation is a driving force. The changes that get made to any android device do get noted by Google, and do eventually get integrated into the Android OS (See the settings toggles added to the notification menu as of Jellybean [4.1]). What's to say that the innovations made today won't be integrated into tomorrow's OS?

What do you think about locked/unlocked bootloaders on mobile devices? Please discuss in the comments section!

March 13, 2013

Set up a High-Quality Development Box for Under $1000 (Part 2)

Being a college student, money is always short. I'm going to walk you through setting up a high-quality development box with Fedora 18. If you don't mind getting super-involved, you could use Arch Linux, however Fedora is really easy to set up and will get you up and running quickly! This is part 2, which covers the installation of Fedora. Part 1, which is about choosing hardware can be found here.

***NOTE*** For this installation, I'm assuming that you have a wired connection.

First: Acquire the installation media
The link to Fedora's installation .iso can be found here. Choose the .iso that looks nicest to you. I'm choosing GNOME for this tutorial.

***NOTE*** For Reference:
GNOME looks a little bit like OSX in terms of layout, while KDE is laid out more like Windows.
Don't let this influence your decision too much though!
Although I am more experienced with Windows than OSX, I tend to prefer GNOME to KDE.


Second: Burn .iso to USB or CD
I'm using the LinuxLive USB Creator to burn the .iso to USB, however this is for Windows only.

Instructions for Linux and Mac can be found here.

Third: Boot the installation media
While your computer is off, insert your USB drive into a USB port. Press the power button, and look for a prompt at the bottom of your screen saying Hit [Some Key] for boot options, or something similar. Common keys are F2, F9, F11, F12, Delete, or Escape. If you're having trouble finding which key it is, google "[your computer model] boot option key" or something to that affect (Or it is effect...? I can never remember...). And select your USB drive.

Fourth: Base install
Once the media has booted, you are presented with a login screen. Just select Live System User (it should be the only option). Once logged in, if you want to play around with Fedora for a little before committing, click on "Try Fedora". Otherwise, choose "Install to Hard Drive".

First you are asked for the language you would like to use during the install, choose whichever language suits you (the default is English (US)). Click continue.
Under storage, click on "Installation Destination" and configure your hard disk. I suggest sticking with automatic partitioning, but you may have to make some changes if dual-booting or choosing to have a separate data partition. When returned to the screen that reads "Localization" and "Storage," click on Begin Installation.
On this screen, all you need to do is set a root password by clicking on the key icon and entering a password twice and clicking done.

***NOTE*** This should be a secure password! It allows root access to your system and can be used to do naughty things by naughty people (get your mind out of the gutter)!

...now we wait for Fedora to finish installing.

Once done, reboot and remove the installation media. When the system comes back up, you are greeted with a welcome screen. Just follow the prompts and choose the default options and you'll be fine!

Fifth: Do a system upgrade.
To perform a system upgrade, we will use yum, Fedora's package manager. Run

sudo yum upgrade

to upgrade all of your packages. It will take a long time, but is highly suggested (This isn't strictly necessary, but it keeps you up-to-date.).

***NOTE*** This step is not necessary for everyone!
Next, we will get wireless working with a Broadcom wireless card. To find out if you have a wireless card, do

lspci -nn | grep 14e4 (14e4 is Broadcom's vendor ID)

If nothing comes up, you can skip to installing development tools! Otherwise, add the rpmfusion repository following the instructions here. Add both free and nonfree.

Then, install broadcom-wl like so

sudo yum install broadcom-wl

...and reboot when done. On reboot, wireless should come up.

Install any development tools you need (Java, Python 2.x or 3.x). You know your needs best, but common tools are an IDE (I suggest Eclipse if you don't have an IDE in mind), and a good text editor like Sublime.

To install Eclipse, do

sudo yum install eclipse

By default, Python 2 is already installed on your system (Version 2.7.3), however you can install Python 3.3.0 simply by running

sudo yum install python3

to run a Python 2 module, run

python [path to module].py

... likewise, to run a Python 3 module, do

python3 [path to module.py]

Congratulations on your new development environment! If there's anything I missed or you want me to cover, please put it in the comments and I'll add it in!

March 11, 2013

Set up a High-Quality Development Box for Under $1000 (Part 1)

Being a college student, money is always short. I'm going to walk you through setting up a high-quality development box with Fedora 18.
***NOTE*** This will be a 2-part tutorial, with the first part about choosing the hardware and the second part about installing Fedora.

Picking your hardware:
Computer hardware is an extremely hard choice to make - doubly so when looking for a machine to run Linux, because nobody offers linux as a default OS option. (Okay, Dell does. Kind of. But I'll cover that later.)

Time to look at specs:
Processor: Anything from an Intel Core 2 Duo to an Intel Core i5 (or if you feel like overkill, go for an i7), you could also go for the ever ambiguous AMD Dual-Core or an AMD Athalon II. I would stay away from the AMD A-Series (for now) though. Although the A series is great for Windows systems, from what I've read there are still issues with Linux systems.

GPU/Graphics:
Unless you're doing something crazy or gaming, integrated graphics will do just fine. In fact, it may be preferable because the Intel integrated graphics are well supported for Linux, whilst NVidia is more or less unsupported. In fact, NVidia was called out by Linus Torvalds for being spectacularly bad about open-source drivers. AMD does have open-source drivers available, but I really don't know anything about them.

RAM:
A decent dev machine should have at least 4GiB of RAM, but feel free to go with anything up to 8GiB. I also suggest getting DDR3 (which is the current standard - chances are that anything you choose will be DDR3).

From there, hard drive space, screen size and cd/dvd drive is up to you. In terms of the original OS, I suggest staying away from Windows 8. Windows 8 introduced something called Secure Boot, which is akin to a locked bootloader and makes it harder to install Linux.

For reference: My Current Linux Machine (Currently runs Arch)

My current machine tackles anything I need to do without thinking about it, although it is a bit old.

In terms of brand, it's really up to you. I tend to avoid Dell because I've had nothing but bad experiences with their hardware. I favor HP and Lenovo.

The cheapest option ($270): The HP 6910p
My suggestion ($501): The Lenovo ThinkPad Edge
The over-the-top option: The Samsung NP700Z7

These are by no means the only machines you can use (Linux will run on just about everything), so feel free to look around on your own!

March 7, 2013

The Wonderful World of Arch (Part 5) [Wireless]

This isn't really a continuation - it's more just my notes on getting wireless working with a Broadcom Wireless chip.

*** LONG ***

First thing first - do *another* system upgrade (I am assuming you are logged in as a normal user and have sudo installed - also assuming you have wired access):

sudo pacman -Syu

This ensures that you have the latest linux headers - required for broadcom wireless.
At this point, I would usually redirect you to the Arch Wiki, but I won't. Unfortunately, the wiki is kind of contradictory about broadcom chips. I'm going to post what worked for *me*. I can't promise that it will work for you, but hopefully it'll give you a good start.

I have a little aside to make now: Installing packages from the AUR (Arch User Repository).

To install a package from the AUR, open a browser (you can install one with pacman: sudo pacman -S chromium). Any browser from here will work. And search google with the string "AUR [package]". Either download the tarball in-browser or wget it from terminal.

cd to the directory the tarball downloaded to and run

tar -xzvf [archive name]

to untar the archive and cd to the directory created. Then run

makepkg

...this will create a *.pkg.tar.xz file which can be installed with

sudo pacman -U [package name].pkg.tar.xz

...this will install the new package.

***NOTE*** You can take a shortcut for installing things from the AUR with a package like aurget. The usage is very similar to that of pacman, hwoever it does not need to be run as root.

Step 1:
Install firmware
Begin by installing b43-fwcutter:

sudo pacman -S b43-fwcutter

Then install b43-firmware from the AUR.

Step 2:
Install broadcom-wl (the wireless driver [proprietary])from the AUR.
Remove b43 and ssb from the kernel with rmmod:

sudo rmmod b43
sudo rmmod ssb



***NOTE*** b43 and ssb may not be loaded - this is okay.

Load wl:

sudo modprobe wl

Check that lib80211 was loaded by wl with lsmod.

sudo lsmod | less

(hit q to exit) If not loaded, load it with

sudo modprobe lib80211

..and update dependencies

sudo depmod -a


Step 3:
Make the module load at boot by creating a file for each module in /etc/modules-load.d with the naming convention [module name].conf
Inside that file, write the module name. For example if you wanted to load wl at boot you would do

sudo nano /etc/modules-load.d/wl.conf

and write wl in the file. Save and exit nano.

You need to load wl, lib80211, and virtio-net at boot.

Configuring Wireless
For configuring wireless, I've chosen to configure everything manually rather than using a network manager like netcfg.
wireless_tools should already be installed. If for some reason it isn't, use pacman to install it.
Additionally, you should install iw and wpa_supplicant, both with pacman.

At this point, you should still be connected to your wired network. You can run ip addr to see the names and connection statuses of each of your interfaces. Make note of the interface that has no ip address - that is your wireless interface. From here on out, replace [interface] with the name of your interface.

***NOTE*** If trying to connect to an ad-hoc network, use "sudo iw [interface] set type ibss" to set your interface to ad-hoc.

Activate the interface with

sudo ip link set [interface] up

...and scan for wireless networks with

sudo iw dev [interface] scan | less

Take note of the SSID, and look for anything referring to WPA or WEP - it will be important when you configure the wireless connection.
The next part is dependent on what kind of security is on the network. Instructions can be found here.
Information on configuring wpa_supplicant.conf can be found here. I can't walk you through this is because it will be different for every network. If you're having trouble, some google-fu will definitely help.
Instead of running

sudo wpa_supplicant -i wlan0 -c /etc/wpa_supplicant.conf

...you should use

sudo wpa_supplicant -Dwext -i[interface] -c/etc/wpa_supplicant.conf -B

-D specifies the driver to use, -i specifies the interface, and -c specifies the configuration file.

From here, you're ready to grab an IP address with

sudo dhcpcd[interface]

...and check that it worked with

ip addr

If you see a line beginning with inet, you have an ip and everything is working!

The next (and final!) step is to configure the network to start at boot.
Create the "/etc/systemd/system/network.service" file with a text editor and make it like this:

[Unit]
Description=Network Connectivity
Wants=network.target
Before=network.target
BindsTo=sys-subsystem-net-devices-[interface].device
After=sys-subsystem-net-devices-[interface].device

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/sbin/ip link set dev [interface] up
ExecStart=/usr/sbin/wpa_supplicant -Dwext -i[interface] -c/etc/wpa_supplicant.conf -B
ExecStart=/sbin/dhcpcd [interface]

[Install]
WantedBy=multi-user.target


Save, and enable with

sudo systemctl enable network

...and reboot! Remove your ethernet cable and wireless should come up on boot! You can check by issuing ip addr.
Congratulations on your fully functioning Arch install!

March 6, 2013

The Wonderful World of Arch (Part 4) [Post-Install]

This is a continuation of my three previous posts, found here, here, and here.

Login using your username and password NOT as root! root should under NO circumstance be used as a normal user.

At this point, we've rebooted and we're ready to configure X.
First, we need to do a system upgrade (to get the latest linux headers) and install sudo.
For the moment, we need to login as root by typing su, then Enter, and then your root password at the password prompt.
Now we can upgrade the system, install sudo, and install X.
Do

pacman -Syu

to upgrade the system, and then:

pacman -S sudo

to install sudo.

Now we have to configure sudo to allow your non-root user to issue root commands.
The usual way to do this is by using:

visudo /etc/sudoers

...however this uses the editor vi, which I do not currently know how to use.

***NOTE*** There is a very good reason for needing to use visudo, which is explained here.

There is a solution to this though:

VISUAL="/usr/bin/nano -p" visudo

That command will open nano as the visudo editor.

In this file, you will need to uncomment the line that reads

# %wheel ALL=(ALL) ALL

by removing the # before the line.

Exit nano, and then type exit to get out of the root shell.

Now we install X.
X (or X11) is a window management system. Ubuntu, Mint, and SUSE all use X under a desktop environment to manage windows.
First, we have to install X from the Arch Repositories:

sudo pacman -S xorg-server xorg-xinit xorg-server-utils
pacman -S mesa


This will be different for everyone, so i'm not going to cover it, instructions can be found here.
If you have a laptop, you should install the synaptics package like so:

sudo pacman -S xf86-input-synaptics

Now to test X. First we install the test environment:

sudo pacman -S xorg-twm xorg-xclock xterm

and then run X:

startx

...and exit by exiting all of the open terminals (there should be 3).

Now that we know X works, it's time to install a GUI!
The desktop environment you choose is up to you - the instructions probably differ for each one. This page has a list of desktop environments (bear in mind that there are more than just those), each with install instructions. I chose Cinnamon because I think it looks gorgeous. The instructions for each DE are fairly straightforward, so I'll leave you on your own for those.

Next comes the display manager, which is essentially a graphical login screen. I chose SLiM, but there are many others. As with the desktop environments, these are fairly straightforward to install and i'm not going to go into the installation.

My next post will be about wrestling with getting WiFi up and working with a Broadcom Wireless chip! Now found here!


March 5, 2013

The Wonderful World of Arch (Part 3)

This is the continuation of my previous posts found here and here.

We left off having created a standard user, and now it's time to install the bootloader. I have decided to use GRUB.
First, install GRUB for BIOS systems:

pacman -S grub-bios

***NOTE*** The following process is for BIOS systems only. If your system uses UEFI, please refer to the documentation found in the Arch Beginners' Guide.

Next, open a virtual console with Alt+F2 and type root at the archiso login: prompt.
Now, create a BIOS boot partition as follows:

cgdisk /dev/sda

Select the 1007.0KiB empty partition and choose new (n).
Hit Enter twice, and when asked for the filesystem type, enter EF02. Do not name the partition.
Hit w to write the filesystem, and quit cgdisk.

Switch back to the original console with Alt+F1 and run grub-install like so:

grub-install --target=i386-pc --recheck /dev/sda
cp /usr/share/locale/en\@quot/LC_MESSAGES/grub.mo /boot/grub/locale/en.mo


Now to configure GRUB, there's not actually much for you to do here, except run a command.

grub-mkconfig -o /boot/grub/grub.cfg

Now onto rebooting! type exit to exit the chroot environment, and unmount the partitions:

umount /mnt/{home,}

...and then reboot:

reboot

...sacrifice your best goat and chicken to the Arch Gods (and remove your installation media)...
...And hopefully it'll boot back up! Mine did!
Next post is about some post-installation stuff. Coming soon! Here!