1.首先下载 git clone https://github.com/BPI-SINOVOIP/BPI-M3-bsp.git
2.添加依赖包 apt-get install git build-essential libncurses5-dev
3.修改BPI-M3-bsp/Makefile 删除交叉编译选项
.PHONY: all clean help
.PHONY: u-boot kernel kernel-config
.PHONY: linux pack
include chosen_board.mk
SUDO=sudo
#unmark for use new toolchain , this time just for KERNEL TEST ONLY
#DONOT USE FOR UBOOT this time,
#due to allwinner UBOOT release without some source code issue.
OUTPUT_DIR=$(CURDIR)/output
U_CONFIG_H=$(U_O_PATH)/include/config.h
K_DOT_CONFIG=$(K_O_PATH)/.config
LICHEE_KDIR=$(CURDIR)/linux-sunxi
ROOTFS=$(CURDIR)/rootfs/linux/default_linux_rootfs.tar.gz
Q=
J=$(shell expr grep ^processor /proc/cpuinfo | wc -l
* 2)
all: bsp
DK, if u-boot and kernel KBUILD_OUT issue fix, u-boot-clean and kernel-clean
are no more needed
clean: u-boot-clean kernel-clean
rm -f chosen_board.mk
pack
pack: sunxi-pack
$(Q)scripts/mk_pack.sh
u-boot
$(U_CONFIG_H): u-boot-sunxi
$(Q)$(MAKE) -C u-boot-sunxi $(UBOOT_CONFIG)_config -j$J
u-boot: $(U_CONFIG_H)
$(Q)$(MAKE) -C u-boot-sunxi all -j$J
u-boot-clean:
rm -f sunxi-pack/chips/sun8iw6p1/bin/u-boot-sun8iw6p1.bin
rm -f u-boot-sunxi/tools/sunxi_env_gen
$(Q)$(MAKE) -C u-boot-sunxi -j$J distclean
linux
$(K_DOT_CONFIG): linux-sunxi
$(Q)$(MAKE) -C linux-sunxi ARCH=arm $(KERNEL_CONFIG)
kernel: $(K_DOT_CONFIG)
$(Q)$(MAKE) -C linux-sunxi ARCH=arm -j$J INSTALL_MOD_PATH=output uImage modules
$(Q)$(MAKE) -C linux-sunxi/modules/gpu ARCH=arm LICHEE_KDIR=${LICHEE_KDIR}
$(Q)$(MAKE) -C linux-sunxi ARCH=arm -j$J INSTALL_MOD_PATH=output modules_install
$(Q)$(MAKE) -C linux-sunxi ARCH=arm -j$J headers_install
#cd linux-sunxi && ${K_CROSS_COMPILE}objcopy -R .note.gnu.build-id -S -O binary vmlinux bImage
kernel-clean:
$(Q)$(MAKE) -C linux-sunxi/arch/arm/mach-sunxi/pm/standby ARCH=arm clean
$(Q)$(MAKE) -C linux-sunxi/modules/gpu ARCH=arm LICHEE_KDIR=${LICHEE_KDIR} clean
$(Q)$(MAKE) -C linux-sunxi ARCH=arm -j$J distclean
rm -rf linux-sunxi/output/
rm -f linux-sunxi/bImage
kernel-config: $(K_DOT_CONFIG)
$(Q)$(MAKE) -C linux-sunxi ARCH=arm -j$J menuconfig
cp linux-sunxi/.config linux-sunxi/arch/arm/configs/$(KERNEL_CONFIG)
bsp
bsp: u-boot kernel
linux
linux:
$(Q)scripts/mk_linux.sh $(ROOTFS)
help:
@echo “”
@echo “Usage:”
@echo " make bsp - Default ‘make’"
@echo " make linux - Build target for linux platform, as ubuntu, need permisstion confirm during the build process"
@echo " Arguments:"
@echo " ROOTFS= - Source rootfs (ie. rootfs.tar.gz with absolute path)"
@echo “”
@echo " make pack - pack the images and rootfs to a PhenixCard download image."
@echo " make clean"
@echo “”
@echo “Optional targets:”
@echo " make kernel - Builds linux kernel"
@echo " make kernel-config - Menuconfig"
@echo " make u-boot - Builds u-boot"
@echo “”
4.修改 BPI-M3-bsp/linux-sunxi/arch/arm/mach-sunxi/pm/standby/Makefile
在
always := standby.code resume1.code
targets := standby.elf resume1.elf
后面加上
hostprogs-y := mksunxichecksum
修改103、104行为
$(obj)/resume1.code: $(obj)/resume1.bin $(obj)/mksunxichecksum
$(obj)/mksunxichecksum $(obj)/resume1.bin $(obj)/super/resume/resume1.code
5在BPI-M3-bsp/linux-sunxi/arch/arm/mach-sunxi/pm/standby/目录下添加
mksunxichecksum.c文件 内容如下:
/*
- © Copyright 2015 Jean-Francois Moine
- © Copyright 2014 Henrik Nordstrom
-
- Based on mksunxiboot
-
- © Copyright 2007-2011
- Allwinner Technology Co., Ltd. <www.allwinnertech.com>
-
- SPDX-License-Identifier: GPL-2.0+
/
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdint.h>
#include <stdlib.h>
/ boot head definition from sun4i boot code /
struct boot_file_head {
uint32_t b_instruction; / one intruction jumping to real code /
uint8_t magic[8]; / =“eGON.BT0” or “eGON.BT1”, not C-style str /
uint32_t check_sum; / generated by PC /
uint32_t length; / generated by PC /
/
- We use a simplified header, only filling in what is needed
- for checksum calculation.
/
};
#define STAMP_VALUE 0x5F0A6C39
/ check sum functon from sun4i boot code */
static int gen_check_sum(struct boot_file_head *head_p)
{
uint32_t length;
uint32_t buf;
uint32_t loop;
uint32_t i;
uint32_t sum;
length = head_p->length;
// if ((length & 0x3) != 0) / must 4-byte-aligned /
// return -1;
buf = (uint32_t )head_p;
head_p->check_sum = STAMP_VALUE; / fill stamp /
loop = length >> 2;
/ calculate the sum /
for (i = 0, sum = 0; i < loop; i++)
sum += buf;
/ write back check sum */
head_p->check_sum = sum;
return 0;
}
int main(int argc, char *argv])
{
struct boot_file_head h, *buf;
unsigned file_size;
FILE *f;
if (argc != 3) {
printf(“Usage: %s file.bin file.code\n”
“calculates BROM checksum in boot header of given .bin file and writes to .code file\n”
"", argv[0]);
exit(1);
}
f = fopen(argv[1], “rb”);
if (!f) {
perror(“Open input file”);
exit(1);
}
fread(&h, 1, sizeof h, f);
file_size = h.length; // wanted length
buf = malloc(file_size);
memset(buf, 0xff, file_size);
rewind(f);
fread(buf, 1, file_size, f);
fclose(f);
gen_check_sum(buf);
f = fopen(argv[2], “wb”);
if (!f) {
perror(“Open output file”);
exit(1);
}
fwrite(buf, 1, file_size, f);
fclose(f);
return 0;
}
保存
运行 ./build.sh
选择内核 1(1-6)
选择编译内容3(1-6)
开始编译
完成后把Uimage 拷贝到 启动分区的boot/bpi m3下面*
root@bananapi:/home/pi/emmc/BPI-M3-bsp# ./build.sh
BPI-M3 BSP Build Tool
This tool support following BPI board(s):
- BPI_M3_720P
- BPI_M3_1080P
- BPI_M3_LCD7
- BPI_M3_USB_720P
- BPI_M3_USB_1080P
- BPI_M3_USB_LCD7
Please choose a target(1-6): 1
Now configuring…
BPI_M3_720P configured. Now run make
Configure success!
This tool support following building mode(s):
- Build all, uboot and kernel and pack to download images.
- Build uboot only.
- Build kernel only.
- kernel configure.
- Build rootfs for linux, and copy target files to output
ROOTFS=/xxx/rootfs.tar.gz
This is optinal, default using rootfs/linux/default_linux_rootfs .tar.gz.
- Pack the builds to target download image, this step must execute afte r u-boot,
kernel and rootfs build out
- Clean all build.
Please choose a mode(1-6): 3
Now building…
make -C linux-sunxi ARCH=arm sun8iw6p1smp_bpi_defconfig
make[1]: Entering directory '/home/pi/emmc/BPI-M3-bsp/linux-sunxi’
drivers/net/wireless/bcmdhd/Kconfig:57:warning: defaults for choice values not s upported
configuration written to .config
make[1]: Leaving directory '/home/pi/emmc/BPI-M3-bsp/linux-sunxi’
make -C linux-sunxi ARCH=arm -j16 INSTALL_MOD_PATH=output uImage modules
make[1]: Entering directory '/home/pi/emmc/BPI-M3-bsp/linux-sunxi’
scripts/kconfig/conf --silentoldconfig Kconfig
drivers/net/wireless/bcmdhd/Kconfig:57:warning: defaults for choice values not s upported
CHK include/linux/version.h
CHK include/generated/utsrelease.h
make[2]: ‘include/generated/mach-types.h’ is up to date.
CALL scripts/checksyscalls.sh
CHK include/generated/compile.h
CC arch/arm/mach-sunxi/pm/standby/common.o
CC arch/arm/mach-sunxi/pm/standby/standby_clock.o
CC arch/arm/mach-sunxi/pm/standby/standby_ir.o
CC arch/arm/mach-sunxi/pm/standby/standby_key.o
CC arch/arm/mach-sunxi/pm/standby/axp209_power.o
CC arch/arm/mach-sunxi/pm/standby/standby_power.o
CC arch/arm/mach-sunxi/pm/standby/standby_twi.o
CC arch/arm/mach-sunxi/pm/standby/standby_usb.o
AS arch/arm/mach-sunxi/pm/standby/standby_delay.o
CC arch/arm/mach-sunxi/pm/standby/./…/pm_debug.o
CC arch/arm/mach-sunxi/pm/standby/./…/mem_timing.o
CC arch/arm/mach-sunxi/pm/standby/./…/mem_mmu_pc.o
AS arch/arm/mach-sunxi/pm/standby/./…/mem_mmu_pc_asm.o
CC arch/arm/mach-sunxi/pm/standby/./…/mem_serial.o
CC arch/arm/mach-sunxi/pm/standby/./…/mem_printk.o
AS arch/arm/mach-sunxi/pm/standby/./…/mem_divlib.o
CC arch/arm/mach-sunxi/pm/standby/./…/mem_divlibc.o
CC arch/arm/mach-sunxi/pm/standby/./…/mem_int.o
CC arch/arm/mach-sunxi/pm/standby/./…/mem_gpio.o
CC arch/arm/mach-sunxi/pm/standby/./…/mem_tmr.o
CC arch/arm/mach-sunxi/pm/standby/./…/mem_tmstmp.o
CC arch/arm/mach-sunxi/pm/standby/./…/mem_clk.o
CC arch/arm/mach-sunxi/pm/standby/standby.o
CC arch/arm/mach-sunxi/pm/standby/./arisc/standby_arisc.o
CC arch/arm/mach-sunxi/pm/standby/./arisc/arisc_hwmsgbox.o
CC arch/arm/mach-sunxi/pm/standby/./arisc/arisc_message_manager.o
CC arch/arm/mach-sunxi/pm/standby/./arisc/arisc_hwspinlock.o
CC arch/arm/mach-sunxi/pm/standby/./…/mem_hwspinlock.o
rm -rf .o arch/arm/mach-sunxi/pm/standby/…/.o
CC arch/arm/mach-sunxi/pm/standby/super/common.o
CC arch/arm/mach-sunxi/pm/standby/super/super_twi.o
AS arch/arm/mach-sunxi/pm/standby/super/super_delay.o
CC arch/arm/mach-sunxi/pm/standby/super/super_clock.o
CC arch/arm/mach-sunxi/pm/standby/super/super_power.o
CC arch/arm/mach-sunxi/pm/standby/super/super_cpus.o
AS arch/arm/mach-sunxi/pm/standby/super/resume/resume1.o
CC arch/arm/mach-sunxi/pm/standby/super/resume/resume_head.o
CC arch/arm/mach-sunxi/pm/standby/super/resume/resume1_c_part.o
CC arch/arm/mach-sunxi/pm/standby/…/pm_debug.o
CC arch/arm/mach-sunxi/pm/standby/…/mem_timing.o
CC arch/arm/mach-sunxi/pm/standby/…/mem_mmu_pc.o
AS arch/arm/mach-sunxi/pm/standby/…/mem_mmu_pc_asm.o
CC arch/arm/mach-sunxi/pm/standby/…/mem_cpu.o
CC arch/arm/mach-sunxi/pm/standby/…/mem_serial.o
CC arch/arm/mach-sunxi/pm/standby/…/mem_printk.o
AS arch/arm/mach-sunxi/pm/standby/…/mem_divlib.o
CC arch/arm/mach-sunxi/pm/standby/…/mem_divlibc.o
CC arch/arm/mach-sunxi/pm/standby/…/mem_int.o
CC arch/arm/mach-sunxi/pm/standby/…/mem_gpio.o
CC arch/arm/mach-sunxi/pm/standby/…/mem_tmr.o
CC arch/arm/mach-sunxi/pm/standby/…/mem_tmstmp.o
CC arch/arm/mach-sunxi/pm/standby/…/mem_hwspinlock.o
CC arch/arm/mach-sunxi/pm/standby/…/mem_clk.o
arch/arm/mach-sunxi/pm/standby/mksunxichecksum arch/arm/mach-sunxi/pm/standby/re sume1.bin arch/arm/mach-sunxi/pm/standby/super/resume/resume1.code
rm -rf .o arch/arm/mach-sunxi/pm/standby/…/.o
CC arch/arm/mach-sunxi/pm/mem_mapping.o
CC arch/arm/mach-sunxi/pm/mem_divlibc.o
CC arch/arm/mach-sunxi/pm/mem_cpu.o
AS arch/arm/mach-sunxi/pm/mem_cpu_asm.o
AS arch/arm/mach-sunxi/pm/mem_mmu_pc_asm.o
CC arch/arm/mach-sunxi/pm/mem_mmu_pc.o
CC arch/arm/mach-sunxi/pm/mem_clk.o
CC arch/arm/mach-sunxi/pm/mem_int.o
CC arch/arm/mach-sunxi/pm/mem_serial.o
CC arch/arm/mach-sunxi/pm/mem_key.o
CC arch/arm/mach-sunxi/pm/mem_usb.o
CC arch/arm/mach-sunxi/pm/mem_ir.o
CC arch/arm/mach-sunxi/pm/mem_tmr.o
CC arch/arm/mach-sunxi/pm/mem_tmstmp.o
CC arch/arm/mach-sunxi/pm/mem_twi.o
CC arch/arm/mach-sunxi/pm/mem_gpio.o
CC arch/arm/mach-sunxi/pm/mem_sram.o
CC arch/arm/mach-sunxi/pm/mem_ccu.o
CC arch/arm/mach-sunxi/pm/mem_cci400.o
CC arch/arm/mach-sunxi/pm/mem_gtbus.o
CC arch/arm/mach-sunxi/pm/pm_debug.o
CC arch/arm/mach-sunxi/pm/pm_debug_secure.o
CC arch/arm/mach-sunxi/pm/mem_timing.o
CC arch/arm/mach-sunxi/pm/mem_hwspinlock.o
CC arch/arm/mach-sunxi/pm/pm.o
CC arch/arm/mach-sunxi/pm/standby/super/super_power.o
CC arch/arm/mach-sunxi/pm/standby/super/super_twi.o
CC arch/arm/mach-sunxi/pm/standby/super/super_clock.o
AS arch/arm/mach-sunxi/pm/standby.o
AS arch/arm/mach-sunxi/pm/mem.o
CC arch/arm/mach-sunxi/pm/aw_pm.o
CC arch/arm/mach-sunxi/pm/aw_pwr_dm.o
CC arch/arm/mach-sunxi/pm/extended_standby-sun8iw6.o
LD arch/arm/mach-sunxi/pm/pm_tmp.o
LD arch/arm/mach-sunxi/pm/built-in.o
LD arch/arm/mach-sunxi/built-in.o
LD vmlinux.o
MODPOST vmlinux.o
WARNING: modpost: Found 23 section mismatch(es).
To see full details build your kernel with:
'make CONFIG_DEBUG_SECTION_MISMATCH=y’
GEN .version
CHK include/generated/compile.h
UPD include/generated/compile.h
CC init/version.o
LD init/built-in.o
LD .tmp_vmlinux1
KSYM .tmp_kallsyms1.S
AS .tmp_kallsyms1.o
LD .tmp_vmlinux2
KSYM .tmp_kallsyms2.S
AS .tmp_kallsyms2.o
LD vmlinux
SYSMAP System.map
SYSMAP .tmp_System.map
Building modules, stage 2.
OBJCOPY arch/arm/boot/Image
Kernel: arch/arm/boot/Image is ready
GZIP arch/arm/boot/compressed/piggy.gzip
MODPOST 953 modules
AS arch/arm/boot/compressed/piggy.gzip.o
LD arch/arm/boot/compressed/vmlinux
OBJCOPY arch/arm/boot/zImage
Kernel: arch/arm/boot/zImage is ready
UIMAGE arch/arm/boot/uImage
Image Name: Linux-3.4.39-BPI-M3-Kernel
Created: Sat Jul 23 11:53:54 2016
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 5723952 Bytes = 5589.80 kB = 5.46 MB
Load Address: 40008000
Entry Point: 40008000
Image arch/arm/boot/uImage is ready