How to compile the Allwinner A10 Linux Kernel
UPDATE : There is an easiest way now, check if it feet your need : http://www.cnx-software.com/2012/07/20/nightly-builds-for-allwinner-a10-u-boot-linux-kernel-and-hardware-packs/
This documentation assumes that you are using a debian system.
Installing an ARM cross-compiler and tools
- first read this: http://emdebian.org/crosstools.html
- edit /etc/apt/sources.list as approriate and advised above (may need to run apt-get install emdebian-archive-keyring also)
- apt-get install gcc-4.4-arm-linux-gnueabi (or appropriate: gcc-4.3 or 4.5)
- apt-get install build-essential git
- apt-get install u-boot-tools (if u-boot-tools not found, try uboot-mkimage)
Compiling last version (from 3.0.8+ leaked tree)
- The most updated tree is the one on: https://github.com/amery/linux-allwinner (moved to https://github.com/linux-sunxi/ )
- first read this: https://github.com/amery/linux-allwinner/wiki
- git clone git://github.com/amery/linux-allwinner.git (moved to https://github.com/linux-sunxi/linux-sunxi.git )
- cd linux-allwinner
- git checkout allwinner-v3.0-android-v2 (or whatever branch you want to compile)
make ARCH=arm sun4i_defconfig make ARCH=arm menuconfig make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- -j3 uImage make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- -j3 INSTALL_MOD_PATH=output modules make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- -j3 INSTALL_MOD_PATH=output modules_install
and you'll have the uImage for uBoot on arch/arm/boot/uImage and the modules on the output/ folder.
Outdated kernel version:
Getting the source code
- first read this: https://alioth.debian.org/scm/?group_id=100475
- git clone git://anonscm.debian.org/arm-netbook/arm-netbook.git (ignore warning: remote HEAD refers to nonexistent ref, unable to checkout.)
- cd arm-netbook
git checkout lichee/v2.6.36 (most recent tested working kernel source)
git checkout lichee/for-next (if you want the v3.0.17 work in progress)
alternative port to android's linux 3.0 https://github.com/amery/linux-allwinner allwinner-v3.0-android branch (WIP)
Compiling the source code (thanks to Juan Carlos Mendez)
- edit scripts/build_sun4i.sh: check that the CROSS_COMPILE variable is right (arm-linux-gnueabi- )
- create the file "rootfs/sun4i_rootfs.cpio.gz" with the command 'touch rootfs/sun4i_rootfs.cpio.gz' (Probably something belongs in it, under investigation)
- run the build script, which will automagically populate a .config: "./build.sh -p sun4i"
- use menuconfig to compile additional packages: "make ARCH=arm menuconfig"
- NOTE: ATM, 2012-12-21 0500Z, the git trees are a little damaged. The fastest route to a successful build means pulling modules/wifi/usi-bcm4329/v184.108.40.206/firmware/4329inuse/fw_bcm4329.bin from the allwinner/v2.6.36 branch into the lichee branch
./build.sh -p sun4i
./build.sh -p sun4i_crane ( this option is recommended for android systems )
the ./build.sh script calls "./scripts/build_sun4i.sh kernel" and "./scripts/build_sun4i.sh modules" itself
also sets the default .config using the files
according with de platform (-p ) parameter
* UPDATED *
You can use the command
make ARCH=arm menuconfig
to add aditional modules
* UPDATED *
By default, it's configured to compile using the CodeSourcery toolchain (arm-none-linux-gnueabi-) with the programs accesibles in the PATH
(currently i'm using Sourcery G++ Lite 2010.09-50 version)
But you can exports the CROSS_COMPILE enviroment variable to point to your toolchain tools...
( i.e export CROSS_COMPILE=~/svn/android-src/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi- )
or you can edit the ./scripts/build_sun4i.sh to change it
When the compilation finish the kernel and modules willl be in the "./output/" directory
Notes on binary files
This from the mailing lists:
I think both of them can be safely removed. I don't know if you know the Allwinner style packaging system. There is an sys_config.fex file, which is a config file for the hardware related things. This sys_config.fex will handled by a pc tools to generate a bin file called sys_config.bin which contains the data structure of the config. And the sys_config.bin will be loaded by the bootloader to a reserved memery in linux. Then in the driver, they will use function like script_parser_xxx to get the hardware information. I think the main purpose for this complicated method is to separate the hardware and the software config work. Allwinner's customs are small companies with low R&D abilities. With this method, customs only need to change the sys_config.fex file to use different peripherals, without modifying the driver. Back to the sys_config1.bin and sys_config_verity_dd3.bin, sys_config1.bin is built in the kernel before, but is loaded by bootloader now, so sys_config1.bin is no use any more, but no one cleaned it. And sys_config_verity_dd3.bin, you can see in sys_config.S,
1: .globl sys_cofig_data 2:sys_cofig_data: 3: .incbin "arch/arm/mach-sun4i/pin/sys_config_verify_ddr3.bin" 4: .globl sys_cofig_data_end 5:sys_cofig_data_end:
the label "sys_cofig_data" is only used one place arch/arm/mach-sun4i/pin/pin_ops.c
95: #ifdef FPGA_RUNTIME_ENV 96: return script_parser_init((char *)(sys_cofig_data)); 97: #else 98: return script_parser_init((char *)__va(CONFIG_SW_SYSMEM_RESERVED_BASE)); 99: #endif
You can see the macro FPGA_RUNTIME_ENV is never defined if you use a chip. So, the sys_config_verify_ddr3.bin is a special config used when the chip is in designing on a fpga, from it's name it should be the config for verifying the ddr3 controller.
I hope i have explained clearly. You can remove the sys_config.S, sys_config1.bin, sys_config_verify_ddr3.bin, and clean the code in arch/arm/mach-sun4i/pin/pin_ops.c.