This shows you the differences between two versions of the page.
|
lkd:laboratoare:01 [2024/07/07 16:03] daniel.baluta |
lkd:laboratoare:01 [2024/07/08 15:18] (current) daniel.baluta |
||
|---|---|---|---|
| Line 15: | Line 15: | ||
| ==== Presentation ==== | ==== Presentation ==== | ||
| - | * follow slides at [[session 1]] | + | * follow slides at {{:lkd:laboratoare:lkd_01.pdf| Session 1}} |
| ==== Practical lab ==== | ==== Practical lab ==== | ||
| Line 96: | Line 95: | ||
| </code> | </code> | ||
| - | And then hit ''Reset' button on the board. | + | And then hit ''Reset'' button on the board. |
| Line 106: | Line 105: | ||
| {{:lkd:laboratoare:boot_run.png?736x356}} | {{:lkd:laboratoare:boot_run.png?736x356}} | ||
| + | |||
| + | <note important>Use user ''root'' and password ''root'' to login on Linux running on the board </note> | ||
| + | === 4. Make a change in the Linux kernel === | ||
| + | |||
| + | Go to the Linux kernel source root tree and modify a file. | ||
| + | |||
| + | <code bash> | ||
| + | $ cd ~/work/nss-linux | ||
| + | |||
| + | $ vim ~/work/arch/arm64/kernel/setup.c | ||
| + | |||
| + | </code> | ||
| + | |||
| + | Add a simple print like in the following patch | ||
| + | |||
| + | <code c> | ||
| + | --- a/arch/arm64/kernel/setup.c | ||
| + | +++ b/arch/arm64/kernel/setup.c | ||
| + | @@ -90,6 +90,8 @@ void __init smp_setup_processor_id(void) | ||
| + | |||
| + | pr_info("Booting Linux on physical CPU 0x%010lx [0x%08x]\n", | ||
| + | (unsigned long)mpidr, read_cpuid_id()); | ||
| + | + | ||
| + | + pr_info("Hello from Embedded Linux Summer School\n"); | ||
| + | } | ||
| + | |||
| + | </code> | ||
| + | |||
| + | Now recompile the kernel. You can go back and read [[#compile_the_linux_kernel | 2. Compile the Linux kernel]]. Sequence for recompiling the kernel is as simple as: | ||
| + | |||
| + | <code bash> | ||
| + | |||
| + | $ cd ~/work/nss-linux | ||
| + | $ source ~/work/scripts/setenv.sh | ||
| + | $ make -j8 | ||
| + | |||
| + | </code> | ||
| + | |||
| + | Boot script ''~/work/scripts/uuu_script'' will use your newly compiled Linux kernel image. So there is no need to change anything after your recompiled the kernel. Just follow again the steps in section [[#boot_the_board |3. Boot the board ]]! | ||
| + | |||
| + | Now, with the new boot image notice the new logs on the console: | ||
| + | |||
| + | <code bash> | ||
| + | |||
| + | [ 0.000000] Booting Linux on physical CPU 0x0000000000 [0x410fd034] | ||
| + | [ 0.000000] Hello from Embedded Linux Summer School | ||
| + | [ 0.000000] Linux version 6.1.55-ga5f70b9823b6-dirty (student@nss) | ||
| + | [ 0.000000] Machine model: TechNexion PICO-IMX8MQ and PI baseboard | ||
| + | |||
| + | </code> | ||
| + | |||
| + | === 5. Make a change in the rootfs === | ||
| + | |||
| + | rootfs (or the root file system) is the filesystem that is mounted at ''/'' (root of the hierarchy) and contains all the files necessary for the operating system to boot and run. | ||
| + | |||
| + | <code bash> | ||
| + | # ls / | ||
| + | bin home lost+found proc srv var | ||
| + | boot lib media root sys | ||
| + | dev lib64 mnt run tmp | ||
| + | etc linuxrc opt sbin usr | ||
| + | </code> | ||
| + | |||
| + | In our setup, the rootfs used to boot the board can be found in ''~/work/images/rootfs.ext2''. Use the following instructions that add one of your own files into the root filesystem. | ||
| + | |||
| + | <code bash> | ||
| + | $ cd ~/work/images | ||
| + | # make a backup of the initial root filesystem | ||
| + | $ cp rootfs.ext2 rootfs.ext2.back | ||
| + | $ sudo mkdir /mnt/my_root | ||
| + | $ sudo mount -o loop rootfs.ext2 /mnt/my_root | ||
| + | |||
| + | # explore the contents of /mnt/my_root directory and notice that these are the exact files that you can find on the board | ||
| + | |||
| + | # create your own file | ||
| + | $ sudo touch /mnt/my_root/root/my_file | ||
| + | |||
| + | # unmount the filesystem | ||
| + | |||
| + | $ sudo umount /mnt/my_root | ||
| + | </code> | ||
| + | |||
| + | Now boot the board and notice that the file you created exists on the board! Follow the steps in section [[#boot_the_board |3. Boot the board ]]! | ||
| + | |||
| + | === 5. Explore the board === | ||
| + | |||
| + | After booting the board and getting the prompt explore the hardware board capabilities. | ||
| + | |||
| + | Check the current Linux kernel version: | ||
| + | <code bash> | ||
| + | $ cat /proc/version | ||
| + | </code> | ||
| + | |||
| + | Check the command line arguments used to start the Linux kernel: | ||
| + | <code bash> | ||
| + | |||
| + | $ cat /proc/cmdline | ||
| + | |||
| + | </code> | ||
| + | |||
| + | List all the cpus in the system: | ||
| + | <code bash> | ||
| + | |||
| + | $ cat /proc/cpuinfo | ||
| + | </code> | ||
| + | |||
| + | List all available free and used physical memory in the system. | ||
| + | |||
| + | <code bash> | ||
| + | $ free -h | ||
| + | |||
| + | </code> | ||
| + | |||
| + | List the physical memory map for the system: | ||
| + | |||
| + | <code bash> | ||
| + | |||
| + | $ cat /proc/iomem | ||
| + | </code> | ||
| + | |||
| + | Notice the address range for ''System RAM'' and for the rest of devices. | ||
| + | |||
| + | Check the current list of filesystems supported by the kernel: | ||
| + | |||
| + | <code bash> | ||
| + | |||
| + | $ cat /proc/filesystems | ||
| + | |||
| + | </code> | ||
| + | |||
| + | Check the current list of modules loaded in the system: | ||
| + | |||
| + | <code bash> | ||
| + | |||
| + | $ cat /proc/modules | ||
| + | |||
| + | </code> | ||
| + | |||
| + | Finally check the kernel log: | ||
| + | |||
| + | <code bash> | ||
| + | |||
| + | $ dmesg | ||
| + | |||
| + | </code> | ||
| + | |||
| + | |||
| + | |||