How update nand flash of my A13

Started by xyphos07, June 04, 2014, 02:12:06 AM

Previous topic - Next topic

xyphos07

I try to update the nand flash of my A13 board with a debian.
I installed live suit and download the image "A13_debian_34_75_WIFI_RALINK_GCC_GPIO_X_I2C_100KHz_UVC_TS_FTDI_video_release_9.img"

but live suit said the image is invalid
something is wrong ?? where i can download a correct image tu update my a13 nand flash??

thanks for you help

LubOlimex

Hello yphos07,

The problem is that LiveSuit is meant for uploading Android images.

The Debian image you have downloaded can be downloaded to microSD card via win32diskimager.exe under Windows or by dd command under Linux.

Please check this article on how to prepare Debian Linux for microSD card: https://www.olimex.com/wiki/Prebuilt_SD_card_images_running_debian

For Android from NAND please check here: https://www.olimex.com/wiki/A13-OLinuXino#Using_an_operating_system_-_Nand_flash

Best regsards,
Lub/OLIMEX
Technical support and documentation manager at Olimex

xyphos07

i do this,
debian is working in my sd card
But How i can update the nand flsah with debian image??

olimex

there is no NAND Flash Debian image yet

seulater

Quote from: olimex on June 10, 2014, 07:45:23 AM
there is no NAND Flash Debian image yet

Is there still no image yet ?

gazum

Does anybody have working NAND Flash Debian image?

Thanks,

colpamax

#6
I've got working Debian image in NAND.
My configuration is: A13-Olinuxino-Wifi with 4Gb Hynix.

1)
You must setup Android image with LiveSuit. (later we will use u-boot from Android to load Linux image). You must load image for your type of board from here
https://ftp.olimex.com/Allwinner_Images/A13-OLinuXino/4.%d0%b0ndroid_images/nand/
For my board image is 
https://ftp.olimex.com/Allwinner_Images/A13-OLinuXino/4.%d0%b0ndroid_images/nand/A13_android_NAND_LCD_800x480_EN_second_release.img

2)
You must prepare SD-card with Debian image, which is good for your board. Be careful - ONLY OLD LINUX KERNEL 3.4.x supports NAND. In later releases NAND support is missing.
For my board Debian image is
https://ftp.olimex.com/Allwinner_Images/A13-OLinuXino/2.legacy_images_kernel_3.4.x/A13_debian_34_90_mainline_u-boot_release_11_3.7z

3) Check boot from Android. After that insert SD card with Linux and boot from SD-card. Check that you have access to NAND memory partitions with Android installed.

4) Under Debian you must replace in /etc/apt/sources.list
   deb http://deb.debian.org/debian/
   with
   deb http://archive.debian.org/debian/

   in order to get updates for your old kernel.
 
5) IF all is OK - than under Debian run this script to delete all Android stuff and replace with Linux files. Android partitions remain unchanged.
5.1) Insert text below into movetonand.sh file.
5.1.1) If you make this under Windows be carefull in Windows EOL is (\r\n) in Linux EOL is (\n). If you insert this script in Windows Notepad the script will not run.
5.2) Add permission to execute with:  chmod +x movetonand.sh
5.3) sudo ./movetonand.sh
#!/bin/sh
apt-get install rsync
apt-get clean
apt-get autoclean

umount /dev/nandi
mkfs.ext4 /dev/nandi
tune2fs -o journal_data_writeback /dev/nandi
tune2fs -O ^has_journal /dev/nandi
e2fsck -f /dev/nandi

umount /dev/nandd
mkfs.ext4 /dev/nandd
tune2fs -o journal_data_writeback /dev/nandd
tune2fs -O ^has_journal /dev/nandd
e2fsck -f /dev/nandd

umount /dev/nande
mkfs.ext4 /dev/nande
tune2fs -o journal_data_writeback /dev/nande
tune2fs -O ^has_journal /dev/nande
e2fsck -f /dev/nande

umount /dev/nandh
mkfs.ext4 /dev/nandh
tune2fs -o journal_data_writeback /dev/nandh
tune2fs -O ^has_journal /dev/nandh
e2fsck -f /dev/nandh



mkdir /mnt/nandroot
mount /dev/nandi /mnt/nandroot

rsync -aAXHv \
 --exclude=/proc \
 --exclude=/home \
 --exclude=/sys \
 --exclude=/dev \
 --exclude=/tmp \
 --exclude=/run \
 --exclude=/mnt \
 --exclude=/media \
 / /mnt/nandroot

mkdir /mnt/nandroot/dev /mnt/nandroot/proc /mnt/nandroot/sys /mnt/nandroot/tmp /mnt/nandroot/run /mnt/nandroot/mnt /mnt/nandroot/media /mnt/nandroot/home

rm -rf /mnt/nandroot/var/log/*
rm -rf /mnt/nandroot/var/tmp/*

mkdir -p /mnt/nandroot/mnt/storage
mkdir -p /mnt/nandroot/mnt/backup


cat << 'EOF' > /mnt/nandroot/etc/fstab
/dev/nandi    /              ext4    defaults,noatime,nodiratime,commit=60    0    1
/dev/nande    /home          ext4    defaults,noatime,nodiratime,commit=60    0    2
/dev/nandh    /mnt/storage   ext4    defaults,noatime,nodiratime,commit=60    0    2
/dev/nandd    /mnt/backup    ext4    defaults,noatime,nodiratime,commit=60    0    2

tmpfs         /tmp           tmpfs   defaults,noatime,mode=1777,size=64M      0    0
tmpfs         /var/log       tmpfs   defaults,noatime,mode=0755,size=32M      0    0
tmpfs         /var/tmp       tmpfs   defaults,noatime,mode=1777,size=32M      0    0
EOF

umount  /mnt/nandroot
rmdir /mnt/nandroot

mkdir /mnt/new_home
mount /dev/nande /mnt/new_home
rsync -aHAXx /home/ /mnt/new_home/
umount /mnt/new_home
rmdir /mnt/new_home


mkdir -p /mnt/sdboot
mount -t vfat /dev/mmcblk0p1 /mnt/sdboot

dd if=/mnt/sdboot/uImage of=/dev/nandc bs=1M
dd if=/mnt/sdboot/script.bin of=/dev/nandf bs=1k
sync
umount /mnt/sdboot
rmdir /mnt/sdboot


cat << 'EOF' > u-boot.txt
baudrate=115200
bootdelay=1
console=ttyS0,115200
loglevel=8
machid=102a
nand_root=/dev/nandi
init=/sbin/init
setargs=setenv bootargs console=${console} root=${nand_root} rootwait init=${init} loglevel=${loglevel}
boot_normal=nand read 0x44000000 0x1300000 0x500000; nand read 0x43000000 0x33300000 0x20000; bootm 0x44000000
bootcmd=run setargs boot_normal
EOF


python -c "
import zlib, struct
with open('u-boot.txt', 'r') as f:
    lines = [line.strip() for line in f if line.strip()]
data = '\x00'.join(lines) + '\x00'
target_size = 131072 - 4
data = data.ljust(target_size, '\x00')
crc = zlib.crc32(data) & 0xffffffff
header = struct.pack('<I', crc)
with open('env.bin', 'wb') as f:
    f.write(header + data)
print('env.bin reafy! filesize:', len(header + data))
"
sudo dd if=env.bin of=/dev/nandb bs=1k
sync

rm env.bin u-boot.txt

echo "All done! Now power off the board, remove SD card and next time it will boot Linux from NAND!"

6)
Shut down your board, remove SD card and power-on. Linux will boot from NAND.

colpamax

#7
Android partitioning remains unchanged.
Debian root partition is installed in biggest nandi (around 2.6 Gb)
Debian Home partition is installed in nandd (around 512 Mb)
2 smaller partitions (256Mb each) are mounted as 'storage' and 'backup' under 'mnt' folder. Use them for your files as you wish.
One more Android 128Mb partition is mounted automatically by XFCE. You can delete Android files from it and use for your needs.

May be for another Android images (for example for 8Gb NAND) script must be changed.
I can't check this.