kernel panic when cloning a BBB using beaglebone-black-make-microSD-flasher-from-eMMC.sh

231 views
Skip to first unread message

Matt99eo

unread,
Jul 27, 2016, 5:26:45 PM7/27/16
to BeagleBoard
Hi, 

Been trying to clone a debian 8.4 running kernel 4.1.x using the RC Nelson script beaglebone-black-make-microSD-flasher-from-eMMC.sh

I have ensured that I have the latest script (git pull when in /opt/scripts/tools)
I have ensured the BBB I am cloning has a network connection during the process.


When I insert he  new uSD card into a new BBB to flash it it ends quickly with a kernel panic.

Here is the serial debug output:

Starting eMMC Flasher from microSD media
Version: [1.20160718: mkfs.ext4 1.43...]
-----------------------------
Checking for Valid bbb-eeprom header
Valid bbb-eeprom header found [335]
-----------------------------
copying: [/dev/mmcblk0] -> [/dev/mmcblk1]
lsblk:
NAME         MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
mmcblk1boot0 179:16   0    1M  1 disk 
mmcblk1boot1 179:24   0    1M  1 disk 
mmcblk0      179:0    0  7.2G  0 disk 
`-mmcblk0p1  179:1    0  7.2G  0 part /
mmcblk1      179:8    0  3.7G  0 disk 
-----------------------------
df -h | grep rootfs:
-----------------------------
Erasing: /dev/mmcblk1
108+0 records in
108+0 records out
113246208 bytes (113 MB) copied, 17.7061 s, 6.4 MB/s
[   34.099130] random: nonblocking pool is initialized
108+0 records in
108+0 records out
113246208 bytes (113 MB) copied, 4.35786 s, 26.0 MB/s
Erasing: /dev/mmcblk1 complete
-----------------------------
Writing bootloader to [/dev/mmcblk1]
dd if= of=/dev/mmcblk1 count=1 seek=1 bs=128k
-----------------------------
dd: failed to open '': No such file or directory[   35.897114] Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000100
[   35.897114] 
[   35.911129] CPU: 0 PID: 1 Comm: init-eMMC-flash Not tainted 4.1.21-bone-rt-r20 #1
[   35.918639] Hardware name: Generic AM33XX (Flattened Device Tree)
[   35.924801] [<c0012e01>] (unwind_backtrace) from [<c0010fe9>] (show_stack+0x11/0x14)
[   35.932590] [<c0010fe9>] (show_stack) from [<c05e2049>] (panic+0x6d/0x188)
[   35.939500] [<c05e2049>] (panic) from [<c002fea9>] (complete_and_exit+0x1/0x18)
[   35.946844] [<c002fea9>] (complete_and_exit) from [<c00372c1>] (sigprocmask+0x59/0x88)
[   35.954801] [<c00372c1>] (sigprocmask) from [<00000001>] (0x1)
[   35.960665] ---[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000100
[   35.960665] 

The line I've highlighed in yellow seams to be the problem.  
Why is the cloning script getting a bootloader in here? 

Any help much appreciated!

William Hermans

unread,
Jul 27, 2016, 5:46:30 PM7/27/16
to beagl...@googlegroups.com
The line I've highlighed in yellow seams to be the problem.  
Why is the cloning script getting a bootloader in here?

Any help much appreciated!

What do you mean "why?" ? Short answer is that a bootloader( actually two - first and second stage ) is required to boot from eMMC.

dd if= of=/dev/mmcblk1 count=1 seek=1 bs=128k is in reference to MLO I believe. uboot.img is roughly 348k as I recall.

--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/f7f021f7-98e5-4ae8-88d7-311f83b8d32b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Matt99eo

unread,
Jul 27, 2016, 5:51:09 PM7/27/16
to BeagleBoard
I mean why isn't the boot loader getting on the uSD I've created using the script?  I know why it needs to be there...

How do I solve this such that I can slam the created uSD into a new BBB and have flash eMMC?

William Hermans

unread,
Jul 27, 2016, 6:10:48 PM7/27/16
to beagl...@googlegroups.com
dd: failed to open '': No such file or directory[   35.897114] Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000100

That's why. It can't find a file or directory. And here is why:


dd if= of=/dev/mmcblk1 count=1 seek=1 bs=128k

See the problem ? Where's the input file ? " " ?

Matt99eo

unread,
Jul 27, 2016, 6:13:53 PM7/27/16
to BeagleBoard
But isn't the script -- beaglebone-black-make-microSD-flasher-from-eMMC.sh -- supposed do do that?

Do I need to manually add this in?  Sorry noob here I don't understand.  I see the problem.  But I don't know how to solve it, hence asking for help :)

William Hermans

unread,
Jul 27, 2016, 6:18:19 PM7/27/16
to beagl...@googlegroups.com
I know nothing of Robert's eMMC flasher script. I would probably never use it. But thus far have not used it. However, the reason why dd error'd out is as I said in my last post. It needs an input file in order to work.

William Hermans

unread,
Jul 27, 2016, 6:22:08 PM7/27/16
to beagl...@googlegroups.com
Here: https://eewiki.net/display/linuxonarm/BeagleBone+Black#BeagleBoneBlack-SetupmicroSDcard is the basic rundown of what has to happen in order to create a working sdcard. The concept should be nearly if not exactly the same for the eMMC with the exception of targeting a different block device. The eMMC, instead of sdcard.

Matt99eo

unread,
Jul 27, 2016, 6:23:04 PM7/27/16
to BeagleBoard
OK could could you reccomend another way to accomplish my objective that does work?  

Thanks for your input!

William Hermans

unread,
Jul 27, 2016, 6:32:06 PM7/27/16
to beagl...@googlegroups.com
Same method you're using, but if= needs to point to a suitable  MLO file. That is: I'm guessing based on the count and bs of that particular dd line. I only say I would probably never use Robert's script to do this as I do not know what he script does, and I am very particular in how my beaglebones are setup. SO instead of reading through his script, I would write my own script. Since I know what needs being done.

As to other methods I'd use. Well technically I've never written to an eMMC yet. Others here probably have more hands on than I in regards to the eMMC. However, as I mention above.  I know what needs doing, and how to do it. Which is something really too complex to just tell someone without experience how to do. Unless I've tested it first. Which won't happen any time soon.

So we're back to square 1.

William Hermans

unread,
Jul 27, 2016, 6:36:26 PM7/27/16
to beagl...@googlegroups.com
One thing that does come to mind that you can try. Would be to get one of the latest Jessie flasher images. Then flash that to eMMC. Afterwords, wipe the rootfs, create a tar backup of the rootfs you want on the eMMC, then tar that over to the eMMC. But as a Linux newb that might be easier said than done.

Perhaps I'll experiment with that sometime this evening if I find the time.

Matt99eo

unread,
Jul 27, 2016, 6:48:40 PM7/27/16
to BeagleBoard
I am noob+ so I'll give'r it a whirl :)

William Hermans

unread,
Jul 27, 2016, 7:14:51 PM7/27/16
to beagl...@googlegroups.com
Ok, so once you have a working eMMC. You'll probably want to make the partition as small as possible, while still being big enough for the rootfs. Then dd backyp the entire eMMC block device. That way, when you dd back to replicate, it'll take less time. Then, if you need, or want to resize the rootfs partition. You do that afterwards. It should make the whole process much quicker. Instead of copying over needed data, and then filling the rest of the eMMC with zero's through dd . . .

William Hermans

unread,
Jul 27, 2016, 7:18:58 PM7/27/16
to beagl...@googlegroups.com
I think I will experiment with this in a bit. What I'll do is grab one of the latest Jessie flasher images. Flash it to eMMC, and then replace the rootfs with an older Wheezy rootfs. I do not have any of this ready, so setup will take me a while. Which will include backing up the eMMC as it sits( factory image ).

Got some other things to do first though. . .

William Hermans

unread,
Jul 27, 2016, 10:46:28 PM7/27/16
to beagl...@googlegroups.com
Still toying around. Ran into a couple things I did not expect, but nothing show stopping yet. The biggest thing on my mind immediately was knowing that Robert was using an UUID for the root mount of the eMMC. Which turned out to be a non issue so far.

I had considered backing up the eMMC as it is now - WIth Debian Jessie on it and one single partition. But I do not like what all is running on this image, and I'm not 100% how to deal with the things I'm not liking. So . . . I think I'll skip that.

Now, time to boot back into the development image, and see what hackery I can engage . . .

William Hermans

unread,
Jul 28, 2016, 12:29:06 AM7/28/16
to beagl...@googlegroups.com
Rough exact steps . . .

On X86 development machine:
william@eee-pc:~$ cd backup/
william@eee-pc:~/backup$ wget https://rcn-ee.com/rootfs/bb.org/testing/2016-06-19/console/BBB-blank-debian-8.5-console-armhf-2016-06-19-2gb.img.xz

william@eee-pc:~/backup$ lsblk

NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 149.1G  0 disk
├─sda1   8:1    0   9.3G  0 part /
├─sda2   8:2    0     1K  0 part
├─sda5   8:5    0     2G  0 part [SWAP]
└─sda6   8:6    0 137.8G  0 part /home
sdb      8:16   1  29.8G  0 disk
└─sdb1   8:17   1  29.8G  0 part

william@eee-pc:~/backup$ xzcat BBB-blank-debian-8.5-console-armhf-2016-06-19-2gb.img.xz | sudo dd of=/dev/sdb
3481600+0 records in
3481600+0 records out
1782579200 bytes (1.8 GB) copied, 500.677 s, 3.6 MB/s

On Beaglebone:

Backup eMMC:
william@beaglebone:~$ lsblk

NAME         MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
mmcblk1boot0 179:16   0    2M  1 disk
mmcblk1boot1 179:24   0    2M  1 disk
mmcblk0      179:0    0 14.7G  0 disk
`-mmcblk0p1  179:1    0  1.7G  0 part /
mmcblk1      179:8    0  3.6G  0 disk
|-mmcblk1p1  179:9    0   96M  0 part
`-mmcblk1p2  179:10   0  3.5G  0 part

william@beaglebone:~$ ls
am33xx-pruss-uio.dts  dev  remove-modules.sh  temp

william@beaglebone:~$ cd dev/
william@beaglebone:~/dev$ ls
C  beaglebone_cleanup  bonejs  dtb-4.4-ti  dtb-single  javascript  misc  test-dts

william@beaglebone:~/dev$ mkdir backup-emmc
william@beaglebone:~/dev$ cd backup-emmc/

This is an NFS share, so will take a while.
william@beaglebone:~/dev/backup-emmc$ time sudo dd if=/dev/mmcblk1 of=./2016-07-27-emmc_backup.img bs=1M
[sudo] password for william:
3688+0 records in
3688+0 records out
3867148288 bytes (3.9 GB) copied, 451.522 s, 8.6 MB/s

real    7m36.950s
user    0m0.252s
sys     1m5.144s

william@beaglebone:~/dev/backup-emmc$ sudo halt

At this point remove the sdcard from the x86 dev machine, and place into the Beaglebone. Then toggle the power button.
If you have a serial debug cable connected to the beaglebone, you can watch the progress of the flasher. This should
finish very quickly. Once the LEDs all go solid, the board is in the process of shutting down. Let all LEDs go off, and
stay off before removing the sdcard and attempting to boot from eMMC.

Once booted from eMMC on the Beaglebone you can login via the serial debug terminal. Or you can login via ssh.


debian@beaglebone:~$ lsblk

NAME         MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
mmcblk0boot0 179:8    0    2M  1 disk
mmcblk0boot1 179:16   0    2M  1 disk
mmcblk0      179:0    0  3.6G  0 disk
`-mmcblk0p1  179:1    0  3.6G  0 part /

debian@beaglebone:~$ uname -r
4.4.12-ti-r31

debian@beaglebone:~$ cat /etc/dogtag
BeagleBoard.org Debian Image 2016-06-19

Knowing the contents pf /etc/fstab will be helpful at this point. Although I plan on mounting the eMMC as device name
not by UUID. So I may as well double check that this will work by changing it now.

debian@beaglebone:~$ cat /etc/fstab
# /etc/fstab: static file system information.
#
UUID=a84daf59-1ce7-4cf8-af6f-b50652ab71a9  /  ext4  noatime,errors=remount-ro  0  1
debugfs  /sys/kernel/debug  debugfs  defaults  0  0

debian@beaglebone:~$ mount |grep mmcblk
/dev/mmcblk0p1 on / type ext4 (rw,noatime,errors=remount-ro,data=ordered)

debian@beaglebone:~$ sudo nano /etc/fstab
Change to:
# /etc/fstab: static file system information.
#
/dev/mmcblk0p1  /  ext4  noatime,errors=remount-ro  0  1
debugfs  /sys/kernel/debug  debugfs  defaults  0  0

debian@beaglebone:~$ sudo reboot

At this point you'll likely see some errors about fsck having issues with various disk properties. These should be
safe to ignore. Now would be the time to make additional changes if you wish to save the contents of the eMMC for
future use. Personally, I need to mount and nfs share so I can now backup the eMMC via dd.


debian@beaglebone:~$ sudo nano /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
        address 192.168.254.167
        netmask 255.255.255.0
        gateway 192.168.2254.254

debian@beaglebone:~$ sudo ifdown eth0
debian@beaglebone:~$ sudo ifup eth0

debian@beaglebone:~$ sudo apt-get update
debian@beaglebone:~$ sudo apt-get install nfs-common rpcbind

debian@beaglebone:~$ mkdir dev
debian@beaglebone:~$ sudo mount -o v3 192.168.254.162:/home/william/share /home/debian/dev
debian@beaglebone:~$ df -h
Filesystem                           Size  Used Avail Use% Mounted on
udev                                  10M     0   10M   0% /dev
tmpfs                                 99M  4.3M   95M   5% /run
/dev/mmcblk0p1                       3.5G  367M  3.0G  11% /
tmpfs                                247M     0  247M   0% /dev/shm
tmpfs                                5.0M     0  5.0M   0% /run/lock
tmpfs                                247M     0  247M   0% /sys/fs/cgroup
192.168.254.162:/home/william/share  136G   51G   79G  39% /home/debian/dev

hmmm, a lot of work to do on this image. So maybe I'll bypass doing a backup.

debian@beaglebone:~$ sudo halt
[ 4676.329564] reboot: System halted

Switched back to sdcard:

william@beaglebone:~$ lsblk

NAME         MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
mmcblk1boot0 179:16   0    2M  1 disk
mmcblk1boot1 179:24   0    2M  1 disk
mmcblk0      179:0    0 14.7G  0 disk
`-mmcblk0p1  179:1    0  1.7G  0 part /
mmcblk1      179:8    0  3.6G  0 disk
`-mmcblk1p1  179:9    0  3.6G  0 part
william@beaglebone:~$ ls /
ID.txt  boot  etc   lib         media  nfs-uEnv.txt  opt   root  sbin  sys  uEnv.txt  var
bin     dev   home  lost+found  mnt    node_modules  proc  run   srv   tmp  usr

william@beaglebone:~$ ls /media/
william@beaglebone:~$ sudo mkdir /media/rootfs

william@beaglebone:~$ sudo mount /dev/mmcblk1p1 /media/rootfs/
william@beaglebone:/media/rootfs$ sudo rm -rf /media/rootfs/
william@beaglebone:~$ ls /media/rootfs/ /* Crickets . . . */

Switched to x86 dev machine:

william@eee-pc:~$ ls cleanup/downloads/linux-images/
bone-debian-7.7-console-armhf-2014-11-19-2gb.img  bone-debian-8.0-console-armhf-2015-05-04-2gb.img
bone-debian-7.8-console-armhf-2015-03-01-2gb.img  v3.8.13-bone47

william@eee-pc:~$ sudo fdisk -lu cleanup/downloads/linux-images/bone-debian-7.8-console-armhf-2015-03-01-2gb.img

Disk cleanup/downloads/linux-images/bone-debian-7.8-console-armhf-2015-03-01-2gb.img: 1782 MB, 1782579200 bytes
184 heads, 31 sectors/track, 610 cylinders, total 3481600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

                                                                          Device Boot      Start         End      Blocks   Id  System
cleanup/downloads/linux-images/bone-debian-7.8-console-armhf-2015-03-01-2gb.img1   *        2048     3481599     1739776   83  Linux

offset= 512 * 2048 or sector size * start
william@eee-pc:~$ sudo mount -o loop,offset=1048576 cleanup/downloads/linux-images/bone-debian-7.8-console-armhf-2015-03-01-2gb.img /media/rootfs/

william@eee-pc:~$ cd /media/rootfs/
william@eee-pc:/media/rootfs$ ls
bin   dev  home    lib         media  nfs-uEnv.txt  proc  run   selinux  sys  uEnv.txt       usr
boot  etc  ID.txt  lost+found  mnt    opt           root  sbin  srv      tmp  uEnv.txt.save  var

william@eee-pc:/media/rootfs$ cat etc/dogtag
BeagleBoard.org Debian Image 2015-03-01

william@eee-pc:/media/rootfs$ sudo tar -zcvpf ~/test-rootfs.tar.gz .
william@eee-pc:/media/rootfs$ cd ~
william@eee-pc:~$ sudo umount /media/rootfs/
william@eee-pc:~$ mv test-rootfs.tar.gz share/

switch back to beaglebone:
william@beaglebone:~$ cd dev/
william@beaglebone:~/dev$ ls | grep rootfs
test-rootfs.tar.gz

william@beaglebone:~/dev$ sudo tar xzvf ./test-rootfs.tar.gz -C /media/rootfs/
william@beaglebone:~/dev$ ls /media/rootfs/
ID.txt  boot  etc   lib         media  nfs-uEnv.txt  proc  run   selinux  sys  uEnv.txt       usr
bin     dev   home  lost+found  mnt    opt           root  sbin  srv      tmp  uEnv.txt.save  var

william@beaglebone:~$ cd /media/rootfs/
william@beaglebone:/media/rootfs$ cat etc/fstab
# /etc/fstab: static file system information.
#
# Auto generated by RootStock-NG: setup_sdcard.sh
#
/dev/mmcblk0p1  /  ext4  noatime,errors=remount-ro  0  1
debugfs  /sys/kernel/debug  debugfs  defaults  0  0

Looks good.

william@beaglebone:/media/rootfs$ cat etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
        address 192.168.254.167
        netmask 255.255.255.0
        gateway 192.168.254.254

william@beaglebone:/media/rootfs$ cat etc/resolv.conf
nameserver 192.168.254.254

william@beaglebone:/media/rootfs$ head boot/uEnv.txt
#Docs: http://elinux.org/Beagleboard:U-boot_partitioning_layout_2.0

uname_r=3.8.13-bone70
#dtb=
cmdline=root=/dev/mmcblk0p1

##Example
#cape_disable=capemgr.disable_partno=
#cape_enable=capemgr.enable_partno=

william@beaglebone:/media/rootfs$ cd ~
william@beaglebone:~$ sudo umount /media/rootfs/

william@beaglebone:~/dev$ sudo halt

Remove sdcard and toggle the power button.
debian@beaglebone:~$ uname -r
3.8.13-bone70
debian@beaglebone:~$ cat /etc/dogtag
BeagleBoard.org Debian Image 2015-03-01

debian@beaglebone:~$ lsblk

NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
mmcblk0boot0 179:8    0     2M  1 disk
mmcblk0boot1 179:16   0     2M  1 disk
mmcblk0      179:0    0   3.6G  0 disk
`-mmcblk0p1  179:1    0   3.6G  0 part /

William Hermans

unread,
Jul 28, 2016, 12:36:58 AM7/28/16
to beagl...@googlegroups.com
By the way . . .

debian@beaglebone:~$ cat /uEnv.txt| grep optargs
mmcargs=setenv bootargs console=tty0 console=${console} ${optargs} ${cape_disable} ${cape_enable} rootfstype=${mmcrootfstype} ${cmdline}
 
This line in the first stage uEnv.txt file contained root=/dev/mmcblk0p1 and was causing problems. So I removed this, and added  root=/dev/mmcblk0p1 to the second stage uEnv.txt file

  • First stage uEnv.txt == /uEnv.txt
  • Second stage uRnv.txt file == /boot/uEnv.txt

Anyway, this is really not a procedure for any newb, unless that newb is very meticulous and persistent.

Matt99eo

unread,
Aug 1, 2016, 1:13:40 PM8/1/16
to BeagleBoard
Hi there,

This has been solved by RC Nelson.  If you encounter this bug simply git the latest version of beaglebone-black-make-microSD-flasher-from-eMMC.sh by executing a git pull command while in /opt/scripts/tools

Thanks again RC!
Reply all
Reply to author
Forward
0 new messages