This page contains useful general Embedded Linux information
As you will find, you will have to use the 'sudo' command many times in Linux when you are an embedded Linux developer.
But, every time you use the sudo command, you have to enter your password.
However, there is a way to configure your Linux PC so that you do not have to enter your password every time you use sudo.
First, run visudo
sudo visudo
Then, use your arrow keys on the keyboard to navigate to bottom and add this line. Replace "chris" with your username.
chris ALL=NOPASSWD: ALL
Press Ctrl + x to save and exit.
You can then type the following command to verify that the configuration file has been changed.
sudo cat /etc/sudoers
When an SD card, MMC card or a USB Flash drive is plugged into a Linux machine, the Linux kernel detects it and assigns it a ‘device name’. However, for the user to be able to access the attached device, it needs to be ‘mounted’ to some location in the Linux filesystem. In most desktop Linux distribution that mounting is done automatically by the OS. The RZ/G2 Linux OS does not do that though, so the external drive needs to be mounted manually before using it.
To mount a device interface, you need an empty target directory to mount to. There is usually a /mnt directory by default in any Linux system with no files in it. You can either use that directory or make your own. Realize that as soon as you use that directory as a mount point, the files and directories that were there (before you mounted) will then be inaccessible until the device is unmounted.
Note: Since SD Card and MMC or so similar, SD devices are referred to as ‘mmc’ devices in Linux.
This section is for the case when the SD card is connected to the system via a dedicated SD card read, NOT via a USB adapter. Go to the next section for instructions on mounting a USB flash drive or and SD card plugged into a USB adapter.
When you plug an SD card in, you will see a message on the serial console like this:
mmc1: new high speed SDHC card at address e624 mmcblk0: mmc1:e624 SU04G 3.69 GiB mmcblk0: p1 p2
This is showing you that a SD/MMC card was detected and it discovered that it has two partitions (p1 and p2). You will then see that you have some new devices under the /dev directory:
$ ls -l /dev/mmc* brw------- 1 root root 179, 0 Jan 1 09:16 /dev/mmcblk0 brw------- 1 root root 179, 1 Jan 1 09:16 /dev/mmcblk0p1 brw------- 1 root root 179, 2 Jan 1 09:16 /dev/mmcblk0p2
The interface mmcblk0 is the raw interface to the entire card starting at sector 0 (otherwise known as the Master Boot Record). The interfaces mmcblk0p1 and mmcblk0p2 are also raw interfaces, but they are index to start at the beginning of each partition the kernel found making it easy for mounting. Note, you can only “mount” a partition /dev/mmcblk0p0, /dev/mmcblk0p1, etc… You cannot mount the entire root device itself ( /dev/mmcblk0 ).
Next, to mount the first partition to directory /mnt you would type
$ mount /dev/mmcblk0p1 /mnt
Then you can see those files by doing:
$ cd /mnt $ ls -l
Note: To see everything in the system that is currently mounted, simply type the command mount with no parameters. As you look through the list that is displayed up, realize that some mounts are not actually physical device, but rather virtual device with various types of file systems. This is an example of how Linux likes to keep interfaces and functionality standard and common across the system (ie, everything is accessible ‘through a file system’), but then hides all the ugly difference deeper in semantics of how you ‘use’ these standard interfaces. For example, Stringed Instruments; Many instruments have strings, but how you play a violin is much different than how you play a banjo.
$ mount
Like the SD Card, when you plug in an USB Flash drive (or an SD card via a USB adapter), you will see a message on the serial console. However, the /dev names will be “sda”, “sdb” and so on (instead of mmc). The ‘s’ and ‘d’ stand for SCSI Device (because a SUB Flash driver is basically the SCSI protocol over USB). The ‘a’ just means the first device plugged in, meaning if you had a USB hub and multiple driver plugged in, you would have sda, sdb, sdc, etc.
IMPORTANT: If you are working on a Linux Host machine, that machine’s hard drive would most likely already be assigned the name ‘sda’. That is the case for example on your Ubuntu 16 laptop, assuming that you accepted the standard options during the installation of Ubuntu. That means that on a desktop machine your USB flash drive will be recognized as ‘sdb’ (or a later letter).
The RZ/G2 boards do not have hard drives, so there is no ‘sda’ device in the system. When you plug in a USB flash drive into an RZ/G board, it will most likely be recognized as ‘sda’.
As before, the kernel automatically breaks the device into separate partition interfaces.
$ ls -l /dev/sda* brw------- 1 root root 8, 0 Jan 1 09:50 /dev/sda brw------- 1 root root 8, 1 Jan 1 09:50 /dev/sda1 brw------- 1 root root 8, 2 Jan 1 09:50 /dev/sda2
Next, to mount the first partition to directory /mnt you would type
$ mount /dev/sda1 /mnt
Then you can see those files by doing:
$ cd /mnt $ ls -l
When writing to a device, the kernel will buffer up the data and only write it out occasionally or if you are writing a lot of data, the system will return that it’s done, but really in the background it will keep writing the data out to the physical device. The command ‘sync’ in Linux means to flush out any pending buffers and not return from the sync command until everything is written.
To unmount a drive (to safely remove it), use the ‘umount’ command. You can pass either the /dev name or the target directory. Example:
$ umount /dev/sda1
or
$ umount /mnt
Note: A sync is done automatically during the umount procedure. So if it takes a long time, it could be that data was still being written out.
Note: Before you umount a drive, make sure you change in your console to a different directory that the one that you mounted (ie, use the ‘cd’ command to somewhere), otherwise you will get an error “Device or resource busy”…..because your console process is still in there and it can’t unmount a location that someone is current look at.
The Linux OS used on the RZ boards brings up the Ethernet interface automatically during startup. This is done by the "systemd-networkd" service that is automatically start each time you boot. If your RZ board is connected to a network that has a DHCP server, the board will obtain an IP address from it automatically. You just need to execute ‘ifconfig’ to see what the assigned IP address is.
$ ifconfig
In some scenarios the Ethernet interface may not be active (meaning "systemd-networkd" is not started or used). In this case, you would enter the follow to enable it and use the ifconfig to show what interfaces are active.
$ ifconfig $ ifconfig eth0 up $ ifconfig
After the interface is enabled, you will need to assign an IP address. You can either do that manually or use DHCP if it is available on the network.
Manual:
$ ifconfig eth 192.168.0.55
DHCP:
$ udhcpc -i eth0
NOTE: After ‘ifconfig eth0 up’, you may notice that it already has an IPv6 address even though it doesn’t have a IPv4 address yet. No one really assigned that IPv6 address. In IPv6, you can always assign yourself a 'link local' address by just taking your MAC address and putt putting "fe80" at the beginning and "fe00" in the middle.
In Linux, by default, using wifi is disabled, so we have to use the command line too RFKill to allow WiFi to be used.
$ rfkill unblock wifi
Then, you have to enable your wifi networking interface.
$ ifconfig -a $ ifconfig wlan0 up $ ifconfig
connmanctl does also have an interactive mode that can be very useful to connect to a WiFi network:
$ connmanctl
First scan for any Wi-Fi networks:
connmanctl> scan wifi
To list services:
connmanctl> services *AO Wired ethernet_aabbccddeeff_cable Esenin wifi_aabbccddeefe_112233445566_managed_psk Majakovskij wifi_aabbccddeefe_112233445566112233445566_managed_psk
Now you need to register the agent to handle user requests:
connmanctl> agent on
You now need to connect to one of the protected services. To do this easily, just use tab completion for the wifi_ service. If you were connecting to OtherNET in the example above you would type:
connmanctl> connect wifi_aabbccddeefe_112233445566_managed_psk
The agent will then ask you to provide any information the daemon needs to complete the connection. The information requested will vary depending on the type of network you are connecting to. The agent will also print additional data about the information it needs as shown in the example below.
Agent RequestInput wifi_aabbccddeefe_112233445566_managed_psk Passphrase = [ Type=psk, Requirement=mandatory ] Passphrase? [TYPE YOUR WIFI PASSORD]
You may get some message regarding the connection, something like:
wlan0: authenticate with 11:22:33:aa:bb:cc
You will also need to add a DNS name server to resolve host names.
connmanctl> config wifi_aabbccddeefe_112233445566_managed_psk --nameservers 8.8.8.8 4.4.4.4
You can now exit:
connmanctl> quit
The WiFi connection will be re-established at next reboot.
If rfkill blocks the wifi after a power-down / power-up:
connmanctl enable wifi
Yocto based images normally use connman as default network manager. For example, to ensure that the static IP address is kept after reboot for your RZ board, you can use the following commands:
$ connmanctl config ethernet_aabbccddeeff_cable --ipv4 manual 192.168.0.55 255.255.255.0 192.168.0.1 $ connmanctl config ethernet_aabbccddeeff_cable --nameservers 8.8.8.8 4.4.4.4
Assuming that aabbccddeeff
is the MAC address. Parameters are: IP address, subnet mask, gateway respectively.
If you want to use dhcp, simply:
$ connmanctl config ethernet_aabbccddeeff_cable --ipv4 dhcp
Secure Shell (SSH) is a cryptographic network protocol for operating network services securely over an unsecured network. Typical applications include remote command-line, login, and remote command execution, but any network service can be secured with SSH. (https://en.wikipedia.org/wiki/Secure_Shell)
To log into your board using SSH, in your Linux PC you would type: $ ssh xx.xx.xx.xx (ip address of board)
Note that you will rarely use ‘ssh’ on the command line like this. It is much better to use some application that knows how to talk over SSH. One such very popular application is Putty, and it is available on both Windows and Linux.
To log into your board, you would use: $ ssh root@xx.xx.xx.xx
SCP (Secure Copy) is a Linux program that allows to copy files over SSH. You can use this to copy files to/from your board, or to/from PC to PC.
SCP examples (taken from https://haydenjames.io/linux-securely-copy-files-using-scp/ )
Copy file from local host to a remote host SCP example:
$ scp file.txt username@to_host:/remote/directory/
This is the command that you would use the most to copy files from your Ubuntu host machine to the RZ/G2 board. In that case the command typically looks like this:
$ scp file.txt root@192.168.xxx.xxx:/home/root/
Copy file from a remote host to local host SCP example:
$ scp username@from_host:file.txt /local/directory/
Copy directory from a remote host to local host SCP example:
$ scp -r username@from_host:/remote/directory/ /local/directory/
Copy directory from local host to a remote host SCP example:
$ scp -r /local/directory/ username@to_host:/remote/directory/
WinSCP is a Windows program that makes it easy to copy files from a Windows PC to either a Linux PC or board. It also allows you to create and edit files on an RZ/G board directly from your Windows machine.
WinSCP can be found here: https://winscp.net/eng/index.php It is pretty simple to use: Just put in the IP address of what you want to connect to.
When connecting to an RZ/G board make sure to select ‘SCP’ as file protocol. The default protocol is SFTP, and the RZ/G Linux OS does not support that by default.
SSHFS-Win allows you to map your home directory on your Linux machine as a Network Share in your Widows PC.
Then, you can drag files back and forth very easy, just like you do for other network share drives.
Because it uses SSH, no special setup is needed on the Linux machine (other than installing SSH).
You will also need to install Windows File System Proxy (Winfsp)
SSHFS-Win
Windows File System Proxy (Winfsp)
Notes:
C:\> net use Z: \\sshfs\chris@10.10.10.30 my_password
C:\> net use Z: \\sshfs.r\chris@10.10.10.30 my_password
C:\> net use Z: \\sshfs.r\chris@10.10.10.30/home my_password
PuTTY is a good program, and it is supported in Windows or Linux. Install and usage is pretty straight forward. You simple create a new connection and enter IP address, username and password. Remember, for the RZ boards, the username is “root” with no password (leave password section blank)
Linux Install:
$ sudo apt-get install
Windows Install:
To copy a file, use the ‘cp’ command. You can use full or relative paths. You can also change the name of the file when copying it.
$ cp (from) (to)
To rename or move a file, use the ‘mv’ command. You can use full or relative paths. You can also change the name of the file when copying it.
$ mv (from) (to)
When you log into a Linux system, you will have a ‘home’ directory. For example, if you logged in with your username freddythebear, then your home directory would be /home/freddythebear. You always have file permission access to all the files in your home directory, that’s why all your application settings are stored there, any many time it is recommended to place all your build project there. However, instead of typing /home/freddythebear all the time, you can just use the character ~ which will always be expanded to your full home directory path.
In the RZ/G2 Linux OS by default we log in as the user ‘root’, so you home folder will be ‘/home/root’.
In Windows, a file is executable if its file name is .EXE (or .COM if you are up on your Windows history). In Linux, in order for a file(application) to be executable, you must set a bit in the properties of that file. The file extension doesn’t really matter at all. You can make a .txt file executable if you wanted it. To make a file executable, you would use the chmod command (“+x” means to make the file executable)
$ chmod +x my_app $ chmod +x my_script.sh
So, now let’s talk about 2 different executable file formats: ELF and shell script.
ELF: An ELF executable file is what you would typically expect an application to be (just like in Windows). But, if that application file, even though it is in ELF format does not have the executable bit set, it’s not going to execute.
Shell scripts: As for shell scripts, these are text file that have command line arguments in them. Basically, the same as a Windows batch file. But just like ELF files, they need the executable bit set on the file permissions. One thing about shell script executables is that the first line of the file is important. In a Linux system, you can have installed multiple types of shells or rather command language interpreters. Therefore, the first line of the file will tell the kernel what shell to use when executing the commands inside that file. If you do not have this line, the kernel will just default to using /dev/sh (which is different from distribution to distribution). Here are some examples of what that first like might look like.
Please note that to run an executable file, the Linux system only checks the system PATH if a full path (or relative path) was not part of the file name. Linux does not explicitly check your current working directory (like Window does). Therefore, to run an application that is in the directory you are currently in, simple add ./ before the file:
$ ./my_app
If you do not do this, the system will come back and tell you it cannot find the application.
This will explain how you can edit a text file on the board using the serial console and a terminal.
If you simply need to create a simple text file (like a script to launch a demo) or modify an existing file, you can do that with the serial console. The program “vi” has been around for years and will included in the file system by default.
You can read all about how to use vi, so here we’ll just give a crash course.
Modes: vi has 2 modes: command mode and edit mode. By default it will be in command mode (and the keyboard keys will be commands…..not actual characters). When you are in edit mode, then the keyboard keys will actually put those characters into the file.
Escape key: The escape button on your keyboard will always put you into command mode. So any time you need to do a command (like save or exit), you would hit the ESC button first.
Simple exercise: Create a new file (or open an existing file)
$ vi my_file.txt
When vi starts it is by default in command mode. But you can press ESC just to be safe :). Enter the input command “ i “ to go into edit mode. Note you just have to press the ‘i’ key on the keyboard and you are done (you don’t need to hit the ENTER key after).
Now save your file by typing the following keyboard sequence. Remember, a colon (:) requires the SHIFT key.
(ESC) : w q (ENTER)
Explanation:
Another option is to use the ‘x’ command, which will both save the file and exit the vi editor.
ESC : x ENTER
Now let’s open your file back up and make some changes.
$ vi my_file.txt
You can delete an entire line of text using the ‘dd’ command. This is done in Command mode.
ESC (go do the desired line) d d
Now you can switch to Edit mode -
(ESC) i
Use the Arrow keys and change some text. To save and exit, do this (same as before)
(ESC) : w q (ENTER)
To just exit without saving, do this (remember a ! requires the SHIFT key)
(ESC) : ! q (ENTER)
The documents that come with the RZ/G BSP say to put the resulting images on an SD Card, but do not really go into explaining how you do that.
For RZ/G, the recommended default message is to have 2 partition: a relatively small FAT partition (e.g. 200MB) and a larger EXT partition. (e.g. 4 to 6GB). It is convenient to have the FAT partition because
Connect your SD card to your Linux machine using a USB card reader.
We’ll need to find out what is the device interface (/dev/xxx) for that device. Type
$ dmesg
And look at the last line. For example, below is what you get when you plug in a brand new 8GB SD card.
[15354.057419] usb-storage 1-2:1.0: USB Mass Storage device detected [15354.057777] scsi host4: usb-storage 1-2:1.0 [15354.057854] usbcore: registered new interface driver usb-storage [15354.058793] usbcore: registered new interface driver uas [15355.076894] scsi 4:0:0:0: Direct-Access Generic- SD/MMC 1.00 PQ: 0 ANSI: 0 CCS [15355.077574] sd 4:0:0:0: Attached scsi generic sg0 type 0 [15355.761262] sd 4:0:0:0: [sdb] 15523840 512-byte logical blocks: (7.95 GB/7.40 GiB) [15355.761549] sd 4:0:0:0: [sdb] Write Protect is off [15355.761553] sd 4:0:0:0: [sdb] Mode Sense: 03 00 00 00 [15355.761804] sd 4:0:0:0: [sdb] No Caching mode page found [15355.761810] sd 4:0:0:0: [sdb] Assuming drive cache: write through [15355.764741] sdb: sdb1 [15355.766878] sd 4:0:0:0: [sdb] Attached SCSI removable disk
“sd” stands for SCSI Disk….because the USB Mass Storage class actually uses SCSI commands over USB.
The “b” is the physical device number. This log message will also tell you what partitions are on the disk.
[15355.764741] sdb: sdb1
The number after the “b” is the partition number. “sdb1” means there is 1 partition. After you partition your SD card with 2 partitions, you’ll have a sdb1 and sdb2.
You’ll also notice that you ‘sdb’ interfaces under /dev
$ ls -l /dev/sdb* brw-rw---- 1 root disk 8, 0 Jan 14 15:44 /dev/sdb brw-rw---- 1 root disk 8, 1 Jan 14 15:44 /dev/sdb1
We are going to use the program ‘fdisk’ to completely reconfigure this SD card.
IMPORTANT: As mentioned before, make sure you are using the correct drive letter. If you are on a Ubuntu Host machine, most likely your hard drive will have the name ‘sda’ , so the plugged in SD card would be assigned the name ‘sdb’.
First, we have to ‘unmount’ the USB flash drive (SD card) so we can completely wipe it. Linux is not going to let us do any of that while it is mounted (in use).
$ sudo umount /dev/sdb1
NOTE: If your card already has 2 partitions (and you are looking to redo everything), then you’ll need to unmount that one as well
$ sudo umount /dev/sdb2
NOTE: You don’t have to unmount the /dev/sdb (without a number), because that one is the raw interface to the entire disk(flash) area….and it’s not ‘mountable’ anyway, so there’s nothing to unmount.
Now start fdisk with and point it at your SD card’s raw device interface -
$ sudo fdisk /dev/sdb
You can type m (then enter) to see a list of all the possible commands.
Type ‘p’ to print what the disk currently looks like. Command (m for help): p
Disk /dev/sdb: 7.4 GiB, 7948206080 bytes, 15523840 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 Disklabel type: dos Disk identifier: 0x00000000 Device Boot Start End Sectors Size Id Type /dev/sdb1 8192 15523839 15515648 7.4G b W95 FAT32
You can see we only have 1 partition (sda1) and it takes up the entire disk (flash).
Use the ‘d’ command to delete any partitions that are currently there.
Command (m for help): d Selected partition 1 Partition 1 has been deleted.
If there is only 1 partition, it won’t ask you anything. If there are multiple partitions, it will ask you which one, but just keep using the ‘d’ command until they are all gone. You can check there is nothing there by using the ‘p’ command.
Command (m for help): p Disk /dev/sdb: 7.4 GiB, 7948206080 bytes, 15523840 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 Disklabel type: dos Disk identifier: 0x00000000
Create a 500MB partition of type FAT. The commands you enter are highlighted.
NOTE: Instead of entering the ‘default’ numbers, you could just hit the enter key.
Command (m for help): n Partition type p primary (0 primary, 0 extended, 4 free) e extended (container for logical partitions) Select (default p): p Partition number (1-4, default 1): 1 First sector (2048-15523839, default 2048): 2048 Last sector, +sectors or +size{K,M,G,T,P} (2048-15523839, default 15523839): +500M Created a new partition 1 of type 'Linux' and of size 500 MiB.
Note: you can skip the next command below. You can format the partition with FAT even if you leave its type to ‘Linux’ here.
Command (m for help): t Selected partition 1 Hex code (type L to list all codes): 6 Changed type of partition 'Linux' to 'FAT16'. Command (m for help): p Disk /dev/sdb: 7.4 GiB, 7948206080 bytes, 15523840 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 Disklabel type: dos Disk identifier: 0x00000000 Device Boot Start End Sectors Size Id Type /dev/sdb1 2048 1026047 1024000 500M 6 FAT16
Create a ‘Linux’ partition that will take up all the remaining space. The commands you enter are highlighted. NOTE: Instead of entering the ‘default’ numbers, you could just hit the enter key.
Command (m for help): n Partition type p primary (1 primary, 0 extended, 3 free) e extended (container for logical partitions) Select (default p): p Partition number (2-4, default 2): 2 First sector (1026048-15523839, default 1026048): 1026048 Last sector, +sectors or +size{K,M,G,T,P} (1026048-15523839, default 15523839): 15523839
Note: If you want to limit the size of the partition, you can enter a value here, e.g. ‘+3G’ will create a 3 GB partition.
Created a new partition 2 of type 'Linux' and of size 6.9 GiB. Command (m for help): p Disk /dev/sdb: 7.4 GiB, 7948206080 bytes, 15523840 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 Disklabel type: dos Disk identifier: 0x00000000 Device Boot Start End Sectors Size Id Type /dev/sdb1 2048 1026047 1024000 500M 6 FAT16 /dev/sdb2 1026048 15523839 14497792 6.9G 83 Linux
The only thing left to do is write this new configuration out to disk (Flash) and exit fdisk using the ‘w’ command.
Command (m for help): w The partition table has been altered. Calling ioctl() to re-read partition table. Syncing disks.
Done!
Now if you unplug your USB card reader and plug it back in, you should have 2 partitions you can write to.
$ ls -l /dev/sdb* brw-rw---- 1 root disk 8, 0 Jan 14 16:39 /dev/sdb brw-rw---- 1 root disk 8, 1 Jan 14 16:39 /dev/sdb1 brw-rw---- 1 root disk 8, 2 Jan 14 16:39 /dev/sdb2
Note they are just partitions at the moment. They are not formatted with any file systems yet.
Use the mkfs.vfat and mkfs.ext3 utilities to format the partitions on the SD card. We will use the -n and -L options to give the volumes (partitions) labels to make them easier to identify.
$ sudo mkfs.vfat -F 16 -n RZG_FAT /dev/sdb1 mkfs.fat 4.1 (2017-01-24) $ sudo mkfs.ext3 -L RZG_ext /dev/sdb2 mke2fs 1.44.1 (24-Mar-2018) Creating filesystem with 1812224 4k blocks and 453376 inodes Filesystem UUID: 31c80d95-26ae-45b7-abfe-944fcdf46a1a Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632 Allocating group tables: done Writing inode tables: done Creating journal (16384 blocks): done Writing superblocks and filesystem accounting information: done
At this point the newly created partition are not mounted, and Ubuntu would not mount them automatically. If you want to put files on these partitions, you can mount them manually, or you can just unplug the USB card reader and plug it back again. Ubuntu will recognize and automatically mount the new partitions.
In Windows, it’s hard to argue that TeraTerm is not the best serial terminal program…..ever! But, TeraTerm is a Windows program. However, in Linux, PuTTY (which is mostly used for SSH communications) is pretty good at being a serial terminal program.
Install PuTTY using this command:
$ sudo apt-get install putty
By default, normal users cannot use serial ports. Therefore, you have to give yourself permissions by adding your account to the “dialout” group. Copy/paste this command below to give your account permissions:
$ sudo usermod -a -G dialout $USER
Then, log out of the Desktop, and then log back in for the change to take effect. Note, if you don’t know how to do that, just reboot your machine.
When you plug in a RZ eval board, it will most likely show up as /dev/ttyUSB0. You can check by running this command directly after plugging it in:
$ dmesg
and looking at the last line of text. Below you will see "ttyUSB0".
[ 7868.845151] ftdi_sio 1-2:1.0: FTDI USB Serial Device converter detected [ 7868.845174] usb 1-2: Detected FT-X [ 7868.845595] usb 1-2: FTDI USB Serial Device converter now attached to ttyUSB0
Start PuTTY either by searching for it in your application menu, or just typing “putty &” in a terminal.
In the “Saved Session” box, type “ttyUSB0” (or whatever you want) and then click the “Save” button. Then next time you do not have to type all this in, you can just double click your saved session it in the Sessions list and it will connect.
Hints:
GTKTerm is a nice serial terminal for Linux. https://github.com/Jeija/gtkterm
Install GTKTerm using this command:
$ sudo apt-get update -y $ sudo apt-get install gtkterm -y
By default, normal users cannot use serial ports. Therefore, you have to give yourself permissions by adding your account to the “dialout” group. Copy/paste this command below to give your account permissions:
$ sudo usermod -a -G dialout $USER
Then, log out of the Desktop, and then log back in for the change to take effect. Note, if you don’t know how to do that, just reboot your machine.
When you plug in a RZ eval board, it will most likely show up as /dev/ttyUSB0. You can check by running this command directly after plugging it in:
$ dmesg
$ gtkterm &
In Linux there is a standard utility called “top” (table of processes) that is used to monitor the running processes in the system (like Task Manager in Windows).
At anytime, you can call top to view what is running in the system.
$ top
Note: Press the key ‘q’ to exit the top application.
If you would like to start an application and then monitor it, you can have that application run in the background by adding a ‘&’ sign at the end of the command line. Then, while that application is running, you can use the ‘top’ command to monitor the amount of CPU usage being used by each process.
Install XFCE4 to be the Desktop environment when we log in
$ sudo apt update $ sudo apt install xfce4 xfce4-goodies
Install Tiger VNC Server
$ sudo apt install tigervnc-standalone-server
Configuring VNC Access
$ vncpasswd
$ nano ~/.vnc/xstartup
#!/bin/sh unset SESSION_MANAGER unset DBUS_SESSION_BUS_ADDRESS exec startxfce4
$ chmod u+x ~/.vnc/xstartup
Test Tiger VNC Server
$ vncserver
$ vncserver -list
TigerVNC server sessions: X DISPLAY # RFB PORT # PROCESS ID :1 5901 5710
$ vncserver -kill :1
Create a Systemd service so it will automatically start on every system boot
$ sudo nano /etc/systemd/system/vncserver@.service
[Unit] Description=Remote Desktop Service (VNC) After=syslog.target network.target [Service] Type=forking User=xxxx ExecStartPre=/usr/bin/vncserver -kill :%i > /dev/null 2>&1 ExecStart=/usr/bin/vncserver -localhost=no :%i ExecStop=/usr/bin/vncserver -kill :%i [Install] WantedBy=multi-user.target
$ sudo systemctl daemon-reload
$ sudo systemctl enable vncserver@1.service
$ sudo systemctl start vncserver@1.service
sudo systemctl status vncserver@1.service
Install Tiger VNC Viewer on a Windows PC
Start TigerVNC Viewer in Windows and Connect to your Linux PC
Next, please consider to read the following section VNC Fixes for Ubuntu
When connect using VNC, you might not be able to open a web browser. If you click on the icon, nothing happens.
Also, if you try to start the web browser on the command line by typing "firefox", you might will get this error
$ firefox
/system.slice/system-vncserver.slice/vncserver@1.service is not a snap cgroup
The explanation is complicated, but the fix is simple.
In your VNC session, on a command line, enter this long command to confirm that the FireFox web browser does show up.
xhost +local: && env XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR env DBUS_SESSION_BUS_ADDRESS=unix:path=$XDG_RUNTIME_DIR/bus firefox
If this works for you, then you simply need to use this use command this to start a web browser every time.
What you can do is create a shortcut on your Desktop.
First, enter this command to find out what your user account ID is. Usually it is 1000, so the output will be /run/user/1000
echo $XDG_RUNTIME_DIR
Next, create a shortcut file on your desktop, then open it up in the Gedit text editor.
cd ~/Desktop
touch FireFox.desktop
chmod +x FireFox.desktop
gedit FireFox.desktop
Then fill that file with the follow contents. Remember, if you user ID is not 1000, please change it when you enter in this text.
[Desktop Entry]
Version=1.0
Type=Application
Name=Firefox
Comment=Firefox Web Browser
Exec=env DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus firefox %u
Icon=firefox
Path=
Terminal=false
StartupNotify=false
Save and Close.
Note: You might have to press the F5 key on your keyboard to refresh the desktop to make it show up.
Now, double click the icon on you Desktop and that should open the FireFox web brower.
The same procedure can be done for a Chromium browser (chromium-browser) if it is installed.
Note: Every time you open Firefox, it will say "Do you want to make Firefox your default browser?". But, you can never get rid of that message that because it is a bug in Ubuntu. So, in Firefox, enter about:preferences as the URL, and then uncheck "Always check if Firefox is your default browser".
$ sudo /usr/bin/update-manager No protocol specified Unable to init server: Could not connect: Connection refused No protocol specified Unable to init server: Could not connect: Connection refused No protocol specified Unable to init server: Could not connect: Connection refused (update-manager:460566): Gtk-WARNING **: 11:24:38.030: cannot open display: :1.0
$ xhost +local: non-network local connections being added to access control list $ sudo /usr/bin/update-manager
1. Edit the file udisk policy file (requires sudo)
Ubuntu 18.04:
$ sudo gedit /usr/share/polkit-1/actions/org.freedesktop.UDisks2.policy
Ubuntu 20.04: (because running Wayland)
$ xhost +local: $ sudo gedit /usr/share/polkit-1/actions/org.freedesktop.UDisks2.policy
2. Find the section "Mount a filesystem", it should be the first one.
<action id="org.freedesktop.udisks2.filesystem-mount"> <description>Mount a filesystem< /description> <description xml:lang="ca">Munta un sistema de fitxers< /description> ... ...
3. At the bottom of that section, change <allow_any> and <allow_inactive> to 'yes'
From:
<defaults> <allow_any>auth_admin</allow_any> <allow_inactive>auth_admin</allow_inactive> <allow_active>yes</allow_active> </defaults> </action>
To:
<defaults> <allow_any>yes</allow_any> <<<<<<<<<< CHANGE TO 'yes' <allow_inactive>yes></allow_inactive> <<<<<<<<<< CHANGE TO 'yes' <allow_active>yes</allow_active> </defaults> </action>
Do the same thing for:
4. Save file. You are done (no reboot needed).
By default Wifi settings and other network related settings need sudo permission. This is especially annoying on the WiFi scanning, prompting for a password each time a new wireless network scan is attempted. To fix this another polkit setting is required. Similarly to previous section, edit /usr/share/polkit-1/actions/org.freedesktop.NetworkManager.policy
, find the section org.freedesktop.NetworkManager.wifi.scan
and change <allow_any>
and <allow_inactive>
to 'yes
'. You may want to change the permissions to org.freedesktop.NetworkManager.network-control
as well.
Settings -> Appearance -> Font Default Font Sans 11 Default Monospace Font Monospace 10 Rendering [x] Enble anti-aliasing Hinting = Slight Sub-pixel order = RGB DPI [ ] Custom DPI Setting
$ cd /usr/share/polkit-1/actions/ $ sudo cp -a org.freedesktop.color.policy org.freedesktop.color.policy.orig $ sudo sed -e 's|>auth_admin<|>no<|g' -i org.freedesktop.color.policy
systemd services can be used to automatically run an application on boot up.
Dependencies to other services (e.g. weston) are not obvious but need to be taken into account properly.
A suitable example that has been proven with different RZ VLP releases can be found here:
How to Autorun Application at the Start up in Linux | Toradex Developer Center
The setup is quite simple:
1. define the service itself in a <service_name>.service file.
"Type=simple" should be sufficient.
The 'command' can be started as root with:
ExecStart=su root <shell_script_name>.sh
copy <service_name>.service to /lib/systemd/system/
2. prepare the shell script (<shell_script_name.sh>) that is going to be started by the <service_name>.service file.
Within this script, discard unwanted command messages by piping the output with > /dev/null 2> /dev/null
If the command in the script opens a window on the Weston GUI, add the proposed XDG_RUNTIME_DIR definition and while loop that waits until the Weston setup finished.
3. enable and start the service with
$ systemctl enable <service_name>.service $ systemctl start <service_name>.service
4. reboot the board and the service will start automatically
To deactivate the service use
$ systemctl stop <service_name>.service $ systemctl disable <service_name>.service