Open jmgomez-IAA opened 4 years ago
sudo apt-get install vnstat
Interface to the EW-7822-uac adaptor = wlx74da385d4193
pi@pypagerx-rpi3:/etc $ sudo vnstat –live -i wlx74da385d4193
Monitoring wlx74da385d4193… (press CTRL-C to stop)
rx: 0 kbit/s 0 p/s tx: 0 kbit/s 0 p/s
vcgencmd measure_temp
vcgencmd get_throttled
Note: if the output = throttled=0x0 then the power supply is supplying enough current/voltage/power to run the Raspberry pi. If you get other values, they mean different things:
throttled=0x50005 Okay, the bits in this number represent: Code: Select all 0: under-voltage 1: arm frequency capped 2: currently throttled 16: under-voltage has occurred 17: arm frequency capped has occurred 18: throttling has occurred under-voltage occurs when voltage drops below 4.63V. The Pi is throttled arm frequency capped occurs with temp > 80’C over-temperature occurs with temp > 85’C. The Pi is throttled
Throttling removes turbo mode, which reduces core voltage, and sets arm and gpu frequencies to non-turbo value. Capping just limits the arm frequency (somewhere between 600MHz and 1200MHz) to try to avoid throttling. If you are throttled and not under-voltage then you can assume over-temperature. (confirm with vcgencmd measure_temp).
So 0x50005 means you are currently under-voltage and throttled. If you want to be able to support this use case without throttling you will need a better power supply.
Although be aware running a stress test is not typical behaviour. If you never see a non-zero get_throttled value in normal usage, then you may not need to do anything.
From <https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=147781&start=50#p972790>
vcgencmd measure_clock arm
vcgencmd measure_volts core
vcgencmd measure_volts sdram_c
vcgencmd measure_volts sdram_i
vcgencmd measure_volts sdram_p
Es recomendable empear acutalizando todo:
~]# rpi-update
~]# apt-get update
~]# apt-get install libncurses-dev
Podemos conservar las fuentes empleando SKIP_REPODELETE=1
SKIP_REPODELETE
sudo SKIP_REPODELETE=1 rpi-update
By default the downloaded files (/root/.rpi-firmware) are deleted at end of update. Use this option to keep the files.
Parace que el kernel se descarga de https://github.com/raspberrypi/linux/archive/3c235dcfe80a7c7ba360219e4a3ecb256f294376.tar.gz
Una vez acutalizado pasamos a ver que dependencias tenemos:
~]# uname -a
> Linux rpi3-jmgomez-01 4.19.83-v7+ #1277 SMP Mon Nov 11 16:30:44 GMT 2019 armv7l GNU/Linux
Habitualmente las cabeceras estarian en el paquete raspberrypi-kernel-headers, pero al ser tan actuales no están en el
~]# apt-get install raspberrypi-kernel-headers
Para obtener las fuentes instaladas por rpi-update empleamos rpi-source
~]# sudo apt-get install git bc bison flex libssl-dev
~]# cd
~]# sudo wget https://raw.githubusercontent.com/notro/rpi-source/master/rpi-source -O /usr/local/bin/rpi-source && sudo chmod +x /usr/local/bin/rpi-source && /usr/local/bin/rpi-source -q --tag-update
~]# rpi-source
Ahora el codigo fuente esta en la carpeta root, y el kernel sabe donde esta, tal vez sea buena idea ejecutarlo en /usr/src
cd /usr/local/STAR-Dundee/STAR-System make -f driver_src/spw_usb/Kbuild clean make -f driver_src/spw_usb/Kbuild ./build_star-system_arm.sh
Necesitamos un makefile que compile nuestro modulo
~]$ cat << EOF | tee Kbuild
Makefile for the STAR-Dundee SpaceWire USB Driver
ifneq ($(KERNELRELEASE),)
EXTRA_CFLAGS += -Wall -Wextra
EXTRA_CFLAGS += -Wmissing-prototypes -Wmissing-declarations
EXTRA_CFLAGS += -pedantic
ifdef DEBUG EXTRA_CFLAGS += -g -O0 endif
EXTRA_CFLAGS += -Os # To get round a bug in __kfree_rcu in kernels > 2.6.39
obj-m := star_spw_usb.o star_spw_usb-objs := spwusb_driver.o spwusb_ioctl.o spwusb_fileops.o >spwusb_datahandling.o \ spwusb_buffers.o spwusb_kernel.o
else
KDIR := /lib/modules/$(shell uname -r)/build PWD := $(shell pwd) INSTALLDIR := /lib/modules/$(shell uname -r)/kernel/drivers/spacewire
default: $(MAKE) -C $(KDIR) M=$(PWD) modules if [ ! -d "$(INSTALLDIR)" ]; \ then mkdir -v -p "$(INSTALLDIR)"; \ fi cp star_spw_usb.ko "$(INSTALLDIR)"
clean: /bin/rm -f .o .ko "$(INSTALLDIR)"\star_spw_usb.ko
endif
Compilamos
sudo make -f Kbuild
Es posbile que falle por que no encuentra el directorio build, eso se debe a que no estan la fuentes de los modulos para compilar. Necesitamos descargar el codigo fuente del kernel y de los modulos.
~]# apt-cache search linux-headers
linux-headers-4.4.0-1-all - All header files for Linux 4.4 (meta-package) linux-headers-4.4.0-1-all-armhf - All header files for Linux 4.4 (meta-package) linux-headers-4.4.0-1-common - Common header files for Linux 4.4.0-1 linux-headers-4.4.0-1-rpi - Header files for Linux 4.4.0-1-rpi linux-headers-4.4.0-1-rpi2 - Header files for Linux 4.4.0-1-rpi2 linux-headers-4.9.0-6-all - All header files for Linux 4.9 (meta-package) linux-headers-4.9.0-6-all-armhf - All header files for Linux 4.9 (meta-package) linux-headers-4.9.0-6-common - Common header files for Linux 4.9.0-6 linux-headers-4.9.0-6-common-rt - Common header files for Linux 4.9.0-6-rt linux-headers-4.9.0-6-rpi - Header files for Linux 4.9.0-6-rpi linux-headers-4.9.0-6-rpi2 - Header files for Linux 4.9.0-6-rpi2 linux-headers-rpi - Header files for Linux rpi configuration (meta-package) linux-headers-rpi-rpfv - This metapackage will pull in the headers for the raspbian kernel for the linux-headers-rpi2 - Header files for Linux rpi2 configuration (meta-package) linux-headers-rpi2-rpfv - This metapackage will pull in the headers for the raspbian kernel for the raspberrypi-kernel-headers - Header files for the Raspberry Pi Linux kernel
Instalamos el paquete make y las cabeceras linux header
~]# apt-get install build-essential
~]# apt-get install linux-image-rpi-rpfv linux-headers-rpi-rpfv
~]# apt-get install raspberrypi-kernel-headers
Antes se requeria apt-get install linux-headers-3.10-3-rpi pero ahora con los metapacakges descargamos nuestra version de headeres.
Es posible que no esten disponibles la version de nuesrtos kernel, y por lo tanto enlazamos a la ultima disponible (la que se instalo)
Ahora tenemos que generar un link si no existe el directorio build en nuestro kernel:
~]# ln -s /lib/modules/4.19.66-v7+/build /lib/modules/4.19.83-v7+/build
Una vez satisfechas las dependencias compilamos
sudo make -f Kbuild
Instalamos el modulo:
Copy hello.ko to /lib/modules/'uname-r'/misc/ Add misc/module-name.ko entry in /lib/modules/'uname-r'/modules.dep sudo depmod sudo modprobe module-name
Kernel.org Raspberry PI 3 — Compile your own 64-bit Linux Kernel 2017 https://www.raspberrypi.org/forums/viewtopic.php?p=495080 https://www.computerhope.com/unix/modprobe.htm
Backup de partition table of the device
~]# sfdisk -d /dev/mmcblk0 > sd_partition_table.txt
Es necesario desplazar root y despues recrecer boot.
~]# fdisk -l /dev/mmcblk0p2
Comenzamos chequeando el estado de nestra tarjeta:
~]# e2fsck -f -y -v C 0 /dev/mmcblk0p2
En primer lugar debemos desplazar la particion rootfs hacia la derecha, siempre que haya espacio.
Movemos el sistema de archivos a la derecha
~]# e2image -ra -p -O 536870912 /dev/mmcblk0p2
Incrementamos el tamaño de la particion
Movemos el sistema de archivos a la derecha
~]# e2image -ra -p -O 536870912 /dev/mmcblk0p2
Decrementamos el tamaño de la particion
~]# fdisk -l /dev/mmcblk0
> Disk /dev/mmcblk0: 7948 MB, 7948206080 bytes, 15523840 sectors
> Units = sectors of 1 * 512 = 512 bytes
> Sector size (logical/physical): 512 bytes / 512 bytes
> I/O size (minimum/optimal): 512 bytes / 512 bytes
> Disk label type: dos
> Identificador del disco: 0x6c586e13
> Disposit. Inicio Comienzo Fin Bloques Id Sistema
> /dev/mmcblk0p1 8192 532479 262144 c W95 FAT32 (LBA)
> /dev/mmcblk0p2 1581056 5439487 1929216 83 Linux
Ahora procedemos a cambiar el tamaño de /boot
Backup de la particion
~]$ cd ~
~]$ mkdir boot-upgrade
~]$ mkdir boot-backup
~]# mount dev/mmcblk0p1 ./boot-upgrade
~]$ rsync -vaP ./boot-backup/ ./boot-upgrade/*
~]# umount /boot-upgrade
Modificamos la tabla de particiones en el fichero de backup y la recargamos en la tarjeta:
~]$ cp sd_partition_table.txt updated_partition_table.txt
~]$ nano updated_partition_table.txt
> partition table of /dev/mmcblk0
> unit: sectors
>
> /dev/mmcblk0p1 : start= 8192, size= 1524288, Id= c
> /dev/mmcblk0p2 : start= 1581056, size= 3858432, Id=83
> /dev/mmcblk0p3 : start= 0, size= 0, Id= 0
> /dev/mmcblk0p4 : start= 0, size= 0, Id= 0
Escribimos la tabla de particiones
```sfdisk /dev/sdb < sfdisk_sdb.mod.txt ```
Restauramos los datos
~]# mkfs.fat -n "BOOT" -F 32 /dev/mmcblk0p1 ~]# mount /dev/mmcblk0p1 ./boot-upgrade ~]# rsync -vaP ./boot-backup/* ./boot-upgrade/ ~]# umount /boot-upgrade ~]# rm -r ./boot-backup
## Extra
Restore the backup sfdisk /dev/sdb <~/sfdisk_sdb.mod.txt
Si ha creado o modificado una partición DOS, como /dev/foo7, utilice dd(1)
para poner a cero los 512 primeros bytes: dd if=/dev/zero of=/dev/foo7 bs=512 count=1
Esta configuración puede hacerse en el host que instala raspbian
Creando un fichero vacio con nombre ssh, el ssh estara activo por defecto.
~]$ mkdir -p /rpi3_system/boot
~]# mount /dev/mmcblk0p1 /rpi3_system/boot
~]# touch /rpi3_system/boot/ssh
~]# umount /rpi3_system/boot
Por defecto, esta creado el siguiente usuario:
usuario: pi pass: raspberry
~]# mkdir -p /rpi3_system//etc/skel/.ssh
~]# nano /rpi3_system/etc/skel/.ssh
# Cambiamos el prompt a algo mas corto:
if [ "$color_prompt" = yes ]; then
# PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w \$\[\033[00m\] '
PS1='\[\033[01;34m\]]\W] \$\[\033[00m\] '
...
# add alias for workspace
alias wk='cd /srv/share/Workspace/'
~]# mkdir -p /rpi3_system//home/jmgomez/
~]# cp /home/jmgomez/.ssh/id_rsa.pub /rpi3_system/home/jmgomez/.ssh/authorized_keys
~]# sudo hostname rpi3-jmgomez-01
~]# nano /rpi3_system/ /etc/hosts
127.0.1.1 rpi3-jmgomez-01
~]# echo "rpi3-jmgomez-01" > /etc/hostname
These are the RAM splits and what they should be used for.
You can change the RAM split by changing the config.txt file
~]$ mkdir -p /rpi3_system/boot
~]$ cd /rpi3_system/boot
~]# mount /dev/mmcblk0p1 /rpi3_system/boot
~]# nano /rpi3_system/boot/config.txt
> gpu_mem=16
~]# umount /rpi3_system/boot
Antes parecía hacerse asi!!
~]$ mkdir -p /rpi3_system/boot ~]$ cd /rpi3_system/boot ~]# mount /dev/mmcblk0p1 /rpi3_system/boot ~]# cp /boot/arm[ram-split]_start.elf /boot/start.elf
where [ram-split] is the amount of RAM to allocate to the CPU. After a reboot the new value will be applied.
~]# mount /dev/mmcblk0p2 /rpi3_system/
~]# mount /dev/mmcblk0p1 /rpi3_system/boot
~]# mkdir -p rpi3_system/share/Workspace/{lineas_trabajo,deploy,librerias,documentos}
~]# umount -R rpi3_system/
En primer lugar conectarse a la Raspberry Pi3 por ssh y logearse con el usuario pi y password raspberry .
~]$ sudo -i
~]# useradd jmgomez
~]# usermod -d /home/jmgomez jmgomez
~]# useradd -d /home/jmgomez -m -U
~]# adduser jmgomez sudo
~]# adduser jmgomez netdev
~]# passwd jmgomez
~]# mkdir -p /home/jmgomez/
~]# cp -rT /etc/skel /home/jmgomez
~]# mkdir -p /home/jmgomez/.ssh
~]# chown -R jmgomez:jmgomez /home/jmgomez
Ahora, vamos a copiar nuestra clave publica para conectarnos sin tener que emplear usuario y contraseña.
~]# scp .ssh/id_rsa.pub jmgomez@10.9.0.14:/home/jmgomez/.ssh/authorized_keys
Change the hostname
~]# sudo hostname rpi3-jmgomez-01
Nos sabemos si la edicion de estos ficheros es obligatoria
~]# nano /rpi3_system/ /etc/hosts
127.0.1.1 rpi3-jmgomez-01
~]# echo "rpi3-jmgomez-01" > /etc/hostname
Delete the pi user:
~]# deluser -remove-home pi
~]# rm -vf /etc/sudoers.d/010_pi-nopasswd
Este fichero es para que pi no tenga que escribir el password para hacer sudo. /etc/sudoers.d/010_pi-nopasswd
Grupos de Raspbian y su emplicacion:
[ ] apt-file apt-get solo busca en los nobres de los paquetes, con apt-file buscamos en los contenidos.
~]# apt-get install -y apt-file
~]# apt-file update
~]# apt list --upgradable
[ ] git repositorios
~]# apt-get install git
[ ] autotools Compilacion
~]# apt-get install autoconf, automake, libtool, gettext
autoconf-archive gnu-standards autoconf-doc libtool gettext
Rpi3 Cluster
Reference Links
https://linuxconfig.org/building-a-raspberry-pi-cluster-part-i-hardware-acquisition-and-assembly