20181214_jeffrey - silenceuncrio/diary GitHub Wiki

0845

繼續跟進 Mitrastart 的 bootloader 點燈 issue

0925

先幫忙在 uboot 加個 env - production 用來判斷該 device 是否已經是 production 了

  • 如果不是
    • 那 uboot 把 linux 帶起來之前就不對 no_good counter 做累加的動作
  • 如果是
    • 那 uboot 把 linux 帶起來之前會對 no_good counter 做累加的動作
    • 這樣一來如果 linux 沒有提供正確的服務的話 no_good = 2 時 uboot 就會改把另一個 partition 的 linux 叫起來提供服務

先清空除了 uboot 之外的 partition - nand erase 80000 7000000

這樣新增的 uboot env - production 才會出現

CLI 要追加一個 command 用來把 uboot env production 設成 yes

1110

NHRP 的 task 被正名成 DMVPN 了

M300 週會時我大概跟大家介紹了一下我遇到的故事

ariel 一下子就幫我把 schedule 拉到明年二月底去了

1420

M360 給 Mitrastar 的 production done 與否的機制已經做好了

uboot 相關修改如下

diff --git a/common/env_common.c b/common/env_common.c
index 8a4473c..fd49ed9 100644
--- a/common/env_common.c
+++ b/common/env_common.c
@@ -139,6 +139,9 @@ uchar default_environment[] = {
 #ifdef CONFIG_DUAL_IMAGE_NO_GOOD
     "no_good="  CONFIG_DUAL_IMAGE_NO_GOOD     "\0"
 #endif
+#ifdef CONFIG_PRODUCTION
+    "production=" CONFIG_PRODUCTION "\0"
+#endif
        "\0"
 };

diff --git a/include/configs/rt2880.h b/include/configs/rt2880.h
index 1d044de..416fc3b 100644
--- a/include/configs/rt2880.h
+++ b/include/configs/rt2880.h
@@ -121,6 +121,20 @@ extern unsigned int  CFG_BLOCKSIZE;



+/*
+** Proscend production state
+** production = Yes
+**   - means the device is ready for service
+** production = No
+**   - means the device is not ready for service
+** default value is "No"
+** after manufacting, this value should be changed to "Yes"
+*/
+
+#define CONFIG_PRODUCTION "No"
+
+
+
 #include <cmd_confdefs.h>

 /*
@@ -456,6 +470,7 @@ extern unsigned int  CFG_BLOCKSIZE;
 #define RT2880_REG_PIOSET       (RT2880_PRGIO_ADDR + 0x30)
 #define RT2880_REG_PIORESET     (RT2880_PRGIO_ADDR + 0x40)
 #endif
+
 #define RALINK_REG(x)          (*((volatile u32 *)(x)))
 #if defined (RT6855A_FPGA_BOARD) || defined (RT6855A_ASIC_BOARD) || \
     defined (MT7621_FPGA_BOARD) || defined (MT7621_ASIC_BOARD) || defined (MT7628_FPGA_BOARD) || defined (MT7628_ASIC_BOARD)
diff --git a/lib_mips/board.c b/lib_mips/board.c
index e11bf36..a4f4827 100644
--- a/lib_mips/board.c
+++ b/lib_mips/board.c
@@ -2048,6 +2048,7 @@ __attribute__((nomips16)) void board_init_r (gd_t *id, ulong dest_addr)
 #ifdef DUAL_IMAGE_SUPPORT
        check_image_validation();
 #endif
+
 /*config bootdelay via environment parameter: bootdelay */
        {
            char * s;
@@ -2136,9 +2137,27 @@ __attribute__((nomips16)) void board_init_r (gd_t *id, ulong dest_addr)
             printf("   \n3: System Boot system code via Flash at dual image b.\n");
         }

-        char tmp_no_good[8];
-        sprintf(tmp_no_good, "%sx", getenv("no_good"));
-        setenv("no_good", tmp_no_good);
+
+
+        char *production = getenv ("production");
+        if (production != NULL)
+        {
+            if (strcmp(production, "No") == 0) {
+                printf("Is the device production done: No\n");
+            } else {
+                printf("Is the device production done: Yes\n");
+                char tmp_no_good[8];
+                sprintf(tmp_no_good, "%sx", getenv("no_good"));
+                setenv("no_good", tmp_no_good);
+            }
+        }
+        else
+        {
+            printf("Is the device production done: Yes(but the env 'production' is not defined)\n");
+            char tmp_no_good[8];
+            sprintf(tmp_no_good, "%sx", getenv("no_good"));
+            setenv("no_good", tmp_no_good);
+        }

commit 吧

commit 568d70e424c1f072bd166a175c54023ac22abab8
Author: jeffrey <[email protected]>
Date:   Fri Dec 14 14:21:57 2018 +0800

    add a uboot env 'production' to handel that:
    - Is the device production done: No
      - do not increase the no_good counter
    - Is the devide producton done: Yes
      - increase the no_good counter
    - the 'production' env is not defined(saved by the previous version uboot)
      - increase the no_good counter

 common/env_common.c      |  3 +++
 include/configs/rt2880.h | 15 +++++++++++++++
 lib_mips/board.c         | 25 ++++++++++++++++++++++---
 3 files changed, 40 insertions(+), 3 deletions(-)

linux 部分需修改 我們自己的 cli command

diff --git a/proscend/prosrc/icos/clishell/cli.c b/proscend/prosrc/icos/clishell/cli.c
index 8487d53..c2481fb 100644
--- a/proscend/prosrc/icos/clishell/cli.c
+++ b/proscend/prosrc/icos/clishell/cli.c
@@ -546,6 +546,13 @@ int cli_reset(int id, int argc, char **argv)
     return 0;
 }

+int cli_production_done(int id, int argc, char **argv)
+{
+    system("fw_setenv production Yes");
+    CLI_OUTPUT("Set the production is done\n");
+    return 0;
+}
+
 int cli_upgrade(int id, int argc, char **argv)
 {
     if (is_exist_cli_help_entry(argc, argv))
diff --git a/proscend/prosrc/icos/clishell/cli.h b/proscend/prosrc/icos/clishell/cli.h
index 8d70f73..0fe79bd 100644
--- a/proscend/prosrc/icos/clishell/cli.h
+++ b/proscend/prosrc/icos/clishell/cli.h
@@ -96,6 +96,8 @@ int cli_reset(int id, int argc, char **argv);
 int cli_upgrade(int id, int argc, char **argv);
 char* cli_get_password(const char* prompt, const char* confirm_prompt, const char* err_msg);
 void cli_write_ret_buf(const char *fmt, ...); //write output to caller's buffer.John20170704
+int cli_reset(int id, int argc, char **argv);
+int cli_production_done(int id, int argc, char **argv);

 int cli_AT_cmd(int id, int argc, char **argv);
 int cli_ping(int id, int argc, char **argv);
diff --git a/proscend/prosrc/icos/clishell/cli_mgmt_identification.c b/proscend/prosrc/icos/clishell/cli_mgmt_identification.c
index c888636..d8352dd 100644
--- a/proscend/prosrc/icos/clishell/cli_mgmt_identification.c
+++ b/proscend/prosrc/icos/clishell/cli_mgmt_identification.c
@@ -18,6 +18,7 @@ typedef enum
     CLI_MGMT_UPTIME_ID,
     CLI_MGMT_LIST_ID,
     CLI_MGMT_IMEI_ID,
+    CLI_MGMT_PRODUCTION_STATE_ID,
 } CLI_MGMT_IDS;

 #define seconds_of_min 60
@@ -110,6 +111,29 @@ static char* get_value_by_id(idenetification *data, int id)
             snprintf(buf, sizeof(buf), "%s", ICOS_shm_status_getPtr(SHM_LTE_CUR_IMEI));
             result = buf;
             break;
+        case CLI_MGMT_PRODUCTION_STATE_ID:
+            if (system("fw_printenv production 1>/dev/null 2>&1") == 0)
+            {
+                // "production" already defined
+                if (system("fw_printenv production | grep Yes 1>/dev/null 2>&1") == 0)
+                {
+                    // production=Yes
+                    snprintf(buf, sizeof(buf), "Yes");
+                }
+                else
+                {
+                    // production=No
+                    snprintf(buf, sizeof(buf), "No");
+                }
+            }
+            else
+            {
+                // system() return -1 on error or return 1 on "production" not defined
+                // either case, production=Yes
+                snprintf(buf, sizeof(buf), "Yes");
+            }
+            result = buf;
+            break;
     }

     return result;
@@ -135,6 +159,7 @@ static int list(idenetification *data)
         CLI_MGMT_MODEM_FIRMWARE_VERSION_ID,
         CLI_MGMT_IMEI_ID,
         CLI_MGMT_UPTIME_ID,
+        CLI_MGMT_PRODUCTION_STATE_ID,
     };

     int length = dim(ids);
@@ -207,6 +232,7 @@ static int _main(int id, int argc, char **argv)
         case CLI_MGMT_MODEM_FIRMWARE_VERSION_ID:
         case CLI_MGMT_UPTIME_ID:
         case CLI_MGMT_IMEI_ID:
+        case CLI_MGMT_PRODUCTION_STATE_ID:
             value = get_value_by_id(&data, id);
             if (value)
             {
@@ -246,6 +272,7 @@ sMenuItem menu_mgmt_identification[] =
     _ACTION_ITEM("modem",            "show modem firmware version", CLI_MGMT_MODEM_FIRMWARE_VERSION_ID),
     _ACTION_ITEM("IMEI",             "show modem IMEI",             CLI_MGMT_IMEI_ID),
     _ACTION_ITEM("uptime",           "show system uptime",          CLI_MGMT_UPTIME_ID),
+    _ACTION_ITEM("production",       "show production state",       CLI_MGMT_PRODUCTION_STATE_ID),

     LIST_ITEM(CLI_MGMT_LIST_ID, _main),

diff --git a/proscend/prosrc/icos/clishell/menutree.c b/proscend/prosrc/icos/clishell/menutree.c
index d3b0cd7..e4cd934 100644
--- a/proscend/prosrc/icos/clishell/menutree.c
+++ b/proscend/prosrc/icos/clishell/menutree.c
@@ -318,6 +318,7 @@ sMenuItem menu_mgmt[] =

     ACTION_ITEM("backup",  "backup the config to TFTP server",    0, cli_config_backup),
     ACTION_ITEM("restore", "restore the config from TFTP server", 0, cli_config_restore),
+    ACTION_ITEM("production", "set the production is done", 0, cli_production_done),

     EXIT_MENU_ITEM,
     END_OF_ITEM
(END)

上 code 吧

commit 888f6743aefa33a1e97dea14de47348a2706c38e
Refs: [develop]
Author: jeffrey <[email protected]>
Date:   Fri Dec 14 14:28:50 2018 +0800

    modify CLI for Mitrastar to prevent partition switchingto due to 'no_good' counter exceed the limit(2)
    - mgmt info list
       - add a field 'production' to show if the device finishing production
         - Yes - the device finished production
         - No - the device is not finished production
    - mgme production
      - set the production is done

    uboot will increase no_good counter only when the device finished production

 proscend/prosrc/icos/clishell/cli.c                |  7 ++++++
 proscend/prosrc/icos/clishell/cli.h                |  2 ++
 .../prosrc/icos/clishell/cli_mgmt_identification.c | 27 ++++++++++++++++++++++
 proscend/prosrc/icos/clishell/menutree.c           |  1 +
 4 files changed, 37 insertions(+)

問一下 ariel 是否有需要 commit 到其他的 branch

順便 commit 到 release/v0.11 去

commit 6b4f4c9f828a133507e6b22d2854709b614590a6
Refs: [release/v0.11], {origin/release/v0.11}
Author: jeffrey <[email protected]>
Date:   Fri Dec 14 14:51:34 2018 +0800

    modify CLI for Mitrastar to prevent partition switchingto due to 'no_good' counter exceed the limit(2)
    - mgmt info list
       - add a field 'production' to show if the device finishing production
         - Yes - the device finished production
         - No - the device is not finished production
    - mgme production
      - set the production is done

    uboot will increase no_good counter only when the device finished production

 proscend/prosrc/icos/clishell/cli.c                |  7 ++++++
 proscend/prosrc/icos/clishell/cli.h                |  1 +
 .../prosrc/icos/clishell/cli_mgmt_identification.c | 27 ++++++++++++++++++++++
 proscend/prosrc/icos/clishell/menutree.c           |  1 +
 4 files changed, 36 insertions(+)

1455

M300 的 v1.75-mfg branch 也要 let the configuraion and log have different mtd partitions

commit 6c3c8304ce8ccaae6689798834d70b27696e426c
Refs: [v1.75-mfg], {origin/v1.75-mfg}
Author: jeffrey <[email protected]>
Date:   Fri Dec 14 15:00:51 2018 +0800

    let the configuraion and log have different mtd partitions:
    root@Cellular Router:~# df
    Filesystem           1024-blocks    Used Available Use% Mounted on
    ubi0:rootfs_a            81080     54244     22660  71% /
    devtmpfs                 90708         4     90704   0% /dev
    tmpfs                   254744       188    254556   0% /run
    tmpfs                   254744       476    254268   0% /var/volatile
    ubi1:config_a             7796        68      7292   1% /mnt/config
    ubi1:config_a             7796        68      7292   1% /mnt/data
    ubi2:config_b             7796       284      7080   4% /var/volatile/tmp/app_2
    ubi2:config_b             7796       284      7080   4% /home/log

 proscend/memory_fs/nandflash/default/rootfs/etc/rc.local | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

到時候就讓 merge 的同仁多費心了

1645

diff --git a/lib_mips/board.c b/lib_mips/board.c
index a4f4827..8d8fa33 100644
--- a/lib_mips/board.c
+++ b/lib_mips/board.c
@@ -1386,6 +1386,64 @@ int check_image_validation(void)
 #endif


+
+#define _LED_GPIO_INTERNET    17
+#define _LED_GPIO_LAN         18
+#define _LED_GPIO_POWER       16
+#define _LED_GPIO_SIGNAL_LOW  13
+#define _LED_GPIO_SIGNAL_HIGH 14
+#define _LED_GPIO_SIGNAL_MID  15
+#define _LED_GPIO_SIM         22
+
+
+
+void ledInit(void)
+{
+    u32 value = 0;
+
+    /* set uartf_share_mode share pin to gpio mode */
+    value = le32_to_cpu(*(volatile u_long *)RT2880_GPIOMODE_REG);
+#if !defined (RT2880_ASIC_BOARD)
+    value &= ~0x1C;  //clear bit[2:4]UARTF_SHARE_MODE
+#endif
+#if defined (MT7620_ASIC_BOARD)
+    value &= ~0x2000;  //clear bit[13] WLAN_LED
+#endif
+    value |= RALINK_GPIOMODE_DFT;
+    *(volatile u_long *)(RT2880_GPIOMODE_REG) = cpu_to_le32(value);
+}
+
+
+
+void ledCtrl(unsigned char pin, unsigned char state)
+{
+    u32 value = 0;
+
+#if defined (MT7621_FPGA_BOARD) || defined (MT7621_ASIC_BOARD) || \
+    defined (MT7628_FPGA_BOARD) || defined (MT7628_ASIC_BOARD)
+    if ((0 <= pin) && (pin < 32))
+#else
+    if ((0 <= pin) && (pin <= 21))
+#endif
+    {
+        value = le32_to_cpu(*(volatile u_long *)RT2880_REG_PIODIR);
+        value |= (1 << pin);
+        *(volatile u_long *)(RT2880_REG_PIODIR) = cpu_to_le32(value);
+
+        value = le32_to_cpu(*(volatile u_long *)RT2880_REG_PIODATA);
+        if (0 == state) {
+            value &= ~(1 << pin);
+        }
+        else
+        {
+            value |= (1 << pin);
+        }
+        *(volatile u_long *)(RT2880_REG_PIODATA) = cpu_to_le32(value);
+    }
+}
+
+
+
 /************************************************************************
  *
  * This is the next part if the initialization sequence: we are now
@@ -2049,6 +2107,52 @@ __attribute__((nomips16)) void board_init_r (gd_t *id, ulong dest_addr)
        check_image_validation();
 #endif
+
+
+    ledInit();
+    ledCtrl(_LED_GPIO_LAN,      0);
+    ledCtrl(_LED_GPIO_POWER,    0);
+    ledCtrl(_LED_GPIO_INTERNET, 0);
+    ledCtrl(_LED_GPIO_SIM,      0);
+    udelay(1000000);
+    ledCtrl(_LED_GPIO_LAN,      1);
+    ledCtrl(_LED_GPIO_POWER,    1);
+    ledCtrl(_LED_GPIO_INTERNET, 1);
+    ledCtrl(_LED_GPIO_SIM,      1);
+    udelay(1000000);
+    ledCtrl(_LED_GPIO_LAN,      0);
+    ledCtrl(_LED_GPIO_POWER,    0);
+    ledCtrl(_LED_GPIO_INTERNET, 0);
+    ledCtrl(_LED_GPIO_SIM,      0);
+    udelay(1000000);
+    ledCtrl(_LED_GPIO_LAN,      1);
+    ledCtrl(_LED_GPIO_POWER,    1);
+    ledCtrl(_LED_GPIO_INTERNET, 1);
+    ledCtrl(_LED_GPIO_SIM,      1);
+    udelay(1000000);
+    ledCtrl(_LED_GPIO_LAN,      0);
+    ledCtrl(_LED_GPIO_POWER,    0);
+    ledCtrl(_LED_GPIO_INTERNET, 0);
+    ledCtrl(_LED_GPIO_SIM,      0);
+    udelay(1000000);
+    ledCtrl(_LED_GPIO_LAN,      1);
+    ledCtrl(_LED_GPIO_POWER,    1);
+    ledCtrl(_LED_GPIO_INTERNET, 1);
+    ledCtrl(_LED_GPIO_SIM,      1);
+    udelay(1000000);
+    ledCtrl(_LED_GPIO_LAN,      0);
+    ledCtrl(_LED_GPIO_POWER,    0);
+    ledCtrl(_LED_GPIO_INTERNET, 0);
+    ledCtrl(_LED_GPIO_SIM,      0);
+    udelay(1000000);
+    ledCtrl(_LED_GPIO_LAN,      1);
+    ledCtrl(_LED_GPIO_POWER,    1);
+    ledCtrl(_LED_GPIO_INTERNET, 1);
+    ledCtrl(_LED_GPIO_SIM,      1);
+    udelay(1000000);
+
+
+
 /*config bootdelay via environment parameter: bootdelay */
        {
            char * s;
(END)

我期待的是除了 signal 的 led 之外

其他五顆燈會以 1 秒的間隔 暗 亮 暗 亮 暗 亮 暗 亮

結果就只有 LAN 這從左邊數過來的第二顆燈聽話

其他的燈完全都不理我

我實在不知道為什麼

只好再寫信問 mitrastar 了