I've updated these instructions so that they use hard float instead of soft float which should give an increase in performance. 'arm-linux-gnueabi' is replaced with 'arm-linux-gnueabihf'
First retrieve the build and cross compiler tools:
sudo apt-get install gcc-arm-linux-gnueabihf build-essential git uboot-mkimage libncurses5-dev
Next create a directory where you want build the kernel and retrieve the kernel source from git. This will take some time. Note the old repository was git://github.com/amery/linux-allwinner.git it has now move to git://github.com/linux-sunxi/linux-sunxi.
mkdir kernel
cd kernel
git clone git://github.com/linux-sunxi/linux-sunxi
Now switch to branch you are interested in, the current stable is linux-sunxi. For debian I'm currently using revision 23e5456879db0175f571dec43095c49e181e0b10 (3.0.36+). Note kernels version beyond 3.0.36+ ethernet (eth0) on the hackberry fails to initialise correctly, see my patch at the end of the blog for a temporary fix.
cd linux-sunxi
git checkout 23e5456879db0175f571dec43095c49e181e0b10
next step is to create a default kernel config, this creates a .config file.
make ARCH=arm sun4i_defconfig
now to add additional modules or change kernel settings do
make ARCH=arm menuconfig
Now can compile the kernel and modules
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j3 uImage
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j3 INSTALL_MOD_PATH=output modules
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j3 INSTALL_MOD_PATH=output modules_install
Last step is to copy the kernel (uImage) to the boot fat partition and the kernel modules to the ext4 partition. Note keep track of the kernel version that is in .config as this will determine which modules directory has to be copied across. Here is the example for the debian image and git revision 23e5456879db0175f571dec43095c49e181e0b10.
cp arch/arm/boot/uImage /media/BOOT/
cp -rp output/lib/modules/3.0.36+/kernel /media/debian/lib/modules/3.0.36+
---------------------------------------------------------------------------------
Patch for ethernet initialisation failure:
--- a/drivers/net/sun4i/sun4i_wemac.c
+++ b/drivers/net/sun4i/sun4i_wemac.c
@@ -53,7 +53,7 @@
#define DRV_VERSION "1.01"
#define DMA_CPU_TRRESHOLD 2000
#define TOLOWER(x) ((x) | 0x20)
-#define PHY_POWER 0
+#define PHY_POWER 1
/*
* Transmit timeout, default 5 seconds.
*/
@@ -1563,7 +1563,8 @@ static int wemac_phy_read(struct net_device *dev, int phyaddr_unused, int reg)
writel(0x1, db->emac_vbase + EMAC_MAC_MCMD_REG);
spin_unlock_irqrestore(&db->lock, flags);
- wemac_msleep(db, 1); /* Wait read complete */
+ // wemac_msleep(db, 1); /* Wait read complete */
+ udelay(150); /* 100 */
/* push down the phy io line and read data */
spin_lock_irqsave(&db->lock, flags);
@@ -1596,7 +1597,8 @@ static void wemac_phy_write(struct net_device *dev,
writel(0x1, db->emac_vbase + EMAC_MAC_MCMD_REG);
spin_unlock_irqrestore(&db->lock, flags);
- wemac_msleep(db, 1); /* Wait write complete */
+// wemac_msleep(db, 1); /* Wait write complete */
+ udelay(150); /* 100 */
spin_lock_irqsave(&db->lock, flags);
/* push down the phy io line */
---------------------------------------------------------------------------------
Patch for ethernet initialisation failure:
--- a/drivers/net/sun4i/sun4i_wemac.c
+++ b/drivers/net/sun4i/sun4i_wemac.c
@@ -53,7 +53,7 @@
#define DRV_VERSION "1.01"
#define DMA_CPU_TRRESHOLD 2000
#define TOLOWER(x) ((x) | 0x20)
-#define PHY_POWER 0
+#define PHY_POWER 1
/*
* Transmit timeout, default 5 seconds.
*/
@@ -1563,7 +1563,8 @@ static int wemac_phy_read(struct net_device *dev, int phyaddr_unused, int reg)
writel(0x1, db->emac_vbase + EMAC_MAC_MCMD_REG);
spin_unlock_irqrestore(&db->lock, flags);
- wemac_msleep(db, 1); /* Wait read complete */
+ // wemac_msleep(db, 1); /* Wait read complete */
+ udelay(150); /* 100 */
/* push down the phy io line and read data */
spin_lock_irqsave(&db->lock, flags);
@@ -1596,7 +1597,8 @@ static void wemac_phy_write(struct net_device *dev,
writel(0x1, db->emac_vbase + EMAC_MAC_MCMD_REG);
spin_unlock_irqrestore(&db->lock, flags);
- wemac_msleep(db, 1); /* Wait write complete */
+// wemac_msleep(db, 1); /* Wait write complete */
+ udelay(150); /* 100 */
spin_lock_irqsave(&db->lock, flags);
/* push down the phy io line */
hi jas,
ReplyDeleteI am trying to compile kernel with tun module but I have some problem.
- In the new "git://github.com/linux-sunxi/linux-sunxi" repository
the command "cd linux-allwinner" doesn't work
- How can I find the kernel, relative brunch and revision?
- The kernel is in git or should I download from kernel.org?
Hi,
DeleteI didn't update the blog properly :( should be:
cd inux-sunxi
after "cd linux-sunxi" you wrote "Now switch to branch you are interested in"
Delete- How can I find the kernel, relative brunch and revision?
- The kernel is in git or should I download from kernel.org?
-where did you find revision 23e5456879db0175f571dec43095c49e181e0b10?
Kernel is in linux-sunxi directory. Are you compiling for Linux or Andriod?
Deletefor linux(your debian release for hackberry).
DeleteI need a tun module (openvpn).
Then just follow the instructions or you may find some of the modules pre-compiled here https://www.miniand.com/forums/forums/development--3/topics/3-0-36-compiled-with-ipv6-and-lots-of-misc-modules.
DeleteShouldn't
ReplyDeletecp -rp output/lib/modules/3.0.36+/kernel /media/debian/lib/modules/3.0.36+
be
cp -rp output/lib/modules/3.0.36+ /media/debian/lib/modules/3.0.36+
?
Tried to checkout 23e.... but got an abort due to untracked working tree files to be overwritten or removed; is there another checkout you might suggest? Thanks. Hlavery
ReplyDeleteGit it telling you that you have changes in your current branch which you either need to commit and discard. Then you should be able to checkout 23e...
DeleteThanks...rather than re-compile, I swapped out the TinyCore kernel from their armhf version, apt-get Xorg, dwm suckless-tools, added a startx invocation to the sysv startup files and rebooted..voila! a working GUI. Added surf, and have working graphical browser.
DeleteSo you have finally got TinyCore running ?
DeleteI have the "Core" version up by switching in the evb.bin, u-boot, and sunxi.spl you provided for the ones one the tinycore .img file. This gives a bterm in framebuffer ( I think) which is interesting and fast for what it does. However, the import app which pulls in .deb files and processes them into Tinycore's .tcz format doesn't entirely work yet, which makes it hard to do what I want to do...add in Xorg and a simple desktop.
Delete@jas...I now have a working prelim TinyCore GUI with X, flwm, xterm. If you would like a look at it, please download from http://www.hlavery.us and give it a try. The second (ext4) partition would need to be expanded to do anything much more; I kept the disk image under 200M. README file will be necessary.
ReplyDeleteThe file is downloading from Hackberry RAM using mongoose as a micro-server; this is the kind of thing TinyCore is very good at.
Anyhow, this version contains sunxi-spl, u-boot and script.bin from your earlier efforts, so I thought I'd offer a look. Thanks, hlavery
Hi Hlavery,
DeleteGood job, I'll give a go!
I seem to have not left contact info anywhere; if you have comments/suggestions pls. send a message to hlavery through the tinycore message boards, http://forum.tinycorelinux.net/, I have some recent small postings there.
ReplyDeleteSent from Arora browser running in Tinycore on Hackberry..."import arora", etc.
Thanks, hlavery
hmhm doesn't work anymore following your tutorial .
ReplyDeletei used it 2 month ago and worked fine ..
root@DreamboxRestream:/var/kernel/linux-sunxi# git checkout c0bd4b6a0c6c0d42235920fb7ddd7110c86e2adb
Previous HEAD position was 839cf7a... Linux 3.0.35
HEAD is now at c0bd4b6... Linux 3.0.36
root@DreamboxRestream:/var/kernel/linux-sunxi# make ARCH=arm sun4i_defconfig
HOSTCC scripts/basic/fixdep
HOSTCC scripts/kconfig/conf.o
HOSTCC scripts/kconfig/zconf.tab.o
HOSTLD scripts/kconfig/conf
***
*** Can't find default configuration "arch/arm/configs/sun4i_defconfig"!
***
make[1]: *** [sun4i_defconfig] Error 1
make: *** [sun4i_defconfig] Error 2
root@DreamboxRestream:/var/kernel/linux-sunxi#
The file sun4i_defconfig seems to be missing it should be in arch/arm/configs/sun4i_defconfig. Check it is in the git repository.
Deleteidd it is missing , also your checkout doesnt work anymore .
ReplyDeletefor 3.0.36 .
can't find 3.0.36+ kernel anymore in Git :(
ReplyDeleteonly find 3.0.36 ...you have a copy ?
i have a perfectly running 3.0.36+ kernel with ax25 support ( build it a while ago following your instructions ) but now i need to add PPP for a usb 3G modem ..but i really struggle ..
ReplyDeleteHi, the 3.0.6+ should still be available on sunxi-3.0 git branch at git://github.com/linux-sunxi/linux-sunxi.git. I still have local copy.
Deletei only find 3.036 .. w/o the + ..
ReplyDeletewhat is the plus for ?
root@ubuntu64:~/kernel/linux-sunxi# git log --grep="Linux 3.0.36"
ReplyDeletecommit c0bd4b6a0c6c0d42235920fb7ddd7110c86e2adb
Author: Greg Kroah-Hartman
Date: Fri Jun 22 11:34:31 2012 -0700
Linux 3.0.36
root@ubuntu64:~/kernel/linux-sunxi# git checkout c0bd4b6a0c6c0d42235920fb7ddd7110c86e2adb
Note: checking out 'c0bd4b6a0c6c0d42235920fb7ddd7110c86e2adb'.
Hi, is there any youtube guide on how to do all this? I just get the hackberry A10 but want to install Debian and make it work with the WIFI. Thanks a lot if someone has any link. Thanks
ReplyDeleteHi, there is more info on the miniand forums which may help along with newer pre-compiled images. https://www.miniand.com/forums/forums/development--3?page=3
DeleteKernel wouldn't check out for me from git, kept failing with:
ReplyDelete"remote: aborting due to possible repository corruption on the remote side.
fatal: early EOF
fatal: index-pack failed"
Fixed by adding '--depth 1' to the clone argument. It means you can't commit but I wasn't planning to anyone. (Even then it took 2 attempts to check out though)
Solution was from : http://jinsucraft.wordpress.com/
anyway*
DeleteWorked other than that Jas-hacks, that's me just built and installed my first kernel. Cheers for the guide!
DeleteHi everybody!
ReplyDeleteI'm trying to follow this guide.
When i launch the command:
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j3 uImage
i get this error:
make[1]: *** [arch/arm/common/built-in.o] Error 237
make: *** [arch/arm/common] Error 2
make: *** Waiting for unfinished jobs....
without stopping the process, it just keeps going and apparently its a minor error.
the problem is that, when it finishes, there's no uImage anywhere!
even the other two commands:
"make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j3 INSTALL_MOD_PATH=output modules
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j3 INSTALL_MOD_PATH=output modules_install
seem to work fine and with no error .
Sombody have any hints on this issue?
Thanks a lot!
Looks like there was a compile error, try the following to display the error:
Deletemake ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- uImage
Hi,
ReplyDeleteI want to ask why do we need to do the git checkout 23...? What is the reason?
I really appreciate your help as I am a newbie at this. Sometimes the cross compiling works, but sometimes it doesn't. Really peculiar.
Thank you in advance!
Hi, "git checkout 23" was used because at the time that was a stable revision, the head was unstable becuase it was work in progress. You can find the latest kernels here http://linux-sunxi.org/Linux.
Deletewhat is the latest stable chackout?
DeleteI compiled the kernel and modules and when I put uImage to boot partition and modules in system/vendor on SD Card to run Android, it dosent boot.
ReplyDeleteJust black screen.
I have stock Android running from SD card from hackberry.
Please, help
Hi!
ReplyDeleteI followed your entire guide but I found usb issues using the kernel compiled... The system doesn't power/recognize any usb device inserted, lsusb doesn't show nothing and even dmesg is silent about usb events... do you know where the problem is?