Outils pour utilisateurs

Outils du site


nouveaucesi
tp1.ino
#include "lib_io_tp.h"
 
void setup() {
  Serial.begin(115200);
  SetupES();
 
}
 
void loop() {
  unsigned char E=readPort();
  writePort(E);
  Serial.print("   ");
  Serial.print(E,HEX);
 
  Serial.println();
  delay(100);
}
lib_io_tp.h
#include <Arduino.h>
void SetupES(void);
unsigned char readPort(void);
void writePort(unsigned char value);
lib_io_tp.cpp
#include "lib_io_tp.h"
 
 
/*mix de 
https://wokwi.com/arduino/projects/313005664351814210
et de
https://wokwi.com/arduino/projects/301188813482361352
*/
 
// Pin definitions:
const int datapin_in = 2;   /* Q7 */
const int clockpin_in =  3;  /* CP */
const int latchpin_in = 4;  /* PL */
const int datapin_out = 5; 
const int clockpin_out = 6;
const int latchpin_out = 7;
/////////////////////////////////////////////////////// 
void SetupES(void){
  pinMode(datapin_in, INPUT);
  pinMode(clockpin_in, OUTPUT);
  pinMode(latchpin_in, OUTPUT);
  // Set the three SPI pins to be outputs:
  pinMode(datapin_out, OUTPUT);
  pinMode(clockpin_out, OUTPUT);  
  pinMode(latchpin_out, OUTPUT);  
  }
///////////////////////////////////////////////////////
unsigned char readPort(void){
unsigned char val=0;
// Step 1: Sample
  digitalWrite(latchpin_in, LOW);
  digitalWrite(latchpin_in, HIGH);
  for (int i = 0; i < 8; i++) {
    int bit = digitalRead(datapin_in);
    val=(val<<1)|bit;
    digitalWrite(clockpin_in, HIGH); // Shift out the next bit
    digitalWrite(clockpin_in, LOW);
  }
  return val;
}
///////////////////////////////////////////////////////
void writePort(unsigned char value){
  shiftOut(datapin_out, clockpin_out, MSBFIRST, value); //Send "data" to the shift register
  //Toggle the latchpin_out to make "data" appear at the outputs
  digitalWrite(latchpin_out, HIGH); 
  digitalWrite(latchpin_out, LOW); 
}
///////////////////////////////////////////////////////
diagram.json
{
  "version": 1,
  "author": "Uri Shaked",
  "editor": "wokwi",
  "parts": [
    { "type": "wokwi-arduino-uno", "id": "uno", "top": -41.14, "left": 32.68, "attrs": {} },
    { "type": "wokwi-74hc165", "id": "sr1", "top": -121.05, "left": 145.07, "attrs": {} },
    { "type": "wokwi-slide-switch", "id": "sw8", "top": -201.18, "left": 0, "attrs": {} },
    { "type": "wokwi-slide-switch", "id": "sw7", "top": -201.18, "left": 40, "attrs": {} },
    { "type": "wokwi-slide-switch", "id": "sw6", "top": -201.18, "left": 80, "attrs": {} },
    { "type": "wokwi-slide-switch", "id": "sw5", "top": -201.18, "left": 120, "attrs": {} },
    { "type": "wokwi-slide-switch", "id": "sw4", "top": -201.18, "left": 160, "attrs": {} },
    { "type": "wokwi-slide-switch", "id": "sw3", "top": -201.18, "left": 200, "attrs": {} },
    { "type": "wokwi-slide-switch", "id": "sw2", "top": -201.18, "left": 240, "attrs": {} },
    { "type": "wokwi-slide-switch", "id": "sw1", "top": -201.18, "left": 280, "attrs": {} },
    {
      "type": "wokwi-74hc595",
      "id": "sr2",
      "top": -302.5,
      "left": 313.3,
      "rotate": 90,
      "attrs": {}
    },
    { "type": "wokwi-led", "id": "led1", "top": -335, "left": 275, "attrs": { "color": "red" , "label": "0" } },
    { "type": "wokwi-led", "id": "led2", "top": -335, "left": 235, "attrs": { "color": "red" , "label": "1"} },
    { "type": "wokwi-led", "id": "led3", "top": -335, "left": 195, "attrs": { "color": "red" , "label": "2"} },
    { "type": "wokwi-led", "id": "led4", "top": -335, "left": 155, "attrs": { "color": "red" , "label": "3"} },
    { "type": "wokwi-led", "id": "led5", "top": -335, "left": 115, "attrs": { "color": "red" , "label": "4"} },
    { "type": "wokwi-led", "id": "led6", "top": -335, "left": 75, "attrs": { "color": "red" , "label": "5"} },
    { "type": "wokwi-led", "id": "led7", "top": -335, "left": 35, "attrs": { "color": "red" , "label": "6"} },
    { "type": "wokwi-led", "id": "led8", "top": -335, "left": -5, "attrs": { "color": "red" , "label": "7"} }
  ],
  "connections": [
    [ "sr1:D7", "sw8:2", "green", [ "v24", "h-114" ] ],
    [ "sr1:D6", "sw7:2", "green", [ "v18", "h-114" ] ],
    [ "sr1:D5", "sw6:2", "green", [ "v12", "h-80" ] ],
    [ "sr1:D4", "sw5:2", "green", [ "v8", "h-45" ] ],
    [ "sr1:D3", "sw4:2", "green", [ "v-26", "h7" ] ],
    [ "sr1:D2", "sw3:2", "green", [ "v-20", "h21" ] ],
    [ "sr1:D1", "sw2:2", "green", [ "v-16", "h61" ] ],
    [ "sr1:D0", "sw1:2", "green", [ "v-10", "h82" ] ],
    [ "sr1:PL", "uno:4", "orange", [ "v36", "h13" ] ],
    [ "sr1:CP", "uno:3", "purple", [ "v30", "h-22" ] ],
    [ "sr1:Q7", "uno:2", "magenta", [ "v-4", "h0" ] ],
    [ "uno:GND.1", "sw8:1", "black", [ "v-16", "h0" ] ],
    [ "sw8:1", "sw7:1", "black", [ "v7", "h0" ] ],
    [ "sw7:1", "sw6:1", "black", [ "v7", "h0" ] ],
    [ "sw6:1", "sw5:1", "black", [ "v7", "h0" ] ],
    [ "sw5:1", "sw4:1", "black", [ "v7", "h0" ] ],
    [ "sw4:1", "sw3:1", "black", [ "v7", "h0" ] ],
    [ "sw3:1", "sw2:1", "black", [ "v7", "h0" ] ],
    [ "sw2:1", "sw1:1", "black", [ "v7", "h0" ] ],
    [ "sw1:3", "uno:5V", "red", [ "v12", "h21", "v335", "h0" ] ],
    [ "sw1:3", "sw2:3", "red", [ "v12", "h0" ] ],
    [ "sw2:3", "sw3:3", "red", [ "v12", "h0" ] ],
    [ "sw3:3", "sw4:3", "red", [ "v12", "h0" ] ],
    [ "sw4:3", "sw5:3", "red", [ "v12", "h0" ] ],
    [ "sw5:3", "sw6:3", "red", [ "v12", "h0" ] ],
    [ "sw6:3", "sw7:3", "red", [ "v12", "h0" ] ],
    [ "sw7:3", "sw8:3", "red", [ "v12", "h0" ] ],
    [ "sr1:VCC", "sw5:3", "red", [ "v-34", "h165" ] ],
    [ "sr1:CE", "sw4:1", "black", [ "v-39", "h158" ] ],
    [ "sr1:GND", "uno:GND.1", "black", [ "v42", "h-233" ] ],
    [ "sr2:GND", "uno:GND.1", "black", [ "v205","h0" ] ],
    [ "sr2:GND", "led1:C", "black", [ "v0", "h-13" ] ],
    [ "sr2:GND", "led2:C", "black", [ "v0", "h-29" ] ],
    [ "sr2:GND", "led3:C", "black", [ "v0", "h-16" ] ],
    [ "sr2:GND", "led4:C", "black", [ "v0", "h-35" ] ],
    [ "sr2:GND", "led5:C", "black", [ "v0", "h-66" ] ],
    [ "sr2:GND", "led6:C", "black", [ "v0", "h-100" ] ],
    [ "sr2:GND", "led7:C", "black", [ "v0", "h206" ] ],
    [ "sr2:GND", "led8:C", "black", [ "v0", "h277" ] ],
    [ "sr2:VCC", "uno:5V", "red", [ "h30", "v500", "h-156" ] ],
    [ "sr2:DS", "uno:5", "blue", [ "h16", "v220", "h-68" ] ],
    [ "uno:GND.1", "sr2:OE", "black", [ "h0","v-16", "h230", "v-52" ] ],
    [ "sr2:STCP", "uno:7", "purple", [ "h7", "v189", "h-77" ] ],
    [ "sr2:SHCP", "uno:6", "gray", [ "h4", "v170", "h-66" ] ],
    [ "sr2:Q7", "led8:A", "green", [ "h0" ] ],
    [ "sr2:Q6", "led7:A", "green", [ "h-4", "v6", "h-194" ] ],
    [ "sr2:Q5", "led6:A", "green", [ "h-7", "v12", "h-161" ] ],
    [ "sr2:Q4", "led5:A", "green", [ "h-10", "v18", "h-131" ] ],
    [ "sr2:Q3", "led4:A", "green", [ "h-13", "v24", "h-95" ] ],
    [ "sr2:Q2", "led3:A", "green", [ "h-16", "v31", "h-64" ] ],
    [ "sr2:Q1", "led2:A", "green", [ "h-19", "v37", "h-40" ] ],
    [ "sr2:Q0", "led1:A", "green", [ "h10", "v-17", "h-63", "v40", "h-6" ] ]
  ]
}

Probleme avec les vcd

en fait ce sont les caractères “d'été” ' et é dans l'heure qui posent problème. codes ascii 39 et 130 dans table ascii french

or d'après https://en.wikipedia.org/wiki/Value_change_dump#:~:text=From%20Wikipedia%2C%20the%20free%20encyclopedia%20Value%20Change%20Dump,language%20by%20the%20IEEE%20Standard%201364-1995%20in%201996.

Each variable is assigned an arbitrary, compact ASCII identifier for use in the value change section. The identifier is composed of printable ASCII characters from ! to ~ (decimal 33 to 126). Several variables can share an identifier if the simulator determines that they will always have the same value.

lecture de la date dans gtkwave: https://github.com/gtkwave/gtkwave/blob/ee52b426351cb2a58af16b11bf401519ccba3ead/gtkwave3-gtk3/src/helpers/fst/fstapi.c

création d'eléments

Installation à l'iut

sudo apt update

il faut taper O plusieurs fois en console

sudo apt install chromium-browser

https://askubuntu.com/questions/118025/bypass-the-yes-no-prompt-in-apt-get-upgrade

sudo DEBIAN_FRONTEND=noninteractive apt update -y
sudo apt -y install chromium-browser  

bizarre sur E10, il n'y a que chromium

sudo apt -y install chromium

sudo apt -y install gtkwave python3-pip 
sudo pip3 install watchdog
cd ~/Téléchargements
wget --no-check-certificate https://bvdp.inetdoc.net/files/cesi/wokwi2gtkwave.py
python3 ./wokwi2gtkwave.py 






dans firefox, 

option (trois traits horizontaux en haut à droite) paramètres dans la partie Téléchargements, cocher: Enregistrer les fichiers dans le dossier et choisir le dossier Téléchargements

il y a le probleme de faire en sorte de télécharger automatiquement le fichier plutot que de l'ouvrir…

https://support.mozilla.org/fr/kb/changer-ce-que-fait-firefox-lorsque-vous-cliquez-telechargez-fichier

cd ~/.mozilla/firefox find .|grep handlers ./kywfgwb2.default/handlers.json

gedit ~/.mozilla/firefox/kywfgwb2.default/handlers.json

explication sur: https://support.mozilla.org/en-US/questions/1197107

firefox indique que wikwi-logic.vcd est un fichier de type GTKWave Dump File à partir de :blob:

plugin a voir: https://addons.mozilla.org/en-US/firefox/addon/content-type-fixer/

avant: {“defaultHandlersVersion”:{“fr”:3},“mimeTypes”:{“application/pdf”:{“action”:3,“extensions”:[“pdf”]},“application/x-bittorrent”:{“action”:0,“ask”:true,“extensions”:[“torrent”]},“video/mp4”:{“action”:0,“ask”:true,“extensions”:[“mp4”]},“application/zip”:{“action”:0,“ask”:true,“extensions”:[“zip”]},“application/force-download”:{“action”:0,“ask”:true,“extensions”:[“cbr”]},“application/x-rar-compressed”:{“action”:0,“ask”:true},“video/x-msvideo”:{“action”:0,“ask”:true,“extensions”:[“avi”]},“text/xml”:{“action”:3,“extensions”:[“xml”]},“image/svg+xml”:{“action”:3,“extensions”:[“svg”]},“image/webp”:{“action”:3,“extensions”:[“webp”]},“image/avif”:{“action”:3,“extensions”:[“avif”]}},“schemes”:{“webcal”:{“action”:2,“ask”:true},“ircs”:{“action”:2,“ask”:true,“handlers”:[null,{“name”:“Mibbit”,“uriTemplate”:“https://www.mibbit.com/?url=%s”}]},“mailto”:{“action”:4,“handlers”:[null,{“name”:“Yahoo! Mail”,“uriTemplate”:“https://compose.mail.yahoo.com/?To=%s”},{“name”:“Gmail”,“uriTemplate”:“https://mail.google.com/mail/?extsrc=mailto&url=%s”}]},“irc”:{“action”:2,“ask”:true,“handlers”:[null,{“name”:“Mibbit”,“uriTemplate”:“https://www.mibbit.com/?url=%s”}]},“apt”:{“action”:4,“ask”:true}}}

après avoir changé AVI en télécharger le fichier: {“defaultHandlersVersion”:{“fr”:3},“mimeTypes”:{“application/pdf”:{“action”:3,“extensions”:[“pdf”]},“application/x-bittorrent”:{“action”:0,“ask”:true,“extensions”:[“torrent”]},“video/mp4”:{“action”:0,“ask”:true,“extensions”:[“mp4”]},“application/zip”:{“action”:0,“ask”:true,“extensions”:[“zip”]},“application/force-download”:{“action”:0,“ask”:true,“extensions”:[“cbr”]},“application/x-rar-compressed”:{“action”:0,“ask”:true},“video/x-msvideo”:{“action”:0,“extensions”:[“avi”]},“text/xml”:{“action”:3,“extensions”:[“xml”]},“image/svg+xml”:{“action”:3,“extensions”:[“svg”]},“image/webp”:{“action”:3,“extensions”:[“webp”]},“image/avif”:{“action”:3,“extensions”:[“avif”]}},“schemes”:{“webcal”:{“action”:2,“ask”:true},“ircs”:{“action”:2,“ask”:true,“handlers”:[null,{“name”:“Mibbit”,“uriTemplate”:“https://www.mibbit.com/?url=%s”}]},“mailto”:{“action”:4,“handlers”:[null,{“name”:“Yahoo! Mail”,“uriTemplate”:“https://compose.mail.yahoo.com/?To=%s”},{“name”:“Gmail”,“uriTemplate”:“https://mail.google.com/mail/?extsrc=mailto&url=%s”}]},“irc”:{“action”:2,“ask”:true,“handlers”:[null,{“name”:“Mibbit”,“uriTemplate”:“https://www.mibbit.com/?url=%s”}]},“apt”:{“action”:4,“ask”:true}}}

modif de fichier pour sauver les .vcd: {“defaultHandlersVersion”:{“fr”:3},“mimeTypes”:{“application/pdf”:{“action”:3,“extensions”:[“pdf”]},“application/x-bittorrent”:{“action”:0,“ask”:true,“extensions”:[“torrent”]},“video/mp4”:{“action”:0,“ask”:true,“extensions”:[“mp4”]},“application/zip”:{“action”:0,“ask”:true,“extensions”:[“zip”]},“application/force-download”:{“action”:0,“ask”:true,“extensions”:[“cbr”]},“application/x-rar-compressed”:{“action”:0,“ask”:true},“video/x-msvideo”:{“action”:0,“ask”:true,“extensions”:[“avi”]},“text/xml”:{“action”:3,“extensions”:[“xml”]},“image/svg+xml”:{“action”:3,“extensions”:[“svg”]},“image/webp”:{“action”:3,“extensions”:[“webp”]},“image/avif”:{“action”:3,“extensions”:[“avif”]}},“schemes”:{“webcal”:{“action”:2,“ask”:true},“ircs”:{“action”:2,“ask”:true,“handlers”:[null,{“name”:“Mibbit”,“uriTemplate”:“https://www.mibbit.com/?url=%s”}]},“mailto”:{“action”:4,“handlers”:[null,{“name”:“Yahoo! Mail”,“uriTemplate”:“https://compose.mail.yahoo.com/?To=%s”},{“name”:“Gmail”,“uriTemplate”:“https://mail.google.com/mail/?extsrc=mailto&url=%s”}]},“irc”:{“action”:2,“ask”:true,“handlers”:[null,{“name”:“Mibbit”,“uriTemplate”:“https://www.mibbit.com/?url=%s”}]},“apt”:{“action”:4,“ask”:true},“vcd”:{“action”:0,“extensions”:[“vcd”]}}}

{“defaultHandlersVersion”:{“fr”:3},“mimeTypes”:{“application/pdf”:{“action”:3,“extensions”:[“pdf”]},“application/x-bittorrent”:{“action”:0,“ask”:true,“extensions”:[“torrent”]},“video/mp4”:{“action”:0,“ask”:true,“extensions”:[“mp4”]},“application/zip”:{“action”:0,“ask”:true,“extensions”:[“zip”]},“application/force-download”:{“action”:0,“ask”:true,“extensions”:[“cbr”]},“application/x-rar-compressed”:{“action”:0,“ask”:true},“video/x-msvideo”:{“action”:0,“ask”:true,“extensions”:[“avi”]},“text/xml”:{“action”:3,“extensions”:[“xml”]},“image/svg+xml”:{“action”:3,“extensions”:[“svg”]},“image/webp”:{“action”:3,“extensions”:[“webp”]},“image/avif”:{“action”:3,“extensions”:[“avif”]}},“schemes”:{“webcal”:{“action”:2,“ask”:true},“ircs”:{“action”:2,“ask”:true,“handlers”:[null,{“name”:“Mibbit”,“uriTemplate”:“https://www.mibbit.com/?url=%s”}]},“mailto”:{“action”:4,“handlers”:[null,{“name”:“Yahoo! Mail”,“uriTemplate”:“https://compose.mail.yahoo.com/?To=%s”},{“name”:“Gmail”,“uriTemplate”:“https://mail.google.com/mail/?extsrc=mailto&url=%s”}]},“irc”:{“action”:2,“ask”:true,“handlers”:[null,{“name”:“Mibbit”,“uriTemplate”:“https://www.mibbit.com/?url=%s”}]},“apt”:{“action”:4,“ask”:true},“vcd”:{“action”:0,“extensions”:[“vcd”]}}}

{“defaultHandlersVersion”:{“fr”:3},“mimeTypes”:{“application/pdf”:{“action”:3,“extensions”:[“pdf”]},“application/x-bittorrent”:{“action”:0,“ask”:true,“extensions”:[“torrent”]},“video/mp4”:{“action”:0,“ask”:true,“extensions”:[“mp4”]},“application/zip”:{“action”:0,“ask”:true,“extensions”:[“zip”]},“application/force-download”:{“action”:0,“ask”:true,“extensions”:[“cbr”]},“application/x-rar-compressed”:{“action”:2,“ask”:true},“video/x-msvideo”:{“action”:0,“ask”:true,“extensions”:[“avi”]},“text/xml”:{“action”:3,“extensions”:[“xml”]},“image/svg+xml”:{“action”:3,“extensions”:[“svg”]},“image/webp”:{“action”:3,“extensions”:[“webp”]},“image/avif”:{“action”:3,“extensions”:[“avif”]}},“schemes”:{“webcal”:{“action”:2,“ask”:true},“ircs”:{“action”:2,“ask”:true,“handlers”:[null,{“name”:“Mibbit”,“uriTemplate”:“https://www.mibbit.com/?url=%s”}]},“mailto”:{“action”:4,“handlers”:[null,{“name”:“Yahoo! Mail”,“uriTemplate”:“https://compose.mail.yahoo.com/?To=%s”},{“name”:“Gmail”,“uriTemplate”:“https://mail.google.com/mail/?extsrc=mailto&url=%s”}]},“irc”:{“action”:2,“ask”:true,“handlers”:[null,{“name”:“Mibbit”,“uriTemplate”:“https://www.mibbit.com/?url=%s”}]},“apt”:{“action”:4,“ask”:true},“application/GTKWave Dump File”:{“action”:0,“ask”:false}}}

{“defaultHandlersVersion”:{“fr”:3},“mimeTypes”:{“application/pdf”:{“action”:3,“extensions”:[“pdf”]},“application/x-bittorrent”:{“action”:0,“ask”:true,“extensions”:[“torrent”]},“video/mp4”:{“action”:0,“ask”:true,“extensions”:[“mp4”]},“application/zip”:{“action”:0,“ask”:true,“extensions”:[“zip”]},“application/force-download”:{“action”:0,“ask”:true,“extensions”:[“cbr”]},“application/x-rar-compressed”:{“action”:2,“ask”:true},“video/x-msvideo”:{“action”:0,“ask”:true,“extensions”:[“avi”]},“text/xml”:{“action”:3,“extensions”:[“xml”]},“image/svg+xml”:{“action”:3,“extensions”:[“svg”]},“image/webp”:{“action”:3,“extensions”:[“webp”]},“image/avif”:{“action”:3,“extensions”:[“avif”]}},“schemes”:{“webcal”:{“action”:2,“ask”:true},“ircs”:{“action”:2,“ask”:true,“handlers”:[null,{“name”:“Mibbit”,“uriTemplate”:“https://www.mibbit.com/?url=%s”}]},“mailto”:{“action”:4,“handlers”:[null,{“name”:“Yahoo! Mail”,“uriTemplate”:“https://compose.mail.yahoo.com/?To=%s”},{“name”:“Gmail”,“uriTemplate”:“https://mail.google.com/mail/?extsrc=mailto&url=%s”}]},“irc”:{“action”:2,“ask”:true,“handlers”:[null,{“name”:“Mibbit”,“uriTemplate”:“https://www.mibbit.com/?url=%s”}]},“apt”:{“action”:4,“ask”:true},“application/vcd”:{“action”:0,“ask”:false,“extensions”:[“vcd”]}}}

liste des mime types: https://www.htmlstrip.com/mime-file-type-checker vcd pas bon…

https://www.bing.com/search?form=MOZLBR&pc=MOZI&q=mime+type+vcd+gtkwave application/vnd.gtkwave-gtkw https://reposcope.com/mimetype/application/vnd.gtkwave-gtkw

il y a également https://reposcope.com/mimetype/application/vnd.gtkwave-vcd application/vnd.gtkwave-vcd

rechercher: mime type GTKWave Dump File https://www.bing.com/search?form=MOZLBR&pc=MOZI&q=mime+type+GTKWave+Dump+File+ application/vnd.gtkwave-ae2

doc du format vcd: https://en.wikipedia.org/wiki/Value_change_dump

https://developer.mozilla.org/fr/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types

Il existe deux types MIME principaux qui jouent un rôle important en terme de types par défaut :

  text/plain est le type MIME par défaut pour les fichiers texte. Un fichier texte doit pouvoir être lu par un utilisateur et ne pas contenir de données binaires.
 
  application/octet-stream est le type MIME par défaut dans tous les autres cas. Un fichier de type inconnu doit être associé à ce type MIME. Les navigateurs traiteront les fichiers associés à ce type MIME de façon particulière pour protéger au maximum l'utilisateur des éventuels risques de sécurité.

bon je n'y arrive pas ça va finir avec:

sudo apt install chromium-browser

Organisation ?

organisation temporelle? (moi en premier pour me libérer au S4?)

appli assembleur → passer en inline asm gcc

appli au WS2812 ou autre

commande de procédé: on peut garder le tapis festo avec interface 8574 arduino ou nucléo

arduino et vstudio code / platform IO: disassembly automatisé ok mais pas de simulateur pour l'assembleur (essayer un autre simu)

passer sous nucléo dans un second temps ?

est ce qu'on part de HAL puis on descend vers bas niveau ou l'inverse?

dev algo sur PC pour debug puis cross compilation

Archi ATMEGA328P

Makefile

Wokwi

éditeur en ligne de code arduino avec simulation de matériel: https://wokwi.com/

code source de wikwi: https://github.com/wokwi

Description arduino uno avec broches et périphériques internes simulés: https://docs.wokwi.com/parts/wokwi-arduino-uno

GDB en ligne: https://docs.wokwi.com/gdb-debugging

projet vide arduino uno: https://wokwi.com/arduino/new?template=arduino-uno

exemple de projet piano: https://wokwi.com/arduino/projects/291958456169005577

analyseur logique: https://docs.wokwi.com/parts/wokwi-logic-analyzer et https://docs.wokwi.com/guides/logic-analyzer#using-the-logic-analyzer

AVR Assembler

sudo apt install avra   
cd ~/Bureau/iutatrier/iut5/cesi/asm_arduino
make
avrdude -c arduino -p m328p -P /dev/ttyACM0 -b 115200 -U flash:w:blink.hex

pour que le Makefile compile et upload le bon programme:

make program="blink" upload 

Différents simulateurs

SimAVR

simulateur arduino couplé avec gtkwave:

https://github.com/buserror/simavr

https://github.com/buserror/simavr/tree/master/examples

TP programmation assembleur sur ATMEGA328P: http://jmfriedt.free.fr/TP_M1_asm32u4.pdf

visualisation fichier vcd avec gtkwave via simavr (simavr peut être utilisé avec GDB )

cd ~/Bureau/iutatrier/iut5/cesi/simuavr
git clone https://github.com/buserror/simavr.git

sous bionic 18.04, c'est installable avec apt, mais je dois compiler à la main

make
  pb:  fatal error: libelf.h: Aucun fichier ou dossier de ce type

il faut installer:

sudo apt install libelf-dev

fatal error: curses.h: Aucun fichier ou dossier de ce type

sudo apt-get install libncurses-dev

Visual studio code

https://fr.wikipedia.org/wiki/Visual_Studio_Code

téléchargement: https://code.visualstudio.com/download

version linux deb: https://code.visualstudio.com/docs/?dv=linux64_deb

sudo dpkg -i code_1.60.2-1632313585_amd64.deb 
dpkg -c code_1.60.2-1632313585_amd64.deb | more
  installe dans ./usr/share/code/bin/code
dus /usr/share/code
  1M	/usr/share/code/bin
  3M	/usr/share/code/swiftshader
  7M	/usr/share/code/locales
  125M	/usr/share/code/resources
  293M	/usr/share/code

il me propose au démarrage: “Do you want to install the recommended extensions for C++?”

https://marketplace.visualstudio.com/vscode

C++

https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools

  • Installation: Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.

ext install ms-vscode.cpptools

Arduino (finalement ne pas l'installer

https://marketplace.visualstudio.com/items?itemName=vsciot-vscode.vscode-arduino

  • Installation: Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.

ext install vsciot-vscode.vscode-arduino

PlatformIO

https://marketplace.visualstudio.com/items?itemName=platformio.platformio-ide

  • Installation: Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.

ext install platformio.platformio-ide

Problème à cause de version python

Error: TypeError [ERR_INVALID_ARG_TYPE]: The "file" argument must be of type string. Received null at /home/bvandepo/.vscode/extensions/platformio.platformio-ide-2.3.3/node_modules/platformio-node-helpers/dist/index.js:1:771390 at a (/home/bvandepo/.vscode/extensions/platformio.platformio-ide-2.3.3/node_modules/platformio-node-helpers/dist/index.js:1:771284) at w (/home/bvandepo/.vscode/extensions/platformio.platformio-ide-2.3.3/node_modules/platformio-node-helpers/dist/index.js:1:771035) at u (/home/bvandepo/.vscode/extensions/platformio.platformio-ide-2.3.3/node_modules/platformio-node-helpers/dist/index.js:1:770559) at /home/bvandepo/.vscode/extensions/platformio.platformio-ide-2.3.3...

passer à python 3.6, installation à la main depuis les sources facile: https://moreless.medium.com/install-python-3-6-on-ubuntu-16-04-28791d5c2167

cd /opt
wget https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tgz
tar -xvf Python-3.6.3.tgz
cd Python-3.6.3
./configure
make 
make install

création d'un projet arduino dans platform io: https://docs.platformio.org/en/latest//integration/ide/vscode.html#quick-start

l'extension arduino fait un conflit avec platformio, la virer!

~/.platformio$ dus
2M	./platforms
29M	./penv
64M	./.cache
274M	./packages
366M	./

Super doc sur asm inliné avec GCC

livre à acheter: https://leanpub.com/arduinoinlineassembly

https://ucexperiment.wordpress.com/2016/03/04/arduino-inline-assembly-tutorial-1/

If certain instructions need to remain consecutive in the output, put them in a single multi-instruction asm statement. GCC’s optimizers can move asm statements relative to other code, including across jumps.

asm statements may not perform jumps into other asm statements. GCC does not know about these jumps, and therefore cannot take account of them when deciding how to optimize. Jumps from asm to C labels are only supported under extended asm.

Under certain circumstances, GCC may duplicate (or remove duplicates of) your assembly code when optimizing. This can lead to unexpected duplicate symbol errors during compilation if your assembly code defines symbols or labels. And since GCC does not parse the Assembler instructions, it has no visibility of any symbols it may reference.

https://ucexperiment.wordpress.com/2016/03/07/arduino-inline-assembly-tutorial-2/

https://ucexperiment.wordpress.com/2016/03/08/arduino-inline-assembly-tutorial-3/

https://ucexperiment.wordpress.com/2016/03/10/arduino-inline-assembly-tutorial-4/

https://ucexperiment.wordpress.com/2016/03/11/arduino-inline-assembly-tutorial-5-2/

https://ucexperiment.wordpress.com/2016/03/13/arduino-status-register-sreg/

https://ucexperiment.wordpress.com/2016/03/14/arduino-inline-assembly-tutorial-6-2/

https://ucexperiment.wordpress.com/2016/03/16/arduino-inline-assembly-tutorial-7-bit-shifts/

https://ucexperiment.wordpress.com/2016/03/19/arduino-inline-assembly-tutorial-8-math/

https://ucexperiment.wordpress.com/2016/03/22/toward-a-more-general-digitalread/

https://ucexperiment.wordpress.com/2016/03/23/arduino-inline-assembly-tutorail-9-branching/

https://ucexperiment.wordpress.com/2016/03/28/arduino-inline-assembly-tutorial-10-strings/

https://ucexperiment.wordpress.com/2016/03/31/arduino-inline-assembler-tutorial-11-tables/

https://ucexperiment.wordpress.com/2016/04/02/arduino-inline-assembly-tutorial-12-functions/

https://ucexperiment.wordpress.com/2016/04/05/arduino-inline-assembler-tutorial-13-interrupts/

https://ucexperiment.wordpress.com/2016/04/06/arduino-inline-assembly-tutorial-14-examples/

https://ucexperiment.wordpress.com/2016/04/06/arduino-inline-assembly-port-pin-compendium/

https://ucexperiment.wordpress.com/2016/05/21/my-cup-overflows/

https://ucexperiment.wordpress.com/2016/11/06/using-atmel-studio-for-arduino-development/

https://ucexperiment.wordpress.com/2016/11/06/atmel-studio-does-blink-in-assembly-language/

dans https://ucexperiment.wordpress.com/2016/04/02/arduino-inline-assembly-tutorial-12-functions/

  • Arguments are allocated left to right, starting in register r25 descending through register r8. All arguments are aligned to start in even-numbered registers (odd-sized arguments, like char, have one free register above them), for example, a single 8-bit value is passed via the r24 register (r25 is assumed empty), a single 16-bit value is passed via the r25:r24 register pair, and a 32-bit value would be passed via r25:r24:r23:r22 register combination.

Return values are expected to be passed in a similar fashion. An 8-bit value is passed via r24, a 16-bit value in r25:r24, and 32-bits in r22:r23:r24:r25. An 8-bit return value may be zero/sign-extended to 16-bits by the called function.

  • Function “call-used” registers are r18-r27, and r30-r31. Any, or all of these registers may be allocated by the compiler for local data. However, we may use them freely in assembler subroutines. Calling C subroutines can clobber any of them, and the caller is responsible for saving and restoring before and after use.
  • Function “call-saved” registers are r2-r17, and r28-r29. They may also be allocated by the compiler for local data, but C subroutines leaves them unchanged. Assembler subroutines are responsible for saving and restoring any of these registers, if changed. The Y register pair (r29:r28) is used as a frame pointer (pointing to local data placed on the stack) if necessary.
  • Fixed registers, r0, and r1 are never allocated by the compiler for local data. The temporary register, r0 can be clobbered by any C code (except interrupt handlers which save it), and may be used freely. The zero register is r1, and assumed to be always zero in any C code. It may be used for other purposes within a piece of assembler code, but must then be cleared after use (clr r1). Interrupt handlers save and clear r1 on entry, and restore r1 on exit (in case it was non-zero).

assembleur AVR

jeu d'instruction etc:

http://ww1.microchip.com/downloads/en/DeviceDoc/AVR-InstructionSet-Manual-DS40002198.pdf#page=18

http://ww1.microchip.com/downloads/en/devicedoc/atmel-0856-avr-instruction-set-manual.pdf#PAGE=22

désassemblage (voir page: https://bvdp.inetdoc.net/wiki/doku.php?id=desassemblage_arduino )

/usr/share/arduino/hardware/tools/avr/bin/avr-objdump -d /tmp/arduino_build_319925/sketch/cesi1.ino.cpp.o > ~/test_disassembly.cpp.asm
/usr/share/arduino/hardware/tools/avr/bin/avr-objdump -d ./cesi1.ino.cpp.o > ./test_disassembly.cpp.asm
/home/bvandepo/Téléchargements/arduino-1.8.13/hardware/tools/avr/bin/avr-objdump -d ./cesi1.ino.cpp.o > ./test_disassembly.cpp.asm
link.txt
Linking everything together...
/home/bvandepo/Téléchargements/arduino-1.8.13/hardware/tools/avr/bin/avr-gcc -w -Os -g -flto -fuse-linker-plugin -Wl,--gc-sections -mmcu=atmega328p -o /tmp/arduino_build_319925/cesi1.ino.elf /tmp/arduino_build_319925/sketch/cesi1.ino.cpp.o /tmp/arduino_build_319925/libraries/Wire/Wire.cpp.o /tmp/arduino_build_319925/libraries/Wire/utility/twi.c.o /tmp/arduino_build_319925/../arduino_cache_377812/core/core_arduino_avr_uno_7c971292e96a0aa19cbc2b17540b3549.a -L/tmp/arduino_build_319925 -lm
/home/bvandepo/Téléchargements/arduino-1.8.13/hardware/tools/avr/bin/avr-objcopy -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 /tmp/arduino_build_319925/cesi1.ino.elf /tmp/arduino_build_319925/cesi1.ino.eep
/home/bvandepo/Téléchargements/arduino-1.8.13/hardware/tools/avr/bin/avr-objcopy -O ihex -R .eeprom /tmp/arduino_build_319925/cesi1.ino.elf /tmp/arduino_build_319925/cesi1.ino.hex
Utilisation de la bibliothèque Wire version 1.0 dans le dossier: /home/bvandepo/Téléchargements/arduino-1.8.13/hardware/arduino/avr/libraries/Wire 
/home/bvandepo/Téléchargements/arduino-1.8.13/hardware/tools/avr/bin/avr-size -A /tmp/arduino_build_319925/cesi1.ino.elf
Le croquis utilise 4124 octets (12%) de l'espace de stockage de programmes. Le maximum est de 32256 octets.
Les variables globales utilisent 410 octets (20%) de mémoire dynamique, ce qui laisse 1638 octets pour les variables locales. Le maximum est de 2048 octets.
/home/bvandepo/Téléchargements/arduino-1.8.13/hardware/tools/avr/bin/avrdude -C/home/bvandepo/Téléchargements/arduino-1.8.13/hardware/tools/avr/etc/avrdude.conf -v -patmega328p -carduino -P/dev/ttyACM0 -b115200 -D -Uflash:w:/tmp/arduino_build_319925/cesi1.ino.hex:i 
cd /tmp/arduino_build_319925/
/usr/share/arduino/hardware/tools/avr/bin/avr-objdump -d ./cesi1.ino.elf > ./test_disassembly.cpp.asm
/usr/share/arduino/hardware/tools/avr/bin/avr-objdump -d ./core/main.cpp.o > ./test_disassembly.cpp.asm
file /tmp/arduino_build_319925/sketch/cesi1.ino.cpp.o
  /tmp/arduino_build_319925/sketch/cesi1.ino.cpp.o: ELF 32-bit LSB relocatable, Atmel AVR 8-bit, version 1 (SYSV), not stripped
/usr/share/arduino/hardware/tools/avr/bin/avr-objdump -S -s -g -e -t -D /tmp/arduino_build_319925/sketch/cesi1.ino.cpp.o > ~/test_disassembly.cpp.asm && gedit  ~/test_disassembly.cpp.asm &
/usr/share/arduino/hardware/tools/avr/bin/avr-objdump --help
doc-avr-objdump.txt
    Usage: /usr/share/arduino/hardware/tools/avr/bin/avr-objdump <option(s)> <fichier(s)>
     Afficher les informations depuis le(s) <fichier(s)> objet.
     Au moins un des commutateurs suivants doit être fourni :
  -a, --archive-headers    Afficher l'information de l'en-tête de l'archive
  -f, --file-headers       Afficher le contenu global du fichier d'en-tête
  -p, --private-headers    Afficher le format spécifique du contenu de l'en-tête de l'objet
  -P, --private=OPT,OPT... Afficher les contenus spécifiques au format de l'objet
  -h, --[section-]headers  Afficher le contenu des en-têtes de section
  -x, --all-headers        Afficher le contenu de tous les en-têtes
  -d, --disassemble        Afficher le contenu en assembleur des sections exécutables
  -D, --disassemble-all    Afficher le contenu en assembleur de toutes les sections
  -S, --source             Inter-mêler le code source avec le désassemblage
  -s, --full-contents      Afficher le contenu complet de toutes les sections demandées
  -g, --debugging          Afficher les informations de mise au point du fichier objet
  -e, --debugging-tags     Afficher les informations de mise au point en utilisant le style ctags
  -G, --stabs              Afficher (en format brut) toutes infos STAB dans le fichier
  -W[lLiaprmfFsoRt] ou
  --dwarf[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,
          =frames-interp,=str,=loc,=Ranges,=pubtypes,
          =gdb_index,=trace_info,=trace_abbrev,=trace_aranges,
          =addr,=cu_index]
                           Afficher les informations DWARF dans le fichier
  -t, --syms               Afficher le contenu de(s) table(s) de symboles
  -T, --dynamic-syms       Afficher le contenu de la table dynamique de symboles
  -r, --reloc              Afficher les entrées de réadressage du fichier
  -R, --dynamic-reloc      Afficher les entrées dynamiques de réadressage du fichier
  @<fichier>               Lire les options à partir du <fichier>
  -v, --version            Afficher la version du logiciel
  -i, --info               Afficher les formats objets et les architectures supportées
  -H, --help               Afficher cette information
 
 Les commutateurs suivants sont optionnels :
  -b, --target=NOMBFD            spécifier le format de l'objet cible comme NOMBFD
  -m, --architecture=MACHINE     spécifier l'architecture cible de la MACHINE
  -j, --section=NOM              afficher seulement les informations de la section du NOM
  -M, --disassembler-options=OPT relayer l'OPTion au désassembleur
  -EB --endian=big               assumer le format « big endian » lors du désassemblage
  -EL --endian=little            assumer le format « little endian » lors du désassemblage
      --file-start-context       inclure le contexte à partir du début du fichier (avec -S)
  -I, --include=RÉPERTOIRE       ajouter le répertoire à la liste de recherche des fichiers sources
  -l, --line-numbers             inclure les numéros de ligne et les noms de fichier dans la sortie
  -F, --file-offsets             inclure les offsets dans le fichier dans les informations affichées
  -C, --demangle[=STYLE]         décoder les mutilations/traitements des noms de symboles
                                  Le STYLE, si spécifié, peut être « auto », « gnu »,
                                  « lucid », « arm », « hp », « edg », « gnu-v3 », « java »
                                  ou « gnat »
  -w, --wide                     formatter la sortie pour plus de 80 colonnes
  -z, --disassemble-zeroes       ne pas escamoter les blocs de zéros lors du désassemblage
      --start-address=ADR        traiter seulement les données dont les adresses sont >= ADR
      --stop-address=ADR         traiter seulement les données dont les adresses sont <= ADR
      --prefix-addresses         afficher les adresses complètes dans le dé-assemblage
      --[no-]show-raw-insn       afficher en hexadécimal le dé-assemblage symbolique
      --insn-width=LARGEUR       afficher LARGEUR octets sur une seule ligne avec -d
      --adjust-vma=DÉCALAGE      ajouter un DÉCALAGE à toutes les adresses affichées des sections
      --special-syms             inclure les symboles spéciaux dans la vidange de symboles
      --prefix=PRÉFIXE           ajouter le PRÉFIXE aux chemins absolus pour -S
      --prefix-strip=NIVEAU      supprimer des répertoires au début de -S
      --dwarf-depth=N        Ne pas afficher les DIEs à une profondeur supérieure ou égale à N
      --dwarf-start=N        Afficher les DIEs en commençant par N, à la même profondeur ou plus bas
      --dwarf-check          Réaliser des contrôles de cohérence interne de dwarf.      
 
/usr/share/arduino/hardware/tools/avr/bin/avr-objdump: cibles supportées : elf32-avr elf32-little elf32-big plugin srec symbolsrec verilog tekhex binary ihex
/usr/share/arduino/hardware/tools/avr/bin/avr-objdump : architectures prises en charge : avr avr:1 avr:2 avr:25 avr:3 avr:31 avr:35 avr:4 avr:5 avr:51 avr:6 avr:100 avr:101 avr:102 avr:103 avr:104 avr:105 avr:106 avr:107 plugin
 
Options supportées par -P/--private :
For AVR ELF files:
  mem-usage   Display memory usage
Rapporter toutes anomalies à <http://www.sourceware.org/bugzilla/>

/home/bvandepo/Téléchargements/arduino-1.8.13/arduino-builder -dump-prefs -logger=machine -hardware /home/bvandepo/Téléchargements/arduino-1.8.13/hardware -hardware /home/bvandepo/.arduino15/packages -tools /home/bvandepo/Téléchargements/arduino-1.8.13/tools-builder -tools /home/bvandepo/Téléchargements/arduino-1.8.13/hardware/tools/avr -tools /home/bvandepo/.arduino15/packages -built-in-libraries /home/bvandepo/Téléchargements/arduino-1.8.13/libraries -libraries /home/bvandepo/Arduino/libraries -fqbn=arduino:avr:uno -vid-pid=2341_0043 -ide-version=10813 -build-path /tmp/arduino_build_319925 -warnings=none -build-cache /tmp/arduino_cache_377812 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=/home/bvandepo/Téléchargements/arduino-1.8.13/hardware/tools/avr -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=/home/bvandepo/Téléchargements/arduino-1.8.13/hardware/tools/avr -prefs=runtime.tools.arduinoOTA.path=/home/bvandepo/Téléchargements/arduino-1.8.13/hardware/tools/avr -prefs=runtime.tools.arduinoOTA-1.3.0.path=/home/bvandepo/Téléchargements/arduino-1.8.13/hardware/tools/avr -prefs=runtime.tools.avr-gcc.path=/home/bvandepo/Téléchargements/arduino-1.8.13/hardware/tools/avr -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=/home/bvandepo/Téléchargements/arduino-1.8.13/hardware/tools/avr -verbose /home/bvandepo/Arduino/cesi1/cesi1.ino /home/bvandepo/Téléchargements/arduino-1.8.13/arduino-builder -compile -logger=machine -hardware /home/bvandepo/Téléchargements/arduino-1.8.13/hardware -hardware /home/bvandepo/.arduino15/packages -tools /home/bvandepo/Téléchargements/arduino-1.8.13/tools-builder -tools /home/bvandepo/Téléchargements/arduino-1.8.13/hardware/tools/avr -tools /home/bvandepo/.arduino15/packages -built-in-libraries /home/bvandepo/Téléchargements/arduino-1.8.13/libraries -libraries /home/bvandepo/Arduino/libraries -fqbn=arduino:avr:uno -vid-pid=2341_0043 -ide-version=10813 -build-path /tmp/arduino_build_319925 -warnings=none -build-cache /tmp/arduino_cache_377812 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=/home/bvandepo/Téléchargements/arduino-1.8.13/hardware/tools/avr -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=/home/bvandepo/Téléchargements/arduino-1.8.13/hardware/tools/avr -prefs=runtime.tools.arduinoOTA.path=/home/bvandepo/Téléchargements/arduino-1.8.13/hardware/tools/avr -prefs=runtime.tools.arduinoOTA-1.3.0.path=/home/bvandepo/Téléchargements/arduino-1.8.13/hardware/tools/avr -prefs=runtime.tools.avr-gcc.path=/home/bvandepo/Téléchargements/arduino-1.8.13/hardware/tools/avr -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=/home/bvandepo/Téléchargements/arduino-1.8.13/hardware/tools/avr -verbose /home/bvandepo/Arduino/cesi1/cesi1.ino Using board 'uno' from platform in folder: /home/bvandepo/Téléchargements/arduino-1.8.13/hardware/arduino/avr Using core 'arduino' from platform in folder: /home/bvandepo/Téléchargements/arduino-1.8.13/hardware/arduino/avr Detecting libraries used… /home/bvandepo/Téléchargements/arduino-1.8.13/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/home/bvandepo/Téléchargements/arduino-1.8.13/hardware/arduino/avr/cores/arduino -I/home/bvandepo/Téléchargements/arduino-1.8.13/hardware/arduino/avr/variants/standard /tmp/arduino_build_319925/sketch/cesi1.ino.cpp -o /dev/null -DARDUINO_LIB_DISCOVERY_PHASE Alternatives for Wire.h: [Wire@1.0] ResolveLibrary(Wire.h)

  1. > candidates: [Wire@1.0]

/home/bvandepo/Téléchargements/arduino-1.8.13/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/home/bvandepo/Téléchargements/arduino-1.8.13/hardware/arduino/avr/cores/arduino -I/home/bvandepo/Téléchargements/arduino-1.8.13/hardware/arduino/avr/variants/standard -I/home/bvandepo/Téléchargements/arduino-1.8.13/hardware/arduino/avr/libraries/Wire/src /tmp/arduino_build_319925/sketch/cesi1.ino.cpp -o /dev/null -DARDUINO_LIB_DISCOVERY_PHASE Using cached library dependencies for file: /home/bvandepo/Téléchargements/arduino-1.8.13/hardware/arduino/avr/libraries/Wire/src/Wire.cpp Using cached library dependencies for file: /home/bvandepo/Téléchargements/arduino-1.8.13/hardware/arduino/avr/libraries/Wire/src/utility/twi.c Generating function prototypes… /home/bvandepo/Téléchargements/arduino-1.8.13/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/home/bvandepo/Téléchargements/arduino-1.8.13/hardware/arduino/avr/cores/arduino -I/home/bvandepo/Téléchargements/arduino-1.8.13/hardware/arduino/avr/variants/standard -I/home/bvandepo/Téléchargements/arduino-1.8.13/hardware/arduino/avr/libraries/Wire/src /tmp/arduino_build_319925/sketch/cesi1.ino.cpp -o /tmp/arduino_build_319925/preproc/ctags_target_for_gcc_minus_e.cpp -DARDUINO_LIB_DISCOVERY_PHASE /home/bvandepo/Téléchargements/arduino-1.8.13/tools-builder/ctags/5.8-arduino11/ctags -u –language-force=c++ -f - –c++-kinds=svpf –fields=KSTtzns –line-directives /tmp/arduino_build_319925/preproc/ctags_target_for_gcc_minus_e.cpp Compilation du croquis… /home/bvandepo/Téléchargements/arduino-1.8.13/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/home/bvandepo/Téléchargements/arduino-1.8.13/hardware/arduino/avr/cores/arduino -I/home/bvandepo/Téléchargements/arduino-1.8.13/hardware/arduino/avr/variants/standard -I/home/bvandepo/Téléchargements/arduino-1.8.13/hardware/arduino/avr/libraries/Wire/src /tmp/arduino_build_319925/sketch/cesi1.ino.cpp -o /tmp/arduino_build_319925/sketch/cesi1.ino.cpp.o Compiling libraries… Compiling library “Wire” Utilisation du fichier déjà compilé : /tmp/arduino_build_319925/libraries/Wire/Wire.cpp.o Utilisation du fichier déjà compilé : /tmp/arduino_build_319925/libraries/Wire/utility/twi.c.o Compiling core… Using precompiled core: /tmp/arduino_cache_377812/core/core_arduino_avr_uno_7c971292e96a0aa19cbc2b17540b3549.a Linking everything together… /home/bvandepo/Téléchargements/arduino-1.8.13/hardware/tools/avr/bin/avr-gcc -w -Os -g -flto -fuse-linker-plugin -Wl,–gc-sections -mmcu=atmega328p -o /tmp/arduino_build_319925/cesi1.ino.elf /tmp/arduino_build_319925/sketch/cesi1.ino.cpp.o /tmp/arduino_build_319925/libraries/Wire/Wire.cpp.o /tmp/arduino_build_319925/libraries/Wire/utility/twi.c.o /tmp/arduino_build_319925/../arduino_cache_377812/core/core_arduino_avr_uno_7c971292e96a0aa19cbc2b17540b3549.a -L/tmp/arduino_build_319925 -lm /home/bvandepo/Téléchargements/arduino-1.8.13/hardware/tools/avr/bin/avr-objcopy -O ihex -j .eeprom –set-section-flags=.eeprom=alloc,load –no-change-warnings –change-section-lma .eeprom=0 /tmp/arduino_build_319925/cesi1.ino.elf /tmp/arduino_build_319925/cesi1.ino.eep /home/bvandepo/Téléchargements/arduino-1.8.13/hardware/tools/avr/bin/avr-objcopy -O ihex -R .eeprom /tmp/arduino_build_319925/cesi1.ino.elf /tmp/arduino_build_319925/cesi1.ino.hex Utilisation de la bibliothèque Wire version 1.0 dans le dossier: /home/bvandepo/Téléchargements/arduino-1.8.13/hardware/arduino/avr/libraries/Wire /home/bvandepo/Téléchargements/arduino-1.8.13/hardware/tools/avr/bin/avr-size -A /tmp/arduino_build_319925/cesi1.ino.elf Le croquis utilise 4124 octets (12%) de l'espace de stockage de programmes. Le maximum est de 32256 octets. Les variables globales utilisent 410 octets (20%) de mémoire dynamique, ce qui laisse 1638 octets pour les variables locales. Le maximum est de 2048 octets. /home/bvandepo/Téléchargements/arduino-1.8.13/hardware/tools/avr/bin/avrdude -C/home/bvandepo/Téléchargements/arduino-1.8.13/hardware/tools/avr/etc/avrdude.conf -v -patmega328p -carduino -P/dev/ttyACM0 -b115200 -D -Uflash:w:/tmp/arduino_build_319925/cesi1.ino.hex:i


visual studio code maison en bas, import arduino project, choisir le dossier du sketch cocher use libraries installed by Arduino IDE Import CTRL+ALT+B

il faut avoir #include <Arduino.h>

“Building in release mode”

ajout de la génération du disassembly avec platformIO: https://www.youtube.com/watch?v=XtB2eWMf6Bw&ab_channel=EricPeronnin

fichier à charger et adapter les chemins: http://www.geii.eu/index.php?option=com_content&view=article&id=243&Itemid=953

asmdump.py à mettre dans le même dossier que /home/bvandepo/Documents/PlatformIO/Projects/211011-210535-uno/platformio.ini

asmdump.py
Import("env", "projenv")
# Ajout de l'option -g aux indicateurs du linker pour obtenir le code source dans le fichier elf.
env.Append(LINKFLAGS=["-g"])
 
# Ajout d'un outil dans le menu Custom de PIO
env.AddCustomTarget(
    "asm_dump",
    "$BUILD_DIR/${PROGNAME}.elf",
    "/home/bvandepo/.platformio/packages/toolchain-atmelavr/avr/bin/objdump -D -S $BUILD_DIR/${PROGNAME}.elf > $BUILD_DIR/${PROGNAME}.asm",
    "Dump ELF to ASM",
    "Dump de firmware.elf vers firmware.asm (source + ASM résultant de la compilation)."
)
 
# Fonction de call back pour extraire le code asm compilé avec le code source
def asmAvecSourceCB(source, target, env):
    print("Dump firmware.elf ...")
    env.Execute("/home/bvandepo/.platformio/packages/toolchain-atmelavr/avr/bin/objdump -D -S $BUILD_DIR/${PROGNAME}.elf > $BUILD_DIR/${PROGNAME}.asm")
    # do some actions
 
# Ajout d'une fonction de call back a exécuté lorsque le fichier firmware.elf est créé.
env.AddPostAction("$BUILD_DIR/${PROGNAME}.elf", asmAvecSourceCB)

note: on peut le faire de manière automatique via copie dans le dossier: ~/Documents/PlatformIO/Projects/211011-210535-uno/

ajouter à la fin de platformio.ini

extra_scripts = asmdump.py

note: on peut le faire de manière automatique via ajout dans le dossier: ~/Documents/PlatformIO/Projects/211011-210535-uno/

lors de l'import d'un projet arduino, platform io DUPLIQUE le fichier pour en faire un projet dans son arborescence propre /home/bvandepo/Documents/PlatformIO/Projects/211011-210535-uno/src/cesi1.ino

cliquer sur le fichier .ino puis CTRL+ALT+B le fichier firmware.asm apparai sous uno→src

ca fonctionne mais..

j'ai tenté de mettre la fonction Traitement dans une paire de fichiers .h/.cpp

bvandepo@rapid:~/Documents/PlatformIO/Projects/211011-210535-uno$ ll src
total 20
drwxrwxr-x 2 bvandepo bvandepo 4096 oct.  11 21:19 ./
drwxrwxr-x 8 bvandepo bvandepo 4096 oct.  11 21:23 ../
-rw-rw-r-- 1 bvandepo bvandepo 4219 oct.  11 21:18 cesi1.ino
-rw-rw-r-- 1 bvandepo bvandepo  263 oct.  11 21:18 traitement.cpp
bvandepo@rapid:~/Documents/PlatformIO/Projects/211011-210535-uno$ ll include/
total 16
drwxrwxr-x 2 bvandepo bvandepo 4096 oct.  11 21:17 ./
drwxrwxr-x 8 bvandepo bvandepo 4096 oct.  11 21:23 ../
-rw-rw-r-- 1 bvandepo bvandepo 1386 oct.  11 21:05 README
-rw-rw-r-- 1 bvandepo bvandepo   49 oct.  11 21:18 traitement.h

mais à cause de l'optimisation, la fonction est inlinée et n'apparait donc pas…

return (valeur+51)%4;
f5c:	68 2f       	mov	r22, r24
f5e:	70 e0       	ldi	r23, 0x00	; 0
f60:	6d 5c       	subi	r22, 0xCD	; 205
 f62:	7f 4f       	sbci	r23, 0xFF	; 255
f64:	63 70       	andi	r22, 0x03	; 3
f66:	77 27       	eor	r23, r23

mettre plutot des commentaires:

f1.cpp
  unsigned char TraiteDonnee(unsigned char valeur)
  {
  //début du code à tester
    return (valeur+51)%4;
  //fin du code à tester
  }

puis rechercher dans le fichier asm: la chaine début du code à tester

conversion binaire → ascii pour 0 à 9:

f2.cpp
unsigned char TraiteDonnee(unsigned char valeur)
{ 
//début du code à tester
 
//  __asm__("andi r24,0x0F\n\t"); 
//ne marche pas seul car le compilateur ne voit pas de return et l'optim dégage le code assembleur...
 
//https://ucexperiment.wordpress.com/2016/04/02/arduino-inline-assembly-tutorial-12-functions/
  //unsigned char len;
  asm (
    "andi %0, 0xf        \n     ori %0, 0x30        \n"    
    : "+r" (valeur) 
  );
  return valeur;
//fin du code à tester
}

TODO: voir si on peut desactiver l'optimisation de gcc…

Application ASM WS2812

WS2812.cpp
/*
* light weight WS2812 lib V2.1 - Arduino support
*
* Controls WS2811/WS2812/WS2812B RGB-LEDs
* Author: Matthias Riegler
*
* Mar 07 2014: Added Arduino and C++ Library
*
* September 6, 2014:	Added option to switch between most popular color orders
*						(RGB, GRB, and BRG) --  Windell H. Oskay
* 
* License: GNU GPL v2 (see License.txt)
*/
 
#include "WS2812.h"
#include <stdlib.h>
 
WS2812::WS2812(uint16_t num_leds) {
	count_led = num_leds;
 
	pixels = (uint8_t*)malloc(count_led*3);
	#ifdef RGB_ORDER_ON_RUNTIME	
		offsetGreen = 0;
		offsetRed = 1;
		offsetBlue = 2;
	#endif
}
 
cRGB WS2812::get_crgb_at(uint16_t index) {
 
	cRGB px_value;
 
	if(index < count_led) {
 
		uint16_t tmp;
		tmp = index * 3;
 
		px_value.r = pixels[OFFSET_R(tmp)];
		px_value.g = pixels[OFFSET_G(tmp)];
		px_value.b = pixels[OFFSET_B(tmp)];
	}
 
	return px_value;
}
 
uint8_t WS2812::set_crgb_at(uint16_t index, cRGB px_value) {
 
	if(index < count_led) {
 
		uint16_t tmp;
		tmp = index * 3;
 
		pixels[OFFSET_R(tmp)] = px_value.r;
		pixels[OFFSET_G(tmp)] = px_value.g;
		pixels[OFFSET_B(tmp)] = px_value.b;		
		return 0;
	} 
	return 1;
}
 
uint8_t WS2812::set_subpixel_at(uint16_t index, uint8_t offset, uint8_t px_value) {
	if (index < count_led) {
		uint16_t tmp;
		tmp = index * 3;
 
		pixels[tmp + offset] = px_value;
		return 0;
	}
	return 1;
}
 
void WS2812::sync() {
	*ws2812_port_reg |= pinMask; // Enable DDR
	ws2812_sendarray_mask(pixels,3*count_led,pinMask,(uint8_t*) ws2812_port,(uint8_t*) ws2812_port_reg );	
}
 
#ifdef RGB_ORDER_ON_RUNTIME	
void WS2812::setColorOrderGRB() { // Default color order
	offsetGreen = 0;
	offsetRed = 1;
	offsetBlue = 2;
}
 
void WS2812::setColorOrderRGB() {
	offsetRed = 0;
	offsetGreen = 1;
	offsetBlue = 2;
}
 
void WS2812::setColorOrderBRG() {
	offsetBlue = 0;
	offsetRed = 1;
	offsetGreen = 2;
}
#endif
 
WS2812::~WS2812() {
	free(pixels);
 
}
 
#ifndef ARDUINO
void WS2812::setOutput(const volatile uint8_t* port, volatile uint8_t* reg, uint8_t pin) {
	pinMask = (1<<pin);
	ws2812_port = port;
	ws2812_port_reg = reg;
}
#else
void WS2812::setOutput(uint8_t pin) {
	pinMask = digitalPinToBitMask(pin);
	ws2812_port = portOutputRegister(digitalPinToPort(pin));
	ws2812_port_reg = portModeRegister(digitalPinToPort(pin));
}
#endif 
light_ws2812.cpp
/*
* light weight WS2812 lib V2.1 - Arduino support
*
* Controls WS2811/WS2812/WS2812B RGB-LEDs
* Author: Tim (cpldcpu@gmail.com)
*
* Jan  18th, 2014  v2.0b Initial Version
* March 7th, 2014  v2.1  Added option to retarget the port register during runtime
*                        Removes inlining to allow compiling with c++
*
* License: GNU GPL v2 (see License.txt)
*/
 
#include "WS2812.h"
 
/*
  This routine writes an array of bytes with RGB values to the Dataout pin
  using the fast 800kHz clockless WS2811/2812 protocol.
*/
 
// Timing in ns
#define w_zeropulse   350
#define w_onepulse    900
#define w_totalperiod 1250
 
// Fixed cycles used by the inner loop
#define w_fixedlow    3
#define w_fixedhigh   6
#define w_fixedtotal  10   
 
// Insert NOPs to match the timing, if possible
#define w_zerocycles    (((F_CPU/1000)*w_zeropulse          )/1000000)
#define w_onecycles     (((F_CPU/1000)*w_onepulse    +500000)/1000000)
#define w_totalcycles   (((F_CPU/1000)*w_totalperiod +500000)/1000000)
 
// w1 - nops between rising edge and falling edge - low
#define w1 (w_zerocycles-w_fixedlow)
// w2   nops between fe low and fe high
#define w2 (w_onecycles-w_fixedhigh-w1)
// w3   nops to complete loop
#define w3 (w_totalcycles-w_fixedtotal-w1-w2)
 
#if w1>0
  #define w1_nops w1
#else
  #define w1_nops  0
#endif
 
// The only critical timing parameter is the minimum pulse length of the "0"
// Warn or throw error if this timing can not be met with current F_CPU settings.
#define w_lowtime ((w1_nops+w_fixedlow)*1000000)/(F_CPU/1000)
#if w_lowtime>550
   #error "Light_ws2812: Sorry, the clock speed is too low. Did you set F_CPU correctly?"
#elif w_lowtime>450
   #warning "Light_ws2812: The timing is critical and may only work on WS2812B, not on WS2812(S)."
   #warning "Please consider a higher clockspeed, if possible"
#endif   
 
#if w2>0
#define w2_nops w2
#else
#define w2_nops  0
#endif
 
#if w3>0
#define w3_nops w3
#else
#define w3_nops  0
#endif
 
#define w_nop1  "nop      \n\t"
#define w_nop2  "rjmp .+0 \n\t"
#define w_nop4  w_nop2 w_nop2
#define w_nop8  w_nop4 w_nop4
#define w_nop16 w_nop8 w_nop8
 
void  WS2812::ws2812_sendarray_mask(uint8_t *data,uint16_t datlen,uint8_t maskhi,uint8_t *port, uint8_t *portreg)
{
  uint8_t curbyte,ctr,masklo;
  uint8_t sreg_prev;
 
  masklo = ~maskhi & *port;
  maskhi |= *port;
  sreg_prev=SREG;
  cli();  
 
  while (datlen--) {
    curbyte=*data++;
 
    asm volatile(
    "       ldi   %0,8  \n\t"
    "loop%=:            \n\t"
    "       st    X,%3 \n\t"    //  '1' [02] '0' [02] - re
#if (w1_nops&1)
w_nop1
#endif
#if (w1_nops&2)
w_nop2
#endif
#if (w1_nops&4)
w_nop4
#endif
#if (w1_nops&8)
w_nop8
#endif
#if (w1_nops&16)
w_nop16
#endif
    "       sbrs  %1,7  \n\t"    //  '1' [04] '0' [03]
    "       st    X,%4 \n\t"     //  '1' [--] '0' [05] - fe-low
    "       lsl   %1    \n\t"    //  '1' [05] '0' [06]
#if (w2_nops&1)
  w_nop1
#endif
#if (w2_nops&2)
  w_nop2
#endif
#if (w2_nops&4)
  w_nop4
#endif
#if (w2_nops&8)
  w_nop8
#endif
#if (w2_nops&16)
  w_nop16 
#endif
    "       brcc skipone%= \n\t"    //  '1' [+1] '0' [+2] - 
    "       st   X,%4      \n\t"    //  '1' [+3] '0' [--] - fe-high
    "skipone%=:               "     //  '1' [+3] '0' [+2] - 
 
#if (w3_nops&1)
w_nop1
#endif
#if (w3_nops&2)
w_nop2
#endif
#if (w3_nops&4)
w_nop4
#endif
#if (w3_nops&8)
w_nop8
#endif
#if (w3_nops&16)
w_nop16
#endif
 
    "       dec   %0    \n\t"    //  '1' [+4] '0' [+3]
    "       brne  loop%=\n\t"    //  '1' [+5] '0' [+4]
    :	"=&d" (ctr)
//    :	"r" (curbyte), "I" (_SFR_IO_ADDR(ws2812_PORTREG)), "r" (maskhi), "r" (masklo)
    :	"r" (curbyte), "x" (port), "r" (maskhi), "r" (masklo)
    );
  }
 
  SREG=sreg_prev;
}
nouveaucesi.txt · Dernière modification: 2021/10/24 10:32 de bvandepo

Outils de la page