domingo, mayo 28, 2017

Compile and run Linux Kernel and Busybox for ARM 64 bits aarch64 on QEMU

Hello everyone, in this post you can read how to and where to download, compile and run Linux kernel and busybox for ARM64 processor.

the first step is to get the toolchain, linux kernel source and busybox source,   in this case we will do it using.

- CodeSourcery Lite for ARM64, the version i have is:  aarch64-amd-2014.11.tar it could be download for free from


Sourcery CodeBench Lite Edition for AMD64 ARM GNU/Linux


as the second step you need to source code for kernel linux and busybox,

to download the kernel, you can do it from    https://www.kernel.org/,  in my case  version 4.11.3
stable:4.11.32017-05-25[tarball]
Busybox can be downloaded from  https://busybox.net/downloads/  latest for today is version  1.26.2


Let take on hands to compile and test  busybox

once you have decompress the toolchain and the sourcecode for busybox, lets compile  using the next command.

Path for toolchain
/media/backups/mariotpc/developer/gcc-arm-none-eabi-6-2017-q1-update/bin/arm-none-eabi-

Path for busybox sourcecode
/media/backups/mariotpc/developer/kernel-and-qemu/busybox-1.26.2

command to configure busybox
make ARCH=arm64 CROSS_COMPILE=/media/backups/mariotpc/developer/aarch64-amd-2014.11/bin/aarch64-amd-linux-gnu- menuconfig

indicate the toolchain path and sysroot for your codesourcery toolchain





command to compile
make ARCH=arm64 CROSS_COMPILE=/media/backups/mariotpc/developer/aarch64-amd-2014.11/bin/aarch64-amd-linux-gnu- install


once the compilation has been complete,  you get the file  busybox in format aarch64, you can check it as follows

[mariotpc@laptop busybox-1.26.2]$ file busybox
busybox: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), statically linked, for GNU/Linux 3.7.0, stripped

Great !!!! the busybox for ARM aarch64 has been success !!!!!


Hands on the Linux Kernel
the configuration parameters are being taken from the ARCH indicated on the command,  for example, the default configuration  for aarch64 is readed from ARCH=arm64

it is located on
/media/backups/mariotpc/developer/kernel-and-qemu/linux-4.11.3/arch/arm64/configs/defconfig


make ARCH=arm64 CROSS_COMPILE=/media/backups/mariotpc/developer/aarch64-amd-2014.11/bin/aarch64-amd-linux-gnu-  defconfig



Generate, compile, build the linux kernel using command:

make ARCH=arm64 CROSS_COMPILE=/media/backups/mariotpc/developer/aarch64-amd-2014.11/bin/aarch64-amd-linux-gnu-  defconfig


  CHK     include/generated/compile.h
  CHK     kernel/config_data.h
  Building modules, stage 2.
  MODPOST 193 modules
[mariotpc@laptop linux-4.11.3]$ 




At this time, we have the linux kernel and the busybox compiled, we need to create the init for boot the kernel, from busybox

1.- create the  rcS  file in the /etc directory as follows.

[mariotpc@laptop etc]$ cat init.d/rcS 
#!/bin/sh
mount -t proc none /proc
mount -t sysfs none /sys
/sbin/mdev -s


inside busybox, on the _install directory run the next commands

find . | cpio -o --format=newc > ../rootfs.img


All has been done,   now start the qemu emulator and lets the linux kernel and busybox to run inside of it,  

Congratulations...!!!!  you are ready to test your production environment 


qemu-system-aarch64 -machine virt -cpu cortex-a57 -machine type=virt -nographic -smp 1 -m 2048 -kernel linux-4.11.3/arch/arm64/boot/Image -initrd busybox-1.26.2/rootfs.img -append "root=/dev/ram rdinit=/sbin/init"


Booting the linux kernel on the qemu environment

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 4.11.3 (mariotpc@laptop.chutzpah) (gcc version 4.9.1 (Sourcery CodeBench Lite 2014.11-95) ) #1 SMP PREEMPT Sat May 27 23:54:08 CST 2017
[    0.000000] Boot CPU: AArch64 Processor [411fd070]
[    0.000000] efi: Getting EFI parameters from FDT:
[    0.000000] efi: UEFI not found.
[    0.000000] cma: Reserved 16 MiB at 0x00000000bf000000
[    0.000000] NUMA: No NUMA configuration found
[    0.000000] NUMA: Faking a node at [mem 0x0000000000000000-0x00000000bfffffff]
[    0.000000] NUMA: Adding memblock [0x40000000 - 0xbfffffff] on node 0


.....

[    1.328196] Freeing unused kernel memory: 1088K

Please press Enter to activate this console.
/ # uname -a
Linux (none) 4.11.3 #1 SMP PREEMPT Sat May 27 23:54:08 CST 2017 aarch64 GNU/Linux

/ # busybox 
BusyBox v1.26.2-MarioTPC (2017-05-27 22:50:31 CST) multi-call binary.
BusyBox is copyrighted by many authors between 1998-2015.
Licensed under GPLv2. See source distribution for detailed
copyright notices.

Usage: busybox [function [arguments]...]
   or: busybox --list[-full]
   or: busybox --install [-s] [DIR]
   or: function [arguments]...

        BusyBox is a multi-call binary that combines many common Unix
        utilities into a single executable.  Most people will create a
        link to busybox for each function they wish to use and BusyBox
        will act like whatever it was invoked as.

Currently defined functions:
        [, [[, acpid, add-shell, addgroup, adduser, adjtimex, arp, arping, ash,
        awk, base64, basename, beep, blkdiscard, blkid, blockdev, bootchartd,


miércoles, mayo 24, 2017

Monitoring interface between ASR5k and the session counter fail

I have been working on a project to create an interface between the Cisco ASR5k and the gplot.

Steps on working

1.- Take the data from the ASR5k session counters

2.- debug the data

3.- Insert the data into the SQLite database

4.- have been checking the feed each minute




5.- show the data on real time.




The interface to take the data and insert into the Database has been developed on C language


jueves, agosto 26, 2010

vpnclient-linux-4.8.00.0490-k9_patch-2.6.33

Hello just after many hours trying to get working on Cisco VPN Client using kernel 2.6.33 finally got my goal...

I got working doing bellow steps.

1.- Download the source code vpnclient-linux-4.8.00.0490-k9.tar.gz
2.- Decompress the source code.

3.- Download patch wget -q http://tuxx-home.at/projects/cisco-vpnclient/vpnclient-linux-2.6.22.diff

4.- Apply the patch

[root@mariotpc vpnclient]# patch -i vpnclient-linux-2.6.22.diff
patching file frag.c
patching file interceptor.c
patching file IPSecDrvOS_linux.c
patching file linuxcniapi.c
patching file linux_os.h

But this is not all, remember you are patching 2.6.22!!!!

At this point compile still does not work....!!!


5.- download the source code for VPNClient vpnclient-linux-x86_64-4.8.02.0030-k9.tar.gz
Note that this is for x86_64 Kernel

6.- Decompress this source code too and Patch with the vpnclient-linux-2.6.31-final.diff
patch -i vpnclient-linux-2.6.31-final.diff

[root@mariotpc vpnclient]# patch -i vpnclient-linux-2.6.31-final.diff
patching file interceptor.c

This will modify the file interceptor.c

Just copy the interceptor.c file to the source code for x86 kernel and run the make command, after a few seconds you will have the modules and the executables ready to install

[root@mariotpc vpnclient]# cp interceptor.c ../vpnclient.86/
cp: overwrite `../vpnclient.86/interceptor.c'? y

[root@mariotpc vpnclient]# cd ../vpnclient.86/

[root@mariotpc vpnclient.86]# make
make -C /lib/modules/2.6.33.3-85.fc13.i686.PAE/build SUBDIRS=/home/mariotpc/Downloads/vpnclient.86 modules
make[1]: Entering directory `/usr/src/kernels/2.6.33.3-85.fc13.i686.PAE'
CC [M] /home/mariotpc/Downloads/vpnclient.86/linuxcniapi.o
In file included from /home/mariotpc/Downloads/vpnclient.86/Cniapi.h:16,
from /home/mariotpc/Downloads/vpnclient.86/linuxcniapi.c:31:
/home/mariotpc/Downloads/vpnclient.86/GenDefs.h:113: error: conflicting types for ‘uintptr_t’
include/linux/types.h:41: note: previous declaration of ‘uintptr_t’ was here
make[2]: *** [/home/mariotpc/Downloads/vpnclient.86/linuxcniapi.o] Error 1
make[1]: *** [_module_/home/mariotpc/Downloads/vpnclient.86] Error 2
make[1]: Leaving directory `/usr/src/kernels/2.6.33.3-85.fc13.i686.PAE'
make: *** [default] Error 2

Update the GenDefs.h according the bellow file...

[root@mariotpc vpnclient.86]# make
make -C /lib/modules/2.6.33.3-85.fc13.i686.PAE/build SUBDIRS=/home/mariotpc/Downloads/vpnclient.86 modules
make[1]: Entering directory `/usr/src/kernels/2.6.33.3-85.fc13.i686.PAE'
CC [M] /home/mariotpc/Downloads/vpnclient.86/linuxcniapi.o
CC [M] /home/mariotpc/Downloads/vpnclient.86/frag.o
CC [M] /home/mariotpc/Downloads/vpnclient.86/IPSecDrvOS_linux.o
CC [M] /home/mariotpc/Downloads/vpnclient.86/interceptor.o
/home/mariotpc/Downloads/vpnclient.86/interceptor.c: In function ‘interceptor_init’:
/home/mariotpc/Downloads/vpnclient.86/interceptor.c:140: warning: assignment discards qualifiers from pointer target type
/home/mariotpc/Downloads/vpnclient.86/interceptor.c: In function ‘add_netdev’:
/home/mariotpc/Downloads/vpnclient.86/interceptor.c:291: warning: assignment from incompatible pointer type
LD [M] /home/mariotpc/Downloads/vpnclient.86/cisco_ipsec.o
Building modules, stage 2.
MODPOST 1 modules
WARNING: could not find /home/mariotpc/Downloads/vpnclient.86/.libdriver.so.cmd for /home/mariotpc/Downloads/vpnclient.86/libdriver.so
LD [M] /home/mariotpc/Downloads/vpnclient.86/cisco_ipsec.ko
make[1]: Leaving directory `/usr/src/kernels/2.6.33.3-85.fc13.i686.PAE'

Great well done...!!!














GenDefs.h to be updated... as follows.

/**************************************************************************
* Copyright (c) 2000, Cisco Systems, All Rights Reserved
***************************************************************************
*
* File: GenDefs.h
* Date: 8/23/00
*
***************************************************************************
* defines base types to be used by all UNITY client components
***************************************************************************/
#ifndef __GENDEFS_H
#define __GENDEFS_H


#ifndef _WIN32
#define PRELIM_UNIX_PORT
#include
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#ifdef HAVE_STDINT_H
#ifndef CNI_LINUX_INTERFACE
#include
#endif
#elif HAVE_INTTYPES_H
#include
#endif

#ifdef HAVE_SYS_TYPES_H
#ifndef CNI_LINUX_INTERFACE
#include
#else
#include
#undef _UINTPTR_T_DEFINED
#undef _INTPTR_T_DEFINED
#endif
#endif

#else //_WIN32
#undef HAVE_CONFIG_H
#undef HAVE_STDINT_H
#undef HAVE_SYS_TYPES_H
#define WORDS_BIGENDIAN 0
#endif //_WIN32

#undef TRUE
#define TRUE 1

#undef FALSE
#define FALSE 0

// it'd be nice if we could switch to the C99 standard types at some point...
#if defined(HAVE_STDINT_H) || defined(HAVE_INTTYPES_H)
typedef uint8_t bool8;
typedef uint16_t bool16;
typedef uint32_t bool32;

typedef int8_t int8;
typedef int16_t int16;
#if !defined(CNI_LINUX_INTERFACE) || !defined(CONFIG_ISDN_PPP) || !defined(CONFIG_ISDN_PPP_VJ) || !defined(_SLHC_H)
typedef int32_t int32;
typedef int64_t int64;
#endif

typedef uint8_t uint8;
typedef uint16_t uint16;
typedef uint32_t uint32;

typedef uint64_t uint64;
#else
//original windows definitions (32 bit)
typedef unsigned char bool8;
typedef unsigned short bool16;
typedef unsigned long bool32;

typedef signed char int8;
typedef signed short int16;
typedef signed long int32;

typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned long uint32;
#ifdef _WIN32
typedef __int64 int64;
typedef unsigned __int64 uint64;
#else
typedef long long int64;
typedef unsigned long long__int64 uint64;
#endif
#endif

// integer types for doing pointer arithmetic, they should be the
// same size as a pointer. Part of the C99 standard, but they aren't
// available everywhere yet.
// These defs should work with IA32 (x86), ILP32 (sparcv8) and LP64 (sparcv9).
// These types are protected with the WIN32 macros (_INTPTR_T_DEFINED), since
// some, but not all of the WIN32 SDK's define these types.
#ifndef _INTPTR_T_DEFINED
#if defined(_LP64)
typedef int64 intptr_t;
#else
typedef int32 intptr_t;
#endif
#define _INTPTR_T_DEFINED
#endif

#ifndef _UINTPTR_T_DEFINED
#if LINUX_VERSION_CODE <>
#if defined(_LP64)
#warning 64 bit
typedef uint64 uintptr_t;
#else
typedef uint32 uintptr_t;
#endif
#endif
#define _UINTPTR_T_DEFINED
#endif


typedef int BOOL;
#ifndef _WIN32
typedef int BOOLEAN;
#endif

#ifdef _WIN32
typedef int mode_t;
#endif

typedef unsigned char uchar;
#ifndef HAVE_SYS_TYPES_H
typedef unsigned int uint;
typedef unsigned short ushort;
typedef unsigned long ulong;
#endif

typedef ulong ULONG;
typedef ulong* PULONG;
typedef uint32 DWORD;
typedef uint32* PDWORD;
typedef long LONG;
typedef long* PLONG;
typedef int INT;
typedef int* PINT;
typedef uint UINT;
typedef uint* PUINT;
typedef uint16 USHORT;
typedef uint16* PUSHORT;
typedef int16 SHORT;
typedef int16* PSHORT;
typedef uint16 WORD;
typedef uint16* PWORD;
typedef char CHAR;
typedef uchar UCHAR;
typedef char* PCHAR;
typedef uint8 BYTE;
typedef uint8* PBYTE;
#define VOID void
typedef void* PVOID;
#ifdef _WIN32
typedef void* HANDLE;
#else
typedef int HANDLE;
#endif //!_WIN32
typedef HANDLE* PHANDLE;
typedef uint8 KIRQL;

/* function parameter context */
#undef IN
#define IN

#undef OUT
#define OUT

#undef BOTH
#define BOTH

#undef packed
#define packed

#ifndef CLEAR
#define CLEAR(a) memset(&a,0,sizeof(a))
#endif

#ifndef POINT_BEYOND
#define POINT_BEYOND(a,t) (t) &((&a)[1])
#endif

#ifndef MAX
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#endif
#ifndef MIN
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#endif

#ifndef _WIN32
#define _ftime ftime
#define _timeb timeb
#define __cdecl
#ifndef WINAPI
#define WINAPI
#endif
#define ALTIGA_NETWORKS /* XXX */
#endif

#ifndef _WIN32
#undef INVALID_SOCKET
#define INVALID_SOCKET -1
#endif

#ifndef MAX_INTERFACES
#define MAX_INTERFACES 20
#endif
/* END OF MACRO HELL */
#endif /*__GENDEFS_H*/

domingo, noviembre 08, 2009

FreeNX client 3.4.0-5 consumes all CPU on my Machine

Hello all

Just to write some about FreeNX Client running on Windows Vista, today noted that all my CPU was consuming when running FreeNX client to connect to Remote Fedora 9 NX Server.

If you have 100% of CPU consuming when running FreeNX client on Windows Vista try running without DirectDraw, To disable go to Advance tab on Windows Client, and check Disable DirectDraw option.


After that, Login again and look how your CPU consume is lower, much lower ....! :)





lunes, julio 06, 2009

Fedora 11 Keyboard and Mouse not working during the instalation - System completely Freeze

Anaconda with the new feature "wireless" did not recognize my cheap and good working in Window$ (with CD drivers of course), $25.00 dollars wireless card.

This is a TRL8185L chipset based card, but at this moment I don't now exactly whether the problem is Anaconda or HAL.
The symptoms was:

1.- When I boot with the LiveCD after sendmail the system became freeze, after many tries,
I googled the symptom I found to use the parameters " nomodeset", "xdriver=vesa", "selinux=0". and these did not work.

2.- I tried to use the Leonidas DVD and did not work. the parameters was "text" , "noprobe" and nothing work.

After all, I try to start the instalation in text mode but using a fast switch to console 4, using ALT+F4. and "Chilero"..:!
Did I see that the system became freeze after NetworkManager start the wlan0...!
then .. proceed to un-engage the card.

put the LiveCD in tray, and start, begin installation and now my Machine is working with Fedora 11.

**********************************************************

I need to add one note here.
In one of my test, I could to do an graphical installation using the LiveCD without quitting the Wireless Card, but after reboot, HAL was not starting, during boot appears as FAILED, and when start in hand, the message was related to "fdi cache".

I think that Anaconda could made the installation nice if HAL could recognize the wireless card from the beginning.

This entry is for that folks that him system became blocked during installation, start the instalation in text mode and switch fast with ALT+F4 this could help to identify the trouble.

Best Regards....
===========================
Using recent fresh Fedora 11 LiveCD instalation to Hard Disk.

domingo, febrero 17, 2008

Runnig FreeBSD as guest using Windows Vista as Host

First Step
Download QEmu Processor Emulator, as you surely know this Application help you to run x86, x86_64 and SPARC (with others) based applications. You can download some GUI with that, in my personal case QEmuManager was selected.

Second Step
Of course Install it, and create a Virtual Machine, with the Virtual Hard Disk, some easy steps to do that are following the wizard steps in the QEmuManager.

if you don't want to use the wizard then.. make the disk with command

qemu-img create -f qcow2 FreeBSD.dsk 5G

will create image with properties like this

image: FreeBSD.dsk
file format: qcow
virtual size: 5.4G (5779750912 bytes)
disk size: 3.3G
cluster_size: 4096

After create a the HD launch in the Virtual Machine

Once time launched, try to boot with the FreeBSD and install it over the new created disk.


If the installation was successful,

then try to login and start some nice services





I'm starting the Apache Web Server








And testing from the Host computer.

martes, junio 05, 2007

Runnig DOS Games using Linux Fedora

Hi, this time i want to tell you how to run some DOS games using a Linux Box,... then go ahead.

First step is to install QEmu on your Linux Box, I'm using Fedora and a modified yum configuration to use mi DVD to install software, to install QEmu do that

"yum install qemu"

after that the Second Step is download FreeDOS from http://www.freedos.org
download fdbasecd.iso

Ok... now we have to do an image of qemu to install FreeDOS for do that write:
qemu-img create dos.img 20M

where dos.img is the name of harddisk and 20M it's the space left to install DOS.

Third step: install FreeDOS on dos.img using qemu... for this write:
qemu -m 32 -std-vga -hda dos.img -boot d -cdrom dbasecd.iso

Here you are using 32 MB of RAM with standard VGA (VESA) with a hard disk of 20 MBand booting form the FreeDOS image CD.
after that you will see...








Ok... then install FreeDOS over the 20M HD, of course you have to create FAT16 partition and format .-
After do the install process...








After try to boot from the DOS disk...
use this command
qemu -m 32 -std-vga -hda dos.img -boot c
ant try to use some utilities







Now... you are ready to run your DOS games... HOW ?
First create an ISO image of your desired game... use the mkisofs utility.

First Copy and Unzip the game

[mariotpc@andrew pre1]$ dir
Prehistorik\ 1.zip
[mariotpc@andrew pre1]$ unzip Prehistorik\ 1.zip
Archive: Prehistorik 1.zip
inflating: --------.ANS
inflating: CHKLIST.CPS
inflating: COURIER.APP
inflating: FILESA.CUR
inflating: FILESA.VGA
inflating: FILESB.CUR
inflating: FILESB.VGA
extracting: GRAWAGA.CFG
inflating: HISTORIK.CS
inflating: HISTORIK.EXE
inflating: HISTORIK.NFO

[mariotpc@andrew pre1]$ dir
--------.ANS COURIER.APP FILESA.VGA FILESB.VGA HISTORIK.CS HISTORIK.NFO
CHKLIST.CPS FILESA.CUR FILESB.CUR GRAWAGA.CFG HISTORIK.EXE

[mariotpc@andrew qemu]$ mkisofs -o pre1.iso pre1/
I: -input-charset not specified, using utf-8 (detected in locale settings)
Total translation table size: 0
Total rockridge attributes bytes: 0
Total directory bytes: 0
Path table size(bytes): 10
Max brk space used 0
569 extents written (1 MB)

[mariotpc@andrew qemu]$ dir
dos.img dos.iso max-user-freq.orig pre1 pre1.iso

After do that run QEmu with this command
qemu -m 32 -std-vga -hda dos.img -boot c -cdrom pre1.iso

And ready to play the game....!


Notes: the CD drive is often mounted on d: drive... just go to this drive and run the exe file.

Compile and run Linux Kernel and Busybox for ARM 64 bits aarch64 on QEMU

Hello everyone, in this post you can read how to and where to download, compile and run Linux kernel and busybox for ARM64 processor. the ...