From e0cb79d1ccb518d9ad30ca042503d0ea1b49fa3f Mon Sep 17 00:00:00 2001 From: Geoffrey Frogeye Date: Wed, 7 Feb 2018 17:57:01 +0100 Subject: [PATCH] Commit initial --- .gitmodules | 15 + arduino/.gitignore | 16 + arduino/FreeRTOSConfig.h | 121 +++++ arduino/Makefile | 260 ++++++++++ arduino/configure | 6 + arduino/port.c | 463 ++++++++++++++++++ arduino/principal.c | 26 + chef/Makefile | 58 +++ chef/bin/.gitignore | 2 + chef/com/.gitignore | 2 + chef/obj/.gitignore | 2 + chef/run.sh | 9 + chef/src/common.c | 1 + chef/src/common.h | 10 + chef/src/premier.c | 7 + chef/src/premier.h | 5 + chef/src/testpin.c | 32 ++ chef/src/testpin.h | 0 fpga/.gitignore | 1 + fpga/Makefile | 195 ++++++++ fpga/Principal.vhd | 29 ++ fpga/README.md | 3 + fpga/hcSr04.vhd | 89 ++++ fpga/hcSr04Fulldiv.vhd | 69 +++ fpga/hedm.vhd | 70 +++ fpga/mercury.ucf | 90 ++++ fpga/project.cfg | 14 + fpga/uart | 1 + fpga/uart.vhd | 1 + raspberrypi/.gitignore | 5 + raspberrypi/Config.in | 2 + raspberrypi/Makefile | 102 ++++ .../robotech/cdfprincipal/linux-extra.conf | 2 + .../board/robotech/cdfprincipal/post-build.sh | 42 ++ .../rootfs_overlay/etc/extra.d/S40wifi | 41 ++ .../rootfs_overlay/etc/extra.d/rcK | 27 + .../rootfs_overlay/etc/extra.d/rcS | 27 + .../rootfs_overlay/etc/init.d/S40keyboard | 33 ++ .../rootfs_overlay/etc/init.d/S50chef | 38 ++ .../rootfs_overlay/etc/init.d/S90extra | 37 ++ .../cdfprincipal/rootfs_overlay/root/.profile | 13 + .../usr/share/keyboard/fr-latin9.bmap | Bin 0 -> 2623 bytes raspberrypi/buildroot | 1 + raspberrypi/configs/cdfprincipal_defconfig | 87 ++++ raspberrypi/external.desc | 2 + raspberrypi/external.mk | 1 + raspberrypi/package/cr1901/Config.in | 1 + raspberrypi/package/cr1901/cr1901.mk | 1 + raspberrypi/package/cr1901/mercpcl/Config.in | 7 + raspberrypi/package/cr1901/mercpcl/mercpcl.mk | 13 + raspberrypi/package/robotech/Config.in | 1 + raspberrypi/package/robotech/chef/Config.in | 6 + raspberrypi/package/robotech/chef/chef.mk | 23 + raspberrypi/package/robotech/chef/code | 1 + raspberrypi/package/robotech/robotech.mk | 1 + raspberrypi/principalconf.sh.demo | 11 + raspberrypi/sshconf.bkp | 6 + 57 files changed, 2128 insertions(+) create mode 100644 .gitmodules create mode 100644 arduino/.gitignore create mode 100644 arduino/FreeRTOSConfig.h create mode 100644 arduino/Makefile create mode 100755 arduino/configure create mode 100644 arduino/port.c create mode 100644 arduino/principal.c create mode 100644 chef/Makefile create mode 100644 chef/bin/.gitignore create mode 100644 chef/com/.gitignore create mode 100644 chef/obj/.gitignore create mode 100644 chef/run.sh create mode 100644 chef/src/common.c create mode 100644 chef/src/common.h create mode 100644 chef/src/premier.c create mode 100644 chef/src/premier.h create mode 100644 chef/src/testpin.c create mode 100644 chef/src/testpin.h create mode 100644 fpga/.gitignore create mode 100644 fpga/Makefile create mode 100644 fpga/Principal.vhd create mode 100644 fpga/README.md create mode 100644 fpga/hcSr04.vhd create mode 100644 fpga/hcSr04Fulldiv.vhd create mode 100644 fpga/hedm.vhd create mode 100644 fpga/mercury.ucf create mode 100644 fpga/project.cfg create mode 160000 fpga/uart create mode 120000 fpga/uart.vhd create mode 100644 raspberrypi/.gitignore create mode 100644 raspberrypi/Config.in create mode 100644 raspberrypi/Makefile create mode 100644 raspberrypi/board/robotech/cdfprincipal/linux-extra.conf create mode 100755 raspberrypi/board/robotech/cdfprincipal/post-build.sh create mode 100755 raspberrypi/board/robotech/cdfprincipal/rootfs_overlay/etc/extra.d/S40wifi create mode 100755 raspberrypi/board/robotech/cdfprincipal/rootfs_overlay/etc/extra.d/rcK create mode 100755 raspberrypi/board/robotech/cdfprincipal/rootfs_overlay/etc/extra.d/rcS create mode 100755 raspberrypi/board/robotech/cdfprincipal/rootfs_overlay/etc/init.d/S40keyboard create mode 100755 raspberrypi/board/robotech/cdfprincipal/rootfs_overlay/etc/init.d/S50chef create mode 100755 raspberrypi/board/robotech/cdfprincipal/rootfs_overlay/etc/init.d/S90extra create mode 100644 raspberrypi/board/robotech/cdfprincipal/rootfs_overlay/root/.profile create mode 100644 raspberrypi/board/robotech/cdfprincipal/rootfs_overlay/usr/share/keyboard/fr-latin9.bmap create mode 160000 raspberrypi/buildroot create mode 100644 raspberrypi/configs/cdfprincipal_defconfig create mode 100644 raspberrypi/external.desc create mode 100644 raspberrypi/external.mk create mode 100644 raspberrypi/package/cr1901/Config.in create mode 100644 raspberrypi/package/cr1901/cr1901.mk create mode 100644 raspberrypi/package/cr1901/mercpcl/Config.in create mode 100644 raspberrypi/package/cr1901/mercpcl/mercpcl.mk create mode 100644 raspberrypi/package/robotech/Config.in create mode 100644 raspberrypi/package/robotech/chef/Config.in create mode 100644 raspberrypi/package/robotech/chef/chef.mk create mode 120000 raspberrypi/package/robotech/chef/code create mode 100644 raspberrypi/package/robotech/robotech.mk create mode 100644 raspberrypi/principalconf.sh.demo create mode 100644 raspberrypi/sshconf.bkp diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..44d5887 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,15 @@ +[submodule "root/buildroot"] + path = root/buildroot + url = git://git.buildroot.net/buildroot +[submodule "ardPince/Arduino-Makefile"] + path = ardPince/Arduino-Makefile + url = https://github.com/sudar/Arduino-Makefile +[submodule "ardMoteur/Arduino-Makefile"] + path = ardMoteur/Arduino-Makefile + url = https://github.com/sudar/Arduino-Makefile +[submodule "fpga/uart"] + path = fpga/uart + url = https://github.com/pabennett/uart.git +[submodule "raspberrypi/buildroot"] + path = raspberrypi/buildroot + url = /home/geoffrey/buildroot diff --git a/arduino/.gitignore b/arduino/.gitignore new file mode 100644 index 0000000..27ba833 --- /dev/null +++ b/arduino/.gitignore @@ -0,0 +1,16 @@ +FreeRTOSv9.0.0/* +*.zip + +*.o +*.lst +*.d +*.hex +*.eep +*.obj +*.elf +*.map +*.obj +*.a90 +*.sym +*.lnk +*.lss diff --git a/arduino/FreeRTOSConfig.h b/arduino/FreeRTOSConfig.h new file mode 100644 index 0000000..37757be --- /dev/null +++ b/arduino/FreeRTOSConfig.h @@ -0,0 +1,121 @@ +/* + FreeRTOS V8.1.2 - Copyright (C) 2014 Real Time Engineers Ltd. + All rights reserved + + VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. + + *************************************************************************** + * * + * FreeRTOS provides completely free yet professionally developed, * + * robust, strictly quality controlled, supported, and cross * + * platform software that has become a de facto standard. * + * * + * Help yourself get started quickly and support the FreeRTOS * + * project by purchasing a FreeRTOS tutorial book, reference * + * manual, or both from: http://www.FreeRTOS.org/Documentation * + * * + * Thank you! * + * * + *************************************************************************** + + This file is part of the FreeRTOS distribution. + + FreeRTOS is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License (version 2) as published by the + Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. + + >>! NOTE: The modification to the GPL is included to allow you to !<< + >>! distribute a combined work that includes FreeRTOS without being !<< + >>! obliged to provide the source code for proprietary components !<< + >>! outside of the FreeRTOS kernel. !<< + + FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. Full license text is available from the following + link: http://www.freertos.org/a00114.html + + 1 tab == 4 spaces! + + *************************************************************************** + * * + * Having a problem? Start by reading the FAQ "My application does * + * not run, what could be wrong?" * + * * + * http://www.FreeRTOS.org/FAQHelp.html * + * * + *************************************************************************** + + http://www.FreeRTOS.org - Documentation, books, training, latest versions, + license and Real Time Engineers Ltd. contact details. + + http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, + including FreeRTOS+Trace - an indispensable productivity tool, a DOS + compatible FAT file system, and our tiny thread aware UDP/IP stack. + + http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High + Integrity Systems to sell under the OpenRTOS brand. Low cost OpenRTOS + licenses offer ticketed support, indemnification and middleware. + + http://www.SafeRTOS.com - High Integrity Systems also provide a safety + engineered and independently SIL3 certified version for use in safety and + mission critical applications that require provable dependability. + + 1 tab == 4 spaces! +*/ + +#ifndef FREERTOS_CONFIG_H +#define FREERTOS_CONFIG_H + +#include + +/*----------------------------------------------------------- + * Application specific definitions. + * + * These definitions should be adjusted for your particular hardware and + * application requirements. + * + * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE + * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. + * + * See http://www.freertos.org/a00110.html. + *----------------------------------------------------------*/ + +// JF: added +#define configUSE_TIMERS 1 +#define configTIMER_TASK_PRIORITY 3 +#define configTIMER_QUEUE_LENGTH 10 +#define configTIMER_TASK_STACK_DEPTH configMINIMAL_STACK_SIZE +// -- done + +#define configUSE_PREEMPTION 1 +#define configUSE_IDLE_HOOK 0 +#define configUSE_TICK_HOOK 0 +#define configCPU_CLOCK_HZ ( ( unsigned long ) 16000000 ) +#define configTICK_RATE_HZ ( ( TickType_t ) 1000 ) +#define configMAX_PRIORITIES ( 4 ) +#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 85 ) +#define configTOTAL_HEAP_SIZE ( (size_t ) ( 4096 ) ) +#define configMAX_TASK_NAME_LEN ( 16 ) +#define configUSE_TRACE_FACILITY 0 +#define configUSE_16_BIT_TICKS 1 +#define configIDLE_SHOULD_YIELD 1 +#define configQUEUE_REGISTRY_SIZE 0 + +/* Co-routine definitions. */ +#define configUSE_CO_ROUTINES 1 +#define configMAX_CO_ROUTINE_PRIORITIES ( 2 ) + +/* Set the following definitions to 1 to include the API function, or zero +to exclude the API function. */ + +#define INCLUDE_vTaskPrioritySet 1 +#define INCLUDE_uxTaskPriorityGet 1 +//##If the following value is set to 1, change the memory managment scheme to heap_2.c: +#define INCLUDE_vTaskDelete 0 +#define INCLUDE_vTaskCleanUpResources 0 +#define INCLUDE_vTaskSuspend 1 +#define INCLUDE_vTaskDelayUntil 1 +#define INCLUDE_vTaskDelay 1 + + +#endif /* FREERTOS_CONFIG_H */ diff --git a/arduino/Makefile b/arduino/Makefile new file mode 100644 index 0000000..73097b9 --- /dev/null +++ b/arduino/Makefile @@ -0,0 +1,260 @@ +# WinAVR Sample makefile written by Eric B. Weddington, Jörg Wunsch, et al. +# Edited by J. Forget +# Released to the Public Domain +# Please read the make user manual! +# +# Additional material for this makefile was submitted by: +# Tim Henigan +# Peter Fleury +# Reiner Patommel +# Sander Pool +# Frederik Rouleau +# Markus Pfaff +# +# On command line: +# +# make NAME=bla.c : compile program bla.c +# +# make clean : Clean out built project files. +# +# make upload : Load the hex file to the device, using avrdude. Please +# customize the avrdude settings below first! +# + +# MCU name +MCU = atmega2560 + +# Output format. (can be srec, ihex, binary) +FORMAT = ihex + +# Target file name (without extension). +TARGET = principal + +# Custom +NAME = $(TARGET).c + +# List C source files here. (C dependencies are automatically generated.) +INSTALL_DIR=./FreeRTOSv9.0.0/FreeRTOS +#DEMO_DIR = $(INSTALL_DIR)/Demo/ +SOURCE_DIR = $(INSTALL_DIR)/Source +PORT_DIR = . + +SRC = \ +$(NAME) \ +$(SOURCE_DIR)/tasks.c \ +$(SOURCE_DIR)/queue.c \ +$(SOURCE_DIR)/list.c \ +$(SOURCE_DIR)/timers.c \ +$(SOURCE_DIR)/croutine.c \ +$(SOURCE_DIR)/portable/MemMang/heap_1.c \ +$(PORT_DIR)/port.c + + +DEBUG_LEVEL=-g +WARNINGS=-Wall + +CFLAGS = -D GCC_MEGA_AVR -I. -I$(SOURCE_DIR)/include -I$(DEMO_DIR)/Common/include \ +$(DEBUG_LEVEL) \ +-fsigned-char -funsigned-bitfields -fpack-struct -fshort-enums \ +$(WARNINGS) \ +-Wa,-adhlns=$(<:.c=.lst) \ +$(patsubst %,-I%,$(EXTRAINCDIRS)) + +# Optional linker flags. +# -Wl,...: tell GCC to pass this to linker. +# -Map: create map file +# --cref: add cross reference to map file +LDFLAGS = -Wl,-Map=$(TARGET).map,--cref + + +# Programming support using avrdude. Settings and variables. + +# Programming hardware: alf avr910 avrisp bascom bsd +# dt006 pavr picoweb pony-stk200 sp12 stk200 stk500 +# +# Type: avrdude -c ? +# to get a full listing. +# +AVRDUDE_PROGRAMMER = stk500 + +AVRDUDE_PORT = /dev/ttyACM0 # programmer connected to serial device + +AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex + +AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) -D + +# --------------------------------------------------------------------------- + +# Define programs and commands. +SHELL = sh + +CC = avr-gcc + +OBJCOPY = avr-objcopy +OBJDUMP = avr-objdump +SIZE = avr-size + +# Programming support using avrdude. +AVRDUDE = avrdude + +REMOVE = rm -f +COPY = cp + +HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex +ELFSIZE = $(SIZE) -A $(TARGET).elf + +# Define Messages +# English +MSG_ERRORS_NONE = Errors: none +MSG_BEGIN = -------- begin -------- +MSG_END = -------- end -------- +MSG_SIZE_BEFORE = Size before: +MSG_SIZE_AFTER = Size after: +MSG_FLASH = Creating load file for Flash: +MSG_EEPROM = Creating load file for EEPROM: +MSG_EXTENDED_LISTING = Creating Extended Listing: +MSG_SYMBOL_TABLE = Creating Symbol Table: +MSG_LINKING = Linking: +MSG_COMPILING = Compiling: +MSG_ASSEMBLING = Assembling: +MSG_CLEANING = Cleaning project: + +# Define all object files. +OBJ = $(SRC:.c=.o) + +# Define all listing files. +LST = $(SRC:.c=.lst) + +# Combine all necessary flags and optional flags. +# Add target processor to flags. +ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) +ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp + +# Default target. +all: begin gccversion sizebefore $(TARGET).elf $(TARGET).hex $(TARGET).eep \ + $(TARGET).lss $(TARGET).sym sizeafter finished end + + +# Eye candy. +# AVR Studio 3.x does not check make's exit code but relies on +# the following magic strings to be generated by the compile job. +begin: + @echo + @echo $(MSG_BEGIN) + +finished: + @echo $(MSG_ERRORS_NONE) + +end: + @echo $(MSG_END) + @echo + + +# Program the device. +upload: $(TARGET).hex $(TARGET).eep + $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) + + +# Create final output files (.hex, .eep) from ELF output file. +%.hex: %.elf + @echo + @echo $(MSG_FLASH) $@ + $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@ + +%.eep: %.elf + @echo + @echo $(MSG_EEPROM) $@ + -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ + --change-section-lma .eeprom=0 -O $(FORMAT) $< $@ + +# Create extended listing file from ELF output file. +%.lss: %.elf + @echo + @echo $(MSG_EXTENDED_LISTING) $@ + $(OBJDUMP) -h -S $< > $@ + +# Create a symbol table from ELF output file. +%.sym: %.elf + @echo + @echo $(MSG_SYMBOL_TABLE) $@ + avr-nm -n $< > $@ + + + +# Link: create ELF output file from object files. +.SECONDARY : $(TARGET).elf +.PRECIOUS : $(OBJ) +%.elf: $(OBJ) + @echo + @echo $(MSG_LINKING) $@ + $(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS) + + +# Compile: create object files from C source files. +%.o : %.c + @echo + @echo $(MSG_COMPILING) $< + $(CC) -c $(ALL_CFLAGS) $< -o $@ + + +# Compile: create assembler files from C source files. +%.s : %.c + $(CC) -S $(ALL_CFLAGS) $< -o $@ + + +# Assemble: create object files from assembler source files. +%.o : %.S + @echo + @echo $(MSG_ASSEMBLING) $< + $(CC) -c $(ALL_ASFLAGS) $< -o $@ + + + + + + +# Target: clean project. +clean: begin clean_list finished end + +clean_list : + @echo + @echo $(MSG_CLEANING) + $(REMOVE) $(TARGET).hex + $(REMOVE) $(TARGET).eep + $(REMOVE) $(TARGET).obj + $(REMOVE) $(TARGET).elf + $(REMOVE) $(TARGET).map + $(REMOVE) $(TARGET).obj + $(REMOVE) $(TARGET).a90 + $(REMOVE) $(TARGET).sym + $(REMOVE) $(TARGET).lnk + $(REMOVE) $(TARGET).lss + $(REMOVE) $(OBJ) + $(REMOVE) $(LST) + $(REMOVE) $(SRC:.c=.s) + $(REMOVE) $(SRC:.c=.d) + + +# Automatically generate C source code dependencies. +# (Code originally taken from the GNU make user manual and modified +# (See README.txt Credits).) +# +# Note that this will work with sh (bash) and sed that is shipped with WinAVR +# (see the SHELL variable defined above). +# This may not work with other shells or other seds. +# +%.d: %.c + set -e; $(CC) -MM $(ALL_CFLAGS) $< \ + | sed 's,\(.*\)\.o[ :]*,\1.o \1.d : ,g' > $@; \ + [ -s $@ ] || rm -f $@ + + +# Remove the '-' if you want to see the dependency files generated. +-include $(SRC:.c=.d) + + + +# Listing of phony targets. +.PHONY : all begin finish end sizebefore sizeafter gccversion \ + clean clean_list program + diff --git a/arduino/configure b/arduino/configure new file mode 100755 index 0000000..77af5cb --- /dev/null +++ b/arduino/configure @@ -0,0 +1,6 @@ +#!/usr/bin/env sh + +wget "https://sourceforge.net/projects/freertos/files/FreeRTOS/V9.0.0/FreeRTOSv9.0.0.zip/download" -O FreeRTOSv9.0.0.zip -c +unzip "FreeRTOSv9.0.0.zip" +rm "FreeRTOSv9.0.0.zip" + diff --git a/arduino/port.c b/arduino/port.c new file mode 100644 index 0000000..cb47fc5 --- /dev/null +++ b/arduino/port.c @@ -0,0 +1,463 @@ +/* + FreeRTOS V8.1.2 - Copyright (C) 2014 Real Time Engineers Ltd. + All rights reserved + + VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. + + *************************************************************************** + * * + * FreeRTOS provides completely free yet professionally developed, * + * robust, strictly quality controlled, supported, and cross * + * platform software that has become a de facto standard. * + * * + * Help yourself get started quickly and support the FreeRTOS * + * project by purchasing a FreeRTOS tutorial book, reference * + * manual, or both from: http://www.FreeRTOS.org/Documentation * + * * + * Thank you! * + * * + *************************************************************************** + + This file is part of the FreeRTOS distribution. + + FreeRTOS is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License (version 2) as published by the + Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. + + >>! NOTE: The modification to the GPL is included to allow you to !<< + >>! distribute a combined work that includes FreeRTOS without being !<< + >>! obliged to provide the source code for proprietary components !<< + >>! outside of the FreeRTOS kernel. !<< + + FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. Full license text is available from the following + link: http://www.freertos.org/a00114.html + + 1 tab == 4 spaces! + + *************************************************************************** + * * + * Having a problem? Start by reading the FAQ "My application does * + * not run, what could be wrong?" * + * * + * http://www.FreeRTOS.org/FAQHelp.html * + * * + *************************************************************************** + + http://www.FreeRTOS.org - Documentation, books, training, latest versions, + license and Real Time Engineers Ltd. contact details. + + http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, + including FreeRTOS+Trace - an indispensable productivity tool, a DOS + compatible FAT file system, and our tiny thread aware UDP/IP stack. + + http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High + Integrity Systems to sell under the OpenRTOS brand. Low cost OpenRTOS + licenses offer ticketed support, indemnification and middleware. + + http://www.SafeRTOS.com - High Integrity Systems also provide a safety + engineered and independently SIL3 certified version for use in safety and + mission critical applications that require provable dependability. + + 1 tab == 4 spaces! +*/ + +/* + +Changes from V2.6.0 + + + AVR port - Replaced the inb() and outb() functions with direct memory + access. This allows the port to be built with the 20050414 build of + WinAVR. +*/ + +#include +#include + +#include "FreeRTOS.h" +#include "task.h" + +/*----------------------------------------------------------- + * Implementation of functions defined in portable.h for the AVR port. + *----------------------------------------------------------*/ + +/* Start tasks with interrupts enables. */ +#define portFLAGS_INT_ENABLED ( ( StackType_t ) 0x80 ) + +/* Hardware constants for timer 1. */ +#define portCLEAR_COUNTER_ON_MATCH ( ( uint8_t ) 0x08 ) +#define portPRESCALE_64 ( ( uint8_t ) 0x03 ) +#define portCLOCK_PRESCALER ( ( uint32_t ) 64 ) +#define portCOMPARE_MATCH_A_INTERRUPT_ENABLE ( ( uint8_t ) 0x02 ) + +/*-----------------------------------------------------------*/ + +/* We require the address of the pxCurrentTCB variable, but don't want to know +any details of its type. */ +typedef void TCB_t; +extern volatile TCB_t * volatile pxCurrentTCB; + +/*-----------------------------------------------------------*/ + +/* + * Macro to save all the general purpose registers, the save the stack pointer + * into the TCB. + * + * The first thing we do is save the flags then disable interrupts. This is to + * guard our stack against having a context switch interrupt after we have already + * pushed the registers onto the stack - causing the 32 registers to be on the + * stack twice. + * + * r1 is set to zero as the compiler expects it to be thus, however some + * of the math routines make use of R1. + * + * The interrupts will have been disabled during the call to portSAVE_CONTEXT() + * so we need not worry about reading/writing to the stack pointer. + */ + +#define portSAVE_CONTEXT() \ + asm volatile ( "push r0 \n\t" \ + "in r0, __SREG__ \n\t" \ + "cli \n\t" \ + "push r0 \n\t" \ + "push r1 \n\t" \ + "clr r1 \n\t" \ + "push r2 \n\t" \ + "push r3 \n\t" \ + "push r4 \n\t" \ + "push r5 \n\t" \ + "push r6 \n\t" \ + "push r7 \n\t" \ + "push r8 \n\t" \ + "push r9 \n\t" \ + "push r10 \n\t" \ + "push r11 \n\t" \ + "push r12 \n\t" \ + "push r13 \n\t" \ + "push r14 \n\t" \ + "push r15 \n\t" \ + "push r16 \n\t" \ + "push r17 \n\t" \ + "push r18 \n\t" \ + "push r19 \n\t" \ + "push r20 \n\t" \ + "push r21 \n\t" \ + "push r22 \n\t" \ + "push r23 \n\t" \ + "push r24 \n\t" \ + "push r25 \n\t" \ + "push r26 \n\t" \ + "push r27 \n\t" \ + "push r28 \n\t" \ + "push r29 \n\t" \ + "push r30 \n\t" \ + "push r31 \n\t" \ + "lds r26, pxCurrentTCB \n\t" \ + "lds r27, pxCurrentTCB + 1 \n\t" \ + "in r0, 0x3d \n\t" \ + "st x+, r0 \n\t" \ + "in r0, 0x3e \n\t" \ + "st x+, r0 \n\t" \ + ); + +/* + * Opposite to portSAVE_CONTEXT(). Interrupts will have been disabled during + * the context save so we can write to the stack pointer. + */ + +#define portRESTORE_CONTEXT() \ + asm volatile ( "lds r26, pxCurrentTCB \n\t" \ + "lds r27, pxCurrentTCB + 1 \n\t" \ + "ld r28, x+ \n\t" \ + "out __SP_L__, r28 \n\t" \ + "ld r29, x+ \n\t" \ + "out __SP_H__, r29 \n\t" \ + "pop r31 \n\t" \ + "pop r30 \n\t" \ + "pop r29 \n\t" \ + "pop r28 \n\t" \ + "pop r27 \n\t" \ + "pop r26 \n\t" \ + "pop r25 \n\t" \ + "pop r24 \n\t" \ + "pop r23 \n\t" \ + "pop r22 \n\t" \ + "pop r21 \n\t" \ + "pop r20 \n\t" \ + "pop r19 \n\t" \ + "pop r18 \n\t" \ + "pop r17 \n\t" \ + "pop r16 \n\t" \ + "pop r15 \n\t" \ + "pop r14 \n\t" \ + "pop r13 \n\t" \ + "pop r12 \n\t" \ + "pop r11 \n\t" \ + "pop r10 \n\t" \ + "pop r9 \n\t" \ + "pop r8 \n\t" \ + "pop r7 \n\t" \ + "pop r6 \n\t" \ + "pop r5 \n\t" \ + "pop r4 \n\t" \ + "pop r3 \n\t" \ + "pop r2 \n\t" \ + "pop r1 \n\t" \ + "pop r0 \n\t" \ + "out __SREG__, r0 \n\t" \ + "pop r0 \n\t" \ + ); + +/*-----------------------------------------------------------*/ + +/* + * Perform hardware setup to enable ticks from timer 1, compare match A. + */ +static void prvSetupTimerInterrupt( void ); +/*-----------------------------------------------------------*/ + +/* + * See header file for description. + */ +StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters ) +{ +uint16_t usAddress; + + /* Place a few bytes of known values on the bottom of the stack. + This is just useful for debugging. */ + + *pxTopOfStack = 0x11; + pxTopOfStack--; + *pxTopOfStack = 0x22; + pxTopOfStack--; + *pxTopOfStack = 0x33; + pxTopOfStack--; + + /* Simulate how the stack would look after a call to vPortYield() generated by + the compiler. */ + + /*lint -e950 -e611 -e923 Lint doesn't like this much - but nothing I can do about it. */ + + /* The start of the task code will be popped off the stack last, so place + it on first. */ + usAddress = ( uint16_t ) pxCode; + *pxTopOfStack = ( StackType_t ) ( usAddress & ( uint16_t ) 0x00ff ); + pxTopOfStack--; + + usAddress >>= 8; + *pxTopOfStack = ( StackType_t ) ( usAddress & ( uint16_t ) 0x00ff ); + pxTopOfStack--; + + usAddress >>= 8; + *pxTopOfStack = ( StackType_t ) ( usAddress & ( uint16_t ) 0x00ff ); + pxTopOfStack--; + + /* Next simulate the stack as if after a call to portSAVE_CONTEXT(). + portSAVE_CONTEXT places the flags on the stack immediately after r0 + to ensure the interrupts get disabled as soon as possible, and so ensuring + the stack use is minimal should a context switch interrupt occur. */ + *pxTopOfStack = ( StackType_t ) 0x00; /* R0 */ + pxTopOfStack--; + *pxTopOfStack = portFLAGS_INT_ENABLED; + pxTopOfStack--; + + + /* Now the remaining registers. The compiler expects R1 to be 0. */ + *pxTopOfStack = ( StackType_t ) 0x00; /* R1 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x02; /* R2 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x03; /* R3 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x04; /* R4 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x05; /* R5 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x06; /* R6 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x07; /* R7 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x08; /* R8 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x09; /* R9 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x10; /* R10 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x11; /* R11 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x12; /* R12 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x13; /* R13 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x14; /* R14 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x15; /* R15 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x16; /* R16 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x17; /* R17 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x18; /* R18 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x19; /* R19 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x20; /* R20 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x21; /* R21 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x22; /* R22 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x23; /* R23 */ + pxTopOfStack--; + + /* Place the parameter on the stack in the expected location. */ + usAddress = ( uint16_t ) pvParameters; + *pxTopOfStack = ( StackType_t ) ( usAddress & ( uint16_t ) 0x00ff ); + pxTopOfStack--; + + usAddress >>= 8; + *pxTopOfStack = ( StackType_t ) ( usAddress & ( uint16_t ) 0x00ff ); + pxTopOfStack--; + + *pxTopOfStack = ( StackType_t ) 0x26; /* R26 X */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x27; /* R27 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x28; /* R28 Y */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x29; /* R29 */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x30; /* R30 Z */ + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x031; /* R31 */ + pxTopOfStack--; + + /*lint +e950 +e611 +e923 */ + + return pxTopOfStack; +} +/*-----------------------------------------------------------*/ + +BaseType_t xPortStartScheduler( void ) +{ + /* Setup the hardware to generate the tick. */ + prvSetupTimerInterrupt(); + + /* Restore the context of the first task that is going to run. */ + portRESTORE_CONTEXT(); + + /* Simulate a function call end as generated by the compiler. We will now + jump to the start of the task the context of which we have just restored. */ + asm volatile ( "ret" ); + + /* Should not get here. */ + return pdTRUE; +} +/*-----------------------------------------------------------*/ + +void vPortEndScheduler( void ) +{ + /* It is unlikely that the AVR port will get stopped. If required simply + disable the tick interrupt here. */ +} +/*-----------------------------------------------------------*/ + +/* + * Manual context switch. The first thing we do is save the registers so we + * can use a naked attribute. + */ +void vPortYield( void ) __attribute__ ( ( naked ) ); +void vPortYield( void ) +{ + portSAVE_CONTEXT(); + vTaskSwitchContext(); + portRESTORE_CONTEXT(); + + asm volatile ( "ret" ); +} +/*-----------------------------------------------------------*/ + +/* + * Context switch function used by the tick. This must be identical to + * vPortYield() from the call to vTaskSwitchContext() onwards. The only + * difference from vPortYield() is the tick count is incremented as the + * call comes from the tick ISR. + */ +void vPortYieldFromTick( void ) __attribute__ ( ( naked ) ); +void vPortYieldFromTick( void ) +{ + portSAVE_CONTEXT(); + if( xTaskIncrementTick() != pdFALSE ) + { + vTaskSwitchContext(); + } + portRESTORE_CONTEXT(); + + asm volatile ( "ret" ); +} +/*-----------------------------------------------------------*/ + +/* + * Setup timer 1 compare match A to generate a tick interrupt. + */ +static void prvSetupTimerInterrupt( void ) +{ +uint32_t ulCompareMatch; +uint8_t ucHighByte, ucLowByte; + + /* Using 16bit timer 1 to generate the tick. Correct fuses must be + selected for the configCPU_CLOCK_HZ clock. */ + + ulCompareMatch = configCPU_CLOCK_HZ / configTICK_RATE_HZ; + + /* We only have 16 bits so have to scale to get our required tick rate. */ + ulCompareMatch /= portCLOCK_PRESCALER; + + /* Adjust for correct value. */ + ulCompareMatch -= ( uint32_t ) 1; + + /* Setup compare match value for compare match A. Interrupts are disabled + before this is called so we need not worry here. */ + ucLowByte = ( uint8_t ) ( ulCompareMatch & ( uint32_t ) 0xff ); + ulCompareMatch >>= 8; + ucHighByte = ( uint8_t ) ( ulCompareMatch & ( uint32_t ) 0xff ); + OCR1AH = ucHighByte; + OCR1AL = ucLowByte; + + /* Setup clock source and compare match behaviour. */ + ucLowByte = portCLEAR_COUNTER_ON_MATCH | portPRESCALE_64; + TCCR1B = ucLowByte; + + /* Enable the interrupt - this is okay as interrupt are currently globally + disabled. */ + ucLowByte = TIMSK1; + ucLowByte |= portCOMPARE_MATCH_A_INTERRUPT_ENABLE; + TIMSK1 = ucLowByte; +} +/*-----------------------------------------------------------*/ + +#if configUSE_PREEMPTION == 1 + + /* + * Tick ISR for preemptive scheduler. We can use a naked attribute as + * the context is saved at the start of vPortYieldFromTick(). The tick + * count is incremented after the context is saved. + */ +ISR ( TIMER1_COMPA_vect , ISR_NAKED ) + { + vPortYieldFromTick(); + asm volatile ( "reti" ); + } +#else + + /* + * Tick ISR for the cooperative scheduler. All this does is increment the + * tick count. We don't need to switch context, this can only be done by + * manual calls to taskYIELD(); + */ +ISR ( TIMER1_COMPA_vect , ISR_NAKED ) + { + xTaskIncrementTick(); + } +#endif diff --git a/arduino/principal.c b/arduino/principal.c new file mode 100644 index 0000000..cab6aed --- /dev/null +++ b/arduino/principal.c @@ -0,0 +1,26 @@ +#include +#include +#include + +void TaskBlink(void *pvParameters) +{ + (void) pvParameters; + TickType_t xLastWakeTime; + const TickType_t xFrequency = 200 / portTICK_PERIOD_MS; + + DDRB = 0xFF; + + xLastWakeTime = xTaskGetTickCount(); + for (;;) + { + PORTB = PINB ^ 0xFF; + vTaskDelayUntil(&xLastWakeTime, xFrequency); + } +} + +int main(void) +{ + xTaskCreate(TaskBlink, "Blink", 128, NULL, 2, NULL); + vTaskStartScheduler(); + return 0; +} diff --git a/chef/Makefile b/chef/Makefile new file mode 100644 index 0000000..bc71177 --- /dev/null +++ b/chef/Makefile @@ -0,0 +1,58 @@ +# VARIABLES + +## Compilateur +CC=gcc +# BibliothĂšques +LIBS= +## Drapeaux pour le linker +LDFLAGS= +## Drapeaux pour le compilateur +CFLAGS= +## GĂ©nĂ©rateurs de drapeaux pour les bibliothĂšques +PKG_CONFIG=pkg-config + +# VARIABLES AUTOMATIQUES +ifdef LIBS + LDFLAGS += $(shell $(PKG_CONFIG) --libs $(LIBS)) + CFLAGS += $(shell $(PKG_CONFIG) --cflags $(LIBS)) +endif + +# Par dĂ©faut on affiche les warnings et on ajoute les symboles de debug pour utiliser GDB +CFLAGS += -Wall -Wextra -pedantic -g -DDEBUG +# buildroot se charge de remplacer ces flags avec des optimisations + +# RÈGLES AUTOMATIQUES DE COMPILATION + +# GĂ©nĂ©ration des fichiers Ă©xecutables +bin/%: obj/%.o + $(CC) $(LDFLAGS) $^ -o $@ +# On enlĂšve les symboles inutiles pour gagner en temps de chargement de l'Ă©xecutable +ifeq ($(DEBUG),no) + strip $@ +endif + +# RÈGLES DE COMPILATION + +# RĂšgle Ă©xecutĂ©e par dĂ©faut (quand on fait juste `make`) +default: bin/testpin bin/premier + +# Binaires (dont il faut spĂ©cifier les objets explicitement) +bin/premier: obj/common.o +bin/testPin: obj/testPin.o + $(CC) $(LDFLAGS) $^ -lwiringPi -o $@ + +# GĂ©nĂ©ration des fichiers objets +obj/%.o: src/%.c src/%.h + $(CC) $(CFLAGS) -c $< -o $@ +obj/%.o: src/%.c + $(CC) $(CFLAGS) -c $< -o $@ + +# OUTILS DE DÉVELOPPEMENT + +# Supprime les fichiers automatiquement gĂ©nĂ©rĂ©s +clean: + rm -f obj/* + rm -f bin/* + +# Au cas oĂč des fichiers avec certains noms existent, les rĂšgles suivantes seront executĂ©es quand mĂȘme +.PHONY: default clean diff --git a/chef/bin/.gitignore b/chef/bin/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/chef/bin/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/chef/com/.gitignore b/chef/com/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/chef/com/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/chef/obj/.gitignore b/chef/obj/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/chef/obj/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/chef/run.sh b/chef/run.sh new file mode 100644 index 0000000..ea9dcbd --- /dev/null +++ b/chef/run.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +EXEC=bin/premier +LOGFILE="${2:=run.log}" + +# Logging +"$EXEC" 2>&1 | while read line; do + echo "$(cat /proc/uptime | cut -d ' ' -f 1) $line" >> "$LOGFILE" +done diff --git a/chef/src/common.c b/chef/src/common.c new file mode 100644 index 0000000..67c02a2 --- /dev/null +++ b/chef/src/common.c @@ -0,0 +1 @@ +#include "common.h" diff --git a/chef/src/common.h b/chef/src/common.h new file mode 100644 index 0000000..72bccea --- /dev/null +++ b/chef/src/common.h @@ -0,0 +1,10 @@ +#ifndef __COMMON_H_ +#define __COMMON_H_ + +#include +#include + +#define SIGNAL_AVANCER 42 + +#endif + diff --git a/chef/src/premier.c b/chef/src/premier.c new file mode 100644 index 0000000..785155c --- /dev/null +++ b/chef/src/premier.c @@ -0,0 +1,7 @@ +#include "premier.h" + +int main() { + printf("Hello world!\n"); + // avancer(10); + return 0; +} diff --git a/chef/src/premier.h b/chef/src/premier.h new file mode 100644 index 0000000..01ffa10 --- /dev/null +++ b/chef/src/premier.h @@ -0,0 +1,5 @@ +#ifndef __PREMIER_H_ + +#include "common.h" + +#endif diff --git a/chef/src/testpin.c b/chef/src/testpin.c new file mode 100644 index 0000000..1bc3fd2 --- /dev/null +++ b/chef/src/testpin.c @@ -0,0 +1,32 @@ +/* Teste si une broche est connectĂ© Ă  une autre */ + +#include +#include +#include + +char testPin(char input, char output) { + pinMode(output, OUTPUT); + pinMode(input, INPUT); + digitalWrite(output, 1); + delay(0); + return digitalRead(input); +} + +int main(int argc, char *argv[]) { + + if (argc != 3) { + printf("Usage: %s INPUT_PIN OUTPUT_PIN\n", argv[0]); + return 2; + } + + if (wiringPiSetup() == -1) { + return 3; + } + + char input = atoi(argv[1]); + char output = atoi(argv[2]); + + char rep = testPin(input, output); + + return rep; +} diff --git a/chef/src/testpin.h b/chef/src/testpin.h new file mode 100644 index 0000000..e69de29 diff --git a/fpga/.gitignore b/fpga/.gitignore new file mode 100644 index 0000000..a007fea --- /dev/null +++ b/fpga/.gitignore @@ -0,0 +1 @@ +build/* diff --git a/fpga/Makefile b/fpga/Makefile new file mode 100644 index 0000000..2df7466 --- /dev/null +++ b/fpga/Makefile @@ -0,0 +1,195 @@ +# From https://github.com/duskwuff/Xilinx-ISE-Makefile +########################################################################### +## Xilinx ISE Makefile +## +## To the extent possible under law, the author(s) have dedicated all copyright +## and related and neighboring rights to this software to the public domain +## worldwide. This software is distributed without any warranty. +########################################################################### + +include project.cfg + + +########################################################################### +# Default values +########################################################################### + +ifndef XILINX + $(error XILINX must be defined) +endif + +ifndef PROJECT + $(error PROJECT must be defined) +endif + +ifndef TARGET_PART + $(error TARGET_PART must be defined) +endif + +TOPLEVEL ?= $(PROJECT) +CONSTRAINTS ?= $(PROJECT).ucf +BITFILE ?= build/$(PROJECT).bit + +COMMON_OPTS ?= -intstyle xflow +XST_OPTS ?= +NGDBUILD_OPTS ?= +MAP_OPTS ?= +PAR_OPTS ?= +BITGEN_OPTS ?= +TRACE_OPTS ?= +FUSE_OPTS ?= -incremental + +PROGRAMMER ?= none + +IMPACT_OPTS ?= -batch impact.cmd + +DJTG_EXE ?= djtgcfg +DJTG_DEVICE ?= DJTG_DEVICE-NOT-SET +DJTG_INDEX ?= 0 + +XC3SPROG_EXE ?= xc3sprog +XC3SPROG_CABLE ?= none +XC3SPROG_OPTS ?= + +MERCPCL_EXE ?= mercpcl + + +########################################################################### +# Internal variables, platform-specific definitions, and macros +########################################################################### + +ifeq ($(OS),Windows_NT) + XILINX := $(shell cygpath -m $(XILINX)) + CYG_XILINX := $(shell cygpath $(XILINX)) + EXE := .exe + XILINX_PLATFORM ?= nt64 + PATH := $(PATH):$(CYG_XILINX)/bin/$(XILINX_PLATFORM) +else + EXE := + XILINX_PLATFORM ?= lin64 + PATH := $(PATH):$(XILINX)/bin/$(XILINX_PLATFORM) +endif + +TEST_NAMES = $(foreach file,$(VTEST) $(VHDTEST),$(basename $(file))) +TEST_EXES = $(foreach test,$(TEST_NAMES),build/isim_$(test)$(EXE)) + +RUN = @echo -ne "\n\n\e[1;33m======== $(1) ========\e[m\n\n"; \ + cd build && $(XILINX)/bin/$(XILINX_PLATFORM)/$(1) + +# isim executables don't work without this +export XILINX + + +########################################################################### +# Default build +########################################################################### + +default: $(BITFILE) + +clean: + rm -rf build + +build/$(PROJECT).prj: project.cfg + @echo "Updating $@" + @mkdir -p build + @rm -f $@ + @$(foreach file,$(VSOURCE),echo "verilog work \"../$(file)\"" >> $@;) + @$(foreach file,$(VHDSOURCE),echo "vhdl work \"../$(file)\"" >> $@;) + +build/$(PROJECT)_sim.prj: build/$(PROJECT).prj + @cp build/$(PROJECT).prj $@ + @$(foreach file,$(VTEST),echo "verilog work \"../$(file)\"" >> $@;) + @$(foreach file,$(VHDTEST),echo "vhdl work \"../$(file)\"" >> $@;) + @echo "verilog work $(XILINX)/verilog/src/glbl.v" >> $@ + +build/$(PROJECT).scr: project.cfg + @echo "Updating $@" + @mkdir -p build + @rm -f $@ + @echo "run" \ + "-ifn $(PROJECT).prj" \ + "-ofn $(PROJECT).ngc" \ + "-ifmt mixed" \ + "$(XST_OPTS)" \ + "-top $(TOPLEVEL)" \ + "-ofmt NGC" \ + "-p $(TARGET_PART)" \ + > build/$(PROJECT).scr + +$(BITFILE): project.cfg $(VSOURCE) $(VHDSOURCE) $(CONSTRAINTS) build/$(PROJECT).prj build/$(PROJECT).scr + @mkdir -p build + $(call RUN,xst) $(COMMON_OPTS) \ + -ifn $(PROJECT).scr + $(call RUN,ngdbuild) $(COMMON_OPTS) $(NGDBUILD_OPTS) \ + -p $(TARGET_PART) $(addprefix -uc ../,$(CONSTRAINTS)) \ + $(PROJECT).ngc $(PROJECT).ngd + $(call RUN,map) $(COMMON_OPTS) $(MAP_OPTS) \ + -p $(TARGET_PART) \ + -w $(PROJECT).ngd -o $(PROJECT).map.ncd $(PROJECT).pcf + $(call RUN,par) $(COMMON_OPTS) $(PAR_OPTS) \ + -w $(PROJECT).map.ncd $(PROJECT).ncd $(PROJECT).pcf + $(call RUN,bitgen) $(COMMON_OPTS) $(BITGEN_OPTS) \ + -w $(PROJECT).ncd $(PROJECT).bit + @echo -ne "\e[1;32m======== OK ========\e[m\n" + + +########################################################################### +# Testing (work in progress) +########################################################################### + +trace: project.cfg $(BITFILE) + $(call RUN,trce) $(COMMON_OPTS) $(TRACE_OPTS) \ + $(PROJECT).ncd $(PROJECT).pcf + +test: $(TEST_EXES) + +build/isim_%$(EXE): build/$(PROJECT)_sim.prj $(VSOURCE) $(VHDSOURCE) $(VTEST) $(VHDTEST) + $(call RUN,fuse) $(COMMON_OPTS) $(FUSE_OPTS) \ + -prj $(PROJECT)_sim.prj \ + -o isim_$*$(EXE) \ + work.$* work.glbl + +isim: build/isim_$(TB)$(EXE) + @grep --no-filename --no-messages 'ISIM:' $(TB).{v,vhd} | cut -d: -f2 > build/isim_$(TB).cmd + @echo "run all" >> build/isim_$(TB).cmd + cd build ; ./isim_$(TB)$(EXE) -tclbatch isim_$(TB).cmd + +isimgui: build/isim_$(TB)$(EXE) + @grep --no-filename --no-messages 'ISIM:' $(TB).{v,vhd} | cut -d: -f2 > build/isim_$(TB).cmd + @echo "run all" >> build/isim_$(TB).cmd + cd build ; ./isim_$(TB)$(EXE) -gui -tclbatch isim_$(TB).cmd + + +########################################################################### +# Programming +########################################################################### + +ifeq ($(PROGRAMMER), impact) +prog: $(BITFILE) + $(XILINX)/bin/$(XILINX_PLATFORM)/impact $(IMPACT_OPTS) +endif + +ifeq ($(PROGRAMMER), digilent) +prog: $(BITFILE) + $(DJTG_EXE) prog -d $(DJTG_DEVICE) -i $(DJTG_INDEX) -f $(BITFILE) +endif + +ifeq ($(PROGRAMMER), xc3sprog) +prog: $(BITFILE) + $(XC3SPROG_EXE) -c $(XC3SPROG_CABLE) $(XC3SPROG_OPTS) $(BITFILE) +endif + +ifeq ($(PROGRAMMER), mercpcl) +prog: $(BITFILE) + $(MERCPCL_EXE) $(BITFILE) +endif + +ifeq ($(PROGRAMMER), none) +prog: + $(error PROGRAMMER must be set to use 'make prog') +endif + + +########################################################################### + +# vim: set filetype=make: # diff --git a/fpga/Principal.vhd b/fpga/Principal.vhd new file mode 100644 index 0000000..69866e4 --- /dev/null +++ b/fpga/Principal.vhd @@ -0,0 +1,29 @@ +library IEEE; +use IEEE.STD_LOGIC_1164.ALL; + + +entity Principal is + Port ( CLK : in STD_LOGIC; + LED : out STD_LOGIC_VECTOR (3 downto 0)); +end Principal; + +architecture Behavioral of Principal is + signal pulse : std_logic := '0'; + signal count : integer range 0 to 49999999 := 0; +begin + + counter : process(CLK) + begin + if CLK'event and CLK = '1' then + if count = 49999999 then + count <= 0; + pulse <= not pulse; + else + count <= count + 1; + end if; + end if; + end process; + + LED(3 downto 0) <= (others => pulse); +end Behavioral; + diff --git a/fpga/README.md b/fpga/README.md new file mode 100644 index 0000000..649fd87 --- /dev/null +++ b/fpga/README.md @@ -0,0 +1,3 @@ +# Programme pour le FPGA + +Convention : les fichiers .vhd commençant par une minuscule sont des modules, ceux commençant par une majuscule peuvent ĂȘtre utilisĂ©s en top-level. diff --git a/fpga/hcSr04.vhd b/fpga/hcSr04.vhd new file mode 100644 index 0000000..a6f5a2b --- /dev/null +++ b/fpga/hcSr04.vhd @@ -0,0 +1,89 @@ +LIBRARY ieee; +USE ieee.std_logic_1164.all; +USE ieee.std_logic_unsigned.all; + +ENTITY hcSr04 IS + GENERIC( + fFpga : INTEGER := 50_000_000 -- frequency of the FPGA clock (Hz) + ); +PORT( + clk : IN STD_LOGIC; -- clock of the FPGA + echo : IN STD_LOGIC; -- echo pin of the hcSr04 + distance : OUT INTEGER RANGE 0 TO 65535; -- Divide by 58 to get the value in cm + trigger : OUT STD_LOGIC; -- trigger pin of the hcSr04 + start : IN STD_LOGIC; -- Set to '1' everytime a measurement is needed (or keep at '1' for continuous measurement) + finished : OUT STD_LOGIC -- Driven to '1' everytime a measurement has finished + ); +END hcSr04; + +ARCHITECTURE Behavioral OF hcSr04 IS + -- Generate us clock + CONSTANT fUs : INTEGER := 1_000_000; -- Frequency of the microsecond clock + CONSTANT usTicks : INTEGER := fFPGA / fUs; -- Number of FPGA tick that makes a microsecond + SIGNAL fpgaCounter : INTEGER RANGE 0 TO usTicks - 1; -- Count the microsecond + SIGNAL usClk : STD_LOGIC; -- Clock that ticks every us + + -- Trigger + CONSTANT triggerDuration : INTEGER := 10; -- Number of us that makes up a trigger sequence + SIGNAL triggerCounter : INTEGER RANGE 0 TO triggerDuration - 1 := 0; -- Progress in the trigger sequence + SIGNAL theTrigger : STD_LOGIC := '0'; -- Trigger pin but with default value + + -- Measurement + CONSTANT measurementDuration : INTEGER := 60_000; -- Number of us that makes up a measurement cycle + SIGNAL measurementCounter : INTEGER RANGE 0 TO measurementDuration - 1 := 0; -- Progress in the measurement cycle + + -- Distance + SIGNAL distanceCounter : INTEGER RANGE 0 TO 65535 := 0; -- Distance measured (in us) + + -- State machine + TYPE stateType IS (waiting, triggering, measuring); + SIGNAL state : stateType; + +BEGIN + us : process(clk) + begin + if rising_edge(clk) then + if fpgaCounter = 0 then + usClk <= '0'; + elsif fpgaCounter = 1 then + usClk <= '1'; + end if; + fpgaCounter <= fpgaCounter + 1; + end if; + end process; + + trigger <= theTrigger; + + measure : process(usClk) + begin + if rising_edge(usClk) then + CASE state IS + WHEN waiting => + finished <= '0'; + IF start = '1' THEN + theTrigger <= '1'; + triggerCounter <= 0; + state <= triggering; + END IF; + WHEN triggering => + triggerCounter <= triggerCounter + 1; + IF triggerCounter = triggerDuration - 1 THEN + theTrigger <= '0'; + measurementCounter <= 0; + distanceCounter <= 0; + state <= measuring; + END IF; + WHEN measuring => + IF echo = '1' and distanceCounter < 65535 THEN + distanceCounter <= distanceCounter + 1; + END IF; + measurementCounter <= measurementCounter + 1; + IF measurementCounter = measurementDuration - 1 THEN + distance <= distanceCounter; + finished <= '1'; + state <= waiting; + END IF; + END CASE; + end if; + end process; +END Behavioral; diff --git a/fpga/hcSr04Fulldiv.vhd b/fpga/hcSr04Fulldiv.vhd new file mode 100644 index 0000000..0bb9514 --- /dev/null +++ b/fpga/hcSr04Fulldiv.vhd @@ -0,0 +1,69 @@ +LIBRARY ieee; +USE ieee.std_logic_1164.all; +USE ieee.std_logic_unsigned.all; +USE ieee.std_logic_arith.all; + +ENTITY hcSr04 IS + GENERIC( + fFpga : INTEGER := 50_000_000; -- frequency of the FPGA clock (Hz) + maxOutput : INTEGER := 65535 -- maximum number to store the distance + ); +PORT( + clk : IN STD_LOGIC; -- clock of the FPGA + echo : IN STD_LOGIC; -- echo pin of the hcSr04 + distance : OUT INTEGER RANGE 0 TO maxOutput; -- Ranges from 0 to 4 meters, 0 if no data + trigger : OUT STD_LOGIC; -- trigger pin of the hcSr04 + start : IN STD_LOGIC; -- Set to '1' everytime a measurement is needed (or keep at '1' for continuous measurement) + finished : OUT STD_LOGIC -- Driven to '1' everytime a measurement has finished + ); +END hcSr04; + +ARCHITECTURE Behavioral OF hcSr04 IS + CONSTANT triggerTicks : INTEGER := fFPGA / 100000; -- Number of FPGA ticks that makes 10us (used for trigger) + CONSTANT measurementTicks : INTEGER := fFPGA / 17; -- Number of FPGA ticks that makes 60ms (used for measurement cycles) + CONSTANT maximumRange : INTEGER := 4; -- Maximum range the sensor can detect + CONSTANT distanceTicks : INTEGER := maximumRange * fFPGA / 172; -- Number of FPGA ticks that makes the maximum distance that can be measured + -- 172 = 1 / 58 s/m + SIGNAL measurementCounter : INTEGER RANGE 0 to measurementTicks - 1 := 0; -- Progress in the measurement + SIGNAL distanceCounter : INTEGER RANGE 0 to distanceTicks - 1 := 0; -- Ticks for wich echo has been at one + SIGNAL triggerCounter : INTEGER RANGE 0 to triggerTicks - 1 := 0; -- Progress in the trigger + TYPE stateType IS (init, waiting, triggering, measuring); + SIGNAL state : stateType; +BEGIN + measure : process(clk) + begin + if rising_edge(clk) then + CASE state IS + WHEN init => + trigger <= '0'; + distance <= 0; + state <= waiting; + WHEN waiting => + finished <= '0'; + IF start = '1' THEN + trigger <= '1'; + triggerCounter <= 0; + state <= triggering; + END IF; + WHEN triggering => + triggerCounter <= triggerCounter + 1; + IF triggerCounter = triggerTicks - 1 THEN + trigger <= '0'; + measurementCounter <= 0; + distanceCounter <= 0; + state <= measuring; + END IF; + WHEN measuring => + IF echo = '1' and distanceCounter < distanceTicks THEN + distanceCounter <= distanceCounter + 1; + END IF; + measurementCounter <= measurementCounter + 1; + IF measurementCounter = measurementTicks - 1 THEN + distance <= distanceCounter * maxOutput / distanceTicks; + finished <= '1'; + state <= waiting; + END IF; + END CASE; + end if; + end process; +END Behavioral; diff --git a/fpga/hedm.vhd b/fpga/hedm.vhd new file mode 100644 index 0000000..d106dbf --- /dev/null +++ b/fpga/hedm.vhd @@ -0,0 +1,70 @@ +-- Process signals from HEDM-550X encoder +-- and output the value read + +-- TODO Quelques modifications apportĂ©es depuis test avec les vraies codeuses +-- un nouveau test sera nĂ©cessaire (vĂ©rifier notamment le sens de parcours) + +library IEEE; +use IEEE.STD_LOGIC_1164.ALL; +use ieee.numeric_std.all; + +entity hedm is + Port ( + clk : in STD_LOGIC; -- Horloge, la frĂ©quence n'importe pas + chA : in STD_LOGIC; -- Canal A + chB : in STD_LOGIC; -- Canal B + counts : out -- Integer; + ); +end hedm; + +architecture Behavioral of hedm is + signal counter : integer; + signal An, Bn : STD_LOGIC; -- Nouvelles valeurs de A et B stockĂ©es pour que les entrĂ©es soient lues une seule fois en dĂ©but de cycle + signal Ap, Bp : STD_LOGIC; -- PrĂ©cĂ©dentes valeurs de A et B pour dĂ©tecter les front montant +begin + processInput : process(clk) + begin + if rising_edge(clk) then + + Ap <= An; + Bp <= Bn; + + An <= A; + Bn <= B; + + -- On pourrait optimiser la logique avec un tableau de Karnaugh ou autres mĂ©thodes + -- de simplification d'algĂšbre de Boole, mais le "compilateur" pour FPGA fera un + -- tout aussi bon travail, on garde donc le code suivant pour la lisibilitĂ© + + if (Ap = '0' and An = '1') then -- Front montant A + if (Bn = '0') then + counter <= counter + 1; + else + counter <= counter - 1; + end if; + elsif (Ap = '1' and An = '0') then -- Front descendant A + if (Bn = '1') then + counter <= counter + 1; + else + counter <= counter - 1; + end if; + elsif (Bp = '0' and Bn = '1') then -- Front montant B + if (An = '1') then + counter <= counter + 1; + else + counter <= counter - 1; + end if; + elsif (Bp = '1' and Bn = '0') then -- Front descendant B + if (An = '0') then + counter <= counter + 1; + else + counter <= counter - 1; + end if; + end if; + end if; + end process; + + counts <= counter; + +end Behavioral; + diff --git a/fpga/mercury.ucf b/fpga/mercury.ucf new file mode 100644 index 0000000..9d77b3f --- /dev/null +++ b/fpga/mercury.ucf @@ -0,0 +1,90 @@ +# __ ____ _ __ +# / |/ (_)_____________ / | / /___ _ ______ _ +# / /|_/ / / ___/ ___/ __ \/ |/ / __ \ | / / __ `/ +# / / / / / /__/ / / /_/ / /| / /_/ / |/ / /_/ / +# /_/ /_/_/\___/_/ \____/_/ |_/\____/|___/\__,_/ +# +# Mercury User Constraints File +# Revision 1.0.142 (10/24/2012) +# Copyright (c) 2012 MicroNova, LLC +# www.micro-nova.com + +# system oscillator +NET "CLK" LOC = "P43" | IOSTANDARD = LVTTL ; +NET "CLK" TNM_NET = "CLK"; +TIMESPEC "TS_CLK" = PERIOD "CLK" 20 ns HIGH 50 %; + +# user LEDs and button +NET "LED<0>" LOC = "P13" | IOSTANDARD = LVTTL ; +NET "LED<1>" LOC = "P15" | IOSTANDARD = LVTTL ; +NET "LED<2>" LOC = "P16" | IOSTANDARD = LVTTL ; +NET "LED<3>" LOC = "P19" | IOSTANDARD = LVTTL ; +NET "BTN" LOC = "P41" | IOSTANDARD = LVTTL ; + +# direct and global-clock I/O +NET "DIO<0>" LOC = "P20" | IOSTANDARD = LVTTL ; +NET "DIO<1>" LOC = "P32" | IOSTANDARD = LVTTL ; +NET "DIO<2>" LOC = "P33" | IOSTANDARD = LVTTL ; +NET "DIO<3>" LOC = "P34" | IOSTANDARD = LVTTL ; +NET "DIO<4>" LOC = "P35" | IOSTANDARD = LVTTL ; +NET "DIO<5>" LOC = "P36" | IOSTANDARD = LVTTL ; +NET "DIO<6>" LOC = "P37" | IOSTANDARD = LVTTL ; +NET "CIO<0>" LOC = "P40" | IOSTANDARD = LVTTL ; +NET "CIO<1>" LOC = "P44" | IOSTANDARD = LVTTL ; + +# in-only pins +NET "INPIN<0>" LOC = "P68" | IOSTANDARD = LVTTL ; +NET "INPIN<1>" LOC = "P97" | IOSTANDARD = LVTTL ; +NET "INPIN<2>" LOC = "P7" | IOSTANDARD = LVTTL ; +NET "INPIN<3>" LOC = "P82" | IOSTANDARD = LVTTL ; + +# level-shifted I/O +NET "IO<0>" LOC = "P59" | IOSTANDARD = LVTTL ; +NET "IO<1>" LOC = "P60" | IOSTANDARD = LVTTL ; +NET "IO<2>" LOC = "P61" | IOSTANDARD = LVTTL ; +NET "IO<3>" LOC = "P62" | IOSTANDARD = LVTTL ; +NET "IO<4>" LOC = "P64" | IOSTANDARD = LVTTL ; +NET "IO<5>" LOC = "P57" | IOSTANDARD = LVTTL ; +NET "IO<6>" LOC = "P56" | IOSTANDARD = LVTTL ; +NET "IO<7>" LOC = "P52" | IOSTANDARD = LVTTL ; +NET "IO<8>" LOC = "P50" | IOSTANDARD = LVTTL ; +NET "IO<9>" LOC = "P49" | IOSTANDARD = LVTTL ; +NET "IO<10>" LOC = "P85" | IOSTANDARD = LVTTL ; +NET "IO<11>" LOC = "P84" | IOSTANDARD = LVTTL ; +NET "IO<12>" LOC = "P83" | IOSTANDARD = LVTTL ; +NET "IO<13>" LOC = "P78" | IOSTANDARD = LVTTL ; +NET "IO<14>" LOC = "P77" | IOSTANDARD = LVTTL ; +NET "IO<15>" LOC = "P65" | IOSTANDARD = LVTTL ; +NET "IO<16>" LOC = "P70" | IOSTANDARD = LVTTL ; +NET "IO<17>" LOC = "P71" | IOSTANDARD = LVTTL ; +NET "IO<18>" LOC = "P72" | IOSTANDARD = LVTTL ; +NET "IO<19>" LOC = "P73" | IOSTANDARD = LVTTL ; +NET "IO<20>" LOC = "P5" | IOSTANDARD = LVTTL ; +NET "IO<21>" LOC = "P4" | IOSTANDARD = LVTTL ; +NET "IO<22>" LOC = "P6" | IOSTANDARD = LVTTL ; +NET "IO<23>" LOC = "P98" | IOSTANDARD = LVTTL ; +NET "IO<24>" LOC = "P94" | IOSTANDARD = LVTTL ; +NET "IO<25>" LOC = "P93" | IOSTANDARD = LVTTL ; +NET "IO<26>" LOC = "P90" | IOSTANDARD = LVTTL ; +NET "IO<27>" LOC = "P89" | IOSTANDARD = LVTTL ; +NET "IO<28>" LOC = "P88" | IOSTANDARD = LVTTL ; +NET "IO<29>" LOC = "P86" | IOSTANDARD = LVTTL ; + +# memory & bus-switch +NET "switch_oen" LOC = "P3" | IOSTANDARD = LVTTL ; +NET "memory_oen" LOC = "P30" | IOSTANDARD = LVTTL ; + +# flash/usb interface +NET "fpga_csn" LOC = "P39" | IOSTANDARD = LVTTL ; +NET "flash_csn" LOC = "P27" | IOSTANDARD = LVTTL ; +NET "spi_mosi" LOC = "P46" | IOSTANDARD = LVTTL ; +NET "spi_miso" LOC = "P51" | IOSTANDARD = LVTTL ; +NET "spi_sck" LOC = "P53" | IOSTANDARD = LVTTL ; + +# ADC interface +NET "adc_miso" LOC = "P21" | IOSTANDARD = LVTTL ; +NET "adc_mosi" LOC = "P10" | IOSTANDARD = LVTTL ; +NET "adc_sck" LOC = "P9" | IOSTANDARD = LVTTL ; +NET "adc_csn" LOC = "P12" | IOSTANDARD = LVTTL ; + +# CLOCK timing diff --git a/fpga/project.cfg b/fpga/project.cfg new file mode 100644 index 0000000..e0228e8 --- /dev/null +++ b/fpga/project.cfg @@ -0,0 +1,14 @@ +PROJECT = Principal +TARGET_PART = xc3s200a-vq100 +XILINX = /opt/Xilinx/14.7/ISE_DS/ISE +PROGRAMMER = mercpcl + +TOPLEVEL = Principal +VHDSOURCE = $(TOPLEVEL).vhd +CONSTRAINTS = mercury.ucf + +# Implement design +# Allow unmatched LOC Constraints +NGDBUILD_OPTS += -aul +# Allow unmatched Timing Group Constraints +NGDBUILD_OPTS += -aut diff --git a/fpga/uart b/fpga/uart new file mode 160000 index 0000000..ba6d1c3 --- /dev/null +++ b/fpga/uart @@ -0,0 +1 @@ +Subproject commit ba6d1c3a7acbec274282c59af11dae64eaec2618 diff --git a/fpga/uart.vhd b/fpga/uart.vhd new file mode 120000 index 0000000..58b210d --- /dev/null +++ b/fpga/uart.vhd @@ -0,0 +1 @@ +uart/source/uart.vhd \ No newline at end of file diff --git a/raspberrypi/.gitignore b/raspberrypi/.gitignore new file mode 100644 index 0000000..c5b25db --- /dev/null +++ b/raspberrypi/.gitignore @@ -0,0 +1,5 @@ +dl +output +principalconf.sh +sshconf +sshkey* diff --git a/raspberrypi/Config.in b/raspberrypi/Config.in new file mode 100644 index 0000000..501218e --- /dev/null +++ b/raspberrypi/Config.in @@ -0,0 +1,2 @@ +source "$BR2_EXTERNAL_CDF_PATH/package/robotech/Config.in" +source "$BR2_EXTERNAL_CDF_PATH/package/cr1901/Config.in" diff --git a/raspberrypi/Makefile b/raspberrypi/Makefile new file mode 100644 index 0000000..2b2a3a7 --- /dev/null +++ b/raspberrypi/Makefile @@ -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/ + diff --git a/raspberrypi/board/robotech/cdfprincipal/linux-extra.conf b/raspberrypi/board/robotech/cdfprincipal/linux-extra.conf new file mode 100644 index 0000000..95ada35 --- /dev/null +++ b/raspberrypi/board/robotech/cdfprincipal/linux-extra.conf @@ -0,0 +1,2 @@ +MEDIA_SUPPORT=n +SOUND=n diff --git a/raspberrypi/board/robotech/cdfprincipal/post-build.sh b/raspberrypi/board/robotech/cdfprincipal/post-build.sh new file mode 100755 index 0000000..52255e5 --- /dev/null +++ b/raspberrypi/board/robotech/cdfprincipal/post-build.sh @@ -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 + diff --git a/raspberrypi/board/robotech/cdfprincipal/rootfs_overlay/etc/extra.d/S40wifi b/raspberrypi/board/robotech/cdfprincipal/rootfs_overlay/etc/extra.d/S40wifi new file mode 100755 index 0000000..a307d4b --- /dev/null +++ b/raspberrypi/board/robotech/cdfprincipal/rootfs_overlay/etc/extra.d/S40wifi @@ -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 $? diff --git a/raspberrypi/board/robotech/cdfprincipal/rootfs_overlay/etc/extra.d/rcK b/raspberrypi/board/robotech/cdfprincipal/rootfs_overlay/etc/extra.d/rcK new file mode 100755 index 0000000..d8484fc --- /dev/null +++ b/raspberrypi/board/robotech/cdfprincipal/rootfs_overlay/etc/extra.d/rcK @@ -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 + diff --git a/raspberrypi/board/robotech/cdfprincipal/rootfs_overlay/etc/extra.d/rcS b/raspberrypi/board/robotech/cdfprincipal/rootfs_overlay/etc/extra.d/rcS new file mode 100755 index 0000000..4b78f4b --- /dev/null +++ b/raspberrypi/board/robotech/cdfprincipal/rootfs_overlay/etc/extra.d/rcS @@ -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 + diff --git a/raspberrypi/board/robotech/cdfprincipal/rootfs_overlay/etc/init.d/S40keyboard b/raspberrypi/board/robotech/cdfprincipal/rootfs_overlay/etc/init.d/S40keyboard new file mode 100755 index 0000000..1b617a5 --- /dev/null +++ b/raspberrypi/board/robotech/cdfprincipal/rootfs_overlay/etc/init.d/S40keyboard @@ -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 $? diff --git a/raspberrypi/board/robotech/cdfprincipal/rootfs_overlay/etc/init.d/S50chef b/raspberrypi/board/robotech/cdfprincipal/rootfs_overlay/etc/init.d/S50chef new file mode 100755 index 0000000..9e67faf --- /dev/null +++ b/raspberrypi/board/robotech/cdfprincipal/rootfs_overlay/etc/init.d/S50chef @@ -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 $? diff --git a/raspberrypi/board/robotech/cdfprincipal/rootfs_overlay/etc/init.d/S90extra b/raspberrypi/board/robotech/cdfprincipal/rootfs_overlay/etc/init.d/S90extra new file mode 100755 index 0000000..ef037ce --- /dev/null +++ b/raspberrypi/board/robotech/cdfprincipal/rootfs_overlay/etc/init.d/S90extra @@ -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 $? diff --git a/raspberrypi/board/robotech/cdfprincipal/rootfs_overlay/root/.profile b/raspberrypi/board/robotech/cdfprincipal/rootfs_overlay/root/.profile new file mode 100644 index 0000000..dfb5415 --- /dev/null +++ b/raspberrypi/board/robotech/cdfprincipal/rootfs_overlay/root/.profile @@ -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="- " diff --git a/raspberrypi/board/robotech/cdfprincipal/rootfs_overlay/usr/share/keyboard/fr-latin9.bmap b/raspberrypi/board/robotech/cdfprincipal/rootfs_overlay/usr/share/keyboard/fr-latin9.bmap new file mode 100644 index 0000000000000000000000000000000000000000..a14bf3d12606e916fec873473ee6b4bc837c44d7 GIT binary patch literal 2623 zcmd^>_itNO6vw~!zIXl3^*456XSi*OR0=dLspITHTPVAQvNv?ZrD+=4ro~Btgi`($ z%3gw&vda=;BLP1khL}P?84~aVVu*R4or*|)CKd`367NXQ_BnTb{5|Kqw{h#x#P*g?KfGW80`2~8rIn|AWmHTB zN|aTit?olV29QNJdeDnjbf6PmXh$1rHS}`E6&2jKzbrgQ4oR&7qZ^bLo1;`r$1)1B zxvEh$sd=hKB~-JTuj|__a*~4D;v7ZBM=RUSlVC6(!&Qp0l zFXUysh^u)H&!z9*Qsh667w{CG#?!fqXYfp};aNO}PdLtpcnL4%$-I~+@ob*JHs*MT z^EcR#AMubQJXccHx^tyeTGgw1?dgpWrjxibMDvzu^~rgYWS$JpX3Ip@V1f6JEi7 ze2(w%9$v$ncnlBV9!PM&-4Eg}+=q{FFP_HR_z`=ZKjZjsf{NFegh`rOQ)f~pZR$;f zX*AG!O4m8Ir0?9R&+u2M|86vyj2k!I{$79RYWN?)%XkzI;!fO-mvBE`#54Euc|ODk_!Zyc2ee=iUm@K0IlO~caW`JT8+aeD<1IXncX`lp-sa|(n*`8P`5zH2 zA3xm_@<-Wh@JFp%@>x-s7s(Rtn<|SWLXYEz&XmQVOZ+b2k|)aiNN;K6%={k8>wkV# z`5$$b(3f`kUnv&ySBiz4QTEUEPZ#q)YR%cuze75uOS+{;dZkbLWkA|xiL4M5`(xCu z&3uwt#v!nel8Y%7%2*0b(0RODYSal;Dr zpVWu@f7sVEt_gxRCX ze~-U{{*_Nss{hLRM?e2(?*D6c