Rockbox Technical Forums

Rockbox Development => Starting Development and Compiling => Topic started by: lights0ut on April 25, 2007, 02:22:15 AM

Title: gigabeat screen rotation patch
Post by: lights0ut on April 25, 2007, 02:22:15 AM
I'm running into some trouble getting this to work, the patch applies fine but I don't understand Takka's instructions very well. AFAIK they go something like this:
patch everything except screen rotate and make an oridinary build
now patch screen rotate.patch and make a second build
---missing a few steps---
hold up on boot to get landscape

he goes on to mention that it's needed to change all instances of ".rockbox" to ".rockbox_1" in the source code, but he's not specific as to which files to edit. there is mention of editing settings.h. I'm not sure what I'm doing wrong/ missing so any help especially from people who've gotten this working would be appreciated.

Somewhere along the lines, I figure that a new bootloader has to be compiled too, so far I've got both builds, ( one patched the rotate patch, and changes to settings.h) After the second build I made a BL which will rotate the BL output but still loads portrait rockbox. Using the regular BL just stays portrait.
Hope I've given enough info. ;)
Title: Re: gigabeat screen rotation patch
Post by: Mad Cow on April 25, 2007, 07:48:46 AM
I think that you need to make a bootloader patched with the rotate patch, then rename one of the build folders (rotated I think) to .rockbox_1. You then hold a button (Up I think) to boot into .rockbox_1 instead of .rockbox. If you look into the patch code for the bootloader you will see references to the 2 different folder names. Now I've never even tried to use this patch, but this I what I learned from looking over the cod ea bit and reading the instructions.

Why are you making a gigabeat build anyways? Don't  you have an ipod?
Title: Re: gigabeat screen rotation patch
Post by: Nate! on April 25, 2007, 11:00:56 AM
Hey ... don't discourage him.  ;D This is the one patch that I've been hoping someone would work on.

I didn't understand the instructions much either.  I gathered that, like was stated, you have to make two builds.  The rotate patched build needs to be put into a .rockbox_1 folder.  In order to have both on your Gigabeat and boot into either using the up arrow, you have to use Takka's bootloader.  That bootloader is about two revisions old now.
Title: Re: gigabeat screen rotation patch
Post by: Mad Cow on April 25, 2007, 12:38:05 PM
Hey ... don't discourage him.  ;D This is the one patch that I've been hoping someone would work on.

I didn't understand the instructions much either.  I gathered that, like was stated, you have to make two builds.  The rotate patched build needs to be put into a .rockbox_1 folder.  In order to have both on your Gigabeat and boot into either using the up arrow, you have to use Takka's bootloader.  That bootloader is about two revisions old now.

Well the bootloader code is in the patch, so compiling one should be no problem.
Title: Re: gigabeat screen rotation patch
Post by: lights0ut on April 25, 2007, 01:59:10 PM
Thanks for your responses guys. Mad Cow, I just got a gigabeat yesterday I've realized their technical superiority ;) I still like my iPod but a new toy is always fun. Gonna take another shot at this, hope I get further this time; so my plan is to just make a vanilla build, patch with just screen rotate, make a rotate build, then a bootloader and see what happens.
Title: Re: gigabeat screen rotation patch
Post by: lights0ut on April 25, 2007, 03:49:41 PM
OK here's what I've accomplished. The method I described has not successfully made a landscape/portrait booting gigabeat. After fiddling with filenames/locations and rotated and non-rotated builds I've come to this:

 - I have built a bootloader that loads rockbox_1.gigabeat from root and looks in .rockbox_1 for the rest
   of the firmware. This happens without needing to hold up.
 - Unpacking a vanilla build to .rockbox and placing rockbox.gigabeat in root does not cause the BL
    to load these by default, it just ignores them.
 - Removing the rotated build and loading just the vanilla as .rockobox and rockbox.gigabeat throws a
   file not  found error, however renaming rockobx.gigabeat (vanilla) to rockbox_1 loads a vanilla build

I think this is telling me that the bootloader only loads the *.gigabeat file, and not the .rockbox folder. So, I think I am missing the code that enables the BL to choose between.
Title: Re: gigabeat screen rotation patch
Post by: Mad Cow on April 25, 2007, 04:01:03 PM
Have you looked through the bl code? There might be something there that gives it away. I'll see what I can find out later today.

By the way. Will you eventually make a multifont/custimline build for the gigabeat? I've been wanting to do that for a while but I can't seem to get the patches.
Title: Re: gigabeat screen rotation patch
Post by: lights0ut on April 25, 2007, 04:12:50 PM
The patches needed for multifont/customline/customlistpos/customdisplaywidth are maintained by pijulius
(he makes the jbuild) and can be found on his website:
http://pijulius.com/julius/rockbox/patches/

The patches are pretty much out of date right now so going about applying them is kind of a waste especially since there are about 2 WPS's right now that use them.

Also, maxwen makes a build for the X5 similar to the jbuild but it uses scrolling margins (a bonus). The build can be found here:
http://rockbox.webhop.org/
however, these patches are also quite outdated, I think they are updated around the same time as julius' patches.maxwen's patches need to be applied in the right order, read the series file.

With regard to the bootloader, I think the file that needs work is /firmware/export/config-gigabeat.h
lines:130 to end.
Code: [Select]
/* Define this if you have adjustable CPU frequency */
/* #define HAVE_ADJUSTABLE_CPU_FREQ */

#define BOOTFILE_EXT "gigabeat"
#define BOOTFILE "rockbox_1." BOOTFILE_EXT
#define BOOTDIR "/.rockbox"

#define HW_SAMPR_CAPS (SAMPR_CAP_96 | SAMPR_CAP_88 | SAMPR_CAP_48 | \
                       SAMPR_CAP_44 | SAMPR_CAP_32 | SAMPR_CAP_24 | \
                       SAMPR_CAP_22 | SAMPR_CAP_16 | SAMPR_CAP_12 | \
                       SAMPR_CAP_11 | SAMPR_CAP_8)

#endif
Title: Re: gigabeat screen rotation patch
Post by: lights0ut on April 25, 2007, 04:43:03 PM
After looking at the iPod's bootloader code I'm beginning to think that bootloader/gigabeat.c is the file that needs to be edited. Looking at how the the iPod chooses the firmware (apple os, rockbox, diagnostic) I think that something like this needs to be added to the gigabeat.c
Code: [Select]
if(button_was_held||(btn==BUTTON_UP)){

printf("loading landscape mode ...");

rc=load_firmware(loadbuffer, "rockbox_1.gigabeat", MAX_LOADSIZE)
}

else {
printf("loading portrait mode ...");
rc=load_firmware(loadbuffer, "rockbox.gigabeat", MAX_LOADSIZE)}

I get the feeling that takka once made a custom bootloader for the patch, but I can't seem to find it on his website as it's in japanese,
the link from the FS tracker to his website is broken.
Title: Re: gigabeat screen rotation patch
Post by: lights0ut on April 25, 2007, 06:59:19 PM
I think that I'm getting in a bit deep here, I figured that the process for the bootloader must be similar to the iPod's mechanism for loading the original firmware. So I took a look at the ipod's bootloader code and attempted to mimic it in the gigabeat's bootloader. I haven't managed to break the bootloader, but I don't get the intended result of up for landscape, no button for portrait. If you want to take a look at the code
http://paste.uni.cc/14821
Title: Re: gigabeat screen rotation patch
Post by: Nate! on April 25, 2007, 07:06:37 PM
I have Takka's bootloader.  I just looked at the zip and it has a build inside also.  Do you guys want me to take that out and just upload the bootloader?

***Edit***
Here it is.

http://rapidshare.com/files/27936244/rotate-bootloader-byTakka.rar.html 
Title: Re: gigabeat screen rotation patch
Post by: lights0ut on April 25, 2007, 07:08:58 PM
I have Takka's bootloader.  I just looked at the zip and it has a build inside also.  Do you guys want me to take that out and just upload the bootloader?  

Yes please
Title: Re: gigabeat screen rotation patch
Post by: lights0ut on April 25, 2007, 11:48:10 PM
Thanks for the upload Nate, but this seems to just be the .gigabeat file, there is no bootloader in the archive. Using this firmware doesn't do anything, I get a "bad checksum" error, so I used the older rockbox bootloader, and I get portrait rockbox. Am I missing something?
Title: Re: gigabeat screen rotation patch
Post by: Nate! on April 26, 2007, 05:13:21 PM
Sorry, I clicked on the wrong thing when I added it to the archive.

Here is the "real" bootloader:
http://rapidshare.com/files/28096805/Rotate-Bootloader-byTakka.rar.html

Let me know if this works.
Title: Re: gigabeat screen rotation patch
Post by: lights0ut on April 26, 2007, 07:12:04 PM
Thanks Nate, I'm working on it now. I would prefer a copy of the code so I could see what Takka did with it, it would be nice to have a new BL so we could use the latest code. I'll see if a msg on the FS tracker helps.
Title: Re: gigabeat screen rotation patch
Post by: lights0ut on April 26, 2007, 07:47:31 PM
Success! I've got myself a screen rotating gigabeat  :D. Now on to patching, I have to use week old source code though because of the improvements to the gigabeats, any suggestions on the patches I should use, I don't know of any that are special for the gigabeat.
Here's what I'm using so far:
-Scrolling margins                             -random album database
-Album Art                                        - playlist viewer titles
-(BMP resize if/when it gets synced)   - switch playlist/sound settings in WPS context menu  
-one click to insert                             -spider solitaire
-plugin backlight
Title: Re: gigabeat screen rotation patch
Post by: Nate! on April 26, 2007, 08:57:50 PM
Sweet!  Congrats on your success.  

Are you talking about which patches to use for one of your famous builds?

I personally am pretty simple.  I only use the Album Art and Scrolling Margins patch.  Now I can include the Rotate patch.  

Mad Cow has a build with a bunch of stuff in it.

Thanks for taking the time out to work on this.  Sincerely!
Title: Re: gigabeat screen rotation patch
Post by: Mad Cow on April 26, 2007, 10:38:55 PM
Sounds good! Maybe you could also add prompt-rtc, which prompts you to set the RTC at startup if it's reset. Maybe pong-multi-pulse a stardict too?

I can't compile a build right now, and maybe for a while as the network card on my compiling computer just decided to die. :( I'd rather have somebody else make a good build rather than me, I'm getting tired of waiting for all of the patches to be synced at the same time.
Title: Re: gigabeat screen rotation patch
Post by: lights0ut on April 27, 2007, 09:29:19 AM
Mad Cow, I will be trying to include those patches from your build, I took a read of the tracker pages, and they sound pretty cool. A pong demo that thumps along with my techno will be sweet, and I didn't know stardict can get you wikipedia on your player. And yea the RTC thing helps for the gigabeats because we can turn the power off.
Any other patches I should know about? I do search the tracker often but there's ones that I miss.
Title: Re: gigabeat screen rotation patch
Post by: mannequin on April 27, 2007, 11:21:08 AM
evilg123, thats great, congrats!

i'd love to add 2 more patches:

New dict plugin: http://www.rockbox.org/tracker/task/6697
MOD player codec: http://www.rockbox.org/tracker/task/5241

both are synced to the current svn.
Title: Re: gigabeat screen rotation patch
Post by: lights0ut on April 27, 2007, 03:20:47 PM
I've uploaded the builds: http://forums.rockbox.org/index.php?topic=10163.0
Title: Re: gigabeat screen rotation patch
Post by: Mad Cow on May 03, 2007, 05:11:54 PM
You need to first define button mappings, which means you need to find the GPIO data for the UP button, the rest seems pretty self-explanatory. I'm trying it out right now.

EDIT: It oads the rotated binary by default, which is really strange. This is the whole loading part of the bootlaoder:
Code: [Select]
   if (BUTTON_UP) {
         printf("Loading Landscape Mode");
loadbuffer = (unsigned char*) 0x100;
    buffer_size = (unsigned char*)0x400000 - loadbuffer;

    rc=load_firmware(loadbuffer, "/.rockbox_1/rockbox_1.gigabeat", buffer_size);
   
if (rc == EOK)
    {
        kernel_entry = (void*) loadbuffer;
        rc = kernel_entry();
}
         
    } else {
printf("Loading Portrait Mode");
    loadbuffer = (unsigned char*) 0x100;
    buffer_size = (unsigned char*)0x400000 - loadbuffer;

    rc = load_firmware(loadbuffer, "/.rockbox/rockbox.gigabeat", buffer_size);


    if (rc == EOK)
    {
        kernel_entry = (void*) loadbuffer;
        rc = kernel_entry();
    }
}
}


Why does does it not work?
Title: Re: gigabeat screen rotation patch
Post by: lights0ut on May 03, 2007, 07:38:33 PM
gcc tells me that the in function whatever 'button_was_held' is uninitialized.
however, I don't know what this means other than something is wrong, but not critical.
To get the exact error, just try to build a bootloader, it makes the .dat but it just loads as usual.
Title: Re: gigabeat screen rotation patch
Post by: Mad Cow on May 03, 2007, 07:42:11 PM
gcc tells me that the in function whatever 'button_was_held' is uninitialized.
however, I don't know what this means other than something is wrong, but not critical.
To get the exact error, just try to build a bootloader, it makes the .dat but it just loads as usual.

There's no "button_was_held" function in the bootloader. You have to define the UP button manually and use that. That's what I did, but it loads the rotated build no matter what, even after some help on IRC.

EDIT: I modified you code a bit, it loads the normal rockbox fine, but only loads the rotated buld halfway before going back to normal. I'll try to fix it later today.

Never mind, it automatically loads to rotated build no matter what, I had the path wrong.
Title: Re: gigabeat screen rotation patch
Post by: lights0ut on May 03, 2007, 07:55:37 PM
Cool, glad to hear you are making some progress and getting help on IRC, thanks for your interest in this :D
Title: Re: gigabeat screen rotation patch
Post by: Mad Cow on May 03, 2007, 07:59:44 PM
Cool, glad to hear you are making some progress and getting help on IRC, thanks for your interest in this :D

Well I'm done for today, this thing is really annoying. I don't know C, so I'm pretty much guessing where everything goes.
Title: Re: gigabeat screen rotation patch
Post by: lights0ut on May 03, 2007, 08:10:54 PM
don't worry, I am about the same knowledge level when it comes to this stuff. I really should learn C now that I'm done school.
Title: Re: gigabeat screen rotation patch
Post by: Mad Cow on May 03, 2007, 11:59:45 PM
From looking at code examples, I see no reason why this doesn't work. ???
Title: Re: gigabeat screen rotation patch
Post by: Mad Cow on May 10, 2007, 12:14:03 PM
GOT IT! ;D

It was the button recognition code that was at fault, not the loading code. Because of this, it loads landscape mode with a press anywhere on the touchpad. It's a bad hack, but it works for now. This bootloader looks for both ".gigabeat" files in their respective folders ".rockbox" and ".rockbox_1"
 Download Here (http://utterlyinsane.org/gigabeat/FWIMG01.DAT)

Here's the diff in case anybody is interested:
Code: [Select]
Index: bootloader/gigabeat.c
===================================================================
--- bootloader/gigabeat.c (revision 13369)
+++ bootloader/gigabeat.c (working copy)
@@ -112,13 +112,27 @@
     {
         error(EDISK,rc);
     }
+
+    if(button_read_device()) {
+         printf("Loading Landscape Mode");
+ loadbuffer = (unsigned char*) 0x100;
+    buffer_size = (unsigned char*)0x400000 - loadbuffer;
+
+    rc=load_firmware(loadbuffer, "/.rockbox_1/rockbox_1.gigabeat", buffer_size);
+    
+ if (rc == EOK)
+    {
+        kernel_entry = (void*) loadbuffer;
+        rc = kernel_entry();
+ }
+        
+    } else
+    printf("Loading Portrait Mode");
 
-    printf("Loading firmware");
-
     loadbuffer = (unsigned char*) 0x100;
     buffer_size = (unsigned char*)0x400000 - loadbuffer;
 
-    rc = load_firmware(loadbuffer, BOOTFILE, buffer_size);
+    rc = load_firmware(loadbuffer, "/.rockbox/rockbox.gigabeat", buffer_size);
     if(rc < 0)
         error(EBOOTFILE, rc);
 
@@ -128,4 +142,3 @@
         rc = kernel_entry();
     }
 }
-
Title: Re: gigabeat screen rotation patch
Post by: Nate! on May 10, 2007, 12:19:00 PM
Haven't tried it yet, but SWEET!  Thanks for your work!  And again, thanks to MadCow and EvilG for reviving this effort.

*** EDIT ***
Just tried your bootloader:
* patched, and loaded patched build.  
 Â  * I have .rockbox and .rockbox_1 directories.  
 Â  * Made sure I copied the fonts directory over to the .rockbox_1 dir.
* Powered down.
* Turned the battery off and on
* Powered on.
*Hit/held the up "button."

I received some print out of text that I can't really see because it flashes too quickly.  I believe it looks like the info you get when you don't have the bootloader correctly installed or something.  Is there anyway to capture that message?

After error, it loads in portrait mode.  Everything works fine in portrait mode.
Title: Re: gigabeat screen rotation patch
Post by: Mad Cow on May 10, 2007, 03:49:55 PM
Haven't tried it yet, but SWEET!  Thanks for your work!  And again, thanks to MadCow and EvilG for reviving this effort.

*** EDIT ***
Just tried your bootloader:
* patched, and loaded patched build.  
   * I have .rockbox and .rockbox_1 directories.  
   * Made sure I copied the fonts directory over to the .rockbox_1 dir.
* Powered down.
* Turned the battery off and on
* Powered on.
*Hit/held the up "button."

I received some print out of text that I can't really see because it flashes too quickly.  I believe it looks like the info you get when you don't have the bootloader correctly installed or something.  Is there anyway to capture that message?

After error, it loads in portrait mode.  Everything works fine in portrait mode.

First of all, you don't need to hold the "up" button, just hold any button on the touchpad, preferably the middle, and start holding it while you're still in Toshiba's bootloader with the loading bar. Also, make sure there's a "rockbox_1.gigabeat" in your ".rockbox_1" dir. The best way to capture that message would probably to take a video of it loading and find the frame(s) with the error message.
Title: Re: gigabeat screen rotation patch
Post by: Nate! on May 10, 2007, 06:58:38 PM
AaaHaa!  I needed to rename the gigabeat.rockbox in the .rockbox_1 dir.  Thanks.  You guys are the greatest.  For Real!
Title: Re: gigabeat screen rotation patch
Post by: Mad Cow on May 10, 2007, 07:03:47 PM
AaaHaa!  I needed to rename the gigabeat.rockbox in the .rockbox_1 dir.  Thanks.  You guys are the greatest.  For Real!

Why did you have to rename it? Did you download my rotated build?
Title: Re: gigabeat screen rotation patch
Post by: Nate! on May 10, 2007, 07:24:34 PM
Oh no, I didn't download your build.  I only really use the Album Art patch.  Maybe I'll add scrolling margins occasionally when it syncs.  Aside from those two and the  Rotate patch, I don't really use any other patches.  And as far as games, I don't really play anything in the airport or where ever except what comes with Rockbox.  (Mostly just Bubbles, Brickmania, and Xobox.)

So that's why I had to rename.  Everything works great now.  I had to of course update a couple WPSs and config files, but everything is great!

I do appreciate you finally getting this to work.  Again, my sincerest thanks!
Title: Re: gigabeat screen rotation patch
Post by: lights0ut on May 10, 2007, 07:29:09 PM
Mad Cow, this is awesome news. Thanks for taking the time to get this code to work, I'm glad that all my headaches were worth someting :D. Guess this means I can make a build for that can be used on the X series, and with all the fancy code improvements like those neet button lights.
Title: Re: gigabeat screen rotation patch
Post by: lights0ut on May 17, 2007, 04:50:13 PM
Nate has let me know that this patch needs a resync due to recent commits for LCD optimizations.
We no longer use DMA for the LCD so the code has been changed a bit. I've been unsuccessfully trying to sync this, so I thought I'd just get the word out.
The file that is out of sync is:
/firmware/target/arm/s3c2440/gigabeat-fx/lcd-meg-fx.c
which has 3 hunks fail. I think what needs to be done is modify the variables in the new functions (LCD_WIDTH changes to R_LCD_WIDTH) but it may be more.
Title: Re: gigabeat screen rotation patch
Post by: lights0ut on May 17, 2007, 06:33:37 PM
I've managed to sync this patch so no worries, but thanks to anyone who even considered lending a hand ;)
Title: Re: gigabeat screen rotation patch
Post by: Mad Cow on May 17, 2007, 07:07:23 PM
I've managed to sync this patch so no worries, but thanks to anyone who even considered lending a hand

What did you do? I'm glad to hear that though, because I'm terrible with patches and I didn't really want to do it. ;)
Title: Re: gigabeat screen rotation patch
Post by: lights0ut on May 17, 2007, 07:53:41 PM
I'll attach the .rej so you can see what wasn't patching, and try to explain as best I can:
-the first hunk I needed to just copy and paste, as well as the second.
-The next hunk dealt with DMA, which was removed from SVN as we do not usDMA to access the
  Gigabeat's LCD. By looking at the diffs from the recent SVN commits I figured that this stuff was
  unneccessary, so I continued to the next hunk
-the hunk after that deals with the memcpy function (which I assume is used to draw the LCD) and appears to
  be the same, so again i just copied the the intended code and replaced it.

At first, I thought I had to find all instances of LCD_WIDTH and replace them with R_LCD_WIDTH etc. but after running into problems I decided to take some closer looks at the patch file, the .orig, the .rej, and the SVN diffs (the SVN diffs were the real key to this). After reading them, I came up with the solution I just explained, and after some 'massaging' it worked. I didn't quite copy and paste as I was supposed to, an extra } character here or there, and I think one of the parts I needed I forgot to paste in the first time. That stuff I figured out from gcc's error messages.

[attachment deleted by admin for age]
Title: Re: gigabeat screen rotation patch
Post by: Mad Cow on May 17, 2007, 08:05:00 PM
I'll attach the .rej so you can see what wasn't patching, and try to explain as best I can:
-the first hunk I needed to just copy and paste, as well as the second.
-The next hunk dealt with DMA, which was removed from SVN as we do not usDMA to access the
  Gigabeat's LCD. By looking at the diffs from the recent SVN commits I figured that this stuff was
  unneccessary, so I continued to the next hunk
-the hunk after that deals with the memcpy function (which I assume is used to draw the LCD) and appears to
  be the same, so again i just copied the the intended code and replaced it.

At first, I thought I had to find all instances of LCD_WIDTH and replace them with R_LCD_WIDTH etc. but after running into problems I decided to take some closer looks at the patch file, the .orig, the .rej, and the SVN diffs (the SVN diffs were the real key to this). After reading them, I came up with the solution I just explained, and after some 'massaging' it worked. I didn't quite copy and paste as I was supposed to, an extra } character here or there, and I think one of the parts I needed I forgot to paste in the first time. That stuff I figured out from gcc's error messages.

I have no idea what you just said, but good job. :D
Title: Re: gigabeat screen rotation patch
Post by: Nate! on May 17, 2007, 09:55:28 PM
Quote from: Mad Cow
I have no idea what you just said, but good job.
I thought it was just me.  Thanks again EvilG for the work.  :D
Title: Re: gigabeat screen rotation patch
Post by: lights0ut on May 17, 2007, 11:16:18 PM
I'm not joking, this makes complete sense to me the way I've explained it.
Title: Re: gigabeat screen rotation patch
Post by: Mad Cow on May 17, 2007, 11:26:32 PM
I'm not joking, this makes complete sense to me the way I've explained it.

Maybe it's because I'm tired. I'll check it out tomorrow, maybe then I'll get it. :P