Rockbox Technical Forums

Rockbox Development => New Ports => Topic started by: chocovy on July 23, 2019, 05:04:46 AM

Title: Fiio M3k
Post by: chocovy on July 23, 2019, 05:04:46 AM
Gonna start a thread for the fiio m3k (not m3)

So far this is what I was able to gather on what's inside the player.

SoC: Ingenic X1000e
OS: Custom (linux-based)
DAC: AKM AK4376A
Power management IC: AXP192
Screen: 2.0 inch IPS TFT 240×320

Until I can figure out how I can disassemble the unit safely the pcb scans have to wait I guess...
Can't really help out on the software side of things as I'm only familiar with C++.

This is where the firmware updater (and other firmware versions of the player) is located
http://www.fiio.me/forum.php?mod=viewthread&tid=43627&extra=page=1

will update this thread on further findings
Title: Re: Fiio M3k
Post by: XVortex on August 18, 2019, 05:15:03 AM
I think it's possible

It’s coming...,
(http://xvtx.ru/rockbox/photos/m3k_rockbox_sm.png)
Title: Fiio M3K
Post by: Bilgus on August 29, 2019, 06:54:28 PM
Fiio M3K New Port Thread

Fiio M3K General Discussion
See: http://forums.rockbox.org/index.php/topic,52952.0.html
Title: Re: Fiio M3k Rockbox Port
Post by: XVortex on September 01, 2019, 12:10:54 PM
Here we go!
Rockbox for the FiiO M3K is available on my site:
http://xvtx.ru/rockbox/download.htm (http://xvtx.ru/rockbox/download.htm)

- Based on the stock FW v1.3.0 (which has also been optimized for speed and memory usage).
- It is flashed like a regular firmware (...and rolls back also).
- Almost everything works, but minor bugs will be fixed over time.

Enjoy!
(and please consider a donation for me or/and rb team if You'd like it).

P.S. source code will available later, when all settle a bit.
Title: Re: Fiio M3k
Post by: amtmart on September 03, 2019, 02:41:23 AM
Awesome work! How does one go about installing this on the player? What bugs have you noticed?
Title: Re: Fiio M3k
Post by: XVortex on September 03, 2019, 05:19:27 AM
You should install it as regular update: https://www.fiio.com/newsinfo/82055.html
There are several minor issues, they will be fixed in the next version. Nothing serious.
Title: Re: Fiio M3k
Post by: amtmart on September 04, 2019, 02:51:12 PM
I got it installed and its working pretty great, gotta say i absolutely love rockbox. only 2 errors so far, both errors on bus (one said 10 i believe and the other 11), first one happened when i tried to open my library before scanning the database, the second happened when listening to music and going through the plugins menu. Hope this helps!

Edit: also just noticed there doesnt seem to be a way to lock the screen with the physical screen lock button
Title: Re: Fiio M3k
Post by: Njones on September 04, 2019, 06:55:04 PM
Depends on which theme. Cabbie has the lock feature. Hold on /off button for 3 seconds to lock or unlock. Updated version available now through link in Rockbox general discussion forum.
Title: Re: Fiio M3k
Post by: amtmart on September 10, 2019, 01:17:58 PM
So I've used it for a few days now and here's the bugs I've encountered.

The worst is that I can no longer boot into the stock OS, it just freezes up after I select fiio music.
It also is completely off on the battery level, it'll be at 0 for a while but stay on, or say 30 then jump to 17 when I plug it in.
It also seems to have a problem keeping setting changes.
Also still experiencing crashes when loading large lists in file view.
Title: Re: Fiio M3k
Post by: snejdy on September 10, 2019, 01:34:59 PM
Hi, thanks for the port - good job.
I found one bug, however.  The left-right balance does not work for me. Volume in both headphones is turned down instead of just one side.
I would also like to ask if it is possible to make the volume control work even when the keys are locked.
Thanks for the reply.
Title: Re: Fiio M3k Rockbox Port
Post by: XVortex on September 11, 2019, 12:28:48 AM
The left-right balance does not work for me.
Will be fixed in the next version.
Title: Re: Fiio M3k
Post by: Bilgus on September 11, 2019, 01:32:17 AM
If the device has a physical lock button we don't put code for the soft lock stuff which allows keys to be pressed while locked
However it is possible to add it http://forums.rockbox.org/index.php/topic,52539.0.html
Title: Re: Fiio M3k Rockbox Port
Post by: jjjameson on September 13, 2019, 12:53:08 AM
The left-right balance does not work for me.
Will be fixed in the next version.

Just letting you know that the most recent version of Rockbox on your site for the M3K is basically unusable, as it doesn’t let you change the volume and instead defaults to just very very loud. Just letting you know.
Title: Re: Fiio M3k
Post by: snejdy on September 27, 2019, 07:56:12 AM
Just an update, im returning the m3k in favor of the fiio m6. this rockbox release constantly freezes my device at different menus, as well as destroying the amazing battery life. i also couldnt get it to boot back into stock fiio software while rockbox is installed. all in all its not worth the trouble, if you have a lot of music avoid the m3k, if you like a working m3k avoid the releases as of this post.


m3k works with this port without any problems, no freezing for me... Only the channel balance does not work...
Title: Re: Fiio M3k
Post by: Nelke on September 27, 2019, 08:13:49 AM
Hi,

my M3K works well with rockbox, thanks XVortex. :) I can boot into the stock player, freezes are only in some plugins but i don't need these.  With Rockbox I have a battery time of about 18-20 hours. Maybe, the runtime was a bit longer with the fiio player.

Before the update I had formatted a sd card in the M3K. Firmware version was 1.3.0. I don't know if it important.

The only problem I have, fast forward/rewind doesn't work in v1.3.0_5bbc553-190915.
That's why I went back to v1.3.0_70b135b-190913.
Title: Re: Fiio M3k
Post by: Njones on September 30, 2019, 09:58:33 AM
I Updated the M3k firmware to 1.4.3 and now I can't get rockbox to work?
Title: Re: Fiio M3k
Post by: swap on October 18, 2019, 06:55:34 AM
Thanks, Great Port.

I have a question.

Fiio m3k Rockbox provide USB support?

Im new en Rocbox and not found howto transfer file usb.

Thanks
Title: Re: Fiio M3k
Post by: diegopau on February 16, 2020, 01:51:05 PM
Hi XVortex,

Are there any plans to further update the firmware for the M3k?

I posted a few issues and suggestions in these messages
http://forums.rockbox.org/index.php/topic,52952.msg245026.html#msg245026
http://forums.rockbox.org/index.php/topic,52952.msg245080.html#msg245080

I would love to know if you plan to address any of those in the future.

Thanks again for bringing Rockbox to this player.
Title: Re: Fiio M3k
Post by: bbame on March 05, 2020, 10:22:13 AM
I was excited to find a rockbox port for my brand new Fiio M3k.  The stock firmware lacks features I've become used to on my old (now dead) SanDisk Clip+ which ran rockbox.  So first of all, thanks very much for doing this!!!

I do have one question, though.  Fast Forward and Rewind don't work - pressing/holding the buttons just makes the screen flash rapidly - and I was wondering if there was something I could do to fix it.  Maybe revert to an earlier version or play with the settings somehow?  Since I listen to a lot of audio books and podcasts and often find myself rewinding/relistening, or fast fowarding past boring parts (or advertising), lack of FF/RW is a big deal for me.

I found other reports of FF/RW not working on this forum - someone suggested changing FF/RW Accel to "Very fast", which I did, but it had no effect.  For now I have changed "skip length" from "skip track" to "30s", but that's really irritating when I'm listening to music and want to skip a song/track.

Any advice?

Specifics: Fiio M3K, originally with stock firmware 1.4.3, now with the latest M3K rockbox version (also 1.4.3).
Title: Re: Fiio M3k Rockbox Port
Post by: speachy on April 15, 2020, 10:18:13 PM
Here we go!
Rockbox for the FiiO M3K is available on my site:
http://xvtx.ru/rockbox/download.htm (http://xvtx.ru/rockbox/download.htm)

P.S. source code will available later, when all settle a bit.

It's been well over six months since you posted that initial version; Have things settled sufficiently for you to toss the source code our way?  I'd love to get this integrated into the mainline.
Title: Re: Fiio M3k
Post by: whiskerc on April 29, 2020, 11:46:28 AM
Two quick questions for anyone using Rockbox on the M3k.

- Can the dual boot screen be bypassed or set to be very short?
- Would you recommend this player and Rockbox port?

I am a longtime (many year) user of Rockbox on the Clip+, but like many others would like to get a replacement ready for when the Clip+ is no more. 

Long live Rockbox :)
Title: Re: Fiio M3k
Post by: speachy on April 29, 2020, 12:01:45 PM
- Can the dual boot screen be bypassed or set to be very short?
- Would you recommend this player and Rockbox port?

Given that the source code for the m3k port has not been publicly released, the answer to both question is, unfortunately, no.
Title: Re: Fiio M3k
Post by: sohnemann on May 12, 2020, 03:43:42 AM
@XVortex

Is there any timeline on when the source will be available?
Would love to contribute to this port.  :)

Cheers
sohnemann
Title: Re: Fiio M3k
Post by: efqw on May 13, 2020, 04:59:24 PM
UPDATE: I have wiki access now, and I'll be moving important bits from my posts to the wiki page soon. Internal pictures have already been uploaded, along with links to datasheets for every single chip found in this device and disassembly instructions.
https://www.rockbox.org/wiki/FiioM3K (https://www.rockbox.org/wiki/FiioM3K)

First of all, it seems like xvortex somehow has access to FiiO's firmware signing keys? The firmware is a zip archive containing around 66 1MB chunks (kernel and rootfs), and every single part is individually signed with apksign!!! The recovery partition is what verifies (I have not tested unsigned/self-signed chunks yet) the individual chunks and writes them to the internal SPI NAND. You can decompress all of the individual parts, concatenate all the rootfs segments together, and you'll have a regular UBI image to play with.

FiiO was accidentally being incredibly helpful here by not stripping the main player binary in the stock fw (xvortex stripped them to make more room for rockbox), so I managed to get a reliable serial console on xvortex's firmware without having to open up the device. You can save this script in your MicroSD and launch it from xvortex's bootloader menu to get a serial console over USB. I've spent a few hours looking at fiio's main player program with Ghidra a while ago, it loads these modules if you connect the device to USB without a MicroSD card inserted (presumably for writing serial numbers). The main player binary immediately hangs up/unloads the kernel modules if you send something into the serial connection, so I assume we won't get a proper shell from that. Luckily busybox was compiled with getty :D

Code: [Select]
#!/bin/ash
insmod /lib/modules/3.10.14/kernel/driver/staging/dwc2/dwc2.ko
insmod /lib/modules/3.10.14/kernel/driver/usb/gadget/libcomposite.ko
insmod /lib/modules/3.10.14/kernel/driver/usb/gadget/u_serial.ko
insmod /lib/modules/3.10.14/kernel/driver/usb/gadget/usb_f_serial.ko
insmod /lib/modules/3.10.14/kernel/driver/usb/gadget/usb_f_acm.ko
insmod /lib/modules/3.10.14/kernel/driver/usb/gadget/g_serial.ko
getty /dev/ttyGS0 115200



Some thoughts:

1. FiiO's buildroot is based on Ingenic's Halley2 buildroot BSP. The Halley2 BSP kernel, u-boot, buildroot and other misc files can be obtained from their FTP server. Please try to mirror it if you can, ingenic has a habit of silently removing files from their FTP server: ftp://198.13.102.99/ingenic_support/X1000_X1000E_X1500/01_SW/00_Board-Level_Consolidation_Version/Kernel3.10.14_X1000_New_Version/08_ingenic-linux-kernel3.10.14-x1000-v9.0-20191212/ingenic-linux-kernel3.10.14-x1000-v9.0-20191212.tar.bz2 (http://ftp://198.13.102.99/ingenic_support/X1000_X1000E_X1500/01_SW/00_Board-Level_Consolidation_Version/Kernel3.10.14_X1000_New_Version/08_ingenic-linux-kernel3.10.14-x1000-v9.0-20191212/ingenic-linux-kernel3.10.14-x1000-v9.0-20191212.tar.bz2)

2. Regardless of whether xvortex ends up releasing the source (I certainly hope they do), we need a soulution for generating update packages that doesn't involve FiiO's signing keys. Getting a signed intermediary package would be interesting, and then perhaps we can patch the recovery to disable signature verification?

3. My attempts on opening this device non-destructively have not been successful because it was glued shut. Applying heat doesn't seem to do much good as the screen still can't be pulled off with a suction cup clamp. Without access to the PCB (native UART), I won't be able to easily recover the device if something goes wrong with the recovery partition, so I can't tinker with the recovery for now.


Finally, here is some system info. Let me know if you have any questions.

Code: [Select]
/proc/mtd:
dev:    size   erasesize  name
mtd0: 00020000 00020000 "uboot"
mtd1: 00400000 00020000 "kernel"
mtd2: 00500000 00020000 "recovery"
mtd3: 05000000 00020000 "rootfs"
mtd4: 026e0000 00020000 "data"

/proc/version:
Linux version 3.10.14-g60d92e8-dirty (fiio64@ubuntu) (gcc version 4.7.2 (Ingenic 2016.11) ) #3 PREEMPT Fri Sep 27 11:46:20 CST 2019

/proc/cpuinfo:
system type : halley2_v10
machine : Unknown
processor : 0
cpu model : Ingenic Xburst V4.15  FPU V0.0
BogoMIPS : 1001.88
wait instruction : yes
microsecond timers : no
tlb_entries : 32
extra interrupt vector : yes
hardware watchpoint : yes, count: 1, address/irw mask: [0x0fff]
isa : mips32r1
ASEs implemented :
shadow register sets : 1
kscratch registers : 0
core : 0
VCED exceptions : not available
VCEI exceptions : not available

Hardware : halley2
Serial : 00000000 00000000 00000000 00000000

/proc/meminfo:
MemTotal:          58140 kB
MemFree:           43032 kB
Buffers:             476 kB
Cached:             2944 kB
SwapCached:            0 kB
Active:             2940 kB
Inactive:           1500 kB
Active(anon):       1024 kB
Inactive(anon):        4 kB
Active(file):       1916 kB
Inactive(file):     1496 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:             0 kB
SwapFree:              0 kB
Dirty:                 8 kB
Writeback:             0 kB
AnonPages:          1024 kB
Mapped:             1308 kB
Shmem:                 8 kB
Slab:               3444 kB
SReclaimable:       1060 kB
SUnreclaim:         2384 kB
KernelStack:         352 kB
PageTables:          156 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:       29068 kB
Committed_AS:      35264 kB
VmallocTotal:    1048372 kB
VmallocUsed:        2096 kB
VmallocChunk:    1045868 kB


/proc/mount_points:
rootfs on / type rootfs (rw)
ubi0:rootfs on / type ubifs (rw,relatime)
proc on /proc type proc (rw,relatime)
sysfs on /sys type sysfs (rw,relatime)
tmpfs on /dev type tmpfs (rw,relatime,size=10240k)
tmpfs on /tmp type tmpfs (rw,relatime,size=10240k)
mdev on /dev type tmpfs (rw,relatime)
devpts on /dev/pts type devpts (rw,relatime,mode=600,ptmxmode=000)
tmpfs on /dev/shm type tmpfs (rw,relatime,size=5120k)
ubi1_0 on /data type ubifs (rw,relatime)
/dev/mmcblk0p1 on /mnt type vfat (rw,relatime,fmask=0000,dmask=0000,allow_utime=0022,codepage=936,iocharset=utf8,shortname=mixed,errors=remount-ro)


/proc/cmdline:
mem=64M@0x0 no_console_suspend console=ttyS2,115200n8 lpj=5009408 ip=off  init=/linuxrc ubi.mtd=3 root=ubi0:rootfs ubi.mtd=4 rootfstype=ubifs rw loglevel=8

/etc/os-release:
NAME=Buildroot
VERSION=2014.05-00055-g03a0bb5
ID=buildroot
VERSION_ID=2014.05
PRETTY_NAME="Buildroot 2014.05"
Title: Re: Fiio M3k
Post by: speachy on May 13, 2020, 06:40:43 PM
First of all, it seems like xvortex somehow has access to FiiO's firmware signing keys? The firmware is a zip archive containing around 66 1MB chunks (kernel and rootfs), and every single part is individually signed with apksign!!! The recovery partition is what verifies (I have not tested unsigned/self-signed chunks yet) the individual chunks and writes them to the internal SPI NAND. You can decompress all of the individual parts, concatenate all the rootfs segments together, and you'll have a regular UBI image to play with.

This comes as a suprise; none of the other hiby-based players I've seen require signed firmware images.

2. Regardless of whether xvortex ends up releasing the source (I certainly hope they do), we need a soulution for generating update packages that doesn't involve FiiO's signing keys. Getting a signed intermediary package would be interesting, and then perhaps we can patch the recovery to disable signature verification?

This package generation mechanism already exists, but it relies on tooling that is Linux-specific (and also requires superuser permissions).  That said, once a suitably-patched package is generated, we can use that to generate binary patches that can be distributed from download.rockbox.org and automagically applied using rbutil.
Title: Re: Fiio M3k
Post by: efqw on May 14, 2020, 07:55:34 PM
Some updates that I forgot to mention in my last post:

1. The main player application is aggressively logging to /data/userfs/app.log. I'm really concerned about this wearing out my NAND, so I deleted it and made a symlink to /dev/null  :D

2. ubinfo:
Code: [Select]
# ubinfo /dev/ubi0
ubi0
Volumes count:                           1
Logical eraseblock size:                 126976 bytes, 124.0 KiB
Total amount of logical eraseblocks:     640 (81264640 bytes, 77.5 MiB)
Amount of available logical eraseblocks: 0 (0 bytes)
Maximum count of volumes                 128
Count of bad physical eraseblocks:       0
Count of reserved physical eraseblocks:  20
Current maximum erase counter value:     15
Minimum input/output unit size:          2048 bytes
Character device major/minor:            250:0
Present volumes:                         0
# ubinfo /dev/ubi1
ubi1
Volumes count:                           1
Logical eraseblock size:                 126976 bytes, 124.0 KiB
Total amount of logical eraseblocks:     311 (39489536 bytes, 37.7 MiB)
Amount of available logical eraseblocks: 0 (0 bytes)
Maximum count of volumes                 128
Count of bad physical eraseblocks:       0
Count of reserved physical eraseblocks:  3
Current maximum erase counter value:     11
Minimum input/output unit size:          2048 bytes
Character device major/minor:            249:0
Present volumes:                         0

3. It's possible that FiiO simply used some stock test keys to sign the packages, but the keys in ingenic-linux-kernel3.10.14-x1000-v9.0-20191212.tar.bz2 don't match. Maybe they have different test keys in older releases?
Title: Re: Fiio M3k
Post by: diegopau on May 20, 2020, 03:40:54 AM
Quote
The main player application is aggressively logging to /data/userfs/app.log. I'm really concerned about this wearing out my NAND, so I deleted it and made a symlink to /dev/null

Hi, now that you explained this I am concerned too. Would you mind posting some details about how I could do this myself?
Title: Re: Fiio M3k
Post by: efqw on May 25, 2020, 04:18:06 PM
Code: [Select]
rm /data/userfs/app.log
ln -s /dev/null /data/userfs/app.log
;)
Title: Re: Fiio M3k
Post by: diegopau on May 26, 2020, 04:14:50 AM
Sorry, I am a complete noob at this. I never started a serial console before so that's where I am stuck:

On the M3K:

1. I created a file named "serial_connection.sh" with the script:

Code: [Select]
#!/bin/ash
insmod /lib/modules/3.10.14/kernel/driver/staging/dwc2/dwc2.ko
insmod /lib/modules/3.10.14/kernel/driver/usb/gadget/libcomposite.ko
insmod /lib/modules/3.10.14/kernel/driver/usb/gadget/u_serial.ko
insmod /lib/modules/3.10.14/kernel/driver/usb/gadget/usb_f_serial.ko
insmod /lib/modules/3.10.14/kernel/driver/usb/gadget/usb_f_acm.ko
insmod /lib/modules/3.10.14/kernel/driver/usb/gadget/g_serial.ko
getty /dev/ttyGS0 115200

2. I placed the file in the root folder of the MicroSD.
3. Now with the M3K connected through USB and the MicroSD inside the M3K I turn it on and on the boot menu I go to TOOLS -> Run script. I select "serial_connection.sh" and I see a message "Running serial_connectio" that lasts around 5 seconds, then it's back to the boot menu.

On the computer I tried installing termite for windows https://www.compuphase.com/software_termite.htm and with the following settings: https://dl.dropboxusercontent.com/s/g2tr7ezcjxnjz7i/vivaldi_7Zpj9Vw9SW.png
I don't have more options than COM1.

It doesn't work and I don't know what else to try.
Title: Re: Fiio M3k
Post by: efqw on May 29, 2020, 11:17:53 AM
You'll be able to see a new serial port pop up on your computer after you launch the script, and the script is blocking, which means it won't quit unless you actually hang up in the serial terminal. I've never tried this in windows, maybe you could use a Linux vm?
Title: Re: Fiio M3k
Post by: diegopau on May 30, 2020, 02:15:51 PM
Done! thank you! I had to use
Code: [Select]
getty /dev/ttyS0 115200instead of
Code: [Select]
getty /dev/ttyGS0 115200
Title: Re: Fiio M3k
Post by: daps on June 20, 2020, 03:42:39 PM
Seems like the Fiio M3 Pro is the new hot budget player. Anyone messing around with it or is it similar to the M3k?
Title: Re: Fiio M3k
Post by: darkcity on June 21, 2020, 05:50:21 AM
It is similar to the M3k

https://www.fiio.com/m3pro_comparisons

It uses the same SoC, Ingenic X1000E, so hopefully rockboxable.

It has a larger touch sensitive screen. Battery life isn't as good.
Title: Re: Fiio M3k
Post by: efqw on July 15, 2020, 02:09:21 AM
Seems like the Fiio M3 Pro is the new hot budget player. Anyone messing around with it or is it similar to the M3k?

The hardware setup should be sufficiently similar to the M3K, but this is a full touchscreen device. While it is indeed more aesthetically pleasing, I don't think it'll work as well with rockbox as the M3K would.
Title: Re: Fiio M3k Rockbox Port
Post by: LuismaSP89 on August 05, 2020, 11:54:54 AM
The left-right balance does not work for me.
Will be fixed in the next version.

Hi  @Xvortex, do you know when you're going to release the next update? Like other users, the forward/rewind buttons doesn't work, and it's a shame since rockbox works with great performance on the M3K, but can't be used normally because of this bug. Also I can't change the track with the "next/previous" button if the loop option is selected for 1 track.

Thank you for taking your time developing this rockbox for M3K  ;)
Title: Re: Fiio M3k
Post by: ZoRG172 on September 03, 2020, 03:58:45 PM
Is there any way to make sure that the blocking blocks only the touch buttons, and the mechanical buttons continue to work as in the native firmware?

upd
I understand correctly that without the author of the port XVortex softlock cannot be installed in any way?
From this post https://forums.rockbox.org/index.php?topic=51589.0
I'm willing to pay for this function: Softlock Options: Disable Touch (Blocks touch screen buttons like the original (only for touch devices) and for fixing the rewind, but the author does not respond  :'(
As there is a device, it’s useless for me, I’ll have to sell it.
Title: Re: Fiio M3k
Post by: speachy on September 28, 2020, 09:50:12 PM
FYI, over the weekend I received the M3K sources from xvortex.

It's probably going to take a week or two but I'm working on getting the patch sliced into more mergable/reviewable chunks.
Title: Re: Fiio M3k
Post by: chinchin on September 29, 2020, 04:02:47 AM
That's great news. Thanks so much to you both.
Title: Re: Fiio M3k
Post by: fossphile on October 01, 2020, 12:26:42 AM
+1 great news to read. Will be very happy to see skip bug fixed :D.
Title: Re: Fiio M3k
Post by: speachy on October 01, 2020, 07:52:46 AM
+1 great news to read. Will be very happy to see skip bug fixed :D.

For my reference, what exactly is this "skip bug" and how would one go about recreating it?    (Basically, is it something unique to the m3k, or is it shared with other devices?)
Title: Re: Fiio M3k
Post by: Thew on October 03, 2020, 03:05:20 AM
I think “fossphile” is referring to the fact that the two screen buttons for track skipping forward and back don’t work in “vortex's” second Rockbox version. They also don’t work for continuous fast-forward and rewind. They both work correctly in “vortex’s” first Rockbox download.
Title: Re: Fiio M3k
Post by: Summer Element on October 03, 2020, 07:17:28 AM
I was excited to find a rockbox port for my brand new Fiio M3k.  The stock firmware lacks features I've become used to on my old (now dead) SanDisk Clip+ which ran rockbox.  So first of all, thanks very much for doing this!!!

I do have one question, though.  Fast Forward and Rewind don't work - pressing/holding the buttons just makes the screen flash rapidly - and I was wondering if there was something I could do to fix it.  Maybe revert to an earlier version or play with the settings somehow?  Since I listen to a lot of audio books and podcasts and often find myself rewinding/relistening, or fast fowarding past boring parts (or advertising), lack of FF/RW is a big deal for me.

I found other reports of FF/RW not working on this forum - someone suggested changing FF/RW Accel to "Very fast", which I did, but it had no effect.  For now I have changed "skip length" from "skip track" to "30s", but that's really irritating when I'm listening to music and want to skip a song/track.

Any advice?

Specifics: Fiio M3K, originally with stock firmware 1.4.3, now with the latest M3K rockbox version (also 1.4.3).

Actually, it can be fixed by changing some setting. Turn to setting-playback settings-fast_forward/rewind and change the step. My M3k has been okay now after that.  ;)
Title: Re: Fiio M3k
Post by: lubatur on October 03, 2020, 08:39:19 AM
Turning to: setting > playback settings > fast_forward/rewind didn't work quite well for me, but:
installing Vortex's firmware M3K_v1.3.0_eef591e-190901.zip, found here: http://xvtx.ru/rockbox/download.htm (http://xvtx.ru/rockbox/download.htm) > FiiO M3K > All versions, FF/RW works as usual.
Thanks to member bbame for finding out/testing and informing.
Title: Re: Fiio M3k
Post by: Njones on October 03, 2020, 01:18:15 PM
How  do you add additional themes to this update?
Title: Re: Fiio M3k
Post by: speachy on October 03, 2020, 01:20:00 PM
With regards to the seek problem, I found and fixed the underlying problem in the vortex code dump -- it was a "Fix" for the LCD not getting shut off properly, but it had some nasty side effects on all of the hosted targets too.

the m3k-specific stuff is close to being mergeable but we need to be able to patch a new bootloader/launcher into the m3k flash image before it'll be of any use to anyone.

Title: Re: Fiio M3k
Post by: speachy on October 04, 2020, 07:59:49 PM
Good news:  The code is finally cleaned up to the point where the m3k binary and bootloader compile cleanly, and it's only a few to-dos away from being ready to merge:

   https://gerrit.rockbox.org/r/#/c/2804/

The bad news is that this code remains completely untested.  We do not yet have the technical ability to generate the patched firmware update image that is necessary to install our bootloader/launcher.  Figuring that out (in a way that can be scripted) is next.
Title: Re: Fiio M3k
Post by: Thew on October 05, 2020, 03:35:06 PM
I’d just like to add my appreciation of your efforts. I have two M3Ks, one of which I’ve Rockboxed with Xvortex’s first version. I particular enjoy creating my own custom User Interface and the initial promise of Rockbox on the M3K is very good. If things work out OK perhaps I’ll end with Rockbox on both my players.
Title: Re: Fiio M3k
Post by: speachy on October 09, 2020, 09:15:49 PM
The port code has landed in the main rockbox repo, and builds are now being generated by the build farm.

Again, this can *not* be deployed on top of an existing xVortex port.  Please do not attempt to do so.

I have not started to work on inserting our loader/launcher into an existing (stock) firmware image.  I do not know how long that will take.
Title: Re: Fiio M3k
Post by: fossphile on October 09, 2020, 10:00:35 PM
yay! brill news. looking forward to installing it on my m3k  :D :D :D
Title: Re: Fiio M3k
Post by: fossphile on October 09, 2020, 10:04:06 PM
With regards to the seek problem, I found and fixed the underlying problem in the vortex code dump -- it was a "Fix" for the LCD not getting shut off properly, but it had some nasty side effects on all of the hosted targets too.

the m3k-specific stuff is close to being mergeable but we need to be able to patch a new bootloader/launcher into the m3k flash image before it'll be of any use to anyone.

YAY!!!!  :D :D :D :D ;D :D :D :D :D that bug has been so annoying!
Title: Re: Fiio M3k
Post by: fossphile on October 09, 2020, 10:07:26 PM
I think “fossphile” is referring to the fact that the two screen buttons for track skipping forward and back don’t work in “vortex's” second Rockbox version. They also don’t work for continuous fast-forward and rewind. They both work correctly in “vortex’s” first Rockbox download.

it was fast forward/backward. i was annoyed at the compromise of losing skip back/forth in order to tap to skip x sec instead of hold down for fast forward/rewind.
Thank you for mentioning my woe.  :)
Title: Re: Fiio M3k
Post by: diegopau on October 10, 2020, 04:50:59 PM
This is great news! quite exciting, I am using the M3K heavily and it is great device even with the existing firmware limitations. Thank you speachy for working on this.

Some suggestions that I already posted in a different thread. I know it is too early, I just wanted to leave them documented since this is where the development is being reported.

- While playing any audio file, in the "While Playing" screen, there are no actions assigned to the touchpad (scrolling up / down), I think it would be a great feature to control the volumen up/down there by swipping up/down the touchpad button. That way we don't need to use the hardware buttons to control volume as long as we are seeing that screen.  even better if it is customizable, some people might prefer brightness up/down, right now there is no action assigned to scroll up/down the touchpad during playback.
- It would be good to remove the problem that efqw explained about how the firmware is constantly logging to a file and maybe wearing out the NAND.
- Is it possible to setup the M3K so it just starts directly to Rockbox without any countdown and just with a single click on the power button (instead of long press)? that's how the clip zip is setup by default: quick click to power button runs Rockbox, power button + volume down button runs Sansa firmware. This makes it quick to turn it on and it is also more gentle on the power button, it will last longer.
- Currently there doesn't seem to be a way to stop the playback, the playback can be paused, but not stopped. I think this is important for the power saving options. So if for example in the clip zip I used to be able to tap in a button that will create a bookmark and stop the playback, and if there is a automated power off setting for 5 minutes of standby, then in 5 minutes the device is off. In the M3K if I am listening to an audiobook and I can only pause the playback and then the automatic stand by power off setting is never triggered.
- It is currently a bit difficult to reach the screen that allows you to select the playback speed, i use it to slowdown a bit audiobooks. I mean this one https://www.dropbox.com/s/jnl5ddplhm6w0p7/IMG_20191112_203959.jpg?dl=0, in the clip zip I accessed it by long pressing the pause/play button, I can't find any button that takes me there in the Fiio M3K, but I did see that there is a way to access it by navigating quite a bit.


Issues that I had
- I have a big file (a long audiobook) that plays perfectly on the Sansa Clip Zip with Rockbox, and also in the Fiio M3K when using Fiio firmware. It doesn't however play when using Rockbox in Fiio M3K, it doesn't do anything. Are there any logs that I can attach? where can I find them? The file properties can be seen here https://www.dropbox.com/s/rh5u0227297uf3q/SMPlayer%20-%20File%20properties%202019-11-12%2020.38.28.png?dl=0, I can share it with you in private if that helps.
- The problems with transferring files through USB, in general this doesn't seem to work. Not a big deal to me, I just transfer them directly to the sd card.
Title: Re: Fiio M3k
Post by: speachy on October 10, 2020, 05:37:29 PM
Some suggestions that I already posted in a different thread. I know it is too early, I just wanted to leave them documented since this is where the development is being reported.

It is _far_ too early to talk about feature/bugrequests, especially versus an unofficial build/fork.

I can only promise you that when the "official" binaries are finally installable, they will present a different set of bugs than what you're used to.
Title: Re: Fiio M3k
Post by: fossphile on October 12, 2020, 12:56:53 PM
I can only promise you that when the "official" binaries are finally installable, they will present a different set of bugs than what you're used to.
Sounds like a improvement :)
Title: Re: Fiio M3k
Post by: bahus on October 21, 2020, 11:59:36 AM
Would be cool to have option to replace volume buttons with next/prev actions and move volume control to touch slider (so making control very similar to iriver h10). I believe it would make it conveniently controlled from the pocket.
Title: Re: Fiio M3k
Post by: alexs on November 07, 2020, 07:41:41 PM
This package generation mechanism already exists, but it relies on tooling that is Linux-specific (and also requires superuser permissions).  That said, once a suitably-patched package is generated, we can use that to generate binary patches that can be distributed from download.rockbox.org and automagically applied using rbutil.

No idea what's the current status here, so just in case, I think I have a way (or one more way) of installing pretty much anything on this device now. There's nothing really Linux-specific about it, but it does involve a valid original M3K.fw. It is however very easy to patch out once discovered, assuming anyone at FiiO cares.

This comes as a suprise; none of the other hiby-based players I've seen require signed firmware images.

Shanling M0 uses the same kind of signed update packages. With the same exact public key for signature checks.

1. The main player application is aggressively logging to /data/userfs/app.log.

A bit of trivia. Navigate to Settings -> About, and press the pause button TWELVE times. The player will copy app.log to the SD card, along with the kernel log. If there's a file named "fiio_linux_app_debug_cmd" in the root directory of the SD card, it will also attempt to capture and copy core dumps of the player application.
Title: Re: Fiio M3k
Post by: speachy on November 08, 2020, 09:51:55 AM
Shanling M0 uses the same kind of signed update packages. With the same exact public key for signature checks.

In other words, it's probably the default Ingenic signing key, probably hiding somewhere in the bowels of their SDK sources...
Title: Re: Fiio M3k
Post by: whiskerc on November 24, 2020, 08:28:26 AM
Just checked in and discovered that progress is being made on the M3K port.  This is excellent news.  Thank you!

When it comes to the point where you are looking for testers, I would be more than happy to help in any way possible.   I have an M3K currently running xvortex M3K_v1.4.3_e99db03-191013.
Title: Re: Fiio M3k
Post by: bahus on November 29, 2020, 03:55:46 PM
when the "official" binaries are finally installable, they will present a different set of bugs than what you're used to.

Why there is no daily builds for this target?
I got that's it's not automatically installable - but isn't it the case for other targets like Xuelin?


I think I have a way (or one more way) of installing pretty much anything on this device now. There's nothing really Linux-specific about it, but it does involve a valid original M3K.fw. It is however very easy to patch out once discovered, assuming anyone at FiiO cares.
If I understand correctly there is some way that can be used for manual installation.
So daily builds might be useful if alexs shares his manual installation method..
Title: Re: Fiio M3k
Post by: saratoga on November 29, 2020, 06:03:31 PM
https://build.rockbox.org/data/rockbox-fiiom3k.zip
Title: Re: Fiio M3k
Post by: Njones on November 29, 2020, 08:05:03 PM
Do you load the zip file or do you unzip it first? Also do you delete the previous rockbox file first?
Title: Re: Fiio M3k
Post by: Njones on November 29, 2020, 08:21:17 PM
Nevermind updated rockbox through tools. The problem that no matter which theme I use it only fills about 1/4 of the screen.
Title: Re: Fiio M3k
Post by: speachy on November 29, 2020, 08:36:04 PM
It seems I need to repeat myself:

The port code has landed in the main rockbox repo, and builds are now being generated by the build farm.

Again, this can *not* be deployed on top of an existing xVortex port.  Please do not attempt to do so.
Title: Re: Fiio M3k
Post by: Njones on November 29, 2020, 08:45:54 PM
Does that mean Delete the previous version and then install this latest one or is this one not ready yet. Please Bear with me , I'm a 69 year old non tech savvy music lover who has used rockbox on several sansa players and the agptek Rocker.
Title: Re: Fiio M3k
Post by: vitt13 on November 30, 2020, 05:30:55 AM
1. FiiO's buildroot is based on Ingenic's Halley2 buildroot BSP. The Halley2 BSP kernel, u-boot, buildroot and other misc files can be obtained from their FTP server. Please try to mirror it if you can, ingenic has a habit of silently removing files from their FTP server: ftp://198.13.102.99/ingenic_support/X1000_X1000E_X1500/01_SW/00_Board-Level_Consolidation_Version/Kernel3.10.14_X1000_New_Version/08_ingenic-linux-kernel3.10.14-x1000-v9.0-20191212/ingenic-linux-kernel3.10.14-x1000-v9.0-20191212.tar.bz2 (http://ftp://198.13.102.99/ingenic_support/X1000_X1000E_X1500/01_SW/00_Board-Level_Consolidation_Version/Kernel3.10.14_X1000_New_Version/08_ingenic-linux-kernel3.10.14-x1000-v9.0-20191212/ingenic-linux-kernel3.10.14-x1000-v9.0-20191212.tar.bz2)
Removed... But I found the tutorial and the link on that archive http://www.ingenic.com.cn/?newsshow/tp/228/id/775.html (http://www.ingenic.com.cn/?newsshow/tp/228/id/775.html). It's on Baidu net disk.
Title: Re: Fiio M3k
Post by: alexs on November 30, 2020, 07:57:58 AM
The tool I used for getting shell access / injecting files into the rootfs. Base64 ZIP. Instructions inside.

Best I can tell, this trick should also work on M3 Pro, I have one ordered and I'll try it once it arrives.
But it's 2020 so that might be next week or next year.

Also I got my test device into the USB boot mode and it works great! but I cannot boot the system like that yet.
Title: Re: Fiio M3k
Post by: alexs on November 30, 2020, 08:26:30 AM
Removed... But I found the tutorial and the link on that archive http://www.ingenic.com.cn/?newsshow/tp/228/id/775.html (http://www.ingenic.com.cn/?newsshow/tp/228/id/775.html). It's on Baidu net disk.

The kernel itself is here: https://github.com/FiiOapp/FiiO_Kernel_M3K
They did not even bother renaminig halley2 files, so arch/mips/xburst/soc-x1000/chip-x1000/halley2 is in fact M3K.
The docs for the SoC are also easily available on Github.

Getting the rest of the SDK from Baidu would be nice though.
Title: Re: Fiio M3k
Post by: bahus on November 30, 2020, 08:33:15 AM
Base64 ZIP. Instructions inside.

Well.. That's doesn't look as simple instruction for windows user... Just in case attaching decoded txt directly to zip (just remove .txt extension from downloaded file)..
Title: Re: Fiio M3k
Post by: vitt13 on November 30, 2020, 09:50:44 AM
The tool I used for getting shell access / injecting files into the rootfs. ... Also I got my test device into the USB boot mode and it works great! but I cannot boot the system like that yet.
Nice! It would be great to steal raw content (with dd tool?) as is all the partitions to be able re-flash (be able recover) with the factory tool "USB cloner v2.5.0". We have only bootloader, kernel image and system ubi image extracted from M3K.fw.
I mean the tool I found here under "burning tools" http://www.ingenic.com.cn/en/?product/id/9/lm/4.html
Just found that Chinese page has the newest tools http://www.ingenic.com.cn/?product/id/9/lm/3.html
Someone have to find out what config we need to use with M3K.
Title: Re: Fiio M3k
Post by: alexs on November 30, 2020, 10:22:03 AM
Well.. That's doesn't look as simple instruction for windows user... Just in case attaching decoded txt directly to zip (just remove .txt extension from downloaded file)..

The only idea of a simple solution for Windows (or Mac) users I can come up with right now is to provide them with a pre-modified M3K.fw. So somebody would build Rockbox, prepare the files and put them up for download. All that on a Linux host of course. The Window users would need to transfer a couple of files onto an SD card and boot the device with the button pressed.
Title: Re: Fiio M3k
Post by: alexs on November 30, 2020, 10:33:12 AM
We have only bootloader, kernel image and system ubi image extracted from M3K.fw.

There are two more partitions there: recovery, which we also have, and userdata which doesn't containt anything important.
Keep in mind rootfs and userdata are both ubi partitions, so dd'ing them is not the best idea.

Quote
Someone have to find out what config we need to use with M3K.

One of the -sfc-nand- options. There's no NOR flash there and this device is not configured to boot from MMC.

That tool will only work with the device in bootrom / USB boot mode. There are two ways to get there: wiping the bootloader (which is what I did on my device) or soldering one of the bootconfig resistors (which should be possible but requires opening the case). Unmodified device running stock firmware will not respond to those requests.

You don't need their Windows tool either. There's a Linux package called ingenic-boot which has the tools to do all of that I think. It's for earlier Ingenic chips but it did not take much for me to make it work with x1000. It's also very simple on the Linux side, because fundamentally all it does is uploading raw code into device's RAM and letting it run there.
Title: Re: Fiio M3k
Post by: bahus on November 30, 2020, 10:46:04 AM
So somebody would build Rockbox

Well this part is already done - daily fiio m3k builds available here: https://build.rockbox.org/data/rockbox-fiiom3k.zip
Title: Re: Fiio M3k
Post by: vitt13 on November 30, 2020, 10:52:50 AM
alexs, Thank you for clarifying.
You don't need their Windows tool either.
Just a note: they also provide Linux tool.
Title: Re: Fiio M3k
Post by: vitt13 on November 30, 2020, 11:15:34 AM
alexs, I thought it should have a trick action to get fastboot mode and then use "Clone tool".
I found there is a set of action for Ingenic XBurst M200S based smart watch https://forum.xda-developers.com/smartwatch/other-smartwatches/amazfit-boot-fastboot-directly-t3546829 and how recovery it with Ingenic Clone tool https://forum.xda-developers.com/smartwatch/amazfit/tutorial-ingenic-cloner-tool-aamzfit-t3908237
but as you say it's not possible for M3K...
Title: Re: Fiio M3k
Post by: speachy on November 30, 2020, 11:39:11 AM
Well this part is already done - daily fiio m3k builds available here: https://build.rockbox.org/data/rockbox-fiiom3k.zip

That's actually updated on every commit; there are no "daily" build snapshots kept for the M3K.

But while there is a rockbox build, the necessary platform integration (ie the rockbox loader application, system scripts, etc) remains to be done.  And there's a lot of work to be done on that front -- While the loader is written, it has seen no meaningful testing, and worse yet, the m3k's underlying Linux kernel and base OS is a real hacky mess, with stuff we take for granted on every other platform simply not working. As an example of this, custom userspace code needs to be written to *shut down* the player because the kernel doesn't have the correct stuff hooked up to be able to use the standard Linux APIs that have been around for literally decades.
Title: Re: Fiio M3k
Post by: alexs on November 30, 2020, 12:15:35 PM
Well it turned out to be quite easy, although I wouldn't call Rockbox usable at this point.

Tool attached. Put the modified M3K.fw together with rockbox-fiiom3k.zip on an SD card and update the player.
The modified M3K.fw can be reused as long as .rockbox/rockbox.m3k path in the zip remains the same.

Edit: "No Rockbox directory, installation incomplete". Well that would explain things.

Edit 2: DON'T USE this script it is wrong, see below.
Title: Re: Fiio M3k
Post by: bahus on November 30, 2020, 12:59:50 PM
Well it turned out to be quite easy, although I wouldn't call Rockbox usable at this point.

Are you saying it's less usable than builds provided by XVortex? https://mega.nz/folder/0wckiIIZ#o_-7wp3aT_ob-EoxsteNqw/folder/EpVAQQ7K (M3K_v1.3.0_eef591e-190901.zip is less buggy than latest)

Can you share modified M3K.fw (using google drive or some free file sharing services like https://gofile.io/ or https://mega.nz)
Title: Re: Fiio M3k
Post by: alexs on November 30, 2020, 01:07:42 PM
Nah, I got it playing and it looks much better now.

This build wants the .rockbox directory to be on the SD card. Not in the internal rootfs where I tried to put it initially.
Title: Re: Fiio M3k
Post by: alexs on November 30, 2020, 01:32:59 PM
Ok so if the idea was to keep Rockbox completely on the SD, I can see how that could work, but I'll need some time to think how to set it up in way that would make any sense. SD cards are removable and hot-pluggable on this device.
Title: Re: Fiio M3k
Post by: bahus on November 30, 2020, 01:44:14 PM
I'll need some time to think how to set it up in way that would make any sense. SD cards are removable and hot-pluggable on this device.

That's also true for all recent Chinese targets (all xDuoo and Aigo ports, Agptek Rocker, ...) where internal memory is not exposed. All of them load rockbox from external SD - that makes rockbox update pretty easy... So I see nothing to worry about it...
Title: Re: Fiio M3k
Post by: speachy on November 30, 2020, 01:47:21 PM
Ok so if the idea was to keep Rockbox completely on the SD, I can see how that could work, but I'll need some time to think how to set it up in way that would make any sense. SD cards are removable and hot-pluggable on this device.

General approach:

1) updated rockbox launcher copied to onboard flash, and startup script modified to launch it.
2) mdev rules updated to auto mount/unmount filesystems upon hotplug.
3) fix bugs as they come up.


As an example of what we care about with (1) and (2), see https://git.rockbox.org/cgit/rockbox.git/tree/tools/hiby_patcher.pl starting around line 137.

EDIT:   The stuff targeting the m3k specifically starts on line 229.  It is _very_ incomplete.
Title: Re: Fiio M3k
Post by: alexs on November 30, 2020, 03:00:50 PM
alexs, I thought it should have a trick action to get fastboot mode and then use "Clone tool".

It might be implemented in the recovery tool. I poked around a lot with Ghidra there, but it's a pretty large piece of code and I wasn't looking for input related things. It does seem to have some input handling code even though it doesn't appear interactive at all. You might be on to something here. Or it might be just some stray code from their GUI library. Either way, it will likely take some time to find out.

I can tell for sure that the 2nd stage bootloader (x-loader) does not support fastboot, and cannot re-activate the bootrom USB mode. The only choice it makes is between the main kernel and the recovery kernel. The USB mode I was talking about is not fastboot either, it's Ingenic specific and it's much simpler than fastboot. I assumed Ingenic tools would use it over fastboot, but now that I think of it, the recovery tool was probably developed by Ingenic as well, so who knows.
Title: Re: Fiio M3k
Post by: alexs on November 30, 2020, 04:25:09 PM
Updated scripts. Should properly run rockbox from SD by copying the loader to internal storage.

Booting without SD card in the slot = USB console.
Booting with SD but no .rockbox there = FiiO player.
Booting with SD and .rockbox is there = RockBox.

Modified M3K.fw: https://gofile.io/d/giokMw

Do not forget to unpack rockbox-fiiom3k.zip onto the SD, there are no Rockbox parts in that M3K.fw.
Title: Re: Fiio M3k
Post by: bahus on November 30, 2020, 05:12:08 PM
Should properly run rockbox from SD by copying to loader to internal storage.
Cool! Thanks! I gave a quick look... Noticed issues: Shutdown doesn't work properly - button backlight is on after shutdown (need to keep power button pressed longer - backlight will be off too) ; USB storage mode doesn't work - only charges on USB insertion...
Title: Re: Fiio M3k
Post by: whiskerc on December 01, 2020, 10:42:26 AM
>Updated scripts. Should properly run rockbox from SD by copying to loader to internal storage.

Yes, clear instructions.  The M3K starts up right to Rockbox when the SD card is loaded.  Will wait to do more testing but wanted to pass on the news that it does work on another M3K.
Title: Re: Fiio M3k
Post by: vitt13 on December 01, 2020, 12:38:01 PM
It might be implemented in the recovery tool.
I've just found the IRC https://www.rockbox.org/irc/log-20200706 messages from efqw_

Quote
With Ingenic's USB Cloner tool, the entire flash can be overwritten without disassembling the device. I have already tried erasing the entire NAND and flashing back my own NAND dumps and it worked perfectly fine.

From what I can see, it loads a ~6kB u-boot SPL into the memory which does memory initialization, and then loads a pre-built u-boot binary, and this is what interacts with the cloner device from now on.

So we can replace the bootloader with u-boot or even re-partition the NAND in theory, but I'm not sure if that's worth the effort to be honest.
Unfortunately there is no detail how he got own NAND dumps.

But I still have not complete understanding how efqw_ did that. I read the X1000/E DS and flow chart shows that USB boot takes part after fail with SFC boot and MSC1 (not presented in FiiO M3K obviously) boot. It seems like SFC boot fails with presented USB connections, or he found magical button pressing set, other than
Quote
Darn it. I was trying to find the boot select pins on the FiiO M3K, and looks like I won't be able to find it unless I pull the SoC off.

boot_sel[0] (PB28) is tied to Volume Down, which is nice I guess

What I wanted was PB29, which is not defined in the source unfortunately. I could make it boot from mmc if I pull down PB29.
Title: Re: Fiio M3k
Post by: alexs on December 01, 2020, 01:26:51 PM
From what I can see, it loads a ~6kB u-boot SPL into the memory which does memory initialization

Oh ok so this what I was messing with. It can only be done if the device is in the USB boot mode. Then it would allow you to upload the SPL.

Quote
boot_sel[0] (PB28) is tied to Volume Down, which is nice I guess

OMFG I'm an idiot. Bingo! That's all you need to flash the device. No need for my unzip hack. No need for Ghidra.
It might take some work to get u-boot working and/or write something custom but it's a clear and straighforward task now.

Power the device down, then plug it into a USB host while holding vol-down button.
It will light up the buttons and enumerate as Ingenic x1000. That's the USB boot mode.

Code: [Select]
[3114458.858415] usb 1-3: new high-speed USB device number 86 using xhci_hcd
[3114459.000769] usb 1-3: New USB device found, idVendor=a108, idProduct=1000, bcdDevice= 1.00
[3114459.000775] usb 1-3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[3114459.000778] usb 1-3: Product: X\x10
[3114459.000781] usb 1-3: Manufacturer: Ingenic

Just for reference, I got to this mode by wiping the header of the NAND bootloader from Linux.
If the header is invalid, SFC boot always fails, so it proceeds to the next option which is USB.

Edit: and I was trying hold-button-power-up with each button! But apparently messed up somewhere.
Title: Re: Fiio M3k
Post by: alexs on December 01, 2020, 01:47:42 PM
Quote
What I wanted was PB29, which is not defined in the source unfortunately. I could make it boot from mmc if I pull down PB29.

Really no need for this by the way. An SPL/TPL capable of loading the next stage from SD card would be enough.

Ingenic x-loader seems to support MMC boot by the way. So it might be really easy.
u-boot is another option, although I don't think this device needs u-boot.
Title: Re: Fiio M3k
Post by: vitt13 on December 03, 2020, 02:55:25 PM
That's all you need to flash the device. No need for my unzip hack. No need for Ghidra.
It might take some work to get u-boot working and/or write something custom but it's a clear and straighforward task now.
It's clear for me now, thanks.

So, generally, running M3K port has to be close to AGPTEK Rocker port (X1000 based), right?
Let me elaborate a bit to clarify situation (please refer to https://www.rockbox.org/wiki/AgptekRocker for additional info). Agptek first loads tiny bit of binary code (SPL) into cold cache which main role is to configure PLL (aka clocks) and RAM controller. Then it loads bootloader (uboot) into ram and passes control to it. Uboot loads linux kernel either from mtd2 or mtd3 (normal kernel or recovery kernel) and passes control to linux. If it is normal boot, kernel mounts UBIFS rootfs from mtd4, if it is recovery boot, kernel loads rootfs from concatenated to itself image. Kernel (both normal and recovery) calls init process (the parent of all processes). Init runs startup scripts to run various services and finally runs hiby player binary which presents GUI for the user.

Now after this lengthy introduction - we patch normal rootfs to call rockbox bootloader binary instead of hiby player binary. So from the technical point of view we DO NOT patch bootloader (uboot) and we do not touch recovery image. This makes all process pretty safe.

And another difference is how OF file is packed.
Quote from: efqw_
efqw_   This device is very similar to the AGPTEK ROCKER in terms of hardware spec (no radio, X1000E instead of X1000, different I2S DAC, same PMU, I2C touch controls instead of a D-PAD).
efqw_   Additionally, this device is using X-Loader instead of U-Boot, and system updates are performed with a recovery partition instead.
efqw_   Firmware packages are split into ~1MB chunks and signed individually with apksign, and then zipped together along with a manifest file.
efqw_   This setup is drastically different from the hiby stuff, where the .upt file is an ISO9660 volume and the blobs are not signed.
So, XVortex has the signature cert. from FiiO Tech.Support but we have not. alexs, your unzip hack is genius and quite useful to have access on system console.

I hope my a bit off-topic messages about possible repairing/recovering are not such distracting from main target.
Title: Re: Fiio M3k
Post by: bahus on December 06, 2020, 10:51:05 AM
Hm... And only now I've noticed that XVortex also provided a way to update rockbox right from boot menu. Go to Tools -> Update rockbox (and script copies .rockbox folder from SD card to internal player storage).

Compared to XVortex latest build has following flaws (no matter how it's been installed via alexs firmware or via Tools):
1) XVortex standard theme is better adjusted (bigger fonts, playing track info in lists etc)
2) Strange shutdown behavior. In latest build you need to press shutdown button way longer. It looks like it's now two stage shutdown (first screen then backlight)
3) It looks like there is power drain when player is shut down by Idle power off or Sleep timer. Noticed few times that after full charge it's been almost dead next day when it's been shut down by idle power off after only few minutes of real use.
Title: Re: Fiio M3k
Post by: speachy on December 06, 2020, 11:07:28 AM
2) Strange shutdown behavior. In latest build you need to press shutdown button way longer. It looks like it's now two stage shutdown (first screen then backlight)
3) It looks like there is power drain when player is shut down by Idle power off or Sleep timer. Noticed few times that after full charge it's been almost dead next day when it's been shut down by idle power off after only few minutes of real use.

These are the same; the player is not getting shut down at all via software (due to the broken-ass kernel), and continuing to hold the power button eventually trips the hardware-level poweroff.

Title: Re: Fiio M3k
Post by: vitt13 on December 06, 2020, 02:11:14 PM
Do we need libSDL (generally) to use rockbox port on M3K? I see that lib was discussed in IRC, but the lib file missed in M3K OF and it presents in AGPTEK Rockr OF.
If it needs, can we bring libSDL-1.2.so.0 from Shanling M2s OF (same X1000/E) since that firmware contains many of the same lib files (in binary comparison) as M3K OF?
Title: Re: Fiio M3k
Post by: vitt13 on December 08, 2020, 01:36:53 PM
the m3k's underlying Linux kernel and base OS is a real hacky mess
I'm not a good programmer but (even for such inexperienced in Linux kernel stuff programming person like me), Fiio's AK4376 driver seems like that developer just rewrote AXP173 driver (why?) with similar realizing all that i2c communication stuffs.
https://github.com/FiiOapp/FiiO_Kernel_M3K/blob/master/sound/soc/ingenic/ocodec/ak4376.c
BTW, same picture is here (that probably is "new" version since M5 was released later and has AK4377 DAC)
https://github.com/FiiOapp/FiiO_Kernel_M5/blob/master/sound/soc/ingenic/ocodec/ak4376.c
Why did programmer not rewrote existing GPL driver from AK? It obviously exists  :-X
https://github.com/rcstar6696/android_kernel_huawei_hi3660/blob/master/drivers/huawei_platform/audio/ak4376/ak4376.c
https://github.com/LG-SD4XX/android_kernel_lge_cv1/blob/master/sound/soc/codecs/ak4376.c

---
I've just found signing tools, splitting scripts and keys in latest Ingenic's SDK ingenic-linux-kernel3.10.14-x1000-v9.0-20191212.tar.bz2 (1.49GB)
in \development\tools\ota and \ota-nand
splitting script
Title: Re: Fiio M3k
Post by: vitt13 on December 22, 2020, 12:39:59 PM
I've just got Ingenic cloner tool with suitable configs for M3K and M5 devices from FiiO's Tech.Support. The archive with tool is also contains original firmware parts (i.e. x-boot, recovery, xImage, system and data). The config is not such different that I suggested, but at least now I have complete and safe way to recover M3K. BTW, new OF has been released and new devices come with 1.4.5 OF onboard.

There is also the way to get log files form OF: just go to "System Settings"->"About M3", and quick press the hardware Play/Pause ⏯ button in the left side for several (13 for me) times until 'copy log done' notification appearing on the screen.

Then you'll find 'm3klog' folder in the root of the microSD card.
Here is mine just for reference
Title: Re: Fiio M3k
Post by: vitt13 on December 22, 2020, 02:39:54 PM
Here is the config (remove *.txt extension) for Ingenic cloner tool v2.5.0 for M3K/M5 devices.
I was worried about [nand] section, blindly making my own config. But it never mind now here is the original one.
Title: Re: Fiio M3k
Post by: vitt13 on January 03, 2021, 03:54:41 PM
If someone else is looking for X1000 PM, here is it https://raw.githubusercontent.com/xyfabc/my_books/master/X1000_PM_20160113.pdf
(btw was on ftp).
Title: Re: Fiio M3k
Post by: alexs on January 04, 2021, 04:15:57 AM
Also available here: https://github.com/JaminCheung/x-loader/tree/master/documents/cpu

That's the bootloader source, and there's some other Ingenic stuff there as well.
Title: Re: Fiio M3k
Post by: vitt13 on January 17, 2021, 05:20:39 PM
Also available here: https://github.com/JaminCheung/x-loader/tree/master/documents/cpu

That's the bootloader source, and there's some other Ingenic stuff there as well.
Nice. There's also ota tool and keys to build/re-build M3K.fw.
I successfully unpacked M3K.fw on parts (xImage, system.ubi, x-loader-pad-with-sleep-lib.bin) and then rebuild M3K.fw with the same signed numbers of updateNNN.zip.
Here is my dirty windows standalone package I built with PyInstaller https://github.com/VitToCode/linux-recovery-ota/releases/tag/1.0
but Linux users directed to JaminCheung original repo.
Title: Re: Fiio M3k
Post by: speachy on January 18, 2021, 10:59:45 PM
I just finished a little poking around the 1.4.5 m3k update, trying to get an idea what was actually changed.

1) there's an updated kernel build (no idea what actually changed, as the sources they've released (in 2018-12) don't seem to correspond to any of the binary builds.
2) Startup script recreates /data partition if it's busted  (responsible for the "welcome screen" hang)
3) New player binary

I doubt any of the general platform jankiness has been fixed.
Title: Re: Fiio M3k
Post by: ZoRG172 on January 21, 2021, 11:31:10 AM
Does this mean that dev builds of Rockbox for M3K we will not see in the near future?
Title: Re: Fiio M3k
Post by: FroggestSpirit on January 25, 2021, 09:32:57 PM
I looked into building the kernel from the FiioApp github, but I wasn't able to (I think it requires a gcc 5 or lower for mipsel). I downloaded the newest version of buildroot from the official github, and was able to build this sucessfully. I believe they recently added Ingenic Xburst (X1000) in the kernel. I'm not really sure what to do with the generated images though, otherwise I was going to try injecting the newly built kernel.
Title: Re: Fiio M3k
Post by: vitt13 on January 26, 2021, 01:24:24 AM
I looked into building the kernel from the FiioApp github, but I wasn't able to (I think it requires a gcc 5 or lower for mipsel).
Look at M5 kernel source https://github.com/FiiOapp/FiiO_Kernel_M5 and compare it with M3K. M5 sources is almost complete but just missing *.S files. And correct ak4376 driver is also there (https://github.com/FiiOapp/FiiO_Kernel_M5/tree/master/sound/soc/ingenic/ocodec). Just recover needed *.S files and can build the M5 kernel. I use prebuilded mips-gcc472-glibc216 toolchain from Ingenic (also on github).
I started with it I thought it might be helpful to rebuild recovery image (xImage with glued ramdisk) with patched 'recovery' (fw update) utility to pass through the unsigned update archives. Since we found on github the correct pair of signing keys from Ingenic developer, now we can build M3K.fw like genuine ones. BTW M5 original firmware built with the different private key but same public key and I'm trying to work around bypass the signature check on M5 device for my friend.
Title: Re: Fiio M3k
Post by: FroggestSpirit on January 27, 2021, 10:35:36 PM
Here's what I got so far to build the kernel:
Download the Halley2 dev stuff here: ftp://grids.be/../mirror/ftp.ingenic.cn/DevSupport/Platform/Halley2/
There's some instructions here: http://www.ingenic.com.cn/en/?newsshow/tp/228/id/108.html
Instead of using "make halley_linux_defconfig" I attached a copy of the .config file that can be used for building the kernel (Mostly from the M5 repo, but modified) rename it to .config

Build the u-boot in the platform/u-boot folder with "make halley_uImage_spinor"
copy "platform/u-boot/tools/mkimage" to the bin folder of the mips cross compiler, and rename it to "mips-linux-gnu-mkimage"
build the kernel in the platform/kernel folder with "make uImage"

I didn't test this yet, but it will build a uImage.
Keep in mind this does not include the AK4376 driver, so that will need to be adapted

EDIT: I wasn't able to get this to boot with the USBFlasher, but if anyone tries, make sure to have a backup handy first. All my attempts bricked it, so I needed to restore from a backup
Title: Re: Fiio M3k
Post by: vitt13 on January 28, 2021, 06:38:00 AM
Here's what I got so far to build the kernel:
...
EDIT: I wasn't able to get this to boot with the USBFlasher, but if anyone tries, make sure to have a backup handy first. All my attempts bricked it, so I needed to restore from a backup
You're going the wrong way.
Here the kernel build environment I recreated from FiiO M5 kernel sources https://github.com/VitToCode/FiiO_Kernel_M5
you just need that and the toolchain.
Rebuilded xImage and recovery has been flashed and tested on M5 device. BTW I use x-loader from original firmware.
Note: if you going to flash only specific partition (i.e. xImage) make sure you uncheck "All erase" setting on SFC tab USB Cloner Tools's.
If you are looking for latest Ingenic Halley2 kernel source, you can find it here http://www.ingenic.com.cn/en/?product/id/9/lm/4.html
Just scroll down to 'Downloads'. Latest version is 'ingenic-linux-kernel3.10.14-x1000-v9.0-20191212.tar.bz2'
Title: Re: Fiio M3k
Post by: FroggestSpirit on January 31, 2021, 02:19:17 PM
Thank you for pointing me in the right direction. I created a repo with a working M3K kernel build, which built off of your repo (thank you!).
This one should be all self contained, the toolchain is included, and all that should need to be done (assuming you have the needed dependancies), is to run build.sh (I did testing in x64 Linux)
https://github.com/froggestspirit/FiiO_M3K_Kernel
I removed a few things from the build that shouldn't be needed, like other archetectures and wireless stuff. From my tests, the kernel worked as normal while using XVortex's rockbox build, although there were a couple SD card issues on the OFW, though I'm not sure if that was user error.
Title: Re: Fiio M3k
Post by: Richie325 on February 09, 2021, 11:05:26 AM
I have been using rockbox on this device for over 2 weeks now. I noticed that the voice in the right earphone is a bit distorted and the left earphone is clear(If you change the balance and listen to only one side you will notice it). I tried different headphones and earphones as well. This issue is not present when i boot to the stock OS.
Title: Re: Fiio M3k
Post by: FroggestSpirit on February 09, 2021, 06:08:30 PM
I've updated the kernel on my github for anyone interested.
https://github.com/froggestspirit/FiiO_M3K_Kernel/releases/tag/v1.01
As I mentioned, I don't know if I'll be working too much more on the kernel itself, but the code is there if anyone wants to pick it up.
Title: Re: Fiio M3k
Post by: Thew on February 10, 2021, 02:59:11 PM
I have been using rockbox on this device for over 2 weeks now. I noticed that the voice in the right earphone is a bit distorted and the left earphone is clear(If you change the balance and listen to only one side you will notice it). I tried different headphones and earphones as well. This issue is not present when i boot to the stock OS.

I've tried many different files and listened very carefully as you suggest but I can't hear any distortion on my Rockboxed M3K.
Title: Re: Fiio M3k
Post by: diegopau on February 12, 2021, 10:13:23 AM
I've updated the kernel on my github for anyone interested.
https://github.com/froggestspirit/FiiO_M3K_Kernel/releases/tag/v1.01
As I mentioned, I don't know if I'll be working too much more on the kernel itself, but the code is there if anyone wants to pick it up.

In this post https://forums.rockbox.org/index.php/topic,52917.msg246172.html#msg246172 efqw explained that "The main player application is aggressively logging to /data/userfs/app.log. I'm really concerned about this wearing out my NAND", is that fixed in that new version of the kernel?
Title: Re: Fiio M3k
Post by: vitt13 on February 12, 2021, 11:22:35 AM
"The main player application is aggressively logging to /data/userfs/app.log. I'm really concerned about this wearing out my NAND", is that fixed in that new version of the kernel?
It's not kernel issue, it's stock player application issue. It relates to firmware (rootfs image) modifications but not to kernel or rockbox.
Title: Re: Fiio M3k
Post by: heyspencerb on February 28, 2021, 04:12:02 PM
I followed alexs's instructions and installed the newest version. The bug of not being able to scroll up on the search input is still the same.

The problem is only being able to move down, left and right, so that if you miss your letter you have to scroll all the way around to it in order to pick it again. Is there any fix to this? Thanks
Title: Re: Fiio M3k
Post by: heyspencerb on February 28, 2021, 04:35:17 PM
Wow, Ok! I should have listened to the warnings in this thread! Gonna post my experience here so others know not to install this version yet.

I have been using the Vortex version for a few weeks and it works great except for some minor bugs like scrubbing through songs and not being able to scroll up while typing text. I wanted to see how the development was going so I followed this thread and installed the latest version of RockBox, that was a mistake!

The current version has a fix for the scrubbing issue, but the search issue is still there, and is honestly worse because now the letters are all on one page and very tiny.

But most of all, this version auto logs you into Rockbox without any option of going to the Fiio version, and the ability to access the device from a computer is totally broken. I don't have an SD card reader so this means I have literally no way to add new music, get to the USB DAC or fix this in any way until I get a reader. I can't go back to the other version because I can't remove the Rockbox files from the SD because file access is broken.

Thanks everyone for working on this, definitely my fault for installing unfinished software, but to people wondering if they should install this, don't do it yet! For now, the Vortex version is in a much better state as it actually lets you go back to the official firmware without an SD card reader. Good luck everyone!
Title: Re: Fiio M3k
Post by: speachy on February 28, 2021, 07:36:38 PM
Wow, Ok! I should have listened to the warnings in this thread! Gonna post my experience here so others know not to install this version yet.

There's a reason it's listed as "unusable" on the main rockbox web page.

(Or more accurately, _many_ reasons...)
Title: Re: Fiio M3k
Post by: heyspencerb on February 28, 2021, 08:52:01 PM
At least it motivated me to try compiling this myself. Gonna see if I can fix up the search menu bug and reorganize the letters in a better way, seeing as the search isn't case sensitive so I really only need one set of the letters.

So far I've changed the calculator labels to say "D I D  T H I S  W O R K" so I have a long way to go lol
Title: Re: Fiio M3k
Post by: heyspencerb on March 01, 2021, 09:21:37 PM
Hey!

I solved the bug of not being able to scroll up in text entry on the Fiio M3K! Someone literally just forgot to add the code to enable "ACTION_KBD_UP".

The problem was totally fixed for me if I add this line:
Code: [Select]
    { ACTION_KBD_UP,          BUTTON_UP,                        BUTTON_NONE },
    { ACTION_KBD_UP,          BUTTON_UP|BUTTON_REPEAT,          BUTTON_NONE },

Before line 100 in the file apps/keymaps/keymap-fiiom3klinux.c

Can someone check my work? I'm not set up to submit code yet, this is my first time ever working on an open source project. Let me know if this looks good and also fixes it for other people!
Title: Re: Fiio M3k
Post by: speachy on March 01, 2021, 09:28:06 PM
That looks good!

If you'd like to take this all the way thorough and submit a patch, you can do that via the bug tracker or through gerrit directly (see https://www.rockbox.org/wiki/UsingGit for how to set it up)  Otherwise I'll be happy to do it for you.

(We will need your legal name to accept a patch, FYI)
Title: Re: Fiio M3k
Post by: heyspencerb on March 01, 2021, 10:03:02 PM
Awesome! If possible I'd love to submit it! It would be my first accepted code.

I followed the guide for submitting and added my ssh key but when I ran the test I got this error:

Permission denied (publickey)
Title: Re: Fiio M3k
Post by: heyspencerb on March 01, 2021, 10:47:53 PM
Fixed the issue! Just submitted for review, thanks!

https://gerrit.rockbox.org/r/c/rockbox/+/3147

Here is the link to the change if you'd be willing to review it!
Title: Re: Fiio M3k
Post by: gperius on March 05, 2021, 08:55:16 PM
Hi, can I flash the 1.4.3 firmware if I'm running 1.4.5? That means can I downgrade?
Title: Re: Fiio M3k
Post by: KarlJ on March 05, 2021, 09:15:13 PM
Hi, can I flash the 1.4.3 firmware if I'm running 1.4.5? That means can I downgrade?
yep ,you can downgrade to any version if u want to
Title: Re: Fiio M3k
Post by: gperius on March 05, 2021, 09:41:54 PM
yep ,you can downgrade to any version if u want to
So I can remove rockbox completely if I want or anything goes wrong by installing the original fw?
Title: Re: Fiio M3k
Post by: Thew on March 06, 2021, 05:30:38 AM
So I can remove rockbox completely if I want or anything goes wrong by installing the original fw?

Yes, I've done it several times with no problems.
Title: Re: Fiio M3k
Post by: JosephM on March 09, 2021, 01:04:16 PM
Seems like the Fiio M3 Pro is the new hot budget player. Anyone messing around with it or is it similar to the M3k?

I just got one and have started messing around with it. There does seem to be one advantage to it: you can trivially get a connection over Android Debug Bridge (even though it's not Android). If you put a file named M3Pro20200418.bin in the root of the micro sd card, it adds an extra tools menu in settings. Once you do that you can put it in USB DAC mode, plug it into your computer, swipe from the left side of the screen to exit DAC mode, go to settings, go to the new tools option, select the 3rd option, then press the option labeled ADB.  Then it shows up on your computer as a Nexus 4, and you've got a root shell. Any changes you make to the system persist across reboots.
Title: Re: Fiio M3k
Post by: RockBoxNewB on March 12, 2021, 05:30:43 PM
Hi everyone!
First of all, thanks to all of you for your helpful insights. I bought myself a FiiO M3K simply because I found out there is a Rockbox port for it. Of course, I am aware that it is still experimental, but curiosity got the better of me.
I've got a simple, possibly stupid, question: How do you revert to an earlier version of the XVorteX rockbox port? I installed the latest one based on 1.4.3, but wanted to try out 1.3.0. I extracted the ZIP for it, placed the .fw file on the root of my SD, selected "Tools" - "Update Rockbox" - but nothing changed, it still boots up the M3K_v1.4.3_e99db03-191013. What am I doing wrong?

Thanks a lot in advance!
Title: Re: Fiio M3k
Post by: Thew on March 13, 2021, 03:46:35 AM
You need to load the old file as you would any Firmware ie: booting up with the Volume + power button. The older version of Rockbox is included in the older Firmware. It doesn't load as an update.
Title: Re: Fiio M3k
Post by: RockBoxNewB on March 13, 2021, 10:42:05 AM
You need to load the old file as you would any Firmware ie: booting up with the Volume + power button. The older version of Rockbox is included in the older Firmware. It doesn't load as an update.

That did the trick, thanks a ton! I already feared I killed my M3K because I created a bootloop by trying to update - but the Vol + and Power combination saved the day and allowed me to roll back. Amazing!
Title: Re: Fiio M3k
Post by: DJKZ on March 24, 2021, 10:59:12 PM
Hi All ,
Been Rockbox'n for a few years now .
have sucessfully installed on Sansa Fuze V2 ,,
Sansa c200 , and iPod nano 2nd Gen .
Was all pretty easy using rockbox directions .
On the FiiO M3K , ( May purchase one soon )
1 - Must you update to the NEWEST firmware
on the M3K first , before installing RockBox ?
2 - Is there a certain firmware number that
works the best ?
( asking because with all my previous install's on
my players ,,, they had said what firmware version
the unit should be using )
Thanks to ALL for any info .
.... update ....
I see when reading post from XVortex from 9/1/2019 ,,
the install was based on FW v1.3.0   .
Has recent owners of the M3K's installed Rockbox
with this firmware ,,,,, or If a M3K is purchased now
( being almost 2 years from XVortex post ) is the player
now shipped with a newer firmware installed ? ,,,, and
if so ,,,,, will the Rockbox install still work ?
Thanks again .
Title: Re: Fiio M3k
Post by: Thew on March 25, 2021, 04:15:49 AM
It doesn’t matter what version of the the firmware is installed on the M3K as it is replaced by a special version that includes Rockbox. XVortex’s last update loads Firmware 1.4.3. There is no version of XVortex’s update that includes the latest original firmware (1.4.5) but the differences are very small. After the update can choose at start-up whether to boot Rockbox (e99db03-191013) or the Fiio OS (1.4.3 VTX).
Title: Re: Fiio M3k
Post by: Richie325 on March 26, 2021, 05:50:53 AM
Can the fix for scrolling up while typing to search a file in the search section be added to Vortex's rockbox build?
Title: Re: Fiio M3k
Post by: Bilgus on March 29, 2021, 02:43:00 PM
We will not be fixing problems in others unofficial builds

Thanks
Title: Re: Fiio M3k
Post by: heyspencerb on March 30, 2021, 03:02:39 PM
Can the fix for scrolling up while typing to search a file in the search section be added to Vortex's rockbox build?

I actually have a solution to this! Can't believe I didn't try this earlier, but you can use Vortex's M3K.fw file and the most current version of Rockbox at the same time. This way you get most of the best of both worlds, you can switch easily between RockBox and the official firmware, and you get all of the fixes from the most recent version of RockBox.

If you want this to work you need to follow these exact steps. This is the only way I have gotten this to work.

1. Go to this link: https://www.dropbox.com/s/vuqcaf1ssk4j1ee/Files.zip?dl=0
 and download the zip file I uploaded there. I am posting a dropbox link because its too big to upload here, let me know if thats not the best way to do this.

2. Un-zip the file. You might only see one file, called M3K.fw, but there is actually two files, the M3K.fw and a hidden directory called '.rockbox'. To see it, on Mac press Cmd+Shift+[.]  and on Ubuntu press control+h I have no idea how to see it on windows, but if you can't see it you can always extract the zip directly to the right location in step 4.

3. Take your sd card you have formatted with the Fiio M3K and plug it into your computer

4. Drag or directly extract both the provided M3k.fw and the .rockbox directory into the home directory on the sd card, so not in any folders. Make sure the files are out of the 'Files' folder I sent them in, they need to be in the home directory on the sd. If you left the official M3K.fw file on the SD, you will need to replace it with the one I provided.

5. Put the SD back in your M3K while its turned off, and press and hold the 'power button' + 'volume up' until the firmware update starts.

6. once the update is done if things went properly, you should get a screen which will offer you either log in to Rockbox, the Fiio firmware, or a settings menu and there will be a countdown. Quickly navigate to the settings menu and enter it. If you miss the timing and log in to either of the other options, restart the device and be sure to go to the settings menu this time. Once in the setting menu, click on "Update Rockbox". This should then go to a screen which says 'Running update.sh ' for a few minutes, then it will say 'Done: 1'.

7. Finally, at this point you can restart the device and you should have the correct version of Rockbox, and the option of switching to the Fiio firmware as well.

If you later want to update the Rockbox version to a new version, you need to do all the same steps but replace the .rockbox file I gave you with the new one you want to use.
Important! in order to update the rockbox, you still need to go through steps 5 and 6! For some reason, you need to do the 'power button' + 'volume up' in order to update the RockBox version too!!

Finally, here are my necessary warnings:
This version of RockBox fixes some bugs in the Vortex version, like seeking, scrolling up, using the top button as a lock button and a few other things, but it introduces a bunch of new issues too!

Some of the bugs this version has that Vortex's does not have:
We do not yet know how to fully turn the device, so right now if you "shut down" in rockbox mode the keypad stays on and the device rapidly loses battery. The only fix to this is to hold the power down for about 8 seconds to trigger the hardware power off whenever you want to turn it off.

I don't personally like how the text entry is laid out in this version with super tiny letters, so I am personally working on a much better entry system. Let me know if you want me to share that version too.

So, if you want to try this, understand that it is still under development and to solve some issues, some other issues are created.
If you want to go back to the standard firmware permanently, delete the M3K.fw file, and the .rockbox directory, remembering that it is a hidden directory so it might not actually be deleted properly if you can't see it, then download the official version on the Fiio site and follow step 5.

Pease give me feedback on this process and let me know if it doesn't work for others, I will try and respond as best as I can. Also, If im breaking rules, let me know
Title: Re: Fiio M3k
Post by: Thew on March 31, 2021, 06:12:41 AM
Can the fix for scrolling up while typing to search a file in the search section be added to Vortex's rockbox build?

Pease give me feedback on this process and let me know if it doesn't work for others, I will try and respond as best as I can. Also, If im breaking rules, let me know

I did try your amended version of Rockbox but swapped back to the version I had before. My main problem was that I couldn’t get my own custom Theme to work (I don’t use or need the search function).

I’m pleased with my Theme and the 18-DejaVuSans.fnt provides a much improved look and readability for me at least.

https://i.postimg.cc/jSTrVBCh/M3K.jpg
Title: Re: Fiio M3k
Post by: ZoRG172 on March 31, 2021, 12:45:50 PM
heyspencerb
I flashed it according to your instructions. Everything worked out! Now the rewind is working, what was most annoying in the vortex port. The player has been idle since summer, so thank you very much!

But there is a problem with the Advanced Key lock function. The device perceives the mechanical play key and the touch key as one and responds to both. Therefore, only the volume buttons can actually be left unlocked. In addition, the player turns on the backlight when you touch any touch button, even if you turn off the lock messages.

I have seen the "Disable Touch" feature in the Advanced Key lock settings on other players, but this version does not. Can this be returned? Or change it in the Advanced Key lock settings so that the signals from the sensor module are completely ignored when the lock is active?
possible to somehow change in the smart blocking settings so that the signals from the sensor module are completely ignored when the blocking is active?
Title: Re: Fiio M3k
Post by: heyspencerb on March 31, 2021, 02:12:30 PM
heyspencerb
But there is a problem with the Advanced Key lock function. The device perceives the mechanical play key and the touch key as one and responds to both. Therefore, only the volume buttons can actually be left unlocked. In addition, the player turns on the backlight when you touch any touch button, even if you turn off the lock messages.

I'm glad it worked out for you! As for the other points, Huh! I had never actually seen the 'Advanced Key Lock' setting before, thats really helpful, learn something new every day. To your point about the center button and side button both being counted as the same, this is a frustration I have for the whole program. I personally think that side button should always be play/pause the same way the volume buttons always maintain the whole function. I am close to hacking this function into my own personal branch, but a proper solution with this as an option in the settings would take more work and time. And the backlight turning on isn't so much a bug as a feature that maybe not everyone likes. I personally like being able to click any button in order to see what's playing currently without changing anything. but this should be made as a setting that can be changed because I can see how not everyone would like that and you should be able to change that.
 
Long story short, to both the Key Lock problem and the backlight problem, see my warning at the end of the last message; this is software that is under constant revision so to fix some bugs, you have to accept new ones. The only way I've found to get it "perfect" is to start compiling it yourself and hacking together the changes you want on your personal branch. If thats not for you, my recommendation is file a bug report on the left side of the site and myself or others might get around to it soon if we also think it's a big deal. I'll say that I personally have been thinking of looking at the center button/side button annoyance so that has a decent chance of getting worked on soon.

EDIT:
I found the issue of why that menu option is gone, and I will test it and hopefully submit a pull request with it tomorrow!
Title: Re: Fiio M3k
Post by: ZoRG172 on March 31, 2021, 03:51:39 PM
To your point about the center button and side button both being counted as the same, this is a frustration I have for the whole program. I personally think that side button should always be play/pause the same way the volume buttons always maintain the whole function. I am close to hacking this function into my own personal branch, but a proper solution with this as an option in the settings would take more work and time.

This functionality is already in the rockbox and it works, you can only block the touch buttons. It's just that this build does not have a menu item: "Disable Touch
Blocks touch screen buttons like the original (only for touch devices) "
Which would solve the problem of the play button.

(http://forums.rockbox.org/index.php?action=dlattach;topic=51589.0;attach=7029;image)

If you activate Advanced Key lock in the settings and select so that the volume buttons are not locked, variables appear in config.cfg:

No Screen Lock For Selected Actions: on
Selective Screen Lock Actions: 545

It may well be that it is enough just to add the required variable to the config to activate Disable Touch, but I don’t know where to look.

I found this thread on this matter https://forums.rockbox.org/index.php?topic=51589.0
Title: Re: Fiio M3k
Post by: heyspencerb on March 31, 2021, 10:49:22 PM
This functionality is already in the rockbox and it works, you can only block the touch buttons.

Awesome! For my part, I was talking more generally about being able to always use the side button as play/pause and the middle as the selector. So far, I found this in the file 'keymap-fiiom3klinux.c'
Code: [Select]
static const struct button_mapping button_context_standard[] = {
    { ACTION_STD_PREV,        BUTTON_UP,                        BUTTON_NONE },
    { ACTION_STD_PREV,        BUTTON_PREV,                      BUTTON_NONE },
    { ACTION_STD_PREVREPEAT,  BUTTON_PREV|BUTTON_REPEAT,        BUTTON_NONE },
    { ACTION_STD_NEXT,        BUTTON_DOWN,                      BUTTON_NONE },
    { ACTION_STD_NEXT,        BUTTON_NEXT,                      BUTTON_NONE },
    { ACTION_STD_NEXTREPEAT,  BUTTON_NEXT|BUTTON_REPEAT,        BUTTON_NONE },
    { ACTION_STD_CONTEXT,     BUTTON_PLAY|BUTTON_REPEAT,        BUTTON_PLAY },
    { ACTION_STD_CANCEL,      BUTTON_HOME|BUTTON_REL,           BUTTON_HOME },
    { ACTION_STD_OK,          BUTTON_PLAY|BUTTON_REL,           BUTTON_PLAY },
    { ACTION_STD_MENU,        BUTTON_OPTION|BUTTON_REL,         BUTTON_OPTION },

    LAST_ITEM_IN_LIST
}; /* button_context_standard */

Along with other context base key bindings. I think if I went through and just changed BUTTON_PLAY to be the play action in all the context arrays it would get the change I want, but that is definitely not a long term solution and is a hacked fix. I might double check that this feature doesn't already exist then see how hard it is to add a new settings feature and maybe make it so that the buttons action in each context could be set or chosen? That way you could really customize the hell out of your buttons. But, thats definitely not a small project lol. But basically a settings tab that then lists each context, then you can choose which button you want to change and then change what that button should do maybe...
Title: Re: Fiio M3k
Post by: heyspencerb on March 31, 2021, 11:14:31 PM
It may well be that it is enough just to add the required variable to the config to activate Disable Touch, but I don’t know where to look.

I think I found it! And this might actually be a pretty simple and fun bug fix! Here is the code that either shows or doesn't show that menu item, its on line 80 of settings_menu.c

Code: [Select]
static int selectivesoftlock_set_mask(void* param)
{
    (void)param;
int mask = global_settings.bt_selective_softlock_actions_mask;
            struct s_mask_items maskitems[]={
                                       {ID2P(LANG_VOLUME)     , SEL_ACTION_VOL},
                                       {ID2P(LANG_ACTION_PLAY), SEL_ACTION_PLAY},
                                       {ID2P(LANG_ACTION_SEEK), SEL_ACTION_SEEK},
                                       {ID2P(LANG_ACTION_SKIP), SEL_ACTION_SKIP},
 #ifdef HAVE_BACKLIGHT
                            {ID2P(LANG_ACTION_AUTOLOCK_ON), SEL_ACTION_AUTOLOCK},
 #endif
 #if defined(HAVE_TOUCHPAD) || defined(HAVE_TOUCHSCREEN)
                        {ID2P(LANG_ACTION_DISABLE_TOUCH) , SEL_ACTION_NOTOUCH},
 #endif
                         {ID2P(LANG_ACTION_DISABLE_NOTIFY), SEL_ACTION_NONOTIFY}
                                            };

            mask = mask_select(mask, ID2P(LANG_SOFTLOCK_SELECTIVE)
                               , maskitems,ARRAYLEN(maskitems));

            if (mask == SEL_ACTION_NONE)
                global_settings.bt_selective_softlock_actions = false;
            else if (global_settings.bt_selective_softlock_actions_mask != mask)
                global_settings.bt_selective_softlock_actions = true;

            global_settings.bt_selective_softlock_actions_mask = mask;

    return true;
}

It looks like someone chose not to consider the front menu buttons on the M3K to be HAVE_TOUCHPAD, so those menu items aren't defined. I can take a look through and try and add that in, which should hopefully open those options up!

EDIT:
Found the file where I need to add#define HAVE_TOUCHPAD to enable this, but I don't have time tonight to do it, test it, and then submit the pull request but I will try and do it in the morning if everything works out
Title: Re: Fiio M3k
Post by: speachy on April 01, 2021, 07:54:32 AM
Found the file where I need to add#define HAVE_TOUCHPAD to enable this, but I don't have time tonight to do it, test it, and then submit the pull request but I will try and do it in the morning if everything works out

It's more complicated than adding HAVE_TOUCHPAD.  But this should do the trick:

https://gerrit.rockbox.org/r/c/rockbox/+/3270

Title: Re: Fiio M3k
Post by: heyspencerb on April 01, 2021, 09:55:49 AM
Awesome! I'll pull it and test it! And ZoRG172, once its merged in the new .rockbox file should be here:  https://build.rockbox.org/data/rockbox-fiiom3klinux.zip, use it in place of the one I provided but follow the same steps as before.

Edit:
Corrected the link because I have no idea what I'm talking about
Title: Re: Fiio M3k
Post by: speachy on April 01, 2021, 10:11:07 AM
Awesome! I'll pull it and test it! And ZoRG172, once its merged in the new .rockbox file should be here: https://build.rockbox.org/data/rockbox-fiiom3k.zip, use it in place of the one I provided but follow the same steps as before.

No, that is the wrong link.  This is the correct one: https://build.rockbox.org/data/rockbox-fiiom3klinux.zip

There are now two M3K ports, neither is really considered usable -- the Linux-based one based on the xvortex code dump (running on top of the extremely buggy FiiO linux platform) and a new native bare-metal port that is where all of the ongoing development effort is focused.  Once the latter is considered usable (it currently lacks such niceties like USB and dual-boot capabilities) the linux-based port will most likely be nuked from orbit.
Title: Re: Fiio M3k
Post by: heyspencerb on April 01, 2021, 11:13:08 AM
Does the new bare-metal port use the same config files as the linux one? For instance, I rebased but I still only see fiiom3klinux.h under the config directory and nothing for the new version. Are they going to share these files until the linux one is killed, then the names will be changed? Or am I just missing the bare-metal versions.
I'm mostly wondering if some of the same issues that have been fixed on the linux version (ie.  the scrolling up issues and such) will need to be fixed again on the new version, or if the fixes will be carried over?
Title: Re: Fiio M3k
Post by: speachy on April 01, 2021, 11:21:16 AM
Nope, there is nothing shared between those two ports.

(and firmware/export/config/fiiom3k.h landed back into the repo on March 28th -- are you sure you're tracking the master branch?)

Title: Re: Fiio M3k
Post by: heyspencerb on April 01, 2021, 11:38:56 AM
I'll double check to make sure, it might explain a lot if I'm not. Side note, when running ./rockboxdev.sh what is the target arch for the bare-metal port? Is it mips or mips-linux? Thanks

Edit:
Found fiiom3k.h in firmware/export/config/, I think my VS code hadn't updated the file list when I pulled.
Title: Re: Fiio M3k
Post by: heyspencerb on April 01, 2021, 01:49:01 PM
Figured it out! Followed the install instructions and got the bare-metal version working. But yeah those instructions are definitely not beginner friendly.

This version runs much faster than the other one though, it boots fast and the database build is a lot better and faster. Though the build definitely has some issues to get started on. The slide to scroll seems to only work in some places, and in others you need to tap to scroll, among other things. I'll look through the bug reports and submit a few as I find more issues.
Title: Re: Fiio M3k
Post by: ZoRG172 on April 01, 2021, 03:01:10 PM
Awesome! I'll pull it and test it! And ZoRG172, once its merged in the new .rockbox file should be here:  https://build.rockbox.org/data/rockbox-fiiom3klinux.zip, use it in place of the one I provided but follow the same steps as before.

Edit:
Corrected the link because I have no idea what I'm talking about
I flashed build from the link, but the menu item did not appear. How do you know or where to track when changes are made?
Title: Re: Fiio M3k
Post by: heyspencerb on April 01, 2021, 08:14:11 PM
I flashed build from the link, but the menu item did not appear. How do you know or where to track when changes are made?

if you look at the link he sent, this change hasn't been reviewed yet.
https://gerrit.rockbox.org/r/c/rockbox/+/3270

 Typically simple changes like this get accepted within a day or two. More generally, if you are really interested in what features are coming up you can go to this link and see what other changes have been submitted but not reviewed yet. It should give you an idea of just how often changes happen in the code base, though most of the changes are specific to other platforms and won't effect you.

https://gerrit.rockbox.org/r/q/status:open
Title: Re: Fiio M3k
Post by: speachy on April 01, 2021, 08:35:20 PM
if you look at the link he sent, this change hasn't been reviewed yet.
https://gerrit.rockbox.org/r/c/rockbox/+/3270

The reason this isn't committed is that I don't know that it works properly.  That's not something I can determine on my own.

(Basically I don't know if I'm disabling the correct input device when the touchpad is "locked" -- 50/50 chance I got it right.  Assuming the rest of the changes are correct, which isn't a given)

Title: Re: Fiio M3k
Post by: ZoRG172 on April 02, 2021, 03:41:49 PM
if you look at the link he sent, this change hasn't been reviewed yet.
https://gerrit.rockbox.org/r/c/rockbox/+/3270

The reason this isn't committed is that I don't know that it works properly.  That's not something I can determine on my own.

(Basically I don't know if I'm disabling the correct input device when the touchpad is "locked" -- 50/50 chance I got it right.  Assuming the rest of the changes are correct, which isn't a given)
Send me a test build and I'll check if it works as expected.
Title: Re: Fiio M3k
Post by: amachronic on April 02, 2021, 03:51:18 PM
Hello, developer of the new M3K port here. Thought I'd chime in since somebody was enterprising enough to try the new native port already!

heyspencerb, I'm glad to hear you got it running. If you find any bugs -- especially major ones -- please do report them on the tracker, I can use all the help I can get with testing. The issue you described with the scrollbar is a known problem (for me), especially in the plugins -- the keymaps are a mess, some places only accept scrollbar and some places only accept tapping, but for the most part it should be simple to fix.

I'm actively working on streamlining the bootloader install but it will be Linux-only for a bit. Hopefully I should be able to get that done this weekend.
Title: Re: Fiio M3k
Post by: dconrad on April 02, 2021, 10:04:30 PM
I tried to follow the m3k native install instructions and managed to not only get my unit to a non-working state, but I can't boot over USB anymore. Any chance of help?

I successfully booted over USB, dumped the bootloader (presumably successfully), patched it (probably unsuccessfully?), booted over USB again, installed it, and now I just get a single keypad blink, and that's all the life it shows.

Attempting to boot over USB now gives the output:

Code: [Select]
# ./usbboot -v -c x1000 -1 ../../build-spl/spl.m3k --wait 1 -2 ../../build/rockbox.bin
Opening USB device a108:1000
Issue SET_DATA_ADDRESS 0xf4001000
Transfer 8632 bytes from host to device
Issue PROGRAM_START1 0xf4001800
Wait 1 seconds
Issue SET_DATA_ADDRESS 0x80004000
Request SET_DATA_ADDRESS failed: -7

If I boot without the SD card in place, I do get the screen to light up and say "No SD card present", so the bootloader is there in some capacity, I think.

If you wouldn't mind helping me out that would be great! I can get on IRC if that's the easiest way.
Title: Re: Fiio M3k
Post by: Thew on April 03, 2021, 04:10:18 AM
I tried to follow the m3k native install instructions and managed to not only get my unit to a non-working state, but I can't boot over USB anymore. Any chance of help?

Have you tried over flashing with the original Fiio Firmware? i.e. having the Fiio Firmware on the SD Card and starting up with the “on” key plus “Volume+” key.
Title: Re: Fiio M3k
Post by: amachronic on April 03, 2021, 08:42:07 AM
dconrad, the good news is if the bootloader can display "No SD Card", the flash should be okay. If you can send me the original and patched NAND dumps then I can double check them for you.

Apologies that I didn't mention this on the wiki  :-[, but if the machine hangs you need to hold the power button for AT LEAST 15-20 seconds to be sure you've forced a power off. It can still be powered on even if all the lights are off. If the device feels warm then let it cool down for 10-15 minutes before you try USB boot again. That might just fix the problem -- I ran into this a few times during development, but it was quite rare for me.

If "cooling down" doesn't help, you could try another SD card in case Rockbox doesn't like yours. Or assuming your original NAND dump is good, you can pull the SPL out of it and see if the original firmware boots:

Code: [Select]
dd if=boot.dump of=xloader.bin bs=1024 count=12
./usbboot -v -c x1000 -1 xloader.bin

(NB. if you're not using the XVortex build you will have to pull out the USB immediately when the backlight comes on or Fiio's player will just go straight to the charging screen.)

Let me know what happens after trying all of this. I'll be on IRC today, in case you're still having problems we can debug it further.

If you really want to, you can get into the recovery by holding "Volume Up" while booting xloader.bin, but there's a chance it'll make the problem worse. So I wouldn't advise it unless you're desperate.
Title: Re: Fiio M3k
Post by: dconrad on April 03, 2021, 10:07:59 AM
Thanks a bunch for the stuff to try!

I had already figured that the power button needs to be held for a long time in order to fully power it off - no change if I hold it for a full 20 seconds, so that's probably not it. As long as the keypad lights up when I plug in the USB cord while holding volume down, I figure that I got it completely powered down.

I've tried a card that works in my other rockbox device, and got the same results, so that's probably not it either.

The good news: booting the original firmware over USB kind of works! It shows the "Welcome!" screen, then the battery charging icon, then goes dead, with none of the buttons responding.

One thing I ran into early on, I discovered that the three builds you need to do (normal, bootloader, spl) need to be in their own build directories (I did rockbox/build, rockbox/build-bl, rockbox/build-xpl), is that how it's supposed to work?

I think I'm going to attempt to load the original firmware back onto it so I can have a fresh go at it, we'll see how that goes. - Putting M3K.fw on the card and booting with Vol+ held just leads to a blinking keypad. I'm not sure if it's boot cycling or actually doing something underneath. Probably the former.

I'll attach my original boot.dump and boot.install if you could peek at them. - here (https://dconrad.neocities.org/assorted_files/Archive.zip)
Title: Re: Fiio M3k
Post by: JimZipCode on April 04, 2021, 12:31:50 PM
... the linux-based port will most likely be nuked from orbit.

It's the only way to be sure.   :)
Title: Re: Fiio M3k
Post by: heyspencerb on April 04, 2021, 05:59:32 PM
Hello, developer of the new M3K port here. Thought I'd chime in since somebody was enterprising enough to try the new native port already!

Hello! First of all, amazing work! The new port is so much faster to boot, run and create databases, and it actually properly shuts the unit off so the amazing battery life is back! As far as bugs, the only catastrophic ones I've found are some of the plugins causing a hard crash and segmentation fault, but I'll go through each and submit bug reports as I see which ones work and which don't. Though the worst offenders of seg faults are the games which is definitely not top priority, as fun as it would be to run DOOM on it.

Is the bare metal port working in the simulator yet? I'd love to try out some new ideas with key mapping and such, but currently I am just making a change and loading it on hardware as the test which is a pain.
Title: Re: Fiio M3k
Post by: amachronic on April 04, 2021, 07:11:21 PM
Is the bare metal port working in the simulator yet?

It should work now, a fix for the keys in the simulator was committed yesterday.
Title: Re: Fiio M3k
Post by: dconrad on April 05, 2021, 08:49:44 PM
Well, I got brave (or dumb, your call) and tried again since I had moved up to FiiO version 1.4.5 while recovering the first time, and got the same result of an unresponsive player. So I'm either not doing something correctly or something is different with my player/environment. At least recovery this time was pretty easy.
Title: Re: Fiio M3k
Post by: amachronic on April 06, 2021, 10:18:14 AM
I realized why you're not able to boot Rockbox over USB once you flash it... the SPL will see that the bootloader is flashed and try to load it, it'll never return to the hardware boot ROM and the USB command will time out. That's my bad, sorry for the confusion.

It seems unlikely you somehow compiled it wrong if you managed to load Rockbox, flash the bootloader, and see error messages from the bootloader. So it's probably a hardware initialization problem.

Could you try flashing the bootloader again, and boot Rockbox normally with this patch applied: https://gerrit.rockbox.org/r/c/rockbox/+/3290 (https://gerrit.rockbox.org/r/c/rockbox/+/3290)? If the bootloader is managing to load Rockbox at all, you should see the backlight light up. Let me know what happens.
Title: Re: Fiio M3k
Post by: dconrad on April 06, 2021, 10:05:46 PM
I tried that patch - it's not turning on the backlight at all. So this would indicate the bootloader can't even load Rockbox for some reason?

Edit: I did try both FAT16 and FAT32, no difference.

Edit 2: I could try it again tomorrow just to be sure.
Title: Re: Fiio M3k
Post by: dconrad on April 07, 2021, 08:31:53 AM
Ok, I'm trying again now that I can be fully focused (work went long yesterday...)

And just because I always believed it's important to show your work:

Code: [Select]
sudo diskutil eraseDisk FAT32 M3K MBRFormat /dev/disk2
Code: [Select]
# ./usbboot -v -c x1000 -1 ../../build-spl/spl.m3k --wait 1 -2 ../../build-m3k/rockbox.bin
Code: [Select]
$ ./nand_patcher.py boot.dump ../../build-bl/bootloader.m3k ../../build-spl/spl.m3k boot.installThe result is SPL size 8632, Boot size 77704
   Result is a single keypad flash, and the backlight never comes on. If I remove the SD card and try to boot, I do get "No SD card present", so the bootloader is definitely installed.
Title: Re: Fiio M3k
Post by: amachronic on April 07, 2021, 03:28:59 PM
Thank you for the detailed post, dconrad. You're doing everything right, so no issue there. I discovered a simple bug in the bootloader today, which might be causing the hang.

Can you try again when you have the opportunity? Do a build with just this bugfix applied to master (https://gerrit.rockbox.org/r/c/rockbox/+/3301 (https://gerrit.rockbox.org/r/c/rockbox/+/3301)). It might already be merged by the time you get around to it, and fingers crossed it will solve your problem.

In case you're still getting a hang, flash a build with the new version of https://gerrit.rockbox.org/r/c/rockbox/+/3290 (https://gerrit.rockbox.org/r/c/rockbox/+/3290) and we'll go from there. Make sure you apply it on top of the bootloader bugfix.
Title: Re: Fiio M3k
Post by: dconrad on April 07, 2021, 08:21:54 PM
Thank you for the detailed post, dconrad. You're doing everything right, so no issue there. I discovered a simple bug in the bootloader today, which might be causing the hang.

Can you try again when you have the opportunity? Do a build with just this bugfix applied to master (https://gerrit.rockbox.org/r/c/rockbox/+/3301 (https://gerrit.rockbox.org/r/c/rockbox/+/3301)). It might already be merged by the time you get around to it, and fingers crossed it will solve your problem.

In case you're still getting a hang, flash a build with the new version of https://gerrit.rockbox.org/r/c/rockbox/+/3290 (https://gerrit.rockbox.org/r/c/rockbox/+/3290) and we'll go from there. Make sure you apply it on top of the bootloader bugfix.

Thanks a bunch for keeping going with this issue! #3301 has already been merged into master at this point, so I just did git pull --rebase to get the latest changes. Unfortunately it didn't have any effect on the behavior, I still get a single flash of the keypad and that's it.

However! I cherry-picked #3290 on top of current master, which at the time of writing is at commit 1b82ebc6e, "Fix: Directory stream not closed in Shortcuts menu". The result is it gets to Loading firmware... and sits like that forever.
Title: Re: Fiio M3k
Post by: amachronic on April 08, 2021, 06:18:43 AM
Okay... that's a little unexpected, but I guess it confirms my original suspicion that the filesystem is somehow to blame.

I understand you're using Mac. I don't have access to a Mac, so I cannot test myself, but I suspect that it must format the filesystem differently and this triggers a bug in the M3K's SD driver. Can you try reformatting the SD card using Linux or Windows, and flash a clean build of Rockbox from master? If that makes it magically boot, then we've found the problem.

You also mentioned you've got another Rockbox device where the SD card works -- what model is it? native or hosted port?

I'll have a think about how to debug further and upload another version of g#3290 later today.
Title: Re: Fiio M3k
Post by: dconrad on April 08, 2021, 08:42:28 AM
Yeah I can do that. I'm using my linux box to build rockbox, but my laptop makes it easy to make the filesystem so I was just doing that. I'll have to go download gparted I think.

By the way, is FAT32 necessary, or is FAT16 ok? I had to do some runaround to get it to do FAT32.

Edit: my other rockbox device is an Eros Q (well, a Hifi Walker H2). Unfortunately it has an audio bug that makes it unusable for me at the moment, but it reads SD cards just fine.
Title: Re: Fiio M3k
Post by: amachronic on April 08, 2021, 11:21:08 AM
The weird thing here is, if you managed to get a flash dump, the SD driver must work in Rockbox, even with the Mac formatting... the bootloader uses the same code so not sure why it is having trouble loading the firmware. I updated g#3290 with extra logging anyway so we can figure out which part of the firmware load hangs, before delving into the SD driver guts.

It could be that the machine is powering up too fast and your card draws too much current. It seems somewhat unlikely, but I chose the power-up delay pretty close to the minimum that worked in order to keep the boot time down. I've extended it to 500ms in g#3290.

Your comment about fat32 runaround made me think: Are you using an old SDSC card, <= 2 GB? 2 GB is the max size for fat16, I think, which might explain why the formatter tries to force it on you.
Title: Re: Fiio M3k
Post by: dconrad on April 08, 2021, 08:31:53 PM
It is indeed just an old 2 gig card, I pulled it out of the small handful I have. Is the bootloader explicitly expecting Fat32?

My plan right now is to try updated g#3290 and see what happens, then reformat the card with gparted if it still doesn't work. I did git reset --hard origin/master, git pull --rebase, and then cherrypicked g#3290 on top of the most recent master (c77cd7027f35, lua print_table add ability to draw a line separator)

So with the updated debugging bootloader and the card formatted as FAT32 from macos, I'm getting:

Code: [Select]
Booting...
Loading firmware...
Open: /.rockbox/rockbox.m3k
file size = 685012
try to read checksum
Read: 685004 @ 800811C4
Verify checksum
Success

But it doesn't actually boot, it just sits there. I'll try formatting it with linux and reinstall the same debugging bootloader and build of rockbox. --> exact same result, down to the counts and address.

I'll try the big card out of my main mp3 player, a modern(ish) 64 gig Sandisk, that I actually bought at a store (wow!), haha usually I just kind of end up with these cards somehow. I'mnNot going to reinstall the bootloader, I'll just plop .rockbox on there and see what happens. --> exact same result again.

What on earth could this be? It's probably some dumb thing, but...

Looks like it's hanging when trying to close the file??
Title: Re: Fiio M3k
Post by: amachronic on April 08, 2021, 09:19:31 PM
That's strange. I'm turning in for the night but this has got me stumped. I've been unable to reproduce despite testing all these g#3290 revisions locally, they boot fine for me. The SD card is probably a red herring.

Could you upload all the *.elf *.m3k and *.map files from your rockbox, bootloader, and SPL builds (be careful since the SPL elf and map files are also called 'bootloader' due to a deficiency in the build system, you need to rename them first). Let me know the commit they're built from, and I'll flash the same binaries tomorrow on my M3K and see what happens. Many thanks for your patience with all the testing!

Btw the bootloader should not care about FAT32 vs FAT16, it uses standard Rockbox filesystem code which is supposed to handle both.
Title: Re: Fiio M3k
Post by: dconrad on April 08, 2021, 09:44:43 PM
Try here (https://dconrad.neocities.org/assorted_files/m3k_binaries.zip)

I kind of wonder if I have the wrong compiler version somehow, or if it's due to the fact that I also have the cross-compiler built for the Hifiwalker H2, which I understand is different because it's a hosted target. I've built loads of working rockbox builds for that, but never a bootloader.

Man, I've been using my neocities account more for transferring files than actually making a website lately...
Title: Re: Fiio M3k
Post by: dconrad on April 08, 2021, 11:41:50 PM
... maybe a silly question, but should I be running "make" or "make -j"? I got started playing with the eros q which apparently is supposed to be built with "make -j", so that's what I've been doing...
Title: Re: Fiio M3k
Post by: speachy on April 09, 2021, 11:33:40 AM
'-j' refers to the number of parallel jobs Make should try to execute at the same time.  '-j2' means two jobs in parallel, '-j4' is 4, etc.  '-j1' is the same as not specifying the argument at all.  Now '-j' with no number is a special case, it actually means 'no limit', and is rarely a good idea.

Usually it's recommended that you'd use a number of jobs no greater than the number of threads your system can run simultaneously.  Under linux, this is reported by running 'nproc'. 
Title: Re: Fiio M3k
Post by: amachronic on April 09, 2021, 11:45:31 AM
dconrad, I flashed your build and it booted just fine... ??? must be hardware issues. I'll do another version of g#3290.
Title: Re: Fiio M3k
Post by: dconrad on April 09, 2021, 12:12:30 PM
Now '-j' with no number is a special case, it actually means 'no limit', and is rarely a good idea.

So does that mean that this page (https://www.rockbox.org/wiki/LinuxSimpleGuideToCompiling) is incorrect then? It specifically says to use "make -j" unless on a really old machine - which I suppose mine could be, depending on your definition of old.
Title: Re: Fiio M3k
Post by: whiskerc on April 09, 2021, 03:42:06 PM
Just wanted to weigh in and say that today I was able to successfully follow the instructions on the wiki page, compile and install.  The M3K boots directly to Rockbox.   Very exciting to see how much work has been done.

I haven't done any testing yet, but will be monitoring this thread and am available to check things as needed.


Title: Re: Fiio M3k
Post by: whiskerc on April 09, 2021, 06:30:09 PM
Thew, would you be willing to share your theme? 
Title: Re: Fiio M3k
Post by: amachronic on April 09, 2021, 07:46:21 PM
dconrad, I pushed another update to g#3290. This one is more complicated and I included instructions in the commit message. If anything's unclear then please ask. If you have the time and inclination this weekend, we could get on IRC and maybe figure this out faster.
Title: Re: Fiio M3k
Post by: dconrad on April 09, 2021, 08:57:27 PM
dconrad, I pushed another update to g#3290. This one is more complicated and I included instructions in the commit message. If anything's unclear then please ask. If you have the time and inclination this weekend, we could get on IRC and maybe figure this out faster.

Sure thing. I can get on IRC whatever time works for you this weekend, I'm in US Central time. Probably tomorrow mid/late morning?

I think I get the gist of your instructions, I might just take video of it so I can go scroll through it again.

I'll try the patch right now, on top of commit 13dbcab6c, "erosq: When mucking with the clickwheel, ensure we keep the screen awake!"

Looks like it's the simplest (well, simplest for me to report) option, t simply stops counting. We end up with:

Code: [Select]
Passed close()
load_firmware: ret=683948
load_firmware: exit
Jumping...

ipr0:00000000 ipr1:00000000
irq epc:8000FF28
t = 15130638

What's interesting is that it now can actually get to the "Jumping" printout, whereas before it couldn't?

ELFs: here (https://dconrad.neocities.org/assorted_files/m3k_elfs_4-9.zip)
Just for fun: youtube vid: here (https://youtu.be/sVXpSuGfvJk)
Title: Re: Fiio M3k
Post by: amachronic on April 10, 2021, 07:09:23 AM
Looks like you're running into a bug due to some hardware/SD card/filesystem differences and it happens to overwrite memory/stack that is critical to the boot. Trashing memory etc can happen in the background but not cause an obvious problem if whatever gets trashed is not used, until code changes cause the memory layout to change and suddenly something important is overwritten.

I'll be on IRC in the next hour or so, we'll have to try a bunch of builds until we can find out what is being corrupted.
Title: Re: Fiio M3k
Post by: amachronic on April 10, 2021, 05:41:48 PM
dconrad, I've updated g#3290 again; compile SPL, bootloader, and Rockbox from that and unzip Rockbox to the SD card. Boot by running bootloader.bin over USB. If we're lucky you should see the logo and get a blinking keypad.

Unfortunately I feel we haven't solved much, despite making some progress in narrowing down a point of failure. We still don't know why the bootloader was hanging on 'Load firmware...' before and we didn't find any memory corruption. The HW being picky about getting re-initialized twice without proper shutdown in between might be a thing, but it wouldn't really explain the prior behavior of the bootloader.

One thing you can try, is to cherry pick patchset 21 of g#3290, and dump 2 other functions in the same way you checked system_init earlier today. I forgot that clk_set_ccr_mux and clk_set_ccr_div are not inlined into system_init so there is still a possibility that one of those two functions got corrupted. (Since patchset 16 didn't flash lights and patchset 17 did, we know that those two are the only functions that need checking.)

You can get the disassembly listing using mipsel-elf-objdump -D rockbox.elf. (That is, the objdump from the toolchain you use to compile for the M3K). Search for <clk_set_ccr_mux>: and <clk_set_ccr_div>: to find the listings of those functions, and then edit bootloader/fiiom3k.c, changing the address in the code below to the address of the function you're going to dump:
Code: [Select]
    /* On line 111... */
    uint32_t* addr = (uint32_t*)(loadbuffer + (0x8007f3d0/*<< change this */ - 0x80004000));
    while(1) {
        lcd_fillrect(0, LCD_HEIGHT - 48, LCD_WIDTH, 12);
    ....

In patchset 21, the address on screen will match the assembly listing, so it's a bit easier to work with. If you are motivated enough to try this, let me know if you spot any corruption.

Now I'm sorry to say this, but -- things are getting out of hand with the level of debugging we're getting to, and I have to give up on you for now. I'm going to focus on polishing up the bootloader installation, get dual boot working, and improve debuggability of the early boot. Those 3 things should have a positive impact on any potential HW problems. There are some other random bugs I am aware of, which if I track down and fix might "accidentally" end up fixing the root cause of the problem you're suffering. At a minimum, it will be easier to localize problems, without going through the trouble of these hacky patches. (As you've seen, it literally takes dozens of edit-compile-test cycles doing it the hacky way...)

A bit longer term, when the Rockbox USB driver is working for this device, I should be able to implement a GDB stub on the machine -- then we can use GDB to make debugging way faster & easier. But let's hope it won't be necessary.

So good luck with this round of testing, and thanks for your excellent cooperation! I'll post again when there's something worthwhile to test with.
Title: Re: Fiio M3k
Post by: dconrad on April 11, 2021, 11:42:50 AM
Thanks amachronic, I'll give all that a shot and see what I can find out. I didn't get a chance to try actually using the device yesterday to see if it would do something weird, we had some washing machine issues I had to deal with all afternoon. I'll get to that soon though! I totally understand moving on to actual improvements - at least we know where the issue might be now, if not what it is.
Title: Re: Fiio M3k
Post by: KatsuoHana on April 16, 2021, 02:02:41 PM
Any further progress on a native port? I've seem to ran into the same problem as dconrad, havcing my player only light up touch buttons once after flashing the freshly-built rockbox.
Surprisingly, after replacing rockbox on SD card with one build with patchset 3290, it boots and flashes light just fine, even without doing anything to bootloader and/or SPL. If I revert all changes to apps/main.c from that patchset, it manages to boot into the system that is somewhat usable (touchpad is a bit unresponsive and even MP3 playback stutters). With that, I think I should be able to revert to stock bootloader and flash the Linux-based version, but it interprets touchpad button and play button as the same one, which makes it either unusable in jeans pocket, or uncontrollable without unlocking keys every time you want to pause the track.
Title: Re: Fiio M3k
Post by: amachronic on April 16, 2021, 04:30:16 PM
Hi, KatsuoHana, I am still working on the M3K. Thanks for trying out g3290 and taking the initiative... did you use the latest patchset 22? IIRC, the main change there is the PLL/system clock initialization. I've got some changes locally which do the same thing in a better way, but I need to clean them up a bit before I push it out. I'll try to get that done this weekend, judging by your testing it should fix the hang on boot.

I am not surprised that things don't work well on g3290 because it has a lot of slowdown due to the debug code I added. Hopefully a proper build with fixes included will work smoother for you.

Play/pause on the WPS is indeed mapped to both the touchpad and physical button. Keymaps are currently not ideal right now, but the button problem you described is more the fault of Rockbox's default settings. This is not fixable by keymaps, or at the driver/firmware level without introducing other gotchas.

If you enable "Advanced Key lock" (aka. softlock) and turn on Autolock On, Always Autolock, Exempt Volume, Exempt Play, and Disable Touch in the submenu, then you get something approximating normal screen locking -- the touchpad turns off when locked, and you can still play/pause and control the volume.

IMO, the way to go is improving softlock and making it more consistent, then enabling it by default on the M3K. I'm sure other touch-enabled players would benefit from this too.
Title: Re: Fiio M3k
Post by: KatsuoHana on April 17, 2021, 02:44:15 AM
Hi, KatsuoHana, I am still working on the M3K. Thanks for trying out g3290 and taking the initiative... did you use the latest patchset 22? IIRC, the main change there is the PLL/system clock initialization. I've got some changes locally which do the same thing in a better way, but I need to clean them up a bit before I push it out. I'll try to get that done this weekend, judging by your testing it should fix the hang on boot.
Yeah, I've fully merged the g3290, including the patchset 22. As I mentioned before, it boots fine if you remove the debug DIE() function in main.c.
If you enable "Advanced Key lock" (aka. softlock) and turn on Autolock On, Always Autolock, Exempt Volume, Exempt Play, and Disable Touch in the submenu, then you get something approximating normal screen locking -- the touchpad turns off when locked, and you can still play/pause and control the volume.
I think I've already tried that on Linux-based build, and it still does not block touchpad button. For now I only exempted volume controls, so I have to unlock the keys every time I want to pause playback.
Title: Re: Fiio M3k
Post by: amachronic on April 17, 2021, 07:59:38 AM
I think I've already tried that on Linux-based build, and it still does not block touchpad button
The hosted port was lacking the proper code to filter out the touchpad afaik; it definitely works properly on the native port.

From what you've reported, https://gerrit.rockbox.org/r/c/rockbox/+/3334 (https://gerrit.rockbox.org/r/c/rockbox/+/3334) should fix the boot hang that you and dconrad are getting. Try re-flashing again after that's merged. NB, it'll break the usbboot method of loading Rockbox, so you will need jztool from https://gerrit.rockbox.org/r/c/rockbox/+/3326 (https://gerrit.rockbox.org/r/c/rockbox/+/3326) to do the install.
Title: Re: Fiio M3k
Post by: KatsuoHana on April 17, 2021, 11:25:57 AM
From what you've reported, https://gerrit.rockbox.org/r/c/rockbox/+/3334 (https://gerrit.rockbox.org/r/c/rockbox/+/3334) should fix the boot hang that you and dconrad are getting. Try re-flashing again after that's merged. NB, it'll break the usbboot method of loading Rockbox, so you will need jztool from https://gerrit.rockbox.org/r/c/rockbox/+/3326 (https://gerrit.rockbox.org/r/c/rockbox/+/3326) to do the install.
Alright, I'll try to flash it again after it stabilizes and gets merged. Thank you for your hard work.
Title: Re: Fiio M3k
Post by: KatsuoHana on April 18, 2021, 02:56:53 AM
Now that it's merged, I've tried it, and it seems to work fine. Tested it out for a few minutes (listened to some MP3s, played Boomshine), haven't noticed any severe bugs. Sadly, it doesn't boot from exFAT-formatted card, saying it's unable to mount the filesystem; I had to explicitly format my card in FAT32. Other than that nitpick, great job.
Title: Re: Fiio M3k
Post by: saratoga on April 18, 2021, 10:17:40 AM
exFAT is definitely not supported, so no surprise there.
Title: Re: Fiio M3k
Post by: dconrad on April 18, 2021, 11:28:22 AM
amachronic, great news! The changes you pushed fixed my issue! I went through and used jztool and it just kind of worked. I guess there's no way to know exactly what it was (not worth the effort to drill down and find out), but presumably it was the clock init change?
Title: Re: Fiio M3k
Post by: amachronic on April 18, 2021, 01:09:50 PM
Alright, glad it's working for everyone now ;D. My guess is the clock setup was the problem -- perhaps some units are not 100% stable with the current configuration.
Title: Re: Fiio M3k
Post by: KatsuoHana on April 22, 2021, 09:20:21 AM
Tested out the updated bootloader, installing it with jztool over the older one works fine, and I like that you don't need to reboot the player after inserting card if you turned it on without it. Rockbox itself works fine as well, no crashes or bugs detected during few days of usage. How long until the port gets moved from unusable to unstable?
Title: Re: Fiio M3k
Post by: amachronic on April 22, 2021, 11:53:08 AM
I simply haven't considered moving the M3K port to unstable yet, although it's very much usable in my opinion. The only concrete thing missing is a binary release of the bootloader and jztool, according to the wiki (https://www.rockbox.org/wiki/TargetClassifications (https://www.rockbox.org/wiki/TargetClassifications)). I suppose it will encourage more much-needed testing if Rockbox is easy to install, so I'll definitely ask about getting the port moved up to unstable.
Title: Re: Fiio M3k
Post by: heyspencerb on April 25, 2021, 10:20:20 PM
Hey! Checking back in because I hadn't updated my bare-metal version in about three weeks, amazing job guys! I can't believe you got USB multimedia working so soon! That's a huge help, even for dev work too! What do the different USB Keyboard Modes mean? The multimedia/Presentation/Browser?

Also, the new bootloader is great! But I do think the new instructions are even less beginner friendly than the last one.

Couple things, in this line:
../../tools/configure --target=fiiom3k --type=x

there is one too many ../ It should only be
../tools/configure --target=fiiom3k --type=x

Also, right after that the tutorial says:
"If all goes well you should have files build-spl/spl.m3k and build-boot/bootloader.m3k."

but doesn't say that you need to run 'make' in both of these directories first. Then at the end, it doesn't tell people how to 'make' rockbox the normal way in order to get your new .rockbox folder.

I know these are super obvious steps to people experienced with linux and with rockbox specifically but any beginner just trying to follow along is gonna get scary looking error messages if they try and follow the steps exactly and they don't know they have to run make, or don't know what the ../ stands for and why it says the file they are looking for doesn't exist. I just wanted to make sure so that people don't keep posting in this thread for tech support when they try and get stuck.

But, great job to all the devs! Super excited about all the new features!!
Title: Re: Fiio M3k
Post by: amachronic on April 26, 2021, 08:50:42 AM
Quote
Also, the new bootloader is great! But I do think the new instructions are even less beginner friendly than the last one.
Thanks for pointing out the mistakes! I'll definitely fix those.

In any event, the M3K native port has now been moved to unstable so there's daily builds available to download. I'm planning on providing a binary build of the bootloader so people don't have to go through the trouble of compiling anything, and encourage more people to install Rockbox on the M3K.

I would've released the current bootloader, but speachy pointed out to me that having separate SPL and bootloader might cause confusion down the road especially if someone mixes up the files from two different builds. Plus, it's not very user friendly. Probably for the best anyway -- I'm taking the opportunity to do some much-needed reorganization and smooth over the install process.
Title: Re: Fiio M3k
Post by: KarlJ on April 28, 2021, 02:53:27 AM
Can I flash my M3k with my Mac? it's work with Big Sur
Title: Re: Fiio M3k
Post by: amachronic on April 28, 2021, 10:23:20 AM
Can I flash my M3k with my Mac? it's work with Big Sur
In theory jztool should work on Mac. But, I don't have a Mac, so I haven't tested it myself. It should compile without a hitch but you'll have to edit the makefile and point it at the libusb library and headers.
Title: Re: Fiio M3k
Post by: KarlJ on April 28, 2021, 07:11:53 PM
Can I flash my M3k with my Mac? it's work with Big Sur
In theory jztool should work on Mac. But, I don't have a Mac, so I haven't tested it myself. It should compile without a hitch but you'll have to edit the makefile and point it at the libusb library and headers.
I download the libusb and copy to the folder include ,but when I compile jztool ,system reminds me endian.h is missing,I don't know how to fix it.
Title: Re: Fiio M3k
Post by: amachronic on April 29, 2021, 08:49:18 AM
Okay, I'll fix the endian.h issue -- that's something I've been meaning to do anyway since it's a problem for Windows too.

Also, make sure you compile libusb. It isn't enough to just drop it in the include folder. Rather than compile it yourself, it looks easier to install with homebrew:
Code: [Select]
brew install libusb
I think I figured out which include/library paths to use for homebrew stuff so I'll add those to the Makefile. I'll probably get this done later today, you can try again then and let me know if you have success or more problems.
Title: Re: Fiio M3k
Post by: speakn2pabst on April 30, 2021, 10:36:33 PM
Hi all.   :) First post, new user.    ;)   

Just wanted to drop a thank you.  I followed the build instructions (on Manjaro/Arch Linux) and have a new native Rockbox build on my M3K.  Still checking it out but seems to function great.  Thanks for the continued work.   ;D
Title: Re: Fiio M3k
Post by: FroggestSpirit on May 03, 2021, 05:47:15 PM
Nice progress here! With USB mode, does that mean it will allow you to play audio over USB, like in a car stereo with a USB port? It'd be nice to ditch the AUX cord, since you cant skip tracks with it.
Title: Re: Fiio M3k
Post by: amachronic on May 03, 2021, 06:14:50 PM
Nice progress here! With USB mode, does that mean it will allow you to play audio over USB, like in a car stereo with a USB port? It'd be nice to ditch the AUX cord, since you cant skip tracks with it.

Sorry, Rockbox doesn't have a USB DAC mode. Or do you mean outputting audio from Rockbox over USB, for playback on another device? (That's not supported either.)
Title: Re: Fiio M3k
Post by: speachy on May 03, 2021, 08:34:36 PM
Nice progress here! With USB mode, does that mean it will allow you to play audio over USB, like in a car stereo with a USB port? It'd be nice to ditch the AUX cord, since you cant skip tracks with it.

AFAIK there is only one "audio over USB" standard that a typical car headunit implements, and that is tied up in the proprietary Apple IAP quagmire.  Even if we were to implement it, we'd have to pretend to be an iPod for it to work, and Apple has historically reacted _very_ unfavourably to such things.

(Android Auto, and possibly modern CarPlay, transfers audio via bluetooth)

Title: Re: Fiio M3k
Post by: FroggestSpirit on May 04, 2021, 05:43:09 PM
Ahh, I never knew that was more of an apple thing. Not sure if it's known, but the GBS plugin doesn't appear to work on the dev build. NES, SNES, Genesis all work, but GBS is generally silent. I got some of the noise channel to play, so I think it's something with the emulation, rather than the buffer or something.
Title: Re: Fiio M3k
Post by: stridechicken on May 09, 2021, 08:06:45 AM
I've managed to install the bare-metal version of Rockbox on my M3K and I'm loving it, thanks everyone for your work. One problem I can't understand though, the lock option works great while music is playing. But it seems that if the device is locked and then the album finishes playback, it is then not possible to unlock, so I have to restart. Is there another way to unlock that I have missed? Why is this happening?
Title: Re: Fiio M3k
Post by: johnb on May 09, 2021, 09:05:45 AM
I managed to compile SPL, bootloader and jztool under WSL2 (as I mentioned on IRC, too). Unfortunately, jztool won't do the installation within WSL2 as the usb device doesn't show.

Can anyone help out and compile jztool for Windows?

Cheers
johnb
Title: Re: Fiio M3k
Post by: amachronic on May 09, 2021, 09:45:27 AM
...
The lock screen issue definitely sounds like a bug, maybe a keymap problem. Thanks for bringing it to my attention! I'll check it out.

...
I got sidetracked and forgot about it, but I intended to mention on IRC that you should try using msys2 to build jztool: https://www.msys2.org (https://www.msys2.org)

Their homepage shows you how to set it up and install a native mingw-w64 toolchain. The last time I did any development on Windows using MinGW, msys/mingw was primitive and a pain to set up. It seems things have improved and they've got a package manager now -- I don't think it should be any harder to use than WSL. If they also provide builds of libusb then hopefully everything should be plug and play! just build from the msys2 shell.

Apologies that I can't be of any more help. I simply haven't gotten around to spinning up a Windows VM myself... since other bootloader stuff is taking up my time... but I do intend to provide jztool binaries for Windows & Linux in the not-too-distant future.
Title: Re: Fiio M3k
Post by: bluebrother on May 09, 2021, 11:16:32 AM
I got sidetracked and forgot about it, but I intended to mention on IRC that you should try using msys2 to build jztool:

You can easily build it using mxe on a Linux machine. Would expect mxe to run in wsl2 as well, but I've never tried.

Generally, you shouldn't need msys -- for Rockbox Utility I spent quite some time (years ago :) ) to get rid of all msys dependencies, you only need MinGW -- and in case of jztool you'd also need libusb. Not sure if that comes prepackaged for MinGW, and if not how hard it would be to build that for Windows (so you might need msys for building that though.)
Title: Re: Fiio M3k
Post by: g.orlandini on May 10, 2021, 02:18:42 AM
First of all, great job, I installed this beta version 2 weeks ago and it works quite well, no big issues.

Minor issues:
- Charging is very slow (around 0,1 A), not a big problem (Every now and then I can wait few hours for a complete charge)
- font size in some pages (Battery view in debug menu) is really small (I need a big magnifier to read!), it should be (at least) double that size for comfortable reading. Is there any option in the menu settings to increase the size ?

Do you advice to reinstall a new bootloader with your improvement "X1000: simplify NAND driver" ? At the moment the bootloader I've installed is working well.

Thanks for your work
Title: Re: Fiio M3k
Post by: amachronic on May 10, 2021, 08:13:11 AM
- Charging is very slow (around 0,1 A), not a big problem (Every now and then I can wait few hours for a complete charge)
Hmm, I thought I had fixed that issue... It's caused by Rockbox thinking there is a USB host (like a PC) although there is none. As a workaround you can set General Settings > System > Battery > Charge During USB connection to Force, it should force the full 500 mA charge rate. I'm not sure why Rockbox is getting confused but I'll look into it when I have the time.

- font size in some pages (Battery view in debug menu) is really small (I need a big magnifier to read!), it should be (at least) double that size for comfortable reading. Is there any option in the menu settings to increase the size ?
Nope, it's hardcoded in the build. I will increase it at some point, I already did that in the bootloader because it was so hard to read. I have to rearrange some debug screens first since they'd become unreadable with a larger font.

Do you advice to reinstall a new bootloader with your improvement "X1000: simplify NAND driver" ? At the moment the bootloader I've installed is working well.
It's not necessary.
Title: Re: Fiio M3k
Post by: 7o9 on May 12, 2021, 02:40:08 PM
Nice job on the new bootloader, amachronic.

Took me two attempts to realize I had to actually install the bootloader from the menu after running jztool.

The boot menu looks very good and it works very well.

Thanks for all your work on this port, it is great to have RockBox on this device.

I know you wrote that you are not looking to do other ports but I am holding out hope that all this work for the FiiO M3K will open doors for a port to the Shanling Q1 (and perhaps even M0).
Title: Re: Fiio M3k
Post by: amachronic on May 12, 2021, 05:09:35 PM
I know you wrote that you are not looking to do other ports but I am holding out hope that all this work for the FiiO M3K will open doors for a port to the Shanling Q1 (and perhaps even M0).

IIRC the Q1 and M0 are nearly identical, except for the buttons and screen I think they have the exact same hardware. Once one is done I think porting to the other should be trivial.

Come to think of it I should create a wiki page for the Q1... I did unpack the firmware at one point and found out you can execute scripts on the stock FW.
Title: Re: Fiio M3k
Post by: bahus on May 14, 2021, 07:11:58 AM
amachronic

Original firmware when in locked state allows to change tracks by long pressing volume buttons. That's not very consistent but quite convenient feature.

I wonder how to make rockbox more usable in pocket and/or locked state. How about making shortcuts with play + volume buttons act as prev/next and ff/rw buttons (So play + short press Vol-  acts as  previous track, play + long press of Vol- acts as rewind, ... ) Looks like convenient one hand shortcuts. Is it feasible?
Title: Re: Fiio M3k
Post by: amachronic on May 14, 2021, 10:41:10 AM
@bahus: I did try the play+volume button mapping on a local build, but I found it a bit tricky to use in practice. It also displaces the WPS hotkey mapping (= long press of play) so it'd create inconsistency with the main keymap. (Not that I find the hotkey very useful.)

But, I don't think the hotkey can do anything useful if the screen is locked, so if the Play+Volume buttons act as skip/seek when the screen is locked and keep the current behavior when unlocked, we can have the best of both worlds.
Title: Re: Fiio M3k
Post by: bahus on May 14, 2021, 12:02:55 PM
I found it a bit tricky to use in practice.
Ideally you should be able to execute multiple actions using volume buttons keeping play button pressed. So if you need to skip multiple tracks - it's enough to press once play button and then press Vol+ multiple times keeping play button pressed.

It also displaces the WPS hotkey mapping
Yes. Long Play button press shouldn't be mapped at all to make it work nicely.  Can't this WPS hotkey be remapped for long press on some touch button (or some other combinations like play button double press, or play + short power press)?


if the Play+Volume buttons act as skip/seek when the screen is locked and keep the current behavior when unlocked, we can have the best of both worlds.
This will work for me too -  it's indeed required mostly for operating with locked screen. I just thought that global implementation would be easy.
Title: Re: Fiio M3k
Post by: 7o9 on May 15, 2021, 02:11:49 AM
Those are some very elaborate and specific ways to control the player.

Please demonstrate how to do those while the device is in your pocket!

I have been having an issue with the device not responding to any buttons except power off after turning on button lock, not even unlocking the buttons again. Trying to reproduce the exact steps but so far I failed to do so. I think it happened when button lock was enabled and the player reached the end of the playlist.
Title: Re: Fiio M3k
Post by: bahus on May 15, 2021, 02:29:14 AM
Those are some very elaborate and specific ways to control the player.
Please demonstrate how to do those while the device is in your pocket!
I have no problem with pressing play button with my middle finger  and Vol+/Vol- with my index finger simultaneously.  If you don't like it or can't do it - it shouldn't affect you in any way. And that's  just my suggestions. What's yours?


Title: Re: Fiio M3k
Post by: amachronic on May 15, 2021, 06:28:59 AM
I have been having an issue with the device not responding to any buttons except power off after turning on button lock, not even unlocking the buttons again. Trying to reproduce the exact steps but so far I failed to do so. I think it happened when button lock was enabled and the player reached the end of the playlist.
You're right that it's specifically due to reaching the end of the playlist -- another user reported this some days ago and I was able to replicate it on the simulator. Will be fixed by https://gerrit.rockbox.org/r/c/rockbox/+/3229 (https://gerrit.rockbox.org/r/c/rockbox/+/3229).

bahus: I did get the button mapping working as you described, it applies only when the screen is locked. So, difficult or not it's at least possible to skip and even seek in tracks without unlocking the player. (EDIT: it's not yet merged)

I do find it hard to skip backward using the key combo because the buttons are packed so close together. Ultimately I'd like to allow for customizable key bindings but that's quite a ways off due to the amount of effort involved.
Title: Re: Fiio M3k
Post by: bahus on May 15, 2021, 07:42:59 AM
I did get the button mapping working as you described

Awesome! Thanks. Are you planning to publish pre-built  files required for installing rockbox?
Title: Re: Fiio M3k
Post by: bahus on May 15, 2021, 12:49:07 PM
Oh files detected :) https://download.rockbox.org/bootloader/fiio/

Be aware installation doesn't work with Zadig WinUsb driver (at least on my Windows 10 machine):
jztool.exe -v fiiom3k load bootloader.m3k
[  ERROR] libusb_open: Operation not supported or unimplemented on this platform

Zadig libusbk driver needs to be installed instead of WinUSB.
So rockbox is successfully installed on Windows. Cool! Thanks for your work and quick response!


Title: Re: Fiio M3k
Post by: amachronic on May 15, 2021, 01:20:19 PM
Be aware installation doesn't work with Zadig WinUsb driver
...
Zadig libusbk driver needs to be installed instead of WinUSB.
Well that's weird. I tested on a fresh Windows 10 VM under Virtualbox and it worked with WinUSB...
Which version of Windows are you using?

(That was pretty fast by the way!  ;))
Title: Re: Fiio M3k
Post by: 7o9 on May 15, 2021, 01:33:55 PM
Those are some very elaborate and specific ways to control the player.
Please demonstrate how to do those while the device is in your pocket!
I have no problem with pressing play button with my middle finger  and Vol+/Vol- with my index finger simultaneously.  If you don't like it or can't do it - it shouldn't affect you in any way. And that's  just my suggestions. What's yours?

Calm down, I was just responding to your original "I wonder how to make rockbox more usable in pocket ...". If this helps you, best of luck with it.

I am still getting used to the keymap of the M3K. It has some things that take a little getting used to, only having used RockBox on a long line of various Sansa's before.
Title: Re: Fiio M3k
Post by: bahus on May 15, 2021, 01:37:48 PM
Which version of Windows are you using?
Windows 10 Pro (Version 2004, OS Build 19041.985)

First feedback: Can you please map prev/next touch buttons in lists as simple move up/down actions (with accelerations on long press) and maybe also play button as enter (as in OF). To me it's very inconvenient to use scroll (it has weird responsiveness) - it would really be great to have ability navigating folders and menus without it.
Title: Re: Fiio M3k
Post by: 7o9 on May 15, 2021, 01:56:49 PM
You can tap the top and bottom of the slide strip for up and down.
Title: Re: Fiio M3k
Post by: bahus on May 15, 2021, 02:01:09 PM
You can tap the top and bottom of the slide strip for up and down.
Yeah I got it. But it's not stable for me. It mostly works but sometime it acts as enter. So I would really like to avoid using scroll at all if possible.
Title: Re: Fiio M3k
Post by: 7o9 on May 15, 2021, 02:47:35 PM
Would be nice if the top and bottom regions were a bit bigger. I hit the 'enter' region often too.

Will try to modify the keymap to see if it makes any difference.

Thing is that you are drawn to click on the top/bottom of the elipse thing but the touchstrip extends above and below that.
Title: Re: Fiio M3k
Post by: amachronic on May 15, 2021, 05:16:17 PM
The touchpad doesn't work well because it isn't physically wired properly, and/or the controller firmware is massively broken. The right 1/3rd of the screen reports two fixed values (for the back and right arrow "buttons") and the left 2/3rds is highly nonlinear which makes the scrollbar a bit janky. By nonlinear I mean this -- If the pad is linear then 1pt = 1mm (for example) no matter where your finger is or what direction you move. But with a nonlinear pad 1pt reported by the pad could be 1mm, or 2mm in another place or 0.1mm at some other point on the screen. And this varies independently in each axis so the problem is compounded. In fact, the pad supports 2-point multitouch, but very unreliably, and only in the left 2/3rds. The touchpad on this device is absolutely TERRIBLE, in fact.

I can easily add an option to change the size of the touch zones, which could be used to make the up/down zones easier to press, but I suspect the issue is simply that the center of the touch is detected poorly -- your finger is very large compared to one "pixel" on the touchpad, and the firmware must calculate the center point based on a huge number of physical inputs from the pad. With bad firmware / bad pad the reported values will also be bad, and it's impossible to fix since it's all hardcoded and hardwired.

Sorry for the long winded rant, but I hope it's explains why the M3K's touchpad sucks.
Title: Re: Fiio M3k
Post by: 7o9 on May 16, 2021, 02:06:36 AM
... long winded rant ...

It was no criticism of your work at all, the touchpad is easily the worst part of the M3K hardware.

It is light, fast, sounds quite good and can still be purchased for a reasonable price. I bought mine after I saw you did your RockBox port, so thanks again for that!

The touchpad of the M3K is also kind of why I mentioned hope for a Shanling Q1/M0 version before. Quite similar platform but those devices feel so much more 'premium' already just by holding them.

Luckily I spend much more time listening to music than fondling the touchpad and once you get somewhat used to it, it is quite bareable.
Title: Re: Fiio M3k
Post by: daps on May 17, 2021, 10:32:49 PM
The touchpad doesn't work well because it isn't physically wired properly, and/or the controller firmware is massively broken. The right 1/3rd of the screen reports two fixed values (for the back and right arrow "buttons") and the left 2/3rds is highly nonlinear which makes the scrollbar a bit janky. By nonlinear I mean this -- If the pad is linear then 1pt = 1mm (for example) no matter where your finger is or what direction you move. But with a nonlinear pad 1pt reported by the pad could be 1mm, or 2mm in another place or 0.1mm at some other point on the screen. And this varies independently in each axis so the problem is compounded. In fact, the pad supports 2-point multitouch, but very unreliably, and only in the left 2/3rds. The touchpad on this device is absolutely TERRIBLE, in fact.

I can easily add an option to change the size of the touch zones, which could be used to make the up/down zones easier to press, but I suspect the issue is simply that the center of the touch is detected poorly -- your finger is very large compared to one "pixel" on the touchpad, and the firmware must calculate the center point based on a huge number of physical inputs from the pad. With bad firmware / bad pad the reported values will also be bad, and it's impossible to fix since it's all hardcoded and hardwired.

Sorry for the long winded rant, but I hope it's explains why the M3K's touchpad sucks.

Isn't the M3K identical to the M3 Pro except the M3 Pro has a touchscreen? Would that make it a good option for a port?
Title: Re: Fiio M3k
Post by: 7o9 on May 18, 2021, 12:56:33 AM
Isn't the M3K identical to the M3 Pro except the M3 Pro has a touchscreen? Would that make it a good option for a port?

M3 Pro has the same SoC but a different DAC (ES9218P). The firmware might be similar to the M3K though which would be helpful.

That ES9218P is used by various other players with the same Ingenic X1000E SoC (Hidizs AP80Pro, Shanling Q1/M0 and others).
Title: Re: Fiio M3k
Post by: darkstarcumberland on May 27, 2021, 10:43:20 PM
Hi all,

I have been using this software on my FiiO M3K and love it. I often switch back and forth between Rockbox (for music playback) & the FiiO Firmware (for using the USB DAC feature). I did this every day for many months with no problem.

Suddenly I have an issue where I cannot switch back to the FiiO Firmware. On the SELECT PLAYER screen, when I choose "FIIO MUSIC," the unit freezes, the countdown freezes, the screen stays on indefinitely until I hold the power button. Rockbox can be loaded as normal, but FiiO Firmware cannot.

I have wiped my SD card, reinstalled the default FiiO firmware, reinstalled Rockbox, multiple times, still this issue occurs.

I can use the FiiO firmware if it is the only thing installed on the device.
Once I install Rockbox, FiiO firmware crashes when attempting to launch. Rockbox loads fine.

I think a similar issue has been discussed in this thread but I can't easily follow the technical discussion.

I have not used the "bootloader.m3k" software because I only have access to Mac and I understand it is not possible with a Mac. I do not really understand what that software would do.

I am using the version of the software found here: http://xvtx.ru/rockbox/download.htm
As far as I can tell there are no new versions in the past several months?
Most recent version 1.4.3, date added: 10/13/2019

If anyone has a solution to this I would welcome it.

Thank you for the work on this great software
Title: Re: Fiio M3k
Post by: amachronic on May 28, 2021, 08:49:11 AM
@darkstarcumberland I think the issue you're having is that some directory has gone missing. Ran into this a few times myself, although I'm not sure why it happens. I don't remember which directory it is, something like /data/userfs but I'm not sure, I'll have to check on my end. Maybe someone else can say? It's easily fixed by running a script from the xvortex 'bootloader'.

If you know how to start getty on the USB serial port, you can get a shell on the M3K and start the Fiio player manually. It will throw some error and you can find out the missing path that way.

For the record XVortex's port isn't really supported -- us rockbox devs have no control over it. Something like it got added to the 'official' Rockbox repository a while back and it's called the "FiiO M3K Linux" port nowadays, although I have never used that version and can't say if it even works. The bootloader.m3k stuff is for the native port which doesn't have dual boot or USB DAC capabilities -- at least not yet -- so I guess switching is not a good idea for you anyway.
Title: Re: Fiio M3k
Post by: g.orlandini on May 29, 2021, 03:11:21 AM
- Charging is very slow (around 0,1 A), not a big problem (Every now and then I can wait few hours for a complete charge)
Hmm, I thought I had fixed that issue... It's caused by Rockbox thinking there is a USB host (like a PC) although there is none. As a workaround you can set General Settings > System > Battery > Charge During USB connection to Force, it should force the full 500 mA charge rate. I'm not sure why Rockbox is getting confused but I'll look into it when I have the time.

- font size in some pages (Battery view in debug menu) is really small (I need a big magnifier to read!), it should be (at least) double that size for comfortable reading. Is there any option in the menu settings to increase the size ?
Nope, it's hardcoded in the build. I will increase it at some point, I already did that in the bootloader because it was so hard to read. I have to rearrange some debug screens first since they'd become unreadable with a larger font.

Do you advice to reinstall a new bootloader with your improvement "X1000: simplify NAND driver" ? At the moment the bootloader I've installed is working well.
It's not necessary.

I confirm that with your workaround (General Settings > System > Battery > Charge During USB connection to Force) charging is @ 450mA (much better than 100 mA).

Any chance for implement recording ? There's a useful plugin/application (Pitch_detector) for musical instruments tuning that needs it.

So far no big issues in this beta version. Great job
Title: Re: Fiio M3k
Post by: amachronic on May 29, 2021, 03:59:22 AM
g.orlandini, in fact I'm planning on doing recording soon. And thanks for reminding me about that USB charging issue, I really need to get to the bottom of that.
Title: Re: Fiio M3k
Post by: g.orlandini on May 30, 2021, 02:26:20 AM
It was a (very) minor issue charging @100 mA, but now with your simple workaround charging @450 mA is really OK.
It would be nice to implement recording.

Great job
Title: Re: Fiio M3k
Post by: darkstarcumberland on May 31, 2021, 11:32:25 AM
@darkstarcumberland I think the issue you're having is that some directory has gone missing. Ran into this a few times myself, although I'm not sure why it happens. I don't remember which directory it is, something like /data/userfs but I'm not sure, I'll have to check on my end. Maybe someone else can say? It's easily fixed by running a script from the xvortex 'bootloader'.

If you know how to start getty on the USB serial port, you can get a shell on the M3K and start the Fiio player manually. It will throw some error and you can find out the missing path that way.

For the record XVortex's port isn't really supported -- us rockbox devs have no control over it. Something like it got added to the 'official' Rockbox repository a while back and it's called the "FiiO M3K Linux" port nowadays, although I have never used that version and can't say if it even works. The bootloader.m3k stuff is for the native port which doesn't have dual boot or USB DAC capabilities -- at least not yet -- so I guess switching is not a good idea for you anyway.

Thank you for the info and solutions. Clearly I am not a dev  ;D But trying to follow along the best I can. I see there are "daily builds" that folks are using, but I suppose since I only have access to a Mac system right now, I cannot set that up.

In any case it's no big deal, I have two possible "solutions" that work for me.
1. Use the M3K for Rockbox only and use a different piece of hardware for my DAC.
2. Get a second micro SD card, keep the Rockbox installer on one card and the Fiio Firmware installer on the other card, and "update" the device each time I need to switch.

I think option 1 is less complicated ;-)

Thanks again to everyone working on this, appreciate this open source option even when things go a little wrong.
Title: Re: Fiio M3k
Post by: amachronic on May 31, 2021, 06:58:40 PM
Sorry, I almost forgot about you @darkstarcumberland...

Code: [Select]
#!/bin/ash
rm -rf /data/userfs
mkdir /data/userfs

Copy and paste the code into a file called fix_fiio_fs.sh (the exact name is not important that's just my example). Put that script on the root of your SD card and run the script from the tools menu. Hopefully that will fix your problem.

Regarding Mac and the native port, I expect that the installer jztool will work fine. The problem is that I can't test it because I don't own a Mac. I need someone who does to compile jztool on Mac and see if it works.
Title: Re: Fiio M3k
Post by: heyspencerb on May 31, 2021, 08:20:21 PM
Hey! So I have been frustrated by how tiny the text is in the search menu on the M3K so I hacked together a fix which looks like this:

https://imgur.com/a/Efasvsa

However this fix is hacky and has some bugs, can you look at my merge request and try out my version? I'm hoping something like this could be added in a better way. It will bring you back to the center of the search menu after each letter to make typing faster, and the letters are organized such that the most commonly used letters are the closest to the center.
Here is the merge request:
https://gerrit.rockbox.org/r/c/rockbox/+/3447

The bug I haven't fixed yet is that when you start typing the first five letters or so appear off to the left side of the screen. Also, make sure you have all of the fonts installed as you need them for this to work. Let me know what you think of the idea, and how this could be implemented in a better way.
Title: Re: Fiio M3k
Post by: amachronic on June 01, 2021, 04:31:40 AM
Cool. I like that the text entry area isn't taking up half the screen like it normally does.

A suggestion: did you try defining a custom keyboard layout and loading it? There's been support for that for an age, I just don't think it's that well documented. You simply create a file with the .kbd extension and put the characters in like so...

Code: [Select]
RY
QSF
JIM
.. etc ..

then you can select the .kbd file in the file browser on Rockbox to load it. There is even a setting for it and it seems to remember your last loaded keyboard & apply it at boot, as long as you drop it in the /.rockbox directory. But it seems there are some missing features, eg. you cannot define multiple pages like the standard keyboard has.

I don't think the font size can be changed right now, but there could be a setting for that. The auto-recentering is a neat idea -- it could also be a setting, although it might appear useless or frustrating at first glance because it won't work well on the "standard" layout.

PS. The tiny text problem is that the 'system font' is 8px. I tried upping it to 16px Terminus to match the bootloader, but it broke the status bar, most of the debug screens, and maybe other stuff. I'm not sure how to fix some of those issues tbh. Anyone else annoyed by the tiny font is welcome to try.
Title: Re: Fiio M3k
Post by: heyspencerb on June 01, 2021, 10:44:42 AM
I'm glad you like the idea!

I definitely see what you mean when you say that recentering wouldn't be for every keyboard layout, as it would drive me crazy on the current layout.

As for font choice, I think the proper way to fix this would be to have the font for the keyboard match the chosen font. Right now it doesn't but I think this would be pretty easy by setting
Code: [Select]
pm->curfont = ;equal to whatever font the system is using currently. If you have all of the fonts downloaded I had success by using pm->curfont = 10; I think. You can look at the list and see what font matches to what number with some experimentation I think.

In order to get the letters in the search box to not overlap I had to increase pm->text_w to 11, but this caused the issue of the first letters starting off the screen. If you don't set pm->text_w, or if you set it to pm->text_w = 6 then the text stays on screen but then each new letter overlaps the lasts so its impossible to read what your writing out.

I will try writing my keyboard layout as a .kbd file, but another thing I have in my personal repo is that the first time you pick a letter the keyboard is laid out based on the most common First letters in English, and then it switches the keyboard to be based on the most common letters in general after that. This feature isn't the most important but do you think it would be a good addition as well?

Cool. I like that the text entry area isn't taking up half the screen like it normally does.
I got the text entry to be only the bottom part by changing pm->main_y = 300; this moves the text entry to the bottom of the screen, otherwise it would be covering up the keyboard. The best way for this would likely be to find what 1/8 of the screen size would be or so, set pm->keyboard_margin to be that size, then do some math to make sure that pm->main_y is set so the text entry is still at the bottom.
Title: Re: Fiio M3k
Post by: amachronic on June 01, 2021, 02:14:28 PM
I will try writing my keyboard layout as a .kbd file, but another thing I have in my personal repo is that the first time you pick a letter the keyboard is laid out based on the most common First letters in English, and then it switches the keyboard to be based on the most common letters in general after that. This feature isn't the most important but do you think it would be a good addition as well?

I suspect you'd have to type a lot before that kind of tweak saves time, versus the initial confusion of getting used to it, especially if using the keyboard only occasionally. I doubt it's widely useful enough to be worth including. Personally I've never seen a software keyboard do this -- I fall into the "confused occasional user" category ;)
Title: Re: Fiio M3k
Post by: GSV3MiaC on June 03, 2021, 01:07:54 PM
Late to the party .. my M3K just arrived (probably be obsolete next week, already hard to find) and I am wondering if/when we will have an 'easily installable' RB version (i.e. one which doesn't require a degree in CS, and three levels of firmware fiddles). Is there any sort of forecast - is that even a feasible goal? Coming from the ClipZip world, I was looking for a simple solution for my old age!

Meantime I guess I can use the Vortex port, although that seems no longer updated, and I think maybe USB/PC connection doesn't work unless you revert to original Firmware?
Title: Re: Fiio M3k
Post by: dconrad on June 03, 2021, 01:29:25 PM
Late to the party .. my M3K just arrived (probably be obsolete next week, already hard to find) and I am wondering if/when we will have an 'easily installable' RB version (i.e. one which doesn't require a degree in CS, and three levels of firmware fiddles). Is there any sort of forecast - is that even a feasible goal? Coming from the ClipZip world, I was looking for a simple solution for my old age!

Meantime I guess I can use the Vortex port, although that seems no longer updated, and I think maybe USB/PC connection doesn't work unless you revert to original Firmware?

Hi GSV3MiaC -

It's not quite "click one button" easy yet, but I assume you saw the new installation instructions (https://forums.rockbox.org/index.php/topic,53858)? It's quite a bit better process than it used to be.
Title: Re: Fiio M3k
Post by: GSV3MiaC on June 03, 2021, 02:38:58 PM
Yes I saw that ... if this is 'quite a bit better' I guess the previous version was truly horrific! :)

I guess I will just have to screw up my courage, dust off my PC, and see whether I can actually follow that far enough to boot RB. First I need a new TF card or two.
Title: Re: Fiio M3k
Post by: amachronic on June 03, 2021, 04:08:09 PM
Yes I saw that ... if this is 'quite a bit better' I guess the previous version was truly horrific! :)

I guess I will just have to screw up my courage, dust off my PC, and see whether I can actually follow that far enough to boot RB. First I need a new TF card or two.

It used to be terrible!

It's now just a one-liner on the command line, more or less. I know the command line is a discouragement to some people, and I wanted to add support into the Rockbox utility but it seems this method of installation is at odds with how it normally works, so I kind of gave up. And making it work without manually running Zadig first is another major annoyance.

Speaking of the new instructions it looks like I totally forgot to announce them properly here...  :(  I was meaning to do that.

Anyway, good luck! If you have any issues feel free to contact me, I'm happy to help.
Title: Re: Fiio M3k
Post by: amachronic on June 06, 2021, 07:25:16 AM
I'm happy to announce we have a working version of jztool for Mac! You can now easily install Rockbox on the M3K from your Mac. Many thanks to dconrad for doing the testing. Instructions and download links can be found at the installation thread (https://forums.rockbox.org/index.php/topic,53858.0.html).
Title: Re: Fiio M3k
Post by: darkstarcumberland on June 07, 2021, 08:00:13 AM
Very cool! I will give it a try when I get some moments to fiddle with it. Right now everything is working "fine enough" and I have some hours of new music to listen to on the device before I start playing with the firmware again ;-)  Cheers
Title: Re: Fiio M3k
Post by: bahus on June 10, 2021, 12:48:48 AM
Anyone else annoyed by the tiny font is welcome to try.

Is it possible to extract XVortex .rockbox folder from his images? He seems to made a bunch of changes to standard theme and bigger font is one of them. Would be cool to have it on native port too.
Title: Re: Fiio M3k
Post by: amachronic on June 10, 2021, 04:34:07 AM
IIRC XVortex is using the Xhibition theme ported to 240x320. You could contact XVortex and ask if he'd release the theme.

The theme can also be grabbed from the M3K.fw package, but you need a Linux box to extract it. M3K.fw is just a zip file. Inside are more zip files named update001.zip, etc. Unzip all of them, and you will see files like system.ubi_001. Use cat system.ubi_* > system.ubi to combine these into a single file. I uploaded a script to the Shanling Q1's wiki page called ubi_extract.sh (https://www.rockbox.org/wiki/pub/Main/ShanlingQ1Port/ubi_extract.sh) which you can run to convert the UBI image to a tarball. You need mtd-utils and the nandsim, ubi, and ubifs kernel modules installed in order to run that script.

Alternatively you could install the XVortex firmware and use a script to copy the .rockbox folder from the internal NAND to the SD card. I don't know offhand where it's located though.
Title: Re: Fiio M3k
Post by: janssea2 on June 10, 2021, 07:53:00 AM
For the moment I use Rockbox from XVortex. Can I overwrite this with jztool?
Title: Re: Fiio M3k
Post by: bahus on June 10, 2021, 07:59:31 AM
For the moment I use Rockbox from XVortex. Can I overwrite this with jztool?
It worked for me. I installed it right over XVortex build. Only I had to install libusbk instead of suggested winusb zadig driver. Not sure if it's somehow related or just a some glitch on my system.
Title: Re: Fiio M3k
Post by: vitt13 on June 10, 2021, 08:10:46 AM
Is it possible to extract XVortex .rockbox folder from his images? He seems to made a bunch of changes to standard theme and bigger font is one of them.
zip archive of extracted /ubifs-root/usr/rockbox content form XVortex's firmware
https://www.mediafire.com/file/c7yl5ruftwiwckf/rockbox.zip/file size 16.19MB
Probably you can grab 'fonts', 'themes' and 'wps' folders with included files from the archive.
I use 'ubireader_extract_files' tool from https://github.com/jrspruitt/ubi_reader
Title: Re: Fiio M3k
Post by: vitt13 on June 10, 2021, 08:36:15 AM
Windows users can use the 'kitchen' https://www.mediafire.com/file/gyau3tsje1kwcz7/Firmware_Kitchen_fiio_m3k_m5.zip/file 6.86MB
What this 'kitchen' does:

- extract parts (partitions) from original firmware file format M3K.fw to use the parts with 'USB Cloner Tool' or to modify/customise the parts
- extract/create UBIFS images i.e. 'system.ubi' and 'data.ubi'

How to:
To extract parts from OTA firmware (M3K.fw) you need to place the M3K.fw file to 'in' folder and run the batch file unpack_M3K_to_parts.bat.
The 'out' folder is output directory for extracted parts i.e. x-loader-pad-with-sleep-lib.bin, xImage, system.ubi, and data.ubi (if presents).

To extract the content of UBIFS image 'system.ubi' or 'data.ubi' you need to presence of the file 'system.ubi' or 'data.ubi' in the directory 'out'
Then run the batch file unpack_system.ubi.bat or unpack_data.ubi.bat
You will get the new folder 'unpacked_system' or 'unpacked_data' with extracted UBI image's content and service file 'perms.txt'.

Attention: this 'kitchen' cannot build back M3K.fw file from the parts.
Use mkotapackage https://github.com/VitToCode/linux-recovery-ota/releases/tag/1.0 to build back the M3K.fw
Title: Re: Fiio M3k
Post by: bahus on June 10, 2021, 08:39:14 AM
Thank you vitt13! Bunch of useful tools indeed.
Title: Re: Fiio M3k
Post by: amachronic on June 10, 2021, 08:56:38 AM
Use mkotapackage https://github.com/VitToCode/linux-recovery-ota/releases/tag/1.0 to build back the M3K.fw

Did you get a hold of the signing keys? ie. will a patched image be flashed by the stock recovery?
Title: Re: Fiio M3k
Post by: vitt13 on June 10, 2021, 09:35:26 AM
Did you get a hold of the signing keys? ie. will a patched image be flashed by the stock recovery?
Yes. I used to post it https://forums.rockbox.org/index.php/topic,52917.msg247653.html#msg247653
M3K.fw is signed with testkey.pk8/testkey.x509.pem signing keys luckily found on this repo https://github.com/YuanhuanLiang/X1000/tree/master/external/recovery/resource/security
Using these keys I got exactly the same files updateNNN.zip, i.e. binary the same. Only last stage, packing M3K.fw from those archives was different, but original M3K.fw file looks like simple uncompressed and unsigned zip archive.
Title: Re: Fiio M3k
Post by: amachronic on June 10, 2021, 02:11:20 PM
Wish I had actually paid attention the forum thread back then... I was told the key was unknown.

This would greatly simplify installation for end users, just dump a patched FW file on the SD card and use the stock recovery. All I'd need to do is get dual boot working in the Rockbox SPL, so the OF recovery is accessible once Rockbox is installed.
Title: Re: Fiio M3k
Post by: Julian67 on June 10, 2021, 03:54:04 PM
Wish I had actually paid attention the forum thread back then... I was told the key was unknown.

This would greatly simplify installation for end users, just dump a patched FW file on the SD card and use the stock recovery. All I'd need to do is get dual boot working in the Rockbox SPL, so the OF recovery is accessible once Rockbox is installed.

Dual boot would be great.  I just bought my M3K, receiving it yesterday.  The original firmware is actually nicely usable.  Gapless works perfectly with albums of flacs, a real deal breaker for me.  But only Rockbox has the perfection of Auto-Change Directory with the option of using random *and* constraining the auto-change.  This is a triumph of civilisation :-)  So I installed Rockbox and it is really impressive on this device.  I've been using iRiver H140 with SSD for years and the M3K seems to be the first time I feel I've found something as good, perhaps better in most ways, which can also handle files of different bit-depth and sample rate with ease.  And the M3K doesn't hiss with low impedance IEMs so that is a big improvement.  The one feature that I'd like to use in the original firmware is the ability to work as a USB DAC.  It would occasionally be very useful.  The experience of installing Rockbox onto this target has been very good.  While Fiio's UI is decent enough, I've been reminded that Rockbox's UI and options are so absolutely focused on the user, so mature and refined (the UI not us users!), that it really serves as an advertisement for what is possible when people collaborate.

Many thanks amachronic for moving this device from a maybe/if only curiosity to a genuine daily driver.

And if anyone is not aware, the M3K is now discontinued.  Here in UK you can no longer find it new on amazon or advancedmp3players or any of the usual Fiio retailers.  But there are retailers on aliexpress who still have stock.  These players are vanishing from retail though.  My first aliexpress purchase was refunded as the vendor actually ran out of product, but the next one had the device at my door in 8 days, so I'm happy.  But if you want one, now is the time.
Title: Re: Fiio M3k
Post by: dconrad on June 10, 2021, 04:43:17 PM
If dual-boot is going to happen, any chance it could be done while preserving the lightning-fast boot time? I love the fact that the device is on within 5 seconds (3 of which are holding the button down!).
Title: Re: Fiio M3k
Post by: amachronic on June 10, 2021, 04:59:23 PM
There won't be any change to the rockbox boot time. It's already doing everything else needed for dual boot, what's missing is the final hardware fiddling before jumping to Linux. I've been looking over the x-loader source (found it from vitt13's stuff, thanks!) and it seems I'm not missing much.
Title: Re: Fiio M3k
Post by: vitt13 on June 10, 2021, 05:21:45 PM
the x-loader source (found it from vitt13's stuff,
Yeah, I found two repos
https://github.com/JaminCheung/x-loader
https://github.com/YuanhuanLiang/X1000/tree/master/bootloader/x-loader
The second one looks newer.
Title: Re: Fiio M3k
Post by: mario69 on June 14, 2021, 06:38:40 AM
i dont understand if this version of rockbox:
http://xvtx.ru/rockbox/download.htm
it's the same version I can download from Rockbox Development Builds
thanks
Title: Re: Fiio M3k
Post by: amachronic on June 14, 2021, 08:29:37 AM
The XVortex version is an "unofficial" 3rd party build. It's also not being updated anymore, as far as I know. The development builds on rockbox.org are for the native M3K port. You can find installation instructions for it here (https://forums.rockbox.org/index.php/topic,53858.0.html).
Title: Re: Fiio M3k
Post by: mario69 on June 14, 2021, 10:14:43 AM
thank you! to switch from XVortex to rockbox how do i do? do i have to uninstall xvortex? or is there a particular procedure?
Title: Re: Fiio M3k
Post by: amachronic on June 14, 2021, 01:27:47 PM
You can install over top of the XVortex firmware, or any other FiiO firmware version. The native port of Rockbox doesn't depend on or interact with the original firmware whatsoever.
Title: Re: Fiio M3k
Post by: amachronic on June 14, 2021, 06:16:57 PM
Dual booting the original FiiO firmware with Rockbox is now supported. Download links for the updated bootloader are at the installation thread (https://forums.rockbox.org/index.php/topic,53858.0.html) as usual.

I'm sure everyone who likes the USB DAC feature will appreciate this.
Title: Re: Fiio M3k
Post by: 7o9 on June 15, 2021, 01:23:38 AM
Great job, it works very well.

Remarkable to see how long it takes the original firmware to get to the main menu. I cannot imagine I will be in the OF often, but it is great to have the option.

Also the tapping on the top/bottom of the middle part of the touchpad in Rockbox to go up/down is something I immediately miss in the OF. The scrolling in the OF is really annoying.
Title: Re: Fiio M3k
Post by: KatsuoHana on June 15, 2021, 04:03:02 AM
Very nice! Though I'd also add an option to boot original FW to recovery menu.
Title: Re: Fiio M3k
Post by: mario69 on June 15, 2021, 08:55:11 AM
when there will be the stable version must you follow the procedure described in the Official FiiO M3K Native installation instructions page? or will it be like the one you do for the sansa clip player? that is much simpler, thanks
Title: Re: Fiio M3k
Post by: Julian67 on June 15, 2021, 09:30:46 AM
Dual booting the original FiiO firmware with Rockbox is now supported. Download links for the updated bootloader are at the installation thread (https://forums.rockbox.org/index.php/topic,53858.0.html) as usual.

I'm sure everyone who likes the USB DAC feature will appreciate this.

Works perfectly, thank you very much.
Title: Re: Fiio M3k
Post by: amachronic on June 15, 2021, 11:01:12 AM
when there will be the stable version must you follow the procedure described in the Official FiiO M3K Native installation instructions page? or will it be like the one you do for the sansa clip player? that is much simpler, thanks
Once the M3K is officially stable, you will be able to install it through the Rockbox utility. In fact, I think the need for manual bootloader installation is pretty much the only reason the M3K port is classified as "unstable."

Unfortunately, the installation method for the M3K is substantially different from other Rockbox players and will require a fair amount of effort to implement, so if you're waiting for an easy install with the Rockbox utility, you may be in for a bit of a long wait.
Title: Re: Fiio M3k
Post by: bahus on June 15, 2021, 11:49:52 AM
I guess providing latest "M3K.fw" firmware with rockbox bootloader incorporated would also count as "simpler way" to install rockbox.

Title: Re: Fiio M3k
Post by: saratoga on June 15, 2021, 01:35:02 PM
Dual booting the original FiiO firmware with Rockbox is now supported. Download links for the updated bootloader are at the installation thread (https://forums.rockbox.org/index.php/topic,53858.0.html) as usual.

I'm sure everyone who likes the USB DAC feature will appreciate this.

FWIW, we usually strongly discourage putting installation instructions in the forums since it is a lot easier for people to find the M3K wiki which is linked from the front page of Rockbox.org.  Once things are worked out, someone should put the instructions in the wiki (and eventually the manual).

Title: Re: Fiio M3k
Post by: amachronic on June 15, 2021, 02:04:49 PM
FWIW, we usually strongly discourage putting installation instructions in the forums since it is a lot easier for people to find the M3K wiki which is linked from the front page of Rockbox.org.  Once things are worked out, someone should put the instructions in the wiki (and eventually the manual).
Ah, my bad. What you're saying makes sense. The instructions were originally in the wiki, but since the bootloader binary release I moved the instructions to the forum... I assumed that was what the "Manual installation" forum was for, but I see now it seems to be intended for questions relating to manual installation.
Title: Re: Fiio M3k
Post by: vitt13 on June 15, 2021, 04:04:18 PM
Dual booting the original FiiO firmware with Rockbox is now supported.
Thank you for your incredible work.
Am I right that dual boot bootloader replaces 'Vol Up and Power' combination that originally uses to run OF recovery (update OF from microSD).
So do we need to save and take in safe original bootloader dump to be able one day reflash crashed OF?
Is it possible to add menu item in rockbox recovery that runs original recovery (update OF from microSD)? It's stupid, yes, because it can replace rockbox bootloader and then we'll need to flash rockbox bootloader again.
So, if we'll have M3K.fw with rockbox bootloader we need a way to run update from M3K.fw after.
Title: Re: Fiio M3k
Post by: mario69 on June 15, 2021, 04:52:06 PM
i try to install rockbox but i receive this error message:
[  ERROR] libusb_open: Operation not supported or unimplemented on this platform

i follow your procedure:
First, download the Rockbox bootloader bootloader.m3k and the installation utility jztool for your platform. You will need to refer to the bootloader file later on the command line so it's recommended to put both files in the same folder.
Next, connect the M3K in USB boot mode: plug in one end of the USB cable, and then plug in the other end while holding down the Volume Down button. If you did it correctly then the button light will turn on and the LCD will remain off. Since the USB boot mode is very low level, you might not see any indication on your computer that a USB device was plugged in.

Windows users should now follow the USB driver installation instructions below, before running jztool.

To load the Rockbox bootloader, open a terminal / command prompt in the folder where you downloaded jztool and run the command below. If you have put bootloader.m3k in different folder, you will have to adjust the path accordingly.

Windows:
Code: [Select]
jztool.exe fiiom3k load bootloader.m3k

what am I doing wrong?
thanks
Title: Re: Fiio M3k
Post by: amachronic on June 15, 2021, 05:42:43 PM
Am I right that dual boot bootloader replaces 'Vol Up and Power' combination that originally uses to run OF recovery (update OF from microSD).
...Is it possible to add menu item in rockbox recovery that runs original recovery...
The OF recovery can be accessed by holding Play+VolUp and Power. (Not the easiest combo, I know.) And yes, it erases the rockbox bootloader. The recovery menu doesn't have an option to boot the OF or OF recovery because of some technical issues with the current implementation. Hopefully I can fix that in the future.

So, if we'll have M3K.fw with rockbox bootloader we need a way to run update from M3K.fw after.
I see patching M3K.fw as a temporary stopgap to ease installation until the M3K is supported by the Rockbox utility. I'm not a big fan of this idea for the long term:
Title: Re: Fiio M3k
Post by: amachronic on June 15, 2021, 05:43:48 PM
i try to install rockbox but i receive this error message:
[  ERROR] libusb_open: Operation not supported or unimplemented on this platform

Did you install the USB drivers with Zadig?
Title: Re: Fiio M3k
Post by: vitt13 on June 15, 2021, 06:54:41 PM
The OF recovery can be accessed by holding Play+VolUp and Power. (Not the easiest combo, I know.)
My bad, I did not read the instructions carefully. Thank you!

I see patching M3K.fw as a temporary stopgap to ease installation until the M3K is supported by the Rockbox utility. I'm not a big fan of this idea for the long term:
Actually it's not patching the whole M3K.fw, it's actually creating new one with public tools. But using only single part (bootloader) is not acceptable for OF 'recovery' app. Technically packing tools allow to create config with only particular parts to update, but 'recovery' app on the player side is not accept them. I need to place and pack all three parts (i.e. dumped bootloader, kernel and system parts too) to new M3K.fw or at least bootloader and system image. And it works.
I.e.
using only bootloader gave me 'update failed'
'bootloader + kernel' gives me freeze on progress bar 'Updating... 8%'
'bootloader + system' gave me successfully update and installed bootloader in result.
'bootloader + kernel + system' gave me successfully update and installed bootloader in result.
Title: Re: Fiio M3k
Post by: amachronic on June 15, 2021, 07:17:41 PM
'bootloader + kernel + system' gave me successfully update and installed bootloader in result.
What if you make the kernel and system parts zero length? Might it be satisfied with that?
(let's just hope there's not an off-by-one error which erases the first 128k of those partitions ;) )
Title: Re: Fiio M3k
Post by: vitt13 on June 16, 2021, 06:24:01 AM
What if you make the kernel and system parts zero length? Might it be satisfied with that?
(let's just hope there's not an off-by-one error which erases the first 128k of those partitions ;) )
No, it looks like it has some verification that do not allow to flash corrupted UBIFS image. Even if I use raw image, or truncated image, it accepts either valid full-sized mtd3 partition image in 'normal' (raw) update mode or valid ubifs image in 'ubifs' update mode.
Here is the source of the 'recovery' application that looks like 'demo' functional https://github.com/JaminCheung/linux-recovery/tree/master/client/recovery
FiiO's 'recovery' application has no logging (as I remember) and has more verification.
---
Here is the resulted original firmware with 'dual boot' bootloader.
https://www.mediafire.com/folder/p2l3a22u3d7kk/M3K_fw_1.4.5_dualboot_rb
M3K.fw 41.54MB
Title: Re: Fiio M3k
Post by: vitt13 on June 17, 2021, 03:03:38 PM
Is it possible to extract XVortex .rockbox folder from his images? He seems to made a bunch of changes to standard theme and bigger font is one of them.
Xhibition theme, credits to XVortex. https://www.mediafire.com/file/txji2isj04wmcm3/xhibition.zip/file
Pay attention: I included config.cfg for example. Make sure you don't replace your own.
Add the string to config manually, if you use customized config
Code: [Select]
font: /.rockbox/fonts/20-Terminus-Bold.fnt
wps: /.rockbox/wps/xhibition.wps
sbs: /.rockbox/wps/xhibition.sbs
backdrop: /.rockbox/backdrops/xhibition2.bmp
Title: Re: Fiio M3k
Post by: bahus on June 18, 2021, 05:29:15 AM
Xhibition theme, credits to XVortex.

Yeah thanks. I've been able to extract it myself from rockbox archive you posted earlier. But TBH I ended up with some different theme (I just didn't realize that we already have so many themes for this device (https://themes.rockbox.org/index.php?target=fiiom3k))
Title: Re: Fiio M3k
Post by: bahus on June 18, 2021, 05:46:44 AM
amachronic
There was (it's broken now (https://forums.rockbox.org/index.php/topic,51844.msg247984.html#msg247984)) useful feature for sansa players - ability to store .rockbox folder in some subfolder(like rbclipzip/.rockbox or rbm3k/.rockbox):
https://forums.rockbox.org/index.php/topic,51844.msg247984.html#msg247984

In short you can specify subfolder name in player specific file (rockbox_main.[PlayerName] like rockbox_main.clipzip)

I find it super useful because it allows you to prepare single "bootable" SD card for different players. Can you implement(or fix and enable) this feature also for m3k(and other x1000 ports)?
Title: Re: Fiio M3k
Post by: amachronic on June 18, 2021, 07:48:33 AM
I was looking into that "multiboot" stuff last night for other reasons, guess that explains why that feature didn't appear to do anything... Thanks for the tip. I'll see if I can get it working, it sounds very useful.