为Cubieboard2构建自己的的Debian Linux的步骤(4)编译组件
soloforce汇编整理
2013年12月28 日
大文实验室/大文哥
壹捌陆捌零陆捌捌陆捌贰
wb4916 AT qq.com
完成时间:2017/6/7 15:42
2 编译组件
2.1 编译U-BOOT:
root@cm-System-Product-Name:/home/rootroot/cubieboard2# tar zxvf u-boot-sunxi_cb2_20170531_1437.tar.gz
root@cm-System-Product-Name:/home/rootroot/cubieboard2# cd u-boot-sunxi
root@cm-System-Product-Name:/home/rootroot/cubieboard2/u-boot-sunxi#
对于Cubieboard2,则这样编译:
root@cm-System-Product-Name:/home/rootroot/cubieboard2/u-boot-sunxi# make distclean CROSS_COMPILE=arm-linux-gnueabihf-
root@cm-System-Product-Name:/home/rootroot/cubieboard2/u-boot-sunxi# make cubieboard2 CROSS_COMPILE=arm-linux-gnueabihf-
……
cd /home/rootroot/cubieboard2/u-boot-sunxi/spl/ && arm-linux-gnueabihf-ld.bfd -T /home/rootroot/cubieboard2/u-boot-sunxi/spl/u-boot-spl.lds --gc-sections --gc-sections -Bstatic -Ttext 0x20 arch/arm/cpu/armv7/start.o --start-group arch/arm/cpu/armv7/libarmv7.o arch/arm/cpu/armv7/sunxi/libsunxi.o arch/arm/lib/libarm.o board/sunxi/libsunxi.o common/libcommon.o common/spl/libspl.o disk/libdisk.o drivers/i2c/libi2c.o drivers/mmc/libmmc.o drivers/power/libpower.o drivers/serial/libserial.o lib/libgeneric.o --end-group /home/rootroot/cubieboard2/u-boot-sunxi/spl/arch/arm/lib/eabi_compat.o -L /usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/sf -lgcc -Map u-boot-spl.map -o u-boot-spl
arm-linux-gnueabihf-objcopy --gap-fill=0xff -O binary /home/rootroot/cubieboard2/u-boot-sunxi/spl/u-boot-spl /home/rootroot/cubieboard2/u-boot-sunxi/spl/u-boot-spl.bin
/home/rootroot/cubieboard2/u-boot-sunxi/tools/mksunxiboot \
/home/rootroot/cubieboard2/u-boot-sunxi/spl/u-boot-spl.bin /home/rootroot/cubieboard2/u-boot-sunxi/spl/sunxi-spl.bin
File size: 0x479c
Load size: 0x479c
Read 0x479c bytes
Write 0x4800 bytes
make[2]:正在离开目录 `/home/rootroot/cubieboard2/u-boot-sunxi/spl'
make -C examples/standalone all
make[2]: 正在进入目录 `/home/rootroot/cubieboard2/u-boot-sunxi/examples/standalone'
arm-linux-gnueabihf-gcc -g -Os -ffunction-sections -fdata-sections -fno-common -ffixed-r8 -msoft-float -D__KERNEL__ -DCONFIG_SYS_TEXT_BASE=0x4a000000 -I/home/rootroot/cubieboard2/u-boot-sunxi/include -fno-builtin -ffreestanding -nostdinc -isystem /usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/include -pipe -DCONFIG_ARM -D__ARM__ -marm -mno-thumb-interwork -mabi=aapcs-linux -march=armv7-a -Wall -Wstrict-prototypes -fno-stack-protector -Wno-format-nonliteral -Wno-format-security -fstack-usage -fno-toplevel-reorder -o hello_world.o hello_world.c -c
arm-linux-gnueabihf-gcc -g -Os -ffunction-sections -fdata-sections -fno-common -ffixed-r8 -msoft-float -D__KERNEL__ -DCONFIG_SYS_TEXT_BASE=0x4a000000 -I/home/rootroot/cubieboard2/u-boot-sunxi/include -fno-builtin -ffreestanding -nostdinc -isystem /usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/include -pipe -DCONFIG_ARM -D__ARM__ -marm -mno-thumb-interwork -mabi=aapcs-linux -march=armv7-a -Wall -Wstrict-prototypes -fno-stack-protector -Wno-format-nonliteral -Wno-format-security -fstack-usage -fno-toplevel-reorder -o stubs.o stubs.c -c
arm-linux-gnueabihf-ld.bfd -r -o libstubs.o stubs.o
arm-linux-gnueabihf-ld.bfd -g -Ttext 0x50000000 \
-o hello_world -e hello_world hello_world.o libstubs.o \
-L/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8 -lgcc
arm-linux-gnueabihf-objcopy -O srec hello_world hello_world.srec 2>/dev/null
arm-linux-gnueabihf-objcopy -O binary hello_world hello_world.bin 2>/dev/null
make[2]:正在离开目录 `/home/rootroot/cubieboard2/u-boot-sunxi/examples/standalone'
make -C examples/api all
make[2]: 正在进入目录 `/home/rootroot/cubieboard2/u-boot-sunxi/examples/api'
make[2]: 没有什么可以做的为 `all'。
make[2]:正在离开目录 `/home/rootroot/cubieboard2/u-boot-sunxi/examples/api'
make[1]:正在离开目录 `/home/rootroot/cubieboard2/u-boot-sunxi'
root@cm-System-Product-Name:/home/rootroot/cubieboard2/u-boot-sunxi#
2.2 编译sunxi-tools:
sunxi-tools提供了fexc、nand-part等工具,在系统安装、定制的过程中可能会用到,所以可以先编译它们。因为这些工具常常在宿主系统上(x86-64 Ubuntu Linux)来针对目标设备、目标系统运行,所以可以把它们编译为x86-64的可执行文件。
root@cm-System-Product-Name:/home/rootroot/cubieboard2/u-boot-sunxi# cd ..
root@cm-System-Product-Name:/home/rootroot/cubieboard2#
root@cm-System-Product-Name:/home/rootroot/cubieboard2# tar zxvf sunxi-tools_cb2_20170531_1442.tar.gz
root@cm-System-Product-Name:/home/rootroot/cubieboard2#
root@cm-System-Product-Name:/home/rootroot/cubieboard2# cd sunxi-tools
root@cm-System-Product-Name:/home/rootroot/cubieboard2/sunxi-tools#
root@cm-System-Product-Name:/home/rootroot/cubieboard2/sunxi-tools# make
gcc -g -O0 -Wall -Wextra -std=c99 -D_POSIX_C_SOURCE=200112L -Iinclude/ -o fexc fexc.c script.c script_uboot.c script_bin.c script_fex.c
ln -s fexc bin2fex
ln -s fexc fex2bin
gcc -g -O0 -Wall -Wextra -std=c99 -D_POSIX_C_SOURCE=200112L -Iinclude/ -o bootinfo bootinfo.c
bootinfo.c: In function ‘print_script’:
bootinfo.c:274:25: warning: unused parameter ‘script’ [-Wunused-parameter]
void print_script(void *script)
^
gcc -g -O0 -Wall -Wextra -std=c99 -D_POSIX_C_SOURCE=200112L -Iinclude/ `pkg-config --cflags libusb-1.0` -o fel fel.c `pkg-config --libs libusb-1.0`
gcc -g -O0 -Wall -Wextra -std=c99 -D_POSIX_C_SOURCE=200112L -Iinclude/ -o pio pio.c
pio.c: In function ‘do_command’:
pio.c:313:57: warning: unused parameter ‘argc’ [-Wunused-parameter]
static int do_command(char *buf, const char **args, int argc)
^
gcc -g -O0 -Wall -Wextra -std=c99 -D_POSIX_C_SOURCE=200112L -Iinclude/ -c -o nand-part-main.o nand-part-main.c
gcc -g -O0 -Wall -Wextra -std=c99 -D_POSIX_C_SOURCE=200112L -Iinclude/ -c -o nand-part-a10.o nand-part.c -D A10
gcc -g -O0 -Wall -Wextra -std=c99 -D_POSIX_C_SOURCE=200112L -Iinclude/ -c -o nand-part-a20.o nand-part.c -D A20
gcc -o nand-part nand-part-main.o nand-part-a10.o nand-part-a20.o
root@cm-System-Product-Name:/home/rootroot/cubieboard2/sunxi-tools#
2.3 配置、编译内核
2.3.1 拷贝预设内核配置文件
对于Cubieboard2 和 Cubieboard3,则如下:
root@cm-System-Product-Name:/home/rootroot/cubieboard2/sunxi-tools# cd ..
root@cm-System-Product-Name:/home/rootroot/cubieboard2#
root@cm-System-Product-Name:/home/rootroot/cubieboard2# tar zxvf linux-sunxi_cb2_20170605_1055.tar.gz
root@cm-System-Product-Name:/home/rootroot/cubieboard2#
root@cm-System-Product-Name:/home/rootroot/cubieboard2# cd linux-sunxi
root@cm-System-Product-Name:/home/rootroot/cubieboard2/linux-sunxi#
root@cm-System-Product-Name:/home/rootroot/cubieboard2/linux-sunxi# ll .config
ls: 无法访问.config: 没有那个文件或目录
root@cm-System-Product-Name:/home/rootroot/cubieboard2/linux-sunxi# cp arch/arm/configs/sun7i_defconfig .config
root@cm-System-Product-Name:/home/rootroot/cubieboard2/linux-sunxi#
2.3.2 配置内核:
下面开始配置内核,这是一个非常冗繁的过程,您必须足够耐心和仔细;而且,配置一个新的内核往往做不到一次性成功,可能需要多次测试内核才能达到您的目的——还是那句话:要足够耐心和仔细!
root@cm-System-Product-Name:/home/rootroot/cubieboard2/linux-sunxi# ll .config
-rw-r--r-- 1 root root 29454 6月 7 14:30 .config
root@cm-System-Product-Name:/home/rootroot/cubieboard2/linux-sunxi# cp .config bak1_orig.config
root@cm-System-Product-Name:/home/rootroot/cubieboard2/linux-sunxi#
root@cm-System-Product-Name:/home/rootroot/cubieboard2/linux-sunxi# ll *config
-rw-r--r-- 1 root root 29454 6月 7 14:35 bak1_orig.config
-rw-r--r-- 1 root root 252 6月 5 10:43 Kconfig
root@cm-System-Product-Name:/home/rootroot/cubieboard2/linux-sunxi# ll *.config
-rw-r--r-- 1 root root 29454 6月 7 14:35 bak1_orig.config
root@cm-System-Product-Name:/home/rootroot/cubieboard2/linux-sunxi#
root@cm-System-Product-Name:/home/rootroot/cubieboard2/linux-sunxi# make ARCH=arm menuconfig
root@cm-System-Product-Name:/home/rootroot/cubieboard2/linux-sunxi# cp .config bak2_soloforce.config
配置的选项很关键,要着重注意以下几项:
• SATA 硬盘支持
• GPIO 支持
• 无线网络支持
• USB 网卡支持
• Tun/Tap 设备支持
• 摄像头支持
• 红外线支持
• USB 串口设备支持
• HDMI 输出支持
下面是一些笔者为Cubieboard2 的内核进行配置的截图
图1(已经默认选中了)
Device Drivers --->
<*> Serial ATA and Parallel ATA drivers --->
<*> SoftWinner Platform AHCI SATA support
图2
Device Drivers --->
[*] GPIO Support --->
< > GPIO Support for sunxi platform
修改为:
<*> GPIO Support for sunxi platform
图3
-*- Networking support --->
-*- Wireless --->
<M> Generic IEEE 802.11 Networking Stack (mac80211)
修改为:
<*> Generic IEEE 802.11 Networking Stack (mac80211)
图4(已经默认选中了)
Device Drivers --->
[*] Network device support --->
[*] Wireless LAN (NEW) --->
<M> Ralink driver support --->
图5
Device Drivers --->
[*] Network device support --->
<M> Universal TUN/TAP device driver support
修改为:
<*> Universal TUN/TAP device driver support
图6(已经默认选中了)
Device Drivers --->
<*> Multimedia support --->
[*] Video capture adapters (NEW) --->
[*] V4L USB devices (NEW) --->
<M> USB Video Class (UVC)
图7
Device Drivers --->
Input device support --->
[*] Keyboards (NEW) --->
< > sunxi IR support (NEW)
修改为:
<*> sunxi IR support
图8
Device Drivers --->
[*] USB support (NEW) --->
<M> USB Serial Converter support --->
修改为:
<*> USB Serial Converter support --->
<M> USB Prolific 2303 Single Port Serial Driver
修改为:
<*> USB Prolific 2303 Single Port Serial Driver
图9(已经默认选中了)
Device Drivers --->
Graphics support --->
{*} Support for frame buffer devices --->
<*> HDMI Driver Support(sunxi)
2.3.3 编译内核
现在可以开始编译内核及模块了
root@cm-System-Product-Name:/home/rootroot/cubieboard2/linux-sunxi# cp .config bak2_soloforce.config
root@cm-System-Product-Name:/home/rootroot/cubieboard2/linux-sunxi# make -j12 ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- uImage modules
……
CHK include/generated/compile.h
UPD include/generated/compile.h
CC init/version.o
LD init/built-in.o
LD .tmp_vmlinux1
drivers/built-in.o:在函数‘axp_mfd_remove’中:
/home/rootroot/cubieboard2/linux-sunxi/drivers/power/axp_power/axp-mfd.c:368:对‘hwmon_device_unregister’未定义的引用
drivers/built-in.o:在函数‘axp20_init_chip’中:
/home/rootroot/cubieboard2/linux-sunxi/drivers/power/axp_power/axp20-mfd.h:149:对‘hwmon_device_register’未定义的引用
make: *** [.tmp_vmlinux1] 错误 1
root@cm-System-Product-Name:/home/rootroot/cubieboard2/linux-sunxi#
root@cm-System-Product-Name:/home/rootroot/cubieboard2/linux-sunxi# make ARCH=arm menuconfig
Device Drivers --->
<M> Hardware Monitoring support --->
修改为:
<*> Hardware Monitoring support --->
root@cm-System-Product-Name:/home/rootroot/cubieboard2/linux-sunxi# cp .config bak3_hwmon+soloforce.config
root@cm-System-Product-Name:/home/rootroot/cubieboard2/linux-sunxi# make -j12 ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- uImage modules
……
LD [M] sound/usb/snd-usb-audio.ko
LD [M] sound/usb/snd-usbmidi-lib.ko
HOSTCC firmware/ihex2fw
IHEX firmware/kaweth/new_code.bin
IHEX firmware/kaweth/trigger_code.bin
IHEX firmware/kaweth/new_code_fix.bin
IHEX firmware/kaweth/trigger_code_fix.bin
IHEX firmware/ti_3410.fw
IHEX firmware/ti_5052.fw
IHEX firmware/mts_gsm.fw
IHEX firmware/mts_edge.fw
IHEX firmware/edgeport/down3.bin
IHEX firmware/mts_cdma.fw
IHEX firmware/cpia2/stv0672_vp4.bin
IHEX2FW firmware/emi26/loader.fw
IHEX2FW firmware/emi26/firmware.fw
IHEX2FW firmware/emi26/bitstream.fw
IHEX2FW firmware/emi62/loader.fw
IHEX2FW firmware/emi62/bitstream.fw
IHEX2FW firmware/emi62/spdif.fw
IHEX2FW firmware/emi62/midi.fw
H16TOFW firmware/edgeport/boot.fw
H16TOFW firmware/edgeport/boot2.fw
H16TOFW firmware/edgeport/down.fw
H16TOFW firmware/edgeport/down2.fw
IHEX2FW firmware/whiteheat_loader.fw
IHEX2FW firmware/keyspan_pda/keyspan_pda.fw
IHEX2FW firmware/whiteheat.fw
IHEX2FW firmware/keyspan_pda/xircom_pgs.fw
root@cm-System-Product-Name:/home/rootroot/cubieboard2/linux-sunxi#
参考资料:
http://blog.csdn.net/smilefyx/article/details/38959895
A20内核编译错误undefined reference to `hwmon_device_register'
2.3.4 发掘更多的可用内存(没有测试,可选项!)
(本节仅供资深用户使用!新手莫动!菜鸟乱改可能会改出来莫名其妙的问题!!!!)
Cubieboard的默认内核配置文件中提供了mali-GPU支持,并为X11、DRI、Framebuer保留了200多兆内存,这些内存将无法被用户使用;如果想把 Cubieboard 作为一个无显示输出的服务器使用,那么这些保留内存应当释放出来供用户使用,此时必须修改内核的配置,使其中包含如下选项(修改时可在menuconfig 中按'/' 键来搜索相关选项),然后再重新编译内核:
CONFIG_SUN4I_G2D=n
CONFIG_FB_SUNXI_RESERVED_MEM=n
CONFIG_SUN4I_G2D_MODULE=n
CONFIG_FB_SUNXI_RESERVED_MEM=n
CONFIG_SUNXI_MALI_RESERVED_MEM=n
CONFIG_DRM_MALI=n
CONFIG_MALI=n
CONFIG_MALI400=n