20171030_jeffrey - silenceuncrio/diary GitHub Wiki

0920

一早來先找 ariel 商量一下關於 eboot env 會消失的 issue

目前確認要修正的有四點

  • uboot_env.sh 不要去初始化 hw_mcsvserialno
  • rc.local 要幫忙挽救 ethaddr
  • rc.local 偵測到以下任一 uboot env 消失的話 幫忙用六個燈來告警
    • hw_mcsvserialnoethaddr
  • uboot env 的佔用 size 要縮小

修正要點之 uboot_env.sh 不要去初始化 hw_mcsvserialno

前幾天之前已經做完了

1130

先修正 uboot env 的佔用 size 要縮小

從以下資訊可得知

Cellular Gateway:/tmp/icos/cli# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00300000 00020000 "boot"
mtd1: 00100000 00020000 "boot_env"
mtd2: 00a00000 00020000 "kernel_a"
mtd3: 00200000 00020000 "dtb_a"
mtd4: 06000000 00020000 "rootfs_a"
mtd5: 01000000 00020000 "config_a"
mtd6: 00400000 00020000 "misc"
mtd7: 00a00000 00020000 "kernel_b"
mtd8: 00200000 00020000 "dtb_b"
mtd9: 06000000 00020000 "rootfs_b"
mtd10: 01000000 00020000 "config_b"

boot_env 的資訊如下

  • size = 00100000 = 1M
  • erasesize = 00020000 = 128K

目前的 /etc/fw_env.config 關於 Flash sector size 的值是錯的

Cellular Gateway:/tmp/icos/cli# cat /etc/fw_env.config
# Configuration file for fw_(printenv/setenv) utility.
# Up to two entries are valid, in this case the redundant
# environment sector is assumed present.
# Notice, that the "Number of sectors" is not required on NOR and SPI-dataflash.
# Futhermore, if the Flash sector size is ommitted, this value is assumed to
# be the same as the Environment size, which is valid for NOR and SPI-dataflash

# MTD device name    Device offset     Env. size         Flash sector size
/dev/mtd1            0x00000000        0x00100000        0x00100000

修改 u-boot-imx 的 include\configs\mx6ul_14X14_evk.h

紀錄一下步驟

  • bitbake u-boot-imx -c devshell
  • quilt new decrease_env_size.patch
  • quilt add include/configs/mx6ul_14x14_evk.h
  • 修改 include/configs/mx6ul_14x14_evk.h
    • 把原本的 CONFIG_ENV_SECT_SIZE0x00100000 改成 0x00020000
    • 也就是從 1M 改成 128K - 相同於 erasesize
  • quilt refresh

得到 patches/decrease_env_size.patch

Index: git/include/configs/mx6ul_14x14_evk.h
===================================================================
--- git.orig/include/configs/mx6ul_14x14_evk.h
+++ git/include/configs/mx6ul_14x14_evk.h
@@ -398,8 +398,8 @@
 
 
 #define CONFIG_ENV_OFFSET       0x00300000
-#define CONFIG_ENV_SECT_SIZE    0x00100000
-#define CONFIG_ENV_SIZE			CONFIG_ENV_SECT_SIZE
+#define CONFIG_ENV_SECT_SIZE    0x00020000
+#define CONFIG_ENV_SIZE		CONFIG_ENV_SECT_SIZE

patches/decrease_env_size.patch 複製到 meta-proscend/recipes-bsp/u-boot/files/

修改 meta-proscend\recipes-bsp\u-boot\u-boot-imx_2015.04.bbappend

diff --git a/meta-proscend/recipes-bsp/u-boot/u-boot-imx_2015.04.bbappend b/meta-proscend/recipes-bsp/u-boot/u-boot-imx_2015.04.bbappend
index c9b126b..3ee5def 100644
--- a/meta-proscend/recipes-bsp/u-boot/u-boot-imx_2015.04.bbappend
+++ b/meta-proscend/recipes-bsp/u-boot/u-boot-imx_2015.04.bbappend
@@ -13,6 +13,7 @@ SRC_URI_append_m300 = " \
     file://uboot_env_v1.0.patch \
     file://remove_fsl_usdhc_and_vedio.patch \
     file://use_usdhc_pad_ctrl_in_gpmi_pad_ctrl.patch \
+    file://decrease_env_size.patch \
 "

 SRC_URI_append_m300e = " \

再來一起修正 /etc/fw_env.config

diff --git a/proscend/base_fs/default/rootfs/etc/fw_env.config b/proscend/base_fs/default/rootfs/etc/fw_env.config
index aaa5865..f03cc33 100644
--- a/proscend/base_fs/default/rootfs/etc/fw_env.config
+++ b/proscend/base_fs/default/rootfs/etc/fw_env.config
@@ -6,4 +6,4 @@
 # be the same as the Environment size, which is valid for NOR and SPI-dataflash

 # MTD device name    Device offset     Env. size         Flash sector size
-/dev/mtd1            0x00000000        0x00100000        0x00100000
+/dev/mtd1            0x00000000        0x00020000        0x00020000

1150

修正要點之 rc.local 要幫忙挽救 ethaddr

diff --git a/proscend/base_fs/default/rootfs/etc/rc.local b/proscend/base_fs/default/rootfs/etc/rc.local
index c5330d5..b7e91f1 100755
--- a/proscend/base_fs/default/rootfs/etc/rc.local
+++ b/proscend/base_fs/default/rootfs/etc/rc.local
@@ -92,7 +92,12 @@ fi

 MAC=$(fw_printenv ethaddr 2>/dev/null | awk -F"=" '{ print $2 }')
 if [ "$MAC" = "" ]; then
-    MAC="random"
+    MAC=$(cat /mnt/data/sysinfo.txt | grep MAC | awk -F"=" '{ print $2 }')
+    if [ "$MAC" = "" ]; then
+        MAC="random"
+    else
+        fw_setenv ethaddr "$MAC"
+    fi
 fi

 HW_MCSV=$(fw_printenv hw_mcsv 2>/dev/null | awk -F"=" '{ print $2 }')

1305

先把目前的修正 build 一份 image 試試

已包含下述修正要點

  • uboot_env.sh 不要去初始化 hw_mcsvserialno
  • rc.local 要幫忙挽救 ethaddr
  • uboot env 的佔用 size 要縮小

1545

希望能這次 eboot env 會消失的 issue 能夠解決

commit 4c467c7e86b0ae3addbec38a32025f7c8d6c5533
Author: jeffrey <[email protected]>
Date:   Mon Oct 30 15:16:47 2017 +0800

    solve the problem about loose ethaddr and serialno after 'fw_setenv' them:
    - decrease the uboot env size
      - same as the erase size
    - restore the following uboot env from /mnt/data/sysinfo.txt when loose them:
      - ethaddr
      - hw_mcsv
      - serialno
    - heartbeat all led for a while to indicate some uboot env loose

 .../u-boot/files/decrease_env_size.patch           | 15 ++++
 .../recipes-bsp/u-boot/u-boot-imx_2015.04.bbappend |  1 +
 proscend/base_fs/default/rootfs/etc/fw_env.config  |  2 +-
 proscend/base_fs/default/rootfs/etc/rc.local       | 95 ++++++++++++++++++++--
 4 files changed, 106 insertions(+), 7 deletions(-)

1610

ariel 表示 heartbeat led 已經在 reser factory default 使用了

避免誤會

我還是把所有的 led 點亮個幾秒來表示有重要的 uboot env loose

1720

commit 2adaf9b8348d73577f345d61b6a756ae76d46f15
Author: jeffrey <[email protected]>
Date:   Mon Oct 30 17:21:24 2017 +0800

    use another way to indicate core uboot env loose

 proscend/base_fs/default/rootfs/etc/rc.local | 52 +++++++++++++++-------------
 1 file changed, 27 insertions(+), 25 deletions(-)