自分用メモ。
あとで清書するかも(しないかも)。
/*===================================================================*/
/* Building RaspberryPi OS and develop enviroment setup */
/*===================================================================*/
[STEP1] Install required dependencies and toolchain.
$sudo apt install git bc bison flex libssl-dev make libc6-dev libncurses5-dev
// install the 32bit toolchain for a 32bit kernel
$sudo apt install crossbuild-essential-armhf
// install the 64bit toolchain for a 64bit kernel
$sudo apt install crossbuild-essential-arm64
// get sources
// this repository is all included of all rasPi models and 32/64bit versions.
$git clone –depth=1 https://github.com/raspberrypi/linux
[STEP2] Settting up build configs
// [for the raspberryPi4 32bit]
$export ARCH=arm
$export KERNEL=kernel7l
$export CROSS_COMPILE=arm-linux-gnueabihf-
// [for the raspberryPi4 64bit]
$export ARCH=arm64
$export KERNEL=kernel8
$export CROSS_COMPILE=aarch64-linux-gnu-
// generate .config file
$make bcm2711_defconfig
[STEP3] Build kernel
// build kernelmodule and dtb files
// [for 32bit builds]
$ make -j4 zImage modules dtbs
// [for 64bit builds]
$ make -j4 Image modules dtbs
// copying modules to /lib/modules
// (not need if just want to build an original module?)
$ sudo make modules_install
REFERENCES – SEE ALSO:
// how to raspberryPi OS cross compile
https://aquarius-train.hatenablog.com/entry/Raspberry_Pi_OS%E3%81%AE%E3%82%AB%E3%83%BC%E3%83%8D%E3%83%AB%E3%82%BD%E3%83%BC%E3%82%B9%E3%83%93%E3%83%AB%E3%83%89%E6%89%8B%E9%A0%86%E8%A7%A3%E8%AA%AC
// RaspberryPi official tutorial
https://www.raspberrypi.org/documentation/linux/kernel/building.md
// how to driver cross compile
https://nw-electric.way-nifty.com/blog/2020/02/post-d872db.html
/*===================================================================*/
/* Building my kernelmodule for raspberryPi OS */
/*===================================================================*/
[!! required of RaspberryPi OS develop enviroment !!]
[STEP1] build and set device tree overlay file !! NOT TESTING !!
cd (workspace)/raspi_linux/LCD-build/Raspberry-Pi-Installer-Scripts/overlays
dtc -@ -I dts -O dtb -o drm-st7789v_240x320.dtbo st7789v_240x320-overlay.dts
// copy build .dtbo file to rasPi overlays directory.
drm-st7789v_240x320.dtbo => /boot/overlays/drm-st7789v_240x320.dtbo
[STEP2] build kernelmodule
make -C ~/raspi_linux/build_kernels/5.4.83-v8+/build M=`pwd` modules
// copy build .ko files to rasPi kernelmodule directory
st7789v_ada.ko => /lib/modules/`uname -r`/kernel/drivers/gpu/drm/tiny/mi0283qt.ko
fb_st7789v.ko => /lib/modules/`uname -r`/kernel/drivers/staging/fbtft/fb_st7789v.ko
[2021/01/26 memo LCD initialize successed.]
// enable SPI setting to raspi-config
// add forrowing line for /boot/config.txt
dtoverlay=drm-st7789v_240x320,rotate=270