szemzoa / awboot

small linux bootloader for Allwinner T113-S3 and V851s
72 stars 33 forks source link

Encounter this problem while compiling #1

Closed Evlers closed 1 year ago

Evlers commented 1 year ago

Encounter a link error, please help solve, thank you~

Info

cross compile: gcc version 7.5.0 host compile: gcc version 7.5.0

Setp

Error

LD    awboot.elf
main.o: In function `sdcard_loadimage':
/home/evler/allwinner/mangopi/dual/mainline/awboot/main.c:104: undefined reference to `__stack_chk_fail'
/home/evler/allwinner/mangopi/dual/mainline/awboot/main.c:104: undefined reference to `__stack_chk_guard'
main.o: In function `load_sdcard':
/home/evler/allwinner/mangopi/dual/mainline/awboot/main.c:137: undefined reference to `__stack_chk_fail'
/home/evler/allwinner/mangopi/dual/mainline/awboot/main.c:137: undefined reference to `__stack_chk_guard'
lib/debug.o: In function `debug':
/home/evler/allwinner/mangopi/dual/mainline/awboot/lib/debug.c:12: undefined reference to `__stack_chk_fail'
/home/evler/allwinner/mangopi/dual/mainline/awboot/lib/debug.c:12: undefined reference to `__stack_chk_guard'
lib/xformat.o: In function `xvformat':
/home/evler/allwinner/mangopi/dual/mainline/awboot/lib/xformat.c:995: undefined reference to `__stack_chk_fail'
/home/evler/allwinner/mangopi/dual/mainline/awboot/lib/xformat.c:995: undefined reference to `__stack_chk_guard'
lib/xformat.o: In function `xformat':
/home/evler/allwinner/mangopi/dual/mainline/awboot/lib/xformat.c:408: undefined reference to `__stack_chk_fail'
/home/evler/allwinner/mangopi/dual/mainline/awboot/lib/xformat.c:408: undefined reference to `__stack_chk_guard'
lib/div.o: In function `div':
/home/evler/allwinner/mangopi/dual/mainline/awboot/lib/div.c:87: undefined reference to `__stack_chk_fail'
/home/evler/allwinner/mangopi/dual/mainline/awboot/lib/div.c:87: undefined reference to `__stack_chk_guard'
lib/div.o: In function `mod':
/home/evler/allwinner/mangopi/dual/mainline/awboot/lib/div.c:100: undefined reference to `__stack_chk_fail'
/home/evler/allwinner/mangopi/dual/mainline/awboot/lib/div.c:100: undefined reference to `__stack_chk_guard'
/home/evler/allwinner/mangopi/dual/mainline/awboot/arch/arm32/mach-t113s3/sdcard.o: In function `go_idle_state':
/home/evler/allwinner/mangopi/dual/mainline/awboot/arch/arm32/mach-t113s3/sdcard.c:82: undefined reference to `__stack_chk_fail'
/home/evler/allwinner/mangopi/dual/mainline/awboot/arch/arm32/mach-t113s3/sdcard.c:82: undefined reference to `__stack_chk_guard'
/home/evler/allwinner/mangopi/dual/mainline/awboot/arch/arm32/mach-t113s3/sdcard.o: In function `mmc_status':
/home/evler/allwinner/mangopi/dual/mainline/awboot/arch/arm32/mach-t113s3/sdcard.c:218: undefined reference to `__stack_chk_fail'
/home/evler/allwinner/mangopi/dual/mainline/awboot/arch/arm32/mach-t113s3/sdcard.c:218: undefined reference to `__stack_chk_guard'
/home/evler/allwinner/mangopi/dual/mainline/awboot/arch/arm32/mach-t113s3/sdcard.o: In function `mmc_read_blocks':
/home/evler/allwinner/mangopi/dual/mainline/awboot/arch/arm32/mach-t113s3/sdcard.c:262: undefined reference to `__stack_chk_fail'
/home/evler/allwinner/mangopi/dual/mainline/awboot/arch/arm32/mach-t113s3/sdcard.c:262: undefined reference to `__stack_chk_guard'
/home/evler/allwinner/mangopi/dual/mainline/awboot/arch/arm32/mach-t113s3/sdcard.o: In function `sdcard_init':
/home/evler/allwinner/mangopi/dual/mainline/awboot/arch/arm32/mach-t113s3/sdcard.c:541: undefined reference to `__stack_chk_fail'
/home/evler/allwinner/mangopi/dual/mainline/awboot/arch/arm32/mach-t113s3/sdcard.c:541: undefined reference to `__stack_chk_guard'
/home/evler/allwinner/mangopi/dual/mainline/awboot/lib/fatfs/ff.o: In function `gen_numname':
/home/evler/allwinner/mangopi/dual/mainline/awboot/lib/fatfs/ff.c:1321: undefined reference to `__stack_chk_fail'
/home/evler/allwinner/mangopi/dual/mainline/awboot/lib/fatfs/ff.c:1321: undefined reference to `__stack_chk_guard'
/home/evler/allwinner/mangopi/dual/mainline/awboot/lib/fatfs/ff.o: In function `f_open':
/home/evler/allwinner/mangopi/dual/mainline/awboot/lib/fatfs/ff.c:2362: undefined reference to `__stack_chk_fail'
/home/evler/allwinner/mangopi/dual/mainline/awboot/lib/fatfs/ff.c:2362: undefined reference to `__stack_chk_guard'
collect2: error: ld returned 1 exit status
Makefile:74: recipe for target 'awboot.elf' failed
make: *** [awboot.elf] Error 1
szemzoa commented 1 year ago

compile it with arm-none-eabi- toolchain

Evlers commented 1 year ago

thank you!! I Can continue compiling with arm-none-eabi- But new problems arise:

---------------------------------------------------------------
Compiler version: gcc version 6.3.1 20170620 (15:6.3.1+svn253039-1build1) 
Build revision: 6098
---------------------------------------------------------------
  CC    /home/evler/allwinner/mangopi/dual/mainline/awboot/arch/arm32/mach-t113s3/sdcard.c
  LD    awboot.elf
/home/evler/allwinner/mangopi/dual/mainline/awboot/arch/arm32/mach-t113s3/sdcard.o: In function `sdcard_detect':
/home/evler/allwinner/mangopi/dual/mainline/awboot/arch/arm32/mach-t113s3/sdcard.c:442: undefined reference to `__aeabi_llsl'
collect2: error: ld returned 1 exit status
Makefile:74: recipe for target 'awboot.elf' failed
make: *** [awboot.elf] Error 1
cmult          = UNSTUFF_BITS(card->csd, 47, 3);
csize          = UNSTUFF_BITS(card->csd, 62, 12);
card->capacity = (csize + 1) << (cmult + 2);

This cmult seems to be beyond a 64-bit variable ??

szemzoa commented 1 year ago

I've succesfully compiled it under OSX, with:

arm-none-eabi-gcc -v gcc version 9.2.1 20191025 (release) [ARM/arm-9-branch revision 277599] (GNU Tools for Arm Embedded Processors 9-2019-q4-major)

and on linux, with:

arm-none-eabi-gcc -v gcc version 8.3.1 20190703 (release) [gcc-8-branch revision 273027] (15:8-2019-q3-1+b1)

If you change the C/A/LD-FLAGS in Makefile from -mabi=aapcs-linux to -mabi=apcs-gnu ?

Evlers commented 1 year ago
OBJCOPY awboot.bin
   text    data     bss     dec     hex filename
  24692     364    5448   30504    7728 awboot.elf
len: 25056
The bootloader head has been fixed, spl size is 32768 bytes.

I before used a version 6.3 compiler and now installing version 8.3.1 is ok !!

sudo dd if=awboot.bin of=/dev/sdd bs=1024 seek=8

But I write to the TF card, connect PB4 and PB5 have no log output..... I am using the mangopi mq-dual board.

szemzoa commented 1 year ago

first try running directly from memory:

Evlers commented 1 year ago

I using xfel have log output

Allwinner T113-loader
DRAM SIZE = 128M
DRAM simple test OK.
CPU freq=1200 MHz
SD/MMC card not found
oops, something went wrong...

Am I writing in the wrong position?? After inserting the TF card does not enter the FEL mode, it should be read to the boot.

szemzoa commented 1 year ago

It seems there is some problem with the MMC card, the awboot doesn't found it (from your log: SD/MMC card not found), and maybe if you write the awboot.bin to the MMC, the internal BROM of the T113 can't handle the MMC too.

Evlers commented 1 year ago

I log is pulled off the TF card for xfel writing, plug in the words can identify the TF card, the following log:

Allwinner T113-loader
DRAM SIZE = 128M
DRAM simple test OK.
CPU freq=1200 MHz
SD/MMC card at 'sdhci0' controller found
SD/MMC: Image: Read file zImage addr=45000000
*** FATFS: f_open, filename: [zImage]: error
oops, something went wrong...

I replaced two TF cards,I try it by writing with an img file!! In addition, where is the kernel you use? Can you recommend it to me? thanks you~

szemzoa commented 1 year ago

You need to make 2 partitions to the SDCARD. The first is a FAT partition, where you need to copy the dtb and the kernel, which the awboot will load, and the second partition (ext4) will be your linux rootfs. (you can build one with buildroot, for example).

You can build your own kernel from mainline 6.0 linux sources with the few patches I added. I uploaded a compiled kernel and dtb for testing.

Evlers commented 1 year ago

Thank you for your help, I saw the update. I'll test it with the file you gave it, and then I will compile one myself. Are you a Chinese?

szemzoa commented 1 year ago

Happy hacking :) No, I'm from Europe.

Evlers commented 1 year ago

Happy hacking :) No, I'm from Europe.

Be funny if you're Chinese,Because we have been communicating in English. 哈哈哈哈 Thanks again for your help~