This is the bug/patch tracker for Rockbox. Click here for more information.
Quick links: Bugs · Patches · Rockbox frontpage
FS#10267 - Sansa AMS FM Radio fix
Attached to Project:
Rockbox
Opened by Michael Chicoine (mc2739) - Monday, 01 June 2009, 01:55 GMT+2
Last edited by Bertrik Sikken (bertrik) - Sunday, 21 June 2009, 00:01 GMT+2
Opened by Michael Chicoine (mc2739) - Monday, 01 June 2009, 01:55 GMT+2
Last edited by Bertrik Sikken (bertrik) - Sunday, 21 June 2009, 00:01 GMT+2
|
DetailsThis patch fixes the FM radio problems that started with r21088.
|
This task depends upon
Closed by Bertrik Sikken (bertrik)
Sunday, 21 June 2009, 00:01 GMT+2
Reason for closing: Fixed
Additional comments about closing: Fixed in svn r21416
Sunday, 21 June 2009, 00:01 GMT+2
Reason for closing: Fixed
Additional comments about closing: Fixed in svn r21416
FS#10048?FS#10048at all up to this point.Second, I'd like to simplify the "generic i2c" driver. We adapted the "generic i2c" driver for the ams targets, we are currently the only users of that driver but it's not doing exactly what the OF does. In my opinion this driver can be made much simpler, for example scl_hi and scl_lo can be merged into a single scl_set function, scl_input and scl_output can be merged into a single scl_dir function, also the 6 different kind of delays can be merged into a single delay that takes an argument (e.g. number of us to wait, or number of half-bit units to wait)
How about writing a usleep() function using TIMER2_VALUE register, since this timer is aways running ?
I believe that would also make FM radio work in
FS#10048as well.Is 4us (250kHz) too large, do we need 400kHz ?
A look in the disassembly and a quick calculation shows that the delay is probably already long enough already (6 instructions per loop).
The most important fix is an extra delay in i2c_start that seemed to be missing. Also it removes some things that seem to be unnecessary.
Still hangs when going to the FM Radio screen. Changing the fm_delay() still seems to correct the problem.
I looked up the datasheet of the radio chip and it seems to support 400 kHz i2c. I'm a bit surprised that apparently a larger delay is needed, maybe there's another bug in the generic i2c driver somewhere. A dissassembly of the current code in SVN shows 6 cycles for the delay loop, so even when no pipeline stalls occur due to branching, the default delay of 100 loops should take at least 2.4 us at 248 MHz CPU clock, which should be more than enough.
Also, the failure is not a deadlock, as the backlight still goes off at its normal timeout and a keypress will turn it back on. The dap will turn off as normal with the power button.
I have also noticed that if I made the delay is too long, it will hang with the logo on the screen and never get to the main menu. I guess that the problem here is with the test for the FM Radio hardware on startup.
Using patches from
FS#10048, I have noticed that the radio will sometimes work with the additional delay and sometimes not. Using this patch: http://www.rockbox.org/tracker/task/10048#comment30627 I was not able to get the radio working with any delay setting. With the previous patch, the radio worked with the 500 loop delay.On my clip, with
FS#10048, with fm_delay actually intentionally lowered down to 20 cycles and with CPU boosted, this still works.Still hangs before entering the FM Radio screen. Increasing fm_delay() loops allows proper operation.
* perhaps i2c bus method selection fails in some way (the fm chip can use both i2c and some other 3-wire protocol). This "just worked" so far and has not really been looked into, but maybe it's giving trouble now at higher CPU speeds.
* perhaps there's still some bug in the generic_i2c driver. I think there's a tiny time window where a short circuit can exist on the SDA line between the fm radio and the as3525 controller: just after sending a byte to the fmradio, we expect an ACK bit back from the fmradio but the SDA line is still in output mode. However the OF seems to do it like this as well.
* perhaps the firmware version of the fmradio chip has an influence on behaviour. The si4702 comes in two firmware versions, 16 and 19. Can you check the chip ids (first two values in the fmradio debug screen)? The radio has to be enabled for this debug screen to work. My clip shows 0x1242 0x1053 indicating an si4702 with firmware version 19.
Uhm... fmradio debug screen shows only zeros on my e250v2 (see screendump)
and bertrik's Clip is version 8, si 4702, Firmware version 19
The datasheet I have is for firmware version 19, we should get a copy of version 16 and see if there is any differences.
FS#10048. The only changes I made were to run in fastbus only mode at 62 MHz boosted and 31MHz unboosted. I will try to test higher frequencies and find the failure point. I have the same chip ids as mc2739.Changing fm_delay to 500 does not help.
However changing DBOP clock to:
#define AS3525_DBOP_FREQ (AS3525_PCLK_FREQ/2)
in an otherwise vanilla r21088 gets the radio going.
This comes from experimenting, not from any knowledge of how or why DBOP clock affects the FM chip.
I have not yet tried the generic_i2c.c patch.
FTR the chip ID is 0x1242 0x0850
The UI seems reasonably responsive with this setup - test_fps says 44.7 fps unboosted, spacerocks is playable.
I looked a bit at the fuze and e200v2 display driver and noticed that the fuze display driver configures GPIO A7 as output and sets it low, this pin is also used for FM radio I2C. The e200v2 display driver doesn't do this. I hope there isn't really any dual-use for this pin so this could simply be a bug, but maybe it has a side-effect of making the FM radio work. Can someone with a fuze try to remove the GPIO A7 stuff (both direction setting and level setting) from the fuze lcd driver and see if this causes the radio to stop working?
I also looked a bit closer at the e200v2 OF. It actually uses a really tiny delay, just 3 loops of 4 instructions. One thing in the e200v2 OF that I didn't find in the Clip OF is that the SDA and SCL I2C lines are both set to 1 for some time before sending an I2C start condition.
fix1: increase si4700 crystal oscillator startup delay
fix2: wait some time after setting i2c SCL signal as output
fix3: more extensive i2c initialisation
fix1: radio does not work, screen cleared except for backdrop and statusbar, not deadlocked (backlight goes off, keypress turns backlight on)
fix2: hangs at Rockbox logo, not deadlocked (backlight goes off, keypress turns backlight on)
fix3: radio does not work, screen cleared except for backdrop and statusbar, not deadlocked (backlight goes off, keypress turns backlight on)
I assume the patches are intended to be applied separately, not all at once to the same source tree?
Like you suspected it was waiting in the loop for the ready signal and it never arrives.
Same results as jago
Attached screenshot of FM radio debug screen
Perhaps it simply needs more time than expected to power up. Can you try attached patch?
Radio still not working with e200_radio_fix1.patch, e200_radio_fix5.patch and si4700_enable_delay.patch