2025/4/15

RK3588 MP520

black 在 pchome 買的 rk3588 板子。
打開蓋子有 maskrom button,所以一樣可以 boot to maskrom
然後 rkdevtool 看得到。

但是官方沒有提供 image file,所以不敢亂燒。
看論壇說 kernel source 是用 apt-get source 的方式提供的,但是我只有找到 dtb 和 header. 沒有source (GPL...疑慮)
只好用預燒的 image 開機,是 debian.
UI 還好算流暢,不會像 pi 用 gui 那樣很頓。
可以用 chromium 看 youtub, hd OK, 4k 會卡,然後 cpu 超熱 (沒有使用 hardware codec ?)
用 top 看有一個 pipewire process 一直吃掉一個核...

因為不能動image,也沒有 uboot, kernel source,所以只好試試看 npu。
follow : ArmSoM Wiki: rknn-sdk
one@MB127:~$ dmesg | grep -i rknpu
...
[    4.532693] [drm] Initialized rknpu 0.9.6 20240322 for fdab0000.npu on minor 1
所以 kernel 有 enable rknpu
照著做,啟動 rknn_server 之後,把 *.rknn 轉好 scp 過去。
然後run:
(toolkit2) one@MB127:~/projects/rknn_model_zoo/examples/yolov5/python$ python yolov5.py --model_path ~/yolov5s_relu.onnx --img_show
use anchors from '../model/anchors_yolov5.txt', which is [[[10.0, 13.0], [16.0, 30.0], [33.0, 23.0]], [[30.0, 61.0], [62.0, 45.0], 
[59.0, 119.0]], [[116.0, 90.0], [156.0, 198.0], [373.0, 326.0]]]
/home/one/projects/rknn_model_zoo/py_utils/onnx_executor.py:12: FutureWarning: In the future `np.bool` will be defined as the 
corresponding NumPy scalar.
  if getattr(np, 'bool', False):
Model-/home/one/yolov5s_relu.onnx is onnx model, starting val
infer 1/1

IMG: bus.jpg
person @ (208 242 286 508) 0.881
person @ (478 238 560 525) 0.859
person @ (109 237 232 534) 0.842
person @ (79 355 121 515) 0.318
bus  @ (91 129 555 465) 0.702

發生 ssh 連線中斷問題,好像進入 suspend 了...
[  4? 15 16:59:14 2025] rk_gmac-dwmac fe1c0000.ethernet end1: Link is Down
[  4? 15 16:59:14 2025] rk_gmac-dwmac fe1c0000.ethernet end1: FPE workqueue stop
[  4? 15 16:59:14 2025] rk_gmac-dwmac fe1c0000.ethernet end1: Register MEM_TYPE_PAGE_POOL RxQ-0
[  4? 15 16:59:14 2025] rk_gmac-dwmac fe1c0000.ethernet end1: PHY [stmmac-1:01] driver [YT8531 Gigabit Ethernet] (irq=POLL)
[  4? 15 16:59:14 2025] dwmac4: Master AXI performs any burst length
[  4? 15 16:59:14 2025] rk_gmac-dwmac fe1c0000.ethernet end1: No Safety Features support found
[  4? 15 16:59:14 2025] rk_gmac-dwmac fe1c0000.ethernet end1: IEEE 1588-2008 Advanced Timestamp supported
[  4? 15 16:59:14 2025] rk_gmac-dwmac fe1c0000.ethernet end1: registered PTP clock
[  4? 15 16:59:14 2025] rk_gmac-dwmac fe1c0000.ethernet end1: FPE workqueue start
[  4? 15 16:59:14 2025] rk_gmac-dwmac fe1c0000.ethernet end1: configuring for phy/rgmii-rxid link mode
[  4? 15 16:59:14 2025] rk_gmac-dwmac fe1c0000.ethernet end1: FPE workqueue stop
[  4? 15 16:59:15 2025] PM: suspend entry (deep)
[  4? 15 16:59:15 2025] Filesystems sync: 0.015 seconds
大概是no activity suspend,雖然有去 settings 確認關掉,但是還是沒用。
所以只好把所有 systemd 的 suspend service 關掉。
--- 關掉一堆,所以不知道真正有效是哪個。所以沒記。
about source code
ref: MP-520更新發生錯誤
關於MP520 Linux kernel版本的說明:
目前MP520採用的Linux kernel為SoC RK3588S原廠提供的版本加以修改成適合MP520主機板。RK3588S原廠推出新版的速度很慢。
我們會將原廠版本經過修改,並在每一滾動發行版中徹底測試再發佈出來。
另外開源界主流的Mainline linux kernel已有RK3588S版本,但是還只限於終端機文字模式,還很陽春,無法支援圖形視窗介面。
等到Mainline linux kernel的RK3588S版本可以支援圖形視窗時,MP520的Kernel,計劃從Mainline Kernel版本修改而成。
這樣就可以隨時保持最新版本了。不過估計至少還需要一、兩年以上的時間。

about system image
ref: MP520-20 請問有官方 image 的下載點嗎?
沒有,但是提供刷機服務
沒有 sourcecode,也沒有 image,所以只能買一個 nvme ssd 來換了,以免郵寄麻煩..
或是把 nvme ssd 接到 pc 來 DD 備份。
...不曉得有甚麼難處,不然找個 googledrive, mega 之類的放也可以,買的人沒很多,要 download 的人也不會很多吧。
可能 image 不是他們自己 build,他們沒有軟體工程師...

2025/4/12

隨便的 memo ...

沒 train 完的 yolo3,用 coco dataset 來試試看。
-- convert coco to pascal_voc format:
pascal_voc/
├── VOC2012/
│   ├── Annotations/         # XML annotation files
│   ├── ImageSets/
│   │   └── Main/
│   │       └── train.txt    # Training image names
│   └── JPEGImages/         # Image files (.jpg)
│
└── VOC2007/
    ├── Annotations/         # XML annotation files
    ├── ImageSets/
    │   └── Main/
    │       └── test.txt     # Testing image names
    └── JPEGImages/         # Image files (.jpg)
train.txt 是 filename list.
所以 自己去 annotations 找 filename.txt,
到 JPEGImages 找 filename.jpg
要分 train 和 validate。

coco dataset 的format:
一個 imagefolder 配一個 json,裡面有 folder 所有的 image 和 labels

datasets 的format 現在大概有三種
  • pascal_voc
  • coco
  • ultralytic yolo


dataloader( ) 中,參數是 filename list. txt 檔的 path,image folder path,label folder path
所以不用依照pascal_voc 的方式,只要 image,label 分開 folder放就可以。



這個: 說的 "YOLODataset" 就是哪個用空白格開的文字檔 (csv with space)
然後 folder 要依照
.
├── images
│   ├── train
│   └── val
└── labels
    ├── train
    └── val
好像有一個 filelist ..

還是專業的厲害,叫 gemma3:27b 從 dataset.py 找出 train.csv 的格式是什麼,一直鬼打牆說 train.csv 找不到。
換成 github copilot + sonnect 3.5,同樣的 prompt 就回答了(只是不知道鄭不正確):
Based on the code in dataset.py, I can explain how the train.csv file should be structured. The file is used to map image names to their corresponding label files.

The train.csv should contain two columns:
1. Image filename
2. Label filename

Here's an example of how train.csv should look:

```csv
image_name,label_name
image1.jpg,image1.txt
image2.jpg,image2.txt
dog_picture.jpg,dog_picture.txt
car_street.jpg,car_street.txt
```

Key points about the CSV structure:
- The image filenames should correspond to files in the `COCO/images/images/` directory
- The label filenames should correspond to files in the `COCO/labels/labels_new/` directory
- Each label file (.txt) contains the bounding box information in the format: <class_label> <x> <y> <width> <height&ht;`

You can create this CSV file using a simple Python script like this:

````python
import os
import pandas as pd

def create_train_csv(image_dir, label_dir, output_csv):
    image_files = [f for f in os.listdir(image_dir) if f.endswith(('.jpg', '.jpeg', '.png'))]
    data = []
    
    for img_file in image_files:
        # Assume label file has same name but .txt extension
        label_file = os.path.splitext(img_file)[0] + '.txt'
        if os.path.exists(os.path.join(label_dir, label_file)):
            data.append([img_file, label_file])
    
    df = pd.DataFrame(data, columns=['image_name', 'label_name'])
    df.to_csv(output_csv, index=False)

# Example usage
create_train_csv(
    'COCO/images/images/',
    'COCO/labels/labels_new/',
    'COCO/train.csv'
)
````

This script will:
1. Scan the images directory
2. Match image files with their corresponding label files
3. Create a CSV file with the correct format expected by the YOLODataset class

The dataset class then uses this CSV file to load the corresponding image and label pairs during training.
然後 COCO dataset 的 annotation 中 class (category 會到 90),但是只有列出 80 個。
據原始論文說是因為 2014 公佈時,object detection 只有這 80個,另外 10 個是 segmentation 的。
我照著說明,修改在這裡


他自己做好的 5k.part 是 ascii file,裡面是 image file 的 list
...
/images/val2014/COCO_val2014_000000581827.jpg
/images/val2014/COCO_val2014_000000581829.jpg
...
剛好有 5000 個 file

哪個 labels.tgz 其實是 tar,沒有gz
解開就是 YOLO 的 label 格式 txt,每個 image 都有一個。