November 11, 2019, 09:49:01 pm

News:

Have you visited the Allwinner Chipset wiki? - http://linux-sunxi.org/


Building Arch Linux Image

Started by maro, February 04, 2013, 02:57:11 pm

Previous topic - Next topic

maro

The following istructions are how to build a arch linux image for the cubieboard, the istructions are similar for the Mele A100 infact initially we are going to build an image for the mele.

Some note before starting:


  • All command must be preceded by sudo

  • You must find the position of your sdCard, in this guide i will use the mine. To find the position use the command mount

  • for /dev/sdb are intended the position of the sd card

  • for /dev/sdbX where X are a number (1  or 2) are intended the position of one partition of the sd card

  • for /media/andrea/boot are intended the mount position of the one partition of the sd card, to find correlation from /dev/sdbX and /media/andrea/boot look at mount table printed into terminal

  • if you don't want do to all of this you go to the end of this post and you will find a link for a image of arch linux



Let's Start:
Make a new bootable SdCard



mkdir arch && cd arch

wget http://archlinuxarm.org/os/sun4i/Mele-bootloader.tar.gz
wget http://archlinuxarm.org/os/ArchLinuxARM-sun4i-latest.tar.gz
tar xzf Mele-bootloader.tar.gz

./mkA10card.sh /dev/sdb

mkdir /tmp/boot
mkdir /tmp/arch
tar -zxf ArchLinuxARM-sun4i-latest.tar.gz -C /tmp/arch

mount /dev/sdb1 /tmp/boot
mount /dev/sdb2 /tmp/arch

cp /tmp/arch/boot/uImage /tmp/boot/uImage
cp script.bin /tmp/boot/script.bin
cp uEnv.txt /tmp/boot/uEnv.txt

sync


But since we have a cubiboard we need to change the hw package



wget http://dl.linux-sunxi.org/amery/sunxi-3.0/latest/cubieboard_hwpack.tar.xz
(http://dl.linux-sunxi.org/amery/sunxi-3.0/latest/cubieboard_512_hwpack.tar.xz if you have cubieboard with 512Mb Ram)

tar xz cubieboard_hwpack.tar.xz


The file in kernel and bootloader must go on the boot partion



cd kernel
cp * /media/andrea/boot
cd ..

cd bootloader
cp * /media/andrea/boot
cd ..


The file in rootfs must fgo on the other partition



cd rootfs
cd lib
cp -Rv * /media/andrea/ALARM/lib/
cd ..

cd etc
cp -Rv * /media/andrea/ALARM/etc/
cd ..


For the final step we need to move some file for a correct boot



cd /media/andrea/ALARM/etc
mv modules modules-load.d/cubieboard.conf
cd ..

cd lib/modules/
mv * /media/andrea/usr/lib/modules
cd ..
rmdir modules

mv framebuffer/ usr/lib/
mv x11 usr/lib/
mv libvecore.so usr/lib/
mv libMali.so usr/lib/
mv libUMP.so usr/lib/


Now finaly we have a Arch Linux Image for the cubieboard, but if you have a monitor and you want do adjust the resolution you must edit the file in the boot partition called uEnv.txt



boot_mmc=fatload mmc 0 0x43000000 ${fexfile}; fatload mmc 0 0x48000000 ${kernel}; bootm 0x48000000
extraargs=rootwait disp.screen0_output_type=3 disp.screen0_output_mode=1280x1024p60
fexfile=script.bin


The username and password is root


At the first boot i suggest to do this command



pacman -Syu
pacman -S sunxi-tools


If you want to use arch linux with a desktop environment



pacman -S xorg-server xorg-xinit xorg-server-utils

pacman -S xf86-video-fbdev (driver video)

pacman -S lxde (desktop environment, to see the alternative https://wiki.archlinux.org/index.php/Desktop_Environment)

pacman -S lxdm (login manager, to see the alternative https://wiki.archlinux.org/index.php/Display_Manager for me it's the only one that worked)

pacman -S alsa-utils (for audio https://wiki.archlinux.org/index.php/Alsa)

systemctl enable lxdm.service (to start the login manager at boot)


Now you have all you need to use linux on the cubiboard but if you want you can download this packages




pacman -S mplayer2 (command line media player)
pacman -S atool unzip unrar (file archiver)
pacman -S midori (fast and light browser that support to play flash video)
pacman -S gedit (text editor same of ubuntu)
pacman -S gnash-gtk (flash player for arm)
pacman -S icedtea-web-java7


To set your locale language



Open a terminal

nano /etc/locale.gen
add your language since i'm italian for me it was it_IT.UTF-8 UTF-8

locale-gen
now you see if the language that you add it's on the list and will generete the file

echo LANG=it_IT.UTF-8 > /etc/locale.conf
export LANG=it_IT.UTF-8


To set the keyboard layout (for me isn't work)



loadkeys YOURLANGUAGE for load the keyboard configuration, use only the first 2 letter like it or us

setfont YOURFONT you must serch the correct font, for me Lat2-Terminus16
nano /etc/vconsole.conf and change the KEYMAP=YOURLANGUAGE and the FONT=YOURFONT for italian: KEYMAP=it and the FONT=Lat2-Terminus16


Troubleshooting


No HDMI AUDIO
(https://wiki.archlinux.org/index.php/Advanced_Linux_Sound_Architecture#HDMI_Output_Does_Not_Work)


from terminal digit [b]aplay -l[/b] so you can see the audio hardware of cubieboard, remember the card and device number of the hdmi

digit [b]aplay -D plughw:1,0 /usr/share/sounds/alsa/Front_Center.wav[/b] to test if you can hears the sound from hdmi, if it not try to change the plughw in base of the table found with aplay -l

if it correct digit [b]nano ~/.asoundrc[/b] and add with the correct number of the card and device:

pcm.!default {
   type hw
   card 1
   device 0
}


No internet connection with Ethernet cable connected


on terminal:

ls /sys/class/net  to show Network Interface Names result for me: eth0 lo tun10

ip link set eth0 up

ip link show dev eht0

dhcpcd eth0

for testing if you are now connected:

ping -c 3 www.google.com


I found that the script used to create the sd card make two partition with the same dimension and it's bad due to that the boot partition require less than 50 mb so for the solution i done this:


i use a usb pen like a bridge

dd if=/dev/sdb (the micro sd) of=/dev/sdc (the usb pen)

sudo apt-get install gparted

use gparted to create two partition of the sd card (if you find a key near the partition on terminal digit sudo umount /dev/sdb* or the dev location of your micro sd)

the first of 50mb called boot

the second of the remain space called ALARM

on terminal sudo eject /dev/sdb

reinsert the micro sd and on terminal

cp -Rv /media/andrea/boot/* (the first partition of usb pen) /media/andrea/boot1 (my pc called boot1 the partition boot of the micro sd)

cp -Rv /media/andrea/ALARM/* (the second partition of usb pen) /media/andrea/ALARM1


I also create a image of the arch linux with a desktop enviroment you can download and use live suit to copy into your micro sd:

https://mega.co.nz/#!jMYVhLoS!OWXvGm0yV8xCVri7FMDAB08dDsMi2XY1Sf86LkfbIKk

The image is compressed with winrar and shoud work with an micro sd > 2gb

The image is come with lxde but if you want to restore the basic arch linux


on the login screen press ctrl + alt +F2

the username and password are root

digit this command in that order:

systemctl disable lxdm.service

pacman -Rs lxdm lxde xorg-server xorg-xinit xorg-server-utils xf86-video-fbdev alsa-utils

reboot


If you want to change the login


on login screen press ctrl + alt + F2

username and password are root

digit systemctl disable lxdm.service

pacman -Rs lxdm if you would to remove lxdm

download a new login  and enable with this command:

systemctl enable xxx.service

reboot


if you want to change desktop environment


on the login screen press ctrl + alt +F2

username and password are root

digit pacman -Rs lxde

download new desktop environment

reboot



whatshisname

I appreciate the effort put into this post but there is no way on God's green earth this will work.

To begin with the mounting order of the SD card early on is wrong.

mkdir /tmp/boot 
mkdir /tmp/arch
tar -zxf ArchLinuxARM-sun4i-latest.tar.gz -C /tmp/arch

mount /dev/sdb1 /tmp/boot 
mount /dev/sdb2 /tmp/arch

needs to be this:


mkdir /tmp/boot
mkdir /tmp/arch

mount /dev/sdb1 /tmp/boot
mount /dev/sdb2 /tmp/arch

tar -zxf ArchLinuxARM-sun4i-latest.tar.gz -C /tmp/arch

Later, even after you've extrapolated where "/media/andrea/" is supposed to be on your system  (I assumed "/mnt/sdb2"), eventually the author asks you to copy files to an "ALARM" subfolder therein which doesn't exist.

I finally get to these steps:

mv framebuffer/ usr/lib/
mv x11 usr/lib/
mv libvecore.so usr/lib/
mv libMali.so usr/lib/
mv libUMP.so usr/lib/

only to discover that "framebuffer", "x11" etc don't exit anywhere in the extracted files.

Maybe the author can fix these errors.  Otherwise, please don't anyone waste their time on these instructions.  Yet one more in a long list of dead-ends in trying to get my blasted cubieboard 1 to boot. Sigh.

beerstein

Hi: Allwinner A10 and A20 (CB1,CB2 and CT) have a similar boot process. As far as I can see, you try to make a bootable sd card for CB1?
The trick is to have an unallocated sd card space before the first partition of your sd card starts. A /boot partition is not a must - I think. The boot loader needs to start at sector 16 (cubietruck) and sector 8 (cubiebord2) I do not know the value for CB1.? May be somebody else here knows?
Then you need o know where your first partition FAT16/Fat32 or ext2 needs o start. This partition holds the kernel and uEnv.txt plus the boot.scr from your distribution (ARCH) plus the cb1 hwpack stuff.


patwood

The boot section starts at the same offset (8K) on the SD card for all CB1, CB2, and CT.  There's a lot more difference between the two for the nand partition layout, but not for SD.  You should be able to create a CB1 version by replacing the A20 uboot/spl with the A10, replacing the A20 uImage with the A10, and putting the A10 /lib/modules/<kernel-build-name>/ directory on the card.

The confusion over sector 8 or 16 may be due to whether bs=1K is set on the dd command line, as the default sector size is 512 bytes.

beerstein

thank you for this:

"The confusion over sector 8 or 16 may be due to whether bs=1K is set on the dd command line, as the default sector size is 512 bytes."
So - is it correct?  when I say:

bs=512 and seek=16             /  is OK  and starts at sector 16 and will bytes 512 bytes long
bs=1024 and seek=8             /should be OK too - starts at sector 8 code will be 1024 bytes long

What confuses me also is the following:
1) on cubieboard2:
sunxi-spl.bin is written with  bs=1024 seek=8
u-boot.bin is written with bs=1024 seek 32

2) and the following file for cubietruck:
u-boot-sunxi-with-spl.ct20140107.bin is written with bs=512 seek=16

What is the difference between one and  two above?

The first partition of the sd card may start at sectors 1024, 2048 or 8192 - which one should we use?
The first partition may be FAT16 or FAT 32 or ext2 ? Or is ext3 and ext4 also allowed?

Lots of questions - hope it is OK



patwood

Quote from: beerstein on January 26, 2014, 02:11:35 pm
thank you for this:

"The confusion over sector 8 or 16 may be due to whether bs=1K is set on the dd command line, as the default sector size is 512 bytes."
So - is it correct?  when I say:

bs=512 and seek=16             /  is OK  and starts at sector 16 and will bytes 512 bytes long
bs=1024 and seek=8             /should be OK too - starts at sector 8 code will be 1024 bytes long


Let's not use sector numbers, as they don't really apply to memory cards, and dd can be programmed to use arbitrary sector sizes (that's what bs= sets).  Let's use KB and MB.

These both point to the exact same offset on the card, 8KB from the start (16 512-byte blocks or 8 1KB blocks).

Quote
What confuses me also is the following:
1) on cubieboard2:
sunxi-spl.bin is written with  bs=1024 seek=8
u-boot.bin is written with bs=1024 seek 32

2) and the following file for cubietruck:
u-boot-sunxi-with-spl.ct20140107.bin is written with bs=512 seek=16

What is the difference between one and  two above?


The difference is the version of the u-boot build.  Older builds had two files: spl, and u-boot.  These can be thought of as stage 1 and stage 2 boot loaders (spl does some basic setup and calls u-boot).

u-boot-sunxi-with-spl... is exactly what the file name says: "u-boot with spl".  The newer u-boot makefile combines the spl and u-boot binaries into one file for easier flashing.  So the combined file is written to the same location as spl would be, since 8KB is the offset where the Allwinner chips expect to see the SD card's boot code.

Newer u-boot builds for both CB1, CB2, and CT all create the u-boot-with-spl file.

Quote
The first partition of the sd card may start at sectors 1024, 2048 or 8192 - which one should we use?
The first partition may be FAT16 or FAT 32 or ext2 ? Or is ext3 and ext4 also allowed?

Lots of questions - hope it is OK


Of course it's okay! These forums are for asking questions and letting people know what we're all up to.

The first partition can start at any point beyond the end of the u-boot binary and it's environment area.  512KB is probably enough, and 1MB should be enough going forward even if u-boot gets lots of enhancements.

Note that 1MB is often used because the erase blocks on SD cards are pretty much guaranteed to be <= 1MB, even for really huge ones, so aligning all your partitions at 1MB offsets should guarantee optimum write performance.

As for the file systems supported on the first partition, I'm just using the defaults that linux gives me for mkfs.vfat; I'll guess it's either a fat16 or fat32, since the fat size is automatically selected for the partition size.

The linux partition can be any file system supported by linux as a root fs and that the kernel has a driver for.  Certainly ext[234] are all valid; Reiser is enabled on the kernels I'm building, as is XFS.  Don't know if you can run a linux root fs off an NTFS file system.