prettify

Jun 22, 2016

compile root file system (busybox)





1.    Busybox compiling config
a.     Don’t set the static library.
b.     Should set up the cross compile prefix.
c.     Set ‘Not support big files’
d.     Set ‘Not use local  /usr’
2.     Compile busybox
a.     make menuconfig
b.     make
c.     make install
d.     the default installing directory for busybox is busybox_root/_install
3.     If using initramfs format as rootfs, when compiling kernel we should set up kernel’s config file to support initramfs. Including the following setting:
                CONFIG_INITRAMFS_SOURCE="/home/project/a/busybox/_install" (this directory _install is from the above step 3)
            The above path is rootfs’s directories path.
            When compiling kernel, it will create the cpio.gz file in              
                 kernel_root/usr/initramfs_data.cpio.gz.
          At the same time, the rootfs will be compiled with kernel image. So the file Image includes kernel and rootfs.

Apr 20, 2016

nfs mount RPC service issue

Ported a 4.1 kernel to ARMv8/CA72 board.  I always failed with the following command

# mount 10.85.151.108:/srv /mnt/nfs
[  241.430956] svc: failed to register lockdv1 RPC service (errno 111).
mount: mounting 10.85.151.108:/srv on /mnt/nfs failed: Connection refused

Finally I have to use this
# mount -o port=2049,nolock,proto=tcp 10.85.151.108:/srv /mnt/nfs

Still trying to figure out why udp is not working.

Apr 1, 2016

Assembly in DS-5 script

set var $AARCH64::$Core::$X0 = 0xd0020000
set var $AARCH64::$Core::$X1 = 0x609
assemble 0x00002000 A64
STR x1, [x0]
ADD x0, x0, #8
STR x1, [x0]
DSB     SY
TLBI    ALLE3
ISB
NOP
B {PC}-4
end

Feb 4, 2016

linux nvme command interface

I worked with NVME device recently. To challenge the firmware, NVME command has to be sent from host. I can choose to use LeCoy's software and hardware box to send command,, another way is to use a plain PC with linux installed.

The test framework is 3-layers architecture, the device driver (dnvme) at bottom,  dynamic link library in the middle to provides APIs, and test scripts (perl or python) on top. Here is available open source resources

NVMe Compliance Test
https://github.com/nvmecompliance/tnvme

Linux driver for NVMe Compliance Suite
https://github.com/nvmecompliance/dnvme

Linux NVME command interface
https://github.com/linux-nvme/nvme-cli

NVME windows command issuer
https://github.com/Miyavi-Chen/NVMe_CMD_issuer

memcpy for ARMv7

There is lot of ways to implement memcpy(), the most efficient way is of course the DMA, although it has overhead to setup the DMA descriptor. Armcc compiler just do it in a simple way

;r0 stores the destine and r1 stores the source


LDM r1!,{r3,r4,r12,lr
STM r0!,{r3,r4,r12,lr}

Each 2 machine cycle copies 16 bytes of data.  I ignored extra codes to handle non-16-bytes-aligned data.

Jan 29, 2016

mutex in armv8

Finally I am working on armv8 soc now. At the very beginning I need a mutex, which is essential for multiple core processors. The old strex/lderx on longer available, now we have ldxr/stxr instead

http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dht0008a/ch01s03s02.html


get_lock PROC
mov w1, #0x1
try_loop
ldaxr w2, [x0]
cbnz w2, try_loop
stxr w2, w1, [x0]
cbnz w2, try_loop
ret
ENDP


free_lock PROC
mov w1, #0x0
stlr w1, [x0]
ret
ENDP

try_lock PROC
mov w1, #0x1
ldaxr w2, [x0]
cbnz w2, exit
stxr w2, w1, [x0]
exit
mov w0, w2
ret
ENDP

Jan 28, 2016

C++ string::split

I can understand the reason why C does not provide the string split function, but C++ is another story. A guy told me today C++ is going to add an split function, but not in C++11. It is been so late. I always have to write something like this

#include <sstream>
#include <vector>

std::vector<std::string> split(const std::string& s, const char delim){
    std::vector<std::string> res;
    std::string item;
    std:stringstream ss(s);
    while(std::getline(ss, item, delim)) {
        if(!item.empty()) res.push_back(item);
    }
    return res;
}

that's too much job from Java's split, no mention the powerful regex based split in Perl.