使用的uboot版本是1.1.6,是打過u-boot-1.1.6_jz2440.patch的;
kernel使用的版本是3.4.2, 也是打過linux-3.4.2_camera_jz2440.patch的;
u-boot-1.1.6編譯步驟如下(開發環境ubuntu16.04):
1. 添加環境變量
vim /etc/profile
export PATH=/usr/local/gcc-3.4.5-glibc-2.3.6/bin:$PATH
這里需要注意的是u-boot-1.1.6版本使用gcc-3.4.5版本去編譯,如果用gcc-4.3版本去編譯的話會報錯。
2.使環境變量生效
source /etc/profil
3.編譯
make 100ask24x0_config make
編譯完成后生成u-boot.bin。
kernel-3.4.2編譯步驟如下(開發環境ubuntu16.04):
1.添加環境變量
這里需要注意的是上面編譯u-boot時把交叉編譯工具鏈設為了gcc-3.4.5,kernel-3.4.2版本編譯需要用gcc-4.3.2,需要修改環境變量
vim /etc/profile
export PATH=/usr/local/usr/local/arm/4.3.2/bin:$PATH
2.使環境變量生效
source /etc/profile
3.編譯
make uImage
編譯完成后uImage生成在arch/arm/boot/目錄下。
內核啟動報錯:Verifying Checksum ... Bad Data CRC
Reading data from 0x25f800 -- 50% complete.reading NAND page at offset 0x260000 failed Could not read entire image due to bad blocks 4194304 bytes read: ERROR ## Booting image at 30007fc0 ... Image Name: Linux-3.4.2 Created: 2020-04-27 14:49:25 UTC Image Type: ARM Linux Kernel Image (uncompressed) Data Size: 2402344 Bytes = 2.3 MB Load Address: 30008000 Entry Point: 30008000 Verifying Checksum ... Bad Data CRC
修改u-boot
查看u-boot-1.1.6/include/configs/100ask24x0.h,第59行:
56 #define MTDIDS_DEFAULT "nand0=nandflash0" 57 #define MTDPARTS_DEFAULT "mtdparts=nandflash0:256k@0(bootloader)," \ 58 "128k(params)," \ 59 "2m(kernel)," \ 60 "-(root)"
kernel-3.4.2編譯生成的uImage是2.3M, 而u-boot-1.1.6里面設置的是2m,明顯分配小了。需要把第59行的2m修改為4m,再次編譯u-boot。
修改kernel
查看linux-3.4.2/arch/arm/mach-s3c24xx/common-smdk.c第125行,
122 [2] = { 123 .name = "kernel", 124 .offset = MTDPART_OFS_APPEND, 125 .size = SZ_2M, 126 },
kernel分配的空間也是2M,太小了,修改成4M,即:
.size = SZ_4M,
再次編譯kernel。
把u-boot.bin和uImage再次燒錄到開發板,在uboot里輸入b,成功啟動。如下:
NAND read: device 0 offset 0x60000, size 0x400000 Reading data from 0x45f800 -- 100% complete. 4194304 bytes read: OK ## Booting image at 30007fc0 ... Image Name: Linux-3.4.2 Created: 2020-04-27 15:26:41 UTC Image Type: ARM Linux Kernel Image (uncompressed) Data Size: 2402344 Bytes = 2.3 MB Load Address: 30008000 Entry Point: 30008000 Verifying Checksum ... OK XIP Kernel Image ... OK Starting kernel ...
kernel啟動時串口輸出亂碼的解決方法
輸出亂碼的原因可能是串口的波特率實際是38400,並沒有設置成115200。
在uboot里設置啟動參數:
set bootargs noinitrd root=/dev/mtdblock3 init=/linuxrc console=ttySAC0,115200
然后再輸入b啟動,這時串口輸出就正常了。
