Tuesday, September 16, 2014

com.serverengines.rdr.EndOfStream: EndOfStream ILO

There is some bug in ILO implementation on HP servers. Its very frustrating, even more when you are in hurry



Fastest way around this is to point your browser to: IP_ADDRESS/M2.JAR and download jar to your computer.

It should connect without problems now.


how to check for debug symbols on osx ?

After last submission of my py2app app to Mac App Store I've received email:



Missing DWARF data - Your app does not include DWARF data with architecture information in Contents/MacOS/Capturebox . In your Xcode build settings, ensure that the debug information is set to "DWARF with dSYM" and that the list of valid architectures does not include PPC.


When creating .app file with py2app be sure to set:

no_strip: True 

in your py2app options.


Existence of debug symbols could be easily checked with otool utility:

otool -Iv /Applications/Calculator.app/Contents/MacOS/Calculator

/Applications/Calculator.app/Contents/MacOS/Calculator:
Indirect symbols for (__TEXT,__stubs) 27 entries
address            index name
0x000000010000f454     8 _CalculateExpression
0x000000010000f45a    14 _NSClassFromString
0x000000010000f460    18 _NSHomeDirectory
....


If there is no output from otool debug symbols were probably removed by strip or some other tool.




Friday, September 12, 2014

taking core dumps on osx (python segmentation fault 11)


so you are testing some python code, suddenly:

imac-sebcia:CaptureboxApp sebcio$ python boot_darwin.py
2014-09-13 00:07:59.795 Python[2130:d07] __main__(): running in --debug mode
2014-09-12 23:27:46.749 Python[1746:d07] buildLatestScreensMenu(): end
Segmentation fault: 11

random segmentation faults in python could be very frustrating. how to trace them on osx ?

1. core dumps are not enabled by default on osx. enable them with:

ulimit -c unlimited

2. run your code again:

imac-sebcia:CaptureboxApp sebcio$ python boot_darwin.py
2014-09-13 00:07:59.795 Python[2130:d07] __main__(): running in --debug mode
2014-09-12 23:27:46.749 Python[1746:d07] buildLatestScreensMenu(): end
Segmentation fault: 11 (core dumped)

3. all core dumps are saved in /cores

imac-sebcia:~ sebcio$ ls -la /cores
total 3461280
drwxrwxr-t@  3 root    admin         102 13 wrz 00:08 .
drwxr-xr-x  34 root    wheel        1224 12 wrz 19:42 ..
-r--------   1 sebcio  admin  1772175360 13 wrz 00:09 core.2132

4. analyze core dump with lldb:

imac-sebcia:cores sebcio$ lldb -c core.2132
Core file '/cores/core.2132' (x86_64) was loaded.
Process 0 stopped
* thread #1: tid = 0x0000, 0x00007fff89cca097 libobjc.A.dylib`objc_msgSend + 23, stop reason = signal SIGSTOP
    frame #0: 0x00007fff89cca097 libobjc.A.dylib`objc_msgSend + 23
libobjc.A.dylib`objc_msgSend + 23:
-> 0x7fff89cca097:  andl   0x18(%r11), %r10d
   0x7fff89cca09b:  shlq   $0x4, %r10
   0x7fff89cca09f:  addq   0x10(%r11), %r10
   0x7fff89cca0a3:  cmpq   (%r10), %rsi
  thread #2: tid = 0x0001, 0x00007fff8e8d0662 libsystem_kernel.dylib`kevent64 + 10, stop reason = signal SIGSTOP
    frame #0: 0x00007fff8e8d0662 libsystem_kernel.dylib`kevent64 + 10
libsystem_kernel.dylib`kevent64 + 10:
-> 0x7fff8e8d0662:  jae    0x7fff8e8d066c            ; kevent64 + 20
   0x7fff8e8d0664:  movq   %rax, %rdi
   0x7fff8e8d0667:  jmpq   0x7fff8e8cc175            ; cerror_nocancel
   0x7fff8e8d066c:  ret
  thread #3: tid = 0x0002, 0x00007fff8e8cfe6a libsystem_kernel.dylib`__work

....




Wednesday, December 25, 2013

osx - set routing after establishing vpn connection

nice and easy trick to set up routing after VPN connection has been established.

just create ip-up file in /etc/ppp

for example:

sudo nano cat /etc/ppp/ip-up

#!/bin/sh
/sbin/route  -v add -net 10.0.0 -interface ppp0

be sure to set chmod 755.



Saturday, October 26, 2013

osal_snv_read and osal_snv_write on BLE112 (CC2540 - 128kb version)

osal_svn_read and osal_snv_write provides a way for applications to store information into device's memory persistently.

Please refer to OSAL API pdf. There is a range of ID's which can be used for your applications to store data in. Others are reserved or used by the stack or ble platform.
Usable ID's are in range:

0x80 - 0xFE

When you run this code on BLE112 (or other cc2540 128kb version):

uint8 array[]={0,1,2,3,4,5,6,7,8,9};
uint8 read_array[10];
uint8_t result = osal_snv_write(0x80,6,array);

You will receive NV_OPER_FAILED in result. Same result when trying to read using osal_snv_read.

After some digging around net I found explanation. Code provided in sample applications (ie. SimpleBLEPeripheral) and HAL subsystem was designed to run on 256kb chip.
One file need to be fixed to use osal_snv read/write functions properly.

Search for hal_board_cfg.h file, look for code shown below:


// NV page definitions must coincide with segment declaration in project *.xcl file.
#if defined NON_BANKED
#define HAL_NV_PAGE_END                30
#elif defined HAL_BOARD_CC2541S
#define HAL_NV_PAGE_END                125
#else
#define HAL_NV_PAGE_END                126
#endif

change it to :


// NV page definitions must coincide with segment declaration in project *.xcl file.
#if defined NON_BANKED
#define HAL_NV_PAGE_END                30
#elif defined HAL_BOARD_CC2541S
#define HAL_NV_PAGE_END                125
#elif defined HAL_BOARD_128K
#define HAL_NV_PAGE_END                62
#else
#define HAL_NV_PAGE_END                126
#endif



and add HAL_BOARD_128K to your preprocessor settings:


Friday, October 4, 2013

connecting CC2540 (BLE112) to MCP23009 using I2C

CC2540 does not have hardware i2c interface. Implementing i2c protocol in software is quite easy task. A lot of samples could be found around the net.

Ive used i2c implementation found on: https://github.com/RedBearLab/Biscuit

Remember to change #defines to reflect your wiring. Also check .c file for hardcoded ports. You need to change this before running code.

My wiring of MCP23009 to BLE112:


wiring MCP23009 i2c extender to CC2540 (BLE112)
Next use the code below to turn on LED diode.

First you need to establish connection to MCP23009 (i2c address: 0x40) and set few registers:

    i2c_init();
    i2c_start(0x40);
      
    // io mode
    i2c_write(0x00);  // IODIR
    i2c_write(0x00);  // 00 - all pins as output
    i2c_stop();
    // polarity
    i2c_restart(0x40);
    i2c_write(0x01);
    i2c_write(0x00);
    i2c_stop();    
    // config
    i2c_restart(0x40);    
    i2c_write(0x05);
    i2c_write(0x00);
    i2c_stop();    
    // pullup
    i2c_restart(0x40);    
    i2c_write(0x06);
    i2c_write(0x00); // 00 - disable pullups
    i2c_stop();    
 
Registers can be found in datasheet, quick look to understand what registers was set in code:



Then you can turn on LED:

    i2c_restart(0x40);
    i2c_write(0x09);
    i2c_write(0xFE);
    i2c_stop();    

Useful links:

MCP23009 datasheet

Monday, September 2, 2013

MySQL - changing table engine in very big table dump

Changing table type from MyISAM to InnoDB or some other engine could be very painful if your table has a lot of rows.
If you have a lot of time you can do it using standard ALTER TABLE syntax.
However If you have more than one drive in you box, a lot faster would be dumping and restoring dump from command line.
After dump use sed to change table type:

sed -e "s/Engine=MyISAM/Engine=InnoDB/gi" input.sql > output.sql

Then import your output.sql.