2023-02-28

[docker] portainer

$ docker volume create portainer_data
$ docker run -d -p 8000:8000 -p 9443:9443 --name portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v /data/portainer:/data portainer/portainer-ce:latest

2023-02-27

[docker] maclvan

1. macvlan을 생성한다.
MACVLAN_PARENT_INTERFACE=enx047bcb5e8b20
MACVLAN_SUBNET=192.168.25.0/24
MACVLAN_GATEWAY=192.168.25.1
docker network create -d macvlan   --subnet=$MACVLAN_SUBNET   --gateway=$MACVLAN_GATEWAY   -o parent=$MACVLAN_PARENT_INTERFACE   macvlan_network

#고정IP
docker run -itd --name=macvlan_container --network=macvlan_network --ip=192.168.25.100 --mac-address=00:11:22:33:44:55 hello:0.1

#자동IP
docker run -it --name=macvlan_container --network=macvlan_network --mac-address=00:11:22:33:44:55 hello:0.1


[BLE] 다이소 ble모듈 리눅스에 연결시... 해결법.

[46864.573210] usb 3-3.4.3.4.3: new full-speed USB device number 15 using xhci_hcd
[46864.682163] usb 3-3.4.3.4.3: New USB device found, idVendor=0bda, idProduct=8771, bcdDevice= 2.00
[46864.682171] usb 3-3.4.3.4.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[46864.682173] usb 3-3.4.3.4.3: Product: Bluetooth Radio
[46864.682174] usb 3-3.4.3.4.3: Manufacturer: Realtek
[46864.682176] usb 3-3.4.3.4.3: SerialNumber: 00E04C239987
[46864.692638] Bluetooth: hci1: RTL: examining hci_ver=0a hci_rev=000b lmp_ver=0a lmp_subver=8761
[46864.693653] Bluetooth: hci1: RTL: rom_version status=0 version=1
[46864.693660] Bluetooth: hci1: RTL: loading rtl_bt/rtl8761bu_fw.bin
[46864.703096] bluetooth hci1: Direct firmware load for rtl_bt/rtl8761bu_fw.bin failed with error -2
[46864.703106] Bluetooth: hci1: RTL: firmware file rtl_bt/rtl8761bu_fw.bin not found


$ cd /usr/lib/firmware/rtl_bt $ sudo ln -s rtl8761b_fw.bin rtl8761bu_fw.bin


2023-02-17

[팁] ssh접속시 다 보내기.

#접속만 하고싶다. sshpass -p 'P@ssw0rd' ssh -o StrictHostKeyChecking=no root@1.2.3.4 #파일복사 하고싶다. sshpass -p 'P@ssw0rd' scp -o StrictHostKeyChecking=no * root@remotsvr.local:/usr/local/fw/ [원문] https://zetawiki.com/wiki/%EB%A6%AC%EB%88%85%EC%8A%A4_sshpass_%EC%82%AC%EC%9A%A9%EB%B2%95 

2023-02-14

[개발노트] embedded linux vscode remote gdb

vscode로 편집만 하던 리눅스 app을 원격 디버깅 해보기.

sudo apt install build-essential gdb gdb-multiarch

vscode 로 폴더 열기.

.vscode 폴더에 3개의 파일 만들기.

launch.json

{
"version": "0.2.0",
"configurations": [
{
"name": "GDB-Debug",
"type": "cppdbg",
"request": "launch",
"program": "${config:BINARY}",
"args": [],
"stopAtEntry": true,
"cwd": "${workspaceFolder}",
"environment": [],
"console": "integratedTerminal",
"MIMode": "gdb",
"targetArchitecture": "arm",
"preLaunchTask": "deploy",
"setupCommands": [
{
"description": "Pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true,
}
],
"miDebuggerPath": "/usr/bin/gdb-multiarch",
"miDebuggerServerAddress": "${config:TARGET_IP}:${config:DEBUG_PORT}",
}
]
}

settings.json

{
"TARGET_IP":"192.168.25.53",
"DEBUG_PORT":"6666",
"BINARY":"s1app3",

"SDK_DIR":"/home/happycpu/work/wrlinux/sdk/environment-setup-cortexa7t2hf-neon-vfpv4-wrs-linux-gnueabi",
}

tasks.json

{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "cross-compile",
"type": "shell",
"command": "sh",
"args": [
"cross-compile.sh",
"${config:SDK_DIR}",
],
"problemMatcher": [],
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "deploy",
"isBackground": true,
"type": "shell",
"command": "sh",
"args": [
"deploy.sh",
"${config:TARGET_IP}",
"${config:DEBUG_PORT}",
"${config:BINARY}"
],
"problemMatcher": {
"base": "$gcc",
"background": {
"activeOnStart": true,
"beginsPattern": "${config:BINARY}",
"endsPattern": "Listening on port [0-9]{4}"
}
},
"dependsOn": [
"cross-compile"
],
},
]
}


스크립트파일2개 추가.

cross-compile.sh

#!/bin/bash
SDK_DIR="$1"

. ${SDK_DIR}
cmake .
make clean; make -j$(nproc)

*yocto 의 sdk를 source 하여주는 행위와 cmake파일 생성하고 make까지 함.


deploy.sh

#!/bin/bash
DEST_IP="$1"
DEBUG_PORT="$2"
BINARY="$3"
DEST_DIR="/root"

# kill gdbserver on tx8m and delete old binary
ssh root@${DEST_IP} "sh -c '/usr/bin/killall -q gdbserver; rm -rf ${DEST_DIR}/${BINARY} exit 0'"

# send binary to target
scp ${BINARY} root@${DEST_IP}:${DEST_DIR}/${BINARY}

# start gdbserver on target
ssh -t root@${DEST_IP} "sh -c 'cd ${DEST_DIR}; gdbserver localhost:${DEBUG_PORT} ${BINARY}'"

*DEST_DIR은 타겟보드의 실행파일 위치.


[원문]https://karo-electronics.github.io/docs/software-documentation/vscode/index.html#





2023-02-03

[yocto embedded linux dotnet azure-iot-sdk-charp] 절차

[머신작업]
yocto에는 meta-dotnet-core를 추가해준다.
$ build/conf/bblayers.conf 에 추가함.
나의 욕토는 hardknott이므로, 추가해준다. 
meta-dotnet-core/conf/layer.conf 
LAYERSERIES_COMPAT_dotnet-core = "honister dunfell kirkstone hardknott"
던펠까지만 있었으면, 상위버전이므로 안될수도있었는데, kirkstone까지 되는것이므로 그 아랫버전은 될것이라 생각하고 했더니 되더라.
이미지에 dotnet-core 추가. 추가 위치는 나의 이미지 어펜드들 모아놓은곳에 추가함.
빌드하면 이미지가 약 100메가정도 늘어남.
추가로, master는 dotnet7.0이 기본이므로, pc의 개발환경과 azure sample소스등이 dotnet60으로 된것을 고려하여 타겟의 버전도 6.0으로 찍어준다.


build command for linux-arm

dotnet publish -r linux-arm -p:PublishSingleFile=true --self-contained false -c Release



2023-02-02

[쉘] 바이너리 파일에서 추출하여 버전빼기


grep -a "\$Revision.*\$" /usr/local/network_adapter.bin 를 실행하면 아래와 같이 추출해준다.
$Id: ESP32 $ $Date: Feb  1 2023 22:28:54 $ $Revision: 0.0.5.std $

이걸 이용해서 추가해서 0.0.5.std 만 추출하고싶다.
grep -a "\$Revision.*\$" /usr/local/network_adapter.bin | cut -d "$" -f6 | cut -d " " -f2
0.0.5.std


암호화 + base64 하고 쉘스크립트.

 #!/bin/bash # IV와 UserKey를 설정합니다 (아스키 문자열을 그대로 사용). IV="0123456789abcdef"  UserKey="0123456789abcdef" # IV와 UserKey를 16...