summary |
shortlog | log |
commit |
commitdiff |
tree
first ⋅ prev ⋅ next
Joseph Hwang [Wed, 16 Jan 2013 10:56:46 +0000 (18:56 +0800)]
Fix the problem of strict aliasing
The strict-aliasing flag has been enabled in gcc. This leads to
the following compiling error:
yapa_fw_update.c:1136:5: error: dereferencing type-punned pointer
will break strict-aliasing rules [-Werror=strict-aliasing]
cc1: all warnings being treated as errors
The term 'aliasing' indicates that pointers of different types
point to the same memory address. The dereference of the type-punned
pointer will lead to undefined behavior. In the particular problem
here, it tries to type cast a char pointer to an integer pointer,
and then dereferences the integer pointer.
The solution is not to type cast different pointer types (except
char pointer which is allowed in the strict aliasing rules).
BUG=chromium-os:37931
TEST=Should emerge cypress-tools successfully.
(cr) emerge-{BOARD} cypress-tools
Change-Id: Id2c6fe668261383aa8b0f5824128abb1da65ce0e
Reviewed-on: https://gerrit.chromium.org/gerrit/41354
Reviewed-by: Benson Leung <bleung@chromium.org>
Commit-Queue: Joseph Shyh-In Hwang <josephsih@chromium.org>
Tested-by: Joseph Shyh-In Hwang <josephsih@chromium.org>
Benson Leung [Wed, 21 Dec 2011 23:34:01 +0000 (15:34 -0800)]
Add 0x7900 as a fixup region for firmware backup bins
A binary diff of the output of cyapa_fw_update -c <iic>
and cyapa_fw_update -b shows that a region that corresponds
to firmware address 0x7900 to 0x797F is different in the
backed up binary. In the converted binary, it is always filled
with 0x08.
BUG=chromium-os:24494
TEST=cyapa_fw_update -b -o /lib/firmware/cyapa.bin
echo -n 1 > /sys/bus/i2c/devices/15-0067/update_fw
Ensure that the fw update succeeds. Check dmesg after
this command is finished, check to see that cyapa device
shows up as an input device.
Change-Id: I5c27bd80323d75cb461a16849c5799edb0f63007
Signed-off-by: Benson Leung <bleung@chromium.org>
Daniel Kurtz [Fri, 2 Dec 2011 04:20:26 +0000 (12:20 +0800)]
Add option to convert from .iic to .bin
The "--convert" option reads in an .iic file and converts it to a .bin
file. The .bin file is saved to the output file specified with the
--output option.
BUG=chromium-os:23066
TEST=cyapa --convert --output=/tmp/CYTRA.bin CYTRA.iic
Change-Id: I0ded7079c79552aa9613923015bc4f633966182b
Daniel Kurtz [Fri, 2 Dec 2011 04:18:28 +0000 (12:18 +0800)]
Do not automatically reboot
Rebooting the machine should be handled by the process driving a touchpad
firmware update, not by the updater itself.
Besides, reboot was only performed between gen2 and gen3 firmware versions.
By now, all firmware is gen3, so reboot should never be required.
Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
BUG=chromium-os:23065
TEST=Update cyapa firmware from gen2 to gen3. No automatic resets.
Also, cyapa_fw_update should not warn about reseting.
Change-Id: I8fa277254fb76cff7e1dedd0de55ac1688564576
Daniel Kurtz [Fri, 2 Dec 2011 03:12:39 +0000 (11:12 +0800)]
Set permissions when creating .bak file
When opening the .bak file, truncate to 0 length if it already exists,
or create with the following permissions if it doesn't exist:
* reading and writing by the owner
* reading only by group members and others
Fixes compiler error on x86.
BUG=chrome-os-partner:7054
TEST=builds clean for x86-generic, arm & x86_64
Change-Id: Iaface75c8f78d4b7e36c50d677fc452297eebeb0
Daniel Kurtz [Wed, 19 Oct 2011 09:44:32 +0000 (17:44 +0800)]
Backup: speedup
The touchpad firmware should not actually requires at least 1 ms,
not 10 ms a 10 msec pause between writing bootloader 'read' command and a
subsequent data buffer read.
Also, instead of reading the command header (first 16 registers) time,
only read the data registers (starting with byte 16).
Combined, this reduces backup time from ~45 seconds to ~10 seconds.
Eliminating the msleep(1) could speed up by almost another factor of 2,
down to ~5.5 seconds.
BUG=chromium-os:21568
TEST=backup 100 times, no false reads
Change-Id: I3344b38af0614ba233d8e7072bc0c9587a13a001
Daniel Kurtz [Fri, 14 Oct 2011 11:50:26 +0000 (19:50 +0800)]
Cleanup checksum calculation
BUG=chromium-os:21568
TEST=downloaded firmware passes checksum test
Change-Id: Id1727e0e242a106b0a263b3b8c347a415ce4c5fa
Daniel Kurtz [Fri, 14 Oct 2011 11:46:51 +0000 (19:46 +0800)]
Cleanup elapsed time calculation
Note: this also fixes a bug where the fractional second was incorectly
displayed. Since the usec wasn't zero-padded, it was being left shifted:
For example, the value "6.000005" was being printed as "6.5".
BUG=chromium-os:21568
TEST=Inspect timer output.
It should always have 6 decimal places, even if usec < 100000.
Change-Id: Ia41a11428aedde45419d99821a411144156e273a
Daniel Kurtz [Fri, 14 Oct 2011 13:36:10 +0000 (21:36 +0800)]
Backup: Fix IDAC regions after reading whole firmware
Instead of fake reading the IDAC regions, fix them after reading the
whole firmware into a local buffer, but saving to disk.
Plus, refactor the fixup operation itself to make it more flexible.
BUG=chromium-os:21568
TEST=confirm that back up file has:
0x08 from 0x7280-0x72FF
0x90 from 0x7380-0x747F
Change-Id: Iea115777d9842ccbb83581b1c125f3a59e41d847
Daniel Kurtz [Fri, 14 Oct 2011 12:57:34 +0000 (20:57 +0800)]
Backup: first read into buffer, then write buffer to disk
BUG=chromium-os:21568
TEST=builds clean;
Check that backed up firmware images are correct
Change-Id: I9bc78ec086f68a2a1bc8b296cd45b08895baa578
Daniel Kurtz [Fri, 14 Oct 2011 14:44:33 +0000 (22:44 +0800)]
Allow reading a backup without doing an update
If no firmware image is provided, but --backup is requested, still read
the current image and save it to disk.
BUG=chromium-os:21568
TEST=cyapa_fw_update -f -b -o /tmp/backup.bin
=> Should backup current firmware to /tmp/backup.bin
Change-Id: I10c79a2ead42038583a627024aca39a68731892b
Daniel Kurtz [Fri, 14 Oct 2011 13:15:13 +0000 (21:15 +0800)]
Refactor file open checks
* Return 0 on success, <0 on error.
* No need to seek check the normal files.
* Use perror(): when a system call fails, it is useful to know why.
* If the checks fail, don't try to access the device in the error path.
BUG=chromium-os:21568
TEST=builds clean
file open/access checks pass in the normal case
file open checks fail when:
* no device present
* firmware file doesn't exist
* permissions are wrong for backup file
Change-Id: Ie7589c6bebed670974425c748f9107263dc01e5d
Daniel Kurtz [Thu, 13 Oct 2011 11:54:44 +0000 (19:54 +0800)]
Refactor Y/N prompts
Refactor common functionality to make code more readable.
Note: this code should have same behaviour, but that behavior isn't
actually correct. It doesn't properly handle the case where there are
multiple Y|N questions asked.
BUG=chromium-os:21568
TEST=builds clean; Y/N questions still asked and answered properly in Y
and N cases.
Change-Id: I1edc0e39dad70865015a442f9b655a1a4f1f5cca
Daniel Kurtz [Thu, 13 Oct 2011 13:16:20 +0000 (21:16 +0800)]
Use nanosleep instead of custom wait()
BUG=chromium-os:21568
TEST=builds clean; build with debug and confirm operations are still
being delayed properly
Change-Id: I341b9b341fa7a28d7cd9ce7e06d90761bd2291ec
Daniel Kurtz [Fri, 14 Oct 2011 07:14:46 +0000 (15:14 +0800)]
Use getopt_long instead of custom arg parsing
One side affect of this change is we no longer copy the filename args into
malloc'ed buffers, we just use const char pointers.
This also fixes how we recognize filename extensions, to ensure that the
filename really ends with the extension (i.e. .bin, not .binary).
BUG=chromium-os:21568
TEST=builds clean;
Test following cases:
cyapa_fw_update
cyapa_fw_update -h
cyapa_fw_update -v
cyapa_fw_update -f
cyapa_fw_update -f -b
cyapa_fw_update -b -o bkup.bin
cyapa_fw_update -b -o bkup
cyapa_fw_update -f fw.iic
cyapa_fw_update -f -b fw.binary
Change-Id: I48c2f686e2118e8b1ca91a54e87ee29c80f37b2e
Daniel Kurtz [Fri, 14 Oct 2011 06:20:57 +0000 (14:20 +0800)]
Use stdbool.h
While we are at it, alphabetize (system) headers and clean up a typo.
BUG=chromium-os:21568
TEST=builds clean
Change-Id: Ie93f0c0b86db43cdeb9aa7269e0d2ba42a9a63ae
Daniel Kurtz [Fri, 14 Oct 2011 12:17:23 +0000 (20:17 +0800)]
Fix big endian conversion
16-bit quantities are sent big-endian in i2c commands.
Populate buffer with MSB and LSB in a platform independent way.
BUG=chromium-os:21568
TEST=builds clean for x86, arm.
offset / block_index should be sent big-endian for both arches.
This should result in a properly backed up image for both arches.
Change-Id: I988c5a050027b2081abd5cb2634cb4221951b6b8
Daniel Kurtz [Fri, 14 Oct 2011 12:09:51 +0000 (20:09 +0800)]
s/arguments/args
Less characters, no loss of readability.
BUG=chromium-os:21568
TEST=builds clean
Change-Id: I7b5a34c6dc42487fdcddb14af9192a3c60c581bb
Daniel Kurtz [Wed, 12 Oct 2011 09:47:38 +0000 (17:47 +0800)]
Fix segfault when parsing arguments with no filename
When user doesn't specify a filename, or specifies '-h' first,
new_fw_image won't be set.
BUG=chromium-os:21568
TEST=emerge-${B} cypress-tools builds clean
On device:
cyapa_fw_update -h
=> prints help; no Segmentation fault
Change-Id: Iab8043587c99dede9a3a338175ebc61025fe2410
Daniel Kurtz [Wed, 12 Oct 2011 09:44:09 +0000 (17:44 +0800)]
Fix compiler warnings.
While we are at it, cleanup some spelling typos, and rename & simplify
check_run_as_root().
BUG=chromium-os:21568
TEST=emerge-${B} cypress-tools
Change-Id: I2fbd186bf655b7266cb0969efb72d13a1a9e9765
Daniel Kurtz [Wed, 12 Oct 2011 09:11:35 +0000 (17:11 +0800)]
Add Makefile
BUG=chromium-os:21568
TEST=manual:
make all
make clean
Change-Id: I067ed79c4e00c07ff881ae1b0e972ada58714654
Daniel Kurtz [Wed, 12 Oct 2011 09:51:55 +0000 (17:51 +0800)]
Disable cros license & tab checks
cypress-tools is copyright Cypress Semiconductor Inc.
This file uses kernel C formatting, which uses tabs instead of spaces.
BUG=chromium-os:21568
TEST=repo upload .
=> No errors about incorrect license.
Change-Id: I1b77f6e9cfb77483c206dd5ed68bad174093837d
Du, Dudley [Thu, 28 Jul 2011 07:17:31 +0000 (15:17 +0800)]
utility: cyapa_fw_update : Upload initial source code and documentation
Upload intial source code and documentation for cyapa_fw_upate utility tool.
BUG=chrome-os-partner
TEST=test with cyapa v0.9.8 and later version driver on Kaen board
Change-Id: I5030b84d8115676b6abd19b3ed8ece934c741862
Signed-off-by: Du, Dudley <dudl@cypress.com>
Dave Parker [Tue, 19 Jul 2011 18:59:33 +0000 (11:59 -0700)]
Add a README.chromium file for the cypress-tools respository.
BUG=None
TEST=None