FS#8624 - Serial port driver for iPod
Attached to Project:
Rockbox
Opened by Linus Nielsen Feltzing (linusnielsen) - Thursday, 21 February 2008, 09:12 GMT
Last edited by MichaelGiacomelli (saratoga) - Thursday, 25 December 2008, 01:50 GMT
Opened by Linus Nielsen Feltzing (linusnielsen) - Thursday, 21 February 2008, 09:12 GMT
Last edited by MichaelGiacomelli (saratoga) - Thursday, 25 December 2008, 01:50 GMT
|
DetailsThis patch is a work in progress that implements the Accessory Protocol in the iPod's that support it. It currently only builds for the iPod Video, but should work on other models as well.
Currently only a few of the Mode 2 commands are implemented. |
This task depends upon
Closed by MichaelGiacomelli (saratoga)
Thursday, 25 December 2008, 01:50 GMT
Reason for closing: Accepted
Additional comments about closing: Committed in r19585.
Thursday, 25 December 2008, 01:50 GMT
Reason for closing: Accepted
Additional comments about closing: Committed in r19585.
As well, a suggestion (for anyone interested in this patch) might be to add a means for logging the things that aren't recognized yet for further development.
I have much more work to do before this gets usable.
Sound works and the volume up and down buttons do adjust the volume but the status bar volume indicator dos not change.
At least I don't see any reason not to include it.
I would love to see progress on this driver, but unfortunately i can't code. I am happy to provide my testing though!
Any idea? Thanks!
For some reason my ipod is not turning on the serial port. It's like the serial port input is really set as an output.
In the source I see "/* Route the Tx/Rx pins. This probably applies to the PP502x only */" Maybe I need to route the pins a different way. I don't have the documentation describing the 0x70000018 register, maybe you can point me in the right direction?
(*(volatile unsigned short *)(0x6000D950)) = 0x4000;
(*(volatile unsigned short *)(0x6000D960)) = 0x4000;
(*(volatile unsigned char *)(0x6000D970)) = 0x40;
(*(volatile unsigned long *)(0x7000008C)) &= ~4;
GPO32_ENABLE &= ~4;
I now get a solid 3.3V signal on the serial input pin.
I'm showing my ignorance of Rockbox here, but is there an easy way to output incoming bytes to screen or file?
I'll post a patch of my changes when it's a bit more solid.
Thanks for the help guys.
Maybe post your work-in-progress anyway, people may be able to help out with stuff like the track transition...
Another problem I have is that sometimes my build will cause the iPod to crash somewhere in thread.c on startup. None of my code should even be running yet. If I change the length of the code with asm(" nop"); then it will work! I haven't tested if it is my code, my build tools, or what.
could remember what volume was set on the remote instead of resetting it to full volume each time the remote is connected.
Your patch is working pretty well,
but I too am noticing some buttons mapping problems.
Maybe it is just the devices I'm using,
but the vol+ and vol- buttons do not work.
I am using a Nano, (just added the Define from the video config over)
and the iPod Radio Remote,
but I believe these would use the same protocols,
right?
I have no idea how the volume stuff is handled by RockBox as my JVC head unit does not use the volume commands. The remote and volume stuff was in Linus' patch above and I just copied it over. I'll try to have a peek and see if there is anything obvious that is wrong but I have no way to test it.
http://forums.rockbox.org/index.php?topic=8937
The dock connector is line out (duh) so changing RockBox volume would have no effect on the sound out of the dock connector, and that is why the remote has a hardware volume control.
lol.
Thank you.
Music gets played at twice the speed and a high pitch
I'll attach my rockbox.ipod file
Does my rockbox.ipod work on your iPod?
What iPod do you have, size of hard drive, etc?
I just don't understand what I am doing wrong. do I need to apply the pp-serial-6.patch as well as the iap.patch?
My patch contains everything in pp-serial-6.patch so just use one or the other. Have you tried just the pp-serial-6.patch?
So what do you mean unofficial radio remote? Can you post a link to your device?
your latest iap.patch also works fine in regards to audio, but again lacking controls
this is my remote in question:
http://www.pearl.de/a-PX2069-1608.shtml
it's basicaly a clone of the apple radio remote. It has a switch on the side to put the ipod into radio mode. It works fine in the OF. I bought it, because it is much cheaper than the official one. By looking at the dock connector, only the following pins have a connection: 3,4,12, 13, 15, 16 and 18 (left to right)
Any chance of it being easily made?
http://www.rush2112.net/mkportal/modules/oscommerce/product_info.php?products_id=34
I tapped into the wires from the JVC, but a better way would be one of these from Ridax: http://home.swipnet.se/ridax/soldext.jpg
David, can that device be inserted between the iPod and an accessory? It looks like it makes the PC into an accessory, which would be useful in sending commands to the Apple firmware for testing. Do you know of anything that would work as a monitor, similar to my kludged together docking station?
way too technical for me.
Any chance of a software end to the problem?
(A capture patch for rockbox preferably?)
http://www.rockbox.org/tracker/task/6494
Problem is,
it hasn't been updated in over a year.
Maybe something in the bootloader that hooks the serial interrupt, and then the Apple firmware will load on top of it. It might work but will be pretty complicated.
Sascha, try that with your remote and tell me what it says. If the command is documented somewhere then I could implement it.
staying in that menu, without pressin *any* button (neither on the ipod nor on the remote), the IAP PACKET changes every 10 seconds.
45 08 1e 20 04 d8 45 08 and so forth, sometimes instead of 1E, it reads 1A, but the sequence stays the same
pressing any button does not change that sequence either, looks like the remote is "polling" or something.
You can try changing the divisor on this line in serial.c:
SER0_DLL = 0x4c; /* 24000000/76/16 = 19736 baud */
It might be 9600, so change it to this and see what happens:
SER0_DLL = 0x9c; /* 24000000/156/16 = 9615 baud */
is seems my length bit isn't including the mode bit.
It's this way for both my Radio Remote,
and iHome.
Radio Remote:
Play:
04 02 00 01 00 F9 21 E1
Left:
04 02 00 10 00 EA 21 E1
Right:
04 02 00 08 00 F2 21 E1
iHome:
Play:
03 02 00 01 EA 55 03 02
Off:
Unknown (Flashes some command multiple times)
44 80 92 46 80 92 46 88
as before, button presses do not change that sequence.
I thought the length bit included the checksum.
0x27 for 38400 bps
0x1A for 57600 bps
0x0D for 115200 bps
When not pressing anything, the Packets are: 06 02 00 00 00 00 00 F8
pressing play will yield this sequence, for the time play being held: 03 02 00 01 FA 00 00 F8
same with ffw: 03 02 00 08 F3 00 00 F8
rev: 03 02 00 10 EB 00 00 F8
switching to "radio" on the remote shows: 02 00 05 F9 00 00 F8
I also noticed, that with this divider, plugin in my remote seems to send the center-button event (select), and then lock the touchwheel on the ipod wont repsond anymore. Pressing play on the remote has the same effect, i.e. rockbox enters the currently higlighted entry and the only button that has any effect is the play button on the remote. I can't get back.
The remote codes for pressing the buttons stay the same :)
they work now
I am trying to getting in this code. I tried to apply the patch
debug_menu.patch (0.7 KiB) to debug the status of the serial port with no success.
I get the error:
LD rockbox.elf
/home/luis/develop/rockbox/build/apps/debug_menu.o: In function `dbg_ports':
debug_menu.c:(.text+0xe78): undefined reference to `serbuf'
collect2: ld returned 1 exit status
make[1]: *** [/home/luis/develop/rockbox/build/apps/rockbox.elf] Error 1
make: *** [build] Error 2
Any suggestions?
only problem is the off button on the iHome doesn't work properly,
but I believe it is sending the 4 bit off command.
Is this supported yet?
(I don't think it is.)
Justin, what are the bytes displayed in the debug page for that off command? Is that button supposed to turn off the iPod completely?
it flashes some command multiple times.
Most of the time the length bit changes,
but every once in a while the param bit does also.
It turns if off (or puts it in a deep sleep) in the Apple firmware,
then changes it to charging mode to charge.
The problem is that on line 230 in iap.c the Mode 2 3-byte command size "serbuf[0]" should be 4 not 6.
The issue is that my logic3 clock dock communicates at 9600 baud and the autodetect doesn't go that low yet. If its possible to make it, that would be great!
Other than changing the above, it works great and rockbox gets even better!
FF 55 06 02 00 00 01 00 00 F7
I'm guessing yours does not send the two extra 0x00 at the end... I will make the code work for both.
Yes the autobaud did not support 9600. I couldn't figure out how to make it support 9600 as well as 38400. Maybe 38400 is not important so here is another version that supports 9600 instead.
If so,
try another bit?
The buttons could be OR'd together I guess but I don't have a remote to test to see if that works and I don't think rockbox does anything with multiple button presses anyway.
Your right, my docks commands are missing your ending 00 bytes.
It also sends mode 2 3-byte repeat and 4-byte shuffle commands that I've 'added' from the mode 4 code, adding an if statement to check (serbuf[0] >= 5 && serbuf[4] == 0) before the 3-byte check.
Is there any plans to further extend the mode 2 support?
I can no longer get my Radio Remote to work properly.
What happened?
it works with the old autodetect iap.patch,
but the current one breaks support for it.
I'm getting problems with held key repeat though on the shuffle and repeat commands - I'm wondering if it would be an idea to implement a skip until the mode 2 button release command has been issued? I think rockbox deals with the held key repeat for the play and stop commands.
Thanks again for working on this patch
still doesn't work.
I get randomly placed FC's, 1C's, and E0's after each button click.
Craig, I implemented something for key repeat for the shuffle and repeat commands, let me know if it works ok. Rockbox has WPS actions for stop and play but not for repeat and shuffle. Without implementing it as a WPS action it won't go through the key repeat stuff. It could be implemented that way but there aren't many bits left for additional buttons so I think implementing it in iap.c is a better choice.
receiving the same FC's, 1C's, and E0's.
and a slightly modified autobaud (With the differences copied from the current.)
that produces a broken build.
(Modified patch on the left, original on the right,
Pink lines mark differences,
Red symbols mark the differences.)
SER0_DLL = 0x1A; /* 24000000/26/16 = 57692 baud */
to this
SER0_DLL = 0x4E; /* 24000000/78/16 = 19230 baud */
That should get it to work until we figure out what is going on.
still not working,
it just has new bits this time.
I've got CC's FF's 4B's 0A's C0's 10's D4's 11's,
and all other random bits on held buttons,
no change on button press.
Give it a shot and let me know what happens.
I think at this point autobaud is not good enough and the best option is to use a configurable baud rate.
it will not work when I first put in the Radio Remote,
but it will when I select 19200 from the menu.
But,
it works again when I hit Auto,
which leads me to think this option isn't working right?
(Wouldn't it stop working again, since it couldn't find the right bitrate in the first place?)
it will not work when I first put in the Radio Remote,
but it will when I select 19200 from the menu.
But,
it works when I hit Auto afterwards,
which leads me to think this option isn't working right?
(Wouldn't it stop working again, since it couldn't find the right bitrate in the first place?)
Craig, I tried your patch and it works fine with my JVC @ 19200, thanks for your work!
I get the following error when I try to build with your patch:
iap.c: In function 'iap_handlepkt':
iap.c:664: error: syntax error at end of input
make[1]: *** [/home/user/rockbox/build_nano/apps/iap.o] Error 1
make: *** [build] Error 2
The accessory has a resistor between pin 21 and ground. The iPod measures the resistance to find out what type of accessory is attached. It is done using the ADC_ACCESSORY A/D channel, but we need to find out how to apply a voltage to the resistor to be able to measure. I guess it is done either via a port pin or the PCF chip. We can probably find that out by disassembling the Apple firmware.
Other device that I have is iHome iH9BR -- no luck with it because it doesn't support iPod Nano that less than 3rd generation.
But the patch is not yet perfect as I have to go into the settings menu and reselect auto each time I boot rockbox to make the patch work with my official
Apple radio remote.
I'm thinking of implementing what's missing. I have no idea howto, though. I thought I'd let you know, if anyone worked on the issue, maybe I can get some pointers :).
So my question is, Rockbox disabled LineOut Volume control by default. How would this affect the iPod accessories ?
I am presently not able to build it myself. Thank you for this nice development!
I am using my Ipod with an Dension interface for Audi.
Had a look at the source and I'm definitely intrigued with playing around with this. I was gonna post what I found for the iap packet values, but they seem to be different quite often, ESPECIALLY play, next, prev. There seems to be some pattern to what's changing...anyway. For now I'll just post what the ones that never do anything--anything in straight brackets being different observed values for that character.
00 02 00 00 fb 40 b9 f[f76] menu
00 02 00 00 fb 80 79 f[f76] select
00 02 00 00 fb 00 01 f7 scroll up
00 02 00 00 fb 00 02 f6 scroll down
So any thoughts on what I am seeing with all these changing values? Couldn't pin next and previous down at all... Also, how come I the leading 00 ends up as a 03 if I do commands from while in the debug menu?
In your above commands the first command is really 03 02 00 00. The first 03 is being overwritten by 00; this occurs when the Onstage receives an ack to the command, which is does not receive while in the debug menu. The rest of the bytes are really just junk from the previous command, so the FB 40 B9 FF are not part of the 03 02 00 00 command, they are part of a previous command.
The best way is to get a hardware serial logger; I realize this isn't easy for most people.
From one Ryan to another, thanks for taking the time to shed some light on those things for me. :)
The debug menu interface is just a hack that dumps the contents of the packet buffer.
Just has a quick look at the patch and it looks OK except for the english.lang part of the diff (has some .mine >>>> <<<<< lines)
One thing though, why is there the SYS_IAP_ events? why arn't they in tick tasks? or possibly using the newer event api instead of being in misc.c
I'm running build 19053 on a 3g ipod. I'd like to try it out with a Dension connector in my car.
Presently, the ipod plays but I was hoping to control it via the car deck or the steering wheel buttons rather than the ipod directly since the connection, and hence the ipod, is in the glove box.
thanks!
Mitch
http://forums.rockbox.org/index.php?topic=17841.0
By the way, I found this link just a few comments above this one.
on the 3G?
Can anyone else confirm that this patch does or does NOT work on a 4G iPod?
I do get sound from the speakers, but I get that without the patch applied as well.