Difference between revisions of "PineNote Development/Booting Linux"
Aarondabomb (talk | contribs) m |
Aarondabomb (talk | contribs) m (almost done) |
||
Line 14: | Line 14: | ||
# Poke around the files (or skip this if you don't like to learn...): | # Poke around the files (or skip this if you don't like to learn...): | ||
## Open <code>uboot.env</code> -- see, it's just text at this point! | ## Open <code>uboot.env</code> -- see, it's just text at this point! | ||
## Open <code>uboot. | ## Open <code>boot-menu.patch</code> to get a feel for how that works | ||
# The boot-menu.patch makes assumptions about where your linux partition lives. Specifically, it will look at partition 0x11 (which is 17 in decimal). Change this in boot-menu.patch to reflect where your linux boot partition lives. | |||
# Apply boot-menu.patch: <code>patch uboot.env boot-menu.patch</code> | |||
## This doesn't work for me for some reason: | |||
<pre> | |||
$ patch uboot.env boot-menu.patch | |||
patching file env.original | |||
Hunk #3 FAILED at 24. | |||
patch unexpectedly ends in middle of line | |||
patch: **** unexpected end of file in patch at line 27 | |||
</pre> | |||
I couldn't figure out what it's complaining about here, so I ended up applying the patch manually. It's pretty straight-forward. | |||
# Rewrite the new environment to the image: <code>./pinenote-uboot-envtool.py insert uboot.img uboot.env uboot-patched.img</code> | |||
# Write the image to the boot partition: <code>dd if=~/uboot-patched.img of=/dev/mmcblk0p1</code> | |||
At this point, restarting your system will boot into Android -- this is because the patched uboot we've just created looks for <code>/boot/which_os.txt</code> to determine whether to boot android or linux, and since it can't find this file (we haven't made it yet), the bootloader defaults to android. | |||
Create that file on the same boot partition you specified in the boot-menu.patch file, placing an `l` in the file for linux. | |||
== Sources and further reading == | == Sources and further reading == | ||
[https://u-boot.readthedocs.io/en/latest/board/rockchip/rockchip.html U-boot with rockchip docs] | [https://u-boot.readthedocs.io/en/latest/board/rockchip/rockchip.html U-boot with rockchip docs] | ||
[https://stackoverflow.com/questions/31244862/what-is-the-use-of-spl-secondary-program-loader Helpful stack overflow to learn a bit about the boot process/terminology] | [https://stackoverflow.com/questions/31244862/what-is-the-use-of-spl-secondary-program-loader Helpful stack overflow to learn a bit about the boot process/terminology] |
Revision as of 21:00, 27 August 2022
To boot linux, we need to patch stock uboot. I used charasyn's method, based off work from Dorian as credited in the script. We'll use the script to pull the uboot environment out of the stock uboot partition. We'll then apply the patch, recreate the image, add a configuration file, and flash the new image to the PineNote.
Steps to patch uboot
- Get the patch and the python tool:
$ mkdir pinenote-uboot && cd pinenote-uboot $ curl https://gist.githubusercontent.com/charasyn/206b2537534b6679b0961be64cf9c35f/raw/cc513998a36fac0cea266260e3ca3e64abfe3696/boot-menu.patch -o boot-menu.patch $ curl https://gist.githubusercontent.com/charasyn/206b2537534b6679b0961be64cf9c35f/raw/cc513998a36fac0cea266260e3ca3e64abfe3696/pinenote-uboot-envtool.py -o pinenote-uboot-envtool.py $ chmod o+x pinenote-uboot-envtool.py
- Write your uboot partition to disk:
dd if=/dev/mmcblk0p1 of=~/uboot.img
- Extract the environment:
./pinenote-uboot-envtool.py extract uboot.img uboot.env
- Poke around the files (or skip this if you don't like to learn...):
- Open
uboot.env
-- see, it's just text at this point! - Open
boot-menu.patch
to get a feel for how that works
- Open
- The boot-menu.patch makes assumptions about where your linux partition lives. Specifically, it will look at partition 0x11 (which is 17 in decimal). Change this in boot-menu.patch to reflect where your linux boot partition lives.
- Apply boot-menu.patch:
patch uboot.env boot-menu.patch
- This doesn't work for me for some reason:
$ patch uboot.env boot-menu.patch patching file env.original Hunk #3 FAILED at 24. patch unexpectedly ends in middle of line patch: **** unexpected end of file in patch at line 27
I couldn't figure out what it's complaining about here, so I ended up applying the patch manually. It's pretty straight-forward.
- Rewrite the new environment to the image:
./pinenote-uboot-envtool.py insert uboot.img uboot.env uboot-patched.img
- Write the image to the boot partition:
dd if=~/uboot-patched.img of=/dev/mmcblk0p1
At this point, restarting your system will boot into Android -- this is because the patched uboot we've just created looks for /boot/which_os.txt
to determine whether to boot android or linux, and since it can't find this file (we haven't made it yet), the bootloader defaults to android.
Create that file on the same boot partition you specified in the boot-menu.patch file, placing an `l` in the file for linux.
Sources and further reading
U-boot with rockchip docs Helpful stack overflow to learn a bit about the boot process/terminology