1

I am trying to compile Raspbian inside of Ubuntu by downloading them through the Git repository, but the tools.git never gets completely downloaded.

I followed another article which insisted on adding another parameter, depth=1. By doing that I was able to complete the download with a lesser size; after which I was able to complete the configuration setup, compilation, and addition of modules.

But when I tried creating the kernel.img file, first the mkimage folder didn't exist, then I manually downloaded the files and then added to the tools folder after which I get following error:

dips@dips:~/raspbian/tools/mkimage$ sudo python ./imagetool-uncompressed.py ../../linux/arch/arm/boot/Image
[sudo] password for dips: 
Traceback (most recent call last):
  File "./imagetool-uncompressed.py", line 35, in <module>
    load_to_mem("boot-uncompressed.txt", 0x00000000)
  File "./imagetool-uncompressed.py", line 30, in load_to_mem
    mem[addr] = int(value >> i * 8 & 0xff)
UnboundLocalError: local variable 'value' referenced before assignment

I am following the steps mentioned here

Thanks .

3

The person who wrote that blog is a bit of a twit. You do not need anything other than the cross-compiler to build and install a kernel. Ignore anything that involves the separate "tools" directory.

i was able to complete the configuration setup and compilation

Good. Go into the arch/arm/boot subdirectory. There should be a file there 2-4 MB in size called zImage, presuming your configuration used gzip as the compression mode. If not (you can check this in menuconfig, it's General setup -> Kernel compression mode), it may be called bzImage for bzip2; I'm not sure what it will be for the other modes.

Copy that onto the first (vfat) partition of the SD card. Rename it, e.g., test-kernel. Now edit the config.txt file in that partition and comment out the current kernel= line and add a replacement:

#kernel=kernel.img
kernel=test-kernel

Now copy the modules and firmware over into the /lib directory on the second (ext4) partition. First, I would back up the current firmware directory, since there's only one, and I have no idea how responsible Simon's choice of configuration was. From inside the lib directory:

tar -cjf firmware.tb2 firmware

This should leave a firmware.tb2 file behind. You can leave it there or store it somewhere else. If you need to restore things later you can use tar -xjf firmware.tb2 from inside the same directory.

Simon says to erase the current firmware and modules directory. NO. NO. NO. DO NOT. Just use the two cp -a commands to copy stuff in. This will overwrite as necessary and leave whatever isn't being replaced.

You can now try to boot. If it doesn't work, you can edit config.txt again and comment out your new line and uncomment the old one to return to the original kernel. In this case, if you want to try again, I would recommend starting with the config used for the original kernel, then add to that in menuconfig. You need to get that from a running pi; it will be /proc/config.gz.1 It is not actually on the SD card so don't bother looking for it. You can put that file in the top level of the kernel source and:

gunzip config.gz
mv config .config

This will replace the one that's there. Now fire up make menuconfig, do whatever, and go through the build and install process again.


1. If you can't find it, try sudo modprobe configs and look again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.