Rockbox Technical Forums

Rockbox Development => Starting Development and Compiling => Topic started by: ciel on April 26, 2018, 04:52:59 PM

Title: Changing and Compiling the Bootloader
Post by: ciel on April 26, 2018, 04:52:59 PM
How do I compile the bootloader for Sansa Clip Plus?

I'm trying to compile the bootloader after making a change to sansa_as3525.c. However, I'm getting several errors, listed below. For example, it cannot find make.inc.

Code: [Select]
./../firmware/export/config.h:895:17: error: operator '>=' has no left operand
 #if (MEMORYSIZE >= 8) && !defined(BOOTLOADER) && !defined(__PCTOOL__) \
                 ^
./../firmware/export/config.h:1042:41: error: operator '&&' has no right operand
     (CONFIG_CPU == AS3525 && MEMORYSIZE > 2 && !defined(BOOTLOADER)) || /* AS3525 +2MB: core, plugins, codecs */ \

Makefile:105: /make.inc: No such file or directory
make: *** No rule to make target '/make.inc'.  Stop.

Before that, I had fixed another error by changing line 41 in /bootloader/Makefile to the following, where the bold part of the path is what I added to fix it. Otherwise, it could not be found.

Code: [Select]
SRC := $(shell cat SOURCES | $(CC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) $(DEFINES) $(EXTRA_DEFINES) -E -P -include "[b]../firmware/export/[/b]config.h" - )
Title: Re: Changing and Compiling the Bootloader
Post by: ciel on April 26, 2018, 04:57:59 PM
Another note is that I can't find a "bootloader.bin" file.
Title: Re: Changing and Compiling the Bootloader
Post by: saratoga on April 26, 2018, 05:06:27 PM
Post the full log, including the configure step.
Title: Re: Changing and Compiling the Bootloader
Post by: Bilgus on April 26, 2018, 05:12:20 PM
Your best bet is to do this through the supplied VM image
see here for that and/or setting up your environment
https://www.rockbox.org/wiki/DevelopmentGuide

That being said.. you can easily brick your player by messing up the bootloader
while it is recoverable it isn't the easiest thing to do as it requires taking the Clip+ apart

Might I ask what you are changing in sansa_as3525.c? If you are confident in the changes pastebin them and I can compile the bootloader for you
If you are trying to learn I'd suggest playing with a firmware build first as it won't brick the player
Title: Re: Changing and Compiling the Bootloader
Post by: ciel on April 26, 2018, 05:29:44 PM
Thank you for the quick responses. I figured it out. It turns out that the bootloader gets compiled to "rockbox.sansa" if I follow the build instructions on the rockbox wiki.

So, I don't need to go into /bootloader and run its Makefile to compile the bootloader.
Title: Re: Changing and Compiling the Bootloader
Post by: ciel on April 26, 2018, 06:22:16 PM
I ran into another problem. I started afresh, and have the current version of rockbox in github. I compiled rockbox in the build folder as instructed, which produced a "rockbox.sansa" file. Then I ran:

Code: [Select]
./mkamsboot clppa.bin rockbox.sansa patched.bin
However, I get an error:

Code: [Select]
[ERR] Packed data (426067 bytes) doesn't fit in the firmware (134008 bytes).
I haven't done anything to the code. How can this be fixed?
Title: Re: Changing and Compiling the Bootloader
Post by: Bilgus on April 26, 2018, 07:19:31 PM
I've a feeling you aren't doing a bootloader build
https://www.rockbox.org/wiki/HowToCompile#A_3._Run_configure
after you do configure you need to press b for bootloader
../tools/configure
'b'
Title: Re: Changing and Compiling the Bootloader
Post by: Bilgus on April 26, 2018, 07:25:01 PM
you know if you would stop for a bit and explain what you are trying to do we might be able to save you some heartache/burn
Title: Re: Changing and Compiling the Bootloader
Post by: Bilgus on April 26, 2018, 07:27:27 PM
to further clarify if you are trying to change something in rockbox ie after the logo pops up you just need to compile firmware
If you are trying to change something when the player boots ie. before the logo thats the bootloader it handles things like booting the OF when you hold the volume key
Title: Re: Changing and Compiling the Bootloader
Post by: ciel on May 10, 2018, 10:22:13 PM
Thank you for the advice. I'm doing some research for my graduate studies. What I've been trying to do is to start up a small game instead of rockbox.

To do that on a Sansa Clip Plus, I added new firmware files in /firmware, and modified bootloader/sansa_as3525.c so that it'd boot the game instead of rockbox. My steps to put the new firmware on the device are:

1. Run "make zip". This creates a "rockbox.sansa" file.
2. Use this "rockbox.sansa" file in the command " ./mkamsboot clppa.bin bootloader-clipplus.sansa patched.bin". However, this command fails, saying that the "Packed data doesn't fit in the firmware".

Do you have any suggestions?
Title: Re: Changing and Compiling the Bootloader
Post by: saratoga on May 10, 2018, 10:25:19 PM
Post the full log, including the configure step.
Title: Re: Changing and Compiling the Bootloader
Post by: __builtin on May 18, 2018, 05:16:46 PM
Thank you for the advice. I'm doing some research for my graduate studies. What I've been trying to do is to start up a small game instead of rockbox.

It would be much easier to for you to just write a plugin instead of essentially having to roll your own operating system, unless that's what you specifically want to do.
Title: Re: Changing and Compiling the Bootloader
Post by: ciel on May 22, 2018, 02:55:03 PM
Yes, that is true, but that is specifically what I'd like to do. But it seems like building the bootloader even from the source code has issues.
Title: Re: Changing and Compiling the Bootloader
Post by: saratoga on May 22, 2018, 07:40:29 PM
I double checked and the clip+ bootloader was ~3 KB over limit.  I committed two patches that reduce the size, so it should work now. 
Title: Re: Changing and Compiling the Bootloader
Post by: ciel on July 11, 2018, 12:44:16 PM
@saratoga: Sorry that I haven't replied sooner, but your patches have been a great help! Thanks.