Skip to content

BSP Documentation 5.15

bitglitcher edited this page Mar 6, 2024 · 10 revisions

Yocto Build Guide 5.15

Development Machine Requirements

  • 8GB of memory minimum

  • 315GB of Disk Space available

  • Ubuntu 20.04

Steps to build

  1. Pull in packages needed for the build.

    sudo apt update

    sudo apt upgrade

    sudo apt install gawk wget git-core diffstat unzip texinfo gcc-multilib \
    build-essential chrpath socat libsdl1.2-dev

    sudo apt install libsdl1.2-dev xterm sed cvs subversion coreutils texi2html \
    docbook-utils python-pysqlite2 help2man make gcc g++ desktop-file-utils \
    libgl1-mesa-dev libglu1-mesa-dev mercurial autoconf automake groff curl lzop asciidoc

    sudo apt install u-boot-tools

    sudo apt install python

  2. Create a project directory. Doesn’t have to be ~/winYocto.
    mkdir ~/winYocto

  3. Configure git.
    git config --global user.name "Your Name"
    git config --global user.email "Your Email"
    git config --list

  4. Install repo tool
    mkdir ~/bin
    curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
    chmod a+x ~/bin/repo
    export PATH=~/bin:$PATH

  5. Download the Yocto Project layers for building the c444 image.
    cd ~/winYocto
    repo init -u https://github.com/WinSystems/c444-manifest.git -b 5.15 -m itx-p-c444_5.15.32.xml
    repo sync

  6. Configure the build directory to target the c444.
    MACHINE=imx8mq-itx-p-c444 DISTRO=c444-xwayland source winsys-setup-release.sh -b build

  7. Run the following to avoid Chromium build failures.
    ulimit -n 10000

  8. Accept the EULA, and begin building the image. In this case the image will be the winsys-image-demo, but there are other target builds available.
    bitbake -k winsys-image-demo

    bitbake NOTES:
    a. The bitbake -k option allows bitbake to continue building as much as it can if there is an error.
    b. bitbake will need to be executed multiple times before successfully completing.
    c. If a package continues to fail bitbake, run the code below, then rerun the bitbake command from Step 8.
    bitbake -c cleanall <recipe-name>

  9. Once the build has completed the image will be under tmp/deploy/images/imx8mq-itx-p-c444.

The files needed to flash a μSD are winsys-image-demo-imx8mq-itx-p-c444.wic.bz2 and winsys-image-demo-imx8mq-itx-p-c444.wic.bmap

The files needed to flash the eMMC using uuu are winsys-image-demo-imx8mq-itx-p-c444.rootfs.tar.bz2 and imx-boot-imx8mq-itx-p-c444-sd.bin-flash_evk

Steps to program the new BSP image

Updating the BSP on the eMMC

Updating the BSP on the μSD

Image Usage

Accessing U-Boot

The U-Boot console by default is piped out over UART1 at 115200 baud. Press any key during boot to stop it from running the default boot command. It has a three second delay by default before it runs the boot command.
Common u-boot commands:
?
Prints out help with all the commands it supports

printenv
Prints out a list of all the environment variables

setenv [variable to set] '[value to set it to]'
Sets the environment variable to desired value

saveenv
Preserves all of the current environment variables between resets.

env default -a
Sets all the environment variables back to defaults

Switching Device Trees

The image produced by the winsys-image-demo target provides two device trees. One supports HDMI and the other supports a 1024x768 LVDS panel. This is how to select the desired device tree from the u-boot prompt.
setenv fdt_file 'imx8mq-itx-p-c444-lvds-auo.dtb'
saveenv
The above switches to the panel device tree.
setenv fdt_file 'imx8mq-itx-p-c444.dtb'
saveenv
The above switches to the HDMI device tree

Switching Linux Boot Media

Linux can be booted from the eMMC or the μSD. Here are the u-boot commands for switching between the two boot media.
μSD boot:
setenv mmcroot '/dev/mmcblk0p2 rootwait rw'
setenv mmcdev 0
saveenv
boot
eMMC boot:
setenv mmcroot '/dev/mmcblk1p2 rootwait rw'
setenv mmcdev 1
saveenv
boot

Setting up RTC

The "PON" flag is triggered during Power-Up Reset, indicating that the time and date information have become corrupted. This flag is initially set upon power-on and must be cleared by writing "0". To accomplish this, we need to initialize the RTC device.

To resolve the following error message:

root@imx8mq-itx-p-c444:/home/winsys# hwclock -r -f /dev/rtc1
hwclock: Failed to read the time from /dev/rtc1: Invalid argument

To clear the PON flag, we can set the RTC clock to a valid static value. Run the command: hwclock --systohc -f /dev/rtc1

Afterwards, check the time using: root@imx8mq-itx-p-c444:~# hwclock -r -f /dev/rtc1 The output should display the correct time and date, such as 2023-05-08 22:20:58.708531+00:00.

Please note that these changes should persist even after rebooting the board, provided there is an RTC battery connected to it.

Adjusting HDMI Resolution

HDMI supports the following resolutions: 640x480p60, 720x480p60, 1280x720p60, 1920x1080p60,3840x2160p60, 4096x2160p60, Here is how to change the resolution at the u-boot prompt.

  1. setenv mmcargs 'setenv bootargs ${jh_clk} console=${console} root=${mmcroot} video=HDMI-A-1:[resolution goes here]@[refresh rate goes here]
  2. saveenv
  3. Boot Linux
  4. Edit /etc/xdg/weston/weston.ini and make sure the following is present in the file:
    [output]
    name=HDMI-A-1
    mode=[resolution goes here]

Disabling Linux console

Doing the following will disable the console and make debug extremely difficult without reflashing the image. Proceed with caution.

  1. Stop at uboot and type the following commands
    setenv console 'null'
    setenv silent 1
    saveenv
    boot
  2. Login to linux and run the following from the command line
    sudo systemctl disable serial-getty@ttymxc0.service
    The step above assumes the console was coming out over UART1

Adjusting U-Boot Delay

U-Boot inserts a time delay before running the boot command. The pause can be adjusted by changing the bootdelay environment variable. It will be difficult to break into u-boot if this variable is set too small.
setenv bootdelay [desired delay time in seconds]

Device Names in Linux

GPIO

GPIO # on Connector GPIO # in Linux
1 0
2 1
3 3
4 5
5 6
6 7
Blue Status LED 84
Green User_LED 132

The descriptor-based interface is the preferred way to manipulate GPIOs. The libgpio library can be used to control GPIOs through C/C++ compiled programs. There is also gpiod, which is a Python3 interface to libgpio. More information can be found at: https://www.kernel.org/doc/html/v4.17/driver-api/gpio/intro.html#gpio-interfaces More information about GPIOD can be found at: https://wiki.loliot.net/docs/lang/python/libraries/gpiod/python-gpiod-about/

GPIOD can be used directly through the command line, these are the available commands.

python3 -m gpiod.test.blink <chip> <line offset>
python3 -m gpiod.test.bulk_blink <chip> <line offset1> [<line offset2> ...]
python3 -m gpiod.test.sequential_blink <chip> <line offset1> \
    [<line offset2> ...]
python3 -m gpiod.test.button <chip> <line offset> [rising|falling|both]
python3 -m gpiod.test.bulk_button <chip> <line offset> [<line offset2> ...]
    <[rising|falling|both]>

Information about the GPIO chips and the pins mapped to them can be found at /sys/kernel/debug/gpio

root@imx8mq-itx-p-c444:~# cat /sys/kernel/debug/gpio
gpiochip0: GPIOs 0-31, parent: platform/30200000.gpio, 30200000.gpio:

gpiochip1: GPIOs 32-63, parent: platform/30210000.gpio, 30210000.gpio:
 gpio-44  (                    |cd                  ) in  lo IRQ ACTIVE LOW
 gpio-51  (                    |usdhc2_vmmc         ) out hi

gpiochip2: GPIOs 64-95, parent: platform/30220000.gpio, 30220000.gpio:
 gpio-87  (                    |enable              ) out hi

gpiochip3: GPIOs 96-127, parent: platform/30230000.gpio, 30230000.gpio:
 gpio-125 (                    |PCIe DIS            ) out hi
 gpio-126 (                    |PCIe reset          ) out hi

gpiochip4: GPIOs 128-159, parent: platform/30240000.gpio, 30240000.gpio:
 gpio-141 (                    |spi1 CS0            ) out hi ACTIVE LOW
 gpio-148 (                    |PCIe CLKREQ         ) out lo
 gpio-154 (                    |rts                 ) out lo ACTIVE LOW
 gpio-155 (                    |cts                 ) in  lo IRQ ACTIVE LOW
 gpio-156 (                    |rts                 ) out hi ACTIVE LOW
 gpio-157 (                    |cts                 ) in  hi IRQ ACTIVE LOW

Available GPIO chip devices can be found in the /dev directory.

root@imx8mq-itx-p-c444:~# ls /dev/gpio*
/dev/gpiochip0  /dev/gpiochip1  /dev/gpiochip2  /dev/gpiochip3  /dev/gpiochip4

UARTs

UART1 shows up as /dev/ttymxc0 and UART 2 shows up as /dev/ttymxc1

RS232/485/422

There are python scripts available at /home/winsys/serial-scripts to switch between different serial protocols.

rs232uart1.py
rs232uart2.py
rs422uart1.py
rs422uart2.py
rs485uart1.py
rs485uart2.py