<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.pine64.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Ahelwer</id>
	<title>PINE64 - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.pine64.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Ahelwer"/>
	<link rel="alternate" type="text/html" href="https://wiki.pine64.org/wiki/Special:Contributions/Ahelwer"/>
	<updated>2026-04-26T08:08:13Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.37.1</generator>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PineNote_Development/Flashing&amp;diff=21028</id>
		<title>PineNote Development/Flashing</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PineNote_Development/Flashing&amp;diff=21028"/>
		<updated>2023-10-24T15:21:38Z</updated>

		<summary type="html">&lt;p&gt;Ahelwer: Expanded page overview&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Under construction}}&lt;br /&gt;
&lt;br /&gt;
{{Info|These instructions are directed towards experienced developers only!}}&lt;br /&gt;
&lt;br /&gt;
This page contains information on flashing software to the [[PineNote]].&lt;br /&gt;
The general process is as follows:&lt;br /&gt;
# Take a backup of all important data on the PineNote&lt;br /&gt;
# Modify the partition layout to make space for your desired Linux distribution&lt;br /&gt;
# Instantiate a root filesystem (rootfs) in the new partition space&lt;br /&gt;
# Install your Linux distribution to the boot partition&lt;br /&gt;
# Modify the boot process to boot the Linux distribution by default&lt;br /&gt;
&lt;br /&gt;
There are multiple possible methods of executing these steps, and this page attempts to document all of them.&lt;br /&gt;
You can use:&lt;br /&gt;
# &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt;, a command line utility for modifying [https://en.wikipedia.org/wiki/Rockchip Rockchip] devices over USB&lt;br /&gt;
# The [[PineNote_Development/UART|UART]] shell&lt;br /&gt;
# [https://en.wikipedia.org/wiki/Android_Debug_Bridge Android Debug Bridge]&lt;br /&gt;
# [https://en.wikipedia.org/wiki/Fastboot Fastboot]&lt;br /&gt;
&lt;br /&gt;
== Getting &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
Most flashing operations on the PineNote are done through &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt;, a command line utility built on libusb.&lt;br /&gt;
PINE64 maintains its own fork [https://gitlab.com/pine64-org/quartz-bsp/rkdeveloptool here] that you will need to get.&lt;br /&gt;
The repo's README contains a list of dependencies (libusb 1.0) and instructions for building the tool.&lt;br /&gt;
&lt;br /&gt;
Installing (not just building) &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; will configure PAM to elevate privileges where necessary on your system; you can configure this manually as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo cp 99-rk-rockusb.rules /etc/udev/rules.d/&lt;br /&gt;
sudo udevadm control --reload&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Entering Maskrom/Rockusb mode ==&lt;br /&gt;
&lt;br /&gt;
Interfacing with the PineNote over USB using &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; requires first booting the PineNote into [http://opensource.rock-chips.com/wiki_Rockusb an alternative operating mode] called Maskrom or Rockusb mode.&lt;br /&gt;
&lt;br /&gt;
=== Possible methods ===&lt;br /&gt;
&lt;br /&gt;
There are three possible methods of entering Maskrom/Rockusb mode:&lt;br /&gt;
&lt;br /&gt;
==== Hardware magnet switch ====&lt;br /&gt;
&lt;br /&gt;
# Connect the PineNote to your computer via USB and boot the PineNote into Android&lt;br /&gt;
# Locate &amp;amp; identify the small circular marking on the back of the PineNote, in the top right quadrant; have the PineNote pen close at hand, or any other small magnet&lt;br /&gt;
# Hold the PineNote power button to bring up the reboot/shutdown menu; select reboot, then place the PineNote face down with the &amp;quot;eraser&amp;quot; end of the pen (or your magnet) resting on the small circular marking&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Download mode.jpeg|Pen method&lt;br /&gt;
PineNoteMagnetOnBack.jpg|Magnet method&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== U-Boot terminal ====&lt;br /&gt;
This method requires a [[PineNote_Development/UART#USB_passthrough|UART dongle with passthrough]] allowing simultaneous UART &amp;amp; USB connections.&lt;br /&gt;
It is nice because you can easily switch back &amp;amp; forth between U-Boot and Rockusb without having to physically manipulate the PineNote or its connectors; this is especially helpful when trying to develop U-Boot.&lt;br /&gt;
&lt;br /&gt;
# Connect to the PineNote via UART and USB simultaneously&lt;br /&gt;
# Interrupt the U-Boot startup using &amp;lt;code&amp;gt;ctrl+c&amp;lt;/code&amp;gt; sent over UART&lt;br /&gt;
# In the U-Boot terminal over UART, run &amp;lt;code&amp;gt;rockusb 0 mmc 0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The UART terminal should print &amp;lt;code&amp;gt;RKUSB&amp;lt;/code&amp;gt; then a spinner will appear.&lt;br /&gt;
You can exit back to the U-Boot terminal by sending &amp;lt;code&amp;gt;ctrl+c&amp;lt;/code&amp;gt; again.&lt;br /&gt;
&lt;br /&gt;
==== Shorting test points ====&lt;br /&gt;
&lt;br /&gt;
If the bootloader is broken/corrupted, you cannot get to Maskrom without opening up the device (it can be opened using spudger and a bit of patience).&lt;br /&gt;
&lt;br /&gt;
Once inside, short TP1301 (GND) and TP1302 (eMMC_D0/FLASH_D0) with a small tweezers, this is how it looks on board view (credit to Caleb):&lt;br /&gt;
&lt;br /&gt;
[[File:PineNote_Maskrom_TP.png|500px]]&lt;br /&gt;
&lt;br /&gt;
=== Success ===&lt;br /&gt;
&lt;br /&gt;
No matter what approach you take, you can tell whether you succeeded by running the &amp;lt;code&amp;gt;lsusb&amp;lt;/code&amp;gt; command on your computer:&lt;br /&gt;
* If you find the entry &amp;lt;code&amp;gt;2207:0018 Fuzhou Rockchip Electronics Company rk3566_eink&amp;lt;/code&amp;gt; in the list, the process did not succeed; reboot and retry&lt;br /&gt;
* The entry &amp;lt;code&amp;gt;2207:350a Fuzhou Rockchip Electronics Company&amp;lt;/code&amp;gt; will occur if you detach then reattach the USB-C cable while the PineNote is in Maskrom/Rockusb mode; &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; won't work and you will have to do a hard reboot (hold down power button for 30 seconds to shutdown)&lt;br /&gt;
* If you find the entry &amp;lt;code&amp;gt;2207:350a Fuzhou Rockchip Electronics Company USB download gadget&amp;lt;/code&amp;gt; then the process succeeded&lt;br /&gt;
&lt;br /&gt;
You can also look at the output of the &amp;lt;code&amp;gt;rkdeveloptool list&amp;lt;/code&amp;gt; command:&lt;br /&gt;
* If this prints out &amp;lt;code&amp;gt;No devices in rockusb mode found&amp;lt;/code&amp;gt; the process did not succeed; reboot and retry&lt;br /&gt;
* If this prints out &amp;lt;code&amp;gt;DevNo=1 Vid=0x2207,Pid=0x350a,LocationID=305 Maskrom&amp;lt;/code&amp;gt; then you probably detached/reattached the USB-C cable while in Maskrom/Rockusb mode and &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; won't work; perform a hard reboot to fix&lt;br /&gt;
* If this prints out &amp;lt;code&amp;gt;DevNo=1 Vid=0x2207,Pid=0x350a,LocationID=303 Loader&amp;lt;/code&amp;gt; then the process succeeded&lt;br /&gt;
&lt;br /&gt;
=== Exiting ===&lt;br /&gt;
&lt;br /&gt;
You can boot the PineNote back into its normal mode of operation by powercycling the PineNote with its hardware power switch, or running the &amp;lt;code&amp;gt;rkdeveloptool reboot&amp;lt;/code&amp;gt; command.&lt;br /&gt;
If you used the magnetic switch method be sure to remove the pen/magnet before rebooting.&lt;br /&gt;
&lt;br /&gt;
== Backup ==&lt;br /&gt;
&lt;br /&gt;
A backup of the content of the internal eMMC before anything gets messed up is '''mandatory'''.&lt;br /&gt;
&lt;br /&gt;
Especially the ''waveform'' partition contains data '''unique''' to your PineNote and is a prime candidate for backup.&lt;br /&gt;
&lt;br /&gt;
Other partitions like U-Boot (need for any operation of the device) or the un-partitioned space at the beginning containing the GPT partition table (and presumably the VCOM setting for the e-ink display and maybe device mac addresses) contain data you may also wish to backup.&lt;br /&gt;
&lt;br /&gt;
Depending of your personal level of data hoarder you may want to backup more than this or even just everything (the large ''userdata'' partition is supposed to be able to be repopulated as empty space by Android)&lt;br /&gt;
&lt;br /&gt;
In any case it is easier to restore/extract data from a backup than not having one if you need one.&lt;br /&gt;
&lt;br /&gt;
This process was developed by Dorian Rudolph, originally described [https://github.com/DorianRudolph/pinenotes here].&lt;br /&gt;
&lt;br /&gt;
=== List partitions ===&lt;br /&gt;
&lt;br /&gt;
First, run &amp;lt;code&amp;gt;rkdeveloptool list-partitions&amp;lt;/code&amp;gt; to print out your PineNote's partitions to get an idea of what you're dealing with.&lt;br /&gt;
The stock PineNote has a fairly standard [https://source.android.com/docs/core/architecture/partitions Android partition setup]:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Number !! Name !! Size !! Purpose&lt;br /&gt;
|-&lt;br /&gt;
| 0 || uboot || 4 MB || The [https://en.wikipedia.org/wiki/Das_U-Boot U-Boot] embedded systems bootloader&lt;br /&gt;
|-&lt;br /&gt;
| 1 || trust || 4 MB || Secrets that can be encrypted with a key stored in the [https://en.wikipedia.org/wiki/Trusted_Platform_Module TPM]&lt;br /&gt;
|-&lt;br /&gt;
| 2 || waveform || 2 MB || Important files controlling the e-ink screen's state changes&lt;br /&gt;
|-&lt;br /&gt;
| 3 || misc || 4 MB || Data used by the recovery partition&lt;br /&gt;
|-&lt;br /&gt;
| 4 || dtbo || 4 MB || [https://en.wikipedia.org/wiki/Devicetree Device Tree Blob for Overlay], files describing the PineNote's hardware configuration&lt;br /&gt;
|-&lt;br /&gt;
| 5 || vbmeta || 1 MB || Data required for [https://android.googlesource.com/platform/external/avb/+/master/README.md verified boot]&lt;br /&gt;
|-&lt;br /&gt;
| 6 || boot || 42 MB || The kernel image &amp;amp; ramdisk to boot&lt;br /&gt;
|-&lt;br /&gt;
| 7 || security || 4 MB || &lt;br /&gt;
|-&lt;br /&gt;
| 8 || recovery || 134 MB || The recovery image, booted during Android updates&lt;br /&gt;
|-&lt;br /&gt;
| 9 || backup || 400 MB || &lt;br /&gt;
|-&lt;br /&gt;
| 10 || cache || 1 GB || Stores temporary data; can be used to install a minimal Linux distribution!&lt;br /&gt;
|-&lt;br /&gt;
| 11 || metadata || 17 MB || Used for disk encryption&lt;br /&gt;
|-&lt;br /&gt;
| 12 || super || 3.25 GB || Android itself is installed here&lt;br /&gt;
|-&lt;br /&gt;
| 13 || logo || 17 MB || Splash image displayed during boot&lt;br /&gt;
|-&lt;br /&gt;
| 14 || device || 67 MB || &lt;br /&gt;
|-&lt;br /&gt;
| 15 || userdata || 119 GB || The big one; user-installed Android apps and files live here&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Patch U-Boot ===&lt;br /&gt;
&lt;br /&gt;
Before we can back up our partitions, we have a problem to solve.&lt;br /&gt;
The version of U-Boot installed on the stock PineNote contains a bug where it can't dump partitions beyond 32 MB (above that limit all bytes in the dump are just &amp;lt;code&amp;gt;0xCC&amp;lt;/code&amp;gt;), meaning the PineNote must be flashed with a fixed version of U-Boot before it is possible to take a backup of the larger partitions.&lt;br /&gt;
It is possible to extract and modify the U-Boot image from your PineNote if you're interested in some light reverse-engineering (following Dorian's notes), or you can simply download a patched U-Boot image directly [https://github.com/DorianRudolph/pinenotes/blob/main/static/uboot_patched.img here].&lt;br /&gt;
&lt;br /&gt;
Once you've acquired a patched U-Boot image, run:&lt;br /&gt;
# &amp;lt;code&amp;gt;rkdeveloptool read-partition uboot uboot_backup.img&amp;lt;/code&amp;gt;&lt;br /&gt;
# &amp;lt;code&amp;gt;rkdeveloptool write-partition uboot uboot_patched.img&amp;lt;/code&amp;gt;&lt;br /&gt;
# &amp;lt;code&amp;gt;rkdeveloptool reboot&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Taking the backup ===&lt;br /&gt;
&lt;br /&gt;
With U-Boot patched, you can back up every partition except for super and userdata; run:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;rkdeveloptool read-partition partition_name partition_name_backup.img&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Unfortunately the super and userdata partitions run into a second limitation preventing dumping partitions larger than 2 GB, this time originating in &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; itself.&lt;br /&gt;
This means if you have a large number of documents in the Android userdata partition they might not all make it into the backup.&lt;br /&gt;
If you don't have many documents (or don't care about losing them) this should not be a problem.&lt;br /&gt;
If you do have a lot of documents, workarounds include:&lt;br /&gt;
* A possible patch written by Thomas exists [https://github.com/tpwrules/nixos-pinenote/blob/96d2c9158edb9da59afcb952cc864fada18382f9/nix/rkdeveloptool/0001-fix-large-dumps.patch here] but has not yet been upstreamed; consider investigating how to get the patch tested &amp;amp; upstreamed, or just apply it to your own local copy of &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt;&lt;br /&gt;
* Use [https://github.com/talpadk/pinenote-backup this] Python script written by Visti Andresen (talpadk) to automatically backup your entire partition by splitting reads into 2 GB chunks&lt;br /&gt;
&lt;br /&gt;
See [https://github.com/m-weigand/pinenote-debian-recipes/releases/tag/v0.1 instructions on this artifact]. It will instruct you on extracting the rootfs into an empty ext4 partition. This can be done from Linux or Android. Further instructions on building your own rootfs [https://github.com/m-weigand/pinenote-debian-recipes can be found here].&lt;br /&gt;
&lt;br /&gt;
=== Using a user installed Linux ===&lt;br /&gt;
A Linux installed to the cache partition should be able to easily backup everything over WiFi or to a USB stick/disk using ''dd''.&lt;br /&gt;
&lt;br /&gt;
However the user would need to backup the cache partition themself (if they want that).&lt;br /&gt;
&lt;br /&gt;
And more importantly they would only be getting the backup ''after'' they started playing with the content of the eMMC.&lt;br /&gt;
&lt;br /&gt;
== Side-by-side setup ==&lt;br /&gt;
&lt;br /&gt;
It is possible to set up a partition for mainline development without disturbing the factory Android installation. This allows updating a mainline kernel, DTB, and initramfs over Wi-Fi until WiFi or USB OTG is working in mainline Linux.&lt;br /&gt;
&lt;br /&gt;
=== Without Repartitioning ===&lt;br /&gt;
&lt;br /&gt;
The recommended partition for this is &amp;lt;tt&amp;gt;mmcblk0p11&amp;lt;/tt&amp;gt; aka &amp;lt;tt&amp;gt;/cache&amp;lt;/tt&amp;gt;. It is large and already formatted as &amp;lt;tt&amp;gt;ext4&amp;lt;/tt&amp;gt;, so it is readable from U-Boot. Here are some general steps:&lt;br /&gt;
&lt;br /&gt;
# From the UART or adb shell, set up your chroot in &amp;lt;tt&amp;gt;/cache&amp;lt;/tt&amp;gt;. I used the Alpine Linux rootfs tarball.&lt;br /&gt;
# Copy in your kernel and DTB, using for example &amp;lt;tt&amp;gt;scp&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;wget&amp;lt;/tt&amp;gt; inside the chroot.&lt;br /&gt;
# Finally, create and boot an &amp;lt;code&amp;gt;extlinux.conf&amp;lt;/code&amp;gt; as described below.&lt;br /&gt;
&lt;br /&gt;
=== With Repartitioning ===&lt;br /&gt;
&lt;br /&gt;
It is possible to shrink the &amp;lt;tt&amp;gt;userdata&amp;lt;/tt&amp;gt; partition, and create a new partition at the end for use with mainline Linux. This provides much more space than &amp;lt;tt&amp;gt;cache&amp;lt;/tt&amp;gt;. However, because &amp;lt;tt&amp;gt;userdata&amp;lt;/tt&amp;gt; is formatted with &amp;lt;tt&amp;gt;f2fs&amp;lt;/tt&amp;gt;, and that filesystem cannot be shrunk, resizing the partition requires wiping &amp;lt;tt&amp;gt;userdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
# Back up any necessary files from userdata&lt;br /&gt;
# Boot to a mainline kernel from &amp;lt;tt&amp;gt;mmcblk0p11&amp;lt;/tt&amp;gt;, either using that partition as rootfs (see above), or using an initramfs with repartitioning tools&lt;br /&gt;
# Modify the partition table with your favorite tool, e.g. &amp;lt;tt&amp;gt;fdisk&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gdisk&amp;lt;/tt&amp;gt;, or &amp;lt;tt&amp;gt;parted&amp;lt;/tt&amp;gt;&lt;br /&gt;
# Reboot into &amp;lt;tt&amp;gt;fastboot&amp;lt;/tt&amp;gt; and wipe &amp;lt;tt&amp;gt;userdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# Reboot into Android, where you can now chroot in and install your favorite distribution to the new partition.&lt;br /&gt;
&lt;br /&gt;
== Using rkdeveloptool ==&lt;br /&gt;
&lt;br /&gt;
=== Building Downstream U-Boot ===&lt;br /&gt;
&lt;br /&gt;
While in maskrom mode, we need to have a u-boot to download onto the device for any of the other commands to work. To build you'll also need to install device-tree-compiler.&lt;br /&gt;
&lt;br /&gt;
You also need to install Python and pyelftools.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Note that rkbin is a &amp;amp;gt;5GB download!&amp;lt;/b&amp;gt; This will take some time to clone and process the deltas.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone -b quartz64 https://gitlab.com/pgwipeout/u-boot-rockchip.git&lt;br /&gt;
git clone -b rkbin https://github.com/JeffyCN/rockchip_mirrors.git rkbin&lt;br /&gt;
cd u-boot-rockchip&lt;br /&gt;
# If using Arch Linux, export CROSS_COMPILE=aarch64-linux-gnu-&lt;br /&gt;
export CROSS_COMPILE=aarch64-none-linux-gnu-&lt;br /&gt;
make rk3566-quartz64_defconfig&lt;br /&gt;
./make.sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
In the current version (current as of 2022-01-02), there might have to be made a change to one line to get a clean compilation:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
diff --git a/lib/avb/libavb/avb_slot_verify.c b/lib/avb/libavb/avb_slot_verify.c&lt;br /&gt;
index 123701fc3b..64a1ce6450 100644&lt;br /&gt;
--- a/lib/avb/libavb/avb_slot_verify.c&lt;br /&gt;
+++ b/lib/avb/libavb/avb_slot_verify.c&lt;br /&gt;
@@ -296,7 +296,7 @@ static AvbSlotVerifyResult load_and_verify_hash_partition(&lt;br /&gt;
   bool image_preloaded = false;&lt;br /&gt;
   uint8_t* digest;&lt;br /&gt;
   size_t digest_len;&lt;br /&gt;
-  const char* found;&lt;br /&gt;
+  const char* found = NULL;&lt;br /&gt;
   uint64_t image_size;&lt;br /&gt;
   size_t expected_digest_len = 0;&lt;br /&gt;
   uint8_t expected_digest_buf[AVB_SHA512_DIGEST_SIZE];&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For systems where the global python executable points to python2, compilation fails with an error related to pyelftools not being installed (even if it is). To fix this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
diff --git a/make.sh b/make.sh&lt;br /&gt;
index 2bba05b4e4..cfe5b0afd5 100755&lt;br /&gt;
--- a/make.sh&lt;br /&gt;
+++ b/make.sh&lt;br /&gt;
@@ -758,7 +758,7 @@ function pack_fit_image()&lt;br /&gt;
        fi&lt;br /&gt;
 &lt;br /&gt;
        if [ &amp;quot;${ARM64_TRUSTZONE}&amp;quot; == &amp;quot;y&amp;quot; ]; then&lt;br /&gt;
-               if ! python -c &amp;quot;import elftools&amp;quot; ; then&lt;br /&gt;
+               if ! python3 -c &amp;quot;import elftools&amp;quot; ; then&lt;br /&gt;
                        echo &amp;quot;ERROR: No python 'pyelftools', please: pip install pyelftools&amp;quot;&lt;br /&gt;
                        exit 1&lt;br /&gt;
                fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can now download u-boot onto the PineNote:&lt;br /&gt;
&lt;br /&gt;
 ./rkdeveloptool boot ../u-boot-rockchip/rk356x_spl_loader_v1.08.111.bin&lt;br /&gt;
&lt;br /&gt;
This should output &amp;quot;''Downloading bootloader succeeded''&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
We can now verify that this worked using e.g. the &amp;quot;read flash info&amp;quot; command:&lt;br /&gt;
&lt;br /&gt;
 ./rkdeveloptool read-flash-info&lt;br /&gt;
&lt;br /&gt;
{{Note|'''TODO:''' Section needs to be finished}}&lt;br /&gt;
&lt;br /&gt;
=== Creating a mainline boot image ===&lt;br /&gt;
&lt;br /&gt;
You can create a filesystem image that replaces the Android boot or recovery partition by doing roughly the following:&lt;br /&gt;
&lt;br /&gt;
# Erase boot and dtbo with rkdeveloptool or fastboot (back them up first!!!)&lt;br /&gt;
# Create an ext2 partition image and mount it (fallocate, mkfs.ext2)&lt;br /&gt;
# Build your mainline kernel&lt;br /&gt;
# Copy the kernel, dtb and an initramfs to the root of the mounted image (use any old postmarketOS initramfs)&lt;br /&gt;
# Create a file in the root of the mounted image called &amp;lt;code&amp;gt;extlinux.conf&amp;lt;/code&amp;gt; as described below&lt;br /&gt;
# Unmount the image and then use rkdeveloptool to flash it to the &amp;quot;recovery&amp;quot; partition on the pinenote (it's about the right size until we get around to replacing the partition layout).&lt;br /&gt;
&lt;br /&gt;
== Using fastboot ==&lt;br /&gt;
&lt;br /&gt;
Follow the steps for [[PineNote Development/Flashing#Creating a mainline boot image|Creating a mainline boot image]], but instead of flashing it with ''rkdeveloptool'', use ''fastboot''. You can enter fastboot in either of two ways:&lt;br /&gt;
&lt;br /&gt;
* Use &amp;quot;reboot bootloader&amp;quot; from adb or a UART console or&lt;br /&gt;
* get a U-Boot prompt and run &amp;lt;code&amp;gt;fastboot usb 0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:PineNote]]&lt;/div&gt;</summary>
		<author><name>Ahelwer</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PineNote_Development/Flashing&amp;diff=20999</id>
		<title>PineNote Development/Flashing</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PineNote_Development/Flashing&amp;diff=20999"/>
		<updated>2023-10-23T17:42:05Z</updated>

		<summary type="html">&lt;p&gt;Ahelwer: /* Taking the backup */ can backup all partitions except for super and userdata&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Under construction}}&lt;br /&gt;
&lt;br /&gt;
{{Info|These instructions are directed towards experienced developers only!}}&lt;br /&gt;
&lt;br /&gt;
This page contains information on flashing software to the [[PineNote]].&lt;br /&gt;
&lt;br /&gt;
Currently, software can be flashed using rkdeveloptool or from the factory Android installation (UART shell, adb, or fastboot).&lt;br /&gt;
&lt;br /&gt;
== Getting &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
Most flashing operations on the PineNote are done through &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt;, a command line utility built on libusb.&lt;br /&gt;
PINE64 maintains its own fork [https://gitlab.com/pine64-org/quartz-bsp/rkdeveloptool here] that you will need to get.&lt;br /&gt;
The repo's README contains a list of dependencies (libusb 1.0) and instructions for building the tool.&lt;br /&gt;
&lt;br /&gt;
Installing (not just building) &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; will configure PAM to elevate privileges where necessary on your system; you can configure this manually as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo cp 99-rk-rockusb.rules /etc/udev/rules.d/&lt;br /&gt;
sudo udevadm control --reload&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Entering Maskrom/Rockusb mode ==&lt;br /&gt;
&lt;br /&gt;
Interfacing with the PineNote over USB using &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; requires first booting the PineNote into [http://opensource.rock-chips.com/wiki_Rockusb an alternative operating mode] called Maskrom or Rockusb mode.&lt;br /&gt;
&lt;br /&gt;
=== Possible methods ===&lt;br /&gt;
&lt;br /&gt;
There are three possible methods of entering Maskrom/Rockusb mode:&lt;br /&gt;
&lt;br /&gt;
==== Hardware magnet switch ====&lt;br /&gt;
&lt;br /&gt;
# Connect the PineNote to your computer via USB and boot the PineNote into Android&lt;br /&gt;
# Locate &amp;amp; identify the small circular marking on the back of the PineNote, in the top right quadrant; have the PineNote pen close at hand, or any other small magnet&lt;br /&gt;
# Hold the PineNote power button to bring up the reboot/shutdown menu; select reboot, then place the PineNote face down with the &amp;quot;eraser&amp;quot; end of the pen (or your magnet) resting on the small circular marking&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Download mode.jpeg|Pen method&lt;br /&gt;
PineNoteMagnetOnBack.jpg|Magnet method&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== U-Boot terminal ====&lt;br /&gt;
This method requires a [[PineNote_Development/UART#USB_passthrough|UART dongle with passthrough]] allowing simultaneous UART &amp;amp; USB connections.&lt;br /&gt;
It is nice because you can easily switch back &amp;amp; forth between U-Boot and Rockusb without having to physically manipulate the PineNote or its connectors; this is especially helpful when trying to develop U-Boot.&lt;br /&gt;
&lt;br /&gt;
# Connect to the PineNote via UART and USB simultaneously&lt;br /&gt;
# Interrupt the U-Boot startup using &amp;lt;code&amp;gt;ctrl+c&amp;lt;/code&amp;gt; sent over UART&lt;br /&gt;
# In the U-Boot terminal over UART, run &amp;lt;code&amp;gt;rockusb 0 mmc 0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The UART terminal should print &amp;lt;code&amp;gt;RKUSB&amp;lt;/code&amp;gt; then a spinner will appear.&lt;br /&gt;
You can exit back to the U-Boot terminal by sending &amp;lt;code&amp;gt;ctrl+c&amp;lt;/code&amp;gt; again.&lt;br /&gt;
&lt;br /&gt;
==== Shorting test points ====&lt;br /&gt;
&lt;br /&gt;
If the bootloader is broken/corrupted, you cannot get to Maskrom without opening up the device (it can be opened using spudger and a bit of patience).&lt;br /&gt;
&lt;br /&gt;
Once inside, short TP1301 (GND) and TP1302 (eMMC_D0/FLASH_D0) with a small tweezers, this is how it looks on board view (credit to Caleb):&lt;br /&gt;
&lt;br /&gt;
[[File:PineNote_Maskrom_TP.png|500px]]&lt;br /&gt;
&lt;br /&gt;
=== Success ===&lt;br /&gt;
&lt;br /&gt;
No matter what approach you take, you can tell whether you succeeded by running the &amp;lt;code&amp;gt;lsusb&amp;lt;/code&amp;gt; command on your computer:&lt;br /&gt;
* If you find the entry &amp;lt;code&amp;gt;2207:0018 Fuzhou Rockchip Electronics Company rk3566_eink&amp;lt;/code&amp;gt; in the list, the process did not succeed; reboot and retry&lt;br /&gt;
* The entry &amp;lt;code&amp;gt;2207:350a Fuzhou Rockchip Electronics Company&amp;lt;/code&amp;gt; will occur if you detach then reattach the USB-C cable while the PineNote is in Maskrom/Rockusb mode; &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; won't work and you will have to do a hard reboot (hold down power button for 30 seconds to shutdown)&lt;br /&gt;
* If you find the entry &amp;lt;code&amp;gt;2207:350a Fuzhou Rockchip Electronics Company USB download gadget&amp;lt;/code&amp;gt; then the process succeeded&lt;br /&gt;
&lt;br /&gt;
You can also look at the output of the &amp;lt;code&amp;gt;rkdeveloptool list&amp;lt;/code&amp;gt; command:&lt;br /&gt;
* If this prints out &amp;lt;code&amp;gt;No devices in rockusb mode found&amp;lt;/code&amp;gt; the process did not succeed; reboot and retry&lt;br /&gt;
* If this prints out &amp;lt;code&amp;gt;DevNo=1 Vid=0x2207,Pid=0x350a,LocationID=305 Maskrom&amp;lt;/code&amp;gt; then you probably detached/reattached the USB-C cable while in Maskrom/Rockusb mode and &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; won't work; perform a hard reboot to fix&lt;br /&gt;
* If this prints out &amp;lt;code&amp;gt;DevNo=1 Vid=0x2207,Pid=0x350a,LocationID=303 Loader&amp;lt;/code&amp;gt; then the process succeeded&lt;br /&gt;
&lt;br /&gt;
=== Exiting ===&lt;br /&gt;
&lt;br /&gt;
You can boot the PineNote back into its normal mode of operation by powercycling the PineNote with its hardware power switch, or running the &amp;lt;code&amp;gt;rkdeveloptool reboot&amp;lt;/code&amp;gt; command.&lt;br /&gt;
If you used the magnetic switch method be sure to remove the pen/magnet before rebooting.&lt;br /&gt;
&lt;br /&gt;
== Backup ==&lt;br /&gt;
&lt;br /&gt;
A backup of the content of the internal eMMC before anything gets messed up is '''mandatory'''.&lt;br /&gt;
&lt;br /&gt;
Especially the ''waveform'' partition contains data '''unique''' to your PineNote and is a prime candidate for backup.&lt;br /&gt;
&lt;br /&gt;
Other partitions like U-Boot (need for any operation of the device) or the un-partitioned space at the beginning containing the GPT partition table (and presumably the VCOM setting for the e-ink display and maybe device mac addresses) contain data you may also wish to backup.&lt;br /&gt;
&lt;br /&gt;
Depending of your personal level of data hoarder you may want to backup more than this or even just everything (the large ''userdata'' partition is supposed to be able to be repopulated as empty space by Android)&lt;br /&gt;
&lt;br /&gt;
In any case it is easier to restore/extract data from a backup than not having one if you need one.&lt;br /&gt;
&lt;br /&gt;
This process was developed by Dorian Rudolph, originally described [https://github.com/DorianRudolph/pinenotes here].&lt;br /&gt;
&lt;br /&gt;
=== List partitions ===&lt;br /&gt;
&lt;br /&gt;
First, run &amp;lt;code&amp;gt;rkdeveloptool list-partitions&amp;lt;/code&amp;gt; to print out your PineNote's partitions to get an idea of what you're dealing with.&lt;br /&gt;
The stock PineNote has a fairly standard [https://source.android.com/docs/core/architecture/partitions Android partition setup]:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Number !! Name !! Size !! Purpose&lt;br /&gt;
|-&lt;br /&gt;
| 0 || uboot || 4 MB || The [https://en.wikipedia.org/wiki/Das_U-Boot U-Boot] embedded systems bootloader&lt;br /&gt;
|-&lt;br /&gt;
| 1 || trust || 4 MB || Secrets that can be encrypted with a key stored in the [https://en.wikipedia.org/wiki/Trusted_Platform_Module TPM]&lt;br /&gt;
|-&lt;br /&gt;
| 2 || waveform || 2 MB || Important files controlling the e-ink screen's state changes&lt;br /&gt;
|-&lt;br /&gt;
| 3 || misc || 4 MB || Data used by the recovery partition&lt;br /&gt;
|-&lt;br /&gt;
| 4 || dtbo || 4 MB || [https://en.wikipedia.org/wiki/Devicetree Device Tree Blob for Overlay], files describing the PineNote's hardware configuration&lt;br /&gt;
|-&lt;br /&gt;
| 5 || vbmeta || 1 MB || Data required for [https://android.googlesource.com/platform/external/avb/+/master/README.md verified boot]&lt;br /&gt;
|-&lt;br /&gt;
| 6 || boot || 42 MB || The kernel image &amp;amp; ramdisk to boot&lt;br /&gt;
|-&lt;br /&gt;
| 7 || security || 4 MB || &lt;br /&gt;
|-&lt;br /&gt;
| 8 || recovery || 134 MB || The recovery image, booted during Android updates&lt;br /&gt;
|-&lt;br /&gt;
| 9 || backup || 400 MB || &lt;br /&gt;
|-&lt;br /&gt;
| 10 || cache || 1 GB || Stores temporary data; can be used to install a minimal Linux distribution!&lt;br /&gt;
|-&lt;br /&gt;
| 11 || metadata || 17 MB || Used for disk encryption&lt;br /&gt;
|-&lt;br /&gt;
| 12 || super || 3.25 GB || Android itself is installed here&lt;br /&gt;
|-&lt;br /&gt;
| 13 || logo || 17 MB || Splash image displayed during boot&lt;br /&gt;
|-&lt;br /&gt;
| 14 || device || 67 MB || &lt;br /&gt;
|-&lt;br /&gt;
| 15 || userdata || 119 GB || The big one; user-installed Android apps and files live here&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Patch U-Boot ===&lt;br /&gt;
&lt;br /&gt;
Before we can back up our partitions, we have a problem to solve.&lt;br /&gt;
The version of U-Boot installed on the stock PineNote contains a bug where it can't dump partitions beyond 32 MB (above that limit all bytes in the dump are just &amp;lt;code&amp;gt;0xCC&amp;lt;/code&amp;gt;), meaning the PineNote must be flashed with a fixed version of U-Boot before it is possible to take a backup of the larger partitions.&lt;br /&gt;
It is possible to extract and modify the U-Boot image from your PineNote if you're interested in some light reverse-engineering (following Dorian's notes), or you can simply download a patched U-Boot image directly [https://github.com/DorianRudolph/pinenotes/blob/main/static/uboot_patched.img here].&lt;br /&gt;
&lt;br /&gt;
Once you've acquired a patched U-Boot image, run:&lt;br /&gt;
# &amp;lt;code&amp;gt;rkdeveloptool read-partition uboot uboot_backup.img&amp;lt;/code&amp;gt;&lt;br /&gt;
# &amp;lt;code&amp;gt;rkdeveloptool write-partition uboot uboot_patched.img&amp;lt;/code&amp;gt;&lt;br /&gt;
# &amp;lt;code&amp;gt;rkdeveloptool reboot&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Taking the backup ===&lt;br /&gt;
&lt;br /&gt;
With U-Boot patched, you can back up every partition except for super and userdata; run:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;rkdeveloptool read-partition partition_name partition_name_backup.img&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Unfortunately the super and userdata partitions run into a second limitation preventing dumping partitions larger than 2 GB, this time originating in &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; itself.&lt;br /&gt;
This means if you have a large number of documents in the Android userdata partition they might not all make it into the backup.&lt;br /&gt;
If you don't have many documents (or don't care about losing them) this should not be a problem.&lt;br /&gt;
If you do have a lot of documents, workarounds include:&lt;br /&gt;
* A possible patch written by Thomas exists [https://github.com/tpwrules/nixos-pinenote/blob/96d2c9158edb9da59afcb952cc864fada18382f9/nix/rkdeveloptool/0001-fix-large-dumps.patch here] but has not yet been upstreamed; consider investigating how to get the patch tested &amp;amp; upstreamed, or just apply it to your own local copy of &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt;&lt;br /&gt;
* Use [https://github.com/talpadk/pinenote-backup this] Python script written by Visti Andresen (talpadk) to automatically backup your entire partition by splitting reads into 2 GB chunks&lt;br /&gt;
&lt;br /&gt;
See [https://github.com/m-weigand/pinenote-debian-recipes/releases/tag/v0.1 instructions on this artifact]. It will instruct you on extracting the rootfs into an empty ext4 partition. This can be done from Linux or Android. Further instructions on building your own rootfs [https://github.com/m-weigand/pinenote-debian-recipes can be found here].&lt;br /&gt;
&lt;br /&gt;
=== Using a user installed Linux ===&lt;br /&gt;
A Linux installed to the cache partition should be able to easily backup everything over WiFi or to a USB stick/disk using ''dd''.&lt;br /&gt;
&lt;br /&gt;
However the user would need to backup the cache partition themself (if they want that).&lt;br /&gt;
&lt;br /&gt;
And more importantly they would only be getting the backup ''after'' they started playing with the content of the eMMC.&lt;br /&gt;
&lt;br /&gt;
== Side-by-side setup ==&lt;br /&gt;
&lt;br /&gt;
It is possible to set up a partition for mainline development without disturbing the factory Android installation. This allows updating a mainline kernel, DTB, and initramfs over Wi-Fi until WiFi or USB OTG is working in mainline Linux.&lt;br /&gt;
&lt;br /&gt;
=== Without Repartitioning ===&lt;br /&gt;
&lt;br /&gt;
The recommended partition for this is &amp;lt;tt&amp;gt;mmcblk0p11&amp;lt;/tt&amp;gt; aka &amp;lt;tt&amp;gt;/cache&amp;lt;/tt&amp;gt;. It is large and already formatted as &amp;lt;tt&amp;gt;ext4&amp;lt;/tt&amp;gt;, so it is readable from U-Boot. Here are some general steps:&lt;br /&gt;
&lt;br /&gt;
# From the UART or adb shell, set up your chroot in &amp;lt;tt&amp;gt;/cache&amp;lt;/tt&amp;gt;. I used the Alpine Linux rootfs tarball.&lt;br /&gt;
# Copy in your kernel and DTB, using for example &amp;lt;tt&amp;gt;scp&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;wget&amp;lt;/tt&amp;gt; inside the chroot.&lt;br /&gt;
# Finally, create and boot an &amp;lt;code&amp;gt;extlinux.conf&amp;lt;/code&amp;gt; as described below.&lt;br /&gt;
&lt;br /&gt;
=== With Repartitioning ===&lt;br /&gt;
&lt;br /&gt;
It is possible to shrink the &amp;lt;tt&amp;gt;userdata&amp;lt;/tt&amp;gt; partition, and create a new partition at the end for use with mainline Linux. This provides much more space than &amp;lt;tt&amp;gt;cache&amp;lt;/tt&amp;gt;. However, because &amp;lt;tt&amp;gt;userdata&amp;lt;/tt&amp;gt; is formatted with &amp;lt;tt&amp;gt;f2fs&amp;lt;/tt&amp;gt;, and that filesystem cannot be shrunk, resizing the partition requires wiping &amp;lt;tt&amp;gt;userdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
# Back up any necessary files from userdata&lt;br /&gt;
# Boot to a mainline kernel from &amp;lt;tt&amp;gt;mmcblk0p11&amp;lt;/tt&amp;gt;, either using that partition as rootfs (see above), or using an initramfs with repartitioning tools&lt;br /&gt;
# Modify the partition table with your favorite tool, e.g. &amp;lt;tt&amp;gt;fdisk&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gdisk&amp;lt;/tt&amp;gt;, or &amp;lt;tt&amp;gt;parted&amp;lt;/tt&amp;gt;&lt;br /&gt;
# Reboot into &amp;lt;tt&amp;gt;fastboot&amp;lt;/tt&amp;gt; and wipe &amp;lt;tt&amp;gt;userdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# Reboot into Android, where you can now chroot in and install your favorite distribution to the new partition.&lt;br /&gt;
&lt;br /&gt;
== Using rkdeveloptool ==&lt;br /&gt;
&lt;br /&gt;
=== Building Downstream U-Boot ===&lt;br /&gt;
&lt;br /&gt;
While in maskrom mode, we need to have a u-boot to download onto the device for any of the other commands to work. To build you'll also need to install device-tree-compiler.&lt;br /&gt;
&lt;br /&gt;
You also need to install Python and pyelftools.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Note that rkbin is a &amp;amp;gt;5GB download!&amp;lt;/b&amp;gt; This will take some time to clone and process the deltas.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone -b quartz64 https://gitlab.com/pgwipeout/u-boot-rockchip.git&lt;br /&gt;
git clone -b rkbin https://github.com/JeffyCN/rockchip_mirrors.git rkbin&lt;br /&gt;
cd u-boot-rockchip&lt;br /&gt;
# If using Arch Linux, export CROSS_COMPILE=aarch64-linux-gnu-&lt;br /&gt;
export CROSS_COMPILE=aarch64-none-linux-gnu-&lt;br /&gt;
make rk3566-quartz64_defconfig&lt;br /&gt;
./make.sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
In the current version (current as of 2022-01-02), there might have to be made a change to one line to get a clean compilation:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
diff --git a/lib/avb/libavb/avb_slot_verify.c b/lib/avb/libavb/avb_slot_verify.c&lt;br /&gt;
index 123701fc3b..64a1ce6450 100644&lt;br /&gt;
--- a/lib/avb/libavb/avb_slot_verify.c&lt;br /&gt;
+++ b/lib/avb/libavb/avb_slot_verify.c&lt;br /&gt;
@@ -296,7 +296,7 @@ static AvbSlotVerifyResult load_and_verify_hash_partition(&lt;br /&gt;
   bool image_preloaded = false;&lt;br /&gt;
   uint8_t* digest;&lt;br /&gt;
   size_t digest_len;&lt;br /&gt;
-  const char* found;&lt;br /&gt;
+  const char* found = NULL;&lt;br /&gt;
   uint64_t image_size;&lt;br /&gt;
   size_t expected_digest_len = 0;&lt;br /&gt;
   uint8_t expected_digest_buf[AVB_SHA512_DIGEST_SIZE];&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For systems where the global python executable points to python2, compilation fails with an error related to pyelftools not being installed (even if it is). To fix this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
diff --git a/make.sh b/make.sh&lt;br /&gt;
index 2bba05b4e4..cfe5b0afd5 100755&lt;br /&gt;
--- a/make.sh&lt;br /&gt;
+++ b/make.sh&lt;br /&gt;
@@ -758,7 +758,7 @@ function pack_fit_image()&lt;br /&gt;
        fi&lt;br /&gt;
 &lt;br /&gt;
        if [ &amp;quot;${ARM64_TRUSTZONE}&amp;quot; == &amp;quot;y&amp;quot; ]; then&lt;br /&gt;
-               if ! python -c &amp;quot;import elftools&amp;quot; ; then&lt;br /&gt;
+               if ! python3 -c &amp;quot;import elftools&amp;quot; ; then&lt;br /&gt;
                        echo &amp;quot;ERROR: No python 'pyelftools', please: pip install pyelftools&amp;quot;&lt;br /&gt;
                        exit 1&lt;br /&gt;
                fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can now download u-boot onto the PineNote:&lt;br /&gt;
&lt;br /&gt;
 ./rkdeveloptool boot ../u-boot-rockchip/rk356x_spl_loader_v1.08.111.bin&lt;br /&gt;
&lt;br /&gt;
This should output &amp;quot;''Downloading bootloader succeeded''&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
We can now verify that this worked using e.g. the &amp;quot;read flash info&amp;quot; command:&lt;br /&gt;
&lt;br /&gt;
 ./rkdeveloptool read-flash-info&lt;br /&gt;
&lt;br /&gt;
{{Note|'''TODO:''' Section needs to be finished}}&lt;br /&gt;
&lt;br /&gt;
=== Creating a mainline boot image ===&lt;br /&gt;
&lt;br /&gt;
You can create a filesystem image that replaces the Android boot or recovery partition by doing roughly the following:&lt;br /&gt;
&lt;br /&gt;
# Erase boot and dtbo with rkdeveloptool or fastboot (back them up first!!!)&lt;br /&gt;
# Create an ext2 partition image and mount it (fallocate, mkfs.ext2)&lt;br /&gt;
# Build your mainline kernel&lt;br /&gt;
# Copy the kernel, dtb and an initramfs to the root of the mounted image (use any old postmarketOS initramfs)&lt;br /&gt;
# Create a file in the root of the mounted image called &amp;lt;code&amp;gt;extlinux.conf&amp;lt;/code&amp;gt; as described below&lt;br /&gt;
# Unmount the image and then use rkdeveloptool to flash it to the &amp;quot;recovery&amp;quot; partition on the pinenote (it's about the right size until we get around to replacing the partition layout).&lt;br /&gt;
&lt;br /&gt;
== Using fastboot ==&lt;br /&gt;
&lt;br /&gt;
Follow the steps for [[PineNote Development/Flashing#Creating a mainline boot image|Creating a mainline boot image]], but instead of flashing it with ''rkdeveloptool'', use ''fastboot''. You can enter fastboot in either of two ways:&lt;br /&gt;
&lt;br /&gt;
* Use &amp;quot;reboot bootloader&amp;quot; from adb or a UART console or&lt;br /&gt;
* get a U-Boot prompt and run &amp;lt;code&amp;gt;fastboot usb 0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:PineNote]]&lt;/div&gt;</summary>
		<author><name>Ahelwer</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PineNote_Development/Flashing&amp;diff=20998</id>
		<title>PineNote Development/Flashing</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PineNote_Development/Flashing&amp;diff=20998"/>
		<updated>2023-10-23T17:27:07Z</updated>

		<summary type="html">&lt;p&gt;Ahelwer: /* List partitions */ Added partition descriptions&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Under construction}}&lt;br /&gt;
&lt;br /&gt;
{{Info|These instructions are directed towards experienced developers only!}}&lt;br /&gt;
&lt;br /&gt;
This page contains information on flashing software to the [[PineNote]].&lt;br /&gt;
&lt;br /&gt;
Currently, software can be flashed using rkdeveloptool or from the factory Android installation (UART shell, adb, or fastboot).&lt;br /&gt;
&lt;br /&gt;
== Getting &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
Most flashing operations on the PineNote are done through &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt;, a command line utility built on libusb.&lt;br /&gt;
PINE64 maintains its own fork [https://gitlab.com/pine64-org/quartz-bsp/rkdeveloptool here] that you will need to get.&lt;br /&gt;
The repo's README contains a list of dependencies (libusb 1.0) and instructions for building the tool.&lt;br /&gt;
&lt;br /&gt;
Installing (not just building) &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; will configure PAM to elevate privileges where necessary on your system; you can configure this manually as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo cp 99-rk-rockusb.rules /etc/udev/rules.d/&lt;br /&gt;
sudo udevadm control --reload&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Entering Maskrom/Rockusb mode ==&lt;br /&gt;
&lt;br /&gt;
Interfacing with the PineNote over USB using &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; requires first booting the PineNote into [http://opensource.rock-chips.com/wiki_Rockusb an alternative operating mode] called Maskrom or Rockusb mode.&lt;br /&gt;
&lt;br /&gt;
=== Possible methods ===&lt;br /&gt;
&lt;br /&gt;
There are three possible methods of entering Maskrom/Rockusb mode:&lt;br /&gt;
&lt;br /&gt;
==== Hardware magnet switch ====&lt;br /&gt;
&lt;br /&gt;
# Connect the PineNote to your computer via USB and boot the PineNote into Android&lt;br /&gt;
# Locate &amp;amp; identify the small circular marking on the back of the PineNote, in the top right quadrant; have the PineNote pen close at hand, or any other small magnet&lt;br /&gt;
# Hold the PineNote power button to bring up the reboot/shutdown menu; select reboot, then place the PineNote face down with the &amp;quot;eraser&amp;quot; end of the pen (or your magnet) resting on the small circular marking&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Download mode.jpeg|Pen method&lt;br /&gt;
PineNoteMagnetOnBack.jpg|Magnet method&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== U-Boot terminal ====&lt;br /&gt;
This method requires a [[PineNote_Development/UART#USB_passthrough|UART dongle with passthrough]] allowing simultaneous UART &amp;amp; USB connections.&lt;br /&gt;
It is nice because you can easily switch back &amp;amp; forth between U-Boot and Rockusb without having to physically manipulate the PineNote or its connectors; this is especially helpful when trying to develop U-Boot.&lt;br /&gt;
&lt;br /&gt;
# Connect to the PineNote via UART and USB simultaneously&lt;br /&gt;
# Interrupt the U-Boot startup using &amp;lt;code&amp;gt;ctrl+c&amp;lt;/code&amp;gt; sent over UART&lt;br /&gt;
# In the U-Boot terminal over UART, run &amp;lt;code&amp;gt;rockusb 0 mmc 0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The UART terminal should print &amp;lt;code&amp;gt;RKUSB&amp;lt;/code&amp;gt; then a spinner will appear.&lt;br /&gt;
You can exit back to the U-Boot terminal by sending &amp;lt;code&amp;gt;ctrl+c&amp;lt;/code&amp;gt; again.&lt;br /&gt;
&lt;br /&gt;
==== Shorting test points ====&lt;br /&gt;
&lt;br /&gt;
If the bootloader is broken/corrupted, you cannot get to Maskrom without opening up the device (it can be opened using spudger and a bit of patience).&lt;br /&gt;
&lt;br /&gt;
Once inside, short TP1301 (GND) and TP1302 (eMMC_D0/FLASH_D0) with a small tweezers, this is how it looks on board view (credit to Caleb):&lt;br /&gt;
&lt;br /&gt;
[[File:PineNote_Maskrom_TP.png|500px]]&lt;br /&gt;
&lt;br /&gt;
=== Success ===&lt;br /&gt;
&lt;br /&gt;
No matter what approach you take, you can tell whether you succeeded by running the &amp;lt;code&amp;gt;lsusb&amp;lt;/code&amp;gt; command on your computer:&lt;br /&gt;
* If you find the entry &amp;lt;code&amp;gt;2207:0018 Fuzhou Rockchip Electronics Company rk3566_eink&amp;lt;/code&amp;gt; in the list, the process did not succeed; reboot and retry&lt;br /&gt;
* The entry &amp;lt;code&amp;gt;2207:350a Fuzhou Rockchip Electronics Company&amp;lt;/code&amp;gt; will occur if you detach then reattach the USB-C cable while the PineNote is in Maskrom/Rockusb mode; &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; won't work and you will have to do a hard reboot (hold down power button for 30 seconds to shutdown)&lt;br /&gt;
* If you find the entry &amp;lt;code&amp;gt;2207:350a Fuzhou Rockchip Electronics Company USB download gadget&amp;lt;/code&amp;gt; then the process succeeded&lt;br /&gt;
&lt;br /&gt;
You can also look at the output of the &amp;lt;code&amp;gt;rkdeveloptool list&amp;lt;/code&amp;gt; command:&lt;br /&gt;
* If this prints out &amp;lt;code&amp;gt;No devices in rockusb mode found&amp;lt;/code&amp;gt; the process did not succeed; reboot and retry&lt;br /&gt;
* If this prints out &amp;lt;code&amp;gt;DevNo=1 Vid=0x2207,Pid=0x350a,LocationID=305 Maskrom&amp;lt;/code&amp;gt; then you probably detached/reattached the USB-C cable while in Maskrom/Rockusb mode and &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; won't work; perform a hard reboot to fix&lt;br /&gt;
* If this prints out &amp;lt;code&amp;gt;DevNo=1 Vid=0x2207,Pid=0x350a,LocationID=303 Loader&amp;lt;/code&amp;gt; then the process succeeded&lt;br /&gt;
&lt;br /&gt;
=== Exiting ===&lt;br /&gt;
&lt;br /&gt;
You can boot the PineNote back into its normal mode of operation by powercycling the PineNote with its hardware power switch, or running the &amp;lt;code&amp;gt;rkdeveloptool reboot&amp;lt;/code&amp;gt; command.&lt;br /&gt;
If you used the magnetic switch method be sure to remove the pen/magnet before rebooting.&lt;br /&gt;
&lt;br /&gt;
== Backup ==&lt;br /&gt;
&lt;br /&gt;
A backup of the content of the internal eMMC before anything gets messed up is '''mandatory'''.&lt;br /&gt;
&lt;br /&gt;
Especially the ''waveform'' partition contains data '''unique''' to your PineNote and is a prime candidate for backup.&lt;br /&gt;
&lt;br /&gt;
Other partitions like U-Boot (need for any operation of the device) or the un-partitioned space at the beginning containing the GPT partition table (and presumably the VCOM setting for the e-ink display and maybe device mac addresses) contain data you may also wish to backup.&lt;br /&gt;
&lt;br /&gt;
Depending of your personal level of data hoarder you may want to backup more than this or even just everything (the large ''userdata'' partition is supposed to be able to be repopulated as empty space by Android)&lt;br /&gt;
&lt;br /&gt;
In any case it is easier to restore/extract data from a backup than not having one if you need one.&lt;br /&gt;
&lt;br /&gt;
This process was developed by Dorian Rudolph, originally described [https://github.com/DorianRudolph/pinenotes here].&lt;br /&gt;
&lt;br /&gt;
=== List partitions ===&lt;br /&gt;
&lt;br /&gt;
First, run &amp;lt;code&amp;gt;rkdeveloptool list-partitions&amp;lt;/code&amp;gt; to print out your PineNote's partitions to get an idea of what you're dealing with.&lt;br /&gt;
The stock PineNote has a fairly standard [https://source.android.com/docs/core/architecture/partitions Android partition setup]:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Number !! Name !! Size !! Purpose&lt;br /&gt;
|-&lt;br /&gt;
| 0 || uboot || 4 MB || The [https://en.wikipedia.org/wiki/Das_U-Boot U-Boot] embedded systems bootloader&lt;br /&gt;
|-&lt;br /&gt;
| 1 || trust || 4 MB || Secrets that can be encrypted with a key stored in the [https://en.wikipedia.org/wiki/Trusted_Platform_Module TPM]&lt;br /&gt;
|-&lt;br /&gt;
| 2 || waveform || 2 MB || Important files controlling the e-ink screen's state changes&lt;br /&gt;
|-&lt;br /&gt;
| 3 || misc || 4 MB || Data used by the recovery partition&lt;br /&gt;
|-&lt;br /&gt;
| 4 || dtbo || 4 MB || [https://en.wikipedia.org/wiki/Devicetree Device Tree Blob for Overlay], files describing the PineNote's hardware configuration&lt;br /&gt;
|-&lt;br /&gt;
| 5 || vbmeta || 1 MB || Data required for [https://android.googlesource.com/platform/external/avb/+/master/README.md verified boot]&lt;br /&gt;
|-&lt;br /&gt;
| 6 || boot || 42 MB || The kernel image &amp;amp; ramdisk to boot&lt;br /&gt;
|-&lt;br /&gt;
| 7 || security || 4 MB || &lt;br /&gt;
|-&lt;br /&gt;
| 8 || recovery || 134 MB || The recovery image, booted during Android updates&lt;br /&gt;
|-&lt;br /&gt;
| 9 || backup || 400 MB || &lt;br /&gt;
|-&lt;br /&gt;
| 10 || cache || 1 GB || Stores temporary data; can be used to install a minimal Linux distribution!&lt;br /&gt;
|-&lt;br /&gt;
| 11 || metadata || 17 MB || Used for disk encryption&lt;br /&gt;
|-&lt;br /&gt;
| 12 || super || 3.25 GB || Android itself is installed here&lt;br /&gt;
|-&lt;br /&gt;
| 13 || logo || 17 MB || Splash image displayed during boot&lt;br /&gt;
|-&lt;br /&gt;
| 14 || device || 67 MB || &lt;br /&gt;
|-&lt;br /&gt;
| 15 || userdata || 119 GB || The big one; user-installed Android apps and files live here&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Patch U-Boot ===&lt;br /&gt;
&lt;br /&gt;
Before we can back up our partitions, we have a problem to solve.&lt;br /&gt;
The version of U-Boot installed on the stock PineNote contains a bug where it can't dump partitions beyond 32 MB (above that limit all bytes in the dump are just &amp;lt;code&amp;gt;0xCC&amp;lt;/code&amp;gt;), meaning the PineNote must be flashed with a fixed version of U-Boot before it is possible to take a backup of the larger partitions.&lt;br /&gt;
It is possible to extract and modify the U-Boot image from your PineNote if you're interested in some light reverse-engineering (following Dorian's notes), or you can simply download a patched U-Boot image directly [https://github.com/DorianRudolph/pinenotes/blob/main/static/uboot_patched.img here].&lt;br /&gt;
&lt;br /&gt;
Once you've acquired a patched U-Boot image, run:&lt;br /&gt;
# &amp;lt;code&amp;gt;rkdeveloptool read-partition uboot uboot_backup.img&amp;lt;/code&amp;gt;&lt;br /&gt;
# &amp;lt;code&amp;gt;rkdeveloptool write-partition uboot uboot_patched.img&amp;lt;/code&amp;gt;&lt;br /&gt;
# &amp;lt;code&amp;gt;rkdeveloptool reboot&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Taking the backup ===&lt;br /&gt;
&lt;br /&gt;
With U-Boot patched, run:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;rkdeveloptool read-partition partition_name partition_name_backup.img&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There is a second backup limit preventing dumping partitions larger than 2 GB, this time from &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt;.&lt;br /&gt;
This means if you have a large number of documents in the Android userdata partition they might not all make it into the backup.&lt;br /&gt;
If you don't have many documents (or don't care about losing them) this should not be a problem.&lt;br /&gt;
If you do have a lot of documents, workarounds include:&lt;br /&gt;
* A possible patch written by Thomas exists [https://github.com/tpwrules/nixos-pinenote/blob/96d2c9158edb9da59afcb952cc864fada18382f9/nix/rkdeveloptool/0001-fix-large-dumps.patch here] but has not yet been upstreamed; consider investigating how to get the patch tested &amp;amp; upstreamed, or just apply it to your own local copy of &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt;&lt;br /&gt;
* Use [https://github.com/talpadk/pinenote-backup this] Python script written by Visti Andresen (talpadk) to automatically backup your entire partition by splitting reads into 2 GB chunks&lt;br /&gt;
&lt;br /&gt;
See [https://github.com/m-weigand/pinenote-debian-recipes/releases/tag/v0.1 instructions on this artifact]. It will instruct you on extracting the rootfs into an empty ext4 partition. This can be done from Linux or Android. Further instructions on building your own rootfs [https://github.com/m-weigand/pinenote-debian-recipes can be found here].&lt;br /&gt;
&lt;br /&gt;
=== Using a user installed Linux ===&lt;br /&gt;
A Linux installed to the cache partition should be able to easily backup everything over WiFi or to a USB stick/disk using ''dd''.&lt;br /&gt;
&lt;br /&gt;
However the user would need to backup the cache partition themself (if they want that).&lt;br /&gt;
&lt;br /&gt;
And more importantly they would only be getting the backup ''after'' they started playing with the content of the eMMC.&lt;br /&gt;
&lt;br /&gt;
== Side-by-side setup ==&lt;br /&gt;
&lt;br /&gt;
It is possible to set up a partition for mainline development without disturbing the factory Android installation. This allows updating a mainline kernel, DTB, and initramfs over Wi-Fi until WiFi or USB OTG is working in mainline Linux.&lt;br /&gt;
&lt;br /&gt;
=== Without Repartitioning ===&lt;br /&gt;
&lt;br /&gt;
The recommended partition for this is &amp;lt;tt&amp;gt;mmcblk0p11&amp;lt;/tt&amp;gt; aka &amp;lt;tt&amp;gt;/cache&amp;lt;/tt&amp;gt;. It is large and already formatted as &amp;lt;tt&amp;gt;ext4&amp;lt;/tt&amp;gt;, so it is readable from U-Boot. Here are some general steps:&lt;br /&gt;
&lt;br /&gt;
# From the UART or adb shell, set up your chroot in &amp;lt;tt&amp;gt;/cache&amp;lt;/tt&amp;gt;. I used the Alpine Linux rootfs tarball.&lt;br /&gt;
# Copy in your kernel and DTB, using for example &amp;lt;tt&amp;gt;scp&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;wget&amp;lt;/tt&amp;gt; inside the chroot.&lt;br /&gt;
# Finally, create and boot an &amp;lt;code&amp;gt;extlinux.conf&amp;lt;/code&amp;gt; as described below.&lt;br /&gt;
&lt;br /&gt;
=== With Repartitioning ===&lt;br /&gt;
&lt;br /&gt;
It is possible to shrink the &amp;lt;tt&amp;gt;userdata&amp;lt;/tt&amp;gt; partition, and create a new partition at the end for use with mainline Linux. This provides much more space than &amp;lt;tt&amp;gt;cache&amp;lt;/tt&amp;gt;. However, because &amp;lt;tt&amp;gt;userdata&amp;lt;/tt&amp;gt; is formatted with &amp;lt;tt&amp;gt;f2fs&amp;lt;/tt&amp;gt;, and that filesystem cannot be shrunk, resizing the partition requires wiping &amp;lt;tt&amp;gt;userdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
# Back up any necessary files from userdata&lt;br /&gt;
# Boot to a mainline kernel from &amp;lt;tt&amp;gt;mmcblk0p11&amp;lt;/tt&amp;gt;, either using that partition as rootfs (see above), or using an initramfs with repartitioning tools&lt;br /&gt;
# Modify the partition table with your favorite tool, e.g. &amp;lt;tt&amp;gt;fdisk&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gdisk&amp;lt;/tt&amp;gt;, or &amp;lt;tt&amp;gt;parted&amp;lt;/tt&amp;gt;&lt;br /&gt;
# Reboot into &amp;lt;tt&amp;gt;fastboot&amp;lt;/tt&amp;gt; and wipe &amp;lt;tt&amp;gt;userdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# Reboot into Android, where you can now chroot in and install your favorite distribution to the new partition.&lt;br /&gt;
&lt;br /&gt;
== Using rkdeveloptool ==&lt;br /&gt;
&lt;br /&gt;
=== Building Downstream U-Boot ===&lt;br /&gt;
&lt;br /&gt;
While in maskrom mode, we need to have a u-boot to download onto the device for any of the other commands to work. To build you'll also need to install device-tree-compiler.&lt;br /&gt;
&lt;br /&gt;
You also need to install Python and pyelftools.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Note that rkbin is a &amp;amp;gt;5GB download!&amp;lt;/b&amp;gt; This will take some time to clone and process the deltas.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone -b quartz64 https://gitlab.com/pgwipeout/u-boot-rockchip.git&lt;br /&gt;
git clone -b rkbin https://github.com/JeffyCN/rockchip_mirrors.git rkbin&lt;br /&gt;
cd u-boot-rockchip&lt;br /&gt;
# If using Arch Linux, export CROSS_COMPILE=aarch64-linux-gnu-&lt;br /&gt;
export CROSS_COMPILE=aarch64-none-linux-gnu-&lt;br /&gt;
make rk3566-quartz64_defconfig&lt;br /&gt;
./make.sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
In the current version (current as of 2022-01-02), there might have to be made a change to one line to get a clean compilation:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
diff --git a/lib/avb/libavb/avb_slot_verify.c b/lib/avb/libavb/avb_slot_verify.c&lt;br /&gt;
index 123701fc3b..64a1ce6450 100644&lt;br /&gt;
--- a/lib/avb/libavb/avb_slot_verify.c&lt;br /&gt;
+++ b/lib/avb/libavb/avb_slot_verify.c&lt;br /&gt;
@@ -296,7 +296,7 @@ static AvbSlotVerifyResult load_and_verify_hash_partition(&lt;br /&gt;
   bool image_preloaded = false;&lt;br /&gt;
   uint8_t* digest;&lt;br /&gt;
   size_t digest_len;&lt;br /&gt;
-  const char* found;&lt;br /&gt;
+  const char* found = NULL;&lt;br /&gt;
   uint64_t image_size;&lt;br /&gt;
   size_t expected_digest_len = 0;&lt;br /&gt;
   uint8_t expected_digest_buf[AVB_SHA512_DIGEST_SIZE];&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For systems where the global python executable points to python2, compilation fails with an error related to pyelftools not being installed (even if it is). To fix this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
diff --git a/make.sh b/make.sh&lt;br /&gt;
index 2bba05b4e4..cfe5b0afd5 100755&lt;br /&gt;
--- a/make.sh&lt;br /&gt;
+++ b/make.sh&lt;br /&gt;
@@ -758,7 +758,7 @@ function pack_fit_image()&lt;br /&gt;
        fi&lt;br /&gt;
 &lt;br /&gt;
        if [ &amp;quot;${ARM64_TRUSTZONE}&amp;quot; == &amp;quot;y&amp;quot; ]; then&lt;br /&gt;
-               if ! python -c &amp;quot;import elftools&amp;quot; ; then&lt;br /&gt;
+               if ! python3 -c &amp;quot;import elftools&amp;quot; ; then&lt;br /&gt;
                        echo &amp;quot;ERROR: No python 'pyelftools', please: pip install pyelftools&amp;quot;&lt;br /&gt;
                        exit 1&lt;br /&gt;
                fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can now download u-boot onto the PineNote:&lt;br /&gt;
&lt;br /&gt;
 ./rkdeveloptool boot ../u-boot-rockchip/rk356x_spl_loader_v1.08.111.bin&lt;br /&gt;
&lt;br /&gt;
This should output &amp;quot;''Downloading bootloader succeeded''&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
We can now verify that this worked using e.g. the &amp;quot;read flash info&amp;quot; command:&lt;br /&gt;
&lt;br /&gt;
 ./rkdeveloptool read-flash-info&lt;br /&gt;
&lt;br /&gt;
{{Note|'''TODO:''' Section needs to be finished}}&lt;br /&gt;
&lt;br /&gt;
=== Creating a mainline boot image ===&lt;br /&gt;
&lt;br /&gt;
You can create a filesystem image that replaces the Android boot or recovery partition by doing roughly the following:&lt;br /&gt;
&lt;br /&gt;
# Erase boot and dtbo with rkdeveloptool or fastboot (back them up first!!!)&lt;br /&gt;
# Create an ext2 partition image and mount it (fallocate, mkfs.ext2)&lt;br /&gt;
# Build your mainline kernel&lt;br /&gt;
# Copy the kernel, dtb and an initramfs to the root of the mounted image (use any old postmarketOS initramfs)&lt;br /&gt;
# Create a file in the root of the mounted image called &amp;lt;code&amp;gt;extlinux.conf&amp;lt;/code&amp;gt; as described below&lt;br /&gt;
# Unmount the image and then use rkdeveloptool to flash it to the &amp;quot;recovery&amp;quot; partition on the pinenote (it's about the right size until we get around to replacing the partition layout).&lt;br /&gt;
&lt;br /&gt;
== Using fastboot ==&lt;br /&gt;
&lt;br /&gt;
Follow the steps for [[PineNote Development/Flashing#Creating a mainline boot image|Creating a mainline boot image]], but instead of flashing it with ''rkdeveloptool'', use ''fastboot''. You can enter fastboot in either of two ways:&lt;br /&gt;
&lt;br /&gt;
* Use &amp;quot;reboot bootloader&amp;quot; from adb or a UART console or&lt;br /&gt;
* get a U-Boot prompt and run &amp;lt;code&amp;gt;fastboot usb 0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:PineNote]]&lt;/div&gt;</summary>
		<author><name>Ahelwer</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PineNote_Development/Flashing&amp;diff=20997</id>
		<title>PineNote Development/Flashing</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PineNote_Development/Flashing&amp;diff=20997"/>
		<updated>2023-10-23T16:52:16Z</updated>

		<summary type="html">&lt;p&gt;Ahelwer: /* Backup */ Added partition table&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Under construction}}&lt;br /&gt;
&lt;br /&gt;
{{Info|These instructions are directed towards experienced developers only!}}&lt;br /&gt;
&lt;br /&gt;
This page contains information on flashing software to the [[PineNote]].&lt;br /&gt;
&lt;br /&gt;
Currently, software can be flashed using rkdeveloptool or from the factory Android installation (UART shell, adb, or fastboot).&lt;br /&gt;
&lt;br /&gt;
== Getting &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
Most flashing operations on the PineNote are done through &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt;, a command line utility built on libusb.&lt;br /&gt;
PINE64 maintains its own fork [https://gitlab.com/pine64-org/quartz-bsp/rkdeveloptool here] that you will need to get.&lt;br /&gt;
The repo's README contains a list of dependencies (libusb 1.0) and instructions for building the tool.&lt;br /&gt;
&lt;br /&gt;
Installing (not just building) &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; will configure PAM to elevate privileges where necessary on your system; you can configure this manually as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo cp 99-rk-rockusb.rules /etc/udev/rules.d/&lt;br /&gt;
sudo udevadm control --reload&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Entering Maskrom/Rockusb mode ==&lt;br /&gt;
&lt;br /&gt;
Interfacing with the PineNote over USB using &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; requires first booting the PineNote into [http://opensource.rock-chips.com/wiki_Rockusb an alternative operating mode] called Maskrom or Rockusb mode.&lt;br /&gt;
&lt;br /&gt;
=== Possible methods ===&lt;br /&gt;
&lt;br /&gt;
There are three possible methods of entering Maskrom/Rockusb mode:&lt;br /&gt;
&lt;br /&gt;
==== Hardware magnet switch ====&lt;br /&gt;
&lt;br /&gt;
# Connect the PineNote to your computer via USB and boot the PineNote into Android&lt;br /&gt;
# Locate &amp;amp; identify the small circular marking on the back of the PineNote, in the top right quadrant; have the PineNote pen close at hand, or any other small magnet&lt;br /&gt;
# Hold the PineNote power button to bring up the reboot/shutdown menu; select reboot, then place the PineNote face down with the &amp;quot;eraser&amp;quot; end of the pen (or your magnet) resting on the small circular marking&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Download mode.jpeg|Pen method&lt;br /&gt;
PineNoteMagnetOnBack.jpg|Magnet method&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== U-Boot terminal ====&lt;br /&gt;
This method requires a [[PineNote_Development/UART#USB_passthrough|UART dongle with passthrough]] allowing simultaneous UART &amp;amp; USB connections.&lt;br /&gt;
It is nice because you can easily switch back &amp;amp; forth between U-Boot and Rockusb without having to physically manipulate the PineNote or its connectors; this is especially helpful when trying to develop U-Boot.&lt;br /&gt;
&lt;br /&gt;
# Connect to the PineNote via UART and USB simultaneously&lt;br /&gt;
# Interrupt the U-Boot startup using &amp;lt;code&amp;gt;ctrl+c&amp;lt;/code&amp;gt; sent over UART&lt;br /&gt;
# In the U-Boot terminal over UART, run &amp;lt;code&amp;gt;rockusb 0 mmc 0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The UART terminal should print &amp;lt;code&amp;gt;RKUSB&amp;lt;/code&amp;gt; then a spinner will appear.&lt;br /&gt;
You can exit back to the U-Boot terminal by sending &amp;lt;code&amp;gt;ctrl+c&amp;lt;/code&amp;gt; again.&lt;br /&gt;
&lt;br /&gt;
==== Shorting test points ====&lt;br /&gt;
&lt;br /&gt;
If the bootloader is broken/corrupted, you cannot get to Maskrom without opening up the device (it can be opened using spudger and a bit of patience).&lt;br /&gt;
&lt;br /&gt;
Once inside, short TP1301 (GND) and TP1302 (eMMC_D0/FLASH_D0) with a small tweezers, this is how it looks on board view (credit to Caleb):&lt;br /&gt;
&lt;br /&gt;
[[File:PineNote_Maskrom_TP.png|500px]]&lt;br /&gt;
&lt;br /&gt;
=== Success ===&lt;br /&gt;
&lt;br /&gt;
No matter what approach you take, you can tell whether you succeeded by running the &amp;lt;code&amp;gt;lsusb&amp;lt;/code&amp;gt; command on your computer:&lt;br /&gt;
* If you find the entry &amp;lt;code&amp;gt;2207:0018 Fuzhou Rockchip Electronics Company rk3566_eink&amp;lt;/code&amp;gt; in the list, the process did not succeed; reboot and retry&lt;br /&gt;
* The entry &amp;lt;code&amp;gt;2207:350a Fuzhou Rockchip Electronics Company&amp;lt;/code&amp;gt; will occur if you detach then reattach the USB-C cable while the PineNote is in Maskrom/Rockusb mode; &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; won't work and you will have to do a hard reboot (hold down power button for 30 seconds to shutdown)&lt;br /&gt;
* If you find the entry &amp;lt;code&amp;gt;2207:350a Fuzhou Rockchip Electronics Company USB download gadget&amp;lt;/code&amp;gt; then the process succeeded&lt;br /&gt;
&lt;br /&gt;
You can also look at the output of the &amp;lt;code&amp;gt;rkdeveloptool list&amp;lt;/code&amp;gt; command:&lt;br /&gt;
* If this prints out &amp;lt;code&amp;gt;No devices in rockusb mode found&amp;lt;/code&amp;gt; the process did not succeed; reboot and retry&lt;br /&gt;
* If this prints out &amp;lt;code&amp;gt;DevNo=1 Vid=0x2207,Pid=0x350a,LocationID=305 Maskrom&amp;lt;/code&amp;gt; then you probably detached/reattached the USB-C cable while in Maskrom/Rockusb mode and &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; won't work; perform a hard reboot to fix&lt;br /&gt;
* If this prints out &amp;lt;code&amp;gt;DevNo=1 Vid=0x2207,Pid=0x350a,LocationID=303 Loader&amp;lt;/code&amp;gt; then the process succeeded&lt;br /&gt;
&lt;br /&gt;
=== Exiting ===&lt;br /&gt;
&lt;br /&gt;
You can boot the PineNote back into its normal mode of operation by powercycling the PineNote with its hardware power switch, or running the &amp;lt;code&amp;gt;rkdeveloptool reboot&amp;lt;/code&amp;gt; command.&lt;br /&gt;
If you used the magnetic switch method be sure to remove the pen/magnet before rebooting.&lt;br /&gt;
&lt;br /&gt;
== Backup ==&lt;br /&gt;
&lt;br /&gt;
A backup of the content of the internal eMMC before anything gets messed up is '''mandatory'''.&lt;br /&gt;
&lt;br /&gt;
Especially the ''waveform'' partition contains data '''unique''' to your PineNote and is a prime candidate for backup.&lt;br /&gt;
&lt;br /&gt;
Other partitions like U-Boot (need for any operation of the device) or the un-partitioned space at the beginning containing the GPT partition table (and presumably the VCOM setting for the e-ink display and maybe device mac addresses) contain data you may also wish to backup.&lt;br /&gt;
&lt;br /&gt;
Depending of your personal level of data hoarder you may want to backup more than this or even just everything (the large ''userdata'' partition is supposed to be able to be repopulated as empty space by Android)&lt;br /&gt;
&lt;br /&gt;
In any case it is easier to restore/extract data from a backup than not having one if you need one.&lt;br /&gt;
&lt;br /&gt;
This process was developed by Dorian Rudolph, originally described [https://github.com/DorianRudolph/pinenotes here].&lt;br /&gt;
&lt;br /&gt;
=== List partitions ===&lt;br /&gt;
&lt;br /&gt;
First, run &amp;lt;code&amp;gt;rkdeveloptool list-partitions&amp;lt;/code&amp;gt; to print out your PineNote's partitions to get an idea of what you're dealing with.&lt;br /&gt;
The stock PineNote has a fairly standard [https://source.android.com/docs/core/architecture/partitions Android partition setup]:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Number !! Name !! Size !! Purpose&lt;br /&gt;
|-&lt;br /&gt;
| 0 || uboot || 4 MB || The [https://en.wikipedia.org/wiki/Das_U-Boot U-Boot] embedded systems bootloader&lt;br /&gt;
|-&lt;br /&gt;
| 1 || trust || 4 MB || Secrets that can be encrypted with a key stored in the [https://en.wikipedia.org/wiki/Trusted_Platform_Module TPM]&lt;br /&gt;
|-&lt;br /&gt;
| 2 || waveform || 2 MB || Important files controlling the e-ink screen's state changes&lt;br /&gt;
|-&lt;br /&gt;
| 3 || misc || 4 MB || Data used by the recovery partition&lt;br /&gt;
|-&lt;br /&gt;
| 4 || dtbo || 4 MB || [https://en.wikipedia.org/wiki/Devicetree Device Tree Blob for Overlay], files describing the PineNote's hardware configuration&lt;br /&gt;
|-&lt;br /&gt;
| 5 || vbmeta || 1 MB || Data required for [https://android.googlesource.com/platform/external/avb/+/master/README.md verified boot]&lt;br /&gt;
|-&lt;br /&gt;
| 6 || boot || 42 MB || The kernel image &amp;amp; ramdisk to boot&lt;br /&gt;
|-&lt;br /&gt;
| 7 || security || 4 MB || &lt;br /&gt;
|-&lt;br /&gt;
| 8 || recovery || 134 MB || The recovery image, booted during Android updates&lt;br /&gt;
|-&lt;br /&gt;
| 9 || backup || 400 MB || &lt;br /&gt;
|-&lt;br /&gt;
| 10 || cache || 1 GB || Stores temporary data; can be used to install a minimal Linux distribution!&lt;br /&gt;
|-&lt;br /&gt;
| 11 || metadata || 17 MB || &lt;br /&gt;
|-&lt;br /&gt;
| 12 || super || 3.25 GB || &lt;br /&gt;
|-&lt;br /&gt;
| 13 || logo || 17 MB || &lt;br /&gt;
|-&lt;br /&gt;
| 14 || device || 67 MB || &lt;br /&gt;
|-&lt;br /&gt;
| 15 || userdata || 119 GB || &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Patch U-Boot ===&lt;br /&gt;
&lt;br /&gt;
Before we can back up our partitions, we have a problem to solve.&lt;br /&gt;
The version of U-Boot installed on the stock PineNote contains a bug where it can't dump partitions beyond 32 MB (above that limit all bytes in the dump are just &amp;lt;code&amp;gt;0xCC&amp;lt;/code&amp;gt;), meaning the PineNote must be flashed with a fixed version of U-Boot before it is possible to take a backup of the larger partitions.&lt;br /&gt;
It is possible to extract and modify the U-Boot image from your PineNote if you're interested in some light reverse-engineering (following Dorian's notes), or you can simply download a patched U-Boot image directly [https://github.com/DorianRudolph/pinenotes/blob/main/static/uboot_patched.img here].&lt;br /&gt;
&lt;br /&gt;
Once you've acquired a patched U-Boot image, run:&lt;br /&gt;
# &amp;lt;code&amp;gt;rkdeveloptool read-partition uboot uboot_backup.img&amp;lt;/code&amp;gt;&lt;br /&gt;
# &amp;lt;code&amp;gt;rkdeveloptool write-partition uboot uboot_patched.img&amp;lt;/code&amp;gt;&lt;br /&gt;
# &amp;lt;code&amp;gt;rkdeveloptool reboot&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Taking the backup ===&lt;br /&gt;
&lt;br /&gt;
With U-Boot patched, run:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;rkdeveloptool read-partition partition_name partition_name_backup.img&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There is a second backup limit preventing dumping partitions larger than 2 GB, this time from &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt;.&lt;br /&gt;
This means if you have a large number of documents in the Android userdata partition they might not all make it into the backup.&lt;br /&gt;
If you don't have many documents (or don't care about losing them) this should not be a problem.&lt;br /&gt;
If you do have a lot of documents, workarounds include:&lt;br /&gt;
* A possible patch written by Thomas exists [https://github.com/tpwrules/nixos-pinenote/blob/96d2c9158edb9da59afcb952cc864fada18382f9/nix/rkdeveloptool/0001-fix-large-dumps.patch here] but has not yet been upstreamed; consider investigating how to get the patch tested &amp;amp; upstreamed, or just apply it to your own local copy of &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt;&lt;br /&gt;
* Use [https://github.com/talpadk/pinenote-backup this] Python script written by Visti Andresen (talpadk) to automatically backup your entire partition by splitting reads into 2 GB chunks&lt;br /&gt;
&lt;br /&gt;
See [https://github.com/m-weigand/pinenote-debian-recipes/releases/tag/v0.1 instructions on this artifact]. It will instruct you on extracting the rootfs into an empty ext4 partition. This can be done from Linux or Android. Further instructions on building your own rootfs [https://github.com/m-weigand/pinenote-debian-recipes can be found here].&lt;br /&gt;
&lt;br /&gt;
=== Using a user installed Linux ===&lt;br /&gt;
A Linux installed to the cache partition should be able to easily backup everything over WiFi or to a USB stick/disk using ''dd''.&lt;br /&gt;
&lt;br /&gt;
However the user would need to backup the cache partition themself (if they want that).&lt;br /&gt;
&lt;br /&gt;
And more importantly they would only be getting the backup ''after'' they started playing with the content of the eMMC.&lt;br /&gt;
&lt;br /&gt;
== Side-by-side setup ==&lt;br /&gt;
&lt;br /&gt;
It is possible to set up a partition for mainline development without disturbing the factory Android installation. This allows updating a mainline kernel, DTB, and initramfs over Wi-Fi until WiFi or USB OTG is working in mainline Linux.&lt;br /&gt;
&lt;br /&gt;
=== Without Repartitioning ===&lt;br /&gt;
&lt;br /&gt;
The recommended partition for this is &amp;lt;tt&amp;gt;mmcblk0p11&amp;lt;/tt&amp;gt; aka &amp;lt;tt&amp;gt;/cache&amp;lt;/tt&amp;gt;. It is large and already formatted as &amp;lt;tt&amp;gt;ext4&amp;lt;/tt&amp;gt;, so it is readable from U-Boot. Here are some general steps:&lt;br /&gt;
&lt;br /&gt;
# From the UART or adb shell, set up your chroot in &amp;lt;tt&amp;gt;/cache&amp;lt;/tt&amp;gt;. I used the Alpine Linux rootfs tarball.&lt;br /&gt;
# Copy in your kernel and DTB, using for example &amp;lt;tt&amp;gt;scp&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;wget&amp;lt;/tt&amp;gt; inside the chroot.&lt;br /&gt;
# Finally, create and boot an &amp;lt;code&amp;gt;extlinux.conf&amp;lt;/code&amp;gt; as described below.&lt;br /&gt;
&lt;br /&gt;
=== With Repartitioning ===&lt;br /&gt;
&lt;br /&gt;
It is possible to shrink the &amp;lt;tt&amp;gt;userdata&amp;lt;/tt&amp;gt; partition, and create a new partition at the end for use with mainline Linux. This provides much more space than &amp;lt;tt&amp;gt;cache&amp;lt;/tt&amp;gt;. However, because &amp;lt;tt&amp;gt;userdata&amp;lt;/tt&amp;gt; is formatted with &amp;lt;tt&amp;gt;f2fs&amp;lt;/tt&amp;gt;, and that filesystem cannot be shrunk, resizing the partition requires wiping &amp;lt;tt&amp;gt;userdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
# Back up any necessary files from userdata&lt;br /&gt;
# Boot to a mainline kernel from &amp;lt;tt&amp;gt;mmcblk0p11&amp;lt;/tt&amp;gt;, either using that partition as rootfs (see above), or using an initramfs with repartitioning tools&lt;br /&gt;
# Modify the partition table with your favorite tool, e.g. &amp;lt;tt&amp;gt;fdisk&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gdisk&amp;lt;/tt&amp;gt;, or &amp;lt;tt&amp;gt;parted&amp;lt;/tt&amp;gt;&lt;br /&gt;
# Reboot into &amp;lt;tt&amp;gt;fastboot&amp;lt;/tt&amp;gt; and wipe &amp;lt;tt&amp;gt;userdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# Reboot into Android, where you can now chroot in and install your favorite distribution to the new partition.&lt;br /&gt;
&lt;br /&gt;
== Using rkdeveloptool ==&lt;br /&gt;
&lt;br /&gt;
=== Building Downstream U-Boot ===&lt;br /&gt;
&lt;br /&gt;
While in maskrom mode, we need to have a u-boot to download onto the device for any of the other commands to work. To build you'll also need to install device-tree-compiler.&lt;br /&gt;
&lt;br /&gt;
You also need to install Python and pyelftools.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Note that rkbin is a &amp;amp;gt;5GB download!&amp;lt;/b&amp;gt; This will take some time to clone and process the deltas.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone -b quartz64 https://gitlab.com/pgwipeout/u-boot-rockchip.git&lt;br /&gt;
git clone -b rkbin https://github.com/JeffyCN/rockchip_mirrors.git rkbin&lt;br /&gt;
cd u-boot-rockchip&lt;br /&gt;
# If using Arch Linux, export CROSS_COMPILE=aarch64-linux-gnu-&lt;br /&gt;
export CROSS_COMPILE=aarch64-none-linux-gnu-&lt;br /&gt;
make rk3566-quartz64_defconfig&lt;br /&gt;
./make.sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
In the current version (current as of 2022-01-02), there might have to be made a change to one line to get a clean compilation:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
diff --git a/lib/avb/libavb/avb_slot_verify.c b/lib/avb/libavb/avb_slot_verify.c&lt;br /&gt;
index 123701fc3b..64a1ce6450 100644&lt;br /&gt;
--- a/lib/avb/libavb/avb_slot_verify.c&lt;br /&gt;
+++ b/lib/avb/libavb/avb_slot_verify.c&lt;br /&gt;
@@ -296,7 +296,7 @@ static AvbSlotVerifyResult load_and_verify_hash_partition(&lt;br /&gt;
   bool image_preloaded = false;&lt;br /&gt;
   uint8_t* digest;&lt;br /&gt;
   size_t digest_len;&lt;br /&gt;
-  const char* found;&lt;br /&gt;
+  const char* found = NULL;&lt;br /&gt;
   uint64_t image_size;&lt;br /&gt;
   size_t expected_digest_len = 0;&lt;br /&gt;
   uint8_t expected_digest_buf[AVB_SHA512_DIGEST_SIZE];&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For systems where the global python executable points to python2, compilation fails with an error related to pyelftools not being installed (even if it is). To fix this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
diff --git a/make.sh b/make.sh&lt;br /&gt;
index 2bba05b4e4..cfe5b0afd5 100755&lt;br /&gt;
--- a/make.sh&lt;br /&gt;
+++ b/make.sh&lt;br /&gt;
@@ -758,7 +758,7 @@ function pack_fit_image()&lt;br /&gt;
        fi&lt;br /&gt;
 &lt;br /&gt;
        if [ &amp;quot;${ARM64_TRUSTZONE}&amp;quot; == &amp;quot;y&amp;quot; ]; then&lt;br /&gt;
-               if ! python -c &amp;quot;import elftools&amp;quot; ; then&lt;br /&gt;
+               if ! python3 -c &amp;quot;import elftools&amp;quot; ; then&lt;br /&gt;
                        echo &amp;quot;ERROR: No python 'pyelftools', please: pip install pyelftools&amp;quot;&lt;br /&gt;
                        exit 1&lt;br /&gt;
                fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can now download u-boot onto the PineNote:&lt;br /&gt;
&lt;br /&gt;
 ./rkdeveloptool boot ../u-boot-rockchip/rk356x_spl_loader_v1.08.111.bin&lt;br /&gt;
&lt;br /&gt;
This should output &amp;quot;''Downloading bootloader succeeded''&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
We can now verify that this worked using e.g. the &amp;quot;read flash info&amp;quot; command:&lt;br /&gt;
&lt;br /&gt;
 ./rkdeveloptool read-flash-info&lt;br /&gt;
&lt;br /&gt;
{{Note|'''TODO:''' Section needs to be finished}}&lt;br /&gt;
&lt;br /&gt;
=== Creating a mainline boot image ===&lt;br /&gt;
&lt;br /&gt;
You can create a filesystem image that replaces the Android boot or recovery partition by doing roughly the following:&lt;br /&gt;
&lt;br /&gt;
# Erase boot and dtbo with rkdeveloptool or fastboot (back them up first!!!)&lt;br /&gt;
# Create an ext2 partition image and mount it (fallocate, mkfs.ext2)&lt;br /&gt;
# Build your mainline kernel&lt;br /&gt;
# Copy the kernel, dtb and an initramfs to the root of the mounted image (use any old postmarketOS initramfs)&lt;br /&gt;
# Create a file in the root of the mounted image called &amp;lt;code&amp;gt;extlinux.conf&amp;lt;/code&amp;gt; as described below&lt;br /&gt;
# Unmount the image and then use rkdeveloptool to flash it to the &amp;quot;recovery&amp;quot; partition on the pinenote (it's about the right size until we get around to replacing the partition layout).&lt;br /&gt;
&lt;br /&gt;
== Using fastboot ==&lt;br /&gt;
&lt;br /&gt;
Follow the steps for [[PineNote Development/Flashing#Creating a mainline boot image|Creating a mainline boot image]], but instead of flashing it with ''rkdeveloptool'', use ''fastboot''. You can enter fastboot in either of two ways:&lt;br /&gt;
&lt;br /&gt;
* Use &amp;quot;reboot bootloader&amp;quot; from adb or a UART console or&lt;br /&gt;
* get a U-Boot prompt and run &amp;lt;code&amp;gt;fastboot usb 0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:PineNote]]&lt;/div&gt;</summary>
		<author><name>Ahelwer</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PineNote_Development/Flashing&amp;diff=20995</id>
		<title>PineNote Development/Flashing</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PineNote_Development/Flashing&amp;diff=20995"/>
		<updated>2023-10-23T15:57:45Z</updated>

		<summary type="html">&lt;p&gt;Ahelwer: /* Taking the backup */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Under construction}}&lt;br /&gt;
&lt;br /&gt;
{{Info|These instructions are directed towards experienced developers only!}}&lt;br /&gt;
&lt;br /&gt;
This page contains information on flashing software to the [[PineNote]].&lt;br /&gt;
&lt;br /&gt;
Currently, software can be flashed using rkdeveloptool or from the factory Android installation (UART shell, adb, or fastboot).&lt;br /&gt;
&lt;br /&gt;
== Getting &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
Most flashing operations on the PineNote are done through &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt;, a command line utility built on libusb.&lt;br /&gt;
PINE64 maintains its own fork [https://gitlab.com/pine64-org/quartz-bsp/rkdeveloptool here] that you will need to get.&lt;br /&gt;
The repo's README contains a list of dependencies (libusb 1.0) and instructions for building the tool.&lt;br /&gt;
&lt;br /&gt;
Installing (not just building) &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; will configure PAM to elevate privileges where necessary on your system; you can configure this manually as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo cp 99-rk-rockusb.rules /etc/udev/rules.d/&lt;br /&gt;
sudo udevadm control --reload&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Entering Maskrom/Rockusb mode ==&lt;br /&gt;
&lt;br /&gt;
Interfacing with the PineNote over USB using &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; requires first booting the PineNote into [http://opensource.rock-chips.com/wiki_Rockusb an alternative operating mode] called Maskrom or Rockusb mode.&lt;br /&gt;
&lt;br /&gt;
=== Possible methods ===&lt;br /&gt;
&lt;br /&gt;
There are three possible methods of entering Maskrom/Rockusb mode:&lt;br /&gt;
&lt;br /&gt;
==== Hardware magnet switch ====&lt;br /&gt;
&lt;br /&gt;
# Connect the PineNote to your computer via USB and boot the PineNote into Android&lt;br /&gt;
# Locate &amp;amp; identify the small circular marking on the back of the PineNote, in the top right quadrant; have the PineNote pen close at hand, or any other small magnet&lt;br /&gt;
# Hold the PineNote power button to bring up the reboot/shutdown menu; select reboot, then place the PineNote face down with the &amp;quot;eraser&amp;quot; end of the pen (or your magnet) resting on the small circular marking&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Download mode.jpeg|Pen method&lt;br /&gt;
PineNoteMagnetOnBack.jpg|Magnet method&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== U-Boot terminal ====&lt;br /&gt;
This method requires a [[PineNote_Development/UART#USB_passthrough|UART dongle with passthrough]] allowing simultaneous UART &amp;amp; USB connections.&lt;br /&gt;
It is nice because you can easily switch back &amp;amp; forth between U-Boot and Rockusb without having to physically manipulate the PineNote or its connectors; this is especially helpful when trying to develop U-Boot.&lt;br /&gt;
&lt;br /&gt;
# Connect to the PineNote via UART and USB simultaneously&lt;br /&gt;
# Interrupt the U-Boot startup using &amp;lt;code&amp;gt;ctrl+c&amp;lt;/code&amp;gt; sent over UART&lt;br /&gt;
# In the U-Boot terminal over UART, run &amp;lt;code&amp;gt;rockusb 0 mmc 0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The UART terminal should print &amp;lt;code&amp;gt;RKUSB&amp;lt;/code&amp;gt; then a spinner will appear.&lt;br /&gt;
You can exit back to the U-Boot terminal by sending &amp;lt;code&amp;gt;ctrl+c&amp;lt;/code&amp;gt; again.&lt;br /&gt;
&lt;br /&gt;
==== Shorting test points ====&lt;br /&gt;
&lt;br /&gt;
If the bootloader is broken/corrupted, you cannot get to Maskrom without opening up the device (it can be opened using spudger and a bit of patience).&lt;br /&gt;
&lt;br /&gt;
Once inside, short TP1301 (GND) and TP1302 (eMMC_D0/FLASH_D0) with a small tweezers, this is how it looks on board view (credit to Caleb):&lt;br /&gt;
&lt;br /&gt;
[[File:PineNote_Maskrom_TP.png|500px]]&lt;br /&gt;
&lt;br /&gt;
=== Success ===&lt;br /&gt;
&lt;br /&gt;
No matter what approach you take, you can tell whether you succeeded by running the &amp;lt;code&amp;gt;lsusb&amp;lt;/code&amp;gt; command on your computer:&lt;br /&gt;
* If you find the entry &amp;lt;code&amp;gt;2207:0018 Fuzhou Rockchip Electronics Company rk3566_eink&amp;lt;/code&amp;gt; in the list, the process did not succeed; reboot and retry&lt;br /&gt;
* The entry &amp;lt;code&amp;gt;2207:350a Fuzhou Rockchip Electronics Company&amp;lt;/code&amp;gt; will occur if you detach then reattach the USB-C cable while the PineNote is in Maskrom/Rockusb mode; &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; won't work and you will have to do a hard reboot (hold down power button for 30 seconds to shutdown)&lt;br /&gt;
* If you find the entry &amp;lt;code&amp;gt;2207:350a Fuzhou Rockchip Electronics Company USB download gadget&amp;lt;/code&amp;gt; then the process succeeded&lt;br /&gt;
&lt;br /&gt;
You can also look at the output of the &amp;lt;code&amp;gt;rkdeveloptool list&amp;lt;/code&amp;gt; command:&lt;br /&gt;
* If this prints out &amp;lt;code&amp;gt;No devices in rockusb mode found&amp;lt;/code&amp;gt; the process did not succeed; reboot and retry&lt;br /&gt;
* If this prints out &amp;lt;code&amp;gt;DevNo=1 Vid=0x2207,Pid=0x350a,LocationID=305 Maskrom&amp;lt;/code&amp;gt; then you probably detached/reattached the USB-C cable while in Maskrom/Rockusb mode and &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; won't work; perform a hard reboot to fix&lt;br /&gt;
* If this prints out &amp;lt;code&amp;gt;DevNo=1 Vid=0x2207,Pid=0x350a,LocationID=303 Loader&amp;lt;/code&amp;gt; then the process succeeded&lt;br /&gt;
&lt;br /&gt;
=== Exiting ===&lt;br /&gt;
&lt;br /&gt;
You can boot the PineNote back into its normal mode of operation by powercycling the PineNote with its hardware power switch, or running the &amp;lt;code&amp;gt;rkdeveloptool reboot&amp;lt;/code&amp;gt; command.&lt;br /&gt;
If you used the magnetic switch method be sure to remove the pen/magnet before rebooting.&lt;br /&gt;
&lt;br /&gt;
== Backup ==&lt;br /&gt;
&lt;br /&gt;
A backup of the content of the internal eMMC before anything gets messed up is '''mandatory'''.&lt;br /&gt;
&lt;br /&gt;
Especially the ''waveform'' partition contains data '''unique''' to your PineNote and is a prime candidate for backup.&lt;br /&gt;
&lt;br /&gt;
Other partitions like U-Boot (need for any operation of the device) or the un-partitioned space at the beginning containing the GPT partition table (and presumably the VCOM setting for the e-ink display and maybe device mac addresses) contain data you may also wish to backup.&lt;br /&gt;
&lt;br /&gt;
Depending of your personal level of data hoarder you may want to backup more than this or even just everything (the large ''userdata'' partition is supposed to be able to be repopulated as empty space by Android)&lt;br /&gt;
&lt;br /&gt;
In any case it is easier to restore/extract data from a backup than not having one if you need one.&lt;br /&gt;
&lt;br /&gt;
This process was developed by Dorian Rudolph, originally described [https://github.com/DorianRudolph/pinenotes here].&lt;br /&gt;
&lt;br /&gt;
=== List partitions ===&lt;br /&gt;
&lt;br /&gt;
First, run &amp;lt;code&amp;gt;rkdeveloptool list-partitions&amp;lt;/code&amp;gt; to print out your PineNote's partitions to get an idea of what you're dealing with.&lt;br /&gt;
The stock PineNote has a fairly standard Android partition setup, including:&lt;br /&gt;
* uboot: the [https://en.wikipedia.org/wiki/Das_U-Boot U-Boot] embedded systems bootloader&lt;br /&gt;
* trust: secrets that can be encrypted with a key stored in the [https://en.wikipedia.org/wiki/Trusted_Platform_Module TPM]&lt;br /&gt;
* waveform: important files controlling the e-ink screen's state changes&lt;br /&gt;
* misc: miscellaneous files needed by the firmware&lt;br /&gt;
* dtbo: [https://en.wikipedia.org/wiki/Devicetree Device Tree Blob for Overlay], files describing the PineNote's hardware configuration&lt;br /&gt;
* vbmeta: data required for verified boot&lt;br /&gt;
* boot, security, recovery, backup, cache, metadata, super, logo, device&lt;br /&gt;
* userdata: the big one; this is where all your files are stored in the stock Android install&lt;br /&gt;
&lt;br /&gt;
=== Patch U-Boot ===&lt;br /&gt;
&lt;br /&gt;
Before we can back up our partitions, we have a problem to solve.&lt;br /&gt;
The version of U-Boot installed on the stock PineNote contains a bug where it can't dump partitions beyond 32 MB (above that limit all bytes in the dump are just &amp;lt;code&amp;gt;0xCC&amp;lt;/code&amp;gt;), meaning the PineNote must be flashed with a fixed version of U-Boot before it is possible to take a backup of the larger partitions.&lt;br /&gt;
It is possible to extract and modify the U-Boot image from your PineNote if you're interested in some light reverse-engineering (following Dorian's notes), or you can simply download a patched U-Boot image directly [https://github.com/DorianRudolph/pinenotes/blob/main/static/uboot_patched.img here].&lt;br /&gt;
&lt;br /&gt;
Once you've acquired a patched U-Boot image, run:&lt;br /&gt;
# &amp;lt;code&amp;gt;rkdeveloptool read-partition uboot uboot_backup.img&amp;lt;/code&amp;gt;&lt;br /&gt;
# &amp;lt;code&amp;gt;rkdeveloptool write-partition uboot uboot_patched.img&amp;lt;/code&amp;gt;&lt;br /&gt;
# &amp;lt;code&amp;gt;rkdeveloptool reboot&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Taking the backup ===&lt;br /&gt;
&lt;br /&gt;
There is a second backup limit preventing dumping partitions larger than 2 GB, this time from &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt;.&lt;br /&gt;
This means if you have a large number of documents in the Android userdata partition they might not all make it into the backup.&lt;br /&gt;
If you don't have many documents (or don't care about losing them) this should not be a problem.&lt;br /&gt;
If you do have a lot of documents, workarounds include:&lt;br /&gt;
* A possible patch written by Thomas exists [https://github.com/tpwrules/nixos-pinenote/blob/96d2c9158edb9da59afcb952cc864fada18382f9/nix/rkdeveloptool/0001-fix-large-dumps.patch here] but has not yet been upstreamed; consider investigating how to get the patch tested &amp;amp; upstreamed, or just apply it to your own local copy of &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt;&lt;br /&gt;
* Use [https://github.com/talpadk/pinenote-backup this] Python script written by Visti Andresen (talpadk) to automatically backup your entire partition by splitting reads into 2 GB chunks&lt;br /&gt;
&lt;br /&gt;
See [https://github.com/m-weigand/pinenote-debian-recipes/releases/tag/v0.1 instructions on this artifact]. It will instruct you on extracting the rootfs into an empty ext4 partition. This can be done from Linux or Android. Further instructions on building your own rootfs [https://github.com/m-weigand/pinenote-debian-recipes can be found here].&lt;br /&gt;
&lt;br /&gt;
=== Using a user installed Linux ===&lt;br /&gt;
A Linux installed to the cache partition should be able to easily backup everything over WiFi or to a USB stick/disk using ''dd''.&lt;br /&gt;
&lt;br /&gt;
However the user would need to backup the cache partition themself (if they want that).&lt;br /&gt;
&lt;br /&gt;
And more importantly they would only be getting the backup ''after'' they started playing with the content of the eMMC.&lt;br /&gt;
&lt;br /&gt;
== Side-by-side setup ==&lt;br /&gt;
&lt;br /&gt;
It is possible to set up a partition for mainline development without disturbing the factory Android installation. This allows updating a mainline kernel, DTB, and initramfs over Wi-Fi until WiFi or USB OTG is working in mainline Linux.&lt;br /&gt;
&lt;br /&gt;
=== Without Repartitioning ===&lt;br /&gt;
&lt;br /&gt;
The recommended partition for this is &amp;lt;tt&amp;gt;mmcblk0p11&amp;lt;/tt&amp;gt; aka &amp;lt;tt&amp;gt;/cache&amp;lt;/tt&amp;gt;. It is large and already formatted as &amp;lt;tt&amp;gt;ext4&amp;lt;/tt&amp;gt;, so it is readable from U-Boot. Here are some general steps:&lt;br /&gt;
&lt;br /&gt;
# From the UART or adb shell, set up your chroot in &amp;lt;tt&amp;gt;/cache&amp;lt;/tt&amp;gt;. I used the Alpine Linux rootfs tarball.&lt;br /&gt;
# Copy in your kernel and DTB, using for example &amp;lt;tt&amp;gt;scp&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;wget&amp;lt;/tt&amp;gt; inside the chroot.&lt;br /&gt;
# Finally, create and boot an &amp;lt;code&amp;gt;extlinux.conf&amp;lt;/code&amp;gt; as described below.&lt;br /&gt;
&lt;br /&gt;
=== With Repartitioning ===&lt;br /&gt;
&lt;br /&gt;
It is possible to shrink the &amp;lt;tt&amp;gt;userdata&amp;lt;/tt&amp;gt; partition, and create a new partition at the end for use with mainline Linux. This provides much more space than &amp;lt;tt&amp;gt;cache&amp;lt;/tt&amp;gt;. However, because &amp;lt;tt&amp;gt;userdata&amp;lt;/tt&amp;gt; is formatted with &amp;lt;tt&amp;gt;f2fs&amp;lt;/tt&amp;gt;, and that filesystem cannot be shrunk, resizing the partition requires wiping &amp;lt;tt&amp;gt;userdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
# Back up any necessary files from userdata&lt;br /&gt;
# Boot to a mainline kernel from &amp;lt;tt&amp;gt;mmcblk0p11&amp;lt;/tt&amp;gt;, either using that partition as rootfs (see above), or using an initramfs with repartitioning tools&lt;br /&gt;
# Modify the partition table with your favorite tool, e.g. &amp;lt;tt&amp;gt;fdisk&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gdisk&amp;lt;/tt&amp;gt;, or &amp;lt;tt&amp;gt;parted&amp;lt;/tt&amp;gt;&lt;br /&gt;
# Reboot into &amp;lt;tt&amp;gt;fastboot&amp;lt;/tt&amp;gt; and wipe &amp;lt;tt&amp;gt;userdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# Reboot into Android, where you can now chroot in and install your favorite distribution to the new partition.&lt;br /&gt;
&lt;br /&gt;
== Using rkdeveloptool ==&lt;br /&gt;
&lt;br /&gt;
=== Building Downstream U-Boot ===&lt;br /&gt;
&lt;br /&gt;
While in maskrom mode, we need to have a u-boot to download onto the device for any of the other commands to work. To build you'll also need to install device-tree-compiler.&lt;br /&gt;
&lt;br /&gt;
You also need to install Python and pyelftools.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Note that rkbin is a &amp;amp;gt;5GB download!&amp;lt;/b&amp;gt; This will take some time to clone and process the deltas.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone -b quartz64 https://gitlab.com/pgwipeout/u-boot-rockchip.git&lt;br /&gt;
git clone -b rkbin https://github.com/JeffyCN/rockchip_mirrors.git rkbin&lt;br /&gt;
cd u-boot-rockchip&lt;br /&gt;
# If using Arch Linux, export CROSS_COMPILE=aarch64-linux-gnu-&lt;br /&gt;
export CROSS_COMPILE=aarch64-none-linux-gnu-&lt;br /&gt;
make rk3566-quartz64_defconfig&lt;br /&gt;
./make.sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
In the current version (current as of 2022-01-02), there might have to be made a change to one line to get a clean compilation:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
diff --git a/lib/avb/libavb/avb_slot_verify.c b/lib/avb/libavb/avb_slot_verify.c&lt;br /&gt;
index 123701fc3b..64a1ce6450 100644&lt;br /&gt;
--- a/lib/avb/libavb/avb_slot_verify.c&lt;br /&gt;
+++ b/lib/avb/libavb/avb_slot_verify.c&lt;br /&gt;
@@ -296,7 +296,7 @@ static AvbSlotVerifyResult load_and_verify_hash_partition(&lt;br /&gt;
   bool image_preloaded = false;&lt;br /&gt;
   uint8_t* digest;&lt;br /&gt;
   size_t digest_len;&lt;br /&gt;
-  const char* found;&lt;br /&gt;
+  const char* found = NULL;&lt;br /&gt;
   uint64_t image_size;&lt;br /&gt;
   size_t expected_digest_len = 0;&lt;br /&gt;
   uint8_t expected_digest_buf[AVB_SHA512_DIGEST_SIZE];&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For systems where the global python executable points to python2, compilation fails with an error related to pyelftools not being installed (even if it is). To fix this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
diff --git a/make.sh b/make.sh&lt;br /&gt;
index 2bba05b4e4..cfe5b0afd5 100755&lt;br /&gt;
--- a/make.sh&lt;br /&gt;
+++ b/make.sh&lt;br /&gt;
@@ -758,7 +758,7 @@ function pack_fit_image()&lt;br /&gt;
        fi&lt;br /&gt;
 &lt;br /&gt;
        if [ &amp;quot;${ARM64_TRUSTZONE}&amp;quot; == &amp;quot;y&amp;quot; ]; then&lt;br /&gt;
-               if ! python -c &amp;quot;import elftools&amp;quot; ; then&lt;br /&gt;
+               if ! python3 -c &amp;quot;import elftools&amp;quot; ; then&lt;br /&gt;
                        echo &amp;quot;ERROR: No python 'pyelftools', please: pip install pyelftools&amp;quot;&lt;br /&gt;
                        exit 1&lt;br /&gt;
                fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can now download u-boot onto the PineNote:&lt;br /&gt;
&lt;br /&gt;
 ./rkdeveloptool boot ../u-boot-rockchip/rk356x_spl_loader_v1.08.111.bin&lt;br /&gt;
&lt;br /&gt;
This should output &amp;quot;''Downloading bootloader succeeded''&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
We can now verify that this worked using e.g. the &amp;quot;read flash info&amp;quot; command:&lt;br /&gt;
&lt;br /&gt;
 ./rkdeveloptool read-flash-info&lt;br /&gt;
&lt;br /&gt;
{{Note|'''TODO:''' Section needs to be finished}}&lt;br /&gt;
&lt;br /&gt;
=== Creating a mainline boot image ===&lt;br /&gt;
&lt;br /&gt;
You can create a filesystem image that replaces the Android boot or recovery partition by doing roughly the following:&lt;br /&gt;
&lt;br /&gt;
# Erase boot and dtbo with rkdeveloptool or fastboot (back them up first!!!)&lt;br /&gt;
# Create an ext2 partition image and mount it (fallocate, mkfs.ext2)&lt;br /&gt;
# Build your mainline kernel&lt;br /&gt;
# Copy the kernel, dtb and an initramfs to the root of the mounted image (use any old postmarketOS initramfs)&lt;br /&gt;
# Create a file in the root of the mounted image called &amp;lt;code&amp;gt;extlinux.conf&amp;lt;/code&amp;gt; as described below&lt;br /&gt;
# Unmount the image and then use rkdeveloptool to flash it to the &amp;quot;recovery&amp;quot; partition on the pinenote (it's about the right size until we get around to replacing the partition layout).&lt;br /&gt;
&lt;br /&gt;
== Using fastboot ==&lt;br /&gt;
&lt;br /&gt;
Follow the steps for [[PineNote Development/Flashing#Creating a mainline boot image|Creating a mainline boot image]], but instead of flashing it with ''rkdeveloptool'', use ''fastboot''. You can enter fastboot in either of two ways:&lt;br /&gt;
&lt;br /&gt;
* Use &amp;quot;reboot bootloader&amp;quot; from adb or a UART console or&lt;br /&gt;
* get a U-Boot prompt and run &amp;lt;code&amp;gt;fastboot usb 0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:PineNote]]&lt;/div&gt;</summary>
		<author><name>Ahelwer</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PineNote_Development/Flashing&amp;diff=20979</id>
		<title>PineNote Development/Flashing</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PineNote_Development/Flashing&amp;diff=20979"/>
		<updated>2023-10-23T00:19:38Z</updated>

		<summary type="html">&lt;p&gt;Ahelwer: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Under construction}}&lt;br /&gt;
&lt;br /&gt;
{{Info|These instructions are directed towards experienced developers only!}}&lt;br /&gt;
&lt;br /&gt;
This page contains information on flashing software to the [[PineNote]].&lt;br /&gt;
&lt;br /&gt;
Currently, software can be flashed using rkdeveloptool or from the factory Android installation (UART shell, adb, or fastboot).&lt;br /&gt;
&lt;br /&gt;
== Getting &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
Most flashing operations on the PineNote are done through &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt;, a command line utility built on libusb.&lt;br /&gt;
PINE64 maintains its own fork [https://gitlab.com/pine64-org/quartz-bsp/rkdeveloptool here] that you will need to get.&lt;br /&gt;
The repo's README contains a list of dependencies (libusb 1.0) and instructions for building the tool.&lt;br /&gt;
&lt;br /&gt;
Installing (not just building) &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; will configure PAM to elevate privileges where necessary on your system; you can configure this manually as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo cp 99-rk-rockusb.rules /etc/udev/rules.d/&lt;br /&gt;
sudo udevadm control --reload&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Entering Maskrom/Rockusb mode ==&lt;br /&gt;
&lt;br /&gt;
Interfacing with the PineNote over USB using &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; requires first booting the PineNote into [http://opensource.rock-chips.com/wiki_Rockusb an alternative operating mode] called Maskrom or Rockusb mode.&lt;br /&gt;
&lt;br /&gt;
=== Possible methods ===&lt;br /&gt;
&lt;br /&gt;
There are three possible methods of entering Maskrom/Rockusb mode:&lt;br /&gt;
&lt;br /&gt;
==== Hardware magnet switch ====&lt;br /&gt;
&lt;br /&gt;
# Connect the PineNote to your computer via USB and boot the PineNote into Android&lt;br /&gt;
# Locate &amp;amp; identify the small circular marking on the back of the PineNote, in the top right quadrant; have the PineNote pen close at hand, or any other small magnet&lt;br /&gt;
# Hold the PineNote power button to bring up the reboot/shutdown menu; select reboot, then place the PineNote face down with the &amp;quot;eraser&amp;quot; end of the pen (or your magnet) resting on the small circular marking&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Download mode.jpeg|Pen method&lt;br /&gt;
PineNoteMagnetOnBack.jpg|Magnet method&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== U-Boot terminal ====&lt;br /&gt;
This method requires a [[PineNote_Development/UART#USB_passthrough|UART dongle with passthrough]] allowing simultaneous UART &amp;amp; USB connections.&lt;br /&gt;
It is nice because you can easily switch back &amp;amp; forth between U-Boot and Rockusb without having to physically manipulate the PineNote or its connectors; this is especially helpful when trying to develop U-Boot.&lt;br /&gt;
&lt;br /&gt;
# Connect to the PineNote via UART and USB simultaneously&lt;br /&gt;
# Interrupt the U-Boot startup using &amp;lt;code&amp;gt;ctrl+c&amp;lt;/code&amp;gt; sent over UART&lt;br /&gt;
# In the U-Boot terminal over UART, run &amp;lt;code&amp;gt;rockusb 0 mmc 0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The UART terminal should print &amp;lt;code&amp;gt;RKUSB&amp;lt;/code&amp;gt; then a spinner will appear.&lt;br /&gt;
You can exit back to the U-Boot terminal by sending &amp;lt;code&amp;gt;ctrl+c&amp;lt;/code&amp;gt; again.&lt;br /&gt;
&lt;br /&gt;
==== Shorting test points ====&lt;br /&gt;
&lt;br /&gt;
If the bootloader is broken/corrupted, you cannot get to Maskrom without opening up the device (it can be opened using spudger and a bit of patience).&lt;br /&gt;
&lt;br /&gt;
Once inside, short TP1301 (GND) and TP1302 (eMMC_D0/FLASH_D0) with a small tweezers, this is how it looks on board view (credit to Caleb):&lt;br /&gt;
&lt;br /&gt;
[[File:PineNote_Maskrom_TP.png|500px]]&lt;br /&gt;
&lt;br /&gt;
=== Success ===&lt;br /&gt;
&lt;br /&gt;
No matter what approach you take, you can tell whether you succeeded by running the &amp;lt;code&amp;gt;lsusb&amp;lt;/code&amp;gt; command on your computer:&lt;br /&gt;
* If you find the entry &amp;lt;code&amp;gt;2207:0018 Fuzhou Rockchip Electronics Company rk3566_eink&amp;lt;/code&amp;gt; in the list, the process did not succeed; reboot and retry&lt;br /&gt;
* The entry &amp;lt;code&amp;gt;2207:350a Fuzhou Rockchip Electronics Company&amp;lt;/code&amp;gt; will occur if you detach then reattach the USB-C cable while the PineNote is in Maskrom/Rockusb mode; &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; won't work and you will have to do a hard reboot (hold down power button for 30 seconds to shutdown)&lt;br /&gt;
* If you find the entry &amp;lt;code&amp;gt;2207:350a Fuzhou Rockchip Electronics Company USB download gadget&amp;lt;/code&amp;gt; then the process succeeded&lt;br /&gt;
&lt;br /&gt;
You can also look at the output of the &amp;lt;code&amp;gt;rkdeveloptool list&amp;lt;/code&amp;gt; command:&lt;br /&gt;
* If this prints out &amp;lt;code&amp;gt;No devices in rockusb mode found&amp;lt;/code&amp;gt; the process did not succeed; reboot and retry&lt;br /&gt;
* If this prints out &amp;lt;code&amp;gt;DevNo=1 Vid=0x2207,Pid=0x350a,LocationID=305 Maskrom&amp;lt;/code&amp;gt; then you probably detached/reattached the USB-C cable while in Maskrom/Rockusb mode and &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; won't work; perform a hard reboot to fix&lt;br /&gt;
* If this prints out &amp;lt;code&amp;gt;DevNo=1 Vid=0x2207,Pid=0x350a,LocationID=303 Loader&amp;lt;/code&amp;gt; then the process succeeded&lt;br /&gt;
&lt;br /&gt;
=== Exiting ===&lt;br /&gt;
&lt;br /&gt;
You can boot the PineNote back into its normal mode of operation by powercycling the PineNote with its hardware power switch, or running the &amp;lt;code&amp;gt;rkdeveloptool reboot&amp;lt;/code&amp;gt; command.&lt;br /&gt;
If you used the magnetic switch method be sure to remove the pen/magnet before rebooting.&lt;br /&gt;
&lt;br /&gt;
== Backup ==&lt;br /&gt;
&lt;br /&gt;
A backup of the content of the internal eMMC before anything gets messed up is '''mandatory'''.&lt;br /&gt;
&lt;br /&gt;
Especially the ''waveform'' partition contains data '''unique''' to your PineNote and is a prime candidate for backup.&lt;br /&gt;
&lt;br /&gt;
Other partitions like U-Boot (need for any operation of the device) or the un-partitioned space at the beginning containing the GPT partition table (and presumably the VCOM setting for the e-ink display and maybe device mac addresses) contain data you may also wish to backup.&lt;br /&gt;
&lt;br /&gt;
Depending of your personal level of data hoarder you may want to backup more than this or even just everything (the large ''userdata'' partition is supposed to be able to be repopulated as empty space by Android)&lt;br /&gt;
&lt;br /&gt;
In any case it is easier to restore/extract data from a backup than not having one if you need one.&lt;br /&gt;
&lt;br /&gt;
This process was developed by Dorian Rudolph, originally described [https://github.com/DorianRudolph/pinenotes here].&lt;br /&gt;
&lt;br /&gt;
=== List partitions ===&lt;br /&gt;
&lt;br /&gt;
First, run &amp;lt;code&amp;gt;rkdeveloptool list-partitions&amp;lt;/code&amp;gt; to print out your PineNote's partitions to get an idea of what you're dealing with.&lt;br /&gt;
The stock PineNote has a fairly standard Android partition setup, including:&lt;br /&gt;
* uboot: the [https://en.wikipedia.org/wiki/Das_U-Boot U-Boot] embedded systems bootloader&lt;br /&gt;
* trust: secrets that can be encrypted with a key stored in the [https://en.wikipedia.org/wiki/Trusted_Platform_Module TPM]&lt;br /&gt;
* waveform: important files controlling the e-ink screen's state changes&lt;br /&gt;
* misc: miscellaneous files needed by the firmware&lt;br /&gt;
* dtbo: [https://en.wikipedia.org/wiki/Devicetree Device Tree Blob for Overlay], files describing the PineNote's hardware configuration&lt;br /&gt;
* vbmeta: data required for verified boot&lt;br /&gt;
* boot, security, recovery, backup, cache, metadata, super, logo, device&lt;br /&gt;
* userdata: the big one; this is where all your files are stored in the stock Android install&lt;br /&gt;
&lt;br /&gt;
=== Patch U-Boot ===&lt;br /&gt;
&lt;br /&gt;
Before we can back up our partitions, we have a problem to solve.&lt;br /&gt;
The version of U-Boot installed on the stock PineNote contains a bug where it can't dump partitions beyond 32 MB (above that limit all bytes in the dump are just &amp;lt;code&amp;gt;0xCC&amp;lt;/code&amp;gt;), meaning the PineNote must be flashed with a fixed version of U-Boot before it is possible to take a backup of the larger partitions.&lt;br /&gt;
It is possible to extract and modify the U-Boot image from your PineNote if you're interested in some light reverse-engineering (following Dorian's notes), or you can simply download a patched U-Boot image directly [https://github.com/DorianRudolph/pinenotes/blob/main/static/uboot_patched.img here].&lt;br /&gt;
&lt;br /&gt;
Once you've acquired a patched U-Boot image, run:&lt;br /&gt;
# &amp;lt;code&amp;gt;rkdeveloptool read-partition uboot uboot_backup.img&amp;lt;/code&amp;gt;&lt;br /&gt;
# &amp;lt;code&amp;gt;rkdeveloptool write-partition uboot uboot_patched.img&amp;lt;/code&amp;gt;&lt;br /&gt;
# &amp;lt;code&amp;gt;rkdeveloptool reboot&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Taking the backup ===&lt;br /&gt;
&lt;br /&gt;
There is a second backup limit preventing dumping partitions larger than 2 GB, this time from &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt;.&lt;br /&gt;
This means if you have a large number of documents in the Android userdata partition they might not all make it into the backup.&lt;br /&gt;
If you don't have many documents (or don't care about losing them) this should not be a problem.&lt;br /&gt;
If you do have a lot of documents, workarounds include:&lt;br /&gt;
* A possible patch written by Thomas exists [https://github.com/tpwrules/nixos-pinenote/blob/96d2c9158edb9da59afcb952cc864fada18382f9/nix/rkdeveloptool/0001-fix-large-dumps.patch here] but has not yet been upstreamed; consider investigating how to get the patch tested &amp;amp; upstreamed, or just apply it to your own local copy of &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt;&lt;br /&gt;
* Use [https://github.com/talpadk/pinenote-backup this] Python script written by Visti Andresen to automatically backup your entire partition by splitting reads into 2 GB chunks&lt;br /&gt;
&lt;br /&gt;
See [https://github.com/m-weigand/pinenote-debian-recipes/releases/tag/v0.1 instructions on this artifact]. It will instruct you on extracting the rootfs into an empty ext4 partition. This can be done from Linux or Android. Further instructions on building your own rootfs [https://github.com/m-weigand/pinenote-debian-recipes can be found here].&lt;br /&gt;
&lt;br /&gt;
=== Using a user installed Linux ===&lt;br /&gt;
A Linux installed to the cache partition should be able to easily backup everything over WiFi or to a USB stick/disk using ''dd''.&lt;br /&gt;
&lt;br /&gt;
However the user would need to backup the cache partition themself (if they want that).&lt;br /&gt;
&lt;br /&gt;
And more importantly they would only be getting the backup ''after'' they started playing with the content of the eMMC.&lt;br /&gt;
&lt;br /&gt;
== Side-by-side setup ==&lt;br /&gt;
&lt;br /&gt;
It is possible to set up a partition for mainline development without disturbing the factory Android installation. This allows updating a mainline kernel, DTB, and initramfs over Wi-Fi until WiFi or USB OTG is working in mainline Linux.&lt;br /&gt;
&lt;br /&gt;
=== Without Repartitioning ===&lt;br /&gt;
&lt;br /&gt;
The recommended partition for this is &amp;lt;tt&amp;gt;mmcblk0p11&amp;lt;/tt&amp;gt; aka &amp;lt;tt&amp;gt;/cache&amp;lt;/tt&amp;gt;. It is large and already formatted as &amp;lt;tt&amp;gt;ext4&amp;lt;/tt&amp;gt;, so it is readable from U-Boot. Here are some general steps:&lt;br /&gt;
&lt;br /&gt;
# From the UART or adb shell, set up your chroot in &amp;lt;tt&amp;gt;/cache&amp;lt;/tt&amp;gt;. I used the Alpine Linux rootfs tarball.&lt;br /&gt;
# Copy in your kernel and DTB, using for example &amp;lt;tt&amp;gt;scp&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;wget&amp;lt;/tt&amp;gt; inside the chroot.&lt;br /&gt;
# Finally, create and boot an &amp;lt;code&amp;gt;extlinux.conf&amp;lt;/code&amp;gt; as described below.&lt;br /&gt;
&lt;br /&gt;
=== With Repartitioning ===&lt;br /&gt;
&lt;br /&gt;
It is possible to shrink the &amp;lt;tt&amp;gt;userdata&amp;lt;/tt&amp;gt; partition, and create a new partition at the end for use with mainline Linux. This provides much more space than &amp;lt;tt&amp;gt;cache&amp;lt;/tt&amp;gt;. However, because &amp;lt;tt&amp;gt;userdata&amp;lt;/tt&amp;gt; is formatted with &amp;lt;tt&amp;gt;f2fs&amp;lt;/tt&amp;gt;, and that filesystem cannot be shrunk, resizing the partition requires wiping &amp;lt;tt&amp;gt;userdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
# Back up any necessary files from userdata&lt;br /&gt;
# Boot to a mainline kernel from &amp;lt;tt&amp;gt;mmcblk0p11&amp;lt;/tt&amp;gt;, either using that partition as rootfs (see above), or using an initramfs with repartitioning tools&lt;br /&gt;
# Modify the partition table with your favorite tool, e.g. &amp;lt;tt&amp;gt;fdisk&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gdisk&amp;lt;/tt&amp;gt;, or &amp;lt;tt&amp;gt;parted&amp;lt;/tt&amp;gt;&lt;br /&gt;
# Reboot into &amp;lt;tt&amp;gt;fastboot&amp;lt;/tt&amp;gt; and wipe &amp;lt;tt&amp;gt;userdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# Reboot into Android, where you can now chroot in and install your favorite distribution to the new partition.&lt;br /&gt;
&lt;br /&gt;
== Using rkdeveloptool ==&lt;br /&gt;
&lt;br /&gt;
=== Building Downstream U-Boot ===&lt;br /&gt;
&lt;br /&gt;
While in maskrom mode, we need to have a u-boot to download onto the device for any of the other commands to work. To build you'll also need to install device-tree-compiler.&lt;br /&gt;
&lt;br /&gt;
You also need to install Python and pyelftools.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Note that rkbin is a &amp;amp;gt;5GB download!&amp;lt;/b&amp;gt; This will take some time to clone and process the deltas.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone -b quartz64 https://gitlab.com/pgwipeout/u-boot-rockchip.git&lt;br /&gt;
git clone -b rkbin https://github.com/JeffyCN/rockchip_mirrors.git rkbin&lt;br /&gt;
cd u-boot-rockchip&lt;br /&gt;
# If using Arch Linux, export CROSS_COMPILE=aarch64-linux-gnu-&lt;br /&gt;
export CROSS_COMPILE=aarch64-none-linux-gnu-&lt;br /&gt;
make rk3566-quartz64_defconfig&lt;br /&gt;
./make.sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
In the current version (current as of 2022-01-02), there might have to be made a change to one line to get a clean compilation:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
diff --git a/lib/avb/libavb/avb_slot_verify.c b/lib/avb/libavb/avb_slot_verify.c&lt;br /&gt;
index 123701fc3b..64a1ce6450 100644&lt;br /&gt;
--- a/lib/avb/libavb/avb_slot_verify.c&lt;br /&gt;
+++ b/lib/avb/libavb/avb_slot_verify.c&lt;br /&gt;
@@ -296,7 +296,7 @@ static AvbSlotVerifyResult load_and_verify_hash_partition(&lt;br /&gt;
   bool image_preloaded = false;&lt;br /&gt;
   uint8_t* digest;&lt;br /&gt;
   size_t digest_len;&lt;br /&gt;
-  const char* found;&lt;br /&gt;
+  const char* found = NULL;&lt;br /&gt;
   uint64_t image_size;&lt;br /&gt;
   size_t expected_digest_len = 0;&lt;br /&gt;
   uint8_t expected_digest_buf[AVB_SHA512_DIGEST_SIZE];&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For systems where the global python executable points to python2, compilation fails with an error related to pyelftools not being installed (even if it is). To fix this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
diff --git a/make.sh b/make.sh&lt;br /&gt;
index 2bba05b4e4..cfe5b0afd5 100755&lt;br /&gt;
--- a/make.sh&lt;br /&gt;
+++ b/make.sh&lt;br /&gt;
@@ -758,7 +758,7 @@ function pack_fit_image()&lt;br /&gt;
        fi&lt;br /&gt;
 &lt;br /&gt;
        if [ &amp;quot;${ARM64_TRUSTZONE}&amp;quot; == &amp;quot;y&amp;quot; ]; then&lt;br /&gt;
-               if ! python -c &amp;quot;import elftools&amp;quot; ; then&lt;br /&gt;
+               if ! python3 -c &amp;quot;import elftools&amp;quot; ; then&lt;br /&gt;
                        echo &amp;quot;ERROR: No python 'pyelftools', please: pip install pyelftools&amp;quot;&lt;br /&gt;
                        exit 1&lt;br /&gt;
                fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can now download u-boot onto the PineNote:&lt;br /&gt;
&lt;br /&gt;
 ./rkdeveloptool boot ../u-boot-rockchip/rk356x_spl_loader_v1.08.111.bin&lt;br /&gt;
&lt;br /&gt;
This should output &amp;quot;''Downloading bootloader succeeded''&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
We can now verify that this worked using e.g. the &amp;quot;read flash info&amp;quot; command:&lt;br /&gt;
&lt;br /&gt;
 ./rkdeveloptool read-flash-info&lt;br /&gt;
&lt;br /&gt;
{{Note|'''TODO:''' Section needs to be finished}}&lt;br /&gt;
&lt;br /&gt;
=== Creating a mainline boot image ===&lt;br /&gt;
&lt;br /&gt;
You can create a filesystem image that replaces the Android boot or recovery partition by doing roughly the following:&lt;br /&gt;
&lt;br /&gt;
# Erase boot and dtbo with rkdeveloptool or fastboot (back them up first!!!)&lt;br /&gt;
# Create an ext2 partition image and mount it (fallocate, mkfs.ext2)&lt;br /&gt;
# Build your mainline kernel&lt;br /&gt;
# Copy the kernel, dtb and an initramfs to the root of the mounted image (use any old postmarketOS initramfs)&lt;br /&gt;
# Create a file in the root of the mounted image called &amp;lt;code&amp;gt;extlinux.conf&amp;lt;/code&amp;gt; as described below&lt;br /&gt;
# Unmount the image and then use rkdeveloptool to flash it to the &amp;quot;recovery&amp;quot; partition on the pinenote (it's about the right size until we get around to replacing the partition layout).&lt;br /&gt;
&lt;br /&gt;
== Using fastboot ==&lt;br /&gt;
&lt;br /&gt;
Follow the steps for [[PineNote Development/Flashing#Creating a mainline boot image|Creating a mainline boot image]], but instead of flashing it with ''rkdeveloptool'', use ''fastboot''. You can enter fastboot in either of two ways:&lt;br /&gt;
&lt;br /&gt;
* Use &amp;quot;reboot bootloader&amp;quot; from adb or a UART console or&lt;br /&gt;
* get a U-Boot prompt and run &amp;lt;code&amp;gt;fastboot usb 0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:PineNote]]&lt;/div&gt;</summary>
		<author><name>Ahelwer</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PineNote_Development/UART&amp;diff=20909</id>
		<title>PineNote Development/UART</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PineNote_Development/UART&amp;diff=20909"/>
		<updated>2023-10-14T21:17:02Z</updated>

		<summary type="html">&lt;p&gt;Ahelwer: /* Using the dongle */ fixed link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Pinenote-uart-dongle.jpeg|thumb|Basic non-stock PineNote UART dongle]]&lt;br /&gt;
&lt;br /&gt;
This page contains information on creating and using a [https://en.wikipedia.org/wiki/Universal_asynchronous_receiver-transmitter UART] dongle for the [[PineNote]].&lt;br /&gt;
The PineNote was shipped with a compatible UART dongle, but replacements are not available to order in case of loss or hardware fault.&lt;br /&gt;
Thankfully it is not difficult to make your own from easily-acquired components and a small bit of soldering.&lt;br /&gt;
&lt;br /&gt;
Fear not if you've never soldered anything before!&lt;br /&gt;
This serves as an excellent first soldering project.&lt;br /&gt;
Borrow the tools from a friend, local hackerspace, or tool library.&lt;br /&gt;
Pine64 also makes [[Pinecil|a nice soldering iron]] themselves.&lt;br /&gt;
&lt;br /&gt;
A PineNote UART dongle enables you to:&lt;br /&gt;
# Interact with the system boot menu&lt;br /&gt;
# Read system events in real time as the PineNote is used&lt;br /&gt;
# Fix the PineNote without opening the case if something goes wrong while [[PineNote Development/Flashing|flashing it]]&lt;br /&gt;
&lt;br /&gt;
Since the PineNote is an embedded system, interfacing with it during boot is more complicated than with an ordinary computer.&lt;br /&gt;
The UART dongle enables you to do this.&lt;br /&gt;
&lt;br /&gt;
The PineNote factory firmware runs UART at a baud rate of 1500000 bps, 8 data bits, 1 stop bit, no parity and no flow control.&lt;br /&gt;
The process by which the PineNote design was modified to include closed-case UART is documented [[PineNote/Hardware Changes/Closed Case UART|here]].&lt;br /&gt;
&lt;br /&gt;
== Stock dongle ==&lt;br /&gt;
&lt;br /&gt;
The stock UART dongle included with the PineNote was a simple device plugging directly into the PineNote's USB-C port.&lt;br /&gt;
The dongle exposed a female USB-C port, which the user plugged into to get UART access.&lt;br /&gt;
This design unfortunately ruled out passthrough USB connections, where the user connects to the PineNote via UART and USB simultaneously.&lt;br /&gt;
The dongle is not currently available for purchase.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Pinenote-stock-uart-dongle-front.jpg|Front&lt;br /&gt;
Pinenote-stock-uart-dongle-back.jpg|Back&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Creating a dongle ==&lt;br /&gt;
&lt;br /&gt;
A typical self-built PineNote UART dongle design has the following components:&lt;br /&gt;
# A USB-C breakout board with a male connector exposing the 24 pins of the PineNote's USB-C port&lt;br /&gt;
# A USB-UART adapter, to plug into a USB port of the computer you'll use to interface with the PineNote&lt;br /&gt;
# [https://en.wikipedia.org/wiki/Jump_wire Jump wires] to connect specific breakout board pins to pins on the USB-UART adapter&lt;br /&gt;
# Two 1,000 Ohm through-hole resistors to splice into the jump wires&lt;br /&gt;
# Electrical tape or heat shrink to wrap connectors and prevent shorts&lt;br /&gt;
&lt;br /&gt;
You will also need the following tools:&lt;br /&gt;
# Soldering iron with solder&lt;br /&gt;
# Wire cutters &amp;amp; strippers&lt;br /&gt;
&lt;br /&gt;
The PineNote's internal UART system is documented in [https://files.pine64.org/doc/PineNote/PineNote_USB-C_Console_UART_breakout_board_schematic_v1.0_20210903.pdf this schematic].&lt;br /&gt;
The purpose of all 24 USB-C pins is documented [https://en.wikipedia.org/wiki/USB-C#Receptacles on the USB-C Wikipedia page].&lt;br /&gt;
We are interested in three sets of pins:&lt;br /&gt;
# The SBU1 (A8) and SBU2 (B8) side band use pins&lt;br /&gt;
# The CC1 (A5) and CC2 (B5) configuration channel pins&lt;br /&gt;
# The GND [https://en.wikipedia.org/wiki/Ground_(electricity) ground return] pins (A1, A12, B1, and B12)&lt;br /&gt;
&lt;br /&gt;
In the PineNote UART schematic you can see (on the bottom right diagram labeled &amp;lt;code&amp;gt;USB_TYPEC_Male&amp;lt;/code&amp;gt;) the side band pins are given the labels &amp;lt;code&amp;gt;UART2_TX_SUB1&amp;lt;/code&amp;gt; for A8 and &amp;lt;code&amp;gt;UART2_RX_SUB2&amp;lt;/code&amp;gt; for B8.&lt;br /&gt;
The first (TX) is used for transmitting data and the second (RX) is used for receiving data, from the perspective of the PineNote.&lt;br /&gt;
Also note the configuration channel pins labeled &amp;lt;code&amp;gt;TYPEC_CC1&amp;lt;/code&amp;gt; for A5 and &amp;lt;code&amp;gt;TYPEC_CC2&amp;lt;/code&amp;gt; for B5.&lt;br /&gt;
The diagram shows they must be connected to a 3.3V source in parallel, mediated by resistors.&lt;br /&gt;
Per the USB-C standard, when these pins are pulled high this indicates the device should enter [https://en.wikipedia.org/wiki/USB-C#Debug_Accessory_Mode Debug Accessory Mode]; connecting them to a voltage source &amp;amp; limiting the current with [https://www.electronics-tutorials.ws/logic/pull-up-resistor.html pull-up resistors] accomplishes this.&lt;br /&gt;
The schematic indicates 10,000 Ohm resistors, but community member Visti Andresen (talpadk) experimented and found 1,000 Ohm resistors work better.&lt;br /&gt;
Our mission is to wire up pins from a USB-UART adapter to a USB-C breakout board following these requirements.&lt;br /&gt;
&lt;br /&gt;
=== Buying components ===&lt;br /&gt;
&lt;br /&gt;
There are many possible USB-C breakout board designs available for purchase online.&lt;br /&gt;
One particularly useful design is a &amp;quot;passthrough&amp;quot; or &amp;quot;intercept&amp;quot; style, with both male and female USB-C ports.&lt;br /&gt;
This design is more versatile in case you want to reuse it in other projects, and also enables you to connect to the PineNote via UART and USB at the same time.&lt;br /&gt;
An example of this product can be found [https://pmdway.com/products/usb-3-1-type-c-male-to-female-breakout-test-board here], although you are encouraged to shop around for cheaper options.&lt;br /&gt;
If you're fine with a bit more soldering, there is a very cheap one [https://www.ebay.com/itm/275407037613 here].&lt;br /&gt;
&lt;br /&gt;
Similarly, there are many USB-UART adapter designs available.&lt;br /&gt;
These devices plug into your computer and expose a number of pins themselves, connecting to specific pins on the breakout board with jump wires.&lt;br /&gt;
It is important to get a 3.3V model, or at least a model with the option of 3.3V, as a 5V source might fry the PineNote.&lt;br /&gt;
[https://pmdway.com/products/usb-to-ttl-serial-cp2104-6-pin-converter-module Here] is one example with jump wires included, although you are again encouraged to shop around for alternatives.&lt;br /&gt;
&lt;br /&gt;
All other necessary components of our UART dongle are readily &amp;amp; cheaply available in many locations.&lt;br /&gt;
&lt;br /&gt;
=== Splicing resistors ===&lt;br /&gt;
&lt;br /&gt;
[[File:PineNote-UART-Y-pull-up-resistor-cable.jpg|thumb|The desired end result; wrap removed from resistors for illustration purposes.]]&lt;br /&gt;
&lt;br /&gt;
This is the only difficult part of the whole process.&lt;br /&gt;
Your goal is to create a Y-shaped jump wire with 1,000 Ohm through-hole resistors spliced into each of the twin arms.&lt;br /&gt;
The solitary leg will connect to a 3.3V source on your USB-UART adapter.&lt;br /&gt;
The twin arms will connect to the configuration channel pins on your USB-C breakout board.&lt;br /&gt;
Per the USB-C standard, when these pins are pulled high this indicates the device should enter [https://en.wikipedia.org/wiki/USB-C#Debug_Accessory_Mode Debug Accessory Mode]; connecting them to a voltage source &amp;amp; limiting the current with [https://www.electronics-tutorials.ws/logic/pull-up-resistor.html pull-up resistors] accomplishes this.&lt;br /&gt;
&lt;br /&gt;
For this project you'll need:&lt;br /&gt;
# A soldering iron with solder&lt;br /&gt;
# Wire cutters &amp;amp; strippers&lt;br /&gt;
# 2x jumper wires, male/female as compatible with your board designs&lt;br /&gt;
# 2x 1,000 Ohm through-hole resistors&lt;br /&gt;
# Electrical tape or heat shrink wrap&lt;br /&gt;
&lt;br /&gt;
Consider buying extra jumper wires and resistors in case you mess up.&lt;br /&gt;
Also double-check that you have 1K resistors with [https://resistorcolorcodecalc.com/ this color code calculator].&lt;br /&gt;
Although the PineNote UART schematic says to use 10K Ohm resistors, community member Visti Andresen (talpadk) experimented and found 1K is more appropriate.&lt;br /&gt;
Assemble your Y-cable as follows:&lt;br /&gt;
# Graft one jump wire onto the other to form a Y shape using [https://www.youtube.com/watch?v=KpiEfuhPqew this] technique, ensuring solitary leg end is compatible with your USB-UART adapter&lt;br /&gt;
# Splice resistors into the twin arms using [https://www.youtube.com/watch?v=RMgMVqqjPZ0 this] technique&lt;br /&gt;
# Splice remaining jump wire onto the ends of the resistors, ensuring ends are compatible with your USB-C breakout board&lt;br /&gt;
# Cover all exposed wire &amp;amp; resistors with electrical tape or heat shrink wrap&lt;br /&gt;
&lt;br /&gt;
=== Assembly ===&lt;br /&gt;
&lt;br /&gt;
Once you have acquired all necessary components, assemble the UART dongle as follows:&lt;br /&gt;
# Connect a jump wire from the GND pin on the USB-UART adapter to any one of the four GND pins on the USB-C breakout board (A1, A12, B1, or B12)&lt;br /&gt;
# Connect a jump wire from the RXD pin on the USB-UART adapter to the &amp;lt;code&amp;gt;UART2_TX_SUB1&amp;lt;/code&amp;gt; SBU1 pin on the USB-C breakout board (A8)&lt;br /&gt;
# Connect a jump wire from the TXD pin on the USB-UART adapter to the &amp;lt;code&amp;gt;UART2_RX_SUB2&amp;lt;/code&amp;gt; SBU2 pin on the USB-C breakout board (B8)&lt;br /&gt;
# Connect your Y-shaped jump wire from the 3.3V source pin on the USB-UART adapter to the CC1 and CC2 pins on the USB-C breakout board (A5 and B5)&lt;br /&gt;
# Wrap all metal connectors in electrical tape or heat shrink to prevent accidental shorts&lt;br /&gt;
&lt;br /&gt;
Be '''very certain''' of your connections for the 3.3V source and its cable, as there is a real risk of irreparably frying your PineNote if they're wrong!&lt;br /&gt;
Especially be sure you are connecting to a 3.3V source and not a 5V source.&lt;br /&gt;
&lt;br /&gt;
Note that if you mix up the TX/RX pins, it will still work but the USB-C breakout board will just plug into the PineNote upside down.&lt;br /&gt;
You can therefore choose which orientation you want by swapping the TX/RX pin connections.&lt;br /&gt;
Experience shows that RX/TX-TX/RX connections will have the PineNote face down while connected, while RX/RX-TX/TX connections will put the PineNote face up.&lt;br /&gt;
&lt;br /&gt;
== Using the dongle ==&lt;br /&gt;
&lt;br /&gt;
First, use your UART dongle to physically connect your PineNote to your computer:&lt;br /&gt;
# Plug the USB-UART adapter into one of your computer's USB ports&lt;br /&gt;
# Plug the USB-C breakout board into the USB-C port on the bottom of your PineNote; the orientation matters, so try both and remember which one works&lt;br /&gt;
&lt;br /&gt;
Once the hardware is connected, we need some program on your computer to communicate over that connection with 1500000 (1.5 million) bps, 8 data bits, 1 stop bit, no parity and no flow control.&lt;br /&gt;
Here's how you do that:&lt;br /&gt;
# Identify the USB-UART adapter in your &amp;lt;code&amp;gt;/dev&amp;lt;/code&amp;gt; directory by running &amp;lt;code&amp;gt;ls /dev&amp;lt;/code&amp;gt; with it plugged in, unplugging it, then again running &amp;lt;code&amp;gt;ls /dev&amp;lt;/code&amp;gt; and seeing what changed; it is likely to be called &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;&lt;br /&gt;
# Check your permissions; run &amp;lt;code&amp;gt;ls -l /dev/ttyUSB0&amp;lt;/code&amp;gt; to see which groups have access to the dongle (probably &amp;lt;code&amp;gt;dialout&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;uucp&amp;lt;/code&amp;gt;), and add your user to that group; remember you need to log out before group changes take effect&lt;br /&gt;
# Install [https://salsa.debian.org/minicom-team/minicom minicom] (or [https://askubuntu.com/q/40959 some other option], but the instructions below are written for &amp;lt;code&amp;gt;minicom&amp;lt;/code&amp;gt;)&lt;br /&gt;
# In a terminal window, run &amp;lt;code&amp;gt;minicom -D /dev/ttyUSB0 -b 1500000&amp;lt;/code&amp;gt; or run &amp;lt;code&amp;gt;minicom --setup&amp;lt;/code&amp;gt; to specify these settings by default&lt;br /&gt;
&lt;br /&gt;
Once the software is set up, power-cycle your PineNote; as the system boots you should see text appearing in your terminal window.&lt;br /&gt;
You can exit the session with &amp;lt;code&amp;gt;ctrl+a x&amp;lt;/code&amp;gt; then pressing &amp;lt;code&amp;gt;Enter&amp;lt;/code&amp;gt; to confirm.&lt;br /&gt;
Run &amp;lt;code&amp;gt;man minicom&amp;lt;/code&amp;gt; for more details.&lt;br /&gt;
&lt;br /&gt;
=== Sending commands ===&lt;br /&gt;
&lt;br /&gt;
Pressing &amp;lt;code&amp;gt;ctrl+a&amp;lt;/code&amp;gt; in &amp;lt;code&amp;gt;minicom&amp;lt;/code&amp;gt; enables you to send keystrokes to your PineNote.&lt;br /&gt;
The most important of these is &amp;lt;code&amp;gt;ctrl+c&amp;lt;/code&amp;gt;, which if sent during boot will put you in the U-Boot command prompt.&lt;br /&gt;
You can then type &amp;lt;code&amp;gt;help&amp;lt;/code&amp;gt; to list possible commands.&lt;br /&gt;
&lt;br /&gt;
=== Troubleshooting ===&lt;br /&gt;
&lt;br /&gt;
If you don't see any text in your terminal as the PineNote boots, or the text is garbled, try the following:&lt;br /&gt;
* Ensure your GND, RX/TX, and CC jump wires are connected to the correct pins on both the USB-UART adapter and the USB-C breakout board&lt;br /&gt;
* Connect your USB-C breakout board to your PineNote in the opposite orientation&lt;br /&gt;
* Run &amp;lt;code&amp;gt;minicom&amp;lt;/code&amp;gt; as sudo in case your user doesn't have appropriate permissions&lt;br /&gt;
* Ensure you are setting the baud rate to 1500000 (1.5 million), and (less importantly because these are probably used by default) 8 data bits, 1 stop bit, no parity and no flow control&lt;br /&gt;
&lt;br /&gt;
If you can see text but are having trouble sending &amp;lt;code&amp;gt;ctrl+c&amp;lt;/code&amp;gt; to the PineNote during boot:&lt;br /&gt;
* Be sure you're typing &amp;lt;code&amp;gt;ctrl+a&amp;lt;/code&amp;gt; first, or whatever escape sequence your terminal emulator uses&lt;br /&gt;
* Send it right as the PineNote is booting, before the loading bar appears on screen&lt;br /&gt;
* Double-check your Y-shaped pull-up resistor cable; if this isn't working properly you'll probably be able to read text but not send text&lt;br /&gt;
&lt;br /&gt;
== USB passthrough ==&lt;br /&gt;
&lt;br /&gt;
If your USB-C breakout board has a passthrough/intercept design, you can connect to your PineNote over USB and UART at the same time.&lt;br /&gt;
This can be useful when you're doing development work on the PineNote boot process so you don't have to continually reconnect cables.&lt;br /&gt;
You'll need a USB-A to USB-C cable, connecting directly from your computer's USB-A hub to your USB-C breakout board's female USB-C port.&lt;br /&gt;
It's important to connect directly from USB-A, without any intermediate USB-C components.&lt;br /&gt;
Note that connecting a live USB cable to your USB-C breakout board in this way dramatically increases the danger of frying your PineNote with a short, so you should only do this if all connectors are safely wrapped in electrical tape.&lt;br /&gt;
&lt;br /&gt;
[[Category:PineNote]]&lt;/div&gt;</summary>
		<author><name>Ahelwer</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PineNote_Development/UART&amp;diff=20908</id>
		<title>PineNote Development/UART</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PineNote_Development/UART&amp;diff=20908"/>
		<updated>2023-10-14T19:48:24Z</updated>

		<summary type="html">&lt;p&gt;Ahelwer: /* Creating a dongle */ added note about debug accessory mode&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Pinenote-uart-dongle.jpeg|thumb|Basic non-stock PineNote UART dongle]]&lt;br /&gt;
&lt;br /&gt;
This page contains information on creating and using a [https://en.wikipedia.org/wiki/Universal_asynchronous_receiver-transmitter UART] dongle for the [[PineNote]].&lt;br /&gt;
The PineNote was shipped with a compatible UART dongle, but replacements are not available to order in case of loss or hardware fault.&lt;br /&gt;
Thankfully it is not difficult to make your own from easily-acquired components and a small bit of soldering.&lt;br /&gt;
&lt;br /&gt;
Fear not if you've never soldered anything before!&lt;br /&gt;
This serves as an excellent first soldering project.&lt;br /&gt;
Borrow the tools from a friend, local hackerspace, or tool library.&lt;br /&gt;
Pine64 also makes [[Pinecil|a nice soldering iron]] themselves.&lt;br /&gt;
&lt;br /&gt;
A PineNote UART dongle enables you to:&lt;br /&gt;
# Interact with the system boot menu&lt;br /&gt;
# Read system events in real time as the PineNote is used&lt;br /&gt;
# Fix the PineNote without opening the case if something goes wrong while [[PineNote Development/Flashing|flashing it]]&lt;br /&gt;
&lt;br /&gt;
Since the PineNote is an embedded system, interfacing with it during boot is more complicated than with an ordinary computer.&lt;br /&gt;
The UART dongle enables you to do this.&lt;br /&gt;
&lt;br /&gt;
The PineNote factory firmware runs UART at a baud rate of 1500000 bps, 8 data bits, 1 stop bit, no parity and no flow control.&lt;br /&gt;
The process by which the PineNote design was modified to include closed-case UART is documented [[PineNote/Hardware Changes/Closed Case UART|here]].&lt;br /&gt;
&lt;br /&gt;
== Stock dongle ==&lt;br /&gt;
&lt;br /&gt;
The stock UART dongle included with the PineNote was a simple device plugging directly into the PineNote's USB-C port.&lt;br /&gt;
The dongle exposed a female USB-C port, which the user plugged into to get UART access.&lt;br /&gt;
This design unfortunately ruled out passthrough USB connections, where the user connects to the PineNote via UART and USB simultaneously.&lt;br /&gt;
The dongle is not currently available for purchase.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Pinenote-stock-uart-dongle-front.jpg|Front&lt;br /&gt;
Pinenote-stock-uart-dongle-back.jpg|Back&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Creating a dongle ==&lt;br /&gt;
&lt;br /&gt;
A typical self-built PineNote UART dongle design has the following components:&lt;br /&gt;
# A USB-C breakout board with a male connector exposing the 24 pins of the PineNote's USB-C port&lt;br /&gt;
# A USB-UART adapter, to plug into a USB port of the computer you'll use to interface with the PineNote&lt;br /&gt;
# [https://en.wikipedia.org/wiki/Jump_wire Jump wires] to connect specific breakout board pins to pins on the USB-UART adapter&lt;br /&gt;
# Two 1,000 Ohm through-hole resistors to splice into the jump wires&lt;br /&gt;
# Electrical tape or heat shrink to wrap connectors and prevent shorts&lt;br /&gt;
&lt;br /&gt;
You will also need the following tools:&lt;br /&gt;
# Soldering iron with solder&lt;br /&gt;
# Wire cutters &amp;amp; strippers&lt;br /&gt;
&lt;br /&gt;
The PineNote's internal UART system is documented in [https://files.pine64.org/doc/PineNote/PineNote_USB-C_Console_UART_breakout_board_schematic_v1.0_20210903.pdf this schematic].&lt;br /&gt;
The purpose of all 24 USB-C pins is documented [https://en.wikipedia.org/wiki/USB-C#Receptacles on the USB-C Wikipedia page].&lt;br /&gt;
We are interested in three sets of pins:&lt;br /&gt;
# The SBU1 (A8) and SBU2 (B8) side band use pins&lt;br /&gt;
# The CC1 (A5) and CC2 (B5) configuration channel pins&lt;br /&gt;
# The GND [https://en.wikipedia.org/wiki/Ground_(electricity) ground return] pins (A1, A12, B1, and B12)&lt;br /&gt;
&lt;br /&gt;
In the PineNote UART schematic you can see (on the bottom right diagram labeled &amp;lt;code&amp;gt;USB_TYPEC_Male&amp;lt;/code&amp;gt;) the side band pins are given the labels &amp;lt;code&amp;gt;UART2_TX_SUB1&amp;lt;/code&amp;gt; for A8 and &amp;lt;code&amp;gt;UART2_RX_SUB2&amp;lt;/code&amp;gt; for B8.&lt;br /&gt;
The first (TX) is used for transmitting data and the second (RX) is used for receiving data, from the perspective of the PineNote.&lt;br /&gt;
Also note the configuration channel pins labeled &amp;lt;code&amp;gt;TYPEC_CC1&amp;lt;/code&amp;gt; for A5 and &amp;lt;code&amp;gt;TYPEC_CC2&amp;lt;/code&amp;gt; for B5.&lt;br /&gt;
The diagram shows they must be connected to a 3.3V source in parallel, mediated by resistors.&lt;br /&gt;
Per the USB-C standard, when these pins are pulled high this indicates the device should enter [https://en.wikipedia.org/wiki/USB-C#Debug_Accessory_Mode Debug Accessory Mode]; connecting them to a voltage source &amp;amp; limiting the current with [https://www.electronics-tutorials.ws/logic/pull-up-resistor.html pull-up resistors] accomplishes this.&lt;br /&gt;
The schematic indicates 10,000 Ohm resistors, but community member Visti Andresen (talpadk) experimented and found 1,000 Ohm resistors work better.&lt;br /&gt;
Our mission is to wire up pins from a USB-UART adapter to a USB-C breakout board following these requirements.&lt;br /&gt;
&lt;br /&gt;
=== Buying components ===&lt;br /&gt;
&lt;br /&gt;
There are many possible USB-C breakout board designs available for purchase online.&lt;br /&gt;
One particularly useful design is a &amp;quot;passthrough&amp;quot; or &amp;quot;intercept&amp;quot; style, with both male and female USB-C ports.&lt;br /&gt;
This design is more versatile in case you want to reuse it in other projects, and also enables you to connect to the PineNote via UART and USB at the same time.&lt;br /&gt;
An example of this product can be found [https://pmdway.com/products/usb-3-1-type-c-male-to-female-breakout-test-board here], although you are encouraged to shop around for cheaper options.&lt;br /&gt;
If you're fine with a bit more soldering, there is a very cheap one [https://www.ebay.com/itm/275407037613 here].&lt;br /&gt;
&lt;br /&gt;
Similarly, there are many USB-UART adapter designs available.&lt;br /&gt;
These devices plug into your computer and expose a number of pins themselves, connecting to specific pins on the breakout board with jump wires.&lt;br /&gt;
It is important to get a 3.3V model, or at least a model with the option of 3.3V, as a 5V source might fry the PineNote.&lt;br /&gt;
[https://pmdway.com/products/usb-to-ttl-serial-cp2104-6-pin-converter-module Here] is one example with jump wires included, although you are again encouraged to shop around for alternatives.&lt;br /&gt;
&lt;br /&gt;
All other necessary components of our UART dongle are readily &amp;amp; cheaply available in many locations.&lt;br /&gt;
&lt;br /&gt;
=== Splicing resistors ===&lt;br /&gt;
&lt;br /&gt;
[[File:PineNote-UART-Y-pull-up-resistor-cable.jpg|thumb|The desired end result; wrap removed from resistors for illustration purposes.]]&lt;br /&gt;
&lt;br /&gt;
This is the only difficult part of the whole process.&lt;br /&gt;
Your goal is to create a Y-shaped jump wire with 1,000 Ohm through-hole resistors spliced into each of the twin arms.&lt;br /&gt;
The solitary leg will connect to a 3.3V source on your USB-UART adapter.&lt;br /&gt;
The twin arms will connect to the configuration channel pins on your USB-C breakout board.&lt;br /&gt;
Per the USB-C standard, when these pins are pulled high this indicates the device should enter [https://en.wikipedia.org/wiki/USB-C#Debug_Accessory_Mode Debug Accessory Mode]; connecting them to a voltage source &amp;amp; limiting the current with [https://www.electronics-tutorials.ws/logic/pull-up-resistor.html pull-up resistors] accomplishes this.&lt;br /&gt;
&lt;br /&gt;
For this project you'll need:&lt;br /&gt;
# A soldering iron with solder&lt;br /&gt;
# Wire cutters &amp;amp; strippers&lt;br /&gt;
# 2x jumper wires, male/female as compatible with your board designs&lt;br /&gt;
# 2x 1,000 Ohm through-hole resistors&lt;br /&gt;
# Electrical tape or heat shrink wrap&lt;br /&gt;
&lt;br /&gt;
Consider buying extra jumper wires and resistors in case you mess up.&lt;br /&gt;
Also double-check that you have 1K resistors with [https://resistorcolorcodecalc.com/ this color code calculator].&lt;br /&gt;
Although the PineNote UART schematic says to use 10K Ohm resistors, community member Visti Andresen (talpadk) experimented and found 1K is more appropriate.&lt;br /&gt;
Assemble your Y-cable as follows:&lt;br /&gt;
# Graft one jump wire onto the other to form a Y shape using [https://www.youtube.com/watch?v=KpiEfuhPqew this] technique, ensuring solitary leg end is compatible with your USB-UART adapter&lt;br /&gt;
# Splice resistors into the twin arms using [https://www.youtube.com/watch?v=RMgMVqqjPZ0 this] technique&lt;br /&gt;
# Splice remaining jump wire onto the ends of the resistors, ensuring ends are compatible with your USB-C breakout board&lt;br /&gt;
# Cover all exposed wire &amp;amp; resistors with electrical tape or heat shrink wrap&lt;br /&gt;
&lt;br /&gt;
=== Assembly ===&lt;br /&gt;
&lt;br /&gt;
Once you have acquired all necessary components, assemble the UART dongle as follows:&lt;br /&gt;
# Connect a jump wire from the GND pin on the USB-UART adapter to any one of the four GND pins on the USB-C breakout board (A1, A12, B1, or B12)&lt;br /&gt;
# Connect a jump wire from the RXD pin on the USB-UART adapter to the &amp;lt;code&amp;gt;UART2_TX_SUB1&amp;lt;/code&amp;gt; SBU1 pin on the USB-C breakout board (A8)&lt;br /&gt;
# Connect a jump wire from the TXD pin on the USB-UART adapter to the &amp;lt;code&amp;gt;UART2_RX_SUB2&amp;lt;/code&amp;gt; SBU2 pin on the USB-C breakout board (B8)&lt;br /&gt;
# Connect your Y-shaped jump wire from the 3.3V source pin on the USB-UART adapter to the CC1 and CC2 pins on the USB-C breakout board (A5 and B5)&lt;br /&gt;
# Wrap all metal connectors in electrical tape or heat shrink to prevent accidental shorts&lt;br /&gt;
&lt;br /&gt;
Be '''very certain''' of your connections for the 3.3V source and its cable, as there is a real risk of irreparably frying your PineNote if they're wrong!&lt;br /&gt;
Especially be sure you are connecting to a 3.3V source and not a 5V source.&lt;br /&gt;
&lt;br /&gt;
Note that if you mix up the TX/RX pins, it will still work but the USB-C breakout board will just plug into the PineNote upside down.&lt;br /&gt;
You can therefore choose which orientation you want by swapping the TX/RX pin connections.&lt;br /&gt;
Experience shows that RX/TX-TX/RX connections will have the PineNote face down while connected, while RX/RX-TX/TX connections will put the PineNote face up.&lt;br /&gt;
&lt;br /&gt;
== Using the dongle ==&lt;br /&gt;
&lt;br /&gt;
First, use your UART dongle to physically connect your PineNote to your computer:&lt;br /&gt;
# Plug the USB-UART adapter into one of your computer's USB ports&lt;br /&gt;
# Plug the USB-C breakout board into the USB-C port on the bottom of your PineNote; the orientation matters, so try both and remember which one works&lt;br /&gt;
&lt;br /&gt;
Once the hardware is connected, we need some program on your computer to communicate over that connection with 1500000 (1.5 million) bps, 8 data bits, 1 stop bit, no parity and no flow control.&lt;br /&gt;
Here's how you do that:&lt;br /&gt;
# Identify the USB-UART adapter in your &amp;lt;code&amp;gt;/dev&amp;lt;/code&amp;gt; directory by running &amp;lt;code&amp;gt;ls /dev&amp;lt;/code&amp;gt; with it plugged in, unplugging it, then again running &amp;lt;code&amp;gt;ls /dev&amp;lt;/code&amp;gt; and seeing what changed; it is likely to be called &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;&lt;br /&gt;
# Check your permissions; run &amp;lt;code&amp;gt;ls -l /dev/ttyUSB0&amp;lt;/code&amp;gt; to see which groups have access to the dongle (probably &amp;lt;code&amp;gt;dialout&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;uucp&amp;lt;/code&amp;gt;), and add your user to that group; remember you need to log out before group changes take effect&lt;br /&gt;
# Install [https://www.gnu.org/software/screen/ minicom] (or [https://askubuntu.com/q/40959 some other option], but the instructions below are written for &amp;lt;code&amp;gt;minicom&amp;lt;/code&amp;gt;)&lt;br /&gt;
# In a terminal window, run &amp;lt;code&amp;gt;minicom -D /dev/ttyUSB0 -b 1500000&amp;lt;/code&amp;gt; or run &amp;lt;code&amp;gt;minicom --setup&amp;lt;/code&amp;gt; to specify these settings by default&lt;br /&gt;
&lt;br /&gt;
Once the software is set up, power-cycle your PineNote; as the system boots you should see text appearing in your terminal window.&lt;br /&gt;
You can exit the session with &amp;lt;code&amp;gt;ctrl+a x&amp;lt;/code&amp;gt; then pressing &amp;lt;code&amp;gt;Enter&amp;lt;/code&amp;gt; to confirm.&lt;br /&gt;
Run &amp;lt;code&amp;gt;man minicom&amp;lt;/code&amp;gt; for more details.&lt;br /&gt;
&lt;br /&gt;
=== Sending commands ===&lt;br /&gt;
&lt;br /&gt;
Pressing &amp;lt;code&amp;gt;ctrl+a&amp;lt;/code&amp;gt; in &amp;lt;code&amp;gt;minicom&amp;lt;/code&amp;gt; enables you to send keystrokes to your PineNote.&lt;br /&gt;
The most important of these is &amp;lt;code&amp;gt;ctrl+c&amp;lt;/code&amp;gt;, which if sent during boot will put you in the U-Boot command prompt.&lt;br /&gt;
You can then type &amp;lt;code&amp;gt;help&amp;lt;/code&amp;gt; to list possible commands.&lt;br /&gt;
&lt;br /&gt;
=== Troubleshooting ===&lt;br /&gt;
&lt;br /&gt;
If you don't see any text in your terminal as the PineNote boots, or the text is garbled, try the following:&lt;br /&gt;
* Ensure your GND, RX/TX, and CC jump wires are connected to the correct pins on both the USB-UART adapter and the USB-C breakout board&lt;br /&gt;
* Connect your USB-C breakout board to your PineNote in the opposite orientation&lt;br /&gt;
* Run &amp;lt;code&amp;gt;minicom&amp;lt;/code&amp;gt; as sudo in case your user doesn't have appropriate permissions&lt;br /&gt;
* Ensure you are setting the baud rate to 1500000 (1.5 million), and (less importantly because these are probably used by default) 8 data bits, 1 stop bit, no parity and no flow control&lt;br /&gt;
&lt;br /&gt;
If you can see text but are having trouble sending &amp;lt;code&amp;gt;ctrl+c&amp;lt;/code&amp;gt; to the PineNote during boot:&lt;br /&gt;
* Be sure you're typing &amp;lt;code&amp;gt;ctrl+a&amp;lt;/code&amp;gt; first, or whatever escape sequence your terminal emulator uses&lt;br /&gt;
* Send it right as the PineNote is booting, before the loading bar appears on screen&lt;br /&gt;
* Double-check your Y-shaped pull-up resistor cable; if this isn't working properly you'll probably be able to read text but not send text&lt;br /&gt;
&lt;br /&gt;
== USB passthrough ==&lt;br /&gt;
&lt;br /&gt;
If your USB-C breakout board has a passthrough/intercept design, you can connect to your PineNote over USB and UART at the same time.&lt;br /&gt;
This can be useful when you're doing development work on the PineNote boot process so you don't have to continually reconnect cables.&lt;br /&gt;
You'll need a USB-A to USB-C cable, connecting directly from your computer's USB-A hub to your USB-C breakout board's female USB-C port.&lt;br /&gt;
It's important to connect directly from USB-A, without any intermediate USB-C components.&lt;br /&gt;
Note that connecting a live USB cable to your USB-C breakout board in this way dramatically increases the danger of frying your PineNote with a short, so you should only do this if all connectors are safely wrapped in electrical tape.&lt;br /&gt;
&lt;br /&gt;
[[Category:PineNote]]&lt;/div&gt;</summary>
		<author><name>Ahelwer</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=File:PineNote-UART-Y-pull-up-resistor-cable.jpg&amp;diff=20907</id>
		<title>File:PineNote-UART-Y-pull-up-resistor-cable.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=File:PineNote-UART-Y-pull-up-resistor-cable.jpg&amp;diff=20907"/>
		<updated>2023-10-14T19:34:18Z</updated>

		<summary type="html">&lt;p&gt;Ahelwer: Added to PineNote category&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary ==&lt;br /&gt;
Photo of a Y-shaped cable with resistors spliced into each of the twin arms.&lt;br /&gt;
== Licensing ==&lt;br /&gt;
{{CC0}}&lt;br /&gt;
[[Category:PineNote]]&lt;/div&gt;</summary>
		<author><name>Ahelwer</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PineNote_Development/UART&amp;diff=20906</id>
		<title>PineNote Development/UART</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PineNote_Development/UART&amp;diff=20906"/>
		<updated>2023-10-14T19:30:31Z</updated>

		<summary type="html">&lt;p&gt;Ahelwer: /* Using the dongle */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Pinenote-uart-dongle.jpeg|thumb|Basic non-stock PineNote UART dongle]]&lt;br /&gt;
&lt;br /&gt;
This page contains information on creating and using a [https://en.wikipedia.org/wiki/Universal_asynchronous_receiver-transmitter UART] dongle for the [[PineNote]].&lt;br /&gt;
The PineNote was shipped with a compatible UART dongle, but replacements are not available to order in case of loss or hardware fault.&lt;br /&gt;
Thankfully it is not difficult to make your own from easily-acquired components and a small bit of soldering.&lt;br /&gt;
&lt;br /&gt;
Fear not if you've never soldered anything before!&lt;br /&gt;
This serves as an excellent first soldering project.&lt;br /&gt;
Borrow the tools from a friend, local hackerspace, or tool library.&lt;br /&gt;
Pine64 also makes [[Pinecil|a nice soldering iron]] themselves.&lt;br /&gt;
&lt;br /&gt;
A PineNote UART dongle enables you to:&lt;br /&gt;
# Interact with the system boot menu&lt;br /&gt;
# Read system events in real time as the PineNote is used&lt;br /&gt;
# Fix the PineNote without opening the case if something goes wrong while [[PineNote Development/Flashing|flashing it]]&lt;br /&gt;
&lt;br /&gt;
Since the PineNote is an embedded system, interfacing with it during boot is more complicated than with an ordinary computer.&lt;br /&gt;
The UART dongle enables you to do this.&lt;br /&gt;
&lt;br /&gt;
The PineNote factory firmware runs UART at a baud rate of 1500000 bps, 8 data bits, 1 stop bit, no parity and no flow control.&lt;br /&gt;
The process by which the PineNote design was modified to include closed-case UART is documented [[PineNote/Hardware Changes/Closed Case UART|here]].&lt;br /&gt;
&lt;br /&gt;
== Stock dongle ==&lt;br /&gt;
&lt;br /&gt;
The stock UART dongle included with the PineNote was a simple device plugging directly into the PineNote's USB-C port.&lt;br /&gt;
The dongle exposed a female USB-C port, which the user plugged into to get UART access.&lt;br /&gt;
This design unfortunately ruled out passthrough USB connections, where the user connects to the PineNote via UART and USB simultaneously.&lt;br /&gt;
The dongle is not currently available for purchase.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Pinenote-stock-uart-dongle-front.jpg|Front&lt;br /&gt;
Pinenote-stock-uart-dongle-back.jpg|Back&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Creating a dongle ==&lt;br /&gt;
&lt;br /&gt;
A typical self-built PineNote UART dongle design has the following components:&lt;br /&gt;
# A USB-C breakout board with a male connector exposing the 24 pins of the PineNote's USB-C port&lt;br /&gt;
# A USB-UART adapter, to plug into a USB port of the computer you'll use to interface with the PineNote&lt;br /&gt;
# [https://en.wikipedia.org/wiki/Jump_wire Jump wires] to connect specific breakout board pins to pins on the USB-UART adapter&lt;br /&gt;
# Two 1,000 Ohm through-hole resistors to splice into the jump wires&lt;br /&gt;
# Electrical tape or heat shrink to wrap connectors and prevent shorts&lt;br /&gt;
&lt;br /&gt;
You will also need the following tools:&lt;br /&gt;
# Soldering iron with solder&lt;br /&gt;
# Wire cutters &amp;amp; strippers&lt;br /&gt;
&lt;br /&gt;
The PineNote's internal UART system is documented in [https://files.pine64.org/doc/PineNote/PineNote_USB-C_Console_UART_breakout_board_schematic_v1.0_20210903.pdf this schematic].&lt;br /&gt;
The purpose of all 24 USB-C pins is documented [https://en.wikipedia.org/wiki/USB-C#Receptacles on the USB-C Wikipedia page].&lt;br /&gt;
We are interested in three sets of pins:&lt;br /&gt;
# The SBU1 (A8) and SBU2 (B8) side band use pins&lt;br /&gt;
# The CC1 (A5) and CC2 (B5) configuration channel pins&lt;br /&gt;
# The GND [https://en.wikipedia.org/wiki/Ground_(electricity) ground return] pins (A1, A12, B1, and B12)&lt;br /&gt;
&lt;br /&gt;
In the PineNote UART schematic you can see (on the bottom right diagram labeled &amp;lt;code&amp;gt;USB_TYPEC_Male&amp;lt;/code&amp;gt;) the side band pins are given the labels &amp;lt;code&amp;gt;UART2_TX_SUB1&amp;lt;/code&amp;gt; for A8 and &amp;lt;code&amp;gt;UART2_RX_SUB2&amp;lt;/code&amp;gt; for B8.&lt;br /&gt;
The first (TX) is used for transmitting data and the second (RX) is used for receiving data, from the perspective of the PineNote.&lt;br /&gt;
Also note the configuration channel pins labeled &amp;lt;code&amp;gt;TYPEC_CC1&amp;lt;/code&amp;gt; for A5 and &amp;lt;code&amp;gt;TYPEC_CC2&amp;lt;/code&amp;gt; for B5.&lt;br /&gt;
These pins are used to signal to the PineNote that a UART dongle is present.&lt;br /&gt;
The diagram shows they must be connected to a 3.3V source in parallel, mediated by resistors.&lt;br /&gt;
The schematic indicates 10,000 Ohm resistors, but community member Visti Andresen (talpadk) experimented and found 1,000 Ohm resistors work better.&lt;br /&gt;
Our mission is to wire up pins from a USB-UART adapter to a USB-C breakout board following these requirements.&lt;br /&gt;
&lt;br /&gt;
=== Buying components ===&lt;br /&gt;
&lt;br /&gt;
There are many possible USB-C breakout board designs available for purchase online.&lt;br /&gt;
One particularly useful design is a &amp;quot;passthrough&amp;quot; or &amp;quot;intercept&amp;quot; style, with both male and female USB-C ports.&lt;br /&gt;
This design is more versatile in case you want to reuse it in other projects, and also enables you to connect to the PineNote via UART and USB at the same time.&lt;br /&gt;
An example of this product can be found [https://pmdway.com/products/usb-3-1-type-c-male-to-female-breakout-test-board here], although you are encouraged to shop around for cheaper options.&lt;br /&gt;
If you're fine with a bit more soldering, there is a very cheap one [https://www.ebay.com/itm/275407037613 here].&lt;br /&gt;
&lt;br /&gt;
Similarly, there are many USB-UART adapter designs available.&lt;br /&gt;
These devices plug into your computer and expose a number of pins themselves, connecting to specific pins on the breakout board with jump wires.&lt;br /&gt;
It is important to get a 3.3V model, or at least a model with the option of 3.3V, as a 5V source might fry the PineNote.&lt;br /&gt;
[https://pmdway.com/products/usb-to-ttl-serial-cp2104-6-pin-converter-module Here] is one example with jump wires included, although you are again encouraged to shop around for alternatives.&lt;br /&gt;
&lt;br /&gt;
All other necessary components of our UART dongle are readily &amp;amp; cheaply available in many locations.&lt;br /&gt;
&lt;br /&gt;
=== Splicing resistors ===&lt;br /&gt;
&lt;br /&gt;
[[File:PineNote-UART-Y-pull-up-resistor-cable.jpg|thumb|The desired end result; wrap removed from resistors for illustration purposes.]]&lt;br /&gt;
&lt;br /&gt;
This is the only difficult part of the whole process.&lt;br /&gt;
Your goal is to create a Y-shaped jump wire with 1,000 Ohm through-hole resistors spliced into each of the twin arms.&lt;br /&gt;
The solitary leg will connect to a 3.3V source on your USB-UART adapter.&lt;br /&gt;
The twin arms will connect to the configuration channel pins on your USB-C breakout board.&lt;br /&gt;
This setup is called using pull-up resistors, and you can read a nice introduction to their purpose [https://www.electronics-tutorials.ws/logic/pull-up-resistor.html here].&lt;br /&gt;
&lt;br /&gt;
For this project you'll need:&lt;br /&gt;
# A soldering iron with solder&lt;br /&gt;
# Wire cutters &amp;amp; strippers&lt;br /&gt;
# 2x jumper wires, male/female as compatible with your board designs&lt;br /&gt;
# 2x 1,000 Ohm through-hole resistors&lt;br /&gt;
# Electrical tape or heat shrink wrap&lt;br /&gt;
&lt;br /&gt;
Consider buying extra jumper wires and resistors in case you mess up.&lt;br /&gt;
Also double-check that you have 1K resistors with [https://resistorcolorcodecalc.com/ this color code calculator].&lt;br /&gt;
Although the PineNote UART schematic says to use 10K Ohm resistors, community member Visti Andresen (talpadk) experimented and found 1K is more appropriate.&lt;br /&gt;
Assemble your Y-cable as follows:&lt;br /&gt;
# Graft one jump wire onto the other to form a Y shape using [https://www.youtube.com/watch?v=KpiEfuhPqew this] technique, ensuring solitary leg end is compatible with your USB-UART adapter&lt;br /&gt;
# Splice resistors into the twin arms using [https://www.youtube.com/watch?v=RMgMVqqjPZ0 this] technique&lt;br /&gt;
# Splice remaining jump wire onto the ends of the resistors, ensuring ends are compatible with your USB-C breakout board&lt;br /&gt;
# Cover all exposed wire &amp;amp; resistors with electrical tape or heat shrink wrap&lt;br /&gt;
&lt;br /&gt;
=== Assembly ===&lt;br /&gt;
&lt;br /&gt;
Once you have acquired all necessary components, assemble the UART dongle as follows:&lt;br /&gt;
# Connect a jump wire from the GND pin on the USB-UART adapter to any one of the four GND pins on the USB-C breakout board (A1, A12, B1, or B12)&lt;br /&gt;
# Connect a jump wire from the RXD pin on the USB-UART adapter to the &amp;lt;code&amp;gt;UART2_TX_SUB1&amp;lt;/code&amp;gt; SBU1 pin on the USB-C breakout board (A8)&lt;br /&gt;
# Connect a jump wire from the TXD pin on the USB-UART adapter to the &amp;lt;code&amp;gt;UART2_RX_SUB2&amp;lt;/code&amp;gt; SBU2 pin on the USB-C breakout board (B8)&lt;br /&gt;
# Connect your Y-shaped jump wire from the 3.3V source pin on the USB-UART adapter to the CC1 and CC2 pins on the USB-C breakout board (A5 and B5)&lt;br /&gt;
# Wrap all metal connectors in electrical tape or heat shrink to prevent accidental shorts&lt;br /&gt;
&lt;br /&gt;
Be '''very certain''' of your connections for the 3.3V source and its cable, as there is a real risk of irreparably frying your PineNote if they're wrong!&lt;br /&gt;
Especially be sure you are connecting to a 3.3V source and not a 5V source.&lt;br /&gt;
&lt;br /&gt;
Note that if you mix up the TX/RX pins, it will still work but the USB-C breakout board will just plug into the PineNote upside down.&lt;br /&gt;
You can therefore choose which orientation you want by swapping the TX/RX pin connections.&lt;br /&gt;
Experience shows that RX/TX-TX/RX connections will have the PineNote face down while connected, while RX/RX-TX/TX connections will put the PineNote face up.&lt;br /&gt;
&lt;br /&gt;
== Using the dongle ==&lt;br /&gt;
&lt;br /&gt;
First, use your UART dongle to physically connect your PineNote to your computer:&lt;br /&gt;
# Plug the USB-UART adapter into one of your computer's USB ports&lt;br /&gt;
# Plug the USB-C breakout board into the USB-C port on the bottom of your PineNote; the orientation matters, so try both and remember which one works&lt;br /&gt;
&lt;br /&gt;
Once the hardware is connected, we need some program on your computer to communicate over that connection with 1500000 (1.5 million) bps, 8 data bits, 1 stop bit, no parity and no flow control.&lt;br /&gt;
Here's how you do that:&lt;br /&gt;
# Identify the USB-UART adapter in your &amp;lt;code&amp;gt;/dev&amp;lt;/code&amp;gt; directory by running &amp;lt;code&amp;gt;ls /dev&amp;lt;/code&amp;gt; with it plugged in, unplugging it, then again running &amp;lt;code&amp;gt;ls /dev&amp;lt;/code&amp;gt; and seeing what changed; it is likely to be called &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;&lt;br /&gt;
# Check your permissions; run &amp;lt;code&amp;gt;ls -l /dev/ttyUSB0&amp;lt;/code&amp;gt; to see which groups have access to the dongle (probably &amp;lt;code&amp;gt;dialout&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;uucp&amp;lt;/code&amp;gt;), and add your user to that group; remember you need to log out before group changes take effect&lt;br /&gt;
# Install [https://www.gnu.org/software/screen/ minicom] (or [https://askubuntu.com/q/40959 some other option], but the instructions below are written for &amp;lt;code&amp;gt;minicom&amp;lt;/code&amp;gt;)&lt;br /&gt;
# In a terminal window, run &amp;lt;code&amp;gt;minicom -D /dev/ttyUSB0 -b 1500000&amp;lt;/code&amp;gt; or run &amp;lt;code&amp;gt;minicom --setup&amp;lt;/code&amp;gt; to specify these settings by default&lt;br /&gt;
&lt;br /&gt;
Once the software is set up, power-cycle your PineNote; as the system boots you should see text appearing in your terminal window.&lt;br /&gt;
You can exit the session with &amp;lt;code&amp;gt;ctrl+a x&amp;lt;/code&amp;gt; then pressing &amp;lt;code&amp;gt;Enter&amp;lt;/code&amp;gt; to confirm.&lt;br /&gt;
Run &amp;lt;code&amp;gt;man minicom&amp;lt;/code&amp;gt; for more details.&lt;br /&gt;
&lt;br /&gt;
=== Sending commands ===&lt;br /&gt;
&lt;br /&gt;
Pressing &amp;lt;code&amp;gt;ctrl+a&amp;lt;/code&amp;gt; in &amp;lt;code&amp;gt;minicom&amp;lt;/code&amp;gt; enables you to send keystrokes to your PineNote.&lt;br /&gt;
The most important of these is &amp;lt;code&amp;gt;ctrl+c&amp;lt;/code&amp;gt;, which if sent during boot will put you in the U-Boot command prompt.&lt;br /&gt;
You can then type &amp;lt;code&amp;gt;help&amp;lt;/code&amp;gt; to list possible commands.&lt;br /&gt;
&lt;br /&gt;
=== Troubleshooting ===&lt;br /&gt;
&lt;br /&gt;
If you don't see any text in your terminal as the PineNote boots, or the text is garbled, try the following:&lt;br /&gt;
* Ensure your GND, RX/TX, and CC jump wires are connected to the correct pins on both the USB-UART adapter and the USB-C breakout board&lt;br /&gt;
* Connect your USB-C breakout board to your PineNote in the opposite orientation&lt;br /&gt;
* Run &amp;lt;code&amp;gt;minicom&amp;lt;/code&amp;gt; as sudo in case your user doesn't have appropriate permissions&lt;br /&gt;
* Ensure you are setting the baud rate to 1500000 (1.5 million), and (less importantly because these are probably used by default) 8 data bits, 1 stop bit, no parity and no flow control&lt;br /&gt;
&lt;br /&gt;
If you can see text but are having trouble sending &amp;lt;code&amp;gt;ctrl+c&amp;lt;/code&amp;gt; to the PineNote during boot:&lt;br /&gt;
* Be sure you're typing &amp;lt;code&amp;gt;ctrl+a&amp;lt;/code&amp;gt; first, or whatever escape sequence your terminal emulator uses&lt;br /&gt;
* Send it right as the PineNote is booting, before the loading bar appears on screen&lt;br /&gt;
* Double-check your Y-shaped pull-up resistor cable; if this isn't working properly you'll probably be able to read text but not send text&lt;br /&gt;
&lt;br /&gt;
== USB passthrough ==&lt;br /&gt;
&lt;br /&gt;
If your USB-C breakout board has a passthrough/intercept design, you can connect to your PineNote over USB and UART at the same time.&lt;br /&gt;
This can be useful when you're doing development work on the PineNote boot process so you don't have to continually reconnect cables.&lt;br /&gt;
You'll need a USB-A to USB-C cable, connecting directly from your computer's USB-A hub to your USB-C breakout board's female USB-C port.&lt;br /&gt;
It's important to connect directly from USB-A, without any intermediate USB-C components.&lt;br /&gt;
Note that connecting a live USB cable to your USB-C breakout board in this way dramatically increases the danger of frying your PineNote with a short, so you should only do this if all connectors are safely wrapped in electrical tape.&lt;br /&gt;
&lt;br /&gt;
[[Category:PineNote]]&lt;/div&gt;</summary>
		<author><name>Ahelwer</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PineNote_Development/UART&amp;diff=20905</id>
		<title>PineNote Development/UART</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PineNote_Development/UART&amp;diff=20905"/>
		<updated>2023-10-14T19:29:38Z</updated>

		<summary type="html">&lt;p&gt;Ahelwer: /* Using the dongle */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Pinenote-uart-dongle.jpeg|thumb|Basic non-stock PineNote UART dongle]]&lt;br /&gt;
&lt;br /&gt;
This page contains information on creating and using a [https://en.wikipedia.org/wiki/Universal_asynchronous_receiver-transmitter UART] dongle for the [[PineNote]].&lt;br /&gt;
The PineNote was shipped with a compatible UART dongle, but replacements are not available to order in case of loss or hardware fault.&lt;br /&gt;
Thankfully it is not difficult to make your own from easily-acquired components and a small bit of soldering.&lt;br /&gt;
&lt;br /&gt;
Fear not if you've never soldered anything before!&lt;br /&gt;
This serves as an excellent first soldering project.&lt;br /&gt;
Borrow the tools from a friend, local hackerspace, or tool library.&lt;br /&gt;
Pine64 also makes [[Pinecil|a nice soldering iron]] themselves.&lt;br /&gt;
&lt;br /&gt;
A PineNote UART dongle enables you to:&lt;br /&gt;
# Interact with the system boot menu&lt;br /&gt;
# Read system events in real time as the PineNote is used&lt;br /&gt;
# Fix the PineNote without opening the case if something goes wrong while [[PineNote Development/Flashing|flashing it]]&lt;br /&gt;
&lt;br /&gt;
Since the PineNote is an embedded system, interfacing with it during boot is more complicated than with an ordinary computer.&lt;br /&gt;
The UART dongle enables you to do this.&lt;br /&gt;
&lt;br /&gt;
The PineNote factory firmware runs UART at a baud rate of 1500000 bps, 8 data bits, 1 stop bit, no parity and no flow control.&lt;br /&gt;
The process by which the PineNote design was modified to include closed-case UART is documented [[PineNote/Hardware Changes/Closed Case UART|here]].&lt;br /&gt;
&lt;br /&gt;
== Stock dongle ==&lt;br /&gt;
&lt;br /&gt;
The stock UART dongle included with the PineNote was a simple device plugging directly into the PineNote's USB-C port.&lt;br /&gt;
The dongle exposed a female USB-C port, which the user plugged into to get UART access.&lt;br /&gt;
This design unfortunately ruled out passthrough USB connections, where the user connects to the PineNote via UART and USB simultaneously.&lt;br /&gt;
The dongle is not currently available for purchase.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Pinenote-stock-uart-dongle-front.jpg|Front&lt;br /&gt;
Pinenote-stock-uart-dongle-back.jpg|Back&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Creating a dongle ==&lt;br /&gt;
&lt;br /&gt;
A typical self-built PineNote UART dongle design has the following components:&lt;br /&gt;
# A USB-C breakout board with a male connector exposing the 24 pins of the PineNote's USB-C port&lt;br /&gt;
# A USB-UART adapter, to plug into a USB port of the computer you'll use to interface with the PineNote&lt;br /&gt;
# [https://en.wikipedia.org/wiki/Jump_wire Jump wires] to connect specific breakout board pins to pins on the USB-UART adapter&lt;br /&gt;
# Two 1,000 Ohm through-hole resistors to splice into the jump wires&lt;br /&gt;
# Electrical tape or heat shrink to wrap connectors and prevent shorts&lt;br /&gt;
&lt;br /&gt;
You will also need the following tools:&lt;br /&gt;
# Soldering iron with solder&lt;br /&gt;
# Wire cutters &amp;amp; strippers&lt;br /&gt;
&lt;br /&gt;
The PineNote's internal UART system is documented in [https://files.pine64.org/doc/PineNote/PineNote_USB-C_Console_UART_breakout_board_schematic_v1.0_20210903.pdf this schematic].&lt;br /&gt;
The purpose of all 24 USB-C pins is documented [https://en.wikipedia.org/wiki/USB-C#Receptacles on the USB-C Wikipedia page].&lt;br /&gt;
We are interested in three sets of pins:&lt;br /&gt;
# The SBU1 (A8) and SBU2 (B8) side band use pins&lt;br /&gt;
# The CC1 (A5) and CC2 (B5) configuration channel pins&lt;br /&gt;
# The GND [https://en.wikipedia.org/wiki/Ground_(electricity) ground return] pins (A1, A12, B1, and B12)&lt;br /&gt;
&lt;br /&gt;
In the PineNote UART schematic you can see (on the bottom right diagram labeled &amp;lt;code&amp;gt;USB_TYPEC_Male&amp;lt;/code&amp;gt;) the side band pins are given the labels &amp;lt;code&amp;gt;UART2_TX_SUB1&amp;lt;/code&amp;gt; for A8 and &amp;lt;code&amp;gt;UART2_RX_SUB2&amp;lt;/code&amp;gt; for B8.&lt;br /&gt;
The first (TX) is used for transmitting data and the second (RX) is used for receiving data, from the perspective of the PineNote.&lt;br /&gt;
Also note the configuration channel pins labeled &amp;lt;code&amp;gt;TYPEC_CC1&amp;lt;/code&amp;gt; for A5 and &amp;lt;code&amp;gt;TYPEC_CC2&amp;lt;/code&amp;gt; for B5.&lt;br /&gt;
These pins are used to signal to the PineNote that a UART dongle is present.&lt;br /&gt;
The diagram shows they must be connected to a 3.3V source in parallel, mediated by resistors.&lt;br /&gt;
The schematic indicates 10,000 Ohm resistors, but community member Visti Andresen (talpadk) experimented and found 1,000 Ohm resistors work better.&lt;br /&gt;
Our mission is to wire up pins from a USB-UART adapter to a USB-C breakout board following these requirements.&lt;br /&gt;
&lt;br /&gt;
=== Buying components ===&lt;br /&gt;
&lt;br /&gt;
There are many possible USB-C breakout board designs available for purchase online.&lt;br /&gt;
One particularly useful design is a &amp;quot;passthrough&amp;quot; or &amp;quot;intercept&amp;quot; style, with both male and female USB-C ports.&lt;br /&gt;
This design is more versatile in case you want to reuse it in other projects, and also enables you to connect to the PineNote via UART and USB at the same time.&lt;br /&gt;
An example of this product can be found [https://pmdway.com/products/usb-3-1-type-c-male-to-female-breakout-test-board here], although you are encouraged to shop around for cheaper options.&lt;br /&gt;
If you're fine with a bit more soldering, there is a very cheap one [https://www.ebay.com/itm/275407037613 here].&lt;br /&gt;
&lt;br /&gt;
Similarly, there are many USB-UART adapter designs available.&lt;br /&gt;
These devices plug into your computer and expose a number of pins themselves, connecting to specific pins on the breakout board with jump wires.&lt;br /&gt;
It is important to get a 3.3V model, or at least a model with the option of 3.3V, as a 5V source might fry the PineNote.&lt;br /&gt;
[https://pmdway.com/products/usb-to-ttl-serial-cp2104-6-pin-converter-module Here] is one example with jump wires included, although you are again encouraged to shop around for alternatives.&lt;br /&gt;
&lt;br /&gt;
All other necessary components of our UART dongle are readily &amp;amp; cheaply available in many locations.&lt;br /&gt;
&lt;br /&gt;
=== Splicing resistors ===&lt;br /&gt;
&lt;br /&gt;
[[File:PineNote-UART-Y-pull-up-resistor-cable.jpg|thumb|The desired end result; wrap removed from resistors for illustration purposes.]]&lt;br /&gt;
&lt;br /&gt;
This is the only difficult part of the whole process.&lt;br /&gt;
Your goal is to create a Y-shaped jump wire with 1,000 Ohm through-hole resistors spliced into each of the twin arms.&lt;br /&gt;
The solitary leg will connect to a 3.3V source on your USB-UART adapter.&lt;br /&gt;
The twin arms will connect to the configuration channel pins on your USB-C breakout board.&lt;br /&gt;
This setup is called using pull-up resistors, and you can read a nice introduction to their purpose [https://www.electronics-tutorials.ws/logic/pull-up-resistor.html here].&lt;br /&gt;
&lt;br /&gt;
For this project you'll need:&lt;br /&gt;
# A soldering iron with solder&lt;br /&gt;
# Wire cutters &amp;amp; strippers&lt;br /&gt;
# 2x jumper wires, male/female as compatible with your board designs&lt;br /&gt;
# 2x 1,000 Ohm through-hole resistors&lt;br /&gt;
# Electrical tape or heat shrink wrap&lt;br /&gt;
&lt;br /&gt;
Consider buying extra jumper wires and resistors in case you mess up.&lt;br /&gt;
Also double-check that you have 1K resistors with [https://resistorcolorcodecalc.com/ this color code calculator].&lt;br /&gt;
Although the PineNote UART schematic says to use 10K Ohm resistors, community member Visti Andresen (talpadk) experimented and found 1K is more appropriate.&lt;br /&gt;
Assemble your Y-cable as follows:&lt;br /&gt;
# Graft one jump wire onto the other to form a Y shape using [https://www.youtube.com/watch?v=KpiEfuhPqew this] technique, ensuring solitary leg end is compatible with your USB-UART adapter&lt;br /&gt;
# Splice resistors into the twin arms using [https://www.youtube.com/watch?v=RMgMVqqjPZ0 this] technique&lt;br /&gt;
# Splice remaining jump wire onto the ends of the resistors, ensuring ends are compatible with your USB-C breakout board&lt;br /&gt;
# Cover all exposed wire &amp;amp; resistors with electrical tape or heat shrink wrap&lt;br /&gt;
&lt;br /&gt;
=== Assembly ===&lt;br /&gt;
&lt;br /&gt;
Once you have acquired all necessary components, assemble the UART dongle as follows:&lt;br /&gt;
# Connect a jump wire from the GND pin on the USB-UART adapter to any one of the four GND pins on the USB-C breakout board (A1, A12, B1, or B12)&lt;br /&gt;
# Connect a jump wire from the RXD pin on the USB-UART adapter to the &amp;lt;code&amp;gt;UART2_TX_SUB1&amp;lt;/code&amp;gt; SBU1 pin on the USB-C breakout board (A8)&lt;br /&gt;
# Connect a jump wire from the TXD pin on the USB-UART adapter to the &amp;lt;code&amp;gt;UART2_RX_SUB2&amp;lt;/code&amp;gt; SBU2 pin on the USB-C breakout board (B8)&lt;br /&gt;
# Connect your Y-shaped jump wire from the 3.3V source pin on the USB-UART adapter to the CC1 and CC2 pins on the USB-C breakout board (A5 and B5)&lt;br /&gt;
# Wrap all metal connectors in electrical tape or heat shrink to prevent accidental shorts&lt;br /&gt;
&lt;br /&gt;
Be '''very certain''' of your connections for the 3.3V source and its cable, as there is a real risk of irreparably frying your PineNote if they're wrong!&lt;br /&gt;
Especially be sure you are connecting to a 3.3V source and not a 5V source.&lt;br /&gt;
&lt;br /&gt;
Note that if you mix up the TX/RX pins, it will still work but the USB-C breakout board will just plug into the PineNote upside down.&lt;br /&gt;
You can therefore choose which orientation you want by swapping the TX/RX pin connections.&lt;br /&gt;
Experience shows that RX/TX-TX/RX connections will have the PineNote face down while connected, while RX/RX-TX/TX connections will put the PineNote face up.&lt;br /&gt;
&lt;br /&gt;
== Using the dongle ==&lt;br /&gt;
&lt;br /&gt;
First, use your UART dongle to physically connect your PineNote to your computer:&lt;br /&gt;
# Plug the USB-UART adapter into one of your computer's USB ports&lt;br /&gt;
# Plug the USB-C breakout board into the USB-C port on the bottom of your PineNote; the orientation matters, so try both and remember which one works&lt;br /&gt;
&lt;br /&gt;
Once the hardware is connected, we need to get some program on your computer to communicate over that connection with 1500000 (1.5 million) bps, 8 data bits, 1 stop bit, no parity and no flow control.&lt;br /&gt;
Here's how you do that:&lt;br /&gt;
# Identify the USB-UART adapter in your &amp;lt;code&amp;gt;/dev&amp;lt;/code&amp;gt; directory by running &amp;lt;code&amp;gt;ls /dev&amp;lt;/code&amp;gt; with it plugged in, unplugging it, then again running &amp;lt;code&amp;gt;ls /dev&amp;lt;/code&amp;gt; and seeing what changed; it is likely to be called &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;&lt;br /&gt;
# Check your permissions; run &amp;lt;code&amp;gt;ls -l /dev/ttyUSB0&amp;lt;/code&amp;gt; to see which groups have access to the dongle (probably &amp;lt;code&amp;gt;dialout&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;uucp&amp;lt;/code&amp;gt;), and add your user to that group; remember you need to log out before group changes take effect&lt;br /&gt;
# Install [https://www.gnu.org/software/screen/ minicom] (or [https://askubuntu.com/q/40959 some other option], but the instructions below are written for &amp;lt;code&amp;gt;minicom&amp;lt;/code&amp;gt;)&lt;br /&gt;
# In a terminal window, run &amp;lt;code&amp;gt;minicom -D /dev/ttyUSB0 -b 1500000&amp;lt;/code&amp;gt; or run &amp;lt;code&amp;gt;minicom --setup&amp;lt;/code&amp;gt; to specify these settings by default&lt;br /&gt;
&lt;br /&gt;
Once the software is set up, power-cycle your PineNote; as the system boots you should see text appearing in your terminal window.&lt;br /&gt;
You can exit the session with &amp;lt;code&amp;gt;ctrl+a x&amp;lt;/code&amp;gt; then pressing &amp;lt;code&amp;gt;Enter&amp;lt;/code&amp;gt; to confirm.&lt;br /&gt;
Run &amp;lt;code&amp;gt;man minicom&amp;lt;/code&amp;gt; for more details.&lt;br /&gt;
&lt;br /&gt;
=== Sending commands ===&lt;br /&gt;
&lt;br /&gt;
Pressing &amp;lt;code&amp;gt;ctrl+a&amp;lt;/code&amp;gt; in &amp;lt;code&amp;gt;minicom&amp;lt;/code&amp;gt; enables you to send keystrokes to your PineNote.&lt;br /&gt;
The most important of these is &amp;lt;code&amp;gt;ctrl+c&amp;lt;/code&amp;gt;, which if sent during boot will put you in the U-Boot command prompt.&lt;br /&gt;
You can then type &amp;lt;code&amp;gt;help&amp;lt;/code&amp;gt; to list possible commands.&lt;br /&gt;
&lt;br /&gt;
=== Troubleshooting ===&lt;br /&gt;
&lt;br /&gt;
If you don't see any text in your terminal as the PineNote boots, or the text is garbled, try the following:&lt;br /&gt;
* Ensure your GND, RX/TX, and CC jump wires are connected to the correct pins on both the USB-UART adapter and the USB-C breakout board&lt;br /&gt;
* Connect your USB-C breakout board to your PineNote in the opposite orientation&lt;br /&gt;
* Run &amp;lt;code&amp;gt;minicom&amp;lt;/code&amp;gt; as sudo in case your user doesn't have appropriate permissions&lt;br /&gt;
* Ensure you are setting the baud rate to 1500000 (1.5 million), and (less importantly because these are probably used by default) 8 data bits, 1 stop bit, no parity and no flow control&lt;br /&gt;
&lt;br /&gt;
If you can see text but are having trouble sending &amp;lt;code&amp;gt;ctrl+c&amp;lt;/code&amp;gt; to the PineNote during boot:&lt;br /&gt;
* Be sure you're typing &amp;lt;code&amp;gt;ctrl+a&amp;lt;/code&amp;gt; first, or whatever escape sequence your terminal emulator uses&lt;br /&gt;
* Send it right as the PineNote is booting, before the loading bar appears on screen&lt;br /&gt;
* Double-check your Y-shaped pull-up resistor cable; if this isn't working properly you'll probably be able to read text but not send text&lt;br /&gt;
&lt;br /&gt;
== USB passthrough ==&lt;br /&gt;
&lt;br /&gt;
If your USB-C breakout board has a passthrough/intercept design, you can connect to your PineNote over USB and UART at the same time.&lt;br /&gt;
This can be useful when you're doing development work on the PineNote boot process so you don't have to continually reconnect cables.&lt;br /&gt;
You'll need a USB-A to USB-C cable, connecting directly from your computer's USB-A hub to your USB-C breakout board's female USB-C port.&lt;br /&gt;
It's important to connect directly from USB-A, without any intermediate USB-C components.&lt;br /&gt;
Note that connecting a live USB cable to your USB-C breakout board in this way dramatically increases the danger of frying your PineNote with a short, so you should only do this if all connectors are safely wrapped in electrical tape.&lt;br /&gt;
&lt;br /&gt;
[[Category:PineNote]]&lt;/div&gt;</summary>
		<author><name>Ahelwer</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PineNote_Development/UART&amp;diff=20904</id>
		<title>PineNote Development/UART</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PineNote_Development/UART&amp;diff=20904"/>
		<updated>2023-10-14T19:29:07Z</updated>

		<summary type="html">&lt;p&gt;Ahelwer: /* Using the dongle */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Pinenote-uart-dongle.jpeg|thumb|Basic non-stock PineNote UART dongle]]&lt;br /&gt;
&lt;br /&gt;
This page contains information on creating and using a [https://en.wikipedia.org/wiki/Universal_asynchronous_receiver-transmitter UART] dongle for the [[PineNote]].&lt;br /&gt;
The PineNote was shipped with a compatible UART dongle, but replacements are not available to order in case of loss or hardware fault.&lt;br /&gt;
Thankfully it is not difficult to make your own from easily-acquired components and a small bit of soldering.&lt;br /&gt;
&lt;br /&gt;
Fear not if you've never soldered anything before!&lt;br /&gt;
This serves as an excellent first soldering project.&lt;br /&gt;
Borrow the tools from a friend, local hackerspace, or tool library.&lt;br /&gt;
Pine64 also makes [[Pinecil|a nice soldering iron]] themselves.&lt;br /&gt;
&lt;br /&gt;
A PineNote UART dongle enables you to:&lt;br /&gt;
# Interact with the system boot menu&lt;br /&gt;
# Read system events in real time as the PineNote is used&lt;br /&gt;
# Fix the PineNote without opening the case if something goes wrong while [[PineNote Development/Flashing|flashing it]]&lt;br /&gt;
&lt;br /&gt;
Since the PineNote is an embedded system, interfacing with it during boot is more complicated than with an ordinary computer.&lt;br /&gt;
The UART dongle enables you to do this.&lt;br /&gt;
&lt;br /&gt;
The PineNote factory firmware runs UART at a baud rate of 1500000 bps, 8 data bits, 1 stop bit, no parity and no flow control.&lt;br /&gt;
The process by which the PineNote design was modified to include closed-case UART is documented [[PineNote/Hardware Changes/Closed Case UART|here]].&lt;br /&gt;
&lt;br /&gt;
== Stock dongle ==&lt;br /&gt;
&lt;br /&gt;
The stock UART dongle included with the PineNote was a simple device plugging directly into the PineNote's USB-C port.&lt;br /&gt;
The dongle exposed a female USB-C port, which the user plugged into to get UART access.&lt;br /&gt;
This design unfortunately ruled out passthrough USB connections, where the user connects to the PineNote via UART and USB simultaneously.&lt;br /&gt;
The dongle is not currently available for purchase.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Pinenote-stock-uart-dongle-front.jpg|Front&lt;br /&gt;
Pinenote-stock-uart-dongle-back.jpg|Back&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Creating a dongle ==&lt;br /&gt;
&lt;br /&gt;
A typical self-built PineNote UART dongle design has the following components:&lt;br /&gt;
# A USB-C breakout board with a male connector exposing the 24 pins of the PineNote's USB-C port&lt;br /&gt;
# A USB-UART adapter, to plug into a USB port of the computer you'll use to interface with the PineNote&lt;br /&gt;
# [https://en.wikipedia.org/wiki/Jump_wire Jump wires] to connect specific breakout board pins to pins on the USB-UART adapter&lt;br /&gt;
# Two 1,000 Ohm through-hole resistors to splice into the jump wires&lt;br /&gt;
# Electrical tape or heat shrink to wrap connectors and prevent shorts&lt;br /&gt;
&lt;br /&gt;
You will also need the following tools:&lt;br /&gt;
# Soldering iron with solder&lt;br /&gt;
# Wire cutters &amp;amp; strippers&lt;br /&gt;
&lt;br /&gt;
The PineNote's internal UART system is documented in [https://files.pine64.org/doc/PineNote/PineNote_USB-C_Console_UART_breakout_board_schematic_v1.0_20210903.pdf this schematic].&lt;br /&gt;
The purpose of all 24 USB-C pins is documented [https://en.wikipedia.org/wiki/USB-C#Receptacles on the USB-C Wikipedia page].&lt;br /&gt;
We are interested in three sets of pins:&lt;br /&gt;
# The SBU1 (A8) and SBU2 (B8) side band use pins&lt;br /&gt;
# The CC1 (A5) and CC2 (B5) configuration channel pins&lt;br /&gt;
# The GND [https://en.wikipedia.org/wiki/Ground_(electricity) ground return] pins (A1, A12, B1, and B12)&lt;br /&gt;
&lt;br /&gt;
In the PineNote UART schematic you can see (on the bottom right diagram labeled &amp;lt;code&amp;gt;USB_TYPEC_Male&amp;lt;/code&amp;gt;) the side band pins are given the labels &amp;lt;code&amp;gt;UART2_TX_SUB1&amp;lt;/code&amp;gt; for A8 and &amp;lt;code&amp;gt;UART2_RX_SUB2&amp;lt;/code&amp;gt; for B8.&lt;br /&gt;
The first (TX) is used for transmitting data and the second (RX) is used for receiving data, from the perspective of the PineNote.&lt;br /&gt;
Also note the configuration channel pins labeled &amp;lt;code&amp;gt;TYPEC_CC1&amp;lt;/code&amp;gt; for A5 and &amp;lt;code&amp;gt;TYPEC_CC2&amp;lt;/code&amp;gt; for B5.&lt;br /&gt;
These pins are used to signal to the PineNote that a UART dongle is present.&lt;br /&gt;
The diagram shows they must be connected to a 3.3V source in parallel, mediated by resistors.&lt;br /&gt;
The schematic indicates 10,000 Ohm resistors, but community member Visti Andresen (talpadk) experimented and found 1,000 Ohm resistors work better.&lt;br /&gt;
Our mission is to wire up pins from a USB-UART adapter to a USB-C breakout board following these requirements.&lt;br /&gt;
&lt;br /&gt;
=== Buying components ===&lt;br /&gt;
&lt;br /&gt;
There are many possible USB-C breakout board designs available for purchase online.&lt;br /&gt;
One particularly useful design is a &amp;quot;passthrough&amp;quot; or &amp;quot;intercept&amp;quot; style, with both male and female USB-C ports.&lt;br /&gt;
This design is more versatile in case you want to reuse it in other projects, and also enables you to connect to the PineNote via UART and USB at the same time.&lt;br /&gt;
An example of this product can be found [https://pmdway.com/products/usb-3-1-type-c-male-to-female-breakout-test-board here], although you are encouraged to shop around for cheaper options.&lt;br /&gt;
If you're fine with a bit more soldering, there is a very cheap one [https://www.ebay.com/itm/275407037613 here].&lt;br /&gt;
&lt;br /&gt;
Similarly, there are many USB-UART adapter designs available.&lt;br /&gt;
These devices plug into your computer and expose a number of pins themselves, connecting to specific pins on the breakout board with jump wires.&lt;br /&gt;
It is important to get a 3.3V model, or at least a model with the option of 3.3V, as a 5V source might fry the PineNote.&lt;br /&gt;
[https://pmdway.com/products/usb-to-ttl-serial-cp2104-6-pin-converter-module Here] is one example with jump wires included, although you are again encouraged to shop around for alternatives.&lt;br /&gt;
&lt;br /&gt;
All other necessary components of our UART dongle are readily &amp;amp; cheaply available in many locations.&lt;br /&gt;
&lt;br /&gt;
=== Splicing resistors ===&lt;br /&gt;
&lt;br /&gt;
[[File:PineNote-UART-Y-pull-up-resistor-cable.jpg|thumb|The desired end result; wrap removed from resistors for illustration purposes.]]&lt;br /&gt;
&lt;br /&gt;
This is the only difficult part of the whole process.&lt;br /&gt;
Your goal is to create a Y-shaped jump wire with 1,000 Ohm through-hole resistors spliced into each of the twin arms.&lt;br /&gt;
The solitary leg will connect to a 3.3V source on your USB-UART adapter.&lt;br /&gt;
The twin arms will connect to the configuration channel pins on your USB-C breakout board.&lt;br /&gt;
This setup is called using pull-up resistors, and you can read a nice introduction to their purpose [https://www.electronics-tutorials.ws/logic/pull-up-resistor.html here].&lt;br /&gt;
&lt;br /&gt;
For this project you'll need:&lt;br /&gt;
# A soldering iron with solder&lt;br /&gt;
# Wire cutters &amp;amp; strippers&lt;br /&gt;
# 2x jumper wires, male/female as compatible with your board designs&lt;br /&gt;
# 2x 1,000 Ohm through-hole resistors&lt;br /&gt;
# Electrical tape or heat shrink wrap&lt;br /&gt;
&lt;br /&gt;
Consider buying extra jumper wires and resistors in case you mess up.&lt;br /&gt;
Also double-check that you have 1K resistors with [https://resistorcolorcodecalc.com/ this color code calculator].&lt;br /&gt;
Although the PineNote UART schematic says to use 10K Ohm resistors, community member Visti Andresen (talpadk) experimented and found 1K is more appropriate.&lt;br /&gt;
Assemble your Y-cable as follows:&lt;br /&gt;
# Graft one jump wire onto the other to form a Y shape using [https://www.youtube.com/watch?v=KpiEfuhPqew this] technique, ensuring solitary leg end is compatible with your USB-UART adapter&lt;br /&gt;
# Splice resistors into the twin arms using [https://www.youtube.com/watch?v=RMgMVqqjPZ0 this] technique&lt;br /&gt;
# Splice remaining jump wire onto the ends of the resistors, ensuring ends are compatible with your USB-C breakout board&lt;br /&gt;
# Cover all exposed wire &amp;amp; resistors with electrical tape or heat shrink wrap&lt;br /&gt;
&lt;br /&gt;
=== Assembly ===&lt;br /&gt;
&lt;br /&gt;
Once you have acquired all necessary components, assemble the UART dongle as follows:&lt;br /&gt;
# Connect a jump wire from the GND pin on the USB-UART adapter to any one of the four GND pins on the USB-C breakout board (A1, A12, B1, or B12)&lt;br /&gt;
# Connect a jump wire from the RXD pin on the USB-UART adapter to the &amp;lt;code&amp;gt;UART2_TX_SUB1&amp;lt;/code&amp;gt; SBU1 pin on the USB-C breakout board (A8)&lt;br /&gt;
# Connect a jump wire from the TXD pin on the USB-UART adapter to the &amp;lt;code&amp;gt;UART2_RX_SUB2&amp;lt;/code&amp;gt; SBU2 pin on the USB-C breakout board (B8)&lt;br /&gt;
# Connect your Y-shaped jump wire from the 3.3V source pin on the USB-UART adapter to the CC1 and CC2 pins on the USB-C breakout board (A5 and B5)&lt;br /&gt;
# Wrap all metal connectors in electrical tape or heat shrink to prevent accidental shorts&lt;br /&gt;
&lt;br /&gt;
Be '''very certain''' of your connections for the 3.3V source and its cable, as there is a real risk of irreparably frying your PineNote if they're wrong!&lt;br /&gt;
Especially be sure you are connecting to a 3.3V source and not a 5V source.&lt;br /&gt;
&lt;br /&gt;
Note that if you mix up the TX/RX pins, it will still work but the USB-C breakout board will just plug into the PineNote upside down.&lt;br /&gt;
You can therefore choose which orientation you want by swapping the TX/RX pin connections.&lt;br /&gt;
Experience shows that RX/TX-TX/RX connections will have the PineNote face down while connected, while RX/RX-TX/TX connections will put the PineNote face up.&lt;br /&gt;
&lt;br /&gt;
== Using the dongle ==&lt;br /&gt;
&lt;br /&gt;
First, use your UART dongle to physically connect your PineNote to your computer:&lt;br /&gt;
# Plug the USB-UART adapter into one of your computer's USB ports&lt;br /&gt;
# Plug the USB-C breakout board into the USB-C port on the bottom of your PineNote; the orientation matters, so try both and remember which one works&lt;br /&gt;
&lt;br /&gt;
Once the hardware is connected, we need to get some program to communicate over UART with 1500000 (1.5 million) bps, 8 data bits, 1 stop bit, no parity and no flow control.&lt;br /&gt;
Here's how you do that:&lt;br /&gt;
# Identify the USB-UART adapter in your &amp;lt;code&amp;gt;/dev&amp;lt;/code&amp;gt; directory by running &amp;lt;code&amp;gt;ls /dev&amp;lt;/code&amp;gt; with it plugged in, unplugging it, then again running &amp;lt;code&amp;gt;ls /dev&amp;lt;/code&amp;gt; and seeing what changed; it is likely to be called &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;&lt;br /&gt;
# Check your permissions; run &amp;lt;code&amp;gt;ls -l /dev/ttyUSB0&amp;lt;/code&amp;gt; to see which groups have access to the dongle (probably &amp;lt;code&amp;gt;dialout&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;uucp&amp;lt;/code&amp;gt;), and add your user to that group; remember you need to log out before group changes take effect&lt;br /&gt;
# Install [https://www.gnu.org/software/screen/ minicom] (or [https://askubuntu.com/q/40959 some other option], but the instructions below are written for &amp;lt;code&amp;gt;minicom&amp;lt;/code&amp;gt;)&lt;br /&gt;
# In a terminal window, run &amp;lt;code&amp;gt;minicom -D /dev/ttyUSB0 -b 1500000&amp;lt;/code&amp;gt; or run &amp;lt;code&amp;gt;minicom --setup&amp;lt;/code&amp;gt; to specify these settings by default&lt;br /&gt;
&lt;br /&gt;
Once the software is set up, power-cycle your PineNote; as the system boots you should see text appearing in your terminal window.&lt;br /&gt;
You can exit the session with &amp;lt;code&amp;gt;ctrl+a x&amp;lt;/code&amp;gt; then pressing &amp;lt;code&amp;gt;Enter&amp;lt;/code&amp;gt; to confirm.&lt;br /&gt;
Run &amp;lt;code&amp;gt;man minicom&amp;lt;/code&amp;gt; for more details.&lt;br /&gt;
&lt;br /&gt;
=== Sending commands ===&lt;br /&gt;
&lt;br /&gt;
Pressing &amp;lt;code&amp;gt;ctrl+a&amp;lt;/code&amp;gt; in &amp;lt;code&amp;gt;minicom&amp;lt;/code&amp;gt; enables you to send keystrokes to your PineNote.&lt;br /&gt;
The most important of these is &amp;lt;code&amp;gt;ctrl+c&amp;lt;/code&amp;gt;, which if sent during boot will put you in the U-Boot command prompt.&lt;br /&gt;
You can then type &amp;lt;code&amp;gt;help&amp;lt;/code&amp;gt; to list possible commands.&lt;br /&gt;
&lt;br /&gt;
=== Troubleshooting ===&lt;br /&gt;
&lt;br /&gt;
If you don't see any text in your terminal as the PineNote boots, or the text is garbled, try the following:&lt;br /&gt;
* Ensure your GND, RX/TX, and CC jump wires are connected to the correct pins on both the USB-UART adapter and the USB-C breakout board&lt;br /&gt;
* Connect your USB-C breakout board to your PineNote in the opposite orientation&lt;br /&gt;
* Run &amp;lt;code&amp;gt;minicom&amp;lt;/code&amp;gt; as sudo in case your user doesn't have appropriate permissions&lt;br /&gt;
* Ensure you are setting the baud rate to 1500000 (1.5 million), and (less importantly because these are probably used by default) 8 data bits, 1 stop bit, no parity and no flow control&lt;br /&gt;
&lt;br /&gt;
If you can see text but are having trouble sending &amp;lt;code&amp;gt;ctrl+c&amp;lt;/code&amp;gt; to the PineNote during boot:&lt;br /&gt;
* Be sure you're typing &amp;lt;code&amp;gt;ctrl+a&amp;lt;/code&amp;gt; first, or whatever escape sequence your terminal emulator uses&lt;br /&gt;
* Send it right as the PineNote is booting, before the loading bar appears on screen&lt;br /&gt;
* Double-check your Y-shaped pull-up resistor cable; if this isn't working properly you'll probably be able to read text but not send text&lt;br /&gt;
&lt;br /&gt;
== USB passthrough ==&lt;br /&gt;
&lt;br /&gt;
If your USB-C breakout board has a passthrough/intercept design, you can connect to your PineNote over USB and UART at the same time.&lt;br /&gt;
This can be useful when you're doing development work on the PineNote boot process so you don't have to continually reconnect cables.&lt;br /&gt;
You'll need a USB-A to USB-C cable, connecting directly from your computer's USB-A hub to your USB-C breakout board's female USB-C port.&lt;br /&gt;
It's important to connect directly from USB-A, without any intermediate USB-C components.&lt;br /&gt;
Note that connecting a live USB cable to your USB-C breakout board in this way dramatically increases the danger of frying your PineNote with a short, so you should only do this if all connectors are safely wrapped in electrical tape.&lt;br /&gt;
&lt;br /&gt;
[[Category:PineNote]]&lt;/div&gt;</summary>
		<author><name>Ahelwer</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PineNote_Development/UART&amp;diff=20903</id>
		<title>PineNote Development/UART</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PineNote_Development/UART&amp;diff=20903"/>
		<updated>2023-10-14T14:07:53Z</updated>

		<summary type="html">&lt;p&gt;Ahelwer: /* Troubleshooting */ added note about data settings in UART&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Pinenote-uart-dongle.jpeg|thumb|Basic non-stock PineNote UART dongle]]&lt;br /&gt;
&lt;br /&gt;
This page contains information on creating and using a [https://en.wikipedia.org/wiki/Universal_asynchronous_receiver-transmitter UART] dongle for the [[PineNote]].&lt;br /&gt;
The PineNote was shipped with a compatible UART dongle, but replacements are not available to order in case of loss or hardware fault.&lt;br /&gt;
Thankfully it is not difficult to make your own from easily-acquired components and a small bit of soldering.&lt;br /&gt;
&lt;br /&gt;
Fear not if you've never soldered anything before!&lt;br /&gt;
This serves as an excellent first soldering project.&lt;br /&gt;
Borrow the tools from a friend, local hackerspace, or tool library.&lt;br /&gt;
Pine64 also makes [[Pinecil|a nice soldering iron]] themselves.&lt;br /&gt;
&lt;br /&gt;
A PineNote UART dongle enables you to:&lt;br /&gt;
# Interact with the system boot menu&lt;br /&gt;
# Read system events in real time as the PineNote is used&lt;br /&gt;
# Fix the PineNote without opening the case if something goes wrong while [[PineNote Development/Flashing|flashing it]]&lt;br /&gt;
&lt;br /&gt;
Since the PineNote is an embedded system, interfacing with it during boot is more complicated than with an ordinary computer.&lt;br /&gt;
The UART dongle enables you to do this.&lt;br /&gt;
&lt;br /&gt;
The PineNote factory firmware runs UART at a baud rate of 1500000 bps, 8 data bits, 1 stop bit, no parity and no flow control.&lt;br /&gt;
The process by which the PineNote design was modified to include closed-case UART is documented [[PineNote/Hardware Changes/Closed Case UART|here]].&lt;br /&gt;
&lt;br /&gt;
== Stock dongle ==&lt;br /&gt;
&lt;br /&gt;
The stock UART dongle included with the PineNote was a simple device plugging directly into the PineNote's USB-C port.&lt;br /&gt;
The dongle exposed a female USB-C port, which the user plugged into to get UART access.&lt;br /&gt;
This design unfortunately ruled out passthrough USB connections, where the user connects to the PineNote via UART and USB simultaneously.&lt;br /&gt;
The dongle is not currently available for purchase.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Pinenote-stock-uart-dongle-front.jpg|Front&lt;br /&gt;
Pinenote-stock-uart-dongle-back.jpg|Back&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Creating a dongle ==&lt;br /&gt;
&lt;br /&gt;
A typical self-built PineNote UART dongle design has the following components:&lt;br /&gt;
# A USB-C breakout board with a male connector exposing the 24 pins of the PineNote's USB-C port&lt;br /&gt;
# A USB-UART adapter, to plug into a USB port of the computer you'll use to interface with the PineNote&lt;br /&gt;
# [https://en.wikipedia.org/wiki/Jump_wire Jump wires] to connect specific breakout board pins to pins on the USB-UART adapter&lt;br /&gt;
# Two 1,000 Ohm through-hole resistors to splice into the jump wires&lt;br /&gt;
# Electrical tape or heat shrink to wrap connectors and prevent shorts&lt;br /&gt;
&lt;br /&gt;
You will also need the following tools:&lt;br /&gt;
# Soldering iron with solder&lt;br /&gt;
# Wire cutters &amp;amp; strippers&lt;br /&gt;
&lt;br /&gt;
The PineNote's internal UART system is documented in [https://files.pine64.org/doc/PineNote/PineNote_USB-C_Console_UART_breakout_board_schematic_v1.0_20210903.pdf this schematic].&lt;br /&gt;
The purpose of all 24 USB-C pins is documented [https://en.wikipedia.org/wiki/USB-C#Receptacles on the USB-C Wikipedia page].&lt;br /&gt;
We are interested in three sets of pins:&lt;br /&gt;
# The SBU1 (A8) and SBU2 (B8) side band use pins&lt;br /&gt;
# The CC1 (A5) and CC2 (B5) configuration channel pins&lt;br /&gt;
# The GND [https://en.wikipedia.org/wiki/Ground_(electricity) ground return] pins (A1, A12, B1, and B12)&lt;br /&gt;
&lt;br /&gt;
In the PineNote UART schematic you can see (on the bottom right diagram labeled &amp;lt;code&amp;gt;USB_TYPEC_Male&amp;lt;/code&amp;gt;) the side band pins are given the labels &amp;lt;code&amp;gt;UART2_TX_SUB1&amp;lt;/code&amp;gt; for A8 and &amp;lt;code&amp;gt;UART2_RX_SUB2&amp;lt;/code&amp;gt; for B8.&lt;br /&gt;
The first (TX) is used for transmitting data and the second (RX) is used for receiving data, from the perspective of the PineNote.&lt;br /&gt;
Also note the configuration channel pins labeled &amp;lt;code&amp;gt;TYPEC_CC1&amp;lt;/code&amp;gt; for A5 and &amp;lt;code&amp;gt;TYPEC_CC2&amp;lt;/code&amp;gt; for B5.&lt;br /&gt;
These pins are used to signal to the PineNote that a UART dongle is present.&lt;br /&gt;
The diagram shows they must be connected to a 3.3V source in parallel, mediated by resistors.&lt;br /&gt;
The schematic indicates 10,000 Ohm resistors, but community member Visti Andresen (talpadk) experimented and found 1,000 Ohm resistors work better.&lt;br /&gt;
Our mission is to wire up pins from a USB-UART adapter to a USB-C breakout board following these requirements.&lt;br /&gt;
&lt;br /&gt;
=== Buying components ===&lt;br /&gt;
&lt;br /&gt;
There are many possible USB-C breakout board designs available for purchase online.&lt;br /&gt;
One particularly useful design is a &amp;quot;passthrough&amp;quot; or &amp;quot;intercept&amp;quot; style, with both male and female USB-C ports.&lt;br /&gt;
This design is more versatile in case you want to reuse it in other projects, and also enables you to connect to the PineNote via UART and USB at the same time.&lt;br /&gt;
An example of this product can be found [https://pmdway.com/products/usb-3-1-type-c-male-to-female-breakout-test-board here], although you are encouraged to shop around for cheaper options.&lt;br /&gt;
If you're fine with a bit more soldering, there is a very cheap one [https://www.ebay.com/itm/275407037613 here].&lt;br /&gt;
&lt;br /&gt;
Similarly, there are many USB-UART adapter designs available.&lt;br /&gt;
These devices plug into your computer and expose a number of pins themselves, connecting to specific pins on the breakout board with jump wires.&lt;br /&gt;
It is important to get a 3.3V model, or at least a model with the option of 3.3V, as a 5V source might fry the PineNote.&lt;br /&gt;
[https://pmdway.com/products/usb-to-ttl-serial-cp2104-6-pin-converter-module Here] is one example with jump wires included, although you are again encouraged to shop around for alternatives.&lt;br /&gt;
&lt;br /&gt;
All other necessary components of our UART dongle are readily &amp;amp; cheaply available in many locations.&lt;br /&gt;
&lt;br /&gt;
=== Splicing resistors ===&lt;br /&gt;
&lt;br /&gt;
[[File:PineNote-UART-Y-pull-up-resistor-cable.jpg|thumb|The desired end result; wrap removed from resistors for illustration purposes.]]&lt;br /&gt;
&lt;br /&gt;
This is the only difficult part of the whole process.&lt;br /&gt;
Your goal is to create a Y-shaped jump wire with 1,000 Ohm through-hole resistors spliced into each of the twin arms.&lt;br /&gt;
The solitary leg will connect to a 3.3V source on your USB-UART adapter.&lt;br /&gt;
The twin arms will connect to the configuration channel pins on your USB-C breakout board.&lt;br /&gt;
This setup is called using pull-up resistors, and you can read a nice introduction to their purpose [https://www.electronics-tutorials.ws/logic/pull-up-resistor.html here].&lt;br /&gt;
&lt;br /&gt;
For this project you'll need:&lt;br /&gt;
# A soldering iron with solder&lt;br /&gt;
# Wire cutters &amp;amp; strippers&lt;br /&gt;
# 2x jumper wires, male/female as compatible with your board designs&lt;br /&gt;
# 2x 1,000 Ohm through-hole resistors&lt;br /&gt;
# Electrical tape or heat shrink wrap&lt;br /&gt;
&lt;br /&gt;
Consider buying extra jumper wires and resistors in case you mess up.&lt;br /&gt;
Also double-check that you have 1K resistors with [https://resistorcolorcodecalc.com/ this color code calculator].&lt;br /&gt;
Although the PineNote UART schematic says to use 10K Ohm resistors, community member Visti Andresen (talpadk) experimented and found 1K is more appropriate.&lt;br /&gt;
Assemble your Y-cable as follows:&lt;br /&gt;
# Graft one jump wire onto the other to form a Y shape using [https://www.youtube.com/watch?v=KpiEfuhPqew this] technique, ensuring solitary leg end is compatible with your USB-UART adapter&lt;br /&gt;
# Splice resistors into the twin arms using [https://www.youtube.com/watch?v=RMgMVqqjPZ0 this] technique&lt;br /&gt;
# Splice remaining jump wire onto the ends of the resistors, ensuring ends are compatible with your USB-C breakout board&lt;br /&gt;
# Cover all exposed wire &amp;amp; resistors with electrical tape or heat shrink wrap&lt;br /&gt;
&lt;br /&gt;
=== Assembly ===&lt;br /&gt;
&lt;br /&gt;
Once you have acquired all necessary components, assemble the UART dongle as follows:&lt;br /&gt;
# Connect a jump wire from the GND pin on the USB-UART adapter to any one of the four GND pins on the USB-C breakout board (A1, A12, B1, or B12)&lt;br /&gt;
# Connect a jump wire from the RXD pin on the USB-UART adapter to the &amp;lt;code&amp;gt;UART2_TX_SUB1&amp;lt;/code&amp;gt; SBU1 pin on the USB-C breakout board (A8)&lt;br /&gt;
# Connect a jump wire from the TXD pin on the USB-UART adapter to the &amp;lt;code&amp;gt;UART2_RX_SUB2&amp;lt;/code&amp;gt; SBU2 pin on the USB-C breakout board (B8)&lt;br /&gt;
# Connect your Y-shaped jump wire from the 3.3V source pin on the USB-UART adapter to the CC1 and CC2 pins on the USB-C breakout board (A5 and B5)&lt;br /&gt;
# Wrap all metal connectors in electrical tape or heat shrink to prevent accidental shorts&lt;br /&gt;
&lt;br /&gt;
Be '''very certain''' of your connections for the 3.3V source and its cable, as there is a real risk of irreparably frying your PineNote if they're wrong!&lt;br /&gt;
Especially be sure you are connecting to a 3.3V source and not a 5V source.&lt;br /&gt;
&lt;br /&gt;
Note that if you mix up the TX/RX pins, it will still work but the USB-C breakout board will just plug into the PineNote upside down.&lt;br /&gt;
You can therefore choose which orientation you want by swapping the TX/RX pin connections.&lt;br /&gt;
Experience shows that RX/TX-TX/RX connections will have the PineNote face down while connected, while RX/RX-TX/TX connections will put the PineNote face up.&lt;br /&gt;
&lt;br /&gt;
== Using the dongle ==&lt;br /&gt;
&lt;br /&gt;
First, use your UART dongle to physically connect your PineNote to your computer:&lt;br /&gt;
# Plug the USB-UART adapter into one of your computer's USB ports&lt;br /&gt;
# Plug the USB-C breakout board into the USB-C port on the bottom of your PineNote; the orientation matters, so try both and remember which one works&lt;br /&gt;
&lt;br /&gt;
Once the hardware is connected, set up your computer's software as follows:&lt;br /&gt;
# Identify the USB-UART adapter in your &amp;lt;code&amp;gt;/dev&amp;lt;/code&amp;gt; directory by running &amp;lt;code&amp;gt;ls /dev&amp;lt;/code&amp;gt; with it plugged in, unplugging it, then again running &amp;lt;code&amp;gt;ls /dev&amp;lt;/code&amp;gt; and seeing what changed; it is likely to be called &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;&lt;br /&gt;
# Check your permissions; run &amp;lt;code&amp;gt;ls -l /dev/ttyUSB0&amp;lt;/code&amp;gt; to see which groups have access to the dongle (probably &amp;lt;code&amp;gt;dialout&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;uucp&amp;lt;/code&amp;gt;), and add your user to that group; remember you need to log out before group changes take effect&lt;br /&gt;
# Install [https://www.gnu.org/software/screen/ minicom] (or [https://askubuntu.com/q/40959 some other option], but the instructions below are written for &amp;lt;code&amp;gt;minicom&amp;lt;/code&amp;gt;)&lt;br /&gt;
# In a terminal window, run &amp;lt;code&amp;gt;minicom -D /dev/ttyUSB0 -b 1500000&amp;lt;/code&amp;gt; or run &amp;lt;code&amp;gt;minicom --setup&amp;lt;/code&amp;gt; to specify these settings by default&lt;br /&gt;
&lt;br /&gt;
Once the software is set up, power-cycle your PineNote; as the system boots you should see text appearing in your terminal window.&lt;br /&gt;
You can exit the session with &amp;lt;code&amp;gt;ctrl+a x&amp;lt;/code&amp;gt; then pressing &amp;lt;code&amp;gt;Enter&amp;lt;/code&amp;gt; to confirm.&lt;br /&gt;
Run &amp;lt;code&amp;gt;man minicom&amp;lt;/code&amp;gt; for more details.&lt;br /&gt;
&lt;br /&gt;
=== Sending commands ===&lt;br /&gt;
&lt;br /&gt;
Pressing &amp;lt;code&amp;gt;ctrl+a&amp;lt;/code&amp;gt; in &amp;lt;code&amp;gt;minicom&amp;lt;/code&amp;gt; enables you to send keystrokes to your PineNote.&lt;br /&gt;
The most important of these is &amp;lt;code&amp;gt;ctrl+c&amp;lt;/code&amp;gt;, which if sent during boot will put you in the U-Boot command prompt.&lt;br /&gt;
You can then type &amp;lt;code&amp;gt;help&amp;lt;/code&amp;gt; to list possible commands.&lt;br /&gt;
&lt;br /&gt;
=== Troubleshooting ===&lt;br /&gt;
&lt;br /&gt;
If you don't see any text in your terminal as the PineNote boots, or the text is garbled, try the following:&lt;br /&gt;
* Ensure your GND, RX/TX, and CC jump wires are connected to the correct pins on both the USB-UART adapter and the USB-C breakout board&lt;br /&gt;
* Connect your USB-C breakout board to your PineNote in the opposite orientation&lt;br /&gt;
* Run &amp;lt;code&amp;gt;minicom&amp;lt;/code&amp;gt; as sudo in case your user doesn't have appropriate permissions&lt;br /&gt;
* Ensure you are setting the baud rate to 1500000 (1.5 million), and (less importantly because these are probably used by default) 8 data bits, 1 stop bit, no parity and no flow control&lt;br /&gt;
&lt;br /&gt;
If you can see text but are having trouble sending &amp;lt;code&amp;gt;ctrl+c&amp;lt;/code&amp;gt; to the PineNote during boot:&lt;br /&gt;
* Be sure you're typing &amp;lt;code&amp;gt;ctrl+a&amp;lt;/code&amp;gt; first, or whatever escape sequence your terminal emulator uses&lt;br /&gt;
* Send it right as the PineNote is booting, before the loading bar appears on screen&lt;br /&gt;
* Double-check your Y-shaped pull-up resistor cable; if this isn't working properly you'll probably be able to read text but not send text&lt;br /&gt;
&lt;br /&gt;
== USB passthrough ==&lt;br /&gt;
&lt;br /&gt;
If your USB-C breakout board has a passthrough/intercept design, you can connect to your PineNote over USB and UART at the same time.&lt;br /&gt;
This can be useful when you're doing development work on the PineNote boot process so you don't have to continually reconnect cables.&lt;br /&gt;
You'll need a USB-A to USB-C cable, connecting directly from your computer's USB-A hub to your USB-C breakout board's female USB-C port.&lt;br /&gt;
It's important to connect directly from USB-A, without any intermediate USB-C components.&lt;br /&gt;
Note that connecting a live USB cable to your USB-C breakout board in this way dramatically increases the danger of frying your PineNote with a short, so you should only do this if all connectors are safely wrapped in electrical tape.&lt;br /&gt;
&lt;br /&gt;
[[Category:PineNote]]&lt;/div&gt;</summary>
		<author><name>Ahelwer</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PineNote_Development/UART&amp;diff=20902</id>
		<title>PineNote Development/UART</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PineNote_Development/UART&amp;diff=20902"/>
		<updated>2023-10-14T14:04:39Z</updated>

		<summary type="html">&lt;p&gt;Ahelwer: /* Using UART */ Added section on sending commands over UART&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Pinenote-uart-dongle.jpeg|thumb|Basic non-stock PineNote UART dongle]]&lt;br /&gt;
&lt;br /&gt;
This page contains information on creating and using a [https://en.wikipedia.org/wiki/Universal_asynchronous_receiver-transmitter UART] dongle for the [[PineNote]].&lt;br /&gt;
The PineNote was shipped with a compatible UART dongle, but replacements are not available to order in case of loss or hardware fault.&lt;br /&gt;
Thankfully it is not difficult to make your own from easily-acquired components and a small bit of soldering.&lt;br /&gt;
&lt;br /&gt;
Fear not if you've never soldered anything before!&lt;br /&gt;
This serves as an excellent first soldering project.&lt;br /&gt;
Borrow the tools from a friend, local hackerspace, or tool library.&lt;br /&gt;
Pine64 also makes [[Pinecil|a nice soldering iron]] themselves.&lt;br /&gt;
&lt;br /&gt;
A PineNote UART dongle enables you to:&lt;br /&gt;
# Interact with the system boot menu&lt;br /&gt;
# Read system events in real time as the PineNote is used&lt;br /&gt;
# Fix the PineNote without opening the case if something goes wrong while [[PineNote Development/Flashing|flashing it]]&lt;br /&gt;
&lt;br /&gt;
Since the PineNote is an embedded system, interfacing with it during boot is more complicated than with an ordinary computer.&lt;br /&gt;
The UART dongle enables you to do this.&lt;br /&gt;
&lt;br /&gt;
The PineNote factory firmware runs UART at a baud rate of 1500000 bps, 8 data bits, 1 stop bit, no parity and no flow control.&lt;br /&gt;
The process by which the PineNote design was modified to include closed-case UART is documented [[PineNote/Hardware Changes/Closed Case UART|here]].&lt;br /&gt;
&lt;br /&gt;
== Stock dongle ==&lt;br /&gt;
&lt;br /&gt;
The stock UART dongle included with the PineNote was a simple device plugging directly into the PineNote's USB-C port.&lt;br /&gt;
The dongle exposed a female USB-C port, which the user plugged into to get UART access.&lt;br /&gt;
This design unfortunately ruled out passthrough USB connections, where the user connects to the PineNote via UART and USB simultaneously.&lt;br /&gt;
The dongle is not currently available for purchase.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Pinenote-stock-uart-dongle-front.jpg|Front&lt;br /&gt;
Pinenote-stock-uart-dongle-back.jpg|Back&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Creating a dongle ==&lt;br /&gt;
&lt;br /&gt;
A typical self-built PineNote UART dongle design has the following components:&lt;br /&gt;
# A USB-C breakout board with a male connector exposing the 24 pins of the PineNote's USB-C port&lt;br /&gt;
# A USB-UART adapter, to plug into a USB port of the computer you'll use to interface with the PineNote&lt;br /&gt;
# [https://en.wikipedia.org/wiki/Jump_wire Jump wires] to connect specific breakout board pins to pins on the USB-UART adapter&lt;br /&gt;
# Two 1,000 Ohm through-hole resistors to splice into the jump wires&lt;br /&gt;
# Electrical tape or heat shrink to wrap connectors and prevent shorts&lt;br /&gt;
&lt;br /&gt;
You will also need the following tools:&lt;br /&gt;
# Soldering iron with solder&lt;br /&gt;
# Wire cutters &amp;amp; strippers&lt;br /&gt;
&lt;br /&gt;
The PineNote's internal UART system is documented in [https://files.pine64.org/doc/PineNote/PineNote_USB-C_Console_UART_breakout_board_schematic_v1.0_20210903.pdf this schematic].&lt;br /&gt;
The purpose of all 24 USB-C pins is documented [https://en.wikipedia.org/wiki/USB-C#Receptacles on the USB-C Wikipedia page].&lt;br /&gt;
We are interested in three sets of pins:&lt;br /&gt;
# The SBU1 (A8) and SBU2 (B8) side band use pins&lt;br /&gt;
# The CC1 (A5) and CC2 (B5) configuration channel pins&lt;br /&gt;
# The GND [https://en.wikipedia.org/wiki/Ground_(electricity) ground return] pins (A1, A12, B1, and B12)&lt;br /&gt;
&lt;br /&gt;
In the PineNote UART schematic you can see (on the bottom right diagram labeled &amp;lt;code&amp;gt;USB_TYPEC_Male&amp;lt;/code&amp;gt;) the side band pins are given the labels &amp;lt;code&amp;gt;UART2_TX_SUB1&amp;lt;/code&amp;gt; for A8 and &amp;lt;code&amp;gt;UART2_RX_SUB2&amp;lt;/code&amp;gt; for B8.&lt;br /&gt;
The first (TX) is used for transmitting data and the second (RX) is used for receiving data, from the perspective of the PineNote.&lt;br /&gt;
Also note the configuration channel pins labeled &amp;lt;code&amp;gt;TYPEC_CC1&amp;lt;/code&amp;gt; for A5 and &amp;lt;code&amp;gt;TYPEC_CC2&amp;lt;/code&amp;gt; for B5.&lt;br /&gt;
These pins are used to signal to the PineNote that a UART dongle is present.&lt;br /&gt;
The diagram shows they must be connected to a 3.3V source in parallel, mediated by resistors.&lt;br /&gt;
The schematic indicates 10,000 Ohm resistors, but community member Visti Andresen (talpadk) experimented and found 1,000 Ohm resistors work better.&lt;br /&gt;
Our mission is to wire up pins from a USB-UART adapter to a USB-C breakout board following these requirements.&lt;br /&gt;
&lt;br /&gt;
=== Buying components ===&lt;br /&gt;
&lt;br /&gt;
There are many possible USB-C breakout board designs available for purchase online.&lt;br /&gt;
One particularly useful design is a &amp;quot;passthrough&amp;quot; or &amp;quot;intercept&amp;quot; style, with both male and female USB-C ports.&lt;br /&gt;
This design is more versatile in case you want to reuse it in other projects, and also enables you to connect to the PineNote via UART and USB at the same time.&lt;br /&gt;
An example of this product can be found [https://pmdway.com/products/usb-3-1-type-c-male-to-female-breakout-test-board here], although you are encouraged to shop around for cheaper options.&lt;br /&gt;
If you're fine with a bit more soldering, there is a very cheap one [https://www.ebay.com/itm/275407037613 here].&lt;br /&gt;
&lt;br /&gt;
Similarly, there are many USB-UART adapter designs available.&lt;br /&gt;
These devices plug into your computer and expose a number of pins themselves, connecting to specific pins on the breakout board with jump wires.&lt;br /&gt;
It is important to get a 3.3V model, or at least a model with the option of 3.3V, as a 5V source might fry the PineNote.&lt;br /&gt;
[https://pmdway.com/products/usb-to-ttl-serial-cp2104-6-pin-converter-module Here] is one example with jump wires included, although you are again encouraged to shop around for alternatives.&lt;br /&gt;
&lt;br /&gt;
All other necessary components of our UART dongle are readily &amp;amp; cheaply available in many locations.&lt;br /&gt;
&lt;br /&gt;
=== Splicing resistors ===&lt;br /&gt;
&lt;br /&gt;
[[File:PineNote-UART-Y-pull-up-resistor-cable.jpg|thumb|The desired end result; wrap removed from resistors for illustration purposes.]]&lt;br /&gt;
&lt;br /&gt;
This is the only difficult part of the whole process.&lt;br /&gt;
Your goal is to create a Y-shaped jump wire with 1,000 Ohm through-hole resistors spliced into each of the twin arms.&lt;br /&gt;
The solitary leg will connect to a 3.3V source on your USB-UART adapter.&lt;br /&gt;
The twin arms will connect to the configuration channel pins on your USB-C breakout board.&lt;br /&gt;
This setup is called using pull-up resistors, and you can read a nice introduction to their purpose [https://www.electronics-tutorials.ws/logic/pull-up-resistor.html here].&lt;br /&gt;
&lt;br /&gt;
For this project you'll need:&lt;br /&gt;
# A soldering iron with solder&lt;br /&gt;
# Wire cutters &amp;amp; strippers&lt;br /&gt;
# 2x jumper wires, male/female as compatible with your board designs&lt;br /&gt;
# 2x 1,000 Ohm through-hole resistors&lt;br /&gt;
# Electrical tape or heat shrink wrap&lt;br /&gt;
&lt;br /&gt;
Consider buying extra jumper wires and resistors in case you mess up.&lt;br /&gt;
Also double-check that you have 1K resistors with [https://resistorcolorcodecalc.com/ this color code calculator].&lt;br /&gt;
Although the PineNote UART schematic says to use 10K Ohm resistors, community member Visti Andresen (talpadk) experimented and found 1K is more appropriate.&lt;br /&gt;
Assemble your Y-cable as follows:&lt;br /&gt;
# Graft one jump wire onto the other to form a Y shape using [https://www.youtube.com/watch?v=KpiEfuhPqew this] technique, ensuring solitary leg end is compatible with your USB-UART adapter&lt;br /&gt;
# Splice resistors into the twin arms using [https://www.youtube.com/watch?v=RMgMVqqjPZ0 this] technique&lt;br /&gt;
# Splice remaining jump wire onto the ends of the resistors, ensuring ends are compatible with your USB-C breakout board&lt;br /&gt;
# Cover all exposed wire &amp;amp; resistors with electrical tape or heat shrink wrap&lt;br /&gt;
&lt;br /&gt;
=== Assembly ===&lt;br /&gt;
&lt;br /&gt;
Once you have acquired all necessary components, assemble the UART dongle as follows:&lt;br /&gt;
# Connect a jump wire from the GND pin on the USB-UART adapter to any one of the four GND pins on the USB-C breakout board (A1, A12, B1, or B12)&lt;br /&gt;
# Connect a jump wire from the RXD pin on the USB-UART adapter to the &amp;lt;code&amp;gt;UART2_TX_SUB1&amp;lt;/code&amp;gt; SBU1 pin on the USB-C breakout board (A8)&lt;br /&gt;
# Connect a jump wire from the TXD pin on the USB-UART adapter to the &amp;lt;code&amp;gt;UART2_RX_SUB2&amp;lt;/code&amp;gt; SBU2 pin on the USB-C breakout board (B8)&lt;br /&gt;
# Connect your Y-shaped jump wire from the 3.3V source pin on the USB-UART adapter to the CC1 and CC2 pins on the USB-C breakout board (A5 and B5)&lt;br /&gt;
# Wrap all metal connectors in electrical tape or heat shrink to prevent accidental shorts&lt;br /&gt;
&lt;br /&gt;
Be '''very certain''' of your connections for the 3.3V source and its cable, as there is a real risk of irreparably frying your PineNote if they're wrong!&lt;br /&gt;
Especially be sure you are connecting to a 3.3V source and not a 5V source.&lt;br /&gt;
&lt;br /&gt;
Note that if you mix up the TX/RX pins, it will still work but the USB-C breakout board will just plug into the PineNote upside down.&lt;br /&gt;
You can therefore choose which orientation you want by swapping the TX/RX pin connections.&lt;br /&gt;
Experience shows that RX/TX-TX/RX connections will have the PineNote face down while connected, while RX/RX-TX/TX connections will put the PineNote face up.&lt;br /&gt;
&lt;br /&gt;
== Using the dongle ==&lt;br /&gt;
&lt;br /&gt;
First, use your UART dongle to physically connect your PineNote to your computer:&lt;br /&gt;
# Plug the USB-UART adapter into one of your computer's USB ports&lt;br /&gt;
# Plug the USB-C breakout board into the USB-C port on the bottom of your PineNote; the orientation matters, so try both and remember which one works&lt;br /&gt;
&lt;br /&gt;
Once the hardware is connected, set up your computer's software as follows:&lt;br /&gt;
# Identify the USB-UART adapter in your &amp;lt;code&amp;gt;/dev&amp;lt;/code&amp;gt; directory by running &amp;lt;code&amp;gt;ls /dev&amp;lt;/code&amp;gt; with it plugged in, unplugging it, then again running &amp;lt;code&amp;gt;ls /dev&amp;lt;/code&amp;gt; and seeing what changed; it is likely to be called &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;&lt;br /&gt;
# Check your permissions; run &amp;lt;code&amp;gt;ls -l /dev/ttyUSB0&amp;lt;/code&amp;gt; to see which groups have access to the dongle (probably &amp;lt;code&amp;gt;dialout&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;uucp&amp;lt;/code&amp;gt;), and add your user to that group; remember you need to log out before group changes take effect&lt;br /&gt;
# Install [https://www.gnu.org/software/screen/ minicom] (or [https://askubuntu.com/q/40959 some other option], but the instructions below are written for &amp;lt;code&amp;gt;minicom&amp;lt;/code&amp;gt;)&lt;br /&gt;
# In a terminal window, run &amp;lt;code&amp;gt;minicom -D /dev/ttyUSB0 -b 1500000&amp;lt;/code&amp;gt; or run &amp;lt;code&amp;gt;minicom --setup&amp;lt;/code&amp;gt; to specify these settings by default&lt;br /&gt;
&lt;br /&gt;
Once the software is set up, power-cycle your PineNote; as the system boots you should see text appearing in your terminal window.&lt;br /&gt;
You can exit the session with &amp;lt;code&amp;gt;ctrl+a x&amp;lt;/code&amp;gt; then pressing &amp;lt;code&amp;gt;Enter&amp;lt;/code&amp;gt; to confirm.&lt;br /&gt;
Run &amp;lt;code&amp;gt;man minicom&amp;lt;/code&amp;gt; for more details.&lt;br /&gt;
&lt;br /&gt;
=== Sending commands ===&lt;br /&gt;
&lt;br /&gt;
Pressing &amp;lt;code&amp;gt;ctrl+a&amp;lt;/code&amp;gt; in &amp;lt;code&amp;gt;minicom&amp;lt;/code&amp;gt; enables you to send keystrokes to your PineNote.&lt;br /&gt;
The most important of these is &amp;lt;code&amp;gt;ctrl+c&amp;lt;/code&amp;gt;, which if sent during boot will put you in the U-Boot command prompt.&lt;br /&gt;
You can then type &amp;lt;code&amp;gt;help&amp;lt;/code&amp;gt; to list possible commands.&lt;br /&gt;
&lt;br /&gt;
=== Troubleshooting ===&lt;br /&gt;
&lt;br /&gt;
If you don't see any text in your terminal as the PineNote boots, or the text is garbled, try the following:&lt;br /&gt;
* Ensure your GND, RX/TX, and CC jump wires are connected to the correct pins on both the USB-UART adapter and the USB-C breakout board&lt;br /&gt;
* Connect your USB-C breakout board to your PineNote in the opposite orientation&lt;br /&gt;
* Run &amp;lt;code&amp;gt;minicom&amp;lt;/code&amp;gt; as sudo in case your user doesn't have appropriate permissions&lt;br /&gt;
* Ensure you are setting the baud rate in the &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt; command to 1500000 (1.5 million)&lt;br /&gt;
&lt;br /&gt;
If you can see text but are having trouble sending &amp;lt;code&amp;gt;ctrl+c&amp;lt;/code&amp;gt; to the PineNote during boot:&lt;br /&gt;
* Be sure you're typing &amp;lt;code&amp;gt;ctrl+a&amp;lt;/code&amp;gt; first, or whatever escape sequence your terminal emulator uses&lt;br /&gt;
* Send it right as the PineNote is booting, before the loading bar appears on screen&lt;br /&gt;
* Double-check your Y-shaped pull-up resistor cable; if this isn't working properly you'll probably be able to read text but not send text&lt;br /&gt;
&lt;br /&gt;
== USB passthrough ==&lt;br /&gt;
&lt;br /&gt;
If your USB-C breakout board has a passthrough/intercept design, you can connect to your PineNote over USB and UART at the same time.&lt;br /&gt;
This can be useful when you're doing development work on the PineNote boot process so you don't have to continually reconnect cables.&lt;br /&gt;
You'll need a USB-A to USB-C cable, connecting directly from your computer's USB-A hub to your USB-C breakout board's female USB-C port.&lt;br /&gt;
It's important to connect directly from USB-A, without any intermediate USB-C components.&lt;br /&gt;
Note that connecting a live USB cable to your USB-C breakout board in this way dramatically increases the danger of frying your PineNote with a short, so you should only do this if all connectors are safely wrapped in electrical tape.&lt;br /&gt;
&lt;br /&gt;
[[Category:PineNote]]&lt;/div&gt;</summary>
		<author><name>Ahelwer</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PineNote_Development/UART&amp;diff=20901</id>
		<title>PineNote Development/UART</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PineNote_Development/UART&amp;diff=20901"/>
		<updated>2023-10-14T13:18:32Z</updated>

		<summary type="html">&lt;p&gt;Ahelwer: /* Assembly */ added note about orientation&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Pinenote-uart-dongle.jpeg|thumb|Basic non-stock PineNote UART dongle]]&lt;br /&gt;
&lt;br /&gt;
This page contains information on creating and using a [https://en.wikipedia.org/wiki/Universal_asynchronous_receiver-transmitter UART] dongle for the [[PineNote]].&lt;br /&gt;
The PineNote was shipped with a compatible UART dongle, but replacements are not available to order in case of loss or hardware fault.&lt;br /&gt;
Thankfully it is not difficult to make your own from easily-acquired components and a small bit of soldering.&lt;br /&gt;
&lt;br /&gt;
Fear not if you've never soldered anything before!&lt;br /&gt;
This serves as an excellent first soldering project.&lt;br /&gt;
Borrow the tools from a friend, local hackerspace, or tool library.&lt;br /&gt;
Pine64 also makes [[Pinecil|a nice soldering iron]] themselves.&lt;br /&gt;
&lt;br /&gt;
A PineNote UART dongle enables you to:&lt;br /&gt;
# Interact with the system boot menu&lt;br /&gt;
# Read system events in real time as the PineNote is used&lt;br /&gt;
# Fix the PineNote without opening the case if something goes wrong while [[PineNote Development/Flashing|flashing it]]&lt;br /&gt;
&lt;br /&gt;
Since the PineNote is an embedded system, interfacing with it during boot is more complicated than with an ordinary computer.&lt;br /&gt;
The UART dongle enables you to do this.&lt;br /&gt;
&lt;br /&gt;
The PineNote factory firmware runs UART at a baud rate of 1500000 bps, 8 data bits, 1 stop bit, no parity and no flow control.&lt;br /&gt;
The process by which the PineNote design was modified to include closed-case UART is documented [[PineNote/Hardware Changes/Closed Case UART|here]].&lt;br /&gt;
&lt;br /&gt;
== Stock dongle ==&lt;br /&gt;
&lt;br /&gt;
The stock UART dongle included with the PineNote was a simple device plugging directly into the PineNote's USB-C port.&lt;br /&gt;
The dongle exposed a female USB-C port, which the user plugged into to get UART access.&lt;br /&gt;
This design unfortunately ruled out passthrough USB connections, where the user connects to the PineNote via UART and USB simultaneously.&lt;br /&gt;
The dongle is not currently available for purchase.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Pinenote-stock-uart-dongle-front.jpg|Front&lt;br /&gt;
Pinenote-stock-uart-dongle-back.jpg|Back&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Creating a dongle ==&lt;br /&gt;
&lt;br /&gt;
A typical self-built PineNote UART dongle design has the following components:&lt;br /&gt;
# A USB-C breakout board with a male connector exposing the 24 pins of the PineNote's USB-C port&lt;br /&gt;
# A USB-UART adapter, to plug into a USB port of the computer you'll use to interface with the PineNote&lt;br /&gt;
# [https://en.wikipedia.org/wiki/Jump_wire Jump wires] to connect specific breakout board pins to pins on the USB-UART adapter&lt;br /&gt;
# Two 1,000 Ohm through-hole resistors to splice into the jump wires&lt;br /&gt;
# Electrical tape or heat shrink to wrap connectors and prevent shorts&lt;br /&gt;
&lt;br /&gt;
You will also need the following tools:&lt;br /&gt;
# Soldering iron with solder&lt;br /&gt;
# Wire cutters &amp;amp; strippers&lt;br /&gt;
&lt;br /&gt;
The PineNote's internal UART system is documented in [https://files.pine64.org/doc/PineNote/PineNote_USB-C_Console_UART_breakout_board_schematic_v1.0_20210903.pdf this schematic].&lt;br /&gt;
The purpose of all 24 USB-C pins is documented [https://en.wikipedia.org/wiki/USB-C#Receptacles on the USB-C Wikipedia page].&lt;br /&gt;
We are interested in three sets of pins:&lt;br /&gt;
# The SBU1 (A8) and SBU2 (B8) side band use pins&lt;br /&gt;
# The CC1 (A5) and CC2 (B5) configuration channel pins&lt;br /&gt;
# The GND [https://en.wikipedia.org/wiki/Ground_(electricity) ground return] pins (A1, A12, B1, and B12)&lt;br /&gt;
&lt;br /&gt;
In the PineNote UART schematic you can see (on the bottom right diagram labeled &amp;lt;code&amp;gt;USB_TYPEC_Male&amp;lt;/code&amp;gt;) the side band pins are given the labels &amp;lt;code&amp;gt;UART2_TX_SUB1&amp;lt;/code&amp;gt; for A8 and &amp;lt;code&amp;gt;UART2_RX_SUB2&amp;lt;/code&amp;gt; for B8.&lt;br /&gt;
The first (TX) is used for transmitting data and the second (RX) is used for receiving data, from the perspective of the PineNote.&lt;br /&gt;
Also note the configuration channel pins labeled &amp;lt;code&amp;gt;TYPEC_CC1&amp;lt;/code&amp;gt; for A5 and &amp;lt;code&amp;gt;TYPEC_CC2&amp;lt;/code&amp;gt; for B5.&lt;br /&gt;
These pins are used to signal to the PineNote that a UART dongle is present.&lt;br /&gt;
The diagram shows they must be connected to a 3.3V source in parallel, mediated by resistors.&lt;br /&gt;
The schematic indicates 10,000 Ohm resistors, but community member Visti Andresen (talpadk) experimented and found 1,000 Ohm resistors work better.&lt;br /&gt;
Our mission is to wire up pins from a USB-UART adapter to a USB-C breakout board following these requirements.&lt;br /&gt;
&lt;br /&gt;
=== Buying components ===&lt;br /&gt;
&lt;br /&gt;
There are many possible USB-C breakout board designs available for purchase online.&lt;br /&gt;
One particularly useful design is a &amp;quot;passthrough&amp;quot; or &amp;quot;intercept&amp;quot; style, with both male and female USB-C ports.&lt;br /&gt;
This design is more versatile in case you want to reuse it in other projects, and also enables you to connect to the PineNote via UART and USB at the same time.&lt;br /&gt;
An example of this product can be found [https://pmdway.com/products/usb-3-1-type-c-male-to-female-breakout-test-board here], although you are encouraged to shop around for cheaper options.&lt;br /&gt;
If you're fine with a bit more soldering, there is a very cheap one [https://www.ebay.com/itm/275407037613 here].&lt;br /&gt;
&lt;br /&gt;
Similarly, there are many USB-UART adapter designs available.&lt;br /&gt;
These devices plug into your computer and expose a number of pins themselves, connecting to specific pins on the breakout board with jump wires.&lt;br /&gt;
It is important to get a 3.3V model, or at least a model with the option of 3.3V, as a 5V source might fry the PineNote.&lt;br /&gt;
[https://pmdway.com/products/usb-to-ttl-serial-cp2104-6-pin-converter-module Here] is one example with jump wires included, although you are again encouraged to shop around for alternatives.&lt;br /&gt;
&lt;br /&gt;
All other necessary components of our UART dongle are readily &amp;amp; cheaply available in many locations.&lt;br /&gt;
&lt;br /&gt;
=== Splicing resistors ===&lt;br /&gt;
&lt;br /&gt;
[[File:PineNote-UART-Y-pull-up-resistor-cable.jpg|thumb|The desired end result; wrap removed from resistors for illustration purposes.]]&lt;br /&gt;
&lt;br /&gt;
This is the only difficult part of the whole process.&lt;br /&gt;
Your goal is to create a Y-shaped jump wire with 1,000 Ohm through-hole resistors spliced into each of the twin arms.&lt;br /&gt;
The solitary leg will connect to a 3.3V source on your USB-UART adapter.&lt;br /&gt;
The twin arms will connect to the configuration channel pins on your USB-C breakout board.&lt;br /&gt;
This setup is called using pull-up resistors, and you can read a nice introduction to their purpose [https://www.electronics-tutorials.ws/logic/pull-up-resistor.html here].&lt;br /&gt;
&lt;br /&gt;
For this project you'll need:&lt;br /&gt;
# A soldering iron with solder&lt;br /&gt;
# Wire cutters &amp;amp; strippers&lt;br /&gt;
# 2x jumper wires, male/female as compatible with your board designs&lt;br /&gt;
# 2x 1,000 Ohm through-hole resistors&lt;br /&gt;
# Electrical tape or heat shrink wrap&lt;br /&gt;
&lt;br /&gt;
Consider buying extra jumper wires and resistors in case you mess up.&lt;br /&gt;
Also double-check that you have 1K resistors with [https://resistorcolorcodecalc.com/ this color code calculator].&lt;br /&gt;
Although the PineNote UART schematic says to use 10K Ohm resistors, community member Visti Andresen (talpadk) experimented and found 1K is more appropriate.&lt;br /&gt;
Assemble your Y-cable as follows:&lt;br /&gt;
# Graft one jump wire onto the other to form a Y shape using [https://www.youtube.com/watch?v=KpiEfuhPqew this] technique, ensuring solitary leg end is compatible with your USB-UART adapter&lt;br /&gt;
# Splice resistors into the twin arms using [https://www.youtube.com/watch?v=RMgMVqqjPZ0 this] technique&lt;br /&gt;
# Splice remaining jump wire onto the ends of the resistors, ensuring ends are compatible with your USB-C breakout board&lt;br /&gt;
# Cover all exposed wire &amp;amp; resistors with electrical tape or heat shrink wrap&lt;br /&gt;
&lt;br /&gt;
=== Assembly ===&lt;br /&gt;
&lt;br /&gt;
Once you have acquired all necessary components, assemble the UART dongle as follows:&lt;br /&gt;
# Connect a jump wire from the GND pin on the USB-UART adapter to any one of the four GND pins on the USB-C breakout board (A1, A12, B1, or B12)&lt;br /&gt;
# Connect a jump wire from the RXD pin on the USB-UART adapter to the &amp;lt;code&amp;gt;UART2_TX_SUB1&amp;lt;/code&amp;gt; SBU1 pin on the USB-C breakout board (A8)&lt;br /&gt;
# Connect a jump wire from the TXD pin on the USB-UART adapter to the &amp;lt;code&amp;gt;UART2_RX_SUB2&amp;lt;/code&amp;gt; SBU2 pin on the USB-C breakout board (B8)&lt;br /&gt;
# Connect your Y-shaped jump wire from the 3.3V source pin on the USB-UART adapter to the CC1 and CC2 pins on the USB-C breakout board (A5 and B5)&lt;br /&gt;
# Wrap all metal connectors in electrical tape or heat shrink to prevent accidental shorts&lt;br /&gt;
&lt;br /&gt;
Be '''very certain''' of your connections for the 3.3V source and its cable, as there is a real risk of irreparably frying your PineNote if they're wrong!&lt;br /&gt;
Especially be sure you are connecting to a 3.3V source and not a 5V source.&lt;br /&gt;
&lt;br /&gt;
Note that if you mix up the TX/RX pins, it will still work but the USB-C breakout board will just plug into the PineNote upside down.&lt;br /&gt;
You can therefore choose which orientation you want by swapping the TX/RX pin connections.&lt;br /&gt;
Experience shows that RX/TX-TX/RX connections will have the PineNote face down while connected, while RX/RX-TX/TX connections will put the PineNote face up.&lt;br /&gt;
&lt;br /&gt;
== Using UART ==&lt;br /&gt;
&lt;br /&gt;
First, use your UART dongle to physically connect your PineNote to your computer:&lt;br /&gt;
# Plug the USB-UART adapter into one of your computer's USB ports&lt;br /&gt;
# Plug the USB-C breakout board into the USB-C port on the bottom of your PineNote; the orientation matters, so try both and remember which one works&lt;br /&gt;
&lt;br /&gt;
Once the hardware is connected, set up your computer's software as follows:&lt;br /&gt;
# Install [https://www.gnu.org/software/screen/ GNU Screen] (or [https://askubuntu.com/q/40959 some other option], but the instructions below are written for &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt;)&lt;br /&gt;
# Identify the USB-UART adapter in your &amp;lt;code&amp;gt;/dev&amp;lt;/code&amp;gt; directory by running &amp;lt;code&amp;gt;ls /dev&amp;lt;/code&amp;gt; with it plugged in, unplugging it, then again running &amp;lt;code&amp;gt;ls /dev&amp;lt;/code&amp;gt; and seeing what changes; it is likely to be called &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;&lt;br /&gt;
# In a terminal window, run &amp;lt;code&amp;gt;screen -L /dev/ttyUSB0 1500000&amp;lt;/code&amp;gt; (you may need to run this as sudo depending on your user's permissions; on most Linux distributions you need to be in the &amp;lt;code&amp;gt;dialout&amp;lt;/code&amp;gt; usergroup)&lt;br /&gt;
&lt;br /&gt;
Once the software is set up, power-cycle your PineNote; as the system boots you should see text appearing in your terminal window.&lt;br /&gt;
You can exit the screen session with &amp;lt;code&amp;gt;ctrl+a k&amp;lt;/code&amp;gt; then pressing &amp;lt;code&amp;gt;y&amp;lt;/code&amp;gt; to confirm.&lt;br /&gt;
The &amp;lt;code&amp;gt;screen -L&amp;lt;/code&amp;gt; flag outputs a text log of the session to the current working directory, probably called &amp;lt;code&amp;gt;screenlog.0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Troubleshooting ====&lt;br /&gt;
&lt;br /&gt;
If you don't see any text in your terminal as the PineNote boots, or the text is garbled, try the following:&lt;br /&gt;
* Ensure your GND, RX/TX, and CC jump wires are connected to the correct pins on both the USB-UART adapter and the USB-C breakout board&lt;br /&gt;
* Connect your USB-C breakout board to your PineNote in the opposite orientation&lt;br /&gt;
* Run the screen command as sudo in case your user doesn't have appropriate permissions&lt;br /&gt;
* Ensure you are setting the baud rate in the &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt; command to 1500000 (1.5 million)&lt;br /&gt;
&lt;br /&gt;
== USB passthrough ==&lt;br /&gt;
&lt;br /&gt;
If your USB-C breakout board has a passthrough/intercept design, you can connect to your PineNote over USB and UART at the same time.&lt;br /&gt;
This can be useful when you're doing development work on the PineNote boot process so you don't have to continually reconnect cables.&lt;br /&gt;
You'll need a USB-A to USB-C cable, connecting directly from your computer's USB-A hub to your USB-C breakout board's female USB-C port.&lt;br /&gt;
It's important to connect directly from USB-A, without any intermediate USB-C components.&lt;br /&gt;
Note that connecting a live USB cable to your USB-C breakout board in this way dramatically increases the danger of frying your PineNote with a short, so you should only do this if all connectors are safely wrapped in electrical tape.&lt;br /&gt;
&lt;br /&gt;
[[Category:PineNote]]&lt;/div&gt;</summary>
		<author><name>Ahelwer</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PineNote_Development/UART&amp;diff=20900</id>
		<title>PineNote Development/UART</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PineNote_Development/UART&amp;diff=20900"/>
		<updated>2023-10-14T13:16:05Z</updated>

		<summary type="html">&lt;p&gt;Ahelwer: Added credit to talpadk&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Pinenote-uart-dongle.jpeg|thumb|Basic non-stock PineNote UART dongle]]&lt;br /&gt;
&lt;br /&gt;
This page contains information on creating and using a [https://en.wikipedia.org/wiki/Universal_asynchronous_receiver-transmitter UART] dongle for the [[PineNote]].&lt;br /&gt;
The PineNote was shipped with a compatible UART dongle, but replacements are not available to order in case of loss or hardware fault.&lt;br /&gt;
Thankfully it is not difficult to make your own from easily-acquired components and a small bit of soldering.&lt;br /&gt;
&lt;br /&gt;
Fear not if you've never soldered anything before!&lt;br /&gt;
This serves as an excellent first soldering project.&lt;br /&gt;
Borrow the tools from a friend, local hackerspace, or tool library.&lt;br /&gt;
Pine64 also makes [[Pinecil|a nice soldering iron]] themselves.&lt;br /&gt;
&lt;br /&gt;
A PineNote UART dongle enables you to:&lt;br /&gt;
# Interact with the system boot menu&lt;br /&gt;
# Read system events in real time as the PineNote is used&lt;br /&gt;
# Fix the PineNote without opening the case if something goes wrong while [[PineNote Development/Flashing|flashing it]]&lt;br /&gt;
&lt;br /&gt;
Since the PineNote is an embedded system, interfacing with it during boot is more complicated than with an ordinary computer.&lt;br /&gt;
The UART dongle enables you to do this.&lt;br /&gt;
&lt;br /&gt;
The PineNote factory firmware runs UART at a baud rate of 1500000 bps, 8 data bits, 1 stop bit, no parity and no flow control.&lt;br /&gt;
The process by which the PineNote design was modified to include closed-case UART is documented [[PineNote/Hardware Changes/Closed Case UART|here]].&lt;br /&gt;
&lt;br /&gt;
== Stock dongle ==&lt;br /&gt;
&lt;br /&gt;
The stock UART dongle included with the PineNote was a simple device plugging directly into the PineNote's USB-C port.&lt;br /&gt;
The dongle exposed a female USB-C port, which the user plugged into to get UART access.&lt;br /&gt;
This design unfortunately ruled out passthrough USB connections, where the user connects to the PineNote via UART and USB simultaneously.&lt;br /&gt;
The dongle is not currently available for purchase.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Pinenote-stock-uart-dongle-front.jpg|Front&lt;br /&gt;
Pinenote-stock-uart-dongle-back.jpg|Back&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Creating a dongle ==&lt;br /&gt;
&lt;br /&gt;
A typical self-built PineNote UART dongle design has the following components:&lt;br /&gt;
# A USB-C breakout board with a male connector exposing the 24 pins of the PineNote's USB-C port&lt;br /&gt;
# A USB-UART adapter, to plug into a USB port of the computer you'll use to interface with the PineNote&lt;br /&gt;
# [https://en.wikipedia.org/wiki/Jump_wire Jump wires] to connect specific breakout board pins to pins on the USB-UART adapter&lt;br /&gt;
# Two 1,000 Ohm through-hole resistors to splice into the jump wires&lt;br /&gt;
# Electrical tape or heat shrink to wrap connectors and prevent shorts&lt;br /&gt;
&lt;br /&gt;
You will also need the following tools:&lt;br /&gt;
# Soldering iron with solder&lt;br /&gt;
# Wire cutters &amp;amp; strippers&lt;br /&gt;
&lt;br /&gt;
The PineNote's internal UART system is documented in [https://files.pine64.org/doc/PineNote/PineNote_USB-C_Console_UART_breakout_board_schematic_v1.0_20210903.pdf this schematic].&lt;br /&gt;
The purpose of all 24 USB-C pins is documented [https://en.wikipedia.org/wiki/USB-C#Receptacles on the USB-C Wikipedia page].&lt;br /&gt;
We are interested in three sets of pins:&lt;br /&gt;
# The SBU1 (A8) and SBU2 (B8) side band use pins&lt;br /&gt;
# The CC1 (A5) and CC2 (B5) configuration channel pins&lt;br /&gt;
# The GND [https://en.wikipedia.org/wiki/Ground_(electricity) ground return] pins (A1, A12, B1, and B12)&lt;br /&gt;
&lt;br /&gt;
In the PineNote UART schematic you can see (on the bottom right diagram labeled &amp;lt;code&amp;gt;USB_TYPEC_Male&amp;lt;/code&amp;gt;) the side band pins are given the labels &amp;lt;code&amp;gt;UART2_TX_SUB1&amp;lt;/code&amp;gt; for A8 and &amp;lt;code&amp;gt;UART2_RX_SUB2&amp;lt;/code&amp;gt; for B8.&lt;br /&gt;
The first (TX) is used for transmitting data and the second (RX) is used for receiving data, from the perspective of the PineNote.&lt;br /&gt;
Also note the configuration channel pins labeled &amp;lt;code&amp;gt;TYPEC_CC1&amp;lt;/code&amp;gt; for A5 and &amp;lt;code&amp;gt;TYPEC_CC2&amp;lt;/code&amp;gt; for B5.&lt;br /&gt;
These pins are used to signal to the PineNote that a UART dongle is present.&lt;br /&gt;
The diagram shows they must be connected to a 3.3V source in parallel, mediated by resistors.&lt;br /&gt;
The schematic indicates 10,000 Ohm resistors, but community member Visti Andresen (talpadk) experimented and found 1,000 Ohm resistors work better.&lt;br /&gt;
Our mission is to wire up pins from a USB-UART adapter to a USB-C breakout board following these requirements.&lt;br /&gt;
&lt;br /&gt;
=== Buying components ===&lt;br /&gt;
&lt;br /&gt;
There are many possible USB-C breakout board designs available for purchase online.&lt;br /&gt;
One particularly useful design is a &amp;quot;passthrough&amp;quot; or &amp;quot;intercept&amp;quot; style, with both male and female USB-C ports.&lt;br /&gt;
This design is more versatile in case you want to reuse it in other projects, and also enables you to connect to the PineNote via UART and USB at the same time.&lt;br /&gt;
An example of this product can be found [https://pmdway.com/products/usb-3-1-type-c-male-to-female-breakout-test-board here], although you are encouraged to shop around for cheaper options.&lt;br /&gt;
If you're fine with a bit more soldering, there is a very cheap one [https://www.ebay.com/itm/275407037613 here].&lt;br /&gt;
&lt;br /&gt;
Similarly, there are many USB-UART adapter designs available.&lt;br /&gt;
These devices plug into your computer and expose a number of pins themselves, connecting to specific pins on the breakout board with jump wires.&lt;br /&gt;
It is important to get a 3.3V model, or at least a model with the option of 3.3V, as a 5V source might fry the PineNote.&lt;br /&gt;
[https://pmdway.com/products/usb-to-ttl-serial-cp2104-6-pin-converter-module Here] is one example with jump wires included, although you are again encouraged to shop around for alternatives.&lt;br /&gt;
&lt;br /&gt;
All other necessary components of our UART dongle are readily &amp;amp; cheaply available in many locations.&lt;br /&gt;
&lt;br /&gt;
=== Splicing resistors ===&lt;br /&gt;
&lt;br /&gt;
[[File:PineNote-UART-Y-pull-up-resistor-cable.jpg|thumb|The desired end result; wrap removed from resistors for illustration purposes.]]&lt;br /&gt;
&lt;br /&gt;
This is the only difficult part of the whole process.&lt;br /&gt;
Your goal is to create a Y-shaped jump wire with 1,000 Ohm through-hole resistors spliced into each of the twin arms.&lt;br /&gt;
The solitary leg will connect to a 3.3V source on your USB-UART adapter.&lt;br /&gt;
The twin arms will connect to the configuration channel pins on your USB-C breakout board.&lt;br /&gt;
This setup is called using pull-up resistors, and you can read a nice introduction to their purpose [https://www.electronics-tutorials.ws/logic/pull-up-resistor.html here].&lt;br /&gt;
&lt;br /&gt;
For this project you'll need:&lt;br /&gt;
# A soldering iron with solder&lt;br /&gt;
# Wire cutters &amp;amp; strippers&lt;br /&gt;
# 2x jumper wires, male/female as compatible with your board designs&lt;br /&gt;
# 2x 1,000 Ohm through-hole resistors&lt;br /&gt;
# Electrical tape or heat shrink wrap&lt;br /&gt;
&lt;br /&gt;
Consider buying extra jumper wires and resistors in case you mess up.&lt;br /&gt;
Also double-check that you have 1K resistors with [https://resistorcolorcodecalc.com/ this color code calculator].&lt;br /&gt;
Although the PineNote UART schematic says to use 10K Ohm resistors, community member Visti Andresen (talpadk) experimented and found 1K is more appropriate.&lt;br /&gt;
Assemble your Y-cable as follows:&lt;br /&gt;
# Graft one jump wire onto the other to form a Y shape using [https://www.youtube.com/watch?v=KpiEfuhPqew this] technique, ensuring solitary leg end is compatible with your USB-UART adapter&lt;br /&gt;
# Splice resistors into the twin arms using [https://www.youtube.com/watch?v=RMgMVqqjPZ0 this] technique&lt;br /&gt;
# Splice remaining jump wire onto the ends of the resistors, ensuring ends are compatible with your USB-C breakout board&lt;br /&gt;
# Cover all exposed wire &amp;amp; resistors with electrical tape or heat shrink wrap&lt;br /&gt;
&lt;br /&gt;
=== Assembly ===&lt;br /&gt;
&lt;br /&gt;
Once you have acquired all necessary components, assemble the UART dongle as follows:&lt;br /&gt;
# Connect a jump wire from the GND pin on the USB-UART adapter to any one of the four GND pins on the USB-C breakout board (A1, A12, B1, or B12)&lt;br /&gt;
# Connect a jump wire from the RXD pin on the USB-UART adapter to the &amp;lt;code&amp;gt;UART2_TX_SUB1&amp;lt;/code&amp;gt; SBU1 pin on the USB-C breakout board (A8)&lt;br /&gt;
# Connect a jump wire from the TXD pin on the USB-UART adapter to the &amp;lt;code&amp;gt;UART2_RX_SUB2&amp;lt;/code&amp;gt; SBU2 pin on the USB-C breakout board (B8)&lt;br /&gt;
# Connect your Y-shaped jump wire from the 3.3V source pin on the USB-UART adapter to the CC1 and CC2 pins on the USB-C breakout board (A5 and B5)&lt;br /&gt;
# Wrap all metal connectors in electrical tape or heat shrink to prevent accidental shorts&lt;br /&gt;
&lt;br /&gt;
Be '''very certain''' of your connections for the 3.3V source and its cable, as there is a real risk of irreparably frying your PineNote if they're wrong!&lt;br /&gt;
Especially be sure you are connecting to a 3.3V source and not a 5V source.&lt;br /&gt;
&lt;br /&gt;
Note that if you mix up the TX/RX pins, it will still work but the USB-C breakout board will just plug into the PineNote upside down.&lt;br /&gt;
You can therefore choose which orientation you want by swapping the TX/RX pin connections.&lt;br /&gt;
&lt;br /&gt;
== Using UART ==&lt;br /&gt;
&lt;br /&gt;
First, use your UART dongle to physically connect your PineNote to your computer:&lt;br /&gt;
# Plug the USB-UART adapter into one of your computer's USB ports&lt;br /&gt;
# Plug the USB-C breakout board into the USB-C port on the bottom of your PineNote; the orientation matters, so try both and remember which one works&lt;br /&gt;
&lt;br /&gt;
Once the hardware is connected, set up your computer's software as follows:&lt;br /&gt;
# Install [https://www.gnu.org/software/screen/ GNU Screen] (or [https://askubuntu.com/q/40959 some other option], but the instructions below are written for &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt;)&lt;br /&gt;
# Identify the USB-UART adapter in your &amp;lt;code&amp;gt;/dev&amp;lt;/code&amp;gt; directory by running &amp;lt;code&amp;gt;ls /dev&amp;lt;/code&amp;gt; with it plugged in, unplugging it, then again running &amp;lt;code&amp;gt;ls /dev&amp;lt;/code&amp;gt; and seeing what changes; it is likely to be called &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;&lt;br /&gt;
# In a terminal window, run &amp;lt;code&amp;gt;screen -L /dev/ttyUSB0 1500000&amp;lt;/code&amp;gt; (you may need to run this as sudo depending on your user's permissions; on most Linux distributions you need to be in the &amp;lt;code&amp;gt;dialout&amp;lt;/code&amp;gt; usergroup)&lt;br /&gt;
&lt;br /&gt;
Once the software is set up, power-cycle your PineNote; as the system boots you should see text appearing in your terminal window.&lt;br /&gt;
You can exit the screen session with &amp;lt;code&amp;gt;ctrl+a k&amp;lt;/code&amp;gt; then pressing &amp;lt;code&amp;gt;y&amp;lt;/code&amp;gt; to confirm.&lt;br /&gt;
The &amp;lt;code&amp;gt;screen -L&amp;lt;/code&amp;gt; flag outputs a text log of the session to the current working directory, probably called &amp;lt;code&amp;gt;screenlog.0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Troubleshooting ====&lt;br /&gt;
&lt;br /&gt;
If you don't see any text in your terminal as the PineNote boots, or the text is garbled, try the following:&lt;br /&gt;
* Ensure your GND, RX/TX, and CC jump wires are connected to the correct pins on both the USB-UART adapter and the USB-C breakout board&lt;br /&gt;
* Connect your USB-C breakout board to your PineNote in the opposite orientation&lt;br /&gt;
* Run the screen command as sudo in case your user doesn't have appropriate permissions&lt;br /&gt;
* Ensure you are setting the baud rate in the &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt; command to 1500000 (1.5 million)&lt;br /&gt;
&lt;br /&gt;
== USB passthrough ==&lt;br /&gt;
&lt;br /&gt;
If your USB-C breakout board has a passthrough/intercept design, you can connect to your PineNote over USB and UART at the same time.&lt;br /&gt;
This can be useful when you're doing development work on the PineNote boot process so you don't have to continually reconnect cables.&lt;br /&gt;
You'll need a USB-A to USB-C cable, connecting directly from your computer's USB-A hub to your USB-C breakout board's female USB-C port.&lt;br /&gt;
It's important to connect directly from USB-A, without any intermediate USB-C components.&lt;br /&gt;
Note that connecting a live USB cable to your USB-C breakout board in this way dramatically increases the danger of frying your PineNote with a short, so you should only do this if all connectors are safely wrapped in electrical tape.&lt;br /&gt;
&lt;br /&gt;
[[Category:PineNote]]&lt;/div&gt;</summary>
		<author><name>Ahelwer</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PineNote_Development/UART&amp;diff=20899</id>
		<title>PineNote Development/UART</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PineNote_Development/UART&amp;diff=20899"/>
		<updated>2023-10-14T13:14:26Z</updated>

		<summary type="html">&lt;p&gt;Ahelwer: Added link to pinecil&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Pinenote-uart-dongle.jpeg|thumb|Basic non-stock PineNote UART dongle]]&lt;br /&gt;
&lt;br /&gt;
This page contains information on creating and using a [https://en.wikipedia.org/wiki/Universal_asynchronous_receiver-transmitter UART] dongle for the [[PineNote]].&lt;br /&gt;
The PineNote was shipped with a compatible UART dongle, but replacements are not available to order in case of loss or hardware fault.&lt;br /&gt;
Thankfully it is not difficult to make your own from easily-acquired components and a small bit of soldering.&lt;br /&gt;
&lt;br /&gt;
Fear not if you've never soldered anything before!&lt;br /&gt;
This serves as an excellent first soldering project.&lt;br /&gt;
Borrow the tools from a friend, local hackerspace, or tool library.&lt;br /&gt;
Pine64 also makes [[Pinecil|a nice soldering iron]] themselves.&lt;br /&gt;
&lt;br /&gt;
A PineNote UART dongle enables you to:&lt;br /&gt;
# Interact with the system boot menu&lt;br /&gt;
# Read system events in real time as the PineNote is used&lt;br /&gt;
# Fix the PineNote without opening the case if something goes wrong while [[PineNote Development/Flashing|flashing it]]&lt;br /&gt;
&lt;br /&gt;
Since the PineNote is an embedded system, interfacing with it during boot is more complicated than with an ordinary computer.&lt;br /&gt;
The UART dongle enables you to do this.&lt;br /&gt;
&lt;br /&gt;
The PineNote factory firmware runs UART at a baud rate of 1500000 bps, 8 data bits, 1 stop bit, no parity and no flow control.&lt;br /&gt;
The process by which the PineNote design was modified to include closed-case UART is documented [[PineNote/Hardware Changes/Closed Case UART|here]].&lt;br /&gt;
&lt;br /&gt;
== Stock dongle ==&lt;br /&gt;
&lt;br /&gt;
The stock UART dongle included with the PineNote was a simple device plugging directly into the PineNote's USB-C port.&lt;br /&gt;
The dongle exposed a female USB-C port, which the user plugged into to get UART access.&lt;br /&gt;
This design unfortunately ruled out passthrough USB connections, where the user connects to the PineNote via UART and USB simultaneously.&lt;br /&gt;
The dongle is not currently available for purchase.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Pinenote-stock-uart-dongle-front.jpg|Front&lt;br /&gt;
Pinenote-stock-uart-dongle-back.jpg|Back&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Creating a dongle ==&lt;br /&gt;
&lt;br /&gt;
A typical self-built PineNote UART dongle design has the following components:&lt;br /&gt;
# A USB-C breakout board with a male connector exposing the 24 pins of the PineNote's USB-C port&lt;br /&gt;
# A USB-UART adapter, to plug into a USB port of the computer you'll use to interface with the PineNote&lt;br /&gt;
# [https://en.wikipedia.org/wiki/Jump_wire Jump wires] to connect specific breakout board pins to pins on the USB-UART adapter&lt;br /&gt;
# Two 1,000 Ohm through-hole resistors to splice into the jump wires&lt;br /&gt;
# Electrical tape or heat shrink to wrap connectors and prevent shorts&lt;br /&gt;
&lt;br /&gt;
You will also need the following tools:&lt;br /&gt;
# Soldering iron with solder&lt;br /&gt;
# Wire cutters &amp;amp; strippers&lt;br /&gt;
&lt;br /&gt;
The PineNote's internal UART system is documented in [https://files.pine64.org/doc/PineNote/PineNote_USB-C_Console_UART_breakout_board_schematic_v1.0_20210903.pdf this schematic].&lt;br /&gt;
The purpose of all 24 USB-C pins is documented [https://en.wikipedia.org/wiki/USB-C#Receptacles on the USB-C Wikipedia page].&lt;br /&gt;
We are interested in three sets of pins:&lt;br /&gt;
# The SBU1 (A8) and SBU2 (B8) side band use pins&lt;br /&gt;
# The CC1 (A5) and CC2 (B5) configuration channel pins&lt;br /&gt;
# The GND [https://en.wikipedia.org/wiki/Ground_(electricity) ground return] pins (A1, A12, B1, and B12)&lt;br /&gt;
&lt;br /&gt;
In the PineNote UART schematic you can see (on the bottom right diagram labeled &amp;lt;code&amp;gt;USB_TYPEC_Male&amp;lt;/code&amp;gt;) the side band pins are given the labels &amp;lt;code&amp;gt;UART2_TX_SUB1&amp;lt;/code&amp;gt; for A8 and &amp;lt;code&amp;gt;UART2_RX_SUB2&amp;lt;/code&amp;gt; for B8.&lt;br /&gt;
The first (TX) is used for transmitting data and the second (RX) is used for receiving data, from the perspective of the PineNote.&lt;br /&gt;
Also note the configuration channel pins labeled &amp;lt;code&amp;gt;TYPEC_CC1&amp;lt;/code&amp;gt; for A5 and &amp;lt;code&amp;gt;TYPEC_CC2&amp;lt;/code&amp;gt; for B5.&lt;br /&gt;
These pins are used to signal to the PineNote that a UART dongle is present.&lt;br /&gt;
The diagram shows they must be connected to a 3.3V source in parallel, mediated by resistors.&lt;br /&gt;
The schematic indicates 10,000 Ohm resistors, but community member talpadk experimented and found 1,000 Ohm resistors work better.&lt;br /&gt;
Our mission is to wire up pins from a USB-UART adapter to a USB-C breakout board following these requirements.&lt;br /&gt;
&lt;br /&gt;
=== Buying components ===&lt;br /&gt;
&lt;br /&gt;
There are many possible USB-C breakout board designs available for purchase online.&lt;br /&gt;
One particularly useful design is a &amp;quot;passthrough&amp;quot; or &amp;quot;intercept&amp;quot; style, with both male and female USB-C ports.&lt;br /&gt;
This design is more versatile in case you want to reuse it in other projects, and also enables you to connect to the PineNote via UART and USB at the same time.&lt;br /&gt;
An example of this product can be found [https://pmdway.com/products/usb-3-1-type-c-male-to-female-breakout-test-board here], although you are encouraged to shop around for cheaper options.&lt;br /&gt;
If you're fine with a bit more soldering, there is a very cheap one [https://www.ebay.com/itm/275407037613 here].&lt;br /&gt;
&lt;br /&gt;
Similarly, there are many USB-UART adapter designs available.&lt;br /&gt;
These devices plug into your computer and expose a number of pins themselves, connecting to specific pins on the breakout board with jump wires.&lt;br /&gt;
It is important to get a 3.3V model, or at least a model with the option of 3.3V, as a 5V source might fry the PineNote.&lt;br /&gt;
[https://pmdway.com/products/usb-to-ttl-serial-cp2104-6-pin-converter-module Here] is one example with jump wires included, although you are again encouraged to shop around for alternatives.&lt;br /&gt;
&lt;br /&gt;
All other necessary components of our UART dongle are readily &amp;amp; cheaply available in many locations.&lt;br /&gt;
&lt;br /&gt;
=== Splicing resistors ===&lt;br /&gt;
&lt;br /&gt;
[[File:PineNote-UART-Y-pull-up-resistor-cable.jpg|thumb|The desired end result; wrap removed from resistors for illustration purposes.]]&lt;br /&gt;
&lt;br /&gt;
This is the only difficult part of the whole process.&lt;br /&gt;
Your goal is to create a Y-shaped jump wire with 1,000 Ohm through-hole resistors spliced into each of the twin arms.&lt;br /&gt;
The solitary leg will connect to a 3.3V source on your USB-UART adapter.&lt;br /&gt;
The twin arms will connect to the configuration channel pins on your USB-C breakout board.&lt;br /&gt;
This setup is called using pull-up resistors, and you can read a nice introduction to their purpose [https://www.electronics-tutorials.ws/logic/pull-up-resistor.html here].&lt;br /&gt;
&lt;br /&gt;
For this project you'll need:&lt;br /&gt;
# A soldering iron with solder&lt;br /&gt;
# Wire cutters &amp;amp; strippers&lt;br /&gt;
# 2x jumper wires, male/female as compatible with your board designs&lt;br /&gt;
# 2x 1,000 Ohm through-hole resistors&lt;br /&gt;
# Electrical tape or heat shrink wrap&lt;br /&gt;
&lt;br /&gt;
Consider buying extra jumper wires and resistors in case you mess up.&lt;br /&gt;
Also double-check that you have 1K resistors with [https://resistorcolorcodecalc.com/ this color code calculator].&lt;br /&gt;
Although the PineNote UART schematic says to use 10K Ohm resistors, community member talpadk experimented and found 1K is more appropriate.&lt;br /&gt;
Assemble your Y-cable as follows:&lt;br /&gt;
# Graft one jump wire onto the other to form a Y shape using [https://www.youtube.com/watch?v=KpiEfuhPqew this] technique, ensuring solitary leg end is compatible with your USB-UART adapter&lt;br /&gt;
# Splice resistors into the twin arms using [https://www.youtube.com/watch?v=RMgMVqqjPZ0 this] technique&lt;br /&gt;
# Splice remaining jump wire onto the ends of the resistors, ensuring ends are compatible with your USB-C breakout board&lt;br /&gt;
# Cover all exposed wire &amp;amp; resistors with electrical tape or heat shrink wrap&lt;br /&gt;
&lt;br /&gt;
=== Assembly ===&lt;br /&gt;
&lt;br /&gt;
Once you have acquired all necessary components, assemble the UART dongle as follows:&lt;br /&gt;
# Connect a jump wire from the GND pin on the USB-UART adapter to any one of the four GND pins on the USB-C breakout board (A1, A12, B1, or B12)&lt;br /&gt;
# Connect a jump wire from the RXD pin on the USB-UART adapter to the &amp;lt;code&amp;gt;UART2_TX_SUB1&amp;lt;/code&amp;gt; SBU1 pin on the USB-C breakout board (A8)&lt;br /&gt;
# Connect a jump wire from the TXD pin on the USB-UART adapter to the &amp;lt;code&amp;gt;UART2_RX_SUB2&amp;lt;/code&amp;gt; SBU2 pin on the USB-C breakout board (B8)&lt;br /&gt;
# Connect your Y-shaped jump wire from the 3.3V source pin on the USB-UART adapter to the CC1 and CC2 pins on the USB-C breakout board (A5 and B5)&lt;br /&gt;
# Wrap all metal connectors in electrical tape or heat shrink to prevent accidental shorts&lt;br /&gt;
&lt;br /&gt;
Be '''very certain''' of your connections for the 3.3V source and its cable, as there is a real risk of irreparably frying your PineNote if they're wrong!&lt;br /&gt;
Especially be sure you are connecting to a 3.3V source and not a 5V source.&lt;br /&gt;
&lt;br /&gt;
Note that if you mix up the TX/RX pins, it will still work but the USB-C breakout board will just plug into the PineNote upside down.&lt;br /&gt;
You can therefore choose which orientation you want by swapping the TX/RX pin connections.&lt;br /&gt;
&lt;br /&gt;
== Using UART ==&lt;br /&gt;
&lt;br /&gt;
First, use your UART dongle to physically connect your PineNote to your computer:&lt;br /&gt;
# Plug the USB-UART adapter into one of your computer's USB ports&lt;br /&gt;
# Plug the USB-C breakout board into the USB-C port on the bottom of your PineNote; the orientation matters, so try both and remember which one works&lt;br /&gt;
&lt;br /&gt;
Once the hardware is connected, set up your computer's software as follows:&lt;br /&gt;
# Install [https://www.gnu.org/software/screen/ GNU Screen] (or [https://askubuntu.com/q/40959 some other option], but the instructions below are written for &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt;)&lt;br /&gt;
# Identify the USB-UART adapter in your &amp;lt;code&amp;gt;/dev&amp;lt;/code&amp;gt; directory by running &amp;lt;code&amp;gt;ls /dev&amp;lt;/code&amp;gt; with it plugged in, unplugging it, then again running &amp;lt;code&amp;gt;ls /dev&amp;lt;/code&amp;gt; and seeing what changes; it is likely to be called &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;&lt;br /&gt;
# In a terminal window, run &amp;lt;code&amp;gt;screen -L /dev/ttyUSB0 1500000&amp;lt;/code&amp;gt; (you may need to run this as sudo depending on your user's permissions; on most Linux distributions you need to be in the &amp;lt;code&amp;gt;dialout&amp;lt;/code&amp;gt; usergroup)&lt;br /&gt;
&lt;br /&gt;
Once the software is set up, power-cycle your PineNote; as the system boots you should see text appearing in your terminal window.&lt;br /&gt;
You can exit the screen session with &amp;lt;code&amp;gt;ctrl+a k&amp;lt;/code&amp;gt; then pressing &amp;lt;code&amp;gt;y&amp;lt;/code&amp;gt; to confirm.&lt;br /&gt;
The &amp;lt;code&amp;gt;screen -L&amp;lt;/code&amp;gt; flag outputs a text log of the session to the current working directory, probably called &amp;lt;code&amp;gt;screenlog.0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Troubleshooting ====&lt;br /&gt;
&lt;br /&gt;
If you don't see any text in your terminal as the PineNote boots, or the text is garbled, try the following:&lt;br /&gt;
* Ensure your GND, RX/TX, and CC jump wires are connected to the correct pins on both the USB-UART adapter and the USB-C breakout board&lt;br /&gt;
* Connect your USB-C breakout board to your PineNote in the opposite orientation&lt;br /&gt;
* Run the screen command as sudo in case your user doesn't have appropriate permissions&lt;br /&gt;
* Ensure you are setting the baud rate in the &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt; command to 1500000 (1.5 million)&lt;br /&gt;
&lt;br /&gt;
== USB passthrough ==&lt;br /&gt;
&lt;br /&gt;
If your USB-C breakout board has a passthrough/intercept design, you can connect to your PineNote over USB and UART at the same time.&lt;br /&gt;
This can be useful when you're doing development work on the PineNote boot process so you don't have to continually reconnect cables.&lt;br /&gt;
You'll need a USB-A to USB-C cable, connecting directly from your computer's USB-A hub to your USB-C breakout board's female USB-C port.&lt;br /&gt;
It's important to connect directly from USB-A, without any intermediate USB-C components.&lt;br /&gt;
Note that connecting a live USB cable to your USB-C breakout board in this way dramatically increases the danger of frying your PineNote with a short, so you should only do this if all connectors are safely wrapped in electrical tape.&lt;br /&gt;
&lt;br /&gt;
[[Category:PineNote]]&lt;/div&gt;</summary>
		<author><name>Ahelwer</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PineNote_Development/UART&amp;diff=20898</id>
		<title>PineNote Development/UART</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PineNote_Development/UART&amp;diff=20898"/>
		<updated>2023-10-14T02:22:37Z</updated>

		<summary type="html">&lt;p&gt;Ahelwer: /* Troubleshooting */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Pinenote-uart-dongle.jpeg|thumb|Basic non-stock PineNote UART dongle]]&lt;br /&gt;
&lt;br /&gt;
This page contains information on creating and using a [https://en.wikipedia.org/wiki/Universal_asynchronous_receiver-transmitter UART] dongle for the [[PineNote]].&lt;br /&gt;
The PineNote was shipped with a compatible UART dongle, but replacements are not available to order in case of loss or hardware fault.&lt;br /&gt;
Thankfully it is not difficult to make your own from easily-acquired components and a small bit of soldering.&lt;br /&gt;
Fear not if you've never soldered anything before!&lt;br /&gt;
This serves as an excellent first soldering project.&lt;br /&gt;
Borrow the tools from a friend, local hackerspace, or tool library.&lt;br /&gt;
&lt;br /&gt;
A PineNote UART dongle enables you to:&lt;br /&gt;
# Interact with the system boot menu&lt;br /&gt;
# Read system events in real time as the PineNote is used&lt;br /&gt;
# Fix the PineNote without opening the case if something goes wrong while [[PineNote Development/Flashing|flashing it]]&lt;br /&gt;
&lt;br /&gt;
Since the PineNote is an embedded system, interfacing with it during boot is more complicated than with an ordinary computer.&lt;br /&gt;
The UART dongle enables you to do this.&lt;br /&gt;
&lt;br /&gt;
The PineNote factory firmware runs UART at a baud rate of 1500000 bps, 8 data bits, 1 stop bit, no parity and no flow control.&lt;br /&gt;
The process by which the PineNote design was modified to include closed-case UART is documented [[PineNote/Hardware Changes/Closed Case UART|here]].&lt;br /&gt;
&lt;br /&gt;
== Stock dongle ==&lt;br /&gt;
&lt;br /&gt;
The stock UART dongle included with the PineNote was a simple device plugging directly into the PineNote's USB-C port.&lt;br /&gt;
The dongle exposed a female USB-C port, which the user plugged into to get UART access.&lt;br /&gt;
This design unfortunately ruled out passthrough USB connections, where the user connects to the PineNote via UART and USB simultaneously.&lt;br /&gt;
The dongle is not currently available for purchase.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Pinenote-stock-uart-dongle-front.jpg|Front&lt;br /&gt;
Pinenote-stock-uart-dongle-back.jpg|Back&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Creating a dongle ==&lt;br /&gt;
&lt;br /&gt;
A typical self-built PineNote UART dongle design has the following components:&lt;br /&gt;
# A USB-C breakout board with a male connector exposing the 24 pins of the PineNote's USB-C port&lt;br /&gt;
# A USB-UART adapter, to plug into a USB port of the computer you'll use to interface with the PineNote&lt;br /&gt;
# [https://en.wikipedia.org/wiki/Jump_wire Jump wires] to connect specific breakout board pins to pins on the USB-UART adapter&lt;br /&gt;
# Two 1,000 Ohm through-hole resistors to splice into the jump wires&lt;br /&gt;
# Electrical tape or heat shrink to wrap connectors and prevent shorts&lt;br /&gt;
&lt;br /&gt;
You will also need the following tools:&lt;br /&gt;
# Soldering iron with solder&lt;br /&gt;
# Wire cutters &amp;amp; strippers&lt;br /&gt;
&lt;br /&gt;
The PineNote's internal UART system is documented in [https://files.pine64.org/doc/PineNote/PineNote_USB-C_Console_UART_breakout_board_schematic_v1.0_20210903.pdf this schematic].&lt;br /&gt;
The purpose of all 24 USB-C pins is documented [https://en.wikipedia.org/wiki/USB-C#Receptacles on the USB-C Wikipedia page].&lt;br /&gt;
We are interested in three sets of pins:&lt;br /&gt;
# The SBU1 (A8) and SBU2 (B8) side band use pins&lt;br /&gt;
# The CC1 (A5) and CC2 (B5) configuration channel pins&lt;br /&gt;
# The GND [https://en.wikipedia.org/wiki/Ground_(electricity) ground return] pins (A1, A12, B1, and B12)&lt;br /&gt;
&lt;br /&gt;
In the PineNote UART schematic you can see (on the bottom right diagram labeled &amp;lt;code&amp;gt;USB_TYPEC_Male&amp;lt;/code&amp;gt;) the side band pins are given the labels &amp;lt;code&amp;gt;UART2_TX_SUB1&amp;lt;/code&amp;gt; for A8 and &amp;lt;code&amp;gt;UART2_RX_SUB2&amp;lt;/code&amp;gt; for B8.&lt;br /&gt;
The first (TX) is used for transmitting data and the second (RX) is used for receiving data, from the perspective of the PineNote.&lt;br /&gt;
Also note the configuration channel pins labeled &amp;lt;code&amp;gt;TYPEC_CC1&amp;lt;/code&amp;gt; for A5 and &amp;lt;code&amp;gt;TYPEC_CC2&amp;lt;/code&amp;gt; for B5.&lt;br /&gt;
These pins are used to signal to the PineNote that a UART dongle is present.&lt;br /&gt;
The diagram shows they must be connected to a 3.3V source in parallel, mediated by resistors.&lt;br /&gt;
The schematic indicates 10,000 Ohm resistors, but community member talpadk experimented and found 1,000 Ohm resistors work better.&lt;br /&gt;
Our mission is to wire up pins from a USB-UART adapter to a USB-C breakout board following these requirements.&lt;br /&gt;
&lt;br /&gt;
=== Buying components ===&lt;br /&gt;
&lt;br /&gt;
There are many possible USB-C breakout board designs available for purchase online.&lt;br /&gt;
One particularly useful design is a &amp;quot;passthrough&amp;quot; or &amp;quot;intercept&amp;quot; style, with both male and female USB-C ports.&lt;br /&gt;
This design is more versatile in case you want to reuse it in other projects, and also enables you to connect to the PineNote via UART and USB at the same time.&lt;br /&gt;
An example of this product can be found [https://pmdway.com/products/usb-3-1-type-c-male-to-female-breakout-test-board here], although you are encouraged to shop around for cheaper options.&lt;br /&gt;
If you're fine with a bit more soldering, there is a very cheap one [https://www.ebay.com/itm/275407037613 here].&lt;br /&gt;
&lt;br /&gt;
Similarly, there are many USB-UART adapter designs available.&lt;br /&gt;
These devices plug into your computer and expose a number of pins themselves, connecting to specific pins on the breakout board with jump wires.&lt;br /&gt;
It is important to get a 3.3V model, or at least a model with the option of 3.3V, as a 5V source might fry the PineNote.&lt;br /&gt;
[https://pmdway.com/products/usb-to-ttl-serial-cp2104-6-pin-converter-module Here] is one example with jump wires included, although you are again encouraged to shop around for alternatives.&lt;br /&gt;
&lt;br /&gt;
All other necessary components of our UART dongle are readily &amp;amp; cheaply available in many locations.&lt;br /&gt;
&lt;br /&gt;
=== Splicing resistors ===&lt;br /&gt;
&lt;br /&gt;
[[File:PineNote-UART-Y-pull-up-resistor-cable.jpg|thumb|The desired end result; wrap removed from resistors for illustration purposes.]]&lt;br /&gt;
&lt;br /&gt;
This is the only difficult part of the whole process.&lt;br /&gt;
Your goal is to create a Y-shaped jump wire with 1,000 Ohm through-hole resistors spliced into each of the twin arms.&lt;br /&gt;
The solitary leg will connect to a 3.3V source on your USB-UART adapter.&lt;br /&gt;
The twin arms will connect to the configuration channel pins on your USB-C breakout board.&lt;br /&gt;
This setup is called using pull-up resistors, and you can read a nice introduction to their purpose [https://www.electronics-tutorials.ws/logic/pull-up-resistor.html here].&lt;br /&gt;
&lt;br /&gt;
For this project you'll need:&lt;br /&gt;
# A soldering iron with solder&lt;br /&gt;
# Wire cutters &amp;amp; strippers&lt;br /&gt;
# 2x jumper wires, male/female as compatible with your board designs&lt;br /&gt;
# 2x 1,000 Ohm through-hole resistors&lt;br /&gt;
# Electrical tape or heat shrink wrap&lt;br /&gt;
&lt;br /&gt;
Consider buying extra jumper wires and resistors in case you mess up.&lt;br /&gt;
Also double-check that you have 1K resistors with [https://resistorcolorcodecalc.com/ this color code calculator].&lt;br /&gt;
Although the PineNote UART schematic says to use 10K Ohm resistors, community member talpadk experimented and found 1K is more appropriate.&lt;br /&gt;
Assemble your Y-cable as follows:&lt;br /&gt;
# Graft one jump wire onto the other to form a Y shape using [https://www.youtube.com/watch?v=KpiEfuhPqew this] technique, ensuring solitary leg end is compatible with your USB-UART adapter&lt;br /&gt;
# Splice resistors into the twin arms using [https://www.youtube.com/watch?v=RMgMVqqjPZ0 this] technique&lt;br /&gt;
# Splice remaining jump wire onto the ends of the resistors, ensuring ends are compatible with your USB-C breakout board&lt;br /&gt;
# Cover all exposed wire &amp;amp; resistors with electrical tape or heat shrink wrap&lt;br /&gt;
&lt;br /&gt;
=== Assembly ===&lt;br /&gt;
&lt;br /&gt;
Once you have acquired all necessary components, assemble the UART dongle as follows:&lt;br /&gt;
# Connect a jump wire from the GND pin on the USB-UART adapter to any one of the four GND pins on the USB-C breakout board (A1, A12, B1, or B12)&lt;br /&gt;
# Connect a jump wire from the RXD pin on the USB-UART adapter to the &amp;lt;code&amp;gt;UART2_TX_SUB1&amp;lt;/code&amp;gt; SBU1 pin on the USB-C breakout board (A8)&lt;br /&gt;
# Connect a jump wire from the TXD pin on the USB-UART adapter to the &amp;lt;code&amp;gt;UART2_RX_SUB2&amp;lt;/code&amp;gt; SBU2 pin on the USB-C breakout board (B8)&lt;br /&gt;
# Connect your Y-shaped jump wire from the 3.3V source pin on the USB-UART adapter to the CC1 and CC2 pins on the USB-C breakout board (A5 and B5)&lt;br /&gt;
# Wrap all metal connectors in electrical tape or heat shrink to prevent accidental shorts&lt;br /&gt;
&lt;br /&gt;
Be '''very certain''' of your connections for the 3.3V source and its cable, as there is a real risk of irreparably frying your PineNote if they're wrong!&lt;br /&gt;
Especially be sure you are connecting to a 3.3V source and not a 5V source.&lt;br /&gt;
&lt;br /&gt;
Note that if you mix up the TX/RX pins, it will still work but the USB-C breakout board will just plug into the PineNote upside down.&lt;br /&gt;
You can therefore choose which orientation you want by swapping the TX/RX pin connections.&lt;br /&gt;
&lt;br /&gt;
== Using UART ==&lt;br /&gt;
&lt;br /&gt;
First, use your UART dongle to physically connect your PineNote to your computer:&lt;br /&gt;
# Plug the USB-UART adapter into one of your computer's USB ports&lt;br /&gt;
# Plug the USB-C breakout board into the USB-C port on the bottom of your PineNote; the orientation matters, so try both and remember which one works&lt;br /&gt;
&lt;br /&gt;
Once the hardware is connected, set up your computer's software as follows:&lt;br /&gt;
# Install [https://www.gnu.org/software/screen/ GNU Screen] (or [https://askubuntu.com/q/40959 some other option], but the instructions below are written for &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt;)&lt;br /&gt;
# Identify the USB-UART adapter in your &amp;lt;code&amp;gt;/dev&amp;lt;/code&amp;gt; directory by running &amp;lt;code&amp;gt;ls /dev&amp;lt;/code&amp;gt; with it plugged in, unplugging it, then again running &amp;lt;code&amp;gt;ls /dev&amp;lt;/code&amp;gt; and seeing what changes; it is likely to be called &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;&lt;br /&gt;
# In a terminal window, run &amp;lt;code&amp;gt;screen -L /dev/ttyUSB0 1500000&amp;lt;/code&amp;gt; (you may need to run this as sudo depending on your user's permissions; on most Linux distributions you need to be in the &amp;lt;code&amp;gt;dialout&amp;lt;/code&amp;gt; usergroup)&lt;br /&gt;
&lt;br /&gt;
Once the software is set up, power-cycle your PineNote; as the system boots you should see text appearing in your terminal window.&lt;br /&gt;
You can exit the screen session with &amp;lt;code&amp;gt;ctrl+a k&amp;lt;/code&amp;gt; then pressing &amp;lt;code&amp;gt;y&amp;lt;/code&amp;gt; to confirm.&lt;br /&gt;
The &amp;lt;code&amp;gt;screen -L&amp;lt;/code&amp;gt; flag outputs a text log of the session to the current working directory, probably called &amp;lt;code&amp;gt;screenlog.0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Troubleshooting ====&lt;br /&gt;
&lt;br /&gt;
If you don't see any text in your terminal as the PineNote boots, or the text is garbled, try the following:&lt;br /&gt;
* Ensure your GND, RX/TX, and CC jump wires are connected to the correct pins on both the USB-UART adapter and the USB-C breakout board&lt;br /&gt;
* Connect your USB-C breakout board to your PineNote in the opposite orientation&lt;br /&gt;
* Run the screen command as sudo in case your user doesn't have appropriate permissions&lt;br /&gt;
* Ensure you are setting the baud rate in the &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt; command to 1500000 (1.5 million)&lt;br /&gt;
&lt;br /&gt;
== USB passthrough ==&lt;br /&gt;
&lt;br /&gt;
If your USB-C breakout board has a passthrough/intercept design, you can connect to your PineNote over USB and UART at the same time.&lt;br /&gt;
This can be useful when you're doing development work on the PineNote boot process so you don't have to continually reconnect cables.&lt;br /&gt;
You'll need a USB-A to USB-C cable, connecting directly from your computer's USB-A hub to your USB-C breakout board's female USB-C port.&lt;br /&gt;
It's important to connect directly from USB-A, without any intermediate USB-C components.&lt;br /&gt;
Note that connecting a live USB cable to your USB-C breakout board in this way dramatically increases the danger of frying your PineNote with a short, so you should only do this if all connectors are safely wrapped in electrical tape.&lt;br /&gt;
&lt;br /&gt;
[[Category:PineNote]]&lt;/div&gt;</summary>
		<author><name>Ahelwer</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PineNote&amp;diff=20897</id>
		<title>PineNote</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PineNote&amp;diff=20897"/>
		<updated>2023-10-14T02:20:25Z</updated>

		<summary type="html">&lt;p&gt;Ahelwer: /* UART Dongle */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:PineNote-1.jpg|400px|thumb|right|The PineNote]]&lt;br /&gt;
&lt;br /&gt;
The '''PineNote''' is the first hybrid notepad computer device combination of notebook, tablet and e-reader using an e-ink panel. It is derived from the Quartz64 model A SBC and powered by a Rockchip RK3566 quad-core ARM Cortex A55 64-bit processor with a MALI G-52 GPU.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
=== State of the software ===&lt;br /&gt;
&lt;br /&gt;
The PineNote is based on the in 2021 released Rockchip RK3566 SoC. The upstreaming status of the SoC functionality can be found on the [[Quartz64 Development#Upstreaming Status|Quartz64 development]] wiki page of the Quartz64 single-board computer using the same SoC. In the [[PineNote_Development#Kernel_modules_/_mainlining_status|PineNote development]] wiki page you'll find the items specific for the PineNote.&lt;br /&gt;
&lt;br /&gt;
The early adopter's batch of the PineNote is aimed solely at early adopters - more specifically, the units are solely intended to find their way into the hands of users with extensive Linux experience. If you’re looking to buy a PineNote in the first batch, you must expect to write software for it, not to write notes on it. The software shipping from the factory for the first batch will not be suitable for taking notes, reading e-books, or writing your dissertation. It may not even boot to a graphical environment.&lt;br /&gt;
&lt;br /&gt;
An early version of a GNOME-based Debian image is available for [[PineNote_Software_Releases|testing]], but should not be expected to meet general-user readiness.&lt;br /&gt;
&lt;br /&gt;
=== Help and support ===&lt;br /&gt;
&lt;br /&gt;
Still have any questions regarding software, shipping, or ordering after reading this wiki? Please don't hesitate to contact the community in the bridged community channels for detailed answers or simply to chat with friendly people in the community! See [[Main Page#Community and Support]]. &lt;br /&gt;
&lt;br /&gt;
Please keep in mind that PINE64 is not like a regular company (see the [https://www.pine64.org/philosophy/ PINE64 philosophy]) and that support resources are limited - the best way to get support quickly is to ask in the community chat! Please only contact the PINE64 support directly if questions couldn't be solved via the community chat or this wiki.&lt;br /&gt;
&lt;br /&gt;
== Software releases ==&lt;br /&gt;
While there are no robust and tested operating system releases for the PineNote available at this time, various linux distributions can be installed on the PineNote, with various degrees of working functionality.&lt;br /&gt;
Operating system software releases, or efforts to create them, can be found in the [[PineNote Software Releases]] section. Please join the development effort and help creating one.&lt;br /&gt;
&lt;br /&gt;
== Development efforts ==&lt;br /&gt;
&lt;br /&gt;
The following page discusses the development efforts for the PineNote:&lt;br /&gt;
&lt;br /&gt;
* [[PineNote Development]] for general information regarding how to flash the device and other development information.&lt;br /&gt;
&lt;br /&gt;
=== Software ===&lt;br /&gt;
&lt;br /&gt;
* [[PineNote Development/Flashing]] for general flashing instructions of data to the PineNote&lt;br /&gt;
* [[PineNote Development/TODOs]]&lt;br /&gt;
&lt;br /&gt;
==== Linux Kernel ====&lt;br /&gt;
&lt;br /&gt;
* [[RK3566 EBC Reverse-Engineering]] for the EBC (eInk Panel) driver.&lt;br /&gt;
* [[PineNote Development/Building Kernel]]&lt;br /&gt;
* BSP Linux SDK version 4.19 for the PineNote and [[Quartz64|Quartz64 Model A]]:&lt;br /&gt;
** [http://files.pine64.org/SDK/Quartz64/QUARTZ64-model-A_BSP%20Linux.tar.gz Direct download] from ''pine64.org'' (32.67GB, MD5 of the TAR-GZip file ''24554419aec29700add97167a3a4c9ed'')&lt;br /&gt;
** [https://tmp.mwfc.info/pinenote/QUARTZ64-model-A_BSP%20Linux.tar.gz Mirror by mwfc]&lt;br /&gt;
** An unofficial torrent download provided by a community member of the BSP Linux and Android SDKs can be found [https://cdn.discordapp.com/attachments/870707390998282292/907726420204208148/pinenote.torrent here] (100GB).&lt;br /&gt;
&lt;br /&gt;
==== User Space ====&lt;br /&gt;
&lt;br /&gt;
* [[PineNote Development/Booting Linux]]&lt;br /&gt;
&lt;br /&gt;
For tweaks and tricks see:&lt;br /&gt;
* [[PineNote Development/Software Tweaks]]&lt;br /&gt;
&lt;br /&gt;
For app development see:&lt;br /&gt;
* [[PineNote Development/Apps]]&lt;br /&gt;
&lt;br /&gt;
==== Android ====&lt;br /&gt;
&lt;br /&gt;
Android 11 e-ink SDK for the PineNote and [[Quartz64|Quartz64 Model A]. This is the Android SDK build for 10.3&amp;quot; eink panels on Quartz64 Model A. &lt;br /&gt;
&lt;br /&gt;
Download:&lt;br /&gt;
* [http://files.pine64.org/SDK/Quartz64/QUARTZ64-model-A_eink.android11_SDK.tar.gz Direct download] from ''pine64.org'' (72.88GB, MD5 of the TAR-GZip file ''293a550584298de4fb95ceae18103672'')&lt;br /&gt;
* [https://tmp.mwfc.info/pinenote/QUARTZ64-model-A_eink.android11_SDK.tar.gz Mirror by mwfc]&lt;br /&gt;
* An unofficial torrent download provided by a community member of the BSP Linux and Android SDKs can be found [https://cdn.discordapp.com/attachments/870707390998282292/907726420204208148/pinenote.torrent here] (100GB).&lt;br /&gt;
* Just the boot blobs (&amp;lt;1MB): [[File:Rk35-blobs.tar.gz]]&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
* View [[Android SDK for RK3566]] for more information how to compile an image for the PineNote using this SDK&lt;br /&gt;
&lt;br /&gt;
==== Related ====&lt;br /&gt;
* [[Quartz64 Development]] for the mainlining status of various functions on the Rockchip RK3566 SoC.&lt;br /&gt;
&lt;br /&gt;
=== Hardware ===&lt;br /&gt;
&lt;br /&gt;
This section includes discussions and their results regarding hardware changes and debugging of the PineNote.&lt;br /&gt;
&lt;br /&gt;
==== Resolved issues ====&lt;br /&gt;
&lt;br /&gt;
The following topics have resolved:&lt;br /&gt;
&lt;br /&gt;
* [[PineNote/Hardware Changes/Closed Case UART]]&lt;br /&gt;
* '''Could the USB-C port support USB 3.1 5Gbps?''' Yes and no. The RK3566 only has a host-mode 5Gbps controller, meaning it can only negotiate such a high data rate with a device such as a flash drive. When the RK3566 is acting as a device, it only supports 480Mbps transfer rates. The hardware required to switch between these modes would raise the PineNote's price unreasonably. Therefore, the USB-C port will remain at USB 2.0 speeds for Host and Device mode.&lt;br /&gt;
* '''Could the USB-C port output DisplayPort?''' Yes and no. The hardware required to support such a feature would raise the PineNote's price unreasonably. Therefore, DisplayPort output will not be possible through the USB-C port.&lt;br /&gt;
* '''Where is the microSD card slot?''' The case design of the PineNote is fixed, making physical changes like adding a microSD card slot would raise the cost unreasonably.&lt;br /&gt;
* '''How will I install software to the PineNote?''' This is a hardware and software question. If the software on your PineNote is completely broken and cannot boot to a recoverable state, a Hall (magnet) sensor was fitted to the PineTab motherboard as U9009. This sensor is attached to SARADC_VIN0_KEY/RECOVERY on the RK3566. With the device powered off, and screen face down, holding a magnet over U9009 and plugging in a USB-C cable causes the device to boot into [http://opensource.rock-chips.com/wiki_Rockusb &amp;quot;rockusb&amp;quot;] flash mode. With proper flashing software and drivers, it should be possible to load a new operating system using rockusb if the system is soft-bricked. Of course, software vendors will need to be more careful with flashing firmware and providing useful &amp;quot;recovery&amp;quot; options on this device due to this process's relative difficulty to other PINE64 devices.&lt;br /&gt;
* [[PineNote/Battery Replacement]]&lt;br /&gt;
&lt;br /&gt;
==== Unresolved issues ====&lt;br /&gt;
&lt;br /&gt;
The following concerns have been brought up as open, unanswered topics:&lt;br /&gt;
&lt;br /&gt;
* Does [https://en.wikipedia.org/wiki/USB-C#Audio_Adapter_Accessory_Mode_2|USB-C Audio Adapter Accessory Mode] work? It appears that the Headphone output of the audio codec was routed to the USB-C audio+USB switch, but it's unclear whether CC lines are hooked up correctly for detection of such a device. The PineNote hardware team will be testing this functionality soon (as of August 19, 2021). Note that Audio Accessory mode is detectable by reading the I2C registers of the WUSB3801Q. So connecting ASEL to a GPIO would be enough to get this working if it is not working already.&lt;br /&gt;
* Why is the Headphone output of the audio codec routed to the speakers? HPL_OUT is routed from the RK817 PMIC and audio codec to U9010 (the USB-C switch) and U6 (the audio amplifier). SPK_OUT is unused. It seems like SPK_OUT should be routed to U6 and HPL_OUT to U9010.&lt;br /&gt;
* Nitpick: The cold white charging LED bleeds through the gap between the rear case and the device's face. It does not bleed onto the screen, but it is jarring in low-light conditions or when the screen is amber. Could be resolved in software by turning off the charge LED when the screen is on.&lt;br /&gt;
* Is there any way to indicate when the device is in rockusb mode, such as connecting a certain magic pin to the power LED?&lt;br /&gt;
* The modem/4G connector (J6010) has its I2C and UART pins unconnected. Could those be connected to the SoC?&lt;br /&gt;
&lt;br /&gt;
==== UART Dongle ====&lt;br /&gt;
{{Note|See main article: [[PineNote Development/UART]]}}&lt;br /&gt;
&lt;br /&gt;
The USB UART dongle delivered with the PineNote allows you to have access to a serial port via USB-C Debug Accessory Mode (''DAM'') without having to open up the device. &lt;br /&gt;
The factory firmware runs at a baud rate of 1500000bps, 8 data bits 1 stop bit, no parity and no flow control. The USB-C male end should go into the PineNote and the female end can be connected with a standard USB-C cable to your computer.&lt;br /&gt;
&lt;br /&gt;
It is relatively easy to build your own UART interface with a USB-C breakout board (for example https://www.ebay.com/itm/275407037613), two resistors and a 3.3V USB serial adapter. It is basically just two 1K pull up resistors (R3, R4), the data sheet values of 10K isn't whats on the real hardware, see the [https://files.pine64.org/doc/PineNote/PineNote_USB-C_Console_UART_breakout_board_schematic_v1.0_20210903.pdf schematic]. The pull ups enable the serial output on SBU1 and SBU2 you can use with any 3.3V USB serial adapter.&lt;br /&gt;
&lt;br /&gt;
The UART dongle is not necessary to flash the PineNote, but is essential if something goes wrong to fix it without having to open the case.&lt;br /&gt;
&lt;br /&gt;
You can flash premade images with the following links:&lt;br /&gt;
* https://github.com/m-weigand/pinenote_uboot_patching_dorians_backup (Note: this creates a U-Boot image to flash, do not worry about idblock.bin on the instructions for the next link)&lt;br /&gt;
* https://github.com/m-weigand/pinenote-debian-recipes/releases/&lt;br /&gt;
&lt;br /&gt;
== Specification ==&lt;br /&gt;
[[File:PineNote_Pen_function.jpg|300px|right]]&lt;br /&gt;
[[File:PineNote_Cover-1.jpg|300px|right]]&lt;br /&gt;
&lt;br /&gt;
=== General Information  ===&lt;br /&gt;
* Dimensions: 191.1x232.5x7.4mm&lt;br /&gt;
* Weight: 438g&lt;br /&gt;
&lt;br /&gt;
=== Core  ===&lt;br /&gt;
* CPU: RK3566 1.8GHz 64-bit quad-core A55&lt;br /&gt;
* GPU: MALI G52 2EE&lt;br /&gt;
* System memory: 4GB LPDDR4&lt;br /&gt;
* Flash: 128GB eMMC&lt;br /&gt;
&lt;br /&gt;
=== E-ink Display ===&lt;br /&gt;
* Size: 10.3&amp;quot;&lt;br /&gt;
* Resolution: 1404x1872&lt;br /&gt;
* DPI: 227&lt;br /&gt;
* Grayscale: 16&lt;br /&gt;
* Front Light: 36 level cold and warm &lt;br /&gt;
* Capacitive multi-touch panel&lt;br /&gt;
* EMR pen digitizer&lt;br /&gt;
&lt;br /&gt;
=== Network ===&lt;br /&gt;
* WiFi: 2.4/5GHz 802.11a/b/g/n/ac&lt;br /&gt;
* Bluetooth: 5.0&lt;br /&gt;
&lt;br /&gt;
=== Audio ===&lt;br /&gt;
* Built in stereo speakers&lt;br /&gt;
* 4 x DMIC microphone&lt;br /&gt;
&lt;br /&gt;
=== Sensor ===&lt;br /&gt;
* G-Sensor for portrait and landscape sensing&lt;br /&gt;
&lt;br /&gt;
=== Power ===&lt;br /&gt;
* 4000mAH LiPo battery&lt;br /&gt;
* DC 5V @ 3A USB-C connector&lt;br /&gt;
&lt;br /&gt;
=== Accessories ===&lt;br /&gt;
* Optional EMR pen with magnetic attachment (included in the first production batch)&lt;br /&gt;
* Optional Cover (included in the first production batch)&lt;br /&gt;
&lt;br /&gt;
== SoC and Memory Specifications ==&lt;br /&gt;
* Based on [https://www.rock-chips.com/a/en/products/RK35_Series/2021/0113/1274.html Rockchip RK3566]&lt;br /&gt;
[[File:RK3566_icon.png|right]]&lt;br /&gt;
&lt;br /&gt;
=== CPU Architecture ===&lt;br /&gt;
* [https://developer.arm.com/ip-products/processors/cortex-a/cortex-a55 Quad-core ARM Cortex-A55@1.8GHz]&lt;br /&gt;
* AArch32 for full backwards compatibility with ARMv7&lt;br /&gt;
* ARM Neon Advanced SIMD (single instruction, multiple data) support for accelerated media and signal processing computation&lt;br /&gt;
* Includes VFP hardware to support single and double-precision operations&lt;br /&gt;
* ARMv8 Cryptography Extensions&lt;br /&gt;
* Integrated 32KB L1 instruction cache and 32KB L1 data cache per core&lt;br /&gt;
* 512KB unified system L3 cache&lt;br /&gt;
* [https://developer.arm.com/ip-products/security-ip/trustzone TrustZone] technology support&lt;br /&gt;
* [https://www.cnx-software.com/2020/12/01/rockchip-rk3568-processor-to-power-edge-computing-and-nvr-applications 22nm process, believed to be FD-SOI]&lt;br /&gt;
&lt;br /&gt;
=== GPU (Graphics Processing Unit) Capabilities ===&lt;br /&gt;
* [https://developer.arm.com/ip-products/graphics-and-multimedia/mali-gpus/mali-g52-gpu Mali-G52 2EE Bifrost GPU@800MHz]&lt;br /&gt;
* 4x Multi-Sampling Anti-Aliasing (MSAA) with minimal performance drop &lt;br /&gt;
* 128KB L2 Cache configurations&lt;br /&gt;
* Supports OpenGL ES 1.1, 2.0, and 3.2&lt;br /&gt;
* Supports Vulkan 1.0 and 1.1&lt;br /&gt;
* Supports OpenCL 2.0 Full Profile&lt;br /&gt;
* Supports 1600 Mpix/s fill rate when at 800MHz clock frequency&lt;br /&gt;
* Supports 38.4 GLOP/s when at 800MHz clock frequency   &lt;br /&gt;
&lt;br /&gt;
=== NPU (Neural Processing Unit) Capabilities ===&lt;br /&gt;
* Neural network acceleration engine with processing performance of up to 0.8 TOPS&lt;br /&gt;
* Supports integer 8 and integer 16 convolution operations&lt;br /&gt;
* Supports the following deep learning frameworks: TensorFlow, TF-lite, Pytorch, Caffe, ONNX, MXNet, Keras, Darknet&lt;br /&gt;
&lt;br /&gt;
=== System Memory ===&lt;br /&gt;
* RAM Memory : 4GB LPDDR4.&lt;br /&gt;
* Flash Memory: 128GB eMMC&lt;br /&gt;
&lt;br /&gt;
== Information, Schematics, and Certifications ==&lt;br /&gt;
&lt;br /&gt;
=== PineNote Developer kit version ===&lt;br /&gt;
Version v1.2 is the PineNote production version that was sold through the Pines64 store&lt;br /&gt;
* [https://files.pine64.org/doc/PineNote/PINENOTE_MAIN-V1R2%20-%20Schematic-20210824.pdf PineNote Mainboard Schematic ver 1.2 20210824 PDF file]&lt;br /&gt;
* [https://files.pine64.org/doc/PineNote/PINENOTE_USB-C-Board-V1.0-sch.pdf PineNote USB-C Daughter Board Schematic ver 1.0 PDF file]&lt;br /&gt;
* [https://files.pine64.org/doc/PineNote/PineNote_USB-C_Console_UART_breakout_board_schematic_v1.0_20210903.pdf PineNote USB-C Console UART Breakout Board Schematic ver 1.0 PDF file] Note: When building USB-C console breakout board, please be aware 10k CC pin pull-up is too weak to pull CC to logically high level. Replacing it to lower resistance, such as 1k is recommended.&lt;br /&gt;
&lt;br /&gt;
The v1.1 is early release schematic just for reference only and used by developers who received the prototype. &lt;br /&gt;
* [https://files.pine64.org/doc/PineNote/PINENOTE_MAIN-V1R1%20-%20Schematic-20210726.pdf PineNote early released Schematic ver 1.1 20210726 PDF file]&lt;br /&gt;
* [https://files.pine64.org/doc/PineNote/PINENOTE_MAIN-V1R1-REF-TOP-20210726.pdf PineNote early released ver 1.1 20210726 PCB Connector placement PDF file]&lt;br /&gt;
&lt;br /&gt;
Certifications:&lt;br /&gt;
* [https://files.pine64.org/doc/cert/PineNote%20FCC15C%20Certificate%20DTS-TC561262.pdf PineNote FCC-15C Certificate]&lt;br /&gt;
* [https://files.pine64.org/doc/cert/PineNote%20FCC15E%20Certificate%20NII-TC973072.pdf PineNote FCC-15E Certificate]&lt;br /&gt;
* [https://files.pine64.org/doc/cert/PineNote%20CE%20RED%20Certicate%20ET-21090682EC.pdf PineNote CE RED Certificate]&lt;br /&gt;
* [https://files.pine64.org/doc/cert/PineNote%20RoHS%20Certificate%20ET-210900082C.pdf PineNote ROHS Certificate]&lt;br /&gt;
&lt;br /&gt;
== Datasheets for Components and Peripherals ==&lt;br /&gt;
&lt;br /&gt;
Rockchip RK3566 SoC information:&lt;br /&gt;
* [https://files.pine64.org/doc/quartz64/Rockchip%20RK3566%20Datasheet%20V1.0-20201210.pdf Rockchip RK3566 ver 1.0 datasheet, release permission from Rockchip]&lt;br /&gt;
&lt;br /&gt;
Rockchip RK817 PMU (Power Management Unit) Information:&lt;br /&gt;
* [https://www.rockchip.fr/RK817%20datasheet%20V1.01.pdf Rockchip RK817 version 1.01 datasheet]&lt;br /&gt;
&lt;br /&gt;
LPDDR4 (200 Balls) SDRAM:&lt;br /&gt;
* ---&lt;br /&gt;
&lt;br /&gt;
eMMC information:&lt;br /&gt;
* [https://en.biwin.com.cn/product/detail/6 Biwin 128GB eMMC model: BWCTASC41P128G]  &lt;br /&gt;
&lt;br /&gt;
E-ink Panel information:&lt;br /&gt;
* [https://files.pine64.org/doc/quartz64/Eink%20P-511-828-V1_ED103TC2%20Formal%20Spec%20V1.0_20190514.pdf E-Ink 10.3&amp;quot; 1872x1404 ED103TC2 Glass Panel Specification]&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/PineNote/TI%20PMU-TPS651851.pdf TPS65185x PMIC for E-Ink Enabled Electronic Paper Display Datasheet]&lt;br /&gt;
&lt;br /&gt;
Touch Screen information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/PineNote/CYTMA448_Summary_RevC_5-26-16.pdf Cypress CYTMA448 multi-Point Capacitive Touch Controller Datasheet]&lt;br /&gt;
* Wacom Pen Digitizer Unit Model: SUDE-10S15MI-01X for 10.3&amp;quot; Display Module&lt;br /&gt;
&lt;br /&gt;
WiFi/BT module information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/rockpro64/AW-CM256SM_DS_DF_V1.9_STD.pdf Azurewave CM256SM 11AC WiFi + Bluetooth5.0 Datasheet]]&lt;br /&gt;
&lt;br /&gt;
G Sensor information:&lt;br /&gt;
* [http://www.silan.com.cn/en/product/details/47.html#app01 Silan SC7A20 3-Axis MEMS Accelerometer]&lt;br /&gt;
&lt;br /&gt;
Audio Amplifier information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/PineNote/Awinic%20AW87318%20Class-K%20Audio%20Amp%20Datasheet.pdf Awinic AW87318 Class-K Audio Amp Datasheet]&lt;br /&gt;
&lt;br /&gt;
== Resources ==&lt;br /&gt;
* [[PineNote Press]]&lt;br /&gt;
&lt;br /&gt;
[[Category:PineNote]] [[Category:Rockchip RK3566]]&lt;/div&gt;</summary>
		<author><name>Ahelwer</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PineNote_Development/UART&amp;diff=20896</id>
		<title>PineNote Development/UART</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PineNote_Development/UART&amp;diff=20896"/>
		<updated>2023-10-14T02:17:48Z</updated>

		<summary type="html">&lt;p&gt;Ahelwer: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Pinenote-uart-dongle.jpeg|thumb|Basic non-stock PineNote UART dongle]]&lt;br /&gt;
&lt;br /&gt;
This page contains information on creating and using a [https://en.wikipedia.org/wiki/Universal_asynchronous_receiver-transmitter UART] dongle for the [[PineNote]].&lt;br /&gt;
The PineNote was shipped with a compatible UART dongle, but replacements are not available to order in case of loss or hardware fault.&lt;br /&gt;
Thankfully it is not difficult to make your own from easily-acquired components and a small bit of soldering.&lt;br /&gt;
Fear not if you've never soldered anything before!&lt;br /&gt;
This serves as an excellent first soldering project.&lt;br /&gt;
Borrow the tools from a friend, local hackerspace, or tool library.&lt;br /&gt;
&lt;br /&gt;
A PineNote UART dongle enables you to:&lt;br /&gt;
# Interact with the system boot menu&lt;br /&gt;
# Read system events in real time as the PineNote is used&lt;br /&gt;
# Fix the PineNote without opening the case if something goes wrong while [[PineNote Development/Flashing|flashing it]]&lt;br /&gt;
&lt;br /&gt;
Since the PineNote is an embedded system, interfacing with it during boot is more complicated than with an ordinary computer.&lt;br /&gt;
The UART dongle enables you to do this.&lt;br /&gt;
&lt;br /&gt;
The PineNote factory firmware runs UART at a baud rate of 1500000 bps, 8 data bits, 1 stop bit, no parity and no flow control.&lt;br /&gt;
The process by which the PineNote design was modified to include closed-case UART is documented [[PineNote/Hardware Changes/Closed Case UART|here]].&lt;br /&gt;
&lt;br /&gt;
== Stock dongle ==&lt;br /&gt;
&lt;br /&gt;
The stock UART dongle included with the PineNote was a simple device plugging directly into the PineNote's USB-C port.&lt;br /&gt;
The dongle exposed a female USB-C port, which the user plugged into to get UART access.&lt;br /&gt;
This design unfortunately ruled out passthrough USB connections, where the user connects to the PineNote via UART and USB simultaneously.&lt;br /&gt;
The dongle is not currently available for purchase.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Pinenote-stock-uart-dongle-front.jpg|Front&lt;br /&gt;
Pinenote-stock-uart-dongle-back.jpg|Back&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Creating a dongle ==&lt;br /&gt;
&lt;br /&gt;
A typical self-built PineNote UART dongle design has the following components:&lt;br /&gt;
# A USB-C breakout board with a male connector exposing the 24 pins of the PineNote's USB-C port&lt;br /&gt;
# A USB-UART adapter, to plug into a USB port of the computer you'll use to interface with the PineNote&lt;br /&gt;
# [https://en.wikipedia.org/wiki/Jump_wire Jump wires] to connect specific breakout board pins to pins on the USB-UART adapter&lt;br /&gt;
# Two 1,000 Ohm through-hole resistors to splice into the jump wires&lt;br /&gt;
# Electrical tape or heat shrink to wrap connectors and prevent shorts&lt;br /&gt;
&lt;br /&gt;
You will also need the following tools:&lt;br /&gt;
# Soldering iron with solder&lt;br /&gt;
# Wire cutters &amp;amp; strippers&lt;br /&gt;
&lt;br /&gt;
The PineNote's internal UART system is documented in [https://files.pine64.org/doc/PineNote/PineNote_USB-C_Console_UART_breakout_board_schematic_v1.0_20210903.pdf this schematic].&lt;br /&gt;
The purpose of all 24 USB-C pins is documented [https://en.wikipedia.org/wiki/USB-C#Receptacles on the USB-C Wikipedia page].&lt;br /&gt;
We are interested in three sets of pins:&lt;br /&gt;
# The SBU1 (A8) and SBU2 (B8) side band use pins&lt;br /&gt;
# The CC1 (A5) and CC2 (B5) configuration channel pins&lt;br /&gt;
# The GND [https://en.wikipedia.org/wiki/Ground_(electricity) ground return] pins (A1, A12, B1, and B12)&lt;br /&gt;
&lt;br /&gt;
In the PineNote UART schematic you can see (on the bottom right diagram labeled &amp;lt;code&amp;gt;USB_TYPEC_Male&amp;lt;/code&amp;gt;) the side band pins are given the labels &amp;lt;code&amp;gt;UART2_TX_SUB1&amp;lt;/code&amp;gt; for A8 and &amp;lt;code&amp;gt;UART2_RX_SUB2&amp;lt;/code&amp;gt; for B8.&lt;br /&gt;
The first (TX) is used for transmitting data and the second (RX) is used for receiving data, from the perspective of the PineNote.&lt;br /&gt;
Also note the configuration channel pins labeled &amp;lt;code&amp;gt;TYPEC_CC1&amp;lt;/code&amp;gt; for A5 and &amp;lt;code&amp;gt;TYPEC_CC2&amp;lt;/code&amp;gt; for B5.&lt;br /&gt;
These pins are used to signal to the PineNote that a UART dongle is present.&lt;br /&gt;
The diagram shows they must be connected to a 3.3V source in parallel, mediated by resistors.&lt;br /&gt;
The schematic indicates 10,000 Ohm resistors, but community member talpadk experimented and found 1,000 Ohm resistors work better.&lt;br /&gt;
Our mission is to wire up pins from a USB-UART adapter to a USB-C breakout board following these requirements.&lt;br /&gt;
&lt;br /&gt;
=== Buying components ===&lt;br /&gt;
&lt;br /&gt;
There are many possible USB-C breakout board designs available for purchase online.&lt;br /&gt;
One particularly useful design is a &amp;quot;passthrough&amp;quot; or &amp;quot;intercept&amp;quot; style, with both male and female USB-C ports.&lt;br /&gt;
This design is more versatile in case you want to reuse it in other projects, and also enables you to connect to the PineNote via UART and USB at the same time.&lt;br /&gt;
An example of this product can be found [https://pmdway.com/products/usb-3-1-type-c-male-to-female-breakout-test-board here], although you are encouraged to shop around for cheaper options.&lt;br /&gt;
If you're fine with a bit more soldering, there is a very cheap one [https://www.ebay.com/itm/275407037613 here].&lt;br /&gt;
&lt;br /&gt;
Similarly, there are many USB-UART adapter designs available.&lt;br /&gt;
These devices plug into your computer and expose a number of pins themselves, connecting to specific pins on the breakout board with jump wires.&lt;br /&gt;
It is important to get a 3.3V model, or at least a model with the option of 3.3V, as a 5V source might fry the PineNote.&lt;br /&gt;
[https://pmdway.com/products/usb-to-ttl-serial-cp2104-6-pin-converter-module Here] is one example with jump wires included, although you are again encouraged to shop around for alternatives.&lt;br /&gt;
&lt;br /&gt;
All other necessary components of our UART dongle are readily &amp;amp; cheaply available in many locations.&lt;br /&gt;
&lt;br /&gt;
=== Splicing resistors ===&lt;br /&gt;
&lt;br /&gt;
[[File:PineNote-UART-Y-pull-up-resistor-cable.jpg|thumb|The desired end result; wrap removed from resistors for illustration purposes.]]&lt;br /&gt;
&lt;br /&gt;
This is the only difficult part of the whole process.&lt;br /&gt;
Your goal is to create a Y-shaped jump wire with 1,000 Ohm through-hole resistors spliced into each of the twin arms.&lt;br /&gt;
The solitary leg will connect to a 3.3V source on your USB-UART adapter.&lt;br /&gt;
The twin arms will connect to the configuration channel pins on your USB-C breakout board.&lt;br /&gt;
This setup is called using pull-up resistors, and you can read a nice introduction to their purpose [https://www.electronics-tutorials.ws/logic/pull-up-resistor.html here].&lt;br /&gt;
&lt;br /&gt;
For this project you'll need:&lt;br /&gt;
# A soldering iron with solder&lt;br /&gt;
# Wire cutters &amp;amp; strippers&lt;br /&gt;
# 2x jumper wires, male/female as compatible with your board designs&lt;br /&gt;
# 2x 1,000 Ohm through-hole resistors&lt;br /&gt;
# Electrical tape or heat shrink wrap&lt;br /&gt;
&lt;br /&gt;
Consider buying extra jumper wires and resistors in case you mess up.&lt;br /&gt;
Also double-check that you have 1K resistors with [https://resistorcolorcodecalc.com/ this color code calculator].&lt;br /&gt;
Although the PineNote UART schematic says to use 10K Ohm resistors, community member talpadk experimented and found 1K is more appropriate.&lt;br /&gt;
Assemble your Y-cable as follows:&lt;br /&gt;
# Graft one jump wire onto the other to form a Y shape using [https://www.youtube.com/watch?v=KpiEfuhPqew this] technique, ensuring solitary leg end is compatible with your USB-UART adapter&lt;br /&gt;
# Splice resistors into the twin arms using [https://www.youtube.com/watch?v=RMgMVqqjPZ0 this] technique&lt;br /&gt;
# Splice remaining jump wire onto the ends of the resistors, ensuring ends are compatible with your USB-C breakout board&lt;br /&gt;
# Cover all exposed wire &amp;amp; resistors with electrical tape or heat shrink wrap&lt;br /&gt;
&lt;br /&gt;
=== Assembly ===&lt;br /&gt;
&lt;br /&gt;
Once you have acquired all necessary components, assemble the UART dongle as follows:&lt;br /&gt;
# Connect a jump wire from the GND pin on the USB-UART adapter to any one of the four GND pins on the USB-C breakout board (A1, A12, B1, or B12)&lt;br /&gt;
# Connect a jump wire from the RXD pin on the USB-UART adapter to the &amp;lt;code&amp;gt;UART2_TX_SUB1&amp;lt;/code&amp;gt; SBU1 pin on the USB-C breakout board (A8)&lt;br /&gt;
# Connect a jump wire from the TXD pin on the USB-UART adapter to the &amp;lt;code&amp;gt;UART2_RX_SUB2&amp;lt;/code&amp;gt; SBU2 pin on the USB-C breakout board (B8)&lt;br /&gt;
# Connect your Y-shaped jump wire from the 3.3V source pin on the USB-UART adapter to the CC1 and CC2 pins on the USB-C breakout board (A5 and B5)&lt;br /&gt;
# Wrap all metal connectors in electrical tape or heat shrink to prevent accidental shorts&lt;br /&gt;
&lt;br /&gt;
Be '''very certain''' of your connections for the 3.3V source and its cable, as there is a real risk of irreparably frying your PineNote if they're wrong!&lt;br /&gt;
Especially be sure you are connecting to a 3.3V source and not a 5V source.&lt;br /&gt;
&lt;br /&gt;
Note that if you mix up the TX/RX pins, it will still work but the USB-C breakout board will just plug into the PineNote upside down.&lt;br /&gt;
You can therefore choose which orientation you want by swapping the TX/RX pin connections.&lt;br /&gt;
&lt;br /&gt;
== Using UART ==&lt;br /&gt;
&lt;br /&gt;
First, use your UART dongle to physically connect your PineNote to your computer:&lt;br /&gt;
# Plug the USB-UART adapter into one of your computer's USB ports&lt;br /&gt;
# Plug the USB-C breakout board into the USB-C port on the bottom of your PineNote; the orientation matters, so try both and remember which one works&lt;br /&gt;
&lt;br /&gt;
Once the hardware is connected, set up your computer's software as follows:&lt;br /&gt;
# Install [https://www.gnu.org/software/screen/ GNU Screen] (or [https://askubuntu.com/q/40959 some other option], but the instructions below are written for &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt;)&lt;br /&gt;
# Identify the USB-UART adapter in your &amp;lt;code&amp;gt;/dev&amp;lt;/code&amp;gt; directory by running &amp;lt;code&amp;gt;ls /dev&amp;lt;/code&amp;gt; with it plugged in, unplugging it, then again running &amp;lt;code&amp;gt;ls /dev&amp;lt;/code&amp;gt; and seeing what changes; it is likely to be called &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;&lt;br /&gt;
# In a terminal window, run &amp;lt;code&amp;gt;screen -L /dev/ttyUSB0 1500000&amp;lt;/code&amp;gt; (you may need to run this as sudo depending on your user's permissions; on most Linux distributions you need to be in the &amp;lt;code&amp;gt;dialout&amp;lt;/code&amp;gt; usergroup)&lt;br /&gt;
&lt;br /&gt;
Once the software is set up, power-cycle your PineNote; as the system boots you should see text appearing in your terminal window.&lt;br /&gt;
You can exit the screen session with &amp;lt;code&amp;gt;ctrl+a k&amp;lt;/code&amp;gt; then pressing &amp;lt;code&amp;gt;y&amp;lt;/code&amp;gt; to confirm.&lt;br /&gt;
The &amp;lt;code&amp;gt;screen -L&amp;lt;/code&amp;gt; flag outputs a text log of the session to the current working directory, probably called &amp;lt;code&amp;gt;screenlog.0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Troubleshooting ====&lt;br /&gt;
&lt;br /&gt;
If you don't see any text in your terminal as the PineNote boots, or the text is garbled, try the following:&lt;br /&gt;
* Ensure your GND, RX and TX jump wires are connected to the correct pins on both the USB-UART adapter and the USB-C breakout board&lt;br /&gt;
* Connect your USB-C breakout board to your PineNote in the opposite orientation&lt;br /&gt;
* Run the screen command as sudo in case your user doesn't have appropriate permissions&lt;br /&gt;
* Ensure you are setting the baud rate in the &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt; command to 1500000 (1.5 million)&lt;br /&gt;
&lt;br /&gt;
== USB passthrough ==&lt;br /&gt;
&lt;br /&gt;
If your USB-C breakout board has a passthrough/intercept design, you can connect to your PineNote over USB and UART at the same time.&lt;br /&gt;
This can be useful when you're doing development work on the PineNote boot process so you don't have to continually reconnect cables.&lt;br /&gt;
You'll need a USB-A to USB-C cable, connecting directly from your computer's USB-A hub to your USB-C breakout board's female USB-C port.&lt;br /&gt;
It's important to connect directly from USB-A, without any intermediate USB-C components.&lt;br /&gt;
Note that connecting a live USB cable to your USB-C breakout board in this way dramatically increases the danger of frying your PineNote with a short, so you should only do this if all connectors are safely wrapped in electrical tape.&lt;br /&gt;
&lt;br /&gt;
[[Category:PineNote]]&lt;/div&gt;</summary>
		<author><name>Ahelwer</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PineNote_Development/Flashing&amp;diff=20895</id>
		<title>PineNote Development/Flashing</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PineNote_Development/Flashing&amp;diff=20895"/>
		<updated>2023-10-14T02:14:19Z</updated>

		<summary type="html">&lt;p&gt;Ahelwer: /* Exit */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Under construction}}&lt;br /&gt;
&lt;br /&gt;
{{Info|These instructions are directed towards experienced developers only!}}&lt;br /&gt;
&lt;br /&gt;
This page contains information on flashing software to the [https://wiki.pine64.org/wiki/PineNote PineNote].&lt;br /&gt;
&lt;br /&gt;
Currently, software can be flashed using rkdeveloptool or from the factory Android installation (UART shell, adb, or fastboot).&lt;br /&gt;
&lt;br /&gt;
== Getting &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
Most flashing operations on the PineNote are done through &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt;, a command line utility built on libusb.&lt;br /&gt;
PINE64 maintains its own fork [https://gitlab.com/pine64-org/quartz-bsp/rkdeveloptool here] that you will need to get.&lt;br /&gt;
The repo's README contains a list of dependencies (libusb 1.0) and instructions for building the tool.&lt;br /&gt;
&lt;br /&gt;
Installing (not just building) &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; will configure PAM to elevate privileges where necessary on your system; you can configure this manually as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo cp 99-rk-rockusb.rules /etc/udev/rules.d/&lt;br /&gt;
sudo udevadm control --reload&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Entering Maskrom/Rockusb mode ==&lt;br /&gt;
&lt;br /&gt;
Interfacing with the PineNote over USB using &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; requires first booting the PineNote into [http://opensource.rock-chips.com/wiki_Rockusb an alternative operating mode] called Maskrom or Rockusb mode.&lt;br /&gt;
&lt;br /&gt;
=== Possible methods ===&lt;br /&gt;
&lt;br /&gt;
There are three possible methods of entering Maskrom/Rockusb mode:&lt;br /&gt;
&lt;br /&gt;
==== Hardware magnet switch ====&lt;br /&gt;
&lt;br /&gt;
# Connect the PineNote to your computer via USB and boot the PineNote into Android&lt;br /&gt;
# Locate &amp;amp; identify the small circular marking on the back of the PineNote, in the top right quadrant; have the PineNote pen close at hand, or any other small magnet&lt;br /&gt;
# Hold the PineNote power button to bring up the reboot/shutdown menu; select reboot, then place the PineNote face down with the &amp;quot;eraser&amp;quot; end of the pen (or your magnet) resting on the small circular marking&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Download mode.jpeg|Pen method&lt;br /&gt;
PineNoteMagnetOnBack.jpg|Magnet method&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== U-Boot terminal ====&lt;br /&gt;
This method requires a [[PineNote_Development/UART#USB_passthrough|UART dongle with passthrough]] allowing simultaneous UART &amp;amp; USB connections.&lt;br /&gt;
It is nice because you can easily switch back &amp;amp; forth between U-Boot and Rockusb without having to physically manipulate the PineNote or its connectors; this is especially helpful when trying to develop U-Boot.&lt;br /&gt;
&lt;br /&gt;
# Connect to the PineNote via UART and USB simultaneously&lt;br /&gt;
# Interrupt the U-Boot startup using &amp;lt;code&amp;gt;ctrl+c&amp;lt;/code&amp;gt; sent over UART&lt;br /&gt;
# In the U-Boot terminal over UART, run &amp;lt;code&amp;gt;rockusb 0 mmc 0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The UART terminal should print &amp;lt;code&amp;gt;RKUSB&amp;lt;/code&amp;gt; then a spinner will appear.&lt;br /&gt;
You can exit back to the U-Boot terminal by sending &amp;lt;code&amp;gt;ctrl+c&amp;lt;/code&amp;gt; again.&lt;br /&gt;
&lt;br /&gt;
==== Shorting test points ====&lt;br /&gt;
&lt;br /&gt;
If the bootloader is broken/corrupted, you cannot get to Maskrom without opening up the device (it can be opened using spudger and a bit of patience).&lt;br /&gt;
&lt;br /&gt;
Once inside, short TP1301 (GND) and TP1302 (eMMC_D0/FLASH_D0) with a small tweezers, this is how it looks on board view (credit to Caleb):&lt;br /&gt;
&lt;br /&gt;
[[File:PineNote_Maskrom_TP.png|500px]]&lt;br /&gt;
&lt;br /&gt;
=== Success ===&lt;br /&gt;
&lt;br /&gt;
No matter what approach you take, you can tell whether you succeeded by running the &amp;lt;code&amp;gt;lsusb&amp;lt;/code&amp;gt; command on your computer:&lt;br /&gt;
* If you find the entry &amp;lt;code&amp;gt;2207:0018 Fuzhou Rockchip Electronics Company rk3566_eink&amp;lt;/code&amp;gt; in the list, the process did not succeed; reboot and retry&lt;br /&gt;
* The entry &amp;lt;code&amp;gt;2207:350a Fuzhou Rockchip Electronics Company&amp;lt;/code&amp;gt; will occur if you detach then reattach the USB-C cable while the PineNote is in Maskrom/Rockusb mode; &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; won't work and you will have to do a hard reboot (hold down power button for 30 seconds to shutdown)&lt;br /&gt;
* If you find the entry &amp;lt;code&amp;gt;2207:350a Fuzhou Rockchip Electronics Company USB download gadget&amp;lt;/code&amp;gt; then the process succeeded&lt;br /&gt;
&lt;br /&gt;
You can also look at the output of the &amp;lt;code&amp;gt;rkdeveloptool list&amp;lt;/code&amp;gt; command:&lt;br /&gt;
* If this prints out &amp;lt;code&amp;gt;No devices in rockusb mode found&amp;lt;/code&amp;gt; the process did not succeed; reboot and retry&lt;br /&gt;
* If this prints out &amp;lt;code&amp;gt;DevNo=1 Vid=0x2207,Pid=0x350a,LocationID=305 Maskrom&amp;lt;/code&amp;gt; then you probably detached/reattached the USB-C cable while in Maskrom/Rockusb mode and &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; won't work; perform a hard reboot to fix&lt;br /&gt;
* If this prints out &amp;lt;code&amp;gt;DevNo=1 Vid=0x2207,Pid=0x350a,LocationID=303 Loader&amp;lt;/code&amp;gt; then the process succeeded&lt;br /&gt;
&lt;br /&gt;
=== Exiting ===&lt;br /&gt;
&lt;br /&gt;
You can boot the PineNote back into its normal mode of operation by powercycling the PineNote with its hardware power switch, or running the &amp;lt;code&amp;gt;rkdeveloptool reboot&amp;lt;/code&amp;gt; command.&lt;br /&gt;
If you used the magnetic switch method be sure to remove the pen/magnet before rebooting.&lt;br /&gt;
&lt;br /&gt;
== Backup ==&lt;br /&gt;
&lt;br /&gt;
A backup of the content of the internal eMMC before anything gets messed up is '''mandatory'''.&lt;br /&gt;
&lt;br /&gt;
Especially the ''waveform'' partition contains data '''unique''' to your PineNote and is a prime candidate for backup.&lt;br /&gt;
&lt;br /&gt;
Other partitions like U-Boot (need for any operation of the device) or the un-partitioned space at the beginning containing the GPT partition table (and presumably the VCOM setting for the e-ink display and maybe device mac addresses) contain data you may also wish to backup.&lt;br /&gt;
&lt;br /&gt;
Depending of your personal level of data hoarder you may want to backup more than this or even just everything (the large ''userdata'' partition is supposed to be able to be repopulated as empty space by Android)&lt;br /&gt;
&lt;br /&gt;
In any case it is easier to restore/extract data from a backup than not having one if you need one.&lt;br /&gt;
&lt;br /&gt;
This process was developed by Dorian Rudolph, originally described [https://github.com/DorianRudolph/pinenotes here].&lt;br /&gt;
&lt;br /&gt;
=== List partitions ===&lt;br /&gt;
&lt;br /&gt;
First, run &amp;lt;code&amp;gt;rkdeveloptool list-partitions&amp;lt;/code&amp;gt; to print out your PineNote's partitions to get an idea of what you're dealing with.&lt;br /&gt;
The stock PineNote has a fairly standard Android partition setup, including:&lt;br /&gt;
* uboot: the [https://en.wikipedia.org/wiki/Das_U-Boot U-Boot] embedded systems bootloader&lt;br /&gt;
* trust: secrets that can be encrypted with a key stored in the [https://en.wikipedia.org/wiki/Trusted_Platform_Module TPM]&lt;br /&gt;
* waveform: important files controlling the e-ink screen's state changes&lt;br /&gt;
* misc: miscellaneous files needed by the firmware&lt;br /&gt;
* dtbo: [https://en.wikipedia.org/wiki/Devicetree Device Tree Blob for Overlay], files describing the PineNote's hardware configuration&lt;br /&gt;
* vbmeta: data required for verified boot&lt;br /&gt;
* boot, security, recovery, backup, cache, metadata, super, logo, device&lt;br /&gt;
* userdata: the big one; this is where all your files are stored in the stock Android install&lt;br /&gt;
&lt;br /&gt;
=== Patch U-Boot ===&lt;br /&gt;
&lt;br /&gt;
Before we can back up our partitions, we have a problem to solve.&lt;br /&gt;
The version of U-Boot installed on the stock PineNote contains a bug where it can't dump partitions beyond 32 MB (above that limit all bytes in the dump are just &amp;lt;code&amp;gt;0xCC&amp;lt;/code&amp;gt;), meaning the PineNote must be flashed with a fixed version of U-Boot before it is possible to take a backup of the larger partitions.&lt;br /&gt;
It is possible to extract and modify the U-Boot image from your PineNote if you're interested in some light reverse-engineering (following Dorian's notes), or you can simply download a patched U-Boot image directly [https://github.com/DorianRudolph/pinenotes/blob/main/static/uboot_patched.img here].&lt;br /&gt;
&lt;br /&gt;
Once you've acquired a patched U-Boot image, run:&lt;br /&gt;
# &amp;lt;code&amp;gt;rkdeveloptool read-partition uboot uboot_backup.img&amp;lt;/code&amp;gt;&lt;br /&gt;
# &amp;lt;code&amp;gt;rkdeveloptool write-partition uboot uboot_patched.img&amp;lt;/code&amp;gt;&lt;br /&gt;
# &amp;lt;code&amp;gt;rkdeveloptool reboot&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Taking the backup ===&lt;br /&gt;
&lt;br /&gt;
There is a second backup limit preventing dumping partitions larger than 2 GB, this time from &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt;.&lt;br /&gt;
This means if you have a large number of documents in the Android userdata partition they might not all make it into the backup.&lt;br /&gt;
If you don't have many documents (or don't care about losing them) this should not be a problem.&lt;br /&gt;
If you do have a lot of documents, workarounds include:&lt;br /&gt;
* A possible patch written by Thomas exists [https://github.com/tpwrules/nixos-pinenote/blob/96d2c9158edb9da59afcb952cc864fada18382f9/nix/rkdeveloptool/0001-fix-large-dumps.patch here] but has not yet been upstreamed; consider investigating how to get the patch tested &amp;amp; upstreamed, or just apply it to your own local copy of &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt;&lt;br /&gt;
* Use [https://github.com/talpadk/pinenote-backup this] Python script written by Visti Andresen to automatically backup your entire partition by splitting reads into 2 GB chunks&lt;br /&gt;
&lt;br /&gt;
See [https://github.com/m-weigand/pinenote-debian-recipes/releases/tag/v0.1 instructions on this artifact]. It will instruct you on extracting the rootfs into an empty ext4 partition. This can be done from Linux or Android. Further instructions on building your own rootfs [https://github.com/m-weigand/pinenote-debian-recipes can be found here].&lt;br /&gt;
&lt;br /&gt;
=== Using a user installed Linux ===&lt;br /&gt;
A Linux installed to the cache partition should be able to easily backup everything over WiFi or to a USB stick/disk using ''dd''.&lt;br /&gt;
&lt;br /&gt;
However the user would need to backup the cache partition themself (if they want that).&lt;br /&gt;
&lt;br /&gt;
And more importantly they would only be getting the backup ''after'' they started playing with the content of the eMMC.&lt;br /&gt;
&lt;br /&gt;
== Side-by-side setup ==&lt;br /&gt;
&lt;br /&gt;
It is possible to set up a partition for mainline development without disturbing the factory Android installation. This allows updating a mainline kernel, DTB, and initramfs over Wi-Fi until WiFi or USB OTG is working in mainline Linux.&lt;br /&gt;
&lt;br /&gt;
=== Without Repartitioning ===&lt;br /&gt;
&lt;br /&gt;
The recommended partition for this is &amp;lt;tt&amp;gt;mmcblk0p11&amp;lt;/tt&amp;gt; aka &amp;lt;tt&amp;gt;/cache&amp;lt;/tt&amp;gt;. It is large and already formatted as &amp;lt;tt&amp;gt;ext4&amp;lt;/tt&amp;gt;, so it is readable from U-Boot. Here are some general steps:&lt;br /&gt;
&lt;br /&gt;
# From the UART or adb shell, set up your chroot in &amp;lt;tt&amp;gt;/cache&amp;lt;/tt&amp;gt;. I used the Alpine Linux rootfs tarball.&lt;br /&gt;
# Copy in your kernel and DTB, using for example &amp;lt;tt&amp;gt;scp&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;wget&amp;lt;/tt&amp;gt; inside the chroot.&lt;br /&gt;
# Finally, create and boot an &amp;lt;code&amp;gt;extlinux.conf&amp;lt;/code&amp;gt; as described below.&lt;br /&gt;
&lt;br /&gt;
=== With Repartitioning ===&lt;br /&gt;
&lt;br /&gt;
It is possible to shrink the &amp;lt;tt&amp;gt;userdata&amp;lt;/tt&amp;gt; partition, and create a new partition at the end for use with mainline Linux. This provides much more space than &amp;lt;tt&amp;gt;cache&amp;lt;/tt&amp;gt;. However, because &amp;lt;tt&amp;gt;userdata&amp;lt;/tt&amp;gt; is formatted with &amp;lt;tt&amp;gt;f2fs&amp;lt;/tt&amp;gt;, and that filesystem cannot be shrunk, resizing the partition requires wiping &amp;lt;tt&amp;gt;userdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
# Back up any necessary files from userdata&lt;br /&gt;
# Boot to a mainline kernel from &amp;lt;tt&amp;gt;mmcblk0p11&amp;lt;/tt&amp;gt;, either using that partition as rootfs (see above), or using an initramfs with repartitioning tools&lt;br /&gt;
# Modify the partition table with your favorite tool, e.g. &amp;lt;tt&amp;gt;fdisk&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gdisk&amp;lt;/tt&amp;gt;, or &amp;lt;tt&amp;gt;parted&amp;lt;/tt&amp;gt;&lt;br /&gt;
# Reboot into &amp;lt;tt&amp;gt;fastboot&amp;lt;/tt&amp;gt; and wipe &amp;lt;tt&amp;gt;userdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# Reboot into Android, where you can now chroot in and install your favorite distribution to the new partition.&lt;br /&gt;
&lt;br /&gt;
== Using rkdeveloptool ==&lt;br /&gt;
&lt;br /&gt;
=== Building Downstream U-Boot ===&lt;br /&gt;
&lt;br /&gt;
While in maskrom mode, we need to have a u-boot to download onto the device for any of the other commands to work. To build you'll also need to install device-tree-compiler.&lt;br /&gt;
&lt;br /&gt;
You also need to install Python and pyelftools.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Note that rkbin is a &amp;amp;gt;5GB download!&amp;lt;/b&amp;gt; This will take some time to clone and process the deltas.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone -b quartz64 https://gitlab.com/pgwipeout/u-boot-rockchip.git&lt;br /&gt;
git clone -b rkbin https://github.com/JeffyCN/rockchip_mirrors.git rkbin&lt;br /&gt;
cd u-boot-rockchip&lt;br /&gt;
# If using Arch Linux, export CROSS_COMPILE=aarch64-linux-gnu-&lt;br /&gt;
export CROSS_COMPILE=aarch64-none-linux-gnu-&lt;br /&gt;
make rk3566-quartz64_defconfig&lt;br /&gt;
./make.sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
In the current version (current as of 2022-01-02), there might have to be made a change to one line to get a clean compilation:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
diff --git a/lib/avb/libavb/avb_slot_verify.c b/lib/avb/libavb/avb_slot_verify.c&lt;br /&gt;
index 123701fc3b..64a1ce6450 100644&lt;br /&gt;
--- a/lib/avb/libavb/avb_slot_verify.c&lt;br /&gt;
+++ b/lib/avb/libavb/avb_slot_verify.c&lt;br /&gt;
@@ -296,7 +296,7 @@ static AvbSlotVerifyResult load_and_verify_hash_partition(&lt;br /&gt;
   bool image_preloaded = false;&lt;br /&gt;
   uint8_t* digest;&lt;br /&gt;
   size_t digest_len;&lt;br /&gt;
-  const char* found;&lt;br /&gt;
+  const char* found = NULL;&lt;br /&gt;
   uint64_t image_size;&lt;br /&gt;
   size_t expected_digest_len = 0;&lt;br /&gt;
   uint8_t expected_digest_buf[AVB_SHA512_DIGEST_SIZE];&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For systems where the global python executable points to python2, compilation fails with an error related to pyelftools not being installed (even if it is). To fix this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
diff --git a/make.sh b/make.sh&lt;br /&gt;
index 2bba05b4e4..cfe5b0afd5 100755&lt;br /&gt;
--- a/make.sh&lt;br /&gt;
+++ b/make.sh&lt;br /&gt;
@@ -758,7 +758,7 @@ function pack_fit_image()&lt;br /&gt;
        fi&lt;br /&gt;
 &lt;br /&gt;
        if [ &amp;quot;${ARM64_TRUSTZONE}&amp;quot; == &amp;quot;y&amp;quot; ]; then&lt;br /&gt;
-               if ! python -c &amp;quot;import elftools&amp;quot; ; then&lt;br /&gt;
+               if ! python3 -c &amp;quot;import elftools&amp;quot; ; then&lt;br /&gt;
                        echo &amp;quot;ERROR: No python 'pyelftools', please: pip install pyelftools&amp;quot;&lt;br /&gt;
                        exit 1&lt;br /&gt;
                fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can now download u-boot onto the PineNote:&lt;br /&gt;
&lt;br /&gt;
 ./rkdeveloptool boot ../u-boot-rockchip/rk356x_spl_loader_v1.08.111.bin&lt;br /&gt;
&lt;br /&gt;
This should output &amp;quot;''Downloading bootloader succeeded''&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
We can now verify that this worked using e.g. the &amp;quot;read flash info&amp;quot; command:&lt;br /&gt;
&lt;br /&gt;
 ./rkdeveloptool read-flash-info&lt;br /&gt;
&lt;br /&gt;
{{Note|'''TODO:''' Section needs to be finished}}&lt;br /&gt;
&lt;br /&gt;
=== Creating a mainline boot image ===&lt;br /&gt;
&lt;br /&gt;
You can create a filesystem image that replaces the Android boot or recovery partition by doing roughly the following:&lt;br /&gt;
&lt;br /&gt;
# Erase boot and dtbo with rkdeveloptool or fastboot (back them up first!!!)&lt;br /&gt;
# Create an ext2 partition image and mount it (fallocate, mkfs.ext2)&lt;br /&gt;
# Build your mainline kernel&lt;br /&gt;
# Copy the kernel, dtb and an initramfs to the root of the mounted image (use any old postmarketOS initramfs)&lt;br /&gt;
# Create a file in the root of the mounted image called &amp;lt;code&amp;gt;extlinux.conf&amp;lt;/code&amp;gt; as described below&lt;br /&gt;
# Unmount the image and then use rkdeveloptool to flash it to the &amp;quot;recovery&amp;quot; partition on the pinenote (it's about the right size until we get around to replacing the partition layout).&lt;br /&gt;
&lt;br /&gt;
== Using fastboot ==&lt;br /&gt;
&lt;br /&gt;
Follow the steps for [[PineNote Development/Flashing#Creating a mainline boot image|Creating a mainline boot image]], but instead of flashing it with ''rkdeveloptool'', use ''fastboot''. You can enter fastboot in either of two ways:&lt;br /&gt;
&lt;br /&gt;
* Use &amp;quot;reboot bootloader&amp;quot; from adb or a UART console or&lt;br /&gt;
* get a U-Boot prompt and run &amp;lt;code&amp;gt;fastboot usb 0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:PineNote]]&lt;/div&gt;</summary>
		<author><name>Ahelwer</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PineNote_Development/Flashing&amp;diff=20894</id>
		<title>PineNote Development/Flashing</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PineNote_Development/Flashing&amp;diff=20894"/>
		<updated>2023-10-14T02:13:59Z</updated>

		<summary type="html">&lt;p&gt;Ahelwer: /* Entering Maskrom/Rockusb mode */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Under construction}}&lt;br /&gt;
&lt;br /&gt;
{{Info|These instructions are directed towards experienced developers only!}}&lt;br /&gt;
&lt;br /&gt;
This page contains information on flashing software to the [https://wiki.pine64.org/wiki/PineNote PineNote].&lt;br /&gt;
&lt;br /&gt;
Currently, software can be flashed using rkdeveloptool or from the factory Android installation (UART shell, adb, or fastboot).&lt;br /&gt;
&lt;br /&gt;
== Getting &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
Most flashing operations on the PineNote are done through &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt;, a command line utility built on libusb.&lt;br /&gt;
PINE64 maintains its own fork [https://gitlab.com/pine64-org/quartz-bsp/rkdeveloptool here] that you will need to get.&lt;br /&gt;
The repo's README contains a list of dependencies (libusb 1.0) and instructions for building the tool.&lt;br /&gt;
&lt;br /&gt;
Installing (not just building) &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; will configure PAM to elevate privileges where necessary on your system; you can configure this manually as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo cp 99-rk-rockusb.rules /etc/udev/rules.d/&lt;br /&gt;
sudo udevadm control --reload&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Entering Maskrom/Rockusb mode ==&lt;br /&gt;
&lt;br /&gt;
Interfacing with the PineNote over USB using &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; requires first booting the PineNote into [http://opensource.rock-chips.com/wiki_Rockusb an alternative operating mode] called Maskrom or Rockusb mode.&lt;br /&gt;
&lt;br /&gt;
=== Possible methods ===&lt;br /&gt;
&lt;br /&gt;
There are three possible methods of entering Maskrom/Rockusb mode:&lt;br /&gt;
&lt;br /&gt;
==== Hardware magnet switch ====&lt;br /&gt;
&lt;br /&gt;
# Connect the PineNote to your computer via USB and boot the PineNote into Android&lt;br /&gt;
# Locate &amp;amp; identify the small circular marking on the back of the PineNote, in the top right quadrant; have the PineNote pen close at hand, or any other small magnet&lt;br /&gt;
# Hold the PineNote power button to bring up the reboot/shutdown menu; select reboot, then place the PineNote face down with the &amp;quot;eraser&amp;quot; end of the pen (or your magnet) resting on the small circular marking&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Download mode.jpeg|Pen method&lt;br /&gt;
PineNoteMagnetOnBack.jpg|Magnet method&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== U-Boot terminal ====&lt;br /&gt;
This method requires a [[PineNote_Development/UART#USB_passthrough|UART dongle with passthrough]] allowing simultaneous UART &amp;amp; USB connections.&lt;br /&gt;
It is nice because you can easily switch back &amp;amp; forth between U-Boot and Rockusb without having to physically manipulate the PineNote or its connectors; this is especially helpful when trying to develop U-Boot.&lt;br /&gt;
&lt;br /&gt;
# Connect to the PineNote via UART and USB simultaneously&lt;br /&gt;
# Interrupt the U-Boot startup using &amp;lt;code&amp;gt;ctrl+c&amp;lt;/code&amp;gt; sent over UART&lt;br /&gt;
# In the U-Boot terminal over UART, run &amp;lt;code&amp;gt;rockusb 0 mmc 0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The UART terminal should print &amp;lt;code&amp;gt;RKUSB&amp;lt;/code&amp;gt; then a spinner will appear.&lt;br /&gt;
You can exit back to the U-Boot terminal by sending &amp;lt;code&amp;gt;ctrl+c&amp;lt;/code&amp;gt; again.&lt;br /&gt;
&lt;br /&gt;
==== Shorting test points ====&lt;br /&gt;
&lt;br /&gt;
If the bootloader is broken/corrupted, you cannot get to Maskrom without opening up the device (it can be opened using spudger and a bit of patience).&lt;br /&gt;
&lt;br /&gt;
Once inside, short TP1301 (GND) and TP1302 (eMMC_D0/FLASH_D0) with a small tweezers, this is how it looks on board view (credit to Caleb):&lt;br /&gt;
&lt;br /&gt;
[[File:PineNote_Maskrom_TP.png|500px]]&lt;br /&gt;
&lt;br /&gt;
=== Success ===&lt;br /&gt;
&lt;br /&gt;
No matter what approach you take, you can tell whether you succeeded by running the &amp;lt;code&amp;gt;lsusb&amp;lt;/code&amp;gt; command on your computer:&lt;br /&gt;
* If you find the entry &amp;lt;code&amp;gt;2207:0018 Fuzhou Rockchip Electronics Company rk3566_eink&amp;lt;/code&amp;gt; in the list, the process did not succeed; reboot and retry&lt;br /&gt;
* The entry &amp;lt;code&amp;gt;2207:350a Fuzhou Rockchip Electronics Company&amp;lt;/code&amp;gt; will occur if you detach then reattach the USB-C cable while the PineNote is in Maskrom/Rockusb mode; &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; won't work and you will have to do a hard reboot (hold down power button for 30 seconds to shutdown)&lt;br /&gt;
* If you find the entry &amp;lt;code&amp;gt;2207:350a Fuzhou Rockchip Electronics Company USB download gadget&amp;lt;/code&amp;gt; then the process succeeded&lt;br /&gt;
&lt;br /&gt;
You can also look at the output of the &amp;lt;code&amp;gt;rkdeveloptool list&amp;lt;/code&amp;gt; command:&lt;br /&gt;
* If this prints out &amp;lt;code&amp;gt;No devices in rockusb mode found&amp;lt;/code&amp;gt; the process did not succeed; reboot and retry&lt;br /&gt;
* If this prints out &amp;lt;code&amp;gt;DevNo=1 Vid=0x2207,Pid=0x350a,LocationID=305 Maskrom&amp;lt;/code&amp;gt; then you probably detached/reattached the USB-C cable while in Maskrom/Rockusb mode and &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; won't work; perform a hard reboot to fix&lt;br /&gt;
* If this prints out &amp;lt;code&amp;gt;DevNo=1 Vid=0x2207,Pid=0x350a,LocationID=303 Loader&amp;lt;/code&amp;gt; then the process succeeded&lt;br /&gt;
&lt;br /&gt;
=== Exit ===&lt;br /&gt;
&lt;br /&gt;
You can boot the PineNote back into its normal mode of operation by powercycling the PineNote with its hardware power switch, or running the &amp;lt;code&amp;gt;rkdeveloptool reboot&amp;lt;/code&amp;gt; command.&lt;br /&gt;
If you used the magnetic switch method be sure to remove the pen/magnet before rebooting.&lt;br /&gt;
&lt;br /&gt;
== Backup ==&lt;br /&gt;
&lt;br /&gt;
A backup of the content of the internal eMMC before anything gets messed up is '''mandatory'''.&lt;br /&gt;
&lt;br /&gt;
Especially the ''waveform'' partition contains data '''unique''' to your PineNote and is a prime candidate for backup.&lt;br /&gt;
&lt;br /&gt;
Other partitions like U-Boot (need for any operation of the device) or the un-partitioned space at the beginning containing the GPT partition table (and presumably the VCOM setting for the e-ink display and maybe device mac addresses) contain data you may also wish to backup.&lt;br /&gt;
&lt;br /&gt;
Depending of your personal level of data hoarder you may want to backup more than this or even just everything (the large ''userdata'' partition is supposed to be able to be repopulated as empty space by Android)&lt;br /&gt;
&lt;br /&gt;
In any case it is easier to restore/extract data from a backup than not having one if you need one.&lt;br /&gt;
&lt;br /&gt;
This process was developed by Dorian Rudolph, originally described [https://github.com/DorianRudolph/pinenotes here].&lt;br /&gt;
&lt;br /&gt;
=== List partitions ===&lt;br /&gt;
&lt;br /&gt;
First, run &amp;lt;code&amp;gt;rkdeveloptool list-partitions&amp;lt;/code&amp;gt; to print out your PineNote's partitions to get an idea of what you're dealing with.&lt;br /&gt;
The stock PineNote has a fairly standard Android partition setup, including:&lt;br /&gt;
* uboot: the [https://en.wikipedia.org/wiki/Das_U-Boot U-Boot] embedded systems bootloader&lt;br /&gt;
* trust: secrets that can be encrypted with a key stored in the [https://en.wikipedia.org/wiki/Trusted_Platform_Module TPM]&lt;br /&gt;
* waveform: important files controlling the e-ink screen's state changes&lt;br /&gt;
* misc: miscellaneous files needed by the firmware&lt;br /&gt;
* dtbo: [https://en.wikipedia.org/wiki/Devicetree Device Tree Blob for Overlay], files describing the PineNote's hardware configuration&lt;br /&gt;
* vbmeta: data required for verified boot&lt;br /&gt;
* boot, security, recovery, backup, cache, metadata, super, logo, device&lt;br /&gt;
* userdata: the big one; this is where all your files are stored in the stock Android install&lt;br /&gt;
&lt;br /&gt;
=== Patch U-Boot ===&lt;br /&gt;
&lt;br /&gt;
Before we can back up our partitions, we have a problem to solve.&lt;br /&gt;
The version of U-Boot installed on the stock PineNote contains a bug where it can't dump partitions beyond 32 MB (above that limit all bytes in the dump are just &amp;lt;code&amp;gt;0xCC&amp;lt;/code&amp;gt;), meaning the PineNote must be flashed with a fixed version of U-Boot before it is possible to take a backup of the larger partitions.&lt;br /&gt;
It is possible to extract and modify the U-Boot image from your PineNote if you're interested in some light reverse-engineering (following Dorian's notes), or you can simply download a patched U-Boot image directly [https://github.com/DorianRudolph/pinenotes/blob/main/static/uboot_patched.img here].&lt;br /&gt;
&lt;br /&gt;
Once you've acquired a patched U-Boot image, run:&lt;br /&gt;
# &amp;lt;code&amp;gt;rkdeveloptool read-partition uboot uboot_backup.img&amp;lt;/code&amp;gt;&lt;br /&gt;
# &amp;lt;code&amp;gt;rkdeveloptool write-partition uboot uboot_patched.img&amp;lt;/code&amp;gt;&lt;br /&gt;
# &amp;lt;code&amp;gt;rkdeveloptool reboot&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Taking the backup ===&lt;br /&gt;
&lt;br /&gt;
There is a second backup limit preventing dumping partitions larger than 2 GB, this time from &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt;.&lt;br /&gt;
This means if you have a large number of documents in the Android userdata partition they might not all make it into the backup.&lt;br /&gt;
If you don't have many documents (or don't care about losing them) this should not be a problem.&lt;br /&gt;
If you do have a lot of documents, workarounds include:&lt;br /&gt;
* A possible patch written by Thomas exists [https://github.com/tpwrules/nixos-pinenote/blob/96d2c9158edb9da59afcb952cc864fada18382f9/nix/rkdeveloptool/0001-fix-large-dumps.patch here] but has not yet been upstreamed; consider investigating how to get the patch tested &amp;amp; upstreamed, or just apply it to your own local copy of &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt;&lt;br /&gt;
* Use [https://github.com/talpadk/pinenote-backup this] Python script written by Visti Andresen to automatically backup your entire partition by splitting reads into 2 GB chunks&lt;br /&gt;
&lt;br /&gt;
See [https://github.com/m-weigand/pinenote-debian-recipes/releases/tag/v0.1 instructions on this artifact]. It will instruct you on extracting the rootfs into an empty ext4 partition. This can be done from Linux or Android. Further instructions on building your own rootfs [https://github.com/m-weigand/pinenote-debian-recipes can be found here].&lt;br /&gt;
&lt;br /&gt;
=== Using a user installed Linux ===&lt;br /&gt;
A Linux installed to the cache partition should be able to easily backup everything over WiFi or to a USB stick/disk using ''dd''.&lt;br /&gt;
&lt;br /&gt;
However the user would need to backup the cache partition themself (if they want that).&lt;br /&gt;
&lt;br /&gt;
And more importantly they would only be getting the backup ''after'' they started playing with the content of the eMMC.&lt;br /&gt;
&lt;br /&gt;
== Side-by-side setup ==&lt;br /&gt;
&lt;br /&gt;
It is possible to set up a partition for mainline development without disturbing the factory Android installation. This allows updating a mainline kernel, DTB, and initramfs over Wi-Fi until WiFi or USB OTG is working in mainline Linux.&lt;br /&gt;
&lt;br /&gt;
=== Without Repartitioning ===&lt;br /&gt;
&lt;br /&gt;
The recommended partition for this is &amp;lt;tt&amp;gt;mmcblk0p11&amp;lt;/tt&amp;gt; aka &amp;lt;tt&amp;gt;/cache&amp;lt;/tt&amp;gt;. It is large and already formatted as &amp;lt;tt&amp;gt;ext4&amp;lt;/tt&amp;gt;, so it is readable from U-Boot. Here are some general steps:&lt;br /&gt;
&lt;br /&gt;
# From the UART or adb shell, set up your chroot in &amp;lt;tt&amp;gt;/cache&amp;lt;/tt&amp;gt;. I used the Alpine Linux rootfs tarball.&lt;br /&gt;
# Copy in your kernel and DTB, using for example &amp;lt;tt&amp;gt;scp&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;wget&amp;lt;/tt&amp;gt; inside the chroot.&lt;br /&gt;
# Finally, create and boot an &amp;lt;code&amp;gt;extlinux.conf&amp;lt;/code&amp;gt; as described below.&lt;br /&gt;
&lt;br /&gt;
=== With Repartitioning ===&lt;br /&gt;
&lt;br /&gt;
It is possible to shrink the &amp;lt;tt&amp;gt;userdata&amp;lt;/tt&amp;gt; partition, and create a new partition at the end for use with mainline Linux. This provides much more space than &amp;lt;tt&amp;gt;cache&amp;lt;/tt&amp;gt;. However, because &amp;lt;tt&amp;gt;userdata&amp;lt;/tt&amp;gt; is formatted with &amp;lt;tt&amp;gt;f2fs&amp;lt;/tt&amp;gt;, and that filesystem cannot be shrunk, resizing the partition requires wiping &amp;lt;tt&amp;gt;userdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
# Back up any necessary files from userdata&lt;br /&gt;
# Boot to a mainline kernel from &amp;lt;tt&amp;gt;mmcblk0p11&amp;lt;/tt&amp;gt;, either using that partition as rootfs (see above), or using an initramfs with repartitioning tools&lt;br /&gt;
# Modify the partition table with your favorite tool, e.g. &amp;lt;tt&amp;gt;fdisk&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gdisk&amp;lt;/tt&amp;gt;, or &amp;lt;tt&amp;gt;parted&amp;lt;/tt&amp;gt;&lt;br /&gt;
# Reboot into &amp;lt;tt&amp;gt;fastboot&amp;lt;/tt&amp;gt; and wipe &amp;lt;tt&amp;gt;userdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# Reboot into Android, where you can now chroot in and install your favorite distribution to the new partition.&lt;br /&gt;
&lt;br /&gt;
== Using rkdeveloptool ==&lt;br /&gt;
&lt;br /&gt;
=== Building Downstream U-Boot ===&lt;br /&gt;
&lt;br /&gt;
While in maskrom mode, we need to have a u-boot to download onto the device for any of the other commands to work. To build you'll also need to install device-tree-compiler.&lt;br /&gt;
&lt;br /&gt;
You also need to install Python and pyelftools.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Note that rkbin is a &amp;amp;gt;5GB download!&amp;lt;/b&amp;gt; This will take some time to clone and process the deltas.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone -b quartz64 https://gitlab.com/pgwipeout/u-boot-rockchip.git&lt;br /&gt;
git clone -b rkbin https://github.com/JeffyCN/rockchip_mirrors.git rkbin&lt;br /&gt;
cd u-boot-rockchip&lt;br /&gt;
# If using Arch Linux, export CROSS_COMPILE=aarch64-linux-gnu-&lt;br /&gt;
export CROSS_COMPILE=aarch64-none-linux-gnu-&lt;br /&gt;
make rk3566-quartz64_defconfig&lt;br /&gt;
./make.sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
In the current version (current as of 2022-01-02), there might have to be made a change to one line to get a clean compilation:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
diff --git a/lib/avb/libavb/avb_slot_verify.c b/lib/avb/libavb/avb_slot_verify.c&lt;br /&gt;
index 123701fc3b..64a1ce6450 100644&lt;br /&gt;
--- a/lib/avb/libavb/avb_slot_verify.c&lt;br /&gt;
+++ b/lib/avb/libavb/avb_slot_verify.c&lt;br /&gt;
@@ -296,7 +296,7 @@ static AvbSlotVerifyResult load_and_verify_hash_partition(&lt;br /&gt;
   bool image_preloaded = false;&lt;br /&gt;
   uint8_t* digest;&lt;br /&gt;
   size_t digest_len;&lt;br /&gt;
-  const char* found;&lt;br /&gt;
+  const char* found = NULL;&lt;br /&gt;
   uint64_t image_size;&lt;br /&gt;
   size_t expected_digest_len = 0;&lt;br /&gt;
   uint8_t expected_digest_buf[AVB_SHA512_DIGEST_SIZE];&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For systems where the global python executable points to python2, compilation fails with an error related to pyelftools not being installed (even if it is). To fix this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
diff --git a/make.sh b/make.sh&lt;br /&gt;
index 2bba05b4e4..cfe5b0afd5 100755&lt;br /&gt;
--- a/make.sh&lt;br /&gt;
+++ b/make.sh&lt;br /&gt;
@@ -758,7 +758,7 @@ function pack_fit_image()&lt;br /&gt;
        fi&lt;br /&gt;
 &lt;br /&gt;
        if [ &amp;quot;${ARM64_TRUSTZONE}&amp;quot; == &amp;quot;y&amp;quot; ]; then&lt;br /&gt;
-               if ! python -c &amp;quot;import elftools&amp;quot; ; then&lt;br /&gt;
+               if ! python3 -c &amp;quot;import elftools&amp;quot; ; then&lt;br /&gt;
                        echo &amp;quot;ERROR: No python 'pyelftools', please: pip install pyelftools&amp;quot;&lt;br /&gt;
                        exit 1&lt;br /&gt;
                fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can now download u-boot onto the PineNote:&lt;br /&gt;
&lt;br /&gt;
 ./rkdeveloptool boot ../u-boot-rockchip/rk356x_spl_loader_v1.08.111.bin&lt;br /&gt;
&lt;br /&gt;
This should output &amp;quot;''Downloading bootloader succeeded''&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
We can now verify that this worked using e.g. the &amp;quot;read flash info&amp;quot; command:&lt;br /&gt;
&lt;br /&gt;
 ./rkdeveloptool read-flash-info&lt;br /&gt;
&lt;br /&gt;
{{Note|'''TODO:''' Section needs to be finished}}&lt;br /&gt;
&lt;br /&gt;
=== Creating a mainline boot image ===&lt;br /&gt;
&lt;br /&gt;
You can create a filesystem image that replaces the Android boot or recovery partition by doing roughly the following:&lt;br /&gt;
&lt;br /&gt;
# Erase boot and dtbo with rkdeveloptool or fastboot (back them up first!!!)&lt;br /&gt;
# Create an ext2 partition image and mount it (fallocate, mkfs.ext2)&lt;br /&gt;
# Build your mainline kernel&lt;br /&gt;
# Copy the kernel, dtb and an initramfs to the root of the mounted image (use any old postmarketOS initramfs)&lt;br /&gt;
# Create a file in the root of the mounted image called &amp;lt;code&amp;gt;extlinux.conf&amp;lt;/code&amp;gt; as described below&lt;br /&gt;
# Unmount the image and then use rkdeveloptool to flash it to the &amp;quot;recovery&amp;quot; partition on the pinenote (it's about the right size until we get around to replacing the partition layout).&lt;br /&gt;
&lt;br /&gt;
== Using fastboot ==&lt;br /&gt;
&lt;br /&gt;
Follow the steps for [[PineNote Development/Flashing#Creating a mainline boot image|Creating a mainline boot image]], but instead of flashing it with ''rkdeveloptool'', use ''fastboot''. You can enter fastboot in either of two ways:&lt;br /&gt;
&lt;br /&gt;
* Use &amp;quot;reboot bootloader&amp;quot; from adb or a UART console or&lt;br /&gt;
* get a U-Boot prompt and run &amp;lt;code&amp;gt;fastboot usb 0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:PineNote]]&lt;/div&gt;</summary>
		<author><name>Ahelwer</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PineNote_Development/Flashing&amp;diff=20893</id>
		<title>PineNote Development/Flashing</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PineNote_Development/Flashing&amp;diff=20893"/>
		<updated>2023-10-14T02:12:42Z</updated>

		<summary type="html">&lt;p&gt;Ahelwer: /* U-Boot */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Under construction}}&lt;br /&gt;
&lt;br /&gt;
{{Info|These instructions are directed towards experienced developers only!}}&lt;br /&gt;
&lt;br /&gt;
This page contains information on flashing software to the [https://wiki.pine64.org/wiki/PineNote PineNote].&lt;br /&gt;
&lt;br /&gt;
Currently, software can be flashed using rkdeveloptool or from the factory Android installation (UART shell, adb, or fastboot).&lt;br /&gt;
&lt;br /&gt;
== Getting &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
Most flashing operations on the PineNote are done through &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt;, a command line utility built on libusb.&lt;br /&gt;
PINE64 maintains its own fork [https://gitlab.com/pine64-org/quartz-bsp/rkdeveloptool here] that you will need to get.&lt;br /&gt;
The repo's README contains a list of dependencies (libusb 1.0) and instructions for building the tool.&lt;br /&gt;
&lt;br /&gt;
Installing (not just building) &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; will configure PAM to elevate privileges where necessary on your system; you can configure this manually as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo cp 99-rk-rockusb.rules /etc/udev/rules.d/&lt;br /&gt;
sudo udevadm control --reload&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Entering Maskrom/Rockusb mode ==&lt;br /&gt;
&lt;br /&gt;
Interfacing with the PineNote over USB using &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; requires first booting the PineNote into [http://opensource.rock-chips.com/wiki_Rockusb an alternative operating mode] called Maskrom or Rockusb mode.&lt;br /&gt;
&lt;br /&gt;
=== Possible Methods ===&lt;br /&gt;
&lt;br /&gt;
There are three possible methods of entering Maskrom/Rockusb mode:&lt;br /&gt;
&lt;br /&gt;
==== Hardware Magnet Switch ====&lt;br /&gt;
&lt;br /&gt;
# Connect the PineNote to your computer via USB and boot the PineNote into Android&lt;br /&gt;
# Locate &amp;amp; identify the small circular marking on the back of the PineNote, in the top right quadrant; have the PineNote pen close at hand, or any other small magnet&lt;br /&gt;
# Hold the PineNote power button to bring up the reboot/shutdown menu; select reboot, then place the PineNote face down with the &amp;quot;eraser&amp;quot; end of the pen (or your magnet) resting on the small circular marking&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Download mode.jpeg|Pen method&lt;br /&gt;
PineNoteMagnetOnBack.jpg|Magnet method&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== U-Boot ====&lt;br /&gt;
This method requires a [[PineNote_Development/UART#USB_passthrough|UART dongle with passthrough]] allowing simultaneous UART &amp;amp; USB connections.&lt;br /&gt;
It is nice because you can easily switch back &amp;amp; forth between U-Boot and Rockusb without having to physically manipulate the PineNote or its connectors; this is especially helpful when trying to develop U-Boot.&lt;br /&gt;
&lt;br /&gt;
# Connect to the PineNote via UART and USB simultaneously&lt;br /&gt;
# Interrupt the U-Boot startup using &amp;lt;code&amp;gt;ctrl+c&amp;lt;/code&amp;gt; sent over UART&lt;br /&gt;
# In the U-Boot terminal over UART, run &amp;lt;code&amp;gt;rockusb 0 mmc 0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The UART terminal should print &amp;lt;code&amp;gt;RKUSB&amp;lt;/code&amp;gt; then a spinner will appear.&lt;br /&gt;
You can exit back to the U-Boot terminal by sending &amp;lt;code&amp;gt;ctrl+c&amp;lt;/code&amp;gt; again.&lt;br /&gt;
&lt;br /&gt;
==== Shorting Test Points ====&lt;br /&gt;
&lt;br /&gt;
If the bootloader is broken/corrupted, you cannot get to Maskrom without opening up the device (it can be opened using spudger and a bit of patience).&lt;br /&gt;
&lt;br /&gt;
Once inside, short TP1301 (GND) and TP1302 (eMMC_D0/FLASH_D0) with a small tweezers, this is how it looks on board view (credit to Caleb):&lt;br /&gt;
&lt;br /&gt;
[[File:PineNote_Maskrom_TP.png|500px]]&lt;br /&gt;
&lt;br /&gt;
=== Success ===&lt;br /&gt;
&lt;br /&gt;
No matter what approach you take, you can tell whether you succeeded by running the &amp;lt;code&amp;gt;lsusb&amp;lt;/code&amp;gt; command on your computer:&lt;br /&gt;
* If you find the entry &amp;lt;code&amp;gt;2207:0018 Fuzhou Rockchip Electronics Company rk3566_eink&amp;lt;/code&amp;gt; in the list, the process did not succeed; reboot and retry&lt;br /&gt;
* The entry &amp;lt;code&amp;gt;2207:350a Fuzhou Rockchip Electronics Company&amp;lt;/code&amp;gt; will occur if you detach then reattach the USB-C cable while the PineNote is in Maskrom/Rockusb mode; &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; won't work and you will have to do a hard reboot (hold down power button for 30 seconds to shutdown)&lt;br /&gt;
* If you find the entry &amp;lt;code&amp;gt;2207:350a Fuzhou Rockchip Electronics Company USB download gadget&amp;lt;/code&amp;gt; then the process succeeded&lt;br /&gt;
&lt;br /&gt;
You can also look at the output of the &amp;lt;code&amp;gt;rkdeveloptool list&amp;lt;/code&amp;gt; command:&lt;br /&gt;
* If this prints out &amp;lt;code&amp;gt;No devices in rockusb mode found&amp;lt;/code&amp;gt; the process did not succeed; reboot and retry&lt;br /&gt;
* If this prints out &amp;lt;code&amp;gt;DevNo=1 Vid=0x2207,Pid=0x350a,LocationID=305 Maskrom&amp;lt;/code&amp;gt; then you probably detached/reattached the USB-C cable while in Maskrom/Rockusb mode and &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; won't work; perform a hard reboot to fix&lt;br /&gt;
* If this prints out &amp;lt;code&amp;gt;DevNo=1 Vid=0x2207,Pid=0x350a,LocationID=303 Loader&amp;lt;/code&amp;gt; then the process succeeded&lt;br /&gt;
&lt;br /&gt;
=== Exiting mode ===&lt;br /&gt;
&lt;br /&gt;
You can boot the PineNote back into its normal mode of operation by powercycling the PineNote with its hardware power switch, or running the &amp;lt;code&amp;gt;rkdeveloptool reboot&amp;lt;/code&amp;gt; command.&lt;br /&gt;
If you used the magnetic switch method be sure to remove the pen/magnet before rebooting.&lt;br /&gt;
&lt;br /&gt;
== Backup ==&lt;br /&gt;
&lt;br /&gt;
A backup of the content of the internal eMMC before anything gets messed up is '''mandatory'''.&lt;br /&gt;
&lt;br /&gt;
Especially the ''waveform'' partition contains data '''unique''' to your PineNote and is a prime candidate for backup.&lt;br /&gt;
&lt;br /&gt;
Other partitions like U-Boot (need for any operation of the device) or the un-partitioned space at the beginning containing the GPT partition table (and presumably the VCOM setting for the e-ink display and maybe device mac addresses) contain data you may also wish to backup.&lt;br /&gt;
&lt;br /&gt;
Depending of your personal level of data hoarder you may want to backup more than this or even just everything (the large ''userdata'' partition is supposed to be able to be repopulated as empty space by Android)&lt;br /&gt;
&lt;br /&gt;
In any case it is easier to restore/extract data from a backup than not having one if you need one.&lt;br /&gt;
&lt;br /&gt;
This process was developed by Dorian Rudolph, originally described [https://github.com/DorianRudolph/pinenotes here].&lt;br /&gt;
&lt;br /&gt;
=== List partitions ===&lt;br /&gt;
&lt;br /&gt;
First, run &amp;lt;code&amp;gt;rkdeveloptool list-partitions&amp;lt;/code&amp;gt; to print out your PineNote's partitions to get an idea of what you're dealing with.&lt;br /&gt;
The stock PineNote has a fairly standard Android partition setup, including:&lt;br /&gt;
* uboot: the [https://en.wikipedia.org/wiki/Das_U-Boot U-Boot] embedded systems bootloader&lt;br /&gt;
* trust: secrets that can be encrypted with a key stored in the [https://en.wikipedia.org/wiki/Trusted_Platform_Module TPM]&lt;br /&gt;
* waveform: important files controlling the e-ink screen's state changes&lt;br /&gt;
* misc: miscellaneous files needed by the firmware&lt;br /&gt;
* dtbo: [https://en.wikipedia.org/wiki/Devicetree Device Tree Blob for Overlay], files describing the PineNote's hardware configuration&lt;br /&gt;
* vbmeta: data required for verified boot&lt;br /&gt;
* boot, security, recovery, backup, cache, metadata, super, logo, device&lt;br /&gt;
* userdata: the big one; this is where all your files are stored in the stock Android install&lt;br /&gt;
&lt;br /&gt;
=== Patch U-Boot ===&lt;br /&gt;
&lt;br /&gt;
Before we can back up our partitions, we have a problem to solve.&lt;br /&gt;
The version of U-Boot installed on the stock PineNote contains a bug where it can't dump partitions beyond 32 MB (above that limit all bytes in the dump are just &amp;lt;code&amp;gt;0xCC&amp;lt;/code&amp;gt;), meaning the PineNote must be flashed with a fixed version of U-Boot before it is possible to take a backup of the larger partitions.&lt;br /&gt;
It is possible to extract and modify the U-Boot image from your PineNote if you're interested in some light reverse-engineering (following Dorian's notes), or you can simply download a patched U-Boot image directly [https://github.com/DorianRudolph/pinenotes/blob/main/static/uboot_patched.img here].&lt;br /&gt;
&lt;br /&gt;
Once you've acquired a patched U-Boot image, run:&lt;br /&gt;
# &amp;lt;code&amp;gt;rkdeveloptool read-partition uboot uboot_backup.img&amp;lt;/code&amp;gt;&lt;br /&gt;
# &amp;lt;code&amp;gt;rkdeveloptool write-partition uboot uboot_patched.img&amp;lt;/code&amp;gt;&lt;br /&gt;
# &amp;lt;code&amp;gt;rkdeveloptool reboot&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Taking the backup ===&lt;br /&gt;
&lt;br /&gt;
There is a second backup limit preventing dumping partitions larger than 2 GB, this time from &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt;.&lt;br /&gt;
This means if you have a large number of documents in the Android userdata partition they might not all make it into the backup.&lt;br /&gt;
If you don't have many documents (or don't care about losing them) this should not be a problem.&lt;br /&gt;
If you do have a lot of documents, workarounds include:&lt;br /&gt;
* A possible patch written by Thomas exists [https://github.com/tpwrules/nixos-pinenote/blob/96d2c9158edb9da59afcb952cc864fada18382f9/nix/rkdeveloptool/0001-fix-large-dumps.patch here] but has not yet been upstreamed; consider investigating how to get the patch tested &amp;amp; upstreamed, or just apply it to your own local copy of &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt;&lt;br /&gt;
* Use [https://github.com/talpadk/pinenote-backup this] Python script written by Visti Andresen to automatically backup your entire partition by splitting reads into 2 GB chunks&lt;br /&gt;
&lt;br /&gt;
See [https://github.com/m-weigand/pinenote-debian-recipes/releases/tag/v0.1 instructions on this artifact]. It will instruct you on extracting the rootfs into an empty ext4 partition. This can be done from Linux or Android. Further instructions on building your own rootfs [https://github.com/m-weigand/pinenote-debian-recipes can be found here].&lt;br /&gt;
&lt;br /&gt;
=== Using a user installed Linux ===&lt;br /&gt;
A Linux installed to the cache partition should be able to easily backup everything over WiFi or to a USB stick/disk using ''dd''.&lt;br /&gt;
&lt;br /&gt;
However the user would need to backup the cache partition themself (if they want that).&lt;br /&gt;
&lt;br /&gt;
And more importantly they would only be getting the backup ''after'' they started playing with the content of the eMMC.&lt;br /&gt;
&lt;br /&gt;
== Side-by-side setup ==&lt;br /&gt;
&lt;br /&gt;
It is possible to set up a partition for mainline development without disturbing the factory Android installation. This allows updating a mainline kernel, DTB, and initramfs over Wi-Fi until WiFi or USB OTG is working in mainline Linux.&lt;br /&gt;
&lt;br /&gt;
=== Without Repartitioning ===&lt;br /&gt;
&lt;br /&gt;
The recommended partition for this is &amp;lt;tt&amp;gt;mmcblk0p11&amp;lt;/tt&amp;gt; aka &amp;lt;tt&amp;gt;/cache&amp;lt;/tt&amp;gt;. It is large and already formatted as &amp;lt;tt&amp;gt;ext4&amp;lt;/tt&amp;gt;, so it is readable from U-Boot. Here are some general steps:&lt;br /&gt;
&lt;br /&gt;
# From the UART or adb shell, set up your chroot in &amp;lt;tt&amp;gt;/cache&amp;lt;/tt&amp;gt;. I used the Alpine Linux rootfs tarball.&lt;br /&gt;
# Copy in your kernel and DTB, using for example &amp;lt;tt&amp;gt;scp&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;wget&amp;lt;/tt&amp;gt; inside the chroot.&lt;br /&gt;
# Finally, create and boot an &amp;lt;code&amp;gt;extlinux.conf&amp;lt;/code&amp;gt; as described below.&lt;br /&gt;
&lt;br /&gt;
=== With Repartitioning ===&lt;br /&gt;
&lt;br /&gt;
It is possible to shrink the &amp;lt;tt&amp;gt;userdata&amp;lt;/tt&amp;gt; partition, and create a new partition at the end for use with mainline Linux. This provides much more space than &amp;lt;tt&amp;gt;cache&amp;lt;/tt&amp;gt;. However, because &amp;lt;tt&amp;gt;userdata&amp;lt;/tt&amp;gt; is formatted with &amp;lt;tt&amp;gt;f2fs&amp;lt;/tt&amp;gt;, and that filesystem cannot be shrunk, resizing the partition requires wiping &amp;lt;tt&amp;gt;userdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
# Back up any necessary files from userdata&lt;br /&gt;
# Boot to a mainline kernel from &amp;lt;tt&amp;gt;mmcblk0p11&amp;lt;/tt&amp;gt;, either using that partition as rootfs (see above), or using an initramfs with repartitioning tools&lt;br /&gt;
# Modify the partition table with your favorite tool, e.g. &amp;lt;tt&amp;gt;fdisk&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gdisk&amp;lt;/tt&amp;gt;, or &amp;lt;tt&amp;gt;parted&amp;lt;/tt&amp;gt;&lt;br /&gt;
# Reboot into &amp;lt;tt&amp;gt;fastboot&amp;lt;/tt&amp;gt; and wipe &amp;lt;tt&amp;gt;userdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# Reboot into Android, where you can now chroot in and install your favorite distribution to the new partition.&lt;br /&gt;
&lt;br /&gt;
== Using rkdeveloptool ==&lt;br /&gt;
&lt;br /&gt;
=== Building Downstream U-Boot ===&lt;br /&gt;
&lt;br /&gt;
While in maskrom mode, we need to have a u-boot to download onto the device for any of the other commands to work. To build you'll also need to install device-tree-compiler.&lt;br /&gt;
&lt;br /&gt;
You also need to install Python and pyelftools.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Note that rkbin is a &amp;amp;gt;5GB download!&amp;lt;/b&amp;gt; This will take some time to clone and process the deltas.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone -b quartz64 https://gitlab.com/pgwipeout/u-boot-rockchip.git&lt;br /&gt;
git clone -b rkbin https://github.com/JeffyCN/rockchip_mirrors.git rkbin&lt;br /&gt;
cd u-boot-rockchip&lt;br /&gt;
# If using Arch Linux, export CROSS_COMPILE=aarch64-linux-gnu-&lt;br /&gt;
export CROSS_COMPILE=aarch64-none-linux-gnu-&lt;br /&gt;
make rk3566-quartz64_defconfig&lt;br /&gt;
./make.sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
In the current version (current as of 2022-01-02), there might have to be made a change to one line to get a clean compilation:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
diff --git a/lib/avb/libavb/avb_slot_verify.c b/lib/avb/libavb/avb_slot_verify.c&lt;br /&gt;
index 123701fc3b..64a1ce6450 100644&lt;br /&gt;
--- a/lib/avb/libavb/avb_slot_verify.c&lt;br /&gt;
+++ b/lib/avb/libavb/avb_slot_verify.c&lt;br /&gt;
@@ -296,7 +296,7 @@ static AvbSlotVerifyResult load_and_verify_hash_partition(&lt;br /&gt;
   bool image_preloaded = false;&lt;br /&gt;
   uint8_t* digest;&lt;br /&gt;
   size_t digest_len;&lt;br /&gt;
-  const char* found;&lt;br /&gt;
+  const char* found = NULL;&lt;br /&gt;
   uint64_t image_size;&lt;br /&gt;
   size_t expected_digest_len = 0;&lt;br /&gt;
   uint8_t expected_digest_buf[AVB_SHA512_DIGEST_SIZE];&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For systems where the global python executable points to python2, compilation fails with an error related to pyelftools not being installed (even if it is). To fix this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
diff --git a/make.sh b/make.sh&lt;br /&gt;
index 2bba05b4e4..cfe5b0afd5 100755&lt;br /&gt;
--- a/make.sh&lt;br /&gt;
+++ b/make.sh&lt;br /&gt;
@@ -758,7 +758,7 @@ function pack_fit_image()&lt;br /&gt;
        fi&lt;br /&gt;
 &lt;br /&gt;
        if [ &amp;quot;${ARM64_TRUSTZONE}&amp;quot; == &amp;quot;y&amp;quot; ]; then&lt;br /&gt;
-               if ! python -c &amp;quot;import elftools&amp;quot; ; then&lt;br /&gt;
+               if ! python3 -c &amp;quot;import elftools&amp;quot; ; then&lt;br /&gt;
                        echo &amp;quot;ERROR: No python 'pyelftools', please: pip install pyelftools&amp;quot;&lt;br /&gt;
                        exit 1&lt;br /&gt;
                fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can now download u-boot onto the PineNote:&lt;br /&gt;
&lt;br /&gt;
 ./rkdeveloptool boot ../u-boot-rockchip/rk356x_spl_loader_v1.08.111.bin&lt;br /&gt;
&lt;br /&gt;
This should output &amp;quot;''Downloading bootloader succeeded''&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
We can now verify that this worked using e.g. the &amp;quot;read flash info&amp;quot; command:&lt;br /&gt;
&lt;br /&gt;
 ./rkdeveloptool read-flash-info&lt;br /&gt;
&lt;br /&gt;
{{Note|'''TODO:''' Section needs to be finished}}&lt;br /&gt;
&lt;br /&gt;
=== Creating a mainline boot image ===&lt;br /&gt;
&lt;br /&gt;
You can create a filesystem image that replaces the Android boot or recovery partition by doing roughly the following:&lt;br /&gt;
&lt;br /&gt;
# Erase boot and dtbo with rkdeveloptool or fastboot (back them up first!!!)&lt;br /&gt;
# Create an ext2 partition image and mount it (fallocate, mkfs.ext2)&lt;br /&gt;
# Build your mainline kernel&lt;br /&gt;
# Copy the kernel, dtb and an initramfs to the root of the mounted image (use any old postmarketOS initramfs)&lt;br /&gt;
# Create a file in the root of the mounted image called &amp;lt;code&amp;gt;extlinux.conf&amp;lt;/code&amp;gt; as described below&lt;br /&gt;
# Unmount the image and then use rkdeveloptool to flash it to the &amp;quot;recovery&amp;quot; partition on the pinenote (it's about the right size until we get around to replacing the partition layout).&lt;br /&gt;
&lt;br /&gt;
== Using fastboot ==&lt;br /&gt;
&lt;br /&gt;
Follow the steps for [[PineNote Development/Flashing#Creating a mainline boot image|Creating a mainline boot image]], but instead of flashing it with ''rkdeveloptool'', use ''fastboot''. You can enter fastboot in either of two ways:&lt;br /&gt;
&lt;br /&gt;
* Use &amp;quot;reboot bootloader&amp;quot; from adb or a UART console or&lt;br /&gt;
* get a U-Boot prompt and run &amp;lt;code&amp;gt;fastboot usb 0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:PineNote]]&lt;/div&gt;</summary>
		<author><name>Ahelwer</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PineNote_Development/Flashing&amp;diff=20892</id>
		<title>PineNote Development/Flashing</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PineNote_Development/Flashing&amp;diff=20892"/>
		<updated>2023-10-14T02:10:11Z</updated>

		<summary type="html">&lt;p&gt;Ahelwer: /* U-Boot */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Under construction}}&lt;br /&gt;
&lt;br /&gt;
{{Info|These instructions are directed towards experienced developers only!}}&lt;br /&gt;
&lt;br /&gt;
This page contains information on flashing software to the [https://wiki.pine64.org/wiki/PineNote PineNote].&lt;br /&gt;
&lt;br /&gt;
Currently, software can be flashed using rkdeveloptool or from the factory Android installation (UART shell, adb, or fastboot).&lt;br /&gt;
&lt;br /&gt;
== Getting &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
Most flashing operations on the PineNote are done through &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt;, a command line utility built on libusb.&lt;br /&gt;
PINE64 maintains its own fork [https://gitlab.com/pine64-org/quartz-bsp/rkdeveloptool here] that you will need to get.&lt;br /&gt;
The repo's README contains a list of dependencies (libusb 1.0) and instructions for building the tool.&lt;br /&gt;
&lt;br /&gt;
Installing (not just building) &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; will configure PAM to elevate privileges where necessary on your system; you can configure this manually as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo cp 99-rk-rockusb.rules /etc/udev/rules.d/&lt;br /&gt;
sudo udevadm control --reload&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Entering Maskrom/Rockusb mode ==&lt;br /&gt;
&lt;br /&gt;
Interfacing with the PineNote over USB using &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; requires first booting the PineNote into [http://opensource.rock-chips.com/wiki_Rockusb an alternative operating mode] called Maskrom or Rockusb mode.&lt;br /&gt;
&lt;br /&gt;
=== Possible Methods ===&lt;br /&gt;
&lt;br /&gt;
There are three possible methods of entering Maskrom/Rockusb mode:&lt;br /&gt;
&lt;br /&gt;
==== Hardware Magnet Switch ====&lt;br /&gt;
&lt;br /&gt;
# Connect the PineNote to your computer via USB and boot the PineNote into Android&lt;br /&gt;
# Locate &amp;amp; identify the small circular marking on the back of the PineNote, in the top right quadrant; have the PineNote pen close at hand, or any other small magnet&lt;br /&gt;
# Hold the PineNote power button to bring up the reboot/shutdown menu; select reboot, then place the PineNote face down with the &amp;quot;eraser&amp;quot; end of the pen (or your magnet) resting on the small circular marking&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Download mode.jpeg|Pen method&lt;br /&gt;
PineNoteMagnetOnBack.jpg|Magnet method&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== U-Boot ====&lt;br /&gt;
This method requires a [[PineNote_Development/UART#USB_passthrough|UART dongle with passthrough]] allowing simultaneous UART &amp;amp; USB connections.&lt;br /&gt;
It is nice because you can easily switch back &amp;amp; forth between U-Boot and Rockusb without having to physically manipulate the PineNote or its connectors; this is especially helpful when trying to develop U-Boot.&lt;br /&gt;
&lt;br /&gt;
# Connect to the PineNote via UART and USB simultaneously&lt;br /&gt;
# Interrupt the U-Boot startup using &amp;lt;code&amp;gt;ctrl-c&amp;lt;/code&amp;gt; sent over UART&lt;br /&gt;
# In the U-Boot terminal over UART, run &amp;lt;code&amp;gt;rockusb 0 mmc 0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Shorting Test Points ====&lt;br /&gt;
&lt;br /&gt;
If the bootloader is broken/corrupted, you cannot get to Maskrom without opening up the device (it can be opened using spudger and a bit of patience).&lt;br /&gt;
&lt;br /&gt;
Once inside, short TP1301 (GND) and TP1302 (eMMC_D0/FLASH_D0) with a small tweezers, this is how it looks on board view (credit to Caleb):&lt;br /&gt;
&lt;br /&gt;
[[File:PineNote_Maskrom_TP.png|500px]]&lt;br /&gt;
&lt;br /&gt;
=== Success ===&lt;br /&gt;
&lt;br /&gt;
No matter what approach you take, you can tell whether you succeeded by running the &amp;lt;code&amp;gt;lsusb&amp;lt;/code&amp;gt; command on your computer:&lt;br /&gt;
* If you find the entry &amp;lt;code&amp;gt;2207:0018 Fuzhou Rockchip Electronics Company rk3566_eink&amp;lt;/code&amp;gt; in the list, the process did not succeed; reboot and retry&lt;br /&gt;
* The entry &amp;lt;code&amp;gt;2207:350a Fuzhou Rockchip Electronics Company&amp;lt;/code&amp;gt; will occur if you detach then reattach the USB-C cable while the PineNote is in Maskrom/Rockusb mode; &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; won't work and you will have to do a hard reboot (hold down power button for 30 seconds to shutdown)&lt;br /&gt;
* If you find the entry &amp;lt;code&amp;gt;2207:350a Fuzhou Rockchip Electronics Company USB download gadget&amp;lt;/code&amp;gt; then the process succeeded&lt;br /&gt;
&lt;br /&gt;
You can also look at the output of the &amp;lt;code&amp;gt;rkdeveloptool list&amp;lt;/code&amp;gt; command:&lt;br /&gt;
* If this prints out &amp;lt;code&amp;gt;No devices in rockusb mode found&amp;lt;/code&amp;gt; the process did not succeed; reboot and retry&lt;br /&gt;
* If this prints out &amp;lt;code&amp;gt;DevNo=1 Vid=0x2207,Pid=0x350a,LocationID=305 Maskrom&amp;lt;/code&amp;gt; then you probably detached/reattached the USB-C cable while in Maskrom/Rockusb mode and &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; won't work; perform a hard reboot to fix&lt;br /&gt;
* If this prints out &amp;lt;code&amp;gt;DevNo=1 Vid=0x2207,Pid=0x350a,LocationID=303 Loader&amp;lt;/code&amp;gt; then the process succeeded&lt;br /&gt;
&lt;br /&gt;
=== Exiting mode ===&lt;br /&gt;
&lt;br /&gt;
You can boot the PineNote back into its normal mode of operation by powercycling the PineNote with its hardware power switch, or running the &amp;lt;code&amp;gt;rkdeveloptool reboot&amp;lt;/code&amp;gt; command.&lt;br /&gt;
If you used the magnetic switch method be sure to remove the pen/magnet before rebooting.&lt;br /&gt;
&lt;br /&gt;
== Backup ==&lt;br /&gt;
&lt;br /&gt;
A backup of the content of the internal eMMC before anything gets messed up is '''mandatory'''.&lt;br /&gt;
&lt;br /&gt;
Especially the ''waveform'' partition contains data '''unique''' to your PineNote and is a prime candidate for backup.&lt;br /&gt;
&lt;br /&gt;
Other partitions like U-Boot (need for any operation of the device) or the un-partitioned space at the beginning containing the GPT partition table (and presumably the VCOM setting for the e-ink display and maybe device mac addresses) contain data you may also wish to backup.&lt;br /&gt;
&lt;br /&gt;
Depending of your personal level of data hoarder you may want to backup more than this or even just everything (the large ''userdata'' partition is supposed to be able to be repopulated as empty space by Android)&lt;br /&gt;
&lt;br /&gt;
In any case it is easier to restore/extract data from a backup than not having one if you need one.&lt;br /&gt;
&lt;br /&gt;
This process was developed by Dorian Rudolph, originally described [https://github.com/DorianRudolph/pinenotes here].&lt;br /&gt;
&lt;br /&gt;
=== List partitions ===&lt;br /&gt;
&lt;br /&gt;
First, run &amp;lt;code&amp;gt;rkdeveloptool list-partitions&amp;lt;/code&amp;gt; to print out your PineNote's partitions to get an idea of what you're dealing with.&lt;br /&gt;
The stock PineNote has a fairly standard Android partition setup, including:&lt;br /&gt;
* uboot: the [https://en.wikipedia.org/wiki/Das_U-Boot U-Boot] embedded systems bootloader&lt;br /&gt;
* trust: secrets that can be encrypted with a key stored in the [https://en.wikipedia.org/wiki/Trusted_Platform_Module TPM]&lt;br /&gt;
* waveform: important files controlling the e-ink screen's state changes&lt;br /&gt;
* misc: miscellaneous files needed by the firmware&lt;br /&gt;
* dtbo: [https://en.wikipedia.org/wiki/Devicetree Device Tree Blob for Overlay], files describing the PineNote's hardware configuration&lt;br /&gt;
* vbmeta: data required for verified boot&lt;br /&gt;
* boot, security, recovery, backup, cache, metadata, super, logo, device&lt;br /&gt;
* userdata: the big one; this is where all your files are stored in the stock Android install&lt;br /&gt;
&lt;br /&gt;
=== Patch U-Boot ===&lt;br /&gt;
&lt;br /&gt;
Before we can back up our partitions, we have a problem to solve.&lt;br /&gt;
The version of U-Boot installed on the stock PineNote contains a bug where it can't dump partitions beyond 32 MB (above that limit all bytes in the dump are just &amp;lt;code&amp;gt;0xCC&amp;lt;/code&amp;gt;), meaning the PineNote must be flashed with a fixed version of U-Boot before it is possible to take a backup of the larger partitions.&lt;br /&gt;
It is possible to extract and modify the U-Boot image from your PineNote if you're interested in some light reverse-engineering (following Dorian's notes), or you can simply download a patched U-Boot image directly [https://github.com/DorianRudolph/pinenotes/blob/main/static/uboot_patched.img here].&lt;br /&gt;
&lt;br /&gt;
Once you've acquired a patched U-Boot image, run:&lt;br /&gt;
# &amp;lt;code&amp;gt;rkdeveloptool read-partition uboot uboot_backup.img&amp;lt;/code&amp;gt;&lt;br /&gt;
# &amp;lt;code&amp;gt;rkdeveloptool write-partition uboot uboot_patched.img&amp;lt;/code&amp;gt;&lt;br /&gt;
# &amp;lt;code&amp;gt;rkdeveloptool reboot&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Taking the backup ===&lt;br /&gt;
&lt;br /&gt;
There is a second backup limit preventing dumping partitions larger than 2 GB, this time from &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt;.&lt;br /&gt;
This means if you have a large number of documents in the Android userdata partition they might not all make it into the backup.&lt;br /&gt;
If you don't have many documents (or don't care about losing them) this should not be a problem.&lt;br /&gt;
If you do have a lot of documents, workarounds include:&lt;br /&gt;
* A possible patch written by Thomas exists [https://github.com/tpwrules/nixos-pinenote/blob/96d2c9158edb9da59afcb952cc864fada18382f9/nix/rkdeveloptool/0001-fix-large-dumps.patch here] but has not yet been upstreamed; consider investigating how to get the patch tested &amp;amp; upstreamed, or just apply it to your own local copy of &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt;&lt;br /&gt;
* Use [https://github.com/talpadk/pinenote-backup this] Python script written by Visti Andresen to automatically backup your entire partition by splitting reads into 2 GB chunks&lt;br /&gt;
&lt;br /&gt;
See [https://github.com/m-weigand/pinenote-debian-recipes/releases/tag/v0.1 instructions on this artifact]. It will instruct you on extracting the rootfs into an empty ext4 partition. This can be done from Linux or Android. Further instructions on building your own rootfs [https://github.com/m-weigand/pinenote-debian-recipes can be found here].&lt;br /&gt;
&lt;br /&gt;
=== Using a user installed Linux ===&lt;br /&gt;
A Linux installed to the cache partition should be able to easily backup everything over WiFi or to a USB stick/disk using ''dd''.&lt;br /&gt;
&lt;br /&gt;
However the user would need to backup the cache partition themself (if they want that).&lt;br /&gt;
&lt;br /&gt;
And more importantly they would only be getting the backup ''after'' they started playing with the content of the eMMC.&lt;br /&gt;
&lt;br /&gt;
== Side-by-side setup ==&lt;br /&gt;
&lt;br /&gt;
It is possible to set up a partition for mainline development without disturbing the factory Android installation. This allows updating a mainline kernel, DTB, and initramfs over Wi-Fi until WiFi or USB OTG is working in mainline Linux.&lt;br /&gt;
&lt;br /&gt;
=== Without Repartitioning ===&lt;br /&gt;
&lt;br /&gt;
The recommended partition for this is &amp;lt;tt&amp;gt;mmcblk0p11&amp;lt;/tt&amp;gt; aka &amp;lt;tt&amp;gt;/cache&amp;lt;/tt&amp;gt;. It is large and already formatted as &amp;lt;tt&amp;gt;ext4&amp;lt;/tt&amp;gt;, so it is readable from U-Boot. Here are some general steps:&lt;br /&gt;
&lt;br /&gt;
# From the UART or adb shell, set up your chroot in &amp;lt;tt&amp;gt;/cache&amp;lt;/tt&amp;gt;. I used the Alpine Linux rootfs tarball.&lt;br /&gt;
# Copy in your kernel and DTB, using for example &amp;lt;tt&amp;gt;scp&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;wget&amp;lt;/tt&amp;gt; inside the chroot.&lt;br /&gt;
# Finally, create and boot an &amp;lt;code&amp;gt;extlinux.conf&amp;lt;/code&amp;gt; as described below.&lt;br /&gt;
&lt;br /&gt;
=== With Repartitioning ===&lt;br /&gt;
&lt;br /&gt;
It is possible to shrink the &amp;lt;tt&amp;gt;userdata&amp;lt;/tt&amp;gt; partition, and create a new partition at the end for use with mainline Linux. This provides much more space than &amp;lt;tt&amp;gt;cache&amp;lt;/tt&amp;gt;. However, because &amp;lt;tt&amp;gt;userdata&amp;lt;/tt&amp;gt; is formatted with &amp;lt;tt&amp;gt;f2fs&amp;lt;/tt&amp;gt;, and that filesystem cannot be shrunk, resizing the partition requires wiping &amp;lt;tt&amp;gt;userdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
# Back up any necessary files from userdata&lt;br /&gt;
# Boot to a mainline kernel from &amp;lt;tt&amp;gt;mmcblk0p11&amp;lt;/tt&amp;gt;, either using that partition as rootfs (see above), or using an initramfs with repartitioning tools&lt;br /&gt;
# Modify the partition table with your favorite tool, e.g. &amp;lt;tt&amp;gt;fdisk&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gdisk&amp;lt;/tt&amp;gt;, or &amp;lt;tt&amp;gt;parted&amp;lt;/tt&amp;gt;&lt;br /&gt;
# Reboot into &amp;lt;tt&amp;gt;fastboot&amp;lt;/tt&amp;gt; and wipe &amp;lt;tt&amp;gt;userdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# Reboot into Android, where you can now chroot in and install your favorite distribution to the new partition.&lt;br /&gt;
&lt;br /&gt;
== Using rkdeveloptool ==&lt;br /&gt;
&lt;br /&gt;
=== Building Downstream U-Boot ===&lt;br /&gt;
&lt;br /&gt;
While in maskrom mode, we need to have a u-boot to download onto the device for any of the other commands to work. To build you'll also need to install device-tree-compiler.&lt;br /&gt;
&lt;br /&gt;
You also need to install Python and pyelftools.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Note that rkbin is a &amp;amp;gt;5GB download!&amp;lt;/b&amp;gt; This will take some time to clone and process the deltas.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone -b quartz64 https://gitlab.com/pgwipeout/u-boot-rockchip.git&lt;br /&gt;
git clone -b rkbin https://github.com/JeffyCN/rockchip_mirrors.git rkbin&lt;br /&gt;
cd u-boot-rockchip&lt;br /&gt;
# If using Arch Linux, export CROSS_COMPILE=aarch64-linux-gnu-&lt;br /&gt;
export CROSS_COMPILE=aarch64-none-linux-gnu-&lt;br /&gt;
make rk3566-quartz64_defconfig&lt;br /&gt;
./make.sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
In the current version (current as of 2022-01-02), there might have to be made a change to one line to get a clean compilation:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
diff --git a/lib/avb/libavb/avb_slot_verify.c b/lib/avb/libavb/avb_slot_verify.c&lt;br /&gt;
index 123701fc3b..64a1ce6450 100644&lt;br /&gt;
--- a/lib/avb/libavb/avb_slot_verify.c&lt;br /&gt;
+++ b/lib/avb/libavb/avb_slot_verify.c&lt;br /&gt;
@@ -296,7 +296,7 @@ static AvbSlotVerifyResult load_and_verify_hash_partition(&lt;br /&gt;
   bool image_preloaded = false;&lt;br /&gt;
   uint8_t* digest;&lt;br /&gt;
   size_t digest_len;&lt;br /&gt;
-  const char* found;&lt;br /&gt;
+  const char* found = NULL;&lt;br /&gt;
   uint64_t image_size;&lt;br /&gt;
   size_t expected_digest_len = 0;&lt;br /&gt;
   uint8_t expected_digest_buf[AVB_SHA512_DIGEST_SIZE];&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For systems where the global python executable points to python2, compilation fails with an error related to pyelftools not being installed (even if it is). To fix this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
diff --git a/make.sh b/make.sh&lt;br /&gt;
index 2bba05b4e4..cfe5b0afd5 100755&lt;br /&gt;
--- a/make.sh&lt;br /&gt;
+++ b/make.sh&lt;br /&gt;
@@ -758,7 +758,7 @@ function pack_fit_image()&lt;br /&gt;
        fi&lt;br /&gt;
 &lt;br /&gt;
        if [ &amp;quot;${ARM64_TRUSTZONE}&amp;quot; == &amp;quot;y&amp;quot; ]; then&lt;br /&gt;
-               if ! python -c &amp;quot;import elftools&amp;quot; ; then&lt;br /&gt;
+               if ! python3 -c &amp;quot;import elftools&amp;quot; ; then&lt;br /&gt;
                        echo &amp;quot;ERROR: No python 'pyelftools', please: pip install pyelftools&amp;quot;&lt;br /&gt;
                        exit 1&lt;br /&gt;
                fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can now download u-boot onto the PineNote:&lt;br /&gt;
&lt;br /&gt;
 ./rkdeveloptool boot ../u-boot-rockchip/rk356x_spl_loader_v1.08.111.bin&lt;br /&gt;
&lt;br /&gt;
This should output &amp;quot;''Downloading bootloader succeeded''&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
We can now verify that this worked using e.g. the &amp;quot;read flash info&amp;quot; command:&lt;br /&gt;
&lt;br /&gt;
 ./rkdeveloptool read-flash-info&lt;br /&gt;
&lt;br /&gt;
{{Note|'''TODO:''' Section needs to be finished}}&lt;br /&gt;
&lt;br /&gt;
=== Creating a mainline boot image ===&lt;br /&gt;
&lt;br /&gt;
You can create a filesystem image that replaces the Android boot or recovery partition by doing roughly the following:&lt;br /&gt;
&lt;br /&gt;
# Erase boot and dtbo with rkdeveloptool or fastboot (back them up first!!!)&lt;br /&gt;
# Create an ext2 partition image and mount it (fallocate, mkfs.ext2)&lt;br /&gt;
# Build your mainline kernel&lt;br /&gt;
# Copy the kernel, dtb and an initramfs to the root of the mounted image (use any old postmarketOS initramfs)&lt;br /&gt;
# Create a file in the root of the mounted image called &amp;lt;code&amp;gt;extlinux.conf&amp;lt;/code&amp;gt; as described below&lt;br /&gt;
# Unmount the image and then use rkdeveloptool to flash it to the &amp;quot;recovery&amp;quot; partition on the pinenote (it's about the right size until we get around to replacing the partition layout).&lt;br /&gt;
&lt;br /&gt;
== Using fastboot ==&lt;br /&gt;
&lt;br /&gt;
Follow the steps for [[PineNote Development/Flashing#Creating a mainline boot image|Creating a mainline boot image]], but instead of flashing it with ''rkdeveloptool'', use ''fastboot''. You can enter fastboot in either of two ways:&lt;br /&gt;
&lt;br /&gt;
* Use &amp;quot;reboot bootloader&amp;quot; from adb or a UART console or&lt;br /&gt;
* get a U-Boot prompt and run &amp;lt;code&amp;gt;fastboot usb 0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:PineNote]]&lt;/div&gt;</summary>
		<author><name>Ahelwer</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PineNote_Development/UART&amp;diff=20891</id>
		<title>PineNote Development/UART</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PineNote_Development/UART&amp;diff=20891"/>
		<updated>2023-10-14T01:46:24Z</updated>

		<summary type="html">&lt;p&gt;Ahelwer: /* Assembly */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Pinenote-uart-dongle.jpeg|thumb|Basic non-stock PineNote UART dongle]]&lt;br /&gt;
&lt;br /&gt;
This page contains information on creating and using a [https://en.wikipedia.org/wiki/Universal_asynchronous_receiver-transmitter UART] dongle for the [[PineNote]].&lt;br /&gt;
The PineNote was shipped with a compatible UART dongle, but replacements are not available to order in case of loss or hardware fault.&lt;br /&gt;
Thankfully it is not difficult to make your own from easily-acquired components and a small bit of soldering.&lt;br /&gt;
Fear not if you've never soldered anything before!&lt;br /&gt;
This serves as an excellent first soldering project.&lt;br /&gt;
Borrow the tools from a friend or a local hackerspace or tool library.&lt;br /&gt;
&lt;br /&gt;
A PineNote UART dongle enables you to:&lt;br /&gt;
# Interact with the system boot menu&lt;br /&gt;
# Read system events in real time as the PineNote is used&lt;br /&gt;
# Fix the PineNote without opening the case if something goes wrong while [[PineNote Development/Flashing|flashing it]]&lt;br /&gt;
&lt;br /&gt;
Since the PineNote is an embedded system, interfacing with it during boot is more complicated than with an ordinary computer.&lt;br /&gt;
The UART dongle enables you to do this.&lt;br /&gt;
&lt;br /&gt;
The PineNote factory firmware runs UART at a baud rate of 1500000 bps, 8 data bits, 1 stop bit, no parity and no flow control.&lt;br /&gt;
The process by which the PineNote design was modified to include closed-case UART is documented [[PineNote/Hardware Changes/Closed Case UART|here]].&lt;br /&gt;
&lt;br /&gt;
== Stock dongle ==&lt;br /&gt;
&lt;br /&gt;
The stock UART dongle included with the PineNote was a simple device plugging directly into the PineNote's USB-C port.&lt;br /&gt;
The dongle exposed a female USB-C port, which the user plugged into to get UART access.&lt;br /&gt;
This design unfortunately ruled out passthrough USB connections, where the user connects to the PineNote via UART and USB simultaneously.&lt;br /&gt;
The dongle is not currently available for purchase.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Pinenote-stock-uart-dongle-front.jpg|Front&lt;br /&gt;
Pinenote-stock-uart-dongle-back.jpg|Back&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Creating a dongle ==&lt;br /&gt;
&lt;br /&gt;
A typical self-built PineNote UART dongle design has the following components:&lt;br /&gt;
# A USB-C breakout board with a male connector exposing the 24 pins of the PineNote's USB-C port&lt;br /&gt;
# A USB-UART adapter, to plug into a USB port of the computer you'll use to interface with the PineNote&lt;br /&gt;
# [https://en.wikipedia.org/wiki/Jump_wire Jump wires] to connect specific breakout board pins to pins on the USB-UART adapter&lt;br /&gt;
# Two 1,000 Ohm through-hole resistors to splice into the jump wires&lt;br /&gt;
# Electrical tape or heat shrink to wrap connectors and prevent shorts&lt;br /&gt;
&lt;br /&gt;
You will also need the following tools:&lt;br /&gt;
# Soldering iron with solder&lt;br /&gt;
# Wire cutters &amp;amp; strippers&lt;br /&gt;
&lt;br /&gt;
The PineNote's internal UART system is documented in [https://files.pine64.org/doc/PineNote/PineNote_USB-C_Console_UART_breakout_board_schematic_v1.0_20210903.pdf this schematic].&lt;br /&gt;
The purpose of all 24 USB-C pins is documented [https://en.wikipedia.org/wiki/USB-C#Receptacles on the USB-C Wikipedia page].&lt;br /&gt;
We are interested in three sets of pins:&lt;br /&gt;
# The SBU1 (A8) and SBU2 (B8) side band use pins&lt;br /&gt;
# The CC1 (A5) and CC2 (B5) configuration channel pins&lt;br /&gt;
# The GND [https://en.wikipedia.org/wiki/Ground_(electricity) ground return] pins (A1, A12, B1, and B12)&lt;br /&gt;
&lt;br /&gt;
In the PineNote UART schematic you can see (on the bottom right diagram labeled &amp;lt;code&amp;gt;USB_TYPEC_Male&amp;lt;/code&amp;gt;) the side band pins are given the labels &amp;lt;code&amp;gt;UART2_TX_SUB1&amp;lt;/code&amp;gt; for A8 and &amp;lt;code&amp;gt;UART2_RX_SUB2&amp;lt;/code&amp;gt; for B8.&lt;br /&gt;
The first (TX) is used for transmitting data and the second (RX) is used for receiving data, from the perspective of the PineNote.&lt;br /&gt;
Also note the configuration channel pins labeled &amp;lt;code&amp;gt;TYPEC_CC1&amp;lt;/code&amp;gt; for A5 and &amp;lt;code&amp;gt;TYPEC_CC2&amp;lt;/code&amp;gt; for B5.&lt;br /&gt;
These pins are used to signal to the PineNote that a UART dongle is present.&lt;br /&gt;
The diagram shows they must be connected to a 3.3V source in parallel, mediated by resistors.&lt;br /&gt;
The schematic indicates 10,000 Ohm resistors, but community member talpadk experimented and found 1,000 Ohm resistors work better.&lt;br /&gt;
Our mission is to wire up pins from a USB-UART adapter to a USB-C breakout board following these requirements.&lt;br /&gt;
&lt;br /&gt;
=== Buying components ===&lt;br /&gt;
&lt;br /&gt;
There are many possible USB-C breakout board designs available for purchase online.&lt;br /&gt;
One particularly useful design is a &amp;quot;passthrough&amp;quot; or &amp;quot;intercept&amp;quot; style, with both male and female USB-C ports.&lt;br /&gt;
This design is more versatile in case you want to reuse it in other projects, and also enables you to connect to the PineNote via UART and USB at the same time.&lt;br /&gt;
An example of this product can be found [https://pmdway.com/products/usb-3-1-type-c-male-to-female-breakout-test-board here], although you are encouraged to shop around for cheaper options.&lt;br /&gt;
If you're fine with a bit more soldering, there is a very cheap one [https://www.ebay.com/itm/275407037613 here].&lt;br /&gt;
&lt;br /&gt;
Similarly, there are many USB-UART adapter designs available.&lt;br /&gt;
These devices plug into your computer and expose a number of pins themselves, connecting to specific pins on the breakout board with jump wires.&lt;br /&gt;
It is important to get a 3.3V model, or at least a model with the option of 3.3V, as a 5V source might fry the PineNote.&lt;br /&gt;
[https://pmdway.com/products/usb-to-ttl-serial-cp2104-6-pin-converter-module Here] is one example with jump wires included, although you are again encouraged to shop around for alternatives.&lt;br /&gt;
&lt;br /&gt;
All other necessary components of our UART dongle are readily &amp;amp; cheaply available in many locations.&lt;br /&gt;
&lt;br /&gt;
=== Splicing resistors ===&lt;br /&gt;
&lt;br /&gt;
[[File:PineNote-UART-Y-pull-up-resistor-cable.jpg|thumb|The desired end result; wrap removed from resistors for illustration purposes.]]&lt;br /&gt;
&lt;br /&gt;
This is the only difficult part of the whole process.&lt;br /&gt;
Your goal is to create a Y-shaped jump wire with 1,000 Ohm through-hole resistors spliced into each of the twin arms.&lt;br /&gt;
The solitary leg will connect to a 3.3V source on your USB-UART adapter.&lt;br /&gt;
The twin arms will connect to the configuration channel pins on your USB-C breakout board.&lt;br /&gt;
This setup is called using pull-up resistors, and you can read a nice introduction to their purpose [https://www.electronics-tutorials.ws/logic/pull-up-resistor.html here].&lt;br /&gt;
&lt;br /&gt;
For this project you'll need:&lt;br /&gt;
# A soldering iron with solder&lt;br /&gt;
# Wire cutters &amp;amp; strippers&lt;br /&gt;
# 2x jumper wires, male/female as compatible with your board designs&lt;br /&gt;
# 2x 1,000 Ohm through-hole resistors&lt;br /&gt;
# Electrical tape or heat shrink wrap&lt;br /&gt;
&lt;br /&gt;
Consider buying extra jumper wires and resistors in case you mess up.&lt;br /&gt;
Also double-check that you have 1K resistors with [https://resistorcolorcodecalc.com/ this color code calculator].&lt;br /&gt;
Although the PineNote UART schematic says to use 10K Ohm resistors, community member talpadk experimented and found 1K is more appropriate.&lt;br /&gt;
Assemble your Y-cable as follows:&lt;br /&gt;
# Graft one jump wire onto the other to form a Y shape using [https://www.youtube.com/watch?v=KpiEfuhPqew this] technique, ensuring solitary leg end is compatible with your USB-UART adapter&lt;br /&gt;
# Splice resistors into the twin arms using [https://www.youtube.com/watch?v=RMgMVqqjPZ0 this] technique&lt;br /&gt;
# Splice remaining jump wire onto the ends of the resistors, ensuring ends are compatible with your USB-C breakout board&lt;br /&gt;
# Cover all exposed wire &amp;amp; resistors with electrical tape or heat shrink wrap&lt;br /&gt;
&lt;br /&gt;
=== Assembly ===&lt;br /&gt;
&lt;br /&gt;
Once you have acquired all necessary components, assemble the UART dongle as follows:&lt;br /&gt;
# Connect a jump wire from the GND pin on the USB-UART adapter to any one of the four GND pins on the USB-C breakout board (A1, A12, B1, or B12)&lt;br /&gt;
# Connect a jump wire from the RXD pin on the USB-UART adapter to the &amp;lt;code&amp;gt;UART2_TX_SUB1&amp;lt;/code&amp;gt; SBU1 pin on the USB-C breakout board (A8)&lt;br /&gt;
# Connect a jump wire from the TXD pin on the USB-UART adapter to the &amp;lt;code&amp;gt;UART2_RX_SUB2&amp;lt;/code&amp;gt; SBU2 pin on the USB-C breakout board (B8)&lt;br /&gt;
# Connect your Y-shaped jump wire from the 3.3V source pin on the USB-UART adapter to the CC1 and CC2 pins on the USB-C breakout board (A5 and B5)&lt;br /&gt;
# Wrap all metal connectors in electrical tape or heat shrink to prevent accidental shorts&lt;br /&gt;
&lt;br /&gt;
Be '''very certain''' of your connections for the 3.3V source and its cable, as there is a real risk of irreparably frying your PineNote if they're wrong!&lt;br /&gt;
Especially be sure you are connecting to a 3.3V source and not a 5V source.&lt;br /&gt;
&lt;br /&gt;
Note that if you mix up the TX/RX pins, it will still work but the USB-C breakout board will just plug into the PineNote upside down.&lt;br /&gt;
You can therefore choose which orientation you want by swapping the TX/RX pin connections.&lt;br /&gt;
&lt;br /&gt;
== Using UART ==&lt;br /&gt;
&lt;br /&gt;
First, use your UART dongle to physically connect your PineNote to your computer:&lt;br /&gt;
# Plug the USB-UART adapter into one of your computer's USB ports&lt;br /&gt;
# Plug the USB-C breakout board into the USB-C port on the bottom of your PineNote; the orientation matters, so try both and remember which one works&lt;br /&gt;
&lt;br /&gt;
Once the hardware is connected, set up your computer's software as follows:&lt;br /&gt;
# Install [https://www.gnu.org/software/screen/ GNU Screen] (or [https://askubuntu.com/q/40959 some other option], but the instructions below are written for &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt;)&lt;br /&gt;
# Identify the USB-UART adapter in your &amp;lt;code&amp;gt;/dev&amp;lt;/code&amp;gt; directory by running &amp;lt;code&amp;gt;ls /dev&amp;lt;/code&amp;gt; with it plugged in, unplugging it, then again running &amp;lt;code&amp;gt;ls /dev&amp;lt;/code&amp;gt; and seeing what changes; it is likely to be called &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;&lt;br /&gt;
# In a terminal window, run &amp;lt;code&amp;gt;screen -L /dev/ttyUSB0 1500000&amp;lt;/code&amp;gt; (you may need to run this as sudo depending on your user's permissions; on most Linux distributions you need to be in the &amp;lt;code&amp;gt;dialout&amp;lt;/code&amp;gt; usergroup)&lt;br /&gt;
&lt;br /&gt;
Once the software is set up, power-cycle your PineNote; as the system boots you should see text appearing in your terminal window.&lt;br /&gt;
You can exit the screen session with &amp;lt;code&amp;gt;ctrl+a k&amp;lt;/code&amp;gt; then pressing &amp;lt;code&amp;gt;y&amp;lt;/code&amp;gt; to confirm.&lt;br /&gt;
The &amp;lt;code&amp;gt;screen -L&amp;lt;/code&amp;gt; flag outputs a text log of the session to the current working directory, probably called &amp;lt;code&amp;gt;screenlog.0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Troubleshooting ====&lt;br /&gt;
&lt;br /&gt;
If you don't see any text in your terminal as the PineNote boots, or the text is garbled, try the following:&lt;br /&gt;
* Ensure your GND, RX and TX jump wires are connected to the correct pins on both the USB-UART adapter and the USB-C breakout board&lt;br /&gt;
* Connect your USB-C breakout board to your PineNote in the opposite orientation&lt;br /&gt;
* Run the screen command as sudo in case your user doesn't have appropriate permissions&lt;br /&gt;
* Ensure you are setting the baud rate in the &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt; command to 1500000 (1.5 million)&lt;br /&gt;
&lt;br /&gt;
== USB passthrough ==&lt;br /&gt;
&lt;br /&gt;
If your USB-C breakout board has a passthrough/intercept design, you can connect to your PineNote over USB and UART at the same time.&lt;br /&gt;
This can be useful when you're doing development work on the PineNote boot process so you don't have to continually reconnect cables.&lt;br /&gt;
You'll need a USB-A to USB-C cable, connecting directly from your computer's USB-A hub to your USB-C breakout board's female USB-C port.&lt;br /&gt;
It's important to connect directly from USB-A, without any intermediate USB-C components.&lt;br /&gt;
Note that connecting a live USB cable to your USB-C breakout board in this way dramatically increases the danger of frying your PineNote with a short, so you should only do this if all connectors are safely wrapped in electrical tape.&lt;br /&gt;
&lt;br /&gt;
[[Category:PineNote]]&lt;/div&gt;</summary>
		<author><name>Ahelwer</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PineNote_Development/UART&amp;diff=20890</id>
		<title>PineNote Development/UART</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PineNote_Development/UART&amp;diff=20890"/>
		<updated>2023-10-14T01:45:36Z</updated>

		<summary type="html">&lt;p&gt;Ahelwer: /* Assembly */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Pinenote-uart-dongle.jpeg|thumb|Basic non-stock PineNote UART dongle]]&lt;br /&gt;
&lt;br /&gt;
This page contains information on creating and using a [https://en.wikipedia.org/wiki/Universal_asynchronous_receiver-transmitter UART] dongle for the [[PineNote]].&lt;br /&gt;
The PineNote was shipped with a compatible UART dongle, but replacements are not available to order in case of loss or hardware fault.&lt;br /&gt;
Thankfully it is not difficult to make your own from easily-acquired components and a small bit of soldering.&lt;br /&gt;
Fear not if you've never soldered anything before!&lt;br /&gt;
This serves as an excellent first soldering project.&lt;br /&gt;
Borrow the tools from a friend or a local hackerspace or tool library.&lt;br /&gt;
&lt;br /&gt;
A PineNote UART dongle enables you to:&lt;br /&gt;
# Interact with the system boot menu&lt;br /&gt;
# Read system events in real time as the PineNote is used&lt;br /&gt;
# Fix the PineNote without opening the case if something goes wrong while [[PineNote Development/Flashing|flashing it]]&lt;br /&gt;
&lt;br /&gt;
Since the PineNote is an embedded system, interfacing with it during boot is more complicated than with an ordinary computer.&lt;br /&gt;
The UART dongle enables you to do this.&lt;br /&gt;
&lt;br /&gt;
The PineNote factory firmware runs UART at a baud rate of 1500000 bps, 8 data bits, 1 stop bit, no parity and no flow control.&lt;br /&gt;
The process by which the PineNote design was modified to include closed-case UART is documented [[PineNote/Hardware Changes/Closed Case UART|here]].&lt;br /&gt;
&lt;br /&gt;
== Stock dongle ==&lt;br /&gt;
&lt;br /&gt;
The stock UART dongle included with the PineNote was a simple device plugging directly into the PineNote's USB-C port.&lt;br /&gt;
The dongle exposed a female USB-C port, which the user plugged into to get UART access.&lt;br /&gt;
This design unfortunately ruled out passthrough USB connections, where the user connects to the PineNote via UART and USB simultaneously.&lt;br /&gt;
The dongle is not currently available for purchase.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Pinenote-stock-uart-dongle-front.jpg|Front&lt;br /&gt;
Pinenote-stock-uart-dongle-back.jpg|Back&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Creating a dongle ==&lt;br /&gt;
&lt;br /&gt;
A typical self-built PineNote UART dongle design has the following components:&lt;br /&gt;
# A USB-C breakout board with a male connector exposing the 24 pins of the PineNote's USB-C port&lt;br /&gt;
# A USB-UART adapter, to plug into a USB port of the computer you'll use to interface with the PineNote&lt;br /&gt;
# [https://en.wikipedia.org/wiki/Jump_wire Jump wires] to connect specific breakout board pins to pins on the USB-UART adapter&lt;br /&gt;
# Two 1,000 Ohm through-hole resistors to splice into the jump wires&lt;br /&gt;
# Electrical tape or heat shrink to wrap connectors and prevent shorts&lt;br /&gt;
&lt;br /&gt;
You will also need the following tools:&lt;br /&gt;
# Soldering iron with solder&lt;br /&gt;
# Wire cutters &amp;amp; strippers&lt;br /&gt;
&lt;br /&gt;
The PineNote's internal UART system is documented in [https://files.pine64.org/doc/PineNote/PineNote_USB-C_Console_UART_breakout_board_schematic_v1.0_20210903.pdf this schematic].&lt;br /&gt;
The purpose of all 24 USB-C pins is documented [https://en.wikipedia.org/wiki/USB-C#Receptacles on the USB-C Wikipedia page].&lt;br /&gt;
We are interested in three sets of pins:&lt;br /&gt;
# The SBU1 (A8) and SBU2 (B8) side band use pins&lt;br /&gt;
# The CC1 (A5) and CC2 (B5) configuration channel pins&lt;br /&gt;
# The GND [https://en.wikipedia.org/wiki/Ground_(electricity) ground return] pins (A1, A12, B1, and B12)&lt;br /&gt;
&lt;br /&gt;
In the PineNote UART schematic you can see (on the bottom right diagram labeled &amp;lt;code&amp;gt;USB_TYPEC_Male&amp;lt;/code&amp;gt;) the side band pins are given the labels &amp;lt;code&amp;gt;UART2_TX_SUB1&amp;lt;/code&amp;gt; for A8 and &amp;lt;code&amp;gt;UART2_RX_SUB2&amp;lt;/code&amp;gt; for B8.&lt;br /&gt;
The first (TX) is used for transmitting data and the second (RX) is used for receiving data, from the perspective of the PineNote.&lt;br /&gt;
Also note the configuration channel pins labeled &amp;lt;code&amp;gt;TYPEC_CC1&amp;lt;/code&amp;gt; for A5 and &amp;lt;code&amp;gt;TYPEC_CC2&amp;lt;/code&amp;gt; for B5.&lt;br /&gt;
These pins are used to signal to the PineNote that a UART dongle is present.&lt;br /&gt;
The diagram shows they must be connected to a 3.3V source in parallel, mediated by resistors.&lt;br /&gt;
The schematic indicates 10,000 Ohm resistors, but community member talpadk experimented and found 1,000 Ohm resistors work better.&lt;br /&gt;
Our mission is to wire up pins from a USB-UART adapter to a USB-C breakout board following these requirements.&lt;br /&gt;
&lt;br /&gt;
=== Buying components ===&lt;br /&gt;
&lt;br /&gt;
There are many possible USB-C breakout board designs available for purchase online.&lt;br /&gt;
One particularly useful design is a &amp;quot;passthrough&amp;quot; or &amp;quot;intercept&amp;quot; style, with both male and female USB-C ports.&lt;br /&gt;
This design is more versatile in case you want to reuse it in other projects, and also enables you to connect to the PineNote via UART and USB at the same time.&lt;br /&gt;
An example of this product can be found [https://pmdway.com/products/usb-3-1-type-c-male-to-female-breakout-test-board here], although you are encouraged to shop around for cheaper options.&lt;br /&gt;
If you're fine with a bit more soldering, there is a very cheap one [https://www.ebay.com/itm/275407037613 here].&lt;br /&gt;
&lt;br /&gt;
Similarly, there are many USB-UART adapter designs available.&lt;br /&gt;
These devices plug into your computer and expose a number of pins themselves, connecting to specific pins on the breakout board with jump wires.&lt;br /&gt;
It is important to get a 3.3V model, or at least a model with the option of 3.3V, as a 5V source might fry the PineNote.&lt;br /&gt;
[https://pmdway.com/products/usb-to-ttl-serial-cp2104-6-pin-converter-module Here] is one example with jump wires included, although you are again encouraged to shop around for alternatives.&lt;br /&gt;
&lt;br /&gt;
All other necessary components of our UART dongle are readily &amp;amp; cheaply available in many locations.&lt;br /&gt;
&lt;br /&gt;
=== Splicing resistors ===&lt;br /&gt;
&lt;br /&gt;
[[File:PineNote-UART-Y-pull-up-resistor-cable.jpg|thumb|The desired end result; wrap removed from resistors for illustration purposes.]]&lt;br /&gt;
&lt;br /&gt;
This is the only difficult part of the whole process.&lt;br /&gt;
Your goal is to create a Y-shaped jump wire with 1,000 Ohm through-hole resistors spliced into each of the twin arms.&lt;br /&gt;
The solitary leg will connect to a 3.3V source on your USB-UART adapter.&lt;br /&gt;
The twin arms will connect to the configuration channel pins on your USB-C breakout board.&lt;br /&gt;
This setup is called using pull-up resistors, and you can read a nice introduction to their purpose [https://www.electronics-tutorials.ws/logic/pull-up-resistor.html here].&lt;br /&gt;
&lt;br /&gt;
For this project you'll need:&lt;br /&gt;
# A soldering iron with solder&lt;br /&gt;
# Wire cutters &amp;amp; strippers&lt;br /&gt;
# 2x jumper wires, male/female as compatible with your board designs&lt;br /&gt;
# 2x 1,000 Ohm through-hole resistors&lt;br /&gt;
# Electrical tape or heat shrink wrap&lt;br /&gt;
&lt;br /&gt;
Consider buying extra jumper wires and resistors in case you mess up.&lt;br /&gt;
Also double-check that you have 1K resistors with [https://resistorcolorcodecalc.com/ this color code calculator].&lt;br /&gt;
Although the PineNote UART schematic says to use 10K Ohm resistors, community member talpadk experimented and found 1K is more appropriate.&lt;br /&gt;
Assemble your Y-cable as follows:&lt;br /&gt;
# Graft one jump wire onto the other to form a Y shape using [https://www.youtube.com/watch?v=KpiEfuhPqew this] technique, ensuring solitary leg end is compatible with your USB-UART adapter&lt;br /&gt;
# Splice resistors into the twin arms using [https://www.youtube.com/watch?v=RMgMVqqjPZ0 this] technique&lt;br /&gt;
# Splice remaining jump wire onto the ends of the resistors, ensuring ends are compatible with your USB-C breakout board&lt;br /&gt;
# Cover all exposed wire &amp;amp; resistors with electrical tape or heat shrink wrap&lt;br /&gt;
&lt;br /&gt;
=== Assembly ===&lt;br /&gt;
&lt;br /&gt;
Once you have acquired all necessary components, assemble the UART dongle as follows:&lt;br /&gt;
# Connect a jump wire from the GND pin on the USB-UART adapter to any one of the four GND pins on the USB-C breakout board (A1, A12, B1, or B12)&lt;br /&gt;
# Connect a jump wire from the RXD pin on the USB-UART adapter to the &amp;lt;code&amp;gt;UART2_TX_SUB1&amp;lt;/code&amp;gt; SBU1 pin on the USB-C breakout board (A8)&lt;br /&gt;
# Connect a jump wire from the TXD pin on the USB-UART adapter to the &amp;lt;code&amp;gt;UART2_RX_SUB2&amp;lt;/code&amp;gt; SBU2 pin on the USB-C breakout board (B8)&lt;br /&gt;
# Connect your Y-shaped jump wire from the 3.3V source pin on the USB-UART adapter to the CC1 and CC2 pins on the USB-C breakout board (A5 and B5)&lt;br /&gt;
# Wrap all metal connectors in electrical tape or heat shrink to prevent accidental shorts&lt;br /&gt;
&lt;br /&gt;
Be '''very certain''' of your connections for the 3.3V source, as there is a real risk of irreparably frying your PineNote if they're wrong!&lt;br /&gt;
Especially be sure you are connecting to a 3.3V source and not a 5V source.&lt;br /&gt;
&lt;br /&gt;
Note that if you mix up the TX/RX pins, it will still work but the USB-C breakout board will just plug into the PineNote upside down.&lt;br /&gt;
You can therefore choose which orientation you want by swapping the TX/RX pin connections.&lt;br /&gt;
&lt;br /&gt;
== Using UART ==&lt;br /&gt;
&lt;br /&gt;
First, use your UART dongle to physically connect your PineNote to your computer:&lt;br /&gt;
# Plug the USB-UART adapter into one of your computer's USB ports&lt;br /&gt;
# Plug the USB-C breakout board into the USB-C port on the bottom of your PineNote; the orientation matters, so try both and remember which one works&lt;br /&gt;
&lt;br /&gt;
Once the hardware is connected, set up your computer's software as follows:&lt;br /&gt;
# Install [https://www.gnu.org/software/screen/ GNU Screen] (or [https://askubuntu.com/q/40959 some other option], but the instructions below are written for &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt;)&lt;br /&gt;
# Identify the USB-UART adapter in your &amp;lt;code&amp;gt;/dev&amp;lt;/code&amp;gt; directory by running &amp;lt;code&amp;gt;ls /dev&amp;lt;/code&amp;gt; with it plugged in, unplugging it, then again running &amp;lt;code&amp;gt;ls /dev&amp;lt;/code&amp;gt; and seeing what changes; it is likely to be called &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;&lt;br /&gt;
# In a terminal window, run &amp;lt;code&amp;gt;screen -L /dev/ttyUSB0 1500000&amp;lt;/code&amp;gt; (you may need to run this as sudo depending on your user's permissions; on most Linux distributions you need to be in the &amp;lt;code&amp;gt;dialout&amp;lt;/code&amp;gt; usergroup)&lt;br /&gt;
&lt;br /&gt;
Once the software is set up, power-cycle your PineNote; as the system boots you should see text appearing in your terminal window.&lt;br /&gt;
You can exit the screen session with &amp;lt;code&amp;gt;ctrl+a k&amp;lt;/code&amp;gt; then pressing &amp;lt;code&amp;gt;y&amp;lt;/code&amp;gt; to confirm.&lt;br /&gt;
The &amp;lt;code&amp;gt;screen -L&amp;lt;/code&amp;gt; flag outputs a text log of the session to the current working directory, probably called &amp;lt;code&amp;gt;screenlog.0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Troubleshooting ====&lt;br /&gt;
&lt;br /&gt;
If you don't see any text in your terminal as the PineNote boots, or the text is garbled, try the following:&lt;br /&gt;
* Ensure your GND, RX and TX jump wires are connected to the correct pins on both the USB-UART adapter and the USB-C breakout board&lt;br /&gt;
* Connect your USB-C breakout board to your PineNote in the opposite orientation&lt;br /&gt;
* Run the screen command as sudo in case your user doesn't have appropriate permissions&lt;br /&gt;
* Ensure you are setting the baud rate in the &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt; command to 1500000 (1.5 million)&lt;br /&gt;
&lt;br /&gt;
== USB passthrough ==&lt;br /&gt;
&lt;br /&gt;
If your USB-C breakout board has a passthrough/intercept design, you can connect to your PineNote over USB and UART at the same time.&lt;br /&gt;
This can be useful when you're doing development work on the PineNote boot process so you don't have to continually reconnect cables.&lt;br /&gt;
You'll need a USB-A to USB-C cable, connecting directly from your computer's USB-A hub to your USB-C breakout board's female USB-C port.&lt;br /&gt;
It's important to connect directly from USB-A, without any intermediate USB-C components.&lt;br /&gt;
Note that connecting a live USB cable to your USB-C breakout board in this way dramatically increases the danger of frying your PineNote with a short, so you should only do this if all connectors are safely wrapped in electrical tape.&lt;br /&gt;
&lt;br /&gt;
[[Category:PineNote]]&lt;/div&gt;</summary>
		<author><name>Ahelwer</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PineNote_Development/UART&amp;diff=20889</id>
		<title>PineNote Development/UART</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PineNote_Development/UART&amp;diff=20889"/>
		<updated>2023-10-14T01:44:34Z</updated>

		<summary type="html">&lt;p&gt;Ahelwer: /* Assembly */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Pinenote-uart-dongle.jpeg|thumb|Basic non-stock PineNote UART dongle]]&lt;br /&gt;
&lt;br /&gt;
This page contains information on creating and using a [https://en.wikipedia.org/wiki/Universal_asynchronous_receiver-transmitter UART] dongle for the [[PineNote]].&lt;br /&gt;
The PineNote was shipped with a compatible UART dongle, but replacements are not available to order in case of loss or hardware fault.&lt;br /&gt;
Thankfully it is not difficult to make your own from easily-acquired components and a small bit of soldering.&lt;br /&gt;
Fear not if you've never soldered anything before!&lt;br /&gt;
This serves as an excellent first soldering project.&lt;br /&gt;
Borrow the tools from a friend or a local hackerspace or tool library.&lt;br /&gt;
&lt;br /&gt;
A PineNote UART dongle enables you to:&lt;br /&gt;
# Interact with the system boot menu&lt;br /&gt;
# Read system events in real time as the PineNote is used&lt;br /&gt;
# Fix the PineNote without opening the case if something goes wrong while [[PineNote Development/Flashing|flashing it]]&lt;br /&gt;
&lt;br /&gt;
Since the PineNote is an embedded system, interfacing with it during boot is more complicated than with an ordinary computer.&lt;br /&gt;
The UART dongle enables you to do this.&lt;br /&gt;
&lt;br /&gt;
The PineNote factory firmware runs UART at a baud rate of 1500000 bps, 8 data bits, 1 stop bit, no parity and no flow control.&lt;br /&gt;
The process by which the PineNote design was modified to include closed-case UART is documented [[PineNote/Hardware Changes/Closed Case UART|here]].&lt;br /&gt;
&lt;br /&gt;
== Stock dongle ==&lt;br /&gt;
&lt;br /&gt;
The stock UART dongle included with the PineNote was a simple device plugging directly into the PineNote's USB-C port.&lt;br /&gt;
The dongle exposed a female USB-C port, which the user plugged into to get UART access.&lt;br /&gt;
This design unfortunately ruled out passthrough USB connections, where the user connects to the PineNote via UART and USB simultaneously.&lt;br /&gt;
The dongle is not currently available for purchase.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Pinenote-stock-uart-dongle-front.jpg|Front&lt;br /&gt;
Pinenote-stock-uart-dongle-back.jpg|Back&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Creating a dongle ==&lt;br /&gt;
&lt;br /&gt;
A typical self-built PineNote UART dongle design has the following components:&lt;br /&gt;
# A USB-C breakout board with a male connector exposing the 24 pins of the PineNote's USB-C port&lt;br /&gt;
# A USB-UART adapter, to plug into a USB port of the computer you'll use to interface with the PineNote&lt;br /&gt;
# [https://en.wikipedia.org/wiki/Jump_wire Jump wires] to connect specific breakout board pins to pins on the USB-UART adapter&lt;br /&gt;
# Two 1,000 Ohm through-hole resistors to splice into the jump wires&lt;br /&gt;
# Electrical tape or heat shrink to wrap connectors and prevent shorts&lt;br /&gt;
&lt;br /&gt;
You will also need the following tools:&lt;br /&gt;
# Soldering iron with solder&lt;br /&gt;
# Wire cutters &amp;amp; strippers&lt;br /&gt;
&lt;br /&gt;
The PineNote's internal UART system is documented in [https://files.pine64.org/doc/PineNote/PineNote_USB-C_Console_UART_breakout_board_schematic_v1.0_20210903.pdf this schematic].&lt;br /&gt;
The purpose of all 24 USB-C pins is documented [https://en.wikipedia.org/wiki/USB-C#Receptacles on the USB-C Wikipedia page].&lt;br /&gt;
We are interested in three sets of pins:&lt;br /&gt;
# The SBU1 (A8) and SBU2 (B8) side band use pins&lt;br /&gt;
# The CC1 (A5) and CC2 (B5) configuration channel pins&lt;br /&gt;
# The GND [https://en.wikipedia.org/wiki/Ground_(electricity) ground return] pins (A1, A12, B1, and B12)&lt;br /&gt;
&lt;br /&gt;
In the PineNote UART schematic you can see (on the bottom right diagram labeled &amp;lt;code&amp;gt;USB_TYPEC_Male&amp;lt;/code&amp;gt;) the side band pins are given the labels &amp;lt;code&amp;gt;UART2_TX_SUB1&amp;lt;/code&amp;gt; for A8 and &amp;lt;code&amp;gt;UART2_RX_SUB2&amp;lt;/code&amp;gt; for B8.&lt;br /&gt;
The first (TX) is used for transmitting data and the second (RX) is used for receiving data, from the perspective of the PineNote.&lt;br /&gt;
Also note the configuration channel pins labeled &amp;lt;code&amp;gt;TYPEC_CC1&amp;lt;/code&amp;gt; for A5 and &amp;lt;code&amp;gt;TYPEC_CC2&amp;lt;/code&amp;gt; for B5.&lt;br /&gt;
These pins are used to signal to the PineNote that a UART dongle is present.&lt;br /&gt;
The diagram shows they must be connected to a 3.3V source in parallel, mediated by resistors.&lt;br /&gt;
The schematic indicates 10,000 Ohm resistors, but community member talpadk experimented and found 1,000 Ohm resistors work better.&lt;br /&gt;
Our mission is to wire up pins from a USB-UART adapter to a USB-C breakout board following these requirements.&lt;br /&gt;
&lt;br /&gt;
=== Buying components ===&lt;br /&gt;
&lt;br /&gt;
There are many possible USB-C breakout board designs available for purchase online.&lt;br /&gt;
One particularly useful design is a &amp;quot;passthrough&amp;quot; or &amp;quot;intercept&amp;quot; style, with both male and female USB-C ports.&lt;br /&gt;
This design is more versatile in case you want to reuse it in other projects, and also enables you to connect to the PineNote via UART and USB at the same time.&lt;br /&gt;
An example of this product can be found [https://pmdway.com/products/usb-3-1-type-c-male-to-female-breakout-test-board here], although you are encouraged to shop around for cheaper options.&lt;br /&gt;
If you're fine with a bit more soldering, there is a very cheap one [https://www.ebay.com/itm/275407037613 here].&lt;br /&gt;
&lt;br /&gt;
Similarly, there are many USB-UART adapter designs available.&lt;br /&gt;
These devices plug into your computer and expose a number of pins themselves, connecting to specific pins on the breakout board with jump wires.&lt;br /&gt;
It is important to get a 3.3V model, or at least a model with the option of 3.3V, as a 5V source might fry the PineNote.&lt;br /&gt;
[https://pmdway.com/products/usb-to-ttl-serial-cp2104-6-pin-converter-module Here] is one example with jump wires included, although you are again encouraged to shop around for alternatives.&lt;br /&gt;
&lt;br /&gt;
All other necessary components of our UART dongle are readily &amp;amp; cheaply available in many locations.&lt;br /&gt;
&lt;br /&gt;
=== Splicing resistors ===&lt;br /&gt;
&lt;br /&gt;
[[File:PineNote-UART-Y-pull-up-resistor-cable.jpg|thumb|The desired end result; wrap removed from resistors for illustration purposes.]]&lt;br /&gt;
&lt;br /&gt;
This is the only difficult part of the whole process.&lt;br /&gt;
Your goal is to create a Y-shaped jump wire with 1,000 Ohm through-hole resistors spliced into each of the twin arms.&lt;br /&gt;
The solitary leg will connect to a 3.3V source on your USB-UART adapter.&lt;br /&gt;
The twin arms will connect to the configuration channel pins on your USB-C breakout board.&lt;br /&gt;
This setup is called using pull-up resistors, and you can read a nice introduction to their purpose [https://www.electronics-tutorials.ws/logic/pull-up-resistor.html here].&lt;br /&gt;
&lt;br /&gt;
For this project you'll need:&lt;br /&gt;
# A soldering iron with solder&lt;br /&gt;
# Wire cutters &amp;amp; strippers&lt;br /&gt;
# 2x jumper wires, male/female as compatible with your board designs&lt;br /&gt;
# 2x 1,000 Ohm through-hole resistors&lt;br /&gt;
# Electrical tape or heat shrink wrap&lt;br /&gt;
&lt;br /&gt;
Consider buying extra jumper wires and resistors in case you mess up.&lt;br /&gt;
Also double-check that you have 1K resistors with [https://resistorcolorcodecalc.com/ this color code calculator].&lt;br /&gt;
Although the PineNote UART schematic says to use 10K Ohm resistors, community member talpadk experimented and found 1K is more appropriate.&lt;br /&gt;
Assemble your Y-cable as follows:&lt;br /&gt;
# Graft one jump wire onto the other to form a Y shape using [https://www.youtube.com/watch?v=KpiEfuhPqew this] technique, ensuring solitary leg end is compatible with your USB-UART adapter&lt;br /&gt;
# Splice resistors into the twin arms using [https://www.youtube.com/watch?v=RMgMVqqjPZ0 this] technique&lt;br /&gt;
# Splice remaining jump wire onto the ends of the resistors, ensuring ends are compatible with your USB-C breakout board&lt;br /&gt;
# Cover all exposed wire &amp;amp; resistors with electrical tape or heat shrink wrap&lt;br /&gt;
&lt;br /&gt;
=== Assembly ===&lt;br /&gt;
&lt;br /&gt;
Once you have acquired all necessary components, assemble the UART dongle as follows:&lt;br /&gt;
# Connect a jump wire from the GND pin on the USB-UART adapter to any one of the four GND pins on the USB-C breakout board (A1, A12, B1, or B12)&lt;br /&gt;
# Connect a jump wire from the RXD pin on the USB-UART adapter to the TX SBU1 pin on the USB-C breakout board (A8)&lt;br /&gt;
# Connect a jump wire from the TXD pin on the USB-UART adapter to the RX SBU2 pin on the USB-C breakout board (B8)&lt;br /&gt;
# Connect your Y-shaped jump wire from the 3.3V source pin on the USB-UART adapter to the CC1 and CC2 pins on the USB-C breakout board (A5 and B5)&lt;br /&gt;
# Wrap all metal connectors in electrical tape or heat shrink to prevent accidental shorts&lt;br /&gt;
&lt;br /&gt;
Be '''very certain''' of your connections for the 3.3V source, as there is a real risk of irreparably frying your PineNote if they're wrong!&lt;br /&gt;
Especially be sure you are connecting to a 3.3V source and not a 5V source.&lt;br /&gt;
&lt;br /&gt;
Note that if you mix up the TX/RX pins, it will still work but the USB-C breakout board will just plug into the PineNote upside down.&lt;br /&gt;
You can therefore choose which orientation you want by swapping the TX/RX pin connections.&lt;br /&gt;
&lt;br /&gt;
== Using UART ==&lt;br /&gt;
&lt;br /&gt;
First, use your UART dongle to physically connect your PineNote to your computer:&lt;br /&gt;
# Plug the USB-UART adapter into one of your computer's USB ports&lt;br /&gt;
# Plug the USB-C breakout board into the USB-C port on the bottom of your PineNote; the orientation matters, so try both and remember which one works&lt;br /&gt;
&lt;br /&gt;
Once the hardware is connected, set up your computer's software as follows:&lt;br /&gt;
# Install [https://www.gnu.org/software/screen/ GNU Screen] (or [https://askubuntu.com/q/40959 some other option], but the instructions below are written for &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt;)&lt;br /&gt;
# Identify the USB-UART adapter in your &amp;lt;code&amp;gt;/dev&amp;lt;/code&amp;gt; directory by running &amp;lt;code&amp;gt;ls /dev&amp;lt;/code&amp;gt; with it plugged in, unplugging it, then again running &amp;lt;code&amp;gt;ls /dev&amp;lt;/code&amp;gt; and seeing what changes; it is likely to be called &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;&lt;br /&gt;
# In a terminal window, run &amp;lt;code&amp;gt;screen -L /dev/ttyUSB0 1500000&amp;lt;/code&amp;gt; (you may need to run this as sudo depending on your user's permissions; on most Linux distributions you need to be in the &amp;lt;code&amp;gt;dialout&amp;lt;/code&amp;gt; usergroup)&lt;br /&gt;
&lt;br /&gt;
Once the software is set up, power-cycle your PineNote; as the system boots you should see text appearing in your terminal window.&lt;br /&gt;
You can exit the screen session with &amp;lt;code&amp;gt;ctrl+a k&amp;lt;/code&amp;gt; then pressing &amp;lt;code&amp;gt;y&amp;lt;/code&amp;gt; to confirm.&lt;br /&gt;
The &amp;lt;code&amp;gt;screen -L&amp;lt;/code&amp;gt; flag outputs a text log of the session to the current working directory, probably called &amp;lt;code&amp;gt;screenlog.0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Troubleshooting ====&lt;br /&gt;
&lt;br /&gt;
If you don't see any text in your terminal as the PineNote boots, or the text is garbled, try the following:&lt;br /&gt;
* Ensure your GND, RX and TX jump wires are connected to the correct pins on both the USB-UART adapter and the USB-C breakout board&lt;br /&gt;
* Connect your USB-C breakout board to your PineNote in the opposite orientation&lt;br /&gt;
* Run the screen command as sudo in case your user doesn't have appropriate permissions&lt;br /&gt;
* Ensure you are setting the baud rate in the &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt; command to 1500000 (1.5 million)&lt;br /&gt;
&lt;br /&gt;
== USB passthrough ==&lt;br /&gt;
&lt;br /&gt;
If your USB-C breakout board has a passthrough/intercept design, you can connect to your PineNote over USB and UART at the same time.&lt;br /&gt;
This can be useful when you're doing development work on the PineNote boot process so you don't have to continually reconnect cables.&lt;br /&gt;
You'll need a USB-A to USB-C cable, connecting directly from your computer's USB-A hub to your USB-C breakout board's female USB-C port.&lt;br /&gt;
It's important to connect directly from USB-A, without any intermediate USB-C components.&lt;br /&gt;
Note that connecting a live USB cable to your USB-C breakout board in this way dramatically increases the danger of frying your PineNote with a short, so you should only do this if all connectors are safely wrapped in electrical tape.&lt;br /&gt;
&lt;br /&gt;
[[Category:PineNote]]&lt;/div&gt;</summary>
		<author><name>Ahelwer</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=File:Pinenote-uart-dongle.jpeg&amp;diff=20888</id>
		<title>File:Pinenote-uart-dongle.jpeg</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=File:Pinenote-uart-dongle.jpeg&amp;diff=20888"/>
		<updated>2023-10-14T01:36:11Z</updated>

		<summary type="html">&lt;p&gt;Ahelwer: Ahelwer uploaded a new version of File:Pinenote-uart-dongle.jpeg&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary ==&lt;br /&gt;
Photo of a USB-UART adapter connected via jump wires to a USB-C breakout board, connecting the PineNote to a computer.&lt;br /&gt;
== Licensing ==&lt;br /&gt;
{{CC0}}&lt;br /&gt;
[[Category:PineNote]]&lt;/div&gt;</summary>
		<author><name>Ahelwer</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PineNote_Development/UART&amp;diff=20887</id>
		<title>PineNote Development/UART</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PineNote_Development/UART&amp;diff=20887"/>
		<updated>2023-10-14T01:29:05Z</updated>

		<summary type="html">&lt;p&gt;Ahelwer: /* Splicing resistors */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Pinenote-uart-dongle.jpeg|thumb|Basic non-stock PineNote UART dongle]]&lt;br /&gt;
&lt;br /&gt;
This page contains information on creating and using a [https://en.wikipedia.org/wiki/Universal_asynchronous_receiver-transmitter UART] dongle for the [[PineNote]].&lt;br /&gt;
The PineNote was shipped with a compatible UART dongle, but replacements are not available to order in case of loss or hardware fault.&lt;br /&gt;
Thankfully it is not difficult to make your own from easily-acquired components and a small bit of soldering.&lt;br /&gt;
Fear not if you've never soldered anything before!&lt;br /&gt;
This serves as an excellent first soldering project.&lt;br /&gt;
Borrow the tools from a friend or a local hackerspace or tool library.&lt;br /&gt;
&lt;br /&gt;
A PineNote UART dongle enables you to:&lt;br /&gt;
# Interact with the system boot menu&lt;br /&gt;
# Read system events in real time as the PineNote is used&lt;br /&gt;
# Fix the PineNote without opening the case if something goes wrong while [[PineNote Development/Flashing|flashing it]]&lt;br /&gt;
&lt;br /&gt;
Since the PineNote is an embedded system, interfacing with it during boot is more complicated than with an ordinary computer.&lt;br /&gt;
The UART dongle enables you to do this.&lt;br /&gt;
&lt;br /&gt;
The PineNote factory firmware runs UART at a baud rate of 1500000 bps, 8 data bits, 1 stop bit, no parity and no flow control.&lt;br /&gt;
The process by which the PineNote design was modified to include closed-case UART is documented [[PineNote/Hardware Changes/Closed Case UART|here]].&lt;br /&gt;
&lt;br /&gt;
== Stock dongle ==&lt;br /&gt;
&lt;br /&gt;
The stock UART dongle included with the PineNote was a simple device plugging directly into the PineNote's USB-C port.&lt;br /&gt;
The dongle exposed a female USB-C port, which the user plugged into to get UART access.&lt;br /&gt;
This design unfortunately ruled out passthrough USB connections, where the user connects to the PineNote via UART and USB simultaneously.&lt;br /&gt;
The dongle is not currently available for purchase.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Pinenote-stock-uart-dongle-front.jpg|Front&lt;br /&gt;
Pinenote-stock-uart-dongle-back.jpg|Back&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Creating a dongle ==&lt;br /&gt;
&lt;br /&gt;
A typical self-built PineNote UART dongle design has the following components:&lt;br /&gt;
# A USB-C breakout board with a male connector exposing the 24 pins of the PineNote's USB-C port&lt;br /&gt;
# A USB-UART adapter, to plug into a USB port of the computer you'll use to interface with the PineNote&lt;br /&gt;
# [https://en.wikipedia.org/wiki/Jump_wire Jump wires] to connect specific breakout board pins to pins on the USB-UART adapter&lt;br /&gt;
# Two 1,000 Ohm through-hole resistors to splice into the jump wires&lt;br /&gt;
# Electrical tape or heat shrink to wrap connectors and prevent shorts&lt;br /&gt;
&lt;br /&gt;
You will also need the following tools:&lt;br /&gt;
# Soldering iron with solder&lt;br /&gt;
# Wire cutters &amp;amp; strippers&lt;br /&gt;
&lt;br /&gt;
The PineNote's internal UART system is documented in [https://files.pine64.org/doc/PineNote/PineNote_USB-C_Console_UART_breakout_board_schematic_v1.0_20210903.pdf this schematic].&lt;br /&gt;
The purpose of all 24 USB-C pins is documented [https://en.wikipedia.org/wiki/USB-C#Receptacles on the USB-C Wikipedia page].&lt;br /&gt;
We are interested in three sets of pins:&lt;br /&gt;
# The SBU1 (A8) and SBU2 (B8) side band use pins&lt;br /&gt;
# The CC1 (A5) and CC2 (B5) configuration channel pins&lt;br /&gt;
# The GND [https://en.wikipedia.org/wiki/Ground_(electricity) ground return] pins (A1, A12, B1, and B12)&lt;br /&gt;
&lt;br /&gt;
In the PineNote UART schematic you can see (on the bottom right diagram labeled &amp;lt;code&amp;gt;USB_TYPEC_Male&amp;lt;/code&amp;gt;) the side band pins are given the labels &amp;lt;code&amp;gt;UART2_TX_SUB1&amp;lt;/code&amp;gt; for A8 and &amp;lt;code&amp;gt;UART2_RX_SUB2&amp;lt;/code&amp;gt; for B8.&lt;br /&gt;
The first (TX) is used for transmitting data and the second (RX) is used for receiving data, from the perspective of the PineNote.&lt;br /&gt;
Also note the configuration channel pins labeled &amp;lt;code&amp;gt;TYPEC_CC1&amp;lt;/code&amp;gt; for A5 and &amp;lt;code&amp;gt;TYPEC_CC2&amp;lt;/code&amp;gt; for B5.&lt;br /&gt;
These pins are used to signal to the PineNote that a UART dongle is present.&lt;br /&gt;
The diagram shows they must be connected to a 3.3V source in parallel, mediated by resistors.&lt;br /&gt;
The schematic indicates 10,000 Ohm resistors, but community member talpadk experimented and found 1,000 Ohm resistors work better.&lt;br /&gt;
Our mission is to wire up pins from a USB-UART adapter to a USB-C breakout board following these requirements.&lt;br /&gt;
&lt;br /&gt;
=== Buying components ===&lt;br /&gt;
&lt;br /&gt;
There are many possible USB-C breakout board designs available for purchase online.&lt;br /&gt;
One particularly useful design is a &amp;quot;passthrough&amp;quot; or &amp;quot;intercept&amp;quot; style, with both male and female USB-C ports.&lt;br /&gt;
This design is more versatile in case you want to reuse it in other projects, and also enables you to connect to the PineNote via UART and USB at the same time.&lt;br /&gt;
An example of this product can be found [https://pmdway.com/products/usb-3-1-type-c-male-to-female-breakout-test-board here], although you are encouraged to shop around for cheaper options.&lt;br /&gt;
If you're fine with a bit more soldering, there is a very cheap one [https://www.ebay.com/itm/275407037613 here].&lt;br /&gt;
&lt;br /&gt;
Similarly, there are many USB-UART adapter designs available.&lt;br /&gt;
These devices plug into your computer and expose a number of pins themselves, connecting to specific pins on the breakout board with jump wires.&lt;br /&gt;
It is important to get a 3.3V model, or at least a model with the option of 3.3V, as a 5V source might fry the PineNote.&lt;br /&gt;
[https://pmdway.com/products/usb-to-ttl-serial-cp2104-6-pin-converter-module Here] is one example with jump wires included, although you are again encouraged to shop around for alternatives.&lt;br /&gt;
&lt;br /&gt;
All other necessary components of our UART dongle are readily &amp;amp; cheaply available in many locations.&lt;br /&gt;
&lt;br /&gt;
=== Splicing resistors ===&lt;br /&gt;
&lt;br /&gt;
[[File:PineNote-UART-Y-pull-up-resistor-cable.jpg|thumb|The desired end result; wrap removed from resistors for illustration purposes.]]&lt;br /&gt;
&lt;br /&gt;
This is the only difficult part of the whole process.&lt;br /&gt;
Your goal is to create a Y-shaped jump wire with 1,000 Ohm through-hole resistors spliced into each of the twin arms.&lt;br /&gt;
The solitary leg will connect to a 3.3V source on your USB-UART adapter.&lt;br /&gt;
The twin arms will connect to the configuration channel pins on your USB-C breakout board.&lt;br /&gt;
This setup is called using pull-up resistors, and you can read a nice introduction to their purpose [https://www.electronics-tutorials.ws/logic/pull-up-resistor.html here].&lt;br /&gt;
&lt;br /&gt;
For this project you'll need:&lt;br /&gt;
# A soldering iron with solder&lt;br /&gt;
# Wire cutters &amp;amp; strippers&lt;br /&gt;
# 2x jumper wires, male/female as compatible with your board designs&lt;br /&gt;
# 2x 1,000 Ohm through-hole resistors&lt;br /&gt;
# Electrical tape or heat shrink wrap&lt;br /&gt;
&lt;br /&gt;
Consider buying extra jumper wires and resistors in case you mess up.&lt;br /&gt;
Also double-check that you have 1K resistors with [https://resistorcolorcodecalc.com/ this color code calculator].&lt;br /&gt;
Although the PineNote UART schematic says to use 10K Ohm resistors, community member talpadk experimented and found 1K is more appropriate.&lt;br /&gt;
Assemble your Y-cable as follows:&lt;br /&gt;
# Graft one jump wire onto the other to form a Y shape using [https://www.youtube.com/watch?v=KpiEfuhPqew this] technique, ensuring solitary leg end is compatible with your USB-UART adapter&lt;br /&gt;
# Splice resistors into the twin arms using [https://www.youtube.com/watch?v=RMgMVqqjPZ0 this] technique&lt;br /&gt;
# Splice remaining jump wire onto the ends of the resistors, ensuring ends are compatible with your USB-C breakout board&lt;br /&gt;
# Cover all exposed wire &amp;amp; resistors with electrical tape or heat shrink wrap&lt;br /&gt;
&lt;br /&gt;
=== Assembly ===&lt;br /&gt;
&lt;br /&gt;
Once you have acquired all necessary components, assemble the UART dongle as follows:&lt;br /&gt;
# Connect a jump wire from the GND pin on the USB-UART adapter to any one of the four GND pins on the USB-C breakout board (A1, A12, B1, or B12)&lt;br /&gt;
# Connect a jump wire from the RXD pin on the USB-UART adapter to the SBU1 pin on the USB-C breakout board (A8)&lt;br /&gt;
# Connect a jump wire from the TXD pin on the USB-UART adapter to the SBU2 pin on the USB-C breakout board (B8)&lt;br /&gt;
# Connect your Y-shaped jump wire from the 3.3V source pin on the USB-UART adapter to the CC1 and CC2 pins on the USB-C breakout board (A5 and B5)&lt;br /&gt;
# Wrap all metal connectors in electrical tape or heat shrink to prevent accidental shorts&lt;br /&gt;
&lt;br /&gt;
Be '''very certain''' of your connections for the 3.3V source, as there is a real risk of irreparably frying your PineNote if they're wrong!&lt;br /&gt;
Especially be sure you are connecting to a 3.3V source and not a 5V source.&lt;br /&gt;
&lt;br /&gt;
Note that if you mix up the TX/RX pins, it will still work but the USB-C breakout board will just plug into the PineNote upside down.&lt;br /&gt;
You can therefore choose which orientation you want by swapping the TX/RX pin connections.&lt;br /&gt;
&lt;br /&gt;
== Using UART ==&lt;br /&gt;
&lt;br /&gt;
First, use your UART dongle to physically connect your PineNote to your computer:&lt;br /&gt;
# Plug the USB-UART adapter into one of your computer's USB ports&lt;br /&gt;
# Plug the USB-C breakout board into the USB-C port on the bottom of your PineNote; the orientation matters, so try both and remember which one works&lt;br /&gt;
&lt;br /&gt;
Once the hardware is connected, set up your computer's software as follows:&lt;br /&gt;
# Install [https://www.gnu.org/software/screen/ GNU Screen] (or [https://askubuntu.com/q/40959 some other option], but the instructions below are written for &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt;)&lt;br /&gt;
# Identify the USB-UART adapter in your &amp;lt;code&amp;gt;/dev&amp;lt;/code&amp;gt; directory by running &amp;lt;code&amp;gt;ls /dev&amp;lt;/code&amp;gt; with it plugged in, unplugging it, then again running &amp;lt;code&amp;gt;ls /dev&amp;lt;/code&amp;gt; and seeing what changes; it is likely to be called &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;&lt;br /&gt;
# In a terminal window, run &amp;lt;code&amp;gt;screen -L /dev/ttyUSB0 1500000&amp;lt;/code&amp;gt; (you may need to run this as sudo depending on your user's permissions; on most Linux distributions you need to be in the &amp;lt;code&amp;gt;dialout&amp;lt;/code&amp;gt; usergroup)&lt;br /&gt;
&lt;br /&gt;
Once the software is set up, power-cycle your PineNote; as the system boots you should see text appearing in your terminal window.&lt;br /&gt;
You can exit the screen session with &amp;lt;code&amp;gt;ctrl+a k&amp;lt;/code&amp;gt; then pressing &amp;lt;code&amp;gt;y&amp;lt;/code&amp;gt; to confirm.&lt;br /&gt;
The &amp;lt;code&amp;gt;screen -L&amp;lt;/code&amp;gt; flag outputs a text log of the session to the current working directory, probably called &amp;lt;code&amp;gt;screenlog.0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Troubleshooting ====&lt;br /&gt;
&lt;br /&gt;
If you don't see any text in your terminal as the PineNote boots, or the text is garbled, try the following:&lt;br /&gt;
* Ensure your GND, RX and TX jump wires are connected to the correct pins on both the USB-UART adapter and the USB-C breakout board&lt;br /&gt;
* Connect your USB-C breakout board to your PineNote in the opposite orientation&lt;br /&gt;
* Run the screen command as sudo in case your user doesn't have appropriate permissions&lt;br /&gt;
* Ensure you are setting the baud rate in the &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt; command to 1500000 (1.5 million)&lt;br /&gt;
&lt;br /&gt;
== USB passthrough ==&lt;br /&gt;
&lt;br /&gt;
If your USB-C breakout board has a passthrough/intercept design, you can connect to your PineNote over USB and UART at the same time.&lt;br /&gt;
This can be useful when you're doing development work on the PineNote boot process so you don't have to continually reconnect cables.&lt;br /&gt;
You'll need a USB-A to USB-C cable, connecting directly from your computer's USB-A hub to your USB-C breakout board's female USB-C port.&lt;br /&gt;
It's important to connect directly from USB-A, without any intermediate USB-C components.&lt;br /&gt;
Note that connecting a live USB cable to your USB-C breakout board in this way dramatically increases the danger of frying your PineNote with a short, so you should only do this if all connectors are safely wrapped in electrical tape.&lt;br /&gt;
&lt;br /&gt;
[[Category:PineNote]]&lt;/div&gt;</summary>
		<author><name>Ahelwer</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PineNote_Development/UART&amp;diff=20886</id>
		<title>PineNote Development/UART</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PineNote_Development/UART&amp;diff=20886"/>
		<updated>2023-10-14T01:26:35Z</updated>

		<summary type="html">&lt;p&gt;Ahelwer: Added photo of Y cable&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Pinenote-uart-dongle.jpeg|thumb|Basic non-stock PineNote UART dongle]]&lt;br /&gt;
&lt;br /&gt;
This page contains information on creating and using a [https://en.wikipedia.org/wiki/Universal_asynchronous_receiver-transmitter UART] dongle for the [[PineNote]].&lt;br /&gt;
The PineNote was shipped with a compatible UART dongle, but replacements are not available to order in case of loss or hardware fault.&lt;br /&gt;
Thankfully it is not difficult to make your own from easily-acquired components and a small bit of soldering.&lt;br /&gt;
Fear not if you've never soldered anything before!&lt;br /&gt;
This serves as an excellent first soldering project.&lt;br /&gt;
Borrow the tools from a friend or a local hackerspace or tool library.&lt;br /&gt;
&lt;br /&gt;
A PineNote UART dongle enables you to:&lt;br /&gt;
# Interact with the system boot menu&lt;br /&gt;
# Read system events in real time as the PineNote is used&lt;br /&gt;
# Fix the PineNote without opening the case if something goes wrong while [[PineNote Development/Flashing|flashing it]]&lt;br /&gt;
&lt;br /&gt;
Since the PineNote is an embedded system, interfacing with it during boot is more complicated than with an ordinary computer.&lt;br /&gt;
The UART dongle enables you to do this.&lt;br /&gt;
&lt;br /&gt;
The PineNote factory firmware runs UART at a baud rate of 1500000 bps, 8 data bits, 1 stop bit, no parity and no flow control.&lt;br /&gt;
The process by which the PineNote design was modified to include closed-case UART is documented [[PineNote/Hardware Changes/Closed Case UART|here]].&lt;br /&gt;
&lt;br /&gt;
== Stock dongle ==&lt;br /&gt;
&lt;br /&gt;
The stock UART dongle included with the PineNote was a simple device plugging directly into the PineNote's USB-C port.&lt;br /&gt;
The dongle exposed a female USB-C port, which the user plugged into to get UART access.&lt;br /&gt;
This design unfortunately ruled out passthrough USB connections, where the user connects to the PineNote via UART and USB simultaneously.&lt;br /&gt;
The dongle is not currently available for purchase.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Pinenote-stock-uart-dongle-front.jpg|Front&lt;br /&gt;
Pinenote-stock-uart-dongle-back.jpg|Back&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Creating a dongle ==&lt;br /&gt;
&lt;br /&gt;
A typical self-built PineNote UART dongle design has the following components:&lt;br /&gt;
# A USB-C breakout board with a male connector exposing the 24 pins of the PineNote's USB-C port&lt;br /&gt;
# A USB-UART adapter, to plug into a USB port of the computer you'll use to interface with the PineNote&lt;br /&gt;
# [https://en.wikipedia.org/wiki/Jump_wire Jump wires] to connect specific breakout board pins to pins on the USB-UART adapter&lt;br /&gt;
# Two 1,000 Ohm through-hole resistors to splice into the jump wires&lt;br /&gt;
# Electrical tape or heat shrink to wrap connectors and prevent shorts&lt;br /&gt;
&lt;br /&gt;
You will also need the following tools:&lt;br /&gt;
# Soldering iron with solder&lt;br /&gt;
# Wire cutters &amp;amp; strippers&lt;br /&gt;
&lt;br /&gt;
The PineNote's internal UART system is documented in [https://files.pine64.org/doc/PineNote/PineNote_USB-C_Console_UART_breakout_board_schematic_v1.0_20210903.pdf this schematic].&lt;br /&gt;
The purpose of all 24 USB-C pins is documented [https://en.wikipedia.org/wiki/USB-C#Receptacles on the USB-C Wikipedia page].&lt;br /&gt;
We are interested in three sets of pins:&lt;br /&gt;
# The SBU1 (A8) and SBU2 (B8) side band use pins&lt;br /&gt;
# The CC1 (A5) and CC2 (B5) configuration channel pins&lt;br /&gt;
# The GND [https://en.wikipedia.org/wiki/Ground_(electricity) ground return] pins (A1, A12, B1, and B12)&lt;br /&gt;
&lt;br /&gt;
In the PineNote UART schematic you can see (on the bottom right diagram labeled &amp;lt;code&amp;gt;USB_TYPEC_Male&amp;lt;/code&amp;gt;) the side band pins are given the labels &amp;lt;code&amp;gt;UART2_TX_SUB1&amp;lt;/code&amp;gt; for A8 and &amp;lt;code&amp;gt;UART2_RX_SUB2&amp;lt;/code&amp;gt; for B8.&lt;br /&gt;
The first (TX) is used for transmitting data and the second (RX) is used for receiving data, from the perspective of the PineNote.&lt;br /&gt;
Also note the configuration channel pins labeled &amp;lt;code&amp;gt;TYPEC_CC1&amp;lt;/code&amp;gt; for A5 and &amp;lt;code&amp;gt;TYPEC_CC2&amp;lt;/code&amp;gt; for B5.&lt;br /&gt;
These pins are used to signal to the PineNote that a UART dongle is present.&lt;br /&gt;
The diagram shows they must be connected to a 3.3V source in parallel, mediated by resistors.&lt;br /&gt;
The schematic indicates 10,000 Ohm resistors, but community member talpadk experimented and found 1,000 Ohm resistors work better.&lt;br /&gt;
Our mission is to wire up pins from a USB-UART adapter to a USB-C breakout board following these requirements.&lt;br /&gt;
&lt;br /&gt;
=== Buying components ===&lt;br /&gt;
&lt;br /&gt;
There are many possible USB-C breakout board designs available for purchase online.&lt;br /&gt;
One particularly useful design is a &amp;quot;passthrough&amp;quot; or &amp;quot;intercept&amp;quot; style, with both male and female USB-C ports.&lt;br /&gt;
This design is more versatile in case you want to reuse it in other projects, and also enables you to connect to the PineNote via UART and USB at the same time.&lt;br /&gt;
An example of this product can be found [https://pmdway.com/products/usb-3-1-type-c-male-to-female-breakout-test-board here], although you are encouraged to shop around for cheaper options.&lt;br /&gt;
If you're fine with a bit more soldering, there is a very cheap one [https://www.ebay.com/itm/275407037613 here].&lt;br /&gt;
&lt;br /&gt;
Similarly, there are many USB-UART adapter designs available.&lt;br /&gt;
These devices plug into your computer and expose a number of pins themselves, connecting to specific pins on the breakout board with jump wires.&lt;br /&gt;
It is important to get a 3.3V model, or at least a model with the option of 3.3V, as a 5V source might fry the PineNote.&lt;br /&gt;
[https://pmdway.com/products/usb-to-ttl-serial-cp2104-6-pin-converter-module Here] is one example with jump wires included, although you are again encouraged to shop around for alternatives.&lt;br /&gt;
&lt;br /&gt;
All other necessary components of our UART dongle are readily &amp;amp; cheaply available in many locations.&lt;br /&gt;
&lt;br /&gt;
=== Splicing resistors ===&lt;br /&gt;
&lt;br /&gt;
[[File:PineNote-UART-Y-pull-up-resistor-cable.jpg|thumb|The goal]]&lt;br /&gt;
&lt;br /&gt;
This is the only difficult part of the whole process.&lt;br /&gt;
Your goal is to create a Y-shaped jump wire with 1,000 Ohm through-hole resistors spliced into each of the twin arms.&lt;br /&gt;
The solitary leg will connect to a 3.3V source on your USB-UART adapter.&lt;br /&gt;
The twin arms will connect to the configuration channel pins on your USB-C breakout board.&lt;br /&gt;
This setup is called using pull-up resistors, and you can read a nice introduction to their purpose [https://www.electronics-tutorials.ws/logic/pull-up-resistor.html here].&lt;br /&gt;
&lt;br /&gt;
For this project you'll need:&lt;br /&gt;
# A soldering iron with solder&lt;br /&gt;
# Wire cutters &amp;amp; strippers&lt;br /&gt;
# 2x jumper wires, male/female as compatible with your board designs&lt;br /&gt;
# 2x 1,000 Ohm through-hole resistors&lt;br /&gt;
# Electrical tape or heat shrink wrap&lt;br /&gt;
&lt;br /&gt;
Consider buying extra jumper wires and resistors in case you mess up.&lt;br /&gt;
Also double-check that you have 1K resistors with [https://resistorcolorcodecalc.com/ this color code calculator].&lt;br /&gt;
Although the PineNote UART schematic says to use 10K Ohm resistors, community member talpadk experimented and found 1K is more appropriate.&lt;br /&gt;
Assemble your Y-cable as follows:&lt;br /&gt;
# Graft one jump wire onto the other to form a Y shape using [https://www.youtube.com/watch?v=KpiEfuhPqew this] technique, ensuring solitary leg end is compatible with your USB-UART adapter&lt;br /&gt;
# Splice resistors into the twin arms using [https://www.youtube.com/watch?v=RMgMVqqjPZ0 this] technique&lt;br /&gt;
# Splice remaining jump wire onto the ends of the resistors, ensuring ends are compatible with your USB-C breakout board&lt;br /&gt;
# Cover all exposed wire &amp;amp; resistors with electrical tape or heat shrink wrap&lt;br /&gt;
&lt;br /&gt;
=== Assembly ===&lt;br /&gt;
&lt;br /&gt;
Once you have acquired all necessary components, assemble the UART dongle as follows:&lt;br /&gt;
# Connect a jump wire from the GND pin on the USB-UART adapter to any one of the four GND pins on the USB-C breakout board (A1, A12, B1, or B12)&lt;br /&gt;
# Connect a jump wire from the RXD pin on the USB-UART adapter to the SBU1 pin on the USB-C breakout board (A8)&lt;br /&gt;
# Connect a jump wire from the TXD pin on the USB-UART adapter to the SBU2 pin on the USB-C breakout board (B8)&lt;br /&gt;
# Connect your Y-shaped jump wire from the 3.3V source pin on the USB-UART adapter to the CC1 and CC2 pins on the USB-C breakout board (A5 and B5)&lt;br /&gt;
# Wrap all metal connectors in electrical tape or heat shrink to prevent accidental shorts&lt;br /&gt;
&lt;br /&gt;
Be '''very certain''' of your connections for the 3.3V source, as there is a real risk of irreparably frying your PineNote if they're wrong!&lt;br /&gt;
Especially be sure you are connecting to a 3.3V source and not a 5V source.&lt;br /&gt;
&lt;br /&gt;
Note that if you mix up the TX/RX pins, it will still work but the USB-C breakout board will just plug into the PineNote upside down.&lt;br /&gt;
You can therefore choose which orientation you want by swapping the TX/RX pin connections.&lt;br /&gt;
&lt;br /&gt;
== Using UART ==&lt;br /&gt;
&lt;br /&gt;
First, use your UART dongle to physically connect your PineNote to your computer:&lt;br /&gt;
# Plug the USB-UART adapter into one of your computer's USB ports&lt;br /&gt;
# Plug the USB-C breakout board into the USB-C port on the bottom of your PineNote; the orientation matters, so try both and remember which one works&lt;br /&gt;
&lt;br /&gt;
Once the hardware is connected, set up your computer's software as follows:&lt;br /&gt;
# Install [https://www.gnu.org/software/screen/ GNU Screen] (or [https://askubuntu.com/q/40959 some other option], but the instructions below are written for &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt;)&lt;br /&gt;
# Identify the USB-UART adapter in your &amp;lt;code&amp;gt;/dev&amp;lt;/code&amp;gt; directory by running &amp;lt;code&amp;gt;ls /dev&amp;lt;/code&amp;gt; with it plugged in, unplugging it, then again running &amp;lt;code&amp;gt;ls /dev&amp;lt;/code&amp;gt; and seeing what changes; it is likely to be called &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;&lt;br /&gt;
# In a terminal window, run &amp;lt;code&amp;gt;screen -L /dev/ttyUSB0 1500000&amp;lt;/code&amp;gt; (you may need to run this as sudo depending on your user's permissions; on most Linux distributions you need to be in the &amp;lt;code&amp;gt;dialout&amp;lt;/code&amp;gt; usergroup)&lt;br /&gt;
&lt;br /&gt;
Once the software is set up, power-cycle your PineNote; as the system boots you should see text appearing in your terminal window.&lt;br /&gt;
You can exit the screen session with &amp;lt;code&amp;gt;ctrl+a k&amp;lt;/code&amp;gt; then pressing &amp;lt;code&amp;gt;y&amp;lt;/code&amp;gt; to confirm.&lt;br /&gt;
The &amp;lt;code&amp;gt;screen -L&amp;lt;/code&amp;gt; flag outputs a text log of the session to the current working directory, probably called &amp;lt;code&amp;gt;screenlog.0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Troubleshooting ====&lt;br /&gt;
&lt;br /&gt;
If you don't see any text in your terminal as the PineNote boots, or the text is garbled, try the following:&lt;br /&gt;
* Ensure your GND, RX and TX jump wires are connected to the correct pins on both the USB-UART adapter and the USB-C breakout board&lt;br /&gt;
* Connect your USB-C breakout board to your PineNote in the opposite orientation&lt;br /&gt;
* Run the screen command as sudo in case your user doesn't have appropriate permissions&lt;br /&gt;
* Ensure you are setting the baud rate in the &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt; command to 1500000 (1.5 million)&lt;br /&gt;
&lt;br /&gt;
== USB passthrough ==&lt;br /&gt;
&lt;br /&gt;
If your USB-C breakout board has a passthrough/intercept design, you can connect to your PineNote over USB and UART at the same time.&lt;br /&gt;
This can be useful when you're doing development work on the PineNote boot process so you don't have to continually reconnect cables.&lt;br /&gt;
You'll need a USB-A to USB-C cable, connecting directly from your computer's USB-A hub to your USB-C breakout board's female USB-C port.&lt;br /&gt;
It's important to connect directly from USB-A, without any intermediate USB-C components.&lt;br /&gt;
Note that connecting a live USB cable to your USB-C breakout board in this way dramatically increases the danger of frying your PineNote with a short, so you should only do this if all connectors are safely wrapped in electrical tape.&lt;br /&gt;
&lt;br /&gt;
[[Category:PineNote]]&lt;/div&gt;</summary>
		<author><name>Ahelwer</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=File:PineNote-UART-Y-pull-up-resistor-cable.jpg&amp;diff=20885</id>
		<title>File:PineNote-UART-Y-pull-up-resistor-cable.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=File:PineNote-UART-Y-pull-up-resistor-cable.jpg&amp;diff=20885"/>
		<updated>2023-10-14T01:24:49Z</updated>

		<summary type="html">&lt;p&gt;Ahelwer: Photo of a Y-shaped cable with resistors spliced into each of the twin arms.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary ==&lt;br /&gt;
Photo of a Y-shaped cable with resistors spliced into each of the twin arms.&lt;br /&gt;
== Licensing ==&lt;br /&gt;
{{CC0}}&lt;/div&gt;</summary>
		<author><name>Ahelwer</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PineNote_Development/UART&amp;diff=20884</id>
		<title>PineNote Development/UART</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PineNote_Development/UART&amp;diff=20884"/>
		<updated>2023-10-14T01:19:46Z</updated>

		<summary type="html">&lt;p&gt;Ahelwer: /* Creating a dongle */ Added note about tools&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Pinenote-uart-dongle.jpeg|thumb|Basic non-stock PineNote UART dongle]]&lt;br /&gt;
&lt;br /&gt;
This page contains information on creating and using a [https://en.wikipedia.org/wiki/Universal_asynchronous_receiver-transmitter UART] dongle for the [[PineNote]].&lt;br /&gt;
The PineNote was shipped with a compatible UART dongle, but replacements are not available to order in case of loss or hardware fault.&lt;br /&gt;
Thankfully it is not difficult to make your own from easily-acquired components and a small bit of soldering.&lt;br /&gt;
Fear not if you've never soldered anything before!&lt;br /&gt;
This serves as an excellent first soldering project.&lt;br /&gt;
Borrow the tools from a friend or a local hackerspace or tool library.&lt;br /&gt;
&lt;br /&gt;
A PineNote UART dongle enables you to:&lt;br /&gt;
# Interact with the system boot menu&lt;br /&gt;
# Read system events in real time as the PineNote is used&lt;br /&gt;
# Fix the PineNote without opening the case if something goes wrong while [[PineNote Development/Flashing|flashing it]]&lt;br /&gt;
&lt;br /&gt;
Since the PineNote is an embedded system, interfacing with it during boot is more complicated than with an ordinary computer.&lt;br /&gt;
The UART dongle enables you to do this.&lt;br /&gt;
&lt;br /&gt;
The PineNote factory firmware runs UART at a baud rate of 1500000 bps, 8 data bits, 1 stop bit, no parity and no flow control.&lt;br /&gt;
The process by which the PineNote design was modified to include closed-case UART is documented [[PineNote/Hardware Changes/Closed Case UART|here]].&lt;br /&gt;
&lt;br /&gt;
== Stock dongle ==&lt;br /&gt;
&lt;br /&gt;
The stock UART dongle included with the PineNote was a simple device plugging directly into the PineNote's USB-C port.&lt;br /&gt;
The dongle exposed a female USB-C port, which the user plugged into to get UART access.&lt;br /&gt;
This design unfortunately ruled out passthrough USB connections, where the user connects to the PineNote via UART and USB simultaneously.&lt;br /&gt;
The dongle is not currently available for purchase.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Pinenote-stock-uart-dongle-front.jpg|Front&lt;br /&gt;
Pinenote-stock-uart-dongle-back.jpg|Back&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Creating a dongle ==&lt;br /&gt;
&lt;br /&gt;
A typical self-built PineNote UART dongle design has the following components:&lt;br /&gt;
# A USB-C breakout board with a male connector exposing the 24 pins of the PineNote's USB-C port&lt;br /&gt;
# A USB-UART adapter, to plug into a USB port of the computer you'll use to interface with the PineNote&lt;br /&gt;
# [https://en.wikipedia.org/wiki/Jump_wire Jump wires] to connect specific breakout board pins to pins on the USB-UART adapter&lt;br /&gt;
# Two 1,000 Ohm through-hole resistors to splice into the jump wires&lt;br /&gt;
# Electrical tape or heat shrink to wrap connectors and prevent shorts&lt;br /&gt;
&lt;br /&gt;
You will also need the following tools:&lt;br /&gt;
# Soldering iron with solder&lt;br /&gt;
# Wire cutters &amp;amp; strippers&lt;br /&gt;
&lt;br /&gt;
The PineNote's internal UART system is documented in [https://files.pine64.org/doc/PineNote/PineNote_USB-C_Console_UART_breakout_board_schematic_v1.0_20210903.pdf this schematic].&lt;br /&gt;
The purpose of all 24 USB-C pins is documented [https://en.wikipedia.org/wiki/USB-C#Receptacles on the USB-C Wikipedia page].&lt;br /&gt;
We are interested in three sets of pins:&lt;br /&gt;
# The SBU1 (A8) and SBU2 (B8) side band use pins&lt;br /&gt;
# The CC1 (A5) and CC2 (B5) configuration channel pins&lt;br /&gt;
# The GND [https://en.wikipedia.org/wiki/Ground_(electricity) ground return] pins (A1, A12, B1, and B12)&lt;br /&gt;
&lt;br /&gt;
In the PineNote UART schematic you can see (on the bottom right diagram labeled &amp;lt;code&amp;gt;USB_TYPEC_Male&amp;lt;/code&amp;gt;) the side band pins are given the labels &amp;lt;code&amp;gt;UART2_TX_SUB1&amp;lt;/code&amp;gt; for A8 and &amp;lt;code&amp;gt;UART2_RX_SUB2&amp;lt;/code&amp;gt; for B8.&lt;br /&gt;
The first (TX) is used for transmitting data and the second (RX) is used for receiving data, from the perspective of the PineNote.&lt;br /&gt;
Also note the configuration channel pins labeled &amp;lt;code&amp;gt;TYPEC_CC1&amp;lt;/code&amp;gt; for A5 and &amp;lt;code&amp;gt;TYPEC_CC2&amp;lt;/code&amp;gt; for B5.&lt;br /&gt;
These pins are used to signal to the PineNote that a UART dongle is present.&lt;br /&gt;
The diagram shows they must be connected to a 3.3V source in parallel, mediated by resistors.&lt;br /&gt;
The schematic indicates 10,000 Ohm resistors, but community member talpadk experimented and found 1,000 Ohm resistors work better.&lt;br /&gt;
Our mission is to wire up pins from a USB-UART adapter to a USB-C breakout board following these requirements.&lt;br /&gt;
&lt;br /&gt;
=== Buying components ===&lt;br /&gt;
&lt;br /&gt;
There are many possible USB-C breakout board designs available for purchase online.&lt;br /&gt;
One particularly useful design is a &amp;quot;passthrough&amp;quot; or &amp;quot;intercept&amp;quot; style, with both male and female USB-C ports.&lt;br /&gt;
This design is more versatile in case you want to reuse it in other projects, and also enables you to connect to the PineNote via UART and USB at the same time.&lt;br /&gt;
An example of this product can be found [https://pmdway.com/products/usb-3-1-type-c-male-to-female-breakout-test-board here], although you are encouraged to shop around for cheaper options.&lt;br /&gt;
If you're fine with a bit more soldering, there is a very cheap one [https://www.ebay.com/itm/275407037613 here].&lt;br /&gt;
&lt;br /&gt;
Similarly, there are many USB-UART adapter designs available.&lt;br /&gt;
These devices plug into your computer and expose a number of pins themselves, connecting to specific pins on the breakout board with jump wires.&lt;br /&gt;
It is important to get a 3.3V model, or at least a model with the option of 3.3V, as a 5V source might fry the PineNote.&lt;br /&gt;
[https://pmdway.com/products/usb-to-ttl-serial-cp2104-6-pin-converter-module Here] is one example with jump wires included, although you are again encouraged to shop around for alternatives.&lt;br /&gt;
&lt;br /&gt;
All other necessary components of our UART dongle are readily &amp;amp; cheaply available in many locations.&lt;br /&gt;
&lt;br /&gt;
=== Splicing resistors ===&lt;br /&gt;
&lt;br /&gt;
This is the only difficult part of the whole process.&lt;br /&gt;
Your goal is to create a Y-shaped jump wire with 1,000 Ohm through-hole resistors spliced into each of the twin arms.&lt;br /&gt;
The solitary leg will connect to a 3.3V source on your USB-UART adapter.&lt;br /&gt;
The twin arms will connect to the configuration channel pins on your USB-C breakout board.&lt;br /&gt;
This setup is called using pull-up resistors, and you can read a nice introduction to their purpose [https://www.electronics-tutorials.ws/logic/pull-up-resistor.html here].&lt;br /&gt;
&lt;br /&gt;
For this project you'll need:&lt;br /&gt;
# A soldering iron with solder&lt;br /&gt;
# Wire cutters &amp;amp; strippers&lt;br /&gt;
# 2x jumper wires, male/female as compatible with your board designs&lt;br /&gt;
# 2x 1,000 Ohm through-hole resistors&lt;br /&gt;
# Electrical tape or heat shrink wrap&lt;br /&gt;
&lt;br /&gt;
Consider buying extra jumper wires and resistors in case you mess up.&lt;br /&gt;
Also double-check that you have 1K resistors with [https://resistorcolorcodecalc.com/ this color code calculator].&lt;br /&gt;
Although the PineNote UART schematic says to use 10K Ohm resistors, community member talpadk experimented and found 1K is more appropriate.&lt;br /&gt;
Assemble your Y-cable as follows:&lt;br /&gt;
# Graft one jump wire onto the other to form a Y shape using [https://www.youtube.com/watch?v=KpiEfuhPqew this] technique, ensuring solitary leg end is compatible with your USB-UART adapter&lt;br /&gt;
# Splice resistors into the twin arms using [https://www.youtube.com/watch?v=RMgMVqqjPZ0 this] technique&lt;br /&gt;
# Splice remaining jump wire onto the ends of the resistors, ensuring ends are compatible with your USB-C breakout board&lt;br /&gt;
# Cover all exposed wire &amp;amp; resistors with electrical tape or heat shrink wrap&lt;br /&gt;
&lt;br /&gt;
=== Assembly ===&lt;br /&gt;
&lt;br /&gt;
Once you have acquired all necessary components, assemble the UART dongle as follows:&lt;br /&gt;
# Connect a jump wire from the GND pin on the USB-UART adapter to any one of the four GND pins on the USB-C breakout board (A1, A12, B1, or B12)&lt;br /&gt;
# Connect a jump wire from the RXD pin on the USB-UART adapter to the SBU1 pin on the USB-C breakout board (A8)&lt;br /&gt;
# Connect a jump wire from the TXD pin on the USB-UART adapter to the SBU2 pin on the USB-C breakout board (B8)&lt;br /&gt;
# Connect your Y-shaped jump wire from the 3.3V source pin on the USB-UART adapter to the CC1 and CC2 pins on the USB-C breakout board (A5 and B5)&lt;br /&gt;
# Wrap all metal connectors in electrical tape or heat shrink to prevent accidental shorts&lt;br /&gt;
&lt;br /&gt;
Be '''very certain''' of your connections for the 3.3V source, as there is a real risk of irreparably frying your PineNote if they're wrong!&lt;br /&gt;
Especially be sure you are connecting to a 3.3V source and not a 5V source.&lt;br /&gt;
&lt;br /&gt;
Note that if you mix up the TX/RX pins, it will still work but the USB-C breakout board will just plug into the PineNote upside down.&lt;br /&gt;
You can therefore choose which orientation you want by swapping the TX/RX pin connections.&lt;br /&gt;
&lt;br /&gt;
== Using UART ==&lt;br /&gt;
&lt;br /&gt;
First, use your UART dongle to physically connect your PineNote to your computer:&lt;br /&gt;
# Plug the USB-UART adapter into one of your computer's USB ports&lt;br /&gt;
# Plug the USB-C breakout board into the USB-C port on the bottom of your PineNote; the orientation matters, so try both and remember which one works&lt;br /&gt;
&lt;br /&gt;
Once the hardware is connected, set up your computer's software as follows:&lt;br /&gt;
# Install [https://www.gnu.org/software/screen/ GNU Screen] (or [https://askubuntu.com/q/40959 some other option], but the instructions below are written for &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt;)&lt;br /&gt;
# Identify the USB-UART adapter in your &amp;lt;code&amp;gt;/dev&amp;lt;/code&amp;gt; directory by running &amp;lt;code&amp;gt;ls /dev&amp;lt;/code&amp;gt; with it plugged in, unplugging it, then again running &amp;lt;code&amp;gt;ls /dev&amp;lt;/code&amp;gt; and seeing what changes; it is likely to be called &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;&lt;br /&gt;
# In a terminal window, run &amp;lt;code&amp;gt;screen -L /dev/ttyUSB0 1500000&amp;lt;/code&amp;gt; (you may need to run this as sudo depending on your user's permissions; on most Linux distributions you need to be in the &amp;lt;code&amp;gt;dialout&amp;lt;/code&amp;gt; usergroup)&lt;br /&gt;
&lt;br /&gt;
Once the software is set up, power-cycle your PineNote; as the system boots you should see text appearing in your terminal window.&lt;br /&gt;
You can exit the screen session with &amp;lt;code&amp;gt;ctrl+a k&amp;lt;/code&amp;gt; then pressing &amp;lt;code&amp;gt;y&amp;lt;/code&amp;gt; to confirm.&lt;br /&gt;
The &amp;lt;code&amp;gt;screen -L&amp;lt;/code&amp;gt; flag outputs a text log of the session to the current working directory, probably called &amp;lt;code&amp;gt;screenlog.0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Troubleshooting ====&lt;br /&gt;
&lt;br /&gt;
If you don't see any text in your terminal as the PineNote boots, or the text is garbled, try the following:&lt;br /&gt;
* Ensure your GND, RX and TX jump wires are connected to the correct pins on both the USB-UART adapter and the USB-C breakout board&lt;br /&gt;
* Connect your USB-C breakout board to your PineNote in the opposite orientation&lt;br /&gt;
* Run the screen command as sudo in case your user doesn't have appropriate permissions&lt;br /&gt;
* Ensure you are setting the baud rate in the &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt; command to 1500000 (1.5 million)&lt;br /&gt;
&lt;br /&gt;
== USB passthrough ==&lt;br /&gt;
&lt;br /&gt;
If your USB-C breakout board has a passthrough/intercept design, you can connect to your PineNote over USB and UART at the same time.&lt;br /&gt;
This can be useful when you're doing development work on the PineNote boot process so you don't have to continually reconnect cables.&lt;br /&gt;
You'll need a USB-A to USB-C cable, connecting directly from your computer's USB-A hub to your USB-C breakout board's female USB-C port.&lt;br /&gt;
It's important to connect directly from USB-A, without any intermediate USB-C components.&lt;br /&gt;
Note that connecting a live USB cable to your USB-C breakout board in this way dramatically increases the danger of frying your PineNote with a short, so you should only do this if all connectors are safely wrapped in electrical tape.&lt;br /&gt;
&lt;br /&gt;
[[Category:PineNote]]&lt;/div&gt;</summary>
		<author><name>Ahelwer</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PineNote_Development/UART&amp;diff=20883</id>
		<title>PineNote Development/UART</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PineNote_Development/UART&amp;diff=20883"/>
		<updated>2023-10-14T01:16:23Z</updated>

		<summary type="html">&lt;p&gt;Ahelwer: /* Splicing resistors */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Pinenote-uart-dongle.jpeg|thumb|Basic non-stock PineNote UART dongle]]&lt;br /&gt;
&lt;br /&gt;
This page contains information on creating and using a [https://en.wikipedia.org/wiki/Universal_asynchronous_receiver-transmitter UART] dongle for the [[PineNote]].&lt;br /&gt;
The PineNote was shipped with a compatible UART dongle, but replacements are not available to order in case of loss or hardware fault.&lt;br /&gt;
Thankfully it is not difficult to make your own from easily-acquired components and a small bit of soldering.&lt;br /&gt;
Fear not if you've never soldered anything before!&lt;br /&gt;
This serves as an excellent first soldering project.&lt;br /&gt;
Borrow the tools from a friend or a local hackerspace or tool library.&lt;br /&gt;
&lt;br /&gt;
A PineNote UART dongle enables you to:&lt;br /&gt;
# Interact with the system boot menu&lt;br /&gt;
# Read system events in real time as the PineNote is used&lt;br /&gt;
# Fix the PineNote without opening the case if something goes wrong while [[PineNote Development/Flashing|flashing it]]&lt;br /&gt;
&lt;br /&gt;
Since the PineNote is an embedded system, interfacing with it during boot is more complicated than with an ordinary computer.&lt;br /&gt;
The UART dongle enables you to do this.&lt;br /&gt;
&lt;br /&gt;
The PineNote factory firmware runs UART at a baud rate of 1500000 bps, 8 data bits, 1 stop bit, no parity and no flow control.&lt;br /&gt;
The process by which the PineNote design was modified to include closed-case UART is documented [[PineNote/Hardware Changes/Closed Case UART|here]].&lt;br /&gt;
&lt;br /&gt;
== Stock dongle ==&lt;br /&gt;
&lt;br /&gt;
The stock UART dongle included with the PineNote was a simple device plugging directly into the PineNote's USB-C port.&lt;br /&gt;
The dongle exposed a female USB-C port, which the user plugged into to get UART access.&lt;br /&gt;
This design unfortunately ruled out passthrough USB connections, where the user connects to the PineNote via UART and USB simultaneously.&lt;br /&gt;
The dongle is not currently available for purchase.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Pinenote-stock-uart-dongle-front.jpg|Front&lt;br /&gt;
Pinenote-stock-uart-dongle-back.jpg|Back&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Creating a dongle ==&lt;br /&gt;
&lt;br /&gt;
A typical self-built PineNote UART dongle design has the following components:&lt;br /&gt;
# A USB-C breakout board with a male connector exposing the 24 pins of the PineNote's USB-C port&lt;br /&gt;
# A USB-UART adapter, to plug into a USB port of the computer you'll use to interface with the PineNote&lt;br /&gt;
# [https://en.wikipedia.org/wiki/Jump_wire Jump wires] to connect specific breakout board pins to pins on the USB-UART adapter&lt;br /&gt;
# Two 1,000 Ohm through-hole resistors to splice into the jump wires&lt;br /&gt;
# Electrical tape or heat shrink to wrap connectors and prevent shorts&lt;br /&gt;
&lt;br /&gt;
The PineNote's internal UART system is documented in [https://files.pine64.org/doc/PineNote/PineNote_USB-C_Console_UART_breakout_board_schematic_v1.0_20210903.pdf this schematic].&lt;br /&gt;
The purpose of all 24 USB-C pins is documented [https://en.wikipedia.org/wiki/USB-C#Receptacles on the USB-C Wikipedia page].&lt;br /&gt;
We are interested in three sets of pins:&lt;br /&gt;
# The SBU1 (A8) and SBU2 (B8) side band use pins&lt;br /&gt;
# The CC1 (A5) and CC2 (B5) configuration channel pins&lt;br /&gt;
# The GND [https://en.wikipedia.org/wiki/Ground_(electricity) ground return] pins (A1, A12, B1, and B12)&lt;br /&gt;
&lt;br /&gt;
In the PineNote UART schematic you can see (on the bottom right diagram labeled &amp;lt;code&amp;gt;USB_TYPEC_Male&amp;lt;/code&amp;gt;) the side band pins are given the labels &amp;lt;code&amp;gt;UART2_TX_SUB1&amp;lt;/code&amp;gt; for A8 and &amp;lt;code&amp;gt;UART2_RX_SUB2&amp;lt;/code&amp;gt; for B8.&lt;br /&gt;
The first (TX) is used for transmitting data and the second (RX) is used for receiving data, from the perspective of the PineNote.&lt;br /&gt;
Also note the configuration channel pins labeled &amp;lt;code&amp;gt;TYPEC_CC1&amp;lt;/code&amp;gt; for A5 and &amp;lt;code&amp;gt;TYPEC_CC2&amp;lt;/code&amp;gt; for B5.&lt;br /&gt;
These pins are used to signal to the PineNote that a UART dongle is present.&lt;br /&gt;
The diagram shows they must be connected to a 3.3V source in parallel, mediated by resistors.&lt;br /&gt;
The schematic indicates 10,000 Ohm resistors, but community member talpadk experimented and found 1,000 Ohm resistors work better.&lt;br /&gt;
Our mission is to wire up pins from a USB-UART adapter to a USB-C breakout board following these requirements.&lt;br /&gt;
&lt;br /&gt;
=== Buying components ===&lt;br /&gt;
&lt;br /&gt;
There are many possible USB-C breakout board designs available for purchase online.&lt;br /&gt;
One particularly useful design is a &amp;quot;passthrough&amp;quot; or &amp;quot;intercept&amp;quot; style, with both male and female USB-C ports.&lt;br /&gt;
This design is more versatile in case you want to reuse it in other projects, and also enables you to connect to the PineNote via UART and USB at the same time.&lt;br /&gt;
An example of this product can be found [https://pmdway.com/products/usb-3-1-type-c-male-to-female-breakout-test-board here], although you are encouraged to shop around for cheaper options.&lt;br /&gt;
If you're fine with a bit more soldering, there is a very cheap one [https://www.ebay.com/itm/275407037613 here].&lt;br /&gt;
&lt;br /&gt;
Similarly, there are many USB-UART adapter designs available.&lt;br /&gt;
These devices plug into your computer and expose a number of pins themselves, connecting to specific pins on the breakout board with jump wires.&lt;br /&gt;
It is important to get a 3.3V model, or at least a model with the option of 3.3V, as a 5V source might fry the PineNote.&lt;br /&gt;
[https://pmdway.com/products/usb-to-ttl-serial-cp2104-6-pin-converter-module Here] is one example with jump wires included, although you are again encouraged to shop around for alternatives.&lt;br /&gt;
&lt;br /&gt;
All other necessary components of our UART dongle are readily &amp;amp; cheaply available in many locations.&lt;br /&gt;
&lt;br /&gt;
=== Splicing resistors ===&lt;br /&gt;
&lt;br /&gt;
This is the only difficult part of the whole process.&lt;br /&gt;
Your goal is to create a Y-shaped jump wire with 1,000 Ohm through-hole resistors spliced into each of the twin arms.&lt;br /&gt;
The solitary leg will connect to a 3.3V source on your USB-UART adapter.&lt;br /&gt;
The twin arms will connect to the configuration channel pins on your USB-C breakout board.&lt;br /&gt;
This setup is called using pull-up resistors, and you can read a nice introduction to their purpose [https://www.electronics-tutorials.ws/logic/pull-up-resistor.html here].&lt;br /&gt;
&lt;br /&gt;
For this project you'll need:&lt;br /&gt;
# A soldering iron with solder&lt;br /&gt;
# Wire cutters &amp;amp; strippers&lt;br /&gt;
# 2x jumper wires, male/female as compatible with your board designs&lt;br /&gt;
# 2x 1,000 Ohm through-hole resistors&lt;br /&gt;
# Electrical tape or heat shrink wrap&lt;br /&gt;
&lt;br /&gt;
Consider buying extra jumper wires and resistors in case you mess up.&lt;br /&gt;
Also double-check that you have 1K resistors with [https://resistorcolorcodecalc.com/ this color code calculator].&lt;br /&gt;
Although the PineNote UART schematic says to use 10K Ohm resistors, community member talpadk experimented and found 1K is more appropriate.&lt;br /&gt;
Assemble your Y-cable as follows:&lt;br /&gt;
# Graft one jump wire onto the other to form a Y shape using [https://www.youtube.com/watch?v=KpiEfuhPqew this] technique, ensuring solitary leg end is compatible with your USB-UART adapter&lt;br /&gt;
# Splice resistors into the twin arms using [https://www.youtube.com/watch?v=RMgMVqqjPZ0 this] technique&lt;br /&gt;
# Splice remaining jump wire onto the ends of the resistors, ensuring ends are compatible with your USB-C breakout board&lt;br /&gt;
# Cover all exposed wire &amp;amp; resistors with electrical tape or heat shrink wrap&lt;br /&gt;
&lt;br /&gt;
=== Assembly ===&lt;br /&gt;
&lt;br /&gt;
Once you have acquired all necessary components, assemble the UART dongle as follows:&lt;br /&gt;
# Connect a jump wire from the GND pin on the USB-UART adapter to any one of the four GND pins on the USB-C breakout board (A1, A12, B1, or B12)&lt;br /&gt;
# Connect a jump wire from the RXD pin on the USB-UART adapter to the SBU1 pin on the USB-C breakout board (A8)&lt;br /&gt;
# Connect a jump wire from the TXD pin on the USB-UART adapter to the SBU2 pin on the USB-C breakout board (B8)&lt;br /&gt;
# Connect your Y-shaped jump wire from the 3.3V source pin on the USB-UART adapter to the CC1 and CC2 pins on the USB-C breakout board (A5 and B5)&lt;br /&gt;
# Wrap all metal connectors in electrical tape or heat shrink to prevent accidental shorts&lt;br /&gt;
&lt;br /&gt;
Be '''very certain''' of your connections for the 3.3V source, as there is a real risk of irreparably frying your PineNote if they're wrong!&lt;br /&gt;
Especially be sure you are connecting to a 3.3V source and not a 5V source.&lt;br /&gt;
&lt;br /&gt;
Note that if you mix up the TX/RX pins, it will still work but the USB-C breakout board will just plug into the PineNote upside down.&lt;br /&gt;
You can therefore choose which orientation you want by swapping the TX/RX pin connections.&lt;br /&gt;
&lt;br /&gt;
== Using UART ==&lt;br /&gt;
&lt;br /&gt;
First, use your UART dongle to physically connect your PineNote to your computer:&lt;br /&gt;
# Plug the USB-UART adapter into one of your computer's USB ports&lt;br /&gt;
# Plug the USB-C breakout board into the USB-C port on the bottom of your PineNote; the orientation matters, so try both and remember which one works&lt;br /&gt;
&lt;br /&gt;
Once the hardware is connected, set up your computer's software as follows:&lt;br /&gt;
# Install [https://www.gnu.org/software/screen/ GNU Screen] (or [https://askubuntu.com/q/40959 some other option], but the instructions below are written for &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt;)&lt;br /&gt;
# Identify the USB-UART adapter in your &amp;lt;code&amp;gt;/dev&amp;lt;/code&amp;gt; directory by running &amp;lt;code&amp;gt;ls /dev&amp;lt;/code&amp;gt; with it plugged in, unplugging it, then again running &amp;lt;code&amp;gt;ls /dev&amp;lt;/code&amp;gt; and seeing what changes; it is likely to be called &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;&lt;br /&gt;
# In a terminal window, run &amp;lt;code&amp;gt;screen -L /dev/ttyUSB0 1500000&amp;lt;/code&amp;gt; (you may need to run this as sudo depending on your user's permissions; on most Linux distributions you need to be in the &amp;lt;code&amp;gt;dialout&amp;lt;/code&amp;gt; usergroup)&lt;br /&gt;
&lt;br /&gt;
Once the software is set up, power-cycle your PineNote; as the system boots you should see text appearing in your terminal window.&lt;br /&gt;
You can exit the screen session with &amp;lt;code&amp;gt;ctrl+a k&amp;lt;/code&amp;gt; then pressing &amp;lt;code&amp;gt;y&amp;lt;/code&amp;gt; to confirm.&lt;br /&gt;
The &amp;lt;code&amp;gt;screen -L&amp;lt;/code&amp;gt; flag outputs a text log of the session to the current working directory, probably called &amp;lt;code&amp;gt;screenlog.0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Troubleshooting ====&lt;br /&gt;
&lt;br /&gt;
If you don't see any text in your terminal as the PineNote boots, or the text is garbled, try the following:&lt;br /&gt;
* Ensure your GND, RX and TX jump wires are connected to the correct pins on both the USB-UART adapter and the USB-C breakout board&lt;br /&gt;
* Connect your USB-C breakout board to your PineNote in the opposite orientation&lt;br /&gt;
* Run the screen command as sudo in case your user doesn't have appropriate permissions&lt;br /&gt;
* Ensure you are setting the baud rate in the &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt; command to 1500000 (1.5 million)&lt;br /&gt;
&lt;br /&gt;
== USB passthrough ==&lt;br /&gt;
&lt;br /&gt;
If your USB-C breakout board has a passthrough/intercept design, you can connect to your PineNote over USB and UART at the same time.&lt;br /&gt;
This can be useful when you're doing development work on the PineNote boot process so you don't have to continually reconnect cables.&lt;br /&gt;
You'll need a USB-A to USB-C cable, connecting directly from your computer's USB-A hub to your USB-C breakout board's female USB-C port.&lt;br /&gt;
It's important to connect directly from USB-A, without any intermediate USB-C components.&lt;br /&gt;
Note that connecting a live USB cable to your USB-C breakout board in this way dramatically increases the danger of frying your PineNote with a short, so you should only do this if all connectors are safely wrapped in electrical tape.&lt;br /&gt;
&lt;br /&gt;
[[Category:PineNote]]&lt;/div&gt;</summary>
		<author><name>Ahelwer</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PineNote_Development/UART&amp;diff=20882</id>
		<title>PineNote Development/UART</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PineNote_Development/UART&amp;diff=20882"/>
		<updated>2023-10-14T01:13:10Z</updated>

		<summary type="html">&lt;p&gt;Ahelwer: /* Buying components */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Pinenote-uart-dongle.jpeg|thumb|Basic non-stock PineNote UART dongle]]&lt;br /&gt;
&lt;br /&gt;
This page contains information on creating and using a [https://en.wikipedia.org/wiki/Universal_asynchronous_receiver-transmitter UART] dongle for the [[PineNote]].&lt;br /&gt;
The PineNote was shipped with a compatible UART dongle, but replacements are not available to order in case of loss or hardware fault.&lt;br /&gt;
Thankfully it is not difficult to make your own from easily-acquired components and a small bit of soldering.&lt;br /&gt;
Fear not if you've never soldered anything before!&lt;br /&gt;
This serves as an excellent first soldering project.&lt;br /&gt;
Borrow the tools from a friend or a local hackerspace or tool library.&lt;br /&gt;
&lt;br /&gt;
A PineNote UART dongle enables you to:&lt;br /&gt;
# Interact with the system boot menu&lt;br /&gt;
# Read system events in real time as the PineNote is used&lt;br /&gt;
# Fix the PineNote without opening the case if something goes wrong while [[PineNote Development/Flashing|flashing it]]&lt;br /&gt;
&lt;br /&gt;
Since the PineNote is an embedded system, interfacing with it during boot is more complicated than with an ordinary computer.&lt;br /&gt;
The UART dongle enables you to do this.&lt;br /&gt;
&lt;br /&gt;
The PineNote factory firmware runs UART at a baud rate of 1500000 bps, 8 data bits, 1 stop bit, no parity and no flow control.&lt;br /&gt;
The process by which the PineNote design was modified to include closed-case UART is documented [[PineNote/Hardware Changes/Closed Case UART|here]].&lt;br /&gt;
&lt;br /&gt;
== Stock dongle ==&lt;br /&gt;
&lt;br /&gt;
The stock UART dongle included with the PineNote was a simple device plugging directly into the PineNote's USB-C port.&lt;br /&gt;
The dongle exposed a female USB-C port, which the user plugged into to get UART access.&lt;br /&gt;
This design unfortunately ruled out passthrough USB connections, where the user connects to the PineNote via UART and USB simultaneously.&lt;br /&gt;
The dongle is not currently available for purchase.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Pinenote-stock-uart-dongle-front.jpg|Front&lt;br /&gt;
Pinenote-stock-uart-dongle-back.jpg|Back&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Creating a dongle ==&lt;br /&gt;
&lt;br /&gt;
A typical self-built PineNote UART dongle design has the following components:&lt;br /&gt;
# A USB-C breakout board with a male connector exposing the 24 pins of the PineNote's USB-C port&lt;br /&gt;
# A USB-UART adapter, to plug into a USB port of the computer you'll use to interface with the PineNote&lt;br /&gt;
# [https://en.wikipedia.org/wiki/Jump_wire Jump wires] to connect specific breakout board pins to pins on the USB-UART adapter&lt;br /&gt;
# Two 1,000 Ohm through-hole resistors to splice into the jump wires&lt;br /&gt;
# Electrical tape or heat shrink to wrap connectors and prevent shorts&lt;br /&gt;
&lt;br /&gt;
The PineNote's internal UART system is documented in [https://files.pine64.org/doc/PineNote/PineNote_USB-C_Console_UART_breakout_board_schematic_v1.0_20210903.pdf this schematic].&lt;br /&gt;
The purpose of all 24 USB-C pins is documented [https://en.wikipedia.org/wiki/USB-C#Receptacles on the USB-C Wikipedia page].&lt;br /&gt;
We are interested in three sets of pins:&lt;br /&gt;
# The SBU1 (A8) and SBU2 (B8) side band use pins&lt;br /&gt;
# The CC1 (A5) and CC2 (B5) configuration channel pins&lt;br /&gt;
# The GND [https://en.wikipedia.org/wiki/Ground_(electricity) ground return] pins (A1, A12, B1, and B12)&lt;br /&gt;
&lt;br /&gt;
In the PineNote UART schematic you can see (on the bottom right diagram labeled &amp;lt;code&amp;gt;USB_TYPEC_Male&amp;lt;/code&amp;gt;) the side band pins are given the labels &amp;lt;code&amp;gt;UART2_TX_SUB1&amp;lt;/code&amp;gt; for A8 and &amp;lt;code&amp;gt;UART2_RX_SUB2&amp;lt;/code&amp;gt; for B8.&lt;br /&gt;
The first (TX) is used for transmitting data and the second (RX) is used for receiving data, from the perspective of the PineNote.&lt;br /&gt;
Also note the configuration channel pins labeled &amp;lt;code&amp;gt;TYPEC_CC1&amp;lt;/code&amp;gt; for A5 and &amp;lt;code&amp;gt;TYPEC_CC2&amp;lt;/code&amp;gt; for B5.&lt;br /&gt;
These pins are used to signal to the PineNote that a UART dongle is present.&lt;br /&gt;
The diagram shows they must be connected to a 3.3V source in parallel, mediated by resistors.&lt;br /&gt;
The schematic indicates 10,000 Ohm resistors, but community member talpadk experimented and found 1,000 Ohm resistors work better.&lt;br /&gt;
Our mission is to wire up pins from a USB-UART adapter to a USB-C breakout board following these requirements.&lt;br /&gt;
&lt;br /&gt;
=== Buying components ===&lt;br /&gt;
&lt;br /&gt;
There are many possible USB-C breakout board designs available for purchase online.&lt;br /&gt;
One particularly useful design is a &amp;quot;passthrough&amp;quot; or &amp;quot;intercept&amp;quot; style, with both male and female USB-C ports.&lt;br /&gt;
This design is more versatile in case you want to reuse it in other projects, and also enables you to connect to the PineNote via UART and USB at the same time.&lt;br /&gt;
An example of this product can be found [https://pmdway.com/products/usb-3-1-type-c-male-to-female-breakout-test-board here], although you are encouraged to shop around for cheaper options.&lt;br /&gt;
If you're fine with a bit more soldering, there is a very cheap one [https://www.ebay.com/itm/275407037613 here].&lt;br /&gt;
&lt;br /&gt;
Similarly, there are many USB-UART adapter designs available.&lt;br /&gt;
These devices plug into your computer and expose a number of pins themselves, connecting to specific pins on the breakout board with jump wires.&lt;br /&gt;
It is important to get a 3.3V model, or at least a model with the option of 3.3V, as a 5V source might fry the PineNote.&lt;br /&gt;
[https://pmdway.com/products/usb-to-ttl-serial-cp2104-6-pin-converter-module Here] is one example with jump wires included, although you are again encouraged to shop around for alternatives.&lt;br /&gt;
&lt;br /&gt;
All other necessary components of our UART dongle are readily &amp;amp; cheaply available in many locations.&lt;br /&gt;
&lt;br /&gt;
=== Splicing resistors ===&lt;br /&gt;
&lt;br /&gt;
This is the only difficult part of the whole process.&lt;br /&gt;
Your goal is to create a Y-shaped jump wire with 1,000 Ohm through-hole resistors spliced into each of the twin arms.&lt;br /&gt;
The solitary leg will connect to a 3.3V source on your USB-UART adapter.&lt;br /&gt;
The twin arms will connect to the configuration channel pins on your USB-C breakout board.&lt;br /&gt;
These are called pull-up resistors, and you can read a nice introduction to their purpose [https://www.electronics-tutorials.ws/logic/pull-up-resistor.html here].&lt;br /&gt;
&lt;br /&gt;
For this project you'll need:&lt;br /&gt;
# A soldering iron with solder&lt;br /&gt;
# Wire cutters &amp;amp; strippers&lt;br /&gt;
# 2x jumper wires, male/female as compatible with your board designs&lt;br /&gt;
# 2x 1,000 Ohm through-hole resistors&lt;br /&gt;
# Electrical tape or heat shrink wrap&lt;br /&gt;
&lt;br /&gt;
Consider buying extra jumper wires and resistors in case you mess up.&lt;br /&gt;
Also double-check that you have 1K resistors with [https://resistorcolorcodecalc.com/ this color code calculator].&lt;br /&gt;
Although the PineNote UART schematic says to use 10K Ohm resistors, community member talpadk experimented and found 1K is more appropriate.&lt;br /&gt;
Assemble your Y-cable as follows:&lt;br /&gt;
# Graft one jump wire onto the other to form a Y shape using [https://www.youtube.com/watch?v=KpiEfuhPqew this] technique, ensuring solitary leg end is compatible with your USB-UART adapter&lt;br /&gt;
# Splice resistors into the twin arms using [https://www.youtube.com/watch?v=RMgMVqqjPZ0 this] technique&lt;br /&gt;
# Splice remaining jump wire onto the ends of the resistors, ensuring ends are compatible with your USB-C breakout board&lt;br /&gt;
# Cover all exposed wire &amp;amp; resistors with electrical tape or heat shrink wrap&lt;br /&gt;
&lt;br /&gt;
=== Assembly ===&lt;br /&gt;
&lt;br /&gt;
Once you have acquired all necessary components, assemble the UART dongle as follows:&lt;br /&gt;
# Connect a jump wire from the GND pin on the USB-UART adapter to any one of the four GND pins on the USB-C breakout board (A1, A12, B1, or B12)&lt;br /&gt;
# Connect a jump wire from the RXD pin on the USB-UART adapter to the SBU1 pin on the USB-C breakout board (A8)&lt;br /&gt;
# Connect a jump wire from the TXD pin on the USB-UART adapter to the SBU2 pin on the USB-C breakout board (B8)&lt;br /&gt;
# Connect your Y-shaped jump wire from the 3.3V source pin on the USB-UART adapter to the CC1 and CC2 pins on the USB-C breakout board (A5 and B5)&lt;br /&gt;
# Wrap all metal connectors in electrical tape or heat shrink to prevent accidental shorts&lt;br /&gt;
&lt;br /&gt;
Be '''very certain''' of your connections for the 3.3V source, as there is a real risk of irreparably frying your PineNote if they're wrong!&lt;br /&gt;
Especially be sure you are connecting to a 3.3V source and not a 5V source.&lt;br /&gt;
&lt;br /&gt;
Note that if you mix up the TX/RX pins, it will still work but the USB-C breakout board will just plug into the PineNote upside down.&lt;br /&gt;
You can therefore choose which orientation you want by swapping the TX/RX pin connections.&lt;br /&gt;
&lt;br /&gt;
== Using UART ==&lt;br /&gt;
&lt;br /&gt;
First, use your UART dongle to physically connect your PineNote to your computer:&lt;br /&gt;
# Plug the USB-UART adapter into one of your computer's USB ports&lt;br /&gt;
# Plug the USB-C breakout board into the USB-C port on the bottom of your PineNote; the orientation matters, so try both and remember which one works&lt;br /&gt;
&lt;br /&gt;
Once the hardware is connected, set up your computer's software as follows:&lt;br /&gt;
# Install [https://www.gnu.org/software/screen/ GNU Screen] (or [https://askubuntu.com/q/40959 some other option], but the instructions below are written for &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt;)&lt;br /&gt;
# Identify the USB-UART adapter in your &amp;lt;code&amp;gt;/dev&amp;lt;/code&amp;gt; directory by running &amp;lt;code&amp;gt;ls /dev&amp;lt;/code&amp;gt; with it plugged in, unplugging it, then again running &amp;lt;code&amp;gt;ls /dev&amp;lt;/code&amp;gt; and seeing what changes; it is likely to be called &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;&lt;br /&gt;
# In a terminal window, run &amp;lt;code&amp;gt;screen -L /dev/ttyUSB0 1500000&amp;lt;/code&amp;gt; (you may need to run this as sudo depending on your user's permissions; on most Linux distributions you need to be in the &amp;lt;code&amp;gt;dialout&amp;lt;/code&amp;gt; usergroup)&lt;br /&gt;
&lt;br /&gt;
Once the software is set up, power-cycle your PineNote; as the system boots you should see text appearing in your terminal window.&lt;br /&gt;
You can exit the screen session with &amp;lt;code&amp;gt;ctrl+a k&amp;lt;/code&amp;gt; then pressing &amp;lt;code&amp;gt;y&amp;lt;/code&amp;gt; to confirm.&lt;br /&gt;
The &amp;lt;code&amp;gt;screen -L&amp;lt;/code&amp;gt; flag outputs a text log of the session to the current working directory, probably called &amp;lt;code&amp;gt;screenlog.0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Troubleshooting ====&lt;br /&gt;
&lt;br /&gt;
If you don't see any text in your terminal as the PineNote boots, or the text is garbled, try the following:&lt;br /&gt;
* Ensure your GND, RX and TX jump wires are connected to the correct pins on both the USB-UART adapter and the USB-C breakout board&lt;br /&gt;
* Connect your USB-C breakout board to your PineNote in the opposite orientation&lt;br /&gt;
* Run the screen command as sudo in case your user doesn't have appropriate permissions&lt;br /&gt;
* Ensure you are setting the baud rate in the &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt; command to 1500000 (1.5 million)&lt;br /&gt;
&lt;br /&gt;
== USB passthrough ==&lt;br /&gt;
&lt;br /&gt;
If your USB-C breakout board has a passthrough/intercept design, you can connect to your PineNote over USB and UART at the same time.&lt;br /&gt;
This can be useful when you're doing development work on the PineNote boot process so you don't have to continually reconnect cables.&lt;br /&gt;
You'll need a USB-A to USB-C cable, connecting directly from your computer's USB-A hub to your USB-C breakout board's female USB-C port.&lt;br /&gt;
It's important to connect directly from USB-A, without any intermediate USB-C components.&lt;br /&gt;
Note that connecting a live USB cable to your USB-C breakout board in this way dramatically increases the danger of frying your PineNote with a short, so you should only do this if all connectors are safely wrapped in electrical tape.&lt;br /&gt;
&lt;br /&gt;
[[Category:PineNote]]&lt;/div&gt;</summary>
		<author><name>Ahelwer</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PineNote_Development/UART&amp;diff=20881</id>
		<title>PineNote Development/UART</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PineNote_Development/UART&amp;diff=20881"/>
		<updated>2023-10-14T01:10:27Z</updated>

		<summary type="html">&lt;p&gt;Ahelwer: /* Creating a dongle */ Adding instructions for creating Y-shaped pull-up resistor cable&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Pinenote-uart-dongle.jpeg|thumb|Basic non-stock PineNote UART dongle]]&lt;br /&gt;
&lt;br /&gt;
This page contains information on creating and using a [https://en.wikipedia.org/wiki/Universal_asynchronous_receiver-transmitter UART] dongle for the [[PineNote]].&lt;br /&gt;
The PineNote was shipped with a compatible UART dongle, but replacements are not available to order in case of loss or hardware fault.&lt;br /&gt;
Thankfully it is not difficult to make your own from easily-acquired components and a small bit of soldering.&lt;br /&gt;
Fear not if you've never soldered anything before!&lt;br /&gt;
This serves as an excellent first soldering project.&lt;br /&gt;
Borrow the tools from a friend or a local hackerspace or tool library.&lt;br /&gt;
&lt;br /&gt;
A PineNote UART dongle enables you to:&lt;br /&gt;
# Interact with the system boot menu&lt;br /&gt;
# Read system events in real time as the PineNote is used&lt;br /&gt;
# Fix the PineNote without opening the case if something goes wrong while [[PineNote Development/Flashing|flashing it]]&lt;br /&gt;
&lt;br /&gt;
Since the PineNote is an embedded system, interfacing with it during boot is more complicated than with an ordinary computer.&lt;br /&gt;
The UART dongle enables you to do this.&lt;br /&gt;
&lt;br /&gt;
The PineNote factory firmware runs UART at a baud rate of 1500000 bps, 8 data bits, 1 stop bit, no parity and no flow control.&lt;br /&gt;
The process by which the PineNote design was modified to include closed-case UART is documented [[PineNote/Hardware Changes/Closed Case UART|here]].&lt;br /&gt;
&lt;br /&gt;
== Stock dongle ==&lt;br /&gt;
&lt;br /&gt;
The stock UART dongle included with the PineNote was a simple device plugging directly into the PineNote's USB-C port.&lt;br /&gt;
The dongle exposed a female USB-C port, which the user plugged into to get UART access.&lt;br /&gt;
This design unfortunately ruled out passthrough USB connections, where the user connects to the PineNote via UART and USB simultaneously.&lt;br /&gt;
The dongle is not currently available for purchase.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Pinenote-stock-uart-dongle-front.jpg|Front&lt;br /&gt;
Pinenote-stock-uart-dongle-back.jpg|Back&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Creating a dongle ==&lt;br /&gt;
&lt;br /&gt;
A typical self-built PineNote UART dongle design has the following components:&lt;br /&gt;
# A USB-C breakout board with a male connector exposing the 24 pins of the PineNote's USB-C port&lt;br /&gt;
# A USB-UART adapter, to plug into a USB port of the computer you'll use to interface with the PineNote&lt;br /&gt;
# [https://en.wikipedia.org/wiki/Jump_wire Jump wires] to connect specific breakout board pins to pins on the USB-UART adapter&lt;br /&gt;
# Two 1,000 Ohm through-hole resistors to splice into the jump wires&lt;br /&gt;
# Electrical tape or heat shrink to wrap connectors and prevent shorts&lt;br /&gt;
&lt;br /&gt;
The PineNote's internal UART system is documented in [https://files.pine64.org/doc/PineNote/PineNote_USB-C_Console_UART_breakout_board_schematic_v1.0_20210903.pdf this schematic].&lt;br /&gt;
The purpose of all 24 USB-C pins is documented [https://en.wikipedia.org/wiki/USB-C#Receptacles on the USB-C Wikipedia page].&lt;br /&gt;
We are interested in three sets of pins:&lt;br /&gt;
# The SBU1 (A8) and SBU2 (B8) side band use pins&lt;br /&gt;
# The CC1 (A5) and CC2 (B5) configuration channel pins&lt;br /&gt;
# The GND [https://en.wikipedia.org/wiki/Ground_(electricity) ground return] pins (A1, A12, B1, and B12)&lt;br /&gt;
&lt;br /&gt;
In the PineNote UART schematic you can see (on the bottom right diagram labeled &amp;lt;code&amp;gt;USB_TYPEC_Male&amp;lt;/code&amp;gt;) the side band pins are given the labels &amp;lt;code&amp;gt;UART2_TX_SUB1&amp;lt;/code&amp;gt; for A8 and &amp;lt;code&amp;gt;UART2_RX_SUB2&amp;lt;/code&amp;gt; for B8.&lt;br /&gt;
The first (TX) is used for transmitting data and the second (RX) is used for receiving data, from the perspective of the PineNote.&lt;br /&gt;
Also note the configuration channel pins labeled &amp;lt;code&amp;gt;TYPEC_CC1&amp;lt;/code&amp;gt; for A5 and &amp;lt;code&amp;gt;TYPEC_CC2&amp;lt;/code&amp;gt; for B5.&lt;br /&gt;
These pins are used to signal to the PineNote that a UART dongle is present.&lt;br /&gt;
The diagram shows they must be connected to a 3.3V source in parallel, mediated by resistors.&lt;br /&gt;
The schematic indicates 10,000 Ohm resistors, but community member talpadk experimented and found 1,000 Ohm resistors work better.&lt;br /&gt;
Our mission is to wire up pins from a USB-UART adapter to a USB-C breakout board following these requirements.&lt;br /&gt;
&lt;br /&gt;
=== Buying components ===&lt;br /&gt;
&lt;br /&gt;
There are many possible USB-C breakout board designs available for purchase online.&lt;br /&gt;
One particularly useful design is a &amp;quot;passthrough&amp;quot; or &amp;quot;intercept&amp;quot; style, with both male and female USB-C ports.&lt;br /&gt;
This design is more versatile in case you want to reuse it in other projects, and also enables you to connect to the PineNote via UART and USB at the same time.&lt;br /&gt;
An example of this product can be found [https://pmdway.com/products/usb-3-1-type-c-male-to-female-breakout-test-board here], although you are encouraged to shop around for cheaper options.&lt;br /&gt;
If you're fine with a bit more soldering, there is a very cheap one [https://www.ebay.com/itm/275407037613 here].&lt;br /&gt;
&lt;br /&gt;
Similarly, there are many USB-UART adapter designs available.&lt;br /&gt;
These devices plug into your computer and expose a number of pins themselves, connecting to specific pins on the breakout board with jump wires.&lt;br /&gt;
It is important to get a 3.3V model, or at least a model with the option of 3.3V, as a 5V model might fry the PineNote.&lt;br /&gt;
[https://pmdway.com/products/usb-to-ttl-serial-cp2104-6-pin-converter-module Here] is one example with jump wires included, although you are again encouraged to shop around for alternatives.&lt;br /&gt;
&lt;br /&gt;
All other necessary components of our UART dongle are readily &amp;amp; cheaply available in many locations.&lt;br /&gt;
&lt;br /&gt;
=== Splicing resistors ===&lt;br /&gt;
&lt;br /&gt;
This is the only difficult part of the whole process.&lt;br /&gt;
Your goal is to create a Y-shaped jump wire with 1,000 Ohm through-hole resistors spliced into each of the twin arms.&lt;br /&gt;
The solitary leg will connect to a 3.3V source on your USB-UART adapter.&lt;br /&gt;
The twin arms will connect to the configuration channel pins on your USB-C breakout board.&lt;br /&gt;
These are called pull-up resistors, and you can read a nice introduction to their purpose [https://www.electronics-tutorials.ws/logic/pull-up-resistor.html here].&lt;br /&gt;
&lt;br /&gt;
For this project you'll need:&lt;br /&gt;
# A soldering iron with solder&lt;br /&gt;
# Wire cutters &amp;amp; strippers&lt;br /&gt;
# 2x jumper wires, male/female as compatible with your board designs&lt;br /&gt;
# 2x 1,000 Ohm through-hole resistors&lt;br /&gt;
# Electrical tape or heat shrink wrap&lt;br /&gt;
&lt;br /&gt;
Consider buying extra jumper wires and resistors in case you mess up.&lt;br /&gt;
Also double-check that you have 1K resistors with [https://resistorcolorcodecalc.com/ this color code calculator].&lt;br /&gt;
Although the PineNote UART schematic says to use 10K Ohm resistors, community member talpadk experimented and found 1K is more appropriate.&lt;br /&gt;
Assemble your Y-cable as follows:&lt;br /&gt;
# Graft one jump wire onto the other to form a Y shape using [https://www.youtube.com/watch?v=KpiEfuhPqew this] technique, ensuring solitary leg end is compatible with your USB-UART adapter&lt;br /&gt;
# Splice resistors into the twin arms using [https://www.youtube.com/watch?v=RMgMVqqjPZ0 this] technique&lt;br /&gt;
# Splice remaining jump wire onto the ends of the resistors, ensuring ends are compatible with your USB-C breakout board&lt;br /&gt;
# Cover all exposed wire &amp;amp; resistors with electrical tape or heat shrink wrap&lt;br /&gt;
&lt;br /&gt;
=== Assembly ===&lt;br /&gt;
&lt;br /&gt;
Once you have acquired all necessary components, assemble the UART dongle as follows:&lt;br /&gt;
# Connect a jump wire from the GND pin on the USB-UART adapter to any one of the four GND pins on the USB-C breakout board (A1, A12, B1, or B12)&lt;br /&gt;
# Connect a jump wire from the RXD pin on the USB-UART adapter to the SBU1 pin on the USB-C breakout board (A8)&lt;br /&gt;
# Connect a jump wire from the TXD pin on the USB-UART adapter to the SBU2 pin on the USB-C breakout board (B8)&lt;br /&gt;
# Connect your Y-shaped jump wire from the 3.3V source pin on the USB-UART adapter to the CC1 and CC2 pins on the USB-C breakout board (A5 and B5)&lt;br /&gt;
# Wrap all metal connectors in electrical tape or heat shrink to prevent accidental shorts&lt;br /&gt;
&lt;br /&gt;
Be '''very certain''' of your connections for the 3.3V source, as there is a real risk of irreparably frying your PineNote if they're wrong!&lt;br /&gt;
Especially be sure you are connecting to a 3.3V source and not a 5V source.&lt;br /&gt;
&lt;br /&gt;
Note that if you mix up the TX/RX pins, it will still work but the USB-C breakout board will just plug into the PineNote upside down.&lt;br /&gt;
You can therefore choose which orientation you want by swapping the TX/RX pin connections.&lt;br /&gt;
&lt;br /&gt;
== Using UART ==&lt;br /&gt;
&lt;br /&gt;
First, use your UART dongle to physically connect your PineNote to your computer:&lt;br /&gt;
# Plug the USB-UART adapter into one of your computer's USB ports&lt;br /&gt;
# Plug the USB-C breakout board into the USB-C port on the bottom of your PineNote; the orientation matters, so try both and remember which one works&lt;br /&gt;
&lt;br /&gt;
Once the hardware is connected, set up your computer's software as follows:&lt;br /&gt;
# Install [https://www.gnu.org/software/screen/ GNU Screen] (or [https://askubuntu.com/q/40959 some other option], but the instructions below are written for &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt;)&lt;br /&gt;
# Identify the USB-UART adapter in your &amp;lt;code&amp;gt;/dev&amp;lt;/code&amp;gt; directory by running &amp;lt;code&amp;gt;ls /dev&amp;lt;/code&amp;gt; with it plugged in, unplugging it, then again running &amp;lt;code&amp;gt;ls /dev&amp;lt;/code&amp;gt; and seeing what changes; it is likely to be called &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;&lt;br /&gt;
# In a terminal window, run &amp;lt;code&amp;gt;screen -L /dev/ttyUSB0 1500000&amp;lt;/code&amp;gt; (you may need to run this as sudo depending on your user's permissions; on most Linux distributions you need to be in the &amp;lt;code&amp;gt;dialout&amp;lt;/code&amp;gt; usergroup)&lt;br /&gt;
&lt;br /&gt;
Once the software is set up, power-cycle your PineNote; as the system boots you should see text appearing in your terminal window.&lt;br /&gt;
You can exit the screen session with &amp;lt;code&amp;gt;ctrl+a k&amp;lt;/code&amp;gt; then pressing &amp;lt;code&amp;gt;y&amp;lt;/code&amp;gt; to confirm.&lt;br /&gt;
The &amp;lt;code&amp;gt;screen -L&amp;lt;/code&amp;gt; flag outputs a text log of the session to the current working directory, probably called &amp;lt;code&amp;gt;screenlog.0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Troubleshooting ====&lt;br /&gt;
&lt;br /&gt;
If you don't see any text in your terminal as the PineNote boots, or the text is garbled, try the following:&lt;br /&gt;
* Ensure your GND, RX and TX jump wires are connected to the correct pins on both the USB-UART adapter and the USB-C breakout board&lt;br /&gt;
* Connect your USB-C breakout board to your PineNote in the opposite orientation&lt;br /&gt;
* Run the screen command as sudo in case your user doesn't have appropriate permissions&lt;br /&gt;
* Ensure you are setting the baud rate in the &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt; command to 1500000 (1.5 million)&lt;br /&gt;
&lt;br /&gt;
== USB passthrough ==&lt;br /&gt;
&lt;br /&gt;
If your USB-C breakout board has a passthrough/intercept design, you can connect to your PineNote over USB and UART at the same time.&lt;br /&gt;
This can be useful when you're doing development work on the PineNote boot process so you don't have to continually reconnect cables.&lt;br /&gt;
You'll need a USB-A to USB-C cable, connecting directly from your computer's USB-A hub to your USB-C breakout board's female USB-C port.&lt;br /&gt;
It's important to connect directly from USB-A, without any intermediate USB-C components.&lt;br /&gt;
Note that connecting a live USB cable to your USB-C breakout board in this way dramatically increases the danger of frying your PineNote with a short, so you should only do this if all connectors are safely wrapped in electrical tape.&lt;br /&gt;
&lt;br /&gt;
[[Category:PineNote]]&lt;/div&gt;</summary>
		<author><name>Ahelwer</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PineNote_Development/UART&amp;diff=20880</id>
		<title>PineNote Development/UART</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PineNote_Development/UART&amp;diff=20880"/>
		<updated>2023-10-13T21:47:29Z</updated>

		<summary type="html">&lt;p&gt;Ahelwer: Began documenting process of splicing resistors into wires&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Pinenote-uart-dongle.jpeg|thumb|Basic non-stock PineNote UART dongle]]&lt;br /&gt;
&lt;br /&gt;
This page contains information on creating and using a [https://en.wikipedia.org/wiki/Universal_asynchronous_receiver-transmitter UART] dongle for the [[PineNote]].&lt;br /&gt;
The PineNote was shipped with a compatible UART dongle, but replacements are not available to order in case of loss or hardware fault.&lt;br /&gt;
Thankfully it is not difficult to make your own from easily-acquired components and a small bit of soldering.&lt;br /&gt;
Fear not if you've never soldered anything before!&lt;br /&gt;
This serves as an excellent first soldering project.&lt;br /&gt;
Borrow the tools from a friend or a local hackerspace or tool library.&lt;br /&gt;
&lt;br /&gt;
A PineNote UART dongle enables you to:&lt;br /&gt;
# Interact with the system boot menu&lt;br /&gt;
# Read system events in real time as the PineNote is used&lt;br /&gt;
# Fix the PineNote without opening the case if something goes wrong while [[PineNote Development/Flashing|flashing it]]&lt;br /&gt;
&lt;br /&gt;
Since the PineNote is an embedded system, interfacing with it during boot is more complicated than with an ordinary computer.&lt;br /&gt;
The UART dongle enables you to do this.&lt;br /&gt;
&lt;br /&gt;
The PineNote factory firmware runs UART at a baud rate of 1500000 bps, 8 data bits, 1 stop bit, no parity and no flow control.&lt;br /&gt;
The process by which the PineNote design was modified to include closed-case UART is documented [[PineNote/Hardware Changes/Closed Case UART|here]].&lt;br /&gt;
&lt;br /&gt;
== Stock dongle ==&lt;br /&gt;
&lt;br /&gt;
The stock UART dongle included with the PineNote was a simple device plugging directly into the PineNote's USB-C port.&lt;br /&gt;
The dongle exposed a female USB-C port, which the user plugged into to get UART access.&lt;br /&gt;
This design unfortunately ruled out passthrough USB connections, where the user connects to the PineNote via UART and USB simultaneously.&lt;br /&gt;
The dongle is not currently available for purchase.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Pinenote-stock-uart-dongle-front.jpg|Front&lt;br /&gt;
Pinenote-stock-uart-dongle-back.jpg|Back&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Creating a dongle ==&lt;br /&gt;
&lt;br /&gt;
A PineNote UART dongle has the following components:&lt;br /&gt;
# A USB-C breakout board with a male connector exposing the 24 pins of the PineNote's USB-C port&lt;br /&gt;
# A USB-UART adapter, to plug into a USB port of the computer you'll use to interface with the PineNote&lt;br /&gt;
# [https://en.wikipedia.org/wiki/Jump_wire Jump wires] to connect specific breakout board pins to pins on the USB-UART adapter&lt;br /&gt;
# Two 1,000 Ohm resistors to splice into the jump wires&lt;br /&gt;
# Electrical tape or heat shrink to wrap connectors and prevent shorts&lt;br /&gt;
&lt;br /&gt;
The PineNote's internal UART system is documented in [https://files.pine64.org/doc/PineNote/PineNote_USB-C_Console_UART_breakout_board_schematic_v1.0_20210903.pdf this schematic].&lt;br /&gt;
The purpose of all 24 USB-C pins is documented [https://en.wikipedia.org/wiki/USB-C#Receptacles on the USB-C Wikipedia page].&lt;br /&gt;
We are interested in three sets of pins:&lt;br /&gt;
# The SBU1 (A8) and SBU2 (B8) side band use pins&lt;br /&gt;
# The CC1 (A5) and CC2 (B5) configuration channel pins&lt;br /&gt;
# The GND [https://en.wikipedia.org/wiki/Ground_(electricity) ground return] pins (A1, A12, B1, and B12)&lt;br /&gt;
&lt;br /&gt;
In the PineNote UART schematic you can see (on the bottom right diagram labeled &amp;lt;code&amp;gt;USB_TYPEC_Male&amp;lt;/code&amp;gt;) the side band pins are given the labels &amp;lt;code&amp;gt;UART2_TX_SUB1&amp;lt;/code&amp;gt; for A8 and &amp;lt;code&amp;gt;UART2_RX_SUB2&amp;lt;/code&amp;gt; for B8.&lt;br /&gt;
The first (TX) is used for transmitting data and the second (RX) is used for receiving data, from the perspective of the PineNote.&lt;br /&gt;
Note also the configuration channel pins labeled &amp;lt;code&amp;gt;TYPEC_CC1&amp;lt;/code&amp;gt; for A5 and &amp;lt;code&amp;gt;TYPECC_CC2&amp;lt;/code&amp;gt; for B5.&lt;br /&gt;
These pins are used to signal to the PineNote that a UART dongle is present.&lt;br /&gt;
The diagram shows they must be connected to a 3.3V source, mediated by resistors.&lt;br /&gt;
&lt;br /&gt;
=== Buying components ===&lt;br /&gt;
&lt;br /&gt;
There are many possible USB-C breakout board designs available for purchase online.&lt;br /&gt;
One particularly useful design is a &amp;quot;passthrough&amp;quot; or &amp;quot;intercept&amp;quot; style, with both male and female USB-C ports.&lt;br /&gt;
This design is more versatile in case you want to reuse it in other projects, and also enables you to connect to the PineNote via UART and USB at the same time.&lt;br /&gt;
An example of this product can be found [https://pmdway.com/products/usb-3-1-type-c-male-to-female-breakout-test-board here], although you are encouraged to shop around for cheaper options.&lt;br /&gt;
If you're fine with a bit more soldering, there is a very cheap one [https://www.ebay.com/itm/275407037613 here].&lt;br /&gt;
&lt;br /&gt;
Similarly, there are many USB-UART adapter designs available.&lt;br /&gt;
These devices plug into your computer and expose a number of pins themselves, connecting to specific pins on the breakout board with jump wires.&lt;br /&gt;
It is important to get a 3.3V model, or at least a model with the option of 3.3V, as a 5V model might fry the PineNote.&lt;br /&gt;
[https://pmdway.com/products/usb-to-ttl-serial-cp2104-6-pin-converter-module Here] is one example with jump wires included, although you are again encouraged to shop around for alternatives.&lt;br /&gt;
&lt;br /&gt;
=== Splicing resistors ===&lt;br /&gt;
&lt;br /&gt;
This is the only difficult part of the whole process.&lt;br /&gt;
You will need to splice 1k Ohm resistors into the jump wires you connect to the configuration channel pins.&lt;br /&gt;
For this you'll need:&lt;br /&gt;
# A soldering iron with solder&lt;br /&gt;
# Wire cutters &amp;amp; strippers&lt;br /&gt;
# 2 female-ended&lt;br /&gt;
TBD&lt;br /&gt;
&lt;br /&gt;
=== Assembly ===&lt;br /&gt;
&lt;br /&gt;
Once you have acquired all necessary components, assemble the UART dongle as follows:&lt;br /&gt;
# Connect a jump wire from the GND pin on the USB-UART adapter to any one of the four GND pins on the USB-C breakout board (A1, A12, B1, or B12)&lt;br /&gt;
# Connect a jump wire from the RXD pin on the USB-UART adapter to the &amp;lt;code&amp;gt;UART2_TX_SUB2&amp;lt;/code&amp;gt; pin on the USB-C breakout board (SBU1 aka A8)&lt;br /&gt;
# Connect a jump wire from the TXD pin on the USB-UART adapter to the &amp;lt;code&amp;gt;UART2_RX_SUB2&amp;lt;/code&amp;gt; pin on the USB-C breakout board (SBU2 aka B8)&lt;br /&gt;
&lt;br /&gt;
Note that if you mix up the TX/RX pins, it will still work but the USB-C breakout board will just plug into the PineNote upside down.&lt;br /&gt;
You can therefore choose which orientation you want by swapping the TX/RX pin connections.&lt;br /&gt;
&lt;br /&gt;
Test that your system works by following the use instructions down below.&lt;br /&gt;
Be very careful not to touch or short the pins while current is flowing through them - this can damage your device!&lt;br /&gt;
Once you have confirmed that your UART dongle works, wrap all metal connectors in electrical tape to prevent accidental shorts.&lt;br /&gt;
&lt;br /&gt;
== Using UART ==&lt;br /&gt;
&lt;br /&gt;
First, use your UART dongle to physically connect your PineNote to your computer:&lt;br /&gt;
# Plug the USB-UART adapter into one of your computer's USB ports&lt;br /&gt;
# Plug the USB-C breakout board into the USB-C port on the bottom of your PineNote; the orientation matters, so try both and remember which one works&lt;br /&gt;
&lt;br /&gt;
Once the hardware is connected, set up your computer's software as follows:&lt;br /&gt;
# Install [https://www.gnu.org/software/screen/ GNU Screen] (or [https://askubuntu.com/q/40959 some other option], but the instructions below are written for &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt;)&lt;br /&gt;
# Identify the USB-UART adapter in your &amp;lt;code&amp;gt;/dev&amp;lt;/code&amp;gt; directory by running &amp;lt;code&amp;gt;ls /dev&amp;lt;/code&amp;gt; with it plugged in, unplugging it, then again running &amp;lt;code&amp;gt;ls /dev&amp;lt;/code&amp;gt; and seeing what changes; it is likely to be called &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;&lt;br /&gt;
# In a terminal window, run &amp;lt;code&amp;gt;screen -L /dev/ttyUSB0 1500000&amp;lt;/code&amp;gt; (you may need to run this as sudo depending on your user's permissions; on most Linux distributions you need to be in the &amp;lt;code&amp;gt;dialout&amp;lt;/code&amp;gt; usergroup)&lt;br /&gt;
&lt;br /&gt;
Once the software is set up, power-cycle your PineNote; as the system boots you should see text appearing in your terminal window.&lt;br /&gt;
You can exit the screen session with &amp;lt;code&amp;gt;ctrl+a k&amp;lt;/code&amp;gt; then pressing &amp;lt;code&amp;gt;y&amp;lt;/code&amp;gt; to confirm.&lt;br /&gt;
The &amp;lt;code&amp;gt;screen -L&amp;lt;/code&amp;gt; flag outputs a text log of the session to the current working directory, probably called &amp;lt;code&amp;gt;screenlog.0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Troubleshooting ====&lt;br /&gt;
&lt;br /&gt;
If you don't see any text in your terminal as the PineNote boots, or the text is garbled, try the following:&lt;br /&gt;
* Ensure your GND, RX and TX jump wires are connected to the correct pins on both the USB-UART adapter and the USB-C breakout board&lt;br /&gt;
* Connect your USB-C breakout board to your PineNote in the opposite orientation&lt;br /&gt;
* Run the screen command as sudo in case your user doesn't have appropriate permissions&lt;br /&gt;
* Ensure you are setting the baud rate in the &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt; command to 1500000 (1.5 million)&lt;br /&gt;
&lt;br /&gt;
== USB passthrough ==&lt;br /&gt;
&lt;br /&gt;
If your USB-C breakout board has a passthrough/intercept design, you can connect to your PineNote over USB and UART at the same time.&lt;br /&gt;
This can be useful when you're doing development work on the PineNote boot process so you don't have to continually reconnect cables.&lt;br /&gt;
You'll need a USB-A to USB-C cable, connecting directly from your computer's USB-A hub to your USB-C breakout board's female USB-C port.&lt;br /&gt;
It's important to connect directly from USB-A, without any intermediate USB-C components.&lt;br /&gt;
Note that connecting a live USB cable to your USB-C breakout board in this way dramatically increases the danger of frying your PineNote with a short, so you should only do this if all connectors are safely wrapped in electrical tape.&lt;br /&gt;
&lt;br /&gt;
[[Category:PineNote]]&lt;/div&gt;</summary>
		<author><name>Ahelwer</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PineNote_Development/UART&amp;diff=20878</id>
		<title>PineNote Development/UART</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PineNote_Development/UART&amp;diff=20878"/>
		<updated>2023-10-12T21:18:10Z</updated>

		<summary type="html">&lt;p&gt;Ahelwer: /* Creating a dongle */ Added note about 3.3V UART&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Pinenote-uart-dongle.jpeg|thumb|Basic non-stock PineNote UART dongle]]&lt;br /&gt;
&lt;br /&gt;
This page contains information on creating and using a [https://en.wikipedia.org/wiki/Universal_asynchronous_receiver-transmitter UART] dongle for the [[PineNote]].&lt;br /&gt;
The PineNote was shipped with a compatible UART dongle, but replacements are not available to order in case of loss or hardware fault.&lt;br /&gt;
Thankfully it is not difficult to make your own from easily-acquired components.&lt;br /&gt;
&lt;br /&gt;
A PineNote UART dongle enables you to:&lt;br /&gt;
# Interact with the system boot menu&lt;br /&gt;
# Read system events in real time as the PineNote is used&lt;br /&gt;
# Fix the PineNote without opening the case if something goes wrong while [[PineNote Development/Flashing|flashing it]]&lt;br /&gt;
&lt;br /&gt;
Since the PineNote is an embedded system, interfacing with it during boot is more complicated than with an ordinary computer.&lt;br /&gt;
The UART dongle enables you to do this.&lt;br /&gt;
&lt;br /&gt;
The PineNote factory firmware runs UART at a baud rate of 1500000 bps, 8 data bits, 1 stop bit, no parity and no flow control.&lt;br /&gt;
The process by which the PineNote design was modified to include closed-case UART is documented [[PineNote/Hardware Changes/Closed Case UART|here]].&lt;br /&gt;
&lt;br /&gt;
== Stock dongle ==&lt;br /&gt;
&lt;br /&gt;
The stock UART dongle included with the PineNote was a simple device plugging directly into the PineNote's USB-C port.&lt;br /&gt;
The dongle exposed a female USB-C port, which the user plugged into to get UART access.&lt;br /&gt;
This design unfortunately ruled out passthrough USB connections, where the user connects to the PineNote via UART and USB simultaneously.&lt;br /&gt;
The dongle is not currently available for purchase.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Pinenote-stock-uart-dongle-front.jpg|Front&lt;br /&gt;
Pinenote-stock-uart-dongle-back.jpg|Back&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Creating a dongle ==&lt;br /&gt;
&lt;br /&gt;
A PineNote UART dongle has four components:&lt;br /&gt;
# A USB-C breakout board with a male connector exposing the 24 pins of the PineNote's female USB-C port (located on the bottom of the device)&lt;br /&gt;
# A USB-UART adapter, to plug into a USB port of the computer you'll use to interface with the PineNote&lt;br /&gt;
# [https://en.wikipedia.org/wiki/Jump_wire Jump wires] to connect specific breakout board pins to pins on the USB-UART adapter&lt;br /&gt;
# Electrical tape to wrap connectors and prevent shorts&lt;br /&gt;
&lt;br /&gt;
The PineNote's internal UART system is documented in [https://files.pine64.org/doc/PineNote/PineNote_USB-C_Console_UART_breakout_board_schematic_v1.0_20210903.pdf this schematic].&lt;br /&gt;
USB-C pins are documented [https://en.wikipedia.org/wiki/USB-C#Specifications on the USB-C Wikipedia page]; of the 24 pins, two are designated for &amp;quot;side band&amp;quot; use.&lt;br /&gt;
These pins are labeled SBU1 (A8) and SBU2 (B8).&lt;br /&gt;
In the PineNote UART schematic you can see (on the bottom right diagram) these pins are given the label &amp;lt;code&amp;gt;UART2_TX_SUB1&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;UART2_RX_SUB2&amp;lt;/code&amp;gt; respectively.&lt;br /&gt;
The first (TX) is used for transmitting data and the second (RX) is used for receiving data.&lt;br /&gt;
These are the pins which must be exposed by the breakout board.&lt;br /&gt;
&lt;br /&gt;
There are many possible USB-C breakout board designs available for purchase online.&lt;br /&gt;
One particularly useful design is a &amp;quot;passthrough&amp;quot; or &amp;quot;intercept&amp;quot; style, with both male and female USB-C ports.&lt;br /&gt;
This design is more versatile in case you want to reuse it in other projects, and also enables you to connect to the PineNote via UART and USB at the same time.&lt;br /&gt;
An example of this product can be found [https://pmdway.com/products/usb-3-1-type-c-male-to-female-breakout-test-board here], although you are encouraged to shop around for cheaper options.&lt;br /&gt;
&lt;br /&gt;
Similarly, there are many USB-UART adapter designs available.&lt;br /&gt;
These devices plug into your computer and expose a number of pins themselves, connecting to specific pins on the breakout board with jump wires.&lt;br /&gt;
It is important to get a 3.3V model, or at least a model with the option of 3.3V, as a 5V model might fry the PineNote.&lt;br /&gt;
[https://pmdway.com/products/usb-to-ttl-serial-cp2104-6-pin-converter-module Here] is one example with jump wires included, although you are again encouraged to shop around for alternatives.&lt;br /&gt;
&lt;br /&gt;
Once you have acquired all necessary components, assemble the UART dongle as follows:&lt;br /&gt;
# Connect a jump wire from the GND ([https://en.wikipedia.org/wiki/Ground_(electricity) ground]) pin on the USB-UART adapter to any one of the four GND pins on the USB-C breakout board (A1, A12, B1, or B12)&lt;br /&gt;
# Connect a jump wire from the RXD pin on the USB-UART adapter to the &amp;lt;code&amp;gt;UART2_TX_SUB2&amp;lt;/code&amp;gt; pin on the USB-C breakout board (SBU1 aka A8)&lt;br /&gt;
# Connect a jump wire from the TXD pin on the USB-UART adapter to the &amp;lt;code&amp;gt;UART2_RX_SUB2&amp;lt;/code&amp;gt; pin on the USB-C breakout board (SBU2 aka B8)&lt;br /&gt;
&lt;br /&gt;
Note that if you mix up the TX/RX pins, it will still work but the USB-C breakout board will just plug into the PineNote upside down.&lt;br /&gt;
You can therefore choose which orientation you want by swapping the TX/RX pin connections.&lt;br /&gt;
&lt;br /&gt;
Test that your system works by following the use instructions down below.&lt;br /&gt;
Be very careful not to touch or short the pins while current is flowing through them - this can damage your device!&lt;br /&gt;
Once you have confirmed that your UART dongle works, wrap all metal connectors in electrical tape to prevent accidental shorts.&lt;br /&gt;
&lt;br /&gt;
== Using UART ==&lt;br /&gt;
&lt;br /&gt;
First, use your UART dongle to physically connect your PineNote to your computer:&lt;br /&gt;
# Plug the USB-UART adapter into one of your computer's USB ports&lt;br /&gt;
# Plug the USB-C breakout board into the USB-C port on the bottom of your PineNote; the orientation matters, so try both and remember which one works&lt;br /&gt;
&lt;br /&gt;
Once the hardware is connected, set up your computer's software as follows:&lt;br /&gt;
# Install [https://www.gnu.org/software/screen/ GNU Screen] (or [https://askubuntu.com/q/40959 some other option], but the instructions below are written for &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt;)&lt;br /&gt;
# Identify the USB-UART adapter in your &amp;lt;code&amp;gt;/dev&amp;lt;/code&amp;gt; directory by running &amp;lt;code&amp;gt;ls /dev&amp;lt;/code&amp;gt; with it plugged in, unplugging it, then again running &amp;lt;code&amp;gt;ls /dev&amp;lt;/code&amp;gt; and seeing what changes; it is likely to be called &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;&lt;br /&gt;
# In a terminal window, run &amp;lt;code&amp;gt;screen -L /dev/ttyUSB0 1500000&amp;lt;/code&amp;gt; (you may need to run this as sudo depending on your user's permissions; on most Linux distributions you need to be in the &amp;lt;code&amp;gt;dialout&amp;lt;/code&amp;gt; usergroup)&lt;br /&gt;
&lt;br /&gt;
Once the software is set up, power-cycle your PineNote; as the system boots you should see text appearing in your terminal window.&lt;br /&gt;
You can exit the screen session with &amp;lt;code&amp;gt;ctrl+a k&amp;lt;/code&amp;gt; then pressing &amp;lt;code&amp;gt;y&amp;lt;/code&amp;gt; to confirm.&lt;br /&gt;
The &amp;lt;code&amp;gt;screen -L&amp;lt;/code&amp;gt; flag outputs a text log of the session to the current working directory, probably called &amp;lt;code&amp;gt;screenlog.0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Troubleshooting ====&lt;br /&gt;
&lt;br /&gt;
If you don't see any text in your terminal as the PineNote boots, or the text is garbled, try the following:&lt;br /&gt;
* Ensure your GND, RX and TX jump wires are connected to the correct pins on both the USB-UART adapter and the USB-C breakout board&lt;br /&gt;
* Connect your USB-C breakout board to your PineNote in the opposite orientation&lt;br /&gt;
* Run the screen command as sudo in case your user doesn't have appropriate permissions&lt;br /&gt;
* Ensure you are setting the baud rate in the &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt; command to 1500000 (1.5 million)&lt;br /&gt;
&lt;br /&gt;
== USB passthrough ==&lt;br /&gt;
&lt;br /&gt;
If your USB-C breakout board has a passthrough/intercept design, you can connect to your PineNote over USB and UART at the same time.&lt;br /&gt;
This can be useful when you're doing development work on the PineNote boot process so you don't have to continually reconnect cables.&lt;br /&gt;
You'll need a USB-A to USB-C cable, connecting directly from your computer's USB-A hub to your USB-C breakout board's female USB-C port.&lt;br /&gt;
It's important to connect directly from USB-A, without any intermediate USB-C components.&lt;br /&gt;
Note that connecting a live USB cable to your USB-C breakout board in this way dramatically increases the danger of frying your PineNote with a short, so you should only do this if all connectors are safely wrapped in electrical tape.&lt;br /&gt;
&lt;br /&gt;
[[Category:PineNote]]&lt;/div&gt;</summary>
		<author><name>Ahelwer</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PineNote_Development/Flashing&amp;diff=20877</id>
		<title>PineNote Development/Flashing</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PineNote_Development/Flashing&amp;diff=20877"/>
		<updated>2023-10-12T20:52:30Z</updated>

		<summary type="html">&lt;p&gt;Ahelwer: /* Entering Maskrom/Rockusb Mode */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Under construction}}&lt;br /&gt;
&lt;br /&gt;
{{Info|These instructions are directed towards experienced developers only!}}&lt;br /&gt;
&lt;br /&gt;
This page contains information on flashing software to the [https://wiki.pine64.org/wiki/PineNote PineNote].&lt;br /&gt;
&lt;br /&gt;
Currently, software can be flashed using rkdeveloptool or from the factory Android installation (UART shell, adb, or fastboot).&lt;br /&gt;
&lt;br /&gt;
== Getting &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
Most flashing operations on the PineNote are done through &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt;, a command line utility built on libusb.&lt;br /&gt;
PINE64 maintains its own fork [https://gitlab.com/pine64-org/quartz-bsp/rkdeveloptool here] that you will need to get.&lt;br /&gt;
The repo's README contains a list of dependencies (libusb 1.0) and instructions for building the tool.&lt;br /&gt;
&lt;br /&gt;
Installing (not just building) &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; will configure PAM to elevate privileges where necessary on your system; you can configure this manually as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo cp 99-rk-rockusb.rules /etc/udev/rules.d/&lt;br /&gt;
sudo udevadm control --reload&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Entering Maskrom/Rockusb mode ==&lt;br /&gt;
&lt;br /&gt;
Interfacing with the PineNote over USB using &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; requires first booting the PineNote into [http://opensource.rock-chips.com/wiki_Rockusb an alternative operating mode] called Maskrom or Rockusb mode.&lt;br /&gt;
&lt;br /&gt;
=== Possible Methods ===&lt;br /&gt;
&lt;br /&gt;
There are three possible methods of entering Maskrom/Rockusb mode:&lt;br /&gt;
&lt;br /&gt;
==== Hardware Magnet Switch ====&lt;br /&gt;
&lt;br /&gt;
# Connect the PineNote to your computer via USB and boot the PineNote into Android&lt;br /&gt;
# Locate &amp;amp; identify the small circular marking on the back of the PineNote, in the top right quadrant; have the PineNote pen close at hand, or any other small magnet&lt;br /&gt;
# Hold the PineNote power button to bring up the reboot/shutdown menu; select reboot, then place the PineNote face down with the &amp;quot;eraser&amp;quot; end of the pen (or your magnet) resting on the small circular marking&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Download mode.jpeg|Pen method&lt;br /&gt;
PineNoteMagnetOnBack.jpg|Magnet method&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== U-Boot ====&lt;br /&gt;
This method requires a [[PineNote Development/UART|UART dongle for the PineNote]] with passthrough allowing simultaneous UART &amp;amp; USB connections.&lt;br /&gt;
It is nice because you can easily switch back &amp;amp; forth between U-Boot and Rockusb without having to physically manipulate the PineNote or its connectors; this is especially helpful when trying to develop U-Boot.&lt;br /&gt;
&lt;br /&gt;
# Interrupt the U-Boot startup using ''ctrl-c'' (while attached using an UART dongle)&lt;br /&gt;
# While in U-Boot use the command &amp;lt;code&amp;gt;rockusb 0 mmc 0&amp;lt;/code&amp;gt; to start Rockusb mode.&lt;br /&gt;
&lt;br /&gt;
==== Shorting Test Points ====&lt;br /&gt;
&lt;br /&gt;
If the bootloader is broken/corrupted, you cannot get to Maskrom without opening up the device (it can be opened using spudger and a bit of patience).&lt;br /&gt;
&lt;br /&gt;
Once inside, short TP1301 (GND) and TP1302 (eMMC_D0/FLASH_D0) with a small tweezers, this is how it looks on board view (credit to Caleb):&lt;br /&gt;
&lt;br /&gt;
[[File:PineNote_Maskrom_TP.png|500px]]&lt;br /&gt;
&lt;br /&gt;
=== Success ===&lt;br /&gt;
&lt;br /&gt;
No matter what approach you take, you can tell whether you succeeded by running the &amp;lt;code&amp;gt;lsusb&amp;lt;/code&amp;gt; command on your computer:&lt;br /&gt;
* If you find the entry &amp;lt;code&amp;gt;2207:0018 Fuzhou Rockchip Electronics Company rk3566_eink&amp;lt;/code&amp;gt; in the list, the process did not succeed; reboot and retry&lt;br /&gt;
* The entry &amp;lt;code&amp;gt;2207:350a Fuzhou Rockchip Electronics Company&amp;lt;/code&amp;gt; will occur if you detach then reattach the USB-C cable while the PineNote is in Maskrom/Rockusb mode; &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; won't work and you will have to do a hard reboot (hold down power button for 30 seconds to shutdown)&lt;br /&gt;
* If you find the entry &amp;lt;code&amp;gt;2207:350a Fuzhou Rockchip Electronics Company USB download gadget&amp;lt;/code&amp;gt; then the process succeeded&lt;br /&gt;
&lt;br /&gt;
You can also look at the output of the &amp;lt;code&amp;gt;rkdeveloptool list&amp;lt;/code&amp;gt; command:&lt;br /&gt;
* If this prints out &amp;lt;code&amp;gt;No devices in rockusb mode found&amp;lt;/code&amp;gt; the process did not succeed; reboot and retry&lt;br /&gt;
* If this prints out &amp;lt;code&amp;gt;DevNo=1 Vid=0x2207,Pid=0x350a,LocationID=305 Maskrom&amp;lt;/code&amp;gt; then you probably detached/reattached the USB-C cable while in Maskrom/Rockusb mode and &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; won't work; perform a hard reboot to fix&lt;br /&gt;
* If this prints out &amp;lt;code&amp;gt;DevNo=1 Vid=0x2207,Pid=0x350a,LocationID=303 Loader&amp;lt;/code&amp;gt; then the process succeeded&lt;br /&gt;
&lt;br /&gt;
=== Exiting mode ===&lt;br /&gt;
&lt;br /&gt;
You can boot the PineNote back into its normal mode of operation by powercycling the PineNote with its hardware power switch, or running the &amp;lt;code&amp;gt;rkdeveloptool reboot&amp;lt;/code&amp;gt; command.&lt;br /&gt;
If you used the magnetic switch method be sure to remove the pen/magnet before rebooting.&lt;br /&gt;
&lt;br /&gt;
== Backup ==&lt;br /&gt;
&lt;br /&gt;
A backup of the content of the internal eMMC before anything gets messed up is '''mandatory'''.&lt;br /&gt;
&lt;br /&gt;
Especially the ''waveform'' partition contains data '''unique''' to your PineNote and is a prime candidate for backup.&lt;br /&gt;
&lt;br /&gt;
Other partitions like U-Boot (need for any operation of the device) or the un-partitioned space at the beginning containing the GPT partition table (and presumably the VCOM setting for the e-ink display and maybe device mac addresses) contain data you may also wish to backup.&lt;br /&gt;
&lt;br /&gt;
Depending of your personal level of data hoarder you may want to backup more than this or even just everything (the large ''userdata'' partition is supposed to be able to be repopulated as empty space by Android)&lt;br /&gt;
&lt;br /&gt;
In any case it is easier to restore/extract data from a backup than not having one if you need one.&lt;br /&gt;
&lt;br /&gt;
This process was developed by Dorian Rudolph, originally described [https://github.com/DorianRudolph/pinenotes here].&lt;br /&gt;
&lt;br /&gt;
=== List partitions ===&lt;br /&gt;
&lt;br /&gt;
First, run &amp;lt;code&amp;gt;rkdeveloptool list-partitions&amp;lt;/code&amp;gt; to print out your PineNote's partitions to get an idea of what you're dealing with.&lt;br /&gt;
The stock PineNote has a fairly standard Android partition setup, including:&lt;br /&gt;
* uboot: the [https://en.wikipedia.org/wiki/Das_U-Boot U-Boot] embedded systems bootloader&lt;br /&gt;
* trust: secrets that can be encrypted with a key stored in the [https://en.wikipedia.org/wiki/Trusted_Platform_Module TPM]&lt;br /&gt;
* waveform: important files controlling the e-ink screen's state changes&lt;br /&gt;
* misc: miscellaneous files needed by the firmware&lt;br /&gt;
* dtbo: [https://en.wikipedia.org/wiki/Devicetree Device Tree Blob for Overlay], files describing the PineNote's hardware configuration&lt;br /&gt;
* vbmeta: data required for verified boot&lt;br /&gt;
* boot, security, recovery, backup, cache, metadata, super, logo, device&lt;br /&gt;
* userdata: the big one; this is where all your files are stored in the stock Android install&lt;br /&gt;
&lt;br /&gt;
=== Patch U-Boot ===&lt;br /&gt;
&lt;br /&gt;
Before we can back up our partitions, we have a problem to solve.&lt;br /&gt;
The version of U-Boot installed on the stock PineNote contains a bug where it can't dump partitions beyond 32 MB (above that limit all bytes in the dump are just &amp;lt;code&amp;gt;0xCC&amp;lt;/code&amp;gt;), meaning the PineNote must be flashed with a fixed version of U-Boot before it is possible to take a backup of the larger partitions.&lt;br /&gt;
It is possible to extract and modify the U-Boot image from your PineNote if you're interested in some light reverse-engineering (following Dorian's notes), or you can simply download a patched U-Boot image directly [https://github.com/DorianRudolph/pinenotes/blob/main/static/uboot_patched.img here].&lt;br /&gt;
&lt;br /&gt;
Once you've acquired a patched U-Boot image, run:&lt;br /&gt;
# &amp;lt;code&amp;gt;rkdeveloptool read-partition uboot uboot_backup.img&amp;lt;/code&amp;gt;&lt;br /&gt;
# &amp;lt;code&amp;gt;rkdeveloptool write-partition uboot uboot_patched.img&amp;lt;/code&amp;gt;&lt;br /&gt;
# &amp;lt;code&amp;gt;rkdeveloptool reboot&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Taking the backup ===&lt;br /&gt;
&lt;br /&gt;
There is a second backup limit preventing dumping partitions larger than 2 GB, this time from &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt;.&lt;br /&gt;
This means if you have a large number of documents in the Android userdata partition they might not all make it into the backup.&lt;br /&gt;
If you don't have many documents (or don't care about losing them) this should not be a problem.&lt;br /&gt;
If you do have a lot of documents, workarounds include:&lt;br /&gt;
* A possible patch written by Thomas exists [https://github.com/tpwrules/nixos-pinenote/blob/96d2c9158edb9da59afcb952cc864fada18382f9/nix/rkdeveloptool/0001-fix-large-dumps.patch here] but has not yet been upstreamed; consider investigating how to get the patch tested &amp;amp; upstreamed, or just apply it to your own local copy of &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt;&lt;br /&gt;
* Use [https://github.com/talpadk/pinenote-backup this] Python script written by Visti Andresen to automatically backup your entire partition by splitting reads into 2 GB chunks&lt;br /&gt;
&lt;br /&gt;
See [https://github.com/m-weigand/pinenote-debian-recipes/releases/tag/v0.1 instructions on this artifact]. It will instruct you on extracting the rootfs into an empty ext4 partition. This can be done from Linux or Android. Further instructions on building your own rootfs [https://github.com/m-weigand/pinenote-debian-recipes can be found here].&lt;br /&gt;
&lt;br /&gt;
=== Using a user installed Linux ===&lt;br /&gt;
A Linux installed to the cache partition should be able to easily backup everything over WiFi or to a USB stick/disk using ''dd''.&lt;br /&gt;
&lt;br /&gt;
However the user would need to backup the cache partition themself (if they want that).&lt;br /&gt;
&lt;br /&gt;
And more importantly they would only be getting the backup ''after'' they started playing with the content of the eMMC.&lt;br /&gt;
&lt;br /&gt;
== Side-by-side setup ==&lt;br /&gt;
&lt;br /&gt;
It is possible to set up a partition for mainline development without disturbing the factory Android installation. This allows updating a mainline kernel, DTB, and initramfs over Wi-Fi until WiFi or USB OTG is working in mainline Linux.&lt;br /&gt;
&lt;br /&gt;
=== Without Repartitioning ===&lt;br /&gt;
&lt;br /&gt;
The recommended partition for this is &amp;lt;tt&amp;gt;mmcblk0p11&amp;lt;/tt&amp;gt; aka &amp;lt;tt&amp;gt;/cache&amp;lt;/tt&amp;gt;. It is large and already formatted as &amp;lt;tt&amp;gt;ext4&amp;lt;/tt&amp;gt;, so it is readable from U-Boot. Here are some general steps:&lt;br /&gt;
&lt;br /&gt;
# From the UART or adb shell, set up your chroot in &amp;lt;tt&amp;gt;/cache&amp;lt;/tt&amp;gt;. I used the Alpine Linux rootfs tarball.&lt;br /&gt;
# Copy in your kernel and DTB, using for example &amp;lt;tt&amp;gt;scp&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;wget&amp;lt;/tt&amp;gt; inside the chroot.&lt;br /&gt;
# Finally, create and boot an &amp;lt;code&amp;gt;extlinux.conf&amp;lt;/code&amp;gt; as described below.&lt;br /&gt;
&lt;br /&gt;
=== With Repartitioning ===&lt;br /&gt;
&lt;br /&gt;
It is possible to shrink the &amp;lt;tt&amp;gt;userdata&amp;lt;/tt&amp;gt; partition, and create a new partition at the end for use with mainline Linux. This provides much more space than &amp;lt;tt&amp;gt;cache&amp;lt;/tt&amp;gt;. However, because &amp;lt;tt&amp;gt;userdata&amp;lt;/tt&amp;gt; is formatted with &amp;lt;tt&amp;gt;f2fs&amp;lt;/tt&amp;gt;, and that filesystem cannot be shrunk, resizing the partition requires wiping &amp;lt;tt&amp;gt;userdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
# Back up any necessary files from userdata&lt;br /&gt;
# Boot to a mainline kernel from &amp;lt;tt&amp;gt;mmcblk0p11&amp;lt;/tt&amp;gt;, either using that partition as rootfs (see above), or using an initramfs with repartitioning tools&lt;br /&gt;
# Modify the partition table with your favorite tool, e.g. &amp;lt;tt&amp;gt;fdisk&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gdisk&amp;lt;/tt&amp;gt;, or &amp;lt;tt&amp;gt;parted&amp;lt;/tt&amp;gt;&lt;br /&gt;
# Reboot into &amp;lt;tt&amp;gt;fastboot&amp;lt;/tt&amp;gt; and wipe &amp;lt;tt&amp;gt;userdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# Reboot into Android, where you can now chroot in and install your favorite distribution to the new partition.&lt;br /&gt;
&lt;br /&gt;
== Using rkdeveloptool ==&lt;br /&gt;
&lt;br /&gt;
=== Building Downstream U-Boot ===&lt;br /&gt;
&lt;br /&gt;
While in maskrom mode, we need to have a u-boot to download onto the device for any of the other commands to work. To build you'll also need to install device-tree-compiler.&lt;br /&gt;
&lt;br /&gt;
You also need to install Python and pyelftools.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Note that rkbin is a &amp;amp;gt;5GB download!&amp;lt;/b&amp;gt; This will take some time to clone and process the deltas.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone -b quartz64 https://gitlab.com/pgwipeout/u-boot-rockchip.git&lt;br /&gt;
git clone -b rkbin https://github.com/JeffyCN/rockchip_mirrors.git rkbin&lt;br /&gt;
cd u-boot-rockchip&lt;br /&gt;
# If using Arch Linux, export CROSS_COMPILE=aarch64-linux-gnu-&lt;br /&gt;
export CROSS_COMPILE=aarch64-none-linux-gnu-&lt;br /&gt;
make rk3566-quartz64_defconfig&lt;br /&gt;
./make.sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
In the current version (current as of 2022-01-02), there might have to be made a change to one line to get a clean compilation:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
diff --git a/lib/avb/libavb/avb_slot_verify.c b/lib/avb/libavb/avb_slot_verify.c&lt;br /&gt;
index 123701fc3b..64a1ce6450 100644&lt;br /&gt;
--- a/lib/avb/libavb/avb_slot_verify.c&lt;br /&gt;
+++ b/lib/avb/libavb/avb_slot_verify.c&lt;br /&gt;
@@ -296,7 +296,7 @@ static AvbSlotVerifyResult load_and_verify_hash_partition(&lt;br /&gt;
   bool image_preloaded = false;&lt;br /&gt;
   uint8_t* digest;&lt;br /&gt;
   size_t digest_len;&lt;br /&gt;
-  const char* found;&lt;br /&gt;
+  const char* found = NULL;&lt;br /&gt;
   uint64_t image_size;&lt;br /&gt;
   size_t expected_digest_len = 0;&lt;br /&gt;
   uint8_t expected_digest_buf[AVB_SHA512_DIGEST_SIZE];&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For systems where the global python executable points to python2, compilation fails with an error related to pyelftools not being installed (even if it is). To fix this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
diff --git a/make.sh b/make.sh&lt;br /&gt;
index 2bba05b4e4..cfe5b0afd5 100755&lt;br /&gt;
--- a/make.sh&lt;br /&gt;
+++ b/make.sh&lt;br /&gt;
@@ -758,7 +758,7 @@ function pack_fit_image()&lt;br /&gt;
        fi&lt;br /&gt;
 &lt;br /&gt;
        if [ &amp;quot;${ARM64_TRUSTZONE}&amp;quot; == &amp;quot;y&amp;quot; ]; then&lt;br /&gt;
-               if ! python -c &amp;quot;import elftools&amp;quot; ; then&lt;br /&gt;
+               if ! python3 -c &amp;quot;import elftools&amp;quot; ; then&lt;br /&gt;
                        echo &amp;quot;ERROR: No python 'pyelftools', please: pip install pyelftools&amp;quot;&lt;br /&gt;
                        exit 1&lt;br /&gt;
                fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can now download u-boot onto the PineNote:&lt;br /&gt;
&lt;br /&gt;
 ./rkdeveloptool boot ../u-boot-rockchip/rk356x_spl_loader_v1.08.111.bin&lt;br /&gt;
&lt;br /&gt;
This should output &amp;quot;''Downloading bootloader succeeded''&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
We can now verify that this worked using e.g. the &amp;quot;read flash info&amp;quot; command:&lt;br /&gt;
&lt;br /&gt;
 ./rkdeveloptool read-flash-info&lt;br /&gt;
&lt;br /&gt;
{{Note|'''TODO:''' Section needs to be finished}}&lt;br /&gt;
&lt;br /&gt;
=== Creating a mainline boot image ===&lt;br /&gt;
&lt;br /&gt;
You can create a filesystem image that replaces the Android boot or recovery partition by doing roughly the following:&lt;br /&gt;
&lt;br /&gt;
# Erase boot and dtbo with rkdeveloptool or fastboot (back them up first!!!)&lt;br /&gt;
# Create an ext2 partition image and mount it (fallocate, mkfs.ext2)&lt;br /&gt;
# Build your mainline kernel&lt;br /&gt;
# Copy the kernel, dtb and an initramfs to the root of the mounted image (use any old postmarketOS initramfs)&lt;br /&gt;
# Create a file in the root of the mounted image called &amp;lt;code&amp;gt;extlinux.conf&amp;lt;/code&amp;gt; as described below&lt;br /&gt;
# Unmount the image and then use rkdeveloptool to flash it to the &amp;quot;recovery&amp;quot; partition on the pinenote (it's about the right size until we get around to replacing the partition layout).&lt;br /&gt;
&lt;br /&gt;
== Using fastboot ==&lt;br /&gt;
&lt;br /&gt;
Follow the steps for [[PineNote Development/Flashing#Creating a mainline boot image|Creating a mainline boot image]], but instead of flashing it with ''rkdeveloptool'', use ''fastboot''. You can enter fastboot in either of two ways:&lt;br /&gt;
&lt;br /&gt;
* Use &amp;quot;reboot bootloader&amp;quot; from adb or a UART console or&lt;br /&gt;
* get a U-Boot prompt and run &amp;lt;code&amp;gt;fastboot usb 0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:PineNote]]&lt;/div&gt;</summary>
		<author><name>Ahelwer</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PineNote_Development/Flashing&amp;diff=20876</id>
		<title>PineNote Development/Flashing</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PineNote_Development/Flashing&amp;diff=20876"/>
		<updated>2023-10-12T15:55:45Z</updated>

		<summary type="html">&lt;p&gt;Ahelwer: /* Exiting mode */ Added note about removing magnet before rebooting&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Under construction}}&lt;br /&gt;
&lt;br /&gt;
{{Info|These instructions are directed towards experienced developers only!}}&lt;br /&gt;
&lt;br /&gt;
This page contains information on flashing software to the [https://wiki.pine64.org/wiki/PineNote PineNote].&lt;br /&gt;
&lt;br /&gt;
Currently, software can be flashed using rkdeveloptool or from the factory Android installation (UART shell, adb, or fastboot).&lt;br /&gt;
&lt;br /&gt;
== Getting &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
Most flashing operations on the PineNote are done through &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt;, a command line utility built on libusb.&lt;br /&gt;
PINE64 maintains its own fork [https://gitlab.com/pine64-org/quartz-bsp/rkdeveloptool here] that you will need to get.&lt;br /&gt;
The repo's README contains a list of dependencies (libusb 1.0) and instructions for building the tool.&lt;br /&gt;
&lt;br /&gt;
Installing (not just building) &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; will configure PAM to elevate privileges where necessary on your system; you can configure this manually as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo cp 99-rk-rockusb.rules /etc/udev/rules.d/&lt;br /&gt;
sudo udevadm control --reload&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Entering Maskrom/Rockusb Mode ==&lt;br /&gt;
&lt;br /&gt;
Interfacing with the PineNote over USB using &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; requires first booting the PineNote into an alternative operating mode called Maskrom or Rockusb mode.&lt;br /&gt;
&lt;br /&gt;
=== Possible Methods ===&lt;br /&gt;
&lt;br /&gt;
There are three possible methods of entering Maskrom/Rockusb mode:&lt;br /&gt;
&lt;br /&gt;
==== Hardware Magnet Switch ====&lt;br /&gt;
&lt;br /&gt;
# Connect the PineNote to your computer via USB and boot the PineNote into Android&lt;br /&gt;
# Locate &amp;amp; identify the small circular marking on the back of the PineNote, in the top right quadrant; have the PineNote pen close at hand, or any other small magnet&lt;br /&gt;
# Hold the PineNote power button to bring up the reboot/shutdown menu; select reboot, then place the PineNote face down with the &amp;quot;eraser&amp;quot; end of the pen (or your magnet) resting on the small circular marking&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Download mode.jpeg|Pen method&lt;br /&gt;
PineNoteMagnetOnBack.jpg|Magnet method&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== U-Boot ====&lt;br /&gt;
This method requires a [[PineNote Development/UART|UART dongle for the PineNote]] with passthrough allowing simultaneous UART &amp;amp; USB connections.&lt;br /&gt;
It is nice because you can easily switch back &amp;amp; forth between U-Boot and Rockusb without having to physically manipulate the PineNote or its connectors; this is especially helpful when trying to develop U-Boot.&lt;br /&gt;
&lt;br /&gt;
# Interrupt the U-Boot startup using ''ctrl-c'' (while attached using an UART dongle)&lt;br /&gt;
# While in U-Boot use the command &amp;lt;code&amp;gt;rockusb 0 mmc 0&amp;lt;/code&amp;gt; to start Rockusb mode.&lt;br /&gt;
&lt;br /&gt;
==== Shorting Test Points ====&lt;br /&gt;
&lt;br /&gt;
If the bootloader is broken/corrupted, you cannot get to Maskrom without opening up the device (it can be opened using spudger and a bit of patience).&lt;br /&gt;
&lt;br /&gt;
Once inside, short TP1301 (GND) and TP1302 (eMMC_D0/FLASH_D0) with a small tweezers, this is how it looks on board view (credit to Caleb):&lt;br /&gt;
&lt;br /&gt;
[[File:PineNote_Maskrom_TP.png|500px]]&lt;br /&gt;
&lt;br /&gt;
=== Success ===&lt;br /&gt;
&lt;br /&gt;
No matter what approach you take, you can tell whether you succeeded by running the &amp;lt;code&amp;gt;lsusb&amp;lt;/code&amp;gt; command on your computer:&lt;br /&gt;
* If you find the entry &amp;lt;code&amp;gt;2207:0018 Fuzhou Rockchip Electronics Company rk3566_eink&amp;lt;/code&amp;gt; in the list, the process did not succeed; reboot and retry&lt;br /&gt;
* The entry &amp;lt;code&amp;gt;2207:350a Fuzhou Rockchip Electronics Company&amp;lt;/code&amp;gt; will occur if you detach then reattach the USB-C cable while the PineNote is in Maskrom/Rockusb mode; &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; won't work and you will have to do a hard reboot (hold down power button for 30 seconds to shutdown)&lt;br /&gt;
* If you find the entry &amp;lt;code&amp;gt;2207:350a Fuzhou Rockchip Electronics Company USB download gadget&amp;lt;/code&amp;gt; then the process succeeded&lt;br /&gt;
&lt;br /&gt;
You can also look at the output of the &amp;lt;code&amp;gt;rkdeveloptool list&amp;lt;/code&amp;gt; command:&lt;br /&gt;
* If this prints out &amp;lt;code&amp;gt;No devices in rockusb mode found&amp;lt;/code&amp;gt; the process did not succeed; reboot and retry&lt;br /&gt;
* If this prints out &amp;lt;code&amp;gt;DevNo=1 Vid=0x2207,Pid=0x350a,LocationID=305 Maskrom&amp;lt;/code&amp;gt; then you probably detached/reattached the USB-C cable while in Maskrom/Rockusb mode and &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; won't work; perform a hard reboot to fix&lt;br /&gt;
* If this prints out &amp;lt;code&amp;gt;DevNo=1 Vid=0x2207,Pid=0x350a,LocationID=303 Loader&amp;lt;/code&amp;gt; then the process succeeded&lt;br /&gt;
&lt;br /&gt;
=== Exiting mode ===&lt;br /&gt;
&lt;br /&gt;
You can boot the PineNote back into its normal mode of operation by powercycling the PineNote with its hardware power switch, or running the &amp;lt;code&amp;gt;rkdeveloptool reboot&amp;lt;/code&amp;gt; command.&lt;br /&gt;
If you used the magnetic switch method be sure to remove the pen/magnet before rebooting.&lt;br /&gt;
&lt;br /&gt;
== Backup ==&lt;br /&gt;
&lt;br /&gt;
A backup of the content of the internal eMMC before anything gets messed up is '''mandatory'''.&lt;br /&gt;
&lt;br /&gt;
Especially the ''waveform'' partition contains data '''unique''' to your PineNote and is a prime candidate for backup.&lt;br /&gt;
&lt;br /&gt;
Other partitions like U-Boot (need for any operation of the device) or the un-partitioned space at the beginning containing the GPT partition table (and presumably the VCOM setting for the e-ink display and maybe device mac addresses) contain data you may also wish to backup.&lt;br /&gt;
&lt;br /&gt;
Depending of your personal level of data hoarder you may want to backup more than this or even just everything (the large ''userdata'' partition is supposed to be able to be repopulated as empty space by Android)&lt;br /&gt;
&lt;br /&gt;
In any case it is easier to restore/extract data from a backup than not having one if you need one.&lt;br /&gt;
&lt;br /&gt;
This process was developed by Dorian Rudolph, originally described [https://github.com/DorianRudolph/pinenotes here].&lt;br /&gt;
&lt;br /&gt;
=== List partitions ===&lt;br /&gt;
&lt;br /&gt;
First, run &amp;lt;code&amp;gt;rkdeveloptool list-partitions&amp;lt;/code&amp;gt; to print out your PineNote's partitions to get an idea of what you're dealing with.&lt;br /&gt;
The stock PineNote has a fairly standard Android partition setup, including:&lt;br /&gt;
* uboot: the [https://en.wikipedia.org/wiki/Das_U-Boot U-Boot] embedded systems bootloader&lt;br /&gt;
* trust: secrets that can be encrypted with a key stored in the [https://en.wikipedia.org/wiki/Trusted_Platform_Module TPM]&lt;br /&gt;
* waveform: important files controlling the e-ink screen's state changes&lt;br /&gt;
* misc: miscellaneous files needed by the firmware&lt;br /&gt;
* dtbo: [https://en.wikipedia.org/wiki/Devicetree Device Tree Blob for Overlay], files describing the PineNote's hardware configuration&lt;br /&gt;
* vbmeta: data required for verified boot&lt;br /&gt;
* boot, security, recovery, backup, cache, metadata, super, logo, device&lt;br /&gt;
* userdata: the big one; this is where all your files are stored in the stock Android install&lt;br /&gt;
&lt;br /&gt;
=== Patch U-Boot ===&lt;br /&gt;
&lt;br /&gt;
Before we can back up our partitions, we have a problem to solve.&lt;br /&gt;
The version of U-Boot installed on the stock PineNote contains a bug where it can't dump partitions beyond 32 MB (above that limit all bytes in the dump are just &amp;lt;code&amp;gt;0xCC&amp;lt;/code&amp;gt;), meaning the PineNote must be flashed with a fixed version of U-Boot before it is possible to take a backup of the larger partitions.&lt;br /&gt;
It is possible to extract and modify the U-Boot image from your PineNote if you're interested in some light reverse-engineering (following Dorian's notes), or you can simply download a patched U-Boot image directly [https://github.com/DorianRudolph/pinenotes/blob/main/static/uboot_patched.img here].&lt;br /&gt;
&lt;br /&gt;
Once you've acquired a patched U-Boot image, run:&lt;br /&gt;
# &amp;lt;code&amp;gt;rkdeveloptool read-partition uboot uboot_backup.img&amp;lt;/code&amp;gt;&lt;br /&gt;
# &amp;lt;code&amp;gt;rkdeveloptool write-partition uboot uboot_patched.img&amp;lt;/code&amp;gt;&lt;br /&gt;
# &amp;lt;code&amp;gt;rkdeveloptool reboot&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Taking the backup ===&lt;br /&gt;
&lt;br /&gt;
There is a second backup limit preventing dumping partitions larger than 2 GB, this time from &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt;.&lt;br /&gt;
This means if you have a large number of documents in the Android userdata partition they might not all make it into the backup.&lt;br /&gt;
If you don't have many documents (or don't care about losing them) this should not be a problem.&lt;br /&gt;
If you do have a lot of documents, workarounds include:&lt;br /&gt;
* A possible patch written by Thomas exists [https://github.com/tpwrules/nixos-pinenote/blob/96d2c9158edb9da59afcb952cc864fada18382f9/nix/rkdeveloptool/0001-fix-large-dumps.patch here] but has not yet been upstreamed; consider investigating how to get the patch tested &amp;amp; upstreamed, or just apply it to your own local copy of &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt;&lt;br /&gt;
* Use [https://github.com/talpadk/pinenote-backup this] Python script written by Visti Andresen to automatically backup your entire partition by splitting reads into 2 GB chunks&lt;br /&gt;
&lt;br /&gt;
See [https://github.com/m-weigand/pinenote-debian-recipes/releases/tag/v0.1 instructions on this artifact]. It will instruct you on extracting the rootfs into an empty ext4 partition. This can be done from Linux or Android. Further instructions on building your own rootfs [https://github.com/m-weigand/pinenote-debian-recipes can be found here].&lt;br /&gt;
&lt;br /&gt;
=== Using a user installed Linux ===&lt;br /&gt;
A Linux installed to the cache partition should be able to easily backup everything over WiFi or to a USB stick/disk using ''dd''.&lt;br /&gt;
&lt;br /&gt;
However the user would need to backup the cache partition themself (if they want that).&lt;br /&gt;
&lt;br /&gt;
And more importantly they would only be getting the backup ''after'' they started playing with the content of the eMMC.&lt;br /&gt;
&lt;br /&gt;
== Side-by-side setup ==&lt;br /&gt;
&lt;br /&gt;
It is possible to set up a partition for mainline development without disturbing the factory Android installation. This allows updating a mainline kernel, DTB, and initramfs over Wi-Fi until WiFi or USB OTG is working in mainline Linux.&lt;br /&gt;
&lt;br /&gt;
=== Without Repartitioning ===&lt;br /&gt;
&lt;br /&gt;
The recommended partition for this is &amp;lt;tt&amp;gt;mmcblk0p11&amp;lt;/tt&amp;gt; aka &amp;lt;tt&amp;gt;/cache&amp;lt;/tt&amp;gt;. It is large and already formatted as &amp;lt;tt&amp;gt;ext4&amp;lt;/tt&amp;gt;, so it is readable from U-Boot. Here are some general steps:&lt;br /&gt;
&lt;br /&gt;
# From the UART or adb shell, set up your chroot in &amp;lt;tt&amp;gt;/cache&amp;lt;/tt&amp;gt;. I used the Alpine Linux rootfs tarball.&lt;br /&gt;
# Copy in your kernel and DTB, using for example &amp;lt;tt&amp;gt;scp&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;wget&amp;lt;/tt&amp;gt; inside the chroot.&lt;br /&gt;
# Finally, create and boot an &amp;lt;code&amp;gt;extlinux.conf&amp;lt;/code&amp;gt; as described below.&lt;br /&gt;
&lt;br /&gt;
=== With Repartitioning ===&lt;br /&gt;
&lt;br /&gt;
It is possible to shrink the &amp;lt;tt&amp;gt;userdata&amp;lt;/tt&amp;gt; partition, and create a new partition at the end for use with mainline Linux. This provides much more space than &amp;lt;tt&amp;gt;cache&amp;lt;/tt&amp;gt;. However, because &amp;lt;tt&amp;gt;userdata&amp;lt;/tt&amp;gt; is formatted with &amp;lt;tt&amp;gt;f2fs&amp;lt;/tt&amp;gt;, and that filesystem cannot be shrunk, resizing the partition requires wiping &amp;lt;tt&amp;gt;userdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
# Back up any necessary files from userdata&lt;br /&gt;
# Boot to a mainline kernel from &amp;lt;tt&amp;gt;mmcblk0p11&amp;lt;/tt&amp;gt;, either using that partition as rootfs (see above), or using an initramfs with repartitioning tools&lt;br /&gt;
# Modify the partition table with your favorite tool, e.g. &amp;lt;tt&amp;gt;fdisk&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gdisk&amp;lt;/tt&amp;gt;, or &amp;lt;tt&amp;gt;parted&amp;lt;/tt&amp;gt;&lt;br /&gt;
# Reboot into &amp;lt;tt&amp;gt;fastboot&amp;lt;/tt&amp;gt; and wipe &amp;lt;tt&amp;gt;userdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# Reboot into Android, where you can now chroot in and install your favorite distribution to the new partition.&lt;br /&gt;
&lt;br /&gt;
== Using rkdeveloptool ==&lt;br /&gt;
&lt;br /&gt;
=== Building Downstream U-Boot ===&lt;br /&gt;
&lt;br /&gt;
While in maskrom mode, we need to have a u-boot to download onto the device for any of the other commands to work. To build you'll also need to install device-tree-compiler.&lt;br /&gt;
&lt;br /&gt;
You also need to install Python and pyelftools.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Note that rkbin is a &amp;amp;gt;5GB download!&amp;lt;/b&amp;gt; This will take some time to clone and process the deltas.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone -b quartz64 https://gitlab.com/pgwipeout/u-boot-rockchip.git&lt;br /&gt;
git clone -b rkbin https://github.com/JeffyCN/rockchip_mirrors.git rkbin&lt;br /&gt;
cd u-boot-rockchip&lt;br /&gt;
# If using Arch Linux, export CROSS_COMPILE=aarch64-linux-gnu-&lt;br /&gt;
export CROSS_COMPILE=aarch64-none-linux-gnu-&lt;br /&gt;
make rk3566-quartz64_defconfig&lt;br /&gt;
./make.sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
In the current version (current as of 2022-01-02), there might have to be made a change to one line to get a clean compilation:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
diff --git a/lib/avb/libavb/avb_slot_verify.c b/lib/avb/libavb/avb_slot_verify.c&lt;br /&gt;
index 123701fc3b..64a1ce6450 100644&lt;br /&gt;
--- a/lib/avb/libavb/avb_slot_verify.c&lt;br /&gt;
+++ b/lib/avb/libavb/avb_slot_verify.c&lt;br /&gt;
@@ -296,7 +296,7 @@ static AvbSlotVerifyResult load_and_verify_hash_partition(&lt;br /&gt;
   bool image_preloaded = false;&lt;br /&gt;
   uint8_t* digest;&lt;br /&gt;
   size_t digest_len;&lt;br /&gt;
-  const char* found;&lt;br /&gt;
+  const char* found = NULL;&lt;br /&gt;
   uint64_t image_size;&lt;br /&gt;
   size_t expected_digest_len = 0;&lt;br /&gt;
   uint8_t expected_digest_buf[AVB_SHA512_DIGEST_SIZE];&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For systems where the global python executable points to python2, compilation fails with an error related to pyelftools not being installed (even if it is). To fix this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
diff --git a/make.sh b/make.sh&lt;br /&gt;
index 2bba05b4e4..cfe5b0afd5 100755&lt;br /&gt;
--- a/make.sh&lt;br /&gt;
+++ b/make.sh&lt;br /&gt;
@@ -758,7 +758,7 @@ function pack_fit_image()&lt;br /&gt;
        fi&lt;br /&gt;
 &lt;br /&gt;
        if [ &amp;quot;${ARM64_TRUSTZONE}&amp;quot; == &amp;quot;y&amp;quot; ]; then&lt;br /&gt;
-               if ! python -c &amp;quot;import elftools&amp;quot; ; then&lt;br /&gt;
+               if ! python3 -c &amp;quot;import elftools&amp;quot; ; then&lt;br /&gt;
                        echo &amp;quot;ERROR: No python 'pyelftools', please: pip install pyelftools&amp;quot;&lt;br /&gt;
                        exit 1&lt;br /&gt;
                fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can now download u-boot onto the PineNote:&lt;br /&gt;
&lt;br /&gt;
 ./rkdeveloptool boot ../u-boot-rockchip/rk356x_spl_loader_v1.08.111.bin&lt;br /&gt;
&lt;br /&gt;
This should output &amp;quot;''Downloading bootloader succeeded''&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
We can now verify that this worked using e.g. the &amp;quot;read flash info&amp;quot; command:&lt;br /&gt;
&lt;br /&gt;
 ./rkdeveloptool read-flash-info&lt;br /&gt;
&lt;br /&gt;
{{Note|'''TODO:''' Section needs to be finished}}&lt;br /&gt;
&lt;br /&gt;
=== Creating a mainline boot image ===&lt;br /&gt;
&lt;br /&gt;
You can create a filesystem image that replaces the Android boot or recovery partition by doing roughly the following:&lt;br /&gt;
&lt;br /&gt;
# Erase boot and dtbo with rkdeveloptool or fastboot (back them up first!!!)&lt;br /&gt;
# Create an ext2 partition image and mount it (fallocate, mkfs.ext2)&lt;br /&gt;
# Build your mainline kernel&lt;br /&gt;
# Copy the kernel, dtb and an initramfs to the root of the mounted image (use any old postmarketOS initramfs)&lt;br /&gt;
# Create a file in the root of the mounted image called &amp;lt;code&amp;gt;extlinux.conf&amp;lt;/code&amp;gt; as described below&lt;br /&gt;
# Unmount the image and then use rkdeveloptool to flash it to the &amp;quot;recovery&amp;quot; partition on the pinenote (it's about the right size until we get around to replacing the partition layout).&lt;br /&gt;
&lt;br /&gt;
== Using fastboot ==&lt;br /&gt;
&lt;br /&gt;
Follow the steps for [[PineNote Development/Flashing#Creating a mainline boot image|Creating a mainline boot image]], but instead of flashing it with ''rkdeveloptool'', use ''fastboot''. You can enter fastboot in either of two ways:&lt;br /&gt;
&lt;br /&gt;
* Use &amp;quot;reboot bootloader&amp;quot; from adb or a UART console or&lt;br /&gt;
* get a U-Boot prompt and run &amp;lt;code&amp;gt;fastboot usb 0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:PineNote]]&lt;/div&gt;</summary>
		<author><name>Ahelwer</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PineNote_Development/Flashing&amp;diff=20875</id>
		<title>PineNote Development/Flashing</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PineNote_Development/Flashing&amp;diff=20875"/>
		<updated>2023-10-12T15:52:38Z</updated>

		<summary type="html">&lt;p&gt;Ahelwer: /* Success */ Added note about detaching USB cable in Maskrom/Rockusb mode&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Under construction}}&lt;br /&gt;
&lt;br /&gt;
{{Info|These instructions are directed towards experienced developers only!}}&lt;br /&gt;
&lt;br /&gt;
This page contains information on flashing software to the [https://wiki.pine64.org/wiki/PineNote PineNote].&lt;br /&gt;
&lt;br /&gt;
Currently, software can be flashed using rkdeveloptool or from the factory Android installation (UART shell, adb, or fastboot).&lt;br /&gt;
&lt;br /&gt;
== Getting &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
Most flashing operations on the PineNote are done through &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt;, a command line utility built on libusb.&lt;br /&gt;
PINE64 maintains its own fork [https://gitlab.com/pine64-org/quartz-bsp/rkdeveloptool here] that you will need to get.&lt;br /&gt;
The repo's README contains a list of dependencies (libusb 1.0) and instructions for building the tool.&lt;br /&gt;
&lt;br /&gt;
Installing (not just building) &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; will configure PAM to elevate privileges where necessary on your system; you can configure this manually as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo cp 99-rk-rockusb.rules /etc/udev/rules.d/&lt;br /&gt;
sudo udevadm control --reload&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Entering Maskrom/Rockusb Mode ==&lt;br /&gt;
&lt;br /&gt;
Interfacing with the PineNote over USB using &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; requires first booting the PineNote into an alternative operating mode called Maskrom or Rockusb mode.&lt;br /&gt;
&lt;br /&gt;
=== Possible Methods ===&lt;br /&gt;
&lt;br /&gt;
There are three possible methods of entering Maskrom/Rockusb mode:&lt;br /&gt;
&lt;br /&gt;
==== Hardware Magnet Switch ====&lt;br /&gt;
&lt;br /&gt;
# Connect the PineNote to your computer via USB and boot the PineNote into Android&lt;br /&gt;
# Locate &amp;amp; identify the small circular marking on the back of the PineNote, in the top right quadrant; have the PineNote pen close at hand, or any other small magnet&lt;br /&gt;
# Hold the PineNote power button to bring up the reboot/shutdown menu; select reboot, then place the PineNote face down with the &amp;quot;eraser&amp;quot; end of the pen (or your magnet) resting on the small circular marking&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Download mode.jpeg|Pen method&lt;br /&gt;
PineNoteMagnetOnBack.jpg|Magnet method&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== U-Boot ====&lt;br /&gt;
This method requires a [[PineNote Development/UART|UART dongle for the PineNote]] with passthrough allowing simultaneous UART &amp;amp; USB connections.&lt;br /&gt;
It is nice because you can easily switch back &amp;amp; forth between U-Boot and Rockusb without having to physically manipulate the PineNote or its connectors; this is especially helpful when trying to develop U-Boot.&lt;br /&gt;
&lt;br /&gt;
# Interrupt the U-Boot startup using ''ctrl-c'' (while attached using an UART dongle)&lt;br /&gt;
# While in U-Boot use the command &amp;lt;code&amp;gt;rockusb 0 mmc 0&amp;lt;/code&amp;gt; to start Rockusb mode.&lt;br /&gt;
&lt;br /&gt;
==== Shorting Test Points ====&lt;br /&gt;
&lt;br /&gt;
If the bootloader is broken/corrupted, you cannot get to Maskrom without opening up the device (it can be opened using spudger and a bit of patience).&lt;br /&gt;
&lt;br /&gt;
Once inside, short TP1301 (GND) and TP1302 (eMMC_D0/FLASH_D0) with a small tweezers, this is how it looks on board view (credit to Caleb):&lt;br /&gt;
&lt;br /&gt;
[[File:PineNote_Maskrom_TP.png|500px]]&lt;br /&gt;
&lt;br /&gt;
=== Success ===&lt;br /&gt;
&lt;br /&gt;
No matter what approach you take, you can tell whether you succeeded by running the &amp;lt;code&amp;gt;lsusb&amp;lt;/code&amp;gt; command on your computer:&lt;br /&gt;
* If you find the entry &amp;lt;code&amp;gt;2207:0018 Fuzhou Rockchip Electronics Company rk3566_eink&amp;lt;/code&amp;gt; in the list, the process did not succeed; reboot and retry&lt;br /&gt;
* The entry &amp;lt;code&amp;gt;2207:350a Fuzhou Rockchip Electronics Company&amp;lt;/code&amp;gt; will occur if you detach then reattach the USB-C cable while the PineNote is in Maskrom/Rockusb mode; &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; won't work and you will have to do a hard reboot (hold down power button for 30 seconds to shutdown)&lt;br /&gt;
* If you find the entry &amp;lt;code&amp;gt;2207:350a Fuzhou Rockchip Electronics Company USB download gadget&amp;lt;/code&amp;gt; then the process succeeded&lt;br /&gt;
&lt;br /&gt;
You can also look at the output of the &amp;lt;code&amp;gt;rkdeveloptool list&amp;lt;/code&amp;gt; command:&lt;br /&gt;
* If this prints out &amp;lt;code&amp;gt;No devices in rockusb mode found&amp;lt;/code&amp;gt; the process did not succeed; reboot and retry&lt;br /&gt;
* If this prints out &amp;lt;code&amp;gt;DevNo=1 Vid=0x2207,Pid=0x350a,LocationID=305 Maskrom&amp;lt;/code&amp;gt; then you probably detached/reattached the USB-C cable while in Maskrom/Rockusb mode and &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; won't work; perform a hard reboot to fix&lt;br /&gt;
* If this prints out &amp;lt;code&amp;gt;DevNo=1 Vid=0x2207,Pid=0x350a,LocationID=303 Loader&amp;lt;/code&amp;gt; then the process succeeded&lt;br /&gt;
&lt;br /&gt;
=== Exiting mode ===&lt;br /&gt;
&lt;br /&gt;
You can boot the PineNote back into its normal mode of operation by powercycling the PineNote with its hardware power switch, or running the &amp;lt;code&amp;gt;rkdeveloptool reset&amp;lt;/code&amp;gt; command.&lt;br /&gt;
&lt;br /&gt;
== Backup ==&lt;br /&gt;
&lt;br /&gt;
A backup of the content of the internal eMMC before anything gets messed up is '''mandatory'''.&lt;br /&gt;
&lt;br /&gt;
Especially the ''waveform'' partition contains data '''unique''' to your PineNote and is a prime candidate for backup.&lt;br /&gt;
&lt;br /&gt;
Other partitions like U-Boot (need for any operation of the device) or the un-partitioned space at the beginning containing the GPT partition table (and presumably the VCOM setting for the e-ink display and maybe device mac addresses) contain data you may also wish to backup.&lt;br /&gt;
&lt;br /&gt;
Depending of your personal level of data hoarder you may want to backup more than this or even just everything (the large ''userdata'' partition is supposed to be able to be repopulated as empty space by Android)&lt;br /&gt;
&lt;br /&gt;
In any case it is easier to restore/extract data from a backup than not having one if you need one.&lt;br /&gt;
&lt;br /&gt;
This process was developed by Dorian Rudolph, originally described [https://github.com/DorianRudolph/pinenotes here].&lt;br /&gt;
&lt;br /&gt;
=== List partitions ===&lt;br /&gt;
&lt;br /&gt;
First, run &amp;lt;code&amp;gt;rkdeveloptool list-partitions&amp;lt;/code&amp;gt; to print out your PineNote's partitions to get an idea of what you're dealing with.&lt;br /&gt;
The stock PineNote has a fairly standard Android partition setup, including:&lt;br /&gt;
* uboot: the [https://en.wikipedia.org/wiki/Das_U-Boot U-Boot] embedded systems bootloader&lt;br /&gt;
* trust: secrets that can be encrypted with a key stored in the [https://en.wikipedia.org/wiki/Trusted_Platform_Module TPM]&lt;br /&gt;
* waveform: important files controlling the e-ink screen's state changes&lt;br /&gt;
* misc: miscellaneous files needed by the firmware&lt;br /&gt;
* dtbo: [https://en.wikipedia.org/wiki/Devicetree Device Tree Blob for Overlay], files describing the PineNote's hardware configuration&lt;br /&gt;
* vbmeta: data required for verified boot&lt;br /&gt;
* boot, security, recovery, backup, cache, metadata, super, logo, device&lt;br /&gt;
* userdata: the big one; this is where all your files are stored in the stock Android install&lt;br /&gt;
&lt;br /&gt;
=== Patch U-Boot ===&lt;br /&gt;
&lt;br /&gt;
Before we can back up our partitions, we have a problem to solve.&lt;br /&gt;
The version of U-Boot installed on the stock PineNote contains a bug where it can't dump partitions beyond 32 MB (above that limit all bytes in the dump are just &amp;lt;code&amp;gt;0xCC&amp;lt;/code&amp;gt;), meaning the PineNote must be flashed with a fixed version of U-Boot before it is possible to take a backup of the larger partitions.&lt;br /&gt;
It is possible to extract and modify the U-Boot image from your PineNote if you're interested in some light reverse-engineering (following Dorian's notes), or you can simply download a patched U-Boot image directly [https://github.com/DorianRudolph/pinenotes/blob/main/static/uboot_patched.img here].&lt;br /&gt;
&lt;br /&gt;
Once you've acquired a patched U-Boot image, run:&lt;br /&gt;
# &amp;lt;code&amp;gt;rkdeveloptool read-partition uboot uboot_backup.img&amp;lt;/code&amp;gt;&lt;br /&gt;
# &amp;lt;code&amp;gt;rkdeveloptool write-partition uboot uboot_patched.img&amp;lt;/code&amp;gt;&lt;br /&gt;
# &amp;lt;code&amp;gt;rkdeveloptool reboot&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Taking the backup ===&lt;br /&gt;
&lt;br /&gt;
There is a second backup limit preventing dumping partitions larger than 2 GB, this time from &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt;.&lt;br /&gt;
This means if you have a large number of documents in the Android userdata partition they might not all make it into the backup.&lt;br /&gt;
If you don't have many documents (or don't care about losing them) this should not be a problem.&lt;br /&gt;
If you do have a lot of documents, workarounds include:&lt;br /&gt;
* A possible patch written by Thomas exists [https://github.com/tpwrules/nixos-pinenote/blob/96d2c9158edb9da59afcb952cc864fada18382f9/nix/rkdeveloptool/0001-fix-large-dumps.patch here] but has not yet been upstreamed; consider investigating how to get the patch tested &amp;amp; upstreamed, or just apply it to your own local copy of &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt;&lt;br /&gt;
* Use [https://github.com/talpadk/pinenote-backup this] Python script written by Visti Andresen to automatically backup your entire partition by splitting reads into 2 GB chunks&lt;br /&gt;
&lt;br /&gt;
See [https://github.com/m-weigand/pinenote-debian-recipes/releases/tag/v0.1 instructions on this artifact]. It will instruct you on extracting the rootfs into an empty ext4 partition. This can be done from Linux or Android. Further instructions on building your own rootfs [https://github.com/m-weigand/pinenote-debian-recipes can be found here].&lt;br /&gt;
&lt;br /&gt;
=== Using a user installed Linux ===&lt;br /&gt;
A Linux installed to the cache partition should be able to easily backup everything over WiFi or to a USB stick/disk using ''dd''.&lt;br /&gt;
&lt;br /&gt;
However the user would need to backup the cache partition themself (if they want that).&lt;br /&gt;
&lt;br /&gt;
And more importantly they would only be getting the backup ''after'' they started playing with the content of the eMMC.&lt;br /&gt;
&lt;br /&gt;
== Side-by-side setup ==&lt;br /&gt;
&lt;br /&gt;
It is possible to set up a partition for mainline development without disturbing the factory Android installation. This allows updating a mainline kernel, DTB, and initramfs over Wi-Fi until WiFi or USB OTG is working in mainline Linux.&lt;br /&gt;
&lt;br /&gt;
=== Without Repartitioning ===&lt;br /&gt;
&lt;br /&gt;
The recommended partition for this is &amp;lt;tt&amp;gt;mmcblk0p11&amp;lt;/tt&amp;gt; aka &amp;lt;tt&amp;gt;/cache&amp;lt;/tt&amp;gt;. It is large and already formatted as &amp;lt;tt&amp;gt;ext4&amp;lt;/tt&amp;gt;, so it is readable from U-Boot. Here are some general steps:&lt;br /&gt;
&lt;br /&gt;
# From the UART or adb shell, set up your chroot in &amp;lt;tt&amp;gt;/cache&amp;lt;/tt&amp;gt;. I used the Alpine Linux rootfs tarball.&lt;br /&gt;
# Copy in your kernel and DTB, using for example &amp;lt;tt&amp;gt;scp&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;wget&amp;lt;/tt&amp;gt; inside the chroot.&lt;br /&gt;
# Finally, create and boot an &amp;lt;code&amp;gt;extlinux.conf&amp;lt;/code&amp;gt; as described below.&lt;br /&gt;
&lt;br /&gt;
=== With Repartitioning ===&lt;br /&gt;
&lt;br /&gt;
It is possible to shrink the &amp;lt;tt&amp;gt;userdata&amp;lt;/tt&amp;gt; partition, and create a new partition at the end for use with mainline Linux. This provides much more space than &amp;lt;tt&amp;gt;cache&amp;lt;/tt&amp;gt;. However, because &amp;lt;tt&amp;gt;userdata&amp;lt;/tt&amp;gt; is formatted with &amp;lt;tt&amp;gt;f2fs&amp;lt;/tt&amp;gt;, and that filesystem cannot be shrunk, resizing the partition requires wiping &amp;lt;tt&amp;gt;userdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
# Back up any necessary files from userdata&lt;br /&gt;
# Boot to a mainline kernel from &amp;lt;tt&amp;gt;mmcblk0p11&amp;lt;/tt&amp;gt;, either using that partition as rootfs (see above), or using an initramfs with repartitioning tools&lt;br /&gt;
# Modify the partition table with your favorite tool, e.g. &amp;lt;tt&amp;gt;fdisk&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gdisk&amp;lt;/tt&amp;gt;, or &amp;lt;tt&amp;gt;parted&amp;lt;/tt&amp;gt;&lt;br /&gt;
# Reboot into &amp;lt;tt&amp;gt;fastboot&amp;lt;/tt&amp;gt; and wipe &amp;lt;tt&amp;gt;userdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# Reboot into Android, where you can now chroot in and install your favorite distribution to the new partition.&lt;br /&gt;
&lt;br /&gt;
== Using rkdeveloptool ==&lt;br /&gt;
&lt;br /&gt;
=== Building Downstream U-Boot ===&lt;br /&gt;
&lt;br /&gt;
While in maskrom mode, we need to have a u-boot to download onto the device for any of the other commands to work. To build you'll also need to install device-tree-compiler.&lt;br /&gt;
&lt;br /&gt;
You also need to install Python and pyelftools.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Note that rkbin is a &amp;amp;gt;5GB download!&amp;lt;/b&amp;gt; This will take some time to clone and process the deltas.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone -b quartz64 https://gitlab.com/pgwipeout/u-boot-rockchip.git&lt;br /&gt;
git clone -b rkbin https://github.com/JeffyCN/rockchip_mirrors.git rkbin&lt;br /&gt;
cd u-boot-rockchip&lt;br /&gt;
# If using Arch Linux, export CROSS_COMPILE=aarch64-linux-gnu-&lt;br /&gt;
export CROSS_COMPILE=aarch64-none-linux-gnu-&lt;br /&gt;
make rk3566-quartz64_defconfig&lt;br /&gt;
./make.sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
In the current version (current as of 2022-01-02), there might have to be made a change to one line to get a clean compilation:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
diff --git a/lib/avb/libavb/avb_slot_verify.c b/lib/avb/libavb/avb_slot_verify.c&lt;br /&gt;
index 123701fc3b..64a1ce6450 100644&lt;br /&gt;
--- a/lib/avb/libavb/avb_slot_verify.c&lt;br /&gt;
+++ b/lib/avb/libavb/avb_slot_verify.c&lt;br /&gt;
@@ -296,7 +296,7 @@ static AvbSlotVerifyResult load_and_verify_hash_partition(&lt;br /&gt;
   bool image_preloaded = false;&lt;br /&gt;
   uint8_t* digest;&lt;br /&gt;
   size_t digest_len;&lt;br /&gt;
-  const char* found;&lt;br /&gt;
+  const char* found = NULL;&lt;br /&gt;
   uint64_t image_size;&lt;br /&gt;
   size_t expected_digest_len = 0;&lt;br /&gt;
   uint8_t expected_digest_buf[AVB_SHA512_DIGEST_SIZE];&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For systems where the global python executable points to python2, compilation fails with an error related to pyelftools not being installed (even if it is). To fix this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
diff --git a/make.sh b/make.sh&lt;br /&gt;
index 2bba05b4e4..cfe5b0afd5 100755&lt;br /&gt;
--- a/make.sh&lt;br /&gt;
+++ b/make.sh&lt;br /&gt;
@@ -758,7 +758,7 @@ function pack_fit_image()&lt;br /&gt;
        fi&lt;br /&gt;
 &lt;br /&gt;
        if [ &amp;quot;${ARM64_TRUSTZONE}&amp;quot; == &amp;quot;y&amp;quot; ]; then&lt;br /&gt;
-               if ! python -c &amp;quot;import elftools&amp;quot; ; then&lt;br /&gt;
+               if ! python3 -c &amp;quot;import elftools&amp;quot; ; then&lt;br /&gt;
                        echo &amp;quot;ERROR: No python 'pyelftools', please: pip install pyelftools&amp;quot;&lt;br /&gt;
                        exit 1&lt;br /&gt;
                fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can now download u-boot onto the PineNote:&lt;br /&gt;
&lt;br /&gt;
 ./rkdeveloptool boot ../u-boot-rockchip/rk356x_spl_loader_v1.08.111.bin&lt;br /&gt;
&lt;br /&gt;
This should output &amp;quot;''Downloading bootloader succeeded''&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
We can now verify that this worked using e.g. the &amp;quot;read flash info&amp;quot; command:&lt;br /&gt;
&lt;br /&gt;
 ./rkdeveloptool read-flash-info&lt;br /&gt;
&lt;br /&gt;
{{Note|'''TODO:''' Section needs to be finished}}&lt;br /&gt;
&lt;br /&gt;
=== Creating a mainline boot image ===&lt;br /&gt;
&lt;br /&gt;
You can create a filesystem image that replaces the Android boot or recovery partition by doing roughly the following:&lt;br /&gt;
&lt;br /&gt;
# Erase boot and dtbo with rkdeveloptool or fastboot (back them up first!!!)&lt;br /&gt;
# Create an ext2 partition image and mount it (fallocate, mkfs.ext2)&lt;br /&gt;
# Build your mainline kernel&lt;br /&gt;
# Copy the kernel, dtb and an initramfs to the root of the mounted image (use any old postmarketOS initramfs)&lt;br /&gt;
# Create a file in the root of the mounted image called &amp;lt;code&amp;gt;extlinux.conf&amp;lt;/code&amp;gt; as described below&lt;br /&gt;
# Unmount the image and then use rkdeveloptool to flash it to the &amp;quot;recovery&amp;quot; partition on the pinenote (it's about the right size until we get around to replacing the partition layout).&lt;br /&gt;
&lt;br /&gt;
== Using fastboot ==&lt;br /&gt;
&lt;br /&gt;
Follow the steps for [[PineNote Development/Flashing#Creating a mainline boot image|Creating a mainline boot image]], but instead of flashing it with ''rkdeveloptool'', use ''fastboot''. You can enter fastboot in either of two ways:&lt;br /&gt;
&lt;br /&gt;
* Use &amp;quot;reboot bootloader&amp;quot; from adb or a UART console or&lt;br /&gt;
* get a U-Boot prompt and run &amp;lt;code&amp;gt;fastboot usb 0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:PineNote]]&lt;/div&gt;</summary>
		<author><name>Ahelwer</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PineNote_Development/UART&amp;diff=20874</id>
		<title>PineNote Development/UART</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PineNote_Development/UART&amp;diff=20874"/>
		<updated>2023-10-12T15:29:08Z</updated>

		<summary type="html">&lt;p&gt;Ahelwer: /* Creating a dongle */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Pinenote-uart-dongle.jpeg|thumb|Basic non-stock PineNote UART dongle]]&lt;br /&gt;
&lt;br /&gt;
This page contains information on creating and using a [https://en.wikipedia.org/wiki/Universal_asynchronous_receiver-transmitter UART] dongle for the [[PineNote]].&lt;br /&gt;
The PineNote was shipped with a compatible UART dongle, but replacements are not available to order in case of loss or hardware fault.&lt;br /&gt;
Thankfully it is not difficult to make your own from easily-acquired components.&lt;br /&gt;
&lt;br /&gt;
A PineNote UART dongle enables you to:&lt;br /&gt;
# Interact with the system boot menu&lt;br /&gt;
# Read system events in real time as the PineNote is used&lt;br /&gt;
# Fix the PineNote without opening the case if something goes wrong while [[PineNote Development/Flashing|flashing it]]&lt;br /&gt;
&lt;br /&gt;
Since the PineNote is an embedded system, interfacing with it during boot is more complicated than with an ordinary computer.&lt;br /&gt;
The UART dongle enables you to do this.&lt;br /&gt;
&lt;br /&gt;
The PineNote factory firmware runs UART at a baud rate of 1500000 bps, 8 data bits, 1 stop bit, no parity and no flow control.&lt;br /&gt;
The process by which the PineNote design was modified to include closed-case UART is documented [[PineNote/Hardware Changes/Closed Case UART|here]].&lt;br /&gt;
&lt;br /&gt;
== Stock dongle ==&lt;br /&gt;
&lt;br /&gt;
The stock UART dongle included with the PineNote was a simple device plugging directly into the PineNote's USB-C port.&lt;br /&gt;
The dongle exposed a female USB-C port, which the user plugged into to get UART access.&lt;br /&gt;
This design unfortunately ruled out passthrough USB connections, where the user connects to the PineNote via UART and USB simultaneously.&lt;br /&gt;
The dongle is not currently available for purchase.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Pinenote-stock-uart-dongle-front.jpg|Front&lt;br /&gt;
Pinenote-stock-uart-dongle-back.jpg|Back&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Creating a dongle ==&lt;br /&gt;
&lt;br /&gt;
A PineNote UART dongle has four components:&lt;br /&gt;
# A USB-C breakout board with a male connector exposing the 24 pins of the PineNote's female USB-C port (located on the bottom of the device)&lt;br /&gt;
# A USB-UART adapter, to plug into a USB port of the computer you'll use to interface with the PineNote&lt;br /&gt;
# [https://en.wikipedia.org/wiki/Jump_wire Jump wires] to connect specific breakout board pins to pins on the USB-UART adapter&lt;br /&gt;
# Electrical tape to wrap connectors and prevent shorts&lt;br /&gt;
&lt;br /&gt;
The PineNote's internal UART system is documented in [https://files.pine64.org/doc/PineNote/PineNote_USB-C_Console_UART_breakout_board_schematic_v1.0_20210903.pdf this schematic].&lt;br /&gt;
USB-C pins are documented [https://en.wikipedia.org/wiki/USB-C#Specifications on the USB-C Wikipedia page]; of the 24 pins, two are designated for &amp;quot;side band&amp;quot; use.&lt;br /&gt;
These pins are labeled SBU1 (A8) and SBU2 (B8).&lt;br /&gt;
In the PineNote UART schematic you can see (on the bottom right diagram) these pins are given the label &amp;lt;code&amp;gt;UART2_TX_SUB1&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;UART2_RX_SUB2&amp;lt;/code&amp;gt; respectively.&lt;br /&gt;
The first (TX) is used for transmitting data and the second (RX) is used for receiving data.&lt;br /&gt;
These are the pins which must be exposed by the breakout board.&lt;br /&gt;
&lt;br /&gt;
There are many possible USB-C breakout board designs available for purchase online.&lt;br /&gt;
One particularly useful design is a &amp;quot;passthrough&amp;quot; or &amp;quot;intercept&amp;quot; style, with both male and female USB-C ports.&lt;br /&gt;
This design is more versatile in case you want to reuse it in other projects, and also enables you to connect to the PineNote via UART and USB at the same time.&lt;br /&gt;
An example of this product can be found [https://pmdway.com/products/usb-3-1-type-c-male-to-female-breakout-test-board here], although you are encouraged to shop around for cheaper options.&lt;br /&gt;
&lt;br /&gt;
Similarly, there are many USB-UART adapter designs available.&lt;br /&gt;
These devices plug into your computer and expose a number of pins themselves, connecting to specific pins on the breakout board with jump wires.&lt;br /&gt;
[https://pmdway.com/products/usb-to-ttl-serial-cp2104-6-pin-converter-module Here] is one example with jump wires included, although you are again encouraged to shop around for alternatives.&lt;br /&gt;
&lt;br /&gt;
Once you have acquired all necessary components, assemble the UART dongle as follows:&lt;br /&gt;
# Connect a jump wire from the GND ([https://en.wikipedia.org/wiki/Ground_(electricity) ground]) pin on the USB-UART adapter to any one of the four GND pins on the USB-C breakout board (A1, A12, B1, or B12)&lt;br /&gt;
# Connect a jump wire from the RXD pin on the USB-UART adapter to the &amp;lt;code&amp;gt;UART2_TX_SUB2&amp;lt;/code&amp;gt; pin on the USB-C breakout board (SBU1 aka A8)&lt;br /&gt;
# Connect a jump wire from the TXD pin on the USB-UART adapter to the &amp;lt;code&amp;gt;UART2_RX_SUB2&amp;lt;/code&amp;gt; pin on the USB-C breakout board (SBU2 aka B8)&lt;br /&gt;
&lt;br /&gt;
Note that if you mix up the TX/RX pins, it will still work but the USB-C breakout board will just plug into the PineNote upside down.&lt;br /&gt;
You can therefore choose which orientation you want by swapping the TX/RX pin connections.&lt;br /&gt;
&lt;br /&gt;
Test that your system works by following the use instructions down below.&lt;br /&gt;
Be very careful not to touch or short the pins while current is flowing through them - this can damage your device!&lt;br /&gt;
Once you have confirmed that your UART dongle works, wrap all metal connectors in electrical tape to prevent accidental shorts.&lt;br /&gt;
&lt;br /&gt;
== Using UART ==&lt;br /&gt;
&lt;br /&gt;
First, use your UART dongle to physically connect your PineNote to your computer:&lt;br /&gt;
# Plug the USB-UART adapter into one of your computer's USB ports&lt;br /&gt;
# Plug the USB-C breakout board into the USB-C port on the bottom of your PineNote; the orientation matters, so try both and remember which one works&lt;br /&gt;
&lt;br /&gt;
Once the hardware is connected, set up your computer's software as follows:&lt;br /&gt;
# Install [https://www.gnu.org/software/screen/ GNU Screen] (or [https://askubuntu.com/q/40959 some other option], but the instructions below are written for &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt;)&lt;br /&gt;
# Identify the USB-UART adapter in your &amp;lt;code&amp;gt;/dev&amp;lt;/code&amp;gt; directory by running &amp;lt;code&amp;gt;ls /dev&amp;lt;/code&amp;gt; with it plugged in, unplugging it, then again running &amp;lt;code&amp;gt;ls /dev&amp;lt;/code&amp;gt; and seeing what changes; it is likely to be called &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;&lt;br /&gt;
# In a terminal window, run &amp;lt;code&amp;gt;screen -L /dev/ttyUSB0 1500000&amp;lt;/code&amp;gt; (you may need to run this as sudo depending on your user's permissions; on most Linux distributions you need to be in the &amp;lt;code&amp;gt;dialout&amp;lt;/code&amp;gt; usergroup)&lt;br /&gt;
&lt;br /&gt;
Once the software is set up, power-cycle your PineNote; as the system boots you should see text appearing in your terminal window.&lt;br /&gt;
You can exit the screen session with &amp;lt;code&amp;gt;ctrl+a k&amp;lt;/code&amp;gt; then pressing &amp;lt;code&amp;gt;y&amp;lt;/code&amp;gt; to confirm.&lt;br /&gt;
The &amp;lt;code&amp;gt;screen -L&amp;lt;/code&amp;gt; flag outputs a text log of the session to the current working directory, probably called &amp;lt;code&amp;gt;screenlog.0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Troubleshooting ====&lt;br /&gt;
&lt;br /&gt;
If you don't see any text in your terminal as the PineNote boots, or the text is garbled, try the following:&lt;br /&gt;
* Ensure your GND, RX and TX jump wires are connected to the correct pins on both the USB-UART adapter and the USB-C breakout board&lt;br /&gt;
* Connect your USB-C breakout board to your PineNote in the opposite orientation&lt;br /&gt;
* Run the screen command as sudo in case your user doesn't have appropriate permissions&lt;br /&gt;
* Ensure you are setting the baud rate in the &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt; command to 1500000 (1.5 million)&lt;br /&gt;
&lt;br /&gt;
== USB passthrough ==&lt;br /&gt;
&lt;br /&gt;
If your USB-C breakout board has a passthrough/intercept design, you can connect to your PineNote over USB and UART at the same time.&lt;br /&gt;
This can be useful when you're doing development work on the PineNote boot process so you don't have to continually reconnect cables.&lt;br /&gt;
You'll need a USB-A to USB-C cable, connecting directly from your computer's USB-A hub to your USB-C breakout board's female USB-C port.&lt;br /&gt;
It's important to connect directly from USB-A, without any intermediate USB-C components.&lt;br /&gt;
Note that connecting a live USB cable to your USB-C breakout board in this way dramatically increases the danger of frying your PineNote with a short, so you should only do this if all connectors are safely wrapped in electrical tape.&lt;br /&gt;
&lt;br /&gt;
[[Category:PineNote]]&lt;/div&gt;</summary>
		<author><name>Ahelwer</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PineNote_Development/UART&amp;diff=20873</id>
		<title>PineNote Development/UART</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PineNote_Development/UART&amp;diff=20873"/>
		<updated>2023-10-12T15:23:50Z</updated>

		<summary type="html">&lt;p&gt;Ahelwer: /* Creating a dongle */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Pinenote-uart-dongle.jpeg|thumb|Basic non-stock PineNote UART dongle]]&lt;br /&gt;
&lt;br /&gt;
This page contains information on creating and using a [https://en.wikipedia.org/wiki/Universal_asynchronous_receiver-transmitter UART] dongle for the [[PineNote]].&lt;br /&gt;
The PineNote was shipped with a compatible UART dongle, but replacements are not available to order in case of loss or hardware fault.&lt;br /&gt;
Thankfully it is not difficult to make your own from easily-acquired components.&lt;br /&gt;
&lt;br /&gt;
A PineNote UART dongle enables you to:&lt;br /&gt;
# Interact with the system boot menu&lt;br /&gt;
# Read system events in real time as the PineNote is used&lt;br /&gt;
# Fix the PineNote without opening the case if something goes wrong while [[PineNote Development/Flashing|flashing it]]&lt;br /&gt;
&lt;br /&gt;
Since the PineNote is an embedded system, interfacing with it during boot is more complicated than with an ordinary computer.&lt;br /&gt;
The UART dongle enables you to do this.&lt;br /&gt;
&lt;br /&gt;
The PineNote factory firmware runs UART at a baud rate of 1500000 bps, 8 data bits, 1 stop bit, no parity and no flow control.&lt;br /&gt;
The process by which the PineNote design was modified to include closed-case UART is documented [[PineNote/Hardware Changes/Closed Case UART|here]].&lt;br /&gt;
&lt;br /&gt;
== Stock dongle ==&lt;br /&gt;
&lt;br /&gt;
The stock UART dongle included with the PineNote was a simple device plugging directly into the PineNote's USB-C port.&lt;br /&gt;
The dongle exposed a female USB-C port, which the user plugged into to get UART access.&lt;br /&gt;
This design unfortunately ruled out passthrough USB connections, where the user connects to the PineNote via UART and USB simultaneously.&lt;br /&gt;
The dongle is not currently available for purchase.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Pinenote-stock-uart-dongle-front.jpg|Front&lt;br /&gt;
Pinenote-stock-uart-dongle-back.jpg|Back&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Creating a dongle ==&lt;br /&gt;
&lt;br /&gt;
A PineNote UART dongle has four components:&lt;br /&gt;
# A USB-C breakout board with a male connector exposing the 24 pins of the PineNote's female USB-C port (located on the bottom of the device)&lt;br /&gt;
# A USB-UART adapter, to plug into a USB port of the computer you'll use to interface with the PineNote&lt;br /&gt;
# [https://en.wikipedia.org/wiki/Jump_wire Jump wires] to connect specific breakout board pins to pins on the USB-UART adapter&lt;br /&gt;
# Electrical tape to wrap connectors and prevent shorts&lt;br /&gt;
&lt;br /&gt;
The PineNote's internal UART system is documented in [https://files.pine64.org/doc/PineNote/PineNote_USB-C_Console_UART_breakout_board_schematic_v1.0_20210903.pdf this schematic].&lt;br /&gt;
USB-C pins are documented [https://en.wikipedia.org/wiki/USB-C#Specifications on the USB-C Wikipedia page]; of the 24 pins, two are designated for &amp;quot;side band&amp;quot; use.&lt;br /&gt;
These pins are labeled SBU1 (A8) and SBU2 (B8).&lt;br /&gt;
In the PineNote UART schematic you can see (on the bottom right diagram) these pins are given the label &amp;lt;code&amp;gt;UART2_TX_SUB1&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;UART2_RX_SUB2&amp;lt;/code&amp;gt; respectively.&lt;br /&gt;
The first (TX) is used for transmitting data and the second (RX) is used for receiving data.&lt;br /&gt;
These are the pins which must be exposed by the breakout board.&lt;br /&gt;
&lt;br /&gt;
There are many possible USB-C breakout board designs available for purchase online.&lt;br /&gt;
One particularly useful design is a &amp;quot;passthrough&amp;quot; or &amp;quot;intercept&amp;quot; style, with both male and female USB-C ports.&lt;br /&gt;
This design is more versatile in case you want to reuse it in other projects, and also enables you to connect to the PineNote via UART and USB at the same time.&lt;br /&gt;
An example of this product can be found [https://pmdway.com/products/usb-3-1-type-c-male-to-female-breakout-test-board here], although you are encouraged to shop around for cheaper options.&lt;br /&gt;
&lt;br /&gt;
Similarly, there are many USB-UART adapter designs available.&lt;br /&gt;
These devices plug into your computer and expose a number of pins themselves, connecting to specific pins on the breakout board with jump wires.&lt;br /&gt;
[https://pmdway.com/products/usb-to-ttl-serial-cp2104-6-pin-converter-module Here] is one example with jump wires included, although you are again encouraged to shop around for alternatives.&lt;br /&gt;
&lt;br /&gt;
Once you have acquired all necessary components, assemble the UART dongle as follows:&lt;br /&gt;
# Connect a jump wire from the GND ([https://en.wikipedia.org/wiki/Ground_(electricity) ground]) pin on the USB-UART adapter to any one of the four GND pins on the USB-C breakout board (A1, A12, B1, or B12)&lt;br /&gt;
# Connect a jump wire from the RXD pin on the USB-UART adapter to the &amp;lt;code&amp;gt;UART2_TX_SUB2&amp;lt;/code&amp;gt; pin on the USB-C breakout board (SBU1 aka A8)&lt;br /&gt;
# Connect a jump wire from the TXD pin on the USB-UART adapter to the &amp;lt;code&amp;gt;UART2_RX_SUB2&amp;lt;/code&amp;gt; pin on the USB-C breakout board (SBU2 aka B8)&lt;br /&gt;
&lt;br /&gt;
Note that if you mix up the TX/RX pins, it will still work but the USB-C breakout board will just plug into the PineNote upside down.&lt;br /&gt;
You can therefore choose what orientation you want by swapping the TX/RX pin connections.&lt;br /&gt;
&lt;br /&gt;
Test that your system works by following the use instructions down below.&lt;br /&gt;
Be very careful not to touch or short the pins while current is flowing through them - this can damage your device!&lt;br /&gt;
Once you have confirmed that your UART dongle works, wrap all metal connectors in electrical tape to prevent accidental shorts.&lt;br /&gt;
&lt;br /&gt;
== Using UART ==&lt;br /&gt;
&lt;br /&gt;
First, use your UART dongle to physically connect your PineNote to your computer:&lt;br /&gt;
# Plug the USB-UART adapter into one of your computer's USB ports&lt;br /&gt;
# Plug the USB-C breakout board into the USB-C port on the bottom of your PineNote; the orientation matters, so try both and remember which one works&lt;br /&gt;
&lt;br /&gt;
Once the hardware is connected, set up your computer's software as follows:&lt;br /&gt;
# Install [https://www.gnu.org/software/screen/ GNU Screen] (or [https://askubuntu.com/q/40959 some other option], but the instructions below are written for &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt;)&lt;br /&gt;
# Identify the USB-UART adapter in your &amp;lt;code&amp;gt;/dev&amp;lt;/code&amp;gt; directory by running &amp;lt;code&amp;gt;ls /dev&amp;lt;/code&amp;gt; with it plugged in, unplugging it, then again running &amp;lt;code&amp;gt;ls /dev&amp;lt;/code&amp;gt; and seeing what changes; it is likely to be called &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;&lt;br /&gt;
# In a terminal window, run &amp;lt;code&amp;gt;screen -L /dev/ttyUSB0 1500000&amp;lt;/code&amp;gt; (you may need to run this as sudo depending on your user's permissions; on most Linux distributions you need to be in the &amp;lt;code&amp;gt;dialout&amp;lt;/code&amp;gt; usergroup)&lt;br /&gt;
&lt;br /&gt;
Once the software is set up, power-cycle your PineNote; as the system boots you should see text appearing in your terminal window.&lt;br /&gt;
You can exit the screen session with &amp;lt;code&amp;gt;ctrl+a k&amp;lt;/code&amp;gt; then pressing &amp;lt;code&amp;gt;y&amp;lt;/code&amp;gt; to confirm.&lt;br /&gt;
The &amp;lt;code&amp;gt;screen -L&amp;lt;/code&amp;gt; flag outputs a text log of the session to the current working directory, probably called &amp;lt;code&amp;gt;screenlog.0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Troubleshooting ====&lt;br /&gt;
&lt;br /&gt;
If you don't see any text in your terminal as the PineNote boots, or the text is garbled, try the following:&lt;br /&gt;
* Ensure your GND, RX and TX jump wires are connected to the correct pins on both the USB-UART adapter and the USB-C breakout board&lt;br /&gt;
* Connect your USB-C breakout board to your PineNote in the opposite orientation&lt;br /&gt;
* Run the screen command as sudo in case your user doesn't have appropriate permissions&lt;br /&gt;
* Ensure you are setting the baud rate in the &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt; command to 1500000 (1.5 million)&lt;br /&gt;
&lt;br /&gt;
== USB passthrough ==&lt;br /&gt;
&lt;br /&gt;
If your USB-C breakout board has a passthrough/intercept design, you can connect to your PineNote over USB and UART at the same time.&lt;br /&gt;
This can be useful when you're doing development work on the PineNote boot process so you don't have to continually reconnect cables.&lt;br /&gt;
You'll need a USB-A to USB-C cable, connecting directly from your computer's USB-A hub to your USB-C breakout board's female USB-C port.&lt;br /&gt;
It's important to connect directly from USB-A, without any intermediate USB-C components.&lt;br /&gt;
Note that connecting a live USB cable to your USB-C breakout board in this way dramatically increases the danger of frying your PineNote with a short, so you should only do this if all connectors are safely wrapped in electrical tape.&lt;br /&gt;
&lt;br /&gt;
[[Category:PineNote]]&lt;/div&gt;</summary>
		<author><name>Ahelwer</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PineNote_Development/UART&amp;diff=20872</id>
		<title>PineNote Development/UART</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PineNote_Development/UART&amp;diff=20872"/>
		<updated>2023-10-12T15:22:03Z</updated>

		<summary type="html">&lt;p&gt;Ahelwer: TX/RX pin connections and orientation&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Pinenote-uart-dongle.jpeg|thumb|Basic non-stock PineNote UART dongle]]&lt;br /&gt;
&lt;br /&gt;
This page contains information on creating and using a [https://en.wikipedia.org/wiki/Universal_asynchronous_receiver-transmitter UART] dongle for the [[PineNote]].&lt;br /&gt;
The PineNote was shipped with a compatible UART dongle, but replacements are not available to order in case of loss or hardware fault.&lt;br /&gt;
Thankfully it is not difficult to make your own from easily-acquired components.&lt;br /&gt;
&lt;br /&gt;
A PineNote UART dongle enables you to:&lt;br /&gt;
# Interact with the system boot menu&lt;br /&gt;
# Read system events in real time as the PineNote is used&lt;br /&gt;
# Fix the PineNote without opening the case if something goes wrong while [[PineNote Development/Flashing|flashing it]]&lt;br /&gt;
&lt;br /&gt;
Since the PineNote is an embedded system, interfacing with it during boot is more complicated than with an ordinary computer.&lt;br /&gt;
The UART dongle enables you to do this.&lt;br /&gt;
&lt;br /&gt;
The PineNote factory firmware runs UART at a baud rate of 1500000 bps, 8 data bits, 1 stop bit, no parity and no flow control.&lt;br /&gt;
The process by which the PineNote design was modified to include closed-case UART is documented [[PineNote/Hardware Changes/Closed Case UART|here]].&lt;br /&gt;
&lt;br /&gt;
== Stock dongle ==&lt;br /&gt;
&lt;br /&gt;
The stock UART dongle included with the PineNote was a simple device plugging directly into the PineNote's USB-C port.&lt;br /&gt;
The dongle exposed a female USB-C port, which the user plugged into to get UART access.&lt;br /&gt;
This design unfortunately ruled out passthrough USB connections, where the user connects to the PineNote via UART and USB simultaneously.&lt;br /&gt;
The dongle is not currently available for purchase.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Pinenote-stock-uart-dongle-front.jpg|Front&lt;br /&gt;
Pinenote-stock-uart-dongle-back.jpg|Back&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Creating a dongle ==&lt;br /&gt;
&lt;br /&gt;
A PineNote UART dongle has four components:&lt;br /&gt;
# A USB-C breakout board with a male connector exposing the 24 pins of the PineNote's female USB-C port (located on the bottom of the device)&lt;br /&gt;
# A USB-UART adapter, to plug into a USB port of the computer you'll use to interface with the PineNote&lt;br /&gt;
# [https://en.wikipedia.org/wiki/Jump_wire Jump wires] to connect specific breakout board pins to pins on the USB-UART adapter&lt;br /&gt;
# Electrical tape to wrap connectors and prevent shorts&lt;br /&gt;
&lt;br /&gt;
The PineNote's internal UART system is documented in [https://files.pine64.org/doc/PineNote/PineNote_USB-C_Console_UART_breakout_board_schematic_v1.0_20210903.pdf this schematic].&lt;br /&gt;
USB-C pins are documented [https://en.wikipedia.org/wiki/USB-C#Specifications on the USB-C Wikipedia page]; of the 24 pins, two are designated for &amp;quot;side band&amp;quot; use.&lt;br /&gt;
These pins are labeled SBU1 (A8) and SBU2 (B8).&lt;br /&gt;
In the PineNote UART schematic you can see (on the bottom right diagram) these pins are given the label &amp;lt;code&amp;gt;UART2_TX_SUB1&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;UART2_RX_SUB2&amp;lt;/code&amp;gt; respectively.&lt;br /&gt;
The first (TX) is used for transmitting data and the second (RX) is used for receiving data.&lt;br /&gt;
These are the pins which must be exposed by the breakout board.&lt;br /&gt;
&lt;br /&gt;
There are many possible USB-C breakout board designs available for purchase online.&lt;br /&gt;
One particularly useful design is a &amp;quot;passthrough&amp;quot; or &amp;quot;intercept&amp;quot; style, with both male and female USB-C ports.&lt;br /&gt;
This design is more versatile in case you want to reuse it in other projects, and also enables you to connect to the PineNote via UART and USB at the same time.&lt;br /&gt;
An example of this product can be found [https://pmdway.com/products/usb-3-1-type-c-male-to-female-breakout-test-board here], although you are encouraged to shop around for cheaper options.&lt;br /&gt;
&lt;br /&gt;
Similarly, there are many USB-UART adapter designs available.&lt;br /&gt;
These devices plug into your computer and expose a number of pins themselves, connecting to specific pins on the breakout board with jump wires.&lt;br /&gt;
[https://pmdway.com/products/usb-to-ttl-serial-cp2104-6-pin-converter-module Here] is one example with jump wires included, although you are again encouraged to shop around for alternatives.&lt;br /&gt;
&lt;br /&gt;
Once you have acquired all necessary components, assemble the UART dongle as follows:&lt;br /&gt;
# Connect a jump wire from the GND ([https://en.wikipedia.org/wiki/Ground_(electricity) ground]) pin on the USB-UART adapter to any one of the four GND pins on the USB-C breakout board (A1, A12, B1, or B12)&lt;br /&gt;
# Connect a jump wire from the RXD pin on the USB-UART adapter to the &amp;lt;code&amp;gt;UART2_TX_SUB2&amp;lt;/code&amp;gt; pin on the USB-C breakout board (SBU1 aka A8)&lt;br /&gt;
# Connect a jump wire from the TXD pin on the USB-UART adapter to the &amp;lt;code&amp;gt;UART2_RX_SUB2&amp;lt;/code&amp;gt; pin on the USB-C breakout board (SBU2 aka B8)&lt;br /&gt;
&lt;br /&gt;
Note that if you mix up the TX/RX pins, it will still work but the USB-C breakout board will just plug into the PineNote upside down.&lt;br /&gt;
You can thus control the orientation of the PineNote with your UART dongle plugged in by swapping the TX/RX pin connections.&lt;br /&gt;
&lt;br /&gt;
Test that your system works by following the use instructions down below.&lt;br /&gt;
Be very careful not to touch or short the pins while current is flowing through them - this can damage your device!&lt;br /&gt;
Once you have confirmed that your UART dongle works, wrap all metal connectors in electrical tape to prevent accidental shorts.&lt;br /&gt;
&lt;br /&gt;
== Using UART ==&lt;br /&gt;
&lt;br /&gt;
First, use your UART dongle to physically connect your PineNote to your computer:&lt;br /&gt;
# Plug the USB-UART adapter into one of your computer's USB ports&lt;br /&gt;
# Plug the USB-C breakout board into the USB-C port on the bottom of your PineNote; the orientation matters, so try both and remember which one works&lt;br /&gt;
&lt;br /&gt;
Once the hardware is connected, set up your computer's software as follows:&lt;br /&gt;
# Install [https://www.gnu.org/software/screen/ GNU Screen] (or [https://askubuntu.com/q/40959 some other option], but the instructions below are written for &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt;)&lt;br /&gt;
# Identify the USB-UART adapter in your &amp;lt;code&amp;gt;/dev&amp;lt;/code&amp;gt; directory by running &amp;lt;code&amp;gt;ls /dev&amp;lt;/code&amp;gt; with it plugged in, unplugging it, then again running &amp;lt;code&amp;gt;ls /dev&amp;lt;/code&amp;gt; and seeing what changes; it is likely to be called &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;&lt;br /&gt;
# In a terminal window, run &amp;lt;code&amp;gt;screen -L /dev/ttyUSB0 1500000&amp;lt;/code&amp;gt; (you may need to run this as sudo depending on your user's permissions; on most Linux distributions you need to be in the &amp;lt;code&amp;gt;dialout&amp;lt;/code&amp;gt; usergroup)&lt;br /&gt;
&lt;br /&gt;
Once the software is set up, power-cycle your PineNote; as the system boots you should see text appearing in your terminal window.&lt;br /&gt;
You can exit the screen session with &amp;lt;code&amp;gt;ctrl+a k&amp;lt;/code&amp;gt; then pressing &amp;lt;code&amp;gt;y&amp;lt;/code&amp;gt; to confirm.&lt;br /&gt;
The &amp;lt;code&amp;gt;screen -L&amp;lt;/code&amp;gt; flag outputs a text log of the session to the current working directory, probably called &amp;lt;code&amp;gt;screenlog.0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Troubleshooting ====&lt;br /&gt;
&lt;br /&gt;
If you don't see any text in your terminal as the PineNote boots, or the text is garbled, try the following:&lt;br /&gt;
* Ensure your GND, RX and TX jump wires are connected to the correct pins on both the USB-UART adapter and the USB-C breakout board&lt;br /&gt;
* Connect your USB-C breakout board to your PineNote in the opposite orientation&lt;br /&gt;
* Run the screen command as sudo in case your user doesn't have appropriate permissions&lt;br /&gt;
* Ensure you are setting the baud rate in the &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt; command to 1500000 (1.5 million)&lt;br /&gt;
&lt;br /&gt;
== USB passthrough ==&lt;br /&gt;
&lt;br /&gt;
If your USB-C breakout board has a passthrough/intercept design, you can connect to your PineNote over USB and UART at the same time.&lt;br /&gt;
This can be useful when you're doing development work on the PineNote boot process so you don't have to continually reconnect cables.&lt;br /&gt;
You'll need a USB-A to USB-C cable, connecting directly from your computer's USB-A hub to your USB-C breakout board's female USB-C port.&lt;br /&gt;
It's important to connect directly from USB-A, without any intermediate USB-C components.&lt;br /&gt;
Note that connecting a live USB cable to your USB-C breakout board in this way dramatically increases the danger of frying your PineNote with a short, so you should only do this if all connectors are safely wrapped in electrical tape.&lt;br /&gt;
&lt;br /&gt;
[[Category:PineNote]]&lt;/div&gt;</summary>
		<author><name>Ahelwer</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PineNote_Development/UART&amp;diff=20871</id>
		<title>PineNote Development/UART</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PineNote_Development/UART&amp;diff=20871"/>
		<updated>2023-10-12T15:17:33Z</updated>

		<summary type="html">&lt;p&gt;Ahelwer: /* Creating a dongle */ reverse TXD/RXD pin instructions&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Pinenote-uart-dongle.jpeg|thumb|Basic non-stock PineNote UART dongle]]&lt;br /&gt;
&lt;br /&gt;
This page contains information on creating and using a [https://en.wikipedia.org/wiki/Universal_asynchronous_receiver-transmitter UART] dongle for the [[PineNote]].&lt;br /&gt;
The PineNote was shipped with a compatible UART dongle, but replacements are not available to order in case of loss or hardware fault.&lt;br /&gt;
Thankfully it is not difficult to make your own from easily-acquired components.&lt;br /&gt;
&lt;br /&gt;
A PineNote UART dongle enables you to:&lt;br /&gt;
# Interact with the system boot menu&lt;br /&gt;
# Read system events in real time as the PineNote is used&lt;br /&gt;
# Fix the PineNote without opening the case if something goes wrong while [[PineNote Development/Flashing|flashing it]]&lt;br /&gt;
&lt;br /&gt;
Since the PineNote is an embedded system, interfacing with it during boot is more complicated than with an ordinary computer.&lt;br /&gt;
The UART dongle enables you to do this.&lt;br /&gt;
&lt;br /&gt;
The PineNote factory firmware runs UART at a baud rate of 1500000 bps, 8 data bits, 1 stop bit, no parity and no flow control.&lt;br /&gt;
The process by which the PineNote design was modified to include closed-case UART is documented [[PineNote/Hardware Changes/Closed Case UART|here]].&lt;br /&gt;
&lt;br /&gt;
== Stock dongle ==&lt;br /&gt;
&lt;br /&gt;
The stock UART dongle included with the PineNote was a simple device plugging directly into the PineNote's USB-C port.&lt;br /&gt;
The dongle exposed a female USB-C port, which the user plugged into to get UART access.&lt;br /&gt;
This design unfortunately ruled out passthrough USB connections, where the user connects to the PineNote via UART and USB simultaneously.&lt;br /&gt;
The dongle is not currently available for purchase.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Pinenote-stock-uart-dongle-front.jpg|Front&lt;br /&gt;
Pinenote-stock-uart-dongle-back.jpg|Back&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Creating a dongle ==&lt;br /&gt;
&lt;br /&gt;
A PineNote UART dongle has four components:&lt;br /&gt;
# A USB-C breakout board with a male connector exposing the 24 pins of the PineNote's female USB-C port (located on the bottom of the device)&lt;br /&gt;
# A USB-UART adapter, to plug into a USB port of the computer you'll use to interface with the PineNote&lt;br /&gt;
# [https://en.wikipedia.org/wiki/Jump_wire Jump wires] to connect specific breakout board pins to pins on the USB-UART adapter&lt;br /&gt;
# Electrical tape to wrap connectors and prevent shorts&lt;br /&gt;
&lt;br /&gt;
The PineNote's internal UART system is documented in [https://files.pine64.org/doc/PineNote/PineNote_USB-C_Console_UART_breakout_board_schematic_v1.0_20210903.pdf this schematic].&lt;br /&gt;
USB-C pins are documented [https://en.wikipedia.org/wiki/USB-C#Specifications on the USB-C Wikipedia page]; of the 24 pins, two are designated for &amp;quot;side band&amp;quot; use.&lt;br /&gt;
These pins are labeled SBU1 (A8) and SBU2 (B8).&lt;br /&gt;
In the PineNote UART schematic you can see (on the bottom right diagram) these pins are given the label &amp;lt;code&amp;gt;UART2_TX_SUB1&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;UART2_RX_SUB2&amp;lt;/code&amp;gt; respectively.&lt;br /&gt;
The first (TX) is used for transmitting data and the second (RX) is used for receiving data.&lt;br /&gt;
These are the pins which must be exposed by the breakout board.&lt;br /&gt;
&lt;br /&gt;
There are many possible USB-C breakout board designs available for purchase online.&lt;br /&gt;
One particularly useful design is a &amp;quot;passthrough&amp;quot; or &amp;quot;intercept&amp;quot; style, with both male and female USB-C ports.&lt;br /&gt;
This design is more versatile in case you want to reuse it in other projects, and also enables you to connect to the PineNote via UART and USB at the same time.&lt;br /&gt;
An example of this product can be found [https://pmdway.com/products/usb-3-1-type-c-male-to-female-breakout-test-board here], although you are encouraged to shop around for cheaper options.&lt;br /&gt;
&lt;br /&gt;
Similarly, there are many USB-UART adapter designs available.&lt;br /&gt;
These devices plug into your computer and expose a number of pins themselves, connecting to specific pins on the breakout board with jump wires.&lt;br /&gt;
[https://pmdway.com/products/usb-to-ttl-serial-cp2104-6-pin-converter-module Here] is one example with jump wires included, although you are again encouraged to shop around for alternatives.&lt;br /&gt;
&lt;br /&gt;
Once you have acquired all necessary components, assemble the UART dongle as follows:&lt;br /&gt;
# Connect a jump wire from the GND ([https://en.wikipedia.org/wiki/Ground_(electricity) ground]) pin on the USB-UART adapter to one of the four GND pins on the USB-C breakout board (A1, A12, B1, or B12)&lt;br /&gt;
# Connect a jump wire from the TXD pin on the USB-UART adapter to the &amp;lt;code&amp;gt;UART2_RX_SUB2&amp;lt;/code&amp;gt; pin on the USB-C breakout board (SBU2 aka B8)&lt;br /&gt;
# Connect a jump wire from the RXD pin on the USB-UART adapter to the &amp;lt;code&amp;gt;UART2_TX_SUB2&amp;lt;/code&amp;gt; pin on the USB-C breakout board (SBU1 aka A8)&lt;br /&gt;
&lt;br /&gt;
Test that your system works by following the use instructions down below.&lt;br /&gt;
Be very careful not to touch or short the pins while current is flowing through them - this can damage your device!&lt;br /&gt;
Once you have confirmed that your UART dongle works, wrap all metal connectors in electrical tape to prevent accidental shorts.&lt;br /&gt;
&lt;br /&gt;
== Using UART ==&lt;br /&gt;
&lt;br /&gt;
First, use your UART dongle to physically connect your PineNote to your computer:&lt;br /&gt;
# Plug the USB-UART adapter into one of your computer's USB ports&lt;br /&gt;
# Plug the USB-C breakout board into the USB-C port on the bottom of your PineNote; it is likely that the orientation matters, so try both and remember which one works&lt;br /&gt;
&lt;br /&gt;
Once the hardware is connected, set up your computer's software as follows:&lt;br /&gt;
# Install [https://www.gnu.org/software/screen/ GNU Screen] (or [https://askubuntu.com/q/40959 some other option], but the instructions below are written for &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt;)&lt;br /&gt;
# Identify the USB-UART adapter in your &amp;lt;code&amp;gt;/dev&amp;lt;/code&amp;gt; directory by running &amp;lt;code&amp;gt;ls /dev&amp;lt;/code&amp;gt; with it plugged in, unplugging it, then again running &amp;lt;code&amp;gt;ls /dev&amp;lt;/code&amp;gt; and seeing what changes; it is likely to be called &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;&lt;br /&gt;
# In a terminal window, run &amp;lt;code&amp;gt;screen -L /dev/ttyUSB0 1500000&amp;lt;/code&amp;gt; (you may need to run this as sudo depending on your user's permissions; on most Linux distributions you need to be in the &amp;lt;code&amp;gt;dialout&amp;lt;/code&amp;gt; usergroup)&lt;br /&gt;
&lt;br /&gt;
Once the software is set up, power-cycle your PineNote; as the system boots you should see text appearing in your terminal window.&lt;br /&gt;
You can exit the screen session with &amp;lt;code&amp;gt;ctrl+a k&amp;lt;/code&amp;gt; then pressing &amp;lt;code&amp;gt;y&amp;lt;/code&amp;gt; to confirm.&lt;br /&gt;
The &amp;lt;code&amp;gt;screen -L&amp;lt;/code&amp;gt; flag outputs a text log of the session to the current working directory, probably called &amp;lt;code&amp;gt;screenlog.0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Troubleshooting ====&lt;br /&gt;
&lt;br /&gt;
If you don't see any text in your terminal as the PineNote boots, or the text is garbled, try the following:&lt;br /&gt;
* Ensure your GND, RX and TX jump wires are connected to the correct pins on both the USB-UART adapter and the USB-C breakout board&lt;br /&gt;
* Connect your USB-C breakout board to your PineNote in the opposite orientation&lt;br /&gt;
* Run the screen command as sudo in case your user doesn't have appropriate permissions&lt;br /&gt;
* Ensure you are setting the baud rate in the &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt; command to 1500000 (1.5 million)&lt;br /&gt;
&lt;br /&gt;
== USB passthrough ==&lt;br /&gt;
&lt;br /&gt;
If your USB-C breakout board has a passthrough/intercept design, you can connect to your PineNote over USB and UART at the same time.&lt;br /&gt;
This can be useful when you're doing development work on the PineNote boot process so you don't have to continually reconnect cables.&lt;br /&gt;
You'll need a USB-A to USB-C cable, connecting directly from your computer's USB-A hub to your USB-C breakout board's female USB-C port.&lt;br /&gt;
It's important to connect directly from USB-A, without any intermediate USB-C components.&lt;br /&gt;
Note that connecting a live USB cable to your USB-C breakout board in this way dramatically increases the danger of frying your PineNote with a short, so you should only do this if all connectors are safely wrapped in electrical tape.&lt;br /&gt;
&lt;br /&gt;
[[Category:PineNote]]&lt;/div&gt;</summary>
		<author><name>Ahelwer</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PineNote_Development/UART&amp;diff=20870</id>
		<title>PineNote Development/UART</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PineNote_Development/UART&amp;diff=20870"/>
		<updated>2023-10-12T13:19:45Z</updated>

		<summary type="html">&lt;p&gt;Ahelwer: /* Using UART */ added note about dialout usergroup&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Pinenote-uart-dongle.jpeg|thumb|Basic non-stock PineNote UART dongle]]&lt;br /&gt;
&lt;br /&gt;
This page contains information on creating and using a [https://en.wikipedia.org/wiki/Universal_asynchronous_receiver-transmitter UART] dongle for the [[PineNote]].&lt;br /&gt;
The PineNote was shipped with a compatible UART dongle, but replacements are not available to order in case of loss or hardware fault.&lt;br /&gt;
Thankfully it is not difficult to make your own from easily-acquired components.&lt;br /&gt;
&lt;br /&gt;
A PineNote UART dongle enables you to:&lt;br /&gt;
# Interact with the system boot menu&lt;br /&gt;
# Read system events in real time as the PineNote is used&lt;br /&gt;
# Fix the PineNote without opening the case if something goes wrong while [[PineNote Development/Flashing|flashing it]]&lt;br /&gt;
&lt;br /&gt;
Since the PineNote is an embedded system, interfacing with it during boot is more complicated than with an ordinary computer.&lt;br /&gt;
The UART dongle enables you to do this.&lt;br /&gt;
&lt;br /&gt;
The PineNote factory firmware runs UART at a baud rate of 1500000 bps, 8 data bits, 1 stop bit, no parity and no flow control.&lt;br /&gt;
The process by which the PineNote design was modified to include closed-case UART is documented [[PineNote/Hardware Changes/Closed Case UART|here]].&lt;br /&gt;
&lt;br /&gt;
== Stock dongle ==&lt;br /&gt;
&lt;br /&gt;
The stock UART dongle included with the PineNote was a simple device plugging directly into the PineNote's USB-C port.&lt;br /&gt;
The dongle exposed a female USB-C port, which the user plugged into to get UART access.&lt;br /&gt;
This design unfortunately ruled out passthrough USB connections, where the user connects to the PineNote via UART and USB simultaneously.&lt;br /&gt;
The dongle is not currently available for purchase.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Pinenote-stock-uart-dongle-front.jpg|Front&lt;br /&gt;
Pinenote-stock-uart-dongle-back.jpg|Back&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Creating a dongle ==&lt;br /&gt;
&lt;br /&gt;
A PineNote UART dongle has four components:&lt;br /&gt;
# A USB-C breakout board with a male connector exposing the 24 pins of the PineNote's female USB-C port (located on the bottom of the device)&lt;br /&gt;
# A USB-UART adapter, to plug into a USB port of the computer you'll use to interface with the PineNote&lt;br /&gt;
# [https://en.wikipedia.org/wiki/Jump_wire Jump wires] to connect specific breakout board pins to pins on the USB-UART adapter&lt;br /&gt;
# Electrical tape to wrap connectors and prevent shorts&lt;br /&gt;
&lt;br /&gt;
The PineNote's internal UART system is documented in [https://files.pine64.org/doc/PineNote/PineNote_USB-C_Console_UART_breakout_board_schematic_v1.0_20210903.pdf this schematic].&lt;br /&gt;
USB-C pins are documented [https://en.wikipedia.org/wiki/USB-C#Specifications on the USB-C Wikipedia page]; of the 24 pins, two are designated for &amp;quot;side band&amp;quot; use.&lt;br /&gt;
These pins are labeled SBU1 (A8) and SBU2 (B8).&lt;br /&gt;
In the PineNote UART schematic you can see (on the bottom right diagram) these pins are given the label &amp;lt;code&amp;gt;UART2_TX_SUB1&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;UART2_RX_SUB2&amp;lt;/code&amp;gt; respectively.&lt;br /&gt;
The first (TX) is used for transmitting data and the second (RX) is used for receiving data.&lt;br /&gt;
These are the pins which must be exposed by the breakout board.&lt;br /&gt;
&lt;br /&gt;
There are many possible USB-C breakout board designs available for purchase online.&lt;br /&gt;
One particularly useful design is a &amp;quot;passthrough&amp;quot; or &amp;quot;intercept&amp;quot; style, with both male and female USB-C ports.&lt;br /&gt;
This design is more versatile in case you want to reuse it in other projects, and also enables you to connect to the PineNote via UART and USB at the same time.&lt;br /&gt;
An example of this product can be found [https://pmdway.com/products/usb-3-1-type-c-male-to-female-breakout-test-board here], although you are encouraged to shop around for cheaper options.&lt;br /&gt;
&lt;br /&gt;
Similarly, there are many USB-UART adapter designs available.&lt;br /&gt;
These devices plug into your computer and expose a number of pins themselves, connecting to specific pins on the breakout board with jump wires.&lt;br /&gt;
[https://pmdway.com/products/usb-to-ttl-serial-cp2104-6-pin-converter-module Here] is one example with jump wires included, although you are again encouraged to shop around for alternatives.&lt;br /&gt;
&lt;br /&gt;
Once you have acquired all necessary components, assemble the UART dongle as follows:&lt;br /&gt;
# Connect a jump wire from the GND ([https://en.wikipedia.org/wiki/Ground_(electricity) ground]) pin on the USB-UART adapter to one of the four GND pins on the USB-C breakout board (A1, A12, B1, or B12)&lt;br /&gt;
# Connect a jump wire from the RXD pin on the USB-UART adapter to the &amp;lt;code&amp;gt;UART2_RX_SUB2&amp;lt;/code&amp;gt; pin on the USB-C breakout board (SBU2 aka B8)&lt;br /&gt;
# Connect a jump wire from the TXD pin on the USB-UART adapter to the &amp;lt;code&amp;gt;UART2_TX_SUB2&amp;lt;/code&amp;gt; pin on the USB-C breakout board (SBU1 aka A8)&lt;br /&gt;
&lt;br /&gt;
Test that your system works by following the use instructions down below.&lt;br /&gt;
Be very careful not to touch or short the pins while current is flowing through them - this can damage your device!&lt;br /&gt;
Once you have confirmed that your UART dongle works, wrap all metal connectors in electrical tape to prevent accidental shorts.&lt;br /&gt;
&lt;br /&gt;
== Using UART ==&lt;br /&gt;
&lt;br /&gt;
First, use your UART dongle to physically connect your PineNote to your computer:&lt;br /&gt;
# Plug the USB-UART adapter into one of your computer's USB ports&lt;br /&gt;
# Plug the USB-C breakout board into the USB-C port on the bottom of your PineNote; it is likely that the orientation matters, so try both and remember which one works&lt;br /&gt;
&lt;br /&gt;
Once the hardware is connected, set up your computer's software as follows:&lt;br /&gt;
# Install [https://www.gnu.org/software/screen/ GNU Screen] (or [https://askubuntu.com/q/40959 some other option], but the instructions below are written for &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt;)&lt;br /&gt;
# Identify the USB-UART adapter in your &amp;lt;code&amp;gt;/dev&amp;lt;/code&amp;gt; directory by running &amp;lt;code&amp;gt;ls /dev&amp;lt;/code&amp;gt; with it plugged in, unplugging it, then again running &amp;lt;code&amp;gt;ls /dev&amp;lt;/code&amp;gt; and seeing what changes; it is likely to be called &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;&lt;br /&gt;
# In a terminal window, run &amp;lt;code&amp;gt;screen -L /dev/ttyUSB0 1500000&amp;lt;/code&amp;gt; (you may need to run this as sudo depending on your user's permissions; on most Linux distributions you need to be in the &amp;lt;code&amp;gt;dialout&amp;lt;/code&amp;gt; usergroup)&lt;br /&gt;
&lt;br /&gt;
Once the software is set up, power-cycle your PineNote; as the system boots you should see text appearing in your terminal window.&lt;br /&gt;
You can exit the screen session with &amp;lt;code&amp;gt;ctrl+a k&amp;lt;/code&amp;gt; then pressing &amp;lt;code&amp;gt;y&amp;lt;/code&amp;gt; to confirm.&lt;br /&gt;
The &amp;lt;code&amp;gt;screen -L&amp;lt;/code&amp;gt; flag outputs a text log of the session to the current working directory, probably called &amp;lt;code&amp;gt;screenlog.0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Troubleshooting ====&lt;br /&gt;
&lt;br /&gt;
If you don't see any text in your terminal as the PineNote boots, or the text is garbled, try the following:&lt;br /&gt;
* Ensure your GND, RX and TX jump wires are connected to the correct pins on both the USB-UART adapter and the USB-C breakout board&lt;br /&gt;
* Connect your USB-C breakout board to your PineNote in the opposite orientation&lt;br /&gt;
* Run the screen command as sudo in case your user doesn't have appropriate permissions&lt;br /&gt;
* Ensure you are setting the baud rate in the &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt; command to 1500000 (1.5 million)&lt;br /&gt;
&lt;br /&gt;
== USB passthrough ==&lt;br /&gt;
&lt;br /&gt;
If your USB-C breakout board has a passthrough/intercept design, you can connect to your PineNote over USB and UART at the same time.&lt;br /&gt;
This can be useful when you're doing development work on the PineNote boot process so you don't have to continually reconnect cables.&lt;br /&gt;
You'll need a USB-A to USB-C cable, connecting directly from your computer's USB-A hub to your USB-C breakout board's female USB-C port.&lt;br /&gt;
It's important to connect directly from USB-A, without any intermediate USB-C components.&lt;br /&gt;
Note that connecting a live USB cable to your USB-C breakout board in this way dramatically increases the danger of frying your PineNote with a short, so you should only do this if all connectors are safely wrapped in electrical tape.&lt;br /&gt;
&lt;br /&gt;
[[Category:PineNote]]&lt;/div&gt;</summary>
		<author><name>Ahelwer</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PineNote_Development/UART&amp;diff=20869</id>
		<title>PineNote Development/UART</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PineNote_Development/UART&amp;diff=20869"/>
		<updated>2023-10-12T13:10:17Z</updated>

		<summary type="html">&lt;p&gt;Ahelwer: Added explanatory links to wikipedia&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Pinenote-uart-dongle.jpeg|thumb|Basic non-stock PineNote UART dongle]]&lt;br /&gt;
&lt;br /&gt;
This page contains information on creating and using a [https://en.wikipedia.org/wiki/Universal_asynchronous_receiver-transmitter UART] dongle for the [[PineNote]].&lt;br /&gt;
The PineNote was shipped with a compatible UART dongle, but replacements are not available to order in case of loss or hardware fault.&lt;br /&gt;
Thankfully it is not difficult to make your own from easily-acquired components.&lt;br /&gt;
&lt;br /&gt;
A PineNote UART dongle enables you to:&lt;br /&gt;
# Interact with the system boot menu&lt;br /&gt;
# Read system events in real time as the PineNote is used&lt;br /&gt;
# Fix the PineNote without opening the case if something goes wrong while [[PineNote Development/Flashing|flashing it]]&lt;br /&gt;
&lt;br /&gt;
Since the PineNote is an embedded system, interfacing with it during boot is more complicated than with an ordinary computer.&lt;br /&gt;
The UART dongle enables you to do this.&lt;br /&gt;
&lt;br /&gt;
The PineNote factory firmware runs UART at a baud rate of 1500000 bps, 8 data bits, 1 stop bit, no parity and no flow control.&lt;br /&gt;
The process by which the PineNote design was modified to include closed-case UART is documented [[PineNote/Hardware Changes/Closed Case UART|here]].&lt;br /&gt;
&lt;br /&gt;
== Stock dongle ==&lt;br /&gt;
&lt;br /&gt;
The stock UART dongle included with the PineNote was a simple device plugging directly into the PineNote's USB-C port.&lt;br /&gt;
The dongle exposed a female USB-C port, which the user plugged into to get UART access.&lt;br /&gt;
This design unfortunately ruled out passthrough USB connections, where the user connects to the PineNote via UART and USB simultaneously.&lt;br /&gt;
The dongle is not currently available for purchase.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Pinenote-stock-uart-dongle-front.jpg|Front&lt;br /&gt;
Pinenote-stock-uart-dongle-back.jpg|Back&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Creating a dongle ==&lt;br /&gt;
&lt;br /&gt;
A PineNote UART dongle has four components:&lt;br /&gt;
# A USB-C breakout board with a male connector exposing the 24 pins of the PineNote's female USB-C port (located on the bottom of the device)&lt;br /&gt;
# A USB-UART adapter, to plug into a USB port of the computer you'll use to interface with the PineNote&lt;br /&gt;
# [https://en.wikipedia.org/wiki/Jump_wire Jump wires] to connect specific breakout board pins to pins on the USB-UART adapter&lt;br /&gt;
# Electrical tape to wrap connectors and prevent shorts&lt;br /&gt;
&lt;br /&gt;
The PineNote's internal UART system is documented in [https://files.pine64.org/doc/PineNote/PineNote_USB-C_Console_UART_breakout_board_schematic_v1.0_20210903.pdf this schematic].&lt;br /&gt;
USB-C pins are documented [https://en.wikipedia.org/wiki/USB-C#Specifications on the USB-C Wikipedia page]; of the 24 pins, two are designated for &amp;quot;side band&amp;quot; use.&lt;br /&gt;
These pins are labeled SBU1 (A8) and SBU2 (B8).&lt;br /&gt;
In the PineNote UART schematic you can see (on the bottom right diagram) these pins are given the label &amp;lt;code&amp;gt;UART2_TX_SUB1&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;UART2_RX_SUB2&amp;lt;/code&amp;gt; respectively.&lt;br /&gt;
The first (TX) is used for transmitting data and the second (RX) is used for receiving data.&lt;br /&gt;
These are the pins which must be exposed by the breakout board.&lt;br /&gt;
&lt;br /&gt;
There are many possible USB-C breakout board designs available for purchase online.&lt;br /&gt;
One particularly useful design is a &amp;quot;passthrough&amp;quot; or &amp;quot;intercept&amp;quot; style, with both male and female USB-C ports.&lt;br /&gt;
This design is more versatile in case you want to reuse it in other projects, and also enables you to connect to the PineNote via UART and USB at the same time.&lt;br /&gt;
An example of this product can be found [https://pmdway.com/products/usb-3-1-type-c-male-to-female-breakout-test-board here], although you are encouraged to shop around for cheaper options.&lt;br /&gt;
&lt;br /&gt;
Similarly, there are many USB-UART adapter designs available.&lt;br /&gt;
These devices plug into your computer and expose a number of pins themselves, connecting to specific pins on the breakout board with jump wires.&lt;br /&gt;
[https://pmdway.com/products/usb-to-ttl-serial-cp2104-6-pin-converter-module Here] is one example with jump wires included, although you are again encouraged to shop around for alternatives.&lt;br /&gt;
&lt;br /&gt;
Once you have acquired all necessary components, assemble the UART dongle as follows:&lt;br /&gt;
# Connect a jump wire from the GND ([https://en.wikipedia.org/wiki/Ground_(electricity) ground]) pin on the USB-UART adapter to one of the four GND pins on the USB-C breakout board (A1, A12, B1, or B12)&lt;br /&gt;
# Connect a jump wire from the RXD pin on the USB-UART adapter to the &amp;lt;code&amp;gt;UART2_RX_SUB2&amp;lt;/code&amp;gt; pin on the USB-C breakout board (SBU2 aka B8)&lt;br /&gt;
# Connect a jump wire from the TXD pin on the USB-UART adapter to the &amp;lt;code&amp;gt;UART2_TX_SUB2&amp;lt;/code&amp;gt; pin on the USB-C breakout board (SBU1 aka A8)&lt;br /&gt;
&lt;br /&gt;
Test that your system works by following the use instructions down below.&lt;br /&gt;
Be very careful not to touch or short the pins while current is flowing through them - this can damage your device!&lt;br /&gt;
Once you have confirmed that your UART dongle works, wrap all metal connectors in electrical tape to prevent accidental shorts.&lt;br /&gt;
&lt;br /&gt;
== Using UART ==&lt;br /&gt;
&lt;br /&gt;
First, use your UART dongle to physically connect your PineNote to your computer:&lt;br /&gt;
# Plug the USB-UART adapter into one of your computer's USB ports&lt;br /&gt;
# Plug the USB-C breakout board into the USB-C port on the bottom of your PineNote; it is likely that the orientation matters, so try both and remember which one works&lt;br /&gt;
&lt;br /&gt;
Once the hardware is connected, set up your computer's software as follows:&lt;br /&gt;
# Install [https://www.gnu.org/software/screen/ GNU Screen] (or [https://askubuntu.com/q/40959 some other option], but the instructions below are written for &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt;)&lt;br /&gt;
# Identify the USB-UART adapter in your &amp;lt;code&amp;gt;/dev&amp;lt;/code&amp;gt; directory by running &amp;lt;code&amp;gt;ls /dev&amp;lt;/code&amp;gt; with it plugged in, unplugging it, then again running &amp;lt;code&amp;gt;ls /dev&amp;lt;/code&amp;gt; and seeing what changes; it is likely to be called &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;&lt;br /&gt;
# In a terminal window, run &amp;lt;code&amp;gt;screen -L /dev/ttyUSB0 1500000&amp;lt;/code&amp;gt; (you may need to run this as sudo depending on your user's permissions)&lt;br /&gt;
&lt;br /&gt;
Once the software is set up, power-cycle your PineNote; as the system boots you should see text appearing in your terminal window.&lt;br /&gt;
You can exit the screen session with &amp;lt;code&amp;gt;ctrl+a k&amp;lt;/code&amp;gt; then pressing &amp;lt;code&amp;gt;y&amp;lt;/code&amp;gt; to confirm.&lt;br /&gt;
The &amp;lt;code&amp;gt;screen -L&amp;lt;/code&amp;gt; flag outputs a text log of the session to the current working directory, probably called &amp;lt;code&amp;gt;screenlog.0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Troubleshooting ====&lt;br /&gt;
&lt;br /&gt;
If you don't see any text in your terminal as the PineNote boots, or the text is garbled, try the following:&lt;br /&gt;
* Ensure your GND, RX and TX jump wires are connected to the correct pins on both the USB-UART adapter and the USB-C breakout board&lt;br /&gt;
* Connect your USB-C breakout board to your PineNote in the opposite orientation&lt;br /&gt;
* Run the screen command as sudo in case your user doesn't have appropriate permissions&lt;br /&gt;
* Ensure you are setting the baud rate in the &amp;lt;code&amp;gt;screen&amp;lt;/code&amp;gt; command to 1500000 (1.5 million)&lt;br /&gt;
&lt;br /&gt;
== USB passthrough ==&lt;br /&gt;
&lt;br /&gt;
If your USB-C breakout board has a passthrough/intercept design, you can connect to your PineNote over USB and UART at the same time.&lt;br /&gt;
This can be useful when you're doing development work on the PineNote boot process so you don't have to continually reconnect cables.&lt;br /&gt;
You'll need a USB-A to USB-C cable, connecting directly from your computer's USB-A hub to your USB-C breakout board's female USB-C port.&lt;br /&gt;
It's important to connect directly from USB-A, without any intermediate USB-C components.&lt;br /&gt;
Note that connecting a live USB cable to your USB-C breakout board in this way dramatically increases the danger of frying your PineNote with a short, so you should only do this if all connectors are safely wrapped in electrical tape.&lt;br /&gt;
&lt;br /&gt;
[[Category:PineNote]]&lt;/div&gt;</summary>
		<author><name>Ahelwer</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=File:Pinenote-stock-uart-dongle-back.jpg&amp;diff=20868</id>
		<title>File:Pinenote-stock-uart-dongle-back.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=File:Pinenote-stock-uart-dongle-back.jpg&amp;diff=20868"/>
		<updated>2023-10-12T00:18:01Z</updated>

		<summary type="html">&lt;p&gt;Ahelwer: Ahelwer uploaded a new version of File:Pinenote-stock-uart-dongle-back.jpg&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary ==&lt;br /&gt;
Photo of the back of the stock UART dongle shipped from Pine64 with the PineNote. Photo provided by user aarondabomb. &lt;br /&gt;
== Licensing ==&lt;br /&gt;
{{CC0}}&lt;br /&gt;
[[Category:PineNote]]&lt;/div&gt;</summary>
		<author><name>Ahelwer</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=File:Pinenote-stock-uart-dongle-front.jpg&amp;diff=20867</id>
		<title>File:Pinenote-stock-uart-dongle-front.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=File:Pinenote-stock-uart-dongle-front.jpg&amp;diff=20867"/>
		<updated>2023-10-12T00:17:02Z</updated>

		<summary type="html">&lt;p&gt;Ahelwer: Ahelwer uploaded a new version of File:Pinenote-stock-uart-dongle-front.jpg&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary ==&lt;br /&gt;
Photo of the front of the stock UART dongle shipped from Pine64 with the PineNote. Photo provided by user aarondabomb.&lt;br /&gt;
== Licensing ==&lt;br /&gt;
{{CC0}}&lt;br /&gt;
[[Category:PineNote]]&lt;/div&gt;</summary>
		<author><name>Ahelwer</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PineNote_Development/Flashing&amp;diff=20866</id>
		<title>PineNote Development/Flashing</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PineNote_Development/Flashing&amp;diff=20866"/>
		<updated>2023-10-12T00:11:49Z</updated>

		<summary type="html">&lt;p&gt;Ahelwer: /* Backup */ Expanded manual backup section&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Under construction}}&lt;br /&gt;
&lt;br /&gt;
{{Info|These instructions are directed towards experienced developers only!}}&lt;br /&gt;
&lt;br /&gt;
This page contains information on flashing software to the [https://wiki.pine64.org/wiki/PineNote PineNote].&lt;br /&gt;
&lt;br /&gt;
Currently, software can be flashed using rkdeveloptool or from the factory Android installation (UART shell, adb, or fastboot).&lt;br /&gt;
&lt;br /&gt;
== Getting &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
Most flashing operations on the PineNote are done through &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt;, a command line utility built on libusb.&lt;br /&gt;
PINE64 maintains its own fork [https://gitlab.com/pine64-org/quartz-bsp/rkdeveloptool here] that you will need to get.&lt;br /&gt;
The repo's README contains a list of dependencies (libusb 1.0) and instructions for building the tool.&lt;br /&gt;
&lt;br /&gt;
Installing (not just building) &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; will configure PAM to elevate privileges where necessary on your system; you can configure this manually as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo cp 99-rk-rockusb.rules /etc/udev/rules.d/&lt;br /&gt;
sudo udevadm control --reload&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Entering Maskrom/Rockusb Mode ==&lt;br /&gt;
&lt;br /&gt;
Interfacing with the PineNote over USB using &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt; requires first booting the PineNote into an alternative operating mode called Maskrom or Rockusb mode.&lt;br /&gt;
&lt;br /&gt;
=== Possible Methods ===&lt;br /&gt;
&lt;br /&gt;
There are three possible methods of entering Maskrom/Rockusb mode:&lt;br /&gt;
&lt;br /&gt;
==== Hardware Magnet Switch ====&lt;br /&gt;
&lt;br /&gt;
# Connect the PineNote to your computer via USB and boot the PineNote into Android&lt;br /&gt;
# Locate &amp;amp; identify the small circular marking on the back of the PineNote, in the top right quadrant; have the PineNote pen close at hand, or any other small magnet&lt;br /&gt;
# Hold the PineNote power button to bring up the reboot/shutdown menu; select reboot, then place the PineNote face down with the &amp;quot;eraser&amp;quot; end of the pen (or your magnet) resting on the small circular marking&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Download mode.jpeg|Pen method&lt;br /&gt;
PineNoteMagnetOnBack.jpg|Magnet method&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== U-Boot ====&lt;br /&gt;
This method requires a [[PineNote Development/UART|UART dongle for the PineNote]] with passthrough allowing simultaneous UART &amp;amp; USB connections.&lt;br /&gt;
It is nice because you can easily switch back &amp;amp; forth between U-Boot and Rockusb without having to physically manipulate the PineNote or its connectors; this is especially helpful when trying to develop U-Boot.&lt;br /&gt;
&lt;br /&gt;
# Interrupt the U-Boot startup using ''ctrl-c'' (while attached using an UART dongle)&lt;br /&gt;
# While in U-Boot use the command &amp;lt;code&amp;gt;rockusb 0 mmc 0&amp;lt;/code&amp;gt; to start Rockusb mode.&lt;br /&gt;
&lt;br /&gt;
==== Shorting Test Points ====&lt;br /&gt;
&lt;br /&gt;
If the bootloader is broken/corrupted, you cannot get to Maskrom without opening up the device (it can be opened using spudger and a bit of patience).&lt;br /&gt;
&lt;br /&gt;
Once inside, short TP1301 (GND) and TP1302 (eMMC_D0/FLASH_D0) with a small tweezers, this is how it looks on board view (credit to Caleb):&lt;br /&gt;
&lt;br /&gt;
[[File:PineNote_Maskrom_TP.png|500px]]&lt;br /&gt;
&lt;br /&gt;
=== Success ===&lt;br /&gt;
&lt;br /&gt;
No matter what approach you take, you can tell whether you succeeded by running the &amp;lt;code&amp;gt;lsusb&amp;lt;/code&amp;gt; command on your computer:&lt;br /&gt;
* If you find the entry &amp;lt;code&amp;gt;2207:0018 Fuzhou Rockchip Electronics Company rk3566_eink&amp;lt;/code&amp;gt; in the list, the process did not succeed; reboot and retry&lt;br /&gt;
* If you find the entry &amp;lt;code&amp;gt;2207:350a Fuzhou Rockchip Electronics Company USB download gadget&amp;lt;/code&amp;gt; then the process succeeded&lt;br /&gt;
&lt;br /&gt;
You can also look at the output of the &amp;lt;code&amp;gt;rkdeveloptool list&amp;lt;/code&amp;gt; command:&lt;br /&gt;
* If this prints out &amp;lt;code&amp;gt;No devices in rockusb mode found&amp;lt;/code&amp;gt; the process did not succeed; reboot and retry&lt;br /&gt;
* If this prints out something like &amp;lt;code&amp;gt;DevNo=1 Vid=0x2207,Pid=0x350a,LocationID=303 Loader&amp;lt;/code&amp;gt; then the process succeeded&lt;br /&gt;
&lt;br /&gt;
=== Exiting mode ===&lt;br /&gt;
&lt;br /&gt;
You can boot the PineNote back into its normal mode of operation by powercycling the PineNote with its hardware power switch, or running the &amp;lt;code&amp;gt;rkdeveloptool reset&amp;lt;/code&amp;gt; command.&lt;br /&gt;
&lt;br /&gt;
== Backup ==&lt;br /&gt;
&lt;br /&gt;
A backup of the content of the internal eMMC before anything gets messed up is '''mandatory'''.&lt;br /&gt;
&lt;br /&gt;
Especially the ''waveform'' partition contains data '''unique''' to your PineNote and is a prime candidate for backup.&lt;br /&gt;
&lt;br /&gt;
Other partitions like U-Boot (need for any operation of the device) or the un-partitioned space at the beginning containing the GPT partition table (and presumably the VCOM setting for the e-ink display and maybe device mac addresses) contain data you may also wish to backup.&lt;br /&gt;
&lt;br /&gt;
Depending of your personal level of data hoarder you may want to backup more than this or even just everything (the large ''userdata'' partition is supposed to be able to be repopulated as empty space by Android)&lt;br /&gt;
&lt;br /&gt;
In any case it is easier to restore/extract data from a backup than not having one if you need one.&lt;br /&gt;
&lt;br /&gt;
This process was developed by Dorian Rudolph, originally described [https://github.com/DorianRudolph/pinenotes here].&lt;br /&gt;
&lt;br /&gt;
=== List partitions ===&lt;br /&gt;
&lt;br /&gt;
First, run &amp;lt;code&amp;gt;rkdeveloptool list-partitions&amp;lt;/code&amp;gt; to print out your PineNote's partitions to get an idea of what you're dealing with.&lt;br /&gt;
The stock PineNote has a fairly standard Android partition setup, including:&lt;br /&gt;
* uboot: the [https://en.wikipedia.org/wiki/Das_U-Boot U-Boot] embedded systems bootloader&lt;br /&gt;
* trust: secrets that can be encrypted with a key stored in the [https://en.wikipedia.org/wiki/Trusted_Platform_Module TPM]&lt;br /&gt;
* waveform: important files controlling the e-ink screen's state changes&lt;br /&gt;
* misc: miscellaneous files needed by the firmware&lt;br /&gt;
* dtbo: [https://en.wikipedia.org/wiki/Devicetree Device Tree Blob for Overlay], files describing the PineNote's hardware configuration&lt;br /&gt;
* vbmeta: data required for verified boot&lt;br /&gt;
* boot, security, recovery, backup, cache, metadata, super, logo, device&lt;br /&gt;
* userdata: the big one; this is where all your files are stored in the stock Android install&lt;br /&gt;
&lt;br /&gt;
=== Patch U-Boot ===&lt;br /&gt;
&lt;br /&gt;
Before we can back up our partitions, we have a problem to solve.&lt;br /&gt;
The version of U-Boot installed on the stock PineNote contains a bug where it can't dump partitions beyond 32 MB (above that limit all bytes in the dump are just &amp;lt;code&amp;gt;0xCC&amp;lt;/code&amp;gt;), meaning the PineNote must be flashed with a fixed version of U-Boot before it is possible to take a backup of the larger partitions.&lt;br /&gt;
It is possible to extract and modify the U-Boot image from your PineNote if you're interested in some light reverse-engineering (following Dorian's notes), or you can simply download a patched U-Boot image directly [https://github.com/DorianRudolph/pinenotes/blob/main/static/uboot_patched.img here].&lt;br /&gt;
&lt;br /&gt;
Once you've acquired a patched U-Boot image, run:&lt;br /&gt;
# &amp;lt;code&amp;gt;rkdeveloptool read-partition uboot uboot_backup.img&amp;lt;/code&amp;gt;&lt;br /&gt;
# &amp;lt;code&amp;gt;rkdeveloptool write-partition uboot uboot_patched.img&amp;lt;/code&amp;gt;&lt;br /&gt;
# &amp;lt;code&amp;gt;rkdeveloptool reboot&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Taking the backup ===&lt;br /&gt;
&lt;br /&gt;
There is a second backup limit preventing dumping partitions larger than 2 GB, this time from &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt;.&lt;br /&gt;
This means if you have a large number of documents in the Android userdata partition they might not all make it into the backup.&lt;br /&gt;
If you don't have many documents (or don't care about losing them) this should not be a problem.&lt;br /&gt;
If you do have a lot of documents, workarounds include:&lt;br /&gt;
* A possible patch written by Thomas exists [https://github.com/tpwrules/nixos-pinenote/blob/96d2c9158edb9da59afcb952cc864fada18382f9/nix/rkdeveloptool/0001-fix-large-dumps.patch here] but has not yet been upstreamed; consider investigating how to get the patch tested &amp;amp; upstreamed, or just apply it to your own local copy of &amp;lt;code&amp;gt;rkdeveloptool&amp;lt;/code&amp;gt;&lt;br /&gt;
* Use [https://github.com/talpadk/pinenote-backup this] Python script written by Visti Andresen to automatically backup your entire partition by splitting reads into 2 GB chunks&lt;br /&gt;
&lt;br /&gt;
See [https://github.com/m-weigand/pinenote-debian-recipes/releases/tag/v0.1 instructions on this artifact]. It will instruct you on extracting the rootfs into an empty ext4 partition. This can be done from Linux or Android. Further instructions on building your own rootfs [https://github.com/m-weigand/pinenote-debian-recipes can be found here].&lt;br /&gt;
&lt;br /&gt;
=== Using a user installed Linux ===&lt;br /&gt;
A Linux installed to the cache partition should be able to easily backup everything over WiFi or to a USB stick/disk using ''dd''.&lt;br /&gt;
&lt;br /&gt;
However the user would need to backup the cache partition themself (if they want that).&lt;br /&gt;
&lt;br /&gt;
And more importantly they would only be getting the backup ''after'' they started playing with the content of the eMMC.&lt;br /&gt;
&lt;br /&gt;
== Side-by-side setup ==&lt;br /&gt;
&lt;br /&gt;
It is possible to set up a partition for mainline development without disturbing the factory Android installation. This allows updating a mainline kernel, DTB, and initramfs over Wi-Fi until WiFi or USB OTG is working in mainline Linux.&lt;br /&gt;
&lt;br /&gt;
=== Without Repartitioning ===&lt;br /&gt;
&lt;br /&gt;
The recommended partition for this is &amp;lt;tt&amp;gt;mmcblk0p11&amp;lt;/tt&amp;gt; aka &amp;lt;tt&amp;gt;/cache&amp;lt;/tt&amp;gt;. It is large and already formatted as &amp;lt;tt&amp;gt;ext4&amp;lt;/tt&amp;gt;, so it is readable from U-Boot. Here are some general steps:&lt;br /&gt;
&lt;br /&gt;
# From the UART or adb shell, set up your chroot in &amp;lt;tt&amp;gt;/cache&amp;lt;/tt&amp;gt;. I used the Alpine Linux rootfs tarball.&lt;br /&gt;
# Copy in your kernel and DTB, using for example &amp;lt;tt&amp;gt;scp&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;wget&amp;lt;/tt&amp;gt; inside the chroot.&lt;br /&gt;
# Finally, create and boot an &amp;lt;code&amp;gt;extlinux.conf&amp;lt;/code&amp;gt; as described below.&lt;br /&gt;
&lt;br /&gt;
=== With Repartitioning ===&lt;br /&gt;
&lt;br /&gt;
It is possible to shrink the &amp;lt;tt&amp;gt;userdata&amp;lt;/tt&amp;gt; partition, and create a new partition at the end for use with mainline Linux. This provides much more space than &amp;lt;tt&amp;gt;cache&amp;lt;/tt&amp;gt;. However, because &amp;lt;tt&amp;gt;userdata&amp;lt;/tt&amp;gt; is formatted with &amp;lt;tt&amp;gt;f2fs&amp;lt;/tt&amp;gt;, and that filesystem cannot be shrunk, resizing the partition requires wiping &amp;lt;tt&amp;gt;userdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
# Back up any necessary files from userdata&lt;br /&gt;
# Boot to a mainline kernel from &amp;lt;tt&amp;gt;mmcblk0p11&amp;lt;/tt&amp;gt;, either using that partition as rootfs (see above), or using an initramfs with repartitioning tools&lt;br /&gt;
# Modify the partition table with your favorite tool, e.g. &amp;lt;tt&amp;gt;fdisk&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gdisk&amp;lt;/tt&amp;gt;, or &amp;lt;tt&amp;gt;parted&amp;lt;/tt&amp;gt;&lt;br /&gt;
# Reboot into &amp;lt;tt&amp;gt;fastboot&amp;lt;/tt&amp;gt; and wipe &amp;lt;tt&amp;gt;userdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# Reboot into Android, where you can now chroot in and install your favorite distribution to the new partition.&lt;br /&gt;
&lt;br /&gt;
== Using rkdeveloptool ==&lt;br /&gt;
&lt;br /&gt;
=== Building Downstream U-Boot ===&lt;br /&gt;
&lt;br /&gt;
While in maskrom mode, we need to have a u-boot to download onto the device for any of the other commands to work. To build you'll also need to install device-tree-compiler.&lt;br /&gt;
&lt;br /&gt;
You also need to install Python and pyelftools.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Note that rkbin is a &amp;amp;gt;5GB download!&amp;lt;/b&amp;gt; This will take some time to clone and process the deltas.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone -b quartz64 https://gitlab.com/pgwipeout/u-boot-rockchip.git&lt;br /&gt;
git clone -b rkbin https://github.com/JeffyCN/rockchip_mirrors.git rkbin&lt;br /&gt;
cd u-boot-rockchip&lt;br /&gt;
# If using Arch Linux, export CROSS_COMPILE=aarch64-linux-gnu-&lt;br /&gt;
export CROSS_COMPILE=aarch64-none-linux-gnu-&lt;br /&gt;
make rk3566-quartz64_defconfig&lt;br /&gt;
./make.sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
In the current version (current as of 2022-01-02), there might have to be made a change to one line to get a clean compilation:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
diff --git a/lib/avb/libavb/avb_slot_verify.c b/lib/avb/libavb/avb_slot_verify.c&lt;br /&gt;
index 123701fc3b..64a1ce6450 100644&lt;br /&gt;
--- a/lib/avb/libavb/avb_slot_verify.c&lt;br /&gt;
+++ b/lib/avb/libavb/avb_slot_verify.c&lt;br /&gt;
@@ -296,7 +296,7 @@ static AvbSlotVerifyResult load_and_verify_hash_partition(&lt;br /&gt;
   bool image_preloaded = false;&lt;br /&gt;
   uint8_t* digest;&lt;br /&gt;
   size_t digest_len;&lt;br /&gt;
-  const char* found;&lt;br /&gt;
+  const char* found = NULL;&lt;br /&gt;
   uint64_t image_size;&lt;br /&gt;
   size_t expected_digest_len = 0;&lt;br /&gt;
   uint8_t expected_digest_buf[AVB_SHA512_DIGEST_SIZE];&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For systems where the global python executable points to python2, compilation fails with an error related to pyelftools not being installed (even if it is). To fix this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
diff --git a/make.sh b/make.sh&lt;br /&gt;
index 2bba05b4e4..cfe5b0afd5 100755&lt;br /&gt;
--- a/make.sh&lt;br /&gt;
+++ b/make.sh&lt;br /&gt;
@@ -758,7 +758,7 @@ function pack_fit_image()&lt;br /&gt;
        fi&lt;br /&gt;
 &lt;br /&gt;
        if [ &amp;quot;${ARM64_TRUSTZONE}&amp;quot; == &amp;quot;y&amp;quot; ]; then&lt;br /&gt;
-               if ! python -c &amp;quot;import elftools&amp;quot; ; then&lt;br /&gt;
+               if ! python3 -c &amp;quot;import elftools&amp;quot; ; then&lt;br /&gt;
                        echo &amp;quot;ERROR: No python 'pyelftools', please: pip install pyelftools&amp;quot;&lt;br /&gt;
                        exit 1&lt;br /&gt;
                fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can now download u-boot onto the PineNote:&lt;br /&gt;
&lt;br /&gt;
 ./rkdeveloptool boot ../u-boot-rockchip/rk356x_spl_loader_v1.08.111.bin&lt;br /&gt;
&lt;br /&gt;
This should output &amp;quot;''Downloading bootloader succeeded''&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
We can now verify that this worked using e.g. the &amp;quot;read flash info&amp;quot; command:&lt;br /&gt;
&lt;br /&gt;
 ./rkdeveloptool read-flash-info&lt;br /&gt;
&lt;br /&gt;
{{Note|'''TODO:''' Section needs to be finished}}&lt;br /&gt;
&lt;br /&gt;
=== Creating a mainline boot image ===&lt;br /&gt;
&lt;br /&gt;
You can create a filesystem image that replaces the Android boot or recovery partition by doing roughly the following:&lt;br /&gt;
&lt;br /&gt;
# Erase boot and dtbo with rkdeveloptool or fastboot (back them up first!!!)&lt;br /&gt;
# Create an ext2 partition image and mount it (fallocate, mkfs.ext2)&lt;br /&gt;
# Build your mainline kernel&lt;br /&gt;
# Copy the kernel, dtb and an initramfs to the root of the mounted image (use any old postmarketOS initramfs)&lt;br /&gt;
# Create a file in the root of the mounted image called &amp;lt;code&amp;gt;extlinux.conf&amp;lt;/code&amp;gt; as described below&lt;br /&gt;
# Unmount the image and then use rkdeveloptool to flash it to the &amp;quot;recovery&amp;quot; partition on the pinenote (it's about the right size until we get around to replacing the partition layout).&lt;br /&gt;
&lt;br /&gt;
== Using fastboot ==&lt;br /&gt;
&lt;br /&gt;
Follow the steps for [[PineNote Development/Flashing#Creating a mainline boot image|Creating a mainline boot image]], but instead of flashing it with ''rkdeveloptool'', use ''fastboot''. You can enter fastboot in either of two ways:&lt;br /&gt;
&lt;br /&gt;
* Use &amp;quot;reboot bootloader&amp;quot; from adb or a UART console or&lt;br /&gt;
* get a U-Boot prompt and run &amp;lt;code&amp;gt;fastboot usb 0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:PineNote]]&lt;/div&gt;</summary>
		<author><name>Ahelwer</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PineNote&amp;diff=20865</id>
		<title>PineNote</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PineNote&amp;diff=20865"/>
		<updated>2023-10-11T23:01:15Z</updated>

		<summary type="html">&lt;p&gt;Ahelwer: /* UART Dongle */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:PineNote-1.jpg|400px|thumb|right|The PineNote]]&lt;br /&gt;
&lt;br /&gt;
The '''PineNote''' is the first hybrid notepad computer device combination of notebook, tablet and e-reader using an e-ink panel. It is derived from the Quartz64 model A SBC and powered by a Rockchip RK3566 quad-core ARM Cortex A55 64-bit processor with a MALI G-52 GPU.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
=== State of the software ===&lt;br /&gt;
&lt;br /&gt;
The PineNote is based on the in 2021 released Rockchip RK3566 SoC. The upstreaming status of the SoC functionality can be found on the [[Quartz64 Development#Upstreaming Status|Quartz64 development]] wiki page of the Quartz64 single-board computer using the same SoC. In the [[PineNote_Development#Kernel_modules_/_mainlining_status|PineNote development]] wiki page you'll find the items specific for the PineNote.&lt;br /&gt;
&lt;br /&gt;
The early adopter's batch of the PineNote is aimed solely at early adopters - more specifically, the units are solely intended to find their way into the hands of users with extensive Linux experience. If you’re looking to buy a PineNote in the first batch, you must expect to write software for it, not to write notes on it. The software shipping from the factory for the first batch will not be suitable for taking notes, reading e-books, or writing your dissertation. It may not even boot to a graphical environment.&lt;br /&gt;
&lt;br /&gt;
An early version of a GNOME-based Debian image is available for [[PineNote_Software_Releases|testing]], but should not be expected to meet general-user readiness.&lt;br /&gt;
&lt;br /&gt;
=== Help and support ===&lt;br /&gt;
&lt;br /&gt;
Still have any questions regarding software, shipping, or ordering after reading this wiki? Please don't hesitate to contact the community in the bridged community channels for detailed answers or simply to chat with friendly people in the community! See [[Main Page#Community and Support]]. &lt;br /&gt;
&lt;br /&gt;
Please keep in mind that PINE64 is not like a regular company (see the [https://www.pine64.org/philosophy/ PINE64 philosophy]) and that support resources are limited - the best way to get support quickly is to ask in the community chat! Please only contact the PINE64 support directly if questions couldn't be solved via the community chat or this wiki.&lt;br /&gt;
&lt;br /&gt;
== Software releases ==&lt;br /&gt;
While there are no robust and tested operating system releases for the PineNote available at this time, various linux distributions can be installed on the PineNote, with various degrees of working functionality.&lt;br /&gt;
Operating system software releases, or efforts to create them, can be found in the [[PineNote Software Releases]] section. Please join the development effort and help creating one.&lt;br /&gt;
&lt;br /&gt;
== Development efforts ==&lt;br /&gt;
&lt;br /&gt;
The following page discusses the development efforts for the PineNote:&lt;br /&gt;
&lt;br /&gt;
* [[PineNote Development]] for general information regarding how to flash the device and other development information.&lt;br /&gt;
&lt;br /&gt;
=== Software ===&lt;br /&gt;
&lt;br /&gt;
* [[PineNote Development/Flashing]] for general flashing instructions of data to the PineNote&lt;br /&gt;
* [[PineNote Development/TODOs]]&lt;br /&gt;
&lt;br /&gt;
==== Linux Kernel ====&lt;br /&gt;
&lt;br /&gt;
* [[RK3566 EBC Reverse-Engineering]] for the EBC (eInk Panel) driver.&lt;br /&gt;
* [[PineNote Development/Building Kernel]]&lt;br /&gt;
* BSP Linux SDK version 4.19 for the PineNote and [[Quartz64|Quartz64 Model A]]:&lt;br /&gt;
** [http://files.pine64.org/SDK/Quartz64/QUARTZ64-model-A_BSP%20Linux.tar.gz Direct download] from ''pine64.org'' (32.67GB, MD5 of the TAR-GZip file ''24554419aec29700add97167a3a4c9ed'')&lt;br /&gt;
** [https://tmp.mwfc.info/pinenote/QUARTZ64-model-A_BSP%20Linux.tar.gz Mirror by mwfc]&lt;br /&gt;
** An unofficial torrent download provided by a community member of the BSP Linux and Android SDKs can be found [https://cdn.discordapp.com/attachments/870707390998282292/907726420204208148/pinenote.torrent here] (100GB).&lt;br /&gt;
&lt;br /&gt;
==== User Space ====&lt;br /&gt;
&lt;br /&gt;
* [[PineNote Development/Booting Linux]]&lt;br /&gt;
&lt;br /&gt;
For tweaks and tricks see:&lt;br /&gt;
* [[PineNote Development/Software Tweaks]]&lt;br /&gt;
&lt;br /&gt;
For app development see:&lt;br /&gt;
* [[PineNote Development/Apps]]&lt;br /&gt;
&lt;br /&gt;
==== Android ====&lt;br /&gt;
&lt;br /&gt;
Android 11 e-ink SDK for the PineNote and [[Quartz64|Quartz64 Model A]. This is the Android SDK build for 10.3&amp;quot; eink panels on Quartz64 Model A. &lt;br /&gt;
&lt;br /&gt;
Download:&lt;br /&gt;
* [http://files.pine64.org/SDK/Quartz64/QUARTZ64-model-A_eink.android11_SDK.tar.gz Direct download] from ''pine64.org'' (72.88GB, MD5 of the TAR-GZip file ''293a550584298de4fb95ceae18103672'')&lt;br /&gt;
* [https://tmp.mwfc.info/pinenote/QUARTZ64-model-A_eink.android11_SDK.tar.gz Mirror by mwfc]&lt;br /&gt;
* An unofficial torrent download provided by a community member of the BSP Linux and Android SDKs can be found [https://cdn.discordapp.com/attachments/870707390998282292/907726420204208148/pinenote.torrent here] (100GB).&lt;br /&gt;
* Just the boot blobs (&amp;lt;1MB): [[File:Rk35-blobs.tar.gz]]&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
* View [[Android SDK for RK3566]] for more information how to compile an image for the PineNote using this SDK&lt;br /&gt;
&lt;br /&gt;
==== Related ====&lt;br /&gt;
* [[Quartz64 Development]] for the mainlining status of various functions on the Rockchip RK3566 SoC.&lt;br /&gt;
&lt;br /&gt;
=== Hardware ===&lt;br /&gt;
&lt;br /&gt;
This section includes discussions and their results regarding hardware changes and debugging of the PineNote.&lt;br /&gt;
&lt;br /&gt;
==== Resolved issues ====&lt;br /&gt;
&lt;br /&gt;
The following topics have resolved:&lt;br /&gt;
&lt;br /&gt;
* [[PineNote/Hardware Changes/Closed Case UART]]&lt;br /&gt;
* '''Could the USB-C port support USB 3.1 5Gbps?''' Yes and no. The RK3566 only has a host-mode 5Gbps controller, meaning it can only negotiate such a high data rate with a device such as a flash drive. When the RK3566 is acting as a device, it only supports 480Mbps transfer rates. The hardware required to switch between these modes would raise the PineNote's price unreasonably. Therefore, the USB-C port will remain at USB 2.0 speeds for Host and Device mode.&lt;br /&gt;
* '''Could the USB-C port output DisplayPort?''' Yes and no. The hardware required to support such a feature would raise the PineNote's price unreasonably. Therefore, DisplayPort output will not be possible through the USB-C port.&lt;br /&gt;
* '''Where is the microSD card slot?''' The case design of the PineNote is fixed, making physical changes like adding a microSD card slot would raise the cost unreasonably.&lt;br /&gt;
* '''How will I install software to the PineNote?''' This is a hardware and software question. If the software on your PineNote is completely broken and cannot boot to a recoverable state, a Hall (magnet) sensor was fitted to the PineTab motherboard as U9009. This sensor is attached to SARADC_VIN0_KEY/RECOVERY on the RK3566. With the device powered off, and screen face down, holding a magnet over U9009 and plugging in a USB-C cable causes the device to boot into [http://opensource.rock-chips.com/wiki_Rockusb &amp;quot;rockusb&amp;quot;] flash mode. With proper flashing software and drivers, it should be possible to load a new operating system using rockusb if the system is soft-bricked. Of course, software vendors will need to be more careful with flashing firmware and providing useful &amp;quot;recovery&amp;quot; options on this device due to this process's relative difficulty to other PINE64 devices.&lt;br /&gt;
* [[PineNote/Battery Replacement]]&lt;br /&gt;
&lt;br /&gt;
==== Unresolved issues ====&lt;br /&gt;
&lt;br /&gt;
The following concerns have been brought up as open, unanswered topics:&lt;br /&gt;
&lt;br /&gt;
* Does [https://en.wikipedia.org/wiki/USB-C#Audio_Adapter_Accessory_Mode_2|USB-C Audio Adapter Accessory Mode] work? It appears that the Headphone output of the audio codec was routed to the USB-C audio+USB switch, but it's unclear whether CC lines are hooked up correctly for detection of such a device. The PineNote hardware team will be testing this functionality soon (as of August 19, 2021). Note that Audio Accessory mode is detectable by reading the I2C registers of the WUSB3801Q. So connecting ASEL to a GPIO would be enough to get this working if it is not working already.&lt;br /&gt;
* Why is the Headphone output of the audio codec routed to the speakers? HPL_OUT is routed from the RK817 PMIC and audio codec to U9010 (the USB-C switch) and U6 (the audio amplifier). SPK_OUT is unused. It seems like SPK_OUT should be routed to U6 and HPL_OUT to U9010.&lt;br /&gt;
* Nitpick: The cold white charging LED bleeds through the gap between the rear case and the device's face. It does not bleed onto the screen, but it is jarring in low-light conditions or when the screen is amber. Could be resolved in software by turning off the charge LED when the screen is on.&lt;br /&gt;
* Is there any way to indicate when the device is in rockusb mode, such as connecting a certain magic pin to the power LED?&lt;br /&gt;
* The modem/4G connector (J6010) has its I2C and UART pins unconnected. Could those be connected to the SoC?&lt;br /&gt;
&lt;br /&gt;
==== UART Dongle ====&lt;br /&gt;
{{Note|See main article: [[PineNote Development/UART]]}}&lt;br /&gt;
&lt;br /&gt;
The USB UART dongle delivered with the PineNote allows you to have access to a serial port via USB-C Debug Accessory Mode (''DAM'') without having to open up the device. &lt;br /&gt;
The factory firmware runs at a baud rate of 1500000bps, 8 data bits 1 stop bit, no parity and no flow control. The USB-C male end should go into the PineNote and the female end can be connected with a standard USB-C cable to your computer.&lt;br /&gt;
&lt;br /&gt;
In case you lose your dongle, you can rebuild one using a USB-C Breakout board.&lt;br /&gt;
&lt;br /&gt;
It is also relatively easy to build your own UART interface with a USB-C breakout board (for example https://www.ebay.com/itm/275407037613), two resistors and a 3.3V USB serial adapter. It is basically just two 1K pull up resistors (R3, R4), the data sheet values of 10K isn't whats on the real hardware, see the [https://files.pine64.org/doc/PineNote/PineNote_USB-C_Console_UART_breakout_board_schematic_v1.0_20210903.pdf schematic]. The pull ups enable the serial output on SBU1 and SBU2 you can use with any 3.3V USB serial adapter.&lt;br /&gt;
&lt;br /&gt;
The UART dongle is not necessary to flash the PineNote, but is essential if something goes wrong to fix it without having to open the case.&lt;br /&gt;
&lt;br /&gt;
You can flash premade images with the following links:&lt;br /&gt;
* https://github.com/m-weigand/pinenote_uboot_patching_dorians_backup (Note: this creates a U-Boot image to flash, do not worry about idblock.bin on the instructions for the next link)&lt;br /&gt;
* https://github.com/m-weigand/pinenote-debian-recipes/releases/&lt;br /&gt;
&lt;br /&gt;
== Specification ==&lt;br /&gt;
[[File:PineNote_Pen_function.jpg|300px|right]]&lt;br /&gt;
[[File:PineNote_Cover-1.jpg|300px|right]]&lt;br /&gt;
&lt;br /&gt;
=== General Information  ===&lt;br /&gt;
* Dimensions: 191.1x232.5x7.4mm&lt;br /&gt;
* Weight: 438g&lt;br /&gt;
&lt;br /&gt;
=== Core  ===&lt;br /&gt;
* CPU: RK3566 1.8GHz 64-bit quad-core A55&lt;br /&gt;
* GPU: MALI G52 2EE&lt;br /&gt;
* System memory: 4GB LPDDR4&lt;br /&gt;
* Flash: 128GB eMMC&lt;br /&gt;
&lt;br /&gt;
=== E-ink Display ===&lt;br /&gt;
* Size: 10.3&amp;quot;&lt;br /&gt;
* Resolution: 1404x1872&lt;br /&gt;
* DPI: 227&lt;br /&gt;
* Grayscale: 16&lt;br /&gt;
* Front Light: 36 level cold and warm &lt;br /&gt;
* Capacitive multi-touch panel&lt;br /&gt;
* EMR pen digitizer&lt;br /&gt;
&lt;br /&gt;
=== Network ===&lt;br /&gt;
* WiFi: 2.4/5GHz 802.11a/b/g/n/ac&lt;br /&gt;
* Bluetooth: 5.0&lt;br /&gt;
&lt;br /&gt;
=== Audio ===&lt;br /&gt;
* Built in stereo speakers&lt;br /&gt;
* 4 x DMIC microphone&lt;br /&gt;
&lt;br /&gt;
=== Sensor ===&lt;br /&gt;
* G-Sensor for portrait and landscape sensing&lt;br /&gt;
&lt;br /&gt;
=== Power ===&lt;br /&gt;
* 4000mAH LiPo battery&lt;br /&gt;
* DC 5V @ 3A USB-C connector&lt;br /&gt;
&lt;br /&gt;
=== Accessories ===&lt;br /&gt;
* Optional EMR pen with magnetic attachment (included in the first production batch)&lt;br /&gt;
* Optional Cover (included in the first production batch)&lt;br /&gt;
&lt;br /&gt;
== SoC and Memory Specifications ==&lt;br /&gt;
* Based on [https://www.rock-chips.com/a/en/products/RK35_Series/2021/0113/1274.html Rockchip RK3566]&lt;br /&gt;
[[File:RK3566_icon.png|right]]&lt;br /&gt;
&lt;br /&gt;
=== CPU Architecture ===&lt;br /&gt;
* [https://developer.arm.com/ip-products/processors/cortex-a/cortex-a55 Quad-core ARM Cortex-A55@1.8GHz]&lt;br /&gt;
* AArch32 for full backwards compatibility with ARMv7&lt;br /&gt;
* ARM Neon Advanced SIMD (single instruction, multiple data) support for accelerated media and signal processing computation&lt;br /&gt;
* Includes VFP hardware to support single and double-precision operations&lt;br /&gt;
* ARMv8 Cryptography Extensions&lt;br /&gt;
* Integrated 32KB L1 instruction cache and 32KB L1 data cache per core&lt;br /&gt;
* 512KB unified system L3 cache&lt;br /&gt;
* [https://developer.arm.com/ip-products/security-ip/trustzone TrustZone] technology support&lt;br /&gt;
* [https://www.cnx-software.com/2020/12/01/rockchip-rk3568-processor-to-power-edge-computing-and-nvr-applications 22nm process, believed to be FD-SOI]&lt;br /&gt;
&lt;br /&gt;
=== GPU (Graphics Processing Unit) Capabilities ===&lt;br /&gt;
* [https://developer.arm.com/ip-products/graphics-and-multimedia/mali-gpus/mali-g52-gpu Mali-G52 2EE Bifrost GPU@800MHz]&lt;br /&gt;
* 4x Multi-Sampling Anti-Aliasing (MSAA) with minimal performance drop &lt;br /&gt;
* 128KB L2 Cache configurations&lt;br /&gt;
* Supports OpenGL ES 1.1, 2.0, and 3.2&lt;br /&gt;
* Supports Vulkan 1.0 and 1.1&lt;br /&gt;
* Supports OpenCL 2.0 Full Profile&lt;br /&gt;
* Supports 1600 Mpix/s fill rate when at 800MHz clock frequency&lt;br /&gt;
* Supports 38.4 GLOP/s when at 800MHz clock frequency   &lt;br /&gt;
&lt;br /&gt;
=== NPU (Neural Processing Unit) Capabilities ===&lt;br /&gt;
* Neural network acceleration engine with processing performance of up to 0.8 TOPS&lt;br /&gt;
* Supports integer 8 and integer 16 convolution operations&lt;br /&gt;
* Supports the following deep learning frameworks: TensorFlow, TF-lite, Pytorch, Caffe, ONNX, MXNet, Keras, Darknet&lt;br /&gt;
&lt;br /&gt;
=== System Memory ===&lt;br /&gt;
* RAM Memory : 4GB LPDDR4.&lt;br /&gt;
* Flash Memory: 128GB eMMC&lt;br /&gt;
&lt;br /&gt;
== Information, Schematics, and Certifications ==&lt;br /&gt;
&lt;br /&gt;
=== PineNote Developer kit version ===&lt;br /&gt;
Version v1.2 is the PineNote production version that was sold through the Pines64 store&lt;br /&gt;
* [https://files.pine64.org/doc/PineNote/PINENOTE_MAIN-V1R2%20-%20Schematic-20210824.pdf PineNote Mainboard Schematic ver 1.2 20210824 PDF file]&lt;br /&gt;
* [https://files.pine64.org/doc/PineNote/PINENOTE_USB-C-Board-V1.0-sch.pdf PineNote USB-C Daughter Board Schematic ver 1.0 PDF file]&lt;br /&gt;
* [https://files.pine64.org/doc/PineNote/PineNote_USB-C_Console_UART_breakout_board_schematic_v1.0_20210903.pdf PineNote USB-C Console UART Breakout Board Schematic ver 1.0 PDF file] Note: When building USB-C console breakout board, please be aware 10k CC pin pull-up is too weak to pull CC to logically high level. Replacing it to lower resistance, such as 1k is recommended.&lt;br /&gt;
&lt;br /&gt;
The v1.1 is early release schematic just for reference only and used by developers who received the prototype. &lt;br /&gt;
* [https://files.pine64.org/doc/PineNote/PINENOTE_MAIN-V1R1%20-%20Schematic-20210726.pdf PineNote early released Schematic ver 1.1 20210726 PDF file]&lt;br /&gt;
* [https://files.pine64.org/doc/PineNote/PINENOTE_MAIN-V1R1-REF-TOP-20210726.pdf PineNote early released ver 1.1 20210726 PCB Connector placement PDF file]&lt;br /&gt;
&lt;br /&gt;
Certifications:&lt;br /&gt;
* [https://files.pine64.org/doc/cert/PineNote%20FCC15C%20Certificate%20DTS-TC561262.pdf PineNote FCC-15C Certificate]&lt;br /&gt;
* [https://files.pine64.org/doc/cert/PineNote%20FCC15E%20Certificate%20NII-TC973072.pdf PineNote FCC-15E Certificate]&lt;br /&gt;
* [https://files.pine64.org/doc/cert/PineNote%20CE%20RED%20Certicate%20ET-21090682EC.pdf PineNote CE RED Certificate]&lt;br /&gt;
* [https://files.pine64.org/doc/cert/PineNote%20RoHS%20Certificate%20ET-210900082C.pdf PineNote ROHS Certificate]&lt;br /&gt;
&lt;br /&gt;
== Datasheets for Components and Peripherals ==&lt;br /&gt;
&lt;br /&gt;
Rockchip RK3566 SoC information:&lt;br /&gt;
* [https://files.pine64.org/doc/quartz64/Rockchip%20RK3566%20Datasheet%20V1.0-20201210.pdf Rockchip RK3566 ver 1.0 datasheet, release permission from Rockchip]&lt;br /&gt;
&lt;br /&gt;
Rockchip RK817 PMU (Power Management Unit) Information:&lt;br /&gt;
* [https://www.rockchip.fr/RK817%20datasheet%20V1.01.pdf Rockchip RK817 version 1.01 datasheet]&lt;br /&gt;
&lt;br /&gt;
LPDDR4 (200 Balls) SDRAM:&lt;br /&gt;
* ---&lt;br /&gt;
&lt;br /&gt;
eMMC information:&lt;br /&gt;
* [https://en.biwin.com.cn/product/detail/6 Biwin 128GB eMMC model: BWCTASC41P128G]  &lt;br /&gt;
&lt;br /&gt;
E-ink Panel information:&lt;br /&gt;
* [https://files.pine64.org/doc/quartz64/Eink%20P-511-828-V1_ED103TC2%20Formal%20Spec%20V1.0_20190514.pdf E-Ink 10.3&amp;quot; 1872x1404 ED103TC2 Glass Panel Specification]&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/PineNote/TI%20PMU-TPS651851.pdf TPS65185x PMIC for E-Ink Enabled Electronic Paper Display Datasheet]&lt;br /&gt;
&lt;br /&gt;
Touch Screen information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/PineNote/CYTMA448_Summary_RevC_5-26-16.pdf Cypress CYTMA448 multi-Point Capacitive Touch Controller Datasheet]&lt;br /&gt;
* Wacom Pen Digitizer Unit Model: SUDE-10S15MI-01X for 10.3&amp;quot; Display Module&lt;br /&gt;
&lt;br /&gt;
WiFi/BT module information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/rockpro64/AW-CM256SM_DS_DF_V1.9_STD.pdf Azurewave CM256SM 11AC WiFi + Bluetooth5.0 Datasheet]]&lt;br /&gt;
&lt;br /&gt;
G Sensor information:&lt;br /&gt;
* [http://www.silan.com.cn/en/product/details/47.html#app01 Silan SC7A20 3-Axis MEMS Accelerometer]&lt;br /&gt;
&lt;br /&gt;
Audio Amplifier information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/PineNote/Awinic%20AW87318%20Class-K%20Audio%20Amp%20Datasheet.pdf Awinic AW87318 Class-K Audio Amp Datasheet]&lt;br /&gt;
&lt;br /&gt;
== Resources ==&lt;br /&gt;
* [[PineNote Press]]&lt;br /&gt;
&lt;br /&gt;
[[Category:PineNote]] [[Category:Rockchip RK3566]]&lt;/div&gt;</summary>
		<author><name>Ahelwer</name></author>
	</entry>
</feed>