Friday, June 14, 2013

Debian Squeeze in mini2440 board

Debian Squeeze in mini2440 board

Toolchains:
Get base debian build essential and ncurses for menuconfig
>sudo apt-get install build-essential ncurses-dev
add to /etc/apt/sources.list
deb http://emdebian.org/debian/ squeeze main
> sudo apt-get update
> sudo apt-get install gcc-4.3-arm-linux-gnueabi
check toolchains
> arm-linux-gnueabi-gcc --version
arm-linux-gnueabi-gcc (Debian 4.3.5-4) 4.3.5Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


Kernel:
get the latest one from friendlyarm
>wget  http://www.friendlyarm.net/dl.php?file=linux-2.6.32.2-mini2440_20110413.tgz
extract and use mini2440_defconfig or other matching config
>make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- mini2440_defconfig
make changes as neccesery on menuconfig
>make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- menuconfig
compile the kernel
>make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- -j8
to create uImage you should had uboot-mkimage
>apt-get install uboot-mkimage
>make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- uImage


Debootstrap:

get debootstrap
>sudo apt-get install debootstrap
get base debian filesystem on folder called rootfs, change this if you wish.
>sudo debootstrap --foreign --arch=armel squeeze rootfs/ http://ftp.debian.org/debian
create preinstall script as follow, you can make changes as necessery
>vi preinstall

#!/bin/bash
#
#script preinstall debian on arm
#after this run the arm system execute
#./debootstrap/debootstrap --second-stage
#i might also creted install.sh for simplified installation
#
#igunos
#

DEBIANURL=http://ftp.debian.org/debian/
DEBIANVER=squeeze

#special for squeeze upon zlib1g failure
mkdir -p /usr/share/man/man1

#----------------------------------------------------------
echo " creating etc/fstab"
rm -f etc/fstab
echo "proc    /proc   proc    none    0       0

" >> etc/fstab
#----------------------------------------------------------
echo " creating etc/hostname"
rm -f etc/hostname
echo "igunosdeb
" >> etc/hostname

#-----------------------------------------------------------
echo " creating etc/hosts"
rm -f etc/hosts
echo "127.0.0.1 igunosdeb 
" >> etc/hosts


#-----------------------------------------------------------
echo " creating /dev/console /dev/ttySAC0"
mknod dev/console c 5 1
mknod dev/ttySAC0 c 204 64

#------------------------------------------------------------
echo " creating etc/inittab"

########################################################################
#normally mini2400 serial named ttySAC0
#but after installing "udev" the name will be changed to s3c2410_serial0
#we need to put both on inittab and securetty
#you can remove ttySAC0 after udev completely installed and run
########################################################################

rm -f etc/inittab
echo "# /etc/inittab: init(8) configuration.
# $Id: inittab,v 1.91 2002/01/25 13:35:21 miquels Exp $

# The default runlevel.
id:2:initdefault:

# Boot-time system configuration/initialization script.
# This is run first except when booting in emergency (-b) mode.
si::sysinit:/etc/init.d/rcS

# What to do in single-user mode.
~~:S:wait:/sbin/sulogin

# /etc/init.d executes the S and K scripts upon change
# of runlevel.
#
# Runlevel 0 is halt.
# Runlevel 1 is single-user.
# Runlevels 2-5 are multi-user.
# Runlevel 6 is reboot.

l0:0:wait:/etc/init.d/rc 0
l1:1:wait:/etc/init.d/rc 1
l2:2:wait:/etc/init.d/rc 2
l3:3:wait:/etc/init.d/rc 3
l4:4:wait:/etc/init.d/rc 4
l5:5:wait:/etc/init.d/rc 5
l6:6:wait:/etc/init.d/rc 6
# Normally not reached, but fallthrough in case of emergency.
z6:6:respawn:/sbin/sulogin

# What to do when CTRL-ALT-DEL is pressed.
ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now

# Action on special keypress (ALT-UpArrow).
#kb::kbrequest:/bin/echo \"Keyboard Request--edit /etc/inittab to let this work.\"
# What to do when the power fails/returns.
pf::powerwait:/etc/init.d/powerfail start
pn::powerfailnow:/etc/init.d/powerfail now
po::powerokwait:/etc/init.d/powerfail stop

# /sbin/getty invocations for the runlevels.
#
# The \"id\" field MUST be the same as the last
# characters of the device (after \"tty\").
#
# Format:
:::
#
# Note that on most Debian systems tty7 is used by the X Window System,
# so if you want to add more getty's go ahead but skip tty7 if you run X.
#
1:23:respawn:/sbin/getty 38400 tty1
2:23:respawn:/sbin/getty 38400 tty2
3:23:respawn:/sbin/getty 38400 tty3
4:23:respawn:/sbin/getty 38400 tty4
5:23:respawn:/sbin/getty 38400 tty5
6:23:respawn:/sbin/getty 38400 tty6

# Example how to put a getty on a serial line (for a terminal)
#
T0:12345:respawn:/sbin/getty 115200 ttySAC0
T1:12345:respawn:/sbin/getty 115200 s3c2410_serial0

# Example how to put a getty on a modem line.
#
#T3:23:respawn:/sbin/mgetty -x0 -s 57600 ttyS3
" >> etc/inittab

#---------------------------------------------------------------
#echo " adding ttySAC0 & s3c3420_serial0 to etc/securetty"
echo "

# serial on mini2440
ttySAC0
s3c2410_serial0
" >> etc/securetty

#----------------------------------------------------------------
echo " creating etc/network/interface"

rm -rf etc/network/interfaces
echo "# We always want the loopback interface.
#
auto lo
iface lo inet loopback

# To use dhcp:
#
#auto eth0
#iface eth0 inet dhcp

# An example static IP setup: (broadcast and gateway are optional)
#
#auto eth0
#iface eth0 inet static
#       address 192.168.0.42
#       network 192.168.0.0
#       netmask 255.255.255.0
#       broadcast 192.168.0.255
#       gateway 192.168.0.1

# Wireless wlan0
#auto wlan0
#iface wlan0 inet dhcp
#    wpa-ssid xxxxxx
#    wpa-psk xxxxx
" >> etc/network/interfaces

#-------------------------------------------------
echo " creating etc/resolv.conf"
rm -f etc/resolv.conf
echo "nameserver 8.8.8.8
nameserver 8.8.4.4
" >> etc/resolv.conf

#------------------------------------------------------
echo " creating etc/apt/sources.list"
rm -f etc/apt/sources.list
echo "deb $DEBIANURL $DEBIANVER main
deb-src $DEBIANURL $DEBIANVER main
" >> etc/apt/sources.list.bak


#--------------------------------------------------------
ln -s bin/sh linuxrc

#======================================================
echo
echo " preinstall finished"
echo " compile your kernel"
echo " install modules to here"
echo " run your system"
echo " execute ./debootstrap/debootstrap --second-stage"
echo " or if available use my sh install.sh"
echo


Save and exit using ":wq" command.
Create install  script as follow, you can makes changes as neccesery
>vi install

#!/bin/bash
mount proc /proc -t proc
export PATH=$PATH:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin

./debootstrap/debootstrap --second-stage

rm -vrf /dev/.udev

passwd -d root

#rm install
#rm preinstall

cp -f /etc/apt/sources.list.bak /etc/apt/sources.list

rm linuxrc
ln -s /sbin/init /linuxrc


Save and exit using ":wq" command
changes both script into executable
>chmod a+x preinstall install
put them on the top of rootfs/ folder which you had debootstrap debian files.
Execute preintsall
>sudo ./preinstall 
Make modules kernel and install them to rootfs
>sudo make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- INSTALL_MOD_PATH=../rootfs modules_install

get the mkyaffs2-128M
>mkyaffs2-128M rootfs rootfs.yaffs2


uImage and rootfs
At this point you got uImage at kernel arch/arm/boot directory and debian squeeze preinstalled filesystem on rootfs.yaffs2 files You had to transfer the uImage via tftp to the board.

TFTP Server
>sudo apt-get install tftpd 
>sudo mkdir /srv/tftp -p
>sudo chmod 0777 /srv/tftp
>cp arch/arm/boot/uImage /srv/tftp/.

U-boot
get the working u-boot bin files from ftp://f0045951:friendlyarm@ftp.friendlyarm.net/src/u-boot-mini2440-20111108.zip
or compile yourself from sources

Connect the serial console, run terminal on 115200 baudrate speed no flow control, no hardware handshake. Get the board run on nor flash to start supervivi. If you had superboot, you should repalce it first to supervivi.
Also start the dnw or supervivi usb transfer tools.

press "q" on terminal
supervivi# load ram 0x31000000 [uboot-size] u

send the u-boot via dnw/supervivi transfer tools
supervivi# go 0x31000000

...
mini2440# nand scrub
mini2440# nand createbbt

Wait for it, don't desperate if terminal not response, it took about 20minutes

mini2440# nand write 0x31000000 u-boot
mini2440# dynpart
mini2440# dynenv set 40000


Put the switch/jumper to boot from nand and hit reset
Now transfer the uImage
mini2440# setenv serverip 10.42.43.1 
mini2440# setenv ipaddr 10.42.43.10 
mini2440# saveenv

See mtdparts for offset and sixe of kernel in nand flash
mini2440# nand erase 0x00060000 0x00500000 
mini2440# tftpboot 0x31000000 uImage
mini2440# nand write.e 0x31000000 kernel ${filesize} 
mini2440# setenv bootcmd nand read 0x31000000 kernel ${filesize}\;bootm 0x31000000
mini2440# setenv bootargs console=ttySAC0,115200 rootfstype=ext3 root=/dev/mmcblk0p2 init=/linuxrc 
mini2440# saveenv

Put the switch/jumper back to nor and hit reset
press "y" to get the yaffs2 file system, and send the rootfs.yaffs2 via dnw.

after finish put the switch back to nand and boot.
 you get noname console

run the install script on board
# ./install

hit the reset again. Now you got working debian squeeze filesystem onboard. use login root with no password.
 








2 comments:

  1. Hi, also we get any window type like pi or can we interface Qt with it

    ReplyDelete
  2. Off course, i've try to install xorg and xfce and work well. You should use bigger flash or boot from sdcard, it tooks about 200MB for file system with X.

    ReplyDelete