Learning/Linux: Difference between revisions

From Renesas.info
(→‎Use ifconfig to find your IP address: Make static IP settings permanent with connman)
Line 127: Line 127:
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.
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.


 
=== Make it permanent ===
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.


=Working with SSH=
=Working with SSH=

Revision as of 07:47, 8 September 2022

This page contains useful General Embedded Linux information

Using SD Card, MMC Card or USB Flash Drive

What is Mounting

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.

Mounting an SD Card or MMC Card

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

Mounting a USB Flash Drive

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

Sync and Un-mount

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.

Networking

Use ifconfig to find your IP address

  • In Windows, you use ipconfig. In Linux, you use ifconfig.
  • The ifconfig command will show you your IP address and MAC address as well as how many packets have been sent/received.

Using Ethernet

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 1925.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.

Make it permanent

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.

Working with SSH

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 PyTTY, and it is available on both Windows and Linux.

To log into your board, you would use: $ ssh root@xx.xx.xx.xx


Copying Files using SCP (in Linux)

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/

Copying Files using WinSCP (Windows Application)

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.

Terminal login using PuTTY (Windows or Linux Application)

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:

  • Type this into a Terminal in Linux
$ sudo apt-get install

Windows Install:

Terminal login using TeraTerm (Windows Application)

  • TeraTerm also supports SSH, so you can use that as well.

TeraTerm SSH Connection.png

Working with Files in Linux

Working with Files

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)

Home Directories

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’.

Executable Files

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.

  • #! /bin/bash
  • #! /bin/dash
  • #! /usr/bin/env python

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.

Edit a text file on the board using vi

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).

  • ESC – switch to Command mode
  • 'i' - switch to Edit mode
  • Now, you can type some text on the keyboard. Type whatever you want.
  • Use the Return key to make multiple lines of text.
  • Use the Arrow keys on your keyboard ←↑↓→ to move around in the text.
  • Note that you can use the Backspace key to delete text.

Now save your file by typing the following keyboard sequence. Remember, a colon (:) requires the SHIFT key.

(ESC)    :    w    q   (ENTER)

Explanation:

  • The ESCAPE put you into Command mode
  • The  : was actually a command that meant that you wanted to enter a list of commands using your keyboard
  • The w was for write the file back to disk
  • The q was for quit the program.
  • The ENTER was to actually send the list of command (remember, we were making a list of things to do)

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)

Partitioning and Formatting an SD Card

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 using a USB card Reader

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

fdisk

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).

fdisk: Delete all existing partitions

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

fdisk: Create a FAT partition of size 500MB

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

fdisk: Create a Linux partition for the remaining space

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


fdisk: Write and exit

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.

Format the partitions

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.

Using PuTTY for your Serial Terminal

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

Install PuTTY using this command:

$ sudo apt-get install putty

Give your user account permissions to access serial ports

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.

Determine your serial port device interface (/dev/ttyxxx)

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

Connecting

Putty Configuration.png

Start PuTTY either by searching for it in your application menu, or just typing “putty &” in a terminal.

  • Click the ‘Serial’ option (radio button)
  • Fill in the ‘Serial line’ option as /dev/ttyUSB0
  • Fill in the ‘Speed’ as 115200
  • 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.
  • Click “Open” at the bottom to connect.

Hints:

  • Copy Text: Anything you highlight with your mouse is automatically copied to the Clipboard
  • Paste Text: Shift + Insert (key)
  • Popup Menu: Ctrl + Right-click in text area
  • Better looking Font: In configuration screen, on left: Window -> Fonts. Change to “Ubuntu Mono” size=12 Remember to re-save (overwrite) the session.

Showing CPU Usage While Executing an Application

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.