[SOLVED] - How to boot from sata

Started by PaceyIV, July 30, 2013, 09:46:54 PM

Previous topic - Next topic

PaceyIV

Hi,
I want to put the rootfs partition (with all the debian image) in a sata hard disk and use the microSD only to load the kernel. How can I do?

Thanks

Lurch


PaceyIV

#2
It doesn't work!
I've got 2 problems:
1. U-Boot say that it reads my uEnv.txt but the kernel use a different root parameter
2. I can't see the sata hard disk! I haven't got the uba device with my hard disk connected to the sata port.

uEnv.txt: the rootfs is at the second partition on my sata hard disk.

root=/dev/uba2 rootwait


Kernel command line recognized by the kernel

Kernel command line: console=ttyS0,115200 root=/dev/mmcblk0p2 rootwait loglevel=8 panic=10


Debug console log
http://pastebin.com/w5fWRBc8

PaceyIV

Problem 2 solved: I download the debian image release 2 on the sd card that I bought.
Now I've got the sdaX device with my partitions.
How can I pass the root parameter to the kernel ?


PaceyIV

Now, I can pass the right root path to kernel with the uEnv.txt below


baudrate=115200
console=ttyS0,115200
bootdelay=1
bootenv=uEnv.txt
bootscr=boot.scr
kernel=uImage
loglevel=8
panicarg=panic=10
root=/dev/sda2 ro rootwait
setargs=setenv bootargs console=${console} root=${root} loglevel=${loglevel} ${panicarg} ${extraargs}


The kernel show this during boot operation:

[    0.000000] Kernel command line: console=ttyS0,115200 root=/dev/sda2 ro rootwait loglevel=8 panic=10


I think the kenel doesn't know how to init my system. It stops with this:


[    3.335731] Waiting for root device /dev/sda2...
[    3.854795] [mmc-msg] mmc 0 detect change, present 1
[    4.349863] [mmc-msg] sdc0 set ios: clk 0Hz bm PP pm UP vdd 3.3V width 1 timing LEGACY(SDR12) dt B
[    4.358817] [mmc-msg] sdc0 power on
[    4.409846] [mmc-msg] sdc0 set ios: clk 400000Hz bm PP pm ON vdd 3.3V width 1 timing LEGACY(SDR12) dt B
[    4.492178] [mmc-err] smc 0 err, cmd 52,  RTO
[    4.497362] [mmc-err] smc 0 err, cmd 52,  RTO
[    4.501739] [mmc-msg] sdc0 set ios: clk 400000Hz bm PP pm ON vdd 3.3V width 1 timing LEGACY(SDR12) dt B
[    4.513539] [mmc-msg] sdc0 set ios: clk 400000Hz bm PP pm ON vdd 3.3V width 1 timing LEGACY(SDR12) dt B
[    4.525097] [mmc-err] smc 0 err, cmd 5,  RTO
[    4.530189] [mmc-err] smc 0 err, cmd 5,  RTO
[    4.535279] [mmc-err] smc 0 err, cmd 5,  RTO
[    4.540369] [mmc-err] smc 0 err, cmd 5,  RTO
[    4.545285] [mmc-msg] sdc0 set ios: clk 400000Hz bm PP pm ON vdd 3.3V width 1 timing LEGACY(SDR12) dt B
[    4.554758] [mmc-msg] sdc0 set ios: clk 400000Hz bm PP pm ON vdd 3.3V width 1 timing LEGACY(SDR12) dt B
[    4.566559] [mmc-msg] sdc0 set ios: clk 400000Hz bm PP pm ON vdd 3.3V width 1 timing LEGACY(SDR12) dt B
[    4.602640] [mmc-msg] sdc0 set ios: clk 400000Hz bm PP pm ON vdd 3.3V width 1 timing SD-HS(SDR25) dt B
[    4.611990] [mmc-msg] sdc0 set ios: clk 50000000Hz bm PP pm ON vdd 3.3V width 1 timing SD-HS(SDR25) dt B
[    4.619601] enter:earphone_hook_handle,line:161, pre_state: -1, state: 1
[    4.683313] [mmc-msg] sdc0 set ios: clk 50000000Hz bm PP pm ON vdd 3.3V width 4 timing SD-HS(SDR25) dt B
[    4.692848] mmc0: new high speed SDHC card at address 0007
[    4.699031] mmcblk0: mmc0:0007 SD04G 3.70 GiB
[    4.705248]  mmcblk0: p1 p2
[   12.733257] [AXP]init charger->rest_vol = 100



XFer

#5
Reading dmesg, I can't see any reference to a SATA disk.

Maybe you compiled SATA support as module, but forgot to build a initramfs?
What if you statically include the SATA support into the kernel?
Just a guess.

Fernando

Lurch

The sata in release 2 kernel doesn't get loaded until much later:
You probably need to change the kernel like Xfer recommends.

[info] Loading kernel module sw_ahci_platform.
[   11.164576] libata version 3.00 loaded.
[   11.207541] sw_ahci sw_ahci.0: SATA power enable do not exist!!
[   11.213589] sw_ahci sw_ahci.0: controller can't do PMP, turning off CAP_PMP
[   11.220591] sw_ahci sw_ahci.0: forcing PORTS_IMPL to 0x1
[   11.226044] sw_ahci sw_ahci.0: AHCI 0001.0100 32 slots 1 ports 3 Gbps 0x1 impl platform mode
[   11.234550] sw_ahci sw_ahci.0: flags: ncq sntf pm led clo only pio slum part ccc
[   11.242533] dma_alloc_coherent mem = 0xffd40000, size = 0x16500, mem_dma=0x4fc20000
[   11.252556] scsi1 : sw_ahci_platform
[   11.257720] ata1: SATA max UDMA/133 mmio [mem 0x01c18000-0x01c18fff] port 0x100 irq 88
[   11.610735] ata1: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
[   12.854103] [AXP]init charger->rest_vol = 100
[   15.274544] ata1.00: ATA-8: WDC WD7500BPVT-22HXZT3, 01.01A01, max UDMA/133
[   15.281451] ata1.00: 1465149168 sectors, multi 0: LBA48 NCQ (depth 31/32)
[   15.341379] ata1.00: configured for UDMA/133
[   15.361320] scsi 1:0:0:0: Direct-Access     ATA      WDC WD7500BPVT-2 01.0 PQ: 0 ANSI: 5
[   15.372325] sd 1:0:0:0: [sdb] 1465149168 512-byte logical blocks: (750 GB/698 GiB)
[   15.379927] sd 1:0:0:0: [sdb] 4096-byte physical blocks
[   15.387122] sd 1:0:0:0: [sdb] Write Protect is off
[   15.392106] sd 1:0:0:0: [sdb] Mode Sense: 00 3a 00 00
[   15.403009] sd 1:0:0:0: [sdb] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[   15.424538]  sdb: unknown partition table
[   15.433084] sd 1:0:0:0: [sdb] Attached SCSI disk
[ ok ] Activating lvm and md swap...done.
[....] Checking file systems...fsck from util-linux 2.20.1

PaceyIV

#7
How can I force the kernel to wait until it discovers sata hard drive?

I add rootdelay=20 in the extraargs into the uEnv.txt but I doesn't works!


[    3.345704] Waiting 20sec before mounting root device...
[    3.865081] [mmc-msg] mmc 0 detect change, present 1
[    4.360145] [mmc-msg] sdc0 set ios: clk 0Hz bm PP pm UP vdd 3.3V width 1 timing LEGACY(SDR12) dt B
[    4.360156] [mmc-msg] sdc0 power on
[    4.399900] [mmc-msg] sdc0 set ios: clk 400000Hz bm PP pm ON vdd 3.3V width 1 timing LEGACY(SDR12) dt B
[    4.492399] [mmc-err] smc 0 err, cmd 52,  RTO
[    4.497595] [mmc-err] smc 0 err, cmd 52,  RTO
[    4.501961] [mmc-msg] sdc0 set ios: clk 400000Hz bm PP pm ON vdd 3.3V width 1 timing LEGACY(SDR12) dt B
[    4.513764] [mmc-msg] sdc0 set ios: clk 400000Hz bm PP pm ON vdd 3.3V width 1 timing LEGACY(SDR12) dt B
[    4.525312] [mmc-err] smc 0 err, cmd 5,  RTO
[    4.530402] [mmc-err] smc 0 err, cmd 5,  RTO
[    4.535494] [mmc-err] smc 0 err, cmd 5,  RTO
[    4.540584] [mmc-err] smc 0 err, cmd 5,  RTO
[    4.545505] [mmc-msg] sdc0 set ios: clk 400000Hz bm PP pm ON vdd 3.3V width 1 timing LEGACY(SDR12) dt B
[    4.554941] [mmc-msg] sdc0 set ios: clk 400000Hz bm PP pm ON vdd 3.3V width 1 timing LEGACY(SDR12) dt B
[    4.566773] [mmc-msg] sdc0 set ios: clk 400000Hz bm PP pm ON vdd 3.3V width 1 timing LEGACY(SDR12) dt B
[    4.602922] [mmc-msg] sdc0 set ios: clk 400000Hz bm PP pm ON vdd 3.3V width 1 timing SD-HS(SDR25) dt B
[    4.612265] [mmc-msg] sdc0 set ios: clk 50000000Hz bm PP pm ON vdd 3.3V width 1 timing SD-HS(SDR25) dt B
[    4.619888] enter:earphone_hook_handle,line:161, pre_state: -1, state: 1
[    4.683581] [mmc-msg] sdc0 set ios: clk 50000000Hz bm PP pm ON vdd 3.3V width 4 timing SD-HS(SDR25) dt B
[    4.693120] mmc0: new high speed SDHC card at address 0007
[    4.699320] mmcblk0: mmc0:0007 SD04G 3.70 GiB
[    4.705522]  mmcblk0: p1 p2
[   12.733537] [AXP]init charger->rest_vol = 100
[   23.360320] Waiting for root device /dev/sda2...


Any other suggestions?

Lurch

Are you sure it is being set up as /dev/sda2 ?
Mine, for example, gets set to /dev/sdbx.
Not sure if you can work with LABEL, which would be easier, but hardcoded paths can be a problem.

PaceyIV

Yes. When I boot from official debian image release two without my uEnv.txt I can see the rootfs on my sata hd on /dev/sda2.
I think the problem is that sda exists only after /dev/ is fully populated and this happens only after init is loaded. :(

PaceyIV

The problem is sw_ahci_platform and ata modules are not compiled static in the kernel provided by official debian R2 image.

They should be in Serial ANA and Parallel ATA drivers in the kernel menu config.

XFer

That's what we said before: you need to compile the kernel yourself and build SATA drivers statically, so the kernel does not need to have the filesystem mounted to load them.
Or you may figure out how to build a initramfs with the SATA modules, so the kernel can use them before mounting the rootfs.
I don't know how to do that, but it's very useful and I think linux-sunxi has docs about it.

Fernando

PaceyIV

I try to create a uInitrd image.

According to this tutorial (http://linux-sunxi.org/Initial_Ramdisk) I add sw_ahci_platform to /etc/initramfs-tools/modules then I create the ramdisk inittmkinitramfs -o initrd.img and convert it to uBoot format with mkimage -A arm -T ramdisk -C none -n uInitrd -d /path/to/initrd.img /path/to/uInitrd

At boot I stop the autoboot and I put the commands


fatload mmc 0 0x43000000 script.bin
fatload mmc 0 0x41000000 uImage
fatload mmc 0 0x45000000 uInitrd
bootm 0x41000000 0x45000000


Now the kernel knows my sda partition but I don't know how to continue the boot


Loading, please wait...
[   10.235668] udevd[681]: starting version 175
[   11.103931] calling  wait_scan_init+0x0/0x14 [scsi_wait_scan] @ 717
[   11.110285] initcall wait_scan_init+0x0/0x14 [scsi_wait_scan] returned 0 after 5 usecs
Begin: Loading essential drivers ... [   11.358537] calling  ata_init+0x0/0x334 [libata] @ 723
[   11.364066] libata version 3.00 loaded.
[   11.368123] initcall ata_init+0x0/0x334 [libata] returned 0 after 4222 usecs
[   11.385670] calling  sw_ahci_init+0x0/0x28 [sw_ahci_platform] @ 723
[   11.392454] sw_ahci sw_ahci.0: SATA power enable do not exist!!
[   11.398512] sw_ahci sw_ahci.0: controller can't do PMP, turning off CAP_PMP
[   11.405561] sw_ahci sw_ahci.0: forcing PORTS_IMPL to 0x1
[   11.411002] sw_ahci sw_ahci.0: AHCI 0001.0100 32 slots 1 ports 3 Gbps 0x1 impl platform mode
[   11.419463] sw_ahci sw_ahci.0: flags: ncq sntf pm led clo only pio slum part ccc
[   11.427335] dma_alloc_coherent mem = 0xffda0000, size = 0x16500, mem_dma=0x45020000
[   11.435805] scsi0 : sw_ahci_platform
[   11.439930] ata1: SATA max UDMA/133 mmio [mem 0x01c18000-0x01c18fff] port 0x100 irq 88
[   11.448229] initcall sw_ahci_init+0x0/0x28 [sw_ahci_platform] returned 0 after 54935 usecs
[   11.794873] ata1: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
[   11.803332] ata1.00: ATA-8: WDC WD3200BEKT-22F3T0, 11.01A11, max UDMA/133
[   11.810141] ata1.00: 625142448 sectors, multi 0: LBA48 NCQ (depth 31/32)
[   11.819376] ata1.00: configured for UDMA/133
[   11.824200] scsi 0:0:0:0: Direct-Access     ATA      WDC WD3200BEKT-2 11.0 PQ: 0 ANSI: 5
[   11.839248] sd 0:0:0:0: [sda] 625142448 512-byte logical blocks: (320 GB/298 GiB)
[   11.847295] sd 0:0:0:0: [sda] Write Protect is off
[   11.852117] sd 0:0:0:0: [sda] Mode Sense: 00 3a 00 00
[   11.857466] sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[   12.158438]  sda: sda1 sda2 sda3 sda4
[   12.164305] sd 0:0:0:0: [sda] Attached SCSI disk
done.
Begin: Running /scripts/init-premount ... done.
Begin: Mounting root file system ... Begin: Running /scripts/local-top ... done.
Begin: Running /scripts/local-premount ... done.
modprobe: module unknown not found in modules.dep
mount: can't read '/etc/fstab': No such file or directory
Begin: Running /scripts/local-bottom ... done.
done.
Begin: Running /scripts/init-bottom ... mount: mounting /dev on /root/dev failed: No such file or directory
done.
Target filesystem doesn't have requested /sbin/init.
No init found. Try passing init= bootarg.
modprobe: module i8042 not found in modules.dep
modprobe: module atkbd not found in modules.dep
modprobe: module uhci-hcd not found in modules.dep


BusyBox v1.20.2 (Debian 1:1.20.0-7) built-in shell (ash)
Enter 'help' for a list of built-in commands.

/bin/sh: can't access tty; job control turned off
(initramfs) [   16.908247] [AXP]init charger->rest_vol = 100

XFer

#13
Here's the problem:

mount: can't read '/etc/fstab': No such file or directory
Begin: Running /scripts/local-bottom ... done.
done.
Begin: Running /scripts/init-bottom ... mount: mounting /dev on /root/dev failed: No such file or directory
done.
Target filesystem doesn't have requested /sbin/init.
No init found. Try passing init= bootarg.


Among other things (no /etc/fstab), the system can't find init.
Maybe it's not into /sbin in your rootfs.
Find it and then pass its path as a boot parameter (i.e., something like init=/usr/sbin/init )
Without init, consoles can't be opened (no tty).

Fernando

PaceyIV

I succeeded in booting my board from sata.

I stop the autoboot and I send this commands:

setenv console 'ttyS0,115200'
setenv root '/dev/sda2'
setenv panicarg 'panic=10'
setenv extra 'rootfstype=ext4 rootwait'
setenv loglevel '8'
setenv setargs 'setenv bootargs console=${console} root=${root} loglevel=${loglevel} ${panicarg} ${extra}'
setenv kernel 'uImage'
setenv boot_mmc 'fatload mmc 0 0x43000000 script.bin; fatload mmc 0 0x41000000 ${kernel}; fatload mmc 0 0x45000000 uInitrd; bootm 0x41000000 0x45000000'
setenv bootcmd 'run setargs boot_mmc'


How can I save this commands in uEnv.txt? With the text below doesn't work!


baudrate=115200
console=ttyS0,115200
bootdelay=1
bootenv=uEnv.txt
bootscr=boot.scr
kernel=uImage
loglevel=8
panicarg=panic=10
root=/dev/sda2 rootwait
extraargs=mac_addr=00:AE:99:A3:E4:AF
setargs=setenv bootargs console=${console} root=${root} loglevel=${loglevel} ${panicarg} ${extraargs}
boot_mmc=fatload mmc 0 0x43000000 script.bin; fatload mmc 0 0x41000000 ${kernel}; fatload mmc 0 0x4500000 uInitrd; bootm 0x41000000 0x4500000
bootcmd=run setargs boot_mmc