2017年3月7日星期二
What's inside initrd (x86_64)
1 File Only - GenuineIntel.bin
Suspect extraction failed.
Get the answer from stackexchange with few modification.
http://unix.stackexchange.com/questions/163346/why-is-it-that-my-initrd-only-has-one-directory-namely-kernel
Instead, do this:
Suspect extraction failed.
Get the answer from stackexchange with few modification.
http://unix.stackexchange.com/questions/163346/why-is-it-that-my-initrd-only-has-one-directory-namely-kernel
$file initrd.img
initrd.img: ASCII cpio archive (SVR4 with no CRC)
$mkdir initTree && cd initTree
$cpio -idv < ../initrd.img
`-- kernel
`-- x86
`-- microcode
`-- GenuineIntel.bin
The cpio block skip method given doesn't work reliably. That's because the initrd images didn't have both archives concatenated on a 512 byte boundary.Instead, do this:
apt-get install binwalk
DECIMAL HEXADECIMAL DESCRIPTION -------------------------------------------------------------------------------- 0 0x0 ASCII cpio archive (SVR4 with no CRC), file name: "kernel", file name length: "0x00000007", file size: "0x00000000" 120 0x78 ASCII cpio archive (SVR4 with no CRC), file name: "kernel/x86", file name length: "0x0000000B", file size: "0x00000000" 244 0xF4 ASCII cpio archive (SVR4 with no CRC), file name: "kernel/x86/microcode", file name length: "0x00000015", file size: "0x00000000" 376 0x178 ASCII cpio archive (SVR4 with no CRC), file name: "kernel/x86/microcode/GenuineIntel.bin", file name length: "0x0000002A", file size: "0x00005400" 22032 0x5610 ASCII cpio archive (SVR4 with no CRC), file name: "TRAILER!!!", file name length: "0x0000000B", file size: "0x00000000" 22528 0x5800 gzip compressed data, from Unix, last modified: 2017-03-06 14:00:21 10181078 0x9B59D6 MySQL ISAM index file Version 3
dd if=initrd.img bs=22528 skip=1 | gunzip | cpio -id 1778+1 records in 1778+1 records out 40073444 bytes (40 MB, 38 MiB) copied, 3.15216 s, 12.7 MB/s 209980 blocks
ls -l total 39208 drwxr-xr-x 2 yip yip 4096 Mar 7 21:36 bin drwxr-xr-x 3 yip yip 4096 Mar 7 21:36 conf drwxr-xr-x 10 yip yip 4096 Mar 7 21:36 etc -rwxr-xr-x 1 yip yip 6907 Mar 7 21:36 init -rw-r--r-- 1 yip yip 40095972 Mar 7 21:30 initrd.img drwxr-xr-x 9 yip yip 4096 Mar 7 21:36 lib drwxr-xr-x 2 yip yip 4096 Mar 7 21:36 lib64 drwxr-xr-x 2 yip yip 4096 Mar 7 21:36 run drwxr-xr-x 2 yip yip 4096 Mar 7 21:36 sbin drwxr-xr-x 7 yip yip 4096 Mar 7 21:36 scripts drwxr-xr-x 4 yip yip 4096 Mar 7 21:36 usr drwxr-xr-x 4 yip yip 4096 Mar 7 21:36 var
2015年10月29日星期四
USBUART module in PSoC5
I currently try to use the CYPRESS PSoC5 (CY8C5888P) chip to capture the signals and send to PC for further analysing in real time. Found that the USBUART module inside this chip is petty good.
Advantages:
1) Automatically generate the INF file. (Act as Virtual COM Port in PC, use usbser.dll, CDC Device)
2) Great data throughput. It can reach minimum ~1.7Mb/s. (Manual DMA mode + triple buffering were used to handle the sampling data, act as Virtual COM Port in PC).
3) Built-in configuration panel. Easy to use.
4) The source code which is generated by PSoC creator is tiny and clear (well optimised). Easy to understand.
5) Examples and Documents are provided.
In order to archive high data throughput, the key points are:
1) use DMA mode if possible.
2) Familiar with HDL is an advantage. You can describe your hardware module using schematic / HDL in this chip.
3) In the PC side, choose the right RS-232 terminal.
I have tried ReadTerm and Bray++ terminal.
I will give Bray++ terminal as 3.5/5
and RealTerm as 4.5/5 (-0.5 because of the user interface...)
I found that some received "block" are missing in Bray++ terminal (It does not support >1,000,000bps well ?!).
RealTerm does not have this issue so far.
2015年10月16日星期五
Capture USB traffic in windows 8
USBPCap + Wireshark
1) Execute USBPcapCMD.exe, check the target device node.
2) Select the target device node, start to capture the file (.pcap).
3) View the pcap file by using Wireshark
For more information, please check:
http://desowin.org/usbpcap/tour.html
1) Execute USBPcapCMD.exe, check the target device node.
2) Select the target device node, start to capture the file (.pcap).
3) View the pcap file by using Wireshark
For more information, please check:
http://desowin.org/usbpcap/tour.html
2015年9月26日星期六
Build the u-boot for raspberry pi 2
Cross compile in ubuntu environment.
1) Download required arm compiler.
I choose the most common one for testing only (not the optimized one).
sudo apt-get install gcc-arm-linux-gnueabi
ncurses-dev is required if you want to config the option by using 'make menuconfig'.
sudo apt-get install ncurses-dev
Get the u-boot package
2) git clone git://git.denx.de/u-boot.git
build the u-boot backage
3) make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- rpi_2_defconfig
Optional) make menuconfig
4) make -j8 V=1
Option) make -j8 V=1 2>&1 | tee build.log | less
Option) make -j8 SHELL='sh -x'
V=1: Output more message during build
u-boot.bin will be generated under the u-boot root directory.
Copy the u-boot.bin to the micro SD-CARD
1) Download required arm compiler.
I choose the most common one for testing only (not the optimized one).
sudo apt-get install gcc-arm-linux-gnueabi
ncurses-dev is required if you want to config the option by using 'make menuconfig'.
sudo apt-get install ncurses-dev
Get the u-boot package
2) git clone git://git.denx.de/u-boot.git
build the u-boot backage
3) make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- rpi_2_defconfig
Optional) make menuconfig
4) make -j8 V=1
Option) make -j8 V=1 2>&1 | tee build.log | less
Option) make -j8 SHELL='sh -x'
V=1: Output more message during build
u-boot.bin will be generated under the u-boot root directory.
Copy the u-boot.bin to the micro SD-CARD
2015年9月11日星期五
Connect STM32F103V8 with ECLIPSE+GDB+JLINK
Use SWD debugging interface.
1) Start the JLINK GDB Server
cd "c:\Program Files (x86)\SEGGER\JLinkARM_V440"
JLinkGDBServer.exe -if swd
2) In the debug configuration:
monitor flash download = 1
monitor flash breakpoints = 1
monitor reg r13 = (0x00000000)
monitor reg pc = (0x00000004)
1) Start the JLINK GDB Server
cd "c:\Program Files (x86)\SEGGER\JLinkARM_V440"
JLinkGDBServer.exe -if swd
2) In the debug configuration:
monitor flash download = 1
monitor flash breakpoints = 1
monitor reg r13 = (0x00000000)
monitor reg pc = (0x00000004)
2015年8月21日星期五
ESP8266 Extend AT command set - Part1
I need to try their SDK example first in order to extend the AT command set.
1) Download the required tools
a) Download the Lubuntu VirtualBox image which is provided by Espressif.
(Provide compiler tool-chain already)
b) Download the latest SDK.
c) Download the FLASH programming tools. (For Windows)
2) According to the readme file, copy the SDK to the share folder.
e.g. Place in D:\Share
After that, setup the share folder path in VirtualBox (D:\Share <-> Share).
VBoxImage default username: esp8266
VBoxImage default password: espressif
{SDK} means ~/Share/esp_iot_sdk_v1.3.0
3) Copy {SDK}/examples/at/ to {SDK}/app/
4) In {SDK}/app/user/user_main.c
modify to
void ICACHE_FLASH_ATTR
at_testCmdTest(uint8_t id)
{
uint8 buffer[32] = {0};
os_sprintf(buffer, "%s\r\n", "my at_testCmdTest");
at_port_print(buffer);
at_response_ok();
}
4) cd {SDK}/app/
5) ./gen_misc.sh
Select below options:
boot_v1.2+
user1.bin
spi speed: default
spi mode: default
spi size and map: 1024KB( 512KB+ 512KB)
6) Download the user1.1024.new.?.bin to the FLASH ---> 0x1000
7) Try to run AT+TEST=? in CuteCOM.
it should return my at_testCmdTest.
1) Download the required tools
a) Download the Lubuntu VirtualBox image which is provided by Espressif.
(Provide compiler tool-chain already)
b) Download the latest SDK.
c) Download the FLASH programming tools. (For Windows)
2) According to the readme file, copy the SDK to the share folder.
e.g. Place in D:\Share
After that, setup the share folder path in VirtualBox (D:\Share <-> Share).
VBoxImage default username: esp8266
VBoxImage default password: espressif
{SDK} means ~/Share/esp_iot_sdk_v1.3.0
3) Copy {SDK}/examples/at/ to {SDK}/app/
4) In {SDK}/app/user/user_main.c
modify to
void ICACHE_FLASH_ATTR
at_testCmdTest(uint8_t id)
{
uint8 buffer[32] = {0};
os_sprintf(buffer, "%s\r\n", "my at_testCmdTest");
at_port_print(buffer);
at_response_ok();
}
4) cd {SDK}/app/
5) ./gen_misc.sh
Select below options:
boot_v1.2+
user1.bin
spi speed: default
spi mode: default
spi size and map: 1024KB( 512KB+ 512KB)
6) Download the user1.1024.new.?.bin to the FLASH ---> 0x1000
7) Try to run AT+TEST=? in CuteCOM.
it should return my at_testCmdTest.
ESP8266 - A Great Product
In ESP8266 SDK,
Something that interests me:
1) Support RTC.
2) SDK provides several functions to get the time using SNTP protocol.
3) Support SSL (Only allow single client connection only)
The default value of maximum SSL packet size is 2KB.
The maximum size packet can be adjusted.
It is good enough for a single IOT SOC chip (Just HKD 12)...
Then, focus on the SSL, found one more interesting thing...
Someone lists out the object symbols in his blog:)
http://41j.com/blog/2015/01/esp8266-sdk-library-symbols/
Many standardized cryptography algorithms (RSA, SHA1, MD5, AES..) have already provided in the object library files,
but they are not explicitly exposed by the vendor.
In other words, once we disassemble the code,
and trace how the parameters passed in these functions (XTENSA ABI).
Actually, it is not necessary to re-implement the cryptography function (greatly reduce the code size).
Something that interests me:
1) Support RTC.
2) SDK provides several functions to get the time using SNTP protocol.
3) Support SSL (Only allow single client connection only)
The default value of maximum SSL packet size is 2KB.
The maximum size packet can be adjusted.
Then, focus on the SSL, found one more interesting thing...
Someone lists out the object symbols in his blog:)
http://41j.com/blog/2015/01/esp8266-sdk-library-symbols/
Many standardized cryptography algorithms (RSA, SHA1, MD5, AES..) have already provided in the object library files,
but they are not explicitly exposed by the vendor.
In other words, once we disassemble the code,
and trace how the parameters passed in these functions (XTENSA ABI).
Actually, it is not necessary to re-implement the cryptography function (greatly reduce the code size).
ESP8266 Initial Test
The module I use: ESP-8266 ESP-01
1) Wire Connection
Since the USB to UART TTL module may not provide sufficient power for ESP-01,
use external power supply is recommended.
3.3V <-> ESP8266 VCC
3.3V <-> ESP8266 CH_PD
USB to UART TTL module RX <-> ESP8266 TX
USB to UART TTL module TX <-> ESP8266 RX
GND <-> USB to UART TTL module GND <-> ESP8266 GND
*: GPIO0 should be connected to GND if we want to update the firmware. Reboot is required before update.
For general purpose, GPIO0 can be float.
==========================================
2) Testing
In Linux environment, CuteCOM is recommended for testing the communication.
Below is the setup procedures:
Device: /dev/ttyUSB0
Baud rate: 115200
Data bits: 8
Stop bits: 1
Parity: None
Handshake: uncheck both
linefeed: default should be set to CR LF (sometimes you need to switch to use HEX Input format e.g. send raw byte)
Open the COM port and listen the response.
reboot the ESP-01 module.
It should return [Ready] string.
P.S.:
Please update to the latest firmware before use:
The latest firmware uses 115200, 8N1, AT COMMAND LINE END - CR LF for communication.
Before update the firmware, we need to download the SDK and the FLASH PROGRAMMING TOOLS first.
More details can be found in SDK documentation.
In CuteCOM, enter the following commands.
Input AT
response OK means success.
Input AT+CWMODE=1
For STATION MODE only . (3=STATION MODE+ SOFTAP MODE)
Input AT+CWLAP
List available access point.
============================================
3) NTP Client Implementation
Get current time stamp using NTP
#RESET
AT+RST
#GET FIRMWARE VER
#AT+GMR
#SET TO STATION MODE
AT+CWMODE=1
#LIST AP
AT+CWLAP
#CONNECT ACCESS POINT
AT+CWJAP="SSID","Password"
#MAKE CONNECTION.
#參考自:https://github.com/sandeepmistry ... lient/NTPClient.ino
#Other NTP Server might not work...
AT+CIPSTART="UDP","129.6.15.28",123
#SEND NTP PACKET
AT+CIPSEND=48
IN CuteCOM, change to HEX input.
Input the following:
E30006EC0000000000000000314E31340000000000000000000000000000000000000000000000000000000000000000
It should return 48 bytes packet.
1) Wire Connection
Since the USB to UART TTL module may not provide sufficient power for ESP-01,
use external power supply is recommended.
3.3V <-> ESP8266 VCC
3.3V <-> ESP8266 CH_PD
USB to UART TTL module RX <-> ESP8266 TX
USB to UART TTL module TX <-> ESP8266 RX
GND <-> USB to UART TTL module GND <-> ESP8266 GND
*: GPIO0 should be connected to GND if we want to update the firmware. Reboot is required before update.
For general purpose, GPIO0 can be float.
==========================================
2) Testing
In Linux environment, CuteCOM is recommended for testing the communication.
Below is the setup procedures:
Device: /dev/ttyUSB0
Baud rate: 115200
Data bits: 8
Stop bits: 1
Parity: None
Handshake: uncheck both
linefeed: default should be set to CR LF (sometimes you need to switch to use HEX Input format e.g. send raw byte)
Open the COM port and listen the response.
reboot the ESP-01 module.
It should return [Ready] string.
P.S.:
Please update to the latest firmware before use:
The latest firmware uses 115200, 8N1, AT COMMAND LINE END - CR LF for communication.
Before update the firmware, we need to download the SDK and the FLASH PROGRAMMING TOOLS first.
More details can be found in SDK documentation.
In CuteCOM, enter the following commands.
Input AT
response OK means success.
Input AT+CWMODE=1
For STATION MODE only . (3=STATION MODE+ SOFTAP MODE)
Input AT+CWLAP
List available access point.
============================================
3) NTP Client Implementation
Get current time stamp using NTP
#RESET
AT+RST
#GET FIRMWARE VER
#AT+GMR
#SET TO STATION MODE
AT+CWMODE=1
#LIST AP
AT+CWLAP
#CONNECT ACCESS POINT
AT+CWJAP="SSID","Password"
#MAKE CONNECTION.
#參考自:https://github.com/sandeepmistry ... lient/NTPClient.ino
#Other NTP Server might not work...
AT+CIPSTART="UDP","129.6.15.28",123
#SEND NTP PACKET
AT+CIPSEND=48
IN CuteCOM, change to HEX input.
Input the following:
E30006EC0000000000000000314E31340000000000000000000000000000000000000000000000000000000000000000
It should return 48 bytes packet.
2015年4月12日星期日
ECC notes
ECC Brief
Q = kP can be expand as several of point doubling + point addition operation
"point doubling + point addition operation" can be expand as several field multiplication + field addition operation
Selection
Selection
at the field level:
F2m,
Fp, Fpm
poly
basis / normal basis
Field
arithmetic algorithm
Selection
at the elliptic curve level:
affine
coordinate / projective coordinate
point
addition / double algorithm
protocol
level:
appropriate
protocol (key exchange / signature)
algorithm
for kP
Fp
affine
coordinate
projective
coordinate - one is called Jacobin.
Doubling:
2J -> J 4M, 3S
Mixed
Coordinate : J+A -> J 8M + 3S
F2m
Point Multiplication
Binary method:
(m/2)PointAdd + (m) PointDouble
NAF method: (m/3)
PointAdd + (m) PointDouble
Montgomery
Multiplication: (6M+5S+3A)m + (1I+10M)
Message Protocol
Diffie Hellman Key
Exchange (man-in-the-middle attack?):
Use same G (base
point) and poly.
Server private key:
PrS
Client private key:
PrC
Server public key:
PuS
Client public key:
PuC
訂閱:
文章 (Atom)









