Difference between revisions of "PineNote Development"

From PINE64
Jump to navigation Jump to search
(add rockchip_sip to required kernel modules)
Tag: Manual revert
 
(40 intermediate revisions by 2 users not shown)
Line 1: Line 1:
This article seeks to provide general development information for the [[PineNote]]. If you are new and down to try a new installation process, the easiest way to get linux is likely to [https://wiki.pine64.org/wiki/PineNote_Development/Installing_Debian install Debian] -- NOTE THAT THIS INSTALLATION PROCESS IS VERY NEW. While many people have been using the kernel that will be installed safely at this point, the instructions for installing Debian via rootfs are very new. Take backups!
This article seeks to provide general mainline Linux development information for the [[PineNote]].


The more stable recommended approach is described below:
== Mainline development ==


Start with [https://github.com/DorianRudolph/pinenotes Dorian's guide] which will guide you through getting Arch installed. For instructions on building the latest kernel, see [[PineNote Development/Building Kernel]]. For helpful configurations, see [[PineNote Development/Apps]]. For ways to pitch in, see [[PineNote Development/TODOs]]. To boot Linux by default instead of Android, see [[PineNote Development/Booting Linux]]. [https://www.youtube.com/watch?v=ZCLyJfbzbrU Here is a video] of a user running Manjaro and some apps on their PineNote on 9/10/2022.
=== Status ===


= Overview =
The following table aims to provide a list of kernel modules required for running the PineNote. It also aims at listing repositories of work in progress. While some overlap with the Quartz64 module list ([[Quartz64_Development#Upstreaming_Status]]) is expected, only modules relevant to the PineNote hardware should be listed here.
 
== Kernel modules / mainlining status ==
 
WORK IN PROGRESS !
 
The following table aims to provide a list of kernel modules required for running the PineNote.
It also aims at listing repositories of work in progress.
While some overlap with the Quartz64 module list ([[Quartz64_Development#Upstreaming_Status]])  
is expected, only modules relevant to the PineNote hardware should be listed here.


{|class="wikitable plainrowheaders" border="1"
{|class="wikitable plainrowheaders" border="1"
! scope="col" | Function
! scope="col" | Function
! scope="col" colspan="2" | Status
! scope="col" colspan="2" | Status
! scope="col" | Component
! scope="col" | Module
! scope="col" | Notes
! scope="col" | Notes
|-
|-
| Suspend mode driver
| Suspend mode driver
| colspan="2" style="text-align:center;"|tbd
| colspan="2" style="text-align:center;"|tbd
|<code>rockchip-sip</code>
| <code>rockchip-sip</code>
|
| The rockchip-sip driver is not mainlineable; it is only needed <sup>[https://github.com/smaeul/linux/commit/72127ca2806623a9de52cc1de39b06a38a22fe48 (via a hack)]</sup> for suspend/resume to work when downstream TF-A is used. Suspend on upstream TF-A ([https://review.trustedfirmware.org/c/TF-A/trusted-firmware-a/+/16952 status]) should work without any special drivers.
|-
|-
| Touchscreen
| Touchscreen
Line 40: Line 31:
| colspan="2" style="text-align:center;"|tbd
| colspan="2" style="text-align:center;"|tbd
| <code>ws8100-pen</code>
| <code>ws8100-pen</code>
|
| https://github.com/smaeul/linux/commit/46e87f1f9c7dd22af26d99f60eb83d2cace43cb5
|-
|-
| EBC Display controller
| EBC Display controller
| colspan="2" style="text-align:center;"|tbd
| colspan="2" style="text-align:center;"|tbd
| <code>rockchip_ebc</code>
| <code>rockchip-ebc</code>
|
| [https://lore.kernel.org/all/20220413221916.50995-1-samuel@sholland.org/ RFC PATCH 00/16 drm/rockchip: Rockchip EBC ("E-Book Controller") display driver]
|-
|-
| EBC PMic
| EBC PMic
| colspan="2" style="text-align:center;"|tbd
| colspan="2" style="text-align:center;"|tbd
| <code>tps65185</code>
| <code>tps65185</code>
|
| driver developed here: <sup>[https://github.com/smaeul/linux/tree/rk35/tps65185]</sup>, small tweaks to resume behavior added on top here: <sup>[https://github.com/m-weigand/linux/commits/mw/rk35/tps65185]
|-
|-
| LED backlight driver
| LED backlight driver
Line 60: Line 51:
| colspan="2" style="background:PaleGreen; text-align:center;"|Linux Mainline
| colspan="2" style="background:PaleGreen; text-align:center;"|Linux Mainline
| <code>st-accel-i2c</code> (silan,sc7a20)
| <code>st-accel-i2c</code> (silan,sc7a20)
| As of 5.18-rc1<sup>[https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=cc6ce5ac2c998d7e869d7289736e0097ce7d2ad1]
| As of 5.18-rc1<sup>[https://git.kernel.org/linus/c7a43b089826b17e46419d93c00c0d2f4b26735f]
|-
|-
| Rastergraphics unit RGA2e
| Rastergraphics unit RGA2e
| colspan="2" style="text-align:center;"|tbd
| colspan="2" style="text-align:center;"|tbd
| <code>rga</code> (v4l2 mem2mem driver)
| <code>rga</code> (v4l2 mem2mem driver)
|
| WIP patches for activation on the Pinenote/dithering/Y4-conversion can be found here: <sup>[https://github.com/m-weigand/linux/commits/mw/rk35/rk356x-rga]</sup>.
Note that the rga2e in the rk3566 only works for RAM <= 4 G!).
Simple demo program found here: <sup>[https://github.com/m-weigand/rga-v4l2-demo]</sup>
|-
|-
| Mali GPU
| Mali GPU
Line 71: Line 64:
| style="background:PaleGreen; text-align:center;"|Upstream Mesa
| style="background:PaleGreen; text-align:center;"|Upstream Mesa
| <code>panfrost</code>
| <code>panfrost</code>
| As of 5.18 <sup>[https://git.kernel.org/linus/810028668c6d9da25664195d6b906c98a8169f72]</sup> this got added to the <code>.dtsi</code> file, but it's status is disabled.
| As of 5.18 <sup>[https://git.kernel.org/linus/810028668c6d9da25664195d6b906c98a8169f72]</sup> this got added to the <code>.dtsi</code> file, but it's status is disabled. Enabling the <code>gpu</code> node upstream needs to wait till <code>rockchip-ebc</code> is upstreamed.
I haven't seen the <code>gpu</code> node getting enabled in the <code>.dts</code> for PineNote (yet)?
|-
|-
| Wifi/BT
| Wifi/BT
Line 80: Line 72:
|}
|}


==== Development work ====
=== Mainlining notes ===


* tps65185: driver developed here: <sup>[https://github.com/smaeul/linux/tree/rk35/tps65185]</sup>, small tweaks to resume behaviour added on top here: <sup>[https://github.com/m-weigand/linux/commits/mw/rk35/tps65185]
Some work happening here: https://gitlab.com/calebccff/linux, the idea is to import the parts of the eink/ebc drivers which are open source and use the downstream u-boot framebuffer driver as a reference to create a basic framebuffer driver.
* RGA: WIP patches for activation on the Pinenote/dithering/Y4-conversion can be found here: <sup>[https://github.com/m-weigand/linux/commits/mw/rk35/rk356x-rga]</sup>. Note that the rga2e in the rk3566 only works for RAM <= 4 G!). Simple demo program found here: <sup>[https://github.com/m-weigand/rga-v4l2-demo]</sup>
* The rockchip-sip driver required for suspend/resume is currently only hacked-in <sup>[https://github.com/smaeul/linux/commit/72127ca2806623a9de52cc1de39b06a38a22fe48]</sup>


= More Information =
Currently mainline struggles to boot due to weird issues while probing fixed regulators (?). It also fails to detect eMMC.
== High-level developer new to embedded linux? ==
Here are some resources I have found helpful in learning to develop on embedded linux devices:
* Great youtube series introducing you to the kernel and lower-level components of Linux: https://www.youtube.com/watch?v=WiZ05pnHZqM
* https://embetronicx.com/
* https://bootlin.com/training/
* https://www.nand2tetris.org


== Notes Written by Some Developers ==
Further work is being done here: https://github.com/smaeul/linux/commits/rk356x-ebc-dev. This has a complete device tree, with working eMMC. Pen input also works out of the box. Wi-Fi and BT work with firmware copied from the factory Android image.
 
* https://github.com/m-weigand/mw_pinenote_misc (Not super legible "notes", but very helpful repo with patches, videos, etc)
** specifically see this section for helpful install/configure scripts: https://github.com/m-weigand/mw_pinenote_misc/tree/main/rockchip_ebc/patches#compiling.
* https://github.com/0cc4m/pinenote-misc
** patch for enabling gpu: https://github.com/0cc4m/pinenote-misc/blob/main/mesa-archlinux-arm/mesa/rockchip_ebc.patch
** prebuilt pkg's: https://github.com/0cc4m/pinenote-misc/releases
* https://pwarren.id.au/pinenote/build_notes.txt
* https://github.com/DorianRudolph/pinenotes
* https://github.com/tpwrules/nixos-pinenote
 
== Alternative to patching of mesa ==
Mesa needs to be patched to add the driver entry point. The alternative to this, is the renaming of the ebc driver to an existing mesa driver entry point. A good existing name can be "repaper". To change the driver name, edit in the kernel tree the following files:<br>
- replace "rockchip-ebc" with "repaper" in the two places in the file: drivers/gpu/drm/rockchip/rockchip_ebc.c <br>
- preventive, replace "repaper" with "repaper-disabled" in the two places in the file: drivers/gpu/drm/tiny/repaper.c <br>
 
== Building the most recent kernel ==
See [https://wiki.pine64.org/wiki/PineNote_Development/Building_Kernel here].
 
 
== Video of Factory Android OS ==
 
[https://www.youtube.com/watch?v=DWuTGgQHw98 PineNote Developer Edition w/Tech Demo Android OS (Video Only)]
 
Informal walkthrough of the factory Android installation on the PineNote Developer Edition, recorded by a community member (Apr 2022). This is useful to look back at the original OS after erasing it from your device, or to get some additional detail before your device arrives.
 
The video also includes a chapter at the end showing [https://www.youtube.com/watch?v=DWuTGgQHw98&t=802s how to enable Android Debug Bridge (`adb`) over USB]. Once enabled, keep the device powered and connect a USB cable directly to the PineNote (i.e. no UART breakout) to a computer running `adb`.
 
== Emulator for Developing/Testing Pinenote Apps ==
https://github.com/michaelshiel/picom-epaper
 
= Flashing Software =
Currently, the only ways to flash software are from the factory Android installation (UART shell, adb, or fastboot) or by using rkdeveloptool.
 
== Backup of the content of the internal MMC before you mess anything up ==
Especially the '''waveform''' partition contains data '''unique''' to your PineNote and is a prime candidate for backup.
 
But other partitions like uboot (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) contains data you may wish to backup.
 
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)
 
In any case it is easier to restore/extract data from a backup than not having one if you need one.
 
=== Manually using rkdeveloptool ===
Dorian has some nice [https://github.com/DorianRudolph/pinenotes notes regarding the PineNote]
 
Don't forget to install a patched uboot for reading beyond 32MB and to respect the 2GB limit/bug of the current rkdeveloptool as per his notes
 
=== Automated backup using a script and rkdeveloptool ===
[https://github.com/talpadk/pinenote-backup pinenote-backup] is a python script for detecting the partitions and automating the backup of partitions or the whole disk
 
I also requires a patched u-boot but automatically handles the 2GB limit by splitting up larger reads into smaller ones
 
=== Using the factory Android installation ===
For any one knowing how and with which caveats: Write ME
 
=== Using a user installed Linux ===
A Linux installed to the cache partition should be able to easily backup everything over WiFi or to a USB stick/disk using dd
 
However the user would need to backup the cache partition themself (if they want that).
 
And more importantly they would only be getting the backup ''after'' they started playing with the content of the MMC.
 
== Side-by-side setup ==
 
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.
 
=== Without Repartitioning ===
 
The recommended partition for this is <tt>mmcblk0p11</tt> aka <tt>/cache</tt>. It is large and already formatted as <tt>ext4</tt>, so it is readable from U-Boot. Here are some general steps:
 
# From the UART or adb shell, set up your chroot in <tt>/cache</tt>. I used the Alpine Linux rootfs tarball.
# Copy in your kernel and DTB, using for example <tt>scp</tt> or <tt>wget</tt> inside the chroot.
# Finally, create and boot an <code>extlinux.conf</code> as described below.
 
=== With Repartitioning ===
 
It is possible to shrink the <tt>userdata</tt> partition, and create a new partition at the end for use with mainline Linux. This provides much more space than <tt>cache</tt>. However, because <tt>userdata</tt> is formatted with <tt>f2fs</tt>, and that filesystem cannot be shrunk, resizing the partition requires wiping <tt>userdata</tt>.
 
# Back up any necessary files from userdata
# Boot to a mainline kernel from <tt>mmcblk0p11</tt>, either using that partition as rootfs (see above), or using an initramfs with repartitioning tools
# Modify the partition table with your favorite tool, e.g. <tt>fdisk</tt>, <tt>gdisk</tt>, or <tt>parted</tt>
# Reboot into <tt>fastboot</tt> and wipe <tt>userdata</tt>.
# Reboot into Android, where you can now chroot in and install your favorite distribution to the new partition.
 
== Using rkdeveloptool ==
 
rkdeveloptool is a command line utility built on libusb.
 
=== Downloading and Building rkdeveloptool ===
 
PINE64 develops [https://gitlab.com/pine64-org/quartz-bsp/rkdeveloptool its own updated fork of rkdeveloptool on GitLab].
 
You will need to have libusb 1.0, its development headers and scdoc installed.
 
<pre>
git clone https://gitlab.com/pine64-org/quartz-bsp/rkdeveloptool.git
cd rkdeveloptool
mkdir build
cd build
cmake ..
</pre>
 
This sets up all the build files. You can then compile with <code>make</code> inside the build directory.
 
After you're done, you'll likely also need to install the udev rules, or else your user won't have permission to access the USB devices:
 
<pre>
sudo cp 99-rk-rockusb.rules /etc/udev/rules.d/
sudo udevadm control --reload
</pre>
 
Copying the udev rules is also performed automatically when you <code>make install</code>.
 
=== Building Downstream U-Boot ===
 
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.
 
You also need to install Python and pyelftools.
 
<b> Note that rkbin is a &gt;5GB download!</b> This will take some time to clone and process the deltas.
 
<pre>
git clone -b quartz64 https://gitlab.com/pgwipeout/u-boot-rockchip.git
git clone -b rkbin https://github.com/JeffyCN/rockchip_mirrors.git rkbin
cd u-boot-rockchip
# If using Arch Linux, export CROSS_COMPILE=aarch64-linux-gnu-
export CROSS_COMPILE=aarch64-none-linux-gnu-
make rk3566-quartz64_defconfig
./make.sh
</pre>
 
<blockquote>
In the version I cloned (current as of 2022-01-02), I had to make a change to one line to get a clean compilation:
 
<pre>
diff --git a/lib/avb/libavb/avb_slot_verify.c b/lib/avb/libavb/avb_slot_verify.c
index 123701fc3b..64a1ce6450 100644
--- a/lib/avb/libavb/avb_slot_verify.c
+++ b/lib/avb/libavb/avb_slot_verify.c
@@ -296,7 +296,7 @@ static AvbSlotVerifyResult load_and_verify_hash_partition(
  bool image_preloaded = false;
  uint8_t* digest;
  size_t digest_len;
-  const char* found;
+  const char* found = NULL;
  uint64_t image_size;
  size_t expected_digest_len = 0;
  uint8_t expected_digest_buf[AVB_SHA512_DIGEST_SIZE];
</pre>
 
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:
<pre>
diff --git a/make.sh b/make.sh
index 2bba05b4e4..cfe5b0afd5 100755
--- a/make.sh
+++ b/make.sh
@@ -758,7 +758,7 @@ function pack_fit_image()
        fi
        if [ "${ARM64_TRUSTZONE}" == "y" ]; then
-              if ! python -c "import elftools" ; then
+              if ! python3 -c "import elftools" ; then
                        echo "ERROR: No python 'pyelftools', please: pip install pyelftools"
                        exit 1
                fi
</pre>
</blockquote>
 
=== Entering Maskrom/Rockusb Mode ===
 
There are three ways to get into Maskrom/Rockusb mode:
 
====  The easy way ====
 
# Flip the device around so that the display faces down
# Lay the pen on the right side, with its tip pointing towards the speaker grill, and its magnet pointing towards the upper right corner of the label on the back (or place the magnetic cap from the pen on the spot marked on the back).
# Turn the device on and wait for it to show up in <code>lsusb</code>. It should now be in Loader mode, according to <code>rkdeveloptool list-devices</code> (note that "Loader" here indicates U-Boot's Rockusb; separately, booting with an erased eMMC displays "Maskrom" [not "Loader"] from the RK3566).
# Unplug the device and plug it back in. It should now be in Rockusb mode.
 
This can be a bit fiddly to get right, and may need a few tries.
 
==== The u-boot way ====
# Interrupt the u-boot startup using ctrl-c (while attached using an UART dongle)
# While in u-boot use the command "rockusb 0 mmc 0" to start rockusb mode.
 
One benefit from this is, that if you have an UART dongle that allows to simultaneous having an UART and USB connection, there is no need to plug and unplug cables and flipping the PineNote around and placing magnets. 
 
This is especially helpful when changing back and forth between u-boot and rockusb, for instance when trying to develop u-boot.
 
==== Shorting test points ====
 
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).
 
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):
 
[[File:PineNote_Maskrom_TP.png|500px]]
 
Then plug the device to the computer and if you see the device with VID=2207/PID=350a then it should be in Maskrom mode, you can verify by typing <code>rkdeveloptool list-devices</code>.
 
<nowiki>Jan 07 15:04:13 melttower kernel: usb 1-14: New USB device found, idVendor=2207, idProduct=350a, bcdDevice= 1.00
Jan 07 15:04:13 melttower kernel: usb 1-14: New USB device strings: Mfr=0, Product=0, SerialNumber=0
 
$ rkdeveloptool list-devices
DevNo=1 Vid=0x2207,Pid=0x350a,LocationID=10e    Maskrom</nowiki>
 
 
If nothing shows up, you can try to hold down the power button for 5 seconds and then try again.
 
=== Running rkdeveloptool ===
 
First, you'll want to make sure the device you've connected is in maskrom mode:
 
<pre>
./rkdeveloptool list
</pre>
 
It should output something like <code>DevNo=1 Vid=0x2207,Pid=0x350a,LocationID=202    Maskrom</code>. If it doesn't, see [[PineNote Development#Entering Maskrom Mode]].
 
You can now download u-boot onto it:
<pre>
./rkdeveloptool boot ../u-boot-rockchip/rk356x_spl_loader_v1.08.111.bin
</pre>
 
This should output <code>Downloading bootloader succeeded.</code>.
 
We can now verify that this worked using e.g. the "read flash info" command:
 
<pre>
./rkdeveloptool read-flash-info
</pre>
 
'''TODO:''' finish this section
 
=== Creating a mainline boot image ===
 
You can create a filesystem image that replaces the Android boot or recovery partition by doing roughly the following:
 
# Erase boot and dtbo with rkdeveloptool or fastboot (back them up first!!!)
# Create an ext2 partition image and mount it (fallocate, mkfs.ext2)
# Build your mainline kernel
# Copy the kernel, dtb and an initramfs to the root of the mounted image (use any old postmarketOS initramfs)
# Create a file in the root of the mounted image called <code>extlinux.conf</code> as described below
# Unmount the image and then use rkdeveloptool to flash it to the "recovery" partition on the pinenote (it's about the right size until we get around to replacing the partition layout).
 
== Using fastboot ==


Follow the steps for "Creating a mainline boot.img", but instead of flashing it with rkdeveloptool, use fastboot. You can enter fastboot in either of two ways:
== Pages discussing the development efforts ==


# Use "reboot bootloader" from adb or a UART console.
The software releases can be found here in the future:
# Get a U-Boot prompt and run <code>fastboot usb 0</code>.


= Mainline development =
* [[PineNote Software Releases]]


== Status ==
The following pages discuss the development efforts for the PineNote:


Some work happening here: https://gitlab.com/calebccff/linux, the idea is to import the parts of the eink/ebc drivers which are open source and use the downstream u-boot framebuffer driver as a reference to create a basic framebuffer driver.
* [[PineNote Development]]
* [[PineNote Development/Flashing]]
* [[PineNote Development/Booting Linux]]
* [[PineNote Development/Building Kernel]]
* [[PineNote Development/TODOs]]


Currently mainline struggles to boot due to weird issues while probing fixed regulators (?). It also fails to detect eMMC.
For tweaks and tricks see:
* [[PineNote Development/Software Tweaks]]


Further work is being done here: https://github.com/smaeul/linux/commits/rk356x-ebc-dev. This has a complete device tree, with working eMMC. Pen input also works out of the box. Wi-Fi and BT work with firmware copied from the factory Android image.
For app development see:
* [[PineNote Development/Apps]]


== How to boot mainline ==
== How to boot mainline ==
Line 371: Line 115:
=== Using sysboot ===
=== Using sysboot ===


<code>extlinux.conf</code> should have the following contents:
The '''extlinux.conf''' should have the following contents:


<pre>
timeout 10
timeout 10
default MAINLINE
default MAINLINE
menu title boot prev kernel
menu title boot prev kernel
 
label MAINLINE
label MAINLINE
  kernel /vmlinuz
  kernel /vmlinuz
  fdt /rk3566-pinenote.dtb
  fdt /rk3566-pinenote.dtb
  initrd /initramfs
  initrd /initramfs
  append earlycon console=tty0 console=ttyS2,1500000n8 fw_devlink=off PMOS_NO_OUTPUT_REDIRECT
  append earlycon console=tty0 console=ttyS2,1500000n8 fw_devlink=off PMOS_NO_OUTPUT_REDIRECT
</pre>


At the u-boot console, run the following command to boot your mainline kernel:
At the U-Boot console, run the following command to boot your mainline kernel:


<pre>
sysboot ${devtype} ${devnum}:9 any ${scriptaddr} extlinux.conf
sysboot ${devtype} ${devnum}:9 any ${scriptaddr} extlinux.conf
</pre>


=== Booting with individual commands ===
=== Booting with individual commands ===
Line 411: Line 151:
==== Getting it from the Android install manually ====
==== Getting it from the Android install manually ====
Copy WiFi/BT firmware from Android:
Copy WiFi/BT firmware from Android:
  mkdir -p /cache/lib/firmware/brcm
  mkdir -p /cache/lib/firmware/brcm
  cp /vendor/etc/firmware/fw_bcm43455c0_ag_cy.bin /cache/lib/firmware/brcm/brcmfmac43455-sdio.bin
  cp /vendor/etc/firmware/fw_bcm43455c0_ag_cy.bin /cache/lib/firmware/brcm/brcmfmac43455-sdio.bin
Line 417: Line 158:


Copy waveform partition (via previously dumped file):
Copy waveform partition (via previously dumped file):
  adb root
  adb root
  adb push waveform.img /cache/lib/firmware/waveform.bin
  adb push waveform.img /cache/lib/firmware/waveform.bin


Or via dd within Linux:
Or via dd within Linux:
  dd if=/dev/mmcblk0p3 of=/lib/firmware/waveform.bin bs=1k count=2048
  dd if=/dev/mmcblk0p3 of=/lib/firmware/waveform.bin bs=1k count=2048


==== Getting the Wifi and Bluetooth driver blobs from "other" sources ====
==== Getting the Wifi and Bluetooth driver blobs from "other" sources ====
===== WiFi =====
===== WiFi =====
The WiFi firmware .bin blob can be obtained by installing the Debian package firmware-brcm80211 (in the non-free section)
The WiFi firmware .bin blob can be obtained by installing the Debian package firmware-brcm80211 (in the non-free section; in Bookworm and later it's in the non-free-firmware section)
 
The WiFi brcmfmac43455-sdio.txt file can according to Eugen be sourced from https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/brcm/brcmfmac43455-sdio.AW-CM256SM.txt needs a renaming when copying it to /lib/firmware/brcm/brcmfmac43455-sdio.txt)


''The content of the upstream .txt is different than the Android configuration, but is supposed to work.''
The WiFi brcmfmac43455-sdio.txt file can according to Eugen be sourced from https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/brcm/brcmfmac43455-sdio.AW-CM256SM.txt needs a renaming when copying it to /lib/firmware/brcm/brcmfmac43455-sdio.txt). The content of the upstream .txt is different than the Android configuration, but is supposed to work.


As you don't have WiFi yet you need to get the firmware-brcm80211*.deb and brcmfmac43455-sdio.txt file on the PineNote by other means, for instance using an USB stick
As you don't have WiFi yet you need to get the ''firmware-brcm80211*.deb'' and ''brcmfmac43455-sdio.txt'' file on the PineNote by other means, for instance using an USB stick


===== Bluetooth =====
===== Bluetooth =====


Once you have WiFi working you can get BCM4345C0.hcd by installing the bluez-firmware  
Once you have WiFi working you can get BCM4345C0.hcd by installing the ''bluez-firmware'':
  sudo apt install bluez-firmware


sudo apt install bluez-firmware


=== Configuring the E-ink refresh mode ===
=== Configuring the E-ink refresh mode ===
https://github.com/m-weigand/mw_pinenote_misc/tree/main/rockchip_ebc/patches contains information on how/where to write in /sys to alter the refresh mode
https://github.com/m-weigand/mw_pinenote_misc/tree/main/gnome_extension contains the gnome extension used in Maximilian image


* https://github.com/m-weigand/mw_pinenote_misc/tree/main/rockchip_ebc/patches contains information on how/where to write in ''/sys'' to alter the refresh mode
* https://github.com/m-weigand/mw_pinenote_misc/tree/main/gnome_extension contains the gnome extension used in Maximilian image


=== Touchscreen and Pen In X.org ===
=== Touchscreen and Pen In X.org ===
Line 449: Line 189:
By default the pen config is flipped 180° (which makes it unusable) and the touchscreen doesn't work. Placing the following config in <code>/etc/X11/xorg.conf.d/50-touchscreen.conf</code> will fix both problems:
By default the pen config is flipped 180° (which makes it unusable) and the touchscreen doesn't work. Placing the following config in <code>/etc/X11/xorg.conf.d/50-touchscreen.conf</code> will fix both problems:


<pre>
Section "InputClass"
Section "InputClass"
    Identifier "evdev touchscreen"
    Identifier "evdev touchscreen"
    MatchProduct "tt21000"
    MatchProduct "tt21000"
    MatchIsTouchscreen "on"
    MatchIsTouchscreen "on"
    Driver        "evdev"
    Driver        "evdev"
EndSection
EndSection
Section "InputClass"
Section "InputClass"
    Identifier    "RotateTouch"
    Identifier    "RotateTouch"
    MatchProduct    "w9013"
    MatchProduct    "w9013"
    Option    "TransformationMatrix" "-1 0 1 0 -1 1 0 0 1"
    Option    "TransformationMatrix" "-1 0 1 0 -1 1 0 0 1"
EndSection
EndSection
 
</pre>
== Further information ==
=== Notes Written by Some Developers ===
 
* https://github.com/m-weigand/mw_pinenote_misc (Not super legible "notes", but very helpful repo with patches, videos, etc)
** specifically see this section for helpful install/configure scripts: https://github.com/m-weigand/mw_pinenote_misc/tree/main/rockchip_ebc/patches#compiling.
* https://github.com/0cc4m/pinenote-misc
** patch for enabling gpu: https://github.com/0cc4m/pinenote-misc/blob/main/mesa-archlinux-arm/mesa/rockchip-ebc.patch
** prebuilt pkg's: https://github.com/0cc4m/pinenote-misc/releases
* https://pwarren.id.au/pinenote/build_notes.txt
* https://github.com/DorianRudolph/pinenotes
* https://github.com/tpwrules/nixos-pinenote
 
=== Alternative to patching of mesa ===
 
Mesa needs to be patched to add the driver entry point. The alternative to this, is the renaming of the ebc driver to an existing mesa driver entry point. A good existing name can be "repaper". To change the driver name, edit in the kernel tree the following files:
 
* replace "rockchip-ebc" with "repaper" in the two places in the file: drivers/gpu/drm/rockchip/rockchip_ebc.c <br>
* preventive, replace "repaper" with "repaper-disabled" in the two places in the file: drivers/gpu/drm/tiny/repaper.c <br>
 
=== Video of Factory Android OS ===
 
[https://www.youtube.com/watch?v=DWuTGgQHw98 PineNote Developer Edition w/Tech Demo Android OS (Video Only)]
 
Informal walkthrough of the factory Android installation on the PineNote Developer Edition, recorded by a community member (Apr 2022). This is useful to look back at the original OS after erasing it from your device, or to get some additional detail before your device arrives.
 
The video also includes a chapter at the end showing [https://www.youtube.com/watch?v=DWuTGgQHw98&t=802s how to enable Android Debug Bridge ("adb") over USB]. Once enabled, keep the device powered and connect a USB cable directly to the PineNote (i.e. no UART breakout) to a computer running <code>adb</code>.
 
[[Category:PineNote]]

Latest revision as of 23:34, 7 April 2023

This article seeks to provide general mainline Linux development information for the PineNote.

Mainline development

Status

The following table aims to provide a list of kernel modules required for running the PineNote. It also aims at listing repositories of work in progress. While some overlap with the Quartz64 module list (Quartz64_Development#Upstreaming_Status) is expected, only modules relevant to the PineNote hardware should be listed here.

Function Status Module Notes
Suspend mode driver tbd rockchip-sip The rockchip-sip driver is not mainlineable; it is only needed (via a hack) for suspend/resume to work when downstream TF-A is used. Suspend on upstream TF-A (status) should work without any special drivers.
Touchscreen Linux Mainline cyttsp5 As of 6.2-rc1[1]
Digitizer Linux Mainline i2c_hid_of
Pen BLE Buttons tbd ws8100-pen https://github.com/smaeul/linux/commit/46e87f1f9c7dd22af26d99f60eb83d2cace43cb5
EBC Display controller tbd rockchip-ebc RFC PATCH 00/16 drm/rockchip: Rockchip EBC ("E-Book Controller") display driver
EBC PMic tbd tps65185 driver developed here: [2], small tweaks to resume behavior added on top here: [3]
LED backlight driver Linux Mainline lm3630a
Accelerometer Linux Mainline st-accel-i2c (silan,sc7a20) As of 5.18-rc1[4]
Rastergraphics unit RGA2e tbd rga (v4l2 mem2mem driver) WIP patches for activation on the Pinenote/dithering/Y4-conversion can be found here: [5].

Note that the rga2e in the rk3566 only works for RAM <= 4 G!). Simple demo program found here: [6]

Mali GPU Linux Mainline Upstream Mesa panfrost As of 5.18 [7] this got added to the .dtsi file, but it's status is disabled. Enabling the gpu node upstream needs to wait till rockchip-ebc is upstreamed.
Wifi/BT Linux Mainline brcmfmac

Mainlining notes

Some work happening here: https://gitlab.com/calebccff/linux, the idea is to import the parts of the eink/ebc drivers which are open source and use the downstream u-boot framebuffer driver as a reference to create a basic framebuffer driver.

Currently mainline struggles to boot due to weird issues while probing fixed regulators (?). It also fails to detect eMMC.

Further work is being done here: https://github.com/smaeul/linux/commits/rk356x-ebc-dev. This has a complete device tree, with working eMMC. Pen input also works out of the box. Wi-Fi and BT work with firmware copied from the factory Android image.

Pages discussing the development efforts

The software releases can be found here in the future:

The following pages discuss the development efforts for the PineNote:

For tweaks and tricks see:

For app development see:

How to boot mainline

UART is currently REQUIRED for this to work! We depend on u-boot falling back to console. Once we have a prebuilt u-boot which will use extlinux by default, UART won't be needed anymore.

You can compile a u-boot that uses extlinux by default by following the instructions here.

Getting to a U-Boot prompt

You can get to a U-Boot prompt by:

  1. Holding Ctrl-C while the display panel initializes.
  2. Wiping the "boot" partition.

Using sysboot

The extlinux.conf should have the following contents:

timeout 10
default MAINLINE
menu title boot prev kernel

label MAINLINE
  kernel /vmlinuz
  fdt /rk3566-pinenote.dtb
  initrd /initramfs
  append earlycon console=tty0 console=ttyS2,1500000n8 fw_devlink=off PMOS_NO_OUTPUT_REDIRECT

At the U-Boot console, run the following command to boot your mainline kernel:

sysboot ${devtype} ${devnum}:9 any ${scriptaddr} extlinux.conf

Booting with individual commands

Booting with individual commands can be useful when you need to temporarily add some kernel command line arguments. Use these or similar commands at the U-Boot shell:

load mmc 0:b ${kernel_addr_r} boot/Image
load mmc 0:b ${fdt_addr_r} boot/rk3566-pinenote.dtb
setenv bootargs ignore_loglevel root=/dev/mmcblk0p11 rootwait init=/bin/bash
booti ${kernel_addr_r} - ${fdt_addr_r}

Configuration

Firmware for WiFi & Bluetooth and Waveform data

Using Maximilian's Debian image

If the Android partition (super) and waveform partition (waveform) is left intact the image extracts the WiFi, BT driver and waveform from the partitions on first run.

For instance if you repartitions the userdata partition and installs the image there.

Getting it from the Android install manually

Copy WiFi/BT firmware from Android:

mkdir -p /cache/lib/firmware/brcm
cp /vendor/etc/firmware/fw_bcm43455c0_ag_cy.bin /cache/lib/firmware/brcm/brcmfmac43455-sdio.bin
cp /vendor/etc/firmware/nvram_ap6255_cy.txt /cache/lib/firmware/brcm/brcmfmac43455-sdio.txt
cp /cache/lib/firmware/BCM4345C0.hcd /cache/lib/firmware/brcm/BCM4345C0.hcd

Copy waveform partition (via previously dumped file):

adb root
adb push waveform.img /cache/lib/firmware/waveform.bin

Or via dd within Linux:

dd if=/dev/mmcblk0p3 of=/lib/firmware/waveform.bin bs=1k count=2048

Getting the Wifi and Bluetooth driver blobs from "other" sources

WiFi

The WiFi firmware .bin blob can be obtained by installing the Debian package firmware-brcm80211 (in the non-free section; in Bookworm and later it's in the non-free-firmware section)

The WiFi brcmfmac43455-sdio.txt file can according to Eugen be sourced from https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/brcm/brcmfmac43455-sdio.AW-CM256SM.txt needs a renaming when copying it to /lib/firmware/brcm/brcmfmac43455-sdio.txt). The content of the upstream .txt is different than the Android configuration, but is supposed to work.

As you don't have WiFi yet you need to get the firmware-brcm80211*.deb and brcmfmac43455-sdio.txt file on the PineNote by other means, for instance using an USB stick

Bluetooth

Once you have WiFi working you can get BCM4345C0.hcd by installing the bluez-firmware:

sudo apt install bluez-firmware

Configuring the E-ink refresh mode

Touchscreen and Pen In X.org

By default the pen config is flipped 180° (which makes it unusable) and the touchscreen doesn't work. Placing the following config in /etc/X11/xorg.conf.d/50-touchscreen.conf will fix both problems:

Section "InputClass"
    Identifier "evdev touchscreen"
    MatchProduct "tt21000"
    MatchIsTouchscreen "on"
    Driver        "evdev"
EndSection
Section "InputClass"
    Identifier    "RotateTouch"
    MatchProduct    "w9013"
    Option    "TransformationMatrix" "-1 0 1 0 -1 1 0 0 1"
EndSection

Further information

Notes Written by Some Developers

Alternative to patching of mesa

Mesa needs to be patched to add the driver entry point. The alternative to this, is the renaming of the ebc driver to an existing mesa driver entry point. A good existing name can be "repaper". To change the driver name, edit in the kernel tree the following files:

  • replace "rockchip-ebc" with "repaper" in the two places in the file: drivers/gpu/drm/rockchip/rockchip_ebc.c
  • preventive, replace "repaper" with "repaper-disabled" in the two places in the file: drivers/gpu/drm/tiny/repaper.c

Video of Factory Android OS

PineNote Developer Edition w/Tech Demo Android OS (Video Only)

Informal walkthrough of the factory Android installation on the PineNote Developer Edition, recorded by a community member (Apr 2022). This is useful to look back at the original OS after erasing it from your device, or to get some additional detail before your device arrives.

The video also includes a chapter at the end showing how to enable Android Debug Bridge ("adb") over USB. Once enabled, keep the device powered and connect a USB cable directly to the PineNote (i.e. no UART breakout) to a computer running adb.