diff --git a/Documentation.md b/Documentation.md new file mode 100644 index 0000000..425002d --- /dev/null +++ b/Documentation.md @@ -0,0 +1,123 @@ +# TP-Armadeus-CryptoMorse +This repository contains a Embedded System group project. + +The goal of the project is to create a software for the Armadeus board that receives messages, crypt them, convert them to morse, and send them through GPIOs. + +## How to compile the armadeus BSP +- __gcc version__: 4.8.4 +- __g++ version__: 4.8.4 + +```bash +> git clone https://github.com/pblottiere/armadeus.git +> cd armadeus +> make apf28_defconfig +# make sure you have g++ +> make all +``` + +__Note__: _the `make` command needs to download files, so it might not work on the school connection because of the proxy_ + +### (Optional) Python Dev + +[Tutorial](http://www.armadeus.org/wiki/index.php?title=Python_development) + +## Communicating with board using TFTP + +### Installing TFTP + +[Tutorial](http://www.armadeus.org/wiki/index.php?title=Communicate_with_your_board_from_a_Linux_Host_(Basics)) + + 1. Install and create the folder for exchanging tftp files + + ```bash + # install tftp + > sudo apt-get install tftpd xinetd + # create the folder for exchange + > sudo mkdir /tftpboot + > sudo chmod 777 /tftpboot + ``` + + 2. Edit or create the configuration file /etc/xinetd.d/tftp and modify/add it the following lines: + + ``` + # default: off + # description: The tftp server serves files using the trivial file transfer + # protocol. The tftp protocol is often used to boot diskless + # workstations, download configuration files to network-aware printers, + # and to start the installation process for some operating systems. + service tftp + { + socket_type = dgram + protocol = udp + wait = yes + user = root + server = /usr/sbin/in.tftpd + server_args = -s /tftpboot + # disable = yes + } + ``` + + 3. Restart xinetd service + + ```bash + > sudo killall -HUP xinetd + ``` + +### Connect to the board + + + +#### Configure minicom + +[Tutorial](https://help.ubuntu.com/community/SerialConsoleHowto) + +#### Access BIOS + +1. Connect to the board using `minicom` +2. Reset the board (button RESET) +3. Cancel the boot by pressing any key... + +#### Configure IP addresses + +```bash +> setenv ipaddr +> setenv serverip # 172.20.5.2 works well +> saveenv +``` + +Restart + +### Flashing the kernel + +[Tutorial](http://www.armadeus.org/wiki/index.php?title=Target_Software_Installation) + +Copy the images to tftp and + +```bash +> cp buildroot/output/images/* /tftpboot +> run update_kernel +> run update_rootfs +``` + +#### Troubleshooting + +How to reset everything + +```bash +BIOS> run update_uboot +BIOS> reset +BIOS> run flash_reset_env +... +BIOS> run update_kernel +BIOS> run update_rootfs +``` + +### Sending a binary to the board + +[Tutorial](http://www.armadeus.org/wiki/index.php?title=HelloWorld) + +Use `arm-linux-gcc` in (`armadeus/buildroot/output/host/usr/bin/`) to compile and generate the binary of your code for the armadeus + +## Using autotools to compile the project + +[Tutorial](http://markuskimius.wikidot.com/programming:tut:autotools/) \ No newline at end of file diff --git a/README.md b/README.md index 425002d..704ad3e 100644 --- a/README.md +++ b/README.md @@ -3,121 +3,36 @@ This repository contains a Embedded System group project. The goal of the project is to create a software for the Armadeus board that receives messages, crypt them, convert them to morse, and send them through GPIOs. -## How to compile the armadeus BSP -- __gcc version__: 4.8.4 -- __g++ version__: 4.8.4 +## Architecture du repository: -```bash -> git clone https://github.com/pblottiere/armadeus.git -> cd armadeus -> make apf28_defconfig -# make sure you have g++ -> make all -``` +### Dossier sprint -__Note__: _the `make` command needs to download files, so it might not work on the school connection because of the proxy_ +Ce dossier contient les codes de chaque sous-partie du projet: + - cryptage + - conversion morse + - controle du gpio + - client-serveur -### (Optional) Python Dev +__NB__: _Tout ces codes (sauf gpio) compilent individuellement **correctement** avec le cross-compilateur_ -[Tutorial](http://www.armadeus.org/wiki/index.php?title=Python_development) +### Dossier main -## Communicating with board using TFTP +Ce dossier contient un fichier main qui regroupe les sous-partie du programme en un seul. +Il contient également un `makefile` qui compile le code à l'aide du cross-compilateur (remplacer `CC` par le bon) +Le `makefile` se charge également d'envoyer par scp le binaire directement à la carte (changer l'adresse IP si nécessaire). -### Installing TFTP +Il faut également compiler le `client.c` en local. -[Tutorial](http://www.armadeus.org/wiki/index.php?title=Communicate_with_your_board_from_a_Linux_Host_(Basics)) +## Utilisation du code: - 1. Install and create the folder for exchanging tftp files +1. Compiler le `main.c` à l'aide du cross-compilateur et envoyer le binaire sur la carte +2. Compiler le `client.c` à l'aide d'un compilateur de la machine hôte. +3. Exécuter le binaire sur la carte. (il s'agit d'un serveur) +4. Exécuter le client compilé sur la machine hôte et suivre les instructions. - ```bash - # install tftp - > sudo apt-get install tftpd xinetd - # create the folder for exchange - > sudo mkdir /tftpboot - > sudo chmod 777 /tftpboot - ``` +## Que fais le code ? - 2. Edit or create the configuration file /etc/xinetd.d/tftp and modify/add it the following lines: +Pour l'instant le client sert à emettre le message désiré. +Le serveur sur la carte, récupère le message, le crypte et le convertit en Morse. - ``` - # default: off - # description: The tftp server serves files using the trivial file transfer - # protocol. The tftp protocol is often used to boot diskless - # workstations, download configuration files to network-aware printers, - # and to start the installation process for some operating systems. - service tftp - { - socket_type = dgram - protocol = udp - wait = yes - user = root - server = /usr/sbin/in.tftpd - server_args = -s /tftpboot - # disable = yes - } - ``` - - 3. Restart xinetd service - - ```bash - > sudo killall -HUP xinetd - ``` - -### Connect to the board - - - -#### Configure minicom - -[Tutorial](https://help.ubuntu.com/community/SerialConsoleHowto) - -#### Access BIOS - -1. Connect to the board using `minicom` -2. Reset the board (button RESET) -3. Cancel the boot by pressing any key... - -#### Configure IP addresses - -```bash -> setenv ipaddr -> setenv serverip # 172.20.5.2 works well -> saveenv -``` - -Restart - -### Flashing the kernel - -[Tutorial](http://www.armadeus.org/wiki/index.php?title=Target_Software_Installation) - -Copy the images to tftp and - -```bash -> cp buildroot/output/images/* /tftpboot -> run update_kernel -> run update_rootfs -``` - -#### Troubleshooting - -How to reset everything - -```bash -BIOS> run update_uboot -BIOS> reset -BIOS> run flash_reset_env -... -BIOS> run update_kernel -BIOS> run update_rootfs -``` - -### Sending a binary to the board - -[Tutorial](http://www.armadeus.org/wiki/index.php?title=HelloWorld) - -Use `arm-linux-gcc` in (`armadeus/buildroot/output/host/usr/bin/`) to compile and generate the binary of your code for the armadeus - -## Using autotools to compile the project - -[Tutorial](http://markuskimius.wikidot.com/programming:tut:autotools/) \ No newline at end of file +__NB:__ _la partie contrôle de la LED par GPIO n'a pas été encore testé. Donc n'est pas dans le main._ \ No newline at end of file diff --git a/main/morse_func2.c b/main/morse_func2.c deleted file mode 100755 index 57a80b5..0000000 --- a/main/morse_func2.c +++ /dev/null @@ -1,92 +0,0 @@ -#include "morse_func.h" - -int ascii2morse(char *s, FILE *outfile){ - - char *letters[] = { - "1 -1 3 ", // A | a - "3 -1 1 -1 1 -1 1 ", // B | b - "3 -1 1 -1 3 -1 1 ", // C | c - "3 -1 1 -1 1 ", // D | d - "1 ", // E | e - "1 -1 1 -1 3 -1 1 ", // F | f - "3 -1 3 -1 1 ", // G | g - "1 -1 1 -1 1 -1 1 ", // H | h - "1 -1 1 -1 ", // I | i - "1 -1 3 -1 3 -1 3 ", // J | j - "3 -1 1 -1 3 ", // K | k - "1 -1 3 -1 1 -1 1 ", // L | l - "3 -1 3 ", // M | m - "3 -1 1 ", // N | n - "3 -1 3 -1 3 ", // O | o - "1 -1 3 -1 3 -1 1 ", // P | p - "3 -1 3 -1 1 -1 3 ", // Q | q - "1 -1 3 -1 1 ", // R | r - "1 -1 1 -1 1 ", // S | s - "3 ", // T | t - "1 -1 1 -1 3 ", // U | u - "1 -1 1 -1 1 -1 3 ", // V | v - "1 -1 3 -1 3 ", // W | w - "3 -1 1 -1 1 -1 3 ", // X | x - "3 -1 1 -1 3 -1 3 ", // Y | y - "3 -1 3 -1 1 -1 1 " // Z | z - }; - - char *numbers[] = { - "3 -1 3 -1 3 -1 3 -1 3 ", // 0 - "1 -1 3 -1 3 -1 3 -1 3 ", // 1 - "1 -1 1 -1 3 -1 3 -1 3 ", // 2 - "1 -1 1 -1 1 -1 3 -1 3 ", // 3 - "1 -1 1 -1 1 -1 1 -1 3 ", // 4 - "1 -1 1 -1 1 -1 1 -1 1 ", // 5 - "3 -1 1 -1 1 -1 1 -1 1 ", // 6 - "3 -1 3 -1 1 -1 1 -1 1 ", // 7 - "3 -1 3 -1 3 -1 1 -1 1 ", // 8 - "3 -1 3 -1 3 -1 3 -1 3 ", // 9 - }; - - int i, c; - for (i=0;i= 'a')) - fputs(letters[c - 'a'],outfile); - - else if((c <= 'Z') && (c >= 'A')) - fputs(letters[c - 'A'],outfile); - - else if((c <= '9') && (c >= '0')) - fputs(numbers[c - '0'],outfile); - - else if(c == '.') - fputs("1 -1 3 -1 1 -1 3 -1 1 -1 3 ",outfile); - - else if(c == ',') - fputs("3 -1 3 -1 1 -1 1 -1 3 -1 3 ",outfile); - - else if(c == '?') - fputs("1 -1 1 -1 3 -1 3 -1 1 -1 1 ",outfile); - - else if(c == '-') - fputs("3 -1 1 -1 1 -1 1 -1 1 -1 3 ",outfile); - - else // caractere non valide - printf("Le caracter %c n'est pas valide \nValeur en ASCII = %d\ni = %d",s[i],s[i],i); - - // espace entre elements - if (s[i+2] == '\0') - break; - if (s[i+1] != ' ') - fputs("-3 ",outfile); // entre elements - else{ - fputs("-7 ",outfile); // fin d'un mot - i++; - } - } - } - - //fclose(f); - - return EXIT_SUCCESS; -} diff --git a/sprint/LED_GPIO/morse2led.c b/sprint/LED_GPIO/morse2led.c new file mode 100644 index 0000000..d15d0bb --- /dev/null +++ b/sprint/LED_GPIO/morse2led.c @@ -0,0 +1,71 @@ +#include +#include +#include "as_gpio.h" + +#define LED_GPIO 21 +#define time_dot 100 // temps base d'un element simple (point). A verifier + +void morseShow(struct as_gpio_device *led, FILE* morseCode); + +int main(int argc, char *argv[]) +{ + if(argc < 2) + { + printf("Utilisation :\n./main infile\n"); + return EXIT_FAILURE; + } + + // ouverture du fichier du code morse + FILE *infile = fopen(argv[1],"r"); + if(infile == NULL) + { + printf("Fichier d'entrée \"%s\" n'existe pas\n", argv[1]); + return EXIT_FAILURE; + } + + // declaration du LED + struct as_gpio_device *led; + led = as_gpio_open(LED_GPIO); + if(led == NULL) + { + printf("Error: can't open gpio\n"); + exit(1); + } + + // on place la LED en sortie + as_gpio_set_pin_direction(led, "out"); + + // boucle principale + morseShow(led,infile); + + as_gpio_close(led); + exit(0); +} + +// boucle principale du programme qui envoit les messages +void morseShow(struct as_gpio_device *led, FILE* morseCode) +{ + // on place la LED en sortie et le switch en entrer + as_gpio_set_pin_direction(led, "out"); + + // boucle principale + // lit un element de temps a la fois + int nthLedDuration, delay; + while (fscanf(morseCode,"%d[^\n]",&nthLedDuration) == 1) + { + if(value > 0) // si positive, allumer le led + { + as_gpio_set_pin_value(led, 1); + delay = nthLedDuration; + } + else // si negatif, eteindre le led + { + as_gpio_set_pin_value(led, 0); + delay = -nthLedDuration; + } + + sleep(time_dot*delay); // meilleure option ? + } +} + + diff --git a/todo.md b/todo.md index 0b04527..94c3bba 100644 --- a/todo.md +++ b/todo.md @@ -7,4 +7,7 @@ ## -ajout d'un script init.d dans `/etc/init.d/` \ No newline at end of file +ajout d'un script init.d dans `/etc/init.d/` + +# Carte qui marche +__ID__: 286000397 \ No newline at end of file