레이블이 IDE-VS Code인 게시물을 표시합니다. 모든 게시물 표시
레이블이 IDE-VS Code인 게시물을 표시합니다. 모든 게시물 표시

4/24/2021

ESP32 OpenOCD 와 GDB 사용

1. ESP32 개발환경구축 


  • ESP32-OpenOCD
ESP32개발환경을 설치하면, 자동으로 아래의 Openocd가 설치가 되며, 없다면, 직접설치

  • JTAG의 기본이해와 OpenOCD 관련내용 
JTAG을 기본적으로 이해하고 OpenOCD로 어떻게 JTAG을 사용하는지 이해 

  • Raspberry Pi 에 OpenOCD 구성 및 구조이해 
이전의 FTDI 기반으로 Raspberry Pi3  OpenOCD 사용 (반드시 숙지)  

  • /dev/ttyUSBx 권한문제

$ ls -al /dev/ttyUSB*           // 권한문제시 직접확인 
crw-rw---- 1 root dialout 188, 0  4월 20 12:25 /dev/ttyUSB0
crw-rw-r-- 1 root plugdev 188, 1  4월 20 12:25 /dev/ttyUSB1
crw-rw-r-- 1 root plugdev 188, 2  4월 20 12:25 /dev/ttyUSB2

//각 Group 권한 추가 
$ sudo usermod -a -G dialout jhlee  //serial 
$ sudo usermod -a -G plugdev jhlee  //JTAG
or
// 직접 권한변경 
$ sudo chmod a+rw /dev/ttyUSB0

  • libusb 권한문제

Info : Configured 2 cores
  Info : Listening on port 6666 for tcl connections
  Info : Listening on port 4444 for telnet connections
  Error: libusb_open() failed with LIBUSB_ERROR_ACCESS
  Error: no device found
  Error: unable to open ftdi device with vid 0403, pid 6010, description '*', serial '*' at bus location '*'
  
문제 해결방법 (udev 권한 변경)

$ lsusb   // 현재 PID 와 VID (Product ID/ Vendor ID) 확인 
...
Bus 001 Device 011: ID 0403:6010 Future Technology Devices International, Ltd FT2232C/D/H Dual UART/FIFO IC
...

$ sudo vi /etc/udev/rules.d/esp32link.rules
ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6010", MODE="664", GROUP="plugdev"

  • Window 10 (Zadig)
Zadig Download 진행 후 아래와 같이 Libusb/WinUSB 설정 진행 



관련이슈내용



1.1  ESP32 Board 와 FT2232H Board 연결 

  • ESP32 Module과 FT2232 연결 
이전의 OpenOCD와 동일하며, 하나는 JTAG  다른하나는 Serail로 연결 
https://docs.espressif.com/projects/esp-idf/en/latest/esp32/hw-reference/esp32/get-started-wrover-kit.html




  • ESP32 OpenOCD 와 GDB 동작구조 
OpenOCD를 사용할 경우 GDB로 연결하여 동작하는데, 아래와 같이 연결되어 동작되어진다.

  https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/jtag-debugging/index.html


  • ESP32 Module 과 JTAG 연결 

ESP32 Pin

JTAG Signal

MTDO / GPIO15

TDO

MTDI / GPIO12

TDI

MTCK / GPIO13

TCK

MTMS / GPIO14

TMS

GND

GND


  • 직접 구성한 FT2232H 와 ESP32 Board 
나의 경우 ESP32에서 제공하는 ESP사에 제공해주는 FT2332H Board가 없어서 기존의 FT2232H Board로 구성한 것이지만, 
별도로 ESP에서 전용 Board를 판매하고 있으니,돈이 있다면, 직접 구입을 하면 편하다. 







2.  VS Code의 Espressif IDF 설치 

  • VS Code의 Extension 에서 Espressif IDF 설치 
VS Code에서 Extension에서 찾아서 설치 


VS Code에서 F1을 누르고, ESP로 치면, ESP-IDF 관련 많은 메뉴들이 존재하는 것을 볼 수 있다. 
VS Code의 이 메뉴 없이 직접 python의 idf.py로 직접 Control로 가능하다. 
idf.py는 esptool.py도 control하기 때문에 모두 idf.py command만 알아도 된다. 

  • 많이 사용하는 Menu들 
  1. ESP-IDF: New Project 
  2. ESP-IDF: Build your project
  3. ESP-IDF: Device configuration
  4. ESP-IDF: Flash(UART) your project
  5. ESP-IDF: Monitor your device
  6. ESP-IDF: OpenOCD  Manager

  • Terminal에서 직접 Command 입력 
$ source ~/esp/esp-idf/export.sh 

$ idf.py --help   //상위에서 제공되는 메뉴기능을 Command로 실행하면된다. 
.......
Commands:
  all                    Aliases: build. Build the project.
  app                    Build only the app.
  app-flash              Flash the app only.
  bootloader             Build only bootloader.
  bootloader-flash       Flash bootloader only.
  build-system-targets   Print list of build system targets.
  clean                  Delete build output files from the build directory.
  confserver             Run JSON configuration server.
  create-component       Create a new component.
  create-project         Create a new project.
  efuse_common_table     Generate C-source for IDF's eFuse fields.
  efuse_custom_table     Generate C-source for user's eFuse fields.
  encrypted-app-flash    Flash the encrypted app only.
  encrypted-flash        Flash the encrypted project.
  erase_flash            Erase entire flash chip.
  erase_otadata          Erase otadata partition.
  flash                  Flash the project.
  fullclean              Delete the entire build directory contents.
  gdb                    Run the GDB.
  gdbgui                 GDB UI in default browser.
  gdbtui                 GDB TUI mode.
  menuconfig             Run "menuconfig" project configuration tool.
  monitor                Display serial output.
  openocd                Run openocd from current path
  partition_table        Build only partition table.
  partition_table-flash  Flash partition table only.
  post_debug             Utility target to read the output of async debug action and stop them.
  python-clean           Delete generated Python byte code from the IDF directory
  read_otadata           Read otadata partition.
  reconfigure            Re-run CMake.
  set-target             Set the chip target to build.
  show_efuse_table       Print eFuse table.
  size                   Print basic size information about the app.
  size-components        Print per-component size information.
  size-files             Print per-source-file size information.
  uf2                    Generate the UF2 binary with all the binaries included
  uf2-app                Generate an UF2 binary for the application only


  • Monitor의 경우 별도의 Command
기본적으로 Exception이 나오면, add2line으로 분석을 해주며, bootloader에서 elf로 올려 분석을 해주는 것으로 보인다. 
Ctrl + ] 는 모니터에서 Exit 


2.1  VSCode의  Espressif IDF 설정  

  • 설치후 Espressif IDF 설정 확인 
Flash 방법도 UART/JTAG으로 두가지 다 가능 



  • 별도의 OpenOCD 세부설정 존재
중요한 것은 이거의 주내용은 Flash Type 관련설정이며, ESP OpenOCD의 위치파악 가능 및 설정확인가능 
  1. UART이면, 해당 Port로 연결
  2. JTAG이면, 해당 Port로 연결


ESP32-OpenOCD에서 확인
$ ls ~/.espressif/tools/openocd-esp32/v0.10.0-esp32-20200709/openocd-esp32/share/openocd/scripts/board/esp32*     //OpenOCD Board 설정 (Interface/Target 분석)
/home/jhlee/.espressif/tools/openocd-esp32/v0.10.0-esp32-20200709/openocd-esp32/share/openocd/scripts/board/esp32-ethernet-kit-3.3v.cfg
/home/jhlee/.espressif/tools/openocd-esp32/v0.10.0-esp32-20200709/openocd-esp32/share/openocd/scripts/board/esp32-solo-1.cfg
/home/jhlee/.espressif/tools/openocd-esp32/v0.10.0-esp32-20200709/openocd-esp32/share/openocd/scripts/board/esp32-wrover-kit-1.8v.cfg
/home/jhlee/.espressif/tools/openocd-esp32/v0.10.0-esp32-20200709/openocd-esp32/share/openocd/scripts/board/esp32-wrover-kit-3.3v.cfg
/home/jhlee/.espressif/tools/openocd-esp32/v0.10.0-esp32-20200709/openocd-esp32/share/openocd/scripts/board/esp32-wrover.cfg
/home/jhlee/.espressif/tools/openocd-esp32/v0.10.0-esp32-20200709/openocd-esp32/share/openocd/scripts/board/esp32s2-kaluga-1.cfg

$ vi ~/.espressif/tools/openocd-esp32/v0.10.0-esp32-20200709/openocd-esp32/share/openocd/scripts/board/esp32-wrover-kit-3.3v.cfg //현재 사용중인 config (Target/Inferface)


2.2  OpenOCD 연결 및 에러사항 

상위 ESP-IDF 메뉴 중 OpenOCD Manager를 이용하여 간단하게 실행가능하며, 직접 idf.py를 이용하여 실행해도 상관없다. 

  • OpenOCD 기본 동작확인
Open On-Chip Debugger  v0.10.0-esp32-20200709 (2020-07-09-08:54)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
adapter speed: 20000 kHz

Info : Configured 2 cores
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : ftdi: if you experience problems at higher adapter clocks, try the command "ftdi_tdo_sample_edge falling"
Info : clock speed 20000 kHz
Info : JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : esp32: Debug controller 0 was reset.
Info : esp32: Core 0 was reset.
Info : esp32: Debug controller 1 was reset.
Info : esp32: Core 1 was reset.
Info : Listening on port 3333 for gdb connections

  • OpenOCD 에러 
아래  에러는 대부분 제대로 연결이 안되거나,  FT2332H는 Channel이 두개인데, Channel 설정오류 즉 연결(Interface)에서 잘되지 않은 것이므로, 
HW으로는 연결사항을 확인하고, SW는 Channel 설정사항을 세부적으로 살펴 보자.  

open On-Chip Debugger  v0.10.0-esp32-20200709 (2020-07-09-08:54)
  Licensed under GNU GPL v2
  For bug reports, read
      http://openocd.org/doc/doxygen/bugs.html
  adapter speed: 20000 kHz

  Info : Configured 2 cores
  Info : Listening on port 6666 for tcl connections
  Info : Listening on port 4444 for telnet connections
  Info : ftdi: if you experience problems at higher adapter clocks, try the command "ftdi_tdo_sample_edge falling"
  Info : clock speed 20000 kHz
  Error: JTAG scan chain interrogation failed: all ones
  Error: Check JTAG interface, timings, target power, etc.
  Error: Trying to use configured scan chain anyway...
  Error: esp32.cpu0: IR capture error; saw 0x1f not 0x01
  Warn : Bypassing JTAG setup events due to errors
  Info : Listening on port 3333 for gdb connections
  • OpenOCD 세부설정 확인 
나의 경우 Channel A가 동작이되지 않아 아래와 같이 Channel B로 소스 수정하여 동작가능 
$ vi ~/.espressif/tools/openocd-esp32/v0.10.0-esp32-20200709/openocd-esp32/share/openocd/scripts/interface/ftdi/esp32_devkitj_v1.cfg 
#
# Driver for the FT2232H JTAG chip on the Espressif DevkitJ board
# (and most other FT2232H and FT232H based boards)
#
 

interface ftdi
ftdi_vid_pid 0x0403 0x6010 0x0403 0x6014

#
# interface 0 channle A 
# interface 1 channel B (나의 경우 현재 Channel B로 사용)
ftdi_channel 1

#
# ftdi_layout_init 0x0008 0xf00b 
#
# 0x0008 0x000b  JTAG 설정 
# TCK, TDI, TDO, TMS: ADBUS0-3
#
# 0x0000 0xf000 LED 설정 
# LEDs: ACBUS4-7

ftdi_layout_init 0x0008 0xf00b
ftdi_layout_signal LED -data 0x1000
ftdi_layout_signal LED2 -data 0x2000
ftdi_layout_signal LED3 -data 0x4000
ftdi_layout_signal LED4 -data 0x8000
.... 

이외 VS Code로 사용할 경우 중복 실행되는 경우 및 설정이 잘못되는 경우가 많으므로, 관련부분을 확인하자. 



2.3 App Tracer 사용 

상위 상태에서 IDF App Tracer -> Start App Trace를 실행해보면 동작되는 것을 확인가능하며, 관련 설정은 아래를 참고해서 미리 해두자. 

APP Trace

Heap Trace

  • VSCode 기반으로 OpenOCD 사용예제 
일반예제로는 좌측의 Tracer 이용하여 사용하지만 제대로 동작되지는 않는 것을 확인 


  • App tracer의 사용법 
Application Level의 JTAG을 사용하고자 한다면, 반드시 sdkdefault에 설정을 추가하고 아래의 Manaul대로 설정하자. 

  https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/app_trace.html



  • ESP32의 App Trace 사용예제
ESP32의 Example에 App Trace를 사용하여 Debug하는 예제가 존재하는데, 이 기반으로 테스트 진행 
반드시 sdkconfig의 설정과 별도의 esp함수가 필요하므로, 세부사항은 상위를 참조 

아래의 App Trace 예제를 보면, ADC Sampling을 하는데, 한번은 app trace를 이용하고 한번은 UART로 보여주는 방식으로 아주 기초적으로 사용하는 방식같다. 

  • Trace Log 분석 


3.  GDB 기반의 Visual Display 도구들 

JTAG을 사용하면, GDB는 사용해야 하며, 이 기반으로 손쉽게 디버깅할 수 있도록 하는 것이 중요한데, 예전것들 부터 보면 아래와 같다. 

  • gdbtui
gdb에서 제공하는 가장 기본적인 Dispaly로 문자 중심으로 표시를 해주는데, 사용한 일이 거의 없다.

  • ddd 
예전에 내가 많이 사용했던 GDB기반의 Display 이지만, Eclipse기반의 Tool들이 나오면서 거의 사용할일이 사실 없다.

  • Eclipse기반의 Tool들 
요즘 대부분의 유명 Chip Vendor사들은 회사마다 자신만의 Eclipse기반의 Tool을 가지고 있어 이 기반으로 손쉽게 gdb 를 사용가능하다.

  • gdbgui
이것은 이번에 나도 처음알게된 것인데 Web broswser 기반으로 동작하는데, 괜찮은 Tool 같은데, 처음 설정이 꼬이면, 제대로 동작이 안되는 것 같다.  

  • visualgdb
VisualStudio기반의 유료로 30일만 사용가능 (이전 OpenOCD에 자세히 설명)


3.1  ESP32 OpenOCD 기반의 GDB 사용법 

  • ESP32의 OpenOCD Ecplise 연결 방법 
ESP Manual을 보면 쉽게 Ecplise에 연결하고 gdbgui를 사용을 언급을 하고 있다. 
Ecplise 기반은 많이 해보았기에, gdbgui로 해보기로 하자. 

  • ESP32 TEST Program 기반 현재 상태 확인 
이전에 만들었던, exaplme로 간단하게 현재 상태를 간단히 분석해보고 gdb 명령과 gdb를 실행해보자.
$ source ~/esp/esp-idf/export.sh    // Ubuntu 20.04기반으로 해서 기본 Python 3으로 됨
Setting IDF_PATH to '/home/jhlee/esp/esp-idf'
Detecting the Python interpreter
Checking "python" ...
Command 'python' not found, did you mean:
  command 'python3' from deb python3
  command 'python' from deb python-is-python3
Checking "python3" ...
Python 3.8.5
"python3" has been detected
Adding ESP-IDF tools to PATH...
Using Python interpreter in /home/jhlee/.espressif/python_env/idf4.4_py3.8_env/bin/python    // python3기반으로 virtulenv 설정
Checking if Python packages are up to date...
The following Python requirements are not satisfied:        // 다음과 같은 문제가 발생 , 다시 설치해도 동일 
gdbgui==0.13.2.0
pygdbmi<=0.9.0.2
To install the missing packages, please run "/home/jhlee/esp/esp-idf/install.sh"
Diagnostic information:
    IDF_PYTHON_ENV_PATH: /home/jhlee/.espressif/python_env/idf4.4_py3.8_env
    Python interpreter used: /home/jhlee/.espressif/python_env/idf4.4_py3.8_env/bin/python


$ cat build/gdbinit  //gdb init 명령어확인
file /home/jhlee/project-name/build/app_trace_to_host.elf
target remote :3333
mon reset halt
flushregs
thb app_main
c


$ xtensa-esp32-elf-gdb -x build/gdbinit build/app_trace_to_host.elf   //gdb test 진행시 에러 발생 python 2.7필요  
xtensa-esp32-elf-gdb: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory

$ ll /usr/bin/py*  //Ubuntu 20.04에는 python2 가 없음

$ which python
/home/jhlee/.espressif/python_env/idf4.4_py3.8_env/bin/python

$ sudo apt-get install libpython2.7           //설치 진행 

$ xtensa-esp32-elf-gdb -x build/gdbinit build/app_trace_to_host.elf   //재진행
....
Type "apropos word" to search for commands related to "word"...
Reading symbols from build/app_trace_to_host.elf...done.
build/gdbinit:2: Error in sourced command file:
:3333: 연결 시간 초과.

  • OpenOCD와 GDB 기본 테스트 진행 
 $ idf.py openocd    //openocd 만 TEST 및 tcl/gdb/telnet server 동작확인 
Executing action: openocd
Note: OpenOCD cfg not found (via env variable OPENOCD_COMMANDS nor as a --openocd-commands argument)
OpenOCD arguments default to: "-f board/esp32-wrover-kit-3.3v.cfg"
OpenOCD started as a background task 43585
Executing action: post_debug
Open On-Chip Debugger  v0.10.0-esp32-20200709 (2020-07-09-08:54)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
Info : Configured 2 cores
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : ftdi: if you experience problems at higher adapter clocks, try the command "ftdi_tdo_sample_edge falling"
Info : clock speed 20000 kHz
Info : JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : Target halted. CPU0: PC=0x400D55BC (active)
Info : Target halted. CPU1: PC=0x400E4926
Info : Listening on port 3333 for gdb connections


$ idf.py openocd gdb                  // openocd 와 gdb TEST 진행 문제없음 
or 
$ idf.py openocd gdb   build/app_trace_to_host.elf   
........
esp32: Core 1 was reset.
Target halted. CPU0: PC=0x40000400 (active)
Target halted. CPU1: PC=0x40000400 
Hardware assisted breakpoint 1 at 0x400d55bc: file ../main/app_trace_to_host_example_main.c, line 92.
Target halted. CPU0: PC=0x400D55BC (active)
Target halted. CPU1: PC=0x400E4926 
[New Thread 1073446776]
[New Thread 1073444120]
[New Thread 1073430168]
[New Thread 1073434616]
[New Thread 1073413208]
[New Thread 1073437016]
[Switching to Thread 1073441464]

Thread 1 hit Temporary breakpoint 1, app_main () at ../main/app_trace_to_host_example_main.c:92
---Type return to continue, or q return to quit---
92      {
(gdb)  


$ idf.py openocd gdbtui   // 엔터를  몇번 치면 소스 가 보임 
or
$ idf.py openocd gdbtui  build/app_trace_to_host.elf   

   ┌──../main/app_trace_to_host_example_main.c────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
   │88       * and logging results with application tracing to the host                                                                                                                                                                           │
   │89       * as well as for comparison printing out sampling result to UART                                                                                                                                                                     │
   │90       */                                                                                                                                                                                                                                   │
   │91      void app_main(void)                                                                                                                                                                                                                   │
H+>│92      {                                                                                                                                                                                                                                     │
   │93          ESP_LOGI(TAG, "Enabling ADC1 on channel 6 / GPIO%d.", ADC1_CHANNEL_6_GPIO_NUM);                                                                                                                                                   │
   │94      #if CONFIG_IDF_TARGET_ESP32                                                                                                                                                                                                           │
   │95          adc1_config_width(ADC_WIDTH_BIT_12);                                                                                                                                                                                              │
   │96      #elif CONFIG_IDF_TARGET_ESP32S2                                                                                                                                                                                                       │
   │97          adc1_config_width(ADC_WIDTH_BIT_13);                                                                                                                                                                                              │
   │98      #endif                                                                                                                                                                                                                                │
   └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
remote Remote target In: app_main                                                                                                                                                                                             L92   PC: 0x400d55bc 
[New Thread 1073413208]
[New Thread 1073437016]
[Switching to Thread 1073441464]

---Type return to continue, or q return to quit---
Thread 1 hit Temporary breakpoint 1, app_main () at ../main/app_trace_to_host_example_main.c:92
(gdb)  quit 

3.2  OpenOCD 기반의 gdbgui  1차 TEST 진행 

결론적으로 제대로 사용해보지 못했으며, 원인은 Version 간의 문제로 보이며, 시간이 없어 이부분 추후에 다시 해보도록 하며, 관련내용을 아래에 기술한다. 
아래내용을 이해하기위해서는 python의 virtual env를 이해해야한다. 

  • gdbgui 만 별도 테스트 
gdbgui 의 경우만 제대로 동작이 되지 않아 이에 관련하여 별도로 테스트를 진행 

$ idf.py openocd gdbgui   // 제대로 실행은 되지만 Webbrowser 에서 제대로 동작되지 않음 
or
$ idf.py  openocd gdbgui monitor -p /dev/ttyUSB0  
Executing action: openocd
Note: OpenOCD cfg not found (via env variable OPENOCD_COMMANDS nor as a --openocd-commands argument)
OpenOCD arguments default to: "-f board/esp32-wrover-kit-3.3v.cfg"
OpenOCD started as a background task 33824
Executing action: gdbgui
gdbgui started as a background task 33825
Executing action: post_debug
Open On-Chip Debugger  v0.10.0-esp32-20200709 (2020-07-09-08:54)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
Info : Configured 2 cores
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : ftdi: if you experience problems at higher adapter clocks, try the command "ftdi_tdo_sample_edge falling"
Info : clock speed 20000 kHz
Info : JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : Listening on port 3333 for gdb connections 

$ which gdbgui      
/home/jhlee/.espressif/python_env/idf4.4_py3.8_env/bin/gdbgui

$ gdbgui   // idf에 기본설치된 gdbgui 만 테스트 진행 
frozen importlib._bootstrap:219: RuntimeWarning: greenlet.greenlet size changed, may indicate binary incompatibility. Expected 144 from C header, got 152 from PyObject
frozen importlib._bootstrap:219: RuntimeWarning: greenlet.greenlet size changed, may indicate binary incompatibility. Expected 144 from C header, got 152 from PyObject
frozen importlib._bootstrap:219: RuntimeWarning: greenlet.greenlet size changed, may indicate binary incompatibility. Expected 144 from C header, got 152 from PyObject
frozen importlib._bootstrap:219: RuntimeWarning: greenlet.greenlet size changed, may indicate binary incompatibility. Expected 144 from C header, got 152 from PyObject
frozen importlib._bootstrap:219: RuntimeWarning: greenlet.greenlet size changed, may indicate binary incompatibility. Expected 144 from C header, got 152 from PyObject
Opening gdbgui with default browser at http://127.0.0.1:5000
exit gdbgui by pressing CTRL+C
frozen importlib._bootstrap:219: RuntimeWarning: greenlet.greenlet size changed, may indicate binary incompatibility. Expected 144 from C header, got 152 from PyObject
frozen importlib._bootstrap:219: RuntimeWarning: greenlet.greenlet size changed, may indicate binary incompatibility. Expected 144 from C header, got 152 from PyObject
세그멘테이션 오류 (core dumped)   //idf에 기본설치된 gdbgui는 제대로 동작이 안됨

$ pip freeze | grep greenlet   //greenlet 문제로 보고 관련 version 확인 
greenlet==1.0.0

$ pip freeze | grep gdb*   //gdbgui version 확인 
gdbgui==0.13.2.0
pygdbmi==0.9.0.2

  • 일반 gdbgui 테스트 진행 (python3)
esp의 python  virtual env를 사용하지 않고 테스트진행 해야해서 상위 설정하지 않고 별도 설치 후 바로 테스트진행하니 문제없음  
$ which gdbgui        //pip3 install gdbgui 별도 설치 
/home/jhlee/.local/bin/gdbgui

$ gdbgui --version
0.14.0.2

$ pip3 freeze | grep greenlet
greenlet==0.4.16

$ gdbgui   //제대로 동작되는 것을 확인
Opening gdbgui with default browser at http://127.0.0.1:5000
View gdbgui dashboard at http://127.0.0.1:5000/dashboard
exit gdbgui by pressing CTRL+C 



  • esp  gdbgui upgrade 하기로 결정
esp 개발환경을 보면, python virtual env를 사용하는데, 내부에 gdbgui가 존재하며, 이를 upgrade를 진행하기로 결정함 
외부 python3.8  package가 아니며, virtual env 안에서만 upgrade 진행 
//source ~/esp/esp-idf/export.sh 진행했기때문에 esp virtual env 사용 
$ which gdbgui      //esp 개발안정버전 4.4 의 python virtual env에 gdbgui 가 설치됨 
/home/jhlee/.espressif/python_env/idf4.4_py3.8_env/bin/gdbgui   //문제는 python3.8기반으로 구성되었으며, 나또한 python3으로 하고싶지만, 동작되지 않음 

$ gdbgui --version
0.13.2.0

$ pip install --upgrade gdbgui     //esp virtual env의 gdbgui upgrade 진행 

$ gdbgui --version
0.14.0.2

$ gdbgui //esp virtual env 에서도 gdbgui 기본동작되는 것확인완료 (역시 version문제)
Opening gdbgui with default browser at http://127.0.0.1:5000
View gdbgui dashboard at http://127.0.0.1:5000/dashboard
exit gdbgui by pressing CTRL+C

$ idf.py openocd gdbgui  // esp openocd 와 gdbgui 기본테스트 진행했지만, Version 문제발생 
The following Python requirements are not satisfied:
gdbgui==0.13.2.0
pygdbmi<=0.9.0.2
To install the missing packages, please run "/home/jhlee/esp/esp-idf/install.sh"
Diagnostic information:
    IDF_PYTHON_ENV_PATH: /home/jhlee/.espressif/python_env/idf4.4_py3.8_env
    Python interpreter used: /home/jhlee/.espressif/python_env/idf4.4_py3.8_env/bin/python
....

$ vi ~/esp/esp-idf/requirements.txt  // version check 하는 부분 수정 (에러는 없어지지만, 제대로 동작되지 않음)

현재 나의 local에 설치하여 gdbgui 별도로 설치하여 동작되는 것을 확인 했지만, idf.py는 python virutal env기반으로 동작되기 때문에  version이 다르다. 
그래서 이를 업그레이드 했지만, idf.py의 내부에서 gdbgui 0.13.2.0 version check하는 부분이 있어 제대로 실행되지 않는다. 

version 체크 하는 부분까지도  다 고쳐서 사용할까도 생각했지만, 나중에 다시 테스트도 해야하니, 이 부분은 다시 원상복귀 하기도 결정했다.

상위와 유사한 상황

  • OpenOCD GDBGUI 1차 TEST 결론
OpenOCD와 TCL/GDB는 잘동작하지만, GDBGUI는 버그로 보인다. 
현재 아래 Manual (최신 Version 4.4) 로 보더라도, Python3으로 설치를 진행하라고 되어있는데, Python2가 필요한 거 보면, 현재도 개발중인 것으로 보이며, 
추후 시간이 된다면, Python2로 변경 후 다시 시도를 해보아도 괜찮을 것 같은데, 다른 부작용이 왠지 있을 것 같다. 


3.3  OpenOCD 기반의 gdbgui  2차 TEST 진행 

기존에 Python3만 동작되었기에, Python2 설치 후  virtual env도 Python2로 바꾸려고 했는데, 실패했다. 
현재 python2 설치되었으며, ESP32는 python3의 virtualenv를 그대로 사용함

$ sudo apt install python2 

$ sudo ln -s /usr/bin/python2 /usr/bin/python 

$ ~/esp/esp-idf/install.sh

일주일 후 다시 시도 후  갑자기 작동되는데, 이전에 왜 동작이 안되었는지 모르겠지만, 다음에 다시 시도 할 경우 다시 해봐야겠음 
며칠사이에 다른 것이 변경이 되었는지, 모르겠음 

$ cd ~/project-name   // 이전과 동일한 Project 
CMakeLists.txt  Makefile  README.md  build  debug.log  example_test.py  main  sdkconfig  sdkconfig.ci  sdkconfig.defaults  trace

$ . esp/esp-idf/export.sh 

$ which gdbgui
/home/jhlee/.espressif/python_env/idf4.4_py3.8_env/bin/gdbgui

$ gdbgui --version
0.13.2.0

$ idf.py openocd gdbgui 
or 
$ idf.py openocd gdbgui monitor -p /dev/ttyUSB1 

Web browser 기반으로 쉽게 Break Point를 쉽게 설정하고, 실행하니 편하다.

우측 정보기반으로 Ecplise 처럼 쉽게 Trace도 가능하다 

Web Browser에서 실행해서 좋은데, Ecplise 처럼 안정적이지는 못한것으로 보이는데, 잘 사용하면 괜찮을 것 같다.  

  • OpenOCD GDBGUI 2차 TEST 결론 
현재 잘 동작하며, 1차 TEST 때 왜 동작이 안되었는지가 다음에 다시 설치할 기회가 있다면, 다시 해보도록하자. 


3.4  Raspberry 를 이용한 OpenOCD 방법 


  • Raspberry Pi 와 ESP32 연결 
FTDI가 아닌 Raspberry를이용하여 OpenOCD 기반으로 JTAG으로  ESP32를 연결하는 방법인데, 새로운 방법이라 아직 시도는 안해봤지만, 추후 해보도록하자. 
상위와 거의 동일하며, FTDI 대신 Raspberry 로 변경된 것으로 보면된다. 추후 VS Code와 연결하여 Debug해보도록 해보자.

6/28/2020

VS Code 설정 및 Debug

1. VS Code Debug

아래와 같이 C 기반으로 테스트 프로그램 작성하여 진행 진행

#include <stdio.h>

int test0()
{
	int test0=0;
	printf("Hello World %d\n",test0);
	return 0;
}

int test1()
{
	int test1=3;
	printf("Hello World %d\n",test1 );
	return 0;
}

int test2()
{
	printf("Hello World 2\n");
	return 0;
}

static int world=2;

int main ()
{
	test0();
	test1();
	test2();
	printf("main World %d\n",world);

 	return 0;
}


VS Code에서 좌측아이콘의 Run and Debug 메뉴로 이동 후 lauch.json 부분 수정 

.vscode/launch.json
{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/test",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}



상위 program 항목: ELF or a.out 으로 심볼테이블 찾아야함
상위 설정 후 좌측 Run Debug 메뉴에서 손쉽게 디버깅 (이미 gdb와 관련부분 이미설치됨)

VS Code 의 Debugging 문서 
세부사항은 아래 문서참조 
  https://code.visualstudio.com/docs/editor/debugging


1.1 OpenOCD 에 연결

만약 OpenOCD의 gdbserver에 연결하고자 한다면, 아래와 같이 Server Address 추가 
Linux에서 build를 했다면, 내부에 gdbinit이 존재할 것이며, 아래와 같이 gdb 위치도 추가

    "configurations": [
        {
            ....
			"miDebuggerServerAddress": "localhost:3333",
			"miDebuggerPath": "gdb path ",
             ....
        }            



1.2 VS Code의 Task 사용법

VS Code에서 Task를 이용하여 외부툴 연결 

Task를 만들어서 VS Code에서 쉽게 Command를 만들어 Shell Script등을 연결하자.

VS Code의 Menu  
Terminal-> Run Task 실행

6/17/2020

VS Code 와 Remote X11 연결

1. WSL 과 VcXsrv의 X Server 연결 

WSL를 사용해본 결과 기능은 제한적이며, WSL2의 경우 Virtual Machine 기능기반으로 사용이 가능하다고 한다. 
하지만, 일반 Virtual Box에서 와 비교하여 제한적이므로 사용시 주의하도록하자. 
WSL2의 경우 Virtual Machine 사용하므로 Virtual Box사용시 문제가 발생한다. 
나의 경우 Virtual Box로 선택해서 사용하지만, 단순한 Linux 사용은 WSL도 괜찮은 것 같다. 
별로 추천은 안함 

  • WSL관련설치 및 WSL2 
관련문서가 변경되어지는 것으로 보아 앞으로도 어떻게 변경될지 모르니, 차라리 MS 문서참고 (WSL가 설치방법은 생략)


  1. 검색->제어판 실행 
  2. 프로그램->Windows 기능 켜기/끄기 



WSL2로 변경이 되어 WSL 설정기능이 없어진것 같으며 확인만 하자



  • WSL Ubuntu 18.04  설치 후 설정
WSL의 Ubuntu 18.04 설치 후 실행하여 update와 upgrade 진행

$ sudo apt-get update
$ sudo apt-get upgrade


  • Package xfce4 별도 설치 

$ sudo apt-get install xfce4 


  • X Server 관련설정

$ cd ~
$ nano .bashrc  //.bahrc 설정 
......
export DISPLAY=:0.0    // [host]:<display>.[screen]

or

$ export DISPLAY=:0.0    // [host]:<display>.[screen]


  • VcXsrv 설치





  • Xlaunch 실행 








우측의 백그라운드로 돌아가는 것을 확인가능하며, X Server 설정을 간단히 확인가능
Host:0.0


  • WSL Ubuntu 18.04  실행 
$ startxfce4
/usr/bin/startxfce4: X server already running on display :0.0
....



  • Window에서 WSL X Window 실행완료 

Window에서 WSL의 X Server를 실행




1.1 SSH의 X Forwarding 기능사용 

Linux에서 SSH의 -X 옵션을 주어 기본적으로 X Forwarding을 가능한데, 이와 같은 기능으로 전체 X Server를 사용하지 않고 창만 사용

  • Xlaunch 실행 


Window의 종류를 선택



  1. Start no client   ( Window에서 X Server 실행되며  Background로 실행됨)
  2. Start a program  (xterm를 이용하여 접속하여  X Server를 접속시도 )




  1. xcalc 실행하며 바로 xcalc 실행가능 
  2. xterm 실행  (SSH로 실행한 후 X11 Forwarding이 되므로 eog or xcalc 로 테스트 가능)




Remote X11 (VcXsrv)
VcXsrv 와 WSL 와 연결
  https://medium.com/@dhanar.santika/installing-wsl-with-gui-using-vcxsrv-6f307e96fac0
  https://seanthegeek.net/234/graphical-linux-applications-bash-ubuntu-windows/

1.2 VS Code WSL 의 Remote X11 

상위를 설치 진행한 후 VcXsrv를 Start no Client 모드로 실행 (XServer 동작)한 후 VS Code Extension에서도 쉽게 Remote X11 동작가능


아래 링크의 2.2 Window WSL 설치부분  ( Remote 관련설치)
  https://ahyuo79.blogspot.com/2020/04/vs-code-extension.html




  https://marketplace.visualstudio.com/items?itemName=spadin.remote-x11

4/30/2020

VS Code Extension

1. VS Code 기본기능사용법  

VS Code의 기능소개 및 각 Tool 기능 
특히 단축키 부분
  https://ahyuo79.blogspot.com/2020/02/visual-studio-code.html

우선 VS Code 기반으로 설치해서 진행하면 Code 관리 및 문서작성도 쉽게 관리가 되어서 편리하다.
요즘 느끼는것은 Eclipse보다 좀 더 편하다고 생각되는데, 다만 VS Code가 node.js 기반이라 그런지 잘 죽는 경향이 있다. 

VS Code는 MS에 개발했지만, Linux에서도 잘돌아가며 나의 경우, 거의 Linux에서 많이 사용한다. 

1.1 VS Code Version Control 

  • 좌측 Source Control 메뉴
좌측메뉴의 Source Control 메뉴 선택후 Git 관련 명령어로 관리하며, SOURCE CONTROL:GIT 에서 아래 명령들을 실행
  1. CHANGES  창 아래에 아직 git add가 되지 않은 부분  (Local Repository)
  2. STAGED CHANGES  git add 후 Local의 Stage에 반영 ( Local Repository)
  3. 우측 상단 "..." 선택 후  "commit all "  ( Local Repository)
  4. 우측 상단  "..."  선택 후 push or sync 진행 (Remote Repository)



VS Code Version Control(Git)
  https://code.visualstudio.com/docs/editor/versioncontrol


1.2 VS Code Task 관리방법 

Task라고 해서 이름이 좀 익숙치 않을 것인데, 사용용도는 내가 만들고자하는 Script를 바로 쉽게 관리하는 기능이라고 생각하면 되겠다. 

  • Terminal -> Run Task 기능 
내가 자주 사용하는 기능으로 Macro라고 생각하면 되겠으며, Task 기반으로 본인이 하고 싶은 것을 만들면 된다. 
예를들면, 어떤 것을 Build 하고 싶다면 관련 Task를 만들어 간단하게 실행이 가능하다. 
Manual을 보면 주로 Build 관련내용이며, 연결하는 방법들이다. 
하지만, 현재 나의 경우는 Linux에서 각 Shell Script 실행용으로 사용중이며, 편하다 
만약 사용하게되면, .vscode 내부에 tasks.json을 별도로 만들어 사용되어지며, 이는 보관을 해야한다. 


  • Task 설정방법 
Terminal -> Configure Task 
직접 .vscode 안에 tasks.json을 만들어서 넣으면 됨 


  • 설정한 Task 실행 
Terminal -> Run Task 

  • tasks.json 의 예제 1 
shell script로 구성으로 Window 와 Linux 같이 호환용 
.vscode/tasks.json // e.g. window and linux
{
  // See https://go.microsoft.com/fwlink/?LinkId=733558
  // for the documentation about the tasks.json format
  "version": "2.0.0",
  "tasks": [
    {
      "label": "Run tests",
      "type": "shell",
      "command": "./scripts/test.sh",        
      "windows": {
        "command": ".\\scripts\\test.cmd"
      },
      "group": "test",
      "presentation": {
        "reveal": "always",
        "panel": "new"
      }
    }
  ]
}  

  • tasks.json 예제2
Shell Script 용도로 Window or Linux에서 아래와 같이 실행하면된다.

.vscode/tasks.json // e.g. 두개의 Task 
{
  // See https://go.microsoft.com/fwlink/?LinkId=733558
  // for the documentation about the tasks.json format
  "version": "2.0.0",
  "tasks": [
    {
      "label": "echo0",
      "type": "shell",
      "command": "echo hello",        
    },
    {
      "label": "echo1",
      "type": "shell",
      "command": "echo hello",        
    }    
  ]
}  

세부설정방법 


1.3 VS Code Extension 

현재 주로 사용중인 VS Code Extension 과 각 기능 소개

  1. Remote Development
  2. C/C++ InteliSense
  3. Setting Sync
  4. Embedded Linux Kernel Dev
  5. bitbake 
  6. udev-rules
  7. TODO Parser
  8. Todo Tree
  9. kconfig


Intellisense의 기능사용법
  https://code.visualstudio.com/docs/editor/intellisense

VSC Essential ( Package 합)
  https://marketplace.visualstudio.com/items?itemName=Gydunhn.vsc-essentials



2. Remote Development 기능 및 설치 

VS Code에서 가장 많이 사용할 기능이며, 기본 사용방법을 알아두도록하자.
SSH를 기반으로 외부 Server에 접속하여 쉽게 개발을 하도록 돕고 있으며,  Remote Server에도 VS Code의 PlugIns 들을 설치진행하여 다양한 기능을 사용가능.

아래 기능은 주로 Window에 VS Code를 설치하고,  Remote Linux Server에 연결하여 직접 개발하는 방식으로 사용한다. 

상위그림 참조
  https://code.visualstudio.com/docs/remote/remote-overview


2.1 Remote Development  설치 

Remote Development 의 기능이 아래의 3 기능을 포함
  https://code.visualstudio.com/docs/remote/linux

  Remote SSH
Window에서 SSH기반으로 Remote Linux Server에 연결하여 쉽게 Source 연결 및 관리
  https://code.visualstudio.com/remote-tutorials/ssh/getting-started

  Remote WSL(Windows Subsystem for Linux)
Window 용 WSL에 쉽게 연결하여 WSL내부의 Source 연결 및 관리 
  https://code.visualstudio.com/remote-tutorials/wsl/enable-wsl

  Remote Container
Docker를 다룬다면 당연히 설치하여 진행 
  https://code.visualstudio.com/remote-tutorials/containers/getting-started





2.2 Window 10 의 WSL 설치 

Window 7에서 Virtual Box 기반으로 Ubuntu 매번 설치를 진행하여 진행하였지만,  Window 10으로 오면서  MS의 WSL기반의 Linux 로 설치진행
그리고, Remote로 WSL를 연결 사실 Remote라기 보다는 Local이 맞겠다. 

  • Window 10 WSL (Window Subsystem for Linux) 설치  
Window 10 Ubuntu 18.04 LTS 설치
  https://wiki.ubuntu.com/WSL
  https://www.microsoft.com/ko-kr/p/ubuntu-1804-lts/9n9tngvndl3q?rtc=1&activetab=pivot:overviewtab

설치후 실행시 문제발생 


PowerShell을 관리자모드 (마우스우측버튼)실행
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux 


상위와 같이 설정하면 PC 재부팅후 실행하면 동작되어짐 

WSL 관련설명 및 설치방법 
  https://docs.microsoft.com/en-us/windows/wsl/about
  https://docs.microsoft.com/ko-kr/windows/wsl/install-win10?redirectedfrom=MSDN

Ubuntu 설치 후 아래와 같이 update 와 upgrade 진행

$ sudo apt update
$ sudo apt upgrade -y





3. Remote Development 사용법

상위에서 설치한 Remote Development를 Window에서 Remote Linux Server or Window 내부의 WSL에 연결하여 소스 및 관리를 해보도록하자.


3.1 VS Code의 Remote Explorer  

Remote Extension을 설치를 했으니, 직접 Remote로 연결하여 Explorer기반으로 소스를 연결및 관리를 진행해보도록 하자. 

  1. 좌측메뉴Remote Explorer 메뉴선택  
  2. Remote Explorer  에서 아래와 같이 선택 
    1. SSH Targets 
    2. WSL Targets 
    3. Containers 





3.2 SSH Target 선택 (Linux Server)

Remote Server에 SSH가 지원이 되면, SSH 기반으로 SCP와 SSH기반으로 Xwindow 도 관련하여 볼수가 있다. 
그러므로 SSH는 기본으로 설정하고 설치를 진행하고 사용해야한다. 

  • 둘 중 하나를 선택 해서 추가 
  1. +  Add New : 처음 설정시  
  2. * Configure : 두번째 설정시 부터 





ssh jhlee@192.168.1.200  -A    //-A Forward 기능 




상위 아이콘 Configuration
or
Remote-SSH: Open Configuration File  





상위 Config를 세부설정확인
  https://code.visualstudio.com/docs/remote/ssh

  • SSH Targets  설정완료 



접속 후 아래 메뉴를 클릭하면 Remote SSH 설정가능 (Remote SSH :  Setting)





기본설정은 완료되었으며, 각 Project 설정은  좌측 Explorer 창에서 새로 시작


3.3  WSL Targets 설정 


Add Distro 를 하면 WSL를 설치가 가능하지만 이미 설치를 진행했기때문에 생략

  • WSL Targets  (Window 10 내부)
Connect To WSL 선택


처음 WSL 접속 할 경우 자동으로 WSL실행하기 때문에 연결 시간이  좀  걸린다.
이 후는 SSH Server 와 거의 유사한 것 같다.

좌측아래의 이 부분을 선택하면 관련설정을 동일하게 볼수 있음



3.4  Containers 설정 

Linux Laptop의 경우 Docker를 이미 많이 사용 중이지만 VS Code의 Container를 이용하여 사용해보기로 했지만, 현재 비추천하며 필요하다면 사용
나중에 괜찮아 질거라고 본다. 

Container 사용방법 및 System Requirement 확인
  https://code.visualstudio.com/docs/remote/containers

  • Sysytem Requirement 확인
Window에서는 Desktop Docker가 필요하며 이를 이용해야한다.

Desktop Docker 설치진행
  https://www.docker.com/products/docker-desktop



New Container 선택


Linux에서 VS Code를 사용할 경우 아래와 같이 쉽게 Docker를 잡을 수 있지만, 차리리 Docker를 설치해서 관리하는게 편한 것 같다.




Docker를 별도로 설치해서 관리하는 게 더 편함



3.5 Remote 구성 후 Open Folder 구성방법

Open Folder 기반으로 프로젝트 구성가능
  1. 첫번째 일 경우,  좌측의 Explorer 메뉴선택 후 Open Folder로  Open Folder
  2. 두번째 일 경우,  이미 존재하므로  File-> Open Folder

각 정보는 Remote Exploer로 자동저장됨



접속 후 좌측메뉴에서 Explorer 선택 후 Open Folder 선택 후 본인이 원하는 Project로 이동
그 기준으로 Project 정보 .vscode가 생성됨





.vscode-server/      // VS Code의 PlugIn Program  과 저장정보 
├── bin
│   └── a5d1cc28bb5da32ec67e86cc50f84c67cc690321
├── data
│   ├── logs
│   ├── Machine
│   ├── machineid
│   └── User
└── extensions
    ├── austin.code-gnu-global-0.2.2
    ├── ms-python.python-2020.5.86806
    ├── ms-vscode.cpptools-0.28.3
    ├── spadin.remote-x11-1.3.4
    └── spadin.remote-x11-ssh-1.3.4

.vscode:  // launch.json 파일


 .vscode 와 .vscode-server  부분에 VS Code 관련부분을 Download하여 설치 진행
만약 문제가 생긴다면, 이 부분을 삭제 후 다시 진행



4. VS Code의 유용한 Extensioon 및 Tools 소개 


VS Code의 Extension을 설치하여 기능을 좀 더 확장하고 이외의 Window Tool or Linux Tool을 사용하여 확장하여 사용해보도록하자. 


4.1 Remote X Window 관련 Tools 소개  

SSH 기반으로 Window에서 X Window로 연결하고 Remote로 보고자 할 경우 사용한다.
구지 SSH가 아니더라도 Remote X window를 제공해준다. 

  • Remote X11
X Sever를 접속할 수 있는 Tool 이지만 불안전한 존재로 아래의 Tool 과 같이 사용한다고 하며, X11 Forwarding은 아래의 Remote X11 (SSH) 필요
  1. VcXsrv  (이것만으로도 xterm을 이용하여 X Forwarding 가능)
  2. Cygwin/X
  3. Xming
  4. X410

  • Remote X11 (SSH)
SSH를 이용하여 X Forwarding 하는 Tool이여 상위 VcXsrv와 거의 동일할 것 같다.
X Shell에서 X Manager를 생각을 하면되겠으며, Linux에서는 SSH에 옵션 -x를 추가하면 쉽게 동작가능하다.
  https://marketplace.visualstudio.com/items?itemName=spadin.remote-x11-ssh

사실현재 Remote X11 과 확장인 Remote X11 (SSH)의 이용은 좀 생각해봐야겠으며, vcXsrv로만으로 충분히 X11 Forwarding이 가능하므로,
이는 좀 더 업그레이드 된 후 다시 사용해보도록 하자.

만약 SSH를 이용한 X11 Forwarding 간단한 TEST 하고싶은면 eog *.png Linux 명령으로 그림을 보면된다.
혹은 간단한 Python을 작성을 하여도 상관없다.


4.2 VS Code의 Extension(소스분석) 

Remote 접속일 경우, Local 이외에도 Remote 부분에도 별도설치를 진행을 해줘야 제대로 동작가능

  • InteliSense
Ecplise의 Index or ctags 처럼 함수와 변수를 쉽게 분석하고, 위치를 찾아주며 다양한 기능을 제공하고 있다.
현재 사용중인 것은 C/C++ 와 Python Package
  https://code.visualstudio.com/docs/editor/intellisense
  https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools

  • Embdedded Linux Kernel Dev
Kernel 의 Device Tree 를 비롯하여, Kernel Config
  https://marketplace.visualstudio.com/items?itemName=microhobby.linuxkerneldev

기타확장
  https://marketplace.visualstudio.com/items?itemName=EugenWiens.bitbake


4.3  VS Code 현재 설정을 Gist로 저장 

요즘 편하게 사용하는 기능인데, VS Code의 환경설정을 Github의 Gist에 저장하는 방법이다.

  • Setting Sync 
회사동료에서 알게된 기능으로 VS Code의 환경설정을 Github의 Gist에 저장이 가능
Github의 계정과 저장할 Gist를 별도로 생성해야함
  https://code.visualstudio.com/docs/editor/settings-sync
  https://marketplace.visualstudio.com/items?itemName=Shan.code-settings-sync


3/22/2020

Visual Studio Code

1. VS Code 

Visual Studio Code 약어로 마이크로 소프트웨어에서 개발했다고 하며, 내부에 Builder 환경이 구축되지 않아 IDE는 아니라고 하는데, IDE로도 문제가 없을 것 같다.
이유는 개발환경을 외부에 별도 설치를 하면, 디버그를 해줄 수 있는 환경을 다 제공을 해주고 있는 시스템이기 때문이다.
이것 때문에 , 다시 Visual Studio를 다시 보게되었는데,  VS Code와 많이 유사하다.

기존에 Window 7/10 Client 에서 원격 Linux Server로 접속하는 방식에서 개발할 경우 기존에는 주로 XShell or Ecplise를 이용하였는데,
회사동료로 부터 VS Code 알게된 후, 앞으로 작업이 편하게 가능한 것 같으며, 다양한 PlugIns들이 많아 점점 확장되어가기 때문에 기대가 너무 크다.


VS Code 지원 OS
  Linux / Window/ Mac
  https://code.visualstudio.com/docs/setup/setup-overview

VS Code Download
  https://code.visualstudio.com/

VS Code 기본사용법
세부설명은 아래의 Doc에서 읽어보면 사용방법을 알수 있다.
  https://code.visualstudio.com/docs/getstarted/introvideos
  https://code.visualstudio.com/docs


1.1 VS Code 의 동작방식 

보통 Window 10에서 원격 Linux Server로 접속하여 개발하며, 불편한 점은 SSH를 접속하여, 소스분석일 것 같다.
기존에는 Ecplise에서 SSH로 연결하여 SFTP와 같이 사용하거나, Samba도 같이 추가사용하여 Index를 구성하고 기타 설정을 하여 편하게 작업을 했지만,
Samba로 했을 경우 File이 깨지는 경우가 간혹이 있어 Samba를 연결하여 사용하는 것을 꺼려 했다.

하지만, VS Code 이런 문제점들을 거의 해결해주는 데 동작방식이 아주 독특하다.

VS Code (Window Client)가 Linux Server에 SSH로 접속 후 SSH Server에 안에 별도의 프로그램을 Linux 에 넣어 같이 통신을 하며 동작을 한다.
그래서 상위의 Ecplise에서 제공해주는 기능을 거의 다 제공을 해주고 있다.
다만 Workspace가 넓어지고 하면 VS Code로 인하여 Linux Server가 성능을 많이 잡아먹는 경우도 발생을 한다.

1.2 VS Code의 기본사용

  • 좌측 메뉴 
  1. Explorer
  2. Search
  3. Source Control (Git)
  4. Run and Debug 
  5. Extension
  6. Remote Explorer ( Extesion에서 Remote Package설치했음)

처음사용을 하면 안에 Customize에서 본인이 사용하고자 하는 설정을 선택해서 사용해보자.
Theme 선택 및 언어 관련 설정을 하자

Themes
  https://medium.com/better-programming/here-are-8-awesome-themes-for-visual-studio-code-1bd173f8b10d



1.3 VS Extension (Remote 부분설치)

Extension에서 현재 필요한 Extension Program들을 설치진행


  • 필요한기능 찾아 설치진행 
Extension에서 Search에서 Remote / Todo 로 검색하여 설치진행


  • Remote 관련부분설치 
Remote Development
- Remote SSH:  SSH Client기능
- Remote Container: Docker를 Install / Config 가 가능하다고 함
- Remote WSL (Windows Subsystem for Linux): 

이외 Remote로 들어가는 것들을 불안해서 중복 좀 설치진행 추후 꼭 필요한 것들만 설치
uDev 문법을 위해 별도 설치 (udev 문법을 자동으로 감지)


필요한 Extension을 Remote Server에도 설치 진행
  1. Yocto 분석을 위해서 Bitbake
  2. Systemd Service 문법을 위해서 설치 
  3. ToDo 관련 부분 설치 ( 다른 TODO기능도 많음)



이 VS Code의 재미있는 부분은 각각의 확장프로그램의 위치가 다 다르며, 유사한 프로그램도 많아 발품을 팔아
본인 원하는 프로그램들을 설치해보고 사용하는 것이 맞을 것 같다.

  1. Server에 설치되어 동작되는 부분
  2. Local에서 동작되는 부분


상단 우측의 ... 부분을 클릭하면 다양한 모드로 볼수 있으며, 매번 소스분석할 때마다, 추천을 해주는 Extension을 이 나와 편하다

Extension Market 관련 설명
  https://code.visualstudio.com/docs/editor/extension-gallery

Remote Extension Manual
  https://code.visualstudio.com/blogs/2019/07/25/remote-ssh
  https://code.visualstudio.com/blogs/2019/05/02/remote-development


https://code.visualstudio.com/docs/getstarted/tips-and-tricks

VS code Tips
  https://code.visualstudio.com/docs/getstarted/tips-and-tricks

  • Extension 관련 유용한 Tips
소스 수정 중 가장 많이 사용되어지는 Tips 

멀티커서 에디팅
    Ctrl+Alt + (방향키)
  https://dayjms.tistory.com/entry/%EB%B9%84%EC%A3%BC%EC%96%BC-%EC%8A%A4%ED%8A%9C%EB%94%94%EC%98%A4-%EC%BD%94%EB%93%9C%EC%9D%98-11%EA%B0%80%EC%A7%80-%EC%9C%A0%EC%9A%A9%ED%95%9C-%EA%B8%B0%EB%8A%A5-1-%EB%A9%80%ED%8B%B0%EC%BB%A4%EC%84%9C-%EC%97%90%EB%94%94%ED%8C%85MultiCursor-Editing


1.4 Remote Project 사용법

상위 Remote 관련 Extension을 설치를 했다면 좌측에 Remote Explorer가 생성이 될 것이다.