From 469a3c60065b49c3858186b092b475ef1a07fe77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julie=C3=B1?= Date: Thu, 24 Apr 2025 16:30:26 +0200 Subject: [PATCH] Added Divers --- Desktop Arcade Machine/components.md | 8 ++ Desktop Arcade Machine/instructions.md | 81 +++++++++++++ Divers/Local AI.md | 43 +++++++ Divers/Rockchip RKNN.md | 156 +++++++++++++++++++++++++ 4 files changed, 288 insertions(+) create mode 100644 Desktop Arcade Machine/components.md create mode 100644 Desktop Arcade Machine/instructions.md create mode 100644 Divers/Local AI.md create mode 100644 Divers/Rockchip RKNN.md diff --git a/Desktop Arcade Machine/components.md b/Desktop Arcade Machine/components.md new file mode 100644 index 0000000..7d9e9c9 --- /dev/null +++ b/Desktop Arcade Machine/components.md @@ -0,0 +1,8 @@ +# Components + +
Qty + +ComponentInfos
1Raspberry Pi 3 Model B +
1Raspberry Pi 3 Power Supply - 5.1v 2.5AI bought the official Raspberry Pi 3 power supply. Tested some of the third party power supply, and even using high quality cables, it wiould still result in under voltage.
18" 1024x768 IPS HE080IA-01D LCD Display[https://www.aliexpress.com/](https://www.aliexpress.com/item/HDMI-VGA-AV-Control-Driver-Board-8-inch-HE080IA-01D-1024-768-IPS-high-definition-LCD/32325920866.html?spm=2114.13010608.0.0.SzvaUj)
1Arcade Joystick + Buttons Kit[https://www.aliexpress.com/](https://www.aliexpress.com/item/DIY-arcade-joystick-handle-set-kits-5-pin-24mm-30mm-push-buttons-spare-parts-USB-cable/32770679289.html?spm=2114.13010308.0.0.nqSdOB)
240mm 4ohm 3W speaker[https://www.aliexpress.com/](https://www.aliexpress.com/item/2pcs-Packs-4Ohm-3W-Full-range-Audio-Stereo-Speaker-40mm-Loudspeakers-Woofer-Speaker/32782192396.html?spm=2114.13010608.0.0.nlJkfT)
1PAM8403 5V digital amplifier board[https://www.aliexpress.com/](https://www.aliexpress.com/item/PAM8403-5V-Power-Audio-Amplifier-Board-2-Channel-3W-W-Volume-Control-Free-Shipping/32452488898.html?spm=2114.13010608.0.0.nlJkfT)
1Short 20cm HDMI Male to Male cable[https://www.aliexpress.com/](https://www.aliexpress.com/item/High-Speed-HDMI-Cable-Full-HD-Short-HDMI-Male-to-Male-Plug-Flat-Cable-Cord-Widely/32772823742.html?spm=2114.13010608.0.0.SzvaUj)
1Short 30cm USB 2.0 male to female extension cable[https://www.aliexpress.com/](https://www.aliexpress.com/item/30CM-USB-2-0-A-Male-to-USB2-0-A-Female-Extension-Molded-Panel-Mount-Extention/32573641881.html?spm=2114.13010608.0.0.nlJkfT)
1Heat Sinks for Raspberry Pi 3[https://www.aliexpress.com/](https://www.aliexpress.com/item/Free-shipping-5pcs-lot-heat-sink-for-A4988-A4983-Stepper-Driver/1833231480.html?spm=2114.13010608.0.0.SzvaUj)
6White LEDs +
6100 Ohms resistors +
1128GB SD CardYou can use a smaller card, but a bigger card allows you to dump in a lot more games.
1A4 Sized 0.5mm Thick Clear PVC SheetThis is used for the marquee - cut to size: 210 x 45 mm.
\ No newline at end of file diff --git a/Desktop Arcade Machine/instructions.md b/Desktop Arcade Machine/instructions.md new file mode 100644 index 0000000..f137008 --- /dev/null +++ b/Desktop Arcade Machine/instructions.md @@ -0,0 +1,81 @@ +# Instructions + +#### Step 1 + +3D print all the pieces. I used PLA for stiffness. All my 3D models were designed to be printed without the need for any support structures. You will need a 3D printer with a minimum print volume of 220mm x 220mm x 120mm in order to print these files. + +I should note that I actually designed and printed these parts \*before\* receiving the actual parts like the LCD screen, controller, speaker, amplifier etc. 3D printing takes quite a lot of time and I didn't want to wait till everything I ordered has arrived in the mail before I started printing. So, some of the parts were designed with some flexibility in terms of how it would be laid out. Also, this was a learning process for me as I am still relatively new to 3D printing, so some parts have gone through many changes as I experimented with the design. I believe all the files I uploaded should be correct, but in case there are any mistakes, do let me know. + +**Please understand that I am sharing these files AS IS. You do need to have a decent knowledge of 3D printing, Raspberry Pi, soldering, etc. in order to put it all together.** Any information that I did not include here, you will be able to Google it. + +Here are reference photos to give you a better idea of how all the pieces fit together. + +![8491071491295148170.png](https://cloud.delmar.bzh/apps/notes/notes/117455/attachment?path=images%2F8491071491295148170.png) +![8866051491285875547.png](https://cloud.delmar.bzh/apps/notes/notes/117455/attachment?path=images%2F8866051491285875547.png) +![4949511491285896855.png](https://cloud.delmar.bzh/apps/notes/notes/117455/attachment?path=images%2F4949511491285896855.png) +![3716051491285922699.png](https://cloud.delmar.bzh/apps/notes/notes/117455/attachment?path=images%2F3716051491285922699.png) +![8436331491285957957.png](https://cloud.delmar.bzh/apps/notes/notes/117455/attachment?path=images%2F8436331491285957957.png) +![1332461491286001545.png](https://cloud.delmar.bzh/apps/notes/notes/117455/attachment?path=images%2F1332461491286001545.png) +![7632211491286039479.png](https://cloud.delmar.bzh/apps/notes/notes/117455/attachment?path=images%2F7632211491286039479.png) +![2822801491286021738.png](https://cloud.delmar.bzh/apps/notes/notes/117455/attachment?path=images%2F2822801491286021738.png) +![3681801491286072749.png](https://cloud.delmar.bzh/apps/notes/notes/117455/attachment?path=images%2F3681801491286072749.png) +![2145881491286092738.png](https://cloud.delmar.bzh/apps/notes/notes/117455/attachment?path=images%2F2145881491286092738.png) +![4767131491286149765.png](https://cloud.delmar.bzh/apps/notes/notes/117455/attachment?path=images%2F4767131491286149765.png) + +##### Exploded views. + +![2138881491286174513.png](https://cloud.delmar.bzh/apps/notes/notes/117455/attachment?path=images%2F2138881491286174513.png) +![4779831491286197187.png](https://cloud.delmar.bzh/apps/notes/notes/117455/attachment?path=images%2F4779831491286197187.png) +![407391491286222781.png](https://cloud.delmar.bzh/apps/notes/notes/117455/attachment?path=images%2F407391491286222781.png) +![1959781491286273888.png](https://cloud.delmar.bzh/apps/notes/notes/117455/attachment?path=images%2F1959781491286273888.png) + +##### Completely assembled views. + +![4476891491286370618.png](https://cloud.delmar.bzh/apps/notes/notes/117455/attachment?path=images%2F4476891491286370618.png) +![4833821491286389026.png](https://cloud.delmar.bzh/apps/notes/notes/117455/attachment?path=images%2F4833821491286389026.png) + +Most of the main pieces are held together using nuts and bolts, or screws. You will need M3 bolts of various lengths (probably 10mm - 16mm) and some screws. I am afraid I lost the specs of the screw I used, but it's about 10mm long and 2.5mm diameter. These were use for the marquee pieces. + +I sprayed primer putty and sanded it down to a smooth finish before spraying matte black paint for the final finish. You want to make sure you sand the top edges of "Body - Front Left" and "Body - Front Right" so that they are nice and smooth, cause otherwise, when you rest your hands on them, the sharp edges will get irritating quite quickly. + +In order to make it look like a commercial quality product, I did a lot of research into the designs of the artwork for old arcade machines. I took inspiration from them to create my own artwork for my arcade machine and had it commercially printed on vinyl stickers. + +**Connecting Everything Together** + +- The controller's USB connector will plug into the Raspberry Pi's USB socket. +- The power connecter for the display will plug into the Raspberry Pi's USB socket. +- The HDMI out on the Raspberry Pi needs to be connected to the HDMI input on the display controller board. +- The speaker needs to be soldered to the amplifier circuit, and the amplfier circuit's power input needs to the connected to the Raspberry Pi's GPIO pin 4 & 6 for the 5V power supply. You also need to solder an earphone jack connector to the amplifier circuit and plug that into the Raspberry Pi's audio socket. +- Solder together the LEDs and wire it to a USB connector. Plug it into the Raspberry Pi's USB socket. + +So, everything is powered directly from the Raspberry Pi. The only cable going into the arcade machine is the Raspberry Pi's power supply cable. + +**Software Setup** + +You will need to get RetroPie setup and configured. For that, please check out RetroPie's website ([https://retropie.org.uk](https://retropie.org.uk/)) and Google for anything you need. All the resources you need are out there! + +#### Step 2 + +**Display Issue Fix** + +The first time you try to power up the full setup, make sure to power the display from a SEPARATE USB power supply FIRST, before turning on your RPi. The display needs to be active first, otherwise your RPi would not use HDMI for display. Also, connect a keyboard to your RPi. + +After powering up your Raspberry Pi, let it boot up all the way until Emulation Station/Attract Mode comes up (depending on your setup). **Exit** to terminal. + +Open the Raspberry Pi configuration file for editing with this command: + +```bash +sudo vim /boot/config.txt +``` + +Use arrows to get to the end of the file and add these 3 lines: + +**\#Always force HDMI output and enable HDMI sound** + +``` +hdmi_force_hotplug=1 + +hdmi_drive=2 +``` + +Now you can turn everything off, reconnect your display's power supply to RPi's USB socket. Now when you turn it on, your RPi will default to HDMI output even though the screen is powering up later than your RPi. \ No newline at end of file diff --git a/Divers/Local AI.md b/Divers/Local AI.md new file mode 100644 index 0000000..88c0c22 --- /dev/null +++ b/Divers/Local AI.md @@ -0,0 +1,43 @@ +# LocalAI + +``` +sudo mkdir -p /mnt/data/localai +``` + +```bash +cd /mnt/data + +git clone https://github.com/go-skynet/LocalAI + +cd LocalAI + +# (optional) Checkout a specific LocalAI tag +# git checkout -b build + +# copy your models to models/ +wget https://gpt4all.io/models/ggml-gpt4all-j.bin -O models/ggml-gpt4all-j + +# cp your-model.bin models/ + +# Use a template from the examples +cp -rf prompt-templates/ggml-gpt4all-j.tmpl models/ + +# (optional) Edit the .env file to set things like context size and threads +# vim .env + +docker-compose up -d --build + +# Now API is accessible at localhost:8080 +curl http://localhost:8080/v1/models +# {"object":"list","data":[{"id":"ggml-gpt4all-j","object":"model"}]} + +curl http://localhost:8080/v1/chat/completions -H "Content-Type: application/json" -d '{ + "model": "ggml-gpt4all-j", + "messages": [{"role": "user", "content": "How are you?"}], + "temperature": 0.9 + }' + +# {"model":"ggml-gpt4all-j","choices":[{"message":{"role":"assistant","content":"I'm doing well, thanks. How about you?"}}]} +``` + +[https://localai.io](https://localai.io "https://localai.io") \ No newline at end of file diff --git a/Divers/Rockchip RKNN.md b/Divers/Rockchip RKNN.md new file mode 100644 index 0000000..65610d3 --- /dev/null +++ b/Divers/Rockchip RKNN.md @@ -0,0 +1,156 @@ +# Rockchip RKNN + +#### Conda + +> [https://docs.conda.io/projects/miniconda/en/latest/](https://docs.conda.io/projects/miniconda/en/latest/ "https://docs.conda.io/projects/miniconda/en/latest/") + +``` +mkdir -p ~/miniconda3 +wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-aarch64.sh -O ~/miniconda3/miniconda.sh +bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3 +rm -rf ~/miniconda3/miniconda.sh +``` + +> After install : + +``` +~/miniconda3/bin/conda init bash +~/miniconda3/bin/conda init zsh +``` + +### Rockchip toolkit + +> [https://github.com/rockchip-linux/rknn-toolkit2](https://github.com/rockchip-linux/rknn-toolkit2 "https://github.com/rockchip-linux/rknn-toolkit2") + +``` +sudo apt-get install libxslt1-dev zlib1g zlib1g-dev libglib2.0-0 \ +libsm6 libgl1-mesa-glx libprotobuf-dev gcc g++ + +# Create a new environment +conda create -n rknn2 python=3.9 +conda activate rknn2 + +# RKNN-Toolkit2 has a specific dependency on numpy +pip install numpy==1.16.6 + +# Install rknn_toolkit2-1.6.0+81f21f4d-cp39-cp39-linux_x86_64.whl +cd ~/rknn-toolkit2/rknn-toolkit2/packages/ +pip install rknn_toolkit2-1.6.0+81f21f4d-cp39-cp39-linux_x86_64.whl +``` + +---------- + +# RKNN + +##### Installing RKNN LLM and RKNN Toolkit 2 + +Réf. : [https://github.com/Pelochus/ezrknpu](https://github.com/Pelochus/ezrknpu) + +```bash +sudo apt install cmake g++ make libgl1 libglx-mesa0 -y + +cd /mnt/data +sudo curl https://raw.githubusercontent.com/Pelochus/ezrknpu/main/install.sh | sudo bash +``` + +##### Test run + +```bash +GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/Pelochus/qwen-1_8B-rk3588 # Running git lfs pull after is usually better +cd qwen-1_8B-rk3588 && git lfs pull # Pull model +rkllm qwen-chat-1_8B.rkllm # Run! +``` + +--- + +##### Installation of Miniforge3 + +```bash +wget -c https://github.com/conda-forge/miniforge/releases/download/24.9.0-0/Miniforge3-24.9.0-0-Linux-aarch64.sh + +chmod 777 Miniforge3-24.9.0-0-Linux-aarch64.sh + +bash Miniforge3-24.9.0-0-Linux-aarch64.sh +``` + +##### Create RKLLM-Toolkit Conda Environment + +```bash +source ~/miniforge3/bin/activate + +conda create -n RKLLM-Toolkit python=3.8 + +# +# To activate this environment, use +# +# $ conda activate RKLLM-Toolkit +# +# To deactivate an active environment, use +# +# $ conda deactivate + +conda activate RKLLM-Toolkit +``` + +##### Install RKLLM-Toolkit + +```bash +pip3 install rkllm_toolkit-x.x.x-cp38-cp38-linux_x86_64.whl +``` + +##### Install OpenCL + +Download the ARM Mali GPU blob from rockchip's repository and put it into /usr/lib/ as follows. And install the firmware for the GPU if not already installed. + +```bash +cd /usr/lib && sudo wget https://github.com/JeffyCN/mirrors/raw/libmali/lib/aarch64-linux-gnu/libmali-valhall-g610-g6p0-x11-wayland-gbm.so +cd /lib/firmware && sudo wget https://github.com/JeffyCN/mirrors/raw/libmali/firmware/g610/mali_csffw.bin +``` + +Add the Mali GPU blob to the OpenCL ICD config file as follows; + +``` +sudo apt install mesa-opencl-icd clinfo +``` + +On Ubuntu, you may get not found errors, especially huawei links. Ignore them. It looks OK. Proceed with the followings; + +```bash +sudo mkdir -p /etc/OpenCL/vendors +echo "/usr/lib/libmali-valhall-g610-g6p0-x11-wayland-gbm.so" | sudo tee /etc/OpenCL/vendors/mali.icd +``` + +Set the dependencies of the Mali OpenCL as follows; + +```bash +sudo apt install libxcb-dri2-0 libxcb-dri3-0 libwayland-client0 libwayland-server0 libx11-xcb1 +``` + +Now you can run "clinfo" to check whether OpenCL is working. + +```bash +clinfo... +``` + +Check whether some dependencies are missing using ldd command as follows; + +``` +ldd /usr/lib/libmali-valhall-g610-g6p0-x11-wayland-gbm.so +``` + +Create Symbolic Link for libOpenCL.so + +The directory "/usr/lib/aarch64-linux-gnu/" will have "libOpenCL.so.1.0.0". But no "libOpenCL.so" file. In this case, create a symbolic link as follows. You need to log into root account to create this, say, "su -"; + +```bash +cd /usr/lib/aarch64-linux-gnu/ && sudo ln -s libOpenCL.so.1.0.0 libOpenCL.so +``` + +Copying OpenCL "CL" Folder into "/usr/include" + +```bash +cd ~/ && wget https://www.roselladb.com/download/CLv3.zip +unzip CLv3.zip +sudo cp -r CL /usr/include +sudo reboot +```