Tag Archive : rpi

/ rpi

Installing Slackware ARM on QEMU

December 9, 2015 | Article | 1 Comment

Slackware ARM is an slackware port to ARM processor.

In this article, we will discuss about installing Slackware for ARM using QEMU on top of Slackware64. On this article we will use:

  1. Slackware64 14.0 (as host)
  2. QEMU 14.0
  3. Slackware for ARM (as guest)

Although we have experiment on Slackware64, you can do this in any platform which has installed QEMU.

Obtaining the Materials

First, make sure you have installed QEMU. On Linux you can follow this article. Although we don’t use Windows on this article, you can also install QEMU on Windows using this article.

Create a working directory, let’s say SlackARM. Adjust following command with your own:

mkdir -p ~/run
mkdir -p ~/SlackwareARM

SLACKARM="~/SlackwareARM"
WORKINGDIR="~/run"

cd $SLACKARM
mkdir -p kernels/versatile isolinux slackware
cd slackware
mkdir a l

cd $WORKINGDIR
mkdir hdd

We need a kernel, a also a working initrd.

cd $SLACKARM/kernels/versatile
wget -c "ftp://ftp.arm.slackware.com/slackwarearm/slackwarearm-14.0/kernels/versatile/zImage-versatile"
wget -c "http://xecdesign.com/downloads/linux-qemu/kernel-qemu"
cd $SLACKARM/isolinux
wget -c "ftp://ftp.arm.slackware.com/slackwarearm/slackwarearm-14.0/isolinux/initrd-versatile.img"

Next, create a QEMU hard disk which will be used by our Slackware:

cd $WORKINGDIR/hdd
qemu-img create -f raw slackhdd.img 2G

A 2GB disk is sufficient for our experiments. Then go to $SLACKARM/slackware and downloads following packages from here. For simplicity, We only need a packages and l packages. The packages on “a packages” must be downloaded to “a directory“, while l package must be downloaded to l directory. Remember that both directory should be stored on “slackware” directory. Here is the list:

“a” packages ($SLACKARM/slackware/a)

  1. aaa_base-14.0-arm-4.tgz
  2. aaa_elflibs-14.0-arm-2.tgz
  3. aaa_terminfo-5.8-arm-1.tgz
  4. bash-4.2.037-arm-1.tgz
  5. bin-11.1-arm-2.tgz
  6. coreutils-8.19-arm-1.tgz
  7. e2fsprogs-1.42.6-arm-1.tgz
  8. etc-14.0-arm-1.tgz
  9. kernel-modules-versatile-3.4.11_versatile-arm-1.tgz
  10. kernel_versatile-3.4.11-arm-1.tgz
  11. pkgtools-14.0-noarch-2.tgz
  12. shadow-4.1.4.3-arm-6.tgz
  13. sysvinit-2.88dsf-arm-2.tgz
  14. sysvinit-functions-8.53-arm-1.tgz
  15. sysvinit-scripts-2.0-noarch-9.tgz
  16. util-linux-2.21.2-arm-3.tgz

“l” packages ($SLACKARM/slackware/l)

  1. glibc-2.15-arm-8.tgz

Make iso files with content of isolinux, kernels, and slackware. Do following command:

cd $SLACKARM
mkisofs -udf -o $WORKINGDIR/slackware-arm-14.0.iso -R -J -V "Slackware ARM 14.0" -hide-rr-moved -v -d -N -A "Slackware ARM 14.0" .

Notice the trailing dot as part of command. When done, a new iso file slackware-arm-14.0.iso will be created on $SLACKARM. My iso size is 94.7 MB.

Running the System

With initrd, kernel, and ISO file, let’s march to last step which is running the system. Do followings:

cd $WORKINGDIR
qemu-system-arm -m 512 -M versatilepb -kernel $SLACKARM/kernels/versatile/zImage-versatile \
-initrd $SLACKARM/isolinux/initrd-versatile.img -hda hdd/slackhdd.img -cdrom slackware-arm-14.0.iso

Some error messages might shown such as:

/bin/grep: No such file or directory

But don’t worry, if you follow this article you now have SlackwareARM installed on QEMU.

You can proceed like you always do in Slackware installation. Once you done the installation, just quit QEMU.

To boot QEMU for normal operation (not installation), do:

qemu-system-arm -M versatilepb -kernel $SLACKARM/kernels/versatile/kernel-qemu \
-hda hdd/slackhdd.img -append 'root=/dev/sda1' \
-no-reboot -serial stdio

Have fun!

Note: You can also use the slackware-current instead of slackware-14.0. I will leave this as an exercise

Installing RetroPie on Raspberry Pi

December 9, 2015 | Article | No Comments

Raspberry Pi, a small computer powered by ARM architecture is a very interesting board for learning embedded system. From Media center into a simple server, Raspberry Pi has opened wide possibility to be explored. Who knows, Pi now can also be used as “Game Console“? What we talk here is Raspberry Pi now can be used as a Game Emulator to play many game console platform.

For this article I use following:

  1. Slackware64 14.0
  2. Windows 8
  3. Raspberry Pi model B
  4. RetroPie image

You can use either Linux (in this article, Slackware) or Windows (in this article Windows 8). Just pick one and follow the rest of article for your choice.

Obtain the Materials

The Operating System images I used is RetroPie, which can be downloaded from RetroPie site. This is huge image, around 1.3GB for it. When extracted, it occupy around 3.2 GB storage space. Be prepared!

The RetroPie software is basically EmulationStation and a stripped down version of Raspbian.

Prepare the Disk (SD Card)

To boot the Raspberry Pi, an installation media and storage media is needed. All we need is a single SD card. The bigger space, the better. You need space for OS and additional space to hold your ROMS. On this article I use my 8GB SD card. You can use any SD card you want, but I recommend to use at least 4GB SD card. The image we download on previous section will be stored on this card and later installed. Make sure you have a way to write on SD card.

Windows-based Instruction

For Windows user, you can follow this section to “burn” the image. For this purpose you need additional software for writing to SD card, such as Win32DiskImager utility.

  1. Extract the image (in this case RetroPieImage_v1.7.zip) so you will get an .img file.
  2. Insert SD card into SD card reader and check what drive letter it assigned to. For example G:\
  3. If it is not new, format it. Or at least make sure there is only one partition (FAT32 is recommended).
  4. Run the Win32DiskImager with administrator privileges.
  5. Select the image we have extracted.
  6. Select the drive letter of the SD card on our machine. Make sure you have the correct drive, or you will destroy data on that drive.
  7. Click Write and wait. The process should be not long.
  8. Exit the imager and eject the SD card

Beside Win32DiskImager, you can also use other tool such as Flashnul.

  1. Follow step 1 to step 3 for Win32DiskImager’s solution
  2. Extract Flashnul from the archive
  3. Open command prompt with elevated privilege (administrator privilege).
  4. Go to your extracted directory and run flashnul with argument “-p”. For example: flashnul -p
  5. You will get list of physical drive attached on your machine, and list of drive. Make sure the drive is correct. At time of writing this article, the SD card is detected as device number 1 with and mounted to drive G:
  6. Load the image to flashnul: flashnul 1 -L RetroPieImage_v1.7.img
  7. If you get an access denied error, try re-plugging the SD card and make sure to close all explorer windows or folders open for the device. If still get denial, try substitute the device number with its drive letter: flashnul G: -L RetroPieImage_v1.7.img

At this point, you have successfully written image to your SD card. And I assume you are. You can proceed to next stage.

Linux-based Instruction

Writing image on Linux is easier, in my opinion. The utility we use is “dd” which is already bundled on most distro. Make sure you know the correct device file for your SD card. In my machine I use a built in card reader and detect my SD card as /dev/sdb. It might be different on your system so better check it. For this article I use /dev/sdb to refer to SD card.

  1. Extract the image (in this case pidora-18-r1c.zip) so you will get an .img file.
  2. Insert SD card into SD card reader .
  3. If it is not new, format it. Or at least make sure there is only one partition (FAT32 is recommended).
  4. Unmount the SD card if it is mounted. We need the whole SD card so if you see partition such as /dev/sdb1, etc its better you unmount them all.
  5. Write the image to SD card. Make sure you replace the input file after if= argument with correct path to .img file and “/dev/sdb” in the output file of= argument with your device. Also make sure to use whole SD drive and not their partition (i.e. not use /dev/sdb1, /dev/sdb1, etc). The command: dd bs=4M if=RetroPieImage_v1.7.img of=/dev/sdb
  6. Run sync as root. This will ensure the write cache is flushed and safe to unmount SD card.
  7. Remove SD card from card reader.

If you hesitate to use terminal and prefer to use GUI method, here is the tutorial. Note that we

  1. Do step 1 to step 3 for previous tutorial. Make sure your directory or image file doesn’t contain any spaces.
  2. Install the ImageWriter tool from https://launchpad.net/usb-imagewriter
  3. Launch the ImageWriter tool (needs administrative privileges)
  4. Select the image file (in this case RetroPieImage_v1.7.img) to be written to the SD card (note: because you started ImageWriter as administrator the starting point when selecting the image file is the administrator’s home folder so you need to change to your own home folder to select the image file)
  5. Select the target device to write the image to. In my case, it’s /dev/sdb
  6. Click the “Write to device” button
  7. Wait for the process to finish and then insert the SD card in the Raspberry Pi

At this point, you have successfully written image to your SD card. And I assume you are. You can proceed to next stage.

Booting Up and Configuring

RetroPie differs from other distribution I have written so far. The connection for audio and video are same to other, the difference comes to the configuration it has.

You will be asked to configure your controller. This isn’t the calibration that is needed to control the various games that you will be playing, this is to configure your retro controller, joystick or even keyboard to navigate the EmulationStation software.

Once you are done, tap the button or key you set as Menu, and select Exit. This will quit out of EmulationStation and go back to the command line. From there, it’s like other OSes, you should enter GUI manually using

startx

The GUI will be launched, enabling us to make necessary changes to controller configuration. In the file manager, open RetroPie\Configs\all and runretroarch.cfg in the text editor. Things might different for each controller available in the market, adjust with your needs.

Running the Pi

To resize the SD card after installation, you can follow this article.

To log in on your Raspberry pi you can use the default login, which is:

Username: root
Password: raspberrypi

Have fun 😀

Installing Pidora on Raspberry Pi

December 9, 2015 | Article | No Comments

Raspberry Pi, a small computer powered by ARM architecture is a very interesting board for learning embedded system. In this article we will discuss about how to install how to install Pidora on Raspberry Pi.

For this article I use following:

  1. Slackware64 14.0
  2. Windows 8
  3. Raspberry Pi model B
  4. Pidora version 18

You can use either Linux (in this article, Slackware) or Windows (in this article Windows 8). Just pick one and follow the rest of article for your choice.

Obtain the Materials

The Operating System images I used is Pidora which use hard-float system ABI provided by Raspberry Pi on their download page. The version I use is latest version at time of writing this article (per August 24th, 2013) and only use hard-float ABI. You can either direct download on this link, or download by torrent by this link.

Prepare the Disk (SD Card)

To boot the Raspberry Pi, an installation media and storage media is needed. All we need is a single SD card. On this article I use my 8GB SD card. You can use any SD card you want, but I recommend to use at least 4GB SD card. The image we download on previous section will be stored on this card and later installed. Make sure you have a way to write on SD card.

Windows-based Instruction

For Windows user, you can follow this section to “burn” the image. For this purpose you need additional software for writing to SD card, such as Win32DiskImager utility.

  1. Extract the image (in this case pidora-18-r1c.zip) so you will get an .img file.
  2. Insert SD card into SD card reader and check what drive letter it assigned to. For example G:\
  3. If it is not new, format it. Or at least make sure there is only one partition (FAT32 is recommended).
  4. Run the Win32DiskImager with administrator privileges.
  5. Select the image we have extracted.
  6. Select the drive letter of the SD card on our machine. Make sure you have the correct drive, or you will destroy data on that drive.
  7. Click Write and wait. The process should be not long.
  8. Exit the imager and eject the SD card

Beside Win32DiskImager, you can also use other tool such as Flashnul.

  1. Follow step 1 to step 3 for Win32DiskImager’s solution
  2. Extract Flashnul from the archive
  3. Open command prompt with elevated privilege (administrator privilege).
  4. Go to your extracted directory and run flashnul with argument “-p”. For example: flashnul -p
  5. You will get list of physical drive attached on your machine, and list of drive. Make sure the drive is correct. At time of writing this article, the SD card is detected as device number 1 with and mounted to drive G:
  6. Load the image to flashnul: flashnul 1 -L pidora-18-r1c.img
  7. If you get an access denied error, try re-plugging the SD card and make sure to close all explorer windows or folders open for the device. If still get denial, try substitute the device number with its drive letter: flashnul G: -L pidora-18-r1c.img

At this point, you have successfully written image to your SD card. And I assume you are. You can proceed to next stage.

Linux-based Instruction

Writing image on Linux is easier, in my opinion. The utility we use is “dd” which is already bundled on most distro. Make sure you know the correct device file for your SD card. In my machine I use a built in card reader and detect my SD card as /dev/sdb. It might be different on your system so better check it. For this article I use /dev/sdb to refer to SD card.

  1. Extract the image (in this case pidora-18-r1c.zip) so you will get an .img file.
  2. Insert SD card into SD card reader .
  3. If it is not new, format it. Or at least make sure there is only one partition (FAT32 is recommended).
  4. Unmount the SD card if it is mounted. We need the whole SD card so if you see partition such as /dev/sdb1, etc its better you unmount them all.
  5. Write the image to SD card. Make sure you replace the input file after if= argument with correct path to .img file and “/dev/sdb” in the output file of= argument with your device. Also make sure to use whole SD drive and not their partition (i.e. not use /dev/sdb1, /dev/sdb1, etc). The command: dd bs=4M if=pidora-18-r1c.img of=/dev/sdb
  6. Run sync as root. This will ensure the write cache is flushed and safe to unmount SD card.
  7. Remove SD card from card reader.

If you hesitate to use terminal and prefer to use GUI method, here is the tutorial. Note that we

  1. Do step 1 to step 3 for previous tutorial. Make sure your directory or image file doesn’t contain any spaces.
  2. Install the ImageWriter tool from https://launchpad.net/usb-imagewriter
  3. Launch the ImageWriter tool (needs administrative privileges)
  4. Select the image file (in this case pidora-18-r1c.img) to be written to the SD card (note: because you started ImageWriter as administrator the starting point when selecting the image file is the administrator’s home folder so you need to change to your own home folder to select the image file)
  5. Select the target device to write the image to. In my case, it’s /dev/sdb
  6. Click the “Write to device” button
  7. Wait for the process to finish and then insert the SD card in the Raspberry Pi

At this point, you have successfully written image to your SD card. And I assume you are. You can proceed to next stage.

Running the Pi

You have write image and at this point your raspberry pi is ready. Now set up raspberry pi to boot: insert your SD card back to raspberry pi, put on power, plug video output (either HDMI or RCA).

To resize the SD card after installation, you can follow this article.

To log in on your Raspberry pi you can use the default login, which is:

Username: root
Password: raspberrypi

Have fun 😀

Raspberry Pi GPIO Reference

December 9, 2015 | Article | 1 Comment

This is reference to Raspberry Pi GPIO, not to Raspberry Pi 2 GPIO.

GPIO or General Purpose Input/Output is a generic pin on a chip whose behavior (including whether it is an input or output pin) can be controlled (programmed) through software. One pin can be act as either Input or Output but can’t be both at a time, means it cannot send and receive data at same time.

GPIO pins have no special purpose defined, and go unused by default.

The Raspberry Pi allows peripherals and expansion boards (such as Rpi Gertboard) to access the CPU by exposing the inputs and outputs.

Quick Cheatsheet

raspberry-pi-gpio-cheat-sheet

Only covers P1 Header

Hardware

P1 Header

Raspberry Pi (both model A and B) has 26 pin 2.54mm (100 mil) expansion header, marked as P1, arranged in a 2×13 strip. They provide 8 GPIO pins plus access to I²C, SPI, UART, as well as +3.3 V, +5 V and GND supply lines. Pin one is the pin in the first column and on the bottom row.

RPi_P1_header

The GPIO pin-header layout, seen from top. Three pins changed between PCB rev.1 and rev.2.

GPIOs

GPIO voltage levels are 3.3 V and are not 5V tolerant. There is no over voltage protection on the board. Thus, you should use an external board with buffers, level conversion, and analog I/O rather than soldering directly onto the main board.

All the GPIO pins can be reconfigured to provide alternate functions, SPI, PWM, I²C, and so. At reset only pins GPIO 14 & 15 are assigned to the alternate function UART, those two can be switched back to GPIO to provide a total of 17 GPIO pins.

Each GPIO can interrup, high/low/rise/fall/change. There is currently no support for GPIO interrupts in the official kernel. However there is a patch, requiring compilation of modified source tree.

GPIO input hysteresis (Schmitt trigger) can be on or off, output slew rate can be fast or limited, and source and sink current is configurable from 2mA up to 16mA. The chipset GPIO pins 0-27 are in the same block and these properties are set per block, not per pin.

R-Pi PCB Revision 2 UPDATE: The R-Pi Rev.2 board being rolled out starting in September 2012 adds 4 more GPIO on a new connector called P5, and changes some of the existing P1 GPIO pinouts. On Rev2, GPIO_GEN2 [BCM2835/GPIO27] is routed to P1 pin 13, and changes what was SCL0/SDA0 to SCL1/SDA1: SCL1 [BCM2835/GPIO3] is routed to P1 pin 5, SDA1 [BCM2835/GPIO2] is routed to P1 pin 3. Also the power and ground connections previously marked “Do Not Connect” on P1 will remain as connected, specifically: P1-04:+5V0, P1-09:GND, P1-14:GND, P1-17:+3V3, P1-20:GND, P1-25:GND.

P1 Header Pin, top row:

Pin Number Pin Name Rev1 Pin Name Rev2 Hardware Notes Alt 0 Function Other Alternative Functions
P1-02 5V0 Supply through input poly fuse
P1-04 5V0 Supply through input poly fuse
P1-06 GND
P1-08 GPIO 14 Boot to Alt 0 -> UART0_TXD ALT5 = UART1_TXD
P1-10 GPIO 15 Boot to Alt 0 -> UART0_RXD ALT5 = UART1_RXD
P1-12 GPIO 18 PCM_CLK ALT4 = SPI1_CE0_N ALT5 = PWM0
P1-14 GND
P1-16 GPIO23 ALT3 = SD1_CMD ALT4 = ARM_RTCK
P1-18 GPIO24 ALT3 = SD1_DAT0 ALT4 = ARM_TDO
P1-20 GND
P1-22 GPIO25 ALT3 = SD1_DAT1 ALT4 = ARM_TCK
P1-24 GPIO08 SPI0_CE0_N
P1-26 GPIO07 SPI0_CE1_N

P1 header Pin, bottom row:

Pin Number Pin Name Rev1 Pin Name Rev2 Hardware Notes Alt 0 Function Other Alternative Functions
P1-01 3.3 V 50 mA max (01 & 17)
P1-03 GPIO 0 GPIO 2 1K8 pull up resistor I2C0_SDA / I2C1_SDA
P1-05 GPIO 1 GPIO 3 1K8 pull up resistor I2C0_SCL / I2C1_SCL
P1-07 GPIO 4 GPCLK0 ALT5 = ARM_TDI
P1-09 GND
P1-11 GPIO17 ALT3 = UART0_RTS ALT4 = SPI1_CE1_N ALT5 = UART1_RTS
P1-13 GPIO21 GPIO27 PCM_DOUT / reserved ALT4 = SPI1_SCLK ALT5 = GPCLK1 / ALT3 = SD1_DAT3 ALT4 = ARM_TMS
P1-15 GPIO22 ALT3 = SD1_CLK ALT4 = ARM_TRST
P1-17 3.3 V 50 mA max (01 & 17)
P1-19 GPIO10 SPI0_MOSI
P1-21 GPIO9 SPI0_MISO
P1-23 GPIO11 SPI0_SCLK
P1-25 GND

Legend:

Colour legend
+5 V
+3.3 V
Ground, 0V
UART
GPIO
SPI
I²C

Pin 3 (SDA0) and Pin 5 (SCL0) are preset to be used as an I²C interface. So there are 1.8 kilohm pulls up resistors on the board for these pins.

Pin 12 supports PWM .

It is also possible to reconfigure GPIO connector pins P1-7, 15, 16, 18, 22 (chipset GPIOs 4 and 22 to 25) to provide an ARM JTAG interface. However ARM_TMS isn’t available on the GPIO connector (chipset pin 12 or 27 is needed). Chipset pin 27 is available on S5, the CSI camera interface however.

It is also possible to reconfigure GPIO connector pins P1-12 and 13 (chipset GPIO 18 and 21) to provide an I2S (a hardware modification may be required) or PCM interface. However, PCM_FS and PCM_DIN (chipset pins 19 and 20) are needed for I2S or PCM.

A second I²C interface (GPIO02_ALT0 is SDA1 and GPIO03_ALT0 is SCL1) and two further GPIOs (GPIO05_ALT0 is GPCLK1, and GPIO27) are available on S5, the CSI camera interface.

Power pins

The maximum permitted current draw from the 3.3V pins is 50mA.

Maximum permitted current draw from the 5V pin is the USB Input current (usually 1A) minus any current draw from the rest of the board.

  1. Model A: 1000mA – 500mA -> max current draw: 500mA
  2. Model B: 1000mA – 700mA -> max current draw: 300mA

Be very careful with the 5 V pins P1-02 and P1-04. If you short 5 V to any other P1 pin you may permanently damage your RasPi. Before probing P1, it’s a good idea to strip short pieces of insulation off a wire and push them over the 5 V pins so you don’t accidentally short them with a probe.

GPIO Hardware Hacking

The complete list of chipset GPIO pins are available on the GPIO connector is:

0, 1, 4, 7, 8, 9, 10, 11, 14, 15, 17, 18, 21, 22, 23, 24, 25

(On the Revision2.0 Raspberry Pis, this list changes to 2, 3, 4, 7, 8, 9, 10, 11, 14, 15, 17, 18, 22, 23, 24, 25, 27, with 28, 29, 30, 31 additionally available on the P5 header).

P1-03 and P1-05 (SDA0 and SCL0 / SDA1 and SCL1) have 1.8 kiloohm pull-up resistors to 3.3V.

If 17 GPIOs aren’t sufficient for your project, there are a few other signals potentially available, with varying levels of software and hardware (soldering iron) hackery skills:

GPIO02, 03, 05 and 27 are available on S5 (the CSI interface) when a camera peripheral is not connected to that socket, and are configured by default to provide the functions SDA1, SCL1, CAM_CLK and CAM_GPIO respectively. SDA1 and SCL1 have 1K6 pull-up resistors to 3.3 V.

GPIO06 is LAN_RUN and is available on pad 12 of the footprint for IC3 on the Model A. On Model B, it is in use for the Ethernet function.

There are a few other chipset GPIO pins accessible on the PCB but are in use:

  • GPIO16 drives status LED D5 (usually SD card access indicator)
  • GPIO28-31 are used by the board ID and are connected to resistors R3 to R10 (only on Rev1.0 boards).
  • GPIO40 and 45 are used by analogue audio and support PWM. They connect to the analogue audio circuitry via R21 and R27 respectively.
  • GPIO46 is HDMI hotplug detect (goes to pin 6 of IC1).
  • GPIO47 to 53 are used by the SD card interface. In particular, GPIO47 is SD card detect (this would seem to be a good candidate for re-use). GPIO47 is connected to the SD card interface card detect switch; GPIO48 to 53 are connected to the SD card interface via resistors R45 to R50.

Raspberry Pi BCM2835 Datasheet

Based on BCM2835 datasheet, including any relevant errata, with a couple of extra columns.

Any GPIOs that aren’t connected on the RaspberryPi Model B revision 1.0 circuit board are crossed out, and the GPIOs available on the GPIO Connector (P1) are in bold, with their default function (according to the schematics) in bold italics.

GPIO Pins Alternative Function Assignment

Pull ALT0 ALT1 ALT2 ALT3 ALT4 ALT5 RPi Rev1.0 signal name RPi Rev2.0 signal name RPi Rev1.0 connection RPi Rev2.0 connection
GPIO0
High SDA0 SA5 <reserved> SDA0 SDA0 P1-03 S5-14
GPIO1
High SCL0 SA4 <reserved> SCL0 SCL0 P1-05 S5-13
GPIO2
High SDA1 SA3 <reserved> SDA1 SDA1 S5-14 P1-03
GPIO3
High SCL1 SA2 <reserved> SCL1 SCL1 S5-13 P1-05
GPIO4
High GPCLK0 SA1 <reserved> ARM_TDI GPIO_GCLK GPIO_GCLK P1-07 P1-07
GPIO5
High GPCLK1 SA0 <reserved> ARM_TDO CAM_CLK CAM_CLK S5-12 S5-12
GPIO6
High GPCLK2 SOE_N / SE <reserved> ARM_RTCK LAN_RUN LAN_RUN IC3-12 IC3-12
GPIO7
High SPI0_CE1_N SWE_N / SRW_N <reserved> SPI_CE1_N SPI_CE1_N P1-26 P1-26
GPIO8
High SPI0_CE0_N SD0 <reserved> SPI_CE0_N SPI_CE0_N P1-24 P1-24
GPIO9
Low SPI0_MISO SD1 <reserved> SPI_MISO SPI_MISO P1-21 P1-21
GPIO10
Low SPI0_MOSI SD2 <reserved> SPI_MOSI SPI_MOSI P1-19 P1-19
GPIO11
Low SPI0_SCLK SD3 <reserved> SPI_SCLK SPI_SCLK P1-23 P1-23
GPIO12
Low PWM0 SD4 <reserved> ARM_TMS nc nc
GPIO13
Low PWM1 SD5 <reserved> ARM_TCK nc nc
GPIO14
Low TXD0 SD6 <reserved> TXD1 TXD0 TXD0 P1-08 P1-08
GPIO15
Low RXD0 SD7 <reserved> RXD1 RXD0 RXD0 P1-10 P1-10
GPIO16
Low <reserved> SD8 <reserved> CTS0 SPI1_CE2_N CTS1 STATUS_LED_N STATUS_LED_N D5 (OK LED) D5 (ACT LED)
GPIO17
Low <reserved> SD9 <reserved> RTS0 SPI1_CE1_N RTS1 GPIO_GEN0 GPIO_GEN0 P1-11 P1-11
GPIO18
Low PCM_CLK SD10 <reserved> BSCSL SDA / MOSI SPI1_CE0_N PWM0 GPIO_GEN1 GPIO_GEN1 P1-12 P1-12
GPIO19
Low PCM_FS SD11 <reserved> BSCSL SCL / SCLK SPI1_MISO PWM1 nc nc
GPIO20
Low PCM_DIN SD12 <reserved> BSCSL / MISO SPI1_MOSI GPCLK0 nc nc
GPIO21
Low PCM_DOUT SD13 <reserved> BSCSL / CE_N SPI1_SCLK GPCLK1 GPIO_GEN2 CAM_GPIO P1-13 S5-11
GPIO22
Low <reserved> SD14 <reserved> SD1_CLK ARM_TRST GPIO_GEN3 GPIO_GEN3 P1-15 P1-15
GPIO23
Low <reserved> SD15 <reserved> SD1_CMD ARM_RTCK GPIO_GEN4 GPIO_GEN4 P1-16 P1-16
GPIO24
Low <reserved> SD16 <reserved> SD1_DAT0 ARM_TDO GPIO_GEN5 GPIO_GEN5 P1-18 P1-18
GPIO25
Low <reserved> SD17 <reserved> SD1_DAT1 ARM_TCK GPIO_GEN6 GPIO_GEN6 P1-22 P1-22
GPIO26
Low <reserved> <reserved> <reserved> SD1_DAT2 ARM_TDI nc nc
GPIO27
Low <reserved> <reserved> <reserved> SD1_DAT3 ARM_TMS CAM_GPIO GPIO_GEN2 S5-11 P1-13
GPIO28
SDA0 SA5 PCM_CLK <reserved> CONFIG0 GPIO_GEN7 R10 / R8 P5-3
GPIO29
SCL0 SA4 PCM_FS <reserved> CONFIG1 GPIO_GEN8 R9 / R7 P5-4
GPIO30
Low <reserved> SA3 PCM_DIN CTS0 CTS1 CONFIG2 GPIO_GEN9 R6 / R4 P5-5
GPIO31
Low <reserved> SA2 PCM_DOUT RTS0 RTS1 CONFIG3 GPIO_GEN10 R5 / R3 P5-6
GPIO32
Low GPCLK0 SA1 <reserved> TXD0 TXD1 nc nc
GPIO33
Low <reserved> SA0 <reserved> RXD0 RXD1 nc nc
GPIO34
High GPCLK0 SOE_N / SE <reserved> <reserved> nc nc
GPIO35
High SPI0_CE1_N SWE_N / SRW_N <reserved> nc nc
GPIO36
High SPI0_CE0_N SD0 TXD0 <reserved> nc nc
GPIO37
Low SPI0_MISO SD1 RXD0 <reserved> nc nc
GPIO38
Low SPI0_MOSI SD2 RTS0 <reserved> nc nc
GPIO39
Low SPI0_SCLK SD3 CTS0 <reserved> nc nc
GPIO40
Low PWM0 SD4 <reserved> SPI2_MISO TXD1 PWM0_OUT PWM0_OUT R21 R21
GPIO41
Low PWM1 SD5 <reserved> <reserved> SPI2_MOSI RXD1 nc nc
GPIO42
Low GPCLK1 SD6 <reserved> <reserved> SPI2_SCLK RTS1 nc nc
GPIO43
Low GPCLK2 SD7 <reserved> <reserved> SPI2_CE0_N CTS1 nc nc
GPIO44
GPCLK1 SDA0 SDA1 <reserved> SPI2_CE1_N nc nc
GPIO45
PWM1 SCL0 SCL1 <reserved> SPI2_CE2_N PWM1_OUT PWM1_OUT R27 R27
GPIO46
High <internal> HDMI_HPD_P HDMI_HPD_P IC1-6 IC1-6
GPIO47
High <internal> SD_CARD_DET SD_CARD_DET S8-10 S8-10
GPIO48
High <internal> SD_CLK_R SD_CLK_R R48 R48
GPIO49
High <internal> SD_CMD_R SD_CMD_R R47 R47
GPIO50
High <internal> SD_DATA0_R SD_DATA0_R R49 R49
GPIO51
High <internal> SD_DATA1_R SD_DATA1_R R50 R50
GPIO52
High <internal> SD_DATA2_R SD_DATA2_R R45 R45
GPIO53
High <internal> SD_DATA3_R SD_DATA3_R R46 R46
Pull ALT0 ALT1 ALT2 ALT3 ALT4 ALT5 RPi Rev1.0 signal name RPi Rev2.0 signal name RPi Rev1.0 connection RPi Rev2.0 connection

As in the table above, the GPIOs available on the GPIO Connector (P1) are in bold, with their default function (according to the schematics) in bold italics.

Special function legend:

Name Function Datasheet section GPIOs
SDA0
BSC master 0 data line BSC GPIO0 GPIO28 GPIO44
SCL0
BSC master 0 clock line BSC GPIO1 GPIO29 GPIO45
SDA1
BSC master 1 data line BSC GPIO2 GPIO44
SCL1
BSC master 1 clock line BSC GPIO3 GPIO45
GPCLK0
General purpose Clock 0 <TBD> GPIO4 GPIO20 GPIO32 GPIO34
GPCLK1
General purpose Clock 1 <TBD> GPIO5 GPIO21 GPIO42 GPIO44
GPCLK2
General purpose Clock 2 <TBD> GPIO6 GPIO43
SPI0_CE1_N
SPI0 Chip select 1 SPI GPIO7 GPIO35
SPI0_CE0_N
SPI0 Chip select 0 SPI GPIO8 GPIO36
SPI0_MISO
SPI0 MISO SPI GPIO9 GPIO37
SPI0_MOSI
SPI0 MOSI SPI GPIO10 GPIO38
SPI0_SCLK
SPI0 Serial clock SPI GPIO11 GPIO39
PWMx
Pulse Width Modulator 0..1 Pulse Width Modulator PWM0: GPIO12 GPIO18 GPIO40
PWM1: GPIO13 GPIO19 GPIO41 GPIO45
TXD0
UART 0 Transmit Data UART GPIO14 GPIO32 GPIO36
RXD0
UART 0 Receive Data UART GPIO15 GPIO33 GPIO37
CTS0
UART 0 Clear To Send UART GPIO16 GPIO30 GPIO39
RTS0
UART 0 Request To Send UART GPIO17 GPIO31 GPIO38
PCM_CLK
PCM clock PCM Audio GPIO18 GPIO28
PCM_FS
PCM Frame Sync PCM Audio GPIO19 GPIO29
PCM_DIN
PCM Data in PCM Audio GPIO20 GPIO30
PCM_DOUT
PCM data out PCM Audio GPIO21 GPIO31
SAx
Secondary mem Address bus Secondary Memory Interface many
SOE_N / SE
Secondary mem. Controls Secondary Memory Interface GPIO6 GPIO34
SWE_N / SRW_N
Secondary mem. Controls Secondary Memory Interface GPIO7 GPIO35
SDx
Secondary mem. data bus Secondary Memory Interface many
BSCSL SDA / MOSI
BSC slave Data, SPI slave MOSI BSC/SPI slave GPIO18
BSCSL SCL / SCLK
BSC slave Clock, SPI slave clock BSC/SPI slave GPIO19
BSCSL – / MISO
BSC <not used>, SPI MISO BSC/SPI slave GPIO20
BSCSL – / CE_N
BSC <not used>, SPI CSn BSC/SPI slave GPIO21
SPI1_CEx_N
SPI1 Chip select 0-2 Auxiliary I/O SPI1_CE0_N: GPIO18
SPI1_CE1_N: GPIO17
SPI1_CE2_N: GPIO16
SPI1_MISO
SPI1 MISO Auxiliary I/O GPIO19
SPI1_MOSI
SPI1 MOSI Auxiliary I/O GPIO20
SPI1_SCLK
SPI1 Serial clock Auxiliary I/O GPIO21
TXD1
UART 1 Transmit Data Auxiliary I/O GPIO14 GPIO32 GPIO40
RXD1
UART 1 Receive Data Auxiliary I/O GPIO15 GPIO33 GPIO41
CTS1
UART 1 Clear To Send Auxiliary I/O GPIO16 GPIO30 GPIO43
RTS1
UART 1 Request To Send Auxiliary I/O GPIO17 GPIO31 GPIO42
SPI2_CEx_N
SPI2 Chip select 0-2 Auxiliary I/O SPI2_CE0_N: GPIO43
SPI2_CE1_N: GPIO44
SPI2_CE2_N: GPIO45
SPI2_MISO
SPI2 MISO Auxiliary I/O GPIO40
SPI2_MOSI
SPI2 MOSI Auxiliary I/O GPIO41
SPI2_SCLK
SPI2 Serial clock Auxiliary I/O GPIO42
ARM_TRST
ARM JTAG reset <TBD> GPIO22
ARM_RTCK
ARM JTAG return clock <TBD> GPIO6 GPIO23
ARM_TDO
ARM JTAG Data out <TBD> GPIO4 GPIO24
ARM_TCK
ARM JTAG Clock <TBD> GPIO13 GPIO25
ARM_TDI
ARM JTAG Data in <TBD> GPIO4 GPIO26
ARM_TMS
ARM JTAG Mode select <TBD> GPIO12 GPIO27
Name Function Datasheet section GPIOs

P2 Header

P2 header is the VideoCore JTAG and use only during the production of the board. It cannot be used as the ARM JTAG. This connector is unpopulated in Rev 2.0 boards.

RPi_P2_header

Usefule P2 pins:

  1. Pin 1 – 3.3V (same as P1-01, 50mA max current draw across both of them)
  2. Pin 7 – GND
  3. Pin 8 – GND

P3 Header

P3 header, inpopulated, is the LAN9512 JTAG. This header is located directly next to P2 header.

RPi_P3_header

Usefule P3 pins:

  1. Pin 7 – GND

P5 Header

Added with the release of the Revision 2.0 PCB design. This pins located directly next to P1 header.

RPi_P5_header

(Seen from the back of the board).

P5 header pin out, top row:

Pin Number Pin Name Rev2 Hardware Notes Alt 0 Function Other Alternative Functions
P5-01 5V0 Supply through input poly fuse
P5-03 GPIO28 I2C0_SDA ALT2 = PCM_CLK
P5-05 GPIO30 ALT2 = PCM_DIN ALT3 = UART0_CTS ALT5 = UART1_CTS
P5-07 GND

P5 header pin out, bottom row:

Pin Number Pin Name Rev2 Hardware Notes Alt 0 Function Other Alternative Functions
P5-02 3.3 V 50 mA max (combined with P1)
P5-04 GPIO29 I2C0_SCL ALT2 = PCM_FS
P5-06 GPIO31 ALT2 = PCM_DOUT ALT3 = UART0_RTS ALT5 = UART1_RTS
P5-08 GND

Note that the connector is intended to be mounted on the bottom of the PCB, so that for those who put the connector on the top side, the pin numbers are swapped. Pin 1 and pin 2 are swapped, etc.

P6 Header

P6 header was added with the release of the Revision 2.0 PCB design. This header is located next to HDMI output.

RPi_P6_header

P6 pinout:

Pin Number Pin Name Rev2 Hardware Notes
P6-01 RUN Short to ground to reset the BCM2835
P6-02 GND

A reset button can be attached to the P6 header, with which the Pi can be reset. Momentarily shorting the two pins of P6 together will cause a soft reset of the CPU (which can also ‘wake’ the Pi from halt/shutdown state).

Internal Pull-Ups and Pull-Downs

The GPIO ports include the ability to enable and disable internal pull-up or pull-down resistors (see below for code examples/support of this).

Pull-up is Min. 50K Ohm, Max 65 KOhm.

Pull-down is Min. 50K Ohm, Max 60 KOhm.

Software

The foundation (Raspberry Pi Foundation) will not include a GPIO driver in the initial release. However the standard Linux GPIO drivers should work with minimal modification.

The community implemented SPI and I²C drivers, which will be integrated with the new Linux pinctrl.

Further reference

  1. http://en.wikipedia.org/wiki/GPIO

Installing OpenELEC on Raspberry Pi

December 9, 2015 | Article | No Comments

Raspberry Pi, a small computer powered by ARM architecture is a very interesting board for learning embedded system. In this article we will discuss about how to install how to install OpenELEC on Raspberry Pi.

For this article I use following:

  1. Slackware64 14.0
  2. Windows 8
  3. Raspberry Pi model B
  4. OpenELEC

You can use either Linux (in this article, Slackware) or Windows (in this article Windows 8). Just pick one and follow the rest of article for your choice.

The installation process will be divide the content into three section according to the host platform:

  1. Automated Installation using Linux
  2. Installation on Linux
  3. Generic Installation for QEMU

What is OpenELEC?

OpenELEC is an embedded operating system built around XBMC, the open source entertainment media hub. Home Theatre PCs are known to be hard to install and configure and can take a massive amount of time to keep running. OpenELEC, on the other hand, is designed to be as lightweight as possible in terms of size and complexity meaning your HTPC becomes no harder to configure than satellite box or DVD player. With it’s small footprint, OpenELEC is also ideal for small systems based on Atom or Fusion platforms so we won’t need a whole computer in your living room!

OpenELEC is designed to be lightweight. It support many system such as NVIDIA’s ION platform, AMD’s Fusion platform, and Broadcom’s Crystal HD chip. OpenELEC can support high definition content on machines with low-powered processors by offloading video content to supported graphics cards and decoders. This means we can build (or buy) small, silent machines to be effectively used as a media center.

Obtain the Materials

The Operating System images I used is latest version of OpenELEC. The version I use is latest version, at time of writing this article (per August 25th, 2013), and can be download from their official site here. Verify your package, you should have a tarball package (file that ends in .tar.bz2) with correct checksum.

Exploring the Package

Extract the content and you will have a folder with some content on it.

For the latest package we download (version 3.1.6) there will be three directory four plaintext, one shell script file, and one image file.

The three directories are:

3rdparty
Like implied by name, the 3rdparty code and file. There is only one folder there, bootloader. The files inside there are used to make a bootloader for OpenELEC’s SD Card.
licenses
Various license used. Including license by third party such as NVIDIA, etc.
target
Our primary interest. There are four files here: KERNEL, KERNEL.md5, SYSTEM, and SYSTEM.md5. Actually there are two important file there, KERNEL and SYSTEM. The files with .md5 extension are used for checksum. KERNEL file is used as OpenELEC kernel (Linux kernel ARM boot executable zImage little endian) and the SYSTEM file is the root filesystem (technically a Squashfs filesystem, little endian).

The shell script (name: create_sdcard) is used to create SD Card. If you read the script, you will see that the script will create two partition. One partition is using FAT32 and the other uses ext2. The FAT32 partition (first partition) is set to 16 cylinders or approximately 130MB. This is interesting information.

Prepare the Disk (SD Card)

To boot the Raspberry Pi, an installation media and storage media is needed. All we need is a single SD card. On this article I use my 8GB SD card. You can use any SD card you want, but I recommend to use at least 4GB SD card. The image we download on previous section will be stored on this card and later installed. Make sure you have a way to write on SD card.

Installation

(1) Automated Installation on Linux

Insert SD Card your Linux system. Look for what device it is recognized as. It can be /dev/sdX, /dev/mmcblk0, etc.

Invoke following command with root privilege (/dev/sdX is our device):

./create_sdcard /dev/sdX

It is very important to make sure you have the right device as it will be wiped as part of the process.

(2) Installation on Windows

There is no batch script or vbscript (or similar to that) for Windows so we should do manually.

Formatting the SD Card

OpenELEC needs properly formatted SD Card. It requires two partition with one of theme is formatted with an ext4 filesystem. A third party such as the MiniTool® Partition Wizard can be used for this purpose. The Home Edition is free for home use only.

Delete all existing partition and create two partitions. Both are primary partition. The first partition is parted as FAT32 with capacity of 130MB. Give the rest SD Card storage to EXT2 (or other EXT) partition. Name the first as Boot and the later as System.

Last but important part, create bootloader configuration. Create a file ‘cmdline.txt’ on the SD card with following content:

boot=/dev/mmcblk0p1 disk=/dev/mmcblk0p2 quiet

Copying OpenELEC to SD Card.

Now mount the first partition (the FAT32 one) to your Windows. Copy the target/KERNEL as kernel.img to partition. Also copy the target/SYSTEM. Next, copy the content of 3rdparty\bootloader folder also to that partition. Also copy openelec.ico and README.md. At this point you should have following items on your partition:

  1. LICENSE.broadcom
  2. README
  3. SYSTEM
  4. bootcode.bin
  5. cmdline.txt
  6. config.txt
  7. fixup.dat
  8. kernel.img
  9. openelec.ico
  10. start.elf

Running the Pi

You have write image and at this point your raspberry pi is ready. Now set up raspberry pi to boot: insert your SD card back to raspberry pi, put on power, plug video output (either HDMI or RCA).

To resize the SD card after installation, you can follow this article.

Finally, you can login to Raspberry Pi using

Username root
Password openelec

If you do not have a USP Input device, you can enable XBMC wifi remote access (via Android/iOS etc) by editing config files directly.

Happy hacking 😀

This article is similar to this article, except it use parted to partitioning.

When write image to CD card for installation of Raspberry Pi, the usable size will only be the size of the image. That means the rest of the space will be waste. On some distribution such as Fedora Remix or Raspbian Wheezy, when final configuration begin the distro run some script to automatically resize and fill the SD card. However not all distro does that. Therefore we need to do manual resize.

In this article we will discuss about how to manually resize SD card on Slackware. Alhtough using Slackware, you can also use other Linux, but we won’t cover that. This article describes activities relating partitions. Incorrectly following instruction is likely to corrupt your system, so please be careful.

On this article I use:

  1. Slackware64 14.0
  2. SD card with Raspbian Wheezy (2GB occupied)

Yes, we will resize Raspbian manually even though we know Raspbian can resize SD card automatically on raspi-config.

Preparation

Insert the SD card to our machine. Make sure it is now mounted. We will use partition tool to resize the partition.

Following on from the instructions above, keep the newly-written SD card in the card reader, but unmounted. We’ll use the parted (partition editor) tool to resize the partitions.

Show partition information to find our SD card. Look for a partition that matches the roughly the size of your distribution image. On Debian Wheezy it should be around 2GB. For example, it is detected as /dev/sdc2. Then unmount that partition. Those can be done by invoking:

mount
umount /dev/sdc2

Resizing

Now use parted utility (GNU Parted) with root privileges. You can do sudo if you are on sudoer group or use super user account.

parted /dev/sdc
(parted) unit chs
(parted) print
Disk /dev/sdc: 121535,3,31
Sector size (logical/physical): 512B/512B
BIOS cylinder,head,sector geometry: 121536,4,32.  Each cylinder is 65.5kB.
Partition Table: msdos

Number  Start      End         Type     File system     Flags
 1      16,0,0     1215,3,31   primary  fat32           lba
 2      1232,0,0   26671,3,31  primary  ext4
 3      26688,0,0  29743,3,31  primary  linux-swap(v1)

This shows how my SD card was formatted after writing the image. Notice that nothing uses the card from end of ‘cylinder’ 29743 to the card’s maximum at 121535.

Partition 1 is the boot partition. Nothing to do here, let’s leave that alone. Partition 2 is the root partition, which we’ll grow to fill most of the card. Some OS versions will have a Partition 3 for swap space, which needs to be moved to the end of the card. Note that on some other versions of linux partitioning swap before primary filesystem. Well, if that’s the case, our task will be easier.

Move the swap partition if it exists (you’ll have to adjust the numbers so that the end of partition 3 is at the end cylinder/head/sector of the card). To calculate the number to use in the following formula can be used:

Partition 3 New Start = (Maximum - (Partition 3 End - Partition 3 Start) ) - 1

so in this example (121535 - ( 29743 - 26688)) -1 = 118479

Note: Following command will not work if your parted versions later than 2.4. On my machine, parted is at version 3.1

(parted) move 3 118479,0,0

Now grow the root partition. This involves removing the partition, re-creating it, then using resize2fs to grow the filesystem to fill the partition. It won’t destroy any data.

(parted) rm 2
(parted) mkpart primary 1232,0,0 118478,3,31
(parted) quit

Note that the starting address of the new partition is identical to its original value, and the ending address is immediately before the start of the swap partition.
Now clean and resize the root partition.

e2fsck -f /dev/sdc2

That command will allow it to add lost-and-found.

resize2fs /dev/sdc2

Then put the card in the RPi and boot. You end up with a 7Gb partition to use.

[email protected]:~$ df -h
Filesystem            Size  Used Avail Use% Mounted on
tmpfs                  94M  4.0K   94M   1% /lib/init/rw
udev                   10M  168K  9.9M   2% /dev
tmpfs                  94M     0   94M   0% /dev/shm
rootfs                7.1G  1.3G  5.4G  20% /
/dev/mmcblk0p1         75M   28M   48M  37% /boot

And that’s it, we can enjoy Raspberry again 😀

Setting up Static IP address for Raspberry Pi

December 5, 2015 | Article | No Comments

A DHCP network makes network configuration easy. Any node (computer, laptop, or devices) connected to this network will automatically get IP address. A raspberry pi connected on DHCP network would also get the benefit. Using this method, we don’t need to set IP address manually.

Dynamic IP is good, but at some point we don’t need it. Even, it gives us troubles. In some case static IP address is convenient for deep inspection.

In this article we will discuss about how to set up static IP address for raspberry pi. The method we use is similar to Linux-based PC does, unless you use non Linux Operating System for your Pi.

In this article I use:

  1. Slackware64 14.0 for desktop OS
  2. Raspbian Wheezy for Raspberry Pi’s OS

Initial Connection, When and What

Where you want to connect or via what network. If you want to do the setting over network, this question must answered first before we proceed. There are two possibilities for doing static IP setup:

  1. DHCP network in which Raspberry Pi has been assigned with a dynamic IP address. In this scenario we want to set up the board to use a static IP (change from dynamic to static)
  2. Peer to peer or connecting your PC to Pi directly, in which raspberry pi request for dynamic IP but our desktop doesn’t provide any. This is difficult because your machine won’t be able to communicate to your pi
  3. peer to peer with DHCP server enabled on your machine. In this scenario the IP is provided by our machine but we need to know what IP it is.
  4. peer to peer, raspberry pi with static IP assigned before. This is the easiest method. In this scenario, we want to change the IP to something else.

If you don’t want to connect the Pi, we can do another thing. Insert your SD card to your machine host SD card reader. We then can configure the system from this.

Any method is fine and I assume you have known how to connect to your Pi. At least you can access the file system.

Configuration Begin

Now, here is the core for this article.

If you want to connect Raspberry Pi to internet via gateway (switch/router) then you should specify which router pi connect to. Find out what gateway address for your network by using route command. You should see a lines like this:

Kernel IP routing table

Destination	Gaterway	Genmask	Flags	Metric	Ref	Use	Iface
default		192.168.1.1	0.0.0.0	UG	0	0	0	eth0
loopback	*		255.0.0.0	U	0	0	0	lo
192.168.1.0	*		255.255.255.0	U	0	0	0	eth0

In this example, my default gateway for this network is 192.168.1.1. Save this information.

If your intention is only to set Pi’s IP for private connection from your machine to your Pi, you can pick any IP you like. However, make sure both Pi and your machine are on same network.

Now open /etc/network/interfaces file as super user. You can use text editos such as vi. Modify the file so it will similar to this one:

# Used by ifup(8) and ifdown(8). See the interfaces(5) manpage or
# /usr/share/doc/ifupdown/examples for more information.
auto lo
iface lo inet loopback
#
# New entries to support static IP follow:

auto eth0
iface eth0 inet static
hwaddress ether b8:27:eb:b5:e8:90
address 192.168.1.113
network 192.168.1.0
netmask 255.255.255.0
broadcast 192.168.1.255
gateway 192.168.1.1

On above snippet, I set the Pi’s IP address to 192.168.1.113/24 with network 192.168.1.0.

Next, rewrite the content of /etc/resolv.conf so. Invoke following command:

cat 'nameserver 192.168.1.1' > /etc/resolv.conf

That line will set our DNS resolver to our gateway.

Reboot your Pi and check whether you get the right IP address by invoking ifconfig command.

If you want to change it back to DHCP aware, change the /etc/network/interfaces content:

# Used by ifup(8) and ifdown(8). See the interfaces(5) manpage or
# /usr/share/doc/ifupdown/examples for more information.
auto lo
iface lo inet loopback
#
# New entries to support static IP follow:

auto eth0
iface eth0 inet dhcp

allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

Java SE Embedded on Raspberry Pi

December 5, 2015 | Article | No Comments

Raspberry, a small computer powered by ARM architecture is a very interesting board for learning embedded system. The joy has not ended soon as Oracle also supported the board with their Java. In this article we will discuss about how to installing Java SE embedded on Raspberry Pi for running Java bytecode.

In this article I use:

  1. Slackware64 14.0
  2. Raspberry Pi Model B
  3. Soft-Float Debian Wheezy
  4. Java SE Embedded

For the installation of Operating System, you can follow this article.

Other things we should prepared:

    • A wired network to which we can connect raspberry pi by an Ethernet cable. The network must supply DHCP IP address

A linux host computer on the same wired Ethernet network as Raspberry Pi to download JAVA. In this case I use Slackware64.

  • Java runtime from Oracle.
  • Enough free space to store Java SE Embedded on Raspberry Pi. 256MB is recommended.

Obtain the Materials

In this section we will use host (Slackware) to download Java SE Embedded and copy it over to the Raspberry Pi. Go to http://www.oracle.com/technetwork/java/embedded/downloads/javase/index.html. To download, you must agree to their license.

Choose Java SE Embedded 7, in this case I choose Java SE Embedded 7 for ARMv6/7 Linux – Headless EABI, SoftVFP ABI, Little Endian. At this time of writing, the version is 7u10 with size 31.39 MB. It is the first item on the list. Download it.

Oracle might ask for you to login. Just create an account if you don’t have any or login with your account if you have.

Setup

Login to Raspberry Pi over the network. The default username is pi with password raspberry. You can use ssh from terminalto do so. Open up another terminal and then copy the Java to pi using scp. Do extraction. You can also store Java on a directory such as /opt/java.

In this article I assume the host computer IP (Slackware64) is 192.168.1.113 and Raspberry IP’s is 192.168.1.114. Of course it would be different in your situation, but you can adjust it. The package is located on /home/xathrya/Downloads with name ejre-7u10-fcs-b18-linux-arm-vfp-client_headless-28_nov_2012.tar.gz.

For detailed command, you can read this commands.

# terminal 1
cd /home/xathrya/Downloads
scp <strong>ejre-7u10-fcs-b18-linux-arm-vfp-client_headless-28_nov_2012.tar.gz</strong> [email protected]:/home/pi

# terminal 2
ssh [email protected]
cd /home/pi
mkdir /opt
mv ejre*.gz /opt; cd /opt/java
tar -zxvf *.gz

# launch Java
mv ejre* ejre
/opt/ejre/bin/java -version

That’s it. At this point, you should be able run Java code on your raspberry 😀

Installing Ubuntu Mate for Raspberry Pi 2

December 5, 2015 | Article | No Comments

Warning!

This is for Raspberry Pi 2, not the first generation Raspberry Pi. Check your device and make sure you have Raspberry Pi 2 before proceeding.

Raspberry Pi, a small computer powered by ARM architecture is a very interesting board for learning embedded system. In this article we will discuss about how to install how to install Ubuntu Mate for Raspberry Pi 2.

For this article I use following:

  1. Slackware64 14.0
  2. Windows 8
  3. Raspberry Pi 2
  4. Ubuntu Mate ArmHf

You can use either Linux (in this article, Slackware) or Windows (in this article Windows 8). Just pick one and follow the rest of article for your choice.

The team who build Ubuntu Mate for Raspberry Pi 2 recommend you to use a Class 6 or Class 10 microSDHC, due to microSDHC I/O throughput is a bottleneck.

Obtain the Materials

The Operating System images I used is Ubuntu Mate. On Raspberry Pi official site. Luckily, Raspberry provide CDN so you can download it from server close to you. You can also obtain it via torrent.

Prepare the Disk (SD Card)

To boot the Raspberry Pi, an installation media and storage media is needed. All we need is a single SD card. On this article I use my 8GB SD card. You can use any SD card you want, but I recommend to use at least 4GB SD card. The image we download on previous section will be stored on this card and later installed. Make sure you have a way to write on SD card.

Windows-based Instruction

For Windows user, you can follow this section to “burn” the image. For this purpose you need additional software for writing to SD card, such as Win32DiskImager utility.

  1. Extract the image (in this caseubuntu-mate-15.10-desktop-armhf-raspberry-pi-2.img.bz2) so you will get an .img file. Windows by default cannot open .bz2 file, you need third party tool such as 7zip to do it.
  2. Insert SD card into SD card reader and check what drive letter it assigned to. For example G:\
  3. If it is not new, format it. Or at least make sure there is only one partition (FAT32 is recommended).
  4. Run the Win32DiskImager with administrator privileges.
  5. Select the image we have extracted.
  6. Select the drive letter of the SD card on our machine. Make sure you have the correct drive, or you will destroy data on that drive.
  7. Click Write and wait. The process should be not long.
  8. Exit the imager and eject the SD card

Beside Win32DiskImager, you can also use other tool such as Flashnul.

  1. Follow step 1 to step 3 for Win32DiskImager’s solution
  2. Extract Flashnul from the archive
  3. Open command prompt with elevated privilege (administrator privilege).
  4. Go to your extracted directory and run flashnul with argument “-p”. For example: flashnul -p
  5. You will get list of physical drive attached on your machine, and list of drive. Make sure the drive is correct. At time of writing this article, the SD card is detected as device number 1 with and mounted to drive G:
  6. Load the image to flashnul: flashnul 1 -L ubuntu-mate-15.10-desktop-armhf-raspberry-pi-2.img
  7. If you get an access denied error, try re-plugging the SD card and make sure to close all explorer windows or folders open for the device. If still get denial, try substitute the device number with its drive letter: flashnul G: -L ubuntu-mate-15.10-desktop-armhf-raspberry-pi-2.img

At this point, you have successfully written image to your SD card. And I assume you are. You can proceed to next stage.

Linux-based Instruction

Writing image on Linux is easier, in my opinion. The utility we use is “dd” which is already bundled on most distro. Make sure you know the correct device file for your SD card. In my machine I use a built in card reader and detect my SD card as /dev/sdb. It might be different on your system so better check it. For this article I use /dev/sdb to refer to SD card.

  1. Extract the image (in this case ubuntu-mate-15.10-desktop-armhf-raspberry-pi-2.img.bz2) so you will get an .img file.
  2. Insert SD card into SD card reader .
  3. If it is not new, format it. Or at least make sure there is only one partition (FAT32 is recommended).
  4. Unmount the SD card if it is mounted. We need the whole SD card so if you see partition such as /dev/sdb1, etc its better you unmount them all.
  5. Write the image to SD card. Make sure you replace the input file after if= argument with correct path to .img file and “/dev/sdb” in the output file of= argument with your device. Also make sure to use whole SD drive and not their partition (i.e. not use /dev/sdb1, /dev/sdb1, etc). The command: dd bs=4M if=ubuntu-mate-15.10-desktop-armhf-raspberry-pi-2.img of=/dev/sdb
  6. Run sync as root. This will ensure the write cache is flushed and safe to unmount SD card.
  7. Remove SD card from card reader.

If you hesitate to use terminal and prefer to use GUI method, here is the tutorial. Note that we

  1. Do step 1 to step 3 for previous tutorial. Make sure your directory or image file doesn’t contain any spaces.
  2. Install the ImageWriter tool from https://launchpad.net/usb-imagewriter
  3. Launch the ImageWriter tool (needs administrative privileges)
  4. Select the image file (in this case ubuntu-mate-15.10-desktop-armhf-raspberry-pi-2.img) to be written to the SD card (note: because you started ImageWriter as administrator the starting point when selecting the image file is the administrator’s home folder so you need to change to your own home folder to select the image file)
  5. Select the target device to write the image to. In my case, it’s /dev/sdb
  6. Click the “Write to device” button
  7. Wait for the process to finish and then insert the SD card in the Raspberry Pi

At this point, you have successfully written image to your SD card. And I assume you are. You can proceed to next stage.

Running the Pi

You have write image and at this point your raspberry pi is ready. Now set up raspberry pi to boot: insert your SD card back to raspberry pi, put on power, plug video output (either HDMI or RCA). You also need to plug an Ethernet cable to a network with a DHCP server and internet gateway. This will be used to set the system clock.

Ubuntu Mate doesn’t have predefined user so we will create it in the end of installation.

Have fun 😀

Warning!

This is for Raspberry Pi 2, not the first generation Raspberry Pi. Check your device and make sure you have Raspberry Pi 2 before proceeding.

Raspberry Pi, a small computer powered by ARM architecture is a very interesting board for learning embedded system. In this article we will discuss about how to install how to install Windows 10 IOT for Raspberry Pi 2.

For this article I use following:

  1. Windows 8
  2. Raspberry Pi 2
  3. Windows 10 IOT Core ISO

You can use either Linux (in this article, Slackware) or Windows (in this article Windows 8). Just pick one and follow the rest of article for your choice.

The build is somehow different compared to other raspberry pi OS installation.

Obtain the Materials

The Operating System images I used is Ubuntu Mate. On Windows official site you can directly download it.

Prepare the Disk (SD Card)

To boot the Raspberry Pi, an installation media and storage media is needed. All we need is a single SD card. On this article I use my 8GB SD card. You can use any SD card you want, but I recommend to use at least 4GB SD card. The image we download on previous section will be stored on this card and later installed. Make sure you have a way to write on SD card.

Windows-based Instruction

For Windows user (modern Windows, Vista onward), you can follow this section to “burn” the image.

The first step is to install the tools, provided by Microsoft.

  1. Mount the ISO file. You can do it by double clicking it. You will see a new drive.
  2. Install Windows_10_IoT_Core_RPi2.msi file, you can double click it and follow the instruction. When installation is complete, flash.ffu will be located at C:\Program Files (x86)\Microsoft IoT\FFU\RaspberryPi2.
  3. Eject the Virtual CD when installation is complete – this can be done by navigating to the top folder of File Explorer, right clicking on the virtual drive, and selecting “Eject”

Next we will install the image to SD card.

  1. Use IoTCoreImageHelper.exe to flash the SD card. Search for “WindowsIoT” from start menu and select the shortcut “WindowsIoTImageHelper
  2. The tool will enumerate devices as shown. Select the SD card you want to flash, and then provide the location of the ffu to flash the image.
  3. Safely remove your USB SD card reader by clicking on “Safely Remove Hardware” in your task tray, or by finding the USB device in File Explorer, right clicking, and choosing “Eject”. Failing to do this can cause corruption of the image.

Wait, what if we don’t want to install the IOT tools? Perhaps, we have the Win32DiskImager or Flashnul already?

Running the Pi

You have write image and at this point your raspberry pi is ready. Now set up raspberry pi to boot: insert your SD card back to raspberry pi, put on power, plug video output (either HDMI or RCA). You also need to plug an Ethernet cable to a network with a DHCP server and internet gateway. This will be used to set the system clock.

Have fun 😀

Social media & sharing icons powered by UltimatelySocial