embeded/i.mx 8m plus2021. 10. 13. 14:38

LF_v5.10.52-2.1.0_images_IMX8MPEVK.zip 파일을 받아서 이미지를 sd 카드에 굽고

부팅해서 들어가보니 경로가 좀 다르다.

tensorflow 2.5.0 버전이면.. 쓸 수 있는 건가?

# cd /usr/bin/tensorflow-lite-2.5.0/examples
# ./benchmark_model --graph=mobilenet_v1_1.0_224_quant.tflite
STARTING!
Log parameter values verbosely: [0]
Graph: [mobilenet_v1_1.0_224_quant.tflite]
Use VXdelegate : [0]
Loaded model mobilenet_v1_1.0_224_quant.tflite
The input model file size (MB): 4.27635
Initialized session in 1.807ms.
Running benchmark for at least 1 iterations and at least 0.5 seconds but terminate if exceeding 150 seconds.
count=4 first=167959 curr=162606 min=162606 max=167959 avg=164253 std=2159

Running benchmark for at least 50 iterations and at least 1 seconds but terminate if exceeding 150 seconds.
count=50 first=162727 curr=163003 min=162308 max=163308 avg=162758 std=190

Inference timings in us: Init: 1807, First inference: 167959, Warmup (avg): 164253, Inference (avg): 162758
Note: as the benchmark tool itself affects memory footprint, the following is only APPROXIMATE to the actual memory footprint of the model at runtime. Take the information at your discretion.
Peak memory footprint (MB): init=2.51562 overall=8.64062

# ./benchmark_model --graph=mobilenet_v1_1.0_224_quant.tflite --use_nnapi=true
STARTING!
Log parameter values verbosely: [0]
Graph: [mobilenet_v1_1.0_224_quant.tflite]
Use NNAPI: [1]
NNAPI accelerators available: [vsi-npu]
Use VXdelegate : [0]
Loaded model mobilenet_v1_1.0_224_quant.tflite
INFO: Created TensorFlow Lite delegate for NNAPI.
Explicitly applied NNAPI delegate, and the model graph will be completely executed by the delegate.
The input model file size (MB): 4.27635
Initialized session in 4.183ms.
Running benchmark for at least 1 iterations and at least 0.5 seconds but terminate if exceeding 150 seconds.
count=1 curr=4649626

Running benchmark for at least 50 iterations and at least 1 seconds but terminate if exceeding 150 seconds.
count=360 first=2665 curr=2733 min=2632 max=2783 avg=2715.67 std=16

Inference timings in us: Init: 4183, First inference: 4649626, Warmup (avg): 4.64963e+06, Inference (avg): 2715.67
Note: as the benchmark tool itself affects memory footprint, the following is only APPROXIMATE to the actual memory footprint of the model at runtime. Take the information at your discretion.
Peak memory footprint (MB): init=2.59766 overall=30.1836

 

label_image로 해보면.. warm up이 먼진 모르겠지만 invoke() 함수 자체는 짧게 걸리는데

그 이전에 먼가 하는게 오래 걸리는지 cpu만으로 돌리는 것 보다 4초 이상 오래 걸린다.

# time ./label_image -w 1
INFO: Loaded model ./mobilenet_v1_1.0_224_quant.tflite
INFO: resolved reporter
INFO: invoked
INFO: average time: 43.865 ms
INFO: 0.764706: 653 military uniform
INFO: 0.121569: 907 Windsor tie
INFO: 0.0156863: 458 bow tie
INFO: 0.0117647: 466 bulletproof vest
INFO: 0.00784314: 835 suit

real    0m0.142s
user    0m0.385s
sys     0m0.020s

# time ./label_image -w 1 -a 1
INFO: Loaded model ./mobilenet_v1_1.0_224_quant.tflite
INFO: resolved reporter
INFO: Created TensorFlow Lite delegate for NNAPI.
INFO: Use NNAPI acceleration.
INFO: Applied NNAPI delegate.
INFO: invoked
INFO: average time: 2.797 ms
INFO: 0.768627: 653 military uniform
INFO: 0.105882: 907 Windsor tie
INFO: 0.0196078: 458 bow tie
INFO: 0.0117647: 466 bulletproof vest
INFO: 0.00784314: 835 suit

real    0m4.748s
user    0m4.648s
sys     0m0.092s

 

아래는 2.1.0 버전에 맞춰서 한 구버전 문서 내용 인 듯.

$ cd /usr/bin/tensorflow-lite-2.1.0/examples
$ ./benchmark_model --graph=mobilenet_v1_1.0_224_quant.tflite
$: ./benchmark_model --graph=mobilenet_v1_1.0_224_quant.tflite --use_nnapi=true

./lbl_img -i grace_hopper.bmp -l labels.txt -w 1
./lbl_img -i grace_hopper.bmp -l labels.txt -w 1 -a 1

[링크 : https://www.mouser.com/pdfDocs/AN12964.pdf]

 

 

+

망할 놈(?)들 도움말이랑 다르잖아?!

# ./label_image --help
ERROR: usage: ./label_image <flags>
Flags:
        --num_threads=1                 int32   optional        number of threads used for inference on CPU.
        --max_delegated_partitions=0    int32   optional        Max number of partitions to be delegated.
        --min_nodes_per_partition=0     int32   optional        The minimal number of TFLite graph nodes of a partition that has to be reached for it to be delegated.A negative value or 0 means to use the default choice of each delegate.
        --num_threads=1                 int32   optional        number of threads used for inference on CPU.
        --max_delegated_partitions=0    int32   optional        Max number of partitions to be delegated.
        --min_nodes_per_partition=0     int32   optional        The minimal number of TFLite graph nodes of a partition that has to be reached for it to be delegated.A negative value or 0 means to use the default choice of each delegate.
        --use_xnnpack=false             bool    optional        use XNNPack
        --use_nnapi=false               bool    optional        use nnapi delegate api
        --nnapi_execution_preference=   string  optional        execution preference for nnapi delegate. Should be one of the following: fast_single_answer, sustained_speed, low_power, undefined
        --nnapi_execution_priority=     string  optional        The model execution priority in nnapi, and it should be one of the following: default, low, medium and high. This requires Android 11+.
        --nnapi_accelerator_name=       string  optional        the name of the nnapi accelerator to use (requires Android Q+)
        --disable_nnapi_cpu=true        bool    optional        Disable the NNAPI CPU device
        --nnapi_allow_fp16=false        bool    optional        Allow fp32 computation to be run in fp16

 

    static struct option long_options[] = {
        {"accelerated", required_argument, nullptr, 'a'},
        {"allow_fp16", required_argument, nullptr, 'f'},
        {"count", required_argument, nullptr, 'c'},
        {"verbose", required_argument, nullptr, 'v'},
        {"image", required_argument, nullptr, 'i'},
        {"labels", required_argument, nullptr, 'l'},
        {"tflite_model", required_argument, nullptr, 'm'},
        {"profiling", required_argument, nullptr, 'p'},
        {"threads", required_argument, nullptr, 't'},
        {"input_mean", required_argument, nullptr, 'b'},
        {"input_std", required_argument, nullptr, 's'},
        {"num_results", required_argument, nullptr, 'r'},
        {"max_profiling_buffer_entries", required_argument, nullptr, 'e'},
        {"warmup_runs", required_argument, nullptr, 'w'},
        {"gl_backend", required_argument, nullptr, 'g'},
        {"hexagon_delegate", required_argument, nullptr, 'j'},
        {"xnnpack_delegate", required_argument, nullptr, 'x'},
        {nullptr, 0, nullptr, 0}};

[링크 : https://github.com/tensorflow/tensorflow/blob/v2.5.0/tensorflow/lite/examples/label_image/label_image.cc]

 

+

그러면.. 어떤식으로 라이브러리를 빌드해서 저게 가능해진거지?

# ldd label_image
        linux-vdso.so.1 (0x0000ffffa0989000)
        libtensorflow-lite.so.2.5.0 => /usr/lib/libtensorflow-lite.so.2.5.0 (0x0000ffffa05ab000)
        libm.so.6 => /lib/libm.so.6 (0x0000ffffa0501000)
        libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x0000ffffa032a000)
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x0000ffffa0305000)
        libc.so.6 => /lib/libc.so.6 (0x0000ffffa0190000)
        /lib/ld-linux-aarch64.so.1 (0x0000ffffa0957000)
        libtim-vx.so => /usr/lib/libtim-vx.so (0x0000ffffa00c7000)
        libdl.so.2 => /lib/libdl.so.2 (0x0000ffffa00b1000)
        libpthread.so.0 => /lib/libpthread.so.0 (0x0000ffffa0082000)
        librt.so.1 => /lib/librt.so.1 (0x0000ffffa006a000)
        libovxlib.so.1.1.0 => /usr/lib/libovxlib.so.1.1.0 (0x0000ffff9fcd1000)
        libOpenVX.so.1 => /usr/lib/libOpenVX.so.1 (0x0000ffff9fa7e000)
        libVSC.so => /usr/lib/libVSC.so (0x0000ffff9eae2000)
        libGAL.so => /usr/lib/libGAL.so (0x0000ffff9e91b000)
        libArchModelSw.so => /usr/lib/libArchModelSw.so (0x0000ffff9e8f3000)
        libNNArchPerf.so => /usr/lib/libNNArchPerf.so (0x0000ffff9e8d0000)

 

 

+

PRELU 연산자 자체는 지원하는 것 같은데 output size mistach가 원인인가?

INFO: Use NNAPI acceleration.
WARNING: Operator RESIZE_BILINEAR (v3) refused by NNAPI delegate: Operator refused due performance reasons.
INFO: Applied NNAPI delegate.
W [vsi_nn_op_eltwise_setup:178]Output size mismatch, expect 917504, but got 50176
E [setup_node:448]Setup node[52] PRELU fail
W [vsi_nn_op_eltwise_setup:178]Output size mismatch, expect 917504, but got 50176
E [setup_node:448]Setup node[52] PRELU fail
ERROR: NN API returned error ANEURALNETWORKS_BAD_DATA at line 4151 while running computation.

ERROR: Node number 56 (TfLiteNnapiDelegate) failed to invoke.

ERROR: Failed to invoke tflite!

[링크 : https://www.nxp.com/docs/en/user-guide/IMX-MACHINE-LEARNING-UG.pdf]

 

 

+

warm up은 코드상으로 1회 invoke 하는 것인데 해당 작업이 4649ms 정도 소요되며

warm up 없이 1회 실행하면 대략 그 정도 시간이 소요된다.

root@imx8mpevk:/usr/bin/tensorflow-lite-2.5.0/examples# time ./label_image -a 1 -w 0 -p 1 -c 1
INFO: Loaded model ./mobilenet_v1_1.0_224_quant.tflite
INFO: resolved reporter
INFO: Created TensorFlow Lite delegate for NNAPI.
INFO: Use NNAPI acceleration.
INFO: Applied NNAPI delegate.
INFO: invoked
INFO: average time: 4649.78 ms
INFO: 0.768627: 653 military uniform
INFO: 0.105882: 907 Windsor tie
INFO: 0.0196078: 458 bow tie
INFO: 0.0117647: 466 bulletproof vest
INFO: 0.00784314: 835 suit

real    0m4.757s
user    0m4.655s
sys     0m0.096s
root@imx8mpevk:/usr/bin/tensorflow-lite-2.5.0/examples# time ./label_image -a 1 -w 0 -p 1 -c 4
INFO: Loaded model ./mobilenet_v1_1.0_224_quant.tflite
INFO: resolved reporter
INFO: Created TensorFlow Lite delegate for NNAPI.
INFO: Use NNAPI acceleration.
INFO: Applied NNAPI delegate.
INFO: invoked
INFO: average time: 1164.36 ms
INFO: 0.768627: 653 military uniform
INFO: 0.105882: 907 Windsor tie
INFO: 0.0196078: 458 bow tie
INFO: 0.0117647: 466 bulletproof vest
INFO: 0.00784314: 835 suit

real    0m4.768s
user    0m4.663s
sys     0m0.092s
root@imx8mpevk:/usr/bin/tensorflow-lite-2.5.0/examples# time ./label_image -a 1 -w 0 -p 1 -c 10000
INFO: Loaded model ./mobilenet_v1_1.0_224_quant.tflite
INFO: resolved reporter
INFO: Created TensorFlow Lite delegate for NNAPI.
INFO: Use NNAPI acceleration.
INFO: Applied NNAPI delegate.
INFO: invoked
INFO: average time: 3.30189 ms
INFO: 0.768627: 653 military uniform
INFO: 0.105882: 907 Windsor tie
INFO: 0.0196078: 458 bow tie
INFO: 0.0117647: 466 bulletproof vest
INFO: 0.00784314: 835 suit

real    0m33.128s
user    0m7.516s
sys     0m1.590s

 

openVX를 통해 처리하는 것 같은데 처음 처리하면 그래프 처리 결과를 스토리지에 저장한다고.

11.3 Hardware accelerators warmup time
For both Arm NN and TensorFlow Lite, the initial execution of model inference takes longer time, because of the model graph initialization needed by the GPU/NPU hardware accelerator. The initialization phase is known as warmup. This time duration can be decreased for subsequent application that runs by storing on disk the information resulted from the initial OpenVX graph processing. The following environment variables should be used for this purpose:
VIV_VX_ENABLE_CACHE_GRAPH_BINARY: flag to enable/disable OpenVX graph caching
VIV_VX_CACHE_BINARY_GRAPH_DIR: set location of the cached information on disk
For example, set these variables on the console in this way:
export VIV_VX_ENABLE_CACHE_GRAPH_BINARY="1"
export VIV_VX_CACHE_BINARY_GRAPH_DIR=`pwd`

[링크 : https://www.nxp.com/docs/en/user-guide/IMX-MACHINE-LEARNING-UG.pdf]

'embeded > i.mx 8m plus' 카테고리의 다른 글

i.mx8m plus win iot 실행  (0) 2023.02.23
i.mx8 tensilica dsp  (0) 2023.02.07
i.mx8m plus win iot  (0) 2023.02.02
imx 8m plus NPU 에러 추적  (5) 2021.10.14
i.MX 8M PLUS  (0) 2021.10.13
Posted by 구차니
embeded/i.mx 8m plus2021. 10. 13. 11:44

오잉? 저번에 볼 땐 8M PLUS에는 cortex-M 계열 없었던 것 같은데?!?!

[링크 : https://www.nxp.com/products/processors-and-microcontrollers/arm-processors/i-mx-applications-processors/i-mx-8-processors/i-mx-8m-plus-arm-cortex-a53-machine-learning-vision-multimedia-and-industrial-iot:IMX8MPLUS]

 

음.. 그냥 내 눈이 삐꾸인걸로 -_ㅠ

[링크 : https://www.nxp.com/products/processors-and-microcontrollers/arm-processors/i-mx-applications-processors/i-mx-8-processors:IMX8-SERIES]

 

아무튼 회사에 굴러(?) 다니는 이 녀석 사용해보려니

헐.. 무슨 디버그 포트가 이렇게 많이 인식 돼? 일단 나의 경우에는 리눅스가 COM27로 연결되었다.

[링크 : https://www.nxp.com/design/development-boards/i-mx-evaluation-and-development-boards/evaluation-kit-for-the-i-mx-8m-plus-applications-processor:8MPLUSLPD4-EVK]

 

패키지에 들어있던 종이 쪼가리구만 -_-

첫째랑 둘째는 누구꺼냐!?

Four UART connections will appear on the PC, the third port for the Cortex-A53 core and the fourth for Cortex-M7 core system debugging.

[링크 : https://www.nxp.com/docs/en/quick-reference-guide/8MPLUSEVKQSG.pdf]

 

Proejct - Tutorial에 Machine Learning

[링크 : https://www.nxp.com/document/guide/getting-started-with-the-i-mx-8m-plus-evk:GS-iMX-8M-Plus-EVK]

 

i.MX 8M PLUS 에는 전체 기능을 다 지원하는데

NPU를 써볼려면 eIQ를 이용해서 먼가 짓을 해야 하는 것 같고.

Cortex-M7도 있으니 (standalone 혹은 collaborative 하게 작동이 가능하다고) 이걸 이용해서 일종의 가속기화 하려나?

 

TFLite

[링크 : https://www.nxp.com/design/software/development-software/eiq-ml-development-environment/eiq-inference-with-tensorflow-lite:eIQTensorFlowLite]

 

TFLite for MCU

[링크 : https://www.nxp.com/design/software/development-software/eiq-ml-development-environment/eiq-inference-with-tensorflow-lite-micro:EIQ-TFLITE-MICRO]

 

위에서 다운로드 링크 누르니 이상한데(?)로 보내버리네

[링크 : https://mcuxpresso.nxp.com/en/welcome] cortex-M7 쓰려면 이게 필요한 듯. 이클립스 기반?

[링크 : https://source.codeaurora.org/external/imx/imx-manifest]

 

오오 i.MX 8M Plus!!

Cortex-A / GPU / NPU 오오오...

[링크 : https://www.nxp.com/docs/en/user-guide/IMX-MACHINE-LEARNING-UG.pdf]

 

 

+

이미지 받아보니 아래와 같이 구성되어 있다.

귀찮으면 fsl-image-validation-imx-imx8mmevk.sdcard 를 sd에 구워서 켜보면 될 듯.

 

imx_m4_demos에는 bin 파일이 있는데 이건 어떻게 올려서 쓰려나?

 

MCUXpresso 안쓰면 uboot에서 해당 파일을 직접 sd에 넣어 실행하는 수 밖에 없나?

4.2 Run applications using U-Boot

This section describes how to run applications using an SD card and pre-built U-Boot image for i.MX processor.
  1. Following the steps from section 2—Embedded Linux of this Getting Started guide, prepare an SD card with a pre-built U-Boot + Linux image from the Linux BSP package for the i.MX 8M Plus processor. If you have already loaded the SD card with a Linux image, you can skip this step.
  2. Insert the SD card in the host computer (Linux or Windows) and copy the application image (for example hello_world.bin) to the FAT partition of the SD card.
  3. Safely remove the SD card from the PC.
  4. Insert the SD card to the target board. Make sure to use the default boot SD slot and double check the Boot switch setup.
  5. Connect the DEBUG UART connector on the board to the PC through USB cable. The Windows OS installs the USB driver automatically, and the Ubuntu OS will find the serial devices as well.
    See Connect USB debug cable section in Out of box for more instructions on serial communication applications.
  6. Open a second terminal on the i.MX8M Plus EVK board’s second enumerated serial port. This is the Cortex®-M7’s serial console. Set the speed to 115200 bit/s, data bits 8, 1 stop bit (115200, 8N1), no parity.
  7. Power up the board and stop the boot process by pressing any key before the U-Boot countdown reaches zero. At the U-Boot prompt on the first terminal, type the following commands.
    => fatload mmc 0:1 0x48000000 hello_world.bin
    => cp.b 0x48000000 0x7e0000 0x20000
    => bootaux 0x7e0000
    These commands copy the image file from the first partition of the SD card into the Cortex®-M7’s TCM and releases the Cortex®-M7 from reset.

 

 

리눅스에서 /sys 등으로 접근할 순 없나?

wic 파일을 win32diskimager로 구우면 되려나?

[링크 : https://www.nxp.com/docs/en/user-guide/IMX_LINUX_USERS_GUIDE.pdf]

[링크 : https://www.nxp.com/part/8MPLUSLPD4-EVK#/]

 

MCUXpresso 로 imx8m quad 선택해서 빌드한다?

[링크 : https://www.embeddedartists.com/wp-content/uploads/2019/03/iMX8M_Working_with_Cortex-M.pdf]

'embeded > i.mx 8m plus' 카테고리의 다른 글

i.mx8m plus win iot 실행  (0) 2023.02.23
i.mx8 tensilica dsp  (0) 2023.02.07
i.mx8m plus win iot  (0) 2023.02.02
imx 8m plus NPU 에러 추적  (5) 2021.10.14
i.MX 8M PLUS tensorflow NPU  (0) 2021.10.13
Posted by 구차니
embeded/odroid2021. 9. 29. 17:50

ADC 제외하고는 3.3V

라즈베리와 동일한 전압레벨이니 ok

[링크 : https://wiki.odroid.com/odroid-c2/hardware/expansion_connectors]

 

이런저런 경고가 뜨지만 무시하고 설치!

$ sudo apt install software-properties-common
$ sudo add-apt-repository ppa:hardkernel/ppa
$ sudo apt update
$ sudo apt install odroid-wiringpi
$ gpio readall
 +-----+-----+---------+------+---+--- C2 ---+---+------+---------+-----+-----+
 | I/O | wPi |   Name  | Mode | V | Physical | V | Mode |  Name   | wPi | I/O |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 |     |     |    3.3V |      |   |  1 || 2  |   |      | 5V      |     |     |
 | 205 |   8 |   SDA.1 |   IN | 1 |  3 || 4  |   |      | 5V      |     |     |
 | 206 |   9 |   SCL.1 |   IN | 1 |  5 || 6  |   |      | 0V      |     |     |
 | 249 |   7 |  IO.249 |   IN | 1 |  7 || 8  |   |      | TxD1    | 15  |     |
 |     |     |      0V |      |   |  9 || 10 |   |      | RxD1    | 16  |     |
 | 247 |   0 |  IO.247 |   IN | 1 | 11 || 12 | 1 | IN   | IO.238  | 1   | 238 |
 | 239 |   2 |  IO.239 |   IN | 1 | 13 || 14 |   |      | 0V      |     |     |
 | 237 |   3 |  IO.237 |   IN | 1 | 15 || 16 | 1 | IN   | IO.236  | 4   | 236 |
 |     |     |    3.3V |      |   | 17 || 18 | 1 | IN   | IO.233  | 5   | 233 |
 | 235 |  12 |  IO.235 |   IN | 1 | 19 || 20 |   |      | 0V      |     |     |
 | 232 |  13 |  IO.232 |   IN | 1 | 21 || 22 | 1 | IN   | IO.231  | 6   | 231 |
 | 230 |  14 |  IO.230 |   IN | 1 | 23 || 24 | 1 | IN   | IO.229  | 10  | 229 |
 |     |     |      0V |      |   | 25 || 26 | 1 | OUT  | IO.225  | 11  | 225 |
 |     |  30 |   SDA.2 |      |   | 27 || 28 |   |      | SCL.2   | 31  |     |
 | 228 |  21 |  IO.228 |   IN | 1 | 29 || 30 |   |      | 0V      |     |     |
 | 219 |  22 |  IO.219 |   IN | 1 | 31 || 32 | 1 | IN   | IO.224  | 26  | 224 |
 | 234 |  23 |  IO.234 |   IN | 0 | 33 || 34 |   |      | 0V      |     |     |
 | 214 |  24 |  IO.214 |   IN | 1 | 35 || 36 | 1 | IN   | IO.218  | 27  | 218 |
 |     |  25 |   AIN.1 |      |   | 37 || 38 |   |      | 1V8     | 28  |     |
 |     |     |      0V |      |   | 39 || 40 |   |      | AIN.0   | 29  |     |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 | I/O | wPi |   Name  | Mode | V | Physical | V | Mode |  Name   | wPi | I/O |
 +-----+-----+---------+------+---+--- C2 ---+---+------+---------+-----+-----+

Err:3 http://deb.odroid.in/c2 bionic InRelease
  The following signatures were invalid: EXPKEYSIG 5360FB9DAB19BAC9 Mauro Ribeiro (mdrjr) <mauro.ribeiro@hardkernel.com>

Reading package lists... Done
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: http://deb.odroid.in/c2 bionic InRelease: The following signatures were invalid: EXPKEYSIG 5360FB9DAB19BAC9 Mauro Ribeiro (mdrjr) <mauro.ribeiro@hardkernel.com>
W: Failed to fetch http://deb.odroid.in/c2/dists/bionic/InRelease  The following signatures were invalid: EXPKEYSIG 5360FB9DAB19BAC9 Mauro Ribeiro (mdrjr) <mauro.ribeiro@hardkernel.com>
W: Some index files failed to download. They have been ignored, or old ones used instead.

[링크 : https://wiki.odroid.com/odroid-c2/application_note/gpio/wiringpi]

'embeded > odroid' 카테고리의 다른 글

ordroid c2 - mrs 명령어 고찰  (0) 2023.09.05
wayland on odroid-c2  (0) 2021.11.22
g_mass_storage rpi - odroid c2  (0) 2021.09.28
g_mass_storage ins/rm 실패  (0) 2021.09.28
odroid c2 ubuntu 18.04, 20.04 kernel 버전 정보  (0) 2021.09.27
Posted by 구차니
embeded/raspberry pi2021. 9. 29. 16:43

1주일 정도 켜놨더니 USB HUB 가 맛이 가서 장치를 인식하지 않는데

원격접속은 문제가 없어서 의아해 하는 중.

 

rpi 2b는 USB 2.0 HUB에 랜 + USB 4port 허브로 구성된 녀석으로 알고 있었는데

3 이후로 바뀐건지 4부터 바뀐건진 모르겠지만

USB가 죽는다고 원격을 못하는 상황은 아니니 훨신 나은 듯?

 

 

+

전체 회로 공개 안하는걸로 정책이 바뀌었나?

[링크 : https://www.raspberrypi.org/documentation/computers/raspberry-pi.html]

[링크 : https://datasheets.raspberrypi.org/]

 

라즈베리 3b 까지는 USB lan 이었는지 랜포트도 그려져 있지 않은데

3b+ 이후 부터는 랜이 따로 나오는 듯?

rpi 4

GbE / TRD[0123]_[NP]

[링크 : https://datasheets.raspberrypi.org/rpi4/raspberry-pi-4-reduced-schematics.pdf]

bcm54213

https://www.hackster.io/news/meet-the-new-raspberry-pi-4-model-b-9b4698c284

 

rpi 3b+

ETH, PoE , TR[0123][np]

[링크 : https://datasheets.raspberrypi.org/rpi3/raspberry-pi-3-b-plus-reduced-schematics.pdf]

보드에서 방열판 떼어보니 LAN7515칩이 발견됨

Hi-Speed USB 2.0 to 10/100/1000 Gigabit Ethernet controller

[링크 : https://www.microchip.com/en-us/product/LAN7500]

 

rpi 3b

[링크 : https://datasheets.raspberrypi.org/rpi3/raspberry-pi-3-b-reduced-schematics.pdf]

 

rpi 2b

[링크 : https://datasheets.raspberrypi.org/rpi2/raspberry-pi-2-b-reduced-schematics.pdf]

'embeded > raspberry pi' 카테고리의 다른 글

rpi pico usb sound  (0) 2021.11.08
rpi3 2초만에 부팅하기  (0) 2021.10.30
rpi zero otg  (0) 2021.09.27
스피커가 부실했군..  (0) 2021.09.26
rpi 2b g_mass_storage  (0) 2021.09.25
Posted by 구차니
embeded/odroid2021. 9. 28. 23:37

dd 해서 파일기반 파일시스템을 만들고 mkfs를 하지 않으면 g_mass_storage에 연결은 되어있지만

USB HOST 측에서 마운트를 할 수 없다(파일 시스템을 알 수 없어 마운트 불가)

// odroid c2 에서 작업
# dd if=/dev/zero of=otg.drive bs=1M count=128
# mkfs -t ext4 otg.drive
# modprobe g_mass_storage filename=otg.drive

 

USB HOST 측에서는 단순하게 마운트 해서 쓰면 되는데

// rpi 2b 에서 작업
$ sudo mount /dev/sda /mnt
$ sudo touch /mnt/tt
$ sudo umount /mnt

 

odroid의 mmcblk0p1을 연결했을 때는 sync 하면 쓰이는게 보였던 것 같은데

파일 기반 파일시스템이라 그런가 rpi 2b에서 파일을 생성하고 sync 해도 변화가 없고, umount를 해도 변화가 없었다.

odroid c2 에서 해당 파일을 umount 하고 mount 해야 변경점이 보이는데

물리 장칙 아니라 그런진 모르겠다.

 

[링크 : https://linuxconfig.org/how-to-create-a-file-based-filesystem-using-dd-command-on-linux]

[링크 : https://www.kernel.org/doc/Documentation/usb/mass-storage.txt]

'embeded > odroid' 카테고리의 다른 글

wayland on odroid-c2  (0) 2021.11.22
odroid c2 gpio 와 wiringpi  (0) 2021.09.29
g_mass_storage ins/rm 실패  (0) 2021.09.28
odroid c2 ubuntu 18.04, 20.04 kernel 버전 정보  (0) 2021.09.27
odroid c2 usb otg, libcomposite usb hid  (0) 2021.09.26
Posted by 구차니
embeded/odroid2021. 9. 28. 22:32

[링크 : https://www.raspberrypi.org/forums/viewtopic.php?t=216810]

 

[링크 : https://linuxlink.timesys.com/docs/wiki/engineering/HOWTO_Use_USB_Gadget_File_Storage]

[링크 : https://www.kernel.org/doc/Documentation/usb/mass-storage.txt]

[링크 : https://linux-sunxi.org/USB_Gadget/Mass_storage]

 

 

# modprobe g_mass_storage file=/dev/mmcblk0p1 removable=y
# dmesg
[   41.197852] Mass Storage Function, version: 2009/09/11
[   41.197867] LUN: removable file: (no medium)
[   41.197950] LUN: removable file: /dev/mmcblk0p1
[   41.197956] Number of LUNs=1
[   41.197965] Number of LUNs=1
[   41.198085] g_mass_storage gadget: Mass Storage Gadget, version: 2009/09/11
[   41.198092] g_mass_storage gadget: userspace failed to provide iSerialNumber
[   41.198097] g_mass_storage gadget: g_mass_storage ready
[   41.504544] USB RESET
[   41.583840] usb 1-1.3: new high-speed USB device number 3 using dwc_otg
[   41.587991] USB RESET
[   41.685839] g_mass_storage gadget: high-speed config #1: Linux File-Backed Storage
[   41.686316] usb-storage 1-1.3:1.0: USB Mass Storage device detected
[   41.686873] usb-storage 1-1.3:1.0: Quirks match for vid 0525 pid a4a5: 10000
[   41.686927] scsi0 : usb-storage 1-1.3:1.0
[   42.684797] scsi 0:0:0:0: Direct-Access     Linux    File-Stor Gadget 0316 PQ: 0 ANSI: 2
[   42.688020] sd 0:0:0:0: [sda] 262144 512-byte logical blocks: (134 MB/128 MiB)
[   42.688133] WARN::dwc_otg_pcd_ep_halt:2432: 1 IN XFer In process
[   42.696834] sd 0:0:0:0: Attached scsi generic sg0 type 0
[   42.794589] sd 0:0:0:0: [sda] Write Protect is off
[   42.794603] sd 0:0:0:0: [sda] Mode Sense: 0f 00 00 00
[   42.794783] WARN::dwc_otg_pcd_ep_halt:2432: 1 IN XFer In process
[   42.904614] sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[   42.906940] WARN::dwc_otg_pcd_ep_halt:2432: 1 IN XFer In process
[   43.014729] WARN::dwc_otg_pcd_ep_halt:2432: 1 IN XFer In process
[   43.125146]  sda:
[   43.127871] WARN::dwc_otg_pcd_ep_halt:2432: 1 IN XFer In process
[   43.235032] WARN::dwc_otg_pcd_ep_halt:2432: 1 IN XFer In process
[   43.344734] sd 0:0:0:0: [sda] Attached SCSI removable disk
# lsmod
Module                  Size  Used by
sg                     31094  0
g_mass_storage          2587  0
usb_f_mass_storage     35010  2 g_mass_storage
libcomposite           46311  2 usb_f_mass_storage,g_mass_storage
ir_lirc_codec           4934  3
lirc_dev               10879  1 ir_lirc_codec
ir_mce_kbd_decoder      3426  0
ir_rc6_decoder          2010  0
ir_sanyo_decoder        1657  0
ir_sony_decoder         1663  0
ir_jvc_decoder          1725  0
ir_rc5_decoder          1586  0
ir_nec_decoder          1789  0
meson_ir                3356  0
w1_gpio                 3801  0
wire                   28614  1 w1_gpio
gxbb_wdt                3395  0
meson_gpiomem           4040  0
sch_fq_codel            7827  2
ip_tables              17220  0
ipv6                  387317  18
autofs4                27592  2
# rmmod g_mass_storage
root@odroid:~# lsmod
Module                  Size  Used by
sg                     31094  0
usb_f_mass_storage     35010  0
libcomposite           46311  1 usb_f_mass_storage
ir_lirc_codec           4934  3
lirc_dev               10879  1 ir_lirc_codec
ir_mce_kbd_decoder      3426  0
ir_rc6_decoder          2010  0
ir_sanyo_decoder        1657  0
ir_sony_decoder         1663  0
ir_jvc_decoder          1725  0
ir_rc5_decoder          1586  0
ir_nec_decoder          1789  0
meson_ir                3356  0
w1_gpio                 3801  0
wire                   28614  1 w1_gpio
gxbb_wdt                3395  0
meson_gpiomem           4040  0
sch_fq_codel            7827  2
ip_tables              17220  0
ipv6                  387317  18
autofs4                27592  2
# modprobe g_mass_storage file=/dev/mmcblk0p1 removable=y
modprobe: ERROR: could not insert 'g_mass_storage': Device or resource busy

[링크 : https://developer.ridgerun.com/wiki/index.php?title=How_to_use_mass_storage_gadget]

Posted by 구차니
embeded/raspberry pi2021. 9. 27. 18:00

rpi 4 cm 에서 usb를 쓰려면 config.txt에 다음의 내용을 추가해야 하는데

dtoverlay=dwc2,dr_mode=host

 

$ modinfo dwc2
filename:       /lib/modules/5.10.60-v7+/kernel/drivers/usb/dwc2/dwc2.ko
license:        Dual BSD/GPL
author:         Synopsys, Inc.
description:    DESIGNWARE HS OTG Core
license:        Dual BSD/GPL
author:         Matthijs Kooijman <matthijs@stdin.nl>
description:    DESIGNWARE HS OTG Platform Glue
srcversion:     C0FF7C976DCDD3E4810AFB1
alias:          of:N*T*Cst,stm32mp15-hsotgC*
alias:          of:N*T*Cst,stm32mp15-hsotg
alias:          of:N*T*Cst,stm32mp15-fsotgC*
alias:          of:N*T*Cst,stm32mp15-fsotg
alias:          of:N*T*Cst,stm32f7-hsotgC*
alias:          of:N*T*Cst,stm32f7-hsotg
alias:          of:N*T*Cst,stm32f4x9-hsotgC*
alias:          of:N*T*Cst,stm32f4x9-hsotg
alias:          of:N*T*Cst,stm32f4x9-fsotgC*
alias:          of:N*T*Cst,stm32f4x9-fsotg
alias:          of:N*T*Capm,apm82181-dwc-otgC*
alias:          of:N*T*Capm,apm82181-dwc-otg
alias:          of:N*T*Camcc,dwc-otgC*
alias:          of:N*T*Camcc,dwc-otg
alias:          of:N*T*Camlogic,meson-g12a-usbC*
alias:          of:N*T*Camlogic,meson-g12a-usb
alias:          of:N*T*Camlogic,meson-gxbb-usbC*
alias:          of:N*T*Camlogic,meson-gxbb-usb
alias:          of:N*T*Camlogic,meson8b-usbC*
alias:          of:N*T*Camlogic,meson8b-usb
alias:          of:N*T*Camlogic,meson8-usbC*
alias:          of:N*T*Camlogic,meson8-usb
alias:          of:N*T*Csamsung,s3c6400-hsotgC*
alias:          of:N*T*Csamsung,s3c6400-hsotg
alias:          of:N*T*Csnps,dwc2C*
alias:          of:N*T*Csnps,dwc2
alias:          of:N*T*Clantiq,xrx200-usbC*
alias:          of:N*T*Clantiq,xrx200-usb
alias:          of:N*T*Clantiq,arx100-usbC*
alias:          of:N*T*Clantiq,arx100-usb
alias:          of:N*T*Crockchip,rk3066-usbC*
alias:          of:N*T*Crockchip,rk3066-usb
alias:          of:N*T*Chisilicon,hi6220-usbC*
alias:          of:N*T*Chisilicon,hi6220-usb
alias:          of:N*T*Cbrcm,bcm2835-usbC*
alias:          of:N*T*Cbrcm,bcm2835-usb
depends:        udc-core,roles
intree:         Y
name:           dwc2
vermagic:       5.10.60-v7+ SMP mod_unload modversions ARMv7 p2v8
pi@raspberrypi:~ $ modinfo dwc2 -v

 

dtoverlay 상으로는 dr_mode 에 host / peripheral / otg를 넣을수 있다고 한다.

$ sudo dtoverlay -h dwc2
Name:   dwc2

Info:   Selects the dwc2 USB controller driver

Usage:  dtoverlay=dwc2,<param>=<val>

Params: dr_mode                 Dual role mode: "host", "peripheral" or "otg"

        g-rx-fifo-size          Size of rx fifo size in gadget mode

        g-np-tx-fifo-size       Size of non-periodic tx fifo size in gadget
                                mode

 

otg 설정에 주변기기로 인식을 시키네..?

dtoverlay=dwc2,dr_mode=peripheral in file /boot/config.txt.

[링크 : https://gist.github.com/gbaman/50b6cca61dd1c3f88f41]

'embeded > raspberry pi' 카테고리의 다른 글

rpi3 2초만에 부팅하기  (0) 2021.10.30
rpi 4는 USB to Ethernet이 아닌가?  (0) 2021.09.29
스피커가 부실했군..  (0) 2021.09.26
rpi 2b g_mass_storage  (0) 2021.09.25
rpi4에서 gpio readall 실행 안될 때  (0) 2021.09.24
Posted by 구차니
embeded/odroid2021. 9. 27. 17:21

odroid c2용 18.04 버전정보를 보니 커널이 3.16

# uname -a
Linux odroid 3.16.72-46 #1 SMP PREEMPT Tue Aug 13 18:09:58 -03 2019 aarch64 aarch64 aarch64 GNU/Linux

 

20.04는 커널 버전이 올라갔으려나?

ubuntu-18.04.3-3.16-minimal-odroid-c2-20190814.img
ubuntu-20.04-3.16-minimal-odroid-c2-20210201.img

파일명을 보아하니.. 커널은 둘다 동일하게 3.16이고 배포판 버전만 올라간듯..

 

[링크 : https://wiki.odroid.com/getting_started/os_installation_guide#tab__odroid-c2]

[링크 : https://dn.odroid.com/S905/Ubuntu/]

 

4.17에 대한 글은 2018년도에 멈춰있네..

[링크 : https://www.hardkernel.com/ko/tag/odroid-c2/]

[링크 : https://forum.odroid.com/viewtopic.php?f=135&t=22717&start=850#p226092]

 

'embeded > odroid' 카테고리의 다른 글

g_mass_storage rpi - odroid c2  (0) 2021.09.28
g_mass_storage ins/rm 실패  (0) 2021.09.28
odroid c2 usb otg, libcomposite usb hid  (0) 2021.09.26
odorid c2 usb otg gadget keyboard as hid  (0) 2021.09.23
odroid c2 OTG와 mass storage  (0) 2021.09.19
Posted by 구차니
embeded/raspberry pi2021. 9. 26. 17:33

일단 앰프는 class D 앰프고

얘는 PWM 어쩌구 하던데 원리까지 알아보려니 급 귀찮고..

 

The PAM8403 is a 3W, class-D audio amplifier.

[링크 : https://pdf1.alldatasheet.com/datasheet-pdf/view/1132029/DIODES/PAM8403.html]

[링크 : https://blog.naver.com/iknowiknow/40021691136]

 

지금보니 스피커는 0.5W

드라이브는 3W+3W 가능한데 오늘 odroid에 연결해서 5V 어댑터 전원 끌어오니 음질이 썩 나쁘진 않은것 같기도?

0.5W 면은 5V * 0.1A 일텐데, 두개니까 0.2A

전에도 그렇겠지만 딱히 커버 불가능한 수준은 아닌것 같은데 왜였을까..

[링크 : https://blog.naver.com/damtaja/221848352426]

2020.04.17 - [embeded/arduino(genuino)] - PAM8403 3W 스테레오 오디오 앰프

 

다른 저가형 사운드바를 봐도 3W 를 많이 쓰는데 비슷한 등급의 부품을 써서 만드는 것 같네.

'embeded > raspberry pi' 카테고리의 다른 글

rpi 4는 USB to Ethernet이 아닌가?  (0) 2021.09.29
rpi zero otg  (0) 2021.09.27
rpi 2b g_mass_storage  (0) 2021.09.25
rpi4에서 gpio readall 실행 안될 때  (0) 2021.09.24
rpi 4 lirc tx, rx  (0) 2021.09.23
Posted by 구차니
embeded/odroid2021. 9. 26. 08:51

방법들은 비슷한데.. 따라하는데 영 안되네?

functions 디렉토리에 hid.usb0 디렉토리를 생성하는데 에러가 발생.

#!/bin/bash
# From the README at https://github.com/girst/hardpass

dtoverlay dwc2
modprobe dwc2
modprobe libcomposite
cd /sys/kernel/config/usb_gadget/
mkdir -p g1
cd g1
echo 0x1d6b > idVendor # Linux Foundation
echo 0x0104 > idProduct # Multifunction Composite Gadget
echo 0x0100 > bcdDevice # v1.0.0
echo 0x0200 > bcdUSB # USB2
mkdir -p strings/0x409
echo "fedcba9876543210" > strings/0x409/serialnumber
echo "girst" > strings/0x409/manufacturer
echo "Hardpass" > strings/0x409/product

N="usb0"
mkdir -p functions/hid.$N
echo 1 > functions/hid.usb0/protocol
echo 1 > functions/hid.usb0/subclass
echo 8 > functions/hid.usb0/report_length

echo -ne \\x05\\x01\\x09\\x06\\xa1\\x01\\x85\\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\\x05\\x75\\x08\\x15\\x00\\x25\\x65\\x05\\x07\\x19\\x00\\x29\\x65\\x81\\x00\\xc0\\x05\\x01\\x09\\x02\\xa1\\x01\\x09\\x01\\xa1\\x00\\x85\\x02\\x05\\x09\\x19\\x01\\x29\\x03\\x15\\x00\\x25\\x01\\x95\\x03\\x75\\x01\\x81\\x02\\x95\\x01\\x75\\x05\\x81\\x03\\x05\\x01\\x09\\x30\\x09\\x31\\x15\\x81\\x25\\x7f\\x75\\x08\\x95\\x02\\x81\\x06\\xC0\\xC0 > functions/hid.usb0/report_desc

C=1
mkdir -p configs/c.$C/strings/0x409
echo "Config $C: ECM network" > configs/c.$C/strings/0x409/configuration
echo 250 > configs/c.$C/MaxPower
ln -s functions/hid.usb0 configs/c.$C/

ls /sys/class/udc > UDC

[링크 : https://ndb796.tistory.com/481]

[링크 : https://www.isticktoit.net/?p=1383]

[링크 : https://www.sysnet.pe.kr/2/0/11363]

 

혹시 권한 문제인가 해서 추가해도 안되고..

sysfs 특성이라 드라이버에서 허가되지 않는 파일은 생성이 안되는 것 같은데 왜 일까..

# ls -al
drwxr-xr-x 2 root root    0 Sep 26 09:15 functions

# chmod 777 functions/
# ls -al
drwxrwxrwx 2 root root    0 Sep 26 09:15 functions

# mkdir hid.usb0
mkdir: cannot create directory 'hid.usb0': No such file or directory
# touch hid.usb0
touch: cannot touch 'hid.usb0': Permission denied

 

 

+

3.16 커널인데 3.19 이후 부터 된다고. 드라이버 지원(하드웨어 가속)을 포기하고 신버전을 써봐야 할지도?

# ll /lib/modules/3.16.72-46/kernel/drivers/usb/gadget/
total 804
drwxr-xr-x 2 root root  4096 Aug 13  2019 ./
drwxr-xr-x 7 root root  4096 Aug 13  2019 ../
-rw-r--r-- 1 root root 14424 Aug 13  2019 g_acm_ms.ko
-rw-r--r-- 1 root root 23784 Aug 13  2019 g_audio.ko
-rw-r--r-- 1 root root 12048 Aug 13  2019 g_cdc.ko
-rw-r--r-- 1 root root 14920 Aug 13  2019 g_ether.ko
-rw-r--r-- 1 root root 19632 Aug 13  2019 g_ffs.ko
-rw-r--r-- 1 root root 24208 Aug 13  2019 g_hid.ko

# insmod g_hid
insmod: ERROR: could not load module g_hid: No such file or directory

# modprobe g_hid
modprobe: ERROR: could not insert 'g_hid': No such device

# uname -a
Linux odroid 3.16.72-46 #1 SMP PREEMPT Tue Aug 13 18:09:58 -03 2019 aarch64 aarch64 aarch64 GNU/Linux

[링크 : https://forum.odroid.com/viewtopic.php?t=36602]

[링크 : https://forum.odroid.com/viewtopic.php?t=30267]

'embeded > odroid' 카테고리의 다른 글

g_mass_storage ins/rm 실패  (0) 2021.09.28
odroid c2 ubuntu 18.04, 20.04 kernel 버전 정보  (0) 2021.09.27
odorid c2 usb otg gadget keyboard as hid  (0) 2021.09.23
odroid c2 OTG와 mass storage  (0) 2021.09.19
odroid c2 ADC  (1) 2021.09.19
Posted by 구차니