20160531_jeffrey - silenceuncrio/diary GitHub Wiki
- 0905 - m300 如何製作 patch
- 0930 - engineering notebook
- 1040 - NodeMCU parsing UART
- 1120 - m300
- 1150 - imx6ulevk.conf
- 1330 - NodeMCU
- 1425 - m300
- 1720 - NodeMCU
- 1155 - AVNET mike con-call
ariel 希望我補一下如何製作 patch 的文件
-
at U-Boot temporary source code, create a new patch
$ quilt new my_changes.patch
-
notify Quilt about the files you plan to edit
$ quilt add include/configs/mx6ul_14x14_evk.h
(this is how to reduce U-Boot image size, make menuconfig is no working) -
make your changes in the source code to the files you added to the patch
-
generate the final patch that contains all your modifications
$ quilt refresh
-
copy the patch file and edit your recipe, in mycase, I put the patch file under a folder named “files”(bitbake will find patch files under this folder) and add the patch into the SRC_URI of the recipe
SRC_URI += "file://my_changes.patch"
剛好可以拿來貼 engineering notebook
玩一下 NodeMCU
NodeMCU 需要 parsing 從 UART 吃進來的字串來設定一些參數
參考 http://lua-users.org/wiki/SplitJoin
用 string.gmatch 就搞定了
local example = "an example string"
for i in string.gmatch(example, "%S+") do
print(i)
end
-- output:
-- an
-- example
-- string
想到 PC 端需要一個簡單的 GUI 讓使用者使用
總不能讓使用者自己敲 command 吧
有空可以看一下這一篇 http://www.ntu.edu.sg/home/ehchua/programming/java/j4a_gui.html
回頭看 m300
i.MX BSP Porting Guide 這一篇並沒有談到從 NAND Flash 開機需要改什麼
再研究一下 fsl-release-bsp/sources/meta-fsl-bsp-release/imx/meta-bsp/conf/machine/imx6ulevk.conf
#@TYPE: Machine
#@NAME: Freescale i.MX6UL Evaluation Kit
#@SOC: i.MX6UL
#@DESCRIPTION: Machine configuration for Freescale i.MX6UL EVK
#@MAINTAINER: Lauren Post <[email protected]>
include conf/machine/include/imx-base.inc
include conf/machine/include/tune-cortexa7.inc
include conf/machine/include/imx6ul-common.inc
SOC_FAMILY = "mx6ul"
KERNEL_DEVICETREE = "imx6ul-14x14-evk.dtb imx6ul-14x14-evk-csi.dtb imx6ul-14x14-evk-btwifi.dtb \
imx6ul-14x14-evk-usb-certi.dtb \
"
UBOOT_CONFIG ??= "sd"
UBOOT_CONFIG[sd] = "mx6ul_14x14_evk_config,sdcard"
UBOOT_CONFIG[qspi1] = "mx6ul_14x14_evk_qspi1_config"
UBOOT_CONFIG[mfgtool] = "mx6ul_14x14_evk_config"
在 yocto 的文件都有個別的解釋
做一下 NodeMCU
下面的範例可解析出 "set xxx 123"
function split(str, pat)
local t = {} -- NOTE: use {n = 0} in Lua-5.0
local fpat = "(.-)" .. pat
local last_end = 1
local s, e, cap = str:find(fpat, 1)
while s do
if s ~= 1 or cap ~= "" then
table.insert(t,cap)
end
last_end = e+1
s, e, cap = str:find(fpat, last_end)
end
if last_end <= #str then
cap = str:sub(last_end)
table.insert(t, cap)
end
return t
end
x = split("set xxx 123", " ")
if x[1] == "set" then
print("set "..x[2].." to "..x[3])
end
m300
回頭再看一下 U-Boot 的 README
Building the Software:
======================
Building U-Boot has been tested in several native build environments
and in many different cross environments. Of course we cannot support
all possibly existing versions of cross development tools in all
(potentially obsolete) versions. In case of tool chain problems we
recommend to use the ELDK (see http://www.denx.de/wiki/DULG/ELDK)
which is extensively used to build and test U-Boot.
If you are not using a native environment, it is assumed that you
have GNU cross compiling tools available in your path. In this case,
you must set the environment variable CROSS_COMPILE in your shell.
Note that no changes to the Makefile or any other source files are
necessary. For example using the ELDK on a 4xx CPU, please enter:
$ CROSS_COMPILE=ppc_4xx-
$ export CROSS_COMPILE
Note: If you wish to generate Windows versions of the utilities in
the tools directory you can use the MinGW toolchain
(http://www.mingw.org). Set your HOST tools to the MinGW
toolchain and execute 'make tools'. For example:
$ make HOSTCC=i586-mingw32msvc-gcc HOSTSTRIP=i586-mingw32msvc-strip tools
Binaries such as tools/mkimage.exe will be created which can
be executed on computers running Windows.
U-Boot is intended to be simple to build. After installing the
sources you must configure U-Boot for one specific board type. This
is done by typing:
make NAME_defconfig
where "NAME_defconfig" is the name of one of the existing configu-
rations; see boards.cfg for supported names.
Note: for some board special configuration names may exist; check if
additional information is available from the board vendor; for
instance, the TQM823L systems are available without (standard)
or with LCD support. You can select such additional "features"
when choosing the configuration, i. e.
make TQM823L_defconfig
- will configure for a plain TQM823L, i. e. no LCD support
make TQM823L_LCD_defconfig
- will configure for a TQM823L with U-Boot console on LCD
etc.
Finally, type "make all", and you should get some working U-Boot
images ready for download to / installation on your system:
- "u-boot.bin" is a raw binary image
- "u-boot" is an image in ELF binary format
- "u-boot.srec" is in Motorola S-Record format
By default the build is performed locally and the objects are saved
in the source directory. One of the two methods can be used to change
this behavior and build U-Boot to some external directory:
1. Add O= to the make command line invocations:
make O=/tmp/build distclean
make O=/tmp/build NAME_defconfig
make O=/tmp/build all
2. Set environment variable KBUILD_OUTPUT to point to the desired location:
export KBUILD_OUTPUT=/tmp/build
make distclean
make NAME_defconfig
make all
Note that the command line "O=" setting overrides the KBUILD_OUTPUT environment
variable.
Please be aware that the Makefiles assume you are using GNU make, so
for instance on NetBSD you might need to use "gmake" instead of
native "make".
If the system board that you have is not listed, then you will need
to port U-Boot to your hardware platform. To do this, follow these
steps:
1. Add a new configuration option for your board to the toplevel
"boards.cfg" file, using the existing entries as examples.
Follow the instructions there to keep the boards in order.
2. Create a new directory to hold your board specific code. Add any
files you need. In your board directory, you will need at least
the "Makefile", a "<board>.c", "flash.c" and "u-boot.lds".
3. Create a new configuration file "include/configs/<board>.h" for
your board
3. If you're porting U-Boot to a new CPU, then also create a new
directory to hold your CPU specific code. Add any files you need.
4. Run "make <board>_defconfig" with your new name.
5. Type "make", and you should get a working "u-boot.srec" file
to be installed on your target system.
6. Debug and solve any problems that might arise.
[Of course, this last step is much harder than it sounds.]
這裡提到了 configure U-Boot for one specific board type
我們在 <UBOOT_DIR>/configs
目錄下可以看到很多 mx6ul 用的 configurations
<UBOOT_DIR>/configs$ ls mx6ul*
mx6ul_14x14_ddr3_arm2_defconfig
mx6ul_14x14_ddr3_arm2_eimnor_defconfig
mx6ul_14x14_ddr3_arm2_emmc_defconfig
mx6ul_14x14_ddr3_arm2_nand_defconfig
mx6ul_14x14_ddr3_arm2_qspi1_defconfig
mx6ul_14x14_ddr3_arm2_spinor_defconfig
mx6ul_14x14_evk_android_defconfig
mx6ul_14x14_evk_ddr_eol_android_defconfig
mx6ul_14x14_evk_ddr_eol_brillo_defconfig
mx6ul_14x14_evk_ddr_eol_defconfig
mx6ul_14x14_evk_ddr_eol_qspi1_defconfig
mx6ul_14x14_evk_defconfig
mx6ul_14x14_evk_qspi1_defconfig
mx6ul_14x14_lpddr2_arm2_defconfig
mx6ul_14x14_lpddr2_arm2_eimnor_defconfig
mx6ul_9x9_evk_defconfig
mx6ul_9x9_evk_qspi1_defconfig
這就可以接回去 fsl-release-bsp/sources/meta-fsl-bsp-release/imx/meta-bsp/conf/machine/imx6ulevk.conf
...
UBOOT_CONFIG ??= "sd"
UBOOT_CONFIG[sd] = "mx6ul_14x14_evk_config,sdcard"
UBOOT_CONFIG[qspi1] = "mx6ul_14x14_evk_qspi1_config"
UBOOT_CONFIG[mfgtool] = "mx6ul_14x14_evk_config"
"sd" is selected as the configuration of the possible three for the UBOOT_MACHINE.
The "sd" configuration defines "mx6ul_14x14_evk_config" as the value for UBOOT_MACHINE, while the "sdcard" specifies the IMAGE_FSTYPES to use for the U-boot image.
還是不知道 mx6ul_14x14_evk_config
會接去哪裡...
不確定是不是接到 <UBOOT_DIR>/configs/mx6ul_14x14_evk_defconfig
可能要從 compile 的訊息著手了
查不到任何關於 mx6ul_14x14_evk_defconfig 的線索
目前懷疑下列這些 header 檔的名字可以被用在 5.5 U-Boot configuration
的 Build command
的 MACHINE
jeffrey@jeffrey-virtual-machine:~/fsl-release-bsp/sources/meta-fsl-bsp-release/imx/meta-bsp/conf/machine$ ls imx6ul* -l
-rw-rw-r-- 1 jeffrey jeffrey 1143 5月 19 15:07 imx6ul14x14ddr3arm2.conf
-rw-rw-r-- 1 jeffrey jeffrey 639 5月 19 15:07 imx6ul14x14lpddr2arm2.conf
-rw-rw-r-- 1 jeffrey jeffrey 2070 5月 19 15:07 imx6ul7d.conf
-rw-rw-r-- 1 jeffrey jeffrey 613 5月 19 15:07 imx6ul9x9evk.conf
-rw-rw-r-- 1 jeffrey jeffrey 678 5月 19 15:07 imx6ulevk.conf
例如像下面的描述
U-Boot type | Build setup | Build command |
---|---|---|
U-Boot NAND | $ echo "UBOOT_CONFIG = "nand"" >> conf/local.conf | $ MACHINE=imx6solosabreauto bitbake -c deploy u-boot-imx |
截至目前我只有試過 MACHINE=imx6ulevk
但 imx6ulevk.conf
裡 the possible configurations for the UBOOT_MACHINE 並沒有 nand
...
UBOOT_CONFIG ??= "sd"
UBOOT_CONFIG[sd] = "mx6ul_14x14_evk_config,sdcard"
UBOOT_CONFIG[qspi1] = "mx6ul_14x14_evk_qspi1_config"
UBOOT_CONFIG[mfgtool] = "mx6ul_14x14_evk_config"
不過像 imx6ul14x14ddr3arm2.conf
可就多了
...
UBOOT_CONFIG ??= "sd"
UBOOT_CONFIG[sd] = "mx6ul_14x14_ddr3_arm2_config,sdcard"
UBOOT_CONFIG[eimnor] = "mx6ul_14x14_ddr3_arm2_eimnor_config"
UBOOT_CONFIG[emmc] = "mx6ul_14x14_ddr3_arm2_emmc_config,sdcard"
UBOOT_CONFIG[nand] = "mx6ul_14x14_ddr3_arm2_nand_config,ubifs"
UBOOT_CONFIG[spinor] = "mx6ul_14x14_ddr3_arm2_spinor_config"
UBOOT_CONFIG[qspi1] = "mx6ul_14x14_ddr3_arm2_qspi1_config"
UBOOT_CONFIG[mfgtool] = "mx6ul_14x14_ddr3_arm2_config"
理論上可以利用像下面的方式才對
U-Boot type | Build setup | Build command |
---|---|---|
U-Boot NAND | $ echo "UBOOT_CONFIG = "nand"" >> conf/local.conf | $ MACHINE=imx6ul14x14ddr3arm2 bitbake -c deploy u-boot-imx |
竟然 build 過了... 而且看到了 image
jeffrey@jeffrey-virtual-machine:~/fsl-release-bsp/build_small/tmp/deploy/images/imx6ul14x14ddr3arm2$ ls -al
total 420
drwxr-xr-x 2 jeffrey jeffrey 4096 5月 31 17:21 .
drwxrwxr-x 4 jeffrey jeffrey 4096 5月 31 17:21 ..
lrwxrwxrwx 1 jeffrey jeffrey 26 5月 31 17:21 u-boot.imx -> u-boot-nand-2015.04-r0.imx
lrwxrwxrwx 1 jeffrey jeffrey 26 5月 31 17:21 u-boot-imx6ul14x14ddr3arm2.imx -> u-boot-nand-2015.04-r0.imx
lrwxrwxrwx 1 jeffrey jeffrey 26 5月 31 17:21 u-boot-imx6ul14x14ddr3arm2.imx-nand -> u-boot-nand-2015.04-r0.imx
lrwxrwxrwx 1 jeffrey jeffrey 26 5月 31 17:21 u-boot.imx-nand -> u-boot-nand-2015.04-r0.imx
-rwxr-xr-x 2 jeffrey jeffrey 420864 5月 31 17:21 u-boot-nand-2015.04-r0.imx
如果是利用下面的方式時產生不出 image 的
U-Boot type | Build setup | Build command |
---|---|---|
U-Boot NAND | $ echo "UBOOT_CONFIG = "nand"" >> conf/local.conf | $ MACHINE=imx6ulevk bitbake -c deploy u-boot-imx |
再把這個 [u-boot.imx-nand] image 請 AVNET 的 FAE 幫我們試試看吧
希望有好結果喔...
做一下 NodeMCU
目前準備的 init.lua
如下
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
count = count+1
smtp_socket:send("QUIT\r\n")
else
smtp_socket:close()
tmr.stop(0)
end
end
function connected(sck)
tmr.alarm(0,600,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
sound_level = 123
sound_duration = 5
sound_cnt = 0
sound_dbg = 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
if sound_dbg == 1 then
print(sound)
end
if sound > sound_level then
sound_cnt = sound_cnt + 1
print("#"..sound_cnt..": sound("..sound..") more than "..sound_level)
if sound_cnt >= sound_duration then
print("send mail")
-- Send an email
send_email(
"detect alarm - sound level: " .. sound,
"alarm level: "..sound_level
)
sound_cnt = 0
end
else
sound_cnt = 0
end
x = 0
v = 0
end
end)
function split(str, pat)
local t = {} -- NOTE: use {n = 0} in Lua-5.0
local fpat = "(.-)" .. pat
local last_end = 1
local s, e, cap = str:find(fpat, 1)
while s do
if s ~= 1 or cap ~= "" then
table.insert(t,cap)
end
last_end = e+1
s, e, cap = str:find(fpat, last_end)
end
if last_end <= #str then
cap = str:sub(last_end)
table.insert(t, cap)
end
return t
end
-- when '\r' is received.
uart.on("data", "\r",
function(data)
if data=="quit\r" then
uart.on("data") -- unregister callback function
end
cmd = split(data, " ")
if cmd[1] == "set" then
if cmd[2] == "level" then
sound_level = tonumber(cmd[3])
print("set sound level to "..sound_level)
end
if cmd[2] == "duration" then
sound_duration = tonumber(cmd[3])
print("set sound duration to "..sound_duration)
end
if cmd[2] == "debug" then
sound_dbg = tonumber(cmd[3])
print("set sound debug to "..sound_dbg)
end
end
if cmd[1] == "info" then
print("sound level: "..sound_level)
print("sound duration: "..sound_duration)
print("sound debug: "..sound_dbg)
end
end, 0)
早上跟 morris 還有 AVNET 的 mike con-call, 情報如下
- mike 並不是用 i.MX6UL 來試 NAND Flash
- 所以也不需要寄我昨天產生的 image 給他試了
- mike 無法幫我們試我們寄給他的 旺宏MXIC 1Gb NAND Flash, 除非是從 AVNET 供料給我們
- 不過 AVNET 內部若有相同型號他倒是可以試一試
- morris 希望我試一下 MfgTool 怎麼用
- 未來的生產的 main board 如果 Flash 燒 code 失敗了該怎麼救