20160606_jeffrey - silenceuncrio/diary GitHub Wiki

Index

  • 0930 - mail 取消 computex 計畫
  • 0935 - 準備 m300 開會
  • 1010 - image layout
  • 1030 - Yocto Project Mega-Manual Creating Partitioned Images
  • 1115 - wic create
  • 1130 - 研究 wic
  • 1310 - wic list images sdimage-bootpart
  • 1325 - wic list images sdimage-bootpart.wks
  • 1445 - wic create sdimage-bootpart -e core-image-minimal 錯誤
  • 1605 - find . -name "*.conf" -exec grep -H "IMAGE_BOOT_FILES" {} \;
  • 1615 - 放棄 追 wic
  • 1630 - NodeMCU C#
  • 1745 - 看影片 太慢
  • 1835 - c# serial port
  • 1955 - morris MEMS 麥克風

0930

早上發現沒收到有人禮拜五去 computex 的 mail
因為自己當天下午三點過後才到會場
只看了 Realtek 的展區就閃了

發了 mail 告知因為辦理岳父出院事宜所以取消了 computex 計畫
補請一天假比較省事

0935

準備一下待會 m300 開會的事宜
回顧上禮拜做了些什麼

1010

剛剛和 ariel 還有 jammy 很快的 review 了一下 schedule

感覺自己讓 NodeMCU 占了太多時間了
稍微調整一下

先來把 image layout 的事情搞清楚

掃一下 Freescale Yocto Project User's Guide

5 Image Build
This section provides the detailed information along with the process for building an image.

第五章沒說到 image layout 相關

6 Image Deployment
After a build is complete, the created image resides in /tmp/deploy/images.
An image is, for the most part, specific to the machine set in the environment setup.
Each image build creates a U-Boot, a kernel, and an image type based on the IMAGE_FSTYPES defined in the machine configuration file.
Most machine configurations provide an SD card image (.sdcard), an ext3 and tar.bz2. The ext3 is the root file system only.
The .sdcard image contains U-Boot, the kernel and the rootfs completely set up for use on an SD card.

第六章也沒說到

掃一下 i.MX Linux® User's Guide

4.1 Software overview
This section describes the software needed for the board to be able to boot and run Linux OS.
To boot a Linux image, four elements are needed:

  • Bootloader (U-Boot)
  • Linux kernel image (zImage)
  • A device tree file (.dtb) for the board being used
  • A root file system (rootfs) for the particular Linux image

The system can be configured for a specific graphical backend.
The graphical backends are X11, XWayland, and Frame Buffer.

這裡說道 linux image 由哪些部分組成

4.3 Preparing an SD/MMC card to boot

這個章節有說到如何將個別的 image 放到 SD 卡去
這裡就值得注意了

Yocto Project Mega-Manual 的 5.8. Creating Partitioned Images 也要注意

1030

先來看 Yocto Project Mega-Manual 的 5.8. Creating Partitioned Images

1115

這邊說到了一個工具叫 wic

先看一下 help message

jeffrey@jeffrey-virtual-machine:~/fsl-release-bsp/build_small$ wic -h
Usage: 

 Create a customized OpenEmbedded image

 usage: wic [--version] | [--help] | [COMMAND [ARGS]]

 Current 'wic' commands are:
    help              Show help for command or one of the topics (see below)
    create            Create a new OpenEmbedded image
    list              List available canned images and source plugins

 Help topics:
    overview          wic overview - General overview of wic
    plugins           wic plugins - Overview and API
    kickstart         wic kickstart - wic kickstart reference


Options:
  --version   show program's version number and exit
  -h, --help  show this help message and exit

看一下 wic help create

jeffrey@jeffrey-virtual-machine:~/fsl-release-bsp/build_small$ wic help create > wic.help.create.txt
jeffrey@jeffrey-virtual-machine:~/fsl-release-bsp/build_small$ cat ./wic.help.create.txt 


NAME
    wic create - Create a new OpenEmbedded image

SYNOPSIS
    wic create <wks file or image name> [-o <DIRNAME> | --outdir <DIRNAME>]
        [-e | --image-name] [-s, --skip-build-check] [-D, --debug]
        [-r, --rootfs-dir] [-b, --bootimg-dir]
        [-k, --kernel-dir] [-n, --native-sysroot] [-f, --build-rootfs]
        [-c, --compress-with]

DESCRIPTION
    This command creates an OpenEmbedded image based on the 'OE
    kickstart commands' found in the <wks file>.

    In order to do this, wic needs to know the locations of the
    various build artifacts required to build the image.

    Users can explicitly specify the build artifact locations using
    the -r, -b, -k, and -n options.  See below for details on where
    the corresponding artifacts are typically found in a normal
    OpenEmbedded build.

    Alternatively, users can use the -e option to have 'wic' determine
    those locations for a given image.  If the -e option is used, the
    user needs to have set the appropriate MACHINE variable in
    local.conf, and have sourced the build environment.

    The -e option is used to specify the name of the image to use the
    artifacts from e.g. core-image-sato.

    The -r option is used to specify the path to the /rootfs dir to
    use as the .wks rootfs source.

    The -b option is used to specify the path to the dir containing
    the boot artifacts (e.g. /EFI or /syslinux dirs) to use as the
    .wks bootimg source.

    The -k option is used to specify the path to the dir containing
    the kernel to use in the .wks bootimg.

    The -n option is used to specify the path to the native sysroot
    containing the tools to use to build the image.

    The -f option is used to build rootfs by running "bitbake <image>"

    The -s option is used to skip the build check.  The build check is
    a simple sanity check used to determine whether the user has
    sourced the build environment so that the -e option can operate
    correctly.  If the user has specified the build artifact locations
    explicitly, 'wic' assumes the user knows what he or she is doing
    and skips the build check.

    The -D option is used to display debug information detailing
    exactly what happens behind the scenes when a create request is
    fulfilled (or not, as the case may be).  It enumerates and
    displays the command sequence used, and should be included in any
    bug report describing unexpected results.

    When 'wic -e' is used, the locations for the build artifacts
    values are determined by 'wic -e' from the output of the 'bitbake
    -e' command given an image name e.g. 'core-image-minimal' and a
    given machine set in local.conf.  In that case, the image is
    created as if the following 'bitbake -e' variables were used:

    -r:        IMAGE_ROOTFS
    -k:        STAGING_KERNEL_DIR
    -n:        STAGING_DIR_NATIVE
    -b:        empty (plugin-specific handlers must determine this)

    If 'wic -e' is not used, the user needs to select the appropriate
    value for -b (as well as -r, -k, and -n).

    The -o option can be used to place the image in a directory with a
    different name and location.

    The -c option is used to specify compressor utility to compress
    an image. gzip, bzip2 and xz compressors are supported.

1130

看來有必要好好研究一下 wic
資料量夠我這兩天忙的了

1310

看一下 wic help list

jeffrey@jeffrey-virtual-machine:~/fsl-release-bsp/build_small$ wic help list > wic.help.list.txt
jeffrey@jeffrey-virtual-machine:~/fsl-release-bsp/build_small$ cat wic.help.list.txt 


NAME
    wic list - List available OpenEmbedded images and source plugins

SYNOPSIS
    wic list images
    wic list <image> help
    wic list source-plugins

DESCRIPTION
    This command enumerates the set of available canned images as well
    as help for those images.  It also can be used to list available
    source plugins.

    The first form enumerates all the available 'canned' images.
    These are actually just the set of .wks files that have been moved
    into the /scripts/lib/wic/canned-wks directory).

    The second form lists the detailed help information for a specific
    'canned' image.

    The third form enumerates all the available --sources (source
    plugins).  The contents of a given partition are driven by code
    defined in 'source plugins'.  Users specify a specific plugin via
    the --source parameter of the partition .wks command.  Normally
    this is the 'rootfs' plugin but can be any of the more specialized
    sources listed by the 'list source-plugins' command.  Users can
    also add their own source plugins - see 'wic help plugins' for
    details.

看一下目前的 wic list images

jeffrey@jeffrey-virtual-machine:~/fsl-release-bsp/build_small$ wic list images
  directdisk                    		Create a 'pcbios' direct disk image
  mkgummidisk                   		Create an EFI disk image
  mkhybridiso                   		Create a hybrid ISO image
  sdimage-bootpart              		Create SD card image with a boot partition
  directdisk-gpt                		Create a 'pcbios' direct disk image
  qemux86-directdisk            		Create a qemu machine 'pcbios' direct disk image
  directdisk-multi-rootfs       		Create multi rootfs image using rootfs plugin
  mkefidisk                     		Create an EFI disk image

跟 SD 相關的有一個 sdimage-bootpart

看一下 wic list sdimage-bootpart help

jeffrey@jeffrey-virtual-machine:~/fsl-release-bsp/build_small$ wic list sdimage-bootpart help

Creates a partitioned SD card image. Boot files
are located in the first vfat partition.

1325

wic list images 應該是依據下述的目錄

jeffrey@jeffrey-virtual-machine:~/fsl-release-bsp/sources/poky/scripts/lib/wic/canned-wks$ ls -al
total 40
drwxrwxr-x 2 jeffrey jeffrey 4096  6月  6 13:25 .
drwxrwxr-x 9 jeffrey jeffrey 4096  6月  6 11:08 ..
-rw-rw-r-- 1 jeffrey jeffrey  457  5月 19 15:07 directdisk-gpt.wks
-rw-rw-r-- 1 jeffrey jeffrey 1171  5月 19 15:07 directdisk-multi-rootfs.wks
-rw-rw-r-- 1 jeffrey jeffrey  433  5月 19 15:07 directdisk.wks
-rw-rw-r-- 1 jeffrey jeffrey  548  5月 19 15:07 mkefidisk.wks
-rw-rw-r-- 1 jeffrey jeffrey  549  5月 19 15:07 mkgummidisk.wks
-rw-rw-r-- 1 jeffrey jeffrey  360  5月 19 15:07 mkhybridiso.wks
-rw-rw-r-- 1 jeffrey jeffrey  535  5月 19 15:07 qemux86-directdisk.wks
-rw-rw-r-- 1 jeffrey jeffrey  362  5月 19 15:07 sdimage-bootpart.wks

來看一下 sdimage-bootpart.wks

jeffrey@jeffrey-virtual-machine:~/fsl-release-bsp/sources/poky/scripts/lib/wic/canned-wks$ cat sdimage-bootpart.wks 
# short-description: Create SD card image with a boot partition
# long-description: Creates a partitioned SD card image. Boot files
# are located in the first vfat partition.

part /boot --source bootimg-partition --ondisk mmcblk --fstype=vfat --label boot --active --align 4 --size 16
part / --source rootfs --ondisk mmcblk --fstype=ext4 --label root --align 4

為了看懂 *.wks 在寫什麼
我們需要參考 5.8.8. OpenEmbedded Kickstart (.wks) Reference

Either of these commands create a partition on the system and uses the following syntax:
part [mntpoint]
partition [mntpoint]
...
The mntpoint is where the partition will be mounted and must be of one of the following forms:

  • /path: For example, /, /usr, or /home
  • swap: The created partition is used as swap space.

Here is a list that describes other supported options you can use with the part and partition commands:

  • --source: This option is a wic-specific option that names the source of the data that populates the partition.
    The most common value for this option is "rootfs", but you can use any value that maps to a valid source plugin.
    For information on the source plugins, see the "Plugins" section.
    .
    If you use --source rootfs, wic creates a partition as large as needed and to fill it with the contents of the root filesystem pointed to by the -r command-line option or the equivalent rootfs derived from the -e command-line option.
    The filesystem type used to create the partition is driven by the value of the --fstype option specified for the partition. See the entry on --fstype that follows for more information.
    .
    If you use --source plugin-name, wic creates a partition as large as needed and fills it with the contents of the partition that is generated by the specified plugin name using the data pointed to by the -r command-line option or the equivalent rootfs derived from the -e command-line option.
    Exactly what those contents and filesystem type end up being are dependent on the given plugin implementation.
    .
    If you do not use the --source option, the wic command creates an empty partition.
    Consequently, you must use the --size option to specify the size of the empty partition.
  • --ondisk or --ondrive: Forces the partition to be created on a particular disk.
  • --fstype: Sets the file system type for the partition. Valid values are:
    • ext4
    • ext3
    • ext2
    • btrfs
    • squashfs
    • swap
  • --label label: Specifies the label to give to the filesystem to be made on the partition.
    If the given label is already in use by another filesystem, a new label is created for the partition.
  • --active: Marks the partition as active.
  • --align (in KBytes): This option is a wic-specific option that says to start a partition on an x KBytes boundary.
  • --size: The minimum partition size in MBytes. Specify an integer value such as 500. Do not append the number with "MB". You do not need this option if you use --source.

1445

試著直接執行 wic create sdimage-bootpart -e core-image-minimal 結果得到錯誤結果

jeffrey@jeffrey-virtual-machine:~/fsl-release-bsp/build_small$ wic create sdimage-bootpart -e core-image-minimal
Checking basic build environment...
Done.

Creating image(s)...

Error: No boot files defined, IMAGE_BOOT_FILES unset

1605

利用 find . -name "*.conf" -exec grep -H "IMAGE_BOOT_FILES" {} \;~/fsl-release-bsp/sources 搜尋任何 *.conf 裡具有 IMAGE_BOOT_FILES 的字眼

jeffrey@jeffrey-virtual-machine:~/fsl-release-bsp/sources$ find . -name "*.conf" -exec grep -H "IMAGE_BOOT_FILES" {} \;
./poky/meta-yocto-bsp/conf/machine/beaglebone.conf:IMAGE_BOOT_FILES ?= "u-boot.${UBOOT_SUFFIX} MLO"
./poky/scripts/lib/bsp/substrate/target/arch/arm/conf/machine/machine.conf:IMAGE_BOOT_FILES ?= "u-boot.${UBOOT_SUFFIX} MLO"
./poky/meta/conf/documentation.conf:IMAGE_BOOT_FILES[doc] = "Whitespace separated list of files from ${DEPLOY_DIR_IMAGE} to place in boot partition. Entries will be installed under a same name as the source file. To change the destination file name, pass a desired name after a semicolon (eg. u-boot.img;uboot)."

1615

先放棄追 wic

回到 i.MX Linux® User's Guide

4.6 Flash memory maps
This section describes the software layout in memory on memory devices used on the i.MX boards.
This information is useful for understanding subsequent sections about image downloading and how the images are placed in memory.
The mtdparts directive can be used in the Linux boot command to specify memory mapping.
The following example briefly describes how to use memory maps. Memory is allocated in the order of how it is listed.
The dash (-) indicates the the rest of the memory.

mtdparts=[memory type designator]:[size]([name of partition]),[size]([name of partition]),-([name of final partition])

感覺這個就是我應該研究的主題了... 跟 Yocto 沒有關係
這純粹就是 U-Boot 所提供的功能

1630

回頭 NodeMCU

月會提到該 project 為 IoT Alarm Sensor
我們需要一個簡單的桌面應用程式來幫助使用者透過 UART 來設定 NodeMCU
目前頃向使用 C#

利用 小山的 C# 教學 來加速開發

1745

看影片感覺還是太慢

1835

直接搜尋 c# serial port 就能找到不少答案

keep 幾篇好文章

感覺 IoT Alarm Sensor 的案子進行到現在已經不是我稍微花點時間就能應付的程度了
先 study 並收集一下情報
面對 morris 以及 charlie 時先用 M300 這個 project 擋一下
一直等到老闆出面再繼續端菜出來

1955

morris 拿給我的那一個啥 MEMS 麥克風非常不靈敏阿...

⚠️ **GitHub.com Fallback** ⚠️