Rockbox Technical Forums

Rockbox Development => New Ports => Topic started by: amachronic on May 23, 2021, 07:52:49 PM

Title: Shanling Q1
Post by: amachronic on May 23, 2021, 07:52:49 PM
Well, I know I said I wasn't gonna do this, but some users here on the forum were asking about a Shanling Q1 port which got me to investigate the "trick" to run scripts on its OF... in the end I found out a bit more information than I originally intended!

I've made some headway disassembling the Q1's Linux kernel, and probably identified most of the important hardware components. I haven't done much on the "hosted" side of things 'cause it's not easy to get an interactive shell on the player. For anybody interested I posted my current findings on the wiki, https://www.rockbox.org/wiki/ShanlingQ1Port (https://www.rockbox.org/wiki/ShanlingQ1Port).

Long story short, it looks like a native port would be pretty easy. All the hard/tedious parts were implemented with the FiiO M3K port. The main downside with a native port is that wifi/bluetooth will probably never work in Rockbox. With a hosted port we at least have a chance of wrapping the OF kernel's functionality with menus, and if Shanling's kernel is well done then tbh there may not be much benefit to a native port. In the short term I'll probably just keep checking out the hardware/software and find out if the OF kernel has any serious shortcomings.

I emailed Shanling and asked them nicely if they'd release their Linux kernel sources for the greater good of Rockbox. I'm not expecting much on that front, but who knows? They might just help us out, it's at least worth asking.

There is one other annoyance -- the Q1's screen resolution is 360x400, which isn't used by any other Rockbox player. So there's no ready-made themes for it, even Cabbie will need to be ported.

I'd like to hear opinions about wireless support... making a wild guess, given Rockbox's "target audience" maybe I'm not the only user who doesn't care much for it.
Title: Re: Shanling Q1
Post by: Milardo on May 23, 2021, 09:42:34 PM
Well, I know I said I wasn't gonna do this, but some users here on the forum were asking about a Shanling Q1 port which got me to investigate the "trick" to run scripts on its OF... in the end I found out a bit more information than I originally intended!

I've made some headway disassembling the Q1's Linux kernel, and probably identified most of the important hardware components. I haven't done much on the "hosted" side of things 'cause it's not easy to get an interactive shell on the player. For anybody interested I posted my current findings on the wiki, https://www.rockbox.org/wiki/ShanlingQ1Port (https://www.rockbox.org/wiki/ShanlingQ1Port).

Long story short, it looks like a native port would be pretty easy. All the hard/tedious parts were implemented with the FiiO M3K port. The main downside with a native port is that wifi/bluetooth will probably never work in Rockbox. With a hosted port we at least have a chance of wrapping the OF kernel's functionality with menus, and if Shanling's kernel is well done then tbh there may not be much benefit to a native port. In the short term I'll probably just keep checking out the hardware/software and find out if the OF kernel has any serious shortcomings.

I emailed Shanling and asked them nicely if they'd release their Linux kernel sources for the greater good of Rockbox. I'm not expecting much on that front, but who knows? They might just help us out, it's at least worth asking.

There is one other annoyance -- the Q1's screen resolution is 360x400, which isn't used by any other Rockbox player. So there's no ready-made themes for it, even Cabbie will need to be ported.

I'd like to hear opinions about wireless support... making a wild guess, given Rockbox's "target audience" maybe I'm not the only user who doesn't care much for it.

A different port, but I'm interested in bluetooth support, is anybody still working on that feature, would like to use it on agptek rocker.
Title: Re: Shanling Q1
Post by: Telehubis on May 24, 2021, 05:32:51 AM
More devices is always a good thing!

But what about that touch screen; is that supported?
Title: Re: Shanling Q1
Post by: 7o9 on May 24, 2021, 08:19:43 AM
Very nice, looking forward to your progress.

The Shanling app is not bad but compared to RockBox it feels incredibly limited. A hosted version would not be bad at all though native works great on the FiiO M3K.

The wireless functionality is not needed for me, I have always only ever used it with wired buds. The wifi functionality that was added in the latest official firmware feels more like a 'because we can' feature than actually useful.

@Telehubis: Seems the touchscreen is using the same controller as the touchstrip on the M3K so it will probably work similar too.
Title: Re: Shanling Q1
Post by: speachy on May 25, 2021, 07:52:19 AM
I'd like to hear opinions about wireless support... making a wild guess, given Rockbox's "target audience" maybe I'm not the only user who doesn't care much for it.

WiFi probably isn't going to ever happen.  The Q1 uses an SDIO-attached broadcom b43xx.  It's not clear if it's a softmac or fullmac part, but either way writing a native driver for that chip is a major undertaking in its own right.  Not to mention potentially writing an 802.11 stack plus coming up with network-enabled applications and usecases.

Bluetooth is a lot simpler at the "driver" level, but we're faced with having to write a stack from scratch or port the likes of bluez/bluedroid, another substantial undertaking. At least that stack would be usable for our other BT-supporting targets...
Title: Re: Shanling Q1
Post by: amachronic on June 06, 2021, 08:09:36 AM
Just posting to let everyone know I have got Rockbox running on the Q1, but no audio or bootloader yet; I'm stuck trying to get the DAC to work. There's a patch in gerrit in case anyone is interested. The simulator works, at least (lol).

I will probably put this aside and come back later, hopefully some 'enlightenment' will strike and I'll figure out how to get the DAC working.
Title: Re: Shanling Q1
Post by: 7o9 on June 06, 2021, 02:14:48 PM
Thanks for the update and your efforts.

I read the comment in Gerrit about the state of your attempts. I also read you have great Google-fu so I am sure you found the LG V30 code for this DAC. Would have hoped that helped.

How did you run it without a bootloader? Read the code, answer is USB boot  :)

Hopefully inspiration will strike at some point. The M3K port is great but the Q1 feels so much nicer and does not have the crazy touchpad.
Title: Re: Shanling Q1
Post by: amachronic on June 06, 2021, 03:00:18 PM
Problem is, I just don't know how the board is physically wired... I've got datasheets but it's no help if the DAC won't turn on.
Title: Re: Shanling Q1
Post by: 7o9 on June 08, 2021, 02:27:08 AM
Saw in the IRC logs that you managed to get audio. Very exciting.

Great that enlightenment struck so quickly!
Title: Re: Shanling Q1
Post by: Telehubis on June 14, 2021, 11:04:35 AM
Just one note on the WiFi - perhaps a dual boot would solve it?
Title: Re: Shanling Q1
Post by: amachronic on June 14, 2021, 01:47:57 PM
Yeah, I actually got dual boot working today for the Q1 and FiiO M3K (that was a real pain due to OF kernel bugs...)

Since I'm here, I may as well say the Q1 port pretty much "works" hardware-wise, aside from some odds and ends, but you can really feel how neglected touchscreens are in Rockbox... It's something I hope to improve over time though. I was able to jury-rig the M3K's bootloader to work on the Q1, but I don't want to release something so half-baked, with the potential for things to go terribly wrong -- my own Q1 was "bricked" for a while due to one such mistake.
Title: Re: Shanling Q1
Post by: 7o9 on June 22, 2021, 03:25:48 PM
I have been playing around a bit with the Q1 patch from Gerrit (https://gerrit.rockbox.org/r/c/rockbox/+/3460) and it works quite well.

You have to start it with usbboot as there is no bootloader yet and it takes some serious getting used to the 3x3 touchscreen grid input.

Having said that, it plays music quite nicely and just looks cool.

Hopefully one day it will be mature enough to use like any other Rockbox player. Unlike most, you can still actually buy the Q1!

Attached is a screendump taken from the actual Q1 running Rockbox and playing a tune.
Title: Re: Shanling Q1
Post by: Telehubis on July 14, 2021, 01:07:07 PM
Saw that Q1 port is available. That is such a great news!
I would like to check it out so can you please share how to install that via usbboot?
Also how to achieve dual boot / revert to OF?

Great work!
Title: Re: Shanling Q1
Post by: amachronic on July 14, 2021, 04:38:29 PM
You'd have to compile the bootloader yourself. All needed files spl.q1, bootloader.bin/.q1 will be in the bootloader build directory. Hold the play (middle) button at boot to enter USB boot mode. Once connected, run usbboot in utils/ingenic_tools:
Code: [Select]
./usbboot -c x1000 -1 <spl.q1> --wait 1 -2 <bootloader.bin>
You'll get a recovery menu; to install the bootloader you need to place bootloader.q1 onto your SD card. You should take a bootloader backup before installation; it creates a backup file named shanlingq1-boot.bin on your SD card. In case you want to revert to the 'pure' OF, simply put that file back on your SD and choose restore in the recovery menu.

Boot options:
Proper docs, bootloader binary, jztool support, etc, should be ready over the next little while. Theme site and daily builds will be available once the patch is merged.

Enjoy!
Title: Re: Shanling Q1
Post by: amachronic on July 25, 2021, 11:38:13 AM
Alright, at last there's bootloader binaries available for the Q1. Installation instructions and download links are in the manual (https://download.rockbox.org/daily/manual/rockbox-shanlingq1/rockbox-buildch2.html). If there's anything unclear or confusing about the manual let me know and I'll fix it; the install process is basically the same as for the FiiO M3K so its installation forum thread (https://forums.rockbox.org/index.php/topic,53858.0.html) might clarify things.
Title: Re: Shanling Q1
Post by: 7o9 on July 25, 2021, 11:52:44 AM
The manual understandably is very generic so some pointers:

- Rockbox Utility support or a release build do not exist yet, you need a 'dev build' from the link on the top left of the Rockbox site.
- Make sure your sd card is fat32. exfat will not work.
- Windows users need to install 'Zadig' for direct usb access support.
- Put the bootloader.q1 file on your sd card before running jztool, you need to install it from the bootloader menu launched by jztool.
- You can get additional fonts here: https://www.rockbox.org/download/byhand.cgi (it does not matter the q1 is not listed, the fonts are the same for all players so pick any).

After succesfully installing, I really recommend turning on the 'Absolute Point' touchscreen mode so you can select items directly in the menus and file lists instead of using 3x3 mode.

'Touchscreen mode' is burried in General Settings -> Display -> Touchscreen Settings.
Title: Re: Shanling Q1
Post by: sadur on August 18, 2021, 11:51:17 AM
Hi.
I'm writing to this thread because I'm a lucky new owner of this beautiful little player (I have an iPod Video with rockbox since 2006, but it has broken :( ).
I'm installed rockbox manually on the Q1 without any problems and it is working very well.
I've uploaded a Theme for this player based on the one I've used in iPod for many years.
About this port, the few things I noticed are:
 - There are no battery estimated time.
 - There are no disk activity (in this case the SD card).
 - For me, the height of the menu items it's to big.
 - It would be nice if the keys were locked via the power button, the screen will never turn on, like the hold button in iPod. This will permit to disable the turn on of the screen on track change in case of the buttons locked.
 - It would be nice too if there is an option to activate the "line-out" like in the original firmware, in rockbox the volume has to be adjusted to the maximum level manually (or via a cfg file in shortcuts.txt)
All the previous points are not essential, but would be nice to have it :)
Finally, thanks for this port!
Title: Re: Shanling Q1
Post by: amachronic on August 18, 2021, 12:59:09 PM
Hi.
I'm writing to this thread because I'm a lucky new owner of this beautiful little player (I have an iPod Video with rockbox since 2006, but it has broken :( ).
I'm installed rockbox manually on the Q1 without any problems and it is working very well.
I've uploaded a Theme for this player based on the one I've used in iPod for many years.
Glad you found it a smooth ride! And thank you for your theme contribution. I think now we're officially up to 4 users   :D

Quote
- There are no battery estimated time.
Known issue, will be fixed eventually. The power management IC used in the X1000 targets is able to report the real-time current consumption and I was hoping to use that to report battery runtime more accurately, based on the actual usage. The Q1's also got a separate, dedicated battery monitor chip which can provide percentage charge & estimated runtime directly, but it's bugged (in multiple ways) and maybe more trouble than its worth if it ends up being no more accurate than Rockbox's estimates.

Quote
- There are no disk activity (in this case the SD card).
Sounds like a bug. I'll try to get it fixed soon.

Quote
- For me, the height of the menu items it's to big.
Agreed. The height can be changed in General Settings > Display > Touchscreen Settings > Line Padding in Lists. Personally, I use 24px but the default works out to something crazy, like 66 px (it's derived from DPI, poorly). Guess I should fix the broken default.

Quote
- It would be nice if the keys were locked via the power button, the screen will never turn on, like the hold button in iPod. This will permit to disable the turn on of the screen on track change in case of the buttons locked.
Keylock is mapped to the power button but you need to configure it in General Settings > System > Advanced Key Lock. For the backlight, you need to go to Display > LCD settings > Backlight exemptions. Also, the keylock only works in the WPS in order to map the power button to 'back' in the menus.

Quote
- It would be nice too if there is an option to activate the "line-out" like in the original firmware, in rockbox the volume has to be adjusted to the maximum level manually (or via a cfg file in shortcuts.txt)
Well, it seems the Q1's DAC always outputs via an integrated headphone amp so it doesn't really have a line out in a strict sense. I did determine conclusively that the original firmware merely sets the volume to 100% when you choose line out mode. That's why Rockbox doesn't have a line out mode -- it wouldn't make much sense as you can accomplish the same thing by volume control. But I get why having an easy setting is nice.
Title: Re: Shanling Q1
Post by: sadur on August 18, 2021, 02:30:54 PM
Thanks for your quick answer!
I'll check your suggestions and wait for possible bug fixes  :)
Title: Re: Shanling Q1
Post by: 7o9 on August 18, 2021, 03:20:01 PM
Quote
- It would be nice if the keys were locked via the power button, the screen will never turn on, like the hold button in iPod. This will permit to disable the turn on of the screen on track change in case of the buttons locked.
Keylock is mapped to the power button but you need to configure it in General Settings > System > Advanced Key Lock. For the backlight, you need to go to Display > LCD settings > Backlight exemptions. Also, the keylock only works in the WPS in order to map the power button to 'back' in the menus.

I do not think that is an answer to the question.

I have the same request, when Key Lock is on, I would like the screen not to be turned on at all when touched.

Additionally, but this is different, I would like the LCD to be turned off immediately when I turn on Key Lock.
Title: Re: Shanling Q1
Post by: amachronic on August 18, 2021, 06:48:32 PM
Disk LED fix is now merged, it was a minor oversight in the driver. For some reason I thought it was handled elsewhere but apparently not.

7o9, are you still experiencing the backlight turning on from touches on recent builds? It should've been fixed by commit 62260aa705 (https://github.com/Rockbox/rockbox/commit/62260aa7057f322f7f99062a6a3bd7534ea0047d). Just double checked it on my end so if you're still getting the problem with the latest build please share steps to reproduce!
Title: Re: Shanling Q1
Post by: 7o9 on August 19, 2021, 03:01:45 AM
You are right, amachronic, that commit seems to help. I was on a build from one or two days before that change.

To get close to what I want, I needed to enable the 'Disable Touch' option under 'Advanced Key Lock'.

Right now I have disabled 'Backlight Exemptions', enabled 'Advanced Key Lock' and have checked the 'Exempt Volume', 'Exempt Play' and 'Exempt Skip' options (for the physical buttons), combined with 'Disable Touch'.

I still do not particularly like the screen turning on when I use those exempted physical buttons but I have not found a way around that.

Thanks!
Title: Re: Shanling Q1
Post by: sadur on August 19, 2021, 11:37:53 AM
I've tested the disk activity indicator and works well :)
Title: Re: Shanling Q1
Post by: Telehubis on September 03, 2021, 08:08:28 AM
I really like this player with Rockbox on it. :)

When it comes to patching; how do I do that? Do I just copy & paste Rockbox newer version folders to the player?
Title: Re: Shanling Q1
Post by: 7o9 on September 03, 2021, 10:04:55 AM
I really like this player with Rockbox on it. :)

When it comes to patching; how do I do that? Do I just copy & paste Rockbox newer version folders to the player?

Yes, extract the latest dev build to your sd card overwriting the .rockbox folder. Make sure to answer 'Yes' when prompted to overwrite existing files.
Title: Shanling Q1
Post by: hoklim on October 10, 2021, 06:54:24 PM
Hey guys! I rockboxed my Q1 yesterday and I must say that I was blown away by how great the result sounds. I find the sound improvement of RB over vanilla FW pretty substantial. Is there an explanation why that might be? Back when I was angry with iBasso players' sound signature changing with every FW release, I had a theory that those Chinese manufacturers are applying some kind of DSP to make everything sound more "audiophile" and only messing things up with it. What is correct explanation however? Or am I just plain wrong in my perception?

Also, I'm sending a small donation, this is really some great work.
Title: Re: Shanling Q1
Post by: Telehubis on October 11, 2021, 04:58:15 AM
Sorry abut OT, but why this thread was moved to this forum? Topics for other players remain in the "new ports" and this goes to "general"...