Build appears good but card won't boot
Chris Miller (MESL)
chris.miller at mesl.co.uk
Fri Aug 22 14:03:41 CEST 2014
Results from 1-3 look OK, I think.
From my build environment:
[root at localhost fs]# pwd
/home/chris/rpidev/nard/intermediate/fs
[root at localhost fs]# ls -l init
-rwxr-xr-x. 1 chris chris 1880 Jun 24 13:19 init
[root at localhost fs]# ls -l bin/ash
lrwxrwxrwx. 1 chris chris 7 Aug 20 23:19 bin/ash -> busybox
[root at localhost fs]# ls -l bin/busybox
-rwsr-xr-x. 1 chris chris 802072 Aug 20 23:21 bin/busybox
[root at localhost fs]# file bin/busybox
bin/busybox: setuid ELF 32-bit LSB executable, ARM, EABI5 version 1
(SYSV), dynamically linked (uses shared libs), for GNU/Linux 3.6.11,
stripped
I tar'ed the Intermediate folder (roughly 43Mb tarball) to a USB stick,
then extracted to the SD card on the Pi (folder size about 53Mb).
From a Pi running pidora, I was able to list the contents of fs/bin,
verify execute permissions on fs/init and busybox, and executing busybox
gives the expected help text (pasted in at the bottom of this email).
Looking at the logs from the serial port, it seems very much as though
it cannot *find* the init script.
I've compared the structures of the two intramfs.cpio.gz files, and
cannot see any structural differences.
I am about to do a more detailed comparison between the various files,
but I have to say this one is a bit baffling!
I can put my sdcard.img.gz up on Dropbox if that would help?
Thank you so much for your help so far.
Chris
[root at pidora home]# cd intermediate/fs/bin
[root at pidora bin]# ls
ash df gzip mknod ps sync
base64 dmesg hostname mktemp pwd tar
busybox dnsdomainname hush more rev touch
cat dumpkmap ionice mount rm true
chattr echo iostat mountpoint rmdir umount
chgrp ed ipcalc mpstat run-parts uname
chmod egrep kbd_mode mv scriptreplay usleep
chown false kill netstat sed vi
conspy fdflush ln nice setserial watch
cp fgrep login pidof sh zcat
cpio fsync ls ping sleep
cttyhack getopt lsattr ping6 stat
date grep makemime pipe_progress stty
dd gunzip mkdir printenv su
[root at pidora bin]# ./busybox
BusyBox v1.22.1 (2014-08-20 01:05:37 BST) multi-call binary.
BusyBox is copyrighted by many authors between 1998-2012.
Licensed under GPLv2. See source distribution for detailed
copyright notices.
Usage: busybox [function [arguments]...]
or: busybox --list[-full]
or: busybox --install [-s] [DIR]
or: function [arguments]...
BusyBox is a multi-call binary that combines many common Unix
utilities into a single executable. Most people will create a
link to busybox for each function they wish to use and BusyBox
will act like whatever it was invoked as.
Currently defined functions:
[, <, adjtimex, arp, arping, ash, awk, base64, basename, blkid,
blockdev, brctl, bunzip2, bzcat, bzip2, cat, chat, chattr, chgrp,
chmod, chown, chpasswd, chpst, chroot, chrt, chvt, cksum,
clear, cmp,
conspy, cp, cpio, crond, crontab, cryptpw, cttyhack, cut, date,
dc, dd,
deallocvt, depmod, devmem, df, diff, dirname, dmesg, dnsdomainname,
dos2unix, du, dumpkmap, echo, ed, egrep, eject, env, envdir,
envuidgid,
ether-wake, expand, expr, false, fbset, fbsplash, fdflush, fdisk,
fgconsole, fgrep, find, findfs, flash_eraseall, flash_lock,
flash_unlock, flashcp, flock, fold, free, freeramdisk, fsck,
fstrim,
fsync, ftpget, ftpput, fuser, getopt, getty, grep, groups, gunzip,
gzip, halt, hd, head, hexdump, hostid, hostname, hush, id,
ifconfig,
ifplugd, inetd, init, inotifyd, insmod, install, ionice,
iostat, ip,
ipaddr, ipcalc, ipcrm, ipcs, iplink, iproute, iprule, iptunnel,
kbd_mode, kill, killall, killall5, klogd, last, less, ln, loadfont,
loadkmap, logger, login, logname, logread, losetup, ls, lsattr,
lsmod,
lsof, lsusb, makedevs, makemime, md5sum, mdev, mesg, microcom,
mkdir,
mkdosfs, mke2fs, mkfifo, mkfs.ext2, mkfs.vfat, mknod, mkpasswd,
mktemp,
modinfo, modprobe, more, mount, mountpoint, mpstat, mv, nameif,
nanddump, nandwrite, nc, netstat, nice, nmeter, nohup,
nslookup, ntpd,
od, openvt, passwd, patch, pgrep, pidof, ping, ping6,
pipe_progress,
pivot_root, pkill, pmap, poweroff, printenv, printf, ps, pscan,
pstree,
pwd, pwdx, rdate, rdev, readahead, readlink, readprofile, realpath,
reboot, renice, reset, resize, rev, rfkill, rm, rmdir, rmmod,
route,
run-parts, runsv, runsvdir, rx, script, scriptreplay, sed,
sendmail,
seq, setconsole, setfont, setkeycodes, setlogcons, setserial,
setsid,
setuidgid, sh, sha1sum, sha256sum, sha3sum, sha512sum, showkey,
slattach, sleep, smemcap, softlimit, sort, split,
start-stop-daemon,
stat, strings, stty, su, sulogin, sum, sv, svlogd, switch_root,
sync,
sysctl, syslogd, tac, tail, tar, tcpsvd, tee, telnet, telnetd,
test,
tftp, tftpd, time, timeout, top, touch, tr, traceroute,
traceroute6,
true, tty, ttysize, tunctl, tune2fs, ubiattach, ubidetach,
ubimkvol,
ubirmvol, ubirsvol, ubiupdatevol, udhcpc, udpsvd, umount, uname,
unexpand, uniq, unix2dos, unzip, uptime, users, usleep, uudecode,
uuencode, vconfig, vi, volname, wall, watch, watchdog, wc,
wget, which,
who, whoami, whois, xargs, yes, zcat, zcip
[root at pidora bin]# cd ..
[root at pidora fs]# ls
bin dev home lib opt root sdcard tmp var
boot etc init mnt proc sbin sys usr
[root at pidora fs]# ls -ltra init
-rwxr-xr-x 1 chris chris 1880 Jun 24 13:19 init
[root at pidora fs]# cat init
#!/bin/ash
#-------------------------------------------------
# Setup paths
PATH_NEWROOT="/newroot"
CMDPREFIX="$PATH_NEWROOT/lib/ld-linux.so \
--inhibit-cache \
--library-path $PATH_NEWROOT/lib \
$PATH_NEWROOT/bin/busybox"
#-------------------------------------------------
echo
echo "Kernel startup finished, now waiting for hotplug events..."
echo
# We are in the boot process and the kernel
# is still probing HW for devices such as
# USB memory sticks etc. We need to wait for
# the enumeration to complete before we move
# the entire root filesystem below.
mount -t devtmpfs devtmpfs /dev
mount -t sysfs sysfs /sys
sleep 1
DELAY=0
until test -b /dev/mmcblk0; do
DELAY=$((DELAY + 1))
test $DELAY -eq 100 && break
sleep 0.2
echo -n "."
done
DELAY=0
TMP1=0
TMP2=0
until test $DELAY -eq 10; do
TMP1=`find /sys/class /sys/bus | wc -l`
test $TMP1 -eq $TMP2 || DELAY=0
TMP2=$TMP1
DELAY=$((DELAY + 1))
sleep 0.2
echo -n "."
done
umount /sys
umount /dev
#-------------------------------------------------
# Find out how large our root filesystem is
# and limit the new tmpfs in size.
SIZE=$(du -sxk / | awk '{ print int ($1 * 1.3 + 51200) }')
mkdir -p $PATH_NEWROOT
chmod 0755 $PATH_NEWROOT
mount -t tmpfs tmpfs $PATH_NEWROOT -o size=${SIZE}k,mode=755
# Copy and move everything (almost) from current
# root filesystem into a new filesystem. By moving
# to a tmpfs we can set a maximum ram usage limit.
echo -n "."
cp -fav /bin $PATH_NEWROOT
echo -n "."
cp -fav /lib $PATH_NEWROOT
echo -n "."
$CMDPREFIX rm -rf /bin /lib
hash -r
# By now we need to execute BusyBox from
# the new root only.
for D in $($CMDPREFIX find / -xdev -mindepth 1 -maxdepth 1 | \
$CMDPREFIX grep -vE "/bin|/lib|$PATH_NEWROOT|/init"); do
$CMDPREFIX echo -n "."
$CMDPREFIX mv -fv $D $PATH_NEWROOT
done
$CMDPREFIX echo "."
exec $CMDPREFIX switch_root $PATH_NEWROOT /sbin/init
[root at pidora fs]# [root at localhost fs]# pwd
-bash: [root at localhost: command not found
[root at pidora fs]# /home/chris/rpidev/nard/intermediate/fs
-bash: /home/chris/rpidev/nard/intermediate/fs: No such file or directory
[root at pidora fs]#
-------- Original Message --------
*Subject: *Re: Build appears good but card won't boot
*From: *Ronny Nilsson <rln-nard at arbetsmyra.dyndns.org>
*To: *chris.miller at mesl.co.uk
*CC: *nard at arbetsmyra.dyndns.org, "nf at file.mesl.co.uk" <nf at file.mesl.co.uk>
*Date: *22/08/2014 09:57
> It looks like the initramfs is loaded but the kernel can't execute from it. We
> need some more clues to solve this... Can you try these suggestions below:
>
> 1) In your build tree, verify that nard/intermediate/fs/init exists and has
> execute permissions.
>
> 2) In your build tree, verify that nard/intermediate/fs/bin/ash is a symlink
> to busybox.
>
> 3) In your build tree, run the command "file nard/intermediate/fs/bin/busybox"
> it should output something like this (long wraped line):
> nard/intermediate/fs/bin/busybox: setuid ELF 32-bit LSB executable, ARM,
> version 1 (SYSV), for GNU/Linux 3.6.11, dynamically linked (uses shared
> libs), stripped
> Notice the ARM keyword! If it's anything else something is wrong.
>
> 4) Boot the Raspberry with a "good" SD-card. Then copy your
> nard/intermediate/fs/* to a USB memory stick and mount that in the Raspberry.
> Next check that you can execute files from the memstick,
> e.g. "/memstick/bin/busybox" should output a help and version text.
>
> /Ronny
>
>
> -------------------
>> Firstly my apologies for not subscribing - I thought I had, but probably
>> pressed a wrong button somewhere.
>>
>> Thanks for your quick response
>>
>> Yes, it is only initramfs which needs to be changed to bring it to life.
>>
>> Full dump from serial port is attached as text file, but last few lines
>> read:
>>
>> [ 4.346573] registered taskstats version 1
>> [ 4.352907] console [netcon0] enabled
>> [ 4.356590] netconsole: network logging started
>> ø[ 4.365225] Freeing unused kernel memory: 160K (c04ce000 - c04f6000)
>> [ 4.373845] Failed to execute /init
>> [ 4.379220] Kernel panic - not syncing: No init found. Try passing
>> init= option to kernel. See Linux Documentation/init.txt for guidance.
>> [ 4.391675] CPU: 0 PID: 1 Comm: swapper Not tainted 3.10.19 #1
>> [ 4.397556] [<c0013de8>] (unwind_backtrace+0x0/0xf4) from
>> [<c00120e8>] (show_stack+0x10/0x14)
>> [ 4.406103] [<c00120e8>] (show_stack+0x10/0x14) from [<c036ed18>]
>> (panic+0x90/0x1f4)
>> [ 4.413858] [<c036ed18>] (panic+0x90/0x1f4) from [<c036e4dc>]
>> (kernel_init+0xb8/0xe4)
>> [ 4.421699] [<c036e4dc>] (kernel_init+0xb8/0xe4) from [<c000e288>]
>> (ret_from_fork+0x14/0x2c)
>>
>> Does this help point up what I've done wrong?
>>
>> With many thanks,
>>
>> Chris
>> -------- Original Message --------
>> *Subject: *Re: Build appears good but card won't boot
>> *From: *Ronny Nilsson <rln-nard at arbetsmyra.dyndns.org>
>> *To: *chris.miller at mesl.co.uk
>> *CC: *nard at arbetsmyra.dyndns.org, "nf at file.mesl.co.uk" <nf at file.mesl.co.uk>
>> *Date: *21/08/2014 09:12
>>
>>> Hi Chris
>>> When you copy files from the good card to you "bad", is it enough to
>>> copy only initramfs.cpio.gz? No need for "zImage"? In that case the
>>> kernel probably starts but fails to recognize the filesystem. The
>>> console messages one might see in the HDMI output of other distributions
>>> at boot are disabled by default in Nard, however they are still
>>> available in the serial port for diagnostics. Would it be possible for
>>> you to get a USB-UART converter and connect it to the expansion pin
>>> header? The kernel will likely print the errors there. (Remember to get
>>> the 3.3V version).
>>> /Ronny
>>>
>>> ---------------------------------------------------------
>>>
>>>> Hi there,
>>>>
>>>> I've run the 'make skeleton' build process in a Fedora 20 32bit VM
>>>> and all appears to go fine (apart from many many _warnings _about
>>>> comparing signed with unsigned, no fatal _errors_), and I get the
>>>> image files such as sdcard.img.gz in nard/images.
>>>>
>>>> My SD card reader comes up as sdd sdd1 sdd2 rather than mmcblk0
>>>>
>>>> If I use the downloaded image nard-sdcard.img.gz in the command
>>>> zcat nard-sdcard.img.gz >/dev/dd
>>>> sync
>>>> I can boot the resulting SD card in a R-Pi: ethernet comes up, and I
>>>> can log in via ssh.
>>>>
>>>> However, if I use the home-built one, the zcat command appears to
>>>> work, and I can then mount the SD card and see the expected list of
>>>> files on the SD card - almost identical to a card made from
>>>> nard-sdcard.img.gz. But on power up, the raspberry pi gives one green
>>>> flash on the sd card activity light (presumably attempting to load
>>>> bootcode.bin), then nothing further happens on LEDs, ethernet or
>>>> (HDMI-attached) screen. I am using the same physical SD card for
>>>> both loads.
>>>>
>>>> I can "mend" the broken card by copying initramfs.cpip.gz and
>>>> initramfs.cpio.gz.md5sum from a "good" card to the "broken" card, so
>>>> it seems likely that the build process is not working correctly.
>>>>
>>>> uname -a returns:
>>>> Linux localhost.localdomain 3.15.10-200.fc20.i686+PAE #1 SMP Thu Aug
>>>> 14 15:58:37 UTC 2014 i686 i686 i386 GNU/Linux
>>>>
>>>> Where should I start to look for my mistake?
>>>>
>>>> Thanks in advance for your suggestions,
>>>>
>>>> Chris Miller
More information about the Nard
mailing list