Frankie's blog


  • 首页

  • 归档

FreeCommander XE文件或者文件夹无法打开右键菜单

发表于 2023-04-21 | 分类于 工具

FreeCommander XE文件或者文件夹无法打开右键菜单

FreeCommander XE文件或者文件夹无法打开右键菜单,一直转圈圈,然后无响应。
解决方法是在”C:\Users\yourdir\AppData\Local\FreeCommanderXE\Settings\FreeCommander.ini”文件中Language=chinese_s.lng下方增加下行即可
ShowContextMenu64Bit=0

reference

  • https://freecommander.com/forum/viewtopic.php?t=10356

RK3399功耗分析与优化

发表于 2022-07-13 | 分类于 开发

Voltage domain(VD) and power domain(PD)

  • VD_CORE_B: including two big cores Contex-A72, the power consumption is relatively large, so separate a voltage domain.
  • VD_CORE_L: including four little cores Contex-A53, the power consumption is relatively large, so separate a voltage domain.
  • VD_LOGIC: including some peripherals’ controller and system bus, such as USB, EMMC, GMAC, SPI, I2C, EDP, VOP, AXI, AHB, APB, and so on.
  • VD_CENTER: including vdpu, vepu, iep, rga and DDR controller.
  • VD_GPU: including GPU, the power consumption is relatively large, so separate a voltage domain.
  • VD_PMU: including PMU, SRAM, GPIO, PVTM and other modules relating to suspend and resume process.

EVB Power consumption

Type power-supply Voltage(V) current(mA) Theoretical current on battery-3.8V(mA) Remark
DC/DC VDD_ARM 0.96 10.20 3.23 With 80% efficiency, conversion formula: V * I / efficiency / voltage of the battery
DC/DC VDD_LOG 0.96 89.30 28.20 eg: Theoretical current of VDD_LOG on battery(3.8V) = 0.96 * 89.3 / 0.8 / 3.8 = 28.2
DC/DC VCC_DDR 1.26 38.50 15.91
DC/DC VCC_IO 2.99 4.50 4.43
LDO VCC_1V8 1.81 28.80 28.80 Output current of LDO is equal to input current
LDO VDD_1V0 1.00 10.90 10.90
LDO VCC3V0_PMU 3.01 1.20 1.20
battery VBAT 3.81 94.60 92.67 Theoretical value is similar to actually measured value

Data analysis for each path

1. VDD_CORE/VDD_CPU/VDD_ARM

  • Confirm if the frequency voltage table (opp-table) is normal or not, if the actually measured voltage is consistent with the set voltage or not.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
 /* Acquire the frequency voltage table, target column means the voltage required by some 
frequency */
# cat /sys/kernel/debug/opp/opp_summary
device rate(Hz) target(uV) min(uV) max(uV)
-------------------------------------------------------------------
platform-dmc
328000000 900000 900000 900000
416000000 900000 900000 900000
666000000 900000 900000 900000
856000000 900000 900000 900000
platform-ff9a0000.gpu
200000000 825000 825000 825000
300000000 825000 825000 825000
400000000 825000 825000 825000
600000000 925000 925000 925000
800000000 1075000 1075000 1075000
cpu4
408000000 825000 825000 1250000
600000000 825000 825000 1250000
816000000 825000 825000 1250000
1008000000 850000 850000 1250000
1200000000 925000 925000 1250000
1416000000 1000000 1000000 1250000
1608000000 1075000 1075000 1250000
1800000000 1175000 1175000 1250000
cpu0
408000000 825000 825000 1250000
600000000 825000 825000 1250000
816000000 850000 850000 1250000
1008000000 925000 925000 1250000
1200000000 1000000 1000000 1250000
1416000000 1125000 1125000 1250000

/* Check the frequency scaling strategy currently used by cpufreq, cpu frequency scaling
is enabled with the default interactive strategy */
# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
interactive

/* Set userspace strategy to fix the frequency of cpu, then set different frequencies,
compare the set voltage with the measured voltage */
# echo userspace > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
userspace

/* Check the frequency point supported by cpufreq */
# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies
408000 600000 816000 1008000 1200000 1248000 129600

/* Set the fixed frequency */
# echo 408000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed

/* Confirm current frequency*/
# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq
408000

/* Confirm current voltage, and compare with measured value, vdd_arm represents the name
of regulator, which is differnt for differnt projects*/
# cat /sys/kernel/debug/regulator/vdd_arm/voltage
950000

/* Acquire current voltages of all regulators*/
# cat /sys/kernel/debug/regulator/regulator_summary
regulator use open bypass voltage current min max
-------------------------------------------------------------------------------
regulator-dummy 0 4 0 0mV 0mA 0mV 0mV
ff100000.saradc 0mV 0mV
backlight 0mV 0mV
deviceless 0mV 0mV
vdd_log 0 1 0 810mV 0mA 810mV 1400mV
deviceless 0mV 0mV
vcc3v3_sys 0 17 0 3300mV 0mA 3300mV 3300mV
deviceless 0mV 0mV
vdd_cpu_b 0 2 0 825mV 0mA 712mV 1500mV
cpu4 825mV 1250mV
deviceless 0mV 0mV
vdd_gpu 0 2 0 825mV 0mA 712mV 1500mV
ff9a0000.gpu 825mV 1500mV
deviceless 0mV 0mV
vdd_center 0 2 0 900mV 0mA 750mV 1350mV
dmc 900mV 1350mV
deviceless 0mV 0mV
vdd_cpu_l 0 2 0 825mV 0mA 750mV 1350mV
cpu0 825mV 1250mV
deviceless 0mV 0mV
vcc_ddr 0 1 0 3300mV 0mA 0mV 0mV
deviceless 0mV 0mV
vcc_1v8 0 1 0 1800mV 0mA 1800mV 1800mV
deviceless 0mV 0mV
vcc1v8_dvp 0 2 0 1800mV 0mA 1800mV 1800mV
ff770000.syscon:io-domains 0mV 0mV
deviceless 0mV 0mV
vcc3v0_tp 0 1 0 3000mV 0mA 3000mV 3000mV
deviceless 0mV 0mV
vcc1v8_pmu 0 1 0 1800mV 0mA 1800mV 1800mV
deviceless 0mV 0mV
vccio_sd 0 3 0 3000mV 0mA 1800mV 3000mV
fe320000.dwmmc 3000mV 3000mV
ff770000.syscon:io-domains 0mV 0mV
deviceless 0mV 0mV
vcca3v0_codec 0 1 0 3000mV 0mA 3000mV 3000mV
deviceless 0mV 0mV
vcc_1v5 0 1 0 1500mV 0mA 1500mV 1500mV
deviceless 0mV 0mV
vcca1v8_codec 0 2 0 1800mV 0mA 1800mV 1800mV
ff770000.syscon:io-domains 0mV 0mV
deviceless 0mV 0mV
vcc_3v0 0 3 0 3000mV 0mA 3000mV 3000mV
ff770000.syscon:io-domains 0mV 0mV
ff320000.syscon:io-domains 0mV 0mV
deviceless 0mV 0mV
vcc3v3_s3 0 1 0 3300mV 0mA 0mV 0mV
deviceless 0mV 0mV
vcc3v3_s0 0 1 0 3300mV 0mA 0mV 0mV
deviceless 0mV 0mV
vcc5v0_host 0 3 0 5000mV 0mA 5000mV 5000mV
phy-ff770000.syscon:usb2-phy@e450.9 0mV 0mV
phy-ff770000.syscon:usb2-phy@e460.1 0mV 0mV
deviceless 0mV 0mV
vcc5v0_sys 0 2 0 5000mV 0mA 5000mV 5000mV
deviceless 0mV 0mV
vcc_lcd 0 2 0 3300mV 0mA 3300mV 3300mV
edp-panel 0mV 0mV
deviceless 0mV 0mV
vcc_sd 0 2 0 3000mV 0mA 3000mV 3000mV
fe320000.dwmmc 3000mV 3100mV
deviceless 0mV 0mV
vcc_phy 0 2 0 0mV 0mA 0mV 0mV
fe300000.ethernet 0mV 0mV
deviceless 0mV 0mV
  • Check cpu loading, analyze if there is abnormal task or interrupt.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/* Use top command to check the task loading, the output of top with different versions 
will have difference, this version of top supports to check the thread and the running
cpu of the thread */
# top -m 5
Tasks: 219 total, 1 running, 218 sleeping, 0 stopped, 0 zombie
Mem: 3.7G total, 1.5G used, 2.2G free, 13M buffers
Swap: 1.5G total, 0 used, 1.5G free, 877M cached
600%cpu 3%user 0%nice 5%sys 590%idle 0%iow 1%irq 1%sirq 0%host

/* PR column represents currently running cpu of the thread, the sum of all cpu loading
percentage is equal to 100%, so the highest loading percentage of each cpu is
100%/NR_CPU, the highest loading percentage of each CPU of SoC with 4 cores is 25% */
PID USER PR NI VIRT RES SHR S[%CPU] %MEM TIME+ ARGS
12834 root 20 0 35M 3.9M 3.1M R 1.6 0.1 0:00.11 top -m 5
10275 root 20 0 0 0 0 I 0.3 0.0 0:00.05 [kworker/u12:1-devfreq_wq]
318 radio 20 0 79M 7.6M 6.6M S 0.3 0.1 0:08.34 rild
290 root 20 0 34M 3.8M 3.2M S 0.3 0.0 0:17.53 sh /vendor/bin/pwm_fan.sh
1 root 20 0 54M 8.7M 6.4M S 0.3 0.2 0:05.12 init second_stage

/* Use cpustats to observe the frequency change of cpu */
# cpustats
Total: User 600 + Nice 0 + Sys 3 + Idle 591 + IOW 0 + IRQ 0 + SIRQ 0 = 1194
 408000kHz 0 +
 600000kHz 0 +
 816000kHz 0 +
 1008000kHz 0 +
 1200000kHz 0 +
 1248000kHz 0 +
 1296000kHz 0 +
 1416000kHz 0 +
 1512000kHz 1200 = 1200 /* within the statistic time, there are 1200 system jiffies in
total, 1512M running for 1200 jiffies */
/* from below, we can see the loading status of each cpu, including user mode, kernel
mode, interrupt and idle time */
cpu0: User 0 + Nice 0 + Sys 1 + Idle 294 + IOW 0 + IRQ 0 + SIRQ 0 = 295
cpu1: User 299 + Nice 0 + Sys 1 + Idle 0 + IOW 0 + IRQ 0 + SIRQ 0 = 300
cpu2: User 1 + Nice 0 + Sys 1 + Idle 296 + IOW 0 + IRQ 0 + SIRQ 0 = 298
cpu3: User 300 + Nice 0 + Sys 1 + Idle 0 + IOW 0 + IRQ 0 + SIRQ 0 = 301

/* check the ratio of running time for each frequency through cpufreq node, time unit:
jiffies */
# cat /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state
408000 718186
600000 548
816000 368
1008000 1578
1200000 1104
1248000 84
1296000 101
1416000 678
1512000 47495

/* check the inturrupt quantity of all peripherals */
# cat /proc/interrupts
          CPU0       CPU1       CPU2       CPU3
 1:          0          0          0          0     GICv2  29 Edge      arch_timer
 2:     181898     165057     636772     839244     GICv2  30 Edge      arch_timer
 5:     180743      39000      28905      65189     GICv2  62 Level     rk_timer
13:     260634          0          0          0     GICv2  39 Level     ff180000.i2c
14:     354805          0          0          0     GICv2  40 Level     ff190000.i2c
15:          0          0          0          0     GICv2  41 Level     ff1a0000.i2c

2. VDD_GPU

The power consumption of VDD_GPU mainly confirms if the the frequency voltage table is normal or not, if
the measured voltage is consistent with the set voltage or not, using devfreq node.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/* acquire the frequency voltage table */
# cat /sys/kernel/debug/opp/opp_summary
device                rate(Hz)    target(uV)    min(uV)    max(uV)
-------------------------------------------------------------------...
platform-ff9a0000.gpu
200000000 825000 825000 825000
300000000 825000 825000 825000
400000000 825000 825000 825000
600000000 925000 925000 925000
800000000 1075000 1075000 1075000
...

/* check the frequency scaling strategy currently used by gpu devfreq, gpu frequency
scaling is enabled with the default simple_ondemand strategy */
# cat /sys/class/devfreq/ff9a0000.gpu/governor
simple_ondemand
Note: ff9a0000 of ff9a0000.gpu is the address of gpu register, so the name will be
different for differnt chips.

/* Set userspace strategy to fix the frequency of gpu, then set different frequencies,
compare the set voltage with measured voltage */
# echo userspace > /sys/class/devfreq/ff9a0000.gpu/governor
# cat /sys/class/devfreq/ff9a0000.gpu/governor
userspace

/* check the frequency points supported by gpu devfreq */
# cat /sys/class/devfreq/ff9a0000.gpu/available_frequencies
520000000 480000000 400000000 300000000 200000000

/* set the fixed frequency */
# echo 200000000 > /sys/class/devfreq/ff9a0000.gpu/userspace/set_freq

/* confirm current frequency */
# cat /sys/class/devfreq/ff9a0000.gpu/cur_freq
200000000

/* confirm current voltage, and compare with measued value */
# cat /sys/kernel/debug/regulator/vdd_gpu/voltage
950000

/* check gpu loading */
# cat /sys/class/devfreq/ff9a0000.gpu/load
0@200000000Hz

3. VDD_LOGIC

Generally VDD_LOGIC will contain many modules, in order to manage the power consumption conveniently,
it will be divided into many PD internally. The power consumption can be analyzed mainly from the
following aspects:

  • Confirm the running frequency and switch status of each module.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# cat /sys/kernel/debug/clk/clk_summary

enable prepare protect duty
clock count count count rate accuracy phase cycle
---------------------------------------------------------------------------------------------
rk808-clkout2 2 2 0 32768 0 0 50000
rk808-clkout1 0 0 0 32768 0 0 50000
xin32k 0 0 0 32768 0 0 50000
CLK_CAMERA_27MHZ 1 1 0 27000000 0 0 50000
clkin_gmac 1 1 0 125000000 0 0 50000
clk_rmii_src 4 4 0 125000000 0 0 50000
clk_rmii_tx 2 2 0 125000000 0 0 50000
clk_rmii_rx 1 1 0 125000000 0 0 50000
clk_mac_ref 1 1 0 125000000 0 0 50000
clk_mac_refout 1 1 0 125000000 0 0 50000
......
  • Confirm the switch status of each PD.
1
2
3
4
5
6
7
8
9
10
11
12
# cat /sys/kernel/debug/pm_genpd/pm_genpd_summary
domain status slaves
/device runtime status
----------------------------------------------------------------------
pd_vopl on
/devices/platform/ff8f3f00.iommu suspended
/devices/platform/ff8f0000.vop suspended
pd_vopb off-0
/devices/platform/ff903f00.iommu suspended
/devices/platform/ff900000.vop suspended
pd_vo on pd_vopb, pd_vopl
......
  • Generally DDR module is put in VDD_LOGIC, and the power consumption of DDR module is relatively
    large, use the same devfreq strategy as GPU to optimize the power consumption, so need to confirm
    the frequency voltage table and measured voltage. DDR also has some configurations with low power
    consumption, such as pd_idle, sr_idle, odt switch and some other timing configurations. The debugging
    process is relatively complex. Need to refer to the detailed DDR document.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# cat /sys/kernel/debug/opp/opp_summary
device                rate(Hz)    target(uV)    min(uV)    max(uV)
------------------------------------------------------------------- platform-dmc
                     194000000       950000      950000      950000
                     328000000       950000      950000      950000
                     450000000       950000      950000      950000
                     528000000       975000      975000      975000
                     666000000      1000000     1000000     1000000
...

/* ddr uses dmc_ondemand frequency scaling strategy by default */
cat /sys/class/devfreq/dmc/governor
dmc_ondemand

Other commands to set the frequency and voltage are the same as GPU devfreq.

4. VCC_DDR

VCC_DDR supplies power mainly for DDR component and DDR-IO part of SoC. The parameters affecting the
power consumption of VCC_DDR include: DDR frequency, DDR loading, DDR low power consumption
configuration, DDR component type and so on. Under the same condition, the power consumption of DDR
components from different vendors may have big difference.

5. VCC_IO

VCC_IO supplies power mainly for IO Pad of SoC and some peripherals. The power consumption can be
analyzed from the following aspects:

  • Check the working status of peripheral module, if there is leakage.
  • Check if IO pin status of SoC matches with the peripheral or not, for example, IO output is high, but the connected peripheral pin is low level.

Common scenario analysis

1. Static desktop

It is mainly the display module which is working, CPU, GPU, DDR should be reduced to the lowest frequency,
and enter low power consumption mode. Adjust VDD_CPU,VDD_GPU,VDD_LOGIC to the lowest voltage of
opp-table, confirm the status of clk_summary and pm_genpd_summary, confirm the peripheral modules
(WIFI, BT, etc.) are all closed. The static desktop generally is used as the basic power consumption of other
scenarios, so need to firstly optimize its power consumption to the best.

2. Video playback

It is mainly the video decoder (VPU/RKVDEC) which is working, GPU generally is closed. Especially confirm if
the running frequency of DDR and voltage of VDD_LOGIC are normal or not.

3. Game

It is mainly CPU and GPU which are working. Especially analyze the loading of CPU and GPU, frequency
change, the voltages of VDD_CPU and VDD_GPU are normal or not.

4. Deepsleep

Generally VDD_CPU and VDD_GPU will turn off the power supply, VDD_LOG only reserves the power supply
for some resume module, so need to focus on the power consumption analysis of IO, DDR components and
some peripherals.

Power consumption optimization strategy

1. CPU optimization

  • Adjust cpufreq parameter.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/* the default frequency scaling strategy used is interactive, relative parameters are 
as follows: */
ls -l /sys/devices/system/cpu/cpu0/cpufreq/interactive
go_hispeed_load    /* when the loading is larger than go_hispeed_load and the frequency
is smaller than hispeed_freq, directly jump to hispeed_freq */

hispeed_freq        /* when jumping from low frequency to high frequency, need to jump
to hispedd_freq first */
above_hispeed_delay /* when the frequency is larger than hispeed_freq, the time duration
before each frequency increase */
min_sample_time    /* after each frequency increase, if it is to reduce the frequency
next time , the time duration before frequency reduce */

target_loads        /* the target loading of the frequency scaling */
timer_rate          /* the loading sampling time,unit:us */
timer_slack         /* the loading sampling time after cpu entering idle */
boost               /* when the frequency is smaller than hispeed_freq, keep boost to
hispeed_freq */
boostpulse          /* when the frequency is smaller than hispeed_freq, boost to
hispeed_freq, keep a while */
boostpulse_duration /* time duration of boostpulse, unit:us */
io_is_busy          /* whether to compute io wait to cpu loading */

We mainly adjust three parameters: hispeed_freq,target_loads,timer_rate:

1. hispeed_freq: select an appropriate transition frequency, to make cpu stable in the
medium frequency, with the best power consumption, too large or too small will cause cpu
jump to high frequency easily and increase the power consumption.
2. target_loads:easier to run with low frequency after this value is increased, both the
power consumption and the performance will be reduced.
3. timer_rate: easier to run with low frequency after this value is increased, both the
power consumption and the performance will be reduced.
  • Close some cpu, limit the highest frequency of cpu.
1
2
3
4
5
6
/* close cpu2,cpu3 */
echo 0 > /sys/devices/system/cpu/cpu2/online
echo 0 > /sys/devices/system/cpu/cpu3/online

/* set the max frequency of cpu0 to 1200MHz */
echo 1200000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq

2. DDR optimization

  • Frequency scaling with scenario: configure different DDR frequencies for different scenarios, such as
    4K video, video recording, dual display and so on.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/* scenario definition */
kernel/include/dt-bindings/soc/rockchip-system-status.h
#define SYS_STATUS_NORMAL (1 << 0)
#define SYS_STATUS_SUSPEND (1 << 1)
#define SYS_STATUS_IDLE (1 << 2)
#define SYS_STATUS_REBOOT (1 << 3)
#define SYS_STATUS_VIDEO_4K (1 << 4)
#define SYS_STATUS_VIDEO_1080P (1 << 5)
#define SYS_STATUS_GPU (1 << 6)
#define SYS_STATUS_RGA (1 << 7)
#define SYS_STATUS_CIF0 (1 << 8)
#define SYS_STATUS_CIF1 (1 << 9)
#define SYS_STATUS_LCDC0 (1 << 10)
#define SYS_STATUS_LCDC1 (1 << 11)
#define SYS_STATUS_BOOST (1 << 12)
#define SYS_STATUS_PERFORMANCE (1 << 13)
#define SYS_STATUS_ISP (1 << 14)
#define SYS_STATUS_HDMI (1 << 15)
#define SYS_STATUS_VIDEO_4K_10B (1 << 16)
#define SYS_STATUS_LOW_POWER (1 << 17)

#define SYS_STATUS_VIDEO (SYS_STATUS_VIDEO_4K | \
SYS_STATUS_VIDEO_1080P | \
SYS_STATUS_VIDEO_4K_10B)
#define SYS_STATUS_DUALVIEW (SYS_STATUS_LCDC0 | SYS_STATUS_LCDC1)

...

/* configure the frequencies for different scenarios in dts */
arch/arm64/boot/dts/rockchip/rk3399-ax2170.dtsi
&dmc {
status = "okay";
center-supply = <&vdd_center>;
upthreshold = <40>;
downdifferential = <20>;
system-status-freq = <
/*system status freq(KHz)*/
SYS_STATUS_NORMAL 856000
SYS_STATUS_REBOOT 856000
SYS_STATUS_SUSPEND 328000
SYS_STATUS_VIDEO_1080P 666000
SYS_STATUS_VIDEO_4K 856000
SYS_STATUS_VIDEO_4K_10B 856000
SYS_STATUS_PERFORMANCE 856000
SYS_STATUS_BOOST 856000
SYS_STATUS_DUALVIEW 856000
SYS_STATUS_ISP 856000
>;
vop-bw-dmc-freq = <
/* min_bw(MB/s) max_bw(MB/s) freq(KHz) */
0 762 416000
763 3012 666000
3013 99999 856000
>;

vop-pn-msch-readlatency = <
0 0x20
4 0x20
>;

auto-min-freq = <328000>;
auto-freq-en = <0>;
};

/* acquire the current scenario */
cat /sys/class/devfreq/dmc/system_status
0x401
  • Frequency scaling with loading: monitor the loading, automatically adjust DDR frequency, frequency
    scaling with loading may cause the reduction of the performance, you can fix DDR frequency in some
    scenario considering the frequency scaling with scenario.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/* configure the parameter of frequency scaling with loading in dts, need to open dfi 
node to monitor DDR utility ratio */
dmc: dmc {
compatible = "rockchip,px30-dmc";
...

/* use dfi to monitor the utility ratio of DDR */
devfreq-events = <&dfi>;
/*
* the threshold of frequency scaling:
* when the utility ratio is over 40%, adjust to the highest frequency.
* when the loading is less than 40% and larger than 40%-20%, maintain current
frequency.

* when the loading is less than 40%-20%, it will adjust the frequency to a certain
value to make the loading to be around 40%-2%/2.

*/
upthreshold = <40>;
downdifferential = <20>;

/* check the DDR loading of current system */
cat /sys/class/devfreq/dmc/load
33@528000000Hz
  • For more detailed configuration and optimization of DDR DEVFREQ, please refer to the document
    《Rockchip-Developer-Guide-Linux4.4-Devfreq》.

3. Thermal control optimization

When the temperature is increasing to certain degree, the power consumption will increase dramatically,
especially in the case with high voltage.

  • Improve the heat dissipation of hardware.
  • Optimize the software thermal control strategy to avoid the big temperature fluctuation.
  • Avoid the high voltage occurring in the case with high temperature through software limitation.
1
2
3
4
5
6
7
8
&cpu0_opp_table {
/* when the temperature is over 85 degree, limit the max voltage of cpu to 1.1V */
rockchip,high-temp = <85000>;
rockchip,high-temp-max-volt = <1100000>;

/* or directly limit the max frequency to avoid the high voltage */
rockchip,high-temp-max-freq = <1008000>;
}

4. Power optimization

  • In voltage conversion circuit, when the voltage reduction and current are relatively large, it is
    recommended to use DCDC to improve the efficiency and reduce the power consumption.

For example:
Input 3.3V, output 1.0V-50mA
|Power Type | Input Current | Power Consumption |
| — | — | — |
| LDO | 50mA | 165mW |
| DCDC(with 80% efficiency) | 18.9mA | 62.4mW |

Git常用命令及操作

发表于 2022-02-08 | 分类于 开发

Git配置

  • Git全局配置

    1
    2
    3
    4
    git config --global user.name "frankieluo"
    git config --global user.email "frankieluo@sina.com"
    git config --global credential.helper store
    git config --global push.default simple

Git基本命令

  • Clone项目

    $ git clone http://gitlab.3bayslife.com:7777/app/alttest.git

  • Status

    $ git status

  • Pull合并项目

    $ git pull

  • Add新的或者修改后的文件

    git add .

  • 提交到本地仓库

    git commit -m "Initial commit"

  • Push到服务器

    git push -u origin master

Git repository 基本操作

  • Create a new repository

    1
    2
    3
    4
    5
    6
    git clone http://gitlab.3bayslife.com:7777/app/alttest.git
    cd alttest
    touch README.md
    git add README.md
    git commit -m "add README"
    git push -u origin master
  • Existing folder

    1
    2
    3
    4
    5
    6
    cd existing_folder
    git init
    git remote add origin http://gitlab.3bayslife.com:7777/app/alttest.git
    git add .
    git commit -m "Initial commit"
    git push -u origin master
  • Existing Git repository

    1
    2
    3
    4
    5
    cd existing_repo
    git remote rename origin old-origin
    git remote add origin http://gitlab.3bayslife.com:7777/app/alttest.git
    git push -u origin --all
    git push -u origin --tags

Git进阶操作

  • 查看远程分支

    $ git branch -a

  • 切换分支

    $ git checkout -b dev origin/dev

    切换回master分支

    $ git checkout master

    再次切回dev分支

    $ git checkout dev

    切换commit分支

    $ git checkout 988d45bae9ceefc9a31b5aadc701f6f115ecd895

  • 服务器代码合并本地代码

    1
    2
    3
    $ git stash     //暂存当前正在进行的工作。
    $ git pull origin master //拉取服务器的代码
    $ git stash pop //合并暂存的代码
  • 回滚本地代码

    $ git reset --hard  //回滚到上一个版本

    $ git checkout -- .

    $ git checkout -- readme.md

  • git rm 与 git rm –cached 的区别
    git rm : 同时从工作区和索引中删除文件。即本地的文件也被删除了。
    git rm –cached : 从索引中删除文件。但是本地文件还存在, 只是不希望这个文件被版本控制。

  • zsh反应慢
    You can add this to your git config and zsh won’t check the status anymore

    git config --add oh-my-zsh.hide-status 1

    git config --add oh-my-zsh.hide-dirty 1

  • git删除未跟踪文件

    删除 untracked files:

    git clean -f

    连 untracked 的目录也一起删掉:

    git clean -fd

    连 gitignore 的untrack 文件/目录也一起删掉 (慎用,一般这个是用来删掉编译出来的 .o之类的文件用的):

    git clean -xfd

    在用上述 git clean 前,墙裂建议加上 -n 参数来先看看会删掉哪些文件,防止重要文件被误删:

    1
    2
    3
    git clean -nxfd
    git clean -nf
    git clean -nfd

git创建新分支并提交到远程

  1. 创建一个本地分支
    git checkout -b 名称

  2. 查看现在的分支状态
    git branch (星号代表当前的分支)

  3. 把新建的分支push到远程,相当于创建一个远程分支
    git push origin 名称:名称

  4. 删除远程分支

    1
    2
    3
    git push origin  :名称
    或者
    git push origin --delete 名称
  5. 删除本地分支(不能在此分支上)
    git branch -d 名称

git log操作

  • How to have git log show filenames like svn log -v:

    For full path names of changed files:

    git log --name-only

    or

    git log --name-only --oneline

  • 查看日期范围内的记录信息

    1
    2
    3
    4
    5
    6
    7
    git log --after="2019-3-31" --before="2019-5-1"

    git log --author="frankieluo" --after="2019-7-30" --before="2019-9-1" > ../usefull/work_JFF2_Aug.log

    git log --author="frankieluo" --after="2019-7-30" --before="2019-9-1" > ../release/work_hardware_test_Aug.log

    git log --author="frankieluo" --after="2019-7-30" --before="2019-9-1" > ../release/alt_test_Aug.log
  • For full path names and status of changed files:
    git log --name-status

  • For abbreviated pathnames and a diffstat of changed files:
    git log --stat

    There’s a lot more options, check out the docs https://git-scm.com/docs/git-log .

  • From the git-diff manpage:

    git log -- vendor/nxp-opensource/uboot-imx/drivers/usb/gadget/fastboot_lock_unlock.h

  • 使用git log查看单个文件改动记录

    git log -- device/fsl/ax2130/overlay/frameworks/base/core/res/res/values/config.xml

    使用git show命令查看commit hashID的详细情况

    git show b61f128ac5015a8c2b14b28c67837ebf1924a5e1

git format-patch

  • 某一笔提交的patch

    git format-patch b61f128ac5015a8c2b14b28c67837ebf1924a5e1 -1

  • 某笔提交(包含)之前的几次提交

    git format-patch commitID -n
    git format-patch b61f128ac5015a8c2b14b28c67837ebf1924a5e1 -2

  • 某两笔(包后不包前)提交之间的所有提交

    git format-patch 1ac240c4561fab6ce400943edb38e46c792b949a..255867fabcf79246d948fadfebe307f8a848bff4

  • 某笔提交(不包含)以后所有提交

    git format-patch 1ac240c4561fab6ce400943edb38e46c792b949a

git merge 解决合并的冲突

把issue2分支和issue3分支的修改合并到master。

  • 切换master分支后,与issue2分支合并。
1
2
3
4
5
6
7
$ git checkout master
Switched to branch 'master'
$ git merge issue2
Updating b2b23c4..8f7aa27
Fast-forward
myfile.txt | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
  • 接着合并issue3分支。
1
2
3
4
$ git merge issue3
Auto-merging myfile.txt
CONFLICT (content): Merge conflict in myfile.txt
Automatic merge failed; fix conflicts and then commit the result.
  • 接着合并issue3分支。
1
2
3
4
$ git merge issue3
Auto-merging myfile.txt
CONFLICT (content): Merge conflict in myfile.txt
Automatic merge failed; fix conflicts and then commit the result.
  • 在发生冲突的地方,Git生成了内容的差异。请做以下修改:
1
2
3
add 把变更录入到索引中
commit 记录索引的状态
pull 取得远端数据库的内容
  • 修改冲突的部分,重新提交
1
2
3
4
$ git add myfile.txt
$ git commit -m "合并issue3分支"
# On branch master
nothing to commit (working directory clean)

Git 合并特定 commits 到另一个分支

git cherry-pick 1ac240

合并某个分支上的一系列commits

在一些特性情况下,合并单个 commit 并不够,你需要合并一系列相连的 commits 。这种情况下就不要选择 cherry-pick 了,rebase 更适合。还以上例为例,假设你需要合并 feature 分支的 commit 76cada ~ 62ecb3 到 dev 分支。

  • 首先需要基于 feature 创建一个新的分支,并指明新分支的最后一个 commit :

git checkout -b newbranch 62ecb3

  • 然后,rebase 这个新分支的 commit 到 dev(–onto dev)。 76cada^ 指明你想从哪个特定的 commit 开始。

git rebase --onto dev 76cada^

得到的结果就是 feature 分支的 commit 76cada ~62ecb3 都被合并到了 dev 分支。

git 删除文件后如何恢复

1
2
3
4
5
6
7
[xxx@xxx static_files]$ git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# deleted: abbr_data
#
  • git reset HEAD abbr_data
  • git checkout -- abbr_data

git diff [–options] [–] […]

  • For instance, to see the difference for a file “main.c” between now and two commits back, here are three equivalent commands:

    1
    2
    3
    $ git diff HEAD^^ HEAD main.c
    $ git diff HEAD^^..HEAD -- main.c
    $ git diff HEAD~2 HEAD -- main.c
  • 某两笔(包前包后)提交之间的所有提交

    git diff commitID1 commitID2 > patch.diff

git apply

  • 检查patch/diff是否能正常打入

    git apply –check file.patch文件
    git apply –check file.diff文件

  • 打入patch/diff

    git apply file.patch文件
    git apply file.diff文件

  • 解决冲突

如果在合入patch的过程中报错了,可以使用下面命令:

git apply –reject file.patch

这个命令会自动合入不冲突的代码,然后保留冲突的部分,同时会生成后缀为.rej的文件,用于保存没有合并进去的部分,可以参考这个进行冲突解决。

解决完冲突后,删除后缀为.rej文件,并执行git add . 添加改动到暂存区

最后执行git am –resolved或者git am –continue

git tag

  • 查看本地分支标签

git tag -l

  • 查看远程所有标签

git ls-remote --tags

  • 给当前分支打标签

git tag v1.1.0

  • 给特定的某个commit版本打标签,比如现在某次提交的id为 039bf8b
1
2
3
4
5
6
7
8
9
git tag v1.0.0 039bf8b

或者可以添加注释

git tag v1.0.0 -m "add tags information" 039bf8b

或者

git tag v1.0.0 039bf8b -m "add tags information"
  • 删除本地某个标签
1
2
3
4
5
6
7
8
9
git tag --delete v1.0.0

或者

git tag -d v1.0.0

或者

git tag --d v1.0.0
  • 删除远程的某个标签
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
git push -d origin v1.0.0

或者

git push --delete origin v1.0.0

或者

git push origin -d v1.0.0

或者

git push origin --delete v1.0.0

或者

git push origin :v1.0.0
  • 将本地标签一次性推送到远程
1
2
3
4
5
6
7
8
9
10
11
12
13
git push origin --tags

或者

git push origin --tag

或者

git push --tags

或者

git push --tag
  • 将本地某个特定标签推送到远程

git push origin v1.0.0

  • 查看某一个标签的提交信息

git show v1.0.0

  • 根据某个commit创建本地分支

例如: 当前分支的某个commit id = 12345678,我们可以基于这个id创建本地分支
git checkout 12345678 -b newBranch

git submodules

  • With version 2.13 of Git and later, –recurse-submodules can be used instead of –recursive:
    git clone --recurse-submodules -j8 git://github.com/foo/bar.git

  • With version 1.9 of Git up until version 2.12 (-j flag only available in version 2.8+):
    git clone --recursive -j8 git://github.com/foo/bar.git

  • With version 1.6.5 of Git and later, you can use:
    git clone --recursive git://github.com/foo/bar.git

  • For already cloned repos, or older Git versions, use:

    1
    2
    3
    git clone git://github.com/foo/bar.git
    cd bar
    git submodule update --init --recursive

git配置代理

  • 添加代理,后面端口号去系统设置 -> 网络和Internet -> 代理
    git config --global https.proxy http://127.0.0.1:10809

  • 去除代理
    git config --global https.proxy ""

  • 查看配置信息

1
2
3
4
5
6
7
git config --global  --list
core.editor="C:\Program Files\Sublime Text 3\subl.exe" -w
user.name=frankieluo
user.email=frankieluo@sina.com
http.sslverify=false
https.sslverify=false
https.proxy=

git进阶用法

  • git status -s | awk '{if ($1 == "M") {print $2} }' | xargs git rm --cached

git常见错误

  • 错误 -fatal: remote origin already exists.

    1、先删除远程 Git 仓库

    $ git remote rm origin

    2、再添加远程 Git 仓库

    $ git remote add origin http://act4.myqnapcloud.com:10080/app/cappec-weather-ios.git

  • 错误 Git refusing to merge unrelated histories

    git pull origin master --allow-unrelated-histories

Android NDK-JNI使用技巧

发表于 2022-01-10 | 分类于 开发

Android NDK-JNI的一些使用技巧

如何在现有项目中加入*.so共享库

  1. 方式一
  • 在”app/src/main/“目录中新建”jniLibs”,将共享库复制到此目录
  • 在android studio中sync files即可
    jniLibs
  1. 方式二
  • 在”app/src/main/“目录中新建”libs”,将共享库复制到此目录
  • 在app/build.gradle中添加libs文件夹路径
1
2
3
4
5
6
7
8
9
10
11
12
13
14
android {
compileSdkVersion 28
defaultConfig {
...

sourceSets {
main {
jni.srcDirs = []
jniLibs.srcDir "src/main/libs"
}
}
}
...
}

如何在现有项目中加入JNI源码

  1. 方式一:使用android studio添加
  • 鼠标右击app工程,选择Add C++ to Module
    jniLibs

  • 选择Link an existing CMakeLists.txt or Android.mk to this module
    jniLibs

  1. 方式二:直接在app/build.gradle中添加代码,其中NDK Version需要更改为android studio设置中指定NDK路径中的版本
1
2
3
4
5
6
7
8
9
10
11
12
13
14
android {
compileSdkVersion 28
defaultConfig {
...

}
externalNativeBuild {
ndkBuild {
path file('src/main/jni/Android.mk')
}
}
ndkVersion '22.1.7171670'
...
}

JNI源码如何生成*.so共享库

  • 找到NDK路径中找到”ndk-build.cmd”,比如我的路径为”C:\Users\ASUS\AppData\Local\Android\Sdk\ndk-bundle\ndk-build.cmd”

  • 在Terminal或者DOS控制到中,CD 到JNI源码位置,然后执行”C:\Users\ASUS\AppData\Local\Android\Sdk\ndk-bundle\ndk-build.cmd”

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    D:\work\App\Myjni\app\src\main\jni>"C:\Users\ASUS\AppData\Local\Android\Sdk\ndk-bundle\ndk-build.cmd"
    fcntl(): Bad file descriptor
    Android NDK: APP_PLATFORM not set. Defaulting to minimum supported version android-16.
    Android NDK: WARNING: APP_PLATFORM android-16 is higher than android:minSdkVersion 1 in D:/work/App/Myjni/app/src/main/AndroidManifest.xml. NDK binaries will *not* be compatible with devices older than android-16. See https://android.googlesource.com/platform
    /ndk/+/master/docs/user/common_problems.md for more information.
    Android NDK: WARNING: Unsupported source file extensions in D:/work/App/Myjni/app/src/main/jni/Android.mk for module i2chmi
    Android NDK: :
    Android NDK: WARNING: Unsupported source file extensions in D:/work/App/Myjni/app/src/main/jni/Android.mk for module i2chmi
    Android NDK: :
    Android NDK: WARNING: Unsupported source file extensions in D:/work/App/Myjni/app/src/main/jni/Android.mk for module i2chmi
    Android NDK: :
    Android NDK: WARNING: Unsupported source file extensions in D:/work/App/Myjni/app/src/main/jni/Android.mk for module i2chmi
    Android NDK: :
    [arm64-v8a] Install : libi2chmi.so => libs/arm64-v8a/libi2chmi.so
    [x86_64] Install : libi2chmi.so => libs/x86_64/libi2chmi.so
    [armeabi-v7a] Install : libi2chmi.so => libs/armeabi-v7a/libi2chmi.so
    [x86] Install : libi2chmi.so => libs/x86/libi2chmi.so

Reference

  • https://developer.android.com/studio/projects/add-native-code?hl=zh-cn
  • https://blog.csdn.net/anhenzhufeng/article/details/78913341
  • https://blog.csdn.net/adojayfan/article/details/120806847

Docker build如何调试

发表于 2021-04-06 | 分类于 工具

前言

Docker编译dockerfile的过程中,经常会碰到构建失败,那么怎样去调试dockerfile呢?
其实Docker编译的时候为每一条编译指令会建立一个临时的镜像,当编译CMD失败时,会保留前一份镜像,我们可以进到这个镜像,然后手动运行下一条CMD,查看编译错误信息。

创建dockerfile

  • mkdir tmp && cd tmp

  • vim Dockerfile

    1
    2
    3
    4
    FROM alpine:3.9
    COPY . /app
    RUN make /app
    CMD python /app/app.py

编译dockerfile

  • docker build -t docker-alpine-test:0.1 .

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    Sending build context to Docker daemon  2.048kB
    Step 1/4 : FROM alpine:3.9
    ---> 78a2ce922f86
    Step 2/4 : COPY . /app
    ---> 2b756be83925
    Step 3/4 : RUN make /app
    ---> Running in 922354c938e3
    /bin/sh: make: not found
    The command '/bin/sh -c make /app' returned a non-zero code: 127

  • $ docker images

    1
    2
    REPOSITORY                   TAG                 IMAGE ID            CREATED             SIZE
    <none> <none> 2b756be83925 9 minutes ago 5.55MB
  • 可以看到docker保留了前一个运行成功的镜像2b756be83925

调试镜像

  • docker run -it 2b756be83925 /bin/sh

    1
    2
    3
    4
    5
    6
    7
    8
    / # ls
    app bin dev etc home lib media mnt opt proc root run sbin srv sys tmp usr var
    / # ls /app/
    Dockerfile
    / # make /app
    /bin/sh: make: not found
    / # python /app/app.py
    /bin/sh: python: not found

Reference

  • https://my.oschina.net/thinwonton/blog/2875227
  • https://docs.docker.com/develop/develop-images/dockerfile_best-practices/

Docker查看容器并安全退出容器

发表于 2021-04-02 | 分类于 工具

前言

Docker中有时候我们会想去查看容器具体内容,文件结构,配置信息等,但如何进入容器内部查看?又如何安全退出而不停止容器呢?

进入容器

  • attach: docker attach fa0b220ed5d0, 此方式只适合本身是可交互方式启动的容器.
  • exec: docker exec -it fa0b220ed5d0 /bin/sh.
    查看exec命令使用说明docker exec -h: “Run a command in a running container”.

退出容器(Ctrl+P+Q)

  • 输入exit或Ctrl+C或Ctrl+D退出容器, 容器也会停止.
  • Ctrl+P+Q, 正常退出而不关闭容器.

Final Cut Pro常用技巧

发表于 2021-03-07 | 分类于 工具

前言

Final Cut Pro 是苹果公司开发的一款专业视频剪辑软件。这里记录一些常用的技巧

基本技巧

  1. 基本工具
    • A选择工具,移动视频会使其他视频位置改变
    • P位置工具,移动视频会遮挡其他视频
    • T裁剪工具,可以调整视频本身的时间
    • B切割工具,可以使用Ctrl+B快捷键替代
    • Z缩放工具,可以使用Ctrl+’+’, Ctril + ‘-‘快捷键替代
  2. 关键帧动画
    • 关键帧是同过视频属性,效果设置不同的参数而成,至少需要打两帧关键帧
    • 选择视频,按Ctrl+v会显示和隐藏关键帧信息
  3. 视频速度调整
    • 所有速度调整都在视频预览窗口下方的圆圈图标按钮
    • 对整段视频做变速,可以先显示速度(shift+n),然后拖动最后速度条小竖线变换视频时间长短调节
    • 速度转场:需要先切割速度,然后对一段视频调整,并保留视频转场
    • 即时重放:可以选中一段视频(打i,o或者用范围选择工具),然后选择即时重放
  4. 调色
    • 色彩基本知识点
      • 色彩因光线而存在。发光物体对应加色模型,三原色是RGB红绿蓝。反光物体对应减色模型,三原色是CMY青品黄。
         
      • 红青、蓝黄、绿品是三组互补色。要增加一种颜色,可以同时增加他的相邻色,或者减少他的互补色。
      • 色相(H)、饱和度(S)和亮度(L)是颜色的三个基本属性。
          
      • 参考链接
        https://zhuanlan.zhihu.com/p/27785954

横竖屏对齐背景放大效果

  1. 新建竖屏视频剪辑
  2. 导入横屏视频
  3. 按住option建,向上或下拖动视频Copy一份
  4. 点击下层视频,在属性中调节变换->缩放,放大至填充屏幕
  5. 可适当调节透明度

给视频添加上下黑边

  • 使用信箱模式

    1. 新建项目并导入视频后,在效果中双击选信箱模式
    2. 在属性中,调节Aspect Ratio为2.35:1,也可以适当调节Offset和Border size
  • 使用裁剪

    1. 新建项目并导入视频后,在属性中选择裁剪
    2. 在上下中,直接输入133.0
  • 调节整个视频的尺寸

    1. 选中项目,信息栏里->修改
    2. 弹出对话框中,视频->自定义->尺寸改为1920x817
    3. 点选视频,在空间符合->类型->选择填充
  • 参考链接
    https://www.bilibili.com/video/av10616842/

视频后期制作小技巧之背景音乐

  1. 使用Downie下载BGM
  2. 使用AU让BGM时长和视频相匹配
    au
    • 拖拽音频文件到文件夹内
    • 文件->新建->多轨回话
    • 拖拽左边文件到右边多轨回话的轨道1中并与开始对齐
    • 点选属性->重新混合->启用重新混合,调节时间为你想要的长度并回车
    • 最后,点击文件->导出->多轨混音->所选剪辑

HDR剪切技巧

  • 正确创建HDR项目

    1. 新建资源库,并’资源库属性’ -> ‘标准’中修改为’广色域HDR’
    2. 新建项目,对于iPhone12拍摄的HDR视频,’编解码器’选择’广色域HDR - Rec. 2020 HLG’
  • HDR项目导入SDR视频偏黑

    1. 添加效果->颜色->HDR工具
    2. 在视频属性HDR工具中模式选择’PQ 转 HLG (Rec.2100)’
    3. 调整’峰值亮度(尼特)’ 为 100
  • SDR项目导入HDR视频过暴

    1. 添加效果->颜色->HDR工具
    2. 在视频属性HDR工具中模式选择’HLG 转 Rec.709 SDR’
  • LUT设置

    1. 尽量使用效果中自定义LUT工具
    2. 然后在属性中输入和输出都选择为’Rec 2020 HLG’

Win10显示器扩展使用技巧

发表于 2021-02-27 | 分类于 工具

前言

多台显示器会带给我们极大便利,提高工作效率。下面介绍一下Win10下显示器扩展的一些小技巧。

镜像与扩展模式

  • Win10设置扩展模式,可以依次点击右下角通知图标->投影去设置
    Win10 display position1

排列显示器

  • 依次右键->显示器设置,在’排列’栏目中可以调整显示器的摆放顺序。可以设置上下,左右,位置可以随意调节。最后点击应用。
    Win10 display position2

Mac显示器扩展使用技巧

发表于 2021-02-26 | 分类于 工具

前言

多台显示器会带给我们极大便利,提高工作效率。下面介绍一下Mac系统下显示器扩展的一些小技巧。

排列显示器

  • 进入左上角苹果图标->系统偏好设置->显示器,在’排列’栏目中可以调整显示器的摆放顺序。可以设置上下,左右,位置可以随意调节。
    mac display position

镜像与扩展模式

  • Mac默认是扩展模式,如果要设置镜像模式,勾选上图中的”镜像显示器”方框。

设置主显示器

  • 拖动上面的小白条,扔到显示器蓝色的框框中。
    mac display main

Python scp自动下载上传文件脚本

发表于 2021-02-25 | 分类于 工具

前言

工作中我们可能经常会需要从服务器或另一台电脑复制大量文件,如果文件在不同的目录,复制就比较麻烦,这个时候用脚本就比较简单了,一键搞定。Python脚本支持多平台,可以在Windows, Mac, Linux上运行。

安装依赖库

  • pip install paramiko
  • pip install scp

直接上源码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import paramiko
from paramiko import SSHClient
from scp import SCPClient
import sys
import datetime

ssh = SSHClient()
ssh.load_system_host_keys()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())

# TODO Step1: 以下4个参数必须改成你自己的服务器配置,依次分别为主机IP地址,SSH端口号(默认22),登录用户名,登录密码
ssh.connect('10.0.11.123', port=22, username='frankieluo', password='123456')

# Define progress callback that prints the current percentage completed for the file
def progress(filename, size, sent):
sys.stdout.write("%s\'s progress: %.2f%% \r" % (filename, float(sent)/float(size)*100) )

# you can also add 4th parameter to track IP and port
# useful with multiple threads to track source
# def progress(filename, size, sent, peername):
# sys.stdout.write("(%s:%s) %s\'s progress: %.2f%% \r" % (peername[0], peername[1], filename, float(sent)/float(size)*100) )

# SCPCLient takes a paramiko transport and progress callback as its arguments.
scp = SCPClient(ssh.get_transport(), progress = progress)

# TODO Step2: 复制文件具体操作,put为上传到服务器,get为下载到本地
scp.put('test.txt', '~/test.txt')

scp.get('test.txt')

# Should now be printing the current progress of your put function.

now = datetime.datetime.now()
sys.stdout.write("\n" + now.isoformat())

scp.close()
  • 根据你的需求,更改TODO标识的地方即可

参考

  • https://pypi.org/project/scp/
123>

24 日志
3 分类
22 标签
© 2025 John Doe
由 Hexo 强力驱动
|
主题 — NexT.Pisces v5.1.4