This is default featured slide 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

*/
레이블이 파이선인 게시물을 표시합니다. 모든 게시물 표시
레이블이 파이선인 게시물을 표시합니다. 모든 게시물 표시

VisualStudio Code에서 esptool.py 사용하기

ESP32 개발시 FW를 한개의 파일로 만들기 위해 esptool.py를 사용하기 위해 해당 component를 설치해야 사용할 수 있다.

설치방법은 cmd를 실행하고 esp idf가 설치된 디렉토리에서 components\esptool_py\esptool 로 이동하여 아래와 같이 설치한다.


c:\esp\esp-idf\components\esptool_py\esptool> python setup.py install
 



수행하면 이후 VSCode상에서도 esptool.py를 사용할 수 있다. 


관련문서 


Python - Bytes, bytearray vs c struct variable

Python에서 bytes, bytearray 를 다룰 때 참고

Format string - Byte order, size, alignment

기본적으로 C 유형은 시스템의 기본 형식 및 바이트 순서로 표시
첫 번째 문자가 이들 중 하나가 아니면 '@'으로 가정
네이티브 바이트 순서는 호스트 시스템에 따라 big-endian 또는 little-endian으로 구분. 예를 들어 Intel x86 및 AMD64 (x86-64)는 little-endian.  Motorola 68000과 PowerPC G5는 big-endian



Format character



Example

>>> from struct import *
>>> pack('hhl', 1, 2, 3)
b'\x01\x00\x02\x00\x03\x00\x00\x00'
>>> unpack('hhl', b'\x00\x01\x00\x02\x00\x00\x00\x03')
(256, 512, 50331648)

>>> pack('<hhl', 1, 2, 3)
b'\x01\x00\x02\x00\x03\x00\x00\x00'
>>> pack('>hhl', 1, 2, 3)
b'\x00\x01\x00\x02\x00\x00\x00\x03'

>>> unpack('<hhl', b'\x00\x01\x00\x02\x00\x00\x00\x03')
(256, 512, 50331648)
>>> unpack('>hhl', b'\x00\x01\x00\x02\x00\x00\x00\x03')
(1, 2, 3)

Windows PC에서 endian을 지정하지 않고 했을 경우 => 네이티브로 판단하여 intel계열의 little-endian 으로 출력

>>> pack('hhl', 1, 2, 3) # Native'@'를 지정한 것으로 처리
b'\x01\x00\x02\x00\x03\x00\x00\x00'
>>> unpack('hhl', b'\x00\x01\x00\x02\x00\x00\x00\x03')
(256, 512, 50331648)


Little-endian vs Big-endian

>>> pack('<hhl', 1, 2, 3)           # little-endian
b'\x01\x00\x02\x00\x03\x00\x00\x00'
>>> pack('>hhl', 1, 2, 3)           # big-endian
b'\x00\x01\x00\x02\x00\x00\x00\x03'

>>> unpack('<hhl', b'\x00\x01\x00\x02\x00\x00\x00\x03')     # little-endian
(256, 512, 50331648)
>>> unpack('>hhl', b'\x00\x01\x00\x02\x00\x00\x00\x03')     # big-endian
(1, 2, 3)