1

I want to create a small Ubuntu 14.0.4 image for raspberry pi2 and followed the following steps, but I can't boot the device. what am I doing wrong?

  1. Partitioned the SD card into two FAT and ext4 partitions. Formatted each.

  2. Downloaded the core rootfs from Here and uncompressed it directly onto the 'ROOT' ext4 partition using tar -xvzf /path/to/ubuntu-base /media/card.

  3. Following the instructions from Here, I compiled a Kernel for RPi2 and installed/copied the necessary files incl. firmware, header and modules onto the proper SD card partitions.

  4. Compiled and copied the U-boot boot loader to the 'BOOT' FAT partition. and some other files including the config.txt, *.elf

Raspberry sends the video signal to the HDMI, i can see the 4 raspberries on the screen at the very beginning of the boot process but then the screen goes black. Where or what did it do wrong?

Thank you all.

bsoren
  • 13
  • 2
  • Just to be sure: When you say you "downloaded the core rootfs from Here" you do mean the `armhf` version, correct? – goldilocks Jul 04 '16 at 13:24
  • @goldilocks Yes the armhf version. I just followed a U-boot blog, booted the Pi into u-boot env. Set the env variables and tried to manually boot the kernel7.img from u-boot cmdline and it gets stuck at Starting Kernel... – bsoren Jul 04 '16 at 13:31
  • Why don't you try getting it to work with the ready made kernel [from here](https://github.com/raspberrypi/firmware/tree/master/boot) first? **Note you will have to install the modules** as well from [one level up](https://github.com/raspberrypi/firmware) in that tree. – goldilocks Jul 04 '16 at 13:33
  • Also, if you did not install the modules you built into the ubuntu root fs, your kernel will likely fail at some point prior to completely the boot process. – goldilocks Jul 04 '16 at 13:36
  • Thank you for the suggestion! ofc I am here to get insights from people with more experience like you, I'll also try that. An update; I also compiled a kernel 3.19 for RPi a couple of days ago. I just copied its zImage to BOOT and went through the same procedure in u-Boot env & it successfully booted into linux with my root logins but with ridiculously large fonts. previous kernel was a version 4.4.xx – bsoren Jul 04 '16 at 13:50
  • Because the pi kernel is built for a very specific piece of hardware, I think it includes everything it needs to get a very basic system up and running even if there are no further driver modules available (I think I have done this by accident before). However, in general for a kernel to operate properly, to its full potential, it does need those modules and they need to be from the same build (or match the version exactly). – goldilocks Jul 04 '16 at 13:55
  • well, i tried copying the /boot from the git you suggested. it boots successfully, Cheers! There's just one tiny issue during the boot process which is at some point it stops and says: "The disk drive for / is not ready yet or not present. Press S to skip mounting or M for manual recovery." although after pressing S i can access my ext4 partition, it needs manual input during boot up which is a problem for my application. how can I get fix that? – bsoren Jul 04 '16 at 14:12
  • I don't know; however, I don't think that is a kernel message (but I could be wrong) meaning it has something to do with how ubuntu's init is configured. Again: *make certain you installed those modules to the `/lib/modules/` directory on the root fs, preserving the directory name, which matches the kernel version* (i.e., currently you should have a `/lib/modules/4.4.14-v7+` directory, if not, you skipped a step; in case it was not clear earlier that is [from here](https://github.com/raspberrypi/firmware/tree/master/modules)). – goldilocks Jul 04 '16 at 14:21
  • The modules are there, guess this is not a kernel issue. i'll investigate more and will post if I could solve the issue. Thanks for your help! – bsoren Jul 04 '16 at 14:48
  • It *could* be a kernel issue, just I believe it most likely is not. I do have another guess for you [based on this](http://ubuntuforums.org/showthread.php?t=1507558), I'll write that up as an answer. – goldilocks Jul 04 '16 at 14:52

1 Answers1

0

I use a generic Fedora image on the Pi 2 and there is a bit of work you must do to adapt that in order to get to everything to work properly. This will apply equally to any distro that does not target the pi specifically, so you should have a read through that.

Even if you do want to use your own kernel in the end, it is probably best to first test your set-up using the ready made one distributed on github by the Rpi Foundation.

https://github.com/raspberrypi/firmware/tree/master/boot

This is actually the entire /boot partition contents, so you might as well just use a copy of the whole thing. However, you will also need to install the corresponding modules into the root filesysem (i.e., the Ubuntu partition). As far as I have noticed, the firmware repo is maintained such that there is only one version of the kernel, in two flavors, one for the ARMv6 models and one for the the ARMv7/8 models, and the corresponding module directories are in another section of the "firmware" repo heirarchy:

https://github.com/raspberrypi/firmware/tree/master/modules

You should copy those directories into the /lib/modules directory in the root fs. There will already be stuff there, possibly including directories for same base kernel version, but thanks to the suffixes used (by the Foundation, + and -v7+, by Ubuntu something longer) there should be no collisions. The Ubuntu ones will never be used and will probably take up a fair bit of space so you may want to delete them at some point (and after system updates which update the kernel). Beware I can't promise this won't cause minor problems with apt, but probably not.

Also, as per the Fedora post, you probably don't want to use /boot as the mount point for first parition because Ubuntu will install stuff there, and the root fs image probably has a /boot partition with contents already. Instead, create a /boot/rpi subdirectory for use as a mount point; this is mentioned again in relation to fstab below.

Based on your error using the ready made kernel ("The disk drive for / is not ready yet or not present") and this ubuntu forums thread, I think the problem is because /etc/fstab has not been tweaked as per step #2 in the answer linked above about Fedora.

Here's a minimal fstab that should work:

proc            /proc           proc    defaults          0       0
/dev/mmcblk0p1  /boot/rpi       vfat    defaults          0       2
/dev/mmcblk0p2  /               ext4    defaults,noatime  0       1

This differs a bit from standard pi distro fstabs in that the first partition is mounted on /boot/rpi instead of /boot for reasons already explained. This partition doesn't actually have to be mounted at all, because it is not used for anything by the OS. On normal pi distros such as Raspbian, it is kept mounted so that apt can update the kernel. However, if you are running a stock Ubuntu, it will not be updating the kernel automatically (or rather, it won't be updating the kernel actually used), so you could leave this completely out of fstab and just mount it yourself when you update the kernel manually (again, see the post about Fedora for details on how to do this).

Note that fstab doesn't include any swap -- you will have to make your own decisions about that. Traditionally pi oriented distros use a compressed RAM disk or a swapfile. The former I think is a bad idea unless you are maxing out usable RAM as a matter of operation (in which case I'd say you need a device with more RAM, or to reconsider what you are doing to fill it up). The latter is fairly harmless, but since the system will start to swap out a bit even when the RAM is not full, it may be at best pointless if you aren't ever planning to max the memory out.

Leaving the system some free memory for the page cache is generally more useful than wasting it on a swap ramdisk, and likewise, leaving little or no free RAM for whatever reason will lead to sub-optimal performance.

goldilocks
  • 56,430
  • 17
  • 109
  • 217
  • Copying this minimal fstab contents to '/etc/fstab' worked like a charm! Thank you :-) – bsoren Jul 04 '16 at 15:50
  • No problem. If you are satisfied with this answer please tick the big checkmark next to it (upper left). – goldilocks Jul 04 '16 at 16:01
  • Sure, could you plz edit the answer & add the part where you referred me to the git for '/boot' partition's contents? That was the primary answer to my original question. would be nice for others who might have the same question. – bsoren Jul 04 '16 at 17:02
  • Okay, done -- in doing so I realized there is a bit of a mistake in that `fstab` which will create complications when you `apt upgrade` Ubuntu. I've corrected it, and you should read from the second paragraph for an explanation (The original actually came from a Raspbian pi I have running; right now my 2 w/ Fedora is not plugged in, and this issue slipped my mind. It should not be a big deal. If you have run `update` and it added stuff to `/boot`, you may want to remove that; I do not think there will be any conflicts but it could get cluttered and confusing). – goldilocks Jul 04 '16 at 17:31