WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Compiling piCore Kernel  (Read 4404 times)

Offline Spaigy

  • Newbie
  • *
  • Posts: 3
Compiling piCore Kernel
« on: February 15, 2016, 04:48:02 PM »
Hi,

I'm looking for some advice on how to go about recompiling the piCore Kernel?

The background is, I've created a patch for the smsc95xx driver which causes it to first check for a MAC address on eeprom before using the smsc95xx.macaddr parameter given by start.elf (or through cmdline.txt). This is because I have some USB-Ethernet adaptors based on the same chip as the Pi and they were all being assigned the same MAC address on boot. I've tested this on a stock Raspbian install, following the guide here: https://www.raspberrypi.org/documentation/linux/kernel/building.md and this has been successful.

My attempt with piCore has been less so though, I downloaded the sources from: http://tinycorelinux.net/7.x/armv6/releases/RPi/src/kernel/ and extracted them all. I then applied the supplied patch and my patch. I also copied the supplied .config file into the extracted kernel sources.

I then ran
Code: [Select]
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- oldconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- bzImage modules dtbs
sudo scripts/mkknlimg arch/arm/boot/zImage ../kernel7.img

and copied the kernel7.img file to the SD card, updated config.txt to point to that kernel and tried booting the pi... alas, it gets stuck on the rainbow screen.

I know I've not done anything with the modules - not too sure what to do here, but could this be causing my problem?
I've also been part-following the guide here: http://wiki.tinycorelinux.net/wiki:custom_kernel but this is geared more to the x86 version so I'm treading a line between that and the Raspbian guide.

Any advice is welcomed!

Thanks

Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 1243
Re: Compiling piCore Kernel
« Reply #1 on: February 15, 2016, 07:47:27 PM »
Have you opened a bug at the rpi github?    I'm sure they would be open to fixing the driver.  If you can get the official source fixed, it will make future upgrades easier.

You will have to remaster the entire image wth modules......not just the kernel.    There are a few threads that outline the process on a rpi, but it's quite involved.   In addition to the remastering process on the wiki.

Offline Spaigy

  • Newbie
  • *
  • Posts: 3
Re: Compiling piCore Kernel
« Reply #2 on: February 16, 2016, 12:40:47 PM »
HI Paul_123

Thanks for your reply. I've submitted a pull request to the RPi github and it's been merged.

As for my compile problems last night, I think the config I was using was for a Pi1, not a Pi2. I've compiled the stock RPi Kernel with standard config, which seems to have done the trick for now, I think there is some optimization to be done though.

For those interested, here's what I did for a working system (assuming /mnt/boot is the fat32 partition of my SD card):

Code: [Select]
git clone https://github.com/raspberrypi/tools
git clone --depth=1 https://github.com/raspberrypi/linux

PATH = $PATH:$HOME/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin

cd linux

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- bcm2709_defconfig
make -j3 ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- bzImage modules dtbs

sudo scripts/mkknling arch/arm/boot/zImage mnt/boot/kernel4117v7.img
sudo cp arch/arm/boot/dts/*.dtb /mnt/root/
sudo cp arch/arm/boot/dts/overlays/*.dtb* /mnt/root/overlays/
sudo cp arch/arm/boot/dts/overlays/README /mnt/root/overlays/

mkdir /mnt/root
cd /mnt/root
zcat /mnt/boot/7.0v7.gz | sudo cpio -i -H newc -d
cd $HOME/linux
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=/mnt/root modules_install
sudo depmod -a -b /mnt/root 4.1.17-v7
sudo ldconfig -r /mnt/root
cd /mnt/root
sudo find | sudo cpio -o -H newc | gzip -2 > /mnt/boot/piCore.gz
advdef -z4 /mnt/boot/piCore.gz

My config.txt now contains this:
Code: [Select]
[PI2]
initramfs piCore.gz followkernel
kernel kernel4117v7.img
cmdline cmdline.txt

This has created a significantly larger initramfs file which has a knock-on on boot time, next step will be to try to reduce the number or size of modules...

Thanks

Craig