Raspberry Pi 4 ã«ã¼ãã«ãã«ãã«ã¤ãã¦ãæé ã«ã¤ãã¦æ¸ãã¾ãã
Linuxã®ã«ã¼ãã«ã®ãã«ãã¯ã以ä¸ã®ãããªçç±ã§å¿
è¦ã«ãªãå ´åãããã¾ãã
- æ°ããæ©å¨ï¼ä¾ãã°ãUSBã®Wi-Fiã¢ããã¿ãªã©ï¼ã使ãããã¨ã â»Linuxã«ã¼ãã«ãã«ããå¿
è¦ãªãå ´åããã
- Linuxã«ã¼ãã«ã«ãæ°ããæ©è½ã追å ãããã¨ãï¼ã©ãºãã¤ãªã©ã®çµã¿è¾¼ã¿æ©å¨ã®å ´åãè¨æ¶å®¹éãå¤ããªããããããã©ã«ãã§ç¡å¹ã«ãªã£ã¦ããæ©è½ãå¤ãï¼
- Linuxã«ã¼ãã«ã®åä½ãåãããªããã«ã¼ãã«ã½ã¼ã¹ãè¤éããã¦ãã½ã¼ã¹ãè¦ã¦ãåãããªãå ´åã«ãå¤ã確èªããããéã£ã¦ããã©ããããããã°ãã°ãå
¥ãã¦ç¢ºèªãããã¨ã
æ®éã«Linuxã使ã£ã¦ãã ããªããã«ã¼ãã«ãã«ããå¿
è¦ã«ãªããã¨ã¯ãªãã ãã«ãããã«ããæ¹ãå¿ãã¦ãã¾ãã®ã§ãè¨äºã«ãã¦ãããã¨æãã¾ãã
ã¾ããã«ã¼ãã«ã®è§£æãè¡ãã¨ãã®ãããã°ãã°ã®å
¥ãæ¹ãªã©ãæ¸ããã¨æãã¾ãã
ã«ã¼ãã«ãã«ãï¼ã»ã«ããã«ãï¼ã®æé
ããã§ã¯ãå
¬å¼ãµã¤ãã®ã«ã¼ãã«ãã«ãã®æé ãæ¸ããããã¼ã¸ï¼https://www.raspberrypi.com/documentation/computers/linux_kernel.htmlï¼ã«åºã¥ãã¦ãå
·ä½çãªæé ã¨ã注æç¹ãè¨è¼ãã¾ãã
å
·ä½çãªã«ã¼ãã«ãã«ãï¼ã»ã«ããã«ãï¼ã®æé
å
¬å¼ãµã¤ãã®æé ãåªç§ããã¦ãæ¸ããã¨ããªãã£ãã§ãï¼ç¬ï¼ã
ã»ã«ããã«ãï¼ãã¼ã¸ã§ã¯ãã¤ãã£ããã«ãã¨è¨è¼ããã¦ããï¼ã¨ã¯ãã¹ãã«ãã®ä¸¡æ¹ã«ã¤ãã¦ãä¸å¯§ã«æ¸ããã¦ããã®ã§ãããã®æé ã«å¾ã£ã¦ã«ã¼ãã«ãã«ããè¡ãã°OKã§ãã
ãã ãã以ä¸ã®ãBuilding the kernelãã®æé ã«ã¤ãã¦ã¯ãç§ã®ç°å¢ã§ã¯åä½ããªãã£ãï¼åä½ããªããªã£ã¦ããï¼ã
$ make -j4 Image.gz modules dtbs
$ sudo make modules_install
$ sudo cp arch/arm64/boot/dts/broadcom/*.dtb /boot/firmware/
$ sudo cp arch/arm64/boot/dts/overlays/*.dtb* /boot/firmware/overlays/
$ sudo cp arch/arm64/boot/dts/overlays/README /boot/firmware/overlays/
$ sudo cp arch/arm64/boot/Image.gz /boot/firmware/$KERNEL.img
ç¾å¨ã®ã©ãºãã¤ã®ææ°ã®ã«ã¼ãã«ãã¼ã¸ã§ã³ã¯ãã«ã¼ãã«6.6ã§ããç§ã®ç°å¢ã¯ã«ã¼ãã«6.1ã§ããããã®æé ã¯æè¿æ´æ°ãããã¿ããã§ãã
以åã®ãBuilding the kernelãã®æé ãæ¸ãã¦ããã
$ make -j4 Image.gz modules dtbs
$ sudo make modules_install
$ sudo cp arch/arm64/boot/dts/broadcom/*.dtb /boot/
$ sudo cp arch/arm64/boot/dts/overlays/*.dtb* /boot/overlays/
$ sudo cp arch/arm64/boot/dts/overlays/README /boot/overlays/
$ sudo cp arch/arm64/boot/Image.gz /boot/$KERNEL.img
ã«ã¼ãã«6.1ã§ã¯ãã/boot/firmwareãã¨ãããã£ã¬ã¯ããªã¯åå¨ããªãã®ã§ãã³ãã¼å
ã®ãã¹ããã/firmwareããåé¤ããã°ããã ãã§ãã
ã»ã«ããã«ãã¨ã¯ãã¹ãã«ãã®æ¯è¼
ããã§ã¯ã¯ãã¹ãã«ãã«ã¤ãã¦ã¯è©³ããæ¸ããªããããã«ãæéããªãã¹ãçããããã¨ããå ´åã¯ãã¯ãã¹ãã«ããé¸æããã°ããã¨æãã¾ãã
å人çã«ã¯ãã¯ãã¹ãã«ãã¯ããã¹ãç°å¢ã«ããã¤ãã®ããã±ã¼ã¸ãã¤ã³ã¹ãã¼ã«ããªããã°ãªããªãï¼ç§ã¯ããªãã¹ãä¸è¦ãªããã±ã¼ã¸ã¯å
¥ããããªãï¼ã®ã¨ããã«ãå¾ã«ãä½ããã®æ段ã§ãã«ã¼ãã«ã¤ã¡ã¼ã¸ãã¢ã¸ã¥ã¼ã«ããã¿ã¼ã²ããã®ã©ãºãã¤ã«éä¿¡ããªããã°ãªããªãã®ãæéã§ãããã¨ãç§ã®å ´åã¯ããã¹ãPCãéåã§ãããã¨ãçç±ã§ãã
ä¸æ¹ããã«ãæéã¯å¤å°é·ãï¼ã ããã2ï½3æéãããï¼ããä½ã失æãã¦ããã©ãºãã¤èªä½ãåã¤ã³ã¹ãã¼ã«ããã°ããã¨ããæ°æ¥½ãªã¨ããããããç§ã¯ãã¤ãã»ã«ããã«ããé¸æãã¦ãã¾ãã
å¤æ´ããå·®åã ããã«ã¼ãã«ãã«ãï¼ã»ã«ããã«ãï¼
ä¸ã®ãBuilding the kernelããå®æ½ããã¨ã2åç®ä»¥éã1æéãããããã£ã¦ãã¾ããããã§ã¯å¹çãæªãã®ã§ãã«ã¼ãã«ã½ã¼ã¹ã«ãããã°ãã°ãå
¥ããããããªããã«ã¼ãã«ã¤ã¡ã¼ã¸ã ãã®æ´æ°ã§å¤§ä¸å¤«ã§ãã
å
·ä½çã«ã¯ã以ä¸ã®æé ã ãã§ãããå¤æ´ããéã«ãããããã ããã5å以å
ã«ã¯ãã«ããå®äºãã¾ãã
$ make -j4 Image.gz
$ KERNEL=kernel8
$ sudo cp arch/arm64/boot/Image.gz /boot/$KERNEL.img
Linuxã«ã¼ãã«ã«ãããã°ãã°ãå
¥ããæ¹æ³
Linuxã«ã¼ãã«ã§ã¯ãprintf()
ã¯ä½¿ãã¾ããã代ããã«ãprintk()
ã使ãå¿
è¦ãããã¾ãã
æè¿ã®ã«ã¼ãã«ã½ã¼ã¹ãè¦ã¦ãã¨ãprintk()
ãç´æ¥ä½¿ããã¦ãã¨ããã¯è¦ããã¨ãããã¾ãããé常ã¯ã代ããã«ãpr_xxx()
ã使ããã¦ãã¾ããxxx
ã«ã¯ãéè¦åº¦ã«å¿ãã¦ãerrãwarnãªã©ãé¸æãããã¨ãã§ãã¾ããå
·ä½çã«ã¯ãinclude/linux/printk.h
ã«å®ç¾©ãããã¾ãã
#define pr_emerg(fmt, ...) printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
#define pr_alert(fmt, ...) printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
#define pr_crit(fmt, ...) printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
#define pr_err(fmt, ...) printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
#define pr_warn(fmt, ...) printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
#define pr_notice(fmt, ...) printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
#define pr_info(fmt, ...) printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
#ifdef DEBUG
#define pr_devel(fmt, ...) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
#else
#define pr_devel(fmt, ...) no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
#endif
ä½ãåªå
度ãã®ãé¸æããå ´åã¯ãOSã«ãã£ã¦ã¯ããããã¯ãã³ã³ãã¤ã«ãªãã·ã§ã³ãèµ·åã¢ã¼ããªã©ã«ãã£ã¦ããã°ã¯åºåãããªãããããã¾ããã
ç®çãããããã°ãã°ã®å ´åãä¸æçã«è¿½å ãã¦ãå¿
è¦ãªããªã£ããåé¤ããã¯ããªã®ã§ãpr_err()
ããpr_warn()
ã¨ãã£ãåªå
度ã®é«ãã®ãã®ãé¸æãã¦ããã°ããã¨æãã¾ãã
ãã使ããããã°ãã°ã®è¨è¿°ä¾
ãã使ããããã°ãã°ã®è¨è¿°ä¾ã«ã¤ãã¦æ¸ãã¦ããã¾ãã
pr_err( "%s %s %d", __FILE__, __func__, __LINE__ );
表示ä¾
[ 497.607358] kernel/verifier.c check 12451
ãã®è¨è¿°ããã¼ã¹ã«ãã¦ã確èªãããå¤æ°ãªã©ãããã°ãä¸è¨ã®ããã«è¿½å ããã°OKã§ãã
è¨è¿°ä¾
pr_err( "%s %s %d ret=%d cnt=%d", __FILE__, __func__, __LINE__, ret, cnt );
表示ä¾
[ 500.031087] kernel/verifier.c check 12451 0 1122
Linuxã«ã¼ãã«ã®ãããã°ãã°ã確èªããæ¹æ³
ãã°ã¬ãã«ã®å®ç¾©
ã«ã¼ãã«ã½ã¼ã¹ã®include/linux/kern_levels.h
ã«å®ç¾©ããã¦ãããæ°å¤ãå°ããã»ã©ç·æ¥åº¦ã®é«ãã¬ãã«ã§ãã
#define LOGLEVEL_EMERG 0
#define LOGLEVEL_ALERT 1
#define LOGLEVEL_CRIT 2
#define LOGLEVEL_ERR 3
#define LOGLEVEL_WARNING 4
#define LOGLEVEL_NOTICE 5
#define LOGLEVEL_INFO 6
#define LOGLEVEL_DEBUG 7
次ã«ãprintkã®åºåã®æ¡ä»¶ï¼ãã°ã¬ãã«ï¼ã確èªãã¾ãã以ä¸ãå®è¡ããã¨ãç¾å¨ã®ãã°ã¬ãã«ãåºåããã¾ãã
$ cat /proc/sys/kernel/printk
3 4 1 3
ä¸çªå·¦ã®æ°å¤ãã³ã³ã½ã¼ã«ã®ãã°ã¬ãã«ã§ããããã®æ°å¤ããå°ããï¼3ã®å ´åã¯ã2ã¨1ã¨0ï¼ã®ãã°ãåºåããã¾ããã¤ã¾ãããã®å ´åã¯ãCRITã¨ALERTã¨EMERGã®ãã°ãåºåããã¾ãã
ãã°ã¬ãã«ã®å¤æ´æ¹æ³
以ä¸ã®ããã«ããã°ãä¸æçã«ãã°ã¬ãã«ãå¤æ´ãããã¨ãã§ãã¾ãï¼åèµ·åããã¨å
ã«æ»ãã¾ãï¼ãä»åã¯ãã¨ã«ããå
¨é¨ã®ãã°ã確èªããããã¨ããè¨å®ã«å¤æ´ãã¦ãã¾ãããªããã«ã¼ã権éãå¿
è¦ãªã®ã§ãä¸æçã«rootã«ãªã£ã¦è¨å®ãã¾ãã
$ sudo su
ã¾ããã³ã³ã½ã¼ã«ã«è¡¨ç¤ºãããªãå ´åã§ãã£ã¦ããdmesgã使ãã°ãå
¨ã¦ã®ã¬ãã«ã®ãã°ã確èªã§ãã¾ãã
$ dmesg
[ 0.000000] Booting Linux on physical CPU 0x0000000000 [0x410fd083]
[ 0.000000] Linux version 6.1.55-v8+ (xxxx@raspberrypi) (gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2)
ï¼ä»¥éãå²æï¼