kernel iomega ix200 kirkwood debian Jessie


Primeiramente gostaria de salientar que não sou o autor principal do conteúdo deste artigo. A minha intenção é de mostrar o que outros autores tem realizado (referenciando links para o conteúdo original) neste blog até como um guia pessoal para uso próprio e ainda compartilhar minhas anotações e pequenas modificações que realizo no conteúdo, desejando que possa ajudar mais alguém em algum lugar.
First and foremost, I take no credit for any of this post’s content. I am really just taking what others have done (which I have links to bellow) and am putting it on my blog for a personal reference and hopefully the small changes that I made to their guides will help someone somewhere.


link: https://github.com/daniviga/ix2-200
link: https://wiki.debian.org/CrossToolchains

sudo lxc-create -t debian -n crossjessie -- -r jessie -a i686

sudo lxc-stop -n crossjessie --kill

sudo chroot /var/lib/lxc/crossjessie/rootfs
apt-get install sysvinit-core
exit
echo "lxc.aa_profile = unconfined" | sudo tee -a /var/lib/lxc/crossjessie/config

sudo lxc-start -d -n crossjessie
sudo lxc-attach -n crossjessie -- apt-get update

sudo lxc-start -d -n crossjessie


Para iniciar um console no cotainer:
sudo lxc-console -n crossjessie -t 1

Preste atenção nas instruções abaixo:
Type <Ctrl+a q> to exit the console, <Ctrl+a Ctrl+a> to enter Ctrl+a itself
o usuário root tem a senha root
echo "deb http://emdebian.org/tools/debian/ jessie main" >> /etc/apt/sources.list

deb http://ftp.br.debian.org/debian jessie-backports main  contrib non-free
deb-src http://ftp.br.debian.org/debian jessie-backports main  contrib non-free


apt-get install curl 
curl http://emdebian.org/tools/debian/emdebian-toolchain-archive.key | apt-key add -

Adicione o repo da fonte:
echo "deb-src http://ftp.br.debian.org/debian/ jessie main contrib non-free" >> /etc/apt/sources.list

dpkg --add-architecture armel 
apt-get update 
apt-get install wget devscripts crossbuild-essential-armel kernel-package gcc-arm-linux-gnueabi ncurses-dev u-boot-tools sshpass


cd /usr/src 
apt-get source linux

ls
/usr/src/linux-3.16.7-ckt25

export CFLAGS="-march=armv5te -mfloat-abi=soft -marm" 
export CROSS_COMPILE="arm-linux-gnueabi-" 
export ARCH="arm"
export LOCALVERSION="" 
export INSTALL_MOD_PATH=../modules

cp .config config.old
wget -O- https://github.com/daniviga/ix2-200/raw/master/configs/config-3.16.0-4-kirkwood-ix2-200 > .config 
make oldconfig


make menuconfig 
make dtbs
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi-
make -j8 modules
make modules_install
OPCIONAL : make -j8 uImage

Compacte e copie os arquivos para o alvo:
cp arch/arm/boot/dts/kirkwood-iomega_ix2_200.dtb /boot/
tar -czf /boot/modules-3.16.7-ckt25.tar.gz ../modules 
cp System.map /boot/System.map-3.16.7-ckt25
cp .config /boot/config-3.16.7-ckt25
cp arch/arm/boot/zImage /boot/zImage-3.16.7-ckt25
cp vmlinux /boot/vmlinux-3.16.7-ckt25
cat arch/arm/boot/zImage arch/arm/boot/dts/kirkwood-iomega_ix2_200.dtb > /boot/zImage-dtb-3.16.7-ckt25

cd /boot 
scp modules-3.16.7-ckt25.tar.gz root@192.168.1.13:/root
scp System.map-3.16.7-ckt25 root@192.168.1.13:/root
scp config-3.16.7-ckt25 root@192.168.1.13:/root
scp zImage-3.16.7-ckt25 root@192.168.1.13:/root
scp vmlinux-3.16.7-ckt25 root@192.168.1.13:/root
scp zImage-dtb-3.16.7-ckt25 root@192.168.1.13:/root
scp kirkwood-iomega_ix2_200.dtb root@192.168.1.13:/root

Acesse o alvo e copie para o local correto
ssh root@192.168.1.13
cp /root/*-3.16.7-ckt25 /boot
cp /root/kirkwood-iomega_ix2_200.dtb /boot
tar xzf modules-3.16.7-ckt25.tar.gz 
cp -r modules/lib /

cd /boot
update-initramfs -v -c -k 3.16.7-ckt25
mkimage -A arm -O linux -T ramdisk -C gzip -a 0x00000000 -e 0x00000000 -n initramfs -d initrd.img-3.16.7-ckt25 uInitrd-3.16.7-ckt25
mkimage -A arm -O linux -T kernel -C none -a 0x00008000 -e 0x00008000 -n Linux-3.16.7-ckt25+dtb -d zImage-dtb-3.16.7-ckt25 uImage-dtb-3.16.7-ckt25

exit

depois fora do terminal crossjessie
exit
CTRL+A + q
sudo lxc-stop -n crossjessie

scp root@192.168.1.13:/boot/*-3.16.7-ckt25 /var/lib/tftpboot/
scp root@192.168.1.13:/boot/kirkwood-iomega_ix2_200.dtb /var/lib/tftpboot/





Acesso ao IX200 pelo terminal serial


screen /dev/ttyUSB0 115200





Teste de Inicialização com o PenDrive

Se quiser testar o boot com um pendrive:
usb start
setenv bootargs_console 'console=ttyS0,115200 mtdparts=orion_nand:0x300000@0x100000(uImage),0x1000000@0x540000(uInitrd) root=/dev/mapper/root-root'
setenv bootargs $(bootargs_console)
ext2load usb 0:1 0x00800000 /uImage-dtb-3.16.7-ckt11
ext2load usb 0:1 0x01100000 /uInitrd-3.16.7-ckt11
bootm 0x00800000 0x01100000

Altere o root=/dev/mapper/root-root acima para o root adequado para sua instalação !!!

Teste de Inicialização com o tFtp Server

Se quiser testar o boot com um tftp server:
setenv bootargs_console 'console=ttyS0,115200 mtdparts=orion_nand:0x300000@0x100000(uImage),0x1000000@0x540000(uInitrd) root=/dev/mapper/root-root'
setenv bootargs $(bootargs_console)
setenv serverip 192.168.1.31
setenv ipaddr 192.168.1.13
tftpboot 0x01100000 uInitrd-3.16.7-ckt25
tftpboot 0x00800000 uImage-dtb-3.16.7-ckt25
bootm 0x00800000 0x01100000

Altere o root=/dev/mapper/root-root acima para o root adequado para sua instalação !!!

Antes copie os arquivos do kernel para o diretório do tftp server /var/lib/tftpboot especificado em cat /etc/default/tftpd-hpa



Inicializando pela Memória Flash

Primeiro verifique:
cat /proc/mtd
dev: size erasesize name
mtd0: 00300000 00004000 "uImage"
mtd1: 01000000 00004000 "uInitrd"

flash_eraseall /dev/mtd0
flash_eraseall /dev/mtd1

#TODO
nandwrite -p /dev/mtd0 /boot/uImage-dtb-3.16.7-ckt25
nandwrite -p /dev/mtd1 /boot/uInitrd-3.16.7-ckt25

reboot

Configurando a Inicialização pela Memória Flash (configurar apenas uma vez)


setenv mtdids 'nand0=orion_nand'
setenv mtdparts 'mtdparts=orion_nand:0x100000@0x000000(uboot)ro,0x20000@0xA0000(uboot_env),0x300000@0x100000(uImage),0x1000000@0x540000(uInitrd)'
setenv bootargs_console 'console=ttyS0,115200 mtdparts=orion_nand:0x300000@0x100000(uImage),0x1000000@0x540000(uInitrd) root=/dev/mapper/root-root'
setenv bootcmd 'setenv bootargs $(bootargs_console); nand read 0x800000 uImage; nand read 0x1100000 uInitrd; bootm 0x00800000 0x01100000'
saveenv
reset

Ajuste o valor de root corretamente !!! se preferir ajustar com o UUID faça assim =>        root=UUID=

O comando para continuar com o boot é:

run bootcmd



link: http://linuxconfig.org/how-to-upgrade-debian-linux-system-from-wheezy-to-jessie-stable-release

Upgrade do Wheezy to Jessie :

apt-get update
apt-get upgrade
apt-get dist-upgrade
sed -i 's/wheezy/jessie/g' /etc/apt/sources.list
apt-get update
apt-get upgrade
apt-get dist-upgrade


Atualize o Initramfs que será depois gravado na memoria flash:
cd /boot 
update-initramfs -v -d -k 3.16.7-ckt25
update-initramfs -v -c -k 3.16.7-ckt25
mkimage -A arm -O linux -T ramdisk -C gzip -a 0x00000000 -e 0x00000000 -n initramfs -d initrd.img-3.16.7-ckt25 uInitrd-3.16.7-ckt25-new
mkimage -A arm -O linux -T kernel -C none -a 0x00008000 -e 0x00008000 -n Linux-3.16.7-ckt25+dtb -d zImage-dtb-3.16.7-ckt25 uImage-dtb-3.16.7-ckt25-new


Na máquina do servidor tftp execute:

scp root@192.168.1.13:/boot/*-3.16.7-ckt25-new /var/lib/tftpboot/

reboot

Inicialize mais uma vez pelo tftp ou ou pendrive.

setenv bootargs_console 'console=ttyS0,115200 mtdparts=orion_nand:0x300000@0x100000(uImage),0x1000000@0x540000(uInitrd) root=/dev/mapper/root-root'
setenv bootargs $(bootargs_console)
setenv serverip 192.168.1.31
setenv ipaddr 192.168.1.13
tftpboot 0x01100000 uInitrd-3.16.7-ckt25-new
tftpboot 0x00800000 uImage-dtb-3.16.7-ckt25-new
bootm 0x00800000 0x01100000


Se der tudo certo salve na memoria flash a nova versão:

Primeiro verifique:
cat /proc/mtd
dev: size erasesize name
mtd0: 00300000 00004000 "uImage"
mtd1: 01000000 00004000 "uInitrd"

flash_eraseall /dev/mtd0
flash_eraseall /dev/mtd1

#TODO
nandwrite -p /dev/mtd0 /boot/uImage-dtb-3.16.7-ckt25-new
nandwrite -p /dev/mtd1 /boot/uInitrd-3.16.7-ckt25-new

reboot


para deixar o boot mais rapido impeça udev net rule de ser executado com o comando:

ln -s /dev/null /etc/udev/rules.d/75-persistent-net-generator.rules



 config to use fw_printenv:

nano /etc/fw_env.config 

/dev/mtd1 0  0x20000
fw_printenv 
Not working yet:

Warning: Bad CRC, using default environment
bootargs=
bootcmd=bootp; setenv bootargs root=/dev/nfs nfsroot=${serverip}:${rootpath} ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}::off; bootm
bootdelay=3
baudrate=115200
stdin=serial,cros-ec-keyb
stdout=serial,lcd
stderr=serial,lcd




Comments