20160527_jeffrey - silenceuncrio/diary GitHub Wiki
- 0925 - imx-test
- 0940 - review m300
- 1010 - i.MX6UL AVNET main board
- 1120 - i.MX6UL main board
- 1130 - full SD card image core-image-minimal-imx6ulevk.sdcard
- 1305 - m300 AVNET FAE cocall
- 1335 - Downloading an image to MMC/SD
- 1400 - NodeMCU
- 1420 - m300 U-Boot
- 1520 - Linux Core U-Boot User's Guide
- 1545 - NodeMCU
- 1650 - 發 email 快上許多
- 1700 - m300 u-Boot mmc
- 1710 - 現成 UI 套 NodeMCU
- 1730 - NodeMCU uart
將昨天幫 jammy 在 build_jammy
build 的 imx-test
tar 一包給 jammy
tar -zcvf build_jammy.tar.gz build_jammy/
先 review 一下這禮拜為 m300 做的
- boot from
u-boot-imx
only in the SD card - reduce U-Boot - modify
mx6ul_14x14_evk.h
- removeCONFIG_VIDEO
- modify
u-boot-imx_2015.04.bb
for patching the modification of U-Boot
i.MX6UL 有一片從 AVNET 來的 main board
ariel 說讓我先玩一下 AVNET 的 i.MX6UL main board
因為該 main board 就是使用 NAND Flash
跟 morris 聊完後知道 AVNET 的 i.MX6UL main board 的 情報如下
- Flash 是 eMMC Flash, 不是我們未來想使用的 NAND Flash
- BMODE[1:0](Boot Options) 固定成
10
(Internal Boot), 無法改成01
(Serial Download) 利用 MfgTool
跟 ariel sync 後決定不去試 AVNET 的 i.MX6UL main board 了
回頭熟悉一下我目前手上的 i.MX6UL main board
整理一下目前該 main board 的情報
- 從 SD Card 開機
- 只有一個 bootloader image
看一下 main board 開機的訊息(已經 stop autoboot)
U-Boot 2015.04-imx_v2015.04_4.1.15_1.0.0_ga+gd7d7c43 (May 25 2016 - 15:21:58)
CPU: Freescale i.MX6UL rev1.0 at 396 MHz
CPU: Temperature 34 C
Reset cause: POR
Board: MX6UL 14x14 EVK
I2C: ready
DRAM: 512 MiB
MMC: FSL_SDHC: 0, FSL_SDHC: 1
*** Warning - bad CRC, using default environment
In: serial
Out: serial
Err: serial
switch to partitions #0, OK
mmc1 is current device
Net: FEC1
Normal Boot
Hit any key to stop autoboot: 0
=>
看一下 U-Boot 本身的情報
=> ?
? - alias for 'help'
base - print or set address offset
bdinfo - print Board Info structure
bmode - sd1|sd2|qspi1|normal|usb|sata|ecspi1:0|ecspi1:1|ecspi1:2|ecspi1:3|esdhc1|esdhc2|esdhc3|esdhc4 [noreset]
boot - boot default, i.e., run 'bootcmd'
bootd - boot default, i.e., run 'bootcmd'
bootm - boot application image from memory
bootp - boot image via network using BOOTP/TFTP protocol
bootz - boot Linux zImage image from memory
clocks - display clocks
cmp - memory compare
coninfo - print console devices and information
cp - memory copy
crc32 - checksum calculation
dcache - enable or disable data cache
dhcp - boot image via network using DHCP/TFTP protocol
dm - Driver model low level access
echo - echo args to console
editenv - edit environment variable
env - environment handling commands
erase - erase FLASH memory
exit - exit script
false - do nothing, unsuccessfully
fatinfo - print information about filesystem
fatload - load binary file from a dos filesystem
fatls - list files in a directory (default /)
fatsize - determine a file's size
fdt - flattened device tree utility commands
flinfo - print FLASH memory information
fuse - Fuse sub-system
go - start application at address 'addr'
help - print command description/usage
i2c - I2C sub-system
icache - enable or disable instruction cache
iminfo - print header information for application image
imxtract- extract a part of a multi-image
itest - return true/false on integer compare
loadb - load binary file over serial line (kermit mode)
loads - load S-Record file over serial line
loadx - load binary file over serial line (xmodem mode)
loady - load binary file over serial line (ymodem mode)
loop - infinite loop on address range
md - memory display
mdio - MDIO utility commands
mii - MII utility commands
mm - memory modify (auto-incrementing address)
mmc - MMC sub system
mmcinfo - display MMC info
mtest - simple RAM read/write test
mw - memory write (fill)
nfs - boot image via network using NFS protocol
nm - memory modify (constant address)
ping - send ICMP ECHO_REQUEST to network host
printenv- print environment variables
protect - enable or disable FLASH write protection
reset - Perform RESET of the CPU
run - run commands in an environment variable
saveenv - save environment variables to persistent storage
setenv - set environment variables
sf - SPI flash sub-system
showvar - print local hushshell variables
sleep - delay execution for some time
source - run script from memory
test - minimal test like /bin/sh
tftpboot- boot image via network using TFTP protocol
true - do nothing, successfully
usb - USB sub-system
usbboot - boot from USB device
version - print monitor, compiler and linker version
=>
一堆現成的 command 可以用
利用 printenv- print environment variables
看一下目前的 environment variables
=> printenv
baudrate=115200
boot_fdt=try
bootcmd=mmc dev ${mmcdev};mmc dev ${mmcdev}; if mmc rescan; then if run loadbootscript; then run bootscript; else if run loadimage; then run mmcboot; else run netboot; fi; fi; else run netboot; fi
bootcmd_mfg=run mfgtool_args;bootz ${loadaddr} ${initrd_addr} ${fdt_addr};
bootdelay=3
bootscript=echo Running bootscript from mmc ...; source
console=ttymxc0
ethact=FEC1
ethaddr=00:04:9f:03:e7:79
ethprime=FEC
fdt_addr=0x83000000
fdt_file=imx6ul-14x14-evk.dtb
fdt_high=0xffffffff
image=zImage
initrd_addr=0x83800000
initrd_high=0xffffffff
ip_dyn=yes
loadaddr=0x80800000
loadbootscript=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${script};
loadfdt=fatload mmc ${mmcdev}:${mmcpart} ${fdt_addr} ${fdt_file}
loadimage=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${image}
mfgtool_args=setenv bootargs console=${console},${baudrate} rdinit=/linuxrc g_mass_storage.stall=0 g_mass_storage.removable=1 g_mass_storage.file=/fat g_mass_storage.ro=1 g_mass_storage.idVendor=0x066F g_mass_storage.idProduct=0x37FF g_mass_storage.iSerialNumber="" clk_ignore_unused
mmcargs=setenv bootargs console=${console},${baudrate} root=${mmcroot}
mmcautodetect=yes
mmcboot=echo Booting from mmc ...; run mmcargs; if test ${boot_fdt} = yes || test ${boot_fdt} = try; then if run loadfdt; then bootz ${loadaddr} - ${fdt_addr}; else if test ${boot_fdt} = try; then bootz; else echo WARN: Cannot load the DT; fi; fi; else bootz; fi;
mmcdev=1
mmcpart=1
mmcroot=/dev/mmcblk1p2 rootwait rw
netargs=setenv bootargs console=${console},${baudrate} root=/dev/nfs ip=dhcp nfsroot=${serverip}:${nfsroot},v3,tcp
netboot=echo Booting from net ...; run netargs; if test ${ip_dyn} = yes; then setenv get_cmd dhcp; else setenv get_cmd tftp; fi; ${get_cmd} ${image}; if test ${boot_fdt} = yes || test ${boot_fdt} = try; then if ${get_cmd} ${fdt_addr} ${fdt_file}; then bootz ${loadaddr} - ${fdt_addr}; else if test ${boot_fdt} = try; then bootz; else echo WARN: Cannot load the DT; fi; fi; else bootz; fi;
script=boot.scr
stderr=serial
stdin=serial
stdout=serial
Environment size: 2118/8188 bytes
=>
覺得我應該先看完整的 image 的 U-Boot environment variables 才對
換了 full SD card image core-image-minimal-imx6ulevk.sdcard
後來看一下 U-Boot 的 environment variables
=> printenv
baudrate=115200
boot_fdt=try
bootcmd=mmc dev ${mmcdev};mmc dev ${mmcdev}; if mmc rescan; then if run loadbootscript; then run bootscript; else if run loadimage; then run mmcboot; else run netboot; fi; fi; else run netboot; fi
bootcmd_mfg=run mfgtool_args;bootz ${loadaddr} ${initrd_addr} ${fdt_addr};
bootdelay=3
bootscript=echo Running bootscript from mmc ...; source
console=ttymxc0
ethact=FEC1
ethaddr=00:04:9f:03:e7:79
ethprime=FEC
fdt_addr=0x83000000
fdt_file=imx6ul-14x14-evk.dtb
fdt_high=0xffffffff
image=zImage
initrd_addr=0x83800000
initrd_high=0xffffffff
ip_dyn=yes
loadaddr=0x80800000
loadbootscript=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${script};
loadfdt=fatload mmc ${mmcdev}:${mmcpart} ${fdt_addr} ${fdt_file}
loadimage=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${image}
mfgtool_args=setenv bootargs console=${console},${baudrate} rdinit=/linuxrc g_mass_storage.stall=0 g_mass_storage.removable=1 g_mass_storage.file=/fat g_mass_storage.ro=1 g_mass_storage.idVendor=0x066F g_mass_storage.idProduct=0x37FF g_mass_storage.iSerialNumber="" clk_ignore_unused
mmcargs=setenv bootargs console=${console},${baudrate} root=${mmcroot}
mmcautodetect=yes
mmcboot=echo Booting from mmc ...; run mmcargs; if test ${boot_fdt} = yes || test ${boot_fdt} = try; then if run loadfdt; then bootz ${loadaddr} - ${fdt_addr}; else if test ${boot_fdt} = try; then bootz; else echo WARN: Cannot load the DT; fi; fi; else bootz; fi;
mmcdev=1
mmcpart=1
mmcroot=/dev/mmcblk1p2 rootwait rw
netargs=setenv bootargs console=${console},${baudrate} root=/dev/nfs ip=dhcp nfsroot=${serverip}:${nfsroot},v3,tcp
netboot=echo Booting from net ...; run netargs; if test ${ip_dyn} = yes; then setenv get_cmd dhcp; else setenv get_cmd tftp; fi; ${get_cmd} ${image}; if test ${boot_fdt} = yes || test ${boot_fdt} = try; then if ${get_cmd} ${fdt_addr} ${fdt_file}; then bootz ${loadaddr} - ${fdt_addr}; else if test ${boot_fdt} = try; then bootz; else echo WARN: Cannot load the DT; fi; fi; else bootz; fi;
script=boot.scr
stderr=serial
stdin=serial
stdout=serial
Environment size: 2118/8188 bytes
=>
4.4.1.1 Downloading an image to MMC/SD 裡說到
2. Configure the U-Boot environment for network communications. The folllowing is an example. The lines preceded by
the "#" character are comments and have no effect.
U-Boot > setenv serverip <your TFTPserver ip>
U-Boot > setenv bootfile <your kernel zImage name on the TFTP server>
U-Boot > setenv fdt_file <your dtb image name on the TFTP server>
The user can set a fake MAC address through ethaddr enviroment if the MAC address is not fused.
U-Boot > setenv ethaddr 00:01:02:03:04:05
U-Boot > save
注意到 serverip
, bootfile
和 fdt_file
這三個 variable
core-image-minimal-imx6ulevk.sdcard
的 U-Boot 的 environment variables 只有 fdt_file 的值
fdt_file=imx6ul-14x14-evk.dtb
看一下 host 上 build 出來的 image 有沒有啥 *.dtd
jeffrey@jeffrey-virtual-machine:~/fsl-release-bsp/build_small/tmp/deploy/images/imx6ulevk$ ls
...
zImage-imx6ul-14x14-evk-btwifi.dtb
zImage-imx6ul-14x14-evk-csi.dtb
zImage-imx6ul-14x14-evk.dtb
zImage-imx6ul-14x14-evk-usb-certi.dtb
...
尷尬的是不只一個
跟 morris 一起跟 m300 AVNET 的 FAE cocall
morris 下禮拜會寄幾顆我忙公司比較常用的 1Gb NAND Flash 給 AVNET
我可以順便拜託 mike 幫我們試一下我們這邊的 U-Boot image 可不可以在該顆 Flash 上讓 i.MX6UL main board boot 起來
下禮拜再照著 5.5 U-Boot configuration
做一份可以從 U-Boot type 為 NAND 的 image 給他
將自己 PC 端的 Tftpd64
的 DHCP Server 的功能也打開
照著 4.4.1.1 Downloading an image to MMC/SD 的流程走一次
Environment size: 2118/8188 bytes
=> setenv serverip 192.168.1.113
=> setenv bootfile zImage
=> setenv fdt_file zImage-imx6ul-14x14-evk.dtb
=> save
Saving Environment to MMC...
Writing to MMC(1)... done
=> dhcp
BOOTP broadcast 1
BOOTP broadcast 2
BOOTP broadcast 3
BOOTP broadcast 4
BOOTP broadcast 5
BOOTP broadcast 6
DHCP client bound to address 192.168.1.200 (15680 ms)
Using FEC1 device
TFTP from server 192.168.1.113; our IP address is 192.168.1.200
Filename 'zImage'.
Load address: 0x80800000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
###########################################
4.5 MiB/s
done
Bytes transferred = 6343464 (60cb28 hex)
=>
看來是已經 download 了 zImage
再偷玩一下 NodeMCU
大概了解了 send_email_smtp.lua 怎麼運作的了
先這樣吧
再回頭看 m300
多跟 U-Boot 相處一下
看看我剛剛做了啥
env default -f -a
=> help env
env - environment handling commands
Usage:
env default [-f] -a - [forcibly] reset default environment
env default [-f] var [...] - [forcibly] reset variable(s) to their default values
env delete [-f] var [...] - [forcibly] delete variable(s)
env edit name - edit environment variable
env exists name - tests for existence of variable
env print [-a | name ...] - print environment
env run var [...] - run commands in an environment variable
env save - save environment
env set [-f] name [arg ...]
=>
=> help save
saveenv - save environment variables to persistent storage
Usage:
saveenv
=>
save 到 persistent storage 去... persistent storage
直接敲敲看
=> saveenv
Saving Environment to MMC...
Writing to MMC(1)... done
=>
MMC? persistent storage? MMC(1)
=> help reset
reset - Perform RESET of the CPU
Usage:
reset
=>
這個沒啥問題...
=> help setenv
setenv - set environment variables
Usage:
setenv [-f] name value ...
- [forcibly] set environment variable 'name' to 'value ...'
setenv [-f] name
- [forcibly] delete environment variable 'name'
=>
這個之前很常用, 所以
setenv serverip <your TFTPserver ip>
就是
set environment variable serverip
to <your TFTPserver ip>
setenv bootfile <your kernel zImage name on the TFTP server>
就是
set environment variable bootfile
to <your kernel zImage name on the TFTP server>
setenv fdt_file <your dtb image name on the TFTP server>
set environment variable fdt_file
to <your dtb image name on the TFTP server>
setenv ethaddr 00:01:02:03:04:05
這個我沒有執行... 因為本來就有值了
=> print ethaddr
ethaddr=00:04:9f:03:e7:79
=>
=> help dhcp
dhcp - boot image via network using DHCP/TFTP protocol
Usage:
dhcp [loadAddress] [[hostIPaddr:]bootfilename]
=>
這邊我就不適很明白了
因為我只敲 dhcp
而已
其實公司之前的做法是先利用 setenv ipaddr <ip address of m300>
設定我們 i.MX main board 的 ip addr
開啟自己 PC 上的 Tftpd64(TFTP Server)
確認好 environment variable bootfile
所設定的 file 再我們的 TFTP Server 上
直接用 tftp
=> tftp
Using FEC1 device
TFTP from server 192.168.1.113; our IP address is 192.168.1.200
Filename 'zImage'.
Load address: 0x80800000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
###########################################
4.2 MiB/s
done
Bytes transferred = 6343464 (60cb28 hex)
=>
這裡的 Load address: 0x80800000
對應到的有
U-Boot environment variable loadaddr
=> printenv loadaddr
loadaddr=0x80800000
=>
mx6ul_14x14_evk.h
...
#define CONFIG_LOADADDR 0x80800000
...
細節不清楚... 不過這兩個地方應該要一致
=> mmc dev
switch to partitions #0, OK
mmc1 is current device
=>
這個要 help 一下
=> help mmc
mmc - MMC sub system
Usage:
mmc info - display info of the current MMC device
mmc read addr blk# cnt
mmc write addr blk# cnt
mmc erase blk# cnt
mmc rescan
mmc part - lists available partition on current mmc device
mmc dev [dev] [part] - show or set current mmc device [partition]
mmc list - lists available devices
mmc hwpartition [args...] - does hardware partitioning
arguments (sizes in 512-byte blocks):
[user [enh start cnt] [wrrel {on|off}]] - sets user data area attributes
[gp1|gp2|gp3|gp4 cnt [enh] [wrrel {on|off}]] - general purpose partition
[check|set|complete] - mode, complete set partitioning completed
WARNING: Partitioning is a write-once setting once it is set to complete.
Power cycling is required to initialize partitions after set to complete.
mmc bootbus dev boot_bus_width reset_boot_bus_width boot_mode
- Set the BOOT_BUS_WIDTH field of the specified device
mmc bootpart-resize <dev> <boot part size MB> <RPMB part size MB>
- Change sizes of boot and RPMB partitions of specified device
mmc partconf dev boot_ack boot_partition partition_access
- Change the bits of the PARTITION_CONFIG field of the specified device
mmc rst-function dev value
- Change the RST_n_FUNCTION field of the specified device
WARNING: This is a write-once field and 0 / 1 / 2 are the only valid values.
mmc setdsr <value> - set DSR register value
=>
所以就是 set current mmc device 成 mmc1?
=> mmc lis
FSL_SDHC: 0
FSL_SDHC: 1 (SD)
mmc0 是啥阿?
不確定是不是跟 mx6ul_14x14_evk.h
裡的 CONFIG_SYS_MMC_IMG_LOAD_PART
有關
...
#define CONFIG_SYS_MMC_IMG_LOAD_PART 1
...
休息一下... 看得頭昏昏
這個 Linux Core U-Boot User's Guide 好像不錯
再看一下 NodeMCU 吧
目前可以做到
一旦偵測到 sound level > 123, 便發 mail 通知 [email protected]
而且 title 就會把 sound level 顯示出來
而且可以一直持續的動作
發 email 的動作也比之前快上許多
require("base64")
-- The email and password from the account you want to send emails from
local MY_EMAIL = "[email protected]"
local EMAIL_PASSWORD = "abc456"
-- The SMTP server and port of your email provider.
-- If you don't know it google [my email provider] SMTP settings
local SMTP_SERVER = "mail.proscend.com"
local SMTP_PORT = "25"
-- The account you want to send email to
local mail_to = "[email protected]"
-- Your access point's SSID and password
local SSID = "ISMS-2G"
local SSID_PASSWORD = "proscendisms"
-- configure ESP as a station
wifi.setmode(wifi.STATION)
wifi.sta.config(SSID,SSID_PASSWORD)
wifi.sta.autoconnect(1)
-- These are global variables. Don't change their values
-- they will be changed in the functions below
local email_subject = ""
local email_body = ""
local count = 0
local smtp_socket = nil -- will be used as socket to email server
-- The display() function will be used to print the SMTP server's response
function display(sck,response)
print(response)
end
-- The do_next() function is used to send the SMTP commands to the SMTP server in the required sequence.
-- I was going to use socket callbacks but the code would not run callbacks after the first 3.
function do_next()
if(count == 0)then
count = count+1
local IP_ADDRESS = wifi.sta.getip()
smtp_socket:send("HELO "..IP_ADDRESS.."\r\n")
elseif(count==1) then
count = count+1
smtp_socket:send("AUTH LOGIN\r\n")
elseif(count == 2) then
count = count + 1
smtp_socket:send(base64.enc(MY_EMAIL).."\r\n")
elseif(count == 3) then
count = count + 1
smtp_socket:send(base64.enc(EMAIL_PASSWORD).."\r\n")
elseif(count==4) then
count = count+1
smtp_socket:send("MAIL FROM:<" .. MY_EMAIL .. ">\r\n")
elseif(count==5) then
count = count+1
smtp_socket:send("RCPT TO:<" .. mail_to ..">\r\n")
elseif(count==6) then
count = count+1
smtp_socket:send("DATA\r\n")
elseif(count==7) then
count = count+1
local message = string.gsub(
"From: \"".. MY_EMAIL .."\"<"..MY_EMAIL..">\r\n" ..
"To: \"".. mail_to .. "\"<".. mail_to..">\r\n"..
"Subject: ".. email_subject .. "\r\n\r\n" ..
email_body,"\r\n.\r\n","")
smtp_socket:send(message.."\r\n.\r\n")
elseif(count==8) then
print(count)
count = count+1
smtp_socket:send("QUIT\r\n")
else
print(count)
smtp_socket:close()
tmr.stop(0)
end
end
function connected(sck)
tmr.alarm(0,400,1,do_next)
end
function send_email(subject,body)
count = 0
email_subject = subject
email_body = body
smtp_socket = net.createConnection(net.TCP,0)
smtp_socket:on("connection",connected)
--smtp_socket:on("receive",display)
smtp_socket:connect(SMTP_PORT,SMTP_SERVER)
end
x = 0
v = 0
send_once = 0
tmr.alarm(1, 100, tmr.ALARM_AUTO, function()
if x < 10 then
x = x + 1
a = adc.read(0)
v = v + a
else
sound = v/10
print(sound)
if send_once == 0 then
if sound > 123 then
-- Send an email
send_email(
"detect alarm - sound level: " .. sound,
"alarm level: 123"
)
end
end
x = 0
v = 0
end
end)
再回來 m300
想辦法熟悉 u-Boot 的 mmc 指令
發現自己搞錯了方向
我應該熟悉的應該是 U-Boot nand command 才對
morris 告知 http://www.onofftech.com/ 這網站有一些現成的 UI
搞不好可以很快地套在 NodeMCU 上
我再抽時間看一下
下班前再看一下 NodeMCU 的 uart 怎麼用好了