How to compile BPI-M3-bsp kernel on BPI-M3

1.at first download code

  git clone https://github.com/BPI-SINOVOIP/BPI-M3-bsp.git
  1. Add depend package

    apt-get install git build-essential libncurses5-dev

3.edit BPI-M3-bsp/Makefile delete the cross compiler options

.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.eidt BPI-M3-bsp/linux-sunxi/arch/arm/mach-sunxi/pm/standby/Makefile

find here

always  := standby.code resume1.code
targets := standby.elf resume1.elf

and add

hostprogs-y := mksunxichecksum 

change 103、104 line to

$(obj)/resume1.code: $(obj)/resume1.bin $(obj)/mksunxichecksum
$(obj)/mksunxichecksum $(obj)/resume1.bin $(obj)/super/resume/resume1.code
  1. at BPI-M3-bsp/linux-sunxi/arch/arm/mach-sunxi/pm/standby/ dir add file: mksunxichecksum.c as below:

/*

  • (C) Copyright 2015 Jean-Francois Moine
  • (C) Copyright 2014 Henrik Nordstrom
  • Based on mksunxiboot
  • (C) 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; }

save and exit.

run

 ./build.sh

compile : 1(1-6) choose compile : 3(1-6) begin to compile .

After the completion of the copy Uimage to boot partition boot/BPI m3 below

 ...
 ...
  CC      fs/mbcache.o
  CC      fs/posix_acl.o
  CC      fs/xattr_acl.o
  CC      fs/fhandle.o
  LD      fs/udf/udf.o
  LD      fs/udf/built-in.o
  LD      fs/nfs/nfs.o
  LD      fs/nfs/built-in.o
  LD      fs/built-in.o
make[1]: Leaving directory '/usr/src/BPI-M3-bsp/linux-sunxi'
Makefile:51: recipe for target 'kernel' failed
make: *** [kernel] Error 2

can you give me more error message ???

you try delete gpu build ,and copy the gpu. ko to you object.make again

which system you use?

root@osirisBPiM3:/usr/src/BPI-M3-bsp # ./build.sh
==========================================
            BPI-M3 BSP Build Tool
==========================================

This tool support following BPI board(s):
------------------------------------------
        1. BPI_M3_720P
        2. BPI_M3_1080P
        3. BPI_M3_LCD7
        4. BPI_M3_USB_720P
        5. BPI_M3_USB_1080P
        6. BPI_M3_USB_LCD7
------------------------------------------
Please choose a target(1-6): 2


 Now configuring...

BPI_M3_1080P configured. Now run `make`

 Configure success!

This tool support following building mode(s):
--------------------------------------------------------------------------------
        1. Build all, uboot and kernel and pack to download images.
        2. Build uboot only.
        3. Build kernel only.
        4. kernel configure.
        5. 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.
        6. Pack the builds to target download image, this step must execute after u-boot,
           kernel and rootfs build out
        7. 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 '/usr/src/BPI-M3-bsp/linux-sunxi'
drivers/net/wireless/bcmdhd/Kconfig:57:warning: defaults for choice values not supported
#
# configuration written to .config
#
make[1]: Leaving directory '/usr/src/BPI-M3-bsp/linux-sunxi'
make -C linux-sunxi ARCH=arm -j16 INSTALL_MOD_PATH=output uImage modules
make[1]: Entering directory '/usr/src/BPI-M3-bsp/linux-sunxi'
scripts/kconfig/conf --silentoldconfig Kconfig
drivers/net/wireless/bcmdhd/Kconfig:57:warning: defaults for choice values not supported
  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
  AS      arch/arm/mach-sunxi/sunxi-headsmp.o
  CC      arch/arm/mach-sunxi/sunxi-platsmp.o
  CC      arch/arm/mach-sunxi/sunxi-hotplug.o
  CC      arch/arm/mach-sunxi/sys_config.o
  CC      arch/arm/mach-sunxi/sunxi_dump_reg.o
  CC      arch/arm/mach-sunxi/sunxi-chip.o
/usr/src/BPI-M3-bsp/linux-sunxi/arch/arm/mach-sunxi/pm/standby/Makefile:107: *** missing separator (did you mean TAB instead of 8 spaces?).  Stop.
/usr/src/BPI-M3-bsp/linux-sunxi/arch/arm/mach-sunxi/pm/Makefile:90: recipe for target 'arch/arm/mach-sunxi/pm/standby/standby.code' failed
make[3]: *** [arch/arm/mach-sunxi/pm/standby/standby.code] Error 2
scripts/Makefile.build:443: recipe for target 'arch/arm/mach-sunxi/pm' failed
make[2]: *** [arch/arm/mach-sunxi/pm] Error 2
make[2]: *** Waiting for unfinished jobs....
  CC      crypto/api.o
  CC      block/elevator.o
.
.
.
.
.
  CC      drivers/base/firmware.o
  CC      block/blk-map.o
  CC      drivers/ata/libahci.o
drivers/bluetooth/hci_rtk_h5.c: In function ‘h5_complete_rx_pkt’:
drivers/bluetooth/hci_rtk_h5.c:591:24: warning: unused variable ‘hdr’ [-Wunused-variable]
   struct hci_event_hdr hdr;
                        ^
drivers/bluetooth/hci_rtk_h5.c: At top level:
drivers/bluetooth/hci_rtk_h5.c:403:13: warning: ‘h5_handle_le_pkt’ defined but not used [-Wunused-function]
 static void h5_handle_le_pkt(struct hci_uart *hu)
             ^
  LD      drivers/block/built-in.o
  CC      drivers/ata/sata_mv.o
  CC      drivers/arisc/interfaces/arisc_debug_level.o
.
.
.
.
.
 CC      drivers/dma/virt-dma.o
  CC      drivers/dma/sunxi-dma.o
  CC [M]  drivers/char/ipmi/ipmi_kcs_sm.o
drivers/clk/sunxi/clk-debugfs.c: In function ‘ccudbg_info_write’:
drivers/clk/sunxi/clk-debugfs.c:482:9: warning: ignoring return value of ‘copy_from_user’, declared with attribute warn_unused_result [-Wunused-result]
         copy_from_user(testclk_priv.info, buf, count);
         ^
drivers/clk/sunxi/clk-debugfs.c: In function ‘ccudbg_info_read’:
drivers/clk/sunxi/clk-debugfs.c:471:6: warning: ignoring return value of ‘copy_to_user’, declared with attribute warn_unused_result [-Wunused-result]
      copy_to_user((void __user *)buf,(const void *)testclk_priv.tmpbuf,(unsigned long)len);
      ^
drivers/clk/sunxi/clk-debugfs.c: In function ‘ccudbg_param_write’:
drivers/clk/sunxi/clk-debugfs.c:440:9: warning: ignoring return value of ‘copy_from_user’, declared with attribute warn_unused_result [-Wunused-result]
         copy_from_user(testclk_priv.param, buf, count);
         ^
drivers/clk/sunxi/clk-debugfs.c: In function ‘ccudbg_param_read’:
drivers/clk/sunxi/clk-debugfs.c:429:6: warning: ignoring return value of ‘copy_to_user’, declared with attribute warn_unused_result [-Wunused-result]
      copy_to_user((void __user *)buf,(const void *)testclk_priv.tmpbuf,(unsigned long)len);
      ^
drivers/clk/sunxi/clk-debugfs.c: In function ‘ccudbg_start_write’:
drivers/clk/sunxi/clk-debugfs.c:397:9: warning: ignoring return value of ‘copy_from_user’, declared with attribute warn_unused_result [-Wunused-result]
         copy_from_user(testclk_priv.start, buf, count);
         ^
drivers/clk/sunxi/clk-debugfs.c: In function ‘ccudbg_start_read’:
drivers/clk/sunxi/clk-debugfs.c:386:6: warning: ignoring return value of ‘copy_to_user’, declared with attribute warn_unused_result [-Wunused-result]
      copy_to_user((void __user *)buf,(const void *)testclk_priv.tmpbuf,(unsigned long)len);
      ^
drivers/clk/sunxi/clk-debugfs.c: In function ‘ccudbg_name_write’:
drivers/clk/sunxi/clk-debugfs.c:355:9: warning: ignoring return value of ‘copy_from_user’, declared with attribute warn_unused_result [-Wunused-result]
         copy_from_user(testclk_priv.name, buf, count);
         ^
drivers/clk/sunxi/clk-debugfs.c: In function ‘ccudbg_name_read’:
drivers/clk/sunxi/clk-debugfs.c:343:6: warning: ignoring return value of ‘copy_to_user’, declared with attribute warn_unused_result [-Wunused-result]
      copy_to_user((void __user *)buf,(const void *)testclk_priv.tmpbuf,(unsigned long)len);
      ^
drivers/clk/sunxi/clk-debugfs.c: In function ‘ccudbg_command_write’:
drivers/clk/sunxi/clk-debugfs.c:312:9: warning: ignoring return value of ‘copy_from_user’, declared with attribute warn_unused_result [-Wunused-result]
         copy_from_user(testclk_priv.command, buf, count);
         ^
drivers/clk/sunxi/clk-debugfs.c: In function ‘ccudbg_command_read’:
drivers/clk/sunxi/clk-debugfs.c:300:6: warning: ignoring return value of ‘copy_to_user’, declared with attribute warn_unused_result [-Wunused-result]
      copy_to_user((void __user *)buf,(const void *)testclk_priv.tmpbuf,(unsigned long)len);
      ^
  CC      drivers/cpufreq/cpufreq_interactive.o
.
.
.
.
.
.
  CC [M]  drivers/md/raid1.o
drivers/leds/ledtrig-sunxi-respiration.c: In function ‘respiration_trig_activate’:
drivers/leds/ledtrig-sunxi-respiration.c:128:2: warning: ignoring return value of ‘sysfs_create_group’, declared with attribute warn_unused_result [-Wunused-result]
  sysfs_create_group(&led_cdev->dev->kobj,
  ^
  CC      drivers/hid/hid-saitek.o
.
.
.
  CC      drivers/media/dvb/dvb-core/dvb_net.o
drivers/media/dvb/dvb-usb/anysee.c: In function ‘anysee_ci_poll_slot_status’:
drivers/media/dvb/dvb-usb/anysee.c:1188:5: warning: ‘tmp’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  if (tmp == 0) {
     ^
  CC      drivers/media/dvb/dvb-core/dvb_ringbuffer.o
.
.
.
..
 CC      drivers/video/sunxi/disp2/disp/de/lowlevel_sun8iw6/de_dsi.o
  CC      drivers/video/sunxi/disp2/disp/de/lowlevel_sun8iw6/de_clock.o
drivers/video/sunxi/disp2/disp/de/lowlevel_sun8iw6/de_wb.c: In function ‘WB_EBIOS_Set_Para’:
drivers/video/sunxi/disp2/disp/de/lowlevel_sun8iw6/de_wb.c:314:94: warning: ‘cs_out_h0’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  if((cs_out_w0 == fs_out_w0)&&(cs_out_h0 == fs_out_h0)&&(cs_out_w1 == fs_out_w1)&&(cs_out_h1 == fs_out_h1))
                                                                                              ^
drivers/video/sunxi/disp2/disp/de/lowlevel_sun8iw6/de_wb.c:314:68: warning: ‘cs_out_w0’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  if((cs_out_w0 == fs_out_w0)&&(cs_out_h0 == fs_out_h0)&&(cs_out_w1 == fs_out_w1)&&(cs_out_h1 == fs_out_h1))
                                                                    ^
  LD      drivers/usb/built-in.o
  LD      drivers/video/sunxi/disp2/disp/disp.o
  LD      drivers/video/sunxi/disp2/disp/built-in.o
  LD      drivers/video/sunxi/built-in.o
  LD      drivers/video/built-in.o
  LD      drivers/built-in.o
make[1]: Leaving directory '/usr/src/BPI-M3-bsp/linux-sunxi'
Makefile:51: recipe for target 'kernel' failed
make: *** [kernel] Error 2

 Build success!

root@osirisBPiM3:/usr/src/BPI-M3-bsp #

CPU temperature during compilation (CPU has a passive cooler)

i build it use debian, the temperature so high is because. 16 line. all cpu is used

now i can not find your error message

???

What version of the " debian " or " Image " you use?

new. maybe 2016.5 c. vw

So as I understand it with you does not have any errors and compiling a success without a problem ? :laughing: Can you show your 3 files ?

BPI-M3-bsp/Makefile BPI-M3-bsp/linux-sunxi/arch/arm/mach-sunxi/pm/standby/Makefile BPI-M3-bsp/linux-sunxi/arch/arm/mach-sunxi/pm/standby/mksunxichecksum.c

… And provide links to pastebin.com ?

周末回家才能 把文件给你 现在在出差 你能听懂吗

我编译的时候没有任何错误 呵呵😊 要把gpu的编译我注释掉

i don’t understand what you said, can you speak in english>

@zhiqing_yu

好了 - 我等到周末

:sunglasses:

hehe you can speak Chinese. great

不是真的,但大陆的角落,我想在我的生活详情,请访问 :mask: :sunglasses:

i am back. you try debian again?

everytime :sunglasses: (我看你睡觉去了) :grin: