* enable input device driver first. HID depends on it.
kernel menuconfig -> device drivers -> input device supports
- select Generic input layer
kernel menuconfig -> device drivers -> HID support -> HID bus support ->
- select /dev/hidraw raw HID device support
- select Generic HID driver
CONFIG_INPUT=y
CONFIG_HID=y
CONFIG_HIDRAW=y
CONFIG_HID_GENERIC=y
Thursday, December 7, 2017
Sunday, December 3, 2017
hidraw udev rules
/etc/udev/rules.d/100-hidraw.rules
KERNEL=="hidraw*", SUBSYSTEM=="hidraw", MODE="0664", ATTRS{idVendor}=="1234", ATTRS{idProduct}=="4321", GROUP="plugdev"
Friday, December 1, 2017
linux lsusb
lsusb -vd 2650:1616
echo -n -e '\x66\x6f\x6f' > /dev/hidraw0
echo -n -e \\x66\\x6f\\x6f > /dev/hidraw0
https://www.kernel.org/doc/Documentation/hid/hidraw.txt
echo -n -e '\x66\x6f\x6f' > /dev/hidraw0
echo -n -e \\x66\\x6f\\x6f > /dev/hidraw0
https://www.kernel.org/doc/Documentation/hid/hidraw.txt
libudev to locate hidraw devices attached to the system. There is a tutorial on libudev with a working example at: http://www.signal11.us/oss/udev/
write() -------- The write() function will write a report to the device. For USB devices, if the device has an INTERRUPT OUT endpoint, the report will be sent on that endpoint. If it does not, the report will be sent over the control endpoint, using a SET_REPORT transfer. The first byte of the buffer passed to write() should be set to the report number. If the device does not use numbered reports, the first byte should be set to 0. The report data itself should begin at the second byte.
http://elixir.free-electrons.com/linux/latest/source/samples/hidraw/hid-example.c
http://www.signal11.us/oss/udev/
$/sys/class/hidraw/hidraw0$ ls
/sys/class/hidraw/hidraw0/device
/sys/bus/usb/devices/2-1.2/
Thursday, November 30, 2017
Set Linux Terminal Console Column Width
* use variable $COLUMNS specifies the wide on terminal session is
ex) export COLUMNS=100
Wednesday, November 29, 2017
how to check kernel module address
cat /proc/modules
cat /proc/kallsyms
/sys/module/<MODULE_NAME>/sections/
cat /proc/kallsyms
/sys/module/<MODULE_NAME>/sections/
Friday, November 3, 2017
github download a commit
wget https://github.com/{username}/{project name}/commit/{sha1}.patch
wget https://github.com/ebmajor/my_github_project/commit/4cea0bd9d9151c3036b59e4131c53339b1a0e1f5.patch
wget https://github.com/ebmajor/my_github_project/commit/4cea0bd9d9151c3036b59e4131c53339b1a0e1f5.patch
Thursday, November 2, 2017
openwrt open-wrt
Adding configuration options
If you would like configure your package installation/compilation in the menuconfig you can do the following: Add MENU:=1 to your package definition like this:
define Package/mjpg-streamer SECTION:=multimedia CATEGORY:=Multimedia TITLE:=MJPG-streamer DEPENDS:=@!LINUX_2_4 +libpthread-stubs +jpeg URL:=http://mjpg-streamer.wiki.sourceforge.net/ MENU:=1 endef
Create a config key in the Makefile:
define Package/mjpg-streamer/config source "$(SOURCE)/Config.in" endef
Create a Config.in file directory where the Makefile is located with the content like this:
# Mjpg-streamer configuration menu "Configuration" depends on PACKAGE_mjpg-streamer config MJPEG_STREAMER_AUTOSTART bool "Autostart enabled" default n menu "Input plugins" depends on PACKAGE_mjpg-streamer config MJPEG_STREAMER_INPUT_FILE bool "File input plugin" help You can stream pictures from jpg files on the filesystem default n config MJPEG_STREAMER_INPUT_UVC bool "UVC input plugin" help You can stream pictures from an Universal Video Class compatible webcamera default y config MJPEG_STREAMER_FPS depends MJPEG_STREAMER_INPUT_UVC int "Maximum FPS" default 15 config MJPEG_STREAMER_PICT_HEIGHT depends MJPEG_STREAMER_INPUT_UVC int "Picture height" default 640 config MJPEG_STREAMER_PICT_WIDTH depends MJPEG_STREAMER_INPUT_UVC int "Picture width" default 480 config MJPEG_STREAMER_DEVICE depends MJPEG_STREAMER_INPUT_UVC string "Device" default /dev/video0 config MJPEG_STREAMER_INPUT_GSPCA bool "GSPCA input plugin" help You can stream pictures from a gspca supported webcamera Note this module is deprecated, use the UVVC plugin instead default n endmenu # ...... endmenu
Above you can see examples for various type config parameters.
And finally you can check your configuration parameters in your Makefile in the following way: (Note that you can reference to the parameters value with it name prefixed with CONFIG_)
ifeq ($(CONFIG_MJPEG_STREAMER_INPUT_UVC),y) $(CP) $(PKG_BUILD_DIR)/input_uvc.so $(1)/usr/lib endif
Monday, October 30, 2017
macbook airport
cd /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources
sudo ./airport en0 -I
sudo ./airport en0 -I
Monday, October 23, 2017
dump mtd block in linux kernel
uboot$ smem
kernel$ cat /proc/mtd
kernel$ ls -l /dev/
kernel$ hexdump -C /dev/mtdblock7 -s 4096 -n 1024
(offset 4096 == 0x1000, len = 1024)
dd if=/dev/mtdblock7 of=/root/data.bin count=64 bs=1024
dd if=/dev/mtd7 of=/root/data.bin bs=32 count=377 skip=128
bs: block size to read at once
count: number of 'bs' to run
* total size = bs * count = 64KB
* flash erase on kernel
kernel$flash_erase /dev/mtdblock7
* flash copy on kernel
kernel$ flashcp u-boot-env /dev/mtdblock7
kernel$ cat /proc/mtd
kernel$ ls -l /dev/
kernel$ hexdump -C /dev/mtdblock7 -s 4096 -n 1024
(offset 4096 == 0x1000, len = 1024)
dd if=/dev/mtdblock7 of=/root/data.bin count=64 bs=1024
dd if=/dev/mtd7 of=/root/data.bin bs=32 count=377 skip=128
bs: block size to read at once
count: number of 'bs' to run
* total size = bs * count = 64KB
* flash erase on kernel
kernel$flash_erase /dev/mtdblock7
* flash copy on kernel
kernel$ flashcp u-boot-env /dev/mtdblock7
Thursday, October 12, 2017
Tuesday, October 10, 2017
hostapd.conf
--- default:: hostapd-etsi-vht80.conf
driver=nl80211
logger_syslog=127
logger_syslog_level=2
logger_stdout=127
logger_stdout_level=2
country_code=DK
ieee80211d=1
ieee80211h=1
hw_mode=a
channel=52
ieee80211n=1
ht_capab=[HT40+][LDPC][SHORT-GI-20][SHORT-GI-40][TX-STBC][RX-STBC1][DSSS_CCK-40]
vht_oper_chwidth=1
vht_oper_centr_freq_seg0_idx=58
ieee80211ac=1
vht_capab=[RXLDPC][SHORT-GI-80][TX-STBC-2BY1][SU-BEAMFORMER][SU-BEAMFORMEE][MU-BEAMFORMER][RX-ANTENNA-PATTERN][TX-ANTENNA-PATTERN][MAX-MPDU-11454][RX-STBC-1][MAX-A-MPDU-LEN-EXP7]
interface=wlan2
ctrl_interface=/var/run/hostapd
disassoc_low_ack=0
preamble=1
wmm_enabled=1
ignore_broadcast_ssid=0
uapsd_advertisement_enabled=1
auth_algs=1
wpa=0
ssid=5G-DFS
bridge=br-lan
***
802.11ac may have one of three lengths: 3,895 bytes, 7,991 bytes, or 11,454 bytes.
but hostapd accept only 7991 and 11454.
[MAX-MPDU-7991]
[MAX-MPDU-11454]
The maximum length of an A-MPDU is controlled by the value of a field called the Maximum A-MPDU Length Exponent, which describes the maximum length of an A-MPDU by the formula
2^(13+Exponent) - 1 bytes.
802.11ac allows values for the exponent ranging from 0 to 7, which allows the maximum A-MPDU length to range from 8 KB to 1 MB.
[MAX-A-MPDU-LEN-EXP7] ~ [MAX-A-MPDU-LEN-EXP1]
Monday, October 9, 2017
android alarm dump
adb shell dumpsys alarm
alarmManager.cancel(pendingIntent)
and pendingIntent.cancel()
Tuesday, October 3, 2017
sharing files on windows among windows, linux, and mac
* using samba protocol
* set-up folder sharing on windows
* on Linux
* install cifs-utils
sudo apt install cifs-utils
* PETER-DESKTOP is to be added to /etc/hosts
* add credential info
----- credential info -----
cat /home/peter/.smbcredentials
username=Peter
password=Password
peter@peter-linux-dell:~$ ls -al .smbcredentials (root, 0600)
-rw------- 1 root root 187 Oct 3 15:16 .smbcredentials
* add this line to /etc/fstab
----- /etc/fstab -----
//PETER-DESKTOP/shares /home/peter/shares cifs auto,iocharset=utf8,uid=1000,credentials=/home/peter/.smbcredentials,file_mode=0775,dir_mode=0775 0 0
* set-up folder sharing on windows
* on Linux
* install cifs-utils
sudo apt install cifs-utils
* PETER-DESKTOP is to be added to /etc/hosts
* add credential info
----- credential info -----
cat /home/peter/.smbcredentials
username=Peter
password=Password
peter@peter-linux-dell:~$ ls -al .smbcredentials (root, 0600)
-rw------- 1 root root 187 Oct 3 15:16 .smbcredentials
-------------------------------------------------------------------------------
----- /etc/fstab -----
//PETER-DESKTOP/shares /home/peter/shares cifs auto,iocharset=utf8,uid=1000,credentials=/home/peter/.smbcredentials,file_mode=0775,dir_mode=0775 0 0
-------------------------------------------------------------------------------
Friday, September 29, 2017
Thursday, September 21, 2017
how to find the location of installed packages (or libraries)
sudo dpkg -L packagename
sudo dpkg -L libnl-3-dev
sudo apt install libnl-genl-3-dev
sudo dpkg -L libnl-genl-3-dev
Wednesday, September 20, 2017
finding missing header files in ubuntu
sudo apt install apt-file
apt-file update
apt-file search netlink/genl/genl.h
libnl-3-dev: /usr/include/libnl3/netlink/genl/genl.h
sudo apt-get install libnl-3-dev
Thursday, September 14, 2017
Wednesday, September 13, 2017
c programming variables' memory location check
gcc -O0 memory.c -Wl,-Map=output.map
memory map of memory sections
https://www.ele.uva.es/~jesus/hardware_empotrado/Compiler.pdf
memory map of memory sections
https://www.ele.uva.es/~jesus/hardware_empotrado/Compiler.pdf
sparse build check
https://kernelnewbies.org/Sparse
http://jake.dothome.co.kr/sparse/
* smatch ??
http://smatch.sourceforge.net/
http://events.linuxfoundation.org/sites/events/files/slides/Static%20code%20checking.pdf
sudo apt-get install sparse
How to use sparse
Choose a subdirectory in the kernel tree that you want to check for sparse warnings and errors, for instance that could be drivers/staging/wlan-ng, and do:
$ make C=2 drivers/staging/wlan-ng/
You can use the variable CF to pass more checkflags to sparse. For example, you can enable endian checks doing:
$ make C=2 CF="-D__CHECK_ENDIAN__" drivers/staging/wlan-ng/
The warnings produced indicate sites in code where types relevant to byteorder are mixed, possibly leading to buggy behavior.
You can observe what are the default checkflags set in the Makefile. You will see something close to the following:
CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \ -Wbitwise -Wno-return-void $(CF)
http://jake.dothome.co.kr/sparse/
* smatch ??
http://smatch.sourceforge.net/
http://events.linuxfoundation.org/sites/events/files/slides/Static%20code%20checking.pdf
Tuesday, September 12, 2017
802.11ac Max. length of A-MPDU
Maximum A-MPDU Length Exponent
Indicates the maximum length of A-MPDU that the STA can receive.
EOF padding is not included in this limit.
This field is an integer in the range of 0 to 7.
The length defined by this field is equal to
2 ^(13 + Maximum A-MPDU Length Exponent) – 1 octets.
Following are some of the useful attributes of 11ac MAC layer.
• MSDU size for MAC payload - 2304
• MPDU size for MAC frame - 11,454
• PSDU size(PLCP payload) - About 4MB
• PPDU size(PLCP frame) - 5.484 ms
hostapd.conf
MAX-A-MPDU-LEN-EXP1 ~ MAX-A-MPDU-LEN-EXP7
MAX-MPDU-7991 or MAX-MPDU-11454
Thursday, August 24, 2017
iperf TOS option
CLIENT SPECIFIC OPTIONS
-S, --tos N set the IP 'type of service'
The type-of-service for outgoing packets. (Many routers ignore the TOS field.)
You may specify the value in hex with a '0x' prefix, in octal with a '0' prefix, or in decimal.
For example, '0x10' hex = '020' octal = '16' decimal.
The TOS numbers specified in RFC 1349 are:
IPTOS_LOWDELAY minimize delay 0x10
IPTOS_THROUGHPUT maximize throughput 0x08
IPTOS_RELIABILITY maximize reliability 0x04
IPTOS_LOWCOST minimize cost 0x02
0 1 2 3 4 5 6 7
+-----+-----+-----+-----+-----+-----+-----+-----+
| PRE | | M |
| CEDENCE | TOS | B |
| | | Z |
+-----+-----+-----+-----+-----+-----+-----+-----+
"PRECEDENCE" is intended to denote the importance or priority of the datagram.
The last field, labeled "MBZ" (for "must be zero") above, is currently unused.
1000 -- minimize delay ( + MBZ (0) = 1000 0 = 1 0000 = 0x10)
0100 -- maximize throughput ( + MBZ (0) = 0100 0 = 0 1000 = 0x08)
0010 -- maximize reliability ( + MBZ (0) = 0010 0 = 0 0100 = 0x04)
0001 -- minimize monetary cost ( + MBZ (0) = 0001 0 = 0 0010 = 0x02)
0000 -- normal service ( + MBZ (0) = 0000 0 = 0 0000 = 0x00)
* bit 3: minimize delay, bit 4: maximize throughput, bit 5: maximize reliability
PRECEDENCE
000 Routine
001 Priority
010 Immediate
011 Flash
100 FlashOverride
101 Critical
110 InterNetwork Control
111 Network Control
A. DOD DD173 Precedence/Priority Filed Explanations (Lowest-Highest):
Routine: (R) “…is used for all messages that justify transmission by electrical means unless the message delivery is of sufficient urgency to require higher precedence.”
Priority: (P) “…is used for all messages that require expeditious action by the addressee(s) and/or furnish essential information for the conduct of ongoing operations.”
Immediate (O) “…is reserved for messages relating to situations that gravely affect the security of National/Allied forces or populace.”
Flash (Z) “…is reserved for initial enemy contact messages or operational combat messages of extreme urgency.”
Flash Override (X) “… is reserved for messages relating to the outbreak of hostilities and/or detonation of nuclear devices.”
CRITIC/ECP “…stands for “Critical and Emergency Call Processing” and should only be used for authorized emergency communications, for example in the United States Government Emergency Telecommunications Service (GETS), the United Kingdom Government Telephone Preference Scheme (GTPS) and similar government emergency preparedness or reactionary implementations elsewhere.”
1. Network Control “…is intended to be used within a network only. The actual use and control of that designation is up to each network.”
2. Internetwork Control “…is intended for use by gateway control originators only.”
TOS (Dec) | TOS (Hex) | TOS (Bin) | TOS Precedence (Bin) | TOS Precedence (Dec) | TOS Precedence Name | TOS Delay flag | TOS Throughput flag | TOS Reliability flag | DSCP (Bin) | DSCP (Hex) | DSCP (Dec) | DSCP/PHB Class |
---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 0x00 | 00000000 | 000 | 0 | Routine | 0 | 0 | 0 | 000000 | 0x00 | 0 | none |
4 | 0x04 | 00000100 | 000 | 0 | Routine | 0 | 0 | 1 | 000001 | 0x01 | 1 | none |
8 | 0x08 | 00001000 | 000 | 0 | Routine | 0 | 1 | 0 | 000010 | 0x02 | 2 | none |
12 | 0x0C | 00001100 | 000 | 0 | Routine | 0 | 1 | 1 | 000011 | 0x03 | 3 | none |
16 | 0x10 | 00010000 | 000 | 0 | Routine | 1 | 0 | 0 | 000100 | 0x04 | 4 | none |
32 | 0x20 | 00100000 | 001 | 1 | Priority | 0 | 0 | 0 | 001000 | 0x08 | 8 | cs1 |
40 | 0x28 | 00101000 | 001 | 1 | Priority | 0 | 1 | 0 | 001010 | 0x0A | 10 | af11 |
48 | 0x30 | 00110000 | 001 | 1 | Priority | 1 | 0 | 0 | 001100 | 0x0C | 12 | af12 |
56 | 0x38 | 00111000 | 001 | 1 | Priority | 1 | 1 | 0 | 001110 | 0x0E | 14 | af13 |
64 | 0x40 | 01000000 | 010 | 2 | Immediate | 0 | 0 | 0 | 010000 | 0x10 | 16 | cs2 |
72 | 0x48 | 01001000 | 010 | 2 | Immediate | 0 | 1 | 0 | 010010 | 0x12 | 18 | af21 |
80 | 0x50 | 01010000 | 010 | 2 | Immediate | 1 | 0 | 0 | 010100 | 0x14 | 20 | af22 |
88 | 0x58 | 01011000 | 010 | 2 | Immediate | 1 | 1 | 0 | 010110 | 0x16 | 22 | af23 |
96 | 0x60 | 01100000 | 011 | 3 | Flash | 0 | 0 | 0 | 011000 | 0x18 | 24 | cs3 |
104 | 0x68 | 01101000 | 011 | 3 | Flash | 0 | 1 | 0 | 011010 | 0x1A | 26 | af31 |
112 | 0x70 | 01110000 | 011 | 3 | Flash | 1 | 0 | 0 | 011100 | 0x1C | 28 | af32 |
120 | 0x78 | 01111000 | 011 | 3 | Flash | 1 | 1 | 0 | 011110 | 0x1E | 30 | af33 |
128 | 0x80 | 10000000 | 100 | 4 | FlashOverride | 0 | 0 | 0 | 100000 | 0x20 | 32 | cs4 |
136 | 0x88 | 10001000 | 100 | 4 | FlashOverride | 0 | 1 | 0 | 100010 | 0x22 | 34 | af41 |
144 | 0x90 | 10010000 | 100 | 4 | FlashOverride | 1 | 0 | 0 | 100100 | 0x24 | 36 | af42 |
152 | 0x98 | 10011000 | 100 | 4 | FlashOverride | 1 | 1 | 0 | 100110 | 0x26 | 38 | af43 |
160 | 0xA0 | 10100000 | 101 | 5 | Critical | 0 | 0 | 0 | 101000 | 0x28 | 40 | cs5 |
176 | 0xB0 | 10110000 | 101 | 5 | Critical | 1 | 0 | 0 | 101100 | 0x2C | 44 | voice-admit |
184 | 0xB8 | 10111000 | 101 | 5 | Critical | 1 | 1 | 0 | 101110 | 0x2E | 46 | ef |
192 | 0xC0 | 11000000 | 110 | 6 | InterNetwork Control | 0 | 0 | 0 | 110000 | 0x30 | 48 | cs6 |
224 | 0xE0 | 11100000 | 111 | 7 | Network Control | 0 | 0 | 0 | 111000 | 0x38 | 56 | cs7 |
Subscribe to:
Posts (Atom)