Create an SD Dard Image for Debian on Sidia Macnica

Create an SD Dard Image for Debian on Sidia Macnica

prerequisition

Build linux 4.4.52 kernel and debian 8 root file system based on this page.

Extract boot loader & u-boot from sodia image file

Our goal is to make a minimum debian system on Sodia board for fast data acquisition system development.  It can be re-used for boot process files by copy from RocketBoard.org provided file.

Download SD image file sodia_sdimage_ACDS16.1_REL_GSRD_PR.tgz from https://rocketboards.org/foswiki/view/Documentation/MacnicaSodiaEvaluationBoard

tar xvf sodia_sdimage_ACDS16.1_REL_GSRD_PR.img.tgz
sudo fdisk -l sodia_sdimage_ACDS16.1_REL_GSRD_PR.img
Device                   Boot   Start     End Sectors  Size Id Type
sodia_debian-4.4.52.img1         2048 1026048 1024001  500M  b W95 FAT32
sodia_debian-4.4.52.img2      1026049 4098049 3072001  1.5G 83 Linux
sodia_debian-4.4.52.img3      4098050 4118530   20481   10M a2 unknown
sudo losetup -f -o $((4098050*512)) sodia_sdimage_ACDS16.1_REL_GSRD_PR.img 
sudo losetup
sudo dd if=/dev/loop0 of=mbr.img bs=1024 count=1024
sudo losetup -d /dev/loop0
sudo mount -o ro,loop,offset=$((2048*512)) sodia_sdimage_ACDS16.1_REL_GSRD_PR.img /mnt
mkdir vfat32
sudo cp -rp /mnt/* vfat32/
sudo umount /mnt

Make SDCard image

dd if=/dev/zero of=sodia_debian.img bs=1M count=2048
sudo losetup -f sodia_debian.img
sudo losetup
NAME       SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE
/dev/loop0         0      0         0  0 /home/toshi/src/build-sodia/sodia_debian.img
sudo fdisk /dev/loop0

Make partition table as below -- create p3 first with type a2, then p1 with type 'b', and then p2 for rest of all blocks.

Device       Boot   Start     End Sectors  Size Id Type
/dev/loop0p1         4096 1052671 1048576  512M  b W95 FAT32
/dev/loop0p2      1052672 4194303 3141632  1.5G 83 Linux
/dev/loop0p3         2048    4095    2048    1M a2 unknown

Format & copy date into image

sudo losetup -f -o $((2048*512)) sodia_debian.img 
sudo losetup -f -o $((4096*512)) sodia_debian.img
sudo losetup -f -o $((1052672*512)) sodia_debian.img
sudo losetup

NAME       SIZELIMIT    OFFSET AUTOCLEAR RO BACK-FILE
/dev/loop0         0         0         0  0 /home/toshi/src/build-sodia/sodia_debian.img
/dev/loop1         0   1048576         0  0 /home/toshi/src/build-sodia/sodia_debian.img
/dev/loop2         0   2097152         0  0 /home/toshi/src/build-sodia/sodia_debian.img
/dev/loop3         0 538968064         0  0 /home/toshi/src/build-sodia/sodia_debian.img

sudo dd if=mbr.img of=/dev/loop1 bs=1024
sudo mkfs.vfat /dev/loop2
sudo mkfs.ext3 /dev/loop3
sudo mount /dev/loop2 /a
sudo cp -r ./vfat32/* /a
sync

sudo mount /dev/loop3 /mnt
cd arm-linux-gnueabifh-rootfs
sudo tar cf - . | sudo tar xvf - -C /mnt 
sync 

cd ../linux-4.4.52
sudo make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j4 modules_install INSTALL_MOD_PATH=/mnt 
sudo cp arch/arm/boot/dts/socfpga_cyclone5_socdk.dtb /a/soc_system.dtb 
sudo cp arch/arm/boot/zImage /a 

#removing root password
sudo chroot /mnt
passwd -d root
(edit /etc/pam.d/common-auth; find a line contains 'pam_unix.so' and change 'nullok_secure' to 'nullok')
(make sure /etc/network/interfaces is appropriate)

#clean up
sudo umount /a
sudo umount /mnt
sudo losetup -d /dev/loop0
sudo losetup -d /dev/loop1
sudo losetup -d /dev/loop2
sudo losetup -d /dev/loop3
Undefined

User login