2014-06-27

Slitaz -- strip


1.
tux@slitaz:~$ strip --help
[..]
  -s --strip-all                   Remove all symbol and relocation information
  -g -S -d --strip-debug           Remove all debugging symbols & sections
     --only-keep-debug             Strip everything but the debug information
  -K --keep-symbol=<name>          Do not strip symbol <name>
     --keep-file-symbols           Do not strip file symbol(s)


2.
tux@slitaz:~$ grep -A 15 'strip_package()' /usr/bin/cook
strip_package() {
    case "$ARCH" in
        arm|x86_64) export STRIP=${HOST_SYSTEM}-strip ;;
        *) export STRIP=strip ;;
    esac
    gettext "Executing strip on all files..."
    for dir in $fs/bin $fs/sbin $fs/usr/bin $fs/usr/sbin $fs/usr/games
    do
        if [ -d "$dir" ]; then
            find $dir -type f -exec $STRIP -s '{}' 2>/dev/null \;
        fi
    done
    find $fs -name "*.so*" -exec $STRIP -s '{}' 2>/dev/null \;
    find $fs -name "*.a" -exec $STRIP --strip-debug '{}' 2>/dev/null \;
    status

tux@slitaz:~$


3.
tux@slitaz:~$ grep strip /usr/bin/cross
        find $tools/bin -type f -exec strip -s '{}' 2>/dev/null \;
        find $tools/lib -name cc1* -exec strip -s '{}' 2>/dev/null \;
        find $tools/lib -name lto* -exec strip -s '{}' 2>/dev/null \;
        find $sysroot -name "*.so*" -exec ${TARGET}-strip -s '{}' 2>/dev/null \;
tux@slitaz:~$

2014-06-26

Slitaz -- valgrind - README_PACKAGERS


7. README_PACKAGERS
http://valgrind.org/docs/manual/dist.readme-packagers.html
-- Do not ship your Linux distro with a completely stripped /lib/ld.so. At least leave the debugging symbol names on -- line number info isn't necessary. If you don't want to leave symbols on ld.so, alternatively you can have your distro install ld.so's debuginfo package by default, or make ld.so.debuginfo be a requirement of your Valgrind RPM/DEB/whatever.

Reason for this is that Valgrind's Memcheck tool needs to intercept calls to, and provide replacements for, some symbols in ld.so at startup (most importantly strlen). If it cannot do that, Memcheck shows a large number of false positives due to the highly optimised strlen (etc) routines in ld.so. This has caused some trouble in the  past. As of version 3.3.0, on some targets (ppc32-linux, ppc64-linux), Memcheck will simply stop at startup (and print an error message) if such symbols are not present, because it is infeasible to continue.

It's not like this is going to cost you much space. We only need the symbols for ld.so (a few K at most). Not the debug info and not any debuginfo or extra symbols for any other libraries.
-- Don't strip the debug info off lib/valgrind/$platform/vgpreload*.so in the installation tree.
-- Don't strip symbols from lib/valgrind/* in the installation tree.
-- Please test the final installation works by running it on something huge.

Slitaz -- valgrind -ld.so

ship a non-stripped ld.so (or whatever the dynamic linker .so is called)
 
ld-2.14.1.so - not stripped
http://goo.gl/5XujLi

tux@slitaz:~$ ls -l /lib/ld*
-rwxr-xr-x 1 root root 682804 Jun 25 11:18 /lib/ld-2.14.1.so
-rwxr-xr-x 1 root root 134308 Jun 25 11:17 /lib/ld-2.14.1.so-orig
lrwxrwxrwx 1 root root 12 Jun 25 10:55 /lib/ld-linux.so.2 -> ld-2.14.1.so

tux@slitaz:~$ file /lib/ld-2.14.1.so
/lib/ld-2.14.1.so: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked, not stripped

tux@slitaz:~$ valgrind --leak-check=full ./test.a
==2218== Memcheck, a memory error detector
==2218== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==2218== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==2218== Command: ./test.a
==2218==
==2218==
==2218== HEAP SUMMARY:
==2218== in use at exit: 0 bytes in 0 blocks
==2218== total heap usage: 0 allocs, 0 frees, 0 bytes allocated
==2218==
==2218== All heap blocks were freed -- no leaks are possible
==2218==
==2218== For counts of detected and suppressed errors, rerun with: -v
==2218== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 11 from 6)

2014-06-24

Slitaz -- valgrind

valgrind:  Fatal error at startup: a function redirection
valgrind: Possible fixes: (1, short term): install glibc's debuginfo
valgrind: package on this machine. (2, longer term): ask the packagers
valgrind: for your Linux distribution to please in future ship a non-
valgrind: stripped ld.so (or whatever the dynamic linker .so is called)
valgrind: that exports the above-named function using the standard
valgrind: calling conventions for this platform.
tux@slitaz:~$ file /lib/ld-2.14.1.so
/lib/ld-2.14.1.so: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked, stripped
tux@slitaz:~$

tux@slitaz:~$ gcc -g -o test.a test.c
tux@slitaz:~$ valgrind --leak-check=full ./test.a
==10582== Memcheck, a memory error detector
==10582== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==10582== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==10582== Command: ./test.a
==10582==

valgrind:  Fatal error at startup: a function redirection
valgrind:  which is mandatory for this platform-tool combination
valgrind:  cannot be set up.  Details of the redirection are:
valgrind: 
valgrind:  A must-be-redirected function
valgrind:  whose name matches the pattern:      strlen
valgrind:  in an object with soname matching:   ld-linux.so.2
valgrind:  was not found whilst processing
valgrind:  symbols from the object with soname: ld-linux.so.2
valgrind: 
valgrind:  Possible fixes: (1, short term): install glibc's debuginfo
valgrind:  package on this machine.  (2, longer term): ask the packagers
valgrind:  for your Linux distribution to please in future ship a non-
valgrind:  stripped ld.so (or whatever the dynamic linker .so is called)
valgrind:  that exports the above-named function using the standard
valgrind:  calling conventions for this platform.  The package you need
valgrind:  to install for fix (1) is called
valgrind: 
valgrind:    On Debian, Ubuntu:                 libc6-dbg
valgrind:    On SuSE, openSuSE, Fedora, RHEL:   glibc-debuginfo
valgrind: 
valgrind:  Cannot continue -- exiting now.  Sorry.

2014-06-18

Slitaz on Radxa Rock


Ubuntu 14.04 and Slitaz on Radxa Rock
http://www.cnx-software.com/2014/05/18/ubuntu-14-04-and-slitaz-on-radxa-rock/

First download boot-slitaz-20140517.img (kernel + slitaz ramdisk), and slitaz-armhf-mini-2012-12-14.zip. Extract the rootfs from slitaz-armhf-mini-2012-12-14.img (ext-4 partition). then follow the 「Flashing Ubuntu to Radxa Rock」 section in my getting started guide for Radxa Rock to flash boot.img. It is simply one line:
upgrade_tool di -b /path-to/boot-slitaz-20140517.img
Simply login with root username, and root password to access the command line. It might also be possible to use a more up-to-date rootfs from http://arm.slitaz.org/rpi/, but it is only armel.
[Update: Alanyih has also been given me the build instructions for his Slitaz image:
git clone -b wip/lsk-android-14.04-radxa-rock https://github.com/linux-rockchip/kernel_rockchip.git
make radxa_rock_defconfig
make zImage rk3188-radxa-rock.dtb
cat arch/arm/boot/zImage arch/arm/boot/dts/rk3188-radxa-rock.dtb > zImage-lsk
mkbootimg --kernel zImage-lsk --ramdisk slitaz-ramdisk.gz -o boot-slitaz-20140517.img
]
Both Ubuntu 14.04 and Slitaz should be able to run on any Rockchip RK3188 device thanks to the device tree and multi-platform enabled Linux kernel, as long as you can somehow come up with the right device file for your device, which may not always be an easy task.
boot-slitaz-20140517.img (kernel + slitaz ramdisk)
http://goo.gl/Mc7L4q

2014-06-02

radxa -- Serial console debugging




Serial console debugging / putty


1.
Connect the cable
Board    TTL2USB Cable
RX    ->  Green
TX    ->  White
GND   ->  Black 


2.
root@slitaz:/home/tux# dmesg | tail
usb 2-1: new full-speed USB device number 3 using uhci_hcd
usbcore: registered new interface driver usbserial
USB Serial support registered for generic
usbcore: registered new interface driver usbserial_generic
usbserial: USB Serial Driver core
USB Serial support registered for pl2303
pl2303 2-1:1.0: pl2303 converter detected
usb 2-1: pl2303 converter now attached to ttyUSB0
usbcore: registered new interface driver pl2303
pl2303: Prolific PL2303 USB to serial adaptor driver


3.
root@slitaz:/home/tux#  cat /proc/tty/drivers
/dev/tty             /dev/tty        5         0 system:/dev/tty
/dev/console         /dev/console    5         1 system:console
/dev/ptmx            /dev/ptmx       5         2 system
/dev/vc/0            /dev/vc/0       4         0 system:vtmaster
usbserial            /dev/ttyUSB   188      0-253 serial
serial               /dev/ttyS       4         64-67 serial
pty_slave            /dev/pts      136         0-1048575 pty:slave
pty_master           /dev/ptm      128         0-1048575 pty:master
unknown              /dev/tty        4         1-63 console


4.
root@slitaz:/home/tux# ls -l /dev/ttyUSB*
crw-rw----    1 root     dialout   188,   0 May  2 21:41 /dev/ttyUSB0


5.
root@slitaz:/home/tux# grep dialout /etc/group
dialout:x:95:tux


6.
root@slitaz:/home/tux# tazpkg -gi putty


7.
DDR Version 1.04 20130517
In
DDR3
300MHz
Bus Width=32 Col=10 Bank=8 Row=15 CS=2 Die Bus-Width=16 Size=2048MB
Memory OK
OUT
BUILD=====2
SdmmcInit=0 0
FwPartOffset=0 , 0
No.1 FLASH ID:2c 64 44 4b a9 0
OK! 248205
unsigned!
SecureBootEn = 0 0
Boot ver: 2013-12-02#2.08
start_linux=====253060
 2571850 Starting kernel...@0x60408000

<hit enter to activate fiq debugger>
[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Initializing cgroup subsys cpu
[    0.000000] Initializing cgroup subsys cpuacct
[    0.000000] Linux version 3.10.37-slitaz (root@slitaz) (gcc version 4.6.3 (SliTaz) ) #1 SMP PREEMPT Sun May 18 00:04:25 UTC 2014
[    0.000000] CPU: ARMv7 Processor [413fc090] revision 0 (ARMv7), cr=10c53c7d
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
[    0.000000] Machine: RK30board, model: rockchip,rk3188

2014-06-01

radxa -- device-tree


device-tree

1.
[..]
Starting udhcpc client on: eth0...
udhcpc (v1.20.2) started
Sending discover...
Sending discover...
Sending discover...
No lease, forking to background
Processing: /etc/init.d/local.sh
Starting all daemons...
Generating Dropbear rsa key... [ Done ]
Generating Dropbear dss key... [ Done ]
Starting SSH server: Dropbear... [ Done ]

Welcome to Radxa Rock
SliTaz boot time: 6s


2.
root@slitaz:~# dmesg | grep -B 3 Machine
[ 0.000000] Linux version 3.10.37-slitaz (root@slitaz) (gcc version 4.6.3 (SliTaz) ) #1 SMP PREEMPT Fri May 16 13:57:21 UTC 2014
[ 0.000000] CPU: ARMv7 Processor [413fc090] revision 0 (ARMv7), cr=10c53c7d
[ 0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
[ 0.000000] Machine: RK30board, model: rockchip,rk3188


3.
root@slitaz:~# ls /proc/device-tree
#address-cells                 nandc
#size-cells                    pinctrl@20008000
adc@2006c000                   pmu@20004000
aliases                        pwm@20030000
amba                           pwm@20030010
ap0-vcc-domain                 pwm@20050020
ap1-vcc-domain                 pwm@20050030
backlight                      rga@10114000
bootram@10080000               rk_screen
bootrom@10120000               rksdmmc@10214000
cache-controller@10138000      rksdmmc@10218000
chosen                         rksdmmc@1021C000
cif-vcc-domain                 rockchip,sram
clocks                         rockchip-hdmi-i2s
clocks-init                    rockchip-hdmi-spdif
codec-hdmi-i2s                 rockchip-i2s@0x1011a000
codec-hdmi-spdif               rockchip-spdif@0x1011e000
compatible                     rockchip_suspend
cpu_axi_bus                    serial@10124000
cpus                           serial@10126000
dvfs                           serial@20064000
dwc-control-usb@200080ac       serial@20068000
fb                             spi@20070000
fiq-debugger                   spi@20074000
flash-vcc-domain               sram@10080020
hsic@10240000                  timer@20038000
i2c@2002d000                   timer@20038020
i2c@2002f000                   timer@20038040
i2c@20056000                   timer@20038060
i2c@2005a000                   timer@20038080
i2c@2005e000                   timer@200380a0
interrupt-controller@1013d000  twd-wdt@1013c620
interrupt-parent               usb@10180000
ion                            usb@101c0000
lcdc0-vcc-domain               vccio0-vcc-domain
lcdc1-vcc-domain               vccio1-vcc-domain
lcdc@1010c000                  vmac-phy
lcdc@1010e000                  vmac@10204000
memory                         wdt@2004c000
name                           wireless-wlan

4.
root@slitaz:~# cat /proc/device-tree/compatible
rockchip,rk3188root@slitaz:~#

root@slitaz:~# cat /proc/device-tree/chosen/bootargs
clk_ignore_unused console=ttyFIQ0,115200 console=tty0 root=/dev/mmcblk0p2 rw rootfstype=ext4 init=/sbin/init mac_addr=de:ad:de:ad:be:ef initrd=0x62000000,0x003E0000 mtdparts=rk29xxnand:0x00008000@0x00002000(boot),-@0x0000A000(linuxroot) bootver=2013-12-02#2.08 firmware_ver=4.2.2

root@slitaz:~# cat /proc/device-tree/wireless-wlan/compatible
wlan-platdataroot@slitaz:~#

Slitaz -- ghex



GHex is a simple binary editor.

root@slitaz:/tmp# hexdump -C /home/tux/putty-0517-140415.log | head 
00000000  3d 7e 3d 7e 3d 7e 3d 7e  3d 7e 3d 7e 3d 7e 3d 7e  |=~=~=~=~=~=~=~=~|
00000010  3d 7e 3d 7e 3d 7e 3d 20  50 75 54 54 59 20 6c 6f  |=~=~=~= PuTTY lo|
00000020  67 20 32 30 31 34 2e 30  35 2e 31 37 20 31 34 3a  |g 2014.05.17 14:|
00000030  30 34 3a 31 35 20 3d 7e  3d 7e 3d 7e 3d 7e 3d 7e  |04:15 =~=~=~=~=~|
00000040  3d 7e 3d 7e 3d 7e 3d 7e  3d 7e 3d 7e 3d 0d 0a 00  |=~=~=~=~=~=~=...|
00000050  44 44 52 20 56 65 72 73  69 6f 6e 20 31 2e 30 34  |DDR Version 1.04|
00000060  20 32 30 31 33 30 35 31  37 0d 0a 49 6e 0d 0a 44  | 20130517..In..D|
00000070  44 52 33 0d 0a 33 30 30  4d 48 7a 0d 0a 42 75 73  |DR3..300MHz..Bus|
00000080  20 57 69 64 74 68 3d 33  32 20 43 6f 6c 3d 31 30  | Width=32 Col=10|
00000090  20 42 61 6e 6b 3d 38 20  52 6f 77 3d 31 35 20 43  | Bank=8 Row=15 C| 

root@slitaz:/tmp# hexdump -C /home/tux/putty-0517-125735.log | head 
00000000  3d 7e 3d 7e 3d 7e 3d 7e  3d 7e 3d 7e 3d 7e 3d 7e  |=~=~=~=~=~=~=~=~|
00000010  3d 7e 3d 7e 3d 7e 3d 20  50 75 54 54 59 20 6c 6f  |=~=~=~= PuTTY lo|
00000020  67 20 32 30 31 34 2e 30  35 2e 31 37 20 31 32 3a  |g 2014.05.17 12:|
00000030  35 37 3a 33 35 20 3d 7e  3d 7e 3d 7e 3d 7e 3d 7e  |57:35 =~=~=~=~=~|
00000040  3d 7e 3d 7e 3d 7e 3d 7e  3d 7e 3d 7e 3d 0d 0a 44  |=~=~=~=~=~=~=..D|
00000050  44 52 20 56 65 72 73 69  6f 6e 20 31 2e 30 34 20  |DR Version 1.04 |
00000060  32 30 31 33 30 35 31 37  0d 0a 49 6e 0d 0a 44 44  |20130517..In..DD|
00000070  52 33 0d 0a 33 30 30 4d  48 7a 0d 0a 42 75 73 20  |R3..300MHz..Bus |
00000080  57 69 64 74 68 3d 33 32  20 43 6f 6c 3d 31 30 20  |Width=32 Col=10 |
00000090  42 61 6e 6b 3d 38 20 52  6f 77 3d 31 35 20 43 53  |Bank=8 Row=15 CS|