Month: January 2016

My IPCam is crashing

Just reporting an issue I got on my IPCamera:

[  113.580000] Unhandled fault: external abort on non-linefetch (0x808) at 0xfc000004
[  113.590000] Internal error: : 808 [#1] PREEMPT
[  113.590000] Modules linked in: rt3070sta sslsd sslotg ssludc snd_soc_magus snd_soc_magus_pcm snd_soc_o
[  113.590000] CPU: 0    Not tainted  (2.6.24ssl #200)
[  113.590000] pc : []    lr : []    psr: a0000013
[  113.590000] sp : c0ed7b34  ip : 00000ba4  fp : c0ed7b44
[  113.590000] r10: c0ed7ed0  r9 : c0ed6000  r8 : c0ed6000
[  113.590000] r7 : c0c52000  r6 : 00000000  r5 : 00000000  r4 : c0c52fe4
[  113.590000] r3 : fc000000  r2 : 0000c0e6  r1 : c0c523dc  r0 : 00000002
[  113.590000] Flags: NzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment user
[  113.590000] Control: 0005317f  Table: 51aac000  DAC: 00000015
[  113.590000] Process encoder (pid: 299, stack limit = 0xc0ed6258)
[  113.590000] Stack: (0xc0ed7b34 to 0xc0ed8000)
[  113.590000] 7b20:                                              782c7ee0 c0ed7b58 c0ed7b48 
[  113.590000] 7b40: c0147090 bf005a24 bece8d00 c0ed7b68 c0ed7b5c bf005cbc c014707c c0ed7b8c 
[  113.590000] 7b60: c0ed7b6c c01dd9d8 bf005cb0 0000000a 00000000 c0ed7ed0 bece8d00 bece8d08 
[  113.590000] 7b80: c0ed7ea0 c0ed7b90 c01de194 c01dd9ac c0892140 00000002 c0ed7bb8 c0ed7ba8 
[  113.590000] 7ba0: c0039658 c0039530 c0892140 c0ed7bcc c0ed7bbc c0039fbc c003963c c02dc908 
[  113.590000] 7bc0: 00000003 c02dc908 0000000a 00000000 00000000 00000000 c0ed7c08 c0ed7be8 
[  113.590000] 7be0: c003a678 c003a48c 80000093 00000001 00000001 c095fca4 c095fc98 c0ed7c18 
[  113.590000] 7c00: c0ed7c0c c003c210 c003a5f8 c02cdab0 00000000 00000000 c02cda8c c02cda8c 
[  113.590000] 7c20: c0ed7c58 c0ed7c30 c006bcd8 c006b04c c02cdab0 00000000 00000001 00000000 
[  113.590000] 7c40: c02cda8c 001200d2 00000000 c0ed7c80 c0ed7c5c c006bf28 c003a48c c02cda8c 
[  113.590000] 7c60: c02cdaa4 60000013 c02cda8c c0f6b9b0 00000000 c0ed7cc4 c0ed7c84 c006c1ac 
[  113.590000] 7c80: c003a48c 00000000 00000000 00000000 00000000 c02ce2a4 00000044 c02ce2a4 
[  113.590000] 7ca0: 001200d2 c02ce2a0 00000000 c0f6b9b0 bece8000 c03a3c00 c0ed7d04 c0ed7cc8 
[  113.590000] 7cc0: c006cd5c c006bf54 c02ce2a4 001200d2 c03048c0 00000010 c0d866c8 00000000 
[  113.590000] 7ce0: bece8000 c0ed7d04 c0ed7d04 bece8000 512c605f 512c60ff c0ed7d44 c0ed7d08 
[  113.590000] 7d00: c0076ad0 c003a48c c0e58ba0 00000000 00000000 00000008 c10115e0 c0eaefb0 
[  113.590000] 7d20: c0eac000 515030df c0f6b9b0 bece8000 c10115e0 000003a0 c0ed7d90 c0ed7d48 
[  113.590000] 7d40: c0077a58 c0076550 c0eaefb0 c1011620 515030df c0ed7d7c c0ed6000 c0ed7d80 
[  113.590000] 7d60: c0ed7d6c c0110124 c003a48c 00000008 c03a3c00 c0ed7d90 c0ed7d84 c0059200 
[  113.590000] 7d80: c0110074 c0ed7dcc c0ed7d94 c0026904 c0059200 c02dc908 00000001 00000800 
[  113.590000] 7da0: 0000081f ffffffff c02c41d8 0000081f c0ed7e78 bece8a30 a0000013 40311000 
[  113.590000] 7dc0: c0ed7e74 c0ed7dd0 c002021c c00267a8 c0c63df4 c0ed7df0 c0ed7df8 c0330e00 
[  113.590000] 7de0: c0ed7ee0 c0ed7e10 c0ed7df4 c008274c c01144d0 c0c27868 c0ed7ee0 0000001c 
[  113.590000] 7e00: c1368b34 c0ed7e24 c0ed7e14 c004ab98 c0082738 c0c27868 c0ed7e50 c0ed7e28 
[  113.590000] 7e20: c004af90 c004ab54 c03a3e0c c0ed6000 c0ed7e50 c0ed7e40 c004a9f0 c004a950 
[  113.590000] 7e40: c03a3e0c c0ed7e8c c0ed7e54 c004b0b4 c004a9e4 c0039110 c02dc8c0 c03a3c30 
[  113.590000] 7e60: c0ed7e88 c0ed7e70 c01d8f94 c011075c c0ed7ed0 c02f3000 00008946 00000000 
[  113.590000] 7e80: bece8d08 c02f3000 00000000 c0ed6000 c0ed7ed0 c0ed7f18 c0ed7ea4 c01dc758 
[  113.590000] 7ea0: c01ddb58 c0bf7e60 20000013 c0ed7ed8 c0ed7ebc c0082eb0 c01144d0 c0bf7e60 
[  113.590000] 7ec0: c0ed7f08 c0bf7e60 c0ed7ee8 c0ed7ed8 30687465 00000000 00000000 00000000 
[  113.590000] 7ee0: bece8d00 00000000 00000000 00000000 fffffdfd 00008946 bece8d08 c02f3000 
[  113.590000] 7f00: 00000000 c0ed6000 40311000 c0ed7f38 c0ed7f1c c01ce740 c01dc214 c0357b20 
[  113.590000] 7f20: ffffffe7 bece8d08 00008946 c0ed7f58 c0ed7f3c c0093688 c01ce56c c0357b20 
[  113.590000] 7f40: c0bf7e84 bece8d08 00000014 c0ed7f84 c0ed7f5c c00939ac c009365c c0087bf8 
[  113.590000] 7f60: c003a48c c0357b20 fffffff7 00008946 00000036 c0021064 c0ed7fa4 c0ed7f88 
[  113.590000] 7f80: c0093a0c c00936f0 00000001 00000014 bece8d08 00054b80 00000000 c0ed7fa8 
[  113.590000] 7fa0: c0020ec0 c00939dc 00000014 bece8d08 00000014 00008946 bece8d08 ffffffff 
[  113.590000] 7fc0: 00000014 bece8d08 00054b80 00000001 0000b3f0 00000000 40311000 00000000 
[  113.590000] 7fe0: 00054384 bece8d00 0002425c 402aec04 20000010 00000014 00000000 00000000 
[  113.590000] Backtrace: 
[  113.590000] Function entered at [] from []
[  113.590000] Function entered at [] from []
[  113.590000]  r4:bece8d00
[  113.590000] Function entered at [] from []
[  113.590000] Function entered at [] from []
[  113.590000]  r6:bece8d08 r5:bece8d00 r4:c0ed7ed0
[  113.590000] Function entered at [] from []
[  113.590000] Function entered at [] from []
[  113.590000] Function entered at [] from []
[  113.590000]  r7:00008946 r6:bece8d08 r5:ffffffe7 r4:c0357b20
[  113.590000] Function entered at [] from []
[  113.590000]  r7:00000014 r6:bece8d08 r5:c0bf7e84 r4:c0357b20
[  113.590000] Function entered at [] from []
[  113.590000]  r8:c0021064 r7:00000036 r6:00008946 r5:fffffff7 r4:c0357b20
[  113.590000] Function entered at [] from []
[  113.590000]  r6:00054b80 r5:bece8d08 r4:00000014
[  113.590000] Code: e1822013 e18120bc e5913018 e19120bc (e1c320b4) 
[  113.600000] ---[ end trace 2337af3bc9041353 ]---
Segmentation fault
/ # [  115.010000] Unhandled fault: external abort on non-linefetch (0x808) at 0xfc000004
[  115.010000] Internal error: : 808 [#2] PREEMPT
[  115.010000] Modules linked in: rt3070sta sslsd sslotg ssludc snd_soc_magus snd_soc_magus_pcm snd_soc_o
[  115.010000] CPU: 0    Tainted: G      D  (2.6.24ssl #200)
[  115.010000] pc : []    lr : []    psr: 80000093
[  115.010000] sp : c0fffeb8  ip : c0fffeb8  fp : c0fffed8
[  115.010000] r10: c0c52000  r9 : c02c67f4  r8 : c0c52360
[  115.010000] r7 : 0000016e  r6 : 00000000  r5 : 60000013  r4 : c0c523dc
[  115.010000] r3 : 00000ba4  r2 : 00003090  r1 : fc000000  r0 : 00000000
[  115.010000] Flags: Nzcv  IRQs off  FIQs on  Mode SVC_32  ISA ARM  Segment user
[  115.010000] Control: 0005317f  Table: 51aac000  DAC: 00000015
[  115.010000] Process encoder (pid: 328, stack limit = 0xc0ffe258)
[  115.010000] Stack: (0xc0fffeb8 to 0xc1000000)
[  115.010000] fea0:                                                       c06bff30 00000000 
[  115.010000] fec0: c0c524ac c0c523dc c0c52f90 c0fffef8 c0fffedc bf002b7c bf0028c8 c02de8e0 
[  115.010000] fee0: c0c52484 c0c523bc c0c523dc c0ffff24 c0fffefc bf006a40 bf002b6c 1ad27480 
[  115.010000] ff00: 00000102 c0ffe000 c02de8e0 c0ffff28 bf0069b8 00000001 c0ffff5c c0ffff28 
[  115.010000] ff20: c0049c88 bf0069c8 c0d86758 c08e7b50 c0ffff3c 00000001 c02de6a4 0000000a 
[  115.010000] ff40: c02de660 00000000 c0ffe000 00000006 c0ffff7c c0ffff60 c00456a8 c0049b0c 
[  115.010000] ff60: c02ca5e0 00000018 c02edf48 00000000 c0ffff8c c0ffff80 c00458b4 c004565c 
[  115.010000] ff80: c0ffffac c0ffff90 c0020048 c0045880 ffffffff be3ff79c ffffffe7 00000001 
[  115.010000] ffa0: 00000000 c0ffffb0 c0020ccc c0020010 fffffffb fffffffa 00000009 0000008f 
[  115.010000] ffc0: fffffffb be3ff79c 00001925 fffffffc 00008366 00000001 00000006 00000000 
[  115.010000] ffe0: fffffff4 be3ff5f4 00000000 0003d668 60000010 ffffffff 00000000 00000000 
[  115.010000] Backtrace: 
[  115.010000] Function entered at [] from []
[  115.010000]  r7:c0c52f90 r6:c0c523dc r5:c0c524ac r4:00000000
[  115.010000] Function entered at [] from []
[  115.010000]  r6:c0c523dc r5:c0c523bc r4:c0c52484
[  115.010000] Function entered at [] from []
[  115.010000] Function entered at [] from []
[  115.010000] Function entered at [] from []
[  115.010000]  r7:00000000 r6:c02edf48 r5:00000018 r4:c02ca5e0
[  115.010000] Function entered at [] from []
[  115.010000] Function entered at [] from []
[  115.010000] Exception stack(0xc0ffffb0 to 0xc0fffff8)
[  115.010000] ffa0:                                     fffffffb fffffffa 00000009 0000008f 
[  115.010000] ffc0: fffffffb be3ff79c 00001925 fffffffc 00008366 00000001 00000006 00000000 
[  115.010000] ffe0: fffffff4 be3ff5f4 00000000 0003d668 60000010 ffffffff                   
[  115.010000]  r7:00000001 r6:ffffffe7 r5:be3ff79c r4:ffffffff
[  115.010000] Code: e5941018 e59f30a0 e1a00006 e18420b3 (e1c120b4) 
[  115.020000] Kernel panic - not syncing: Fatal exception in interrupt

And there are the u-boot configuration:

object$ p  
Unknown command 'p' - try 'help'
object$ pri
bootdelay=1
baudrate=115200
ethaddr=00:02:04:06:08:0a
ipaddr=192.168.3.189
bootfile="uImage"
filesize=153000
bootcmd=bootm 0x10030000
bootargs=mem=20M console=ttyS0,115200 init=/init root=/dev/mtdblock3
stdin=serial
stdout=serial
stderr=serial

Environment size: 244/32764 bytes
Advertisements

Configuring Linux’s serial port to raw mode

I was facing a strange issue when debugging a serial communication from a microcontroller on a Linux machine.

I was using this command to print modem communication:

$ cat /dev/ttyUSB0 | hexdump -v -e '/1 "%02X "' -e '/1 "%c\n"'

41 A
54 T
5A Z
0A 
0A 

The microcontroller was sending “ATZ\r\n” but in the Linux I saw only “ATZ\n\n”, initially I suspected that RTOS NuttX in the microcontroller was converting the “\r” (0x0D) to “\n” (0x0A).

After some low level debug I verified that NuttX was writing “\r” correctly in the serial port’s buffer.

Then I realized the guilt should be the Linux. In fact Linux handles serial port as a TTY interface. It means that Linux will do some post processing of serial data.

Fortunately we can change this behavior configuring the serial port to RAW mode, this way:

$ sudo stty -F /dev/ttyUSB0 raw
$ sudo stty -F /dev/ttyUSB0 -echo -echoe -echok
$ sudo stty -F /dev/ttyUSB0 115200

Now everything goes fine:

$ cat /dev/ttyUSB0 | hexdump -v -e '/1 "%02X "' -e '/1 "%c\n"'

41 A
54 T
5A Z
0D 
0A 

Source: http://www.armadeus.com/wiki/index.php?title=Serial_ports_usage_on_Linux

Using the NuttX’s USB Mass Storage to copy SPI NOR Flash Content

I’m using an 8MiB SPI NOR (Winbond W25Q64) on my board and I was looking for a way to copy its content.

Some readers could recall I used the hexdump and screen to copy small files from NuttX, but it is not an option when you need to copy big files. For instance, I want to copy a more than 5MiB file.

Then I decided to use the NuttX USBMSC driver to export the SPI NOR partition.

The first thing to do is enable the USBMSC driver:

Device Drivers  --->
[*] USB Device Driver Support  --->
--- USB Device Driver Support

[*]   USB Mass storage class device  
(64)    Max packet size for endpoint0  
(2)     Bulk OUT endpoint number
(3)     Bulk IN endpoint number
(4)     The number of write requests that can be in flight
(4)     The number of read requests that can be in flight
(64)    Bulk IN request size
(64)    Bulk OUT request size
(0x584e) Mass storage Vendor ID
(NuttX) Mass storage vendor string
(0x5342) Mass storage Product ID
(Mass Storage) Mass storage product string
(0x399) USB MSC Version Number
[*]     Mass storage removable
(128)   USBMSC SCSI daemon priority
(2048)  USBMSC SCSI daemon stack size

Now we need to enable the USB Mass Storage Commands:

System Libraries and NSH Add-Ons  --->
[*] USB Mass Storage Device Commands  --->

--- USB Mass Storage Device Commands
(1)   Number of LUNs
(0)   LUN1 Minor Device Number
(/dev/smart0p1) LUN1 Device Path

As you can see I changed the default LUN1 (Logic Unit 1) from /dev/mmcsd1 to /dev/smart0p1 since it is my SPI NOR Flash partition.

Also I created a stm32_usbmsc.c file with the “int usbmsc_archinitialize(void)” function just returning 0, since the SPI NOR initialization is done automatically.

After compiling and flashing the nuttx.bin on my board I started the USB Mass Storage with the “msconn” command:

NuttShell (NSH)
nsh> msconn
mcsonn_main: Creating block drivers
mcsonn_main: Configuring with NLUNS=1
mcsonn_main: handle=2000c320
mcsonn_main: Bind LUN=0 to /dev/smart0p1
mcsonn_main: Connected

Immediately I listen the new USB device connected on my Linux, but the device didn’t appear in the Nautilus. Using dmesg I could see what was going on:

[10875.354625] usb 3-4: new full-speed USB device number 6 using xhci_hcd
[10875.484111] usb 3-4: New USB device found, idVendor=584e, idProduct=5342
[10875.484118] usb 3-4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[10875.484122] usb 3-4: Product: Mass Storage
[10875.484125] usb 3-4: Manufacturer: NuttX
[10875.484127] usb 3-4: SerialNumber: 0101
[10875.545293] usb-storage 3-4:1.0: USB Mass Storage device detected
[10875.545467] scsi6 : usb-storage 3-4:1.0
[10875.545611] usbcore: registered new interface driver usb-storage
[10876.543778] scsi 6:0:0:0: Direct-Access     NuttX    Mass Storage     0101 PQ: 0 ANSI: 2
[10876.544518] sd 6:0:0:0: Attached scsi generic sg2 type 0
[10876.544848] sd 6:0:0:0: [sdb] 10240 512-byte logical blocks: (5.24 MB/5.00 MiB)
[10876.761447] sd 6:0:0:0: [sdb] Write Protect is off
[10876.761456] sd 6:0:0:0: [sdb] Mode Sense: 0b 00 00 00
[10876.981478] sd 6:0:0:0: [sdb] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[10877.446426]  sdb: unknown partition table
[10877.881947] sd 6:0:0:0: [sdb] Attached SCSI removable disk

Because the NuttX Mass Storage Partition /dev/smart0p1 is not a FAT partition, but SmartFS, Linux couldn’t recognize it.

No problem, I just need to see the partition content.

Using the dd command I copied the flash partition:

$ sudo dd if=/dev/sdb of=/tmp/smartfs.bin
10240+0 records in
10240+0 records out
5242880 bytes (5.2 MB) copied, 9.58846 s, 547 kB/s

That is all! If you don’t know yet, NuttX Rocks!

UPDATE: Ken Pettit created a FUSE support for SmartFS, you can find it (called nxfuse) in the tools repository from NuttX project in the bitbucket.

Install Nexus Experience ROM on Moto G 2014

I installed the Nexus Experience ROM in the Moto G of a friend of mine.

These are the files I used:

Android6.0.1_NX_R10.0.4_MotoG2014.zip
NX-GAPPS_M_Release1.2_STD.zip
TWRP_2.7.1.1.img

These files (except TMRP) can be downloaded from here.

This version is lighter than stock Motorola version because it is a pure Nexus base system.

More info (Portuguese) : http://www.andremachado.org/artigos/1501/usando-o-android-sem-as-aplicacoes-do-google.html