mirror of
https://github.com/sipeed/NanoKVM.git
synced 2026-09-11 00:22:56 -05:00
Merge branch 'main' into 20250227/Draggable
This commit is contained in:
7
.gitignore
vendored
7
.gitignore
vendored
@@ -16,4 +16,9 @@ web/web
|
||||
.idea
|
||||
.vscode
|
||||
|
||||
NanoKVM-Server
|
||||
NanoKVM-Server
|
||||
|
||||
support/sg2002/kvm_system/build
|
||||
support/sg2002/kvm_system/dist
|
||||
support/sg2002/kvm_system/CMakeLists.txt
|
||||
|
||||
|
||||
25
README.md
25
README.md
@@ -20,6 +20,31 @@ English | [中文](./README_ZH.md) | [日本語](./README_JA.md)
|
||||
|
||||
## Opensource & Contribution
|
||||
|
||||
### 2025.03.04 Update Content
|
||||
+ Updated directory structure
|
||||
|
||||
``` shell
|
||||
├── kvmapp # APP update package
|
||||
│ ├── jpg_stream # Compatible for direct updates from very old versions
|
||||
│ ├── kvm_new_app # Triggers necessary components for kvm_system update
|
||||
│ ├── kvm_system # kvm_system application
|
||||
│ ├── server # NanoKVM front-end and back-end applications
|
||||
│ └── system # Necessary system components
|
||||
├── server # NanoKVM back-end
|
||||
├── support # Auxiliary functions (image subsystem, system status, system updates, screen, keys, etc.)
|
||||
│ ├── sg2002 # NanoKVM-Lite/Full/PCIe
|
||||
│ └── h618 # NanoKVM-Pro
|
||||
├── web # NanoKVM front-end
|
||||
├── LICENSE
|
||||
├── README_JA.md
|
||||
├── README.md
|
||||
├── README_ZH.md
|
||||
└── CHANGELOG.md
|
||||
```
|
||||
|
||||
+ Add NanoKVM app installation package `kvmapp`
|
||||
+ Add compilation scripts and compilation instructions
|
||||
|
||||
### Update 2025.02.19
|
||||
All components of NanoKVM were open-sourced, including the [front-end](https://github.com/sipeed/NanoKVM/tree/main/web), [back-end](https://github.com/sipeed/NanoKVM/tree/main/server), [kvm_vision](https://github.com/sipeed/NanoKVM/tree/main/vision/components/kvm), [kvm_mmf](https://github.com/sipeed/NanoKVM/tree/main/vision/components/kvm_mmf), [kvm_system](https://github.com/sipeed/NanoKVM/tree/main/support), the [kvmapp update package](https://github.com/sipeed/NanoKVM-System/tree/main/kvmapp), [system sdk](https://github.com/sipeed/LicheeRV-Nano-Build/tree/NanoKVM), and [packaging methods](https://github.com/sipeed/LicheeRV-Nano-Build/blob/NanoKVM/kvm/NanoKVM_img.sh).
|
||||
|
||||
|
||||
110
README_JA.md
110
README_JA.md
@@ -1,11 +1,13 @@
|
||||
# NanoKVM
|
||||
NanoKVM
|
||||
======
|
||||
|
||||
<div align="center">
|
||||
|
||||

|
||||
|
||||
<h3>
|
||||
<a href="https://wiki.sipeed.com/hardware/zh/lichee/RV_Nano/1_intro.html"> クイックスタート </a> |
|
||||
<a href="https://wiki.sipeed.com/hardware/en/kvm/NanoKVM/introduction.html"> クイックスタート </a>
|
||||
|
|
||||
<a href="https://cn.dl.sipeed.com/shareURL/KVM/nanoKVM"> ハードウェア </a>
|
||||
</h3>
|
||||
|
||||
@@ -13,18 +15,29 @@
|
||||
|
||||
</div>
|
||||
|
||||
> Your NanoKVM Power by RISC-V !
|
||||
> NanoKVM は [RISC-V](https://en.wikipedia.org/wiki/RISC-V) を搭載しています!
|
||||
> 使用中に問題や提案がある場合は、ここで issue を提出するか、[MaixHub Discussion](https://maixhub.com/discussion/nanokvm) でお知らせください。
|
||||
|
||||
## オープンソース & 貢献 & 出荷
|
||||
## オープンソース & コントリビューション
|
||||
|
||||
スターが2Kに近づいています!10月中旬にバックエンドのソースコードを整理してオープンソース化します!(また、10.1前のすべての予約注文が出荷される時期でもあります)
|
||||
### 2025.02.19 更新
|
||||
|
||||
### 10.18 更新
|
||||
NanoKVM のすべてのコンポーネントはオープンソース化されており、[front-end](https://github.com/sipeed/NanoKVM/tree/main/web)、[back-end](https://github.com/sipeed/NanoKVM/tree/main/server)、[kvm_vision](https://github.com/sipeed/NanoKVM/tree/main/vision/components/kvm)、[kvm_mmf](https://github.com/sipeed/NanoKVM/tree/main/vision/components/kvm_mmf)、[kvm_system](https://github.com/sipeed/NanoKVM/tree/main/support)、[kvmapp update package](https://github.com/sipeed/NanoKVM-System/tree/main/kvmapp)、[system sdk](https://github.com/sipeed/LicheeRV-Nano-Build/tree/NanoKVM)、[packaging methods](https://github.com/sipeed/LicheeRV-Nano-Build/blob/NanoKVM/kvm/NanoKVM_img.sh)が含まれます。
|
||||
|
||||
10.8にバックエンドコードをオープンソース化しました。すぐにPRを提出してくれたCivilに感謝します。最新のNanoKVM-PCIeを報酬として提供します!
|
||||
10月中旬のバッチはテストとパッケージングを開始しており、10.1前のほとんどの注文は次週と次々週に出荷されます。
|
||||
10.1以降、アリエクスプレスの出荷日は12月に変更されました。これは保守的な納期です。10月の注文は11.15〜12.15の間に発送される予定です。
|
||||
### 2025.02.14 更新
|
||||
|
||||
最新のアプリケーションバージョン v2.1.6 には、多くのセキュリティ強化とバグ修正が追加されているため、一般のユーザーはこのバージョン以降へのアップグレードをお勧めします。
|
||||
|
||||
### 2025.02.05 更新
|
||||
|
||||
セキュリティを懸念しているユーザーは、この issue をお読みください: <https://github.com/sipeed/NanoKVM/issues/301>、セキュリティに関するすべての懸念事項について説明されています。
|
||||
GitHub は、オープンで透明性のあるプラットフォームとして、いわゆる「バックドア」の懸念事項を議論する場を提供しています。オープンソースであることにより、製品のセキュリティがさらに強化されます!
|
||||
|
||||
### 2024.10.18 更新
|
||||
|
||||
10/08にバックエンドコードをオープンソース化しました。すぐにPRを提出してくれたCivilに感謝します。最新のNanoKVM-PCIeを報酬として提供します!
|
||||
10月中旬のバッチはテストとパッケージングを開始しており、10/01以前のほとんどの注文は次週と次々週に出荷されます。
|
||||
10/01以降、アリエクスプレスの出荷日は12月に変更されました。これは保守的な納期です。10月の注文は11/15〜12/15の間に発送される予定です。
|
||||
|
||||
## 紹介
|
||||
|
||||
@@ -33,35 +46,35 @@ Lichee NanoKVMは2つのバージョンがあります:
|
||||
NanoKVM Liteは基本構成で、一定のDIY能力を持つ個人ユーザーや大量のニーズを持つ企業ユーザーに適しています。
|
||||
NanoKVM Fullは完全版で、洗練されたケースと完全なアクセサリーを備え、起動時にすぐに使用できるシステムミラーカードが内蔵されており、個人ユーザーに推奨されます。
|
||||
|
||||

|
||||

|
||||
|
||||
## 技術仕様
|
||||
|
||||
| 製品 | NanoKVM (Lite) | NanoKVM (Full) | PiKVM V4 |
|
||||
| --- | --- | --- | --- |
|
||||
| 計算ユニット | LicheeRV Nano(RISCV) | LicheeRV Nano(RISCV) | CM4 (ARM) |
|
||||
| 解像度 | 1080P @ 60fps | 1080P @ 60fps | 1080P @ 60fps |
|
||||
| ビデオエンコーディング | MJPEG, H264 | MJPEG, H264 | MJPEG, H264 |
|
||||
| ビデオ遅延 | 90~230ms | 90~230ms | 100~230ms |
|
||||
| UEFI/BIOS | ✓ | ✓ | ✓ |
|
||||
| 仮想HID | ✓ | ✓ | ✓ |
|
||||
| 仮想CD-ROM | ✓ | ✓ | ✓ |
|
||||
| IPMI | ✓ | ✓ | ✓ |
|
||||
| Wake-on-LAN | ✓ | ✓ | ✓ |
|
||||
| ETH | 100M/10M | 100M/10M | 1000M/100M/10M |
|
||||
| ATX電源制御 | なし、ユーザーが自分で接続 | USBインターフェースIO制御ボード | RJ-45インターフェースIO制御ボード |
|
||||
| OLED | なし、ユーザーが自分で接続 | 128x64 0.96" 白 | 128x32 0.91" 白 |
|
||||
| UART | 2 | 2 | 1 |
|
||||
| TFカード | なし | ✓ | ✓ |
|
||||
| 拡張 | なし | PoE | WiFi/LTE |
|
||||
| 消費電力 | 0.2A@5V | 0.2A@5V | ピーク2.6A@5V |
|
||||
| 電源入力 | PC USBで給電可能 | PC USBまたは補助電源 | DC 5V 3A電源が必要 |
|
||||
| 冷却 | 静音ファンレス | 静音ファンレス | ファン冷却 |
|
||||
| サイズ | 23x37x15mm <br> ~1/30 PiKVM V4サイズ | 40x36x36mm <br/> ~1/7 PiKVM V4サイズ | 120x68x44mm |
|
||||
| 製品 | NanoKVM (Lite) | NanoKVM (Full) | PiKVM V4 |
|
||||
|----------------------- |-------------------------------------- |---------------------------------- |----------------------------------- |
|
||||
| 計算ユニット | LicheeRV Nano(RISCV) | LicheeRV Nano(RISCV) | CM4 (ARM) |
|
||||
| 解像度 | 1080P @ 60fps | 1080P @ 60fps | 1080P @ 60fps |
|
||||
| ビデオエンコーディング | MJPEG, H264 | MJPEG, H264 | MJPEG, H264 |
|
||||
| ビデオ遅延 | 90~230ms | 90~230ms | 100~230ms |
|
||||
| UEFI/BIOS | ✓ | ✓ | ✓ |
|
||||
| 仮想HID | ✓ | ✓ | ✓ |
|
||||
| 仮想CD-ROM | ✓ | ✓ | ✓ |
|
||||
| IPMI | ✓ | ✓ | ✓ |
|
||||
| Wake-on-LAN | ✓ | ✓ | ✓ |
|
||||
| ETH | 100M/10M | 100M/10M | 1000M/100M/10M |
|
||||
| ATX電源制御 | なし、ユーザーが自分で接続 | USBインターフェースIO制御ボード | RJ-45インターフェースIO制御ボード |
|
||||
| OLED | なし、ユーザーが自分で接続 | 128x64 0.96" 白 | 128x32 0.91" 白 |
|
||||
| UART | 2 | 2 | 1 |
|
||||
| TFカード | なし | ✓ | ✓ |
|
||||
| 拡張 | なし | PoE | WiFi/LTE |
|
||||
| 消費電力 | 0.2A@5V | 0.2A@5V | ピーク時 2.6A@5V |
|
||||
| 電源入力 | PC USBで給電可能 | PC USBまたは補助電源 | DC 5V 3A電源が必要 |
|
||||
| 冷却 | 静音ファンレス | 静音ファンレス | ファン冷却 |
|
||||
| サイズ | 23x37x15mm ~1/30 PiKVM V4サイズ | 40x36x36mm ~1/7 PiKVM V4サイズ | 120x68x44mm |
|
||||
|
||||

|
||||

|
||||
|
||||
## ハードウェアプラットフォーム NanoKVM
|
||||
## NanoKVM ハードウェアプラットフォーム
|
||||
|
||||
NanoKVMはSipeed [LicheeRV Nano](https://wiki.sipeed.com/hardware/zh/lichee/RV_Nano/1_intro.html)に基づいており、仕様、回路図、寸法図は[こちら](http://cn.dl.sipeed.com/shareURL/LICHEE/LicheeRV_Nano)で確認できます。
|
||||
|
||||
@@ -69,12 +82,41 @@ NanoKVM LiteはLicheeRV NanoとHDMItoCSIボードで構成され、NanoKVM FULL
|
||||
|
||||
NanoKVMイメージはLicheeRV Nano SDKおよびMaixCDKに基づいて構築されており、LicheeRV Nanoを使用する資料と互換性があります。逆に、KVMソフトウェアはLicheeRV Nanoや他のSG2002製品では使用できません。LicheeRV NanoやMaixCamでHDMI入力アプリケーションを構築したい場合は、技術サポートを受けるためにお問い合わせください。
|
||||
|
||||
注:SG2002の256MBメモリのうち、現在105MBがマルチメディアサブシステムに割り当てられており、NanoKVMはビデオ画像の取得と処理にこのメモリを使用します。
|
||||
注:SG2002の256MBメモリのうち、現在158MBがマルチメディアサブシステムに割り当てられており、NanoKVMはビデオ画像の取得と処理にこのメモリを使用します。
|
||||
|
||||
+ [NanoKVM-A 回路図](https://cn.dl.sipeed.com/fileList/KVM/nanoKVM/HDK/02_Schematic/SCH_RV_Nano_KVM_A_30111.pdf)
|
||||
+ [NanoKVM-B 回路図](https://cn.dl.sipeed.com/fileList/KVM/nanoKVM/HDK/02_Schematic/SCH_HDMI_MIPI_31011.pdf)
|
||||
+ [NanoKVM イメージダウンロード](https://github.com/sipeed/NanoKVM/releases/tag/NanoKVM)
|
||||
|
||||
## ロードマップ
|
||||
|
||||
### Q1 2025
|
||||
|
||||
**改善:**
|
||||
|
||||
- [x] HDMI モジュールをリファクタリングし、libmaixcam_lib.so の依存関係を削除
|
||||
- [x] SSH をデフォルトで無効にし、Web UI に有効/無効の切り替えを追加
|
||||
- [x] Tailscale をデフォルトで無効にし、Web UI に有効/無効の切り替えを追加
|
||||
- [x] 設定ファイルに JWT 設定オプションを追加
|
||||
- [x] bcrypt を利用したパスワードストレージのセキュリティ保護
|
||||
|
||||
**配布:**
|
||||
|
||||
- [x] GitHub 経由でのアプリケーション配布
|
||||
- [x] オンラインでの更新の際に整合性チェックを実施
|
||||
- [ ] オフラインでの更新をサポート
|
||||
|
||||
**バグ修正:**
|
||||
|
||||
- [x] DNS の問題を修正
|
||||
- [x] CSRF の脆弱性を修正
|
||||
|
||||
**機能**
|
||||
|
||||
- [ ] [79](https://github.com/sipeed/NanoKVM/issues/79) Zerotier をサポート
|
||||
- [ ] [99](https://github.com/sipeed/NanoKVM/issues/99) WireGuard をサポート
|
||||
- [ ] [249](https://github.com/sipeed/NanoKVM/issues/249) Mouse Jiggler を追加
|
||||
|
||||
## 購入方法
|
||||
|
||||
* [Aliexpress(グローバル、米国とロシアを除く)](https://www.aliexpress.com/item/1005007369816019.html)
|
||||
|
||||
46
README_ZH.md
46
README_ZH.md
@@ -6,8 +6,9 @@ NanoKVM
|
||||

|
||||
|
||||
<h3>
|
||||
<a href="https://wiki.sipeed.com/hardware/zh/lichee/RV_Nano/1_intro.html"> 快速开始 </a> |
|
||||
<a href="https://cn.dl.sipeed.com/shareURL/KVM/nanoKVM"> 硬件资料 </a>
|
||||
<a href="https://wiki.sipeed.com/hardware/en/kvm/NanoKVM/introduction.html"> Quick Start </a>
|
||||
|
|
||||
<a href="https://cn.dl.sipeed.com/shareURL/KVM/nanoKVM"> Hardware </a>
|
||||
</h3>
|
||||
|
||||
[English](./README.md) | 中文 | [日本語](./README_JA.md)
|
||||
@@ -17,6 +18,47 @@ NanoKVM
|
||||
> Your NanoKVM Power by RISC-V !
|
||||
> 如果您在使用过程中有任何问题或建议,请在这里提交 issue, 或在 [MaixHub Discussion](https://maixhub.com/discussion/nanokvm)告诉我们.
|
||||
|
||||
## 开源与贡献
|
||||
|
||||
### 2025.03.04 更新内容
|
||||
+ 更新目录结构
|
||||
|
||||
``` shell
|
||||
├── kvmapp # APP更新包
|
||||
│ ├── jpg_stream # 兼容从非常老的版本中直接更新
|
||||
│ ├── kvm_new_app # 触发 kvm_system 更新必要组件
|
||||
│ ├── kvm_system # kvm_system 应用
|
||||
│ ├── server # NanoKVM 前后端应用
|
||||
│ └── system # 必要系统组件
|
||||
├── server # NanoKVM 后端
|
||||
├── support # 辅助功能(图像子系统、系统状态、系统更新、屏幕、按键……)
|
||||
│ ├── sg2002 # NanoKVM-Lite/Full/PCIe
|
||||
│ └── h618 # NanoKVM-Pro
|
||||
├── web # NanoKVM 前端
|
||||
├── LICENSE
|
||||
├── README_JA.md
|
||||
├── README.md
|
||||
├── README_ZH.md
|
||||
└── CHANGELOG.md
|
||||
```
|
||||
|
||||
+ 添加 NanoKVM app安装包`kvmapp`
|
||||
+ 添加编译脚本和编译说明
|
||||
|
||||
### 2025.02.19 更新内容
|
||||
所有 NanoKVM 组件已开源,包括
|
||||
[前端](https://github.com/sipeed/NanoKVM/tree/main/web)、[后端](https://github.com/sipeed/NanoKVM/tree/main/server)、[kvm_vision](https://github.com/sipeed/NanoKVM/tree/main/vision/components/kvm)、[kvm_mmf](https://github.com/sipeed/NanoKVM/tree/main/vision/components/kvm_mmf)、[kvm_system](https://github.com/sipeed/NanoKVM/tree/main/support)、[kvmapp 更新包](https://github.com/sipeed/NanoKVM-System/tree/main/kvmapp)、[系统 SDK](https://github.com/sipeed/LicheeRV-Nano-Build/tree/NanoKVM) 和 [固件打包方法](https://github.com/sipeed/LicheeRV-Nano-Build/blob/NanoKVM/kvm/NanoKVM_img.sh)。
|
||||
|
||||
### 2025.02.14 更新内容
|
||||
最新的 APP v2.1.6 添加了大多数安全增强和 bug 修复,建议普通用户升级到此版本或更新版本。
|
||||
|
||||
### 2025.02.05 更新内容
|
||||
对于关注安全的用户,可以阅读此问题:https://github.com/sipeed/NanoKVM/issues/301,您会找到有关所有安全问题的解释。GitHub 作为一个开放和透明的平台,为讨论所谓的“后门”担忧提供了空间。开源使产品更加安全!
|
||||
|
||||
### 2024.10.18 更新内容
|
||||
我们在 10.8 中开源了后端代码,感谢您立即提交的文明 PR,我们将赠送您最新的 NanoKVM-PCIe 作为奖励!
|
||||
十月中旬的批次正在开始测试和打包,大多数在 10.1 之前的订单将在下周和下下周发货。
|
||||
自 10.1 起,AliExpress 的发货日期已更改为 12 月,这是一个保守的交货时间。十月的订单应在 11.15~12.15 期间发出。
|
||||
|
||||
## 简介
|
||||
|
||||
|
||||
91
kvmapp/jpg_stream/S95nanokvm
Executable file
91
kvmapp/jpg_stream/S95nanokvm
Executable file
@@ -0,0 +1,91 @@
|
||||
#!/bin/sh
|
||||
# nanokvm Rev2.1
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
echo -n kvm > /boot/hostname.prefix
|
||||
cp /mnt/data/sensor_cfg.ini.LT /mnt/data/sensor_cfg.ini
|
||||
|
||||
str_value=$(cat /sys/class/cvi-base/base_uid | awk '{print $2}')
|
||||
first_uint=$(echo $str_value | cut -d'_' -f1)
|
||||
second_uint=$(echo $str_value | cut -d'_' -f2)
|
||||
result="$first_uint$second_uint"
|
||||
echo $result > /device_key
|
||||
|
||||
# if [ ! -e /etc/kvm/hw ]
|
||||
# then
|
||||
|
||||
# fi
|
||||
|
||||
# echo 504 > /sys/class/gpio/export # pwr led
|
||||
# echo 505 > /sys/class/gpio/export # hdd led
|
||||
# echo 503 > /sys/class/gpio/export # pwr key
|
||||
# echo 507 > /sys/class/gpio/export # rst key
|
||||
|
||||
# echo in > /sys/class/gpio/gpio504/direction # pwr led
|
||||
# echo in > /sys/class/gpio/gpio505/direction # hdd led
|
||||
# echo out > /sys/class/gpio/gpio503/direction # pwr key
|
||||
# echo out > /sys/class/gpio/gpio507/direction # rst key
|
||||
|
||||
iptables -A INPUT -i eth0 -p tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT
|
||||
iptables -A OUTPUT -o eth0 -p tcp --sport 80 -m state --state ESTABLISHED -j ACCEPT
|
||||
iptables -A OUTPUT -o eth0 -p tcp --dport 22 -m state --state NEW,ESTABLISHED -j ACCEPT
|
||||
iptables -A INPUT -i eth0 -p tcp --sport 22 -m state --state ESTABLISHED -j ACCEPT
|
||||
iptables -A OUTPUT -o eth0 -p tcp --sport 8000 -m state --state ESTABLISHED -j DROP
|
||||
|
||||
cp -r /kvmapp/kvm_system /tmp/
|
||||
/tmp/kvm_system/kvm_system &
|
||||
|
||||
# if [ -e /kvmapp/kvm_stream ]
|
||||
# then
|
||||
# cp -r /kvmapp/kvm_stream /tmp/
|
||||
# /tmp/kvm_stream/kvm_stream &
|
||||
# fi
|
||||
|
||||
cp -r /kvmapp/server /tmp/
|
||||
/tmp/server/NanoKVM-Server &
|
||||
;;
|
||||
stop)
|
||||
killall kvm_system
|
||||
# killall kvm_stream
|
||||
killall NanoKVM-Server
|
||||
rm -r /tmp/kvm_system
|
||||
# rm -r /tmp/kvm_stream
|
||||
rm -r /tmp/server
|
||||
echo "OK"
|
||||
;;
|
||||
# restart_stream)
|
||||
# killall kvm_stream
|
||||
# rm -r /tmp/kvm_stream
|
||||
# if [ -e /kvmapp/kvm_stream ]
|
||||
# then
|
||||
# cp -r /kvmapp/kvm_stream /tmp/
|
||||
# /tmp/kvm_stream/kvm_stream &
|
||||
# echo "OK"
|
||||
# fi
|
||||
# ;;
|
||||
restart)
|
||||
killall kvm_system
|
||||
# killall kvm_stream
|
||||
killall NanoKVM-Server
|
||||
rm -r /tmp/kvm_system
|
||||
# rm -r /tmp/kvm_stream
|
||||
rm -r /tmp/server
|
||||
|
||||
cp -r /kvmapp/kvm_system /tmp/
|
||||
/tmp/kvm_system/kvm_system &
|
||||
|
||||
# if [ -e /kvmapp/kvm_stream ]
|
||||
# then
|
||||
# cp -r /kvmapp/kvm_stream /tmp/
|
||||
# /tmp/kvm_stream/kvm_stream &
|
||||
# fi
|
||||
|
||||
cp -r /kvmapp/server /tmp/
|
||||
/tmp/server/NanoKVM-Server &
|
||||
|
||||
sync
|
||||
|
||||
echo "OK"
|
||||
;;
|
||||
esac
|
||||
5
kvmapp/jpg_stream/jpg_stream
Executable file
5
kvmapp/jpg_stream/jpg_stream
Executable file
@@ -0,0 +1,5 @@
|
||||
rm /etc/init.d/S95webkvm
|
||||
cp /kvmapp/jpg_stream/S95nanokvm /etc/init.d/
|
||||
cp /kvmapp/jpg_stream/dl_lib/libmaixcam_lib.so /kvmapp/kvm_system/dl_lib
|
||||
rm -r /kvmapp/jpg_stream
|
||||
/etc/init.d/S95nanokvm restart
|
||||
0
support/kvm_system/main/Kconfig → kvmapp/kvm_system/kvm_stream
Normal file → Executable file
0
support/kvm_system/main/Kconfig → kvmapp/kvm_system/kvm_stream
Normal file → Executable file
42
kvmapp/system/init.d/S01fs
Executable file
42
kvmapp/system/init.d/S01fs
Executable file
@@ -0,0 +1,42 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ "$1" = "start" ]
|
||||
then
|
||||
# use all sdcard free space for data
|
||||
parted -s /dev/mmcblk0 "resizepart 2 -0"
|
||||
echo "yes
|
||||
8192MB
|
||||
" | parted ---pretend-input-tty /dev/mmcblk0 "resizepart 2 8192MB"
|
||||
# resize data filesystem
|
||||
(resize2fs /dev/mmcblk0p2) &
|
||||
|
||||
|
||||
. /etc/profile
|
||||
printf "mounting filesystem : "
|
||||
mkdir -p /boot
|
||||
mount -t vfat /dev/mmcblk0p1 /boot
|
||||
mount -t configfs configfs /sys/kernel/config
|
||||
mount -t debugfs debugfs /sys/kernel/debug
|
||||
|
||||
if [ -e /boot/usb.disk0 ]
|
||||
then
|
||||
if [ ! -e /etc/kvm.disk0 ]
|
||||
then
|
||||
touch /etc/kvm.disk0
|
||||
# use all sdcard free space for data
|
||||
parted -s /dev/mmcblk0 "mkpart primary 8193MB 100%"
|
||||
sleep 1
|
||||
# resize data filesystem
|
||||
(mkfs.exfat /dev/mmcblk0p3) &
|
||||
sleep 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -e /dev/mmcblk0p3 ]
|
||||
then
|
||||
mkdir -p /data
|
||||
mount /dev/mmcblk0p3 /data
|
||||
fi
|
||||
|
||||
echo "OK"
|
||||
fi
|
||||
139
kvmapp/system/init.d/S03usbdev
Executable file
139
kvmapp/system/init.d/S03usbdev
Executable file
@@ -0,0 +1,139 @@
|
||||
#!/bin/sh
|
||||
# kvmhwd Rev2.0
|
||||
|
||||
start_usb_dev(){
|
||||
. /etc/profile
|
||||
echo "usb mode: device"
|
||||
cd /sys/kernel/config/usb_gadget
|
||||
|
||||
mkdir g0
|
||||
cd g0
|
||||
|
||||
echo 0x3346 > idVendor
|
||||
echo 0x1009 > idProduct
|
||||
mkdir strings/0x409
|
||||
echo '0123456789ABCDEF' > strings/0x409/serialnumber
|
||||
echo 'sipeed' > strings/0x409/manufacturer
|
||||
echo 'NanoKVM' > strings/0x409/product
|
||||
|
||||
mkdir configs/c.1
|
||||
echo 0xE0 > configs/c.1/bmAttributes
|
||||
echo 120 > configs/c.1/MaxPower
|
||||
mkdir configs/c.1/strings/0x409
|
||||
echo "NanoKVM" > configs/c.1/strings/0x409/configuration
|
||||
|
||||
if [ -e /boot/usb.ncm ]
|
||||
then
|
||||
mkdir functions/ncm.usb0
|
||||
ln -s functions/ncm.usb0 configs/c.1/
|
||||
else
|
||||
if [ -e /boot/usb.rndis0 ]
|
||||
then
|
||||
mkdir functions/rndis.usb0
|
||||
ln -s functions/rndis.usb0 configs/c.1/
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -e /boot/disable_hid ]
|
||||
then
|
||||
# keyboard
|
||||
mkdir functions/hid.GS0
|
||||
if [ -e /boot/BIOS ]
|
||||
then
|
||||
echo 1 > functions/hid.GS0/subclass
|
||||
fi
|
||||
if [ ! -e /boot/usb.notwakeup ]
|
||||
then
|
||||
echo 1 > functions/hid.GS0/wakeup_on_write
|
||||
fi
|
||||
echo 1 > functions/hid.GS0/protocol
|
||||
echo 6 > functions/hid.GS0/report_length
|
||||
echo -ne \\x05\\x01\\x09\\x06\\xa1\\x01\\x05\\x07\\x19\\xe0\\x29\\xe7\\x15\\x00\\x25\\x01\\x75\\x01\\x95\\x08\\x81\\x02\\x95\\x01\\x75\\x08\\x81\\x03\\x95\\x05\\x75\\x01\\x05\\x08\\x19\\x01\\x29\\x05\\x91\\x02\\x95\\x01\\x75\\x03\\x91\\x03\\x95\\x06\\x75\\x08\\x15\\x00\\x25\\x65\\x05\\x07\\x19\\x00\\x29\\x65\\x81\\x00\\xc0 > functions/hid.GS0/report_desc
|
||||
ln -s functions/hid.GS0 configs/c.1
|
||||
|
||||
# mouse
|
||||
mkdir functions/hid.GS1
|
||||
if [ -e /boot/BIOS ]
|
||||
then
|
||||
echo 1 > functions/hid.GS1/subclass
|
||||
fi
|
||||
if [ ! -e /boot/usb.notwakeup ]
|
||||
then
|
||||
echo 1 > functions/hid.GS1/wakeup_on_write
|
||||
fi
|
||||
echo 2 > functions/hid.GS1/protocol
|
||||
echo -ne \\x34 > functions/hid.GS1/report_length
|
||||
echo -ne \\x5\\x1\\x9\\x2\\xa1\\x1\\x9\\x1\\xa1\\x0\\x5\\x9\\x19\\x1\\x29\\x3\\x15\\x0\\x25\\x1\\x95\\x3\\x75\\x1\\x81\\x2\\x95\\x1\\x75\\x5\\x81\\x3\\x5\\x1\\x9\\x30\\x9\\x31\\x9\\x38\\x15\\x81\\x25\\x7f\\x75\\x8\\x95\\x3\\x81\\x6\\xc0\\xc0 > functions/hid.GS1/report_desc
|
||||
ln -s functions/hid.GS1 configs/c.1
|
||||
|
||||
# touchpad
|
||||
mkdir functions/hid.GS2
|
||||
if [ -e /boot/BIOS ]
|
||||
then
|
||||
echo 1 > functions/hid.GS2/subclass
|
||||
fi
|
||||
if [ ! -e /boot/usb.notwakeup ]
|
||||
then
|
||||
echo 1 > functions/hid.GS2/wakeup_on_write
|
||||
fi
|
||||
echo 2 > functions/hid.GS2/protocol
|
||||
echo 6 > functions/hid.GS2/report_length
|
||||
echo -ne \\x05\\x01\\x09\\x02\\xa1\\x01\\x09\\x01\\xa1\\x00\\x05\\x09\\x19\\x01\\x29\\x03\\x15\\x00\\x25\\x01\\x95\\x03\\x75\\x01\\x81\\x02\\x95\\x01\\x75\\x05\\x81\\x01\\x05\\x01\\x09\\x30\\x09\\x31\\x15\\x00\\x26\\xff\\x7f\\x35\\x00\\x46\\xff\\x7f\\x75\\x10\\x95\\x02\\x81\\x02\\x05\\x01\\x09\\x38\\x15\\x81\\x25\\x7f\\x35\\x00\\x45\\x00\\x75\\x08\\x95\\x01\\x81\\x06\\xc0\\xc0 > functions/hid.GS2/report_desc
|
||||
ln -s functions/hid.GS2 configs/c.1
|
||||
fi
|
||||
|
||||
if [ -e /boot/usb.disk0 ]
|
||||
then
|
||||
mkdir functions/mass_storage.disk0
|
||||
ln -s functions/mass_storage.disk0 configs/c.1/
|
||||
echo 1 > functions/mass_storage.disk0/lun.0/removable
|
||||
if [ -e /boot/usb.disk0.ro ]
|
||||
then
|
||||
echo 1 > functions/mass_storage.disk0/lun.0/ro
|
||||
echo 0 > functions/mass_storage.disk0/lun.0/cdrom
|
||||
fi
|
||||
disk=$(cat /boot/usb.disk0)
|
||||
if [ -z "${disk}" ]
|
||||
then
|
||||
# if [ ! -e /mnt/usbdisk.img ]
|
||||
# then
|
||||
# fallocate -l 8G /mnt/usbdisk.img
|
||||
# mkfs.vfat /mnt/usbdisk.img
|
||||
# fi
|
||||
echo /dev/mmcblk0p3 > functions/mass_storage.disk0/lun.0/file
|
||||
else
|
||||
cat /boot/usb.disk0 > functions/mass_storage.disk0/lun.0/file
|
||||
fi
|
||||
fi
|
||||
|
||||
ls /sys/class/udc/ | cat > UDC
|
||||
echo device > /proc/cviusb/otg_role
|
||||
}
|
||||
|
||||
start_usb_host(){
|
||||
echo '' > /sys/kernel/config/usb_gadget/g0/UDC
|
||||
echo host > /proc/cviusb/otg_role
|
||||
}
|
||||
|
||||
restart_usb_dev(){
|
||||
echo > /sys/kernel/config/usb_gadget/g0/UDC
|
||||
sleep 1
|
||||
ls /sys/class/udc/ | cat > /sys/kernel/config/usb_gadget/g0/UDC
|
||||
echo "USB Restart OK!"
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start_usb_dev
|
||||
;;
|
||||
restart)
|
||||
restart_usb_dev
|
||||
;;
|
||||
stop)
|
||||
start_usb_host
|
||||
;;
|
||||
stop_start)
|
||||
start_usb_host
|
||||
start_usb_dev
|
||||
;;
|
||||
esac
|
||||
209
kvmapp/system/init.d/S15kvmhwd
Executable file
209
kvmapp/system/init.d/S15kvmhwd
Executable file
@@ -0,0 +1,209 @@
|
||||
#!/bin/sh
|
||||
# kvmhwd Rev2.3
|
||||
|
||||
Alpha_OLED_RST_Pin=371
|
||||
Beta_OLED_RST_Pin=502
|
||||
Beta_OLED_SCL=595
|
||||
Beta_OLED_SDA=507
|
||||
WiFi_EN_Pin=506
|
||||
Alpha_PWR_LED_Pin=504
|
||||
Alpha_HDD_LED_Pin=505
|
||||
Alpha_PWR_KEY_Pin=503
|
||||
Alpha_RST_KEY_Pin=507
|
||||
Beta_PWR_LED_Pin=504
|
||||
Beta_PWR_KEY_Pin=503
|
||||
Beta_RST_KEY_Pin=505
|
||||
PCIe_HDMI_RST_Pin=451
|
||||
|
||||
init_alpha_hw(){
|
||||
devmem 0x030010D0 32 0x2 # I2C1_SCL
|
||||
devmem 0x030010DC 32 0x2 # I2C1_SDA
|
||||
devmem 0x030010D4 32 0x3 # OLED_RST
|
||||
devmem 0x0300103C 32 0x3 # GPIOA15
|
||||
devmem 0x03001050 32 0x3 # GPIOA22
|
||||
devmem 0x0300105C 32 0x3 # GPIOA23
|
||||
devmem 0x03001060 32 0x3 # GPIOA24
|
||||
devmem 0x03001054 32 0x3 # GPIOA25
|
||||
devmem 0x03001058 32 0x3 # GPIOA27
|
||||
|
||||
devmem 0x03001068 32 0x6 # GPIOA 18 UART1 RX
|
||||
devmem 0x03001064 32 0x6 # GPIOA 19 UART1 TX
|
||||
devmem 0x03001070 32 0x2 # GPIOA 28 UART2 TX
|
||||
devmem 0x03001074 32 0x2 # GPIOA 29 UART2 RX
|
||||
|
||||
echo ${Alpha_OLED_RST_Pin} > /sys/class/gpio/export # OLED_RST
|
||||
echo out > /sys/class/gpio/gpio${Alpha_OLED_RST_Pin}/direction
|
||||
echo 1 > /sys/class/gpio/gpio${Alpha_OLED_RST_Pin}/value
|
||||
|
||||
echo ${Alpha_PWR_LED_Pin} > /sys/class/gpio/export # pwr led
|
||||
echo ${Alpha_HDD_LED_Pin} > /sys/class/gpio/export # hdd led
|
||||
echo ${Alpha_PWR_KEY_Pin} > /sys/class/gpio/export # pwr key
|
||||
echo ${Alpha_RST_KEY_Pin} > /sys/class/gpio/export # rst key
|
||||
|
||||
echo in > /sys/class/gpio/gpio${Alpha_PWR_LED_Pin}/direction # pwr led
|
||||
echo in > /sys/class/gpio/gpio${Alpha_HDD_LED_Pin}/direction # hdd led
|
||||
echo out > /sys/class/gpio/gpio${Alpha_PWR_KEY_Pin}/direction # pwr key
|
||||
echo out > /sys/class/gpio/gpio${Alpha_RST_KEY_Pin}/direction # rst key
|
||||
|
||||
rmmod /mnt/system/ko/i2c-gpio.ko
|
||||
rmmod /mnt/system/ko/i2c-algo-bit.ko
|
||||
|
||||
# rm /etc/init.d/S25wifimod
|
||||
# rm /etc/init.d/S30wifi
|
||||
}
|
||||
|
||||
init_beta_pcie_hw(){
|
||||
devmem 0x0300103C 32 0x3 # GPIOA15
|
||||
devmem 0x03001050 32 0x3 # GPIOA22
|
||||
devmem 0x0300105C 32 0x3 # GPIOA23
|
||||
devmem 0x03001060 32 0x3 # GPIOA24
|
||||
devmem 0x03001054 32 0x3 # GPIOA25
|
||||
devmem 0x03001058 32 0x3 # GPIOA27
|
||||
|
||||
devmem 0x030010E4 32 0x0 # SDIO CLK
|
||||
devmem 0x030010E0 32 0x0 # SDIO CMD
|
||||
devmem 0x030010DC 32 0x0 # SDIO D0
|
||||
devmem 0x030010D8 32 0x0 # SDIO D1
|
||||
devmem 0x030010D4 32 0x0 # SDIO D2
|
||||
devmem 0x030010D0 32 0x0 # SDIO D3
|
||||
|
||||
devmem 0x03001068 32 0x6 # GPIOA 18 UART1 RX
|
||||
devmem 0x03001064 32 0x6 # GPIOA 19 UART1 TX
|
||||
devmem 0x03001070 32 0x2 # GPIOA 28 UART2 TX
|
||||
devmem 0x03001074 32 0x2 # GPIOA 29 UART2 RX
|
||||
|
||||
echo ${Beta_OLED_RST_Pin} > /sys/class/gpio/export # Beta OLED_RST
|
||||
echo out > /sys/class/gpio/gpio${Beta_OLED_RST_Pin}/direction
|
||||
echo 1 > /sys/class/gpio/gpio${Beta_OLED_RST_Pin}/value
|
||||
|
||||
echo ${Beta_PWR_LED_Pin} > /sys/class/gpio/export # pwr led
|
||||
echo ${Beta_PWR_KEY_Pin} > /sys/class/gpio/export # pwr key
|
||||
echo ${Beta_RST_KEY_Pin} > /sys/class/gpio/export # rst key
|
||||
echo ${PCIe_HDMI_RST_Pin} > /sys/class/gpio/export # hdmi rst key
|
||||
|
||||
echo in > /sys/class/gpio/gpio${Beta_PWR_LED_Pin}/direction # pwr led
|
||||
echo out > /sys/class/gpio/gpio${Beta_PWR_KEY_Pin}/direction # pwr key
|
||||
echo out > /sys/class/gpio/gpio${Beta_RST_KEY_Pin}/direction # rst key
|
||||
echo out > /sys/class/gpio/gpio${PCIe_HDMI_RST_Pin}/direction # rst key
|
||||
|
||||
echo 1 > /sys/class/gpio/gpio${PCIe_HDMI_RST_Pin}/value # rst key
|
||||
|
||||
rmmod /mnt/system/ko/i2c-gpio.ko
|
||||
rmmod /mnt/system/ko/i2c-algo-bit.ko
|
||||
insmod /mnt/system/ko/i2c-algo-bit.ko
|
||||
insmod /mnt/system/ko/i2c-gpio.ko
|
||||
}
|
||||
|
||||
kvm_hw_detect(){
|
||||
if [ ! -e /etc/kvm/hdmi_version ]
|
||||
then
|
||||
rm /etc/kvm/hw
|
||||
fi
|
||||
if [ -e /etc/kvm/hw ]
|
||||
then
|
||||
echo "/etc/kvm/hw exist"
|
||||
else
|
||||
echo "/etc/kvm/hw not exist"
|
||||
if [ -d "/etc/kvm/" ]
|
||||
then
|
||||
echo "/etc/kvm/ exist"
|
||||
else
|
||||
mkdir /etc/kvm/
|
||||
fi
|
||||
devmem 0x0300104C 32 0x3 # GPIOA26 / WiFi_EN
|
||||
echo ${WiFi_EN_Pin} > /sys/class/gpio/export # WiFi_EN
|
||||
echo out > /sys/class/gpio/gpio${WiFi_EN_Pin}/direction
|
||||
echo 0 > /sys/class/gpio/gpio${WiFi_EN_Pin}/value
|
||||
|
||||
devmem 0x0300103C 32 0x3 # GPIOA15
|
||||
devmem 0x03001050 32 0x3 # GPIOA22
|
||||
devmem 0x0300105C 32 0x3 # GPIOA23
|
||||
devmem 0x03001060 32 0x3 # GPIOA24
|
||||
devmem 0x03001054 32 0x3 # GPIOA25
|
||||
devmem 0x03001058 32 0x3 # GPIOA27
|
||||
|
||||
devmem 0x030010D0 32 0x2 # I2C1_SCL
|
||||
devmem 0x030010DC 32 0x2 # I2C1_SDA
|
||||
devmem 0x030010D4 32 0x3 # OLED_RST
|
||||
echo ${Alpha_OLED_RST_Pin} > /sys/class/gpio/export # OLED_RST
|
||||
echo out > /sys/class/gpio/gpio${Alpha_OLED_RST_Pin}/direction
|
||||
echo 1 > /sys/class/gpio/gpio${Alpha_OLED_RST_Pin}/value
|
||||
|
||||
kvm_tmp=$(i2cdetect -ry 1 0x3d 0x3d | grep 3d)
|
||||
if [ -n "$kvm_tmp" ]
|
||||
then
|
||||
# alpha hw
|
||||
echo "alpha" > /etc/kvm/hw
|
||||
else
|
||||
# beta/pcie hw
|
||||
echo ${Alpha_OLED_RST_Pin} > /sys/class/gpio/unexport # OLED_RST
|
||||
echo ${Beta_OLED_RST_Pin} > /sys/class/gpio/export # Beta_OLED_RST_Pin
|
||||
echo out > /sys/class/gpio/gpio${Beta_OLED_RST_Pin}/direction
|
||||
echo 1 > /sys/class/gpio/gpio${Beta_OLED_RST_Pin}/value
|
||||
|
||||
rmmod /mnt/system/ko/i2c-gpio.ko
|
||||
rmmod /mnt/system/ko/i2c-algo-bit.ko
|
||||
insmod /mnt/system/ko/i2c-algo-bit.ko
|
||||
insmod /mnt/system/ko/i2c-gpio.ko
|
||||
|
||||
kvm_tmp=$(i2cdetect -ry 4 0x2c 0x2c | grep 2c)
|
||||
if [ -n "$kvm_tmp" ]
|
||||
then
|
||||
echo "c" > /etc/kvm/hdmi_version
|
||||
else
|
||||
echo "u" > /etc/kvm/hdmi_version
|
||||
fi
|
||||
|
||||
kvm_tmp=$(i2cdetect -ry 5 0x3c 0x3c | grep 3c)
|
||||
if [ -n "$kvm_tmp" ]
|
||||
then
|
||||
echo "pcie" > /etc/kvm/hw
|
||||
sync
|
||||
reboot
|
||||
else
|
||||
echo "beta" > /etc/kvm/hw
|
||||
# rm /etc/init.d/S25wifimod
|
||||
# rm /etc/init.d/S30wifi
|
||||
sync
|
||||
fi
|
||||
|
||||
echo 1 > /sys/class/gpio/gpio${WiFi_EN_Pin}/value
|
||||
echo ${WiFi_EN_Pin} > /sys/class/gpio/unexport # WiFi_EN
|
||||
fi
|
||||
fi
|
||||
sync
|
||||
}
|
||||
|
||||
kvm_hw_init(){
|
||||
FIND_FILE="/etc/kvm/hw"
|
||||
if [ `grep -c "alpha" $FIND_FILE` -ne '0' ]
|
||||
then
|
||||
echo "hw = alpha!"
|
||||
init_alpha_hw
|
||||
fi
|
||||
if [ `grep -c "beta" $FIND_FILE` -ne '0' ]
|
||||
then
|
||||
echo "hw = beta!"
|
||||
init_beta_pcie_hw
|
||||
fi
|
||||
if [ `grep -c "pcie" $FIND_FILE` -ne '0' ]
|
||||
then
|
||||
echo "hw = pcie!"
|
||||
init_beta_pcie_hw
|
||||
fi
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
kvm_hw_detect
|
||||
kvm_hw_init
|
||||
;;
|
||||
re-detect)
|
||||
rm /etc/kvm/hw
|
||||
kvm_hw_detect
|
||||
kvm_hw_init
|
||||
;;
|
||||
re-init)
|
||||
kvm_hw_init
|
||||
;;
|
||||
esac
|
||||
115
kvmapp/system/init.d/S30eth
Executable file
115
kvmapp/system/init.d/S30eth
Executable file
@@ -0,0 +1,115 @@
|
||||
#!/bin/sh
|
||||
|
||||
. /etc/profile
|
||||
|
||||
# /boot/eth.nodhcp for example
|
||||
# ipaddr/net gw[optional]
|
||||
# 192.168.0.101/24 192.168.0.1
|
||||
# 192.168.3.116/22
|
||||
|
||||
RESERVE_INET="192.168.0.1/24"
|
||||
|
||||
start() {
|
||||
printf "start ethernet: "
|
||||
if [ -e /boot/eth.nodhcp ]
|
||||
then
|
||||
[ -e /boot/eth.nodhcp ] &&
|
||||
cat /boot/eth.nodhcp | while read inet gw
|
||||
do
|
||||
addr=${inet%/*}
|
||||
netid=${inet#*/}
|
||||
[ -z $gw ] &&
|
||||
gw=$( echo $addr| ( IFS='.' read a b c d; echo $((
|
||||
(((((($a<<8)+$b)<<8)+$c)<<8)+$d)
|
||||
& (((1<<$netid)-1)<<(32-$netid))
|
||||
))
|
||||
)) &&
|
||||
gw=$(($gw>>24&0xff)).$(($gw>>16&0xff)).$(($gw>>8&0xff)).$((1+( $gw>>0&0xff )))
|
||||
|
||||
arping -Dqc2 -Ieth0 $addr || continue
|
||||
ip a add $inet brd + dev eth0
|
||||
ip r add default via $gw dev eth0
|
||||
cat > /etc/resolve.conf << EOF
|
||||
nameserver $gw
|
||||
nameserver 8.8.8.8
|
||||
nameserver 114.114.114.114
|
||||
EOF
|
||||
break
|
||||
done &&
|
||||
ip a show dev eth0|grep inet || (
|
||||
udhcpc -i eth0 -t 3 -T 1 -A 5 -b -p /run/udhcpc.eth0.pid &>/dev/null
|
||||
ip a show dev eth0|grep inet
|
||||
) || (
|
||||
# failed to apply dynamic addr, need a available static addr to visit the LAN
|
||||
inet=$RESERVE_INET
|
||||
addr=${inet%/*}
|
||||
ip a add $inet brd + dev eth0
|
||||
) || exit 1
|
||||
else
|
||||
(udhcpc -i eth0 -t 10 -T 1 -A 5 -b -p /run/udhcpc.eth0.pid) &
|
||||
fi
|
||||
|
||||
echo "OK"
|
||||
}
|
||||
stop() {
|
||||
[[ ! -e "/run/udhcpc.eth0.pid" ]] && echo "udhcpc is not running..." && exit 1
|
||||
kill `cat /run/udhcpc.eth0.pid`
|
||||
rm /run/udhcpc.eth0.pid
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
restart|reload)
|
||||
$0 stop
|
||||
$0 start
|
||||
;;
|
||||
doc)
|
||||
cat <<EOF
|
||||
If you want to set your own static ip address
|
||||
rather then fetch it by dhcp.
|
||||
Then you need to create a file \`/boot/eth.nodhcp\`,
|
||||
and edit it following the format below:
|
||||
\`addr/netid gw[optional]\` in one line
|
||||
for example (support muti definations, checks with arp):
|
||||
1. 192.168.0.101/24 192.168.0.1
|
||||
2. 192.168.3.116/22
|
||||
Delete this file if you change to use dhcp default.
|
||||
ATTENTION: If all the STATIC address you set in the file is
|
||||
already in use on this LAN checked with arp, then none
|
||||
of them will be yours. And it will trigger dhcp, try to
|
||||
fetch DYNAMIC one. If it's also failed, your address will
|
||||
be the REVERSE one, 192.168.0.1/24. Just to be sure that
|
||||
you can visit your NanoKVM device through eth to fix some
|
||||
problems by ssh, unless you must disassemble it and modify
|
||||
or rewrite the TFCard once again.
|
||||
EOF
|
||||
echo ""
|
||||
cat <<EOF
|
||||
如果您想自行设置静态 ip 地址而不是使用 dhcp 来获取它。
|
||||
|
||||
那么您需要新建一个文件 \`/boot/eth.nodhcp\`,然后按照以下格式编辑它:
|
||||
\`addr/netid gw[optional]\` 在一行内
|
||||
示例(支持多个预设,会通过 arp 检查是否占用):
|
||||
1. 192.168.0.101/24 192.168.0.1
|
||||
2. 192.168.3.116/22
|
||||
|
||||
如果您想改回默认 dhcp 获取 ip 地址的方式,删除该文件后即可恢复。
|
||||
|
||||
注意:如果您预设的所有静态 ip 地址都被 arp 检测到已占用,则不会成功设置。
|
||||
此时会触发 dhcp 尝试获取 ip 地址,如果仍失败,那么最终会强制设置成
|
||||
192.168.90.1/24。这是为了保证您的 NanoKVM 设备总是能有一个可用的
|
||||
ip 地址,方便您通过局域网 ssh 连接设备进行一些修复,否则您可能需要
|
||||
拆开外壳以手动修改 TF 卡或重新烧卡。
|
||||
|
||||
|
||||
EOF
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart}"
|
||||
exit 1
|
||||
esac
|
||||
175
kvmapp/system/init.d/S30wifi
Executable file
175
kvmapp/system/init.d/S30wifi
Executable file
@@ -0,0 +1,175 @@
|
||||
#!/bin/sh
|
||||
|
||||
. /etc/profile
|
||||
|
||||
gen_hostapd_conf() {
|
||||
ssid="${1}"
|
||||
pass="${2}"
|
||||
echo "ctrl_interface=/var/run/hostapd"
|
||||
echo "ctrl_interface_group=0"
|
||||
echo "ssid=${ssid}"
|
||||
echo "hw_mode=g"
|
||||
echo "channel=1"
|
||||
echo "beacon_int=100"
|
||||
echo "dtim_period=2"
|
||||
echo "max_num_sta=255"
|
||||
echo "rts_threshold=-1"
|
||||
echo "fragm_threshold=-1"
|
||||
echo "macaddr_acl=0"
|
||||
echo "auth_algs=3"
|
||||
echo "wpa=2"
|
||||
echo "wpa_passphrase=${pass}"
|
||||
echo "ieee80211n=1"
|
||||
}
|
||||
|
||||
gen_udhcpd_conf() {
|
||||
interface=${1}
|
||||
ipv4_prefix=${2}
|
||||
echo "start ${ipv4_prefix}.100"
|
||||
echo "end ${ipv4_prefix}.200"
|
||||
echo "interface ${interface}"
|
||||
echo "pidfile /var/run/udhcpd.${interface}.pid"
|
||||
echo "lease_file /var/lib/misc/udhcpd.${interface}.leases"
|
||||
echo "option subnet 255.255.255.0"
|
||||
echo "option lease 864000"
|
||||
}
|
||||
|
||||
gen_dnsmasq_conf() {
|
||||
ipv4_prefix=${1}
|
||||
echo "bind-interfaces"
|
||||
echo "interface=wlan0"
|
||||
echo "address=/config.kvm/${ipv4_prefix}.1"
|
||||
echo "no-hosts"
|
||||
echo "dhcp-range=${ipv4_prefix}.2,${ipv4_prefix}.254"
|
||||
echo "dhcp-option=6,${ipv4_prefix}.1"
|
||||
echo "dhcp-option=3,${ipv4_prefix}.1"
|
||||
echo "dhcp-authoritative"
|
||||
}
|
||||
|
||||
start() {
|
||||
echo "wifi mode: sta"
|
||||
ssid=""
|
||||
pass=""
|
||||
if [ -e /boot/wifi.ssid ] && [ -e /boot/wifi.pass ]; then
|
||||
echo "Updating WiFi credentials from /boot to /etc/kvm/"
|
||||
|
||||
rm -f /etc/kvm/wifi.ssid /etc/kvm/wifi.pass
|
||||
|
||||
mv /boot/wifi.ssid /etc/kvm/wifi.ssid
|
||||
mv /boot/wifi.pass /etc/kvm/wifi.pass
|
||||
|
||||
chown root:root /etc/kvm/wifi.ssid /etc/kvm/wifi.pass
|
||||
chmod 644 /etc/kvm/wifi.ssid /etc/kvm/wifi.pass
|
||||
fi
|
||||
if [ -e /etc/kvm/wifi.ssid ]
|
||||
then
|
||||
ssid=`cat /etc/kvm/wifi.ssid`
|
||||
fi
|
||||
if [ -e /etc/kvm/wifi.pass ]
|
||||
then
|
||||
pass=`cat /etc/kvm/wifi.pass`
|
||||
fi
|
||||
echo "ctrl_interface=/var/run/wpa_supplicant" > /etc/wpa_supplicant.conf
|
||||
wpa_passphrase "$ssid" "$pass" >> /etc/wpa_supplicant.conf
|
||||
wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant.conf
|
||||
if [ ! -e /boot/wifi.nodhcp ]
|
||||
then
|
||||
(udhcpc -i wlan0 -t 10 -T 1 -A 5 -b -p /run/udhcpc.wlan0.pid) &
|
||||
fi
|
||||
}
|
||||
|
||||
ap_start() {
|
||||
echo "wifi mode: ap"
|
||||
id2=$(printf "%d" 0x$(sha512sum /sys/class/cvi-base/base_uid | head -c 2))
|
||||
id3=$(printf "%d" 0x$(sha512sum /sys/class/cvi-base/base_uid | head -c 4 | tail -c 2))
|
||||
if [ "$id2" = "$id3" ]
|
||||
then
|
||||
id2=$((id2 + 1))
|
||||
fi
|
||||
if [ "$id2" -ge 255 ]
|
||||
then
|
||||
id2=253
|
||||
fi
|
||||
if [ "$id3" -ge 255 ]
|
||||
then
|
||||
id3=254
|
||||
fi
|
||||
ssid=""
|
||||
pass=""
|
||||
if [ -e /kvmapp/kvm/ap.ssid ]
|
||||
then
|
||||
ssid=`cat /kvmapp/kvm/ap.ssid`
|
||||
fi
|
||||
if [ -e /kvmapp/kvm/ap.pass ]
|
||||
then
|
||||
pass=`cat /kvmapp/kvm/ap.pass`
|
||||
fi
|
||||
gen_hostapd_conf "$ssid" "$pass" > /etc/hostapd.conf
|
||||
ipv4_prefix=10.$id3.$id2
|
||||
if [ ! -e /etc/udhcpd.wlan0.conf ]
|
||||
then
|
||||
gen_udhcpd_conf wlan0 "${ipv4_prefix}" > /etc/udhcpd.wlan0.conf
|
||||
fi
|
||||
# gen_dnsmasq_conf "${ipv4_prefix}" > /etc/dnsmasq.conf
|
||||
|
||||
# iptables --policy INPUT ACCEPT
|
||||
# iptables --policy FORWARD ACCEPT
|
||||
# iptables --policy OUTPUT ACCEPT
|
||||
# iptables -F
|
||||
# iptables -t nat -F
|
||||
# iptables -t nat -A PREROUTING -i wlan0 -p udp --dport 53 -j DNAT --to ${ipv4_prefix}.1
|
||||
|
||||
ifconfig wlan0 up
|
||||
ip route del default || true
|
||||
ip add flush dev wlan0
|
||||
ip addr add $ipv4_prefix.1/24 dev wlan0
|
||||
# dnsmasq --pid-file=/tmp/dnsmasq.run -C /etc/dnsmasq.conf
|
||||
hostapd -B -i wlan0 /etc/hostapd.conf
|
||||
udhcpd -S /etc/udhcpd.wlan0.conf
|
||||
}
|
||||
|
||||
stop() {
|
||||
ps -ef|grep hostapd|grep -v grep|awk '{print $1}'|xargs kill -2 || true
|
||||
ps -ef|grep "udhcpd -S /etc/udhcpd.wlan0.conf" |grep -v grep|awk '{print $1}'|xargs kill -2 || true
|
||||
killall wpa_supplicant || true
|
||||
if [ -e /run/udhcpc.wlan0.pid ]
|
||||
then
|
||||
kill `cat /run/udhcpc.wlan0.pid` || true
|
||||
rm -f /run/udhcpc.wlan0.pid
|
||||
fi
|
||||
if [ -e /var/run/udhcpd.wlan0.pid ]
|
||||
then
|
||||
kill `cat /var/run/udhcpd.wlan0.pid` || true
|
||||
rm -f /var/run/udhcpd.wlan0.pid
|
||||
fi
|
||||
if [ -e /tmp/dnsmasq.run ]
|
||||
then
|
||||
kill `cat /tmp/dnsmasq.run` || true
|
||||
rm -f /tmp/dnsmasq.run
|
||||
fi
|
||||
# if [ -e /etc/wpa_supplicant.conf]
|
||||
# then
|
||||
# echo > /etc/wpa_supplicant.conf
|
||||
# fi
|
||||
airmon-ng stop wlan0mon || true
|
||||
}
|
||||
|
||||
restart() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
if [ "${1}" = "start" ]
|
||||
then
|
||||
start
|
||||
elif [ "${1}" = "stop" ]
|
||||
then
|
||||
stop
|
||||
elif [ "${1}" = "ap" ]
|
||||
then
|
||||
stop
|
||||
ap_start
|
||||
elif [ "${1}" = "restart" ]
|
||||
then
|
||||
restart
|
||||
fi
|
||||
49
kvmapp/system/init.d/S50ssdpd
Executable file
49
kvmapp/system/init.d/S50ssdpd
Executable file
@@ -0,0 +1,49 @@
|
||||
#!/bin/sh
|
||||
|
||||
DAEMON=ssdpd
|
||||
PIDFILE=/var/run/$DAEMON.pid
|
||||
CFGFILE=/etc/default/$DAEMON
|
||||
|
||||
DAEMON_ARGS=""
|
||||
|
||||
# Read configuration variable file if it is present
|
||||
# shellcheck source=/dev/null
|
||||
[ -r "$CFGFILE" ] && . "$CFGFILE"
|
||||
|
||||
# shellcheck disable=SC2086
|
||||
start() {
|
||||
printf 'Starting %s: ' "$DAEMON"
|
||||
if start-stop-daemon -S -q -p "$PIDFILE" -x "$DAEMON" -- $DAEMON_ARGS; then
|
||||
echo "OK"
|
||||
else
|
||||
echo "FAIL"
|
||||
fi
|
||||
}
|
||||
|
||||
stop() {
|
||||
printf 'Stopping %s: ' "$DAEMON"
|
||||
if start-stop-daemon -K -q -p "$PIDFILE" -x "$DAEMON"; then
|
||||
echo "OK"
|
||||
else
|
||||
echo "FAIL"
|
||||
fi
|
||||
}
|
||||
|
||||
restart() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start|stop|restart)
|
||||
"$1"
|
||||
;;
|
||||
reload)
|
||||
restart
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart|reload}"
|
||||
exit 1
|
||||
esac
|
||||
|
||||
exit $?
|
||||
69
kvmapp/system/init.d/S50sshd
Executable file
69
kvmapp/system/init.d/S50sshd
Executable file
@@ -0,0 +1,69 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# sshd Starts sshd.
|
||||
#
|
||||
|
||||
# Make sure the ssh-keygen progam exists
|
||||
[ -f /usr/bin/ssh-keygen ] || exit 0
|
||||
|
||||
umask 077
|
||||
|
||||
startssh() {
|
||||
/usr/bin/ssh-keygen -A
|
||||
|
||||
printf "Starting sshd: "
|
||||
/usr/sbin/sshd
|
||||
touch /var/lock/sshd
|
||||
echo "OK"
|
||||
}
|
||||
start() {
|
||||
# Create any missing keys
|
||||
if [ -e /etc/kvm/ssh_stop ]
|
||||
then
|
||||
if [ -e /boot/start_ssh_once ]
|
||||
then
|
||||
rm /boot/start_ssh_once
|
||||
startssh
|
||||
else
|
||||
echo "SSH does not start"
|
||||
fi
|
||||
else
|
||||
startssh
|
||||
fi
|
||||
}
|
||||
stop() {
|
||||
printf "Stopping sshd: "
|
||||
killall sshd
|
||||
rm -f /var/lock/sshd
|
||||
echo "OK"
|
||||
}
|
||||
restart() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
restart|reload)
|
||||
restart
|
||||
;;
|
||||
permanent_on)
|
||||
rm /etc/kvm/ssh_stop
|
||||
start
|
||||
;;
|
||||
permanent_off)
|
||||
touch /etc/kvm/ssh_stop
|
||||
stop
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart|permanent_on|permanent_off}"
|
||||
exit 1
|
||||
esac
|
||||
|
||||
exit $?
|
||||
|
||||
50
kvmapp/system/init.d/S95nanokvm
Executable file
50
kvmapp/system/init.d/S95nanokvm
Executable file
@@ -0,0 +1,50 @@
|
||||
#!/bin/sh
|
||||
# nanokvm Rev3.0
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
echo -n kvm > /boot/hostname.prefix
|
||||
cp /mnt/data/sensor_cfg.ini.LT /mnt/data/sensor_cfg.ini
|
||||
|
||||
str_value=$(cat /sys/class/cvi-base/base_uid | awk '{print $2}')
|
||||
first_uint=$(echo $str_value | cut -d'_' -f1)
|
||||
second_uint=$(echo $str_value | cut -d'_' -f2)
|
||||
result="$first_uint$second_uint"
|
||||
echo $result > /device_key
|
||||
|
||||
iptables -A INPUT -i eth0 -p tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT
|
||||
iptables -A OUTPUT -o eth0 -p tcp --sport 80 -m state --state ESTABLISHED -j ACCEPT
|
||||
iptables -A OUTPUT -o eth0 -p tcp --dport 22 -m state --state NEW,ESTABLISHED -j ACCEPT
|
||||
iptables -A INPUT -i eth0 -p tcp --sport 22 -m state --state ESTABLISHED -j ACCEPT
|
||||
iptables -A OUTPUT -o eth0 -p tcp --sport 8000 -m state --state ESTABLISHED -j DROP
|
||||
|
||||
cp -r /kvmapp/kvm_system /tmp/
|
||||
/tmp/kvm_system/kvm_system &
|
||||
|
||||
cp -r /kvmapp/server /tmp/
|
||||
/tmp/server/NanoKVM-Server &
|
||||
;;
|
||||
stop)
|
||||
killall kvm_system
|
||||
killall NanoKVM-Server
|
||||
rm -r /tmp/kvm_system
|
||||
rm -r /tmp/server
|
||||
echo "OK"
|
||||
;;
|
||||
restart)
|
||||
killall kvm_system
|
||||
killall NanoKVM-Server
|
||||
rm -r /tmp/kvm_system
|
||||
rm -r /tmp/server
|
||||
|
||||
cp -r /kvmapp/kvm_system /tmp/
|
||||
/tmp/kvm_system/kvm_system &
|
||||
|
||||
cp -r /kvmapp/server /tmp/
|
||||
/tmp/server/NanoKVM-Server &
|
||||
|
||||
sync
|
||||
|
||||
echo "OK"
|
||||
;;
|
||||
esac
|
||||
114
kvmapp/system/init.d/S98tailscaled
Executable file
114
kvmapp/system/init.d/S98tailscaled
Executable file
@@ -0,0 +1,114 @@
|
||||
#!/bin/sh
|
||||
|
||||
DAEMON="tailscaled"
|
||||
PIDFILE="/var/run/$DAEMON.pid"
|
||||
|
||||
# Set the port to listen on for incoming VPN packets.
|
||||
# Remote nodes will automatically be informed about the new port number,
|
||||
# but you might want to configure this in order to set external firewall
|
||||
# settings.
|
||||
PORT="41641"
|
||||
|
||||
# Extra flags you might want to pass to tailscaled.
|
||||
FLAGS=""
|
||||
|
||||
# You need tailscaled at /usr/sbin to server, and tailscale at /usr/bin to operate
|
||||
# STATIC version needed. Download page at https://pkgs.tailscale.com/stable/#static
|
||||
PKG_URL_LATEST="https://pkgs.tailscale.com/stable/tailscale_latest_riscv64.tgz"
|
||||
[ ! -x /usr/sbin/$DAEMON ] &&
|
||||
echo "/usr/sbin/$DAEMON not found, please download it from $PKG_URL_LATEST" &&
|
||||
echo "Then unpack it, copy $DAEMON to /usr/sbin and copy tailscale to /usr/bin" &&
|
||||
exit 1
|
||||
VERSION=$(/usr/sbin/$DAEMON --version|sed -n '1p'|xargs echo -n)
|
||||
|
||||
[ -x /usr/bin/tailscale ] || echo "/usr/bin/tailscale not found, your installation of tailscale may be broken"
|
||||
|
||||
# just for those need forwarding
|
||||
[ ! -f /etc/sysctl.d/99-tailscale.conf ] &&
|
||||
mkdir -p /etc/sysctl.d/ &&
|
||||
echo "missing /etc/sysctl.d/99-tailscale.conf, try make it below:" &&
|
||||
(tee /etc/sysctl.d/99-tailscale.conf <<EOF
|
||||
net.ipv4.ip_forward = 1
|
||||
net.ipv6.conf.all.forwarding = 1
|
||||
EOF
|
||||
) &&
|
||||
echo "if this message repeats showing, please look at $0 if you need forwarding"
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
tailscale set --accept-dns=false
|
||||
if [ -f /etc/kvm/GOMEMLIMIT ]; then
|
||||
value=$(cat /etc/kvm/GOMEMLIMIT)
|
||||
export GOMEMLIMIT="${value}MiB"
|
||||
else
|
||||
export GOMEMLIMIT=1024MiB
|
||||
fi
|
||||
|
||||
echo "GOMEMLIMIT set to ${GOMEMLIMIT}"
|
||||
printf "Starting $DAEMON[$VERSION]: "
|
||||
start-stop-daemon -S -bmq -p "$PIDFILE" -x "/usr/sbin/$DAEMON" -- \
|
||||
--state=/var/lib/tailscale/tailscaled.state \
|
||||
--socket=/var/run/tailscale/tailscaled.sock \
|
||||
--port=${PORT} \
|
||||
$FLAGS
|
||||
[ $? = 0 ] && echo "OK" || echo "FAIL"
|
||||
;;
|
||||
stop)
|
||||
printf "Stopping $DAEMON: "
|
||||
start-stop-daemon -K -p "$PIDFILE"
|
||||
[ $? = 0 ] && (echo "OK"; rm -f "$PIDFILE") || echo "FAIL"
|
||||
printf "cleaning tailscaled: "
|
||||
/usr/sbin/$DAEMON --cleanup &>/dev/null
|
||||
[ $? = 0 ] && echo "OK" || echo "FAIL"
|
||||
;;
|
||||
restart|reload)
|
||||
$0 stop
|
||||
$0 start
|
||||
;;
|
||||
doc)
|
||||
cat <<EOF
|
||||
To use tailscale, you need to meet these conditions below:
|
||||
1. Both tailscale and tailscaled were installed.
|
||||
2. At least one tailscale's account were registered.
|
||||
(https://login.tailscale.com/start)
|
||||
3. Your NanoKVM device must keep online.
|
||||
|
||||
Then, follow the steps below:
|
||||
1. Login in https://login.tailscale.com on your PC
|
||||
to enter into yout admin console.
|
||||
2. Run 'tailscale login' on your device, and copy the link showed
|
||||
to open on your PC, and confirm the auth.
|
||||
3. Congratulations, your NanoKVM device is now on the tailnet, try to
|
||||
visit it from all your device which on the same tailnet.
|
||||
4. run 'tailscale set --webclient' and manage your device
|
||||
on the web interface from localnet and tailenet.
|
||||
|
||||
Added: no more action to be repeat after your device reboot.
|
||||
EOF
|
||||
echo ""
|
||||
cat <<EOF
|
||||
为了正常使用 tailscale, 你需要满足以下几个条件:
|
||||
1. tailscale 和 tailscaled 这两个静态链接的二进制程序
|
||||
都已经正确安装在系统上。
|
||||
2. 至少注册一个 tailscale 的帐号才能使用其服务。
|
||||
(https://login.tailscale.com/start)
|
||||
3. 你的 NanoKVM 设备必须保持在线。
|
||||
|
||||
然后,跟着以下步骤操作:
|
||||
1. 在你的电脑上登录 https://login.tailscale.com 以进入控制台。
|
||||
2. 在你的 NanoKVM ssh 终端上执行 'tailscale login', 然后复制
|
||||
出现的链接到浏览器上,登录并通过验证。
|
||||
3. 祝贺,你的 NanoKVM 现在已经加入了 tailnet 然后你可以从任意
|
||||
同样已加入同一 tailnet 的设备去访问你的 NanoKVM。
|
||||
4. 执行 'tailscale set --webclient' 然后你就可以从 '局域网' 和
|
||||
'tailnet' 来访问特定网页,用来管理你的设备。
|
||||
|
||||
补充: 不需要重复上面的操作,哪怕你的设备重启过。
|
||||
EOF
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart}"
|
||||
exit 1
|
||||
esac
|
||||
|
||||
exit 0
|
||||
BIN
kvmapp/system/ko/soph_mipi_rx.ko
Normal file
BIN
kvmapp/system/ko/soph_mipi_rx.ko
Normal file
Binary file not shown.
126
kvmapp/system/update-nanokvm.py
Executable file
126
kvmapp/system/update-nanokvm.py
Executable file
@@ -0,0 +1,126 @@
|
||||
import os
|
||||
import shutil
|
||||
import time
|
||||
import zipfile
|
||||
|
||||
import requests
|
||||
|
||||
temporary = "/root/.kvm-cache/"
|
||||
|
||||
|
||||
def mkdir():
|
||||
is_exists = os.path.exists(temporary)
|
||||
if is_exists:
|
||||
shutil.rmtree(temporary)
|
||||
os.mkdir(temporary)
|
||||
print(f"create temporary directory {temporary}")
|
||||
|
||||
|
||||
def read(file):
|
||||
with open(file, "r") as f:
|
||||
content = f.read()
|
||||
return content.replace("\n", "")
|
||||
|
||||
|
||||
def download_firmware():
|
||||
print("download firmware...")
|
||||
|
||||
now = int(time.time())
|
||||
url = f"https://cdn.sipeed.com/nanokvm/latest.zip?n={now}"
|
||||
print(f"download from {url}")
|
||||
|
||||
response = requests.get(url)
|
||||
|
||||
if response.status_code != 200:
|
||||
raise Exception(f"download firmware failed, status: {response.status_code}")
|
||||
|
||||
content_type = response.headers.get("content-type")
|
||||
if content_type != "application/zip":
|
||||
raise Exception(f"download firmware failed, content_type: {content_type}")
|
||||
|
||||
zip_file = f"{temporary}/latest.zip"
|
||||
with open(zip_file, "wb") as f:
|
||||
for chunk in response.iter_content(chunk_size=1024):
|
||||
f.write(chunk)
|
||||
|
||||
with zipfile.ZipFile(zip_file, "r") as f:
|
||||
f.extractall(temporary)
|
||||
|
||||
print("download firmware done")
|
||||
|
||||
|
||||
def download_lib():
|
||||
print("download lib...")
|
||||
|
||||
device_key = read("/device_key")
|
||||
|
||||
url = f"https://maixvision.sipeed.com/api/v1/nanokvm/encryption?uid={device_key}"
|
||||
headers = {"token": "MaixVision2024"}
|
||||
response = requests.get(url, headers=headers, stream=True)
|
||||
|
||||
if response.status_code != 200:
|
||||
raise Exception(f"download lib failed, status: {response.status_code}")
|
||||
|
||||
content_type = response.headers.get("content-type")
|
||||
if content_type != "application/octet-stream":
|
||||
raise Exception(f"download lib failed, content_type: {content_type}")
|
||||
|
||||
lib_file = f"{temporary}/libmaixcam_lib.so"
|
||||
with open(lib_file, "wb") as f:
|
||||
f.write(response.content)
|
||||
|
||||
lib_dir = f"{temporary}/latest/kvm_system/dl_lib/"
|
||||
shutil.copy(lib_file, lib_dir)
|
||||
|
||||
print("download lib done")
|
||||
|
||||
|
||||
def update():
|
||||
backup_dir = "/root/old"
|
||||
firmware_dir = "/kvmapp"
|
||||
|
||||
if os.path.exists(backup_dir):
|
||||
shutil.rmtree(backup_dir)
|
||||
|
||||
if os.path.exists(firmware_dir):
|
||||
shutil.move(firmware_dir, backup_dir)
|
||||
|
||||
shutil.move(f"{temporary}/latest", firmware_dir)
|
||||
|
||||
|
||||
def change_permissions():
|
||||
for root, dirs, files in os.walk("/kvmapp"):
|
||||
os.chmod(root, 0o755)
|
||||
|
||||
for file in files:
|
||||
file_path = os.path.join(root, file)
|
||||
os.chmod(file_path, 0o755)
|
||||
|
||||
print("change permissions done")
|
||||
|
||||
|
||||
def main():
|
||||
try:
|
||||
print("stop service...")
|
||||
os.system("/etc/init.d/S95nanokvm stop")
|
||||
|
||||
print("start update......")
|
||||
|
||||
mkdir()
|
||||
download_firmware()
|
||||
# download_lib()
|
||||
update()
|
||||
change_permissions()
|
||||
|
||||
version = read("/kvmapp/version")
|
||||
print(f"update to {version} success.")
|
||||
print("restart service\nthe nanokvm will reboot")
|
||||
except Exception as e:
|
||||
print(f"update failed\n{e}")
|
||||
finally:
|
||||
shutil.rmtree(temporary)
|
||||
os.system("/etc/init.d/S95nanokvm restart")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -16,7 +16,7 @@ server
|
||||
├── middleware // サーバーミドルウェアコンポーネント
|
||||
├── proto // API リクエスト/レスポンス定義
|
||||
├── router // API ルートハンドラ
|
||||
├── service // コアサービスの実<EFBFBD><EFBFBD>
|
||||
├── service // コアサービスの実装
|
||||
├── utils // ユーティリティ関数
|
||||
└── main.go
|
||||
```
|
||||
@@ -39,17 +39,23 @@ cert:
|
||||
logger:
|
||||
level: info
|
||||
file: stdout
|
||||
|
||||
|
||||
# 認証設定 (enable/disable)
|
||||
# 注意: 認証を無効にするのは開発環境でのみ行ってください
|
||||
authentication: enable
|
||||
|
||||
# JWT 秘密鍵の設定
|
||||
# 空のままにすると、サーバー起動時にランダムな鍵が生成されます
|
||||
secretKey: ""
|
||||
jwt:
|
||||
# JWT 秘密鍵の設定。 空のままにすると、サーバー起動時にランダムな 64 バイトの鍵が自動的に生成されます。
|
||||
secretKey: ""
|
||||
# JWT トークンの有効期限(秒単位)。 デフォルト: 2678400 (31 日)
|
||||
refreshTokenDuration: 2678400
|
||||
# ユーザーがログアウトすると、すべての JWT トークンが無効になります。 デフォルト: true
|
||||
revokeTokensOnLogout: true
|
||||
|
||||
# カスタム STUN サーバーのアドレス
|
||||
stun: stun.l.google.com:19302
|
||||
|
||||
# カスタム TURN サーバーのアドレスと認証情報
|
||||
turn:
|
||||
turnAddr: turn.cloudflare.com:3478
|
||||
turnUser: example_user
|
||||
@@ -80,3 +86,12 @@ turn:
|
||||
1. デプロイ前に、ブラウザでアプリケーションを最新バージョンに更新します。手順は[こちら](https://wiki.sipeed.com/hardware/en/kvm/NanoKVM/system/updating.html)を参照してください。
|
||||
2. コンパイルして生成された `NanoKVM-Server` ファイルを使用して、NanoKVM の `/kvmapp/server/` ディレクトリ内の元のファイルを置き換えます。
|
||||
3. NanoKVM で `/etc/init.d/S95nanokvm restart` を実行してサービスを再起動します。
|
||||
|
||||
## 手動更新
|
||||
|
||||
> ファイルのアップロードには SSH が必要です。Web 設定で有効にしてください: `設定 > SSH`
|
||||
|
||||
1. [GitHub](https://github.com/sipeed/NanoKVM/releases) から最新のアプリケーションをダウンロードします。
|
||||
2. ダウンロードしたファイルを解凍し、解凍したフォルダーの名前を `kvmapp` に変更します。
|
||||
3. NanoKVM 上の既存の `/kvmapp` ディレクトリをバックアップし、新しい `kvmapp` フォルダーに置き換えます。
|
||||
4. NanoKVM で `/etc/init.d/S95nanokvm restart` を実行してサービスを再起動します。
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
## If you want to compile kvm_system yourself, please follow the steps below:
|
||||
# NanoKVM Support Instructions
|
||||
|
||||
1. Clone the MaixCDK repository: `git clone https://github.com/sipeed/MaixCDK.git`
|
||||
2. Improve the Compilation Environment, refer to [here](https://github.com/sipeed/MaixCDK/tree/main/docs/doc_zh#%E5%BF%AB%E9%80%9F%E5%BC%80%E5%A7%8B)
|
||||
3. Copy `./kvm_system` to `~/MaixCDK` and open it in terminal
|
||||
4. Execute `maixcdk build` and Select `maixcam` to complete the compilation
|
||||
5. Replace `/kvmapp/kvm_system/kvm_system` in the NanoKVM system with `dist/kvm_system_release/kvm_system`
|
||||
6. Execute: `/etc/init.d/S95nanokvm restart` on NanoKVM
|
||||
`/support` contains auxiliary functions for NanoKVM, such as image subsystem, system status monitoring, system updates, screen key drivers, and a few system functions.
|
||||
|
||||
Currently, NanoKVM is divided into two versions based on the main control chip: SG2002 (which includes NanoKVM-Lite/Full/PCIe) and H618 (including NanoKVM-Pro). Different chips have significantly different projects and compilation environments. To distinguish between them, they are stored separately in `/support/sg2002` and `/support/h618`.
|
||||
|
||||
5
support/README_ZH.md
Normal file
5
support/README_ZH.md
Normal file
@@ -0,0 +1,5 @@
|
||||
# NanoKVM support 说明
|
||||
|
||||
`/support`包含NanoKVM辅助性的功能,如图像子系统、系统状态监控、系统更新、屏幕按键驱动和少部分的系统功能
|
||||
|
||||
当前 NanoKVM 根据主控芯片的不同分为两个版本:SG2002(包含NanoKVM-Lite/Full/PCIe)和H618(包括NanoKVM-Pro),不同的芯片有差异较大的工程和编译环境,为做区分,将它们分别存放在`/support/sg2002`和`/support/h618`
|
||||
26
support/sg2002/README.md
Normal file
26
support/sg2002/README.md
Normal file
@@ -0,0 +1,26 @@
|
||||
# NanoKVM Support Instructions
|
||||
|
||||
## Environment Preparation
|
||||
1. NanoKVM-Lite/Full/PCIe is based on the SG2002 as the main control chip. The projects in the support section are compiled under the [MaixCDK](https://github.com/sipeed/MaixCDK) framework. Before compiling, please ensure that the `MaixCDK` environment is correctly configured. For configuration instructions, click [here](https://github.com/sipeed/MaixCDK/blob/main/docs/doc_zh/README.md).
|
||||
|
||||
## kvm_system Compilation Instructions
|
||||
|
||||
> The `kvm_system` is responsible for monitoring the NanoKVM system status, system updates, screen key drivers, and a few system functions, compiled with MaixCDK.
|
||||
|
||||
1. Before compiling, please ensure that the above-mentioned `MaixCDK` environment is correctly configured.
|
||||
2. Modify the paths of `MAIXCDK_PATH` and `NanoKVM_PATH` in `./build`.
|
||||
3. Execute `./build kvm_system` to compile `kvm_system`.
|
||||
4. Use `scp ./kvm_system/dist/kvm_system_release/kvm_system root@192.168.x.x:/kvmapp/kvm_system` to copy it to NanoKVM for testing.
|
||||
5. Use `./build add_to_kvmapp` to place the executable file into the `/kvmapp` installation package.
|
||||
6. Use `./build kvm_system clean` to clean the compilation of `kvm_system`.
|
||||
|
||||
## kvm_vision Compilation Instructions
|
||||
|
||||
> `kvm_vision` refers to the image acquisition and encoding subsystem of NanoKVM, compiled with MaixCDK to produce dynamic libraries for Go calls. Use `kvm_vision_test` to compile and test the dynamic library.
|
||||
|
||||
1. Before compiling, please ensure that the above-mentioned `MaixCDK` environment is correctly configured.
|
||||
2. Modify the paths of `MAIXCDK_PATH` and `NanoKVM_PATH` in `./build`.
|
||||
3. Execute `./build kvm_vision` to compile `kvm_vision_test`.
|
||||
4. You can test the dynamic libraries in `kvm_vision_test/dist/kvm_vision_test_release/dl_lib/`.
|
||||
5. Use `./build add_to_kvmapp` to place the dynamic libraries into the `/kvmapp` installation package.
|
||||
6. Use `./build kvm_vision clean` to clean the compilation of `kvm_vision`.
|
||||
26
support/sg2002/README_ZH.md
Normal file
26
support/sg2002/README_ZH.md
Normal file
@@ -0,0 +1,26 @@
|
||||
# NanoKVM support 说明
|
||||
|
||||
## 环境准备
|
||||
1. NanoKVM-Lite/Full/PCIe 以SG2002为主控芯片,support 部分的工程在[MaixCDK](https://github.com/sipeed/MaixCDK) 框架下编译。编译前,请保证`MaixCDK`环境已正确配置,配置教程点击[这里](https://github.com/sipeed/MaixCDK/blob/main/docs/doc_zh/README.md)
|
||||
|
||||
## kvm_system 编译说明
|
||||
|
||||
> `kvm_system` 负责 NanoKVM 系统状态监控、系统更新、屏幕按键驱动和少部分的系统功能,借助 MaixCDK 编译
|
||||
|
||||
1. 编译前,请保证上述 1.`MaixCDK`环境已正确配置
|
||||
2. 修改 `./build` 中 `MAIXCDK_PATH` 和 `NanoKVM_PATH`的路径
|
||||
3. 执行 `./build kvm_system` 编译 kvm_system
|
||||
4. 使用 `scp ./kvm_system/dist/kvm_system_release/kvm_system root@192.168.x.x:/kvmapp/kvm_system` 拷贝入 NanoKVM 测试
|
||||
5. 使用 `./build add_to_kvmapp` 可以将可执行文件放入 `/kvmapp` 安装包内
|
||||
6. 使用 `./build kvm_system clean` 可以清除 kvm_system 的编译
|
||||
|
||||
## kvm_vision 编译说明
|
||||
|
||||
> `kvm_vision` 是 NanoKVM 图像获取编码子系统的统称,使用MaixCDK编译出动态库供Go调用,使用 `kvm_vision_test` 编译和测试动态库
|
||||
|
||||
1. 编译前,请保证上述 1.`MaixCDK`环境已正确配置
|
||||
2. 修改 `./build` 中 `MAIXCDK_PATH` 和 `NanoKVM_PATH`的路径
|
||||
3. 执行 `./build kvm_vision` 编译 kvm_vision_test
|
||||
4. 可使用 `kvm_vision_test/dist/kvm_vision_test_release/dl_lib/` 中的动态库测试
|
||||
5. 使用 `./build add_to_kvmapp` 可以将动态库放入 `/kvmapp` 安装包内
|
||||
6. 使用 `./build kvm_vision clean` 可以清除 kvm_system 的编译
|
||||
66
support/sg2002/additional/kvm_mmf/CMakeLists.txt
Normal file
66
support/sg2002/additional/kvm_mmf/CMakeLists.txt
Normal file
@@ -0,0 +1,66 @@
|
||||
|
||||
list(APPEND ADD_REQUIREMENTS basic ini)
|
||||
list(APPEND ADD_INCLUDE "include")
|
||||
|
||||
# sophgo-middleware
|
||||
set(middleware_src_path "${CMAKE_CURRENT_SOURCE_DIR}/../3rd_party/sophgo-middleware/sophgo-middleware")
|
||||
|
||||
|
||||
set(source_dir "src")
|
||||
append_srcs_dir(ADD_SRCS "${source_dir}")
|
||||
|
||||
# middleware
|
||||
set(middleware_include_dir .
|
||||
${middleware_src_path}/v2/component/panel/${CONFIG_SOPHGO_MIDDLEWARE_CHIP}
|
||||
${middleware_src_path}/v2/include
|
||||
${middleware_src_path}/v2/include/isp/${CONFIG_SOPHGO_MIDDLEWARE_CHIP}
|
||||
${middleware_src_path}/v2/sample/common
|
||||
${middleware_src_path}/v2/uapi
|
||||
${middleware_src_path}/v2/3rdparty/inih
|
||||
${middleware_src_path}/v2/modules/ive/include/
|
||||
)
|
||||
list(APPEND ADD_INCLUDE ${middleware_include_dir})
|
||||
set_property(SOURCE ${middleware_include_dir} PROPERTY GENERATED 1)
|
||||
|
||||
append_srcs_dir(middleware_src_dir ${middleware_src_path}/v2/sample/common
|
||||
${middleware_src_path}/v2/component/isp/sensor/sg200x/lontium_lt6911
|
||||
)
|
||||
list(APPEND ADD_SRCS ${middleware_src_dir}
|
||||
"${source_dir}/kvm_mmf.cpp")
|
||||
set_property(SOURCE ${middleware_src_dir} PROPERTY GENERATED 1)
|
||||
|
||||
set(middleware_static_lib_file "")
|
||||
list(APPEND ADD_STATIC_LIB ${middleware_static_lib_file})
|
||||
set_property(SOURCE ${middleware_static_lib_file} PROPERTY GENERATED 1)
|
||||
|
||||
set(mmf_lib_dir ${middleware_src_path}/v2/lib)
|
||||
|
||||
if(CONFIG_SOPHGO_MIDDLEWARE_C_LIBRARY STREQUAL "musl")
|
||||
set(middleware_dynamic_lib_file ${mmf_lib_dir}/libcvi_bin.so
|
||||
${mmf_lib_dir}/libae.so
|
||||
${mmf_lib_dir}/libaf.so
|
||||
${mmf_lib_dir}/libawb.so
|
||||
${mmf_lib_dir}/libcvi_bin_isp.so
|
||||
${mmf_lib_dir}/libisp_algo.so
|
||||
${mmf_lib_dir}/libisp.so
|
||||
${mmf_lib_dir}/libsys.so
|
||||
${mmf_lib_dir}/libvdec.so
|
||||
${mmf_lib_dir}/libvenc.so
|
||||
${mmf_lib_dir}/libvpu.so
|
||||
${mmf_lib_dir}/3rd/libini.so)
|
||||
elseif(CONFIG_SOPHGO_MIDDLEWARE_C_LIBRARY STREQUAL "glibc")
|
||||
set(middleware_dynamic_lib_file ${mmf_lib_dir}/libcvi_vb.so
|
||||
${mmf_lib_dir}/libcvi_sys.so
|
||||
${mmf_lib_dir}/libcvi_debug.so
|
||||
)
|
||||
else()
|
||||
message(FATAL_ERROR "No sophgo middleware c library support, please check menuoconfig to select c library")
|
||||
endif()
|
||||
list(APPEND ADD_DYNAMIC_LIB ${middleware_dynamic_lib_file})
|
||||
set_property(SOURCE ${middleware_dynamic_lib_file} PROPERTY GENERATED 1)
|
||||
|
||||
list(APPEND ADD_DEFINITIONS_PRIVATE -DSENSOR_LONTIUM_LT6911
|
||||
-DSENSOR2_TYPE=LONTIUM_LT6911_2M_60FPS_8BIT)
|
||||
|
||||
|
||||
register_component(DYNAMIC)
|
||||
322
support/sg2002/additional/peripheral/port/maixcam/maix_i2c.cpp
Normal file
322
support/sg2002/additional/peripheral/port/maixcam/maix_i2c.cpp
Normal file
@@ -0,0 +1,322 @@
|
||||
/**
|
||||
* @author neucrack@sipeed, lxowalle@sipeed
|
||||
* @copyright Sipeed Ltd 2023-
|
||||
* @license Apache 2.0
|
||||
* @update 2023.9.8: Add framework, create this file.
|
||||
*/
|
||||
|
||||
|
||||
#include "maix_i2c.hpp"
|
||||
#include "maix_basic.hpp"
|
||||
#include "cstdio"
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <linux/i2c-dev.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#define DEV_PATH "/dev/i2c-%d"
|
||||
|
||||
namespace maix::peripheral::i2c
|
||||
{
|
||||
|
||||
std::vector<int> list_devices()
|
||||
{
|
||||
std::vector<int> data;
|
||||
// list all files in /dev, find i2c-*
|
||||
std::vector<std::string> *files = fs::listdir("/dev");
|
||||
for (auto &file : *files)
|
||||
{
|
||||
if (file.find("i2c-") != std::string::npos)
|
||||
{
|
||||
try
|
||||
{
|
||||
data.push_back(std::stoi(file.substr(4)));
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
log::error("i2c bus id %s format error", file.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
delete files;
|
||||
return data;
|
||||
}
|
||||
|
||||
I2C::I2C(int id, i2c::Mode mode, int freq, i2c::AddrSize addr_size)
|
||||
{
|
||||
char buf[32];
|
||||
|
||||
snprintf(buf, sizeof(buf), DEV_PATH, id);
|
||||
if(access(buf, F_OK) == 0){
|
||||
if (mode == i2c::SLAVE)
|
||||
{
|
||||
throw err::Exception(err::Err::ERR_NOT_IMPL, "i2c::SLAVE mode not implemented");
|
||||
}
|
||||
if (addr_size != i2c::SEVEN_BIT)
|
||||
{
|
||||
throw err::Exception(err::Err::ERR_NOT_IMPL, "addr_size " + std::to_string(addr_size) + " not support");
|
||||
}
|
||||
|
||||
int fd = ::open(buf, O_RDWR);
|
||||
if (fd < 0)
|
||||
{
|
||||
throw err::Exception(err::Err::ERR_IO, "open " + std::string(buf) + " failed");
|
||||
}
|
||||
_fd = fd;
|
||||
_freq = freq;
|
||||
_mode = mode;
|
||||
_addr_size = addr_size;
|
||||
} else {
|
||||
printf("not exit i2c\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
I2C::~I2C()
|
||||
{
|
||||
if (_fd > 0)
|
||||
{
|
||||
::close(_fd);
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<int> I2C::scan(int addr)
|
||||
{
|
||||
std::vector<int> data;
|
||||
int addr_start = 0x08;
|
||||
int addr_end = 0x77;
|
||||
if(addr > 0)
|
||||
{
|
||||
addr_start = addr;
|
||||
addr_end = addr;
|
||||
}
|
||||
|
||||
if (_mode != i2c::Mode::MASTER)
|
||||
{
|
||||
log::error("Only for master mode");
|
||||
return data;
|
||||
}
|
||||
|
||||
switch (_addr_size)
|
||||
{
|
||||
case i2c::AddrSize::SEVEN_BIT:
|
||||
for (int address = addr_start; address <= addr_end; ++address)
|
||||
{
|
||||
if (::ioctl(_fd, I2C_SLAVE, address) < 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
unsigned char buffer[1];
|
||||
if (::read(_fd, buffer, sizeof(buffer)) >= 0)
|
||||
{
|
||||
data.push_back(address);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
log::error("bit %d not support", _addr_size);
|
||||
return data;
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
int I2C::writeto(int addr, const uint8_t *data, int len)
|
||||
{
|
||||
if (_mode != i2c::Mode::MASTER)
|
||||
{
|
||||
log::error("Only for master mode");
|
||||
return (int)-err::Err::ERR_NOT_PERMIT;
|
||||
}
|
||||
|
||||
if (0 != ioctl(_fd, I2C_SLAVE, addr))
|
||||
{
|
||||
// log::error("set slave address failed");
|
||||
return (int)-err::Err::ERR_IO;
|
||||
}
|
||||
|
||||
if (len != ::write(_fd, data, len))
|
||||
{
|
||||
log::error("write failed");
|
||||
return (int)-err::Err::ERR_IO;
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
int I2C::writeto(int addr, const std::vector<unsigned char> data)
|
||||
{
|
||||
return writeto(addr, data.data(), (int)data.size());
|
||||
}
|
||||
|
||||
int I2C::writeto(int addr, const Bytes &data)
|
||||
{
|
||||
return writeto(addr, data.data, (int)data.size());
|
||||
}
|
||||
|
||||
Bytes* I2C::readfrom(int addr, int len)
|
||||
{
|
||||
Bytes *data = new Bytes(nullptr, len);
|
||||
|
||||
if (_mode != i2c::Mode::MASTER)
|
||||
{
|
||||
log::error("Only for master mode");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (0 != ioctl(_fd, I2C_SLAVE, addr))
|
||||
{
|
||||
// log::error("set slave address failed");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (len != ::read(_fd, data->data, len))
|
||||
{
|
||||
log::error("read failed");
|
||||
delete data;
|
||||
return nullptr;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
int I2C::writeto_mem(int addr, int mem_addr, const uint8_t *data, int len, int mem_addr_size, bool mem_addr_le)
|
||||
{
|
||||
if (_mode != i2c::Mode::MASTER)
|
||||
{
|
||||
log::error("Only for master mode");
|
||||
return (int)-err::Err::ERR_NOT_PERMIT;
|
||||
}
|
||||
if(mem_addr_size % 8 != 0)
|
||||
{
|
||||
log::error("mem_addr_size must be multiple of 8");
|
||||
return (int)-err::Err::ERR_IO;
|
||||
}
|
||||
|
||||
if (0 != ioctl(_fd, I2C_SLAVE, addr))
|
||||
{
|
||||
// log::error("set slave address failed");
|
||||
return (int)-err::Err::ERR_IO;
|
||||
}
|
||||
|
||||
std::vector<unsigned char> data_final;
|
||||
|
||||
if(mem_addr_size == 8)
|
||||
{
|
||||
data_final.push_back((unsigned char)mem_addr);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(mem_addr_le)
|
||||
{
|
||||
for(int i = 0; i < mem_addr_size / 8; i++)
|
||||
{
|
||||
data_final.push_back((unsigned char)(mem_addr & 0xff));
|
||||
mem_addr >>= 8;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(int i = 0; i < mem_addr_size / 8; i++)
|
||||
{
|
||||
data_final.push_back((unsigned char)(mem_addr >> (8 * (mem_addr_size / 8 - i - 1))));
|
||||
}
|
||||
}
|
||||
}
|
||||
for(int i = 0; i < len; i++)
|
||||
{
|
||||
data_final.push_back(data[i]);
|
||||
}
|
||||
int write_len = ::write(_fd, data_final.data(), data_final.size());
|
||||
if (data_final.size() != (size_t)write_len)
|
||||
{
|
||||
log::error("write failed, write_len: %d", write_len);
|
||||
return (int)-err::Err::ERR_IO;
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
int I2C::writeto_mem(int addr, int mem_addr, const std::vector<unsigned char> data, int mem_addr_size, bool mem_addr_le)
|
||||
{
|
||||
return writeto_mem(addr, mem_addr, data.data(), (int)data.size(), mem_addr_size, mem_addr_le);
|
||||
}
|
||||
|
||||
int I2C::writeto_mem(int addr, int mem_addr, const Bytes &data, int mem_addr_size, bool mem_addr_le)
|
||||
{
|
||||
return writeto_mem(addr, mem_addr, data.data, (int)data.size(), mem_addr_size, mem_addr_le);
|
||||
}
|
||||
|
||||
Bytes* I2C::readfrom_mem(int addr, int mem_addr, int len, int mem_addr_size, bool mem_addr_le)
|
||||
{
|
||||
// write mem_addr and restart to read
|
||||
if (_mode != i2c::Mode::MASTER)
|
||||
{
|
||||
log::error("Only for master mode");
|
||||
return nullptr;
|
||||
}
|
||||
if(mem_addr_size % 8 != 0)
|
||||
{
|
||||
log::error("mem_addr_size must be multiple of 8");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// write mem_addr first and restart to read
|
||||
if (0 != ioctl(_fd, I2C_SLAVE, addr))
|
||||
{
|
||||
// log::error("set slave address failed");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::vector<unsigned char> data_final;
|
||||
if(mem_addr_size == 8)
|
||||
{
|
||||
data_final.push_back((unsigned char)mem_addr);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(mem_addr_le)
|
||||
{
|
||||
for(int i = 0; i < mem_addr_size / 8; i++)
|
||||
{
|
||||
data_final.push_back((unsigned char)(mem_addr & 0xff));
|
||||
mem_addr >>= 8;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
for(int i = 0; i < mem_addr_size / 8; i++)
|
||||
{
|
||||
data_final.push_back((unsigned char)(mem_addr >> (8 * (mem_addr_size / 8 - i - 1))));
|
||||
}
|
||||
}
|
||||
}
|
||||
// write read with I2C_RDWR
|
||||
struct i2c_msg msgs[2];
|
||||
msgs[0].addr = addr;
|
||||
msgs[0].flags = 0;
|
||||
msgs[0].len = data_final.size();
|
||||
msgs[0].buf = data_final.data();
|
||||
|
||||
Bytes *data = new Bytes(nullptr, len);
|
||||
msgs[1].addr = addr;
|
||||
msgs[1].flags = I2C_M_RD;
|
||||
msgs[1].len = len;
|
||||
msgs[1].buf = data->data;
|
||||
|
||||
struct i2c_rdwr_ioctl_data msgset;
|
||||
msgset.msgs = msgs;
|
||||
msgset.nmsgs = 2;
|
||||
|
||||
int read_len = ioctl(_fd, I2C_RDWR, &msgset);
|
||||
if (read_len != 2)
|
||||
{
|
||||
log::error("read failed");
|
||||
delete data;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -18,7 +18,7 @@ namespace maix::image
|
||||
|
||||
/**
|
||||
* Image formats
|
||||
* @attention for developers, update this enum will also need to update the fmt_size in maix_image.cpp
|
||||
* @attention for MaixPy firmware developers, update this enum will also need to update the fmt_size and fmt_names too !!!
|
||||
* @maixpy maix.image.Format
|
||||
*/
|
||||
enum Format
|
||||
@@ -36,6 +36,22 @@ namespace maix::image
|
||||
FMT_YVU420P, // YYY...VVV...UUU
|
||||
FMT_YUV420P, // YYY...UUU...VVV
|
||||
FMT_GRAYSCALE,
|
||||
FMT_BGGR6, // 6-bit Bayer format with a BGGR pattern.
|
||||
FMT_GBRG6, // 6-bit Bayer format with a GBRG pattern.
|
||||
FMT_GRBG6, // 6-bit Bayer format with a GRBG pattern.
|
||||
FMT_RGGB6, // 6-bit Bayer format with a RGGB pattern.
|
||||
FMT_BGGR8, // 8-bit Bayer format with a BGGR pattern.
|
||||
FMT_GBRG8, // 8-bit Bayer format with a GBRG pattern.
|
||||
FMT_GRBG8, // 8-bit Bayer format with a GRBG pattern.
|
||||
FMT_RGGB8, // 8-bit Bayer format with a RGGB pattern.
|
||||
FMT_BGGR10, // 10-bit Bayer format with a BGGR pattern.
|
||||
FMT_GBRG10, // 10-bit Bayer format with a GBRG pattern.
|
||||
FMT_GRBG10, // 10-bit Bayer format with a GRBG pattern.
|
||||
FMT_RGGB10, // 10-bit Bayer format with a RGGB pattern.
|
||||
FMT_BGGR12, // 12-bit Bayer format with a BGGR pattern.
|
||||
FMT_GBRG12, // 12-bit Bayer format with a GBRG pattern.
|
||||
FMT_GRBG12, // 12-bit Bayer format with a GRBG pattern.
|
||||
FMT_RGGB12, // 12-bit Bayer format with a RGGB pattern.
|
||||
FMT_UNCOMPRESSED_MAX,
|
||||
|
||||
// compressed format below, not compressed should define upper
|
||||
@@ -45,32 +61,8 @@ namespace maix::image
|
||||
FMT_COMPRESSED_MAX,
|
||||
|
||||
FMT_INVALID = 0xFF // format not valid
|
||||
};
|
||||
// enum Format
|
||||
// {
|
||||
// FMT_RGB888 = 0, // RGBRGB...RGB, R at the lowest address
|
||||
// FMT_BGR888 = 1, // BGRBGR...BGR, B at the lowest address
|
||||
// FMT_RGBA8888 = 2, // RGBARGBA...RGBA, R at the lowest address
|
||||
// FMT_BGRA8888 = 3, // BGRABGRA...BGRA, B at the lowest address
|
||||
// FMT_RGB565 = 4,
|
||||
// FMT_BGR565 = 5,
|
||||
// FMT_YUV422SP = 6, // YYY...UVUVUV...UVUV
|
||||
// FMT_YUV422P = 7, // YYY...UUU...VVV
|
||||
// FMT_YVU420SP = 8, // YYY...VUVUVU...VUVU, NV21
|
||||
// FMT_YUV420SP = 9, // YYY...UVUVUV...UVUV, NV12
|
||||
// FMT_YVU420P = 10, // YYY...VVV...UUU
|
||||
// FMT_YUV420P = 11, // YYY...UUU...VVV
|
||||
// FMT_GRAYSCALE = 12, // YYY...
|
||||
// FMT_UNCOMPRESSED_MAX,
|
||||
}; // !!!! update this section please update fmt_size and fmt_names too !!!!
|
||||
|
||||
// // compressed format below, not compressed should define upper
|
||||
// FMT_COMPRESSED_MIN = 200,
|
||||
// FMT_JPEG = 201,
|
||||
// FMT_PNG = 202,
|
||||
// FMT_COMPRESSED_MAX,
|
||||
|
||||
// FMT_INVALID = 0xFF // format not valid
|
||||
// };
|
||||
/**
|
||||
* Image format size in bytes
|
||||
* @attention It's a copy of this variable in MaixPy,
|
||||
@@ -91,12 +83,29 @@ namespace maix::image
|
||||
1.5,
|
||||
1.5,
|
||||
1.5,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
1, // grayscale
|
||||
0.75, // 6-bit Bayer format
|
||||
0.75, // 6-bit Bayer format
|
||||
0.75, // 6-bit Bayer format
|
||||
0.75, // 6-bit Bayer format
|
||||
1, // 8-bit Bayer format
|
||||
1, // 8-bit Bayer format
|
||||
1, // 8-bit Bayer format
|
||||
1, // 8-bit Bayer format
|
||||
1.25, // 10-bit Bayer format
|
||||
1.25, // 10-bit Bayer format
|
||||
1.25, // 10-bit Bayer format
|
||||
1.25, // 10-bit Bayer format
|
||||
1.5, // 12-bit Bayer format
|
||||
1.5, // 12-bit Bayer format
|
||||
1.5, // 12-bit Bayer format
|
||||
1.5, // 12-bit Bayer format
|
||||
0, // uncompereed_max
|
||||
0, // compressed_min
|
||||
1, // jpeg
|
||||
1, // png
|
||||
0, // compressed_max
|
||||
0 // invalid
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -114,10 +123,32 @@ namespace maix::image
|
||||
"YUV422P",
|
||||
"YVU420SP",
|
||||
"YUV420SP",
|
||||
"YVU420P"
|
||||
"YVU420P",
|
||||
"YUV420P",
|
||||
"GRAYSCALE",
|
||||
"MAX"};
|
||||
"BGGR6",
|
||||
"GBRG6",
|
||||
"GRBG6",
|
||||
"RG6B6",
|
||||
"BGGR8",
|
||||
"GBRG8",
|
||||
"GRBG8",
|
||||
"RG6B8",
|
||||
"BGGR10",
|
||||
"GBRG10",
|
||||
"GRBG10",
|
||||
"RG6B10",
|
||||
"BGGR12",
|
||||
"GBRG12",
|
||||
"GRBG12",
|
||||
"RG6B12",
|
||||
"UNCOMPRESSED_MAX",
|
||||
"COMPRESSED_MIN",
|
||||
"JPEG",
|
||||
"PNG",
|
||||
"COMPRESSED_MAX",
|
||||
"INVALID"
|
||||
};
|
||||
|
||||
/**
|
||||
* Image size type
|
||||
@@ -171,7 +202,7 @@ namespace maix::image
|
||||
* @param index 0 for width, 1 for height
|
||||
* @return int& width or height
|
||||
* @maixpy maix.image.Size.__getitem__
|
||||
* @maixcdk maix.image.Size.[]
|
||||
* @maixcdk maix.image.Size.operator[]
|
||||
*/
|
||||
int &operator[](int index)
|
||||
{
|
||||
@@ -267,4 +298,16 @@ namespace maix::image
|
||||
EDGE_CANNY,
|
||||
EDGE_SIMPLE,
|
||||
};
|
||||
|
||||
/**
|
||||
* FlipDir
|
||||
* @maixpy maix.image.FlipDir
|
||||
*/
|
||||
enum class FlipDir
|
||||
{
|
||||
X,
|
||||
Y,
|
||||
XY
|
||||
};
|
||||
|
||||
}
|
||||
164
support/sg2002/build
Executable file
164
support/sg2002/build
Executable file
@@ -0,0 +1,164 @@
|
||||
#!/bin/bash
|
||||
|
||||
export MAIXCDK_PATH=~/MaixCDK
|
||||
export NanoKVM_PATH=~/NanoKVM
|
||||
|
||||
Project_Name="None"
|
||||
Project_PATH="None"
|
||||
Project_Action="None"
|
||||
KVMAPP_PATH="$NanoKVM_PATH/kvmapp"
|
||||
|
||||
maixcdk_build() {
|
||||
local input_value="$1"
|
||||
|
||||
DIST_PATH="./dist"
|
||||
rm -rf $DIST_PATH
|
||||
|
||||
if [ "$input_value" = "from_zero" ]
|
||||
then
|
||||
maixcdk build <<EOF
|
||||
2
|
||||
EOF
|
||||
else
|
||||
maixcdk build
|
||||
fi
|
||||
}
|
||||
|
||||
chack_build(){
|
||||
DIST_PATH="./dist"
|
||||
if [ -d "$DIST_PATH" ]
|
||||
then
|
||||
echo "SUCCESS"
|
||||
else
|
||||
echo "FAILURE"
|
||||
fi
|
||||
}
|
||||
|
||||
maixcdk_clean(){
|
||||
maixcdk distclean
|
||||
maixcdk clean
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
kvm_system)
|
||||
Project_Name="kvm_system"
|
||||
Project_PATH="$NanoKVM_PATH/support/sg2002/kvm_system"
|
||||
echo -e "\e[36m[build] \e[32mProject: kvm_system \e[0m"
|
||||
;;
|
||||
kvm_vision)
|
||||
Project_Name="kvm_vision"
|
||||
Project_PATH="$NanoKVM_PATH/support/sg2002/kvm_vision_test"
|
||||
echo -e "\e[36m[build] \e[32mProject: kvm_system \e[0m"
|
||||
;;
|
||||
*)
|
||||
echo -e "\e[36m[build] \e[31mInvalid project name \e[0m"
|
||||
echo -e "\e[36m[build] \e[32mPlease select a project:\e[0m"
|
||||
echo -e "0: kvm_system"
|
||||
echo -e "1: kvm_vision"
|
||||
while true; do
|
||||
read -p "Please enter 0 or 1 : " input
|
||||
if [[ "$input" -eq 0 ]]
|
||||
then
|
||||
Project_Name="kvm_system"
|
||||
Project_PATH="$NanoKVM_PATH/support/sg2002/kvm_system"
|
||||
break
|
||||
elif [[ "$input" -eq 1 ]]
|
||||
then
|
||||
Project_Name="kvm_vision"
|
||||
Project_PATH="$NanoKVM_PATH/support/sg2002/kvm_vision_test"
|
||||
break
|
||||
else
|
||||
echo -e "\e[36m[build] \e[31mInvalid Index \e[0m"
|
||||
fi
|
||||
done
|
||||
esac
|
||||
|
||||
if [ -z "$2" ]
|
||||
then
|
||||
Project_Action="build"
|
||||
else
|
||||
Project_Action=$2
|
||||
fi
|
||||
|
||||
if [ ! "$Project_Name" = "None" ]
|
||||
then
|
||||
case "$Project_Action" in
|
||||
build)
|
||||
# echo -e "\e[36m[build] \e[32mStart using MaixCDK to compile kvm_system...\e[0m"
|
||||
|
||||
JSON_PATH="$Project_PATH/build/config/project_vars.json"
|
||||
Platform_Char="\"PLATFORM\": \"maixcam\""
|
||||
|
||||
if [ ! -e "$MAIXCDK_PATH/components/kvm" ]
|
||||
then
|
||||
echo -e "\e[36m[build] \e[32mDetected that the library has not been modified; first, move the library\e[0m"
|
||||
|
||||
mv -f $MAIXCDK_PATH/components/vision $NanoKVM_PATH/support/sg2002/additional/original
|
||||
# mv $MAIXCDK_PATH/components/maixcam_lib $NanoKVM_PATH/support/sg2002/additional/original
|
||||
mv -f $MAIXCDK_PATH/components/peripheral/port/maixcam/maix_i2c.cpp $NanoKVM_PATH/support/sg2002/additional/original
|
||||
mv -f $MAIXCDK_PATH/components/3rd_party/sophgo-middleware/sophgo-middleware/v2/sample/common/sample_common_sensor.c $NanoKVM_PATH/support/sg2002/additional/original
|
||||
|
||||
cp -rf $NanoKVM_PATH/support/sg2002/additional/kvm $MAIXCDK_PATH/components
|
||||
cp -rf $NanoKVM_PATH/support/sg2002/additional/kvm_mmf $MAIXCDK_PATH/components
|
||||
cp -rf $NanoKVM_PATH/support/sg2002/additional/vision $MAIXCDK_PATH/components
|
||||
cp -f $NanoKVM_PATH/support/sg2002/additional/peripheral/port/maixcam/maix_i2c.cpp $MAIXCDK_PATH/components/peripheral/port/maixcam/maix_i2c.cpp
|
||||
cp -f $NanoKVM_PATH/support/sg2002/additional/sophgo-middleware/v2/sample/common/sample_common_sensor.c $MAIXCDK_PATH/components/3rd_party/sophgo-middleware/sophgo-middleware/v2/sample/common/
|
||||
|
||||
echo -e "\e[36m[build] \e[32mMove the library completed!\e[0m"
|
||||
fi
|
||||
|
||||
cd $Project_PATH
|
||||
if [ -f $JSON_PATH ]
|
||||
then
|
||||
if grep -q $Platform_Char $JSON_PATH; then
|
||||
maixcdk_build
|
||||
else
|
||||
maixcdk_clean
|
||||
maixcdk_build "from_zero"
|
||||
fi
|
||||
else
|
||||
maixcdk_build "from_zero"
|
||||
fi
|
||||
|
||||
RES=$(chack_build)
|
||||
|
||||
if [ "$RES" = "SUCCESS" ]
|
||||
then
|
||||
echo -e "\e[36m[build] \e[32mBuild completed! Use \e[34m./build $Project_Name add_to_kvmapp\e[32m to add it to kvmapp.\e[0m"
|
||||
else
|
||||
echo -e "\e[36m[build] \e[31mBuild Error!\e[0m"
|
||||
fi
|
||||
;;
|
||||
clean)
|
||||
cd $Project_PATH
|
||||
maixcdk_clean
|
||||
echo -e "\e[36m[build] \e[32m$Project_Name cleanup completed!\e[0m"
|
||||
;;
|
||||
add_to_kvmapp)
|
||||
if [ "$Project_Name" = "kvm_system" ]
|
||||
then
|
||||
SOURCE_PATH="$Project_PATH/dist/kvm_system_release/kvm_system"
|
||||
TARGET_PATH="$KVMAPP_PATH/kvm_system/kvm_system"
|
||||
chmod +x $SOURCE_PATH
|
||||
rm -f $TARGET_PATH
|
||||
else
|
||||
SOURCE_PATH="$Project_PATH/dist/kvm_vision_test_release/dl_lib"
|
||||
TARGET_PATH="$KVMAPP_PATH/server/"
|
||||
fi
|
||||
if [ -e $SOURCE_PATH ]
|
||||
then
|
||||
cp -rf $SOURCE_PATH $TARGET_PATH
|
||||
echo -e "\e[36m[build] \e[32mkvm_system has been moved to kvmapp.\e[0m"
|
||||
else
|
||||
echo -e "\e[36m[build] \e[31mThe source file does not exist. Please compile using \e[34m./build kvm_system \e[31mfirst.\e[0m"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo -e "\e[36m[build] \e[31mInvalid Action: \e[34m$2 \e[0m"
|
||||
echo -e "\e[36m[build] \e[31mUsage: $0 [Project Name]{kvm_system|kvm_vision} [Action]{-/build|clean|add_to_kvmapp} e.g. \e[34m./build kvm_system clean \e[0m"
|
||||
exit 1
|
||||
esac
|
||||
else
|
||||
echo -e "\e[36m[build] \e[31mInvalid Name \e[0m"
|
||||
exit 1
|
||||
fi
|
||||
@@ -43,6 +43,8 @@ int get_ping_allow_state()
|
||||
} else {
|
||||
kvm_sys_state.ping_allow = 1;
|
||||
}
|
||||
|
||||
return kvm_sys_state.ping_allow;
|
||||
}
|
||||
|
||||
// net_port
|
||||
@@ -51,7 +53,7 @@ int get_ip_addr(ip_addr_t ip_type)
|
||||
switch (ip_type){
|
||||
case ETH_IP: // eth_addr
|
||||
if(strcmp(ip_address()["eth0"].c_str(), (char*)kvm_sys_state.eth_addr) != 0){
|
||||
if(*(ip_address()["eth0"].c_str()) == NULL){
|
||||
if(*(ip_address()["eth0"].c_str()) == 0){
|
||||
printf("can`t get ip addr\r\n");
|
||||
kvm_sys_state.eth_addr[0] = 0;
|
||||
return 0;
|
||||
@@ -66,7 +68,7 @@ int get_ip_addr(ip_addr_t ip_type)
|
||||
return 1;
|
||||
case WiFi_IP: // wifi_addr
|
||||
if(strcmp(ip_address()["wlan0"].c_str(), (char*)kvm_sys_state.wifi_addr) != 0){
|
||||
if(*(ip_address()["wlan0"].c_str()) == NULL){
|
||||
if(*(ip_address()["wlan0"].c_str()) == 0){
|
||||
printf("can`t get ip addr\r\n");
|
||||
kvm_sys_state.wifi_addr[0] = 0;
|
||||
return 0;
|
||||
@@ -80,7 +82,7 @@ int get_ip_addr(ip_addr_t ip_type)
|
||||
}
|
||||
return 1;
|
||||
case Tailscale_IP: // tail_addr
|
||||
if(*(ip_address()["tailscale0"].c_str()) == NULL){
|
||||
if(*(ip_address()["tailscale0"].c_str()) == 0){
|
||||
printf("can`t get ip addr\r\n");
|
||||
kvm_sys_state.tail_addr[0] = 0;
|
||||
return 0;
|
||||
@@ -93,7 +95,7 @@ int get_ip_addr(ip_addr_t ip_type)
|
||||
printf("\r\n");
|
||||
return 1;
|
||||
case RNDIS_IP: // rndis_addr
|
||||
if(*(ip_address()["usb0"].c_str()) == NULL){
|
||||
if(*(ip_address()["usb0"].c_str()) == 0){
|
||||
printf("can`t get ip addr\r\n");
|
||||
kvm_sys_state.rndis_addr[0] = 0;
|
||||
return 0;
|
||||
@@ -465,4 +467,6 @@ void kvm_update_tailscale_state(void)
|
||||
uint8_t ion_free_space(void)
|
||||
{
|
||||
//cat /sys/kernel/debug/ion/cvi_carveout_heap_dump/summary | grep "usage rate:" | awk '{print $2}'
|
||||
|
||||
return 0;
|
||||
}
|
||||
0
support/sg2002/kvm_vision_test/main/Kconfig
Normal file
0
support/sg2002/kvm_vision_test/main/Kconfig
Normal file
@@ -1,158 +0,0 @@
|
||||
|
||||
list(APPEND ADD_REQUIREMENTS basic ini)
|
||||
list(APPEND ADD_INCLUDE "include")
|
||||
|
||||
# sophgo-middleware
|
||||
set(middleware_version_str "${CONFIG_SOPHGO_MIDDLEWARE_VERSION_MAJOR}.${CONFIG_SOPHGO_MIDDLEWARE_VERSION_MINOR}.${CONFIG_SOPHGO_MIDDLEWARE_VERSION_PATCH}")
|
||||
set(middleware_unzip_path "${DL_EXTRACTED_PATH}/sophgo-middleware")
|
||||
set(middleware_src_path "${middleware_unzip_path}/sophgo-middleware-${middleware_version_str}")
|
||||
|
||||
|
||||
set(source_dir "src")
|
||||
append_srcs_dir(ADD_SRCS "${source_dir}")
|
||||
|
||||
# middleware
|
||||
set(middleware_include_dir .
|
||||
${middleware_src_path}/v2/component/panel/${CONFIG_SOPHGO_MIDDLEWARE_CHIP}
|
||||
${middleware_src_path}/v2/include
|
||||
${middleware_src_path}/v2/include/isp/${CONFIG_SOPHGO_MIDDLEWARE_CHIP}
|
||||
${middleware_src_path}/v2/sample/common
|
||||
${middleware_src_path}/v2/uapi
|
||||
${middleware_src_path}/v2/3rdparty/inih
|
||||
${middleware_src_path}/v2/modules/ive/include/
|
||||
)
|
||||
list(APPEND ADD_INCLUDE ${middleware_include_dir})
|
||||
set_property(SOURCE ${middleware_include_dir} PROPERTY GENERATED 1)
|
||||
|
||||
append_srcs_dir(middleware_src_dir ${middleware_src_path}/v2/sample/common
|
||||
${middleware_src_path}/v2/component/isp/sensor/sg200x/lontium_lt6911
|
||||
)
|
||||
list(APPEND ADD_SRCS ${middleware_src_dir}
|
||||
"${source_dir}/kvm_mmf.cpp")
|
||||
set_property(SOURCE ${middleware_src_dir} PROPERTY GENERATED 1)
|
||||
|
||||
set(middleware_static_lib_file "")
|
||||
list(APPEND ADD_STATIC_LIB ${middleware_static_lib_file})
|
||||
set_property(SOURCE ${middleware_static_lib_file} PROPERTY GENERATED 1)
|
||||
|
||||
if(${middleware_version_str} VERSION_EQUAL "0.0.4")
|
||||
set(mmf_lib_dir ${middleware_src_path}/v2/lib)
|
||||
else()
|
||||
set(mmf_lib_dir ${middleware_src_path}/v2/${CONFIG_SOPHGO_MIDDLEWARE_CHIP}/lib_${CONFIG_SOPHGO_MIDDLEWARE_C_LIBRARY}_riscv64)
|
||||
endif()
|
||||
if(CONFIG_SOPHGO_MIDDLEWARE_C_LIBRARY STREQUAL "musl")
|
||||
if(${middleware_version_str} VERSION_EQUAL "0.0.4")
|
||||
set(middleware_dynamic_lib_file ${mmf_lib_dir}/libcvi_bin.so
|
||||
${mmf_lib_dir}/libae.so
|
||||
${mmf_lib_dir}/libaf.so
|
||||
${mmf_lib_dir}/libawb.so
|
||||
${mmf_lib_dir}/libcvi_bin_isp.so
|
||||
${mmf_lib_dir}/libisp_algo.so
|
||||
${mmf_lib_dir}/libisp.so
|
||||
${mmf_lib_dir}/libsys.so
|
||||
${mmf_lib_dir}/libvdec.so
|
||||
${mmf_lib_dir}/libvenc.so
|
||||
${mmf_lib_dir}/libvpu.so
|
||||
${mmf_lib_dir}/3rd/libini.so)
|
||||
else()
|
||||
set(middleware_dynamic_lib_file ${mmf_lib_dir}/libcvi_bin.so
|
||||
${mmf_lib_dir}/libae.so
|
||||
${mmf_lib_dir}/libaf.so
|
||||
${mmf_lib_dir}/libawb.so
|
||||
${mmf_lib_dir}/libcipher.so
|
||||
${mmf_lib_dir}/libcvi_bin_isp.so
|
||||
${mmf_lib_dir}/libisp_algo.so
|
||||
${mmf_lib_dir}/libisp.so
|
||||
# ${mmf_lib_dir}/libraw_replay.so
|
||||
# ${mmf_lib_dir}/libsns_full.so
|
||||
# ${mmf_lib_dir}/libsns_gc4653.so
|
||||
${mmf_lib_dir}/libsys.so
|
||||
${mmf_lib_dir}/libvdec.so
|
||||
${mmf_lib_dir}/libvenc.so
|
||||
${mmf_lib_dir}/libvpu.so
|
||||
${mmf_lib_dir}/libz.so
|
||||
${mmf_lib_dir}/3rd/libini.so)
|
||||
endif()
|
||||
elseif(CONFIG_SOPHGO_MIDDLEWARE_C_LIBRARY STREQUAL "glibc")
|
||||
set(middleware_dynamic_lib_file ${mmf_lib_dir}/libcvi_vb.so
|
||||
${mmf_lib_dir}/libcvi_sys.so
|
||||
${mmf_lib_dir}/libcvi_debug.so
|
||||
)
|
||||
else()
|
||||
message(FATAL_ERROR "No sophgo middleware c library support, please check menuoconfig to select c library")
|
||||
endif()
|
||||
list(APPEND ADD_DYNAMIC_LIB ${middleware_dynamic_lib_file})
|
||||
set_property(SOURCE ${middleware_dynamic_lib_file} PROPERTY GENERATED 1)
|
||||
|
||||
list(APPEND ADD_DEFINITIONS_PRIVATE -DSENSOR_LONTIUM_LT6911
|
||||
-DSENSOR2_TYPE=LONTIUM_LT6911_2M_60FPS_8BIT)
|
||||
|
||||
|
||||
register_component(DYNAMIC)
|
||||
|
||||
|
||||
|
||||
# Config enable component2 or not in Kconfig
|
||||
################# Add include #################
|
||||
# list(APPEND ADD_INCLUDE "include"
|
||||
# )
|
||||
# list(APPEND ADD_PRIVATE_INCLUDE "include_private")
|
||||
###############################################
|
||||
|
||||
############## Add source files ###############
|
||||
# list(APPEND ADD_SRCS "src/lib2.c"
|
||||
# )
|
||||
# FILE(GLOB_RECURSE EXTRA_SRC "src/*.c")
|
||||
# FILE(GLOB EXTRA_SRC "src/*.c")
|
||||
# list(APPEND ADD_SRCS ${EXTRA_SRC})
|
||||
# aux_source_directory(src ADD_SRCS) # collect all source file in src dir, will set var ADD_SRCS
|
||||
# append_srcs_dir(ADD_SRCS "src") # append source file in src dir to var ADD_SRCS
|
||||
# list(REMOVE_ITEM COMPONENT_SRCS "src/test.c")
|
||||
# set(ADD_ASM_SRCS "src/asm.S")
|
||||
# list(APPEND ADD_SRCS ${ADD_ASM_SRCS})
|
||||
# SET_PROPERTY(SOURCE ${ADD_ASM_SRCS} PROPERTY LANGUAGE C) # set .S ASM file as C language
|
||||
# SET_SOURCE_FILES_PROPERTIES(${ADD_ASM_SRCS} PROPERTIES COMPILE_FLAGS "-x assembler-with-cpp -D BBBBB")
|
||||
###############################################
|
||||
|
||||
|
||||
###### Add required/dependent components ######
|
||||
# list(APPEND ADD_REQUIREMENTS basic ini)
|
||||
###############################################
|
||||
|
||||
###### Add link search path for requirements/libs ######
|
||||
# list(APPEND ADD_LINK_SEARCH_PATH "${CONFIG_TOOLCHAIN_PATH}/lib")
|
||||
# list(APPEND ADD_REQUIREMENTS pthread m) # add system libs, pthread and math lib for example here
|
||||
# set (OpenCV_DIR opencv/lib/cmake/opencv4)
|
||||
# find_package(OpenCV REQUIRED)
|
||||
###############################################
|
||||
|
||||
############ Add static libs ##################
|
||||
# list(APPEND ADD_STATIC_LIB "lib/libtest.a")
|
||||
###############################################
|
||||
|
||||
############ Add dynamic libs ##################
|
||||
# list(APPEND ADD_DYNAMIC_LIB "lib/arch/v831/libmaix_nn.so"
|
||||
# "lib/arch/v831/libmaix_cam.so"
|
||||
# )
|
||||
###############################################
|
||||
|
||||
#### Add compile option for this component ####
|
||||
#### Just for this component, won't affect other
|
||||
#### modules, including component that depend
|
||||
#### on this component
|
||||
# list(APPEND ADD_DEFINITIONS_PRIVATE -DAAAAA=1)
|
||||
|
||||
#### Add compile option for this component
|
||||
#### and components denpend on this component
|
||||
# list(APPEND ADD_DEFINITIONS -DAAAAA222=1
|
||||
# -DAAAAA333=1)
|
||||
###############################################
|
||||
|
||||
############ Add static libs ##################
|
||||
#### Update parent's variables like CMAKE_C_LINK_FLAGS
|
||||
# set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -Wl,--start-group libmaix/libtest.a -ltest2 -Wl,--end-group" PARENT_SCOPE)
|
||||
###############################################
|
||||
|
||||
# register component, DYNAMIC or SHARED flags will make component compiled to dynamic(shared) lib
|
||||
# register_component()
|
||||
|
||||
@@ -22,6 +22,8 @@ src
|
||||
|
||||
## ローカル開発
|
||||
|
||||
> 開発には SSH が必要です。Web 設定で有効にすることができます: `設定 > SSH`
|
||||
|
||||
CORS 制限のため、ローカル開発中は認証を無効にする必要があります。
|
||||
|
||||
認証機能を開発するには、プロジェクトをビルドして NanoKVM でテストする必要があります。
|
||||
@@ -55,4 +57,7 @@ pnpm build
|
||||
3. `web` を NanoKVM の `/kvmapp/server/` にアップロードします。
|
||||
4. NanoKVM で `/etc/init.d/S95nanokvm restart` を実行してサービスを再起動します。
|
||||
|
||||
また、ブラウザに古いバージョンのキャッシュが残っている可能性があります。ページが開かない場合は、強制リフレッシュまたはキャッシュのクリアを試してください。
|
||||
Tips:
|
||||
|
||||
1. ファイルのアップロードには SSH が必要です。Web 設定で有効にすることができます: `設定 > SSH`
|
||||
2. ブラウザに古いバージョンのキャッシュが残っている可能性があります。ページが開かない場合は、強制リフレッシュまたはキャッシュのクリアを試してください。
|
||||
|
||||
@@ -47,6 +47,7 @@ const en = {
|
||||
finishBtn: 'Finished'
|
||||
},
|
||||
screen: {
|
||||
title: 'Screen',
|
||||
video: 'Video Mode',
|
||||
resolution: 'Resolution',
|
||||
auto: 'Automatic',
|
||||
@@ -65,6 +66,7 @@ const en = {
|
||||
resetHdmi: 'Reset HDMI'
|
||||
},
|
||||
keyboard: {
|
||||
title: 'Keyboard',
|
||||
paste: 'Paste',
|
||||
tips: 'Only standard keyboard letters and symbols are supported',
|
||||
placeholder: 'Please input',
|
||||
@@ -73,6 +75,7 @@ const en = {
|
||||
ctrlaltdel: 'Ctrl+Alt+Del'
|
||||
},
|
||||
mouse: {
|
||||
title: 'Mouse',
|
||||
default: 'Default cursor',
|
||||
pointer: 'Pointer cursor',
|
||||
cell: 'Cell cursor',
|
||||
@@ -86,13 +89,14 @@ const en = {
|
||||
resetHid: 'Reset HID'
|
||||
},
|
||||
image: {
|
||||
title: 'Image',
|
||||
title: 'Images',
|
||||
loading: 'Loading...',
|
||||
empty: 'Nothing Found',
|
||||
cdrom: 'Mount the image in CD-ROM mode',
|
||||
mountFailed: 'Mount Failed',
|
||||
mountDesc:
|
||||
"In some systems, it's necessary to eject the virtual disk on the remote host before mounting the image.",
|
||||
refresh: 'Refresh the image list',
|
||||
tips: {
|
||||
title: 'How to upload',
|
||||
usb1: 'Connect the NanoKVM to your computer via USB.',
|
||||
@@ -110,7 +114,7 @@ const en = {
|
||||
}
|
||||
},
|
||||
script: {
|
||||
title: 'Script',
|
||||
title: 'Scripts',
|
||||
upload: 'Upload',
|
||||
run: 'Run',
|
||||
runBackground: 'Run Background',
|
||||
@@ -139,7 +143,7 @@ const en = {
|
||||
ok: 'Ok'
|
||||
},
|
||||
download: {
|
||||
title: 'Download Image',
|
||||
title: 'Image Downloader',
|
||||
input: 'Please enter a remote image URL',
|
||||
ok: 'Ok',
|
||||
disabled: '/data partition is RO, so we cannot download the image'
|
||||
@@ -257,8 +261,15 @@ const en = {
|
||||
}
|
||||
},
|
||||
error: {
|
||||
title: "We've ran into an issue",
|
||||
refresh: 'Refresh'
|
||||
title: 'We\'ve ran into an issue',
|
||||
refresh: 'Refresh',
|
||||
},
|
||||
fullscreen: {
|
||||
toggle: 'Toggle Fullscreen',
|
||||
},
|
||||
menu: {
|
||||
collapse: 'Collapse Menu',
|
||||
expand: 'Expand Menu',
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -14,8 +14,7 @@ const ko = {
|
||||
placeholderPassword2: '비밀번호를 다시 입력하세요.',
|
||||
noEmptyUsername: '사용자 이름은 비어있을 수 없습니다.',
|
||||
noEmptyPassword: '비밀번호는 비어있을 수 없습니다.',
|
||||
noAccount:
|
||||
'사용자 정보를 불러오는 데 실패했습니다. 페이지를 새로고침하거나 비밀번호를 초기화하세요.',
|
||||
noAccount: '사용자 정보를 불러오는 데 실패했습니다. 페이지를 새로고침하거나 비밀번호를 초기화하세요.',
|
||||
invalidUser: '사용자 이름이나 비밀번호가 틀렸습니다.',
|
||||
error: '알 수 없는 오류',
|
||||
changePassword: '비밀번호 변경',
|
||||
@@ -28,7 +27,8 @@ const ko = {
|
||||
cancel: '취소',
|
||||
loginButtonText: '로그인',
|
||||
tips: {
|
||||
reset1: '비밀번호를 재설정하려면 NanoKVM의 BOOT 버튼을 10초 동안 누르고 계세요.',
|
||||
reset1:
|
||||
'비밀번호를 재설정하려면 NanoKVM의 BOOT 버튼을 10초 동안 누르고 계세요.',
|
||||
reset2: '자세한 절차는 이 문서를 참조하세요:',
|
||||
reset3: '웹 기본 계정:',
|
||||
reset4: 'SSH 기본 계정:',
|
||||
@@ -89,9 +89,11 @@ const ko = {
|
||||
title: '이미지',
|
||||
loading: '불러오는 중...',
|
||||
empty: '아무것도 없습니다.',
|
||||
cdrom: 'CD-ROM 모드로 이미지 마운트',
|
||||
mountFailed: '이미지 마운트 실패',
|
||||
mountDesc:
|
||||
'일부 시스템에서는 이미지를 마운트하기 전에 원격 호스트에서 가상 디스크를 제거해야 합니다.',
|
||||
refresh: '이미지 목록 새로고침',
|
||||
tips: {
|
||||
title: '업로드 방법',
|
||||
usb1: 'USB를 통해 NanoKVM을 컴퓨터에 연결하세요.',
|
||||
@@ -99,7 +101,7 @@ const ko = {
|
||||
usb3: '컴퓨터에서 가상 디스크를 열고 이미지 파일을 가상 디스크의 루트 디렉토리로 복사하세요.',
|
||||
scp1: 'NanoKVM과 컴퓨터가 동일한 로컬 네트워크에 있는지 확인하세요.',
|
||||
scp2: '컴퓨터에서 터미널을 열고 SCP 명령을 사용하여 이미지 파일을 NanoKVM의 /data 디렉터리에 업로드하세요.',
|
||||
scp3: '예: scp [이미지 파일 경로] root@[NanoKVM IP 주소]:/data',
|
||||
scp3: '예시: scp [이미지 파일 경로] root@[NanoKVM IP 주소]:/data',
|
||||
tfCard: 'TF 카드',
|
||||
tf1: '이 방법은 Linux 시스템에서 지원됩니다',
|
||||
tf2: 'NanoKVM에서 TF 카드를 가져옵니다(전체 버전의 경우 먼저 케이스를 분해하세요).',
|
||||
@@ -116,7 +118,7 @@ const ko = {
|
||||
runFailed: '실행 실패',
|
||||
attention: '주의',
|
||||
delDesc: '이 파일을 정말로 삭제합니까?',
|
||||
confirm: '예',
|
||||
confirm: '네',
|
||||
cancel: '아니오',
|
||||
delete: '삭제',
|
||||
close: '닫기'
|
||||
@@ -222,7 +224,8 @@ const ko = {
|
||||
upTailscale: 'tailscale을 NanoKVM 의 다음 경로에 업로드 했습니다. : /usr/bin/',
|
||||
upTailscaled: 'tailscaled을 NanoKVM 의 다음 경로에 업로드 했습니다. : /usr/sbin/',
|
||||
refresh: '현재 페이지 새로고침',
|
||||
notLogin: '이 기기는 현재 연동 되지 않았습니다. 로그인해서 계정에 이 장치를 연동하세요.',
|
||||
notLogin:
|
||||
'이 기기는 현재 연동 되지 않았습니다. 로그인해서 계정에 이 장치를 연동하세요.',
|
||||
urlPeriod: '이 주소는 10분간 유효합니다.',
|
||||
login: '로그인',
|
||||
loginSuccess: '로그인 성공',
|
||||
@@ -233,7 +236,7 @@ const ko = {
|
||||
logout: '로그아웃',
|
||||
logout2: '정말로 로그아웃 합니까?',
|
||||
uninstall: 'Tailscale 제거',
|
||||
okBtn: '예',
|
||||
okBtn: '네',
|
||||
cancelBtn: '아니오'
|
||||
},
|
||||
update: {
|
||||
@@ -253,6 +256,10 @@ const ko = {
|
||||
updateBtn: '업데이트',
|
||||
logoutBtn: '로그아웃'
|
||||
}
|
||||
},
|
||||
error: {
|
||||
title: '문제가 발생했습니다.',
|
||||
refresh: '새로고침'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ChangeEvent, useEffect, useRef, useState } from 'react';
|
||||
import { Button, Divider, Input, Popover } from 'antd';
|
||||
import { Button, Divider, Input, Popover, Tooltip } from 'antd';
|
||||
import type { InputRef } from 'antd';
|
||||
import clsx from 'clsx';
|
||||
import { useSetAtom } from 'jotai';
|
||||
@@ -21,6 +21,9 @@ export const DownloadImage = () => {
|
||||
const [diskEnabled, setDiskEnabled] = useState(false);
|
||||
const [popoverKey, setPopoverKey] = useState(0);
|
||||
|
||||
const tooltip = t('download.title');
|
||||
const [tooltipValue, setTooltipValue] = useState(tooltip);
|
||||
|
||||
const inputRef = useRef<InputRef>(null);
|
||||
|
||||
const intervalId = useRef<NodeJS.Timeout | undefined>(undefined);
|
||||
@@ -165,11 +168,16 @@ export const DownloadImage = () => {
|
||||
trigger="click"
|
||||
arrow={false}
|
||||
open={isPopoverOpen}
|
||||
onOpenChange={handleOpenChange}
|
||||
onOpenChange={(visible) => {
|
||||
handleOpenChange(visible);
|
||||
setTooltipValue(visible ? '' : tooltip);
|
||||
}}
|
||||
>
|
||||
<div className="flex h-[30px] w-[30px] cursor-pointer items-center justify-center rounded text-neutral-300 hover:bg-neutral-700 hover:text-white">
|
||||
<DownloadIcon size={18} />
|
||||
</div>
|
||||
<Tooltip title={tooltipValue} placement="bottom">
|
||||
<div className="flex h-[30px] w-[30px] cursor-pointer items-center justify-center rounded text-neutral-300 hover:bg-neutral-700 hover:text-white">
|
||||
<DownloadIcon size={18} />
|
||||
</div>
|
||||
</Tooltip>
|
||||
</Popover>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { MaximizeIcon, MinimizeIcon } from 'lucide-react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Tooltip } from 'antd';
|
||||
|
||||
export const Fullscreen = () => {
|
||||
const { t } = useTranslation();
|
||||
const [isFullscreen, setIsFullscreen] = useState(false);
|
||||
const [tooltipValue, setTooltipValue] = useState(t('fullscreen.toggle'));
|
||||
|
||||
useEffect(() => {
|
||||
function onFullscreenChange() {
|
||||
@@ -27,11 +31,13 @@ export const Fullscreen = () => {
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
className="hidden h-[30px] w-[30px] cursor-pointer items-center justify-center rounded text-neutral-300 hover:bg-neutral-700 hover:text-white sm:flex"
|
||||
onClick={handleFullscreen}
|
||||
>
|
||||
{isFullscreen ? <MinimizeIcon size={18} /> : <MaximizeIcon size={18} />}
|
||||
</div>
|
||||
<Tooltip title={tooltipValue} placement="bottom">
|
||||
<div
|
||||
className="hidden h-[30px] w-[30px] cursor-pointer items-center justify-center rounded text-neutral-300 hover:bg-neutral-700 hover:text-white sm:flex"
|
||||
onClick={handleFullscreen}
|
||||
>
|
||||
{isFullscreen ? <MinimizeIcon size={18} /> : <MaximizeIcon size={18} />}
|
||||
</div>
|
||||
</Tooltip>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -16,9 +16,10 @@ import { client } from '@/lib/websocket.ts';
|
||||
type ImagesProps = {
|
||||
cdrom: boolean;
|
||||
setIsMounted: (isMounted: boolean) => void;
|
||||
onRefresh?: (callback: () => void) => void;
|
||||
};
|
||||
|
||||
export const Images = ({ cdrom, setIsMounted }: ImagesProps) => {
|
||||
export const Images = ({ cdrom, setIsMounted, onRefresh }: ImagesProps) => {
|
||||
const { t } = useTranslation();
|
||||
const [notify, contextHolder] = notification.useNotification();
|
||||
|
||||
@@ -31,6 +32,12 @@ export const Images = ({ cdrom, setIsMounted }: ImagesProps) => {
|
||||
getImages();
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (onRefresh) {
|
||||
onRefresh(getImages);
|
||||
}
|
||||
}, [onRefresh]);
|
||||
|
||||
function getImages() {
|
||||
if (isLoading) return;
|
||||
setIsLoading(true);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { Divider, Popover, Switch, Tooltip } from 'antd';
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import { Button, Divider, Popover, Switch, Tooltip } from 'antd';
|
||||
import clsx from 'clsx';
|
||||
import { DiscIcon } from 'lucide-react';
|
||||
import { DiscIcon, RefreshCwIcon } from 'lucide-react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useMediaQuery } from 'react-responsive';
|
||||
|
||||
@@ -18,6 +18,13 @@ export const Image = () => {
|
||||
const [isMounted, setIsMounted] = useState(false);
|
||||
const [cdrom, setCdrom] = useState(false);
|
||||
|
||||
|
||||
const getImagesRef = useRef<() => void>(() => {});
|
||||
|
||||
const tooltip = t('image.title');
|
||||
const [tooltipValue, setTooltipValue] = useState(tooltip);
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
getMountedImage().then((rsp) => {
|
||||
if (rsp.code !== 0) return;
|
||||
@@ -30,6 +37,12 @@ export const Image = () => {
|
||||
});
|
||||
}, []);
|
||||
|
||||
const refreshImages = () => {
|
||||
if (getImagesRef.current) {
|
||||
getImagesRef.current();
|
||||
}
|
||||
};
|
||||
|
||||
const content = (
|
||||
<div className="min-w-[300px]">
|
||||
<div className="flex items-center justify-between px-1">
|
||||
@@ -38,18 +51,26 @@ export const Image = () => {
|
||||
<Tips />
|
||||
</div>
|
||||
|
||||
<Tooltip title={t('image.cdrom')} placement="bottom">
|
||||
<div className="flex items-center space-x-2">
|
||||
<span className="text-xs text-neutral-400">CD-ROM</span>
|
||||
<div className="flex items-center space-x-2">
|
||||
<Tooltip title={t('image.cdrom')} placement="bottom">
|
||||
<div className="flex items-center space-x-2">
|
||||
<span className="text-xs text-neutral-400">CD-ROM</span>
|
||||
|
||||
<Switch size="small" checked={cdrom} onChange={(checked) => setCdrom(checked)}></Switch>
|
||||
</div>
|
||||
</Tooltip>
|
||||
<Switch size="small" checked={cdrom} onChange={(checked) => setCdrom(checked)}></Switch>
|
||||
</div>
|
||||
</Tooltip>
|
||||
|
||||
<Tooltip title={t('image.refresh')} placement="bottom">
|
||||
<Button type="default" icon={<RefreshCwIcon size={16} />} onClick={refreshImages} />
|
||||
</Tooltip>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Divider style={{ margin: '10px 0 15px 0' }} />
|
||||
|
||||
{isPopoverOpen && <Images cdrom={cdrom} setIsMounted={setIsMounted} />}
|
||||
{isPopoverOpen && (
|
||||
<Images cdrom={cdrom} setIsMounted={setIsMounted} onRefresh={(callback) => (getImagesRef.current = callback)} />
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -60,16 +81,21 @@ export const Image = () => {
|
||||
trigger="click"
|
||||
arrow={false}
|
||||
open={isPopoverOpen}
|
||||
onOpenChange={setIsPopoverOpen}
|
||||
onOpenChange={(visible) => {
|
||||
setIsPopoverOpen(visible);
|
||||
setTooltipValue(visible ? '' : tooltip);
|
||||
}}
|
||||
>
|
||||
<div
|
||||
className={clsx(
|
||||
'flex h-[30px] w-[30px] cursor-pointer items-center justify-center rounded hover:bg-neutral-700',
|
||||
isMounted ? 'text-blue-500' : 'text-neutral-300 hover:text-white'
|
||||
)}
|
||||
>
|
||||
<DiscIcon size={18} />
|
||||
</div>
|
||||
<Tooltip title={tooltipValue} placement="bottom">
|
||||
<div
|
||||
className={clsx(
|
||||
'flex h-[30px] w-[30px] cursor-pointer items-center justify-center rounded hover:bg-neutral-700',
|
||||
isMounted ? 'text-blue-500' : 'text-neutral-300 hover:text-white'
|
||||
)}
|
||||
>
|
||||
<DiscIcon size={18} />
|
||||
</div>
|
||||
</Tooltip>
|
||||
</Popover>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { Divider } from 'antd';
|
||||
import { Divider, Tooltip } from 'antd';
|
||||
import clsx from 'clsx';
|
||||
import { useAtom } from 'jotai';
|
||||
import { MenuIcon, XIcon } from 'lucide-react';
|
||||
@@ -19,6 +19,7 @@ import { Script } from './script';
|
||||
import { Settings } from './settings';
|
||||
import { Terminal } from './terminal';
|
||||
import { Wol } from './wol';
|
||||
import { t } from 'i18next';
|
||||
|
||||
export const Menu = () => {
|
||||
const [menuDisabledItems, setMenuDisabledItems] = useAtom(menuDisabledItemsAtom);
|
||||
@@ -69,6 +70,7 @@ export const Menu = () => {
|
||||
<Settings />
|
||||
<Fullscreen />
|
||||
|
||||
<Tooltip title={t('menu.collapse')} placement="bottom">
|
||||
<div
|
||||
className="mr-1 flex h-[30px] w-[30px] cursor-pointer items-center justify-center rounded text-neutral-300 hover:bg-neutral-700 hover:text-white"
|
||||
onClick={() => setIsMenuOpen((o) => !o)}
|
||||
@@ -78,6 +80,11 @@ export const Menu = () => {
|
||||
</div>
|
||||
|
||||
{!isMenuOpen && (
|
||||
</Tooltip>
|
||||
</div>
|
||||
|
||||
{!isMenuOpen && (
|
||||
<Tooltip title={t('menu.expand')} placement="bottom">
|
||||
<div
|
||||
className="flex h-[30px] w-[50px] items-center justify-center rounded bg-neutral-800/50 text-white/50 hover:bg-neutral-800 hover:text-white"
|
||||
onClick={() => setIsMenuOpen((o) => !o)}
|
||||
@@ -86,6 +93,8 @@ export const Menu = () => {
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</Tooltip>
|
||||
)}
|
||||
</div>
|
||||
</Draggable>
|
||||
);
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
import { useState } from 'react';
|
||||
import { Popover } from 'antd';
|
||||
import { Popover, Tooltip } from 'antd';
|
||||
import { KeyboardIcon } from 'lucide-react';
|
||||
import { t } from 'i18next';
|
||||
|
||||
import { Paste } from './paste.tsx';
|
||||
import { VirtualKeyboard } from './virtual-keyboard.tsx';
|
||||
import { CtrlAltDel } from './ctrl-alt-del.tsx';
|
||||
|
||||
|
||||
export const Keyboard = () => {
|
||||
const [isPopoverOpen, setIsPopoverOpen] = useState(false);
|
||||
|
||||
const tooltip = t('keyboard.title')
|
||||
const [tooltipValue, setTooltipValue] = useState(tooltip);
|
||||
|
||||
const content = (
|
||||
<>
|
||||
<Paste setIsPopoverOpen={setIsPopoverOpen} />
|
||||
@@ -24,11 +29,16 @@ export const Keyboard = () => {
|
||||
trigger="click"
|
||||
arrow={false}
|
||||
open={isPopoverOpen}
|
||||
onOpenChange={setIsPopoverOpen}
|
||||
onOpenChange={(visible) => {
|
||||
setIsPopoverOpen(visible);
|
||||
setTooltipValue(visible ? "" : tooltip);
|
||||
}}
|
||||
>
|
||||
<div className="flex h-[30px] w-[30px] cursor-pointer items-center justify-center rounded text-neutral-300 hover:bg-neutral-700 hover:text-white">
|
||||
<KeyboardIcon size={18} />
|
||||
</div>
|
||||
<Tooltip title={tooltipValue} placement="bottom">
|
||||
<div className="flex h-[30px] w-[30px] cursor-pointer items-center justify-center rounded text-neutral-300 hover:bg-neutral-700 hover:text-white">
|
||||
<KeyboardIcon size={18} />
|
||||
</div>
|
||||
</Tooltip>
|
||||
</Popover>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { Divider, Popover } from 'antd';
|
||||
import { Divider, Popover, Tooltip } from 'antd';
|
||||
import clsx from 'clsx';
|
||||
import { useAtom } from 'jotai';
|
||||
import {
|
||||
@@ -27,6 +27,9 @@ export const Mouse = () => {
|
||||
const [isPopoverOpen, setIsPopoverOpen] = useState(false);
|
||||
const [isResetting, setIsResetting] = useState(false);
|
||||
|
||||
const tooltip = t('mouse.title');
|
||||
const [tooltipValue, setTooltipValue] = useState(tooltip);
|
||||
|
||||
const mouseStyles = [
|
||||
{ name: t('mouse.default'), icon: <MousePointerIcon size={14} />, value: 'cursor-default' },
|
||||
{ name: t('mouse.grab'), icon: <HandIcon size={14} />, value: 'cursor-grab' },
|
||||
@@ -154,11 +157,16 @@ export const Mouse = () => {
|
||||
trigger="click"
|
||||
arrow={false}
|
||||
open={isPopoverOpen}
|
||||
onOpenChange={setIsPopoverOpen}
|
||||
onOpenChange={(visible) => {
|
||||
setIsPopoverOpen(visible);
|
||||
setTooltipValue(visible ? "" : tooltip);
|
||||
}}
|
||||
>
|
||||
<div className="flex h-[30px] w-[30px] cursor-pointer items-center justify-center rounded text-neutral-300 hover:bg-neutral-700 hover:text-white">
|
||||
<MouseIcon size={18} />
|
||||
</div>
|
||||
<Tooltip title={tooltipValue}>
|
||||
<div className="flex h-[30px] w-[30px] cursor-pointer items-center justify-center rounded text-neutral-300 hover:bg-neutral-700 hover:text-white">
|
||||
<MouseIcon size={18} />
|
||||
</div>
|
||||
</Tooltip>
|
||||
</Popover>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { Popover, Slider } from 'antd';
|
||||
import { Popover, Slider, Tooltip } from 'antd';
|
||||
import clsx from 'clsx';
|
||||
import { CirclePowerIcon, LoaderCircleIcon, PowerIcon, RotateCcwIcon } from 'lucide-react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
@@ -13,6 +13,9 @@ export const Power = () => {
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [powerDuration, setPowerDuration] = useState(8);
|
||||
|
||||
const tooltip = t('power.title');
|
||||
const [tooltipValue, setTooltipValue] = useState(tooltip);
|
||||
|
||||
useEffect(() => {
|
||||
getLed();
|
||||
const interval = setInterval(getLed, 5000);
|
||||
@@ -95,19 +98,24 @@ export const Power = () => {
|
||||
trigger="click"
|
||||
arrow={false}
|
||||
open={isPopoverOpen}
|
||||
onOpenChange={setIsPopoverOpen}
|
||||
onOpenChange={(visible) => {
|
||||
setIsPopoverOpen(visible);
|
||||
setTooltipValue(visible ? '' : tooltip);
|
||||
}}
|
||||
>
|
||||
<div className="flex h-[30px] w-[30px] cursor-pointer items-center justify-center rounded hover:bg-neutral-700 hover:text-white">
|
||||
<div
|
||||
className={clsx('h-[18px] w-[18px]', isPowerOn ? 'text-green-600' : 'text-neutral-500')}
|
||||
>
|
||||
{isLoading ? (
|
||||
<LoaderCircleIcon className="animate-spin" size={18} />
|
||||
) : (
|
||||
<PowerIcon size={18} />
|
||||
)}
|
||||
<Tooltip title={tooltipValue} placement="bottom">
|
||||
<div className="flex h-[30px] w-[30px] cursor-pointer items-center justify-center rounded hover:bg-neutral-700 hover:text-white">
|
||||
<div
|
||||
className={clsx('h-[18px] w-[18px]', isPowerOn ? 'text-green-600' : 'text-neutral-500')}
|
||||
>
|
||||
{isLoading ? (
|
||||
<LoaderCircleIcon className="animate-spin" size={18} />
|
||||
) : (
|
||||
<PowerIcon size={18} />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Tooltip>
|
||||
</Popover>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { Popover } from 'antd';
|
||||
import { Popover, Tooltip } from 'antd';
|
||||
import { useAtomValue } from 'jotai';
|
||||
import { MonitorIcon } from 'lucide-react';
|
||||
|
||||
@@ -14,6 +14,7 @@ import { Quality } from './quality';
|
||||
import { Reset } from './reset.tsx';
|
||||
import { Resolution } from './resolution';
|
||||
import { VideoMode } from './video-mode.tsx';
|
||||
import { t } from 'i18next';
|
||||
|
||||
export const Screen = () => {
|
||||
const videoMode = useAtomValue(videoModeAtom);
|
||||
@@ -21,10 +22,12 @@ export const Screen = () => {
|
||||
const [fps, setFps] = useState(30);
|
||||
const [quality, setQuality] = useState(2);
|
||||
|
||||
const tooltip = t('screen.title');
|
||||
const [tooltipValue, setTooltipValue] = useState(tooltip);
|
||||
|
||||
useEffect(() => {
|
||||
updateScreen('type', videoMode === 'mjpeg' ? 0 : 1);
|
||||
updateScreen('resolution', resolution!.height);
|
||||
|
||||
updateQuality();
|
||||
updateFps();
|
||||
}, []);
|
||||
@@ -69,10 +72,13 @@ export const Screen = () => {
|
||||
placement="bottomLeft"
|
||||
trigger="click"
|
||||
arrow={false}
|
||||
onOpenChange={(visible) => setTooltipValue(visible ? '' : tooltip)}
|
||||
>
|
||||
<div className="flex h-[30px] w-[30px] cursor-pointer items-center justify-center rounded text-neutral-300 hover:bg-neutral-700 hover:text-white">
|
||||
<MonitorIcon size={18} />
|
||||
</div>
|
||||
<Tooltip title={tooltipValue}>
|
||||
<div className="flex h-[30px] w-[30px] cursor-pointer items-center justify-center rounded text-neutral-300 hover:bg-neutral-700 hover:text-white">
|
||||
<MonitorIcon size={18} />
|
||||
</div>
|
||||
</Tooltip>
|
||||
</Popover>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ChangeEvent, useRef, useState } from 'react';
|
||||
import { UploadOutlined } from '@ant-design/icons';
|
||||
import { Button, Divider, Popconfirm, Popover } from 'antd';
|
||||
import { Button, Divider, Popconfirm, Popover, Tooltip } from 'antd';
|
||||
import clsx from 'clsx';
|
||||
import { ChevronRightIcon, FileJsonIcon } from 'lucide-react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
@@ -22,6 +22,9 @@ export const Script = () => {
|
||||
const [isUploading, setIsUploading] = useState(false);
|
||||
const inputRef = useRef<any>(null);
|
||||
|
||||
const tooltip = t('script.title');
|
||||
const [tooltipValue, setTooltipValue] = useState(tooltip);
|
||||
|
||||
function handleOpenChange(open: boolean) {
|
||||
if (open) {
|
||||
getScripts();
|
||||
@@ -194,11 +197,16 @@ export const Script = () => {
|
||||
trigger="click"
|
||||
arrow={false}
|
||||
open={isPopoverOpen}
|
||||
onOpenChange={handleOpenChange}
|
||||
onOpenChange={(visible) => {
|
||||
handleOpenChange(visible);
|
||||
setTooltipValue(visible ? '' : tooltip);
|
||||
}}
|
||||
>
|
||||
<div className="flex h-[30px] w-[30px] cursor-pointer items-center justify-center rounded text-neutral-300 hover:bg-neutral-700 hover:text-white">
|
||||
<FileJsonIcon size={18} />
|
||||
</div>
|
||||
<Tooltip title={tooltipValue} placement="bottom">
|
||||
<div className="flex h-[30px] w-[30px] cursor-pointer items-center justify-center rounded text-neutral-300 hover:bg-neutral-700 hover:text-white">
|
||||
<FileJsonIcon size={18} />
|
||||
</div>
|
||||
</Tooltip>
|
||||
</Popover>
|
||||
|
||||
{isRunning && <Run script={currentScript} setIsRunning={setIsRunning} />}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { Badge, Modal } from 'antd';
|
||||
import { Badge, Modal, Tooltip } from 'antd';
|
||||
import clsx from 'clsx';
|
||||
import {
|
||||
BadgeInfoIcon,
|
||||
@@ -32,6 +32,9 @@ export const Settings = () => {
|
||||
|
||||
const [isUpdateAvailable, setIsUpdateAvailable] = useState(false);
|
||||
|
||||
const tooltip = t('settings.title');
|
||||
const [tooltipValue, setTooltipValue] = useState(tooltip);
|
||||
|
||||
const tabs = [
|
||||
{ id: 'about', icon: <BadgeInfoIcon size={16} />, component: <About /> },
|
||||
{ id: 'appearance', icon: <PaletteIcon size={16} />, component: <Appearance /> },
|
||||
@@ -92,16 +95,18 @@ export const Settings = () => {
|
||||
|
||||
return (
|
||||
<>
|
||||
<div
|
||||
className="flex h-[30px] w-[30px] cursor-pointer items-center justify-center rounded text-white hover:bg-neutral-700"
|
||||
onClick={() => setIsModalOpen(true)}
|
||||
>
|
||||
<Badge dot={isUpdateAvailable} color="blue" offset={[0, 2]}>
|
||||
<div className="pt-[3px]">
|
||||
<SettingsIcon size={18} />
|
||||
</div>
|
||||
</Badge>
|
||||
</div>
|
||||
<Tooltip title={tooltipValue} placement="bottom">
|
||||
<div
|
||||
className="flex h-[30px] w-[30px] cursor-pointer items-center justify-center rounded text-white hover:bg-neutral-700"
|
||||
onClick={() => setIsModalOpen(true)}
|
||||
>
|
||||
<Badge dot={isUpdateAvailable} color="blue" offset={[0, 2]}>
|
||||
<div className="pt-[3px]">
|
||||
<SettingsIcon size={18} />
|
||||
</div>
|
||||
</Badge>
|
||||
</div>
|
||||
</Tooltip>
|
||||
|
||||
<Modal
|
||||
open={isModalOpen}
|
||||
@@ -110,6 +115,7 @@ export const Settings = () => {
|
||||
destroyOnClose={true}
|
||||
styles={{ content: { padding: 0 } }}
|
||||
onCancel={closeModal}
|
||||
afterOpenChange={(visible) => setTooltipValue(visible ? '' : tooltip)}
|
||||
>
|
||||
<div className="flex min-h-[500px] rounded-lg outline outline-1 outline-neutral-700">
|
||||
<div className="flex flex-col space-y-0.5 rounded-l-lg bg-neutral-800 py-5 sm:w-1/5 sm:px-2">
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useState } from 'react';
|
||||
import { Divider, Popover } from 'antd';
|
||||
import { Divider, Popover, Tooltip } from 'antd';
|
||||
import { SquareTerminalIcon } from 'lucide-react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
@@ -10,6 +10,9 @@ export const Terminal = () => {
|
||||
const { t } = useTranslation();
|
||||
const [isPopoverOpen, setIsPopoverOpen] = useState(false);
|
||||
|
||||
const tooltip = t('terminal.title');
|
||||
const [tooltipValue, setTooltipValue] = useState(tooltip);
|
||||
|
||||
const content = (
|
||||
<div className="min-w-[200px]">
|
||||
<div className="flex items-center justify-between px-1">
|
||||
@@ -30,11 +33,16 @@ export const Terminal = () => {
|
||||
trigger="click"
|
||||
arrow={false}
|
||||
open={isPopoverOpen}
|
||||
onOpenChange={setIsPopoverOpen}
|
||||
onOpenChange={(visible) => {
|
||||
setIsPopoverOpen(visible);
|
||||
setTooltipValue(visible ? '' : tooltip);
|
||||
}}
|
||||
>
|
||||
<div className="flex h-[30px] w-[30px] cursor-pointer items-center justify-center rounded text-neutral-300 hover:bg-neutral-700 hover:text-white">
|
||||
<SquareTerminalIcon size={18} />
|
||||
</div>
|
||||
<Tooltip title={tooltipValue} placement="bottom">
|
||||
<div className="flex h-[30px] w-[30px] cursor-pointer items-center justify-center rounded text-neutral-300 hover:bg-neutral-700 hover:text-white">
|
||||
<SquareTerminalIcon size={18} />
|
||||
</div>
|
||||
</Tooltip>
|
||||
</Popover>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ChangeEvent, useRef, useState } from 'react';
|
||||
import { Button, Divider, Input, List, Popover } from 'antd';
|
||||
import { Button, Divider, Input, List, Popover, Tooltip } from 'antd';
|
||||
import type { InputRef } from 'antd';
|
||||
import clsx from 'clsx';
|
||||
import { useSetAtom } from 'jotai';
|
||||
@@ -22,6 +22,9 @@ export const Wol = () => {
|
||||
const [status, setStatus] = useState('');
|
||||
const [log, setLog] = useState('');
|
||||
|
||||
const tooltip = t('wol.title');
|
||||
const [tooltipValue, setTooltipValue] = useState(tooltip);
|
||||
|
||||
const [macList, setMacList] = useState<string[]>([]);
|
||||
|
||||
const inputRef = useRef<InputRef>(null);
|
||||
@@ -153,11 +156,16 @@ export const Wol = () => {
|
||||
trigger="click"
|
||||
arrow={false}
|
||||
open={isPopoverOpen}
|
||||
onOpenChange={handleOpenChange}
|
||||
onOpenChange={(visible) => {
|
||||
handleOpenChange(visible);
|
||||
setTooltipValue(visible ? '' : tooltip);
|
||||
}}
|
||||
>
|
||||
<div className="flex h-[30px] w-[30px] cursor-pointer items-center justify-center rounded text-neutral-300 hover:bg-neutral-700 hover:text-white">
|
||||
<NetworkIcon size={16} />
|
||||
</div>
|
||||
<Tooltip title={tooltipValue} placement="bottom">
|
||||
<div className="flex h-[30px] w-[30px] cursor-pointer items-center justify-center rounded text-neutral-300 hover:bg-neutral-700 hover:text-white">
|
||||
<NetworkIcon size={16} />
|
||||
</div>
|
||||
</Tooltip>
|
||||
</Popover>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user