Monthly Archives: May 2025

A RISC-V Operating System Instruction Manual

estimated reading time: 1 min

To some, an operating system is a burden or waste of resources, like those working on embedded systems and other low-power applications. To others it’s necessary, abstracting away hardware so that higher-level programming can be done. For most people it’s perhaps not thought of at all. But for a few, the operating system is the most interesting piece of software running on a computer and if you’d like to investigate what makes this often overlooked aspect of computer science interesting, take a look at this course on operating systems from Cornell University.

The operating system itself is called Earth and Grass Operating System because it splits the functionality of the operating system into three separate parts. The Earth layer involves dealing with hardware, the Grass layer involves hardware-independent aspects, and a third application layer implements other key operating system features. It’s built for a RISC-V processor, since that instruction set is completely open source and transparent about what it’s doing. It’s also incredibly small, coming in at around 2000 lines of code. The course covers nine areas, with the first six being core operating system functions and the remaining three covering more advanced operating system concepts.

For understanding the intricacies and sometimes mysterious ways that operating systems work, a course like this can go a long way into unraveling those mysteries and developing a deeper understanding of how it brings the hardware to work for higher-level software. We actually featured this operating system two years ago, before this course was created, which covers this project for those who like to take a more self-directed approach, or simply want a lightweight OS for a RISC-V system.

from wallabag — all feed https://ift.tt/Qebro9I

Reverse Engineering LEGO Island

estimated reading time: 2 min

While LEGO themed video games have become something of a staple, in 1997 they were something of an odity. LEGO Island became the first LEGO video game released outside of Japan in 1997 and become something of a hit with over one million copies sold. The game was beloved among fans and set the stage for more LEGO video games to come. In an effort of love, [MattKC] put together a team to reverse engineer the game.

The team set out with the intent to create a near perfect recreation of the codebase, relying on custom made tools to run byte checks on the rewrite compilation and the original binary. While the project is functionally complete, [MattKC] believes it is impossible to get a byte accurate codebase. This is because of what the team called “compiler entropy.” Strange behaviors exists inside of Microsoft’s Visual C++ compiler of the era, and small changes in the code have seemingly random effects to unrelated parts of the binary. To mitigate this issue would likely require either partially reverse engineering Visual C++ or brute forcing the code, both of which would take a large amount of effort and time for no real benefit.

Another interesting step the team had to work out was how the game handled graphics. In the version of Direct X used, the developers could chose between immediate mode and retained mode. The difference largely boils down to how models and assets are handled. In immediate mode, Direct X is largely just a render engine and everything else is handled by the developer. With retained mode, Direct X works more similarly to a game engine where all the model and asset management is handled by Direct X. Almost all developers ended up using immediate mode to the point that Microsoft deprecated support for retained mode. For this reason, if you were to download and run LEGO island on a modern Windows PC, it would yell at you for not having the proper libraries. There is debate about how best to handle this moving forward. The team could rely on an unsupported library from Microsoft, reverse engineer that library only making the functions needed, or using leaked source code.

With the completion of the reverse engineering, engineering can commence. For example, an annoying and persistent bug caused the game to crash if you tried to exit. While it was effective in closing the game, it also caused progress to be lost. That particular bug was fixed simply by initializing a variable in the game’s fronted. Interestingly, that bug was not present in the late betas of the game that had been dug up from the depths of the internet leading to questions as to why a rewrite of the fronted was necessary so late in the development. Now efforts are commencing to port the game to other platforms which bring with it fresh headaches including rewriting for OpenGL and the balance of keeping a historically accurate game with the needs of modern development.

from wallabag — all feed https://ift.tt/ANGM9OQ

Cute Tamagotchi Cow

estimated reading time: 2 min

Supplies

  1. ESP32 CYD (cheap yellow display) (2432S028R)
  2. suitable power source / power bank
  3. 3D printed parts. or some wood for the barn

or

  1. wood / plywood and color
  1. Arduino IDE software

(Basic experience with Arduino is required)

Step 1: The Cow Graphics

For our cow, we need a stage/barn with a feeding station and water trough, each of which displays different levels.

The cow should

  1. stand, smile, chew, look sad
  2. eat, drink
  3. lying down ruminating , smile, sleep

These images are stored as code on an extra file named “cow-all.h” and loaded when needed.

The images are self made, you are free to use them.

Step 2: The Cow Software

The CYD is a fantastic combination of ESP32 and Touchschreeen. It saves you the annoying soldering and cables.

My programming is admittedly a bit amateurish. You can certainly get more out of the CYD in terms of design or give the cow more functions. But at least the program steps are easy to follow.

The library can be used to simulate a wide variety of working surfaces. We don’t show a background, but concentrate on the cow, watering place and feeding place. Three click areas are integrated in a hidden manner, i.e. they are not visible but can be clicked in three places: Water and feed place for refilling and the cow itself for stroking.

The cow’s status is (soon) saved on the ESP32 so that the device can be switched off at any time and you keep the food/mood status.

The values of hunger and thirst change randomly. The ESP32 counts the milliseconds. These values can be set according to your personal preferences.

The file “cow-all.h” contains all the different cow images in code and must be stored in the same folder as “demo.ino” or “tamagotchi_cow.ino”!

Attachments

Step 3: Speaker and LDR Sensor

The speaker for ‘Mooh’ is optional. Unfortunately, I have not yet been able to get the sound function to work without complications with the screen. Every time the SD card is online the touchscreen is not working properly. Any idea?

The mp3 file(s) could be saved on the SD card. The connection pins are on the back of the CYD. I got the speaker from an old fixed line telephone.

The built-in LDR sensor (GPIO 34) tells the cow when to sleep. When it is dark, she lies down. During this time, water and food are not consumed.

Attachments

Step 4: The Barn

For the ambience, I quickly designed a stable with tinkercad.com and turned it into reality with the 3D printer. Of course, you can also build a wonderful miniature stable out of wood here. Don’t forget good ventilation at the back side.

Hay_Barn

Attachments

Step 5: Moooh

Function:

The cow eats and drinks when its internal water and feed levels drop (= hunger, thirst). If the water or feed container is empty, the cow is hungry, unhappy and mooing.

If you tap on water or feed, the supplies are replenished and the cow can eat. If you tap on the cow (= stroking), it is also happy and moos comfortably.

When the LDR notices darkness the cow is going to sleep. She does not eat and does not develop much hunger or thirst.

Have fun with your new pet!

from wallabag — all feed https://ift.tt/vS3d0Wc

Comptine-moi Le Monde ! Une Boite À Comptines Multiculturelles !

estimated reading time: 8 min

Supplies

Électronique

  1. 2x Tang Bang T1-1931S 3W Speaker
  2. 1x DFRobot DFPlayer Pro
  3. 1x DFRobot Dreamer Nano 4.0 ou tout type de carte arduino avec au moins 12 entrées numériques et 2 entrées analogiques
  4. 1x DFRobot AA Boost Module ou une batterie usb ou un transformateur usb
  5. 12x Boutons de bornes d’arcade 22mm
  6. 1x Embase jack 3,5mm
  7. 2x Piles AA 1,5V rechargeable
  8. Fil électrique

Mécanique

  1. Vis M4 x 10mm
  2. Insert M4
  3. Vis nylon M3 x 10mm

Consommables

  1. 40cm x 25cm de contreplaqué 5mm
  2. 1kg de filament impression 3D
  3. Colle époxy
  4. Colle contact
  5. (Papier à poncer grain 500)
  6. (huile minérale)

Matériel

  1. Soudure : Fer à souder / etain / pince coupante …
  2. Serres-joints / pinces

Step 1: Présentation Technique Du Projet

Le DFPlayer Pro sert à lire les fichiers sons, à partir d’une mémoire interne accessible via le port USB C de la carte.

Le DFRuino Nano gere l’interface entre les boutons et le DFPlayer, il y a donc les 12 boutons d’arcade, le potentiomètre de volume ainsi que le switch situé sur la prise jack permettant de couper les haut-parleurs quand on branche un casque.

Les deux haut-parleurs ont une puissance de 3W et sont dans une boite fermée avec radiateur passif, permettant une bonne restitution des fréquences grave et medium avec une faible puissance audio.

Le AA Boost module est un module qui regroupe :

  1. un porte pile pour deux piles AA
  2. un boost converter permettant de passer de 1,5V à 5V
  3. un switch on/off
  4. deux leds permettant d’afficher le niveau des piles

Step 2: Impression 3D Du Boitier

Le boitier a été conçu afin de pouvoir être imprimer sur une Bambulap P1P et donc sur une imprimante avec un plateau de taille standard (25cm x 25cm).

Le boitier comporte 3 parties :

  1. le boitier central qui accueille les boutons et l’électronique
  2. les deux “oreilles” pour accueillir les haut-parleurs 3W

A cela, s’ajoutent les éléments périphériques :

  1. cache piles
  2. bouton de volume
  3. prise casque

Les différents éléments ont été imprimés avec un filament PLA PolyTerra en privilégiant la solidité des périmètres (env. 2mm) et un remplissage de 40%.

L’impression 3D de l’ensemble des éléments prends environ 2 x 7h sur une imprimante Bambulab P1P.

Attachments

Step 3: Collage Du Boitier

Les 3 parties du boitier sont collés avec de la colle époxy bi-composant

Un serre-joint et des pinces permettent de maintenir l’ensemble en place pendant le collage

Step 4: Pose Des Inserts

Le boitier comprends 8 inserts M4 à poser, 4 pour visser la face avant et 2 par hauts-parleurs.

Les inserts M4 sont posés à l’aide d’un fer à souder dans les trous prévus à cet effet.

Step 5: Compartiment Des Piles

La trappe pour les piles, située derrière le boitier est cachée grâce à un couvercle fixé à l’aide d’aimants ronds de 5mm x 1mm. Les 8 aimants sont collés avec de la colle contact.

La carte DFRobot AA Boost module dispose de deux trous de fixation. Afin de fixer la carte de manière à ne pas l’abimer en retirant les piles, il est nécessaire de percer un troisième trou en bas de la carte et de reporter ce trou dans la trappe de pile.

La carte DFRobot AA Boost est fixée à l’aide de 3 vis nylon, afin de ne pas créer de faux-contacts entre les deux faces de la carte percée.

Step 6: Finition

Pour obtenir un rendu lisse et sans artefacts d’impression 3D, le boitier est poncés à l’aide de papier grain 500 et d’huile minérale afin d’éviter de blanchir le PLA.

Pour ma part j’ai utilisé de l’huile pour moule silicone, mais je penses que toute les huiles minérales transparentes et desodorisé font l’affaire.

Step 7: Face De La Boite À Comptine

La face avant est découpée au laser dans du contreplaqué de peuplier de 5mm.

Avant la découpe, il est judicieux de faire un test de gravure ainsi qu’un test de perçage pour avoir le bon ajustement des boutons.

Noir : gravure

Rouge : découpe

Pour la finition, j’ai poncé la face avant avec du papier grain 120 puis grain 500.

La prise casque est collée avec de la colle contact (cyanoacrylate).

Les trous pour les boutons sont conçu pour permettre un assemblage “en force”

Attachments

Step 8: Electronique

1.Carte électronique

La carte électronique, réalisé sur perfboard se compose d’un DFPlayer Pro et d’un DFRuino Nano.

Le câblage “interne” de la carte est réalisé avec du câble à wrapper de 0,6mm

[AJOUTER PHOTO CARTE]

2.Câblage

Le câblage des boutons et des haut-parleurs est réalisés avec du câble silicone

Notes

  1. Vue le nombre de ports présents sur la carte, il n’a pas été jugé nécessaire de câbler le boutons poussoirs en matrice, de plus cela aurait complexifié le code et le câblage.
  2. Le switch entre le casque et les haut-parleurs se fait de manière un peu “bricolé” on mesure la tension de la prise casque avec l’entrée A1, le switch est relié à VREF. Quand on connecte la prise jack, cela deconnecte le switch de la prise casque. La tension mesurée sur A1 devient inférieur à VREF et on peut donc couper les haut-parleurs.

Step 9: Programmation De La Carte

La carte Leonardo est programmé avec l’IDE Arduino.

Le code est assez simple, car il se compose de plusieurs exemples connus et librairies arduino :

  1. La librairie DFRobot_DF1201S pour commander le DFPlayer Pro en série via le port UART
  2. Un debounce des boutons poussoirs avec la librarie Bounce2
  3. Une fonction smooth permettant de lisser les valeurs du bouton de volume

Le code s’initialise avec plusieurs constantes et variables :

  1. buttonPin : les pins associés au 12 boutons sont scannés afin de voir si ils sont appuyés
  2. lastDebounceTime et debounceDelay : le temps depuis lequel le bouton a été appuyé est stocké dans un tableau afin de faire un debounce
  3. volumePin et mutePin : les pins A0 et A1 où sont connectés le bouton de volume et le switch de la prise casque
  4. lastIndexPlayed : dernier bouton joué, ce qui permet de mettre en pause en cas d’appuie sur le même bouton

Afin de ne pas trop pousser l’amplificateur du DFPlayerPro dans ses retranchements, le volume maximum est réduit par rapport à ce qu’il est possible par la librairie. Cela permet de ne pas aller à la saturation de l’amplificateur, ce qui est courant sur les amplificateurs 3W de class D où la puissance maximale est souvent donnée pour un THD (saturation) de 10%.

Le souci majeur rencontré avec la programmation de la boite à comptine a été le delai du lancement d’une comptine due à la fonction DF1201S.isPlaying(). Cette fonction est utilisée afin de pouvoir arrêter la lecture si une comptine est en train d’être lue.

Contrairement au DFPlayer “classique” le DFPlayerPro ne présente pas de pin “busy” permettant de savoir s’il y a une lecture en cours. Il a fallu donc passer par la fonction logicielle DF1201S.isPlaying().

La fonction n’est d’ailleurs pas présente dans la documentation de base de la carte, notamment car c’est une fonctionnalité ajouté à posteriori. Un delai de 2000ms est ajouté dans la fonction isPlaying() car celle-ci repose sur l’usage de DF1201S.getCurTime(), qui donne le temps de lecture en seconde (et non en miliseconde).

Cette méthode pose deux problèmes :

  1. un délai de 2s au lancement de chaque son
  2. la fonction est bloquante, ce qui met en pause l’exécution du programme

Afin de corriger cela, nous avons programmé une nouvelle version de la fonction DF1201S.isPlaying() qui teste en continu si le DFPlayer Pro est en lecture ou en pause. Ainsi la fonction isPlaying mesure toute les secondes si la lecture d’un fichier est en cours, et stocke cet état dans la variable booléenne isPlayingFlag.

// Rewritting of the isPlaying fonction of DFPlayer Pro lib making it non-blocking and changing the delay to 1s

bool isPlaying() {

if (!startMeasure) {

lastMeasure = DF1201S.getCurTime();

startMeasure = true;

isPlayingElapsedMillis = 0;

}

if (isPlayingElapsedMillis > 1000) {

uint16_t newMeasure = DF1201S.getCurTime();

if (newMeasure – lastMeasure != 0) {

isPlayingFlag = true;

} else {

isPlayingFlag = false;

}

startMeasure = false;

}

}

Une amélioration possible du programme serait de passer directement en UART afin de voir s’il est possible d’avoir le temps de lecture en milliseconde, ce qui permettrait de réduire de délai de la fonction isPlaying().

Attachments

Step 10: Importation Des Sons

Les sons sont importés en connectant le DFPlayer Pro à l’ordinateur via un cable USB C.

Important : Il est conseillé de ne pas alimenter la boite à comptine lors de la connexion du DFPlayer Pro à l’ordinateur.

Lors que le module est connecté à l’ordinateur, il se comporte comme une clé USB et apparaît dans l’explorateur de fichier sous le nom PLAYER.

Pour importer les sons :

  1. Créer un dossier “sons” dans le DFPlayer
  2. Renommer les sons selon le numéro du bouton sur lequel ils doivent être joués
  3. Exemple pour le 1er bouton, le son doit se nommer 1.mp3
  4. Importer les sons en .mp3 dans le dossier “sons”

Step 11: Note De Fin

A la suite de la réalisation de ce projet, j’ai pu entrevoir plusieurs amélioration ou suite possible.

D’un point de vue technique, le délai au lancement d’une comptine pourrait être réduit soit par une modification de la librairie de la carte, soit en faisant l’impasse sur la mise en pause de la comptine. Le son est assez satisfaisant au vue des contraintes d’espaces et l’alimentation sur batterie. Quand le son est poussé au maximum, il y a une légère saturation, qui est sûrement du à l’amplificateur de qualité moyenne de la carte ainsi qu’à la vibration du boitier.

Pour ce qui est du design, bien que ça ne soit ici pas le public visé il serait intéressant de travailler sur l’inclusivité de la boite à comptine, notamment auprès d’un public malvoyant en y intégrant des boutons imptimés en 3D pour en facilité l’usage.

Remerciement :

Olivier Schmitt (Médiateur numérique – Bibliothèque Villejean)

Tony Vanpoucke (Fabmanager – Université Rennes 2)

Baptiste Cognec (Stage de Master 2 Création Numérique)

from wallabag — all feed https://ift.tt/cwR8bQt

This Smart Coffee Table Display Real-Time Traffic Conditions

Is there anything worse than getting on the highway for your morning commute, just to find that traffic is worse than usual due to an accident or a light drizzle? If you’re late one more time, your boss is probably going to write you up! One solution is to wake up early and start your commute earl

from Pocket
via Did you enjoy this article? Then read the full version from the author’s website.