OperationNT414C / CtrBootManager

A 3ds "bootloader" like app
16 stars 3 forks source link

unable to compile #4

Open CokeCookie opened 8 years ago

CokeCookie commented 8 years ago

When trying to compile the source I always receive the same error. Output on the console looks like this:

[user@ArchLinux build]$ cmake --build . --target screeninit_a9lh
Scanning dependencies of target screeninit
[ 33%] Building C object CMakeFiles/screeninit.dir/screeninit/source/main.c.obj
[ 66%] Building ASM object CMakeFiles/screeninit.dir/screeninit/source/start.s.obj
[100%] Linking C executable screeninit
/opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/5.3.0/../../../../arm-none-eabi/bin/ld:/home/user/build-repos/CtrBootManager/screeninit/linker.ld:1: syntax error
collect2: error: ld returned 1 exit status

Sadly I don't know how to fix this.

OperationNT414C commented 8 years ago

Hello CokeCookie,

I don't understand why you get this error. The compilation process seems fine on my environment:

C:\Users\Alexandre\Desktop\CtrBootManager-1.0\build>cmake --build . --target screeninit_a9lh
Scanning dependencies of target screeninit
[ 33%] Building C object CMakeFiles/screeninit.dir/screeninit/source/main.c.obj
[ 66%] Building ASM object CMakeFiles/screeninit.dir/screeninit/source/start.s.obj
[100%] Linking C executable screeninit
[100%] Built target screeninit
Scanning dependencies of target screeninit_a9lh
[100%] Built target screeninit_a9lh

However, you can skip this step if you wish: it is used to generate "build/screeninit.h" file (with the step using "bin2h") and I already give a pre-generated file. So you can directly go to the last step: cmake --build . --target CtrBootManager_a9lh

Do you have the same issue with this step too ?

CokeCookie commented 8 years ago

Well, I get another error on the last step:

[user@ArchLinux build]$ cmake --build . --target CtrBootManager_a9lh
[  3%] Generating binaries_asm/__CtrBootManager9_embed_stage2.bin.s
Scanning dependencies of target __CtrBootManager9_embed_stage2.bin
[  6%] Building ASM object CMakeFiles/__CtrBootManager9_embed_stage2.bin.dir/binaries_asm/__CtrBootManager9_embed_stage2.bin.s.obj
[  9%] Linking ASM static library lib__CtrBootManager9_embed_stage2.bin.a
[  9%] Built target __CtrBootManager9_embed_stage2.bin
Scanning dependencies of target CtrBootManager9
[ 12%] Building C object CMakeFiles/CtrBootManager9.dir/source/loader.c.obj
[ 16%] Building C object CMakeFiles/CtrBootManager9.dir/source/anim.c.obj
[ 19%] Building C object CMakeFiles/CtrBootManager9.dir/source/menu.c.obj
[ 22%] Building C object CMakeFiles/CtrBootManager9.dir/source/menu_more.c.obj
[ 25%] Building C object CMakeFiles/CtrBootManager9.dir/source/menu_picker.c.obj
[ 29%] Building C object CMakeFiles/CtrBootManager9.dir/source/config.c.obj
[ 32%] Building C object CMakeFiles/CtrBootManager9.dir/source/main.c.obj
[ 35%] Building C object CMakeFiles/CtrBootManager9.dir/source/text.c.obj
[ 38%] Building C object CMakeFiles/CtrBootManager9.dir/source/quicklz.c.obj
[ 41%] Building C object CMakeFiles/CtrBootManager9.dir/source/screeninit.c.obj
[ 45%] Building C object CMakeFiles/CtrBootManager9.dir/source/menu_boot.c.obj
[ 48%] Building C object CMakeFiles/CtrBootManager9.dir/source/font.c.obj
[ 51%] Building C object CMakeFiles/CtrBootManager9.dir/source/gfx.c.obj
[ 54%] Building C object CMakeFiles/CtrBootManager9.dir/source/font_default.c.obj
[ 58%] Building C object CMakeFiles/CtrBootManager9.dir/source/ini.c.obj
[ 61%] Building C object CMakeFiles/CtrBootManager9.dir/source/utility.c.obj
[ 64%] Building C object CMakeFiles/CtrBootManager9.dir/source/movie.c.obj
[ 67%] Building C object CMakeFiles/CtrBootManager9.dir/source/menu_config.c.obj
[ 70%] Building C object CMakeFiles/CtrBootManager9.dir/source/arm9/source/platform.c.obj
[ 74%] Building ASM object CMakeFiles/CtrBootManager9.dir/source/arm9/source/fatfs/sdmmc/delay.s.obj
[ 77%] Building C object CMakeFiles/CtrBootManager9.dir/source/arm9/source/fatfs/sdmmc/sdmmc.c.obj
[ 80%] Building C object CMakeFiles/CtrBootManager9.dir/source/arm9/source/fatfs/option/ccsbcs.c.obj
[ 83%] Building C object CMakeFiles/CtrBootManager9.dir/source/arm9/source/fatfs/diskio.c.obj
[ 87%] Building C object CMakeFiles/CtrBootManager9.dir/source/arm9/source/fatfs/ff.c.obj
[ 90%] Building C object CMakeFiles/CtrBootManager9.dir/source/arm9/source/hid.c.obj
[ 93%] Building ASM object CMakeFiles/CtrBootManager9.dir/source/arm9/source/bs-start.s.obj
[ 96%] Building C object CMakeFiles/CtrBootManager9.dir/source/arm9/source/i2c.c.obj
[100%] Linking C executable CtrBootManager9
[100%] Built target CtrBootManager9
Scanning dependencies of target CtrBootManager_a9lh
make[3]: set-section-flags: Command not found
[100%] Built target CtrBootManager_a9lh
OperationNT414C commented 8 years ago

About the last error: make[3]: set-section-flags: Command not found

I already had it, it seems to be due to the presence of "makerom" and "bannertools".

image

You must disable them when you generate your project from cmake. Use "cmake-gui" to make it easier. The following warning must appear:

CMake Warning at cmake/Tools3DS.cmake:136 (message):
  bannertool - not found
Call Stack (most recent call first):
  CMakeLists.txt:10 (include)

CMake Warning at cmake/Tools3DS.cmake:151 (message):
  makerom - not found
Call Stack (most recent call first):
  CMakeLists.txt:10 (include)
CokeCookie commented 8 years ago

after removing bannertool + makerom the warning appears on the first cmake command (step 3):

CMake Warning at cmake/Tools3DS.cmake:136 (message):
  bannertool - not found
Call Stack (most recent call first):
  CMakeLists.txt:10 (include)

CMake Warning at cmake/Tools3DS.cmake:151 (message):
  makerom - not found
Call Stack (most recent call first):
  CMakeLists.txt:10 (include)

But the error on the last step remains the same.

CokeCookie commented 8 years ago

Okay, thanks to this post I was able to sort of 'fix' the problem on the last step.

1) cmake -DCMAKE_TOOLCHAIN_FILE=../DevkitArm3DS.cmake ../ 2) change line 56 in build/CMakeFiles/CtrBootManager_a9lh.dir/build.make from

--set-section-flags .bss=alloc,load,contents -O binary /home/user/build-repos/CtrBootManager/build/CtrBootManager9 /home/user/build-repos/CtrBootManager/build/CtrBootManager9.bin

to

arm-none-eabi-objcopy --set-section-flags .bss=alloc,load,contents -O binary /home/user/build-repos/CtrBootManager/build/CtrBootManager9 /home/user/build-repos/CtrBootManager/build/CtrBootManager9.bin

3) cmake --build . --target CtrBootManager_a9lh 4) Payload compiled without problems. (even with bannertool + makerom enabled)

[100%] Linking C executable CtrBootManager9
[100%] Built target CtrBootManager9
Scanning dependencies of target CtrBootManager_a9lh
[100%] Built target CtrBootManager_a9lh

This probably isn't the best way to fix this, maybe you can come up with a better solution.

OperationNT414C commented 8 years ago

I am sorry but I am not really good with cmake. In my case, a similar issue really came from bannertool and makerom presence. If you find a way to fix "CMakeLists.txt" file or "DevkitArm3DS.cmake" for all those issues, I would be happy to integrate your changes. Any way, thank you for your solution!

Did it also solve your linking issue on "screeninit" part?

CokeCookie commented 8 years ago

No, the error on the screeninit part is still unsolved. My solution only works with the screeninit.h you provided. I'd really like to fix this but I know next to nothing about cmake. Looks like we'll need the help of someone more experienced to fix it completely.

CokeCookie commented 8 years ago

Okay I made some little changes and can now compile the a9lh payload without problems. Please take a look at my fork and tell me if anything isn't working for you. Otherwise I'll just create a pull request and we can call this fixed

OperationNT414C commented 8 years ago

I just look at your modifications, the following files look fine for me:

I also see that you removed "source/CakeBrah". I try to maintain the 3DSX version alive too so this change can be a problem for this version. However, to compile the 3DSX version, I was unable to find a way to use a common project folder as you can see in this page by downloading "CtrBootManager_2.1.1src.zip": https://gbatemp.net/threads/release-ctrbootmanager-ctrbootmanager9.431647/ I used the "master" branch and copy/paste all the other files which is a little bit ugly solution...

Anyway, thank you for your research on compilation process!

CokeCookie commented 8 years ago

make.sh: Initially I had to switch over to Windows and use this version of bin2h to generate a working screeninit.h. But I've found a version here that works on Windows and Linux (I tested both) with this command:

bin2h -i screeninit.bin -o screeninit.h -n screeninit -s

So we could solve this in two ways:

  1. provide a compiled screeninit.h and remove bin2h -c screeninit < screeninit.bin > screeninit.h from the building instructions/process.
  2. provide a compiled version of bin2h for Win/Linux and edit the instructions accordingly.

I didn't remove CakeBrah, I just thought I'd update the submodule to the latest commit while I'm at it. Either way I wasn't able to compile the 3dsx version myself, so if you could explain more detailed what I need to do/change to make it work, I'll take a look at it.

OperationNT414C commented 8 years ago

For "bin2h", I found this already compiled version: http://www.deadnode.org/sw/bin2h/ So the command I suggest is based on this version. Maybe the easiest way is to keep as it is: I provide an already generated "screeninit.h" but there is still the command lines to regenerate it.

For the 3DSX version, as I said, my process isn't automatic:

I am sure there would be a way to create a valid CMakeList which would allow to generate both A9LH and 3DSX version but my low CMake knowledge make me gave up (and I don't like spending time on compilation process, I prefer coding :-) ).

CokeCookie commented 8 years ago

Yes that bin2h version is the same that I used on Windows, only finding a version for Linux took some time. But ok, I'll edit my fork like you suggested and let you know when I'm done.

Concerning the 3dsx version: For now your solution probably is good enough since you provide a compiled .3dsx in your releases. Though as soon as I've got more time (3-4 weeks from now) I'll have another look at it.

OperationNT414C commented 8 years ago

I will also be very busy until 10 July so I won't have a lot of time to spend on CtrBootManager.

Jerry-Shaw commented 7 years ago

Hi, still failed to compile on Windows 7. Very bad at C. "screeninit" file not exists :<