Differences

This shows you the differences between two versions of the page.

Link to this comparison view

ass:laboratoare:04:tasks:01 [2023/07/22 01:42]
radu.mantu created
ass:laboratoare:04:tasks:01 [2024/08/09 18:48] (current)
florin.stancu [01. Preparation]
Line 23: Line 23:
 <spoiler kernel_fdt.patch>​ <spoiler kernel_fdt.patch>​
 <code diff> <code diff>
-diff --git a/​arch/​arm64/​boot/​dts/​freescale/​imx8mq-pico-pi.dts ​b/​arch/​arm64/​boot/​dts/​freescale/​imx8mq-pico-pi.dts +diff --git i/​arch/​arm64/​boot/​dts/​freescale/​imx8mq-pico-pi.dts ​w/​arch/​arm64/​boot/​dts/​freescale/​imx8mq-pico-pi.dts 
-index 89cbec5c41b2..3fe7f3713e4b ​100644 +index 89cbec5c4..e15b104d6 ​100644 
---- a/​arch/​arm64/​boot/​dts/​freescale/​imx8mq-pico-pi.dts +--- i/​arch/​arm64/​boot/​dts/​freescale/​imx8mq-pico-pi.dts 
-+++ b/​arch/​arm64/​boot/​dts/​freescale/​imx8mq-pico-pi.dts ++++ w/​arch/​arm64/​boot/​dts/​freescale/​imx8mq-pico-pi.dts 
-@@ -19,6 +19,25 @@ chosen ​+@@ -35,6 +35,13 @@ reg_usb_otg_vbus:​ regulator-usb-otg-vbus ​
-  stdout-path = &uart1;+  regulator-max-microvolt = <​5000000>;​ 
 + ​ gpio ​<&gpio3 14 GPIO_ACTIVE_LOW>​;
   };   };
- ++
 + firmware { + firmware {
 + optee { + optee {
Line 37: Line 38:
 + }; + };
 + }; + };
-+ }
-+ leds { +  
-+ compatible = "​gpio-leds"​+ &fec1 
-+ pinctrl-names = "​default";​ +@@ -80,6 +87,7 @@ buck1: BUCK1 {
-+
-+ led { +
-+ label = "​gpio-led";​ +
-+ pintctrl-0 = <&pinctrl_led>;​ +
-+ gpios = <&​gpio5 5 0>; +
-+ linux,​default-trigger = "​heartbeat";​ +
-+ }; +
-+ }; +
-+
- ​ pmic_osc:​ clock-pmic ​{ +
- ​ compatible = "​fixed-clock";​ +
- ​ #​clock-cells = <0>; +
-@@ -80,6 +99,7 @@ buck1: BUCK1 {+
  ​ regulator-min-microvolt = <​700000>;​  ​ regulator-min-microvolt = <​700000>;​
  ​ regulator-max-microvolt = <​1300000>;​  ​ regulator-max-microvolt = <​1300000>;​
Line 61: Line 49:
  ​ rohm,​dvs-run-voltage = <​900000>;​  ​ rohm,​dvs-run-voltage = <​900000>;​
  ​ rohm,​dvs-idle-voltage = <​850000>;​  ​ rohm,​dvs-idle-voltage = <​850000>;​
-@@ -91,6 +111,7 @@ buck2: BUCK2 {+@@ -91,6 +99,7 @@ buck2: BUCK2 {
  ​ regulator-min-microvolt = <​700000>;​  ​ regulator-min-microvolt = <​700000>;​
  ​ regulator-max-microvolt = <​1300000>;​  ​ regulator-max-microvolt = <​1300000>;​
Line 69: Line 57:
  ​ rohm,​dvs-run-voltage = <​1000000>;​  ​ rohm,​dvs-run-voltage = <​1000000>;​
  ​ rohm,​dvs-idle-voltage = <​900000>;​  ​ rohm,​dvs-idle-voltage = <​900000>;​
-@@ -101,6 +122,7 @@ buck3: BUCK3 {+@@ -101,6 +110,7 @@ buck3: BUCK3 {
  ​ regulator-min-microvolt = <​700000>;​  ​ regulator-min-microvolt = <​700000>;​
  ​ regulator-max-microvolt = <​1300000>;​  ​ regulator-max-microvolt = <​1300000>;​
Line 77: Line 65:
   };   };
    
-@@ -109,6 +131,7 @@ buck4: BUCK4 {+@@ -109,6 +119,7 @@ buck4: BUCK4 {
  ​ regulator-min-microvolt = <​700000>;​  ​ regulator-min-microvolt = <​700000>;​
  ​ regulator-max-microvolt = <​1300000>;​  ​ regulator-max-microvolt = <​1300000>;​
Line 85: Line 73:
   };   };
    
-@@ -117,6 +140,7 @@ buck5: BUCK5 {+@@ -117,6 +128,7 @@ buck5: BUCK5 {
  ​ regulator-min-microvolt = <​700000>;​  ​ regulator-min-microvolt = <​700000>;​
  ​ regulator-max-microvolt = <​1350000>;​  ​ regulator-max-microvolt = <​1350000>;​
Line 93: Line 81:
    
  ​ buck6:​ BUCK6 {  ​ buck6:​ BUCK6 {
-@@ -124,6 +148,7 @@ buck6: BUCK6 {+@@ -124,6 +136,7 @@ buck6: BUCK6 {
  ​ regulator-min-microvolt = <​3000000>;​  ​ regulator-min-microvolt = <​3000000>;​
  ​ regulator-max-microvolt = <​3300000>;​  ​ regulator-max-microvolt = <​3300000>;​
Line 101: Line 89:
    
  ​ buck7:​ BUCK7 {  ​ buck7:​ BUCK7 {
-@@ -131,6 +156,7 @@ buck7: BUCK7 {+@@ -131,6 +144,7 @@ buck7: BUCK7 {
  ​ regulator-min-microvolt = <​1605000>;​  ​ regulator-min-microvolt = <​1605000>;​
  ​ regulator-max-microvolt = <​1995000>;​  ​ regulator-max-microvolt = <​1995000>;​
Line 109: Line 97:
    
  ​ buck8:​ BUCK8 {  ​ buck8:​ BUCK8 {
-@@ -138,6 +164,7 @@ buck8: BUCK8 {+@@ -138,6 +152,7 @@ buck8: BUCK8 {
  ​ regulator-min-microvolt = <​800000>;​  ​ regulator-min-microvolt = <​800000>;​
  ​ regulator-max-microvolt = <​1400000>;​  ​ regulator-max-microvolt = <​1400000>;​
Line 117: Line 105:
    
  ​ ldo1:​ LDO1 {  ​ ldo1:​ LDO1 {
-@@ -161,6 +188,7 @@ ldo3: LDO3 {+@@ -161,6 +176,7 @@ ldo3: LDO3 {
  ​ regulator-min-microvolt = <​1800000>;​  ​ regulator-min-microvolt = <​1800000>;​
  ​ regulator-max-microvolt = <​3300000>;​  ​ regulator-max-microvolt = <​3300000>;​
Line 125: Line 113:
    
  ​ ldo4:​ LDO4 {  ​ ldo4:​ LDO4 {
-@@ -168,6 +196,7 @@ ldo4: LDO4 {+@@ -168,6 +184,7 @@ ldo4: LDO4 {
  ​ regulator-min-microvolt = <​900000>;​  ​ regulator-min-microvolt = <​900000>;​
  ​ regulator-max-microvolt = <​1800000>;​  ​ regulator-max-microvolt = <​1800000>;​
Line 133: Line 121:
    
  ​ ldo5:​ LDO5 {  ​ ldo5:​ LDO5 {
-@@ -175,6 +204,7 @@ ldo5: LDO5 {+@@ -175,6 +192,7 @@ ldo5: LDO5 {
  ​ regulator-min-microvolt = <​1800000>;​  ​ regulator-min-microvolt = <​1800000>;​
  ​ regulator-max-microvolt = <​3300000>;​  ​ regulator-max-microvolt = <​3300000>;​
Line 141: Line 129:
    
  ​ ldo6:​ LDO6 {  ​ ldo6:​ LDO6 {
-@@ -182,6 +212,7 @@ ldo6: LDO6 {+@@ -182,6 +200,7 @@ ldo6: LDO6 {
  ​ regulator-min-microvolt = <​900000>;​  ​ regulator-min-microvolt = <​900000>;​
  ​ regulator-max-microvolt = <​1800000>;​  ​ regulator-max-microvolt = <​1800000>;​
Line 149: Line 137:
    
  ​ ldo7:​ LDO7 {  ​ ldo7:​ LDO7 {
-@@ -189,6 +220,7 @@ ldo7: LDO7 {+@@ -189,6 +208,7 @@ ldo7: LDO7 {
  ​ regulator-min-microvolt = <​1800000>;​  ​ regulator-min-microvolt = <​1800000>;​
  ​ regulator-max-microvolt = <​3300000>;​  ​ regulator-max-microvolt = <​3300000>;​
Line 157: Line 145:
   };   };
   };   };
-@@ -415,4 +447,10 @@ pinctrl_wdog:​ wdoggrp { +
- ​ MX8MQ_IOMUXC_GPIO1_IO02_WDOG1_WDOG_B 0xc6 +
- ​ >;​ +
-  }; +
-+
-+ pinctrl_led:​ ledggrp { +
-+ fsl,pins = < +
-+ MX8MQ_IOMUXC_SPDIF_EXT_CLK_GPIO5_IO5 0x19 +
-+ >; +
-+ }; +
- };+
 </​code>​ </​code>​
 </​spoiler>​ </​spoiler>​
Line 197: Line 175:
 === Task B - The rootfs === === Task B - The rootfs ===
  
-For this lab we want to be able to easily transfer files to our boards. We are going to achieve this via SSH, so include ​ ''​BR2_PACKAGE_OPENSSH''​ in your build configuration. Additionally,​ we want to place a configuration file for the SSH daemon (i.e. **sshd**) at ''/​etc/​ssh/​sshd_config''​. In order to achieve this, we are going to use a //rootfs overlay//. Essentially,​ we are going to specify the absolute path to a certain directory+For this lab we want to be able to easily transfer files to our boards. We are going to achieve this via SSH, so include ​ ''​BR2_PACKAGE_OPENSSH''​ in your BuildRoot'​s ''​.config''​ 
 + 
 +Additionally,​ we want to place a configuration file for the SSH daemon (i.e. **sshd**) at ''/​etc/​ssh/​sshd_config'' ​(this is required to allow //root// login with password). In order to achieve this, we are going to use a //rootfs overlay//. Essentially,​ we are going to specify the absolute path to a certain directory ​(we'll call it ''​overlay/''​). After BuildRoot finishes creating the rootfs in its staging directory, it will take the contents of our overlay and copy it over, overwriting any pre-existing instance of a file. 
 + 
 +<code bash> 
 +# create the overlay directory + intermediate dirs between / and sshd_config 
 +[student@host ~/​buildroot]$ mkdir -p overlay/​etc/​ssh 
 + 
 +# copy existing sshd_config (from openssh package) 
 +[student@host ~/​buildroot]$ cp /​etc/​ssh/​sshd_config overlay/​etc/​ssh 
 + 
 +# TODO: make sure the following settings are uncommented and have the right value 
 +#   ​PermitRootLogin yes 
 +#   ​PasswordAuthentication yes 
 +</​code>​ 
 + 
 +Next, set the absolute path to ''​buildroot/​overlay/''​ to the ''​BR2_ROOTFS_OVERLAY''​ config variable. Then, recompile the CPIO archive. 
 + 
 +<​note>​ 
 +Make sure you have the **coreutils**,​ **openssh**,​ **iproute2** and **vim** packages installed! 
 +</​note>​ 
 + 
 +=== Task C - Persistent storage configuration over UMS === 
 + 
 +For this task we are going to make our current configuration persistent. The first step is to boot (as we normally do) to **bl33**, and get the U-Boot shell. From there, we are going to expose the 16GB eMMC memory on the board as an external storage device to our host computer. This means that we can format it and copy files directly once mounted. 
 + 
 +== Step 1: eMMC partitioning == 
 + 
 +Some of you may already have the following disk setup. If that's the case, you can move on. 
 + 
 +Our immediate goal is to create two partitions. One will hold a FIT image containing the kernel and FDT (but no ramdisk) from which we are going to boot Linux. The second will represent the root filesystem and will contain everything that BuildRoot generated. Between the partition table and the first partition we are going to leave ~10MB of unused space for later use. 
 + 
 +<code bash> 
 +# expose eMMC via UMS 
 +u-boot=> ums mmc 0 
 + 
 +# check on you host what the newly discovered device is called 
 +# from this point on, assuming it's called /dev/sdb 
 +[student@host ~]$ dmesg 
 +[student@host ~]$ lsblk 
 + 
 +# format the external eMMC storage device 
 +[student@host ~]$ fdisk /dev/sdb 
 + 
 +# create a fresh MBR partition table 
 +(fdisk) o 
 + 
 +# create a 100MB partition starting at 10MB offset 
 +(fdisk) n 
 +Partition type: p 
 +Partition number: 1 
 +First sector: 20480       # not the default value! 
 +Last sector: +100M 
 + 
 +# print the current partition table; check out end sector of partition 1! 
 +(fdisk) p 
 +Device ​    Boot Start    End Sectors ​ Size Id Type 
 +/​dev/​sdb1 ​      20480 225279 ​ 204800 ​ 100M 83 Linux 
 + 
 +# create a second partition, to take up the rest of the space 
 +(fdisk) n 
 +Partition type: p 
 +Partition number: 2 
 +First sector: 225290 
 +Last sector: <​Enter>​ 
 + 
 +# write changes to disk 
 +(fdisk) w 
 + 
 +# format partition 1 as FAT32 & partition 2 as ext4 
 +[student@host ~]$ sudo mkfs.fat -F 32 /dev/sdb1 
 +[student@host ~]$ sudo mkfs.ext4 /dev/sdb2 
 + 
 +# copy FIT image (without ramdisk!) to FAT32 partition 
 +[student@host ~/staging]$ sudo mount /dev/sdb1 /mnt 
 +[student@host ~/staging]$ sudo cp linux.itb /mnt 
 +[student@host ~/staging]$ sudo umount /mnt 
 + 
 +# extract rootfs CPIO contents onto ext4 partition 
 +# NOTE: ext4 required in order to support symlinks 
 +[student@host ~/​buildroot]$ sudo mount /dev/sdb2 /mnt 
 +[student@host ~/​buildroot]$ sudo cpio -i -D /mnt -F output/​images/​rootfs.cpio 
 +[student@host ~/staging]$ sudo umount /mnt 
 +</​code>​ 
 + 
 +== Step 2: Automatic boot to Linux == 
 + 
 +Next, we want to set up **bl33** to boot automatically. For this, we need to configure a number of commands to run by default. Add the following commands (separated by '';''​ instead of new line) to the ''​CONFIG_BOOTCOMMAND''​ variable in U-Boot'​s config. 
 + 
 +<​code>​ 
 +fatload mmc 0:1 0x80000000 linux.itb 
 +setenv bootargs console=ttymxc0,​115200,​115200 root=/​dev/​mmcblk0p2 rw clk_ignore_unused 
 +bootm 0x80000000 
 +</​code>​ 
 + 
 +Recompile U-Boot and regenerate the Firmware Image Package (i.e. ''​flash.bin''​). Next, we are going to copy the FIP on the eMMC, in the empty space between the MBR and the first partition. When doing an eMMC boot, the **bl1** bootrom will look for the FIP at a 33KB offset into the storage device. Same is true for an SD card boot. 
 + 
 +<code bash> 
 +# place the FIP onto the eMMC at 32KB offset from the start 
 +# NOTE: for other ARMv8 platforms, this offset could be 33KB; check the datasheet 
 +[student@host ~/​imx-mkimage/​iMX8M]$ dd if=flash.bin of=/dev/sda bs=1024 seek=32 conv=fsync oflag=direct status=progress 
 +</​code>​ 
 + 
 +Now change the jumpers on the board to perform an eMMC boot. 
 + 
 +=== Task D - Network configuration === 
 + 
 +About now you should have logged onto the board via the serial console. In this task we want to establish a network connection between your host and the board. For this to happen, we need to configure static IPs on the two network interfaces (since we don't have a DHCP server). Consider providing network connectivity for the board a bonus task ;) 
 + 
 +<code bash> 
 +# observe the ethernet interfaces 
 +# NOTE: usually named ethX, enpXsY, enoX, endX 
 +# NOTE: -c flag for color output from iproute2 
 +# NOTE: "addr show" can be abbreviated to "a s" 
 +[student@host ~]$ ip -c addr show 
 +2: enp60s0: <​BROADCAST,​MULTICAST,​UP,​LOWER_UP>​ mtu 1500 qdisc fq_codel state UP group default qlen 1000 
 +    link/ether 8c:​47:​be:​24:​bb:​61 brd ff:​ff:​ff:​ff:​ff:​ff 
 + 
 +[root@board ~]$ ip -c a s 
 +2: end0: <​BROADCAST,​MULTICAST>​ mtu 1500 qdisc noop state DOWN group default qlen 1000 
 +    link/ether 00:​1f:​7b:​65:​03:​3c brd ff:​ff:​ff:​ff:​ff:​ff 
 +     
 +# configure static IPs on each interface 
 +[student@host ~]$ ip addr add 192.168.101.1/​24 dev enp60s0 
 +[root@board ~]$   ip addr add 192.168.101.2/​24 dev end0 
 + 
 +# enable links 
 +[student@host ~]$ ip link set dev enp60s0 up 
 +[root@board ~]$   ip link set dev end0 up 
 + 
 +# add routing information 
 +[student@host ~]$ ip route add 192.168.101.0/​24 dev enp60s0 
 +[root@board ~]$   ip route add 192.168.101.0/​24 dev end0 
 + 
 +# ping the target 
 +[student@host ~]$ ping 192.168.101.2 
 + 
 +# connect to the target via SSH 
 +[root@board ~]$ systemctl status sshd 
 +[root@board ~]$ systemctl start sshd      # only if not already started 
 + 
 +[student@host ~]$ ssh root@192.168.101.2 
 +</​code>​
ass/laboratoare/04/tasks/01.1689979334.txt.gz · Last modified: 2023/07/22 01:42 by radu.mantu
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0