3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

初めてのRaspberry Pi Pico ⑧ 新しいディレクトリで開発をする

Last updated at Posted at 2021-02-07

PicoをC言語で開発するには、pico/pico-examplesの中で作業をしています。新たにpico/worksを作り、この中でLチカをします。
###コピーしてくるもの
 /home/pi/pico/pico-examplesから、

  • pico_sdk_import.cmake
  • example_auto_set_url.cmake
  • cmakeフォルダ
  • blinkフォルダ
  • CMakeLists.txt

を/home/pi/pico/worksにコピーします。

mkdir build

 buildフォルダを作ります。
w101.png
 CMakeLists.txtをテキスト・エディタで開き、次のように必要なフォルダの記述だけにします。

cmake_minimum_required(VERSION 3.12)

# Pull in SDK (must be before project)
include(pico_sdk_import.cmake)

project(pico_examples C CXX ASM)
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)

set(PICO_EXAMPLES_PATH ${PROJECT_SOURCE_DIR})

# Initialize the SDK
pico_sdk_init()

include(example_auto_set_url.cmake)
# Add blink example
add_subdirectory(blink)
add_subdirectory(cmake)

###準備OK

 buildフォルダにおります(/home/pi/pico/works/build/)。

pi@raspberrypi:~ $ cd pico
pi@raspberrypi:~/pico $ cd works
pi@raspberrypi:~/pico/works $ cd build
pi@raspberrypi:~/pico/works/build $ ls
pi@raspberrypi:~/pico/works/build $ 

 もちろん空っぽです。このディレクトリで、

cmake ..

 たくさんのファイルが作られます。
w103.png

 新しくできたblinkにおります。

cd blink

 makeします。

make -j4
[  0%] Building ASM object pico-sdk/src/rp2_common/boot_stage2/CMakeFiles/bs2_default.dir/boot2_w25q080.S.obj
[  0%] Creating directories for 'ELF2UF2Build'
[  2%] Linking ASM executable bs2_default.elf
[  2%] Built target bs2_default

。。。

[ 97%] Building C object blink/CMakeFiles/blink.dir/home/pi/pico/pico-sdk/src/rp2_common/pico_stdio_uart/stdio_uart.c.obj
[100%] Linking CXX executable blink.elf
[100%] Built target blink

  ラズパイのデスクトップにPico(PRI-RP2)をマウントするために、BOOTSELボタンを押したままUSBケーブルをつなげました(抜き差し)。
 できたblink.uf2をPRI-RP2ドライブへドロップします。
w104.png

 LEDが点滅し始めます。

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?