[{"content":"This guide is based heavily on the official guide from Variscite, with some additional info i found useful while learning this.\n1 Dependencies 1.1 Ubuntu 16.04 LTS \u0026amp; 18.04 LTS This tutorial was made with a machine running Ubuntu 18.04 LTS 64-bit, which worked almost flawless, though Variscite\u0026rsquo;s original tutorial is based on Ubuntu 16.04 64-bit.\nsudo apt-get install gawk wget git diffstat unzip texinfo gcc-multilib \\ build-essential chrpath socat cpio python python3 python3-pip python3-pexpect \\ xz-utils debianutils iputils-ping libsdl1.2-dev xterm sudo apt-get install autoconf libtool libglib2.0-dev libarchive-dev python-git \\ sed cvs subversion coreutils texi2html docbook-utils python-pysqlite2 \\ help2man make gcc g++ desktop-file-utils libgl1-mesa-dev libglu1-mesa-dev \\ mercurial automake groff curl lzop asciidoc u-boot-tools dos2unix mtd-utils pv \\ libncurses5 libncurses5-dev libncursesw5-dev libelf-dev zlib1g-dev 1.2 Ubuntu 20.04 LTS Compiling Yocto thud does not work on Ubuntu 20.04 LTS 64-bit. The GNU C library, or short glibc, is version 2.30 in Ubuntu 20.04, which is incompatible to glibc 2.29, which the bitbake command expects. This patch from OCtober 2019 in the OpenEmbedded Core Layer fixes this, but it hasn\u0026rsquo;t been implemented into the Variscite BSP for Yocto thud. The last update for the thud-fslc-4.14.78-mx7-v1.0 tag was in May 2019, so it probably won\u0026rsquo;t be updated anymore. Downgrading the glibc is not recommended, so you should compile it in a virtual machine or with docker.\n2 Download Yocto Thud based on Freescale Community BSP First we set up our git username and email. If you already set up git, you can skip this.\ngit config --global user.name \u0026#34;Your Name\u0026#34; git config --global user.email \u0026#34;Your Email\u0026#34; Next we are going to Download repo. repo is a layer on top of git to simplify some tasks.\ncurl http://commondatastorage.googleapis.com/git-repo-downloads/repo \u0026gt; /usr/local/bin/repo chmod a+x /usr/local/bin/repo or sudo apt install repo (This version could be older than the one you would download via curl)\nThen we are going to make our folder where all our development files will be located and switch to that folder.\nmkdir ~/dev/var-fslc-yocto Next you can either choose a specific release tag:\nrepo init -u https://github.com/varigit/variscite-bsp-platform.git -b refs/tags/TAG_NAME For example: repo init -u https://github.com/varigit/variscite-bsp-platform.git -b refs/tags/thud-fslc-4.14.78-mx7-v1.0 repo sync -j4 Or you choose the latest release, which is recommended:\nrepo init -u https://github.com/varigit/variscite-bsp-platform.git -b thud repo sync -j4 3 Setup and build Yocto 3.1 Supported images The following images are provided by Variscite for evaluation purpose:\nfsl-image-gui: Default Variscite demo image with GUI and without any Qt5 content. This image recipe works on all backends for X11, Frame Buffer and Wayland and the content is optimized to fit 512MB NAND flash. fsl-image-qt5: Extends fsl-image-gui image with Qt5 support and various Qt samples for X11, Frame Buffer and Wayland backends. Note: Will result in image size greater than 512 MB, which will not fit into NAND flash. Use SD card or eMMC to test.\nThe following images are provided by FSL Community BSP:\nfsl-image-machine-test: A console-only image that includes gstreamer packages and test and benchmark applications. fsl-image-mfgtool-initramfs: Small image to be used with Manufacturing Tool (mfg-tool) in a production environment. See the list of Yocto Project’s reference images in Yocto Project Reference Manual.\n3.2 Supported distros The following distros can be used:\nfslc-x11: Distro for X11 without wayland. This distro include x11 feature and doesn’ has wayland support. fslc-framebuffer: Distro for Framebuffer graphical backend. This distro doesn’t include X11 and wayland features. fslc-wayland: Distro for Wayland without X11. This distro includes wayland feature but doesn’t have x11 support. fslc-xwayland: Distro for Wayland with X11. This distro includes both wayland and X11 features. Note: Also standard Poky distros can be used\n3.3 Build X11 GUI demo image cd ~/var-fslc-yocto MACHINE=imx7-var-som DISTRO=fslc-x11 . setup-environment build_x11 The above command is only mandatory for the very first build setup: whenever restarting a newer build session (from a different terminal or in a different time), you can skip the full setup and just run:\ncd ~/var-fslc-yocto source setup-environment build_x11 Optionally you can customize the local.conf. See chapter 4\nlaunch bitbake:\nWithout Qt content:\nbitbake fsl-image-gui Or with Qt content:\nbitbake fsl-image-qt5 3.4 Build console-only demo image cd ~/var-fslc-yocto MACHINE=imx7-var-som DISTRO=fslc-framebuffer . setup-environment build_fb Optionally you can customize the local.conf. See chapter 4\nWithout Qt content:\nbitbake fsl-image-gui Or with Qt content:\nbitbake fsl-image-qt5 3.5 Forcing Clean Build In order to update the kernel, U-Boot and rootfs:\nbitbake -c cleanall u-boot-variscite linux-variscite kernel-module-imx-gpu-viv ti-compat-wireless-wl18xx wl18xx-firmware cryptodev-module for GUI image\nbitbake -c clean fsl-image-gui for Qt5 image\nbitbake -c clean fsl-image-qt5 4 Customization 4.1 Customize the Linux Kernel To customize the Linux Kernel, first, source the setup-environment script, f.e.:\nsource setup-environment build_x11 Then run menuconfig and configure the Kernel to your needs:\nbitbake -c menuconfig virtual/kernel When finished, save and exit.\nThe .config file is saved to ~/dev/var-fslc-yocto/build_x11/tmp/work/imx7_var_som-fslc-linux-gnueabi/linux-variscite/4.14.78-r0/build/.config\nAt this point, you can continue following the rest of step 4 of the Yocto Build Release page to build your image with the newly configured kernel, or just build the kernel by running \u0026ldquo;bitbake virtual/kernel\u0026rdquo;, or, you can follow the next steps to use this configuration permanently. To save the configuration in a defconfig format:\nbitbake -c savedefconfig virtual/kernel The defconfig file is saved to ~/dev/var-fslc-yocto/build_x11/tmp/work/imx7_var_som-fslc-linux-gnueabi/linux-variscite/4.14.78-r0/build/defconfig\nTo make the Kernel recipe use this configuration permanently, you copy it to another location and create a .bbappend file, which links the defconfig to the kernel recipe.\nCopy your defconfig:\ncd ~/dev/var-fslc-yocto/sources/meta-variscite-fslc/recipes-kernel/linux/ mkdir -p files cp ~/dev/var-fslc-yocto/build_x11/tmp/work/imx7_var_som-fslc-linux-gnueabi/linux-variscite/4.14.78-r0/build/defconfig files/my_defconfig Create a linux-variscite_4.14.78.bbappend file:\ngedit linux-variscite_4.14.78.bbappend and append the following to it:\nSRC_URI += \u0026#34;file://my_defconfig\u0026#34; KERNEL_DEFCONFIG_imx7-var-som = \u0026#34;${WORKDIR}/my_defconfig\u0026#34; 4.1 Use systemd instead of SysV init Append the following to the conf/local.conf file in your Yocto build directory, to use systemd instead of SysV init in your images:\nDISTRO_FEATURES_append = \u0026#34; systemd\u0026#34; VIRTUAL-RUNTIME_init_manager = \u0026#34;systemd\u0026#34; DISTRO_FEATURES_BACKFILL_CONSIDERED = \u0026#34;sysvinit\u0026#34; VIRTUAL-RUNTIME_initscripts = \u0026#34;\u0026#34; IMX_DEFAULT_DISTRO_FEATURES_append = \u0026#34; systemd\u0026#34; 4.2 Add additional packages 4.2.1 General Packages and package groups can be added to image recipes. See the Yocto Development manual for how to customize an image: http://www.yoctoproject.org/docs/current/dev-manual/dev-manual.html#usingpoky-extend-customimage-imagefeatures\n4.2.2 Adding a package to the local build of the BSP Search for the corresponding recipe and which layer the recipe is in. This link is a useful tool for doing so: http://layers.openembedded.org/layerindex/branch/morty/layers/\nIf the package is in the meta-openembedded layer, the recipe is already available in your build tree.\nAdd the following line to YOCTO_DIR/BUILD_DIR/conf/local.conf:\nIMAGE_INSTALL_append = \u0026quot; \u0026quot;\nNote: The leading white-space between the \u0026quot; and the package name is necessary for the append command.\nIf you need to add a layer to the BSP, clone or extract it to the YOCTO_DIR/sources/ directory. Then, modify YOCTO_DIR/BUILD_DIR/conf/bblayers.conf to include this new layer in BBLAYERS:\nBBLAYERS += \u0026ldquo;${BSPDIR}/sources/\u0026lt;new_layer\u0026gt;\u0026rdquo;\n3 Webserver support\nRecipes in meta-openembedded/meta-webserver/recipes-httpd:\napache2 cherokee hiawatha monkey nginx nostromo sthttpd Recipes in poky/meta/recipes-extended/lighttpd: lighttpd Although full of capabilities and features, Apache is commonly considered quite heavy, so is not generally used for embedded devices. Nostromo and sthttpd are commonly considered ultralight webserver, with a very small set of capabilities and features, with very limited resource requirements. The usual choice is usually between the following 5:\ncherokee hiawatha monkey nginx lighttpd Here you can find an article comparing the above 5 webserver: https://www.linux.com/news/which-light-weight-open-source-web-server-right-you 4 Accelerated browsers support\nYocto build system allow integrating browsers that support iMX6 GPU accelerations.\nThe common used browsers are:\nqtwebkit based browsers: QtWebKit is the WebKit porting to QT. WebKit is an open source web browser engine. QT5 provide some demo implementations in webkitwidgets examples. qtwebengine based browsers: QtWebEngine integrates chromium's fast moving web capabilities into QT. QT5 provide some demo implementations in webenginewidgets examples. chromium based browsers: Chromium is an open-source browser project. Till 2016, FSLC community maintained chromium-imx project: customized Chromium versions (up to v48) providing GPU and VPU integration for iMX6 CPUs.\nMuch more updated Chromium versions are available from meta-browser, only providing GPU integration.\nThe minimum requirements to use chromium browsers is X11 or Wayland.\nQT based browsers directly rely on QT integration with iMX6 accelerations.\nQtWebKit has been superseded by QtWebEngine, mainly because QtWebKit has not been actively synchronized with the upstream WebKit code since Qt 5.2 and has been deprecated in Qt 5.5. Further details are available in Qt WebEngine Overview\nQT team provides a QtWebEngine browser for embedded touch devices and related recipes hase been integrated in our BSP starting from Sumo.\nThe performance of each browser is strictly related to the features to be used, so different html applications can provide better performance with different browsers.\nThe following table try to summarize some benchmark for Wayland backend: website QtWebKit QtWebEngine Chromium http://peacekeeper.futuremark.com crash 623 n/a http://www.kevs3d.co.uk/dev/canvasmark n/a 4796 3780 http://webglsamples.org/blob/blob.html 2 fps 32 fps 34 fps 4.1 Add QtWebKit examples to the build\nAdd the following line to YOCTO_DIR/BUILD_DIR/conf/local.conf:\nIMAGE_INSTALL_append = \u0026quot; qtwebkit-examples-examples\u0026quot;\nThe demo browser used for the above tests is available as\n/usr/share/qt5/examples/webkitwidgets/fancybrowser/fancybrowser\n4.2 Add QtWebEngine examples to the build\nAdd the following line to YOCTO_DIR/BUILD_DIR/conf/local.conf:\nIMAGE_INSTALL_append = \u0026quot; qtwebengine-examples\u0026quot;\nThe demo browser used for the above tests is available as\n/usr/share/qt5/examples/webenginewidgets/fancybrowser/fancybrowser\n4.3 Add Chromium to the build\nAdd the following line to YOCTO_DIR/BUILD_DIR/conf/local.conf:\nIMAGE_INSTALL_append = \u0026quot; chromium\u0026quot; LICENSE_FLAGS_WHITELIST += \u0026ldquo;commercial_libav commercial_x264\u0026rdquo;\nIf you plan to use Chromium, please take care of the specific requirements for commercial license of libav and x264 packages.\nThe demo browser used for the above tests is available as\n/usr/bin/google-chrome 5 Create a bootable SD card 5.1 Yocto pre-built SD card The Yocto build products contains many files. For example, fsl-image-gui-imx7-var-som.wic.gz, depending on your build. This is a complete image to be flashed directly to an SD card.\nExample usage:\nsudo umount /dev/sdX* # For GUI-X11 \u0026amp; Qt5-X11 cd ~/var-fslc-yocto/build_x11 # Or # For Qt5-FB cd ~/var-fslc-yocto/build_fb # For fsl-image-gui image (GUI-X11) zcat tmp/deploy/images/imx7-var-som/fsl-image-gui-imx7-var-som.wic.gz | sudo dd of=/dev/sdX bs=1M \u0026amp;\u0026amp; sync # Or # For fsl-image-qt5 image (Qt5-X11 \u0026amp; Qt5-FB) zcat tmp/deploy/images/imx7-var-som/fsl-image-qt5-imx7-var-som.wic.gz | sudo dd of=/dev/sdX bs=1M \u0026amp;\u0026amp; sync Replace sdX with the right device name. This can be obtained by \u0026ldquo;dmesg\u0026rdquo; command on your host Linux PC, after the SD card reader is inserted.\nNote: Booting your system from an SD card requires pressing the boot-select button, or switching the relevant DIP switch to \u0026ldquo;Boot from SD card\u0026rdquo;, according to the relevant start-up guide of your system.\nDrawbacks of the native .wic.gz yocto-built image, (relative to the Recovery/Extended SD card):\nThe rootfs partition doesn\u0026rsquo;t use the entire SD card. The rootfs partition is not labeled as rootfs. The NAND flash and eMMC installation scripts and images are not included. ","permalink":"https://samsifpv.ch/wiki/building-yocto/","summary":"\u003cp\u003eThis guide is based heavily on the \u003ca href=\"http://variwiki.com/index.php?title=Yocto_Build_Release\u0026amp;release=RELEASE_THUD_V1.0_VAR-SOM-MX7\"\u003eofficial guide\u003c/a\u003e from \u003ca href=\"https://www.variscite.com\"\u003eVariscite\u003c/a\u003e, with some additional info i found useful while learning this.\u003c/p\u003e\n\u003ch2 id=\"1-dependencies\"\u003e1 Dependencies\u003c/h2\u003e\n\u003ch3 id=\"11-ubuntu-1604-lts--1804-lts\"\u003e1.1 Ubuntu 16.04 LTS \u0026amp; 18.04 LTS\u003c/h3\u003e\n\u003cp\u003eThis tutorial was made with a machine running Ubuntu 18.04 LTS 64-bit, which worked almost flawless, though Variscite\u0026rsquo;s original tutorial is based on Ubuntu 16.04 64-bit.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo apt-get install gawk wget git diffstat unzip texinfo gcc-multilib \\\nbuild-essential chrpath socat cpio python python3 python3-pip python3-pexpect \\\nxz-utils debianutils iputils-ping libsdl1.2-dev xterm\n\nsudo apt-get install autoconf libtool libglib2.0-dev libarchive-dev python-git \\\nsed cvs subversion coreutils texi2html docbook-utils python-pysqlite2 \\\nhelp2man make gcc g++ desktop-file-utils libgl1-mesa-dev libglu1-mesa-dev \\\nmercurial automake groff curl lzop asciidoc u-boot-tools dos2unix mtd-utils pv \\\nlibncurses5 libncurses5-dev libncursesw5-dev libelf-dev zlib1g-dev\n\u003c/code\u003e\u003c/pre\u003e\u003ch3 id=\"12-ubuntu-2004-lts\"\u003e1.2 Ubuntu 20.04 LTS\u003c/h3\u003e\n\u003cp\u003eCompiling Yocto thud does not work on Ubuntu 20.04 LTS 64-bit. The GNU C library, or short glibc, is version 2.30 in Ubuntu 20.04, which is incompatible to glibc 2.29, which the bitbake command expects. \u003ca href=\"https://patchwork.openembedded.org/patch/165581/\"\u003eThis patch\u003c/a\u003e from OCtober 2019 in the OpenEmbedded Core Layer fixes this, but it hasn\u0026rsquo;t been implemented into the Variscite BSP for Yocto thud. The last update for the thud-fslc-4.14.78-mx7-v1.0 tag was in May 2019, so it probably won\u0026rsquo;t be updated anymore. Downgrading the glibc is not recommended, so you should compile it in a virtual machine or with docker.\u003c/p\u003e","title":"Building a Linux Distro with Yocto for the Variscite MX7"},{"content":"Type: A Point subdomain.domain.com to a hard coded IP Address. Most direct and straight forward option, also note any change you make in your DNS program is reflected on the internet and made live immediately. The only way you will not see immediate results is if you have cached a query on your computer by looking it up PRIOR to configuring it in your DNS program.\nType: MX Point subdomain.domain.com to a mail server. These type of records are special for just mail servers, they can co-exist with A records, and their only use is for routing mail to a different location. All mail implementations check for this record first before attempting to route an e-mail message. If a MX record does not exist for a host, an e-mail delivery would be attempted directly to the IP that the hostname resolves to.\nType: AAAA Point subdomain.domain.com to a IPv6 address. Useful for those who are using IPv6 on their personal networks or those who are using a IPv4 to IPv6 tunnel at home.\nType: CNAME Point subdomain.domain.com to another hostname. Good for those who are using other dynamic DNS services. You can create a CNAME record to another host and whatever subdomain.domain.com you choose here will go to whatever IP address the CNAMEd host has.\nType: NS Point subdomain.domain.com to another NAMESERVER. If you choose this option, then whatever subdomain.domain.com address you choose will have to be configured and setup on the destination ADDRESS (nameserver) that you choose. This option basically means you are delegating a DNS host to another DNS server all together, so when you choose this option you are telling every computer on the internet to ask the \u0026lsquo;address\u0026rsquo; where subdomain.domain.com is located at. If the host you point an NS record to is not configured to answer for the subdomain.domain.com that you are using in your DNS program then the subdomain.domain.com host will not resolve.\nType: TXT Lets you create TXT records, used for a number of different things, most commonly for DKIM records (for combatting spam) so other receiving mail servers can verify email was sent from you by verifying your publically published crypto-signature.\nType: SPF A anti-spam record, good to have on any domain you\u0026rsquo;re sending email with. Not used anymore, use TXT records for SPF entries.\n","permalink":"https://samsifpv.ch/wiki/dns-entry-types/","summary":"\u003ch3 id=\"type-a\"\u003eType: A\u003c/h3\u003e\n\u003cp\u003ePoint subdomain.domain.com to a hard coded IP Address. Most direct and straight forward option, also note any change you make in your DNS program is reflected on the internet and made live immediately. The only way you will not see immediate results is if you have cached a query on your computer by looking it up PRIOR to configuring it in your DNS program.\u003c/p\u003e\n\u003ch3 id=\"type-mx\"\u003eType: MX\u003c/h3\u003e\n\u003cp\u003ePoint subdomain.domain.com to a mail server. These type of records are special for just mail servers, they can co-exist with A records, and their only use is for routing mail to a different location. All mail implementations check for this record first before attempting to route an e-mail message. If a MX record does not exist for a host, an e-mail delivery would be attempted directly to the IP that the hostname resolves to.\u003c/p\u003e","title":"Common DNS Entry Types"},{"content":"Use the file command first to get info about the possible compression. A tar archive has the filenames included in it at the top. You can determine that it is likely to be one of those formats by looking at the first few bytes. You should then test to see if it really is one of those, using an integrity check from the associated utility for that format, or by actually proceeding to decompress.\nYou can find the header formats in the descriptions:\nZip (.zip) format description, starts with 0x50, 0x4b, 0x03, 0x04 (unless empty — then the last two are 0x05, 0x06 or 0x06, 0x06) Gzip (.gz) format description, starts with 0x1f, 0x8b, 0x08 xz (.xz) format description, starts with 0xfd, 0x37, 0x7a, 0x58, 0x5a, 0x00 Others:\nzlib (.zz) format description, starts with two bytes (in bits) 0aaa1000 bbbccccc, where ccccc is chosen so that the first byte viewed as a int16 times 256 plus the second byte viewed as a int16 is a multiple of 31. e.g: 01111000(bits) = 120(int16), 10011100(bits) = 156(int16), 120 * 256 + 156 = 30876 which is a multiple of 31 compress (.Z) starts with 0x1f, 0x9d bzip2 (.bz2) starts with 0x42, 0x5a, 0x68 ","permalink":"https://samsifpv.ch/wiki/detect_compression_type/","summary":"\u003cp\u003eUse the file command first to get info about the possible compression.\nA tar archive has the filenames included in it at the top.\nYou can determine that it is likely to be one of those formats by looking at the first few bytes. You should then test to see if it really is one of those, using an integrity check from the associated utility for that format, or by actually proceeding to decompress.\u003c/p\u003e","title":"Detect compression type of a file"},{"content":"Edit the sudoers file\nsudo visudo # or vim /etc/sudoers After the entry #includedir /etc/sudoers.d add this:\n\u0026lt;username\u0026gt;\tALL=(ALL) NOPASSWD: ALL Save and exit, and you\u0026rsquo;re good to go!\n","permalink":"https://samsifpv.ch/wiki/passwordless-sudo/","summary":"\u003cp\u003eEdit the sudoers file\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo visudo\n# or\nvim /etc/sudoers\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eAfter the entry \u003ccode\u003e#includedir /etc/sudoers.d\u003c/code\u003e add this:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e\u0026lt;username\u0026gt;\tALL=(ALL) NOPASSWD: ALL\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eSave and exit, and you\u0026rsquo;re good to go!\u003c/p\u003e","title":"Give password-less sudo to a user"},{"content":"Base for this project is the Variscite VAR-SOM-MX7 together with its development board.\nGoal of this project is to get a speaker running over i2s on an embedded Linux system, and get a deeper understanding of the linux environment in general.\nFirst steps This guide assumes you already successfully compiled Yocto and have basic knowledge of navigating through an linux environment.\nThere are 2 things needed for this whole thing to work. First, Linux needs the driver for the Speaker/Microphone installed and loaded, so it can communicate with it. Second it needs to know where the Hardware is mapped to.\n1. Driver 1.1 Find the Driver First we check if the driver is already installed on the system. lsmod shows the currently loaded modules and is just a pretty view of the /proc/modules directory. If the driver isn\u0026rsquo;t listed there, there is still the possibility that the driver isn\u0026rsquo;t loaded. To see all modules, list the contents of the /sys/module directory with ls /sys/module. You can load the driver with modprobe \u0026lt;module-name\u0026gt;.\nTo see if the driver is statically built into the kernel we use cat /lib/modules/$(uname -r)/modules.builtin. This will give us a list of all the modules that statically built into the kernel and are not removable without switching the kernel.\nIf the required driver isn\u0026rsquo;t listed anywhere, it\u0026rsquo;s not in the kernel, and so we have to compile it. There are 2 ways to do that. We either bake it directly into the kernel, or we set it up as a Loadable Kernel Module (KVM), which we can load and unload whenever we want. This is recommended, since it doesn\u0026rsquo;t necessarily crash your kernel when a driver stops working, and you can load an updated module instead of recompiling the kernel, or unload it when you don\u0026rsquo;t need it.\n1.2 Compile the Driver To compile the kernel module or to bake the driver into the kernel we need the source files of our Yocto build. We assume you have set that up already.\nNow run the setup environment:\ncd ~/var-fslc-yocto MACHINE=imx7-var-som DISTRO=fslc-x11 . setup-environment build_x11 The above command is only mandatory for the very first build setup: whenever restarting a newer build session (from a different terminal or in a different time), you can skip the full setup and just run:\ncd ~/var-fslc-yocto source setup-environment build_x11 After that, run the menuconfig, this is used to configure the Linux kernel:\nbitbake -c menuconfig virtual/kernel This command will show a TUI (Terminal User Interface). In this we can configure our Linux kernel.\nNow to set our driver as a module or built-in, we have to go into the driver settings. First, got into Device Drivers.\nNext go to Sound card support.\nGo to Advanced Linux Sound Architecture (ALSA).\nFinally, open ALSA for SoC audio support.\nIn this menu, search for your driver. By pressing Y you include the driver in the kernel, N excludes it, and M sets it as a module.\nNote: You can also do these steps by editing the config file, which is located ~/var-fslc-yocto/build_x11/tmp/work-shared/imx7-var-som/kernel-source/arch/arm/configs/imx_v7_var_defconfig.\nNote: If your driver isn\u0026rsquo;t in the menuconfig, it is possible that is is just not shown. Check ~/var-fslc-yocto/build_x11/tmp/work-shared/imx7-var-som/kernel-source/driver/ or in my case ~/var-fslc-yocto/build_x11/tmp/work-shared/imx7-var-som/kernel-source/sound/soc/codecs/. If you find it under there, edit the Kconfig file in the same directory. Scroll to you specific driver, and add a description after tristate just like this:\nNow the driver will be compiled as a Kernel module. The Kernel will usually load the driver itself, if it finds it in the device tree. That will be the next thing to do, editing the device tree.\n2. Device tree The device tree is located under ~/var-fslc-yocto/build_x11/tmp/work-shared/imx7-var-som/kernel-source/arch/arm/boot/dts/. You can inspect the config to see which device tree files are used: ~/dev/var-fslc-yocto/sources/meta-variscite-fslc/conf/machine/imx7-var-som.conf. In our case it\u0026rsquo;s the imx7d-var-som.dtsi:\nvim ~/var-fslc-yocto/build_x11/tmp/work-shared/imx7-var-som/kernel-source/arch/arm/boot/dts/imx7d-var-som.dtsi We want to add another sound node, as well as a codec node for our max98357a driver. Just add another sound node like this:\nsound0:sound@0 { compatible = \u0026#34;simple-audio-card\u0026#34;; simple-audio-card,name = \u0026#34;max98357aaudio\u0026#34;; simple-audio-card,format = \u0026#34;i2s\u0026#34;; simple-audio-card,cpu { sound-dai = \u0026lt;\u0026amp;sai2 0\u0026gt;; }; simple-audio-card,codec { sound-dai = \u0026lt;\u0026amp;max98357a\u0026gt;; }; }; Note: The sound has to be placed under the root node /, That means in between the curly brackets {}.\nOur new sound node has the name sound, with the unit adress 0. We also set the label sound0, but since we dont refer to it, it is optional. Since now 2 nodes have the name sound, we need to change the existing sound node to sound@1.\nsound1: sound@1 { ... Now we add the the codec node, also under the root node:\nmax98357a: max98357a { #sound-dai-cells = \u0026lt;0\u0026gt;; compatible = \u0026#34;maxim,max98357a\u0026#34;; }; Finally, we need to activate our i2s node, since it\u0026rsquo;s disabled by default. This device tree names them sai (Serial Audio Interface). So search for the i2s interface you connected your driver to, in this case sai2, and change it\u0026rsquo;s status from disabled to okay.\n\u0026amp;sai2 { pinctrl-names = \u0026#34;default\u0026#34;; pinctrl-0 = \u0026lt;\u0026amp;pinctrl_sai2\u0026gt;; assigned-clocks = \u0026lt;\u0026amp;clks IMX7D_SAI2_ROOT_SRC\u0026gt;, \u0026lt;\u0026amp;clks IMX7D_SAI2_ROOT_CLK\u0026gt;; assigned-clock-parents = \u0026lt;\u0026amp;clks IMX7D_PLL_AUDIO_POST_DIV\u0026gt;; assigned-clock-rates = \u0026lt;0\u0026gt;, \u0026lt;36864000\u0026gt;; status = \u0026#34;okay\u0026#34;;\t//Set this to from disabled to okay }; This should be enough to get it working.\n3. Build Yocto Just compile the kernel and rebuild the project, and you\u0026rsquo;re done.\nbitbake virtual/kernel bitbake fsl-image-gui Note: With the -f option you can force a build.\n4. Check if everything works as intended After you successfully built your Yocto image, load the image onto your Board, and start it up. Open the terminal and check if the driver is loaded.\nlsmod lsmod shows the currently loaded modules and is just a pretty view of the /proc/modules directory. If the driver isn\u0026rsquo;t listed there, there is still the possibility that the driver isn\u0026rsquo;t loaded. To see all modules, list the contents of the /sys/module directory with ls /sys/module. You can load the driver with modprobe \u0026lt;module-name\u0026gt;. If your kernel module doesn\u0026rsquo;t show up anywhere, check again if you did your kernel configuration correctly, and if you compiled your kernel correctly.\nNow if that works, we need to check if ALSA detects our soundcard. we can check with aplay -l if our soundcard is detected. If not, check with dmesg for possible clues why it wasn\u0026rsquo;t detected.\n5. Play Music If everything is alright, then test your driver with speaker-test. Or play some music with a music player, like mplayer or mpv.\nThe End.\n","permalink":"https://samsifpv.ch/wiki/how-to-add-a-driver-to-yocto/","summary":"\u003cp\u003eBase for this project is the Variscite VAR-SOM-MX7 together with its development board.\u003c/p\u003e\n\u003cp\u003eGoal of this project is to get a speaker running over i2s on an embedded Linux system, and get a deeper understanding of the linux environment in general.\u003c/p\u003e\n\u003ch2 id=\"first-steps\"\u003eFirst steps\u003c/h2\u003e\n\u003cp\u003eThis guide assumes you already successfully compiled Yocto and have basic knowledge of navigating through an linux environment.\u003c/p\u003e\n\u003cp\u003eThere are 2 things needed for this whole thing to work. First, Linux needs the driver for the Speaker/Microphone installed and loaded, so it can communicate with it. Second it needs to know where the Hardware is mapped to.\u003c/p\u003e","title":"How to add a Speaker via i2s and enable it in Yocto"},{"content":"Windows 11 significantly raised its hardware requirements compared to Windows 10. Among the changes, it requires more RAM and storage space. It also requires a Trusted Platform Module (TPM) version 2.0 and a UEFI boot environment.\nGNOME Boxes doesn’t yet support TPM and UEFI environments. However, the underlying virtualization technology supports it. You just need to tweak a few configuration options along the way. Read the instructions carefully!\nInstall GNOME Boxes and its prerequisites Start by installing GNOME Boxes from your Linux distribution’s package repository. You cannot use the Flatpak/Flathub version as it doesn’t currently support emulating a TPM. The package is called gnome-boxes everywhere. You need version 40 or newer!\nInstall the TianoCore Open Virtual Machine Firmware (OVMF) from your package repository. This will let your VM boot as a modern secure boot-enabled UEFI system instead of a legacy BIOS system. The package is called edk2-ovmf in Fedora Linux 34 and ovmf Ubuntu 22.\nInstall the swtpm emulator (software TPM (SWTPM)) from your package repository. The package is called swtpm-tools in both Fedora Linux 34 and Ubuntu 22 (it’s found in the Universe repository). As yout normal user (not root), run the SWTPM set up command in a terminal:\nswtpm_setup --create-config-files skip-if-exist Installing Windows 11 in GNOME Boxes Start GNOME Boxes and click on the New button (top left) to create a new VM. The dialog can look a bit overwhelming, but it’s only asking you for one thing: an installation disk image file (“ISO”).\nSelect the Windows 11 ISO file you’ve downloaded from Microsoft. Do not trust ISO files from sources other than the official website of the software vendor. GNOME Boxes will list it at the top of the dialog (likely misidentified as Windows 10) if it’s stored in your Downloads folder. You can also use the select disk image option at the bottom of the dialog.\nDo not accept the Express Installation option. Express installs are only available for some operating systems (OS) and don’t yet work with Windows 11. This option is shown because current versions of Boxes misidentify Windows 11 as Windows 10. Instead, click on the Next button in the top right corner.\nOn the next screen, assign the Windows guest system at least 8 GB of RAM and 124 GB of disk space. The virtual hard disk image won’t consume all that space right away, but grows dynamically as it gets used.\nClick the Create button and wait. The Windows installer should boot up inside the VM and prompt you to select your preferred language and locale. Do not proceed with the installation! The VM is running in legacy BIOS mode and without a TPM. We need to correct that before proceeding.\nAt this point, you’ll need to make a few manual changes to the VM configuration before we jump back into the Windows Installer. Make sure to follow the instructions carefully.\nRight-click on the VM and select Properties. Go to the Advanced tab and click on the Edit Config button (it may be called Edit XML in older versions). Scroll down to the line that says . Scan the lines until it says for any mentions of a TPM. Skip this step if you find any. To enable the TPM emulator, insert a blank line after and paste the following snippet:\n\u0026lt;tpm model=\u0026#34;tpm-crb\u0026#34;\u0026gt; \u0026lt;backend type=\u0026#34;emulator\u0026#34; version=\u0026#34;2.0\u0026#34;/\u0026gt; \u0026lt;/tpm\u0026gt; Scroll down to the line that says . Verify that the type element matches the below (the numbers in the machine attribute may differ). If it doesn’t match then you probably haven’t enabled virtualization in your BIOS. Fix that first, delete the VM, and try again.\n\u0026lt;type arch=\u0026#34;x86_64\u0026#34; machine=\u0026#34;pc-q35-6.1\u0026#34;\u0026gt;hvm\u0026lt;/type\u0026gt; Locate the newly installed OVMF secure boot firmware image file on your system. The file is called OVMF_CODE.secboot.fd, but the installation path is different between Linux distributions. It’s located in /usr/share/edk2/ovmf/ in Fedora Linux 34 and in /usr/share/OVMF/ in Ubuntu 22.\nScan the lines until it says for any mentions of a loader. Skip this step if you find any. Insert a blank line after the type element, and paste the following (supply the correct full path from the previous step):\n\u0026lt;loader readonly=\u0026#34;yes\u0026#34; type=\u0026#34;pflash\u0026#34;\u0026gt;/PATH-HERE/OVMF_CODE.secboot.fd\u0026lt;/loader\u0026gt; Click the Apply button to save the changes.\nQuit and restart GNOME Boxes again.\nDouble-click on the VM in Boxes to start it and resume the installation. Complete the Windows 11 installation by following the prompts.\nPost-installation Once you’ve installed Windows 11, you can just use it as-is in GNOME Boxes. However, you’ll be stuck with low performance, 800×600 px screen resolution, and no clipboard integration. Let’s get those sorted out in order.\nYou can increase the performance of most I/O operations by installing the VirtIO guest agent and driver set. Inside the VM, download and install VirtIO guest addons (look for virtio-win-gt-x64.msi). Restart the VM afterward.\nYou have two options for higher screen resolutions and clipboard integration. You can either continue to use GNOME Boxes or switch to GNOME Connections. Connections is a version of Boxes that focuses on accessing remote desktops instead of VMs. The two apps look and feel very similar.\nYou can use Connections to connect to the VM using the Remote Desktop Protocol (RDP). This is the most performant and reliable option. However, it requires a license for Windows 11 Professional or Enterprise. Windows 11 Home doesn’t include the required RDP server component.\nYou can enable the RDP server from the Windows Settings app: System: Remote Desktop: Remote Desktop. After enabling a network service, take a moment to double-check your network firewalls and make sure that you have a strong and unique password. You may have exposed the service on the public internet. Note that networking into the VM also requires more configuration and is out of scope for this article.\nYour other option is to keep using GNOME Boxes with a graphics driver optimized for use within VMs, and optionally the SPICE guest agent. To enable greater screen resolutions, you need to download and install the newest version of the QXL-WDDM-DoD driver (look for the newest date, then QxlWddmDod_x64.msi). The download link may lead to a page that looks like gobbledygook. If this happens: Go back, right-click, and select Save As. The QXL-WDDM-DoD driver works in Windows 11 but doesn’t officially support the OS.\nOptionally, you can enable auto-resizing/adaptive screen resizing and clipboard integration by downloading and installing the SPICE guest agent (look for the newest date, then spice-vdagent-x64.msi). Restart the VM afterward. Known issues\nThe SPICE display server can sometimes stop working under heavy processor loads. You need to restart the VM to get it back up and running. This isn’t an issue when using RDP.\nOnline snapshots don’t work with UEFI-based systems. You need to power off the VM before you can create a snapshot.\n","permalink":"https://samsifpv.ch/wiki/w11-vm-on-linux/","summary":"\u003cp\u003eWindows 11 significantly raised its hardware requirements compared to Windows 10. Among the changes, it requires more RAM and storage space. It also requires a Trusted Platform Module (TPM) version 2.0 and a UEFI boot environment.\u003c/p\u003e\n\u003cp\u003eGNOME Boxes doesn’t yet support TPM and UEFI environments. However, the underlying virtualization technology supports it. You just need to tweak a few configuration options along the way. Read the instructions carefully!\u003c/p\u003e\n\u003ch2 id=\"install-gnome-boxes-and-its-prerequisites\"\u003eInstall GNOME Boxes and its prerequisites\u003c/h2\u003e\n\u003cp\u003eStart by installing GNOME Boxes from your Linux distribution’s package repository.\nYou cannot use the Flatpak/Flathub version as it doesn’t currently support emulating a TPM.\nThe package is called gnome-boxes everywhere. You need version 40 or newer!\u003c/p\u003e","title":"How to run Windows 11 in GNOME Boxes (with UEFI and TPM2 emulation)"},{"content":"The Macbook I used: Macbook 13 Mid 2010\nNvidia driver solution:\nhttps://askubuntu.com/questions/264247/proprietary-nvidia-drivers-with-efi-on-mac-to-prevent-overheating/613573#613573\nMonitor brightness:\nhttps://askubuntu.com/questions/76081/brightness-not-working-after-installing-nvidia-driver\nNvidia driver:\nhttps://medium.com/@nolanmudge/installing-an-nvidia-graphics-driver-with-a-ubuntu-14-04-and-up-efi-boot-52725dd6927c\nWifi: firmware-b43-installer\nFan: maxfanctld\nPower management: powertop, tlp\nWifi scanning: just set home network in /etc/wpa_supplicant/wpa_supplicant.conf like this:\nNetwork={\\nssid=\\\u0026#34;ssid\\\u0026#34;\\npsk=\\\u0026#34;pw\\\u0026#34;\\n} Backlightbrightness: xbacklight, and custom shortcuts like that:\ncustom shortcuts:\nhttps://askubuntu.com/questions/69114/how-do-i-logout-using-only-the-keyboard/69161#69161\\nxbacklight: https://askubuntu.com/questions/354488/how-to-execute-command-with-keys\\n\u0026quot;,\n","permalink":"https://samsifpv.ch/wiki/install-linux-on-macbook/","summary":"\u003cp\u003eThe Macbook I used: \u003ca href=\"https://everymac.com/systems/apple/macbook_pro/specs/macbook-pro-core-2-duo-2.4-aluminum-13-mid-2010-unibody-specs.html\"\u003eMacbook 13 Mid 2010\u003c/a\u003e\u003c/p\u003e\n\u003cp\u003eNvidia driver solution:\u003cbr\u003e\n\u003ca href=\"https://askubuntu.com/questions/264247/proprietary-nvidia-drivers-with-efi-on-mac-to-prevent-overheating/613573#613573\"\u003ehttps://askubuntu.com/questions/264247/proprietary-nvidia-drivers-with-efi-on-mac-to-prevent-overheating/613573#613573\u003c/a\u003e\u003c/p\u003e\n\u003cp\u003eMonitor brightness:\u003cbr\u003e\n\u003ca href=\"https://askubuntu.com/questions/76081/brightness-not-working-after-installing-nvidia-driver\"\u003ehttps://askubuntu.com/questions/76081/brightness-not-working-after-installing-nvidia-driver\u003c/a\u003e\u003c/p\u003e\n\u003cp\u003eNvidia driver:\u003cbr\u003e\n\u003ca href=\"https://medium.com/@nolanmudge/installing-an-nvidia-graphics-driver-with-a-ubuntu-14-04-and-up-efi-boot-52725dd6927c\"\u003ehttps://medium.com/@nolanmudge/installing-an-nvidia-graphics-driver-with-a-ubuntu-14-04-and-up-efi-boot-52725dd6927c\u003c/a\u003e\u003c/p\u003e\n\u003cp\u003eWifi: \u003ccode\u003efirmware-b43-installer\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eFan: \u003ccode\u003emaxfanctld\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003ePower management: \u003ccode\u003epowertop, tlp\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eWifi scanning: just set home network in \u003ccode\u003e/etc/wpa_supplicant/wpa_supplicant.conf\u003c/code\u003e like this:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eNetwork={\\nssid=\\\u0026#34;ssid\\\u0026#34;\\npsk=\\\u0026#34;pw\\\u0026#34;\\n}\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eBacklightbrightness: \u003ccode\u003exbacklight\u003c/code\u003e, and custom shortcuts like that:\u003c/p\u003e\n\u003cp\u003ecustom shortcuts:\u003cbr\u003e\n\u003ca href=\"https://askubuntu.com/questions/69114/how-do-i-logout-using-only-the-keyboard/69161#69161\"\u003ehttps://askubuntu.com/questions/69114/how-do-i-logout-using-only-the-keyboard/69161#69161\u003c/a\u003e\\nxbacklight: \u003ca href=\"https://askubuntu.com/questions/354488/how-to-execute-command-with-keys\"\u003ehttps://askubuntu.com/questions/354488/how-to-execute-command-with-keys\u003c/a\u003e\\n\u0026quot;,\u003c/p\u003e","title":"Install Linux on an old Macbook"},{"content":"Headers # H1 ## H2 ### H3 #### H4 ##### H5 ###### H6 H1 H2 H3 H4 H5 H6 Emphasis Italics: *asterisks* or _underscores_ Bold: **asterisks** or __underscores__ Combined: **asterisks** and _underscores_ Strikethrough: two tildes. ~~Scratch this~~ Underline: \u0026lt;ins\u0026gt;underline\u0026lt;ins/\u0026gt; Italics: asterisks or underscores\nBold: asterisks or underscores\nCombined: asterisks and underscores\nStrikethrough: two tildes. Scratch this\nUnderline: underline\nLists 1. First ordered list item 2. Another item * Unordered sub-list. 1. Actual numbers don\u0026#39;t matter, just that it\u0026#39;s a number 1. Ordered sub-list 2. And another item. You can have properly indented paragraphs within list items. Notice the blank line above, and the leading spaces (at least one, but we\u0026#39;ll use three here to also align the raw Markdown). To have a line break without a paragraph, you will need to use two trailing spaces. Note that this line is separate, but within the same paragraph. (This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.) * Unordered list can use asterisks - Or minuses + Or pluses First ordered list item\nAnother item\nUnordered sub-list. Actual numbers don\u0026rsquo;t matter, just that it\u0026rsquo;s a number\nOrdered sub-list And another item.\nYou can have properly indented paragraphs within list items. Notice the blank line above, and the leading spaces (at least one, but we\u0026rsquo;ll use three here to also align the raw Markdown).\nTo have a line break without a paragraph, you will need to use two trailing spaces.\nNote that this line is separate, but within the same paragraph.\n(This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)\nUnordered list can use asterisks Or minuses Or pluses Links [I\u0026#39;m an inline-style link](https://www.google.com) [I\u0026#39;m an inline-style link with title](https://www.google.com \u0026#34;Google\u0026#39;s Homepage\u0026#34;) [I\u0026#39;m a reference-style link][Arbitrary case-insensitive reference text] [I\u0026#39;m a relative reference to a repository file](./markdown-cheatsheet.md) [You can use numbers for reference-style link definitions][1] Or leave it empty and use the [link text itself]. URLs and URLs in angle brackets will automatically get turned into links. http://www.example.com or \u0026lt;http://www.example.com\u0026gt; and sometimes example.com (but not on Github, for example). Some text to show that the reference links can follow later. [arbitrary case-insensitive reference text]: https://www.mozilla.org [1]: http://slashdot.org [link text itself]: http://www.reddit.com I\u0026rsquo;m an inline-style link\nI\u0026rsquo;m an inline-style link with title\nI\u0026rsquo;m a reference-style link\nI\u0026rsquo;m a relative reference to a repository file\nYou can use numbers for reference-style link definitions\nOr leave it empty and use the link text itself.\nURLs and URLs in angle brackets will automatically get turned into links. http://www.example.com or http://www.example.com and sometimes example.com (but not on Github, for example).\nSome text to show that the reference links can follow later.\nImages Inline-style: ![alt text](https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png \u0026#34;Logo Title Text 1\u0026#34;) Reference-style: ![alt text][logo] [logo]: https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png \u0026#34;Logo Title Text 2\u0026#34; Here\u0026rsquo;s our logo (hover to see the title text):\nInline-style: Reference-style: Code Inline `code` has `back-ticks around` it. Inline code has back-ticks around it.\nBlocks of code are either fenced by lines with three back-ticks ```, or are indented with four spaces.\n```javascript var s = \u0026quot;JavaScript syntax highlighting\u0026quot;; alert(s); ``` ```python s = \u0026quot;Python syntax highlighting\u0026quot; print s if true: print(\u0026quot;true\u0026quot;) ``` ``` No language indicated, so no syntax highlighting. But let's throw in a \u0026lt;b\u0026gt;tag\u0026lt;/b\u0026gt;. ``` var s = \u0026#34;JavaScript syntax highlighting\u0026#34;; alert(s); s = \u0026#34;Python syntax highlighting\u0026#34; print s if true: print(\u0026#34;true\u0026#34;) No language indicated, so no syntax highlighting. But let\u0026#39;s throw in a \u0026lt;b\u0026gt;tag\u0026lt;/b\u0026gt;. Tables Tables aren\u0026rsquo;t part of the core Markdown spec, but they are part of GFM and Markdown Here supports them. They are an easy way of adding tables to your email \u0026ndash; a task that would otherwise require copy-pasting from another application.\nColons can be used to align columns. | Tables | Are | Cool | | ------------- |:-------------:| -----:| | col 3 is | right-aligned | $1600 | | col 2 is | centered | $12 | | zebra stripes | are neat | $1 | There must be at least 3 dashes separating each header cell. The outer pipes (|) are optional, and you don\u0026#39;t need to make the raw Markdown line up prettily. You can also use inline Markdown. Markdown | Less | Pretty --- | --- | --- *Still* | `renders` | **nicely** 1 | 2 | 3 Colons can be used to align columns.\nTables Are Cool col 3 is right-aligned $1600 col 2 is centered $12 zebra stripes are neat $1 There must be at least 3 dashes separating each header cell. The outer pipes (|) are optional, and you don\u0026rsquo;t need to make the raw Markdown line up prettily. You can also use inline Markdown.\nMarkdown Less Pretty Still renders nicely 1 2 3 Blockquotes \u0026gt; Blockquotes are very handy in email to emulate reply text. \u0026gt; This line is part of the same quote. Quote break. \u0026gt; This is a very long line that will still be quoted properly when it wraps. Oh boy let\u0026#39;s keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can *put* **Markdown** into a blockquote. Blockquotes are very handy in email to emulate reply text. This line is part of the same quote.\nQuote break.\nThis is a very long line that will still be quoted properly when it wraps. Oh boy let\u0026rsquo;s keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can put Markdown into a blockquote.\nInline HTML You can also use raw HTML in your Markdown, and it\u0026rsquo;ll mostly work pretty well.\n\u0026lt;dl\u0026gt; \u0026lt;dt\u0026gt;Definition list\u0026lt;/dt\u0026gt; \u0026lt;dd\u0026gt;Is something people use sometimes.\u0026lt;/dd\u0026gt; \u0026lt;dt\u0026gt;Markdown in HTML\u0026lt;/dt\u0026gt; \u0026lt;dd\u0026gt;Does *not* work **very** well. Use HTML \u0026lt;em\u0026gt;tags\u0026lt;/em\u0026gt;.\u0026lt;/dd\u0026gt; \u0026lt;/dl\u0026gt; Horizontal Rule Three or more... --- Hyphens *** Asterisks ___ Underscores Three or more\u0026hellip;\nHyphens\nAsterisks\nUnderscores\nLine Breaks Depends. Normal Markdown requires two spaces before the line break.\nlike this. Or that. yeah. like this.\nOr that.\nyeah.\n","permalink":"https://samsifpv.ch/wiki/markdown-cheatsheet/","summary":"\u003ch2 id=\"headers\"\u003eHeaders\u003c/h2\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# H1\n## H2\n### H3\n#### H4\n##### H5\n###### H6\n\u003c/code\u003e\u003c/pre\u003e\u003ch1 id=\"h1\"\u003eH1\u003c/h1\u003e\n\u003ch2 id=\"h2\"\u003eH2\u003c/h2\u003e\n\u003ch3 id=\"h3\"\u003eH3\u003c/h3\u003e\n\u003ch4 id=\"h4\"\u003eH4\u003c/h4\u003e\n\u003ch5 id=\"h5\"\u003eH5\u003c/h5\u003e\n\u003ch6 id=\"h6\"\u003eH6\u003c/h6\u003e\n\u003ch2 id=\"emphasis\"\u003eEmphasis\u003c/h2\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eItalics: *asterisks* or _underscores_  \nBold: **asterisks** or __underscores__  \nCombined: **asterisks** and _underscores_  \nStrikethrough: two tildes. ~~Scratch this~~  \nUnderline: \u0026lt;ins\u0026gt;underline\u0026lt;ins/\u0026gt;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eItalics: \u003cem\u003easterisks\u003c/em\u003e or \u003cem\u003eunderscores\u003c/em\u003e\u003cbr\u003e\nBold: \u003cstrong\u003easterisks\u003c/strong\u003e or \u003cstrong\u003eunderscores\u003c/strong\u003e\u003cbr\u003e\nCombined: \u003cstrong\u003easterisks\u003c/strong\u003e and \u003cem\u003eunderscores\u003c/em\u003e\u003cbr\u003e\nStrikethrough: two tildes. \u003cdel\u003eScratch this\u003c/del\u003e\u003cbr\u003e\nUnderline: \u003c!-- raw HTML omitted --\u003eunderline\u003c!-- raw HTML omitted --\u003e\u003c/p\u003e\n\u003ch2 id=\"lists\"\u003eLists\u003c/h2\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e1. First ordered list item\n2. Another item\n\t* Unordered sub-list. \n1. Actual numbers don\u0026#39;t matter, just that it\u0026#39;s a number\n\t1. Ordered sub-list\n2. And another item.\n\n\tYou can have properly indented paragraphs within list items. Notice the blank line above, and the leading spaces (at least one, but we\u0026#39;ll use three here to also align the raw Markdown).\n\n\tTo have a line break without a paragraph, you will need to use two trailing spaces.  \n\tNote that this line is separate, but within the same paragraph.  \n\t(This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)\n\n* Unordered list can use asterisks\n- Or minuses\n+ Or pluses\n\u003c/code\u003e\u003c/pre\u003e\u003col\u003e\n\u003cli\u003e\n\u003cp\u003eFirst ordered list item\u003c/p\u003e","title":"Markdown Cheatsheet"},{"content":"1 Physical - data cables 2 Data - Switching, MAC addresses 3 Network - IP addresses, routing 4 Transport - TCP/UDP 5 Session - Session management 6 Presentation - WMV, JPEG, MOV 7 Application - HTTP, SMTP\nPlease do not throw sausage pizza away\n","permalink":"https://samsifpv.ch/wiki/osi-model/","summary":"\u003cp\u003e1 Physical - data cables\n2 Data - Switching, MAC addresses\n3 Network - IP addresses, routing\n4 Transport - TCP/UDP\n5 Session - Session management\n6 Presentation - WMV, JPEG, MOV\n7 Application - HTTP, SMTP\u003c/p\u003e\n\u003cp\u003ePlease do not throw sausage pizza away\u003c/p\u003e","title":"OSI-Model"},{"content":"Bandit Passwords PW for bandit4: pIwrPrtPN36QITSp3EQaw936yaFoFgAB bandit5: koReBOKuIDDepwhWk7jZC0RTdopnAYKh bandit6: DXjZPULLxYr17uwoI01bNLQbtFemEgo7 bandit7: HKBPTKQnIay4Fw76bEy8PVxKEDQRKTzs bandit8: cvX2JJa4CFALtqS87jk27qwqGhBM9plV bandit9: UsvVyFSfZZWbi6wgC7dAFyFuR6jQQUhR bandit10:truKLdjsbJ5g7yyJ2X2R0o3a5HQJFuLk bandit11:IFukwKGsFW8MOq3IRFqrxE1hxTNEbUPR bandit12:5Te8Y4drgCRfCx8ugdwuEX8KFC6k2EUu bandit13:8ZjyCRiBWFYkneahHwxCv3wb2a1ORpYL bandit14:4wcYUJFw0k0XLShlDzztnTBHiqxU3b3e bandit15:BfMYroe26WYalil77FoDi9qh59eK5xNr\n","permalink":"https://samsifpv.ch/wiki/overthewire_wargames/","summary":"\u003ch2 id=\"bandit-passwords\"\u003eBandit Passwords\u003c/h2\u003e\n\u003cp\u003ePW for bandit4: pIwrPrtPN36QITSp3EQaw936yaFoFgAB\nbandit5: koReBOKuIDDepwhWk7jZC0RTdopnAYKh\nbandit6: DXjZPULLxYr17uwoI01bNLQbtFemEgo7\nbandit7: HKBPTKQnIay4Fw76bEy8PVxKEDQRKTzs\nbandit8: cvX2JJa4CFALtqS87jk27qwqGhBM9plV\nbandit9: UsvVyFSfZZWbi6wgC7dAFyFuR6jQQUhR\nbandit10:truKLdjsbJ5g7yyJ2X2R0o3a5HQJFuLk\nbandit11:IFukwKGsFW8MOq3IRFqrxE1hxTNEbUPR\nbandit12:5Te8Y4drgCRfCx8ugdwuEX8KFC6k2EUu\nbandit13:8ZjyCRiBWFYkneahHwxCv3wb2a1ORpYL\nbandit14:4wcYUJFw0k0XLShlDzztnTBHiqxU3b3e\nbandit15:BfMYroe26WYalil77FoDi9qh59eK5xNr\u003c/p\u003e","title":"Over The Wire Wargames Solutions"},{"content":"PDF arranger Can make booklets. Arrange, delete, add pages to pdfs.\npdfbook Use pdfbook2 from texlive-extra-utils to create a booklet.\npdfjam If some pdf program complains about different sized pages, use pdfjam to make them all the same size\npdfjam --outfile out.pdf --paper a5paper in.pdf Jpdf Tweak Swiss army knife for pdfs. Watermarks, page numbering, bookmarks, attachments, document info, encryption, etc.\nOCRmyPDF OCR on images and pdfs.\nocrmypdf no_ocr.pdf ocr.pdf --sidecar ocr.txt -l deu+eng --force-ocr If \u0026ndash;force-ocr is issued, then all pages will be rasterized to images, discarding any hidden OCR text, rasterizing any printable text, and flattening form fields or interactive objects into their visual representation. This is useful for redoing OCR, for fixing OCR text with a damaged character map (text is selectable but not searchable), and destroying redacted information.\nInstalling additional language packs¶ OCRmyPDF uses Tesseract for OCR, and relies on its language packs for all languages. On most platforms, English is installed with Tesseract by default, but not always.\nTesseract supports most languages. Languages are identified by standardized three-letter codes (called ISO 639-2 Alpha-3). Tesseract’s documentation also lists the three-letter code for your language. Some are anglicized, e.g. Spanish is spa rather than esp, while others are not, e.g. German is deu and French is fra.\nAfter you have installed a language pack, you can use it with ocrmypdf -l , for example ocrmypdf -l spa. For multilingual documents, you can specify all languages to be expected, e.g. ocrmypdf -l eng+fra for English and French. English is assumed by default unless other language(s) are specified.\nFor more info, see: https://ocrmypdf.readthedocs.io/en/latest/languages.html#lang-packs\npdf.tocgen Generate table of contents.\nTo write a toc file back to doc.pdf:\npdftocio doc.pdf \u0026lt; toc https://github.com/Krasjet/pdf.tocgen\n","permalink":"https://samsifpv.ch/wiki/pdf-tools/","summary":"\u003ch2 id=\"pdf-arranger\"\u003ePDF arranger\u003c/h2\u003e\n\u003cp\u003eCan make booklets. Arrange, delete, add pages to pdfs.\u003c/p\u003e\n\u003ch2 id=\"pdfbook\"\u003epdfbook\u003c/h2\u003e\n\u003cp\u003eUse pdfbook2 from texlive-extra-utils to create a booklet.\u003c/p\u003e\n\u003ch2 id=\"pdfjam\"\u003epdfjam\u003c/h2\u003e\n\u003cp\u003eIf some pdf program complains about different sized pages, use pdfjam to make them all the same size\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003epdfjam --outfile out.pdf --paper a5paper in.pdf\n\u003c/code\u003e\u003c/pre\u003e\u003ch2 id=\"jpdf-tweak\"\u003eJpdf Tweak\u003c/h2\u003e\n\u003cp\u003eSwiss army knife for pdfs. Watermarks, page numbering, bookmarks, attachments,\ndocument info, encryption, etc.\u003c/p\u003e\n\u003ch2 id=\"ocrmypdf\"\u003eOCRmyPDF\u003c/h2\u003e\n\u003cp\u003eOCR on images and pdfs.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eocrmypdf no_ocr.pdf ocr.pdf --sidecar ocr.txt -l deu+eng --force-ocr\n\u003c/code\u003e\u003c/pre\u003e\u003cblockquote\u003e\n\u003cp\u003eIf \u0026ndash;force-ocr is issued, then all pages will be rasterized to images,\ndiscarding any hidden OCR text, rasterizing any printable text, and\nflattening form fields or interactive objects into their visual\nrepresentation. This is useful for redoing OCR, for fixing OCR text with a\ndamaged character map (text is selectable but not searchable), and destroying\nredacted information.\u003c/p\u003e","title":"PDF-Tools"},{"content":"Context of the problem:\nHaving a myimage.img bigger then the hardware support (if it is smaller there should be no problem; however, using the same strategy, you can better fit the image in the hardware support).\nThe secret is to use standard Linux tools and instruments: GParted, fdisk and truncate.\nRequirements: A Linux PC The .img you want to shrink (myimage.img in this example) Creating loopback device: GParted is an application typically used to manage partition tables and filesystems. In order to shrink the image, GParted is going to be used along the first part of the answer.\nGParted operates on devices, not simple files like images. This is why we first need to create a device for the image. We do this using the loopback-functionality of Linux.\nLet\u0026rsquo;s enable enable the loopback:\nsudo modprobe loop Let\u0026rsquo;s request a new (free) loopback device:\nsudo losetup -f The command returns the path to a free loopback device:\n/dev/loop0 Let\u0026rsquo;s create a device of the image:\nsudo losetup /dev/loop0 myimage.img The device /dev/loop0 represents myimage.img. We want to access the partitions that are on the image, so we need to ask the kernel to load those too:\nsudo partprobe /dev/loop0 This should give us the device /dev/loop0p1, which represents the first partition in myimage.img. We do not need this device directly, but GParted requires it.\nResize partition using GParted: Let\u0026rsquo;s load the new device using GParted:\nsudo gparted /dev/loop0 Now notice a few things:\nThere is one partition. The partition allocates the entire disk/device/image. The partition is filled partly. We want to resize this partition so that is fits its content, but not more than that. Select the partition and click Resize/Move. Drag the right bar to the left as much as possible. Note that sometimes GParted will need a few MB extra to place some filesystem-related data. You can press the up-arrow at the New size-box a few times to do so. For example, I pressed it 10 times (=10MiB) for FAT32 to work. For NTFS you might not need to at all. Finally press Resize/Move. You will return to the GParted window. Notice that there is a part of the disk unallocated. This part of the disk will not be used by the partition, so we can shave this part off of the image later. GParted is a tool for disks, so it doesn\u0026rsquo;t shrink images, only partitions, we have to do the shrinking of the image ourselves. Press Apply in GParted. It will now move files and finally shrink the partition, so it can take a minute or two, but most of the time it finishes quickly. Afterwards close GParted.\nNow we don\u0026rsquo;t need the loopback-device anymore, so unload it:\nsudo losetup -d /dev/loop0 Shaving the image: Now that we have all the important data at the beginning of the image it is time to shave off that unallocated part. We will first need to know where our partition ends and where the unallocated part begins. We do this using fdisk:\nfdisk -l myimage.img Here we will see an output similar to the following:\nDisk myimage.img: 6144 MB, 6144000000 bytes, 12000000 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x000ea37d Device Boot Start End Blocks Id System myimage.img1 2048 9181183 4589568 b W95 FAT32 Note two things in the output:\nThe partition ends on block 9181183 (shown under End) The block-size is 512 bytes (shown as sectors of 1 * 512) We will use these numbers in the rest of the example. The block-size (512) is often the same, but the ending block (9181183) will differ for you. The numbers mean that the partition ends on byte 9181183512 of the file. After that byte comes the unallocated-part. Only the first 9181183512 bytes will be useful for our image.\nNext we shrink the image-file to a size that can just contain the partition. For this we will use the truncate command (thanks uggla!). With the truncate command need to supply the size of the file in bytes. The last block was 9181183 and block-numbers start at 0. That means we need (9181183+1)*512 bytes. This is important, else the partition will not fit the image. So now we use truncate with the calculations:\ntruncate --size=$[(9181183+1)*512] myimage.img Writing image file to SD card dd if=/data.img of=/dev/mmcblk0 status=progress bs=4M ","permalink":"https://samsifpv.ch/wiki/shrink-image/","summary":"\u003cp\u003eContext of the problem:\u003c/p\u003e\n\u003cp\u003eHaving a myimage.img bigger then the hardware support (if it is smaller there should be no problem; however, using the same strategy, you can better fit the image in the hardware support).\u003c/p\u003e\n\u003cp\u003eThe secret is to use standard Linux tools and instruments: GParted, fdisk and truncate.\u003c/p\u003e\n\u003ch2 id=\"requirements\"\u003eRequirements:\u003c/h2\u003e\n\u003cul\u003e\n\u003cli\u003eA Linux PC\u003c/li\u003e\n\u003cli\u003eThe .img you want to shrink (myimage.img in this example)\u003c/li\u003e\n\u003c/ul\u003e\n\u003ch2 id=\"creating-loopback-device\"\u003eCreating loopback device:\u003c/h2\u003e\n\u003cp\u003eGParted is an application typically used to manage partition tables and filesystems. In order to shrink the image, GParted is going to be used along the first part of the answer.\u003c/p\u003e","title":"Shrinking .img files on Linux"},{"content":" Target Description halt Shut down all services and halt the system poweroff Shut down all services and power off the system shutdown Shut down the system normally rescue Single-user (root) mode for maintenance and recovery functions. It mounts all file-system but does not start any networking related service or function. multi-user Multi-user command line mode for regular tasks. It starts all essential and custom services and provides the CLI prompt for login and work. graphical Same as the multi-user.target but also includes GUI. A user can use the graphical desktop environment to login and work or can use regular command line interface. reboot Reboot the system normally. default Default target to boot the system. Usually set either to multi-user.target or graphical.target. emergency Start an emergency shell and mount only root file-system. Other file-system and networking remain disabled. hibernate Save the running state of the system to the hard disk and power off the system. When the system is power on again, the systemd restores the saved state. suspend Same as the hibernate except the system state is saved in the memory and power to the memory is not turned off. ","permalink":"https://samsifpv.ch/wiki/systemd-targets/","summary":"\u003ctable\u003e\n  \u003cthead\u003e\n      \u003ctr\u003e\n          \u003cth\u003eTarget\u003c/th\u003e\n          \u003cth\u003eDescription\u003c/th\u003e\n      \u003c/tr\u003e\n  \u003c/thead\u003e\n  \u003ctbody\u003e\n      \u003ctr\u003e\n          \u003ctd\u003ehalt\u003c/td\u003e\n          \u003ctd\u003eShut down all services and halt the system\u003c/td\u003e\n      \u003c/tr\u003e\n      \u003ctr\u003e\n          \u003ctd\u003epoweroff\u003c/td\u003e\n          \u003ctd\u003eShut down all services and power off the system\u003c/td\u003e\n      \u003c/tr\u003e\n      \u003ctr\u003e\n          \u003ctd\u003eshutdown\u003c/td\u003e\n          \u003ctd\u003eShut down the system normally\u003c/td\u003e\n      \u003c/tr\u003e\n      \u003ctr\u003e\n          \u003ctd\u003erescue\u003c/td\u003e\n          \u003ctd\u003eSingle-user (root) mode for maintenance and recovery functions. It mounts all file-system but does not start any networking related service or function.\u003c/td\u003e\n      \u003c/tr\u003e\n      \u003ctr\u003e\n          \u003ctd\u003emulti-user\u003c/td\u003e\n          \u003ctd\u003eMulti-user command line mode for regular tasks. It starts all essential and custom services and provides the CLI prompt for login and work.\u003c/td\u003e\n      \u003c/tr\u003e\n      \u003ctr\u003e\n          \u003ctd\u003egraphical\u003c/td\u003e\n          \u003ctd\u003eSame as the multi-user.target but also includes GUI. A user can use the graphical desktop environment to login and work or can use regular command line interface.\u003c/td\u003e\n      \u003c/tr\u003e\n      \u003ctr\u003e\n          \u003ctd\u003ereboot\u003c/td\u003e\n          \u003ctd\u003eReboot the system normally.\u003c/td\u003e\n      \u003c/tr\u003e\n      \u003ctr\u003e\n          \u003ctd\u003edefault\u003c/td\u003e\n          \u003ctd\u003eDefault target to boot the system. Usually set either to multi-user.target or graphical.target.\u003c/td\u003e\n      \u003c/tr\u003e\n      \u003ctr\u003e\n          \u003ctd\u003eemergency\u003c/td\u003e\n          \u003ctd\u003eStart an emergency shell and mount only root file-system. Other file-system and networking remain disabled.\u003c/td\u003e\n      \u003c/tr\u003e\n      \u003ctr\u003e\n          \u003ctd\u003ehibernate\u003c/td\u003e\n          \u003ctd\u003eSave the running state of the system to the hard disk and power off the system. When the system is power on again, the systemd restores the saved state.\u003c/td\u003e\n      \u003c/tr\u003e\n      \u003ctr\u003e\n          \u003ctd\u003esuspend\u003c/td\u003e\n          \u003ctd\u003eSame as the hibernate except the system state is saved in the memory and power to the memory is not turned off.\u003c/td\u003e\n      \u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e","title":"Systemd targets"},{"content":"Commands (May not be preinstalled on your distro) gdu - disk usage in go with multiprocessor (alternative: ncdu)\nfd - better find\nwavemon - analyse wifi\npv and progress - watch progress of a command\nhardinfo - hardwareinfo\nsshfs - mount remote servers\nCrop multiple fotos for i in *.png; do convert -crop aaaxbbb+ccc+ddd \u0026#34;$i\u0026#34; out/\u0026#34;$i\u0026#34;; done Where:\naaa is the x offset from the left bbb is the y offset from the right ccc is the horizontal size of the output image ddd is the vertical size of the output image All in pixels, you can get them by selecting just one image in gimp and looking at the bottom bar for the values ;)\nList autostart apps: ls /etc/init.d All the files in this directory are actually links to the applications and on boot the OS goes through this directory and starts them all. To list all AutoStart Applications in gnome, list all files under \u0026quot;autostart\u0026quot; directories. e.g.:\nfind / -name \\\u0026#34;*autostart*\\\u0026#34; # or ls -1 /etc/xdg/autostart/ \\ /home/$USER/.config/autostart/ \\ /usr/share/gdm/autostart/ \\ /usr/share/gnome/autostart/ To list all autostart enabled systemd services:\nsudo systemctl list-unit-files --type=service --state=enabled --all List Serial ports Linux dmesg | grep tty Network traffic bmon:\nsudo apt install bmon nethogs:\nsudo apt install nethogs See window info xprop See information about a specific window you click on after executing the command.\nTest Keyboard keys xev Tells you which key you just pressed.\nDisk space visualisation sudo apt install ncdu ncdu Networking tools sudo apt install net-tools ifconfig and other stuff\nText editors Nano sudo apt install nano nano Vim sudo apt install vim vim File explorers TUI Midnight commander sudo apt install mc mc Terminal file explorer which supports mouse and has 2 independent tabs\nRanger sudo apt install ranger ranger Vim-like terminal file explorer.\nGraphical PcmanFM sudo apt install pcmanfm pcmanfm Uses GTK theming\nThunar sudo apt install thunar thunar Nautilus sudo apt install nautilus nautilus Uses GTK theming\nDolphin sudo apt install dolphin dolphin Task management sudo apt install taskwarrior # or brew install task task Ascii Art Generator sudo apt install figlet figlet See currently logged in Users, and their processes w Change shell chsh -s /bin/zsh Add user to sudoers file usermod -aG sudo \u0026lt;username\u0026gt; adduser \u0026lt;username\u0026gt; sudo Scan network # Ping broadcast adress (ping 192.168.1.255) arp -a Scan wifi networks nmcli dev wifi Show serial data screen /dev/cu.usbserial-26401 115200 Watch watch Repeats an command infinite times. Can be set with an interval.\nExample: CPU frequency sudo watch -n 1 cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_cur_freq Kdenlive sudo apt install kdenlive A nice video editor for linux and windows. Made for KDE, but works on other platforms as well.\nNote: In order to change themes on Ubuntu, you must install the breeze theme like this:\nsudo apt install breeze\nList services systemctl list-unit-files Ever wanted to know all available systemd services?\nLoadable Kernel Modules All these commands are available in the package modutils\nInfo about a kernel module modinfo \u0026lt;module-name\u0026gt; Insert an LKM into the kernel. insmod Remove an LKM from the kernel. rmmod Determine interdependencies between LKMs. depmod Kerneld daemon program kerneld Display symbols that are exported by the kernel for use by new LKMs. ksyms List currently loaded LKMs. lsmod Display contents of .modinfo section in an LKM object file. modinfo Insert or remove an LKM or set of LKMs intelligently modprobe For example, if you must load A before loading B, Modprobe will automatically load A when you tell it to load B.\n","permalink":"https://samsifpv.ch/wiki/linux-commands/","summary":"\u003ch2 id=\"commands-may-not-be-preinstalled-on-your-distro\"\u003eCommands (May not be preinstalled on your distro)\u003c/h2\u003e\n\u003cp\u003egdu - disk usage in go with multiprocessor (alternative: ncdu)\u003cbr\u003e\nfd - better find\u003cbr\u003e\nwavemon - analyse wifi\u003cbr\u003e\npv and progress - watch progress of a command\u003cbr\u003e\nhardinfo - hardwareinfo\u003cbr\u003e\nsshfs - mount remote servers\u003c/p\u003e\n\u003ch2 id=\"crop-multiple-fotos\"\u003eCrop multiple fotos\u003c/h2\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003efor i in *.png; do convert -crop aaaxbbb+ccc+ddd \u0026#34;$i\u0026#34; out/\u0026#34;$i\u0026#34;; done\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eWhere:\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003eaaa is the x offset from the left\u003c/li\u003e\n\u003cli\u003ebbb is the y offset from the right\u003c/li\u003e\n\u003cli\u003eccc is the horizontal size of the output image\u003c/li\u003e\n\u003cli\u003eddd is the vertical size of the output image\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003eAll in pixels, you can get them by selecting just one image in gimp and looking at the bottom bar for the values ;)\u003c/p\u003e","title":"Useful Linux commands and applications"},{"content":"Function attributes fallthrough The fallthrough attribute with a null statement serves as a fallthrough statement. It hints to the compiler that a statement that falls through to another case label, or user-defined label in a switch statement is intentional and thus the -Wimplicit-fallthrough warning must not trigger.\nFor compatibility with GCC and Clang you can also use // fall through or // fallthrough.\nswitch(cond) { case 1: bar(1); __attribute__((fallthrough)); case 2: … } deprecated \u0026amp; deprecated (msg) The deprecated attribute results in a warning if the function is used anywhere in the source file. This is useful when identifying functions that are expected to be removed in a future version of a program. The warning also includes the location of the declaration of the deprecated function, to enable users to easily find further information about why the function is deprecated, or what they should do instead.\nThe optional msg argument, which must be a string, is printed in the warning if present.\nThe deprecated attribute can also be used for variables and types (see Specifying Attributes of Variables, see Specifying Attributes of Types.)\nThe attribute unavailable works the same, but produces and error instead of a warning.\noptimize (level, …) \u0026amp; optimize (string, …)S The optimize attribute is used to specify that a function is to be compiled with different optimization options than specified on the command line. The optimize attribute arguments of a function behave as if appended to the command-line.\nValid arguments are constant non-negative integers and strings. Each numeric argument specifies an optimization level. Each string argument consists of one or more comma-separated substrings. Each substring that begins with the letter O refers to an optimization option such as -O0 or -Os.\nExample:\nint foo(int i) __attribute__((optimize(\u0026#34;-O3\u0026#34;))); warn_unused_result The warn_unused_result attribute causes a warning to be emitted if a caller of the function with this attribute does not use its return value. This is useful for functions where not checking the result is either a security problem or always a bug, such as realloc.\nExample:\nint __attribute__((warn_unused_result)) foo(void) { return 42; } AVR Function attributes signal \u0026amp; interrupt The function is an interrupt service routine (ISR). The compiler generates function entry and exit sequences suitable for use in an interrupt handler when one of the attributes is present.\nThe AVR hardware globally disables interrupts when an interrupt is executed.\nISRs with the signal attribute do not re-enable interrupts. It is save to enable interrupts in a signal handler. This “save” only applies to the code generated by the compiler and not to the IRQ layout of the application which is responsibility of the application. ISRs with the interrupt attribute re-enable interrupts. The first instruction of the routine is a SEI instruction to globally enable interrupts. The recommended way to use these attributes is by means of the ISR macro provided by avr/interrupt.h from AVR-LibC:\n#include \u0026lt;avr/interrupt.h\u0026gt; ISR (INT0_vect) // Uses the \u0026#34;signal\u0026#34; attribute. { // Code } ISR (ADC_vect, ISR_NOBLOCK) // Uses the \u0026#34;interrupt\u0026#34; attribute. { // Code } Variable attributes nonstring The nonstring variable attribute specifies that an object or member declaration with type array of char, signed char, or unsigned char, or pointer to such a type is intended to store character arrays that do not necessarily contain a terminating NUL. This is useful in detecting uses of such arrays or pointers with functions that expect NUL-terminated strings, and to avoid warnings when such an array or pointer is used as an argument to a bounded string manipulation function such as strncpy. For example, without the attribute, GCC will issue a warning for the strncpy call below because it may truncate the copy without appending the terminating NUL character. Using the attribute makes it possible to suppress the warning. However, when the array is declared with the attribute the call to strlen is diagnosed because when the array doesn’t contain a NUL-terminated string the call is undefined. To copy, compare, of search non-string character arrays use the memcpy, memcmp, memchr, and other functions that operate on arrays of bytes. In addition, calling strnlen and strndup with such arrays is safe provided a suitable bound is specified, and not diagnosed.\nstruct Data { char name [32] __attribute__ ((nonstring)); }; int f (struct Data *pd, const char *s) { strncpy (pd-\u0026gt;name, s, sizeof pd-\u0026gt;name); … return strlen (pd-\u0026gt;name); // unsafe, gets a warning } ","permalink":"https://samsifpv.ch/wiki/gcc-attributes/","summary":"\u003ch2 id=\"function-attributes\"\u003eFunction attributes\u003c/h2\u003e\n\u003ch3 id=\"fallthrough\"\u003efallthrough\u003c/h3\u003e\n\u003cp\u003eThe fallthrough attribute with a null statement serves as a fallthrough\nstatement. It hints to the compiler that a statement that falls through to\nanother case label, or user-defined label in a switch statement is intentional\nand thus the -Wimplicit-fallthrough warning must not trigger.\u003c/p\u003e\n\u003cblockquote\u003e\n\u003cp\u003eFor compatibility with GCC and Clang you can also use \u003ccode\u003e// fall through\u003c/code\u003e or\n\u003ccode\u003e// fallthrough\u003c/code\u003e.\u003c/p\u003e\n\u003c/blockquote\u003e\n\u003cdiv class=\"highlight\"\u003e\u003cpre tabindex=\"0\" class=\"chroma\"\u003e\u003ccode class=\"language-c\" data-lang=\"c\"\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003e\u003cspan class=\"k\"\u003eswitch\u003c/span\u003e\u003cspan class=\"p\"\u003e(\u003c/span\u003e\u003cspan class=\"n\"\u003econd\u003c/span\u003e\u003cspan class=\"p\"\u003e)\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003e\u003cspan class=\"p\"\u003e{\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003e\u003cspan class=\"k\"\u003ecase\u003c/span\u003e \u003cspan class=\"mi\"\u003e1\u003c/span\u003e\u003cspan class=\"o\"\u003e:\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003e  \u003cspan class=\"nf\"\u003ebar\u003c/span\u003e\u003cspan class=\"p\"\u003e(\u003c/span\u003e\u003cspan class=\"mi\"\u003e1\u003c/span\u003e\u003cspan class=\"p\"\u003e);\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003e    \u003cspan class=\"nf\"\u003e__attribute__\u003c/span\u003e\u003cspan class=\"p\"\u003e((\u003c/span\u003e\u003cspan class=\"n\"\u003efallthrough\u003c/span\u003e\u003cspan class=\"p\"\u003e));\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003e  \u003cspan class=\"k\"\u003ecase\u003c/span\u003e \u003cspan class=\"mi\"\u003e2\u003c/span\u003e\u003cspan class=\"o\"\u003e:\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003e    \u003cspan class=\"err\"\u003e…\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003e\u003cspan class=\"p\"\u003e}\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\u003ch3 id=\"deprecated--deprecated-msg\"\u003edeprecated \u0026amp; deprecated (msg)\u003c/h3\u003e\n\u003cp\u003eThe deprecated attribute results in a warning if the function is used anywhere\nin the source file. This is useful when identifying functions that are expected\nto be removed in a future version of a program. The warning also includes the\nlocation of the declaration of the deprecated function, to enable users to\neasily find further information about why the function is deprecated, or what\nthey should do instead.\u003c/p\u003e","title":"Common GCC Attributes"},{"content":"The Array version: char a[] = \u0026#34;string\u0026#34;; Creates an array that is large enough to hold the string literal string, including its NULL terminator. The array string is initialized with the string literal string. The array can be modified at a later time. Also, the array\u0026rsquo;s size is known even at compile time, so sizeof operator can be used to determine its size.\nThe pointer version: char *p = \u0026#34;string\u0026#34;; Creates a pointer to point to a string literal \u0026ldquo;string\u0026rdquo;. This is faster than the array version, but string pointed by the pointer should not be changed, because it is located in a read only implementation-defined memory. Modifying such an string literal results in Undefined Behavior.\nIn fact C++03 deprecates use of string literal without the const keyword [Ref 1]. So the declaration should be:\nconst char *p = \u0026#34;string\u0026#34;; Also,you need to use the strlen() function, and not sizeof to find size of the string since the sizeof operator will just give you the size of the pointer variable.\nWhich version is better and which one shall I use? Depends on the Usage.\nIf you do not need to make any changes to the string, use the pointer version. If you intend to change the data, use the array version. Note that, use of string literal without the const keyword is perfectly valid in C. However, modifying a string literal is still an Undefined Behavior in C [Ref 2].\nThis brings up an interesting question, What is the difference between char* and const char* when used with string literals in C?\n[Ref 1]: C++03 Standard: §4.2/2\nA string literal (2.13.4) that is not a wide string literal can be converted to an rvalue of type “pointer to char”; a wide string literal can be converted to an rvalue of type “pointer to wchar_t”. In either case, the result is a pointer to the first element of the array. This conversion is considered only when there is an explicit appropriate pointer target type, and not when there is a general need to convert from an lvalue to an rvalue. [Note: this conversion is deprecated. See Annex D. ] For the purpose of ranking in overload resolution (13.3.3.1.1), this conversion is considered an array-to-pointer conversion followed by a qualification conversion (4.4). [Example: \u0026ldquo;abc\u0026rdquo; is converted to “pointer to const char” as an array-to-pointer conversion, and then to “pointer to char” as a qualification conversion. ]\nC++11 simply removes the above quotation which implies that it is illegal code in C++11.\n[Ref 2]: C99 standard 6.4.5/5 \u0026ldquo;String Literals - Semantics\u0026rdquo;:\nIn translation phase 7, a byte or code of value zero is appended to each multibyte character sequence that results from a string literal or literals. The multibyte character sequence is then used to initialize an array of static storage duration and length just sufficient to contain the sequence. For character string literals, the array elements have type char, and are initialized with the individual bytes of the multibyte character sequence; for wide string literals, the array elements have type wchar_t, and are initialized with the sequence of wide characters\u0026hellip;\nIt is unspecified whether these arrays are distinct provided their elements have the appropriate values. If the program attempts to modify such an array, the behavior is undefined.\n","permalink":"https://samsifpv.ch/wiki/difference-chararray-charpointer/","summary":"\u003ch2 id=\"the-array-version\"\u003eThe Array version:\u003c/h2\u003e\n\u003cdiv class=\"highlight\"\u003e\u003cpre tabindex=\"0\" class=\"chroma\"\u003e\u003ccode class=\"language-c\" data-lang=\"c\"\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003e\u003cspan class=\"kt\"\u003echar\u003c/span\u003e \u003cspan class=\"n\"\u003ea\u003c/span\u003e\u003cspan class=\"p\"\u003e[]\u003c/span\u003e \u003cspan class=\"o\"\u003e=\u003c/span\u003e \u003cspan class=\"s\"\u003e\u0026#34;string\u0026#34;\u003c/span\u003e\u003cspan class=\"p\"\u003e;\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\u003cp\u003eCreates an array that is large enough to hold the string literal \u003ccode\u003estring\u003c/code\u003e, including its \u003ccode\u003eNULL\u003c/code\u003e terminator. The array string is initialized with the string literal \u003ccode\u003estring\u003c/code\u003e. \u003cstrong\u003eThe array can be modified at a later time.\u003c/strong\u003e Also, the array\u0026rsquo;s size is known even at compile time, so \u003ccode\u003esizeof\u003c/code\u003e \u003cstrong\u003eoperator can be used to determine its size.\u003c/strong\u003e\u003c/p\u003e\n\u003ch2 id=\"the-pointer-version\"\u003eThe pointer version:\u003c/h2\u003e\n\u003cdiv class=\"highlight\"\u003e\u003cpre tabindex=\"0\" class=\"chroma\"\u003e\u003ccode class=\"language-c\" data-lang=\"c\"\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003e\u003cspan class=\"kt\"\u003echar\u003c/span\u003e \u003cspan class=\"o\"\u003e*\u003c/span\u003e\u003cspan class=\"n\"\u003ep\u003c/span\u003e  \u003cspan class=\"o\"\u003e=\u003c/span\u003e \u003cspan class=\"s\"\u003e\u0026#34;string\u0026#34;\u003c/span\u003e\u003cspan class=\"p\"\u003e;\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\u003cp\u003eCreates a pointer to point to a string literal \u0026ldquo;string\u0026rdquo;. This is faster than the array version, \u003cstrong\u003ebut string pointed by the pointer should not be changed\u003c/strong\u003e, because it is located in a read only implementation-defined memory. Modifying such an string literal results in \u003cstrong\u003eUndefined Behavior\u003c/strong\u003e.\u003c/p\u003e","title":"What is the difference between `char a[]` and `char *p`"}]