Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bootloader doesn't meet size limits when compiled #74

Closed
Plaque-fcc opened this issue Dec 22, 2024 · 7 comments
Closed

Bootloader doesn't meet size limits when compiled #74

Plaque-fcc opened this issue Dec 22, 2024 · 7 comments

Comments

@Plaque-fcc
Copy link

$ make -C bootloader build
make: Entering directory '/build/rv003usb/bootloader'
riscv64-linux-gnu-gcc -o bootloader.elf  bootloader.c ../rv003usb/rv003usb.S  -g -Os -flto -ffunction-sections -fdata-sections -fmessage-length=0 -msmall-data-limit=8 -march=rv32ec -mabi=ilp32e -DCH32V003=1 -static-libgcc -I/usr/include/newlib -I../ch32v003fun/ch32v003fun/../extralibs -I../ch32v003fun/ch32v003fun -nostdlib -I. -Wall -I. -I../lib -DUSE_TINY_BOOT -I../rv003usb -Wl,--print-memory-usage -L../ch32v003fun/ch32v003fun/../misc -lgcc -T ch32v003fun-usb-bootloader.ld -Wl,--gc-sections
/tmp/ccwYoG6F.s: Assembler messages:
/tmp/ccwYoG6F.s:561: Warning: setting incorrect section attributes for .rodata
/usr/lib/gcc-cross/riscv64-linux-gnu/11/../../../../riscv64-linux-gnu/bin/ld: bootloader.elf section `.text' will not fit in region `FLASH'
/usr/lib/gcc-cross/riscv64-linux-gnu/11/../../../../riscv64-linux-gnu/bin/ld: region `FLASH' overflowed by 720 bytes
/usr/lib/gcc-cross/riscv64-linux-gnu/11/../../../../riscv64-linux-gnu/bin/ld: bootloader.elf: error: PHDR segment not covered by LOAD segment
Memory region         Used Size  Region Size  %age Used
           FLASH:        2640 B       1920 B    137.50%
             RAM:         280 B         2 KB     13.67%
collect2: error: ld returned 1 exit status
make: *** [../ch32v003fun/ch32v003fun/ch32v003fun.mk:235: bootloader.elf] Error 1
make: Leaving directory '/build/rv003usb/bootloader'

I just cloned the project locally (with submodule), and it outputs this message that the bootloader is oversized.

Why is this happening and how can we fix it?

@Plaque-fcc Plaque-fcc changed the title Bootloader doesn't meet size window when compiled Bootloader doesn't meet size limits when compiled Dec 22, 2024
@cnlohr
Copy link
Owner

cnlohr commented Dec 22, 2024

Please run riscv64-linux-gnu-gcc -v -- for the bootloader you should be using gcc14

@Plaque-fcc
Copy link
Author

Please run riscv64-linux-gnu-gcc -v -- for the bootloader you should be using gcc14

gcc version 11.4.0

Feels like I'm stuck at GCC v12 for now. Thanks for your quick reply (you can probably add minimum requirements in the README, btw).

@Plaque-fcc
Copy link
Author

Or even with GCC v11 for RISCV64.

@cnlohr
Copy link
Owner

cnlohr commented Dec 27, 2024

Ok, honestly, gcc v11 should be OK. What configuration do you have? Some configurations for the bootloader are not able to fit in the bootloader space. Or is your install a virgin install?

@Plaque-fcc
Copy link
Author

Ok, honestly, gcc v11 should be OK. What configuration do you have? Some configurations for the bootloader are not able to fit in the bootloader space. Or is your install a virgin install?

Totally clean install. I may be getting something wrong. Tried with Ubuntu 22.04.5 LTS x86_64. Will likely upgrade it to the next LTS in a few days.

I didn't configure anything in the bootloader at all. Fresh clone, doesn't work → came to ask.

@Plaque-fcc
Copy link
Author

Anyway, my (other) ARM64 machine can't compile it (guess there are difficulties cross-compiling for RISC-V on anything than AMD64 and probably x86 so far unless you're on bleeding edge or building toolchain yourself).

Therefore, I'm going to upgrade my old LTS instance to the latest LTS one and give it another try. Will get back with the news.

@Plaque-fcc Plaque-fcc reopened this Jan 4, 2025
@Plaque-fcc
Copy link
Author

Good news, I wasn't using the right toolchain, solved with building one from source #493.

Thanks for your help, closing this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants