Good practices, useful tools, tips and tricks etc. for embedded developers. All in one place.
Thursday, August 30, 2012
Fog photography
A nice tutorial on fog photography, how to make the best of it. Not avoiding or removing it but taking it as an advantage. http://www.cambridgeincolour.com/tutorials/fog-photography.htm
Thursday, February 16, 2012
Ubiquiti AirCam serial console boot
The price-performance HD camera from Ubiquiti has a serial console where you can access the operating system (Linux). Pins for the console are not present on the PCB so you have to solder them by yourself - it should be an easy task as the pins are 100mils and are located on the edge of PCB. But be careful and remember, you are doing it on your own responsibility! And soldering on PCB definitely voids your warranty.
To cut this story short, the console pins use TTL 3.3V levels so you need an TTL-RS232 signal level converter (Max, Nokia cable, CP2102 USB adapter etc.). The console parameters are 38400-8-none-1. Have fun!
The console output:
MP SPI-NOR Bootstrap v0.2
Boot image offset: 0x6000. Booting Image .....
0567Will set the following freq...
PLL1: 800 MHz, PLL2: 540 MHz, CPU freq: 540 MHz, AHB freq: 270 MHz, DDR freq: 800 MHz
go...
*********************************************
Please input Space to run Linux
Please input ESC to run UBOOT
Please input . to run burn-in
Otherwise, system will run Linux after 5 sec
*********************************************
Load image from SPI-NOR offset 0xa6000 to sdram 0x4000000
Jump 0x4000000
U-Boot 2008.10-svn8779 (Apr 19 2011 - 18:25:15)
DRAM: 128 MB
Manufacturer ID : 0018
Device ID : 009F
Device Code 2 : 0018
Flash: 0 kB
*** Warning - bad CRC, using default environment
flash no default environment
In: serial
Out: serial
Err: serial
Net: FTMAC110#0
Reset button is not active.
SF: Got idcode c2 20 17
Hit any key to stop autoboot: 0
## Starting application at 0x04000000 ...
Uncompressing Linux... done, booting the kernel.
Linux version 2.6.28 (buildd@builder) (gcc version 4.5.2 (Linaro GCC 4.5-2011.02-0) ) #1 PREEMPT Fri Nov 25 17:54:59 EET 2011
CPU: FA626TE [66056261] revision 1 (ARMv5TE), cr=0000797f
CPU: VIPT aliasing data cache, VIPT aliasing instruction cache
Machine: Faraday GM8126
Warning: bad configuration page, trying to continue
Memory policy: ECC disabled, Data cache writeback
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 32512
Kernel command line: mem=128M console=uart,shift,2,io,0xF9830000,38400 init=/init root=/dev/mtdblock2 rootfstype=squashfs
Early serial console at I/O port 0xf9830000 (options '38400', shift 2)
console [uart0] enabled
PID hash table entries: 512 (order: 9, 2048 bytes)
IC: GM8128 MP
GM Clock: CPU = 540 MHz, AHBCLK = 270 MHz, PLL1CLK = 800 MHz, PLL2CLK = 540 MHz
console handover: boot [uart0] -> real [ttyS0]
Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
Memory: 128MB = 128MB total
Memory: 126904KB available (2442K code, 283K data, 108K init)
Calibrating delay loop... 534.52 BogoMIPS (lpj=267264)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
net_namespace: 652 bytes
Fmem: node 0 is online, alloc pages = 20480(active pages = 32768)
high_memory:0xc8000000, VM Start:0xc8800000, End:0xe0000000
NET: Registered protocol family 16
PMU: Mapped at 0xf9900000
pmu_get_cpu_clk:203 <fclk_mode=2, pll2_out=540000000>
Attach GM AHB-DMA Driver
SCSI subsystem initialized
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 4096 (order: 3, 32768 bytes)
TCP bind hash table entries: 4096 (order: 2, 16384 bytes)
TCP: Hash tables configured (established 4096 bind 4096)
TCP reno registered
NET: Registered protocol family 1
Video Timer(timer3) Max 31000ms in 0xf9720840 HZ.
squashfs: version 4.0 (2009/01/31) Phillip Lougher
msgmni has been set to 248
io scheduler noop registered
io scheduler anticipatory registered (default)
io scheduler deadline registered
io scheduler cfq registered
probe ftgpio010.0 OK!!, at c8808000
probe ftgpio010.1 OK!!, at c880c000
probe ftgpio010.2 OK!!, at c8810000
Serial: 8250/16550 driver 4 ports, IRQ sharing disabled
serial8250: ttyS0 at I/O 0xf9830000 (irq = 9) is a 16550A
serial8250: ttyS1 at I/O 0xf9840000 (irq = 10) is a 16550A
serial8250: ttyS2 at I/O 0xf9880000 (irq = 21) is a 16550A
serial8250: ttyS3 at I/O 0xf9890000 (irq = 22) is a 16550A
brd: module loaded
PPP generic driver version 2.4.2
NET: Registered protocol family 24
Linux video capture interface: v2.00
Driver 'sd' needs updating - please use bus_type methods
Driver 'sr' needs updating - please use bus_type methods
Creating 5 MTD partitions on "wb_spi_flash":
0x00000000-0x000e0000 : "boot"
0x000e0000-0x00200000 : "kernel"
0x00200000-0x007b0000 : "rootfs"
0x007b0000-0x007f0000 : "cfg"
0x007f0000-0x00800000 : "eeprom"
Probe FTSSP010 SPI Controller at 0x98200000 (irq 6)
mice: PS/2 mouse device common for all mice
i2c /dev entries driver
ftiic010 ftiic010.0: irq 18, mapped at c8818000
Advanced Linux Sound Architecture Driver Version 1.0.18rc3.
ALSA device list:
No soundcards found.
TCP cubic registered
NET: Registered protocol family 10
lo: Disabled Privacy Extensions
IPv6 over IPv4 tunneling driver
sit0: Disabled Privacy Extensions
NET: Registered protocol family 17
802.1Q VLAN Support v1.8 Ben Greear <greearb@candelatech.com>
All bugs added by David S. Miller <davem@redhat.com>
VFS: Mounted root (squashfs filesystem) readonly.
Freeing init memory: 108K
Please be patient, while OpenWrt loads ...
...mounts done
...filesystem init done
...base ok
...update ok
...symlinks ok
...httpd ok
...detect ok
...video ok
...running /sbin/init
init started: BusyBox v1.18.4 (2011-11-25 17:48:51 EET)
Please press Enter to activate this console.
To cut this story short, the console pins use TTL 3.3V levels so you need an TTL-RS232 signal level converter (Max, Nokia cable, CP2102 USB adapter etc.). The console parameters are 38400-8-none-1. Have fun!
The console output:
MP SPI-NOR Bootstrap v0.2
Boot image offset: 0x6000. Booting Image .....
0567Will set the following freq...
PLL1: 800 MHz, PLL2: 540 MHz, CPU freq: 540 MHz, AHB freq: 270 MHz, DDR freq: 800 MHz
go...
*********************************************
Please input Space to run Linux
Please input ESC to run UBOOT
Please input . to run burn-in
Otherwise, system will run Linux after 5 sec
*********************************************
Load image from SPI-NOR offset 0xa6000 to sdram 0x4000000
Jump 0x4000000
U-Boot 2008.10-svn8779 (Apr 19 2011 - 18:25:15)
DRAM: 128 MB
Manufacturer ID : 0018
Device ID : 009F
Device Code 2 : 0018
Flash: 0 kB
*** Warning - bad CRC, using default environment
flash no default environment
In: serial
Out: serial
Err: serial
Net: FTMAC110#0
Reset button is not active.
SF: Got idcode c2 20 17
Hit any key to stop autoboot: 0
## Starting application at 0x04000000 ...
Uncompressing Linux... done, booting the kernel.
Linux version 2.6.28 (buildd@builder) (gcc version 4.5.2 (Linaro GCC 4.5-2011.02-0) ) #1 PREEMPT Fri Nov 25 17:54:59 EET 2011
CPU: FA626TE [66056261] revision 1 (ARMv5TE), cr=0000797f
CPU: VIPT aliasing data cache, VIPT aliasing instruction cache
Machine: Faraday GM8126
Warning: bad configuration page, trying to continue
Memory policy: ECC disabled, Data cache writeback
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 32512
Kernel command line: mem=128M console=uart,shift,2,io,0xF9830000,38400 init=/init root=/dev/mtdblock2 rootfstype=squashfs
Early serial console at I/O port 0xf9830000 (options '38400', shift 2)
console [uart0] enabled
PID hash table entries: 512 (order: 9, 2048 bytes)
IC: GM8128 MP
GM Clock: CPU = 540 MHz, AHBCLK = 270 MHz, PLL1CLK = 800 MHz, PLL2CLK = 540 MHz
console handover: boot [uart0] -> real [ttyS0]
Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
Memory: 128MB = 128MB total
Memory: 126904KB available (2442K code, 283K data, 108K init)
Calibrating delay loop... 534.52 BogoMIPS (lpj=267264)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
net_namespace: 652 bytes
Fmem: node 0 is online, alloc pages = 20480(active pages = 32768)
high_memory:0xc8000000, VM Start:0xc8800000, End:0xe0000000
NET: Registered protocol family 16
PMU: Mapped at 0xf9900000
pmu_get_cpu_clk:203 <fclk_mode=2, pll2_out=540000000>
Attach GM AHB-DMA Driver
SCSI subsystem initialized
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 4096 (order: 3, 32768 bytes)
TCP bind hash table entries: 4096 (order: 2, 16384 bytes)
TCP: Hash tables configured (established 4096 bind 4096)
TCP reno registered
NET: Registered protocol family 1
Video Timer(timer3) Max 31000ms in 0xf9720840 HZ.
squashfs: version 4.0 (2009/01/31) Phillip Lougher
msgmni has been set to 248
io scheduler noop registered
io scheduler anticipatory registered (default)
io scheduler deadline registered
io scheduler cfq registered
probe ftgpio010.0 OK!!, at c8808000
probe ftgpio010.1 OK!!, at c880c000
probe ftgpio010.2 OK!!, at c8810000
Serial: 8250/16550 driver 4 ports, IRQ sharing disabled
serial8250: ttyS0 at I/O 0xf9830000 (irq = 9) is a 16550A
serial8250: ttyS1 at I/O 0xf9840000 (irq = 10) is a 16550A
serial8250: ttyS2 at I/O 0xf9880000 (irq = 21) is a 16550A
serial8250: ttyS3 at I/O 0xf9890000 (irq = 22) is a 16550A
brd: module loaded
PPP generic driver version 2.4.2
NET: Registered protocol family 24
Linux video capture interface: v2.00
Driver 'sd' needs updating - please use bus_type methods
Driver 'sr' needs updating - please use bus_type methods
Creating 5 MTD partitions on "wb_spi_flash":
0x00000000-0x000e0000 : "boot"
0x000e0000-0x00200000 : "kernel"
0x00200000-0x007b0000 : "rootfs"
0x007b0000-0x007f0000 : "cfg"
0x007f0000-0x00800000 : "eeprom"
Probe FTSSP010 SPI Controller at 0x98200000 (irq 6)
mice: PS/2 mouse device common for all mice
i2c /dev entries driver
ftiic010 ftiic010.0: irq 18, mapped at c8818000
Advanced Linux Sound Architecture Driver Version 1.0.18rc3.
ALSA device list:
No soundcards found.
TCP cubic registered
NET: Registered protocol family 10
lo: Disabled Privacy Extensions
IPv6 over IPv4 tunneling driver
sit0: Disabled Privacy Extensions
NET: Registered protocol family 17
802.1Q VLAN Support v1.8 Ben Greear <greearb@candelatech.com>
All bugs added by David S. Miller <davem@redhat.com>
VFS: Mounted root (squashfs filesystem) readonly.
Freeing init memory: 108K
Please be patient, while OpenWrt loads ...
...mounts done
...filesystem init done
...base ok
...update ok
...symlinks ok
...httpd ok
...detect ok
...video ok
...running /sbin/init
init started: BusyBox v1.18.4 (2011-11-25 17:48:51 EET)
Please press Enter to activate this console.
Saturday, December 10, 2011
AVCHD in Avidemux
AVCHD is a HD movie format that is present on many consumer cameras, most notably on Panasonic TZ (SZ in America) compact series. Searching for a decent replacement for VirtualDub (Swiss army knife for video editing) for Windows I came across Avidemux. It is a nice tool but still in development stage so it has some problems with editing AVCHD movies - for example, trying to save a part of a AVCHD movie into MPEG4 format without recording (video copy, audio copy) produces corrupt movies with either sound not working or not synchronized with picture etc. But there is a solution or at least a workaround for it: replace the AVCHD container* with MPEG4v2 and the editing works as it should.
In this step FFmpeg utility comes handy - with a simple script, similar to the one mentioned in the "Batch convert MP3 bitrate on Windows using lame MP3 encoder" post we can change the container:
forfiles /m *.mts /c "cmd /c ffmpeg.exe -i @file -acodec copy -vcodec copy @file.mp4"
But be sure to have enough free disk space before starting the process. :) After the conversion you have the choice: delete the AVCHD (*.MTS) files and keep the new MPEG4 files for archiving purposes or vice versa. But be aware: FFmpeg does not support the hdmv_pgs_subtitle data stream (GPS information embedded in the video) so this information could be lost with the conversion.
*What is a container (or mux/demux)? It is a "receipt" how video and audio stream(s) are saved inside a file. So by changing the container the video and audio streams get somehow reordered inside the file but the actual content of a streams do not change. There is no recoding involved, just pure copying from source to destination file. This is a quite important because:
In this step FFmpeg utility comes handy - with a simple script, similar to the one mentioned in the "Batch convert MP3 bitrate on Windows using lame MP3 encoder" post we can change the container:
forfiles /m *.mts /c "cmd /c ffmpeg.exe -i @file -acodec copy -vcodec copy @file.mp4"
But be sure to have enough free disk space before starting the process. :) After the conversion you have the choice: delete the AVCHD (*.MTS) files and keep the new MPEG4 files for archiving purposes or vice versa. But be aware: FFmpeg does not support the hdmv_pgs_subtitle data stream (GPS information embedded in the video) so this information could be lost with the conversion.
*What is a container (or mux/demux)? It is a "receipt" how video and audio stream(s) are saved inside a file. So by changing the container the video and audio streams get somehow reordered inside the file but the actual content of a streams do not change. There is no recoding involved, just pure copying from source to destination file. This is a quite important because:
- It is fast.
- There is no loss in quality.
Thursday, November 24, 2011
Get signal quality from GPRS modem
A quite sophisticated bash script for getting signal quality (AT+CSQ) from GPRS modem:
#!/bin/bash
function get_response
{
local ECHO
# cat will read the response, then die on timeout
cat <&5 >$TMP &
echo "$1" >&5
# wait for cat to die
wait $!
exec 6<$TMP
read ECHO <&6
if [ "$ECHO" != "$1" ]
then
exec 6<&-
return 1
fi
read ECHO <&6
read RESPONSE <&6
exec 6<&-
return 0
}
TMP="/tmp/response"
# Clear out old response
: > $TMP
# Set modem with timeout of 5/10 a second
stty -F /dev/ttyACM0 -echo igncr -icanon onlcr ixon min 0 time 5
# Open modem on FD 5
exec 5<>/dev/ttyACM0
get_response "AT" || echo "Bad response"
RESPONSE=`cat $TMP`
echo "Response was ${RESPONSE}"
echo
get_response "AT+CSQ" || echo "Bad response"
RESPONSE=`cat $TMP`
echo "Response was ${RESPONSE}"
exec 5<&-
#!/bin/bash
function get_response
{
local ECHO
# cat will read the response, then die on timeout
cat <&5 >$TMP &
echo "$1" >&5
# wait for cat to die
wait $!
exec 6<$TMP
read ECHO <&6
if [ "$ECHO" != "$1" ]
then
exec 6<&-
return 1
fi
read ECHO <&6
read RESPONSE <&6
exec 6<&-
return 0
}
TMP="/tmp/response"
# Clear out old response
: > $TMP
# Set modem with timeout of 5/10 a second
stty -F /dev/ttyACM0 -echo igncr -icanon onlcr ixon min 0 time 5
# Open modem on FD 5
exec 5<>/dev/ttyACM0
get_response "AT" || echo "Bad response"
RESPONSE=`cat $TMP`
echo "Response was ${RESPONSE}"
echo
get_response "AT+CSQ" || echo "Bad response"
RESPONSE=`cat $TMP`
echo "Response was ${RESPONSE}"
exec 5<&-
Tuesday, November 15, 2011
GCC 4: error: lvalue required as increment operand
If you are compiling C code with GCC 4.x version you might receive the error:
error: lvalue required as increment operand
error: lvalue required as increment operand
But the code compiled flawlessly with older versions of GCC.
The problem lies in GCC 4 which is a little more picky about the code. So we need to fix the code. Here is an example of the problematic code:
void CopyFromFrame8900(void *Dest, unsigned int Size)
{
*((unsigned int *)Dest)++ = ReadFrame8900();
}
And the fix for it:
void CopyFromFrame8900(void *Dest, unsigned int Size)
{
*((unsigned int *)Dest) = ReadFrame8900();
Dest = (void *)Dest + 1;
}
Sunday, November 13, 2011
Preferred video/audio codecs in Windows
Ever tried to open a AVCHD (h264) video stream in VirtualDub? Well, it is not that simple - VirtualDub is designed for Video For Windows (VFW) interface, but AVCHD decoders work as DirectShow filters. It is like expecting an iPhone application to work on the Android phone.
The solution for the problem (opening AVCHD in VirtualDub) is to use DirectShow plugin for VirtualDub that allows you to open the video. You can get the plugin here: http://forums.virtualdub.org/index.php?act=ST&f=7&t=15093&st=0
Of course you also need an AVCHD (h264) decoder that is VirtualDub compatible (supports RGB decoded output) where Microsoft DTV-DVD Video Decoder isn't. But there are many options, FFmepeg is one of them, feel free to choose one yourself.
So you have DirectShow plugin and some RGB-compatible decoder installed but the video is still not displayed in VirtualDub. You see a green area where the actual video picture should be previewed and VirtualDub might be complaining about decoder's RGB compatibility. The problem is in the priority list of decoders that still picks MS DTV-DVD decoder. You can change this with some registry editing but there is something better - a utility for changing decoder priorities: http://www.codecguide.com/windows7_preferred_filter_tweaker.htm
The usage is straight forward so happy video editing once it works.
The solution for the problem (opening AVCHD in VirtualDub) is to use DirectShow plugin for VirtualDub that allows you to open the video. You can get the plugin here: http://forums.virtualdub.org/index.php?act=ST&f=7&t=15093&st=0
Of course you also need an AVCHD (h264) decoder that is VirtualDub compatible (supports RGB decoded output) where Microsoft DTV-DVD Video Decoder isn't. But there are many options, FFmepeg is one of them, feel free to choose one yourself.
So you have DirectShow plugin and some RGB-compatible decoder installed but the video is still not displayed in VirtualDub. You see a green area where the actual video picture should be previewed and VirtualDub might be complaining about decoder's RGB compatibility. The problem is in the priority list of decoders that still picks MS DTV-DVD decoder. You can change this with some registry editing but there is something better - a utility for changing decoder priorities: http://www.codecguide.com/windows7_preferred_filter_tweaker.htm
The usage is straight forward so happy video editing once it works.
Monday, September 26, 2011
Check compact flash (CF) memory card integrity
Sometimes compact flash (CF) memory cards cause troubles. And you don't know if the problem is the card or the reader, maybe something else? A small utility that might come handy in that situation: http://www.thelifedigital.com/scan-the-flash-drive-for-errors-with-check-flash/
Direct link for utility download if the page above dies: http://www.mikelab.kiev.ua/PROGRAMS/ChkFlsh.zip
And may all your bits be with you!
Direct link for utility download if the page above dies: http://www.mikelab.kiev.ua/PROGRAMS/ChkFlsh.zip
And may all your bits be with you!
Subscribe to:
Posts (Atom)