embeded/rpi pico2021. 7. 7. 19:07

23페이지에 나오는 내용(2021.07.07 기준)

예전에 stellarisware(ti/cortex-m3) 쓸 때 이런 컨셉이 있었던 것 같은데, 플래시 용량 줄이는 것 외에는 큰 메리트가 있는지

몰랐는데 아키텍쳐의 차이인진 모르겠지만 벤치마크를 보니 꽤나 혹한다.

2.7.2. Floating-point Support
The SDK provides a highly optimized single and double precision floating point implementation. In addition to being fast, many of the functions are actually implemented using support provided in the RP2040 bootrom. This means the interface from your code to the ROM floating point library has very minimal impact on your program size, certainly using dramatically less flash storage than including the standard floating point routines shipped with your compiler. The physical ROM storage on RP2040 has single-cycle access (with a dedicated arbiter on the RP2040 busfabric), and accessing code stored here does not put pressure on the flash cache or take up space in memory, so not only are the routines fast, the rest of your code will run faster due them being resident in ROM. This implementation is used by default as it is the best choice in the majority of cases, however it is also possible to switch to using the regular compiler soft floating point support.

 

bootrom에 있는 함수들을 이용하면 더욱 빠르게 부동소수점 연산이 가능하다는데

나누기 연산의 경우 GCC 라이브러리에 비해서 586% 감소한다고

아래 두개는 먼가 미친듯한 성능 차이가 있어서 끌어 와봄.

Function        ROM/SDK (μs) GCC 9 (μs) Performance Ratio
__aeabi_fdiv 74.7                  437.5          586%
__aeabi_f2lz 63.1                 1240.5        1966%
__aeabi_f2ulz 46.1               1157            2510%

 

27페이지에 나오는 내용인데(2021.07.07 기준)

GCC 라이브러리를 사용하여 계산하는 것과

SDK 라이브러리(RP2040 hardware divider)를 이용하는 것의 속도 차이가 어마어마하다고 한다.

일단 하드웨어 divider를 사용하니 당연한걸지도 모르지만 고정속도라..

[링크 : https://datasheets.raspberrypi.org/pico/raspberry-pi-pico-c-sdk.pdf]

[링크 : https://github.com/raspberrypi/pico-sdk]

[링크 : https://webnautes.tistory.com/1475]

 

+

2021.07.08

라즈베리 파이 pico의 bootrom 소스 리파지터리.

아무튼.. 위의 내용은 어셈블러로 함수를 작성해 놓은 듯.

[링크 : https://github.com/raspberrypi/pico-bootrom/blob/master/bootrom/mufplib-double.S]

[링크 : https://github.com/raspberrypi/pico-bootrom/blob/master/bootrom/mufplib.S]

'embeded > rpi pico' 카테고리의 다른 글

rpi pico usb sound  (0) 2021.11.08
rpi pico pwm channel  (0) 2021.08.02
rpi pico USB 키보드 코드 수정  (0) 2021.07.01
rpi pico, circuitpython, USB HID  (0) 2021.06.28
rpi pico pinout  (0) 2021.06.28
Posted by 구차니
embeded/rpi pico2021. 7. 1. 17:34

GND에 빨간선이 연결되어있고

스위치의 반대편은 GPIO로 연결되어 있는데

GPIO에 pull up이 있어서 인지 스위치를 누르면 ground로 인식이 된다.

(아래 코드에서 4번째 라인 not을 지웠다가 파일 바꾼다고 dog 고생을...)

while True:
    # Check each pin
    for key_pin in key_pin_array:
        if not key_pin.value:  # Is it grounded?
            i = key_pin_array.index(key_pin)
            print("Pin #{} is grounded.".format(i))

            # Turn on the red LED
            led.value = True

            while not key_pin.value:
                pass  # Wait for it to be ungrounded!
            # "Type" the Keycode or string
            key = keys_pressed[i]  # Get the corresponding Keycode or string
            if isinstance(key, str):  # If it's a string...
                keyboard_layout.write(key)  # ...Print the string
            else:  # If it's not a string...
                keyboard.press(control_key, key)  # "Press"...
                keyboard.release_all()  # ..."Release"!

            # Turn off the red LED
            led.value = False

    time.sleep(0.01)

 

아무튼.. 원래 의도는 3V 전원에서 330옴 통해서 전류 제한해서 gpio로 3.3V가 들어가게 하는거였는데

멀 잘못했네.. 멀티메터로는 정상적으로 3.3V 나오던데 ㅠㅠ

 

[링크 : https://tutorial.cytron.io/.../keyboard-emulator-using-raspberry-pi-pico-maker-pi-pico-and-circuitpython/]

[링크 : https://circuitpython.readthedocs.io/projects/hid/en/latest/api.html]

 

 

+

'embeded > rpi pico' 카테고리의 다른 글

rpi pico pwm channel  (0) 2021.08.02
rpi pico c  (0) 2021.07.07
rpi pico, circuitpython, USB HID  (0) 2021.06.28
rpi pico pinout  (0) 2021.06.28
rpi pico USB OTG를 이용한 오실로스코프  (0) 2021.06.27
Posted by 구차니
embeded/rpi pico2021. 6. 28. 16:14

usb hid 라이브러리

[링크 : https://circuitpython.org/libraries]

circuit python uf2 다운로드

[링크 : https://circuitpython.org/board/raspberry_pi_pico/]

 

step 1. circuit python uf2 파일 쓰기

BOOTSEL 누르고 부팅해서 adafruit-circuitpython-raspberry_pi_pico-en_US-6.3.0.uf2 파일을 드라이브에 던진다.

 

step 2. lib 복사

circuitpython이 설치되면 리부팅 되고 아래와 같은 구조의 디렉토리가 보이게 된다.

adafruit-circuitpython-bundle-6.x-mpy-20210625.zip 를 받아 zip 파일내의

adafruit_hid 디렉토리를 lib/adafruit_hid 에 복사한다.

[링크 : https://learn.adafruit.com/welcome-to-circuitpython/circuitpython-libraries]

 

step 3. code.py 작성

아래는 꽂으면 A만 미친듯이 눌러대는 녀석이다. (그러니 현재는 테러용 USB ㅋㅋ)

마치 shift가 눌린 것 처럼 작동하는데 코드는 좀 더 분석이 필요하다.

Import time

import board
import digitalio
import usb_hid
from adafruit_hid.keyboard import Keyboard
from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS
from adafruit_hid.keycode import Keycode

# The Keycode sent for each button, will be paired with a control key
keys_pressed = [Keycode.A, "Hello World!\n"]
control_key = Keycode.SHIFT

# The keyboard object!
time.sleep(1)  # Sleep for a bit to avoid a race condition on some systems
keyboard = Keyboard(usb_hid.devices)
keyboard_layout = KeyboardLayoutUS(keyboard)  # We're in the US :)

while True:
    keyboard_layout.write('A')
    time.sleep(0.01)

 

Hello world 출력하는 키보드(!) 예제 ㅋㅋ

import time

import board
import digitalio
import usb_hid
from adafruit_hid.keyboard import Keyboard
from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS
from adafruit_hid.keycode import Keycode

# The keyboard object!
time.sleep(1)  # Sleep for a bit to avoid a race condition on some systems
keyboard = Keyboard(usb_hid.devices)
keyboard_layout = KeyboardLayoutUS(keyboard)  # We're in the US :)

while True:
    keyboard_layout.write('H')
    keyboard_layout.write('e')
    keyboard_layout.write('l')
    keyboard_layout.write('l')
    keyboard_layout.write('o')
    keyboard_layout.write(' ')
    keyboard_layout.write('w')
    keyboard_layout.write('o')
    keyboard_layout.write('r')
    keyboard_layout.write('l')
    keyboard_layout.write('d')
    time.sleep(1)

[링크 : https://tutorial.cytron.io/.../keyboard-emulator-using-raspberry-pi-pico-maker-pi-pico-and-circuitpython/]

[링크 : https://learn.adafruit.com/getting-started-with-raspberry-pi-pico-circuitpython]

[링크 : https://learn.adafruit.com/circuitpython-essentials/circuitpython-hid-keyboard-and-mouse]

 

'embeded > rpi pico' 카테고리의 다른 글

rpi pico c  (0) 2021.07.07
rpi pico USB 키보드 코드 수정  (0) 2021.07.01
rpi pico pinout  (0) 2021.06.28
rpi pico USB OTG를 이용한 오실로스코프  (0) 2021.06.27
rpi pico usb 저장소  (0) 2021.06.24
Posted by 구차니
embeded/rpi pico2021. 6. 28. 11:51

VBUS(GP40, 우측 상단)에 연결하면 USB Host 모드로만 작동해야 한다는 의미 같은데

아마 USB device 모드라면 USB를 통해 전원을 입력받아야 하기 때문이려나?

Whilst it is possible to connect the Raspberry Pi’s 5V pin to the Raspberry Pi Pico VBUS pin, this is not recommended.
Shorting the 5V rails together will mean that the Micro USB cannot be used. An exception is when using the Raspberry
Pi Pico in USB host mode, in this case 5V must be connected to the VBUS pin.

 

 

GP0이 TX GP1이 RX

 

LED는 GPIO25에 연결되어 있고, TP5로도 연결이 되어있는데

BOOTSEL은 TP6에만 되어있고 GPIO로 연결은 되어 있지 않다.

TP1 – Ground (close coupled ground for differential USB signals)
TP2 – USB DM
TP3 – USB DP
TP4 – GPIO23/SMPS PS pin (do not use)
TP5 – GPIO25/LED (not recommended to be used)
TP6 – BOOTSEL

[링크 : https://www.raspberrypi-spy.co.uk/2021/01/pi-pico-pinout-and-power-pins/#prettyPhoto]

 

[링크 : https://datasheets.raspberrypi.org/pico/getting-started-with-pico.pdf]

Posted by 구차니
embeded/rpi pico2021. 6. 27. 08:23

USB OTG 케이블을 이용하여

간이 오실로스코프를 만들수 있다니 혹하는데 3.3V 까지 밖에 안되니 주의를 기울여야 할지도..

 

[링크 : https://hackaday.com/2021/06/26/raspberry-pi-pico-oscilloscope/]

[링크 : https://github.com/fhdm-dev/scoppy]

 

+ 2024.07.30

[링크 : https://www.instructables.com/Raspberry-Pi-Pico-200Khz-Digital-Oscilloscope/]

[링크 : https://oscilloscope.fhdm.xyz/wiki/Installation-&-Getting-Started]

'embeded > rpi pico' 카테고리의 다른 글

rpi pico, circuitpython, USB HID  (0) 2021.06.28
rpi pico pinout  (0) 2021.06.28
rpi pico usb 저장소  (0) 2021.06.24
rpi pico main.py 올리기 윈도우10, 우분투  (0) 2021.06.24
rpi pico micropython  (0) 2021.06.23
Posted by 구차니
embeded/rpi pico2021. 6. 24. 19:38

usn storage는 bootloader나 펌웨어 올리는 용도라고

micropython 에서 파일 시스템 처럼 제공하는건 그럼 그렇게 보여질 뿐인건가?

 

[링크 : https://forum.micropython.org/viewtopic.php?t=9745]

'embeded > rpi pico' 카테고리의 다른 글

rpi pico pinout  (0) 2021.06.28
rpi pico USB OTG를 이용한 오실로스코프  (0) 2021.06.27
rpi pico main.py 올리기 윈도우10, 우분투  (0) 2021.06.24
rpi pico micropython  (0) 2021.06.23
rpi pico - RP2040  (0) 2021.06.23
Posted by 구차니
embeded/rpi pico2021. 6. 24. 12:35

우분투에서 rpi pico를 연결하면 아래와 같이 뜨고

[   44.398531] usb 2-1.2: new full-speed USB device number 4 using ehci-pci
[   44.508833] usb 2-1.2: New USB device found, idVendor=2e8a, idProduct=0005, bcdDevice= 1.00
[   44.508840] usb 2-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[   44.508845] usb 2-1.2: Product: Board in FS mode
[   44.508848] usb 2-1.2: Manufacturer: MicroPython
[   44.508852] usb 2-1.2: SerialNumber: e6609cb2d3440b2a
[   44.535497] cdc_acm 2-1.2:1.0: ttyACM0: USB ACM device
[   44.536117] usbcore: registered new interface driver cdc_acm
[   44.536119] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters

 

동영상에서 본대로 해보니 되는데 일단은 ttyACM0을 sudo 없이 여는 법을 찾아봐야...(휠 설정을 찾아야 하나)

아무튼 rshell을 통해서 접속하면 /pyboard 라는 경로가 생기는데 이쪽으로 복사해야 된다.

USB 저장장소로 인식되는 건.. 펌웨어만 올리는 용도인가?

$ sudo pip3 install rshell
Collecting rshell
  Downloading rshell-0.0.30.tar.gz (51 kB)
     |████████████████████████████████| 51 kB 514 kB/s 
Collecting pyserial
  Downloading pyserial-3.5-py2.py3-none-any.whl (90 kB)
     |████████████████████████████████| 90 kB 2.8 MB/s 
Collecting pyudev>=0.16
  Downloading pyudev-0.22.0.tar.gz (85 kB)
     |████████████████████████████████| 85 kB 2.3 MB/s 
Requirement already satisfied: six in /usr/lib/python3/dist-packages (from pyudev>=0.16->rshell) (1.14.0)
Building wheels for collected packages: rshell, pyudev
  Building wheel for rshell (setup.py) ... done
  Created wheel for rshell: filename=rshell-0.0.30-py3-none-any.whl size=52770 sha256=69461b75172bb35e222ba9bfd46158ac9463367a21b39f76cc59b930ecf91e60
  Stored in directory: /root/.cache/pip/wheels/e4/ac/b5/2937f0e9ff638dc7ee71168edfa9245ca968438f4a3f7dff9d
  Building wheel for pyudev (setup.py) ... done
  Created wheel for pyudev: filename=pyudev-0.22.0-py3-none-any.whl size=63469 sha256=fad8e733a62171573d784a43062b27df75b2d4117cd364e446804b9210c93b2b
  Stored in directory: /root/.cache/pip/wheels/8b/d1/11/6a9855487e4bba54c63dfb07a09505787d50a5e27f90b0af33
Successfully built rshell pyudev
Installing collected packages: pyserial, pyudev, rshell
Successfully installed pyserial-3.5 pyudev-0.22.0 rshell-0.0.30

$ sudo rshell
Connecting to /dev/ttyACM0 (buffer-size 128)...
Trying to connect to REPL  connected
Retrieving sysname ... rp2
Testing if sys.stdin.buffer exists ... Y
Retrieving root directories ... 
Setting time ... Jun 24, 2021 12:31:53
Evaluating board_name ... pyboard
Retrieving time epoch ... Jan 01, 1970
Welcome to rshell. Use Control-D (or the exit command) to exit rshell.
/home/minimonk> ls -al main.py
   166 Jun 24 12:31 main.py
/home/minimonk> ls -al /pyboard/
/home/minimonk> mount
Unrecognized command: mount
/home/minimonk> cp main.py /pyboard/main.py
Copying '/home/minimonk/main.py' to '/pyboard/main.py' ...
/home/minimonk> exit

$

 

+

thonny 를 윈도우에 깔고 시작!

음.. initial settings에 standard와 raspberry pi가 있는데 일단은.. pico가 라즈베리일려나?

 

Switch to regular mode 버튼을 눌러보면

 

tools - options - general 에 가서 바꿀수 있다는데 라즈베리 파이 모드에서는 안뜨는 메뉴인듯

재시작해보면 달라지긴 한데.. 

 

UI만 달라졌을뿐 큰 차이는 없는 듯?

 

암튼 우측 하단에 Python 이라고 된 걸 클릭해서

MicroPython (Raspberry Pi Pico) 로 바꾸면 설정 끝

 

빈걸 저장 눌러보니 어디다 저장할지 물어보는데 "Raspberry Pi Pico"를 누르면

 

라즈베리 내의 저장된 파일 목록이 뜬다. (오오 신기 -_-)

 

main.py로 하면 리부팅시 작동하는 걸 확인할 수 있다.

일단은 이런 프로그램을 거치지 않으면.. 올릴수도 없는건가?

[링크 : https://thonny.org/]

[링크 : https://www.digikey.be/en/maker/projects/raspberry-pi-pico-and-rp2040-micropython-part-1-blink/...]

[링크 : https://www.electronicshub.org/raspberry-pi-pico-micropython-tutorial/]

'embeded > rpi pico' 카테고리의 다른 글

rpi pico USB OTG를 이용한 오실로스코프  (0) 2021.06.27
rpi pico usb 저장소  (0) 2021.06.24
rpi pico micropython  (0) 2021.06.23
rpi pico - RP2040  (0) 2021.06.23
지름 도착 - rpi pico / esp32-cam  (0) 2021.06.23
Posted by 구차니
embeded/rpi pico2021. 6. 23. 15:16

소스에서 부터 빌드하긴 귀찮으니 빌드된 바이너리를 다운로드!

[링크 : https://micropython.org/download/rp2-pico/rp2-pico-latest.uf2]

 

파일을 넣자마다 스토리지가 사라지면서 자동으로 시리얼 포트가 생성된다.

VID 2E8A / PID 5 가 라즈베리 파이 시리얼 포트 장치 식별자인듯?

 

엔터치니 버전 정보없이 그냥 python 콘솔만 뜬다.

[링크 : https://www.raspberrypi.org/documentation/rp2040/getting-started/#getting-started-with-micropython]

 

USB 메모리로 인식시키려면 BOOTSEL 버튼을 누른채 USB를 연결하면 된다.

스토리지로 연결했는데 RP2 Boot 라는 장치가 뜨네?

 

main.py

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

 

데이터 시트 찾아보니 main.py를 쓰면 된다고 언급되어 있다. (최상위 디렉토리에 넣으면 안되는건가? 왜 안되지? ㅠㅠ)

If you "save a file to the device" and give it the special name main.py, then MicroPython starts running that script as
soon as power is supplied to Raspberry Pi Pico in the future.

 

+

boot.py와 main.py를 읽게 되어있다는데...

[링크 : https://www.mfitzp.com/tutorials/using-micropython-raspberry-pico/]

 

엥? 이 말도 안되는 용량 믿어도 되나!?

 

rshell 이라는 걸 통해서 복사를 해주어야 만 하는건가?

[링크 : https://youtu.be/IMZUZuytt7o?t=195]

'embeded > rpi pico' 카테고리의 다른 글

rpi pico usb 저장소  (0) 2021.06.24
rpi pico main.py 올리기 윈도우10, 우분투  (0) 2021.06.24
rpi pico - RP2040  (0) 2021.06.23
지름 도착 - rpi pico / esp32-cam  (0) 2021.06.23
rpi pico / usb hid?  (1) 2021.06.21
Posted by 구차니
embeded/rpi pico2021. 6. 23. 14:05

Cortex-M0 * 2 @ 133Mhz

264KB SRAM

2MB QSPI (onboard)

USB 1.1 with device and host (USB HID device 만들수 있는게 이거 때문인가?)

SPI * 2

I2C * 2

UART * 3

12bit ADC * 1

PWM 16ch

[링크 : https://www.raspberrypi.org/documentation/rp2040/getting-started/#board-specifications]

 

*.uf2 파일이 생성되고 그 파일을 USB에 넣으면 실행 되는 듯.

[링크 : https://datasheets.raspberrypi.org/pico/getting-started-with-pico.pdf] C 버전

 

python 실행환경을 빌드해서 해당 실행 파일을 USB에 넣어 실행하면 시리얼 포트로 파이썬 콘솔이 뜨는 구조?

[링크 : https://datasheets.raspberrypi.org/pico/raspberry-pi-pico-python-sdk.pdf] python 버전

 

+

cortex-m3 부터가 armv7-m 계열이고 cortex-m0/1 은 ARMv6-M 계열

CoreMark/MHz 에서 M0는 2.33 M3는 3.34 인걸 보면 동 클럭시 60% 정도 성능일 듯.

나쁘게 말하면 130MHz 가 cortex-m3 50Mhz 보다 약간 나은 수준으로 예상된다.

[링크 : http://wooguystudy.blogspot.com/2019/02/arm-cortex-m0m0m3m4m7.html]

 

+

W25Q16JVUXIQ winbond 3V Dual / Quad SPI 16Mbit

자료가 없어서 회로도 뒤져봄

 

RT6150B-33GQW richtek ic buck-boost 0.8A / 1.8~5.5V to 3.3V

[링크 : https://pdf1.alldatasheet.net/datasheet-pdf/view/1283912/WINBOND/W25Q16JVUXIQ.html]

 

RP2040 microcontrollers use 3.3V for GPIO.

https://datasheets.raspberrypi.org/pico/raspberry-pi-pico-faq.pdf

 

'embeded > rpi pico' 카테고리의 다른 글

rpi pico main.py 올리기 윈도우10, 우분투  (0) 2021.06.24
rpi pico micropython  (0) 2021.06.23
지름 도착 - rpi pico / esp32-cam  (0) 2021.06.23
rpi pico / usb hid?  (1) 2021.06.21
rpi pico  (0) 2021.01.31
Posted by 구차니
embeded/rpi pico2021. 6. 23. 12:38

esp32-cam이 1.2만 정도 하던게 할인해서 8천원이라 질렀고

라즈베리 파이 pico는 배송비 생각나서 싸니까 지르고 ㅋㅋ

아무튼 준비 2~3일 걸린다고 해서 금요일이나 받겠거니 했는데 수요일에 도착 똭!

 

rpi pico

micro USB 가 있어서 PC에 꽂으니 인식!

 

INDEX.HTM 은 열어보니 아래 링크로 이동하고

[링크 : https://www.raspberrypi.org/documentation/rp2040/getting-started/]

<html><head><meta http-equiv="refresh" content="0;URL='https://raspberrypi.com/device/RP2?version=E0C912952D54'"/></head><body>Redirecting to <a href='https://raspberrypi.com/device/RP2?version=E0C912952D54'>raspberrypi.com</a></body></html>

 

INFO_UF2.TXT 파일은 열어보니 아래와 같은 내용이 나오는데..

UF2 Bootloader v2.0
Model: Raspberry Pi RP2
Board-ID: RPI-RP2

 

아직 가지고 놀 방법을 몰라서 고심중..

 

ESP32

그냥 보기만 해도 흐믓한데. 도대체 어떻게 펌웨어를 올리지? 시리얼 포트가 있는 것도 아니고

SD 메모리에 바이너리 넣으면 알아서 되는건가? 이것저것 찾는중

 

동영상을 보니 CH340으로 시리얼 연결하고, 아두이노 IDE에서 업로드 하면 되는걸 봐서는 시리얼 포트가 필요하겠군...

[링크 : https://www.youtube.com/watch?v=XfnwhQnh9_4]

  [링크 : https://www.devicemart.co.kr/goods/view?no=12496229]

[링크 : https://github.com/bkeevil/esp32-cam]

'embeded > rpi pico' 카테고리의 다른 글

rpi pico main.py 올리기 윈도우10, 우분투  (0) 2021.06.24
rpi pico micropython  (0) 2021.06.23
rpi pico - RP2040  (0) 2021.06.23
rpi pico / usb hid?  (1) 2021.06.21
rpi pico  (0) 2021.01.31
Posted by 구차니