6. Special considerations
This section is dedicated to device specific requirements that require extra attention and consideration when programming.
6.1 Ethernet, setting a static IP-address
There are several ways of setting the IP address of a device. The default method is DHCP, but a static IP address can also be used. This can be done through the network interfaces configuration file.
6.1.1 File method for IP address configuration in NetworkManager
Note
From CC Linux version 3.4 and above, NetworkManager is used for the network configurations.
This method requires knowledge about the interfaces and the basic usage of NetworkManager daemon. You can see the active connections by using the command below.
$ sudo nmcli con show --active
To set a static IP address to the connection, you can use the command below. Please note that the connection name will be different than the interface name. (e.g ‘Wired connection 1’ for eth0):
$ sudo nmcli con mod ‘{Connection Name}’ ipv4.method manual ipv4.address {Static IP}/24
To set it back as a dynamic IP interface, you can use the command below:
$ sudo nmcli con mod ‘{Connection Name}’ ipv4.method auto ipv4.address “”
Once the file has been edited, it is recommended to either reboot the device, or to bring the network interfaces down and up again, for the IP address configuration to take effect:
$ sudo nmcli con up ‘{Connection Name}’
6.2 CAN
In Linux, CAN is interfaced using SocketCAN which is a standard used in the Linux kernel.
Usage of SocketCAN requires knowledge of some system specific settings and details described herein. For additional SocketCAN information see the official SocketCAN documentation.
CAN bit timings are set by default for settings considered robust for most applications. The default bit timings are set as follows for V700, V510/V710/V705 and V1000/V1200 (note that all devices do not have all buses and that V1000/1200 two CAN version has CAN0 and CAN3 only):
ip link set can0 type can bitrate 50000 sjw 5
ip link set can1 type can bitrate 50000 sjw 5
ip link set can2 type can bitrate 50000 sjw 5
ip link set can3 type can bitrate 50000 sjw 10
ip link set dev canX txqueuelen 1000
The default settings can be modified in file /etc/udev/rules.d/16-cc-can-config.rules
Refer to https://www.kernel.org/doc/Documentation/networking/can.txt for details.
6.2.1 Changing interface names with udev
In some cases, it may be beneficial to change interface names to arbitrary values. An example of this are the interfaces on the V1000 and V1200-devices where one of the can channels is interfaced over SPI to enable powerup on CAN.
In practice, legacy software naming prevents renaming the can channels many times.
To mitigate the order, an example script for udev could be:
SUBSYSTEM=="net", KERNELS=="5a8d0000.can", ACTION=="add", NAME="canfd0"
SUBSYSTEM=="net", KERNELS=="spi0.0", ACTION=="add", NAME="canfd1"
SUBSYSTEM=="net", KERNELS=="5a8e0000.can", ACTION=="add", NAME="canfd2"
SUBSYSTEM=="net", KERNELS=="5a8f0000.can", ACTION=="add", NAME="canfd3"
Warning: do not swap the kernel assigned can (can0-n) names for different interfaces, as this will end up in a race condition with indeterministic channel names.
6.2.2 Configuration of the device interface
The device node files for the CAN interfaces are can0 … canX for a device with (X+1) CAN interfaces. The interfaces should be shown when listing all network interfaces with the ifconfig command.
The CAN bus itself is not initialized during start-up. Before any communications can be executed, the user must set correct bus speed (as an example 250kbps) by first writing the value into the bitrate parameter:
$ sudo ip link set can0 type can bitrate 250000
To work properly with external CAN devices, the sample point of baud rate timings and sjw might need to be configured:
$ sudo ifconfig can0 type can sample-point 0.78 sjw 5
and then setting interface up with ifconfig:
$ sudo ifconfig can0 up
After this, ifconfig should show can0 as a network interface:
$ ifconfig
can0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00
UP RUNNING NOARP MTU:16 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:10
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Interrupt:31
For V1000/V1200 tcan4550.ko is used for the CAN controller connected on SPI. Startup scripts handle the loading of the kernel modules upon start-up. The loaded modules can be checked via terminal access using the lsmod command:
$ lsmod | grep can
flexcan 10092 0
can_dev 8641 1 flexcan,xilinx
Since the drivers are compiled as modules, unnecessary protocols may be removed or new modules inserted, according to user needs.
6.2.3 CAN-FD
Some devices support CAN with flexible data rate (FD), see the Technical Manual of your device for more details. The nominal and data baud rates are setup using socketCAN in a similar fashion as standard CAN (example 500 kbps nominal, 2 Mbps data):
$ sudo ip link set can0 type can bitrate 500000 dbitrate 2000000 fd on
In order to work properly with external CAN-FD devices the sample point of baud rate timings and sjw might need to be adjusted:
$ sudo ip link set can0 type can sample-point 0.78 dsample-point 0.8 dsjw 5
6.2.4 Configuring the CAN socket transmission buffer
By default, the CAN driver is configured with a transmission buffer that can hold up to 10 CAN frames. As each frame is sent over the bus, the buffer is cleared. However, it is possible to write frames to the socket faster than the frames are sent. If your application needs to send more than 10 CAN frames in a burst, it might be a good idea to increase the size of the transmission buffer:
$ ifconfig can0 txqueuelen 100
Note: For SPI-based can interfaces (Yukon-platforms) it might be beneficial to increase the buffer length even more i.e 1000.
6.2.5 Bus off recovery options
It is possible to implement automatic bus off recovery after bus off has occurred. State changes are automatically detected, and controller is re-initialized after the specified time-out period.
Automatic bus off recovery is by default turned off. It can be turned on using the ip command, where the wanted restart period in milliseconds is set. For example, a 100 ms restart period for can0 is set from command line like this:
$ ifconfig can0 down
$ ip link set can0 type can restart-ms 100
$ ifconfig can0 up
Same commands apply for all available CAN interfaces by replacing can0 appropriately. The restart period interval is possible to set as needed by the application. Value zero turns automatic bus recovery off.
Warning: Enabling automatic bus off recovery may disturb other nodes on the bus if CAN interface is incorrectly initialized.
6.3 Graphics, Weston
The graphics framework uses the Wayland protocol reference implementation Weston for graphic operations. Wayland is fast and efficient, and is used by most modern advanced Linux systems, giving it vast standard support in the Linux user space.
For example, Qt has a plugin that enables the Qt libraries to be built for Weston. For Qt applications the impact for that means that it simply needs to be started with a specific flag, platform wayland-egl, and built with the correct development libraries. In CC Linux, this flag has been set to the default graphics framework, hence there’s no need to pass the flag.
Weston includes a windowing system, enabling several applications to overlap while in operation.
The Wayland protocol does not, by default, allow its clients (Qt applications etc.) to have any information about where the client is positioned on the screen. Therefore, some Qt functions, like QWidget::pos(), will always give a zero return. This issue has been resolved in CC Linux by adding an extension to wayland, where the window starting coordinates can be given to the application. Please refer to the Software Guide for more information.
6.4 Serial Number Broadcast interface
The device has a Serial Number Broadcast service (SNB). The SNB does not have a programming interface at the device end, but the broadcasted data output can be handled elsewhere; including in another device if required.
The message sent is a multicast UDP datagram to address 224.0.0.27. The message contains a char array with three values separated by tabs; Serial number, Firmware version and device type. The sender’s IP address is available in datagram headers.
Example data contents (without quotes):
“PR01<tab>10.0.0<tab>0”
An example implementation of the data listener is available in the BSP: apps/snb/snb_reader.c.
6.5 Polarity of PWM outputs
The PWM outputs can be either high or low sided, which will affect the duty cycle behavior. For high sided outputs, a duty cycle of 90% will result in the output signal being 90% high and 10% low. For low sided outputs, the opposite is true - the output signal will be 10% high and 90% low.
Refer to the Technical Manual of your device in order to know if it has PWM outputs and if they are high or low sided.
6.6 Suspend
- Upon suspending of the device, some peripherals are turned off. These will need to be restarted by the user application upon resume from suspend. The following peripherals are affected (available peripherals differ for different devices, see the Technical Manual for your device):
Buzzer/Speaker
PWM outputs
Digital outputs
Configurable inputs (applies to vx10)
The CCAux API function PowerMgr_hasResumed() can be called from within the user application in order to detect a resume from suspend event, see the CCAux API documentation [7].
6.7 General-purpose input/output (GPIO)
Note that this is for low-level gpio only and is not needed for control of PWM outputs or reading configurable inputs.
In the kernel version 6.15 and later the sysfs interface for GPIOs have been removed (traditionally found in /sys/class/gpio). Instead, the libgpiod utilities should be used. For instance, to set GPIO bank 3 GPIO 15 as low, issue the following command:
gpioset gpiochip3 15=0
For more information, read the libgpiod manual pages.
6.8 eMMC/CFCARD wear monitoring
6.8.1 eMMC
The easiest way is to use mmc-utils (not included in the image but can be easily added).
ccs# mmc extcsd read /dev/mmcblk1 | grep -i life eMMC Life Time Estimation A [EXT_CSD_DEVICE_LIFE_TIME_EST_TYP_A]: 0x00 eMMC Life Time Estimation B [EXT_CSD_DEVICE_LIFE_TIME_EST_TYP_B]: 0x01
Usually only the life time estimate for B is available. See table 1 for more details.
Table 1 Liftime data type B
Value |
Description |
---|---|
0x00 |
Not defined |
0x01 |
0% - 10% life time used |
0x02 |
10% - 20% life time used |
0x03 |
20% - 30% life time used |
0x04 |
30% - 40% life time used |
0x05 |
40% - 50% life time used |
0x06 |
50% - 60% life time used |
0x07 |
60% - 70% life time used |
0x08 |
70% - 80% life time used |
0x09 |
80% - 90% life time used |
0x0A |
90% - 100% life time used |
0x0B |
Exceeded the maximum device life time |
Others |
Reserved |
In case lifetime type A is given the data returned is described in Table 2
Value |
PRE-EOL Info |
Description |
---|---|---|
0x00 |
Not Defined |
|
0x01 |
Normal |
Normal |
0x02 |
Warning |
Consumed 80% of reserved blocks |
0x03 |
Urgent |
|
0x04 ~ 0xFF |
Reserved |
6.8.2 CF/CFast card
These cards support S.M.A.R.T. so the status can be checked with the help of smartmontools
For example like this:
rootx1200:/home/ccs# smartctl -a /dev/sda
smartctl 7.3 2022-02-28 r5338 [x86_64-linux-5.15.156-sxel] (local build)
Copyright (C) 2002-22, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF INFORMATION SECTION ===
Device Model: CactusFlashCard
Serial Number: KC245S 04006152
LU WWN Device Id: 5 000000 000000000
Firmware Version: P1003B
User Capacity: 64,023,257,088 bytes [64.0 GB]
Sector Size: 512 bytes logical/physical
Rotation Rate: Solid State Device
TRIM Command: Available, deterministic, zeroed
Device is: Not in smartctl database 7.3/5319
ATA Version is: ACS-2 (minor revision not indicated)
SATA Version is: SATA 3.1, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is: Sun Feb 6 04:48:11 2022 UTC
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED
General SMART Values:
Offline data collection status: (0x00) Offline data collection activity
was never started.
Auto Offline Data Collection: Disabled.
Self-test execution status: ( 0) The previous self-test routine completed
without error or no self-test has ever
been run.
Total time to complete Offline
data collection: ( 0) seconds.
Offline data collection
capabilities: (0x71) SMART execute Offline immediate.
No Auto Offline data collection support.
Suspend Offline collection upon new
command.
No Offline surface scan supported.
Self-test supported.
Conveyance Self-test supported.
Selective Self-test supported.
SMART capabilities: (0x0002) Does not save SMART data before
entering power-saving mode.
Supports SMART auto save timer.
Error logging capability: (0x01) Error logging supported.
General Purpose Logging supported.
Short self-test routine
recommended polling time: ( 1) minutes.
Extended self-test routine
recommended polling time: ( 1) minutes.
Conveyance self-test routine
recommended polling time: ( 1) minutes.
SCT capabilities: (0x003d) SCT Status supported.
SCT Error Recovery Control supported.
SCT Feature Control supported.
SCT Data Table supported.
SMART Attributes Data Structure revision number: 1
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE
1 Raw_Read_Error_Rate 0x0000 100 100 000 Old_age Offline - 0
5 Reallocated_Sector_Ct 0x0000 100 100 000 Old_age Offline - 0
9 Power_On_Hours 0x0000 100 100 000 Old_age Offline - 2
12 Power_Cycle_Count 0x0000 100 100 000 Old_age Offline - 524
160 Unknown_Attribute 0x0000 100 100 000 Old_age Offline - 0
161 Unknown_Attribute 0x0000 100 100 000 Old_age Offline - 145
163 Unknown_Attribute 0x0000 100 100 000 Old_age Offline - 19
164 Unknown_Attribute 0x0000 100 100 000 Old_age Offline - 14587
165 Unknown_Attribute 0x0000 100 100 000 Old_age Offline - 64
166 Unknown_Attribute 0x0000 100 100 000 Old_age Offline - 0
167 Unknown_Attribute 0x0000 100 100 000 Old_age Offline - 7
168 Unknown_Attribute 0x0000 100 100 000 Old_age Offline - 3000
169 Unknown_Attribute 0x0000 100 100 000 Old_age Offline - 100
175 Program_Fail_Count_Chip 0x0000 100 100 000 Old_age Offline - 0
176 Erase_Fail_Count_Chip 0x0000 100 100 000 Old_age Offline - 0
177 Wear_Leveling_Count 0x0000 100 100 050 Old_age Offline - 0
178 Used_Rsvd_Blk_Cnt_Chip 0x0000 100 100 000 Old_age Offline - 0
181 Program_Fail_Cnt_Total 0x0000 100 100 000 Old_age Offline - 0
182 Erase_Fail_Count_Total 0x0000 100 100 000 Old_age Offline - 0
192 Power-Off_Retract_Count 0x0000 100 100 000 Old_age Offline - 85
194 Temperature_Celsius 0x0000 100 100 000 Old_age Offline - 40
195 Hardware_ECC_Recovered 0x0000 100 100 000 Old_age Offline - 0
196 Reallocated_Event_Count 0x0000 100 100 016 Old_age Offline - 0
197 Current_Pending_Sector 0x0000 100 100 000 Old_age Offline - 0
198 Offline_Uncorrectable 0x0000 100 100 000 Old_age Offline - 0
199 UDMA_CRC_Error_Count 0x0000 100 100 050 Old_age Offline - 4
232 Available_Reservd_Space 0x0000 100 100 000 Old_age Offline - 100
241 Total_LBAs_Written 0x0000 100 100 000 Old_age Offline - 644
242 Total_LBAs_Read 0x0000 100 100 000 Old_age Offline - 2190
245 Unknown_Attribute 0x0000 100 100 000 Old_age Offline - 14587
SMART Error Log Version: 1
No Errors Logged
SMART Self-test log structure revision number 1
No self-tests have been logged. [To run self-tests, use: smartctl -t]
SMART Selective self-test log data structure revision number 1
SPAN MIN_LBA MAX_LBA CURRENT_TEST_STATUS
1 0 0 Not_testing
2 0 0 Not_testing
3 0 0 Not_testing
4 0 0 Not_testing
5 0 0 Not_testing
6 0 65535 Read_scanning was never started
Selective self-test flags (0x0):
After scanning selected spans, do NOT read-scan remainder of disk.
If Selective self-test is pending on power-up, resume after 0 minute delay.