Commit graph

11914 commits

Author SHA1 Message Date
Aidan MacDonald
1aa9f26b02 arm: workaround to build Cortex-M7 targets with GCC 4.9
Cortex-M7 support was added in GCC 5, while GCC 4.9 only
supports the M4. The instruction set is almost identical
between both processors; the only difference is that the
M7 supports double-precision floating point and the M4
doesn't.

Since Rockbox currently doesn't use the FPU, building M7
targets as M4 works fine.

Change-Id: I5880d6e81a85fa9b3e16e08d57e7955b4493df0b
2025-04-19 13:16:36 -04:00
Aidan MacDonald
6ea328f0f1 arm: add div0 handler for 64-bit division on ARMv7-M
Even though ARMv7-M has a hardware divider, 64-bit division is
handled in software and needs a div0 handler. The libgcc routines
call __aeabi_{i,l}div0 so we alias those to __div0.

Change-Id: I5152c43d39e25e03f31404753f13978a614aca06
2025-04-19 09:43:40 -04:00
Vencislav Atanasov
545506c923 New port: iPod Nano 4G
Currently, only the development bootloader can be built successfully.

This is a part of the large iPod Nano 3G and iPod Nano 4G support patch.

Credit: Cástor Muñoz <cmvidal@gmail.com>
Change-Id: I74ea0da999ddb1d8ce5d0f5434141b3f0b5f7448
2025-04-18 20:40:49 -04:00
Vencislav Atanasov
d6cd237f80 New port: iPod Nano 3G
Currently, only a bootloader can be built successfully. The development bootloader is functional, it enables further progress on the port.

This is a part of the large iPod Nano 3G and iPod Nano 4G support patch.

Credit: Cástor Muñoz <cmvidal@gmail.com>
Change-Id: Idf85e42334b0e0ae36f9ed273e2940d5d7736e34
2025-04-18 20:10:29 -04:00
Aidan MacDonald
3ed9fb3115 arm: add initial ARM Cortex-M support
M-profile cores manage interrupts differently from classic cores
and lack the FIQ. Split the interrupt management parts out into
separate headers but keep the endian swapping routines (which are
not profile-dependent) in the common system-arm header.

The initial part of the vector table is common to all Cortex-M
CPUs and is intended to be included by the target linker script,
with the vendor-specific part of the vector table appended to it.

Change-Id: Ib2ad5b9dc41db27940e39033cfef4308923db66d
2025-04-18 13:19:42 -04:00
Aidan MacDonald
c33aafcd5c arm: add ARMv7-M version of ARMv6 mixer code
GCC cannot compile the existing assembly here on ARMv7-M,
claiming impossible constraints. It is actually possible to
compile if the input arguments (addresses and sizes) are
first moved to a high register so as not to conflict with
the use of r0-r7 in ldm/stm -- this is exactly what GCC does
for ARMv6, but it won't do it on ARMv7-M for some reason.

We can get a result similar to the ARMv6 code by manually
moving the inputs into temporaries, but the generated code
is a actually a bit smaller on ARMv7-M if the r0-r7 block is
shifted up to r3-r10. This only works since ARMv7-M supports
the 32-bit Thumb encoding -- 16-bit Thumb can't represent an
ldm/stm instruction of this type.

It's worth #ifdef'ing the code because although the ARMv7-M
version works on ARMv6 too, it spills a lot of registers on
the stack even though register use is mostly similar.

Change-Id: I9bc8b5c76e198aecfd0a0e7a2158b1c00f82c4df
2025-04-18 10:57:45 -04:00
Vencislav Atanasov
a1bf19de36 Fix unused function warning
Change-Id: I6252a6db2a0f9cdd3d0c18262b5809856a5bd977
2025-04-18 10:57:04 -04:00
Aidan MacDonald
1c96d51717 arm: add ARMv7-M support for thread context switching
On ARMv7-M, stm/ldm instructions can't include SP, so we must
load and store that separately. This changes the order of
registers in the context struct, but it doesn't seem to be
accessed anywhere else so this shouldn't cause any problems.

Change-Id: Ie1cd23272f23384e030f51f0b76739624fa7332b
2025-04-18 10:55:32 -04:00
Aidan MacDonald
6712779ccb x1000: fix regression on Q1 with misaligned write pointer
Commit 1fb906500a ("x1000: LCD DMA fix") caused a regression
on the Q1 by breaking the LCD_X1000_DMA_WAIT_FOR_FRAME logic,
since the wrong branch of lcd_wait_frame() was taken.

Change-Id: Icb44335f506a1a691280de8219188526bb11468f
2025-04-18 10:49:27 -04:00
Aidan MacDonald
76c62dc429 x1000: remove bogus modes from lcd_dma_start()
These 'modes' don't do anything here except clutter the code.

Change-Id: I4e0eef39e0c3bac288c40d571ba855c9ffd7c1a1
2025-04-18 10:49:27 -04:00
Aidan MacDonald
b71337f1fd x1000: remove LCD fast sleep define
All the X1000 targets use "fast" sleep, as opposed to the normal
HAVE_LCD_SLEEP define which creates a user-configurable option.
Remove the ifdefs to make the code a bit easier to read.

Change-Id: Ibb80c92a8e23191651fee61fc8cf6f4e4fac8750
2025-04-18 10:35:49 -04:00
Vencislav Atanasov
7e2019fde9 iPod Nano 2G NAND: Use the correct bit names for FMCSTAT
Looks like they were always off-by-one, so the wrong functions have been used to rectify this bug. This is now properly fixed.

No changes to the ipodnano2g binaries (bootloader, rockbox)

Change-Id: I19fe1b89f9e5d722f7e877d60f68fc3275c3642a
2025-04-18 10:26:57 -04:00
Aidan MacDonald
a0bfcd77c8 arm: enable unified assembly syntax in more files
This makes these files compileable, or in some cases less
broken, on Cortex-M targets.

In lcd-16bit.c, newer versions of GAS complain about the
infix condition codes so we use the suffix form instead,
which requires unified syntax to compile on GCC 4.9.

Change-Id: If45166d3fc83d64c692cbb331096a966397aa9e9
2025-04-18 10:26:02 -04:00
Aidan MacDonald
639b587fc7 arm: add support for processors with hardware division
ARMv7-M has hardware division, so it doesn't require __div0
or any support functions for 32-bit division.

Change-Id: I840683a1a77d737f378899ca4bcf858216b81014
2025-04-18 09:22:48 -04:00
Aidan MacDonald
7e8a818d95 arm: add ARM architecture profile detection
Add some logic to detect classic and M-profile cores, and make
this info available to the build system. All existing targets
are classic profile.

Change-Id: I07bfcd418bcaa6297b9bbf889fc189f167147428
2025-04-18 09:22:48 -04:00
Roman Artiukhin
059df3782f unicode: Explicitly set INT_MAX for unlimited utf8_size
-1 could be supplied unintentionally from user code when utf8_size is computable value

Fixup for 004304dc and 1f548f74

Change-Id: I93008ea289bdb134f051975c25b0db9d0e64b823
2025-03-28 15:05:13 -04:00
William Wilgus
856da7f366 Debug - OS stacks - show current stack usage too
Change-Id: I41f895786e409c3f4ea500f99eb74cbd6cdbe5b6
2025-03-20 16:50:08 -04:00
Christian Soffke
9d82db1146 pwrmgmt: sleep timer: don't shut down while charging
This mirrors the behavior of idle poweroff,
which inhibits shutdown as long as a charger
is plugged in, even if a device is capable
of powering off while charging.

Since usb_inserted() already checks for USB_POWERED,
certain devices with the ability to power off while
charging, already exhibit this behavior when using
the sleep timer anyway.

Change-Id: I35ed4b542a8a4df06a34395c85f4d37fc1d2ce53
2025-03-14 11:48:12 +01:00
William Wilgus
3c4aed56c0 [FixRed] Creative Zen
missing ;

Change-Id: Ia24562ef47f03227ff536c743b4939e63ada0d01
2025-03-11 03:02:14 -04:00
William Wilgus
4f3bbeaffc Remove BATTERY_TYPES
Change-Id: I4fa03a10d0032fd6f92722bbe1d4b7eec0b95cb4
2025-03-11 02:26:38 -04:00
William Wilgus
69664cc4e9 Asan fix warning for 1-bit vert #2
try #2 at this
if there isn't enough data remaining to fill the columns
then don't read any more data

looking at the blame for this driver it had similar logic originally

But really on native this is just extra overhead so..
Ifdef out for native

Change-Id: I105dea1f7adc0448f345b268fcfa8574333132a9
2025-03-11 01:21:05 -04:00
William Wilgus
42a9582cc1 Asan fix warning for 1-bit vert
1-bit vertical displays overread the buffer due to the way the
packing works, this isn't the hottest path anyway but
we can check if height <= 8 and make stride 0 so the dummy data
gets the beginning of the data instead

Change-Id: I88ab4dc37bfd2d680d125f964beafe0ddfb00645
2025-03-10 13:13:20 -04:00
William Wilgus
fffae07833 [Bugfix] Scroll engine, backwards scrolling causes display corruption
When a line is over a selected length bi-directional scrolling
is disabled.

In non bidir scrolling the string is copied to a buffer twice with
a space between "scroll text" + "   " + "scroll text"

this is to allow scrolling the line in the forward direction
with minimal extra logic

Note: that is the ONLY direction it is equiped to handle

In the USB screen I observed while switching through the different modes
that sometimes the text was corrupted

turns out you can still have scroll->backwards set to true
which causes offset to go negatve but we never check if offset < 0
in non bidir scrolling mode and happily continue with ever more negative offsets

Change-Id: I210f7880be953d3cc42469828a7ca5fc2b2ab96f
2025-03-09 09:16:07 -04:00
William Wilgus
a05bd377ab [FixRed] YPR1
the YPR1 apparently can do voltage or percent measure
I'm pretty sure its missing logic for disksafe and shutdown,
perhaps the device takes care of it for you?

hopefully someone with the device notices the issue
(perhaps due to a older battery needing capacity tweaked)

Change-Id: I79d3927fa8b154ba231aa6894de7920a4e4dd4c7
2025-03-06 19:28:21 -05:00
William Wilgus
87ca944366 [Fix Red] Hopefully fix the last of the red for device_battery_tables..
Change-Id: I96668b32e026abff4290b36ade168a0d0eb7c7e6
2025-03-06 13:50:16 -05:00
William Wilgus
43ab8dc413 [Fix Red] Fix remaining red from, Import battery tables
Change-Id: I0b41a90089843adfe49da453d76c0c3ef0c78057
2025-03-06 13:10:32 -05:00
William Wilgus
a1fd56ba8e [FixRed] Bootloaders, devices without size_t defined
Change-Id: I452760478ea7324458a05c7af0a88bcbe92def45
2025-03-06 12:39:37 -05:00
William Wilgus
10f8312db4 FS#13538 export and import battery level tables
when battery_bench is run
exports a file in the rockbox directory called 'battery_levels.default'

if the user wants their own levels they can rename the file battery_levels.cfg
and it will be loaded at boot

some minimal error checking is performed prior to using the values

added manual entry

Change-Id: Ia0126faced0c7229fcf8385a1bcb584b5a9dc378
2025-03-06 11:54:21 -05:00
Aidan MacDonald
64d8fc7c0c Sansa Connect: fix a likely typo in busy wait loop in USB driver
GCC 9.5 issues a -Wmisleading-indentation warning due to an extra
semicolon at the end of the while loop. It does seem unintentional
since the loop is a busy wait, so remove the semicolon.

Change-Id: I83b8676cbf38434b8148c43906c6bba9c16d036e
2025-03-01 14:26:35 -05:00
Aidan MacDonald
4377d4b0fa firmware: fix missing includes in some firmware headers
Add includes for any types/macros we use in these headers.

Change-Id: Icfcd7a58376c5738fe6562cdb3cdd7855df35c75
2025-03-01 13:20:51 -05:00
William Wilgus
50da856992 [BugFix] itoa conflicts with mingw rename to itoa_buf
Change-Id: Ife361f2fd8c8946db5bb2e0e58c0981b2ed3c5f3
2025-02-18 10:41:18 -05:00
Solomon Peachy
2c1d31fcd9 xduoox3: Fix inverted test for USB power supply detection
Only affected status display, charging is handled entirely by hardware.

Introduced in f3026cd0 (2024-11-02)

Change-Id: I08c7c442fb3bddf18e5a0d33dac963c24d3c9182
2025-02-10 14:31:32 -05:00
Solomon Peachy
39285d06d5 xduoox3: Rework how we detect "charging" state
The "charging" status is apparently "charging needed" as it
is asserted even when power is not being supplied.  So first check
to see if USB is connected, and if so, then check the "charging" status.

Change-Id: I3050f187e0b6c9d97d25d80015b413cd02e5c3b2
2025-02-10 09:47:48 -05:00
Solomon Peachy
0a2a90c182 FS#13560: ATA: Don't check for 80 pin cables on SATA devices.
On PATA, we'd cap our transers at UDMA2 if the device reported that an
80 pin cable wasn't detected, but SATA devices do not perform this test.

So alter the check to only apply on PATA devices, so that SATA devices
can run at full UDMA speeds.

Change-Id: Id7aa25f2a702c0af73d707395439d69da1e04719
2025-02-10 09:23:11 -05:00
William Wilgus
95f4accf45 use lcd_drawinfo instead of separate drawmode, fg, bg calls
Change-Id: I181ff3a93f03ce1ae44a20f2b216de400320207f
2025-02-08 01:02:22 -05:00
Paul Sauro
4bde992ca3 pp502x: Fully shut down storage power on older(4g/photo, mini, mini2g) iPods
On these older iPods, power was not being shut down completely, which led to a backfeed situation leading to decreased battery life and some stability issues.

This was particuarly apparent when using SD card adapters that do not
respect the ATA power management commands (ie all of them), as they never enter a low-power state on their own.

With this change, there are reports of battery life exceeding 20 hours of continuous playback (~30% increase with CF cards, 3x improvement with SD cards) and appears to resolve intermittent wakeup stability issues with SD adapters.

Change-Id: I46cfff7a59bb18a448989812303f30869df24d2d
2025-02-07 09:49:50 -05:00
William Wilgus
f55fe21f66 add itoa(), replace snprintf("%d") calls
we can save some space and still end up with a 20% faster function

Change-Id: Ia58900122944b8527ef01a673afe18ea794acb41
2025-02-03 01:23:49 -05:00
William Wilgus
231d552972 isdigit replace with a slightly faster and shorter conditional
in testing of three ways of doing this
current: ((_ctype_+1)[(unsigned char)(c)]&_N)

alt1(this patch): (((unsigned int) (c) - '0') < 10)

alt2: ((unsigned int)(c ^ 0x30) < 10)

alt1 and alt2 are the same in terms of speed and instructions (on arm v7) but alt2 has one more
instruction on mips

(across several archs in godbolt mips, armv7v8, x86) and on ARM7 (clipzip) device about 9% faster

less false positives for both alt1 and 2 when you start supplying more than 8bits
not sure if that matters in practice though

I tried similar with isxdigit but could only get to within 1 instruction of the ctype implementation
although it negated the array lookup I saw no discernable speed difference on device

https://godbolt.org/z/qGvh4hqnG

Change-Id: I5c9e8fd3915709853e0e33427038e20a068058b6
2025-02-02 13:57:58 -05:00
Christian Soffke
cf42dd6b12 powermgmt: adjust sleep timer behavior
Responding to the bug report posted by iPodVT:
https://forums.rockbox.org/index.php/topic,55180.msg255292

- An active sleep timer that runs out will now cause the
player to shut down regardless of playback state

- When playback state is paused or stopped, once the
idle timer has run out, player will shut down, regardless
of any running sleep timer

Change-Id: I33de682a63ed1db76174eb2394ef5568f37cc677
2025-02-02 13:00:30 -05:00
William Wilgus
f501dd00eb short circuit is_diacritic for 5-15% text drawing speed-up
characters less than the first diacritic in the symbol table (0x300)
return false after checking the MRU table

we gain some performance by eliding the function call all together if less than first diacritic

Change-Id: I02c14e350eb168eca808523affad443cd43888b4
2025-01-31 21:48:44 -05:00
William Wilgus
7100090f99 Remove NVRAM infavor of a separate cfg file
remove nvram and use the existing settings framework for it

add a crc check to the user_settings data to see if we need to save
the user setting file or if we can just save the status file (resume.cfg)

move volume to the system_status struct so we don't write the whole settings file
over volume changes

allow user to still export volume with save sound settings

allow the user to also export pitch and speed

name the file .resume.cfg

Rename all the SYSTEM_STATUS save file variables to TLAs to save space and
discourage tinkering

Cleanup DEBUG_AVAIL_SETTINGS output

when saving user_settings it calls status_save as well this cause the resume
file to be written twice. instead remove the callback for status_save
when setting_save is called

remove header text when saving .resume.cfg

convert status_save() to status_save(bool force)
add SYSTEM_STATUS_UPDATE_TICKS

for ATA device set this to 5 minutes
since we arlready wait for the disk to be up before saving
we don't want to miss our window

for all other every 15 minutes

that way if the battery is too low by the time shutdown comes around you
don't lose much progress

Change-Id: I27214ffd6e5d5494ee5ca83b14f04a41ba426ad7
2025-01-21 00:04:32 -05:00
Vencislav Atanasov
8e293b4948 serial: Add serial_tx_raw() function for sending raw bytes to the serial port
serial_tx() can only be used for NULL-terminated strings, and also adds CR before every LF.

Change-Id: I8c3eafa5bc152bb54abf4629ee76396dc1cb9b8c
2025-01-20 08:17:48 -05:00
Solomon Peachy
46eb089f97 More fixes for when both battery PERCENTAGE and VOLTAGE are enabled
Hopefully this fixes the last of the red

Change-Id: I732a595cfda088fb5517a15d83c29427dfc18137
2025-01-20 08:16:38 -05:00
Solomon Peachy
07b0015d17 Fix android build, regression from 96463d855f
Change-Id: I1ddb80645c0e895a536a1cec8bebf6e721f8932e
2025-01-20 07:14:48 -05:00
Dana Conrad
96463d855f erosqnative: hw4 units prefer egauge battery percentage
Use AXP2101's egauge battery percent level if available (hw4 units).
If not available (_battery_level() will return -1 on hw1-hw3 units),
fall back to voltage battery level.

Also fix logic in axp2101_battery_status()

Change-Id: Ic300418532dae6f7772fff8bf5e2b32516f3b973
2025-01-19 17:30:21 -05:00
William Wilgus
02c256565f [FixRed] Reove HAVE_PITCHCONTROL from bootloaders, fix warble
Change-Id: I85a3580bd5fac881ca36efc260791d03f0b8c83a
2025-01-19 01:20:58 -05:00
William Wilgus
4e271642df [Feature] Persist pitch settings through reboots part deux
Revisit this after discussion with chris_s on IRC and forum

Pitch menu now changes icon when pitch has been changed

uses NVRAM to save the pitch settings unconditionally

Manual updated

Change-Id: Idcb4c2b7fe42f7a203dc4bfc46285657f370d0fd
2025-01-19 00:29:47 -05:00
William Wilgus
54333536fe [BugFix] YesNo screen wait for button release on exit
if you run yesno screens back to back or another screen with
wait_for_release you may never see the release

instead clear anything in the queue but release events

Change-Id: I1b1e42cbb44f2fdfed441ab1f217b6ea4fe07492
2025-01-17 00:42:25 -05:00
Solomon Peachy
9417ece0ea imx233: Make bootloader compile, fix up remanining warnings
Change-Id: Ie87d178c56455b93364dffa656ebbee9cd7a4bad
2025-01-08 09:14:20 -05:00
Christian Soffke
18aa0f6278 Creative Zen Vision: fix config file (?!)
If I'm interpreting the git history correctly,
the config file for Zen Vision was at some point
inadvertently replaced with one for the
Zen Vision:M.

This deletes the currently unused creativezv.h,
and moves its contents into zenvision.h.

The config files appear to be identical except for
CREATIVE_ZV vs CREATIVE_ZVM define, different
keypads (CREATIVEZVM_PAD vs CREATIVEZV_PAD) and
BOOTFILE_EXT (zv vs zvm), a different model name
and number, as well as different LCD dimensions
and DPI.

The buttonmap still seems to require adjustment.

Change-Id: I9a5e65df750db21be5f5a1ed7a80a50706237781
2025-01-08 08:06:45 -05:00