Creating Ubuntu Image for ppc-4210

From Estone Technology Wiki
Jump to: navigation, search

Creating Ubuntu 14.04 Image

Install host dependencies

$ sudo apt-get install gparted git build-essential libncurses5 wget u-boot-tools zlib1g-dev ncurses-dev
$ sudo apt-get install cmake libc-dev-armhf-cross pkg-config-arm-linux-gnueabihf build-essential checkinstall cmake
$ sudo apt-get install pkg-config lzop libc6 libstdc++6 debootstrap qemu-user-static binfmt-support zlib1g:i386

Installing SDK

Download SDK

Installation

$ cd ~/Downloads
$ chmod +x poky-glibc-x86_64-meta-toolchain-qt5-cortexa9hf-neon-toolchain-2.1.3.sh
$ sh poky-glibc-x86_64-meta-toolchain-qt5-cortexa9hf-neon-toolchain-2.1.3.sh

build u-boot

$ cd ~/
$ git clone -b imx_v2015.04_3.14.52_1.1.0_ga https://github.com/estonetechnology/ppc-4510-linux-uboot
$ cd ppc-4510-linux-uboot/
$ source /opt/poky/2.1.3/environment-setup-cortexa9hf-neon-poky-linux-gnueabi 
$ export ARCH=arm 
$ export CROSS_COMPILE=arm-poky-linux-gnueabi- 
$ make hio-imx6dl-board_spl_defconfig 
$ make
  • Generate required files:

SPL:ppc-4510-linux-uboot/SPL
u-boot.img:ppc-4510-linux-uboot/u-boot.img

Build Kernel

$ cd ~/
$ git clone -b imx_3.14.52_1.1.0_ga https://github.com/estonetechnology/imx6qdl-linux-kernel.git
$ cd imx6qdl-linux-kernel/
$ source /opt/poky/2.1.3/environment-setup-cortexa9hf-neon-poky-linux-gnueabi
$ export ARCH=arm
$ export CROSS_COMPILE=arm-poky-linux-gnueabi-
$ make hio-imx6dl-ppc4210_defconfig 
$ make 
$ make hio-imx6dl-ppc4210.dtb

move your image to binary folder

$ cd ~/
$ mkdir binary
$ sudo cp -v ppc-4510-linux-uboot/u-boot.img binary/
$ sudo cp -v ppc-4510-linux-uboot/SPL binary/
$ sudo cp -v imx6qdl-linux-kernel/arch/arm/boot/zImage binary/  
$ sudo cp -v imx6qdl-linux-kernel/arch/arm/boot/dts/hio-imx6dl-ppc4210.dtb binary/
$ cd binary/
$ mv hio-imx6dl-ppc4210.dtb imx6dl-hio.dtb	/*rename the dtb file to default name*/
  • Generate required files:

zImage: imx6qdl-linux-kernel/arch/arm/boot/zImage
hio-imx6dl-ppc4210.dtb: imx6qdl-linux-kernel/arch/arm/boot/dts/hio-imx6dl-ppc4210.dtb

Build rootfs

Installing with debootstrap

$ cd ~/
$ target=rootfs
$ distro=trusty
$ sudo debootstrap --arch=armhf --foreign --include=ubuntu-keyring,apt-transport-https,ca-certificates,openssl $distro "$target" http://ports.ubuntu.com
$ sudo cp /usr/bin/qemu-arm-static $target/usr/bin
$ sudo cp /etc/resolv.conf $target/etc
$ sudo chroot $target 
# distro=trusty
# export LC_ALL=C LANGUAGE=C LANG=C
# /debootstrap/debootstrap --second-stage

Edit the sources.list repositories

# cat <<EOT > /etc/apt/sources.list
# deb http://ports.ubuntu.com/ubuntu-ports/ $distro main universe
# deb-src http://ports.ubuntu.com/ubuntu-ports/ $distro main universe
# EOT
# apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 40976EAF437D05B5
# apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 3B4FE6ACC0B21F32
# apt-get update
# apt -y -f install
# apt-get upgrade
# apt-get install nano

Add x11 and LXDE to base rootfs

# apt-get install xinit lxde lxterminal lxappearance lxrandr lxshortcut lxinput xinit  xserver-xorg-dev mesa-utils mesa-utils-extra

Set up the lxde login environment

Add root login password

# passwd root  

Add linaro username

# adduser linaro	

Add Serial Console

# sudo nano etc/init/tty1.conf
Add this:  
exec /sbin/getty -L 115200 ttymxc1

Edit networks interfaces

# sudo nano etc/network/interfaces 
Add this:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp

Exit chroot

# exit
$ cd ~/
$ sudo mkdir /binary/rootfs
$ sudo cp -a rootfs/* /binary/rootfs

Note:your rootfs is ready,It is in the current folder

Create MicroSD Image

Preparing MicroSD Card

Requirements:

  • Host Machine (Linux Ubuntu)
  • MicroSD Card (Minimum 8GB)
  • card reader

Prepare MicroSD with fdisk

1. Plug MicroSD to the host machine (Linux Ubuntu)
2. Open Terminal by pressing Ctrl+Alt+T keys in your keyboard simultaneously
3. In the terminal type in lsblk command to see what letter your MicroSD card was given
(Example: /dev/sda, /dev/sdb, /dev/sdc, etc..)

$ lsblk                                           

Lsblk-1.png


4. Locate the MicroSD card in the HDD menu Note: MicroSD letter (/dev/sd<x>) is dependent on the amount of HDD's that are connected to the host machine
Example: As shown in the image, MicroSD is located at /dev/sdc
Lsblk-hdd.png


5. Once MicroSD is located run the fdisk command to start MicroSD Filesystem preparation

$ sudo fdisk /dev/sd<x> 

Fdisk-start.png


  • Here is a list of all available options:

Command (m for help): m 
Help:
 DOS (MBR)
  a   toggle a bootable flag
  b   edit nested BSD disklabel
  c   toggle the dos compatibility flag
 Generic
  d   delete a partition
  F   list free unpartitioned space
  l   list known partition types
  n   add a new partition
  p   print the partition table
  t   change a partition type
  v   verify the partition table
  i   print information about a partition
 Misc
  m   print this menu
  u   change display/entry units
  x   extra functionality (experts only)
 Script
  I   load disk layout from sfdisk script file
  O   dump disk layout to sfdisk script file
 Save & Exit
  w   write table to disk and exit
  q   quit without saving changes
 Create a new label
  g   create a new empty GPT partition table
  G   create a new empty SGI (IRIX) partition table
  o   create a new empty DOS partition table
  s   create a new empty Sun partition table


6. We will now create the first partition for the MicroSD

Command (m for help): n 
Partition type
  p   primary (0 primary, 0 extended, 4 free)
  e   extended (container for logical partitions)
Select (default p): p 
Partition number (1-4, default 1): 1 
First sector (2048-124735487, default 2048): 10240 
Last sector, +sectors or +size{K,M,G,T,P} (10240-124735487, default 124735487): +100M 
Command (m for help): t 
Selected partition 1
Hex code (type L to list codes): c 
Changed system type of partition 1 to c (W95 FAT32 (LBA))
Created a new partition 1 of type 'c W95 FAT32 (LBA)' and of size 100 MiB.


7. Now we will create the MicroSD second partition

Command (m for help): n 
Partition type
  p   primary (1 primary, 0 extended, 3 free)
  e   extended (container for logical partitions)
Select (default p): p 
Partition number (2-4, default 2): 2 
First sector (2048-124735487, default 2048): 215040 
Last sector, +sectors or +size{K,M,G,T,P} (215040-124735487, default 124735487): Press 'Enter' key 
Created a new partition 2 of type 'Linux' and of size 59.4 GiB.


8. Once the 2nd partition is created you need to write changes to the MicroSD card

Command (m for help):  w 
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

9. Now we will add partition filesystem type to the 2 partitions that were created

For 1st Partition:

$ sudo mkfs.vfat /dev/sd<x>1
$ sudo mount /dev/sd<x>1 /mnt
$ cd binary/
$ sudo cp imx6dl-hio.dtb zImage u-boot.img /mnt
$ sync
$ sudo umount /dev/sd<x>1

For 2nd Partition:

$ sudo mkfs.ext4 /dev/sd<x>2
$ sudo mount /dev/sd<x>2 /mnt
$ sudo cp -a rootfs/* /mnt
$ sync
$ sudo umount /dev/sd<x>2
$ sudo dd if=SPL of=/dev/sd<x> bs=1k seek=1

Note:the binary folder is from create ubuntu images

Boot from SD card run ubuntu

Set the boot switch to "2"

Emb2230-sw2.png

Insert the Create MicroSD Image into the SD card slot

Ppc-4210-sd.png

Insert the power on it will from sd run now