jmgomez-IAA / loogbook

Personal web page
0 stars 0 forks source link

Post Ideas: RTOS Projects #26

Open jmgomez-IAA opened 5 years ago

jmgomez-IAA commented 5 years ago

Open Operating System RTOS

Probar y testear: https://www.zephyrproject.org/ Probar y testear: https://www.rtems.org

jmgomez-IAA commented 5 years ago

Zephyr

En primer lugar para trabajar con Zephyr tenemos que instalar el SDK, que contiene todas las herramientas que se emplean en la compilacion del RTOS.

Install Zephyr SDK

Instrucciones para Linux

Dependencias

Los scripts de compilación de Zephyr requieren las siguientes herramientas para fucnuionar.

sudo dnf group install "Development Tools" "C Development Tools and Libraries"
dnf install git cmake ninja-build gperf ccache dfu-util dtc wget \
  python3-pip xz file glibc-devel.i686 libstdc++-devel.i686

La version de CMake debe ser superior a la 3.13.1. #]~ cmake --version

Instalar el SDK

#]~ wget https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.10.0/zephyr-sdk-0.10.0-setup.run 
#]~ chmod +x zephyr-sdk-0.10.0-setup.run 
#]~ ./zephyr-sdk-0.10.0-setup.run

Por defecto se instala en /opt/zephyr-sdk por lo que requiere permisos de administrador.

Una vez instalado se requieren las siguientes variables para funcionar y que deben ser instaladas antes de hacer el SOURCES.

#]~ export ZEPHYR_TOOLCHAIN_VARIANT=zephyr
#]~ export ZEPHYR_SDK_INSTALL_DIR=<sdk installation directory>

Para nuestro caso:

#]~  export ZEPHYR_TOOLCHAIN_VARIANT=zephyr
#]~ export ZEPHYR_SDK_INSTALL_DIR=/opt/zephyr-sdk

Getting the Zephyr Sources

  1. Clonar el repositorio de Zephyr: git clone https://github.com/zephyrproject-rtos/zephyr.git

  2. Elegir la rama de trabajo:

    #]~ git branch -r 
    #]~ git checkout v1.14-branch

Compilando el helloworld.

Emulacion en Cortex-M3 con QEMU Emulación en Risc-V

Links

Ejemplo para RISC-V

jmgomez-IAA commented 4 years ago

RTEMS

Requirements

Raspbian

$]#  sudo apt-get install autoconf automake bison flex binutils gcc g++ gdb 
texinfo unzip ncurses-dev python-dev git

CentOS

Estructura de directorios

Variable Ruta Description
$BASE /srv/share/Workspace/lineas_trabajo/source/rtems_solutions/rtems_base/ trabajo
$TOOL /opt/rtems/5 toolbox generada por Source Build
$SOURCE $BASE/src Codigo fuente
$BUILD $BASE/src Codigo fuente

Procedimiento

$]#  yum install autoconf automake binutils gcc gcc-c++ gdb make patch bison flex xz unzip ncurses-devel texinfo zlib-devel python-devel git pax

pax no aparece en la ayuda de la web. pero es requerido.

Creamos el directorio correspondiente para nuestro installation prefix y le damos permisos a nuestro usuario:

$]# mkdir -p /opt/rtems/5
$]# chown jmgomez:jmgomez /opt/rtems/5
$]# ls /opt/rtems/ -la

total 0 drwxr-xr-x. 3 root root 15 mar 3 10:13 . drwxr-xr-x. 17 root root 241 mar 3 10:13 .. drwxr-xr-x. 2 jmgomez jmgomez 6 mar 3 10:13 5

Creamos nuestro directorio de trabajo:

$]# mkdir -p $/srv/share/Workspace/lineas_trabajo/source/rtems_solutions/rtems_base/src
$]# cd /srv/share/Workspace/lineas_trabajo/source/rtems_solutions/rtems_base/src

Clonamos los repositororios:

$]# git clone git://git.rtems.org/rtems-source-builder.git rsb
$]# git clone git://git.rtems.org/rtems.git

Nos colocamos en rtems source builder y verificamos que srb esta correctamente instalado:

$]# cd rsb/rtems
$]# ../source-builder/sb-check

Ahora vamos a contruir nuestra toolbox:

$]# ../source-builder/sb-set-builder --source-only-download 5/rtems-sparc
$]# ../source-builder/sb-set-builder --prefix=/opt/rtems/5 5/rtems-sparc

Verificamos que se ha instaldo correctamente nuesrto compilador de sparc:

$]# /opt/rtems/5/bin/sparc-rtems5-gcc --version --verbose

Using built-in specs. COLLECT_GCC=/opt/rtems/5/bin/sparc-rtems5-gcc COLLECT_LTO_WRAPPER=/opt/rtems/5/libexec/gcc/sparc-rtems5/7.5.0/lto-wrapper sparc-rtems5-gcc (GCC) 7.5.0 20191114 (RTEMS 5, RSB 5 (834a0ea88a48), Newlib fbaa096) Copyright (C) 2017 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Target: sparc-rtems5

Build RTEMS

Primero hacemos el bootstrap par que las autotools generen los makes.

$]# cd ..
$]# cd rtems/
$]# export PATH=/opt/rtems/5/bin/:${PATH}
$]# echo $PATH
$]# ./bootstrap -c
$]# ../rsb/source-builder/sb-bootstrap 

Creamos un directorio de trabajo, externo al arbol git:

$]# mkdir -p /srv/share/Workspace/lineas_trabajo/source/rtems_solutions/rtems_base/src/build/b-gr712

Y finalmente hacemos el configure de los makes para nuestra arquitectura:

$]# cd /srv/share/Workspace/lineas_trabajo/source/rtems_solutions/rtems_base/src/build/b-gr712
$]# export PATH=/opt/rtems/5/bin:${PATH}
$]# ../../rtems/configure \
    --prefix=$HOME/quick-start/rtems/5 \
    --enable-maintainer-mode \
    --target=sparc-rtems5 \
    --enable-rtemsbsp=leon3 \
    --enable-debug --enable-smp
    --enable-tests

Finalmente compilamos e instalamos

$]# make 
$]# make install

Ahora vamos a los ejemplos:

$]# file ./sparc-rtems5/c/leon3/testsuites/samples/hello.exe
rtems_base/src/build/b-gr712/sparc-rtems5/c/leon3/testsuites/samples/hello.exe: ELF 32-bit MSB executable, SPARC, version 1 (SYSV), statically linked, with unknown capability 0x41000000 = 0xf676e75, with unknown capability 0x10000 = 0x70403, not stripped

$]# grmon -u -ftdi
grlib> load ./sparc-rtems5/c/leon3/testsuites/samples/hello.exe
section: .text at 0x40000000, size 104240 bytes
section: .rtemsroset at 0x40019730, size 80 bytes
section: .data at 0x4001b780, size 1568 bytes
total size: 105888 bytes (755.6 kbit/s)
read 599 symbols
entry point: 0x40000000
grlib> run

*** BEGIN OF TEST HELLO WORLD ***
*** TEST VERSION: 5.0.0.198c07e5a58413bb2b16c01a15c545875d144ad5
*** TEST STATE: EXPECTED_PASS
*** TEST BUILD: RTEMS_NETWORKING RTEMS_POSIX_API RTEMS_SMP
*** TEST TOOLS: 7.5.0 20191114 (RTEMS 5, RSB 5 (834a0ea88a48), Newlib fbaa096)
Hello World

*** END OF TEST HELLO WORLD ***

Program exited normally.
grlib> quit
jmgomez-IAA commented 4 years ago

RTEMS

Archlinux Host

The following packages are required on a fresh Archlinux 64bit installation:

$]# sudo pacman -S python-pip

$]# sudo pacman -S base-devel gdb xz unzip ncurses git zlib```
sudo pacman -S base-devel gdb xz unzip ncurses git zlib
[sudo] password for jmgomez: 
:: There are 24 members in group base-devel:
:: Repository core
>   1) autoconf  2) automake  3) binutils  4) bison  5) fakeroot  6) file  7) findutils  8) flex  9) gawk
>   10) gcc  11) gettext  12) grep  13) groff  14) gzip  15) libtool  16) m4  17) make  18) pacman
>   19) patch  20) pkgconf  21) sed  22) sudo  23) texinfo  24) which

>>Packages (32)
>> gdb-common-8.3.1-4  guile2.0-2.0.14-3  autoconf-2.69-6  automake-1.16.1-2
>>              binutils-2.33.1-2  bison-3.5-1  fakeroot-1.24-2  file-5.38-1  findutils-4.7.0-2
>>              flex-2.6.4-3  gawk-5.0.1-2  gcc-9.2.0-4  gdb-8.3.1-4  gettext-0.20.1-3  git-2.25.0-1
>>              grep-3.4-1  groff-1.22.4-3  gzip-1.10-3  libtool-2.4.6+42+gb88cebd5-8  m4-1.4.18-3
>>              make-4.2.1-4  ncurses-6.1-7  pacman-5.2.1-4  patch-2.7.6-8  pkgconf-1.6.3-3  sed-4.8-1
>>              sudo-1.8.30-1  texinfo-6.7-2  unzip-6.0-13  which-2.21-5  xz-5.2.4-2  zlib-1:1.2.11-4

Tenemos que emplar una version de texinfo concreta para gcc4.7, texinfo-legacy from AUR.

```$]# sudo pacman -Rdd texinfo ```
> Packages (1) texinfo-6.7-2
> Total Removed Size:  8.52 MiB
> :: Do you want to remove these packages? [Y/n] Y

**No existe alternativa a texinfo-6 asi, que seguimos con el**
``` $]# sudo pacman -S texinfo```

#### [Project sandboxing](https://docs.rtems.org/branches/master/user/installation/project-sandboxing.html#projectsandboxing)

$]# sudo mkdir -p /opt/rtems/5 $]# sudo chown jmgomez:users /opt/rtems/5 $]# sudo ls -la /opt/rtems/

> total 12
> drwxr-xr-x 3 root    root  4096 Mar  3 10:00 .
> drwxr-xr-x 4 root    root  4096 Mar  3 10:00 ..
> drwxr-xr-x 2 jmgomez users 4096 Mar  3 10:00 5

Por lo tanto nuestro project prefix sera: -prefix /srv/share/Workspace/lineas_trabajo/source/rtems_solutions/rtems_base/src

mkdir -p $/srv/share/Workspace/lineas_trabajo/source/rtems_solutions/rtems_base/src cd /srv/share/Workspace/lineas_trabajo/source/rtems_solutions/rtems_base/src git clone git://git.rtems.org/rtems-source-builder.git rsb git clone git://git.rtems.org/rtems.git



## Links

https://blog.dbalan.in/blog/2013/05/28/getting-started-with-rtems-on-archlinux/index.html

## Q&A 
1. Xq [pacman -Rdd texinfo](https://unix.stackexchange.com/questions/10178/how-do-i-force-remove-a-package-in-arch-with-pacman)?
> Tenemos que borrar solo ese paquete, y mantener las dependencias.
> # pacman -Rdd perl-libwww
>
> Please notice the double -d in the command, if you use --nodeps you have to specify that twice too. This removes all the packages which depend on perl-libwww:
> # pacman -Rc perl-libwww
jmgomez-IAA commented 4 years ago

RTEMS 4.11 en Centos7

Estructura de directorios

Variable Ruta Description
$BASE /srv/share/Workspace/lineas_trabajo/source/rtems_solutions/rtems_base/ trabajo
$TOOL /opt/rtems/5 toolbox generada por Source Build
$SOURCE $BASE/src Codigo fuente
$BUILD $BASE/src Codigo fuente

Procedimiento

Se necesitan las librerías de desarrollo gcc, la compilación está basada en autotools.

$]#  yum install autoconf automake binutils gcc gcc-c++ gdb make patch bison flex xz unzip ncurses-devel texinfo zlib-devel python-devel git pax

pax no aparece en la ayuda de la web. pero es requerido.

Creamos el directorio correspondiente para nuestro installation prefix y le damos permisos a nuestro usuario:

$]# mkdir -p /opt/rtems/4.11
$]# chown jmgomez:jmgomez /opt/rtems/4.11
$]# ls /opt/rtems/ -la

Creamos nuestro directorio de trabajo:

$]# mkdir -p $/srv/share/Workspace/lineas_trabajo/source/rtems_solutions/rtems_base/src
$]# cd /srv/share/Workspace/lineas_trabajo/source/rtems_solutions/rtems_base/src

Clonamos los repositororios:

$]# git clone git://git.rtems.org/rtems-source-builder.git rsb
$]# git fetch --all --tags --prune
$]# git checkout 4.11 origin/4.11
$]# git branch -u origin/4.11

$]# git clone git://git.rtems.org/rtems.git
$]#  git fetch --all --tags --prune
$]# git checkout -b 4.11 origin/4.11
$]# git branch -u origin/4.11

Nos colocamos en rtems source builder y verificamos que srb esta correctamente instalado:

$]# cd rsb/rtems
$]# ../source-builder/sb-check

Ahora vamos a contruir nuestra toolbox:

$]# ../source-builder/sb-set-builder --source-only-download 4.11/rtems-sparc
$]# ../source-builder/sb-set-builder --log=$BUILD/1-sparc.txt --prefix=${TOOL} 4.11/rtems-sparc

Verificamos que se ha instaldo correctamente nuesrto compilador de sparc:

]$ /opt/rtems/4.11/bin/sparc-rtems4.11-gcc --version --verbose

Using built-in specs. COLLECT_GCC=/opt/rtems/4.11/bin/sparc-rtems4.11-gcc COLLECT_LTO_WRAPPER=/opt/rtems/4.11/libexec/gcc/sparc-rtems4.11/4.9.3/lto-wrapper sparc-rtems4.11-gcc (GCC) 4.9.3 20150626 (RTEMS 4.11, RSB c88c92d7fc9373ab167369669917f7de7695516e, Newlib 2.2.0.20150423) Copyright (C) 2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Target: sparc-rtems4.11

Build RTEMS

Primero hacemos el bootstrap par que las autotools generen los makes.

$]# cd ../../rtems/
$]# export PATH=/opt/rtems/4.11/bin/:${PATH}
$]# echo $PATH
$]# ./bootstrap -c
$]# ../rsb/source-builder/sb-bootstrap 

Creamos un directorio de trabajo, externo al arbol git:

$]# mkdir -p /srv/share/Workspace/lineas_trabajo/source/rtems_solutions/rtems_base/src/build/b-gr712

Y finalmente hacemos el configure de los makes para nuestra arquitectura:

$]# cd /srv/share/Workspace/lineas_trabajo/source/rtems_solutions/rtems_base/src/build/rtems4.11-leon3
$]# export PATH=/opt/rtems/4.11/bin:${PATH}
$]# ../../rtems/configure \
    --prefix=$TOOL/bin \
    --enable-maintainer-mode \
    --target=sparc-rtems4.11 \
    --enable-rtemsbsp=leon3 \
    --enable-debug
    --enable-tests

Finalmente compilamos e instalamos

$]# make 
$]# make install

Check the build:

$]# file sparc-rtems4.11/c/leon3/testsuites/samples/hello/hello.exe
$]# grmon -u -ftdi 
grlib> load sparc-rtems4.11/c/leon3/testsuites/samples/hello/hello.exe
section: .text at 0x40000000, size 115152 bytes
section: .data at 0x4001c1d0, size 1600 bytes
total size: 116752 bytes (755.7 kbit/s)
read 690 symbols
entry point: 0x40000000
grlib> run

*** BEGIN OF TEST HELLO WORLD ***
Hello World
*** END OF TEST HELLO WORLD ***

Program exited normally.
grlib> quit

Links

Getting started with RTEMS on Archlinux

https://devel.rtems.org/wiki/TBR/BSP/Leon3

https://docs.rtems.org/releases/rtems-docs-4.11.2/bsp-howto/networking.html

jmgomez-IAA commented 4 years ago

SpaceWire RAMP Library https://github.com/yuasatakayuki

jmgomez-IAA commented 4 years ago

Building LibBSD for RTEMS using Waf https://rmeena840.github.io/Fourth-Post/ https://rmeena840.github.io/Third-Post/

jmgomez-IAA commented 4 years ago

http://sichenzhao.blogspot.com/2017/06/rtems-libbsd-generates-drive-device.html?m=1

jmgomez-IAA commented 4 years ago

https://github.com/alanc98 http://alanstechnotes.blogspot.com

http://alanstechnotes.blogspot.com/2013/03/rtems-on-raspberry-pi.html?m=1

jmgomez-IAA commented 4 years ago

https://www.raspberrypi.org/forums/viewtopic.php?f=56&t=201447

jmgomez-IAA commented 4 years ago

RTEMS Build application

The Makefile system used in these examples is dependent on the environment variable RTEMS_MAKEFILE_PATH being set. This can be set on each command line that invokes "make" or it can be exported into your environment.

RTEMS_MAKEFILE_PATH points to the installed BSP image you are compiling for. It is composed as follows:

@prefix@/@target@/BSP

where:

A coupte of examples:

export RTEMS_MAKEFILE_PATH=${HOME}/rtems-work/tools/5/sparc-rtems5/erc32 make clean make

OR:

RTEMS_MAKEFILE_PATH=${HOME}/rtems-work/tools/5/sparc-rtems5/erc32 make clean RTEMS_MAKEFILE_PATH=${HOME}/rtems-work/tools/5/sparc-rtems5/erc32 make

You can switch a build from one BSP to another by changing the value of RTEMS_MAKEFILE_PATH but be careful to "make clean" on the old BSP before building the new one.

Deprecration Warning: This style of Makefile has been included in RTEMS since the earliest days. However, it is being replaced by the use of waf and something akin to pkgconfig to obtain compilation settings. The intent is to make it easier for users to configure their preferred build system for an RTEMS application

export RTEMS_HOME=/opt/rtems/5 export PATH=$RTEMS_HOME/bin:$PATH

Este es nuestro cofigure

../../src/rtems/configure --prefix=/srv/share/Workspace/lineas_trabajo/source/rtems_solutions/rtems_base/rtems/5 --enable-maintainer-mode --target=sparc-rtems5 --enable-rtemsbsp=leon3 --enable-tests

export RTEMS_ROOT=/srv/share/Workspace/lineas_trabajo/source/rtems_solutions/rtems_base/build/rtems5_leon3/sparc-rtems5/c/leon3/

Este es el prefix que se uso en la configuracion, seguido del BSP a emplear en la compilacion de la app.

export RTEMS_MAKEFILE_PATH=/srv/share/Workspace/lineas_trabajo/source/rtems_solutions/rtems_base/rtems/5/sparc-rtems5/leon3/

LINKS: https://rtems-users.rtems.narkive.com/ngieRXzs/how-can-i-get-a-bsp-and-start-to-develop-my-rtems-application-on-eclipse-where-is-the-bsp-path