Accessing the Pinecil UART with picoprobe · Daniel Mangum
This submit is the second in a RISC-V Bytes subseries on the
PINE64 Pinecil soldering iron and growth board.
Earlier and subsequent posts might be discovered underneath the RISC-V
Bytes class.
Within the most recent Pinecil
post,
we walked by way of find out how to solder the header pins on the Pinecil breakout
board. With the headers
hooked up, we are able to now talk with the Pinecil’s microcontroller by way of a quantity
of protocols. At the moment we’re going to concentrate on accessing the Common
Asynchronous Receiver / Transmitter (UART) {hardware} in an effort to obtain serial
knowledge from the microcontroller, resembling log messages, on a growth machine
(e.g. laptop computer).
Nevertheless, although the breakout board does enable us to entry the UART pins, it’s
probably that your growth machine doesn’t expose its personal UART interface.
As an alternative, most machines are geared up with extra generally used ports for
peripherals, resembling Universal Serial Bus
(USB). In an effort to talk between the
Pinecil microcontroller and the event machine, we’ll want some type of
bridge. Whereas there’s loads of devoted {hardware} that may be bought for a
few {dollars}, resembling this USB to serial
converter, I’ve been leveraging my
small assortment of Raspberry Pi
Pico’s
for duties resembling this since attending Hackaday Supercon
2023 and hacking on the
conference badge, which
included a Pico on the back of the
PCB.
The Pico is the primary Raspberry Pi product to make use of in-house silicon,
incorporating the RP2040, a
microcontroller with twin ARM
Cortex-M0+ processors,
and a extremely versatile programmable input / output
(PIO) system. The “draw back” of
utilizing a normal objective microcontroller, slightly than devoted {hardware}, for our
USB-UART bridge is that we’ll want to jot down or get hold of firmware that performs the
desired performance.
Thankfully, Raspbery Pi explicitly encourages utilizing the Pico for the sort of
use case.
Appendix A of the Pico Getting Started
Guide
introduces using the Pico as a programming and debugging gadget. To assist
this state of affairs, they’ve provided open supply firmware, appropriately named
picoprobe
, that’s constructed on
FreeRTOS and the Pico C/C++
SDK.
Whereas the information primarily describes its use when working with a second Pico,
picoprobe
might be helpful with every other gadget that exposes UART pins or a
Serial Wire Debug
(SWD)
port. Raspberry Pi additionally affords a debug
probe, which is actually
a Pico with picoprobe
pre-programmed on the RP2040, and devoted ports and
connectors for UART and SWD.
picoprobe
is configured utilizing a header file, which is then included in
src/picoprobe_config.h
.
There are two built-in configurations, one for the
Pico
and one for the debug
probe.
We will use the Pico configuration, and since it’s the default, the next
steps can be utilized to construct picoprobe
with none updates.
- Guarantee all submodules are updated.
$ git submodule replace --init
Submodule 'CMSIS_5' (https://github.com/ARM-software/CMSIS_5) registered for path 'CMSIS_5'
Submodule 'freertos' (https://github.com/FreeRTOS/FreeRTOS-Kernel) registered for path 'freertos'
Cloning into '/dwelling/hasheddan/code/github.com/raspberrypi/picoprobe/CMSIS_5'...
Cloning into '/dwelling/hasheddan/code/github.com/raspberrypi/picoprobe/freertos'...
Submodule path 'CMSIS_5': checked out 'a65b7c9a3e6502127fdb80eb288d8cbdf251a6f4'
Submodule path 'freertos': checked out '2dfdfc4ba4d8bb487c8ea6b5428d7d742ce162b8'
- Create a construct listing and enter it.
- Generate construct information with
cmake
, specifying that the Pico SDK must be
fetched as a part of the operation (PICO_SDK_FETCH_FROM_GIT
).
$ PICO_SDK_FETCH_FROM_GIT=on cmake ..
Utilizing PICO_SDK_FETCH_FROM_GIT from atmosphere ('on')
Downloading Raspberry Pi Pico SDK
PICO_SDK_PATH is /dwelling/hasheddan/code/github.com/raspberrypi/picoprobe/construct/_deps/pico_sdk-src
Defaulting PICO_PLATFORM to rp2040 since not specified.
Defaulting PICO platform compiler to pico_arm_gcc since not specified.
-- Defaulting construct kind to 'Launch' since not specified.
PICO compiler is pico_arm_gcc
-- The C compiler identification is GNU 10.3.1
-- The CXX compiler identification is GNU 10.3.1
-- Detecting C compiler ABI information
-- Detecting C compiler ABI information - achieved
-- Examine for working C compiler: /usr/bin/arm-none-eabi-gcc - skipped
-- Detecting C compile options
-- Detecting C compile options - achieved
-- Detecting CXX compiler ABI information
-- Detecting CXX compiler ABI information - achieved
-- Examine for working CXX compiler: /usr/bin/arm-none-eabi-g++ - skipped
-- Detecting CXX compile options
-- Detecting CXX compile options - achieved
-- The ASM compiler identification is GNU
-- Discovered assembler: /usr/bin/arm-none-eabi-gcc
Construct kind is Launch
Defaulting PICO goal board to pico since not specified.
Utilizing board configuration from /dwelling/hasheddan/code/github.com/raspberrypi/picoprobe/construct/_deps/pico_sdk-src/src/boards/embrace/boards/pico.h
-- Discovered Python3: /usr/bin/python3.10 (discovered model "3.10.12") discovered elements: Interpreter
TinyUSB obtainable at /dwelling/hasheddan/code/github.com/raspberrypi/picoprobe/construct/_deps/pico_sdk-src/lib/tinyusb/src/moveable/raspberrypi/rp2040; enabling construct assist for USB.
BTstack obtainable at /dwelling/hasheddan/code/github.com/raspberrypi/picoprobe/construct/_deps/pico_sdk-src/lib/btstack
cyw43-driver obtainable at /dwelling/hasheddan/code/github.com/raspberrypi/picoprobe/construct/_deps/pico_sdk-src/lib/cyw43-driver
Pico W Bluetooth construct assist obtainable.
lwIP obtainable at /dwelling/hasheddan/code/github.com/raspberrypi/picoprobe/construct/_deps/pico_sdk-src/lib/lwip
mbedtls obtainable at /dwelling/hasheddan/code/github.com/raspberrypi/picoprobe/construct/_deps/pico_sdk-src/lib/mbedtls
-- Configuring achieved
-- Producing achieved
-- Construct information have been written to: /dwelling/hasheddan/code/github.com/raspberrypi/picoprobe/construct
- Construct the firmware.
$ make
[ 2%] Constructed goal bs2_default
[ 4%] Constructed goal bs2_default_padded_checksummed_asm
[ 5%] Performing construct step for 'PioasmBuild'
[100%] Constructed goal pioasm
[ 6%] No set up step for 'PioasmBuild'
[ 7%] Accomplished 'PioasmBuild'
[ 11%] Constructed goal PioasmBuild
[ 12%] Constructed goal picoprobe_probe_pio_h
[ 13%] Constructed goal picoprobe_probe_oen_pio_h
[ 14%] Performing construct step for 'ELF2UF2Build'
[100%] Constructed goal elf2uf2
[ 15%] No set up step for 'ELF2UF2Build'
[ 15%] Accomplished 'ELF2UF2Build'
[ 19%] Constructed goal ELF2UF2Build
[ 20%] Constructing C object CMakeFiles/picoprobe.dir/src/led.c.obj
[ 21%] Constructing C object CMakeFiles/picoprobe.dir/src/primary.c.obj
[ 22%] Constructing C object CMakeFiles/picoprobe.dir/src/usb_descriptors.c.obj
[ 23%] Constructing C object CMakeFiles/picoprobe.dir/src/probe.c.obj
[ 24%] Constructing C object CMakeFiles/picoprobe.dir/src/cdc_uart.c.obj
[ 25%] Constructing C object CMakeFiles/picoprobe.dir/src/sw_dp_pio.c.obj
[ 25%] Constructing C object CMakeFiles/picoprobe.dir/src/tusb_edpt_handler.c.obj
[ 26%] Constructing C object CMakeFiles/picoprobe.dir/CMSIS_5/CMSIS/DAP/Firmware/Supply/DAP.c.obj
[ 27%] Constructing C object CMakeFiles/picoprobe.dir/CMSIS_5/CMSIS/DAP/Firmware/Supply/JTAG_DP.c.obj
[ 28%] Constructing C object CMakeFiles/picoprobe.dir/CMSIS_5/CMSIS/DAP/Firmware/Supply/DAP_vendor.c.obj
[ 29%] Constructing C object CMakeFiles/picoprobe.dir/CMSIS_5/CMSIS/DAP/Firmware/Supply/SWO.c.obj
[ 30%] Linking CXX executable picoprobe.elf
[100%] Constructed goal picoprobe
After the construct is full, we must always see various artifacts within the construct
listing.
$ ls
CMakeCache.txt cmake_install.cmake elf2uf2 generated picoprobe.bin picoprobe.elf picoprobe.hex pico-sdk probe_oen.pio.h
CMakeFiles _deps FREERTOS_KERNEL Makefile picoprobe.dis picoprobe.elf.map picoprobe.uf2 pioasm probe.pio.h
There are a number of methods to program the Pico, however the easiest is by holding down
the boot choose (BOOTSEL
) button whilst you join it to your growth
machine. This may trigger the Pico to seem as a USB Mass Storage
Device, which means
you may entry it out of your machine’s filesystem.
$ ls /media/hasheddan/RPI-RP2/
INDEX.HTM INFO_UF2.TXT
Copying the picoprobe.uf2
file into the mounted listing will trigger the
RP2040 to reboot and begin operating the firmware.
$ cp picoprobe.uf2 /media/hasheddan/RPI-RP2/
The Pico ought to now present up as a USB serial gadget.
$ ls /dev/ | grep "ACM|USB"
ttyACM0
We will use minicom
to watch the serial output. Initially we shouldn’t see
any output as picoprobe
is configured to direct its debug info to
UART0
by default. The output we ultimately see over USB serial would be the
bridged output from the Pinecil microcontroller.
$ minicom -D /dev/ttyACM0 -b 2000000
The Pinecil v2 runs on the Bouffalo Lab
BL706 chipset, which
features a 32-bit RISC-V processor primarily based on the SiFive
E24
core.
It’s supported by the open supply IronOS
venture, which was initially developed as different firmware for the
TS100 iron. IronOS is
the default firmware on the Pinecil.
IronOS can be constructed on FreeRTOS, and leverages the bl_mcu_sdk
, which has
developed into the bouffalo_sdk
.
In accordance with the
datasheet,
the BL706 has two built-in UARTs, and IronOS
configures
UART0
to run at 2000000
baud, which is why we provided the -b 2000000
to
minicom
above.
#if outlined(BSP_USING_UART0)
#ifndef UART0_CONFIG
#outline UART0_CONFIG
{ .id = 0, .baudrate = 2000000, .databits = UART_DATA_LEN_8, .stopbits = UART_STOP_ONE, .parity = UART_PAR_NONE, .fifo_threshold = 0, }
#endif
#endif
IronOS has a superb Docker-based build
flow,
which alleviates the necessity to set up your personal RISC-V toolchain. The next
steps can be utilized to construct an English binary for the Pinecil v2.
- Begin the construct container.
$ ./scripts/deploy.sh
====>>>> Firing up & beginning container...
* kind "./scripts/deploy.sh clear" to delete created container (however not cached knowledge)
====>>>> /usr/bin/docker compose -f /dwelling/hasheddan/code/github.com/Ralim/IronOS/./scripts/../Env.yml run --rm builder
/construct/ironos #
- Run construct script.
/construct/ironos # cd supply/ && ./construct.sh -l EN -m Pinecilv2
********************************************
IronOS Firmware
builder for Miniware + Pine64
by Ralim
********************************************
Out there languages : BE BG CS DA DE EL EN ES ET FI FR HR HU IT JA_JP LT NB NL NL_BE PL PT RO RU SK SL SR_CYRL SR_LATN SV TR UK VI YUE_HK ZH_CN ZH_TW
Requested languages : EN
********************************************
Out there fashions : TS100 TS80 TS80P Pinecil MHP30 Pinecilv2 S60 TS101
Requested fashions : Pinecilv2
********************************************
Cleansing earlier builds
[Success]
********************************************
Constructing firmware for Pinecilv2 in EN
...
[Success]
********************************************
-- Firmwares efficiently generated --
Finish...
After the construct completes, you may kind exit
to exit the container. Construct
artifacts must be current in supply/Hexfile/
.
$ ls supply/Hexfile/
Pinecilv2_EN.bin Pinecilv2_EN.dfu Pinecilv2_EN.elf Pinecilv2_EN.elf.map Pinecilv2_EN.hex
The Pinecil might be programmed, together with when connecting by way of the breakout board,
by holding down the button labeled -
whereas plugging the USB cable into your
growth machine. Pine64 affords an in-system programming
(ISP) software for its
Bouffalo Lab units, appropriately named blisp
, which might be downloaded from
the venture’s releases page.
After putting in, the next command can be utilized to flash the IronOS firmware
onto the gadget.
$ sudo ./blisp write -c bl70x --reset Pinecilv2_EN.bin
Sending a handshake...
Handshake profitable!
Getting chip information...
BootROM model 1.0.2.7, ChipID: 0000C41CD8FDD7C4
0b / 59200 (0.00%)
4092b / 59200 (6.91%)
...
59200b / 59200 (100.00%)
Sending a handshake...
Handshake with eflash_loader profitable.
Enter file recognized as a .bin file
Erasing flash to flash boot header
Flashing boot header...
Erasing flash for firmware, this may take a whereas...
Flashing the firmware 188440 bytes @ 0x00002000...
0b / 188440 (0.00%)
2052b / 188440 (1.09%)
...
188440b / 188440 (100.00%)
Checking program...
Program OK!
Resetting the chip.
Flash full!
Connecting the Pinecil to the Pico
Link to heading
The final step to see the serial output emitted by the IronOS firmware operating on
the Pinecil is to attach the UART pins on the breakout board to the Pico
operating picoprobe
. UART1
on the Pico is used for the USB-UART bridge, and
pins 6 and seven correspond to UART1 TX
and UART1 RX
respectively. The RX
pin
on the Pinecil breakout UART header must be related to pin 6 on the Pico,
whereas TX
must be related to pin 7. Lastly, the UART GND
(floor) pin on
the breakout board must be related to a GND
pin, resembling pin 3, on the
Pico. The complete mapping is supplied beneath.
Pinecil Breakout | Pico |
---|---|
UART RX | Pin 6 (UART1 TX) |
UART TX | Pin 7 (UART1 RX) |
UART GND | Pin 3 (GND) |
For a visible illustration of the mapping, view the duvet picture of this submit,
which is a pin-accurate depiction of the wiring.
With the wiring in place, the Pico related to your growth machine, and
minicom
operating, we are able to join the Pinecil to an influence supply by way of the breakout
board. We must always see the next output in our minicom
session with the
Pico.
dynamic reminiscence init success,heap dimension = 48 Kbyte
present flash cfg:
jedec id 0x000000
mid 0xC2
iomode 0x11
clk delay 0x01
clk invert 0x01
learn reg cmd0 0x05
learn reg cmd1 0x00
write reg cmd0 0x01
write reg cmd1 0x00
qe write len 0x02
cread assist 0x00
cread code 0x00
burst wrap cmd 0x77
-------------------
Allow IRQ's
Hiya from Pinecil by way of picoprobe!
Pine64 Pinecilv2 Beginning
BLE Beginning
BLE Beginning...Finished
BLE Beginning promoting
This info is emitted by invoking
bflb_platform_init()
on startup. With the power to construct, program, and monitor the firmware, we are able to
begin to make modifications and check them out on the Pinecil {hardware}. In our subsequent
submit, we’ll start strolling by way of precisely what the Bouffalo Lab SDK and IronOS
are doing, then see how we are able to modify them to incorporate new performance.