20190423_jeffrey - silenceuncrio/diary GitHub Wiki

0905

來試昨天 build 的 image

先用 M300-SG_013600001722C2A9_mfgtools.zip 來燒一片 V1.72

直接透過 web upgrade 成昨天下班前 build 的 V2.00 image

upgrade 後直接重開機

U-Boot 2015.04imx_v2015.04_4.1.15_1.2.0_ga+gede7538 (Apr 22 2019 - 10:00:13)

CPU:   Freescale i.MX6UL rev1.1 at 396 MHz
CPU:   Temperature 43 C
Reset cause: POR
Board: MX6UL 14x14 EVK
I2C:   ready
DRAM:  512 MiB
turn on the IO control power
turn on sys led
reset Ethernet 1
reset Ethernet 2
reset Mobile
force_idle_bus: sda=0 scl=0 sda.gp=0x1d scl.gp=0x1c
NAND:  256 MiB
In:    serial
Out:   serial
Err:   serial
Net:   Phy 1 not found
PHY reset timed out
FEC1
Error: FEC1 address not set.

Normal Boot
Hit any key to stop autoboot:  0
replace primary app
a to b
run bootargs_b
bootargs for room b

NAND read: device 0 offset 0x8400000, size 0x800000
 8388608 bytes read: OK

NAND read: device 0 offset 0x8e00000, size 0x100000
 1048576 bytes read: OK
Saving Environment to NAND...
Erasing NAND...
Erasing at 0x3e0000 -- 100% complete.
Writing to NAND... OK
Kernel image @ 0x80800000 [ 0x000000 - 0x4fae50 ]
## Flattened Device Tree blob at 83000000
   Booting using the fdt blob at 0x83000000
   Using Device Tree in place at 83000000, end 8300a1dc

Starting kernel ...

順利開機

反過來先用 mfgtool 燒一個 V2.00

然後 downgrade 成 V1.72

重開機

正常開機且 V1.72 進 linux 後會因 uboot_env_ver 不 match 而 patch 自己所需要的 uboot env

直接拔插電重開機

1000

讓 V2.00 來跟 V1.77 測一下

先測 V1.77 upgrade 到 V2.00

mfgtool 燒錄 M300-SG_013600001772E76A_mfgtools.zip

upgrade 成 V2.00 image

重開機

正常開機

再測 V2.00 downgrade 成 V1.77

mfgtool 燒錄 V2.00

downgrade 成 M300-SG_v1.77_013600001772E76A.img

重開機

正常開機

看來 V2.00 是解掉這問題了

那有沒有機會把 mfgtool 燒錄的 V1.77 在 upgrade V2.00 的時候

克服掉 downgrade 成 V1.77 之前的版本會掛掉 的缺點呢

關鍵就是 uboot_env_ver

我需要把該 env 寫成 1.4

這樣一來 downgrade 到 V1.77 之前的版本就會因為 uboot_env_ver 不 match 而 patch 自己所需要的 uboot env 了

如果寫在 uboot 用 setenv 的方式 會讓 downgrade 到 V1.77 之後的每一次開機都去 patch

會讓開機時間變久

比較適合設定 uboot_env_ver 應該是在 firmware_patch.sh

這個 file 會被包在 V2.00 的 firmware 裡面

當從 V1.77 upgrade 成 V2.00 的時候

firmware_patch.sh 一被執行就把 uboot_env_ver 寫成 1.4 即可

修改如下

diff --git a/proscend/tools/firmware_patch.sh b/proscend/tools/firmware_patch.sh
old mode 100755
new mode 100644
index 3ff1420..870dd47
--- a/proscend/tools/firmware_patch.sh
+++ b/proscend/tools/firmware_patch.sh
@@ -13,6 +13,9 @@ function patch_nandflash {
   echo "Flashing Bootloader"
   kobs-ng init -x -v --chip_0_device_path=/dev/mtd0 /tmp/firmware/u-boot-m300.imx-nand

+  # set uboot_env_ver to 1.4; downgrade to the version lower than 1.4 would patch the uboot env afterward
+  fw_setenv uboot_env_ver 1.4
+
   echo "patch for NAND Flash storage memory succeeded"
 }

build image 來試試

1110

測試手法應該是

V1.77(mfgtool) upgrade 成 V2.00 再 downgrade 成 V1.77

mfgtool 燒錄 M300-SG_013600001772E76A_mfgtools.zip

開機後看一下 uboot_env_ver 的值

bash-4.3# fw_printenv uboot_env_ver
uboot_env_ver=1.3
bash-4.3#

upgrade 成 V2.00

開機後看一下 uboot_env_ver 的值

root@Cellular Router:~# fw_printenv uboot_env_ver
uboot_env_ver=1.4
root@Cellular Router:~#

來 downgrade 成 V1.72

開機

正常開機且 V1.72 進 linux 後會因 uboot_env_ver 不 match 而 patch 自己所需要的 uboot env

...
Running local boot scripts (/etc/rc.local)uboot_env_ver not match, patching for the current applicaiton
...

直接拔插電重開機

開機正常

可以上 code 了

commit 235cbd4d20c91b88edb9c915d3afd426729bcf88
Refs: [release/v2.00], {origin/release/v2.00}
Author: jeffrey <[email protected]>
Date:   Tue Apr 23 11:47:10 2019 +0800

    patch uboot to 1.4
    - solve the downgrade problem
    - even V1.77 with mfgtool, after upgrade to V2.00, downgrade to V1.72 have no problem

 .../recipes-bsp/u-boot/files/uboot_env_v1.4.patch  | 52 ++++++++++++++++++++++
 .../recipes-bsp/u-boot/u-boot-imx_2015.04.bbappend |  1 +
 proscend/tools/firmware_patch.sh                   |  3 ++
 3 files changed, 56 insertions(+)

1400

繼續 lighttpd

切回 branch feature/lighttpd

先 build 個 image

花點時間了解一下 lighttpd 的 authentication 要怎麼用

官方文件 Module mod_auth - Using Authentication

感覺 login 和 multi user 的機制很不好做啊

試著切到 branch release/v2.00

把 iweb 用的 mongoose 從 6.9 升級到 6.14

用 mfgtool 燒個 image 透過 lan 端試試 HTTPS 連線

開機後紀錄一下 iweb 兩個 process

root@Cellular Router:~# ps aux | grep iweb
root      2024  0.0  0.3  10648  1740 pts/3    Ss+  07:17   0:00 iweb -p 80 -d /www
root      2205  0.2  0.5  10648  2764 pts/5    Ss+  07:17   0:00 iweb -p 443 -d /www -s
root      8005  0.0  0.0   1768   320 ttymxc0  S+   07:20   0:00 grep iweb
  • HTTP(2024)
  • HTTPS(2205)

透過 lan 端試試 HTTPS 連線

還是有機率性的 CGI 會 fail

雖然有好一點點

看來 mongoose 升級這條路行不通了

1720

現有寫在 iwe 裡的 api 全部要想辦法改成 CGI 的形式

而且我還要想辦法在自己寫的 CGI 裡實作出像 mongoose 提供的以下機制

/*
 * Registers a callback for a specified http endpoint
 * Note: if callback is registered it is called instead of the
 * callback provided in mg_bind
 *
 * Example code snippet:
 *
 * ```c
 * static void handle_hello1(struct mg_connection *nc, int ev, void *ev_data) {
 *   (void) ev; (void) ev_data;
 *   mg_printf(nc, "HTTP/1.0 200 OK\r\n\r\n[I am Hello1]");
 *  nc->flags |= MG_F_SEND_AND_CLOSE;
 * }
 *
 * static void handle_hello2(struct mg_connection *nc, int ev, void *ev_data) {
 *  (void) ev; (void) ev_data;
 *   mg_printf(nc, "HTTP/1.0 200 OK\r\n\r\n[I am Hello2]");
 *  nc->flags |= MG_F_SEND_AND_CLOSE;
 * }
 *
 * void init() {
 *   nc = mg_bind(&mgr, local_addr, cb1);
 *   mg_register_http_endpoint(nc, "/hello1", handle_hello1);
 *   mg_register_http_endpoint(nc, "/hello1/hello2", handle_hello2);
 * }
 * ```
 */
void mg_register_http_endpoint(struct mg_connection *nc, const char *uri_path,
                               MG_CB(mg_event_handler_t handler,
                                     void *user_data));