1
0
Fork 0
mirror of https://github.com/RobotechLille/cdf2018-principal synced 2025-09-05 09:35:56 +02:00

Commit initial

This commit is contained in:
Geoffrey Frogeye 2018-02-07 17:57:01 +01:00
commit e0cb79d1cc
57 changed files with 2128 additions and 0 deletions

5
raspberrypi/.gitignore vendored Normal file
View file

@ -0,0 +1,5 @@
dl
output
principalconf.sh
sshconf
sshkey*

2
raspberrypi/Config.in Normal file
View file

@ -0,0 +1,2 @@
source "$BR2_EXTERNAL_CDF_PATH/package/robotech/Config.in"
source "$BR2_EXTERNAL_CDF_PATH/package/cr1901/Config.in"

102
raspberrypi/Makefile Normal file
View file

@ -0,0 +1,102 @@
default: compile
upgrade-all: upgrade-chef upgrade-arduino upgrade-fpga upgrade-filesystem
# CONSTANTES
# Périphérique bloc à utiliser pour flasher
SDCARD=/dev/mmcblk0
# SYSTÈME D'EXPLOITATION
# Configuration
buildroot/.config: configs/cdfprincipal_defconfig
make -C buildroot BR2_EXTERNAL=.. cdfprincipal_defconfig
configure: buildroot/.config
# Compile l'OS (ça prend quelques heures)
compile: configure
make -C buildroot target-finalize
# Crée l'image à flasher
image:
make -C buildroot
# Supprime tous les fichiers de l'OS
clean:
make -C buildroot clean
# Dernier recours en cas de compilation d'OS foireuse
# (faut être patient)
recompile: clean compile
# Flashe l'image sur la carte SD
flash: image $(SDCARD)
sudo dd status=progress if=buildroot/output/images/sdcard.img of=$(SDCARD) bs=1M
sync
echo -e "resizepart 2\n100%\nquit" | sudo parted $(SDCARD)
sync
sudo resize2fs $(SDCARD)*2
sync
# Graphiques (parce que c'est rigolo)
graphs:
make -C buildroot graph-{size,build,depends{,-requirements}}
# CONNEXION AU ROBOT
# Il vous faudra pour ces actions le fichier principalconf.sh
# Crée un fichier de conf utilisable pour s'y connecter
sshconf: principalconf.sh
source $$PWD/$<; echo -e "Host principal p\n User root\n Hostname $$ADDRESS\n PreferredAuthentications publickey\n PubkeyAuthentication yes\n IdentityFile \"$$PWD/sshkey\"" > "$@"
source $$PWD/$<; echo -e "$$SSHCPRV" > sshkey
chmod 600 sshkey
# Lance une connexion SSH, tout bêtement
ssh: sshconf
ssh -F sshconf principal
# Redémarre le robot
reboot: sshconf
ssh -F sshconf principal /sbin/reboot
# Met le robot à l'heure (jusqu'au prochain redémarrage)
# (ce qui est une mauvaise idée parce que du coup rsync
# n'écrase pas les fichiers modifiés directement sur le Pi)
#date: sshconf
# ssh -F sshconf principal "date -s $(date +%Y%m%d%H%M.%S)"
# Met à jour le Raspberry Pi (par rapport à ce dépôt)
upgrade-filesystem: sshconf configure
make -C buildroot target-finalize
@# TODO Récupérer les ACL plutot que de mettre tous les fichiers en root
rsync --rsh 'ssh -F sshconf' --archive --chown root:root buildroot/output/target/ principal:/
# Met jour les overlays (une partie des fichiers)
upgrade-overlays: sshconf
rsync --rsh 'ssh -F sshconf' --archive --chown root:root robotech/chef/rootfs_overlay/ principal:/
# ARDUINO
upgrade-arduino:
make -C ../arduino/
scp -F sshconf -q "../arduino/principal.hex" principal:/tmp/principal.hex
ssh -F sshconf principal "avrdude -p atmega2560 -P /dev/ttyACM0 -c stk500 -D -U flash:w:/tmp/principal.hex"
# FPGA
upgrade-fpga:
make -C ../fpga/
scp -F sshconf -q "../fpga/build/Principal.bit" principal:/tmp/Principal.bit
ssh -F sshconf principal "mercpcl /tmp/Principal.bit"
# CHEF
prog: chef
chef:
make -C buildroot chef-rebuild
upgrade-chef: chef
make -C buildroot chef-reinstall
rsync --rsh 'ssh -F sshconf' --archive --chown root:root buildroot/output/target/opt/chef principal:/opt/

View file

@ -0,0 +1,2 @@
MEDIA_SUPPORT=n
SOUND=n

View file

@ -0,0 +1,42 @@
#!/bin/sh
if file ${BR2_EXTERNAL_CDF_PATH}/principalconf.sh &> /dev/null
then
source ${BR2_EXTERNAL_CDF_PATH}/principalconf.sh
# Wi-Fi configuration
mkdir -p ${TARGET_DIR}/etc/wpa_supplicant/
wpa_passphrase "$WPASSID" "$WPAPSK" > ${TARGET_DIR}/etc/wpa_supplicant/wpa_supplicant.conf
# Le ifup de Busybox ne supporte pas les options wpa-*, donc on utilisera les wpa_supplicant en direct
# Network configuration
echo -e "
auto wlan0
iface wlan0 inet static
address $ADDRESS
netmask $NETMASK
gateway $GATEWAY
" >> ${TARGET_DIR}/etc/network/interfaces
# SSH configuration
rm ${TARGET_DIR}/etc/dropbear &> /dev/null
mkdir -p ${TARGET_DIR}/etc/dropbear/
echo "$SSHSPRV" | base64 -d > ${TARGET_DIR}/etc/dropbear/dropbear_ecdsa_host_key
mkdir -p ${TARGET_DIR}/root/.ssh/
echo "$SSHCPUB" > ${TARGET_DIR}/root/.ssh/authorized_keys
else
echo "Récupérez le fichier principalconf.sh pour pouvoir vous connecter au vrai robot !"
fi
# Demote some services
for service in S20urandom S40network S50dropbear
do
if [ -f ${TARGET_DIR}/etc/init.d/${service} ]
then
mv ${TARGET_DIR}/etc/init.d/${service} ${TARGET_DIR}/etc/extra.d/${service}
fi
done
dd if=/dev/urandom of=${TARGET_DIR}/etc/random-seed bs=512 count=1

View file

@ -0,0 +1,41 @@
#!/bin/sh
#
# Connect to Wi-Fi network
#
start() {
printf "Starting Wi-Fi connection: "
# modprobe brcmfmac
modprobe r8188eu
ip link set wlan0 up
wpa_supplicant -D wext -B -iwlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf -P /var/run/wpa_supplicant.pid
ifup wlan0
echo "OK"
}
stop() {
printf "Stopping Wi-Fi connection: "
start-stop-daemon -K -q -p /var/run/wpa_supplicant.pid
ifdown wlan0
# rmmod brcmfmac
rmmod r8188eu
echo "OK"
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
stop
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac
exit $?

View file

@ -0,0 +1,27 @@
#!/bin/sh
# Stop all init scripts in /etc/extra.d
# executing them in reversed numerical order.
#
for i in $(ls -r /etc/extra.d/S??*) ;do
# Ignore dangling symlinks (if any).
[ ! -f "$i" ] && continue
case "$i" in
*.sh)
# Source shell script for speed.
(
trap - INT QUIT TSTP
set stop
. $i
)
;;
*)
# No sh extension, so fork subprocess.
$i stop
;;
esac
done

View file

@ -0,0 +1,27 @@
#!/bin/sh
# Start all init scripts in /etc/extra.d
# executing them in numerical order.
#
for i in /etc/extra.d/S??* ;do
# Ignore dangling symlinks (if any).
[ ! -f "$i" ] && continue
case "$i" in
*.sh)
# Source shell script for speed.
(
trap - INT QUIT TSTP
set start
. $i
)
;;
*)
# No sh extension, so fork subprocess.
$i start
;;
esac
done

View file

@ -0,0 +1,33 @@
#!/bin/sh
#
# Changes keyboard layout to AZERTY
#
start() {
printf "Starting AZERTY keyboard: "
loadkmap < /usr/share/keyboard/fr-latin9.bmap
echo "OK"
}
stop() {
printf "Stopping AZERTY keyboard: "
echo "OK"
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
stop
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac
exit $?

View file

@ -0,0 +1,38 @@
#!/bin/sh
#
# Start main program
#
EXEC=$(which sh)
PIDFILE=/var/run/chef.pid
LOGFILE=/var/run/chef.log
start() {
printf "Starting chef: "
start-stop-daemon -p "$PIDFILE" -x "$EXEC" -b -m -S -- "/opt/chef/run.sh" -l "$LOGFILE"
echo "OK"
}
stop() {
printf "Stopping chef: "
start-stop-daemon -p "$PIDFILE" -x "$EXEC" -K
echo "OK"
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
stop
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac
exit $?

View file

@ -0,0 +1,37 @@
#!/bin/sh
#
# Start extra services when not in debug mode
#
start() {
printf "Starting extra services: "
if ! /opt/cdf/bin/testpin 0 1
then
/etc/extra.d/rcS
fi
echo "OK"
}
stop() {
printf "Stopping extra services: "
/etc/extra.d/rcK
echo "OK"
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
stop
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac
exit $?

View file

@ -0,0 +1,13 @@
#/bin/bash
alias la='ls -al'
alias ll='ls -l'
alias cp="cp -i"
alias mv="mv -i"
alias free='free -m'
alias df='df -h'
export PS1="[\u@\h \$] "
export PS2="> "
export PS3="+ "
export PS4="- "

1
raspberrypi/buildroot Submodule

@ -0,0 +1 @@
Subproject commit 8f03647169a17b10503594e5f3d95113a01171f9

View file

@ -0,0 +1,87 @@
# From configs/raspberrypi3_defconfig
BR2_arm=y
BR2_cortex_a7=y
BR2_ARM_EABIHF=y
BR2_ARM_FPU_NEON_VFPV4=y
BR2_TOOLCHAIN_BUILDROOT_CXX=y
BR2_SYSTEM_DHCP="eth0"
# Linux headers same as kernel, a 4.4 series
BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_4=y
BR2_LINUX_KERNEL=y
BR2_LINUX_KERNEL_CUSTOM_GIT=y
BR2_LINUX_KERNEL_CUSTOM_REPO_URL="https://github.com/raspberrypi/linux.git"
BR2_LINUX_KERNEL_CUSTOM_REPO_VERSION="1ebe8d4a4c96cd6a90805c74233a468854960f67"
BR2_LINUX_KERNEL_DEFCONFIG="bcm2709"
# Build the DTB from the kernel sources
BR2_LINUX_KERNEL_DTS_SUPPORT=y
BR2_LINUX_KERNEL_INTREE_DTS_NAME="bcm2710-rpi-3-b"
BR2_PACKAGE_RPI_FIRMWARE=y
BR2_PACKAGE_RPI_FIRMWARE_INSTALL_DTB_OVERLAYS=y
# Required tools to create the SD image
BR2_PACKAGE_HOST_DOSFSTOOLS=y
BR2_PACKAGE_HOST_GENIMAGE=y
BR2_PACKAGE_HOST_MTOOLS=y
# Filesystem / image
BR2_TARGET_ROOTFS_EXT2=y
BR2_TARGET_ROOTFS_EXT2_4=y
# BR2_TARGET_ROOTFS_TAR is not set
BR2_ROOTFS_POST_BUILD_SCRIPT="board/raspberrypi3/post-build.sh"
BR2_ROOTFS_POST_IMAGE_SCRIPT="board/raspberrypi3/post-image.sh"
BR2_ROOTFS_POST_SCRIPT_ARGS="--add-pi3-miniuart-bt-overlay"
# Custom
# Pour accélerer la compilation
BR2_TOOLCHAIN_EXTERNAL=y
BR2_CCACHE=y
# Pour faire joli
BR2_TARGET_GENERIC_HOSTNAME="principal"
BR2_TARGET_GENERIC_ISSUE="Robotech - CdF 2018 - Robot principal"
# Configuration noyau supplémentaire
BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="${BR2_EXTERNAL_CDF_PATH}/board/robotech/cdfprincipal/linux-extra.conf"
# TODO Not working
# Paquets nécessaires
BR2_PACKAGE_CHEF=y
# Fichiers supplémentaires
BR2_ROOTFS_OVERLAY="${BR2_EXTERNAL_CDF_PATH}/board/robotech/cdfprincipal/rootfs_overlay/"
BR2_ROOTFS_POST_BUILD_SCRIPT="board/raspberrypi3/post-build.sh ${BR2_EXTERNAL_CDF_PATH}/board/robotech/cdfprincipal/post-build.sh"
# Ne pas activer la connexion ethernet par défaut
BR2_SYSTEM_DHCP=""
# Pour le Wi-Fi
BR2_PACKAGE_LINUX_FIRMWARE=y
BR2_PACKAGE_LINUX_FIRMWARE_RTL_81XX=y # Clef Wi-Fi Geoffrey
#BR2_PACKAGE_LINUX_FIRMWARE_BRCM_BCM43XXX=y # RPi3 Natif (cassé physiquement sur notre carte)
BR2_PACKAGE_WPA_SUPPLICANT=y
# Pour upgrader à chaud
BR2_PACKAGE_DROPBEAR=y
BR2_PACKAGE_RSYNC=y
# Pour faire plaisir à Geoffrey
BR2_PACKAGE_HTOP=y
# Pour uploader sur le Arduino
BR2_TOOLCHAIN_BUILDROOT_WCHAR=y
BR2_SHARED_LIBS=y
BR2_PACKAGE_UCLIBC=y
BR2_PACKAGE_AVRDUDE=y
# Pour uploader sur le FPGA
BR2_PACKAGE_MERCPCL=y

View file

@ -0,0 +1,2 @@
name: CDF
desc: Robotech - Coupe de France de Robotique - Robot principal

1
raspberrypi/external.mk Normal file
View file

@ -0,0 +1 @@
include $(sort $(wildcard $(BR2_EXTERNAL_CDF_PATH)/package/*/*.mk))

View file

@ -0,0 +1 @@
source "$BR2_EXTERNAL_CDF_PATH/package/cr1901/mercpcl/Config.in"

View file

@ -0,0 +1 @@
include $(sort $(wildcard $(BR2_EXTERNAL_CDF_PATH)/package/cr1901/*/*.mk))

View file

@ -0,0 +1,7 @@
config BR2_PACKAGE_MERCPCL
bool "mercpcl"
select BR2_PACKAGE_LIBUSB
select BR2_PACKAGE_LIBFTDI
help
Command-line utility that can be used to program
Mercury FPGA development boards.

View file

@ -0,0 +1,13 @@
################################################################################
#
# mercpcl
#
################################################################################
MERCPCL_VERSION = ce3d815f76f8f5d7254e5e17a90e30d9affacfea
MERCPCL_SITE = $(call github,cr1901,mercpcl,$(MERCPCL_VERSION))
MERCPCL_DEPENDENCIES = libftdi libusb
MERCPCL_LICENSE = GPLv3
MERCPCL_LICENSE_FILES = LICENSE
$(eval $(cmake-package))

View file

@ -0,0 +1 @@
source "$BR2_EXTERNAL_CDF_PATH/package/robotech/chef/Config.in"

View file

@ -0,0 +1,6 @@
config BR2_PACKAGE_CHEF
bool "chef"
select BR2_PACKAGE_WIRINGPI
help
Cerveau du robot principal pour la Coupe de France
de Robotique, équipe Robotech Lille (Polytech Lille).

View file

@ -0,0 +1,23 @@
################################################################################
#
# Programme chef - Coupe de France de Robotique
#
################################################################################
CHEF_VERSION = 1.0
CHEF_SITE = $(BR2_EXTERNAL_CDF_PATH)/package/robotech/chef/code
CHEF_SITE_METHOD = local
CHEF_DEPENDENCIES = wiringpi
define CHEF_BUILD_CMDS
$(MAKE) -C $(@D) clean
$(MAKE) $(TARGET_CONFIGURE_OPTS) -C $(@D)
endef
define CHEF_INSTALL_TARGET_CMDS
$(INSTALL) -d -m 0755 $(TARGET_DIR)/opt/chef/bin
$(INSTALL) -d -m 0755 $(TARGET_DIR)/opt/chef/com
$(INSTALL) -D -m 0755 $(@D)/bin/* $(TARGET_DIR)/opt/chef/bin
$(INSTALL) -D -m 0755 $(@D)/run.sh $(TARGET_DIR)/opt/chef
endef
$(eval $(generic-package))

View file

@ -0,0 +1 @@
../../../../chef

View file

@ -0,0 +1 @@
include $(sort $(wildcard $(BR2_EXTERNAL_CDF_PATH)/package/robotech/*/*.mk))

View file

@ -0,0 +1,11 @@
WPASSID="MySSID"
WPAKEYMGMT="WPA-PSK"
WPAPSK=mypassword
ADDRESS=192.168.1.42
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
SSHCPUB="ecdsa-sha2-nistp256 ... principal@robotech"
SSHCPRV="-----BEGIN EC PRIVATE KEY-----
...
-----END EC PRIVATE KEY-----"
SSHSPRV="..."

6
raspberrypi/sshconf.bkp Normal file
View file

@ -0,0 +1,6 @@
Host principal p
User root
Hostname 192.168.43.72
PreferredAuthentications publickey
PubkeyAuthentication yes
IdentityFile "/home/geoffrey/CdF/cdf2018-principal/root/sshkey"