Author Topic: Creating a Bootable SD Card for the pcDuino (Updated 3/18/2013)  (Read 3816 times)

digitalhack

  • Jr. Member
  • **
  • Posts: 59
  • Karma: +0/-0
    • View Profile
    • Digital Hack's Blog
All,

One of the things that I have wanted to be able to do with my pcDuino is boot from an SD Card.  I have found this useful in my work with the Raspberry PI as it makes it easy to setup environments to support different uses of the system.

After poking around the pcDuino site I didn't find a bootable image that can be downloaded and written to an SD Card.

Update (3/16/2013): It appears that on 3/12/2013 an SD Card Bootable Image was added to the downloads page at https://s3.amazonaws.com/pcduino/Images/pcDuino_xbmc_mmc_20130312.7z.

Update (3/17/2013): When I loaded the SD Card Bootable Image above while the pcDuino booted and appeared to be functional there were errors during the boot.  As a result I continued forward to see if I could come up with an error free boot.  See the reply below for the procedure I came up with

Update (3/18/2013): Added instructions on how to load the latest copy of u-boot for the A10

Searching the Internet I came across a lot of good work done by Jeff Doozan and others to create a bootable sd card image for the A10.  Following his instructions I was able to build a bootable sd card for Debian 7.0.

Below are my notes posted in the hopes that they will help others.  I haven’t had a chance to do much testing with the resulting image but that will come with time.

Please note that the process below has the possibility of damaging your pcDuino if not done correctly.

I am interested in any feedback you might have.

digitalhack

Creating a Bootable SD Card for the pcDuino

Step 1 - Setting up the System

To use this process you will need a logic level (3.3V) to RS-232 converter or you can use a one of the 3.3V serial to USB converters.  This will be connected to the Debug Port.  The setup for the Debug Port is  115200 8N1.  I used the Sparkfun FTDI V3.3 Basic.

The debug port is labeled J5 and the pinout, with the board oriented so the debug port is at the top and the Ethernet connection is to the right, are RX, GND, TX.

There is a picture in the user manual on page 5 that shows the debut port and a diagram on page 9 that shows the pinout.

You will also need to have the system connected to the Internet using an Ethernet cable plugged into the RJ45 jack.

Step 2 – Download and Initial Boot

Download Rescue System 1.2  image from http://forum.doozan.com/read.php?6,9115,9115.

Unzip the image and copy it to an sd card using the instructions at the site.  There are instructions for both Linux and Windows.

I used the Windows instructions and copied the image to a 2Gb sd card using Win32DiskImager.

Insert the sd card into the pcDuino.

Boot

Ensure that you booted from the sd card.  Sometimes from a power on boot the sd card doesn’t respond quick enough and the image in nand gets booted.  If this happens press the reset button and boot again.

If you booted the image on the sd card you will get the following message  “A10 Rescue System” followed by a prompt “rescue login:”.  Login to root with password root.

Step 3 – Setup the remainder of the SD Card

Download the init-partition-mmc.sh from https://github.com/doozan/a10-rescue-scripts, load it on to the pcDuino.  I did this using the following steps:

  • Using my mouse copy the raw text from github in the browser window.
  • In your pcDuino console window enter: “cat > init-partition-mmc.sh” .
  • Then paste to enter the script.
  • Once the paste finished enter “ctrl-d” to get back to the command line.
  • Make the script file executable: “chmod 744 init-partition-mmc.sh”.
  • Execute the script: “./init-partition-mmc.sh”

This will execute the script.   I have gotten warnings during the partition but these don’t appear to keep the process from working.

Warning: The resulting partition is not properly aligned for best performance.

Once the partition is complete you will get the following message:

Successfully partitioned mmcblk0

Step 4 – Install Debian onto the sd card

Download the autorun-install-debian.sh from https://github.com/doozan/a10-rescue-scripts, load it on to the pcDuino using the same steps as above with the new filename.

Execute the script and find something to do as it takes about 90 minutes to build the system.

When the script completes it will reboot the pcDuino.

Step 5 – Base System

You should now have a base system that you can build on top of.  Login in with root and a password of root to access the system.
« Last Edit: March 18, 2013, 07:50:56 PM by digitalhack »

digitalhack

  • Jr. Member
  • **
  • Posts: 59
  • Karma: +0/-0
    • View Profile
    • Digital Hack's Blog
Re: Creating a Bootable SD Card for the pcDuino (Updated 3/18/2013)
« Reply #1 on: March 17, 2013, 10:32:13 AM »
I spent some time yesterday with my quest for a bootable sd card.  I tried the XBMC image from the website and noticed that I got a bunch of boot errors.  As result I decided to move forward and see what I could come up with.

By the end of the day I had come up with the procedure below that will result in a bootable sd card that as best as I can tell boots error free.

This process does not require use of the debug port but does require a PC running linux.

Step 1 - Download archive with u-boot binary files.

http://download.doozan.com/a10/u-boot.sun4i.mmc_boot.22072012.tar.bz2

Extract the files.  You will only need two:

u-boot-doozan/sun4i-spl.bin
u-boot-doozan/u-boot.bin

Step 2 - Zero the first 32M of the card and Install the boot images

Note that in the process below my sd card was in /dev/sdb and when I attached my pcDuino it was /dev/sdc.

root@oberon:~/Projects/pcDuino#  dd if=/dev/zero of=/dev/sdb bs=1024 count=32768
32768+0 records in
32768+0 records out
33554432 bytes (34 MB) copied, 0.0625702 s, 536 MB/s

root@oberon:~/Projects/pcDuino# dd if=/home/gjdonaldson/Projects/pcDuino/u-boot-doozan/sun4i-spl.bin of=/dev/sdb bs=1024 seek=8
15+1 records in
15+1 records out
15872 bytes (16 kB) copied, 0.144486 s, 110 kB/s

root@oberon:~/Projects/pcDuino# dd if=/home/gjdonaldson/Projects/pcDuino/u-boot-doozan/u-boot.bin of=/dev/sdb bs=1024 seek=32
128+1 records in
128+1 records out
131892 bytes (132 kB) copied, 0.0449999 s, 2.9 MB/s


Step 3 – Create the boot partition

root@oberon:~/Projects/pcDuino# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x753f9b12.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-15564799, default 2048): <cr>
Last sector, +sectors or +size{K,M,G} (2048-15564799, default 15564799): +32M

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): b
Changed system type of partition 1 to b (W95 FAT32)

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: If you have created or modified any DOS 6.x
partitions, please see the fdisk manual page for additional
information.
Syncing disks.
root@oberon:~/Projects/pcDuino#

root@oberon:/# fdisk -l /dev/sdb

Disk /dev/sdb: 7969 MB, 7969177600 bytes
107 heads, 4 sectors/track, 36366 cylinders, total 15564800 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x753f9b12

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048       67583       32768    b  W95 FAT32
root@oberon:/#


Step 4 – Copy boot partition files from pcDuino

Connect your pcDuino via OTG port which will result in a mass storage device showing up on your system. Mount the first partition on your sd card and the pcDuino.

You will need two files uImage and evb.bin which needs to be renamed to script.bin

root@oberon:/# mkdir /media/pcDuino
root@oberon:/# mkdir /media/sdcard

root@oberon:/# mount -t vfat /dev/sdb1 /media/sdcard
root@oberon:/# mount -t vfat /dev/sdc /media/pcDuino

root@oberon:/# ls /media/pcDuino
boot.axf  drv_de.drv  font24.sft  linux      script0.bin  sprite      uImage
boot.ini  evb.bin     font32.sft  magic.bin  script.bin   sprite.axf

root@oberon:/# cp /media/pcDuino/uImage /media/sdcard/
root@oberon:/# cp /media/pcDuino/evb.bin /media/sdcard/script.bin

root@oberon:/# ls /media/sdcard
script.bin  uImage

root@oberon:/# umount /media/sdcard
root@oberon:/# umount /media/pcDuino


Step 5 – Setup your root file system and swap

root@oberon:/# fdisk /dev/sdb

Command (m for help): n
Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended
Select (default p): p
Partition number (1-4, default 2): <CR>
Selected partition 2
First sector (67584-15564799, default 67584): <CR>
Using default value 67584
Last sector, +sectors or +size{K,M,G} (67584-15564799, default 15564799): +1600M
Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

root@oberon:/# fdisk /dev/sdb

Command (m for help): n
Partition type:
   p   primary (2 primary, 0 extended, 2 free)
   e   extended
Select (default p): p
Partition number (1-4, default 3): <CR>
Selected partition 3
First sector (3344384-15564799, default 3344384): <CR>
Using default value 3344384
Last sector, +sectors or +size{K,M,G} (3344384-15564799, default 15564799): +128MB
Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

root@oberon:/# fdisk -l /dev/sdb

Disk /dev/sdb: 7969 MB, 7969177600 bytes
246 heads, 62 sectors/track, 1020 cylinders, total 15564800 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x753f9b12

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048       67583       32768    b  W95 FAT32
/dev/sdb2           67584     3344383     1638400   83  Linux
/dev/sdb3         3344384     3594383      125000   83  Linux

root@oberon:/# mkfs.ext4 /dev/sdb2
mke2fs 1.42 (29-Nov-2011)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
102544 inodes, 409600 blocks
20480 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=419430400
13 block groups
32768 blocks per group, 32768 fragments per group
7888 inodes per group
Superblock backups stored on blocks:
   32768, 98304, 163840, 229376, 294912

Allocating group tables: done                           
Writing inode tables: done                           
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information:     
done

root@oberon:/# mkswap /dev/sdb3
Setting up swapspace version 1, size = 124996 KiB
no label, UUID=938b0573-21f5-422c-a4cc-6ee8292eab3d
root@oberon:/#


Step 6 – Write the Root File System to the SD Card

root@oberon:/# dd if=/home/gjdonaldson/Projects/pcDuino/images/ubuntu-2013-0203/ubuntu/ubuntu_20130203.img of=/dev/sdb2
3072000+0 records in
3072000+0 records out
1572864000 bytes (1.6 GB) copied, 518.098 s, 3.0 MB/s


At this point you should have an SD Card that you can put in the pcDuino and it will boot.

« Last Edit: March 18, 2013, 07:53:43 PM by digitalhack »

digitalhack

  • Jr. Member
  • **
  • Posts: 59
  • Karma: +0/-0
    • View Profile
    • Digital Hack's Blog
Re: Creating a Bootable SD Card for the pcDuino (Updated 3/18/2013)
« Reply #2 on: March 18, 2013, 07:49:49 PM »
I spent some more time on Sunday looking at how to improve the bootable sd card.

I was able to build the card with the latest copy of u-boot for the A10.

The benefit of this is that you can set u-boot environment variables in uEnv.txt which will get loaded during the boot process.

You will need two files from the site below:

http://dl.linux-sunxi.org/nightly/latest/

sunxi-spl.bin
u-boot.bin

These files need to be copied via dd as described in the process above under Step 2.

You will need to copy the four files below to you boot partition on the sd card.  This is in place of Step 4 above.

script.bin - this is the evb.bin (and not the script.bin) renamed from the boot partition of the pcDuino.
uImage - this is uImage from the boot partition.

boot.scr - this file is attached to this post.  This file only contains a version command.
uEnv.txt - this file is attached to this post.  This file is empty but could have lines var=something added to be set at boot time.
« Last Edit: March 18, 2013, 07:56:08 PM by digitalhack »