### Board-Specific Setup Code Example Source: https://github.com/bpi-sinovoip/bpi-r3-bsp-5.15/blob/main/linux-mt/Documentation/sh/new-machine.rst Provides definitions for get_system_type() and platform_setup(), which are required for board setup. This example demonstrates how to define the system type and perform initial hardware setup for a new board. ```c /* * arch/sh/boards/vapor/setup.c - Setup code for imaginary board */ #include const char *get_system_type(void) { return "FooTech Vaporboard"; } int __init platform_setup(void) { /* * If our hardware actually existed, we would do real * setup here. Though it's also sane to leave this empty * if there's no real init work that has to be done for * this board. */ /* Start-up imaginary PCI ... */ /* And whatever else ... */ return 0; } ``` -------------------------------- ### VFIO Container and Group Setup in C Source: https://github.com/bpi-sinovoip/bpi-r3-bsp-5.15/blob/main/linux-mt/Documentation/driver-api/vfio.rst Example C code demonstrating how to create a VFIO container, open an IOMMU group, add the group to the container, set up an IOMMU, map DMA memory, and get a file descriptor for a specific device. ```c int container, group, device, i; struct vfio_group_status group_status = { .argsz = sizeof(group_status) }; struct vfio_iommu_type1_info iommu_info = { .argsz = sizeof(iommu_info) }; struct vfio_iommu_type1_dma_map dma_map = { .argsz = sizeof(dma_map) }; struct vfio_device_info device_info = { .argsz = sizeof(device_info) }; /* Create a new container */ container = open("/dev/vfio/vfio", O_RDWR); if (ioctl(container, VFIO_GET_API_VERSION) != VFIO_API_VERSION) /* Unknown API version */ if (!ioctl(container, VFIO_CHECK_EXTENSION, VFIO_TYPE1_IOMMU)) /* Doesn't support the IOMMU driver we want. */ /* Open the group */ group = open("/dev/vfio/26", O_RDWR); /* Test the group is viable and available */ ioctl(group, VFIO_GROUP_GET_STATUS, &group_status); if (!(group_status.flags & VFIO_GROUP_FLAGS_VIABLE)) /* Group is not viable (ie, not all devices bound for vfio) */ /* Add the group to the container */ ioctl(group, VFIO_GROUP_SET_CONTAINER, &container); /* Enable the IOMMU model we want */ ioctl(container, VFIO_SET_IOMMU, VFIO_TYPE1_IOMMU); /* Get addition IOMMU info */ ioctl(container, VFIO_IOMMU_GET_INFO, &iommu_info); /* Allocate some space and setup a DMA mapping */ dma_map.vaddr = mmap(0, 1024 * 1024, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0); dma_map.size = 1024 * 1024; dma_map.iova = 0; /* 1MB starting at 0x0 from device view */ dma_map.flags = VFIO_DMA_MAP_FLAG_READ | VFIO_DMA_MAP_FLAG_WRITE; ioctl(container, VFIO_IOMMU_MAP_DMA, &dma_map); /* Get a file descriptor for the device */ device = ioctl(group, VFIO_GROUP_GET_DEVICE_FD, "0000:06:0d.0"); /* Test and setup the device */ ``` -------------------------------- ### QEMU System Configuration Example Source: https://github.com/bpi-sinovoip/bpi-r3-bsp-5.15/blob/main/u-boot-mt/doc/usage/cmd/qfw.rst This example demonstrates how to launch a QEMU system with specified machine type, BIOS, memory, and graphics settings, including loading a kernel and initrd. This setup is often a prerequisite for using 'qfw load'. ```bash $ qemu-system-x86_64 -machine pc-i440fx-2.5 -bios u-boot.rom -m 1G \ -nographic -kernel vmlinuz -initrd initrd ``` -------------------------------- ### IIO HW Consumer Setup Example Source: https://github.com/bpi-sinovoip/bpi-r3-bsp-5.15/blob/main/linux-mt/Documentation/driver-api/iio/hw-consumer.rst Demonstrates the typical setup for an IIO HW consumer, including allocation and usage within a device probe and read function. Ensure hwc is properly allocated before use. ```c static struct iio_hw_consumer *hwc; static const struct iio_info adc_info = { .read_raw = adc_read_raw, }; static int adc_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int *val, int *val2, long mask) { ret = iio_hw_consumer_enable(hwc); /* Acquire data */ ret = iio_hw_consumer_disable(hwc); } static int adc_probe(struct platform_device *pdev) { hwc = devm_iio_hw_consumer_alloc(&iio->dev); } ``` -------------------------------- ### Boot Trace Example Source: https://github.com/bpi-sinovoip/bpi-r3-bsp-5.15/blob/main/atf-mt/docs/plat/qti-msm8916.rst Example output from the debug console during the BL31 boot process on MSM8916, showing platform setup, service initialization, CPU workarounds, and the entry point for the non-secure world. ```text ... S - DDR Frequency, 400 MHz NOTICE: BL31: v2.6(debug):v2.6 NOTICE: BL31: Built : 20:00:00, Dec 01 2021 INFO: BL31: Platform setup start INFO: ARM GICv2 driver initialized INFO: BL31: Platform setup done INFO: BL31: Initializing runtime services INFO: BL31: cortex_a53: CPU workaround for 819472 was applied INFO: BL31: cortex_a53: CPU workaround for 824069 was applied INFO: BL31: cortex_a53: CPU workaround for 826319 was applied INFO: BL31: cortex_a53: CPU workaround for 827319 was applied INFO: BL31: cortex_a53: CPU workaround for 835769 was applied INFO: BL31: cortex_a53: CPU workaround for disable_non_temporal_hint was applied INFO: BL31: cortex_a53: CPU workaround for 843419 was applied INFO: BL31: cortex_a53: CPU workaround for 1530924 was applied INFO: BL31: Preparing for EL3 exit to normal world INFO: Entry point address = 0x8f600000 INFO: SPSR = 0x3c9 U-Boot 2021.10 (Dec 01 2021 - 20:00:00 +0000) Qualcomm-DragonBoard 410C ... ``` -------------------------------- ### Finalize disk image setup in VM Source: https://github.com/bpi-sinovoip/bpi-r3-bsp-5.15/blob/main/linux-mt/Documentation/bpf/s390.rst After starting the VM for the first time, run this command inside the VM to finalize the disk image setup. This is a required step for the debootstrap installation. ```bash /debootstrap/debootstrap --second-stage ``` -------------------------------- ### Example extlinux.conf Entries Source: https://github.com/bpi-sinovoip/bpi-r3-bsp-5.15/blob/main/u-boot-mt/doc/develop/distro.rst These examples show different configurations for extlinux.conf, demonstrating how to specify kernel, initrd, and append parameters for various boot targets. ```text append ro root=UUID=8eac677f-8ea8-4270-8479-d5ddbb797450 console=ttyS0,115200n8 LANG=en_US.UTF-8 drm.debug=0xf fdtdir /boot/dtb-3.17.0-0.rc4.git2.1.fc22.armv7hl+lpae initrd /boot/initramfs-3.17.0-0.rc4.git2.1.fc22.armv7hl+lpae.img ``` ```text label Fedora-0-rescue-8f6ba7b039524e0eb957d2c9203f04bc (0-rescue-8f6ba7b039524e0eb957d2c9203f04bc) kernel /boot/vmlinuz-0-rescue-8f6ba7b039524e0eb957d2c9203f04bc initrd /boot/initramfs-0-rescue-8f6ba7b039524e0eb957d2c9203f04bc.img append ro root=UUID=8eac677f-8ea8-4270-8479-d5ddbb797450 console=ttyS0,115200n8 fdtdir /boot/dtb-3.16.0-0.rc6.git1.1.fc22.armv7hl+lpae ``` -------------------------------- ### U-Boot tftpput Example Workflow Source: https://github.com/bpi-sinovoip/bpi-r3-bsp-5.15/blob/main/u-boot-mt/doc/usage/cmd/tftpput.rst This example shows a typical workflow for using the tftpput command. It involves setting up network configuration, loading a file from an SD card, and then transferring it to a TFTP server. ```bash => setenv autoload no => dhcp BOOTP broadcast 1 DHCP client bound to address 192.168.1.40 (7 ms) => load mmc 0:1 $loadaddr test.txt 260096 bytes read in 13 ms (19.1 MiB/s) => tftpput $loadaddr $filesize 192.168.1.3:upload/test.txt Using ethernet@1c30000 device TFTP to server 192.168.1.3; our IP address is 192.168.1.40 Filename 'upload/test.txt'. Save address: 0x42000000 Save size: 0x3f800 Saving: ################# 4.4 MiB/s done Bytes transferred = 260096 (3f800 hex) => ``` -------------------------------- ### Example: Initial Boot Method Listing Source: https://github.com/bpi-sinovoip/bpi-r3-bsp-5.15/blob/main/u-boot-mt/doc/usage/cmd/bootmeth.rst Demonstrates the output of 'bootmeth list' when all boot methods are present and in their default order. ```text Order Seq Name Description ----- 0 0 distro Syslinux boot from a block device 1 1 efi EFI boot from an .efi file 2 2 pxe PXE boot from a network device 3 3 sandbox Sandbox boot for testing 4 4 efi_mgr EFI bootmgr flow ----- (5 bootmeths) ``` -------------------------------- ### GPIO IRQ Chip Setup Example Source: https://github.com/bpi-sinovoip/bpi-r3-bsp-5.15/blob/main/linux-mt/Documentation/driver-api/gpio/driver.rst A typical example demonstrating the setup of a chained cascaded interrupt handler using the gpio_irq_chip structure. This code snippet is part of the infrastructure helpers for GPIO irqchips. ```c /* Typical state container with dynamic irqchip */ struct my_gpio { struct gpio_chip gc; struct irq_chip irq; }; int irq; /* from platform etc */ struct my_gpio *g; ``` -------------------------------- ### Basic NX-GZIP Setup Example Source: https://github.com/bpi-sinovoip/bpi-r3-bsp-5.15/blob/main/linux-mt/Documentation/powerpc/vas-api.rst A basic C function demonstrating the initialization of variables for using the NX-GZIP device, including file descriptors and memory pointers. ```c int use_nx_gzip() { int rc, fd; void *addr; struct vas_setup_attr txattr; ``` -------------------------------- ### Example CSF Blocks Line Source: https://github.com/bpi-sinovoip/bpi-r3-bsp-5.15/blob/main/u-boot-mt/doc/imx/habv4/guides/mx8m_spl_secure_boot.txt This is an example of a 'Blocks' line within a CSF file, specifying the memory area to be authenticated. It includes the start address in DRAM, start address in flash.bin, size, and filename. ```text Blocks = 0x7e0fc0 0x0 0x306f0 "flash.bin" ``` -------------------------------- ### NCR53C8XX Boot Setup Command Example Source: https://github.com/bpi-sinovoip/bpi-r3-bsp-5.15/blob/main/linux-mt/Documentation/scsi/ncr53c8xx.rst Example of passing setup commands to the ncr53c8xx driver at boot time using lilo. This enables tagged commands, sets synchronous negotiation speed, and enables debug mode. ```bash lilo: linux root=/dev/hda2 ncr53c8xx=tags:4,sync:10,debug:0x200 ``` -------------------------------- ### Loading and Booting Kernel with bootz Source: https://github.com/bpi-sinovoip/bpi-r3-bsp-5.15/blob/main/u-boot-mt/doc/usage/cmd/bootz.rst This example demonstrates the sequence of commands to load a device tree, kernel image, and initial RAM disk, followed by booting the kernel using the bootz command. ```text => load mmc 0:2 $fdt_addr_r dtb 23093 bytes read in 7 ms (3.1 MiB/s) => load mmc 0:2 $kernel_addr_r vmlinuz 5079552 bytes read in 215 ms (22.5 MiB/s) => load mmc 0:2 $ramdisk_addr_r initrd.img 23854965 bytes read in 995 ms (22.9 MiB/s) => bootz $kernel_addr_r $ramdisk_addr_r:$filesize $fdt_addr_r Kernel image @ 0x42000000 [ 0x000000 - 0x4d8200 ] ## Flattened Device Tree blob at 43000000 Booting using the fdt blob at 0x43000000 EHCI failed to shut down host controller. Loading Ramdisk to 48940000, end 49ffff75 ... OK Loading Device Tree to 48937000, end 4893fa34 ... OK Starting kernel ... ``` -------------------------------- ### NCR53C8XX Driver Exclusion Example Source: https://github.com/bpi-sinovoip/bpi-r3-bsp-5.15/blob/main/linux-mt/Documentation/scsi/ncr53c8xx.rst Example demonstrating how to exclude a specific 53C8xx adapter using the 'excl' keyword with insmod. This installs the sym53c8xx driver on all adapters except the one at IO port 0x1400, then installs the ncr53c8xx driver to that specific adapter. ```bash insmod sym53c8xx sym53c8xx=excl:0x1400 insmod ncr53c8xx ``` -------------------------------- ### U-Boot Example: Managing Boot Devices Source: https://github.com/bpi-sinovoip/bpi-r3-bsp-5.15/blob/main/u-boot-mt/doc/usage/cmd/bootdev.rst This example demonstrates a typical workflow: listing boot devices, selecting one by its sequence number, scanning for bootflows, and then displaying information about the selected device. ```bash U-Boot> bootdev list Seq Probed Status Uclass Name --- ------ ------ -------- ------------------ 0 [ + ] OK mmc mmc@7e202000.bootdev 1 [ ] OK mmc sdhci@7e300000.bootdev 2 [ ] OK ethernet smsc95xx_eth.bootdev --- ------ ------ -------- ------------------ (3 devices) U-Boot> bootdev sel 0 U-Boot> bootflow scan U-Boot> bootdev info Name: mmc@7e202000.bootdev Sequence: 0 Status: Probed Uclass: mmc Bootflows: 1 (1 valid) ``` -------------------------------- ### EP93xx Framebuffer Setup Platform Callback Source: https://github.com/bpi-sinovoip/bpi-r3-bsp-5.15/blob/main/linux-mt/Documentation/fb/ep93xx-fb.rst Implement the setup callback for the EP93xx framebuffer driver. This function is called when the driver is installed. ```c static int some_board_fb_setup(struct platform_device *pdev) { struct ep93xxfb_mach_info *mach_info = pdev->dev.platform_data; struct fb_info *fb_info = platform_get_drvdata(pdev); /* Board specific framebuffer setup */ } ``` -------------------------------- ### Remote Filesystem Memory Setup Example Source: https://github.com/bpi-sinovoip/bpi-r3-bsp-5.15/blob/main/linux-mt/Documentation/devicetree/bindings/reserved-memory/qcom,rmtfs-mem.txt Example of setting up remote filesystem memory for APQ8016, allocating a region for the Hexagon DSP. ```devicetree reserved-memory { #address-cells = <2>; #size-cells = <2>; ranges; rmtfs@86700000 { compatible = "qcom,rmtfs-mem"; reg = <0x0 0x86700000 0x0 0xe0000>; no-map; qcom,client-id = <1>; }; }; ``` -------------------------------- ### Create a simple 'Hello World' initramfs Source: https://github.com/bpi-sinovoip/bpi-r3-bsp-5.15/blob/main/linux-mt/Documentation/filesystems/ramfs-rootfs-initramfs.rst This snippet demonstrates how to create a minimal C program, compile it statically, package it into a cpio.gz archive, and test it using QEMU as an external initramfs. ```c #include #include int main(int argc, char *argv[]) { printf("Hello world!\n"); sleep(999999999); } ``` ```bash gcc -static hello.c -o init echo init | cpio -o -H newc | gzip > test.cpio.gz # Testing external initramfs using the initrd loading mechanism. qemu -kernel /boot/vmlinuz -initrd test.cpio.gz /dev/zero ``` -------------------------------- ### Download and Prepare Firmware Source: https://github.com/bpi-sinovoip/bpi-r3-bsp-5.15/blob/main/u-boot-mt/doc/board/toradex/apalis-imx8.rst Download the SC firmware and the NXP firmware-imx-8.0.bin, then make it executable. ```bash wget https://github.com/toradex/meta-fsl-bsp-release/blob/toradex-sumo-4.14.78-1.0.0_ga-bringup/imx/meta-bsp/recipes-bsp/imx-sc-firmware/files/mx8qm-apalis-scfw-tcm.bin?raw=true mv mx8qm-apalis-scfw-tcm.bin?raw=true mx8qm-apalis-scfw-tcm.bin wget https://www.nxp.com/lgfiles/NMG/MAD/YOCTO/firmware-imx-8.0.bin chmod +x firmware-imx-8.0.bin ./firmware-imx-8.0.bin ``` -------------------------------- ### Devicetree Initrd Start and End Example Source: https://github.com/bpi-sinovoip/bpi-r3-bsp-5.15/blob/main/linux-mt/Documentation/devicetree/bindings/chosen.txt Holds the physical start (inclusive) and end (exclusive) addresses of an initrd loaded by the bootloader. ```devicetree / { chosen { linux,initrd-start = <0x82000000>; linux,initrd-end = <0x82800000>; }; }; ``` -------------------------------- ### Example: Build U-Boot on STM32H743 Discovery Source: https://github.com/bpi-sinovoip/bpi-r3-bsp-5.15/blob/main/u-boot-mt/doc/board/st/stm32_MCU.rst Build U-Boot for the STM32H743 discovery board. This example demonstrates setting the output directory and applying the board-specific defconfig before building. ```bash # export KBUILD_OUTPUT=stm32h743-disco # make stm32h743-disco_defconfig # make all ``` -------------------------------- ### Start Espeakup Manually Source: https://github.com/bpi-sinovoip/bpi-r3-bsp-5.15/blob/main/linux-mt/Documentation/admin-guide/spkguide.txt Manually starts the Espeakup binary, typically located in /usr/bin after a manual installation. Requires root privileges. ```bash /usr/bin/espeakup ``` -------------------------------- ### U-Boot Network Boot Configuration Example Source: https://github.com/bpi-sinovoip/bpi-r3-bsp-5.15/blob/main/u-boot-mt/doc/develop/distro.rst This example demonstrates a U-Boot menu configuration for network booting, specifying kernel, FDT directory, and append parameters for different targets. ```text TIMEOUT 100 MENU TITLE TFTP boot options LABEL jetson-tk1-emmc MENU LABEL ../zImage root on Jetson TK1 eMMC LINUX ../zImage FDTDIR ../ APPEND console=ttyS0,115200n8 console=tty1 loglevel=8 rootwait rw earlyprintk root=PARTUUID=80a5a8e9-c744-491a-93c1-4f4194fd690b LABEL venice2-emmc MENU LABEL ../zImage root on Venice2 eMMC LINUX ../zImage FDTDIR ../ APPEND console=ttyS0,115200n8 console=tty1 loglevel=8 rootwait rw earlyprintk root=PARTUUID=5f71e06f-be08-48ed-b1ef-ee4800cc860f LABEL sdcard MENU LABEL ../zImage, root on 2GB sdcard LINUX ../zImage FDTDIR ../ APPEND console=ttyS0,115200n8 console=tty1 loglevel=8 rootwait rw earlyprintk root=PARTUUID=b2f82cda-2535-4779-b467-094a210fbae7 LABEL fedora-installer-fk MENU LABEL Fedora installer w/ Fedora kernel LINUX fedora-installer/vmlinuz INITRD fedora-installer/initrd.img.orig FDTDIR fedora-installer/dtb APPEND loglevel=8 ip=dhcp inst.repo=http://10.0.0.2/mirrors/fedora/linux/development/rawhide/armhfp/os/ rd.shell cma=64M ``` -------------------------------- ### ftrace Annotate Option Example Source: https://github.com/bpi-sinovoip/bpi-r3-bsp-5.15/blob/main/linux-mt/Documentation/trace/ftrace.rst This example demonstrates the output when the 'annotate' option is enabled, showing CPU buffer start markers and trace events. ```text annotate -0 [001] dNs4 21169.031481: wake_up_idle_cpu <-add_timer_on -0 [001] dNs4 21169.031482: _raw_spin_unlock_irqrestore <-add_timer_on -0 [001] .Ns4 21169.031484: sub_preempt_count <-_raw_spin_unlock_irqrestore ##### CPU 2 buffer started #### -0 [002] .N.1 21169.031484: rcu_idle_exit <-cpu_idle -0 [001] .Ns3 21169.031484: _raw_spin_unlock <-clocksource_watchdog -0 [001] .Ns3 21169.031485: sub_preempt_count <-_raw_spin_unlock ``` -------------------------------- ### CS42888 Codec Device Tree Example Source: https://github.com/bpi-sinovoip/bpi-r3-bsp-5.15/blob/main/linux-mt/Documentation/devicetree/bindings/sound/cs42xx8.txt Example Device Tree configuration for the CS42888 CODEC. Ensure all required properties are correctly specified for your hardware setup. ```devicetree cs42888: codec@48 { compatible = "cirrus,cs42888"; reg = <0x48>; clocks = <&codec_mclk 0>; clock-names = "mclk"; VA-supply = <®_audio>; VD-supply = <®_audio>; VLS-supply = <®_audio>; VLC-supply = <®_audio>; reset-gpios = <&pca9557_b 1 GPIO_ACTIVE_LOW>; }; ``` -------------------------------- ### Download and Prepare Firmware Source: https://github.com/bpi-sinovoip/bpi-r3-bsp-5.15/blob/main/u-boot-mt/doc/board/kontron/pitx-imx8m.rst Download the NXP firmware package, make it executable, run the installer, and copy the DDR and HDMI firmware binaries to the U-Boot build directory. ```bash wget https://www.nxp.com/lgfiles/NMG/MAD/YOCTO/firmware-imx-8.11.bin chmod +x firmware-imx-8.11.bin ./firmware-imx-8.11 cp firmware-imx-8.11/firmware/ddr/synopsys/lpddr4*.bin $(builddir) cp firmware-imx-8.11/firmware/hdmi/cadence/signed_hdmi_imx8m.bin $(builddir) ``` -------------------------------- ### TI Composite Divider Clock Example Source: https://github.com/bpi-sinovoip/bpi-r3-bsp-5.15/blob/main/linux-mt/Documentation/devicetree/bindings/clock/ti/divider.txt Example of a TI composite divider clock for dpll_core_m3x2_div_ck. It specifies a maximum divisor of 31 and uses the default index start. ```dts dpll_core_m3x2_div_ck: dpll_core_m3x2_div_ck { #clock-cells = <0>; compatible = "ti,composite-divider-clock"; clocks = <&dpll_core_x2_ck>; ti,max-div = <31>; reg = <0x0134>; ti,index-starts-at-one; }; ``` -------------------------------- ### Example: Pointing to SETUP_E820_EXT using setup_indirect Source: https://github.com/bpi-sinovoip/bpi-r3-bsp-5.15/blob/main/linux-mt/Documentation/x86/boot.rst Illustrates how to use the setup_indirect structure to point to SETUP_E820_EXT data. This involves setting the type to SETUP_INDIRECT, specifying the size of setup_indirect in 'len', and providing the address and length of the actual data in 'addr' and 'len' respectively within the setup_indirect structure. ```c struct setup_data { __u64 next = 0 or ; __u32 type = SETUP_INDIRECT; __u32 len = sizeof(setup_indirect); __u8 data[sizeof(setup_indirect)] = struct setup_indirect { __u32 type = SETUP_INDIRECT | SETUP_E820_EXT; __u32 reserved = 0; __u64 len = ; __u64 addr = ; } } ``` -------------------------------- ### Get CAN Interface Index and Bind Socket Source: https://github.com/bpi-sinovoip/bpi-r3-bsp-5.15/blob/main/linux-mt/Documentation/networking/can.rst Example demonstrating how to get the interface index for a CAN device (e.g., 'can0') using ioctl and then bind a raw CAN socket to that interface. ```C int s; struct sockaddr_can addr; struct ifreq ifr; s = socket(PF_CAN, SOCK_RAW, CAN_RAW); strcpy(ifr.ifr_name, "can0" ); ioctl(s, SIOCGIFINDEX, &ifr); addr.can_family = AF_CAN; addr.can_ifindex = ifr.ifr_ifindex; bind(s, (struct sockaddr *)&addr, sizeof(addr)); (..) ``` -------------------------------- ### Compiling and Running the sampling.c Example Source: https://github.com/bpi-sinovoip/bpi-r3-bsp-5.15/blob/main/linux-mt/tools/lib/perf/Documentation/libperf-sampling.txt Compile and run the 'sampling.c' example. This requires root privileges due to the use of hardware cycles events. ```bash $ gcc -o sampling sampling.c -lperf $ sudo ./sampling ``` -------------------------------- ### Example Capsule Update Configuration Source: https://github.com/bpi-sinovoip/bpi-r3-bsp-5.15/blob/main/u-boot-mt/doc/develop/uefi/uefi.rst Example initialization of the `efi_fw_image` and `efi_capsule_update_info` structures for performing capsule updates. This includes defining GUIDs, names, indices, and the DFU string. ```c struct efi_fw_image fw_images[] = { { .image_type_id = DEVELOPERBOX_UBOOT_IMAGE_GUID, .fw_name = u"DEVELOPERBOX-UBOOT", .image_index = 1, }, { .image_type_id = DEVELOPERBOX_FIP_IMAGE_GUID, .fw_name = u"DEVELOPERBOX-FIP", .image_index = 2, }, { .image_type_id = DEVELOPERBOX_OPTEE_IMAGE_GUID, .fw_name = u"DEVELOPERBOX-OPTEE", .image_index = 3, }, }; struct efi_capsule_update_info update_info = { .dfu_string = "mtd nor1=u-boot.bin raw 200000 100000;" "fip.bin raw 180000 78000;" "optee.bin raw 500000 100000", .images = fw_images, }; ``` -------------------------------- ### Example: Second Bond Configuration (boot.local) Source: https://github.com/bpi-sinovoip/bpi-r3-bsp-5.15/blob/main/linux-mt/Documentation/networking/bonding.rst Example configuration for adding a second bond with two e1000 interfaces in active-backup mode, using ARP monitoring, to an init script. ```bash modprobe e1000 echo +bond1 > /sys/class/net/bonding_masters echo active-backup > /sys/class/net/bond1/bonding/mode ifconfig bond1 192.168.2.1 netmask 255.255.255.0 up echo +192.168.2.100 /sys/class/net/bond1/bonding/arp_ip_target echo 2000 > /sys/class/net/bond1/bonding/arp_interval echo +eth2 > /sys/class/net/bond1/bonding/slaves echo +eth3 > /sys/class/net/bond1/bonding/slaves ``` -------------------------------- ### Install XED Tool Source: https://github.com/bpi-sinovoip/bpi-r3-bsp-5.15/blob/main/linux-mt/tools/perf/Documentation/build-xed.txt Clone the mbuild and xed repositories, build the xed tool, and install it locally. Ensure to run ldconfig and copy the example binary to the bin directory. ```bash $ git clone https://github.com/intelxed/mbuild.git mbuild $ git clone https://github.com/intelxed/xed $ cd xed $ ./mfile.py --share $ ./mfile.py examples $ sudo ./mfile.py --prefix=/usr/local install $ sudo ldconfig $ sudo cp obj/examples/xed /usr/local/bin ``` -------------------------------- ### Setup Vendor U-Boot Build Environment Source: https://github.com/bpi-sinovoip/bpi-r3-bsp-5.15/blob/main/u-boot-mt/doc/board/amlogic/libretech-cc.rst Download and set up the required old compilers and clone the vendor U-Boot repository for building bootloader components. ```bash $ wget https://releases.linaro.org/archive/13.11/components/toolchain/binaries/gcc-linaro-aarch64-none-elf-4.8-2013.11_linux.tar.xz $ wget https://releases.linaro.org/archive/13.11/components/toolchain/binaries/gcc-linaro-arm-none-eabi-4.8-2013.11_linux.tar.xz $ tar xvfJ gcc-linaro-aarch64-none-elf-4.8-2013.11_linux.tar.xz $ tar xvfJ gcc-linaro-arm-none-eabi-4.8-2013.11_linux.tar.xz $ export PATH=$PWD/gcc-linaro-aarch64-none-elf-4.8-2013.11_linux/bin:$PWD/gcc-linaro-arm-none-eabi-4.8-2013.11_linux/bin:$PATH $ git clone https://github.com/BayLibre/u-boot.git -b libretech-cc amlogic-u-boot $ cd amlogic-u-boot $ make libretech_cc_defconfig $ make $ export FIPDIR=$PWD/fip ``` -------------------------------- ### NCR53C8XX Module Installation with Options Source: https://github.com/bpi-sinovoip/bpi-r3-bsp-5.15/blob/main/linux-mt/Documentation/scsi/ncr53c8xx.rst Example of installing the ncr53c8xx driver module using insmod with options. This demonstrates using spaces as separators for options when defining a string variable. ```bash insmod ncr53c8xx.o ncr53c8xx="tags:4 sync:10 debug:0x200" ``` -------------------------------- ### Example udev install rules script Source: https://github.com/bpi-sinovoip/bpi-r3-bsp-5.15/blob/main/linux-mt/Documentation/admin-guide/aoe/examples.rst This shell script installs udev rules for AoE devices. It copies the rules file to the system's udev rules directory. ```shell #!/bin/sh cp udev.rules /etc/udev/rules.d/50-aoe.rules udevadm control --reload-rules ``` -------------------------------- ### Create and Start OrangeFS Server (Distribution Packages) Source: https://github.com/bpi-sinovoip/bpi-r3-bsp-5.15/blob/main/linux-mt/Documentation/filesystems/orangefs.rst Creates a filesystem, starts the OrangeFS server, and tests its connectivity. ```bash pvfs2-server -f /etc/orangefs/orangefs.conf ``` ```bash systemctl start orangefs-server ``` ```bash pvfs2-ping -m /pvfsmnt ``` -------------------------------- ### Typical Firmware Workflow Example Source: https://github.com/bpi-sinovoip/bpi-r3-bsp-5.15/blob/main/linux-mt/Documentation/driver-api/firmware/request_firmware.rst Illustrates the common pattern of requesting firmware, copying it to the device, and then releasing the firmware entry. Ensure firmware is requested before use and released afterward. ```c if(request_firmware(&fw_entry, $FIRMWARE, device) == 0) copy_fw_to_device(fw_entry->data, fw_entry->size); release_firmware(fw_entry); ``` -------------------------------- ### Runtime Pin Muxing Example Source: https://github.com/bpi-sinovoip/bpi-r3-bsp-5.15/blob/main/linux-mt/Documentation/driver-api/pin-control.rst This example demonstrates how to dynamically switch a function between different pin groups at runtime. It requires setup in the probe function and selection in a runtime function. ```c #include struct pinctrl *p; struct pinctrl_state *s1, *s2; foo_probe() { /* Setup */ p = devm_pinctrl_get(&device); if (IS_ERR(p)) ... s1 = pinctrl_lookup_state(foo->p, "pos-A"); if (IS_ERR(s1)) ... s2 = pinctrl_lookup_state(foo->p, "pos-B"); if (IS_ERR(s2)) ... } foo_switch() { /* Enable on position A */ ret = pinctrl_select_state(s1); if (ret < 0) ... ... /* Enable on position B */ ret = pinctrl_select_state(s2); if (ret < 0) ... ... } ``` -------------------------------- ### seq_file start() iterator function example Source: https://github.com/bpi-sinovoip/bpi-r3-bsp-5.15/blob/main/linux-mt/Documentation/filesystems/seq_file.rst This C code snippet demonstrates the start() function for a seq_file iterator. It allocates memory for the position and initializes it, preparing for the iteration process. ```c static void *ct_seq_start(struct seq_file *s, loff_t *pos) { loff_t *spos = kmalloc(sizeof(loff_t), GFP_KERNEL); if (! spos) ``` -------------------------------- ### Bootstrap and Start OrangeFS Server (Source Build) Source: https://github.com/bpi-sinovoip/bpi-r3-bsp-5.15/blob/main/linux-mt/Documentation/filesystems/orangefs.rst Starts the OrangeFS server using the generated configuration file. ```bash /opt/ofs/sbin/pvfs2-server -f /etc/pvfs2.conf ``` ```bash /opt/ofs/sbin/pvfs2-server /etc/pvfs2.conf ``` -------------------------------- ### Example 'make help' Output Source: https://github.com/bpi-sinovoip/bpi-r3-bsp-5.15/blob/main/linux-mt/Documentation/sh/new-machine.rst Illustrates how a new board's defconfig target appears in the 'make help' output after successful integration into the build system. ```text Architecture specific targets (sh): ======================= ============================================= zImage Compressed kernel image (arch/sh/boot/zImage) adx_defconfig Build for adx cqreek_defconfig Build for cqreek dreamcast_defconfig Build for dreamcast ... vapor_defconfig Build for vapor ======================= ============================= ``` -------------------------------- ### TI Divider Clock Example 1 Source: https://github.com/bpi-sinovoip/bpi-r3-bsp-5.15/blob/main/linux-mt/Documentation/devicetree/bindings/clock/ti/divider.txt Example of a TI divider clock configuration for dpll_usb_m2_ck. It uses a standard divider with index starting at one and a maximum divisor of 127. ```dts dpll_usb_m2_ck: dpll_usb_m2_ck@4a008190 { #clock-cells = <0>; compatible = "ti,divider-clock"; clocks = <&dpll_usb_ck>; ti,max-div = <127>; reg = <0x190>; ti,index-starts-at-one; }; ``` -------------------------------- ### Launch QEMU with Kernel, Initrd, and SMP Source: https://github.com/bpi-sinovoip/bpi-r3-bsp-5.15/blob/main/u-boot-mt/doc/board/emulation/qemu-x86.rst Launch QEMU with kernel, initrd, and SMP options specified on the command line, leveraging QEMU's firmware interface. ```bash qemu-system-i386 -nographic -bios path/to/u-boot.rom -m 1024 \ -kernel /path/to/bzImage -append 'root=/dev/ram console=ttyS0' \ -initrd /path/to/initrd -smp 8 ``` -------------------------------- ### Example Usage Source: https://github.com/bpi-sinovoip/bpi-r3-bsp-5.15/blob/main/linux-mt/tools/lib/traceevent/Documentation/libtraceevent-page_size.txt Demonstrates how to set and get the page size using tep_set_page_size and tep_get_page_size. ```c #include #include ... struct tep_handle *tep = tep_alloc(); ... int page_size = getpagesize(); tep_set_page_size(tep, page_size); printf("The page size for this machine is %d\n", tep_get_page_size(tep)); ... ``` -------------------------------- ### Boot GRUB EFI from FIT Image using bootm Source: https://github.com/bpi-sinovoip/bpi-r3-bsp-5.15/blob/main/u-boot-mt/doc/develop/uefi/uefi.rst Example session showing how to load a FIT image and boot a GRUB EFI application using the 'bootm' command with a specific configuration. ```shell => load mmc 0:1 ${kernel_addr_r} image.fit 4620426 bytes read in 83 ms (53.1 MiB/s) => bootm ${kernel_addr_r}#config-grub-nofdt ## Loading kernel from FIT Image at 40400000 ... Using 'config-grub-nofdt' configuration Verifying Hash Integrity ... sha256,rsa2048:dev+ OK Trying 'efi-grub' kernel subimage Description: GRUB EFI Firmware Created: 2019-11-20 8:18:16 UTC Type: Kernel Image (no loading done) Compression: uncompressed Data Start: 0x404000d0 Data Size: 450560 Bytes = 440 KiB Hash algo: sha256 Hash value: 4dbee00021112df618f58b3f7cf5e1595533d543094064b9ce991e8b054a9eec Verifying Hash Integrity ... sha256+ OK XIP Kernel Image (no loading done) ## Transferring control to EFI (at address 404000d0) ... Welcome to GRUB! ``` -------------------------------- ### Get Multiple Regulators Source: https://github.com/bpi-sinovoip/bpi-r3-bsp-5.15/blob/main/linux-mt/Documentation/power/regulator/consumer.rst Example of obtaining access to multiple regulators for different supplies. ```c digital = regulator_get(dev, "Vcc"); /* digital core */ analog = regulator_get(dev, "Avdd"); /* analog */ ``` -------------------------------- ### Example: Boot Method Listing After Reordering Source: https://github.com/bpi-sinovoip/bpi-r3-bsp-5.15/blob/main/u-boot-mt/doc/usage/cmd/bootmeth.rst Shows the output of 'bootmeth list' after the boot method order has been changed to include only 'sandbox' and 'distro'. ```text Order Seq Name Description ----- 0 3 sandbox Sandbox boot for testing 1 0 distro Syslinux boot from a block device ----- (2 bootmeths) ``` -------------------------------- ### Using traceputs for Start and End Markers Source: https://github.com/bpi-sinovoip/bpi-r3-bsp-5.15/blob/main/linux-mt/Documentation/trace/histogram.rst This example shows how to use the traceputs function to mark the start and end of a timed operation. It is often used in conjunction with clock_nanosleep for precise timing. ```c traceputs("start"); clock_nanosleep(...); traceputs("end"); ``` -------------------------------- ### Palmas Device Tree Configuration Example Source: https://github.com/bpi-sinovoip/bpi-r3-bsp-5.15/blob/main/linux-mt/Documentation/devicetree/bindings/mfd/palmas.txt This example shows a typical Device Tree node for a Palmas PMIC, including compatible devices, interrupt controller setup, and optional muxing properties. ```dts palmas { compatible = "ti,twl6035", "ti,palmas"; reg = <0x48> interrupt-parent = <&intc>; interrupt-controller; #interrupt-cells = <2>; ti,mux-pad1 = <0>; ti,mux-pad2 = <0>; #address-cells = <1>; #size-cells = <0>; pmic { compatible = "ti,twl6035-pmic", "ti,palmas-pmic"; .... }; } ```