Outils pour utilisateurs

Outils du site


issue197:micro-ci_micro-la

Greetings yet again, my fellow beings. I come to you again, beaming across the Ether. For a few months now, I've been wanting to discuss a program called rshell written by Dave Hylands, or better known to the MicroPython community as dhylands. Back in 2015, he released the very first version of rshell to connect to the pyboard microcontroller. In his words “rshell allows you to copy files to and from the pyboard's file system, show the contents of files, and to use the repl.” There is a lot that this little program can do, and I use it off and on – mainly to do bulk file copies to and from my various Microcontrollers. So far, I've used it on ESP8266, ESP32, Wio Terminal and of course my RPi Pico/Pico-W boards. It's a really easy way to move files back and forth and you can do a whole lot more. So, let's look at rshell in the real world. First, you need to install it, and since it's written in Python, we can use pip/pip3. pip3 install rshell Once we have rshell installed, we'll use it to back up one of our Microcontrollers, in my case one of my RPi Pico-W boards.

Je vous salue une fois de plus, mes amis. Je viens à nouveau à vous, par l'intermédiaire de l'Ether.

Depuis quelques mois, j'ai envie de parler d'un programme appelé rshell écrit par Dave Hylands, mieux connu par la communauté MicroPython sous le nom de dhylands. En 2015, il a publié la toute première version de rshell pour se connecter au microcontrôleur pyboard. Selon lui, « rshell vous permet de copier des fichiers vers et depuis le système de fichiers du pyboard, d'afficher le contenu des fichiers et d'utiliser le repl. »

Ce petit programme peut faire beaucoup de choses, et je l'utilise de temps en temps - principalement pour faire des copies de fichiers en masse depuis et vers mes différents microcontrôleurs. Jusqu'à présent, je l'ai utilisé sur ESP8266, ESP32, Wio Terminal et, bien entendu, sur mes cartes RPi Pico/Pico-W. C'est un moyen très simple de déplacer des fichiers d'un côté à l'autre et vous pouvez faire bien d'autres choses avec aussi.

Regardons donc rshell dans le monde réel.

Tout d'abord, vous devez l'installer, et comme il est écrit en Python, nous pouvons utiliser pip/pip3.

pip3 install rshell

Une fois rshell installé, nous allons l'utiliser pour sauvegarder un de nos microcontrôleurs, dans mon cas une de mes cartes RPi Pico-W.

In a terminal (you can use the same one that you use to install rshell), you need to go to your Micropython backup folder. Don't have one yet? So make one. I have one for each of my main board types. In my case, it's on my desktop as “Pico-W”. I create a sub-folder each time I back up a board by date, and if I need to back up different boards on the same day, I create additional folders within that day's folder. Now, connect your board to your usb port and make sure you know where it is. Use ls /dev/tty* to find it. So, shown above, mine is on /dev/ttyACM0, which is where any of my RPi Pico boards almost always show up. Now startup rshell (shown below). Now we are connected. Let's verify what's on the Pico. Notice that rshell displays the root directory when you get connected, but I like to use the “ls” command just to verify. When you start up rshell, the microcontroller you are connected to is mounted as /pyboard. So we need to use the command ‘ls /pyboard’ (previous page, top).

Dans un terminal (vous pouvez utiliser le même que celui que vous avez utilisé pour installer rshell), vous devez aller dans votre dossier de sauvegarde Micropython. Vous n'en avez pas encore ? Alors faites-en un. J'en ai un pour chacun de mes principaux types de cartes. Dans mon cas, il se trouve sur mon bureau sous le nom de « Pico-W ». Je crée un sous-dossier chaque fois que je sauvegarde une carte par date, et si je dois sauvegarder plusieurs cartes le même jour, je crée des dossiers supplémentaires dans le dossier de ce jour.

Maintenant, connectez votre carte à votre port USB et assurez-vous de savoir où il se trouve. Utilisez

ls /dev/tty*

pour le trouver.

Ainsi, comme indiqué ci-dessus, le mien est sur /dev/ttyACM0, qui est l'endroit où toutes mes cartes RPi Pico apparaissent presque toujours.

Lancez maintenant rshell (voir ci-dessous).

Nous sommes maintenant connectés. Vérifions ce qu'il y a sur la carte Pico. Notez que rshell affiche le répertoire racine lorsque vous vous êtes connecté, mais j'aime utiliser la commande « ls » juste pour vérifier. Lorsque vous démarrez rshell, le microcontrôleur auquel vous êtes connecté est monté en tant que /pyboard. Nous devons donc utiliser la commande « ls /pyboard » (page précédente, en haut).

Now we are in the REPL shell. You can run Micropython commands directly from the shell, one line at a time. We’ll type in a short program that will allow us to toggle the onboard LED. »> from machine import Pin »> led = Pin(“LED”, Pin.OUT) »> led.toggle() »> led.toggle() »> To leave the REPL, type <Ctrl>X. »> ^X /home/greg/Desktop/Pico-W/backoffs/PicoW09092023> If you are not in the REPL, you can use cat to view the contents of a file (next page, bottom right). Now go back to the REPL and we can update the MicroPython version with the “latest and greatest” version. You have to download the newest version from the MicroPython.org site. The latest nightly build, as I'm writing this, is v1.20.0-450 built on 2023-09-06. Save it somewhere convenient and go back to the REPL in your terminal. You can use the REPL command “machine.bootloader()” to put the board into the bootloader mode. Note that your terminal might seem to “freak out”, but that’s normal. I’ve reformatted the terminal output for ease of viewing (top right).

Nous sommes maintenant dans le shell REPL. Vous pouvez exécuter des commandes Micropython directement depuis le shell, une ligne à la fois. Nous allons taper un petit programme qui nous permettra d'allumer la LED de la carte.

from machine import Pin
led = Pin(“LED”, Pin.OUT)
led.toggle()
led.toggle()

Pour quitter le REPL, tapez <Ctrl>X.

^X

/home/greg/Desktop/Pico-W/backoffs/PicoW09092023>.

Si vous n'êtes pas dans le REPL, vous pouvez utiliser cat pour voir le contenu d'un fichier (page suivante, en bas à droite).

Retournez maintenant dans le REPL et nous pouvons mettre à jour la version de MicroPython avec la version « latest and greatest » (la dernière et la meilleure). Vous devez télécharger la dernière version depuis le site MicroPython.org. La dernière « nightly build », au moment où j'écris ces lignes, est la v1.20.0-450 construite le 2023-09-06. Sauvegardez-la dans un endroit pratique et retournez dans le REPL dans votre terminal. Vous pouvez utiliser la commande REPL « machine.bootloader() » pour mettre la carte en mode bootloader. Notez que votre terminal peut sembler « flipper », mais c'est normal. J'ai reformaté la sortie du terminal pour en faciliter la visualisation (en haut à droite).

Once you have this, press <Enter> in the terminal and you will receive the original prompt again. serial port /dev/ttyACM0 closed /home/greg/Desktop/Pico-W/backoffs/picoW_sep06_2023> Then re-enter the REPL (middle right). That's it. You've successfully updated your MicroPython version without having to go through the normal “unplug | hold down the bootsel button | plug in” process. If you don't want to keep using “pyboard” as the name of your board, you can name your board whatever you wish. /home/greg/Desktop> echo 'name=“pico”' > /pyboard/board.py /home/greg/Desktop> You have to use <Ctrl>C to disconnect and then reconnect rshell to get this to take effect (next page, top right).

Une fois que vous l'avez fait, appuyez sur <Entrée> dans le terminal et vous obtiendrez à nouveau l'invite d'origine.

serial port /dev/ttyACM0 closed

/home/greg/Desktop/Pico-W/backoffs/picoW_sep06_2023>

Ensuite, entrez à nouveau dans le REPL (au milieu à droite).

Et le tour est joué. Vous avez réussi à mettre à jour votre version de MicroPython sans avoir à passer par le processus normal « débrancher | maintenir le bouton bootsel | brancher ».

Si vous ne voulez pas continuer à utiliser « pyboard » comme nom de votre carte, vous pouvez nommer votre carte comme vous le souhaitez.

/home/greg/Desktop> echo 'name=“pico”' > /pyboard/board.py

/home/greg/Desktop>

Il faut utiliser <Ctrl>C pour vous déconnecter, puis reconnectez rshell pour que cela prenne effet (page suivante, en haut à droite).

From now on (as long as the board.py file exists on the microcontroller), you can use “pico” to refer to the board instead of “pyboard”. What’s in the “magical” board.py file? Actually, very little. We’ll use cat to look at the file contents. /home/greg/Desktop/Pico-W/backoffs/PicoW09092023> cat /pico/board.py name=“pico” I prefer to keep the mount point at /pyboard, since I use rshell with my RPi Pico boards (both plain and W), my ESP8266 boards, my ESP32 boards, and my WIO terminal. Trying to remember to use a different board name each time is a bit beyond the capabilities of my old brain. If you need to edit a file on the microcontroller (now named pico in my case), you can use the command “edit /pico/{filename}”. We’ll try editing the ‘i2cscan.py’ file.

A partir de maintenant (tant que le fichier board.py existe sur le microcontrôleur), vous pouvez utiliser « pico » pour faire référence à la carte au lieu de « pyboard ».

Que contient le fichier « magique » board.py ? En fait, très peu de choses. Nous allons utiliser cat pour regarder le contenu du fichier.

/home/greg/Desktop/Pico-W/backoffs/PicoW09092023> cat /pico/board.py

name=“pico”

Je préfère garder le point de montage à /pyboard, car j'utilise rshell avec mes cartes RPi Pico (simples et W), mes cartes ESP8266, mes cartes ESP32, et mon terminal WIO. Essayer de se souvenir d'utiliser un nom de carte différent à chaque fois est un peu au-delà des capacités de mon vieux cerveau.

Si vous avez besoin d'éditer un fichier sur le microcontrôleur (maintenant nommé pico dans mon cas), vous pouvez utiliser la commande « edit /pico/{nom de fichier} ». Nous allons essayer d'éditer le fichier « i2cscan.py ».

We are now in a vim editor. Any changes that you want to save, press <esc> then “:wq”. If you didn’t make changes, you can exit by pressing <esc> then “:qa”. Finally, to quit rshell, use <Ctrl>C. That’s about it. You can go to the rshell github repository (https://github.com/dhylands/rshell) to find all the possible commands you can use. Until then, as always; stay safe, healthy, positive and creative!

Nous sommes maintenant dans un éditeur vim. Si vous souhaitez enregistrer des modifications, appuyez sur <esc> puis sur « :wq ». Si vous n'avez pas fait de changements, vous pouvez quitter en appuyant sur <esc> puis « :qa ».

Enfin, pour quitter rshell, utilisez <Ctrl>C.

C'est à peu près tout. Vous pouvez vous rendre sur le dépôt github de rshell (https://github.com/dhylands/rshell) pour trouver toutes les commandes possibles que vous pouvez utiliser.

En attendant, comme toujours, restez en sécurité, en bonne santé, positif et créatif !

texte en noir page 40

Now let's copy everything from the Pico into our empty folder on the desktop.

Copions maintenant tout ce qui se trouve sur le Pico dans notre dossier vide sur le bureau.

That’s it. A complete backup of our Pico device, in a few seconds, with a single command. Now, let’s say you want to delete everything from the Pico and start fresh.

C'est tout. Une sauvegarde complète de notre appareil Pico, en quelques secondes, avec une seule commande. Supposons maintenant que vous souhaitiez tout effacer dans le Pico et repartir à zéro.

To verify that we have wiped the filespace of the Pico, just do another ‘ls /pyboard’.

Pour vérifier que nous avons effacé le filespace du Pico, il suffit de faire un autre « ls /pyboard ».

Since our Pico has now been wiped, let’s push everything back.

Puisque notre Pico a été effacé, rechargeons tout.

texte en noir page 41

And verify that everything went back, do another ‘ls /pyboard’.

Et pour vérifier que tout est bien revenu, refaites un « ls /pyboard ».

Of course you can copy and delete more, by using the normal terminal commands. You can even do a ‘ls -al’ command to get the mount point listing in a single column view.

Bien sûr, vous pouvez copier et effacer plus, en utilisant les commandes normales du terminal. Vous pouvez même utiliser la commande « ls -al » pour obtenir la liste des points de montage en une seule colonne.

Now let's jump into the REPL. Type “repl” in your terminal

Maintenant, entrons dans le REPL. Tapez « repl » dans votre terminal

texte en noir page 43

Now let’s verify that the board isn’t mounted as pyboard anymore.

Vérifions maintenant que la carte n'est plus montée en tant que pyboard.

So let’s try doing a ‘ls /pico’.

Essayons de faire un « ls /pico ».

issue197/micro-ci_micro-la.txt · Dernière modification : 2023/10/02 09:57 de auntiee