CoreMP135 Buildroot

Source Code

1.Visit Github to download the CoreMP135 source code. This project is compiled using the buildroot externel method and is independent of the buildroot source code.

git clone https://github.com/m5stack/CoreMP135_buildroot.git
git clone https://github.com/m5stack/CoreMP135_buildroot-external-st.git

2.Place the two projects in the same directory

├── Core135_buildroot
├── Core135_buildroot-external-st

Compile

1.Enter the Core135_buildroot directory

make BR2_EXTERNAL=../Core135_buildroot-external-st/ m5stack_coremp135_defconfig
make -j4

2.After compilation is completed, the generated sdcard.img image file can be obtained in the output/images directory.

Compile driver

1.In the buildroot project of CoreMP135, the screen driver and other contents are added to the source code project through patches. The kernel already contains the drivers for all peripherals on the machine. In subsequent development, you may need to use modules developed by yourself. The following is Hello_world driver example. To compile, you can compile it in the following way and install it into the device.

External module compilation method

1.Create a hello_world_driver folder and contain the following files Makefile, hello_world_driver.c

//hello_world_driver.c
#include <linux/init.h>
#include <linux/module.h>

MODULE_LICENSE("GPL");
MODULE_AUTHOR("Your Name");
MODULE_DESCRIPTION("A simple hello world kernel module");

static int __init hello_world_init(void)
{
     printk(KERN_INFO "Hello, world!\n");
     return 0;
}

static void __exit hello_world_exit(void)
{
     printk(KERN_INFO "Goodbye, world!\n");
}

module_init(hello_world_init);
module_exit(hello_world_exit);

2.Point the kernel address in the Makefile to the linux kernel path in the buildroot directory, and the tool chain to the tool chain path used in buildroot. Note: Please modify according to your actual project path

//Makefile
KERN_DIR := /home/sean/workspace/mp135/release/Core135_buildroot/output/build/linux-custom
CROSS_COMPILE := /home/sean/workspace/mp135/release/Core135_buildroot/output/host/bin/arm-none-linux-gnueabihf-
MODULE_NAME := hello_world_driver
PWD := $(shell pwd)


obj-m := $(MODULE_NAME).o

default:
$(MAKE) ARCH=arm -C $(KERN_DIR) CROSS_COMPILE=$(CROSS_COMPILE) M=$(PWD) modules

clean:
$(MAKE) ARCH=arm -C $(KERN_DIR) CROSS_COMPILE=$(CROSS_COMPILE) M=$(PWD) clean

3.Run the following command to compile the module, and the module .ko file will be output.

make
On This Page