顯示具有 Embedded System 標籤的文章。 顯示所有文章
顯示具有 Embedded System 標籤的文章。 顯示所有文章

2018年1月17日 星期三

[Embedded System][make menuconfig] How to define tag and use it under Makefile and code

  1. Edit Kconfig
edit vendor/vendor.Kconfig
Add following line
config CONFIG_VENDOR_HAPPY
    bool "support"
        default y
        help
                Enable code
Execute “make menuconfig” will generate “.config”.
  1. Put into the code
#ifdef CONFIG_VENDOR_HAPPY
void customer()
{
    if (!Clean)
    {
        Clean = 1;
    }

}
#endif //CONFIG_VENDOR_HAPPY
  1. Put into the Makefile
    -include $(TARGET_HOME)/.config
    ifeq ($(GOGO),y)

2017年12月4日 星期一

[Cross Compile] undefined reference to symbol - DSO missing from command line

Q:
(undefined reference to symbol ‘__aeabi_idivmod@@GCC_3.5’) can’t find function

arm-openwrt-linux-uclibcgnueabi-ld: build/form-and-join.o: undefined reference to symbol ‘__aeabi_idivmod@@GCC_3.5’
/home/freeman/trunk/qca-networking-spf-4-0/qsdk/staging_dir/toolchain-arm_cortex-a7_gcc-4.8-linaro_uClibc-1.0.14_eabi/bin/../../toolchain-arm_cortex-a7_gcc-4.8-linaro_uClibc-1.0.14_eabi/lib/libgcc_s.so.1: error adding symbols: DSO missing from command line

A:
So need to find (libgcc_s.so.1), and add it into Makefile.

Example

LIBS= \
-L$(BUILD_DIR)/../gcc/ \
-lgcc \

Reference:

2017年1月11日 星期三

[Embedded System] How to strip prefix at make

Dont add prefix under configure
For example :
_ ./configure \
–cross-compile \
–hostcc=gcc \

When install binary file, please type as following command.
make install DESTDIR=/test

Reference:

2017年1月10日 星期二

[Strace][Embedded] How to trace binary error

Using strace to trace

For example:
When I trace smbd by using strace.
Error log : strace smbd > /tmp/smbd.strace.txt
Full log : strace smbd 2&> /tmp/smbd.strace.txt

The log will like below. This log only have error log.

[1970/01/01 13:32:22,  0] ../lib/util/debug.c:595(reopen_logs_internal)
  Unable to open new log file '/home/freeman/test/Samba/EMBED/samba/OBJ/SAMBA_OBJ/var/log.smbd': No such file or directory
[1970/01/01 13:32:22,  0] ../source3/lib/dumpcore.c:249(dump_core_setup)
  Unable to setup corepath for smbd: No such file or directory
[1970/01/01 13:32:22,  0] ../lib/util/debug.c:595(reopen_logs_internal)
  Unable to open new log file '/home/freeman/test/Samba/EMBED/samba/OBJ/SAMBA_OBJ/var/log.smbd': No such file or directory
[1970/01/01 13:32:23,  0] ../source3/smbd/server.c:1198(main)
  smbd version 4.1.5 started.
  Copyright Andrew Tridgell and the Samba Team 1992-2013
[1970/01/01 13:32:23,  0] ../source3/smbd/server.c:1213(main)
  error opening config file '/home/freeman/test/Samba/EMBED/samba/OBJ/SAMBA_OBJ/etc/smb.conf'

According this log I can debug binary file why can’t execute it.

The error message display server.c:1213 have error. So I can jump to server.c:1213, and see what happen about this place.
Maybe I can fix this bug by myself for embedded system.

Reference:

2016年12月20日 星期二

[Samba][ARM] samba-4.1.5 cross compile for ARMv7

Download Samba from github
Samba for ARM

Download repository from github
git clone https://github.com/Jumbo88888/Samba

Modify auto.sh
cd Samba/EMBED/samba

Modify following ARM-gcc
CC=arm-linux-gnueabihf-gcc \
AR=arm-linux-gnueabihf-ar \
CPP=arm-linux-gnueabihf-cpp \
RANLIB=arm-linux-gnueabihf-gcc-ranlib \
Save it.

Start to compile the code.
make && make install

2016年11月30日 星期三

[Compiler Server] Building compiler server for ARM

Install library package for 32bit



Edit /etc/pacman.conf

[multilib]
Include = /etc/pacman.d/mirrorlist



update the package list and upgrade with pacman -Syu
pacman -Syu

pacman -S lib32-zlib # Compression library implementing the deflate compression method found in gzip and PKZIP (32-bit)
pacman -S lib32-gcc-libs # Runtime libraries shipped by GCC (32-bit)
pacman -S lib32-glibc # GNU C Library (32-bit)


Install system tool package



Download Regina-REXX-3.9.1.tar.gz and compile it.
After compile the package, then install it.
Regina-REXX-3.9.1.tar.gz

sudo pacman -S bison
sudo pacman -S flex
sudo pacman -S intltool
sudo pacman -S lzop
sudo pacman -S libtool
sudo pacman -S ccache
sudo pacman -S jdk8-openjdk 


Envrionment settings



Set python to version 2.7
Using python2.7 compile the code.
cd /bin
ln -sf python2.7 python


Add following code into .bashrc
vim ~/.bashrc

export CXC_COMPILER_ROOT_DIR=/opt/toolchains/zOEMtools_eCos/eCos20/gnutools/mipsisa32-elf-i386-linux
export GNUTOOLS=/opt/toolchains/zOEMtools_eCos/eCos20/gnutools
export ARM_TOOLCHAIN_PATH=/opt/toolchains/stbgcc-4.5.4-2.5/bin
PATH=$CXC_COMPILER_ROOT_DIR/bin:/opt/toolchains/BrcmUtils:/opt/toolchains/stbgcc-4.8-1.5/bin:/opt/toolchains/uclibc-crosstools-gcc-4.2.3-4/usr/bin:$ARM_TOOLCHAIN_PATH:$PATH

2016年11月22日 星期二

[C] valgrind - debug memory

Valgrind is an instrumentation framework for building dynamic analysis tools.

Let download source code and use it.
Source Code download place

valgrind –leak-check=full ./

Reference:


Embedded System

Please refer the code at github - Valgrind

export VALGRIND_LIB=/lib/valgrind

Reference:

2016年7月10日 星期日

2016年4月2日 星期六

2016年1月17日 星期日

[Rpcapd] How to use rpcapd

1. Compile rpcapd
Download from github

git clone git@github.com:Jumbo88888/Linux_Cross_Compiler_tools.git

2. Upload the library of libpcap and rpcapd

3. Execute the command
rpcapd -4 -p 8888 -n

Reference:

2015年12月23日 星期三

[Switch] How to disable bridge to become hub

When ageing time set to 0.
That mean this switch become hub.

Description :
The aging time is the number of seconds a MAC address will be kept in the forwarding database after having received a packet from this MAC address.
 brctl setageing bridgename time
 
The another action will need to set register of switch chip.
This action need to refer to spec.

Reference:

2015年8月20日 星期四

[Openssl] create ca & server & client by using pkitool


#!/bin/sh
export OPENSSL="openssl"
export GREP="grep"
export OPENSSL_CONF="/var/tmp/easy-rsa/openssl-1.0.0.cnf"
export KEY_CONFIG="/var/tmp/easy-rsa/openssl-1.0.0.cnf"
export KEY_DIR="/var/tmp/easy-rsa/keys"
export KEY_SIZE=1024
export CA_EXPIRE=3650
export KEY_EXPIRE=3650
export KEY_COUNTRY="TW"
export KEY_PROVINCE="TW"
export KEY_CITY="Taipei"
export KEY_ORG="ASUS"
export KEY_EMAIL="me@myhost.mydomain"
export KEY_CN="rt-600"
export KEY_CN=""
mkdir /var/tmp/easy-rsa/keys/
echo "" > /var/tmp/easy-rsa/keys/index.txt
echo 01 > /var/tmp/easy-rsa/keys/serial
/var/tmp/easy-rsa/pkitool --initca
/var/tmp/easy-rsa/pkitool --server server
/var/tmp/easy-rsa/pkitool client

Reference:

2015年7月26日 星期日

[Embedded] u-boot for mini2440


Prework
Download compiler
ARM linux gcc for mini2440

Set the enviroment
export PATH=/tmp/opt/FriendlyARM/toolschain/4.4.3/bin:$PATH
export LD_LIBRARY_PATH=/tmp/opt/FriendlyARM/toolschain/4.4.3/arm-none-linux-gnueabi/sys-root/lib:/tmp/opt/FriendlyARM/toolschain/4.4.3/arm-none-linux-gnueabi/lib:/tmp/opt/FriendlyARM/toolschain/4.4.3/arm-none-linux-gnueabi/sys-root/lib:/tmp/opt/FriendlyARM/toolschain/4.4.3/arm-none-linux-gnueabi/sys-root/usr/lib/tmp/opt/FriendlyARM/toolschain/4.4.3/arm-none-linux-gnueabi/debug-root/usr/lib
CROSS_COMPILE=arm-none-linux-gnueabi-

Download uboot source code
wget http://repo.or.cz/w/u-boot-openmoko/mini2440.git/snapshot/HEAD.tar.gz
tar xvf HEAD.tar.gz
cd mini2440-HEAD-530af20

Start to compile u-boot
make mini2440_config
make

Solve:
undefine image_print_contents_noindent
vim mkimage.c
add // before image_print_contents_noindent, compile will pass.

Execute u-boot.bin
./qemu-system-arm -M mini2440 -serial stdio -mtdblock u-boot.bin

2015年7月25日 星期六

[Embedded][Emulator] qemu for mini2440


1. Download package
git clone git://repo.or.cz/qemu/mini2440.git  qemu

2. configure
./configure --prefix=/tmp --target-list=arm-softmmu
Solve : undefined reference to `clock_gettime’
Edit vim arm-softmmu/Makefile
LIBS+=-lm --> LIBS+=-lm -lrt

3. Install
make -j8

Reference:

2015年1月22日 星期四

[C] Get environment variable


Embedded System
armeb-unknown-linux-uclibcgnueabi-gcc env.c
/*************************************************************************\
*                  Copyright (C) Michael Kerrisk, 2014.                   *
*                                                                         *
* This program is free software. You may use, modify, and redistribute it *
* under the terms of the GNU General Public License as published by the   *
* Free Software Foundation, either version 3 or (at your option) any      *
* later version. This program is distributed without any warranty.  See   *
* the file COPYING.gpl-v3 for details.                                    *
\*************************************************************************/

#include<stdio.h>

extern char **environ;

int main(int argc, char *argv[])
{
        char **ep;
        for (ep = environ; *ep != NULL; ep++)
                puts(*ep);

        return 0;
}


Result:
USER=root
LD_LIBRARY_PATH=/gw/lib:/gw/usr/lib:/lib:/usr/lib:/lib:/usr/lib
OLDPWD=/tmp
HOME=/
usbhostaddr=
TERM=vt102
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/sbin:/usr/bin:/gw/sbin:/gw/bin:/gw/usr/sbin:/gw/
SHELL=/bin/sh
PWD=/tmp


Reference:
1. The Linux Programming Interface

2014年8月29日 星期五

2014年8月15日 星期五