Commit graph

52 commits

Author SHA1 Message Date
Aidan MacDonald
ed7ab52e27 makefiles: Suppress stray backslash warnings with grep 3.8
GNU grep 3.8 warns about "\#" when compiling. The "#" has to be
escaped for Makefiles and shell, but it isn't special to grep so
grep thinks it's an invalid escape sequence.

Change-Id: Ieb2607d42b7daa1939ca0101b915ec0c7afd4298
2023-03-21 04:48:31 -04:00
James Buren
018372bf39 usb: implement macro for initializing USB strings
This uses the new unicode string literal feature that is available
now to greatly simplify the initialization of these special string
types. This makes them much more readable at a quick glance.

Change-Id: Iad8b49aa763486608e3bb7e83fb8abfb48ce0a7b
2021-03-25 13:26:03 -05:00
Solomon Peachy
ec413f7692 jz4760: Heavily rework USB driver to add working DMA support
* DMA Bulk IN (ie our TX) results in sequential transfers 33-68% faster.
 * DMA Bulk OUT (ie RX) is mostly stripped out due to complete brokenness.
 * Interrupt and control endpoints remain PIO-driven.

Other improvements:

1) Use consistent endpoint references (no magic numbers)
2) Greatly enhanced logging
3) DMA support can be compiled out completely
4) Setting lockswitch will disable all DMA operations at runtime
5) Much more robust error checking and recovery

Change-Id: I57b82e655e55ced0dfe289e379b0b61d8fe443b4
2020-09-17 11:26:04 -04:00
Marcin Bukat
734be0d6aa MIPS: fix memset()
swr/swl instructions used for word aligning were wrong. This
made memset() terribly broken. I can't imagine how it went
uncaught for soooo long. Spotted by Solomon Peachy.

I run unit tests for alignments 0,1,2,3
size 1, 2, 3, 4, 5, 63, 64, 65, 127, 128, 129;
and fill pattern 0x00 and other (since 0 is special case in this
implementation).

Change-Id: I513a10734335fe97734c10ab5a6c3e3fb3f4687a
2018-09-07 09:43:05 +02:00
Marcin Bukat
8b744571c0 ATJ hwstub: Add cache coherency
All the hard work was done by pamaury. I simply added proper
defines.

Change-Id: Ib374eea7cd20f35518ad8a68d771c57c54ae01ca
2017-09-15 21:44:59 +02:00
Amaury Pouly
9bb6050d40 hwstub: rewrite exception catching
Since we can catch exceptions like data aborts on read/write, it takes very
little to also catch exceptions in calls. When extending this with the catching
of illegal instructions, the call instruction now becomes much more robust and
also for address and instruction probing. Since we can catch several types of
exception, rename set_data_abort_jmp to set_exception_jmp. At the same time,
simplify the logic in read/write request handlers. Also fix a bug in ARM
jump code: it was using
  stmia r1, {..., pc}
as if pc would get current pc + 8 but this is actually implementation defined
on older ARMs (typically pc + 12) and deprecated on newer ARMs, so rewrite the
code avoid that. The set_exception_jmp() function now also reports the exception
type.

Change-Id: Icd0dd52d2456b361b27c4776be09c3d13528ed93
2017-01-24 15:34:19 +01:00
Amaury Pouly
f3cce72269 hwstub/jz460b: implement exception recovery
Now that we now that jz4760b implements EBASE, we can use it to rebase
exceptions to use a k1seg address, that maps to the physical address of the
TCSM0. It requires to enable HAB1 to have this translation. This most the most
inefficient way to access tighly coupled memory ever, but it works.

Change-Id: I894ca929c9835696102eb2fef44b06e6eaf96d44
2017-01-24 15:34:19 +01:00
Amaury Pouly
9851849ae6 hwstub/jz4760b: build packtools automatically if neeeded
Change-Id: I543e405bf75868d0f7509a35e08fe31ed253e0e6
2017-01-24 15:31:05 +01:00
Amaury Pouly
8934169666 hwstub: add verbose mode to make
Use make V=1 to print all commands

Change-Id: I28bd4151178413f10ddab292f1d582a9d019f5ea
2017-01-24 15:31:05 +01:00
Amaury Pouly
8fabbb008c hwstub: add support for coprocessor operations
At the moment the stub only implement them for MIPS.

Change-Id: Ica835a0e9c70fa5675c3d655eae986e812a47de8
2017-01-24 15:25:14 +01:00
Amaury Pouly
56340f4cd0 hwstub: add the possibility to flush caches before exec
This is needed on the jz4760b because if some data is loaded to DRAM, then it
is cached and a disaster lurks if dcaches/icache are not flushed. Targets that
needs this must define CONFIG_FLUSH_CACHES in target-config.h and implement
target_flush_caches(). Currently MIPS has some generic code for mips32r1 that
requires to define {D,I}CACHE_SIZE and {D,I}CACHE_LINE_SIZE in target-config.h

Change-Id: I5a3fc085de9445d8c8a2eb61ae4e2dc9bb6b4e8e
2017-01-24 15:25:14 +01:00
Amaury Pouly
cc2389b7a6 hwstub: add jz4760b stub
The stub is quite versatile: it can be loaded using bootrom or another other
means (like factory boot on Fiio X1). It relocates itself to TCSM0 and provides
basic functionality (it does not recover from failed read/writes at the moment).

Change-Id: Ib646a4b43fba9358d6f93f0f73a5c2e9bcd775a7
2017-01-24 15:22:27 +01:00
Marcin Bukat
ba9f405dc4 ATJ hwstub make irq based usb driver work
0e2b490 introduced rework of usb driver which was broken. It was reverted
in f2da975 to restore hwstub functionality on ATJ.

This commit reenables usb rework AND fixes remining issues.
The problem was with 0 length OUT thransfers. Additionally
a few cleanups were made.

Change-Id: I529ea9ad6540509e9287ca7e1cd2b44369b03cbb
2016-11-10 13:57:02 +01:00
Marcin Bukat
f2da975be6 Revert "hwstub: rework usb driver for atj213x"
This reverts commit 0e2b4908d0.

Although I swear it was tested it apparently broke hwstub on atj.
I will need to investigate more whats going on. Revert for now.

Change-Id: I2ff3adf8c72bb0e53be7d81b975382adfb700eab
2016-11-08 08:37:24 +01:00
Amaury Pouly
3d8a08ca25 hwstub: rewrite and expand library
Rewrite the hwstub library in C++, with a clean and modular design.
The library was designed from the ground up to be aware of multithreading
issues and to handle memory allocation nicely with shared pointers.

Compared to the original library, it brings the following major features:
- support for JZ boot devices, it is very easy to add support for others
- support for network transparent operations (through sockets): both tcp
  and unix domains are support

Change-Id: I75899cb9c7aa938c17ede2bb3f468e7a55d625b4
2016-04-08 19:37:30 +02:00
Marcin Bukat
906a623698 hwstub: fix warning: no newline at end of file with newer gcc
Change-Id: Icb4233fb9b2b0d5b6f8c4a35dff300f38c8d3025
2016-03-14 12:21:42 +01:00
Marcin Bukat
0e2b4908d0 hwstub: rework usb driver for atj213x
Change-Id: I7b175103e567ae4375ff94e74ed1a06215f640c3
2016-03-14 12:21:42 +01:00
Amaury Pouly
bc25437448 hwstub: make it possible to override toolchain
Default toolchain can be overriden using PREFIX, for example:
PREFIX=arm-none-eabi- make

Change-Id: I06f5ad0ad492b9f648ccba853a851918644f0500
2015-09-29 22:49:02 +02:00
Amaury Pouly
2cdfc43f10 hwstub: implement read/write data abort recovery
Change-Id: I1625873b6864584c40984723d82548ad242ee08e
2015-01-13 23:35:33 +01:00
Marcin Bukat
0cd9e4e6bc hwstub/atj213x: add clock setup to crt0.S
Change-Id: I3b6e1b8ee1fa76396f7abe7df69af26e9599cfe9
Reviewed-on: http://gerrit.rockbox.org/1055
Reviewed-by: Marcin Bukat <marcin.bukat@gmail.com>
Tested: Marcin Bukat <marcin.bukat@gmail.com>
2014-11-28 19:39:38 +01:00
Marcin Bukat
cd04a5f1aa hwstub/qeditor: add support for atomic read/writes
The current code assumed that READ/WRITE would produce atomic read/writes for
8/16/32-bit words, which in turned put assumption on the memcpy function.
Since some memcpy implementation do not always guarantee such strong assumption,
introduce two new operation READ/WRITE_ATOMIC which provide the necessary
tools to do correct read and write to register in a single memory access.

Change-Id: I37451bd5057bb0dcaf5a800d8aef8791c792a090
2014-11-18 23:30:44 +01:00
Marcin Bukat
d11704fed5 hwstub: Add atj213x support
Change-Id: Ic32200f9ab2c6977e503307a9cbe43a1328d0341
2014-11-05 08:18:59 +01:00
Marcin Bukat
b7e3515a62 hwstub: small fixup in rk27xx usb driver
Change-Id: Ibf3b91af11041834ce650f663b213bac0113f721
2014-09-11 12:31:52 +02:00
Amaury Pouly
d815c26e8f hwstub: implement jump/call in stub
Change-Id: I876fa012c5ae1509e57f5816a8ed31dc69d62ca0
2014-09-08 11:07:42 +02:00
Amaury Pouly
6d13d9b718 hwstub: fix missing \n
Change-Id: I077a38d8a8905b7ad686d0d00b2a8a48bd206ade
2014-09-07 17:45:43 +02:00
Amaury Pouly
d3df564486 hwstub: fix horrible bug
Change-Id: I8042f692045a23dbb545d840e5169ce4b99fe5d2
2014-09-07 17:45:35 +02:00
Amaury Pouly
dd05dc76a4 hwstub: don't put revision in the protocol, it's specific to the implementation
Change-Id: I1311a22da41fe977f1613f1e313a864baa03027c
2014-09-07 17:45:28 +02:00
Amaury Pouly
12ce7fc2cc hwstub: remove protocol to make it use its own interface
This way, hwstub can be implemented along with other usb features/interfaces.

Change-Id: I7148cab845049cc0a8b8e740fa0d52d3a385eaed
2014-09-07 17:45:10 +02:00
Marcin Bukat
e20256d6ae Add RKW build target in rk27xx hwstub
Change-Id: I5ad44916bc1ac5e8a9384db2369f07b137a1a715
2014-06-15 12:49:56 +02:00
Marcin Bukat
72d1d19ae7 hwstub: fix usb driver for rk27xx
Change-Id: I299e76837715c320987177eaea8459f8f199cb96
2014-06-15 12:49:56 +02:00
Amaury Pouly
238be18d03 hwstub: add proper PP support
- drop support for PP500x: it's very different from other PP and although
  it would be possible to support them, I don't have one to test the code
- make sure only the CPU is started
- add PP descriptor to report chip ID and revision
- add code in shell and lua to support pp (no register description yet)
- compile for ARMv4 because PP502x is an ARM7TDMI

Change-Id: I36c4e465dfc2cfdfe7433b2f65cc8f6f0720fe62
2014-04-12 00:11:13 +02:00
Amaury Pouly
910235b49a hwstub: fix error in config descriptor, cleanup some code
Change-Id: I853340ed2c187a044726ca03ec52aed655707e27
2014-04-12 00:11:13 +02:00
Amaury Pouly
ccfa51835e Add hwstub support for portal player (manufacturer mode)
It is very similar to how e200tool from MrH works but uses the framework
of hwstub which is makes it completely trivial since we already have the
USB driver written.

Change-Id: I61cdc245d3f828c2682bcd6ecfed5a1cc0094139
2014-04-07 22:26:50 +02:00
Amaury Pouly
81dfed27cf utils/hwstub: make stmp stub able to load in a MMU'ed environement
In might be useful to load hwstub in an environment with the MMU active,
in which case care must be taken on the order in which things are done.
Mostly, one should not disable the MMU before moving stuff around. The code
assumes the linking address (0 currently) is identity mapped.

Change-Id: I8d54ce9e8cadcde2e08990353ca7a46803731ca7
2014-02-10 23:14:25 +01:00
Amaury Pouly
c17d30f204 utils/hwstub: completely rework the protocol, drop unused features
The protocol has evolved a lot during the 2.x.y lifetime, bringing more
features which later got unused. This commit removes all the unused stuff
and simplifies everything:
- drop the feature mask: everything is mandatory or stalled on error
- remove the info request and put all static information in standard USB
  descriptors which are part of the configuration descriptor (and can be
  retrieved using the standard GetDescriptor request).
- remove the USB interface, we had only one anyway
- remove all endpoint descriptors
- remove the exit/atexit stuff, it never worked as intended anyway
- update the hwstub library and make it able to handle any device
- update the tools (mostly renaming and removing of code)

Change-Id: I1872bba7f4177fc3891180e8f944aab88f5bde31
2014-02-10 23:14:24 +01:00
Amaury Pouly
8666871cb3 hwstub/stmp: disable watchdog
Some targets like Sony NWZ use a watchdog, so we must disable it to prevent
spurious reboot when we take over

Change-Id: I138a8d7f9a1b089acb2d08d7f6c4a58e8b088b3a
2013-12-13 00:20:18 +01:00
Amaury Pouly
3bbe52bb85 hwstub/stmp: cleanup
Conditional no longer needed since ctr0.S is private to target, also setup
stack just before jumping to C code only

Change-Id: I74116239be9e87bbe53e8fa814c45f04f242f1c1
2013-12-13 00:20:18 +01:00
Marcin Bukat
3440f3518e hwstub: Prepare for multi arch support
Change-Id: Id38411ff95660e60ee23f99350b275b92b3e4578
Reviewed-on: http://gerrit.rockbox.org/690
Reviewed-by: Amaury Pouly <amaury.pouly@gmail.com>
2013-12-06 11:46:01 +01:00
Amaury Pouly
f365a5123f hwstub: forgot the db command file for stmp
Change-Id: I08ca6be221d3633c5b6e5e4b023afca33713e428
2013-12-06 11:37:10 +01:00
Marcin Bukat
8e63338591 hwstub rk27xx port
Change-Id: I85ac57117911544b65ccd56eb16303e30be67cab
2013-11-24 00:10:36 +01:00
Amaury Pouly
287be81c16 hwstub: use a more reasonable hclk frequency
The old code would set CPU to 64MHz and HCLK to 9MHz but that's too low for
many things like usb and gpmi. So change HCLK to ~32MHZ.

Change-Id: I6459f25900e42603333cebccb7b0ed26c59640ad
2013-11-18 21:44:06 +00:00
Amaury Pouly
27111d83be hwstub: fix stmp3600
The microseconds register has a different address

Change-Id: I29d2e7feea9eb34b0d539ee217babd092542b612
2013-10-26 17:34:58 +02:00
Amaury Pouly
1085d15a3e hwstub: produce sb1 image too (for STMP3600)
Change-Id: Ib7f38fba1e524ed7438cdc395441d801c5eabcaa
2013-10-26 17:34:35 +02:00
Amaury Pouly
bfb67f41a9 hwstub: don't touch mmu registers on non-STMP targets, they might not exist
Change-Id: Ib18475fd90e0d29ab6d7214116f7a0041584d621
2013-10-22 00:34:44 +02:00
Amaury Pouly
1c63993e05 imxtools/sbtools: always probe report size for HID recovery mode
Some older versions of the ROM (TA3 for example), use a 64 byte report size
instead of 1024, so hardcoding 1024 is just a bad idea.

Change-Id: I720c4465cfe2f519bffa307175614bba58766dce
2013-10-09 13:05:43 +02:00
Amaury Pouly
3b6d2ac28a hwstub: add delay functions, and plain binary/sb file generation
Change-Id: Idbedb9277b355edcd93975ec5a268428c7b89633
2013-09-10 23:19:34 +02:00
Amaury Pouly
4aae8274b3 hwstub: fix power off and reboot code on stmp
Change-Id: Ia717c5e6f78a2cecc6a0628e4c667ea39f32c44c
2013-08-11 19:17:57 +02:00
Amaury Pouly
0ec1536d64 hwstub: allow the stub to relocate itself
Change-Id: Iab60c6ec0e8eda19c76c84241f8367d53cb4f87b
2013-08-11 19:17:36 +02:00
Amaury Pouly
3c5ee9ac57 hwstub: forgot file
Change-Id: Ib79f4ef89c734d7ba2fcbf648aadc346576e1c17
2013-07-16 22:23:14 +02:00
Amaury Pouly
e5de5e09c1 hwstub: enhance exit protocol and implement on stmp
Rename STOP command to EXIT, introduce ATEXIT, this gives better
control over the exit of the stub. Add stmp implementation.

Change-Id: I45442c8b88b9330d12ef439417ca5ffa1520477a
2013-07-16 19:29:42 +02:00