Commit graph

481 commits

Author SHA1 Message Date
Aidan MacDonald
52ca658069 x1000: Add support for DS35x1GAxxx flash chips
This flash chip is found on some Surfans F20 units. For our purposes
it's the same as the GD5F1GA4xExx so just #define an alias instead of
adding a whole new chip struct.

Change-Id: I2f4c4fbf1faf3a0c7a1503534430afacbddc426e
2022-12-01 12:11:46 -05:00
Aidan MacDonald
d09fb6bb6b x1000: Pass CPM scratch register to the bootloader
Change-Id: Iaef4606dc6f3cb9904d87ee92db69fb9ef48bcb0
2022-10-28 20:58:26 +01:00
Aidan MacDonald
744ea2ff43 x1000: Allow SPL and bootloader to pass arguments to next stage
Change-Id: I61591d704c14acf06cd192a6e9355f0a9c25d0d8
2022-10-28 20:32:38 +01:00
Aidan MacDonald
9e258652c4 x1000: Add a basic sanity check for bootloader backups
The bootloader backup is intentionally simple, but it's a little
*too* simple. Add a sanity check to make sure what we're backing
up or restoring contains the first 8 bytes of the SPL header.
This isn't going to catch all possible problems, but it'll stop
obviously non-functional backups from being restored.

Change-Id: I6e80351aeb96c467f0514bd0ecd77d94ff72a8f8
2022-10-28 20:32:38 +01:00
Aidan MacDonald
4bd97c6535 mips: consolidate exception handling, add exception backtraces
Merge the x1000 and jz47xx exception handling code since they use
the same exception vectors and handlers. The interrupt handler is
now called from the common exception vector, but remains separate
for each board since they have different IRQ layouts.

The new exception handler can provide a stack traceback from the
interrupted code, rather than the (uninteresting) caller traceback
displayed by panicf. This allows you to see what led up to a null
pointer deref or division by zero, which makes it _much_ easier to
track down errors that occur in common leaf functions like strcmp.

Change-Id: I59a0ebb5e40fcb36505c3bfdb47f8cac2f9936b1
2022-10-17 09:04:18 -04:00
William Wilgus
12ef045fdf move buflib_free invalid handle check to the function
allow buflib_free to check for invalid or already freed handles
within the function -- remove all the invalid handle guards thru core_free

Change-Id: Ibdcbc82760fc93b674c42283fca420d94907df8e
2022-10-15 09:26:58 -04:00
Solomon Peachy
418169aff8 Revert "Remove YUV blitting functions and LCD modes"
This reverts commit fe6aa21e9e.

Change-Id: I8bb1e5d6c52ed1478002d2140ef494ec5d62b8e3
2022-10-13 11:08:06 -04:00
Solomon Peachy
2928b71a69 mips: Work around an issue with GCC 8.
Change-Id: I9867674978ab6d4c99f5fa67c93e5b830531aefd
2022-10-10 08:24:33 -04:00
Aidan MacDonald
fe6aa21e9e Remove YUV blitting functions and LCD modes
None of this is needed now that mpegplayer is gone.

Change-Id: I360366db8513e4d988021e8d7b7d8eb09930efb8
2022-10-03 13:30:01 +01:00
Aidan MacDonald
bab8a41532 x1000: add support for GD5F1GQ4xExx NAND flash
This is another chip used in newer Surfans F20 units. Like the
Winbond chip, it's a 1-gigabit chip with on-die ECC. Notably it
has an expanded 128-byte OOB area that is only accessible when
on-die ECC is disabled.

Change-Id: I2203918a15c914097f5a6bbe4afa2d3a60dc67f7
2022-09-17 10:14:26 -04:00
Aidan MacDonald
e64b0e81ad x1000: add support for the W25N01GVxx NAND flash
This chip is apparently used in some Surfans F20 units, and has
the same geometry as the ATO25D1GA. It has an on-die ECC engine.

Change-Id: I4d37a2455620ce43cec0a9bcbb32c776d1a8eba1
2022-09-17 10:14:26 -04:00
Aidan MacDonald
17443de221 x1000: refactor NAND chip identification
Decouple chip IDs from chips, and allow the chip ID table to list
which read ID method should be used. Use a safe controller setup
during identification instead of using the first chip's parameters.

Change-Id: Ia725959c31b2838f4a3a30e5bb7fa6652ef377ed
2022-09-17 10:14:26 -04: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
9ab5d311cb x1000: move NAND commands to chip data
Using predefined commands is too inflexible so allow the chip data
to specify I/O commands directly.

Change-Id: Ie8f943914da4b8299678a59b1063c4c6d226e83e
2022-07-21 11:39:03 +01:00
Aidan MacDonald
c72f9c6d0f x1000: add NAND OTP access switch
Provide a way to toggle the OTP bit for reading OTP pages, mostly
useful for debug purposes.

Change-Id: Iec697de2dc188588c43d9ed466201971cac8f30c
2022-07-19 13:15:26 +01:00
Aidan MacDonald
db2817eb1a Fix red in commit 131566b8f8
Use per-function sections to avoid linking in x1000_boot_linux()
on normal builds, which prevents link errors due to referencing
a non-existent usb_close().

Change-Id: Ied7b233603c49fc856db8445e368675b181e2f1f
2022-07-10 15:58:45 +01:00
Aidan MacDonald
47cbeb2e67 x1000: add support for simple on-die ECC with NAND flash
Many SPI NAND flash chips have on-die ECC engines that report
ECC status via the status feature register. This code handles
the common case where ECC status is reported with 2 bits: one
bit to indicate if flips were detected & corrected, and another
bit to indicate an uncorrectable error.

Change-Id: I5d587cd960ca9d090d2629e890724a6bc411e70c
2022-07-10 15:22:32 +01:00
Aidan MacDonald
df29c7991a x1000: add setup_chip hook for NAND chips
Add a chip setup hook for configuring vendor specific registers
after the chip is identified.

Change-Id: Ifffa7f01be16fd147a9db3d6e402b7b0debd7e12
2022-07-10 15:22:31 +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
cc017f211a x1000: support 2nd device ID byte for NAND flash
Some components have additional ID bytes. Add support for an
optional 2nd device ID byte during the identification routine.

Change-Id: I5bbad73fb57004067c6f13f223f7bf4d43ff7849
2022-07-10 15:22:10 +01:00
Aidan MacDonald
131566b8f8 x1000: fix linux boot USB issues
If the USB controller is active when we hand over to Linux it'll
often trigger "irq nobody cared" warnings. Disabling the controller
before boot prevents that.

Also move the USB PHY bit workaround from the dualboot cleanup hook
to the main Linux boot function. Mainline kernels don't clear these
bits either.

Change-Id: Ieaf896c3b8c3e58a8c47de5afeb384ae2511a5fa
2022-07-10 09:48:39 -04:00
Aidan MacDonald
d0d13baf3e x1000: fix command line passing for linux boot
Change-Id: I2a016a5f64ef980f49a8cbdcbb0e0af9ad768ce0
2022-07-10 09:48:39 -04:00
Solomon Peachy
7296f30490 jz4760: Reformat USB driver a little. Prep work for later changes.
Change-Id: I74d068661ea8a8a59a88f0c2c5a938dcf6fb8b20
2022-06-12 17:09:32 -04: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
Aidan MacDonald
e05aa27124 x1000: move NAND commands to header file
Change-Id: Ic95b80494a101f7b349e115d82e9dfe3a64b643f
2022-05-30 14:02:13 +01:00
Aidan MacDonald
5ee9a45126 mips: stop backtraces at main()
Initialize ra=0 before calling main so backtraces don't walk
through the startup code.

Change-Id: Ia8796ce38b32d14025b47b3e00061267ee25cbaf
2022-05-22 07:16:11 -04:00
Dana Conrad
de285741bf ErosQ Native: Make power delay bootloader-only
gotta go fast

Change-Id: Ic01e4aa70a2bec4c48ae7cf8f32f8dfd366decad
2022-04-01 12:04:46 -04: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
7243f6b343 x1000: Add multiboot support
Enables multiboot for the FiiO M3K, Shanling Q1, and Eros Q native port.
Note this requires an up-to-date Rockbox _and_ bootloader.

Usage instructions will (eventually) be found on the wiki:
https://www.rockbox.org/wiki/MultibootBootloader

Change-Id: Ia2da1ad6ef611e499d2fbafa93838387bc1023ba
2022-03-27 10:35:02 -04:00
Aidan MacDonald
5d0f697e87 x1000: remove the last vestiges of boot option support
There should be no need for any compatibility hacks since this
value was mostly used internally between the SPL and bootloader.
clk_init() was the only user in the main Rockbox binary which
accessed it, but when loaded by the Rockbox bootloader that code
will not be reached since BOOT_FLAG_CLK_INIT is already set.

Change-Id: Idd68b9834172e652b47432bfb1e00c923ea35407
2022-03-25 21:36:51 +00:00
Aidan MacDonald
3ae4a98e3b x1000: spl: remove selectable boot option support
Now the SPL boots the Rockbox bootloader unconditionally, which
allows for some simplification.

Change-Id: Id75c82db25a87e0e9043bb0771f622b1fc9482fb
2022-03-25 21:36:51 +00:00
Aidan MacDonald
2810c549a6 x1000: spl: remove dual boot support code
Removes the SPL's dual boot support code, and removes the dual
boot selection code on the M3K and Q1 since they can now do it
from the main bootloader.

Change-Id: Ie1b27e98c6ed4b3e37db86cfb485d6f3a6c5b25e
2022-03-25 21:36:51 +00:00
Aidan MacDonald
7cb49cfb33 x1000: spl: split off NAND storage to separate file
Just tidying. No functional changes.

Change-Id: I8aa85c789d1a6bd357797c6c95e38a7325eba809
2022-03-25 21:36:51 +00:00
Aidan MacDonald
5b011c8dca x1000: add bad block marker position to nand_chip info
Change-Id: I6f466d87f6f11bc3e23463c469f318ecb7049ba7
2022-03-24 23:40:07 +00:00
Aidan MacDonald
44fbb1a593 x1000: bootloader: add LCD dualboot cleanup for the M3K
Disable LCD interrupts before booting the OF - the OF kernel
hangs at boot if they are enabled.

Change-Id: I4f119818d0243953cdd620e17d9509b4fb16cc28
2022-03-24 23:40:07 +00:00
William Wilgus
cfeeb7889d Lcd save function pointer to frame buffer get_address_fn before loops
Calling multiple levels of indirection in a loop slows things down

Really these need to be rewritten to take a start and end address
like most of the rest of the codebase

But this is safer without having test hardware in hand

Change-Id: Idae7b92ee779d020ed7fcc9334e2d5a9c710e64d
2022-03-21 23:53:48 -04:00
Aidan MacDonald
67f7d399e5 x1000: restore crt0.S cache flush
I-cache must be flushed after copying code to IRAM... duh.

Change-Id: I6eacc4b7c4385175724c947f6c53f7bbddcb6295
2022-03-16 23:21:29 +00:00
Aidan MacDonald
c676736792 x1000: optimize crt0.S, improve correctness
Replace inline section copy/fill loops with subroutines, which
reduces code size a bit and and handle zero size copies properly.

Remove the cache initialization loop as well. There's no actual
reason for this because the SPL initializes the caches and just
dropping the cache can even be harmful (in this case it wasn't,
because the SPL flushes the whole cache right before calling in).

Change-Id: I7cddc9ed6d060b1f1bdd75544297883d014cad2d
2022-03-16 12:02:24 -04:00
Aidan MacDonald
8b4949381c x1000: add TCSM section to linker script
This is intended for debugging OF kernel boot problems and has
to be enabled manually at compile time to make it usable.

Change-Id: Ie5ce9f0a7639be0acf5e3879cfc3a7b8b89caa5c
2022-03-12 14:50:45 -05:00
Aidan MacDonald
d56964cc2b x1000: add dual boot helpers for the main bootloader
Two helpers (_init_clocktree and _init_uart2) already existed in
the SPL and are copied verbatim from there. The SPL versions are
still present and will be removed when dual boot works from the
main bootloader.

The other two helpers (_cleanup and _load_pdma_fw) are new.

Change-Id: I4661667966e26f52e6c5142f1947d2a34b7008ef
2022-03-12 18:25:10 +00:00
Aidan MacDonald
a87f93d8ff x1000: add function for booting linux kernels
Change-Id: I0750b084fe88d21a8686daf0681b32b1dcba8fec
2022-03-12 18:25:10 +00:00
Aidan MacDonald
58225bd2c8 x1000: remove plugin and codec buffers on bootloader
On the bootloader there's no point reserving memory for these,
the only users of codecbuf/pluginbuf are in the apps/ tree.

Change-Id: Ib57b4d59aff8f4dcc753d7993956ed15e61cdc52
2022-03-12 18:25:10 +00:00
Aidan MacDonald
38eafb60ff x1000: use core_alloc in bootloader for loading rockbox
Using the audio buffer directly is a bad idea because this will
render core_alloc non-functional if load_firmware() writes into
the buffer but then fails, for example on a checksum mismatch.

Change-Id: Ib2d17bcea53bdea1c4c5496cec0c4eee5dd66069
2022-03-12 18:25:10 +00:00
Aidan MacDonald
603412f447 x1000: Clarify definition & usage of RAM areas
Document what the symbols are supposed to mean, fixup SPL's
usage of DRAM_END which should really be SDRAM_END instead.
No functional changes.

Change-Id: Ie85b0ee35fea8b7858891e5b9d6634eaae42c9f8
2022-03-11 11:15:56 -05:00
Aidan MacDonald
428491df69 x1000: support new binary header in rolo
Change-Id: I192c3d69616c39534ff329174c4d8d4a357d014d
2022-03-11 11:15:56 -05:00
Aidan MacDonald
eae9f6f5b7 erosqnative: Fix missing END marker in LCD enable sequence
Change-Id: I75b3a396174e84d72e70c6f177bc1702021805f1
2022-03-11 10:42:18 -05:00
Aidan MacDonald
ca12478df6 x1000: add simple binary header to declare the load address
The header format is basic, a variable length list of values
tagged by 4-byte strings. The main application to to allow a
loader to determine the load address of the binary at runtime
instead of using a hardcoded address. But the header contents
aren't fixed and it could be extended for other purposes too.

Change-Id: If51d85b4c2eb53c919a91b54985b157e8e5c20ef
2022-03-06 23:22:49 +00:00
Aidan MacDonald
d541a3a191 x1000: fix nand driver reference counting
Somehow I screwed this up as well. Seems it didn't cause trouble.

Change-Id: I5ab99dd9182a4e60d55984fecbf20ca823dbd004
2022-03-04 08:57:35 -05:00
Aidan MacDonald
3cb7167e22 x1000: fix bug in nand_read_bytes
This didn't account for partial page reads properly which resulted
in corrupted data. Fortunately, current released bootloaders do not
perform such reads so they don't trigger this bug.

Change-Id: I426a95ef8d0f20f4567498530e216d80e1aceef2
2022-03-04 08:57:35 -05:00
Aidan MacDonald
e8faf2f2ad buflib: add a common dummy callbacks struct & use it
There are various allocations that can't be moved or shrunk.
Provide a global callback struct for this use case instead of
making each caller declare its own dummy struct.

Also fixed ROLO and x1000 installer code which incorrectly
used movable allocations.

Change-Id: I00088396b9826e02e69a4a33477fe1a7816374f1
2022-02-12 10:24:32 -05:00