君正X2000E(LPDDR2) uboot和kernel線上升級
君正X2000E儲存使用的是Nand Flash,所以uboot和kernel的升級可以使用MTD工具裡的flash_erase和nandwrite來實現nand flash的擦除和寫入。
u-boot升級
X2000E的分區劃分在使用君正的映象燒錄工具cloner燒錄時會自動劃分好,具體的劃分規則可以根據 ”配置 -> SFC -> 分割槽資訊“ 來調整。
檢視nand flash分割槽資訊,可以使用以下命令:
# cat /proc/mtd dev: size erasesize name mtd0: 00100000 00020000 "uboot" mtd1: 00800000 00020000 "kernel" mtd2: 0f50000000020000 "rootfs"
如上,共有mtd0 ~ mtd2三個分割槽,分別作為uboot、kernel、rootfs分割槽使用。
注意:
線上升級uboot的時候,由於沒有預設實現uboot內建flash引數,使用nand_write寫入新的uboot檔案後無法正常啟動。
解決辦法:
-
需要修改uboot配置檔案
例:u-boot/include/configs/halley5.h
/* 開啟如下配置巨集 */ #define CONFIG_NAND_BUILTIN_PARAMS
- 新增一款flash引數,配置檔案路徑如下:
u-boot/tools/ingenic-tools/sfc_builtin_params/nand_device.c
- nand flash裝置引數預設編譯進映象,因此只需要配置partitions引數,具體如下所示:
/* * params: nand flash partitions */ nand_partition_builtin_params_t nand_builtin_params = { .magic_num = SPINAND_MAGIC_NUM, /* max 10 partitions*/ .partition_num = 3, #if 0 .partition_num = 4, #endif .partition = { [0].name = "uboot", [0].offset = 0x0, [0].size = 0x100000, [0].mask_flags = NANDFLASH_PART_RW, [0].manager_mode = MTD_MODE, [1].name = "kernel", [1].offset = 0x100000, [1].size = 0x800000, [1].mask_flags = NANDFLASH_PART_RW, [1].manager_mode = MTD_MODE, [2].name = "rootfs", [2].offset = 0x900000, [2].size = 0x0, [2].mask_flags = NANDFLASH_PART_RW, [2].manager_mode = UBI_MANAGER, #if 0 [2].name = "rootfs", [2].offset = 0x900000, [2].size = 0x2800000, [2].mask_flags = NANDFLASH_PART_RW, [2].manager_mode = UBI_MANAGER, [3].name = "userdata", [3].offset = 0x3100000, [3].size = 0xcf00000, [3].mask_flags = NANDFLASH_PART_RW, [3].manager_mode = UBI_MANAGER, #endif}, };
如上所示,劃分了3個分割槽,分別是uboot、kernel、rootfs三個分割槽。rootfs分割槽的大小我們這裡設定為0,表示把除uboot分割槽和kernel分割槽以外的空間都作為rootfs分割槽。當然,你也可以設定為你想要的分割槽大小和分割槽個數。
u-boot升級步驟
- 擦除uboot分割槽
# flash_erase /dev/mtd0 0 0 Erasing 128 Kibyte @ e0000 -- 100 % complete
- 寫入uboot分割槽
# nandwrite -p /dev/mtd0 uboot Writing data to block 0 at offset 0x0 Writing data to block 1 at offset 0x20000 Writing data to block 2 at offset 0x40000
kernel升級步驟
- 擦除kernel分割槽
# flash_erase /dev/mtd1 0 0 Erasing 128 Kibyte @ 7e0000 -- 100 % complete
- 寫入kernel分割槽
# nandwrite -p /dev/mtd1 kernel Writing data to block 0 at offset 0x0 Writing data to block 1 at offset 0x20000 Writing data to block 2 at offset 0x40000 Writing data to block 3 at offset 0x60000 Writing data to block 4 at offset 0x80000 Writing data to block 5 at offset 0xa0000 Writing data to block 6 at offset 0xc0000 Writing data to block 7 at offset 0xe0000 Writing data to block 8 at offset 0x100000 Writing data to block 9 at offset 0x120000 Writing data to block 10 at offset 0x140000 Writing data to block 11 at offset 0x160000 Writing data to block 12 at offset 0x180000 Writing data to block 13 at offset 0x1a0000 Writing data to block 14 at offset 0x1c0000 Writing data to block 15 at offset 0x1e0000 Writing data to block 16 at offset 0x200000 Writing data to block 17 at offset 0x220000 Writing data to block 18 at offset 0x240000 Writing data to block 19 at offset 0x260000 Writing data to block 20 at offset 0x280000 Writing data to block 21 at offset 0x2a0000 Writing data to block 22 at offset 0x2c0000 Writing data to block 23 at offset 0x2e0000 Writing data to block 24 at offset 0x300000 Writing data to block 25 at offset 0x320000 Writing data to block 26 at offset 0x340000 Writing data to block 27 at offset 0x360000 Writing data to block 28 at offset 0x380000 Writing data to block 29 at offset 0x3a0000 Writing data to block 30 at offset 0x3c0000 Writing data to block 31 at offset 0x3e0000 Writing data to block 32 at offset 0x400000 Writing data to block 33 at offset 0x420000 Writing data to block 34 at offset 0x440000 Writing data to block 35 at offset 0x460
u-boot和kernel升級完之後,reboot即可生效。
如何判斷uboot和kernel升級成功了呢?
- uboot可根據cpu啟動時uboot列印的build時間來判斷
- kernel可根據 uname -a 的結果得到kernel的build時間
拓展
君正X2000系列有三種型號,分別是X2000(LPDDR3)、X2000E(LPDDR2)、X2000H(LPDDR3),那麼對於X2000和X2000H的uboot線上升級,可以和X2000E使用同一個uboot檔案嗎?
顯然不行,由於DDR型別不同,所以在u-boot裡要區分開來,X2000和X2000H要使用針對LPDDR3的u-boot配置。
修改如下:
iff --git a/u-boot/include/configs/halley5.h b/u-boot/include/configs/halley5.h index 35017de475..cfc714fd20 100644 --- a/u-boot/include/configs/halley5.h +++ b/u-boot/include/configs/halley5.h @@ -97,7 +97,7 @@ #define CONFIG_DDR_HOST_CC /*#define CONFIG_DDR_TYPE_DDR3*/ #define CONFIG_DDR_TYPE_LPDDR3 -#define CONFIG_DDR_TYPE_LPDDR2 +/*#define CONFIG_DDR_TYPE_LPDDR2*/ #define CONFIG_DDR_CS0 1 /* 1-connected, 0-disconnected */ #define CONFIG_DDR_CS1 0 /* 1-connected, 0-disconnected */ #define CONFIG_DDR_DW32 0 /* 1-32bit-width, 0-16bit-width */ @@ -118,7 +118,7 @@ /* #define CONFIG_LPDDR3_MT52L256M32D1PF_FPGA*/ /* #define CONFIG_LPDDR3_AD310032C_AB_FPGA */ #define CONFIG_LPDDR3_W63AH6NKB_BI - #define CONFIG_LPDDR3_NK6CL256M16DKX_H1 + /*#define CONFIG_LPDDR3_NK6CL256M16DKX_H1*/ #endif #define CONFIG_DDR_PHY_IMPEDANCE 40
如果你使用君正的cloner燒錄工具燒錄u-boot的話,你會發現,即使你不做上面的改動,X2000/X2000H和X2000E使用同一個uboot檔案,都可以正常使用。那是因為燒錄工具cloner在燒錄時會根據不同的CPU型號燒錄不同的配置。
- X2000 使用cloner燒錄時選用的配置
- X2000E 使用cloner燒錄時選用的配置
至此,一切都明朗了。