Commit graph

1052 commits

Author SHA1 Message Date
Amaury Pouly
cb8a98e365 imxtools: correctly read unencrypted images in raw mode
Change-Id: I87830b81a017f36d2887d9c289d09812f227b157
2017-01-16 19:51:12 +01:00
Amaury Pouly
a5950c69af imxtools: rework key/IV overriding logic
The overriding of the IV and real key should be the exception, there is no
need to manually set them to false.

Change-Id: Id66754f20a79aa5c1a991839345d1242e0aa587d
2017-01-16 19:50:25 +01:00
Amaury Pouly
2df6b1fc43 imxtools: rework sb file production
The old code had some annoying way of dealing with padding by adding explicit
instructions to the stream, which is 1) ugly 2) not in par with freescale
tools. The trick, which this new version implements, is to put the useful length
of the section in the section header, and the actual (with padding) length in
the boot tag. This way the tools can just ignore padding instruction by
reading the section header, and the bootloader can still load the image because
it uses the boot tags.
Also correctly handle the case where the first section does not start right
after the header (there is a bug in freescale tools for this case by the way).
There is an ambiguity in the way the padding instructions should be encrypted:
the bootloader should logically treat them as regular instruction of the section
stream, but it appears the freescale tools do not generate them as part of the
stream and instead encrypt them like boot tags, which is stupid because there
is no way the bootloader could decrypt them, and anyway we don't care because
the bootloader doesn't decrypt them at all.

Change-Id: Iabdc1d1f9f82d374779bf03efb75c2c3998f5b5d
2017-01-16 19:49:07 +01:00
Amaury Pouly
0cabc1fc51 nwztools/upgtools: add real KAS for NW-ZX100 and fix typo
Change-Id: I4e4679d6e92c1c0fc8a03db5201aee39d82b24b2
2017-01-14 12:02:34 +01:00
Amaury Pouly
1d7f6048f4 nwztools: add a "reset all settings" message in dest_tool
Users can't read the wiki instructions, hopefully they can read this...

Change-Id: I3840879fdc663fb6e7f9234f352eea04a556256a
2017-01-09 22:15:53 +01:00
Amaury Pouly
90284b6fe0 nwztools: fix typo (nwz-zx100 -> nw-zx100)
Also now gen_db.py can check for such mismatch

Change-Id: I4d91aae0dde08c866eda2ed5da3c11431c46e06a
2017-01-09 21:48:43 +01:00
Amaury Pouly
1d7b37eda1 nwztools: add various info about S740, S750, S640, E050
Change-Id: I2cc887ce2824a2d0b9aeb2a89df662c621c28750
2017-01-08 22:34:57 +01:00
Amaury Pouly
a38e9bac26 nwztools: forgot file
Change-Id: I4341f2af71675cb795987ecc5ce12104445a9d97
2017-01-08 22:33:00 +01:00
Amaury Pouly
18b4bf299f nwztools/upgtools: add real NW-A20 kas
Change-Id: I88fb2aefafbc7820a49847fbf0888de9cf81bd3f
2017-01-08 16:08:43 +01:00
Amaury Pouly
9b2fab1ca9 Makefile cleanups
Change-Id: I69b8b81d357553c979682d42097eba864c951512
2017-01-08 16:08:28 +01:00
Amaury Pouly
1895af8e15 nwztools/scitool: rework node size, remove relaxed mode
The cool now takes the database as a hint and will not complain if the device
returns less data. The tool also supports user provided size and raw node numbers
that are not in the database (advanced usage).

Change-Id: I8cec536718d7eff01c7803bea648d6122b82377a
2017-01-08 16:07:18 +01:00
Amaury Pouly
26774ece35 nwztools: add NW-WM1 kas
Like the NW-A30, we don't know how to use it, but record it anyway.

Change-Id: Iebd26637253613625a4885afe88695ad3ffb0605
2017-01-08 12:31:47 +01:00
Amaury Pouly
80d91e0cf5 nwztools: add A35 model and KAS
We don't know the encryption method, the KAS is completely different but it
might be useful to record it anyway for future purposes. MID extracted from
device, Japanese NW-A35.

Change-Id: I4c4bb5b063da99003b5c316061d8c490b77428a4
2017-01-08 12:30:46 +01:00
Amaury Pouly
096ae78c20 nwztool/upgtools: replace NWZ-A10 kas by the real one
Extracted from a target.

Change-Id: Ieb4aff15f332a681142a7079c1adf3b1da31de24
2017-01-08 12:09:54 +01:00
Amaury Pouly
1bd8207e30 nwztools: rename nwz-a20 to nw-a20, that was a typo
Change-Id: I88ae7391732c6f41c3c4adccce2ddf0a92142067
2017-01-08 12:09:49 +01:00
Amaury Pouly
5a0a7b8b58 nwztools: remove NW-ZX2
It is Android based and despite the fact that Sony wrote an NVP driver for it,
experiments suggest it is unused because it returns ff all the time...

Change-Id: I37750b659e341b21bed5ebaccf60f9f5fe569f64
2017-01-07 22:22:59 +01:00
Amaury Pouly
be68b6a7bd nwztools: add NW-WM1A/Z model IDs
Also fix code that was supposed to sort things deterministically and was a
massive failure.

Change-Id: Iedf25f05a94ef51421710a283eb60f33ee977de1
2017-01-07 17:32:47 +01:00
Amaury Pouly
76c73c707a nwztools/scsitools: use new SCSI library
Change-Id: I1b5688ba7ad99c7a22ba4532c8237b4563e4a9e4
2017-01-07 16:31:28 +01:00
Amaury Pouly
86e745a25e nwztools/scsitool: add relaxed mode for nvp
Change-Id: I0a139eb236f825368ae627fdbb2f75286f747f10
2017-01-07 15:53:03 +01:00
Amaury Pouly
456a3fc952 imxtools: various fixes for Windows
Don't use colors since the terminal doesn't support it. Also packing is broken
on MinGW so use #pragma pack when compiling for windows, this is also supported
by MSCV.

Change-Id: I635649d52ed5f2e0af46cb9ca2ec325955b2ddb2
2017-01-07 15:52:33 +01:00
Amaury Pouly
950f4bdc02 imxtools: move firmware read/write to library
Split the ugly firmware read/write into a API function and a much simplified code.
Also the code can now report progress.

Change-Id: I3f998eaf0c067c6da42b1d2dd9c5a5bf43c6915d
2017-01-07 15:52:33 +01:00
Amaury Pouly
0778184782 imxtools/scsitools: move stmp scsi api to its own file
No code modification code, just moving code around.

Change-Id: I30744d3994aa7540f4b5b158f31b51959d5d8586
2017-01-07 15:52:33 +01:00
Amaury Pouly
7fafbe1fc1 imxtools/scsitools: rework stmp scsi API
Sanitize the whole library by hiding most of the horrible details of the
implementation. This means that all logical/drive/table attributes are exported
in structures that are internally filled by higher-level API functions. This makes
the code much more readable and prepares for a split between scsitool and the stmp
scsi library.

Change-Id: Id85d450b25cf99cd7c0896c6fc35bcd00babe9e1
2017-01-07 15:52:33 +01:00
Amaury Pouly
0fd869423a imxtools/scsitools: use new SCSI library
The function names and prototypes are also normalized so make subsequent reworks
easier.

Change-Id: Ifa5d64aa144b11f8c087517ddc904744e3037361
2017-01-07 15:52:33 +01:00
Amaury Pouly
ae84354b40 Add multiplatform library for raw SCSI commands
Several tools need to perform raw SCSI commands, and we need to support Linux,
Windows and Mac OS, without pulling tons of dependencies to build it easily.
This very simple library has no dependency and supports Linux.

TODO:
- windows
- mac os

Change-Id: I496f5ad2490bd3e96ad962d31cce4e511a523c3a
2017-01-07 15:52:33 +01:00
Amaury Pouly
ad2297d353 nwztools/scsitool: add option to force/specify series
We cannot auto-detect a device if we don't know its model ID, but we can't know
the model ID if we haven't decrypted the upgrade which requires the key. The only
way to solve this chicken-and-egg problem is to get the NVP table from kernel,
create an empty series in the database (no model ID), then get the key using
scsitool and forcing the model (using this commit), then decrypt the upgrade
and get the model ID list.

Change-Id: I8eced486a5f6a1a99028b25fdc4f87a3b11e31a8
2017-01-04 17:14:31 +01:00
Amaury Pouly
dbeb6db1b5 nwztools: cleanup crypto, switch MD5 to Crypto++
We already use Crypto++ for DES anyway, and using OpenSSL is not great because
of its incompatible licence.

Change-Id: I78771b84c1708795a0c0c30afa5bdfe4885dea4e
2017-01-04 17:05:15 +01:00
Amaury Pouly
92ecbd5fb8 nwztools/upg: move upg handling to its own file, completely rework kas handling
This was a huge mess, the new is much cleaner hopefully.

Change-Id: I43663d021dc8bc31662d3923e1c3da22d987ebf9
2017-01-04 17:04:38 +01:00
Amaury Pouly
5cfd4a5b8e nwztools/upgtools: add more brute force algorithms
Allow to search for hex with upper case and alphanumeric. This is *much* slower
of course.

Change-Id: I41a2fc63c4b2220c21147b711098ebc37ddb3527
2017-01-04 17:04:19 +01:00
Amaury Pouly
bfd5704749 nwztools: add NW-WM1 nvp table, regenerate database
Change-Id: If5781f0a98b3f2fee08a2daed383064cc59f1680
2017-01-04 17:03:54 +01:00
Amaury Pouly
3c3e133f99 nwztools: small fixes
Make sure scripts use bash, make nwz database generator more deterministic

Change-Id: I26812b697abe0406fb3c60d6eb231cb27edc81d5
2017-01-04 17:03:14 +01:00
Amaury Pouly
985f6e6935 imxtools: fix bug aes128 (did not update cbc-macp)
Although this does bug is never triggered because we never decrypt and use the
resulting CBC-MAC, it's a major overlook.

Change-Id: I3c5d318e6428d528483bf888ea284e9ded3889f0
2017-01-01 19:52:00 +01:00
Amaury Pouly
5c50efc9ce hwstub/tools: always run make for the libraries
This ensures that the libs are always up-to-date hopefully.

Change-Id: I790302fcabc91457091006de749b76735fdd510f
2016-12-12 11:53:41 +01:00
Amaury Pouly
8e82839fe2 hwstub: various cleanups
- hwstub load now properly stops reading the log when the device returns a 0
  size buffer instead of STALLing
- add debug output option to hwstub_load
- correctly report transfered size on write error
- add some debug error message in usb code so that some errors can be diagnosed
  more easily
- add a batch mode to hwstub_shell to disable the interactive shell
- increase usb control timeout to 1sec, 100ms was really tight
- cap usb buffer size to ~4000 bytes because libusb has a hardwired limit of
  4096 bytes for control transfers

Change-Id: Id3200ab99ce70a7a3b09ce7faeaafa4a0fac64c7
2016-12-12 11:35:16 +01:00
Amaury Pouly
a88f57ec36 nwztools/scripts: mount storage with ext3 instead of ext2
Since ext3 supports ext2, we can support more platforms. Some platforms use ext4
with a very specific set of options, we I haven't encountered those yet so it's
not currently a problem.

Change-Id: Iff87e925a4caa866c6a66b1883ad6baab88c0b8d
2016-11-20 21:36:54 +01:00
Amaury Pouly
ce966d3d28 hwstub/tools: fix compilation of shell against lua5.3
The unsigned function were deprecated and hidden begind a compat flag. Since
they will get removed in the next version, I simply reimplemented them, those
are mostly casts anyway.

Change-Id: Ie5db81d7c8589b1e5e9b45a2a4ed41919aa07387
2016-11-20 21:36:54 +01:00
Amaury Pouly
06502772a8 nwztools/plattools: improve makefile to build images automatically
Change-Id: Ibf17fe523c6ef534368d6f94f43fce5ac0c91caf
2016-11-20 21:36:54 +01:00
Marcin Bukat
deaeb73912 Add KAS for NWZ-E470
Change-Id: I1b8272a486ba2377e5047855acda3f80aa92c232
2016-11-14 20:54:05 +01:00
Amaury Pouly
0c1a96101c nwztools: rework dualboot
The new code gets closer to an actual bootloader:
- it provides a menu with three options: Sony, Rockox, tools with icons (and
  extracts the Sony logo from the NVP)
- the dualboot install script now creates a symlink from /.rockbox to
  /contents/.rockox which is necessary to run rockbox
- more text drawing / framebuffer functions
In the long run, we will move this under bootloader/ and rbutil/ and also use
firmware/ drawing facilities, at the moment we use OF display program which
is slow and creates some flickering.
The logo extraction/placement code was tested with resolution 240x320 and I
guessed some reasonable values for 240x400, but those will probably need some
tweaking.

Change-Id: I0319be902d21a7d33c1dee0fffdb4797065dbf8a
2016-11-12 22:16:48 +01:00
Amaury Pouly
33856d9ceb nwztool/scsitools: cleanup and add destination changer tool
Now that we have a nice database of player index, the scsitool becomes more
useful and supports a lot more players. I did some general cleanup of the code,
though eventually it would be nice to really split it into a library and a CLI.
The SCSI vendor command allow to read but also write most NVP nodes. Since there
seems to a demand to change destination and sound pressure settings on device,
I implement this feature in the tool. I do not plan to allow arbitrary NVP
writes because this could easily brick the device. Changing the destination
should be safe, but as usual, use at your own risks.

Change-Id: Iff4e8cc3ac97b965c1df849051c5fd373756cda5
2016-11-11 16:07:14 +01:00
Amaury Pouly
c95e30b75d nwztools/plattools: use player database and rework stuff
Using the database, we can now safely read/write the NVP. I also add more
support for Sony's "display" tool.

Change-Id: I8439fe9bad391c7f29859d99f236781be7983625
2016-11-11 16:07:14 +01:00
Amaury Pouly
44bb2856a5 nwztools/database: add database of information on Sony NWZ linux players
There must be an evil genius in Sony's Walkman division. Someone who made sure
that each model is close enough to the previous one so that little code is needed
but different enough so that an educated guess is not enough.

Each linux-based Sony player has a model ID (mid) which is a 32-bit integer.
I was able to extract a list of all model IDs and the correspoding name of
the player (see README). This gives us 1) a nice list of all players (because
NWZ-A729 vs NWZ-A729B, really Sony?) 2) an easy way to find the name of player
programatically. It seems that the lower 8-bit of the model ID gives the storage
size but don't bet your life on it. The remaining bytes seem to follow some kind
of pattern but there are exceptions.

From this list, I was able to build a list of all Sony's series (up to quite
recent one). The only safe way to build that is by hand, with a list of series,
each series having a list of model IDs. The notion of series is very important
because all models in a series share the same firmware.

A very important concept on Sony's players is the NVP, an area of the flash
that stores data associated with keys. The README contains more information but
basically this is where is record the model ID, the destination, the boot flags,
the firmware upgrade flags, the boot image, the DRM keys, and a lot of other stuff.
Of course Sony decided to slightly tweak the index of the keys regularly over time
which means that each series has a potentially different map, and we need this map
to talk to the NVP driver. Fortunately, Sony distributes the kernel for all its
players and they contain a kernel header with this information. I wrote a script
to unpack kernel sources and parse this header, producing a bunch of nw-*.txt
files, included in this commit. This map is very specific though: it maps Sony's
3-letter names (bti) to indexes (1). This is not very useful without the
decription (bti = boot image) and its size (262144). This information is harder
to come by, and is only stored in one place: if icx_nvp_emmc.ko drivers, found
on the device. Fortunately, Sony distributes a number of firmware upgrade, that
contain the rootfs, than once extracted contain this driver. The driver is a
standard ELF files with symbols. I wrote a parsing tool (nvptool) that is able
to extract this information from the drivers. Using that, I produced a bunch
of nodes-nw*.txt files. A reasonable assumption is that nodes meaning and
size do not change over time (bti is always the boot image and is always
262144 bytes), so by merging a few of those file, we can get a complete picture
(note that some nodes that existed in older player do not exists anymore so
we really need to merge several ones from different generations).

The advantage of storing all this information in plain text files, is that it
now makes it easy to parse it and produce whatever format we want to use it.
I wrote a python script that parses all this mess and produces a C file and
header with all this information (nwz_db.{c,h}).

Change-Id: Id790581ddd527d64418fe9e4e4df8e0546117b80
2016-11-11 16:07:14 +01:00
Amaury Pouly
19de536ce2 nwztools/upgtools: cleanup
There is no need to store the key and sig since those are derived from the KAS
anyway.

Change-Id: I228913b1cb32e496db265e9a7aaf3bb4200a9f6b
2016-11-11 16:07:14 +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
3b7e7cb535 hwstub_shell: fix a horrible bug
Change-Id: I4ac259e6cd7b707ca725c6ba1c526f5aeed56b71
2016-11-06 21:59:50 +01:00
Amaury Pouly
25bd580509 forgot file
Change-Id: I32e23035a608ee04a69690975ab4bf629a902388
2016-11-06 00:15:08 +01:00
Amaury Pouly
5017babb30 nwztools/plattools: fix black screen issue in dualboot, rework dualboot
Sony added extensions to the frambuffer interface. It is important to take them
into account since the OF uses them and might leave the framebuffer in an
unusual state which would make the dualboot not display anything. Also rework
the dualboot code so that it can boot rockbox (not doing anything at the moment),
display all tools or boot the OF.

Change-Id: Ia0f589c9ec8558f375270841503c0964aff07f0b
2016-11-06 00:12:04 +01:00
Amaury Pouly
d492f25c54 nwztools: add preliminary dualboot and dualboot install script
At the moment, the script install_duaboot does the following:
- rename SpiderApp to SpiderApp.of (unless it already exists)
- install payload as SpiderApp
- fixes permissions
Since SpiderApp is the main app, it will execute instead of the OF.
The current dualboot code (dualboot.c) is still a preliminary but the current
version displays an "all tools" menu to choose for. When exitting the menu
using BACK, it will run the OF.

With the modifications made by the install script, it should not be possible
to break the device. In the worst case scenario, the dualboot code crashes
and it restarted by the sysmgrd, or hangs. A safe way to recover is to plug
the USB cable and reset the device: the system manager will then start the
USB app and one can reflash the device if necessary.

Change-Id: Id9edab0347538ad2a8651a28aea7fd083feaa626
2016-11-01 17:09:07 +01:00
Amaury Pouly
b045e4da34 nwztools/upgtools: sanitize series name and add keys
Unify series names: e46x -> e460 to be consistent with Sony' name. Add keys
for various players that were cracked using upgtools. The real KAS would need
to be extracted from a target but at least we can open/create firmware upgrades.

Change-Id: Id23a10e10170d7f6330c6699bf205c4df5ddebfe
2016-10-31 17:51:18 +01:00
Amaury Pouly
0a2290653b nwztools/plattools: rework/clean and add an all-in-one tool
This new tool (all_tools) embeds all the other tools and provides a menu to
choose which one to run.

Change-Id: I0e07864dd46559a7079b0f942c25155e6fa07112
2016-10-31 17:50:16 +01:00
Amaury Pouly
ad9a2d5241 nwztools/plattools: add a tool to change destination and sound pressure
Since the nwz_lib does not have any nvp code yet, it's quite of ugly hack
with hardcoded nvp node (11) for shipment information (shp). Thus I whitelisted
two series (NWZ-E460 and NWZ-A860) which I know for sure use this node ID.

Change-Id: I94c9b0db1f9d7ad764d2aa50576a911e710f25e1
2016-10-28 23:28:25 +02:00
Amaury Pouly
3097239ce6 nwztools/plattools: add device list
This list can map from model id to device name. It was automatically extracted
from Sony's tools. In the future, we will probably generate it from a clean
database containing more useful information.

Change-Id: Ibe580edf25b60bf0bf4aef4a06f40dddd19c5404
2016-10-28 23:27:29 +02:00
Amaury Pouly
281c8d4700 nwztools/scripts: export model id in an environment variable
This is useful because there is no easy way to get it except from Sony's tool,
unless one knows the npv node, but that requires to know the model already...

Change-Id: I202f7cdb2f7cf924cc5bdb53c17e34600d4bf153
2016-10-28 23:25:43 +02:00
Amaury Pouly
37f95f67fe nwztools/upgtools: rewrite keysig brute force search
The new search has two new features:
- it takes advantage of the fact that DES keys are only 56-bit long (and not 64)
- it is now multithreaded
As a proof of concept, I ran it on the A10 series firmware upgrade and was able
to find the key in a few seconds using 4 threads. The search is still limited
to ascii hex passwords (seems to work on all devices I have tried thus far).

Change-Id: Ied080286d2bbdc493a6ceaecaaadba802b429666
2016-10-27 23:06:16 +02:00
Amaury Pouly
794104dd17 nwztools/plattools: switch to BACK key to quit
The power off/option does not exist on some models.

Change-Id: Ifb45293b3b3faa96d9fece2340cbd98299a4a0b7
2016-10-26 20:46:57 +02:00
Amaury Pouly
d42b43c786 nwztools/plattools: add test_power, rework input, add test_ts (touchscreen)
Change-Id: I55ca29627801b5e760d1dbe407d96cd055f659ab
2016-10-26 20:46:57 +02:00
Amaury Pouly
fed083cf06 hwstub: fix compile and linking ordering
Change-Id: I0acd3db2f644f4521da715d4931315bdb7548eae
2016-10-22 15:55:33 +02:00
Amaury Pouly
0b01ca69e0 nwztools/plattools: add adc test
Change-Id: Ic3ef964e8b5cc7b8ca3f02f141e9e4436a4d41db
2016-10-19 18:20:27 +02:00
Amaury Pouly
8d24b62912 nwztools/plattools: add backlight test
Change-Id: I4bef0824eeed54238578d8b24a9845e8602d61af
2016-10-19 17:58:40 +02:00
Amaury Pouly
ba91ff10e8 nwztools: add a new plattools directory with code to run on the device
This is code is intended to development into a library of code for the NWZ that
will be useful to write the "bootloader" on those device. At the same time, it
comes with test programs that are easy to run in firmware upgrade mode and also
provide a great test bench for the library. At the moment, two test programs are
available:
- test_display: simply prints two messages using /usr/bin/lcdmsg
- test_keys: displays input key event

Change-Id: I9d214894ffc9127b528fcdd3eb5d6b61f4e657a7
2016-10-19 17:09:04 +02:00
Amaury Pouly
13d892eef1 nwztools: update makefile and add script
The new script allows the upgrade to execute a file found on the user partition.

Change-Id: I564941d01bcdbae050002e77cb119f3d95ecdc21
2016-10-19 17:09:04 +02:00
Amaury Pouly
eaa1cb3469 fix typo
Change-Id: Ia69e5ff941549ca98b23b40927137bb29876b8f9
2016-10-19 17:09:04 +02:00
Amaury Pouly
21fb5aff39 nwztools: rework upg scripts
The exec_file allows to embed a script/executable and run it on target. It takes
of unpacking, remounting contents rw and redirect output to exec.txt at the root
of the drive. More generally, rework how the makefile works.

Change-Id: Iec719227be96e80701ad8f5398d2d34389f4da9e
2016-10-19 17:09:04 +02:00
Amaury Pouly
6f7ee0bb7c regtools: fix library bug when checking if a reference is valid or not
Change-Id: I8adea40d2fa7c1a26f1975d987233249f61af8ef
2016-09-21 00:31:18 +01:00
Amaury Pouly
7b1bcae879 regtools: rename error_t to err_t to avoid name clash
Change-Id: Ib8d34e4f58f3225b1dafc533ce7e1b7867ad053b
2016-09-21 00:31:12 +01:00
Amaury Pouly
84ff8a4df9 headergen_v1: remove warnings with newer GCCs
Change-Id: I90ed3a0c911014eee013cbea0e98a85f4310471d
2016-09-21 00:31:07 +01:00
Amaury Pouly
cf82f208e3 nwztools: cleanup the code
There was a lot of copy and paste, and the code was just crap. This commit tries
to clarify the code and also document the encryption procedure. Hopefully I didn't
break anything.

Change-Id: I257793010e7cf94f2b090b30bb8608359d3886e3
2016-08-30 17:21:05 +10:00
Amaury Pouly
de8950d63d upgtools: add NWZ-E45x Series key and signature
Also fix a typo in the script makefile

Change-Id: Ie747d8b99ca0f6a98bbcaf1c82e66c7788f00e6e
2016-08-30 17:21:05 +10:00
Amaury Pouly
71a369b37a upgtools: small cleanups
KAS was in its own structure for historical reasons, but it's stupid now.

Change-Id: Ie8d69ac6d489337cd857ace1abe5b1e4b1177172
2016-08-30 17:21:05 +10:00
Amaury Pouly
9d121cfd51 nwztools: upgrade upgtools and add dumping script
Change-Id: I315d1010ce5477c0112f4a890156b360e8123e11
2016-08-17 21:26:31 +01:00
Amaury Pouly
e62203aac1 regtools: add headergen_v2
This new header generator works differently from the previous one:
- it uses the new format
- the generated macro follow a different style (see below)
- the generated macro are highly documented!
- it supports SCT-style platform or RMW-style ones

Compared to the old style, the new one generate a big set of macros per
register/field/enum (loosely related to iohw.h from Embedded C spec). The user
then calls generic (names are customizable) macros to perform operations:

reg_read(REG_A)
reg_read(REG_B(3))
reg_read_field(REG_A, FIELD_X)
reg_read_field(REG_B(3), COOL_FIELD)
reg_write(REG_A, 0x42)
reg_write_field(REG_A, FIELD_X(1), FIELD_Y(3), IRQ_V(FIQ))
reg_write_fielc(REG_B(3), COOL_FIELD_V(I_AM_COOL), BLA(42))

the following use RMW or SET/CLR variants, depending on target:
reg_set_field(REG_A, FLAG_U, FLAG_V)
reg_clr_field(REG_A, FIELD_X, FIELD_Y, IRQ)
reg_clr_field(REG_B(3), COOL_FIELD, BLA)

the following does clear followed by set, on SET/CLR targets:
reg_cs(REG_A, 0xff, 0x42)
reg_cs(REG_B(3), 0xaa, 0x55)
reg_cs_field(REG_A, FIELD_X(1), FIELD_Y(3), IRQ_V(FIQ))
reg_cs_field(REG_B(3), COOL_FIELD_V(I_AM_COOL))

The generator code is pretty long but has lots of documentation and lots of
macro names can be customized.

Change-Id: I5d6c5ec2406e58b5da11a5240c3a409a5bb5239a
2016-05-25 00:11:07 +01:00
Amaury Pouly
c90d42dcc6 jz4670_tools: add usbboot tool, tweak Makefile and packtool
Although the jz4740 contains a similar tool to usbboot, its command-line
interface is not very useful, also it does not compile by default because it
relies on some external code, and it contains code specific to some JZ4740
devices.

Change-Id: I22688238d147e21fb0fd524466b333b6003d4ff1
2016-04-08 18:54:46 +01:00
Amaury Pouly
4934bd6f24 hwstub: remove the old library
Change-Id: I94d0f67cfd0d636407cd9cf3afbe0db4064de28e
2016-04-08 18:52:36 +01:00
Amaury Pouly
5ac0166388 qeditor: port to the new hwstub library and add features
This commit adds support for the version of the hwstub library, which requires
a lot of changes. It also adds some editing features, such as register access
and much better editing of fields using the mouse (double click on a field
to be able to resize and move it).

Change-Id: I3c4e4cc855cb44911c72bc8127bad841b68efe52
2016-04-08 18:46:46 +01:00
Amaury Pouly
cc4c9b70bc regtools: add register access to soc desc
Registers (and variants) can now specify the type of access supported:
- unspecified: for variant means same as register, for register defaults R/W
- read/write
- read only
- write only
Backward compatibility is preserved by setting access to unspecified by default.

Change-Id: I3e84ae18f962a45db62f996a542d08405d05b895
2016-04-08 19:38:36 +02:00
Amaury Pouly
f6c61eb11a hwstub: port hwstub_shell to the new library
Also use this opportunity to cleanup support for multiple devices: the shell
now supports dynamic changes in the device and will call init() everytime
a new device is selected, to prepare a new environment. The shell now
honors register width on register read/write. The shell also provides access
to variants as follows by creating a subtable under the register using the
variant type in UPPER case and having the same layout as a register.
For example if register HW.GPIO.DIR has variants "set" and "clr", those can
be used like this:
HW.GPIO.DIR.SET.write(0xff)
HW.GPIO.DIR.CLR.write(0xff00)

Change-Id: I943947fa98bce875de0cba4338e8b7196a4c1165
2016-04-08 19:38:18 +02:00
Amaury Pouly
a2f4c5201d hwstub: port hwstub_load to the new library
Change-Id: I7e8ae50907401a9480a0da809a4470f1728d3a57
2016-04-08 19:37:59 +02: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
Amaury Pouly
56dc54d38a soc_desc: add default constructors to most structures
After being caught by several bugs of the type "let's forgot to initialize
a field to default value", I'm finally fixing this.

Change-Id: I01c33e0611d4f697f767db66465e4fb30858cdab
2016-04-08 18:06:27 +02:00
Marcin Bukat
bb48fa02d2 regtools: Convert rk27xx register description file to v2 format
Change-Id: I60a764567d2fc73ed87fca2a8b0eaf643d4984bc
2016-03-14 13:51:33 +01: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
7619031307 regtools: make description file parser stricter
The parser would simply ignore unknown elements or attributes, which is bad
on many levels. Now any unknown tag will trigger a fatal error.

Change-Id: I32eead8e96c1567241cf2a565d9e20e62877c14d
2016-02-07 15:46:06 +00:00
Amaury Pouly
7d87ebb470 regtools/desc: convert v1 stmp description files to v2
Conversion done using swiss_knife as follows:
./swiss_knife convert --author "Amaury Pouly" --version "2.4.0" desc/regs-stmp3XXX-v1.xml desc/regs-stmp3XXX.xml

Change-Id: Iad26e04f8f599cf25339a33aa65f231379434e98
2016-02-06 15:32:53 +00:00
Amaury Pouly
6e54f72590 regtools/desc: rename v1 stmp files
Change-Id: Ib66a404acf1f640e19b30b35d6a976094ae4264a
2016-02-06 15:29:38 +00:00
Amaury Pouly
6b9610fb90 regtoosl/qeditor: port to the new description format
This big commit port qeditor from v1 to v2 register file format. Although
the display code was much simplified, the edit code had to be rewritten.
The new code also brings many improvement to the register display widget.

The new code also compiles with both Qt4 and Qt5, although it is recommended
to use Qt5 to get some improvements, especially in the layout of editor.

Change-Id: I24633ac37a144f25d9e705b565654269ec9cfbd3
2016-02-06 15:20:48 +00:00
Amaury Pouly
0f701a64be regtools: update v2 specification, library and tools
A v2 register description file can now include register variants and instances
addresses can now be a list (previously it could only be a stride or a formula).
Update the library to deal with that. The convert option of swiss_knife was
updated and one incompatible change was introduce: if a v1 device has several
addresses, those are converted to a single v2 instance with list (instead of
several single instances). This should have been the behaviour from the start.
Swiss_knife can now also convert regdumps, in which case it needs to be given
both the dump and register description file. Also introduce two register
descriptions files (vsoc1000 and vsoc2000) which give more complicated examples
of v2 register description files.

Change-Id: Id9415b8363269ffaf9216abfc6dd1bd1adbfcf8d
2016-02-06 15:12:55 +00:00
Cástor Muñoz
2ae94318c6 update deploy.py to recognize and use Qt5
Change-Id: Ied8c9d153a34bd8b689a34e45708262cede5348d
2016-01-17 18:38:28 +01:00
Marcin Bukat
ad5e5c42fb hwstub: fix atj213x dsp lua code
Change-Id: I5fbd1799b958bedbe74f91bdcdd8a544e15d2a78
2015-11-17 22:40:31 +01:00
Marcin Bukat
f47f04b65f hwstub: Add ajt213x lua interface for DSP block
With this you can upload and run code on DSP core in atj213x.

The files can be produced using as2181. You can download
this assembler from https://github.com/wodz/as2181
You should use extended mode (-x switch) since DSP core
in atj is non standard and uses 24bit operands.
PX register has different meaning as well and is used as MSB
when loading other registers with immediates (immediate field
is 16bit in instruction so to set register to 24bit value
you need to store MSB in PX prior to this).

MAC MR is 56bit accordingly.

HIP interface seems to be mapped at standard addresses
(except that regular 218x doesn't have HIP).

Have a fun!

Change-Id: I9a80ca0dd3718ba8435ae8579bfffa66e067e022
2015-11-17 13:35:09 +01:00
Amaury Pouly
3fdb86ea41 qeditor: fix uninitialised variable
Change-Id: I12a785e554b7d598b91e526af1b7ebc1fc44f610
2015-10-03 23:09:35 +02: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
1cada1f833 soc_desc: new version of the desc file format
Fix qeditor to use the old soc_desc_v1.
Port hwstub_shell to the new description format.

Change-Id: I9fefbff534bfaa5c3603bb3dd8307a2b76e88cfc
2015-09-11 16:40:19 +02:00
Amaury Pouly
c8d3638b9e qeditor: introduce new "sexy register display"
Change-Id: Ib938b4be71d2c7623851dbc3c211f96105077d7d
2015-09-11 16:02:34 +02:00
Amaury Pouly
2c832968c9 qeditor: use delegate to show bit range information
Change-Id: I314365c3a2cb9d230c412f24d2a8034a12c43444
2015-09-10 15:20:38 +02:00
Cástor Muñoz
ab3581c7ef utils/parse_testcodec.rb: add support for Opus files
Change-Id: I19e59cfe86598c2e5a7b070ef72b5a12e88b7242
2015-07-17 00:51:22 +02:00
Marcin Bukat
e70ea5d21f hwstub: Add completion and some pretty printing to the shell
This uses slightly hacked luaprompt to provide all the goodis.
See https://github.com/dpapavas/luaprompt for original.

Change-Id: Iedddb79abae5809299322bc215722dd928c35cca
2015-06-28 17:55:17 +02:00
Dominik Riebeling
8360937ac2 Append build date when building dev version from local foler.
Change-Id: I1172cb0c4910f1d49b6a5d1125a809491a5aba9c
2015-06-07 22:19:54 +02:00
Dominik Riebeling
e5320303cc Make revision handling work when building from local folder.
Change-Id: I8e6cc0eb8a5bff722bf5278ffa7685436c3d846a
2015-05-30 18:40:40 +02:00