Commit graph

36 commits

Author SHA1 Message Date
Aidan MacDonald
1e9ad3ca0d Remove buflib allocation names, part two
Remove allocation names from the buflib API and fix up all callers.

Change-Id: I3df922e258d5f0d711d70e72b56b4ed634fb0f5a
2023-01-13 10:32:54 +00:00
Aidan MacDonald
b4e7c60c6d Shanling Q1: Disable recovery kernel boot option
The Q1 handles firmware updates by unpacking the firmware image
from the player app, then rebooting into the recovery kernel.
The recovery kernel reflashes the player kernel and rootfs with
the unpacked update files on the SD card.

Booting the recovery kernel directly is therefore not useful to
the vast majority of users; remove the option from the recovery
menu and remove the key combo.

Change-Id: I6cebfb6a3514ff2ae7d6f3904ac93b481773799b
2022-10-29 12:51:05 +01:00
Aidan MacDonald
a5b08d0af7 Shanling Q1: Support OF-initiated firmware updates
It's now possible to install OF updates on a rockboxed Shanling Q1.
Previously these didn't work because the RB bootloader interrupted
the update process.

Updates will proceed as they normally do on a non-Rockboxed Q1,
except at the end of the update you'll reboot to Rockbox instead
of the OF. This is only a minor inconvienience and doesn't affect
the update process.

Change-Id: I0f8fc96f073c50c1512bf60e0927491be8178eb0
2022-10-29 12:51:02 +01:00
Aidan MacDonald
4101aeac54 x1000: simplify NAND command macros
There is actually no need to parameterize most commands with row
or column cycles, usually the opcode and row/column address width
are linked. When this is not the case we can use raw SFC commands
or define new macros.

Change-Id: I22459d732dc01012e6a8ae026c4fb85495d372b4
2022-07-21 11:39:19 +01:00
Aidan MacDonald
2fce0a98f8 x1000: add flash ONFI info dumper to bootloader
Dumps parts of the standard ONFI info located at page 0x01
of the OTP area to a file for easy copy'n'pasting.

Change-Id: Ie0ba66d27c400737f14deec7c21e9dcb144028a6
2022-07-19 13:43:38 +01:00
Aidan MacDonald
45e2d5d641 x1000: check for ECC failures in bootloader uimage reader
Update the uimage reader's bad block handling to treat an ECC
uncorrectable error on the first page of the block as a bad block.

Change-Id: Id3aa7a338fcc36c0e2381063b119efe41f957122
2022-07-19 13:15:26 +01:00
Aidan MacDonald
ad8ace53e5 x1000: remove 'typedef struct' from NAND driver
Using 'typedef struct' is not in line with the project coding style
and somewhat problematic, so get rid of it here.

Change-Id: Icfe79de72ed82cb7526e9f4e8296ec12084c01ac
2022-07-10 15:22:10 +01:00
Aidan MacDonald
4d01168b9b x1000: add flash probe tool to bootloader
The flash probe mimics the boot ROM's flash read routines and
dumps the manufacturer & device IDs and 16-byte parameter data
to a file on the SD card.

Change-Id: I3d413bd0cc05a9d7f2285b85454420c3e90274e9
2022-05-30 14:08:02 +01:00
Dana Conrad
7aa2a23b95 Eros Q Native: Add Original Firmware Boot option
Hold "Play" to boot the OF, or boot it from the recovery menu
by holding "Vol. Up". If you had the hosted port installed on your
player before installing the native port, you'll still have to go
through the hosted bootloader.

A couple notes:

- When booting from the menu, the recovery menu disappears, then
  reappears before going into the OF.

- You need to hold the play button for like a half second after the
  blue light comes on in order to get into the OF.

The recovery appears to be there, but it doesn't seem to be intended
for end users - it just says "Updater V1.1 - Insert TF Pls". I haven't
tested it beyond seeing that it boots, so I'm going to comment it out
for now.

Change-Id: Ie271ee479bb628cc74141b7fe07273b3f193f358
2022-04-01 12:04:30 -04:00
Aidan MacDonald
bd8cd58568 x1000: bootloader: Add button handlers for OF boot
The SPL soon won't be paying attention to buttons, so the bootloader
should check them.

Change-Id: I2048ca9fd19193f329bebecfefd986760c33fd68
2022-03-25 21:36:51 +00:00
Aidan MacDonald
cda8bd5437 x1000: bootloader: set touchscreen to button mode
The touchscreen "buttons" are used for screenshots on the Q1.

Change-Id: I6bff00976c614d203986e810e51f859e78e372ab
2022-03-25 21:36:51 +00:00
Aidan MacDonald
6bc69c797c x1000: bootloader: accept button input during splash
This allows screenshots to be taken while a splash is displayed.

Change-Id: Id494189283db1b6877416f5a1ef1a13c8b654507
2022-03-25 21:36:51 +00:00
Dana Conrad
3d88f455cf Fix double define of BL_SCREENSHOT_NAME on fiiom3k
Change-Id: Iaee40887de19ac2d78ec9bdea08cee678b7e50ef
2022-03-25 21:36:51 +00:00
Aidan MacDonald
5160c90690 x1000: bootloader: add screenshot function
Screenshots of the recovery menu will be useful for documentation.

This can be disabled by turning off HAVE_BOOTLOADER_SCREENDUMP in
the target config file if the bootloader should ever run up against
max size limits.

Change-Id: I62ec1e465df2ca7a8a0e78625d88b31f6c4ef078
2022-03-25 21:36:51 +00:00
Aidan MacDonald
4cf36dfbf3 x1000: bootloader: skip bad blocks when loading flashed kernels
Bad blocks in a kernel flash partition seem to be handled by skipping
ahead to the next block; this is a common bad block management scheme
for simple software like bootloaders (and is the default method for
reading NAND partitions in u-boot).

Extend the uImage flash reader to skip bad blocks while reading.

Change-Id: I815875e83a2418e2642f736e04a3437c31b354ba
2022-03-25 17:31:39 -04:00
Aidan MacDonald
9bbe08f3ec x1000: bootloader: add whole-chip flash dump option
I don't expect this will be all that useful, but why not...

Change-Id: Ieb486bb719c5cc61e0f3e95f9fb603a1c30c6528
2022-03-24 23:40:07 +00:00
Aidan MacDonald
c3562b6df6 x1000: bootloader: add debug tools menu
Add a debug menu to invoke two new actions, dumping the OF kernel
and recovery images from flash to the SD card.

Change-Id: I3ca943fac22e725a2d56b84d62f4a04821042fed
2022-03-24 23:40:07 +00:00
Aidan MacDonald
0d21d80ca8 x1000: bootloader: add basic flash dump utility
Change-Id: Id4ce0f00a78ef27399bdef6a7b32c23f89b9cb05
2022-03-24 23:40:07 +00:00
Aidan MacDonald
ee68d9df8e x1000: bootloader: display uimage load error code
Change-Id: I08361aa85406303c10bb487636a6a61a93d2b127
2022-03-24 23:40:07 +00:00
Aidan MacDonald
fbe9e4ac10 x1000: bootloader: refactor splash/splash2
Allow the use of printf formatting and multiple lines of text
using newlines in the string.

Change-Id: I65919bf29c16c34c38cf3995e02d2ddbbaa4bdf3
2022-03-24 23:40:07 +00:00
Aidan MacDonald
f7a341555d fiiom3k: trim OF kernel arguments to fix boot hangs
The M3K's kernel has an incredibly stupid function that mangles the
kernel args and copies them to a 100-byte buffer without any kind of
bounds checking. So, if the kernel arguments are more than 99 chars
the stack may be corrupted, sometimes crashing the kernel.

Fortunately, most of the arguments the OF uses are useless, and the
truly necessary arguments fit within the absurd 99-char limit.

Change-Id: I01ef4513298f79d3c08538239802c21e88509631
2022-03-24 23:40:07 +00:00
Aidan MacDonald
6a6c6083fa x1000: bootloader: fix Linux self-extracting kernel boot
Basically, there's longstanding bug in Linux with self-extracting
kernels on MIPS which just happened to manifest now on the M3K as
a hang on boot. The fix is applied to the M3K and Q1 since they
both use this type of kernel image.

Change-Id: I17d2bad6eebd677cd6d2e0bf146450c71fcf1229
2022-03-24 23:40:07 +00:00
Aidan MacDonald
90cb0b0ae5 x1000: bootloader: add mainline Linux boot option
This adds a *very basic* Linux loader to the Rockbox bootloader,
which allows running a mainline Linux kernel using the following
file layout on the SD card:

- /uImage
- /linux_cmdline.txt

The command line arguments are listed in linux_cmdline.txt, all
lines are concatenated together and whitespace is converted into
spaces. Comments aren't supported however.

The loader doesn't support the modern devicetree boot protocol,
so it can only pass command line arguments. It would be easy to
support an appended dtb though.

Change-Id: I373f465dbbdafe94738f619748cbb0278fc2c25f
2022-03-24 23:40:07 +00:00
Aidan MacDonald
53a92f0ecc x1000: bootloader: add original firmware boot capability
Adds the ability to boot the OF's player or recovery kernels
from the bootloader. Works on Shanling Q1 but broken on the
FiiO M3K (kernel hang) so leave it disabled for the M3K.

Change-Id: I26b973fba1c22afb906a78865963a96dd2107932
2022-03-24 23:40:07 +00:00
Aidan MacDonald
0ce287503c x1000: bootloader: use list widget for the recovery menu
This allows the menu to scroll when there isn't enough vertical
space to display the whole menu.

Change-Id: I6dc3e84cde0c1b003e579f107ae7f13e0ea33a5a
2022-03-12 14:50:45 -05:00
Aidan MacDonald
4b51ca5ce6 x1000: bootloader: add GUI list widget
Change-Id: Ic5bf4747ed99b713b7c035153865ed9bdebd89b0
2022-03-12 14:50:45 -05:00
Aidan MacDonald
e6c2f26e82 x1000: bootloader: add uImage loaders
Adds loaders for uImages on the SD card or on a raw flash partition.
These work similarily to load_rockbox() and return a buflib alloc
and size. Booting the image is left up to the caller.

Change-Id: I0d58e8c6a61d8349bc5223431cdd06dfdf2503fa
2022-03-12 18:25:10 +00:00
Aidan MacDonald
b87f2ed851 x1000: bootloader: refactor rockbox boot
Separate loading out into its own routine with a file name
parameter in preparation for multiboot support.

Change-Id: Ic651e9fa7738ea97789e4a9669834c4e3ef22d66
2022-03-12 18:25:10 +00:00
Aidan MacDonald
ed897d1359 x1000: bootloader: move the main function to its own file
Now that everything has been refactored into separate files the
main routine is the only thing left to move. Put it in main.c.

Change-Id: I53aba87ed281b52944fb80d9a62beaec1c87f152
2022-03-12 18:25:10 +00:00
Aidan MacDonald
5bdb2fccdb x1000: bootloader: refactor usb handling
Drop init_usb(), instead initialize USB early in the main function
so the hardware is placed into a known good state after a USB boot.
The impact on boot time should be minimal.

Change-Id: I9774ddfc2c27811363bdb0c54cb0e57b5ca59d73
2022-03-12 18:25:10 +00:00
Aidan MacDonald
7554a49309 x1000: bootloader: refactor init_disk
Add check_disk() to query the disk insertion status and prompt the
user if necessary. Use this in place of init_disk().

Perform an unconditional disk_mount_all() from the main function.

Change-Id: I9a8cc42266edf99cd15ece3aee8fa25835df04ae
2022-03-12 18:25:10 +00:00
Aidan MacDonald
905591215f x1000: bootloader: split off recovery menu code
Change-Id: I6c6a25dc248b5dcbca796781f761bef05337431c
2022-03-12 18:25:10 +00:00
Aidan MacDonald
e2fcbd04ea x1000: bootloader: split off rockbox boot code
Change-Id: Ie3a097b24ee96551f6c3d08938dcb83f59ba1073
2022-03-12 18:25:10 +00:00
Aidan MacDonald
22cf852db1 x1000: bootloader: split off installer code
Change-Id: I75918301214cd415392f8c95e8a07205cfa21659
2022-03-12 18:25:10 +00:00
Aidan MacDonald
6fb1b8b342 x1000: bootloader: split off GUI code
Change-Id: If716cfd117c48da2cff221b8854630022bb0fe48
2022-03-12 18:25:10 +00:00
Aidan MacDonald
8558255f45 x1000: bootloader: split off definitions to a header
Change-Id: Ic3e8bc8f61974dbfc30e833abd9a0f0b850e0a43
2022-03-12 18:25:10 +00:00