Commit graph

47 commits

Author SHA1 Message Date
James Buren
6b3b4df6f6 rockbox: move firmware checksum algorithms into a common header
Before this was just implemented inline wherever it was needed. Now
it is provided as 2 inline functions in a header called checksum.h.
There should be no differences in actual behavior.

Change-Id: I5d756cc01dc6225f5cc8b6af90911a3fc7b57cd5
2020-11-22 05:12:04 +00:00
James Buren
c79ddb6bf4 iriver_flash: update valid bootloaders table
This removes all the pre-release bootloader of version 7 and
replaces them with production releases of version 8. The
pre-releases have their own problems and should be left
behind as they were never officially released.

Change-Id: If96531ba63cf4401d04133bda94735fe94ae4de1
2020-11-16 11:57:18 +00:00
James Buren
c10eea46a9 iriver_flash: add macros to reduce the rom chip table
The table is now gated by the FLASH_SIZE macro as any given
target will not have a known rom chip of a differing size
than the FLASH_SIZE. This will reduce the resulting code
a bit as well.

Change-Id: I06a283f9f44118080a106e1bcd410e81e0a48d92
2020-11-14 23:21:15 +00:00
James Buren
33d42c20de iriver_flash: do not let the backlight timeout while running
I discovered it was doing this on the H300 during longer operations
and I freaked out at first. This disables this feature until the
program is finished so as to not give anyone else an unnecessary
fright while using it. It will also cut down on frivilous reports.

Change-Id: I0db406912c7f71835576203a540aba8910afa849
2020-11-14 18:47:12 +00:00
James Buren
4aa749b59d iriver_flash: refactor code to be easier to understand
This overhauls most of the code to be easier to understand in terms
of the interactions with the flash. I found the original to be rather
confusing with how it kept switching between byte and word offsets.

My solution was to make all external access to the flash in terms of
sectors and bytes. Whatever the flash uses internally is now handled
by the subroutines for performing the erase, program, and verify
operations.

This helps make it far more consistent for the code that actually uses
these operations as they do not need to concern themselves with word
sizes and offsets anymore.

As a side effect of this change the flash operations are now done
entirely by subroutines; even the batch operations that used to use
custom loops.

Additionally some functions were merged with other functions in order
to reduce the amount of functions as well as consolidating common
code fragments.

Change-Id: I4698e920a226a3bbe8070004a14e5848abdd70ec
2020-11-11 13:30:09 +00:00
James Buren
2d85c72151 iriver_flash: fix issues with DoUserDialog
First the argument should be const since the original parameter is.

Second the pointer arithmetic for detecting whether rockbox is running
from ROM or not is incorrect. It ends up being at a location twice as
far as intended since the arithmetic does not account for the pointer
type's underlying size. It should also be dependent on the target's
FLASH_SIZE.

Third the LCD setup is moved to the entry point since it is the best
place to setup and restore the LCD changes.

Change-Id: If9ddaf2cd937f1edf61c82a8a27f48d01807068a
2020-10-30 15:55:36 +00:00
James Buren
fa3184f951 iriver_flash: make most remaining functions static
This increases opportunities for optimizations as well.

Change-Id: I4105990d7d1fca93c735762721cfc293973c5344
2020-10-30 06:25:49 +00:00
James Buren
7c498b9043 iriver_flash: revise valid_bootloaders and detect_valid_bootloader
The main change is revising how the checksums are guarded by macros.
But both are also converted to static linkage so they can be better
optimized by GCC. I also change the types around to reflect how the
space the data types actually need. Furthermore I make use of C99
changes to how variables can be declared to move them closer to where
they are used.

Change-Id: I0b21b655f3f4a7c4bbd4365a384a551e75451159
2020-10-30 05:40:29 +00:00
James Buren
6bc6af6a0e iriver_flash: revise load_firmware_file function
This moves the checksum into the local stack and turns the second
parameter into an optional argument. This also reads the model
segment that was previously unused so it can also be checked as
an extra safeguard in the event the checksum somehow matches
yet the model is incorrect.

Change-Id: I9a8c2d731e4f1818e6e4aee3c3978777c16ccf19
2020-10-30 05:20:42 +00:00
James Buren
f1bfbb52f1 iriver_flash: revise cfi_read_id and cfi_get_flash_info
First neither of these functions can fail on supported targets
so they have become void functions. Their return values were
not being used anyway.

Second support for other flash chips not even used on the
supported targets has been removed. It appears they were
only ever used on the discontinued Arch devices.

Third cfi_read_id was restructured to remove obsolete code
for error checking that is not necessary at all. The datasheets
appear to indicate that the commands used cannot fail.

Fourth cfi_get_flash_info was restructured to use a new approach
to initializing the flash_info struct. It no longer initializes
the structure twice.

Fifth the relevant code has been updated to use the full 16 bits
that are exposed by the flash rom ID interface.

Change-Id: I25b1ada3d4621e2d80ac66d3d9a964964268cb3b
2020-10-29 23:01:25 +00:00
James Buren
f65e410497 iriver_flash: rewrite how the flash commands wait for the ROM
This uses the toggle bit method referenced in the datasheets for the
supported ROM chips and moves the code to a reusable subroutine. It
also introduces a short delay to give the bus a chance to recover. The
older ROM datasheet doesn't mention this delay as necessary but the
newer one does so it now does this for both.

Change-Id: Ie9dc8833bbd3ee545072b0c724ab220d13208d3d
2020-10-29 05:30:28 +00:00
James Buren
bee736f3ea iriver_flash: make cfi_read_id use FB directly
Change-Id: Id747b0846515443871a0df10d83e3b1fc4731e7c
2020-10-27 16:01:16 +00:00
James Buren
e5b963b8e1 iriver_flash: remove trailing whitespaces
Change-Id: I5f32ba177a2ca559768e621bbad1d896c9adcafa
2020-10-27 16:00:15 +00:00
Solomon Peachy
f62eee569c iriver_flash: we need -fno-delete-null-pointer-checks
Change-Id: I36bbfc81d9cb79a9627e5ba7ee50e1305f54848b
2020-10-26 21:27:46 -04:00
James Buren
dd3ea521ad iriver_flash: correctly calculate when to stop erasing the bootloader
It was originally hard-coded at 0x200 which is 512 sectors. This
only works for the H100 and H120. The larger ROM of the H300 is 1024
sectors in size. In either case the bootloader starts 16 sectors before
the end of the ROM so rely on this fact to correctly calculate where to
stop the bootloader erasure.

Change-Id: Iec4112ebf24379f80a7bf1363035e005c434907e
2020-10-26 02:29:01 +00:00
James Buren
129001909d h300: enable support for iriver_flash
This also modifies the configuration file to include macros
defined in the H100 / H120 implementation.

Change-Id: Iae845889c98661ec548c04fc57e733dcc346c0f1
2020-10-26 01:07:14 +00:00
James Buren
1419070b3d iriver_flash: add support for SST39VF3201 ROM chips
These are used in the iRiver H300 series.

Change-Id: Iafbd165bdfd71b691698156d3fd91243c50b3b61
2020-10-25 23:18:21 +00:00
Solomon Peachy
09785a8499 fix more yellow
Change-Id: I74bad58707d05ea167169d4315c05eb0cd1c8b7b
2020-10-13 17:23:56 -04:00
Solomon Peachy
b94db707fb Fix more warnings.
Change-Id: Ib3a9fc622a46b1fc72e94dcbc6d29d2e430cd81b
2020-10-13 15:48:31 -04:00
James Buren
b5c2a4ab96 Add support for new bootloaders for iRiver h1x0 series
This resolves a long-standing issue with ATA errors in certain
situations, mostly in CF card modified units.

Change-Id: Iec23fa6de117a6c9657320432ed585170e95a4eb
2020-10-12 15:33:59 +00:00
Nils Wallménius
0ba13e45f0 Fix warning about using static vars in non static inline functions with gcc 4.5.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28911 a1c6a512-1295-4272-9138-f99709370657
2010-12-27 10:46:29 +00:00
Rafaël Carré
ab9fd1840b plugins: use lcd_putsf/lcd_putsxyf
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27926 a1c6a512-1295-4272-9138-f99709370657
2010-08-28 21:46:45 +00:00
Rafaël Carré
7014faee69 Remove build conditions inside .c plugin files
Rather use the Makefile to specify which files must be built
Fix color builds with test plugins enabled (test_scanrate gave an empty
.o file)

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27886 a1c6a512-1295-4272-9138-f99709370657
2010-08-25 19:00:58 +00:00
Thomas Martitz
cae4ae2c71 Second try: Introduce plugin_crt0.c that every plugin links.
It handles exit() properly, calling the handler also when the plugin returns
normally (also make exit() more standard compliant while at it).
It also holds PLUGIN_HEADER, so that it doesn't need to be in each plugin anymore.

To work better together with callbacks passed to rb->default_event_handler_ex() introduce exit_on_usb() which will call the exit handler before showing the usb screen and exit() after it.
In most cases rb->default_event_handler_ex() was passed a callback which was manually called at all other return points. This can now be done via atexit().

In future plugin_crt0.c could also handle clearing bss, initializing iram and more.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27873 a1c6a512-1295-4272-9138-f99709370657
2010-08-24 14:30:46 +00:00
Thomas Martitz
93cb949372 Revert "Introduce plugin_crt0.c that every plugin links."
Too much errors and no time to fix them now.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27863 a1c6a512-1295-4272-9138-f99709370657
2010-08-23 17:12:26 +00:00
Thomas Martitz
abdc5935be Introduce plugin_crt0.c that every plugin links.
It handles exit() properly, calling the handler also when the plugin returns
normally (also it makes exit() more standard compliant while at it).
It also holds PLUGIN_HEADER, so that it doesn't need to be in each plugin anymore.

To work better together with callbacks passed to rb->default_event_handler_ex introduce exit_on_usb() which will call the exit handler before showing the usb screen and exit() after it.
In most cases it was passed a callback which was manually called at all other return points. This can now be done via atexit().

In future plugin_crt0.c could also handle clearing bss, initializing iram and more.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27862 a1c6a512-1295-4272-9138-f99709370657
2010-08-23 16:56:49 +00:00
Rafaël Carré
5d236b2bfd Generate C file / header for svn version string
It's now easier to force rebuild of files depending on the svn revision

version.c/version.h are generated once with new tools/genversion.sh
Changes in the VCS are still not auto detected, so you'll have to remove
builddir/version.* if you want to change the string in your binaries

APPSVERSION is now called RBVERSION and is defined in the generated
header instead of being defined by the Makefiles
appsversion is now called rbversion (the plugin api number didn't change
since old modules are still binary compatible)

Change some bootloaders to use knwon-at-buildtime RBVERSION instead of
"%s" + rbversion

You'll need to run make clean to regenerate dependencies after the
removal of apps/version.h

To build binaries with a different version string, hand-edit
tools/version.sh or tools/genversion.sh (which calls the former)

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26320 a1c6a512-1295-4272-9138-f99709370657
2010-05-27 09:41:46 +00:00
Nils Wallménius
360d00f600 Fix reds.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23712 a1c6a512-1295-4272-9138-f99709370657
2009-11-22 19:08:29 +00:00
Andrew Mahone
04b7cefd63 fix mem* wrappers in UI on cygwin, by not building certain plugins on sim, rather than building empty ones
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19856 a1c6a512-1295-4272-9138-f99709370657
2009-01-25 18:27:17 +00:00
Andrew Mahone
23d9812273 loader-initialized global plugin API:
struct plugin_api *rb is declared in PLUGIN_HEADER, and pointed to by
__header.api

the loader uses this pointer to initialize rb before calling entry_point

entry_point is no longer passed a pointer to the plugin API

all plugins, and pluginlib functions, are modified to refer to the
global rb

pluginlib functions which only served to copy the API pointer are
removed

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19776 a1c6a512-1295-4272-9138-f99709370657
2009-01-16 10:34:40 +00:00
Jonathan Gordon
4b472de39b a few more button/statusbar fixes...
* hopefully fix the last of the plugins which dont handle the enw SYS event.
* fix FS#9750 - WPS's which dont specify (or force the wps on) wernt showing the statusbar at all
* lamp, battery_bench, *_flash button handling fixes
* plugins using the core menu code will again show the statusbar



git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19656 a1c6a512-1295-4272-9138-f99709370657
2009-01-03 13:27:19 +00:00
Daniel Stenberg
2acc0ac542 Updated our source code header to explicitly mention that we are GPL v2 or
later. We still need to hunt down snippets used that are not. 1324 modified
files...
http://www.rockbox.org/mail/archive/rockbox-dev-archive-2008-06/0060.shtml


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17847 a1c6a512-1295-4272-9138-f99709370657
2008-06-28 18:10:04 +00:00
Steve Bavin
6526577818 Plugin parameters should be const.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17492 a1c6a512-1295-4272-9138-f99709370657
2008-05-13 09:57:56 +00:00
Miika Pekkarinen
37dc15b672 Added the checksum for H100/H110/H115 bootloader also.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16254 a1c6a512-1295-4272-9138-f99709370657
2008-02-09 15:32:55 +00:00
Miika Pekkarinen
698113d9db Prepare for a new bootloader 7-pre4 release for iriver H100 series. Synced to work properly with SVN, and hopefully fixed remote detection problem and audio thump for some users. Also pure H100/H115 should be supported now. Actual bootloaders will be released separately.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16252 a1c6a512-1295-4272-9138-f99709370657
2008-02-09 15:06:09 +00:00
Michael Sevakis
8676dc25f5 Missed a couple. Hopefully fix all warnings.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13234 a1c6a512-1295-4272-9138-f99709370657
2007-04-21 19:07:15 +00:00
Michael Sevakis
26d242ae65 General housekeeping: Make plugin buffer functions take size_t * instead of int * to match the parameter type of the buffer functions called in the core. Get rid of unsafe int * <==> size_t * casting. Use ssize_t where int was used and size_t where unsigned int was used in the buffer calls to not alter signedness in the plugins. No API version change since it should only be an issue for 64-bit sim builds.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13233 a1c6a512-1295-4272-9138-f99709370657
2007-04-21 18:38:25 +00:00
Jens Arnold
79c8a8cbbe Let GCC check arguments of some more printf-style functions, also for plugins and codecs.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12815 a1c6a512-1295-4272-9138-f99709370657
2007-03-17 09:02:53 +00:00
Jens Arnold
4d6374c923 Get rid of the 'center' parameter for splashes. There were only 2 of almost 500 splashes which were not centered.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12807 a1c6a512-1295-4272-9138-f99709370657
2007-03-16 21:56:08 +00:00
Miika Pekkarinen
35b0c3f24f Updated bootloader for H120/H140 and entirely disabled flashing code for H100 until somebody tests it.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11993 a1c6a512-1295-4272-9138-f99709370657
2007-01-12 20:45:37 +00:00
Miika Pekkarinen
0ea4d3197e Prepare core support for the iriver bootloader supporting ROM images
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11991 a1c6a512-1295-4272-9138-f99709370657
2007-01-12 18:34:00 +00:00
Miika Pekkarinen
7c9230c64f Don't corrupt the original firmware when updating bootloader.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11234 a1c6a512-1295-4272-9138-f99709370657
2006-10-16 08:34:48 +00:00
Miika Pekkarinen
973ee5d8d9 Gracefully shutdown unless firmware is found.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10879 a1c6a512-1295-4272-9138-f99709370657
2006-09-04 16:06:11 +00:00
Miika Pekkarinen
25425360b5 Enabled iriver flashing plugin with additional safety checks,
confirmation and ability to restore original firmware.


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10547 a1c6a512-1295-4272-9138-f99709370657
2006-08-12 14:00:41 +00:00
Miika Pekkarinen
22860a910a Fixed hold switch detection from bootloader when rockbox has been
flashed.


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10533 a1c6a512-1295-4272-9138-f99709370657
2006-08-11 19:59:16 +00:00
Miika Pekkarinen
e1eb91b976 Bootloader support to search firmware also from flash. Bootloader <->
Rockbox communication when Rockbox has been flashed.


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10499 a1c6a512-1295-4272-9138-f99709370657
2006-08-09 12:04:13 +00:00
Miika Pekkarinen
85ba65d2a3 Initial version of the iriver flashing plugin for H1xx. Building of
the code not yet enabled, because the code still lacks some features
and safety checks.


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10463 a1c6a512-1295-4272-9138-f99709370657
2006-08-05 16:11:39 +00:00