Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

"help wanted" region `FLASH' overflowed by 1724 bytes #5

Open
GusseDev opened this issue May 14, 2023 · 22 comments
Open

"help wanted" region `FLASH' overflowed by 1724 bytes #5

GusseDev opened this issue May 14, 2023 · 22 comments

Comments

@GusseDev
Copy link

Hello !
thanks for your great work!
I can't wait to see how it turns out!
for the moment I'm stuck in the compilation process, I get the following error and I can't go any further:

/home/gusse/.local/xPacks/@xpack-dev-tools/arm-none-eabi-gcc/11.3.1-1.1.2/.content/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: build/gw_zelda3.elf section `.rodata' will not fit in region `FLASH'
/home/gusse/.local/xPacks/@xpack-dev-tools/arm-none-eabi-gcc/11.3.1-1.1.2/.content/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: region `FLASH' overflowed by 1724 bytes
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:475: build/gw_zelda3.elf] Error 1
make[1]: Leaving directory '/home/gusse/game-and-watch-zelda3'
make: *** [Makefile:553 : flash] Erreur 2

I made the test on 2 GnW a mario and a zelda, and the trouble is the same, here is the command that I use:

make INTFLASH_BANK=2 EXTFLASH_SIZE_MB=64 EXTFLASH_OFFSET=1048576 ADAPTER=stlink OPENOCD=/opt/openocd-git/bin/openocd GNW_TARGET=mario LANGUAGE=us flash

And some other variations have the same result. I also do a make clean before compilation...
I tried several commands without success.
I specify that I am not 100% at ease under linux, but I manage.
For information, I manage to flash without problem the retro go coverflow version in dual boot.
My GnW are upgraded to 64Mb too.
If I miss some information don't hesitate to ask !
Thanks in advance for your help!

@BrianPugh
Copy link
Contributor

The error you're currently seeing is due to using gcc 11.3.1 instead of a more modern version (12.2.1) and is purely a zelda3 issue. Checkout the stacksmashing discord server (#homebrew channel) for more rapid responses.

@GusseDev
Copy link
Author

great !! thank you !! I have to check that, and I have found this way but I have to test that !!

@marian-m12l
Copy link
Owner

@GusseDev Sorry for being so slow to react.. As @BrianPugh mentionned using a newer gcc should work better. However I've just pushed a few improvements that include some memory reorg with increased margins (a few KB) to try a make it work on gcc 11 or 10.

@GusseDev
Copy link
Author

no worries! you do it for free and happily, it's just great what you did!
I don't think you should bother adjusting for older versions 😊, just document it and it's beautiful!
Thanks again for your great work, I'm going to try this out!

@marian-m12l
Copy link
Owner

marian-m12l commented May 21, 2023

Thanks, and please feel free to give feedback if things need to be improved.

The "section overflow" issue has risen several times already and in some cases I think specific builds of gcc 12 (for raspberry pi IIRC) did not fix it. I'm hoping that with bigger margins (free space was under 1KB at some point) it will suit more configs.

@GusseDev
Copy link
Author

I have updated my gcc version to gcc 12.3:

gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/12/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 12.3.0-1ubuntu1~22.04' --with-bugurl=file:///usr/share/doc/gcc-12/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-12 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-12-ALHxjy/gcc-12-12.3.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-12-ALHxjy/gcc-12-12.3.0/debian/tmp-gcn/usr --enable-offload-defaulted --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.3.0 (Ubuntu 12.3.0-1ubuntu1~22.04)

But I get another error:

....bi-gcc/11.3.1-1.1.2/.content/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m+dp/hard/libc_nano.a(libc_a-readr.o): in function `_read_r':
(.text._read_r+0x10): warning: _read is not implemented and will always fail
/home/gusse/.local/xPacks/@xpack-dev-tools/arm-none-eabi-gcc/11.3.1-1.1.2/.content/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: build/main.o: in function `app_main':
main.c:(.text.app_main+0x300): undefined reference to `zelda_extflash_assets_length'
/home/gusse/.local/xPacks/@xpack-dev-tools/arm-none-eabi-gcc/11.3.1-1.1.2/.content/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: main.c:(.text.app_main+0x304): undefined reference to `zelda_extflash_assets'
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:476 : build/gw_zelda3.elf] Erreur 1
make[1] : on quitte le répertoire « /home/gusse/game-and-watch-zelda3 »
make: *** [Makefile:554 : flash] Erreur 2

Have you an idea ? or maybe I forget something...
I have deleted my folder and update to your latest version
Thank you

@marian-m12l
Copy link
Owner

What command are you running?

Can you see the source files generated from the ROM assets in Core/Src/Porting/ ?

@GusseDev
Copy link
Author

hmmm sorry I have made a mistake in my command (I have set Language params twice...)
No it's flash ! but no boot, I have to adjust setting, I'm on the good way.
just for information, the command I have used :

make -j12 INTFLASH_BANK=1 OPENOCD=/opt/openocd-git/bin/openocd LANGUAGE=us GNW_TARGET=mario flash ADAPTER=stlink LARGE_FLASH=1

@marian-m12l
Copy link
Owner

No error during flashing? What's your flash chip? I'll try on first bank since I haven't tried it much that way.

@marian-m12l
Copy link
Owner

No issues on first bank on my side.

@GusseDev
Copy link
Author

Without offset params, it's flash, but no boot with the previous command.
And with you command adapted accordingly with my GnW with 64Mb memory :

make INTFLASH_BANK=2 EXTFLASH_SIZE_MB=63 EXTFLASH_OFFSET=1048576 ADAPTER=stlink OPENOCD=/opt/openocd-git/bin/openocd GNW_TARGET=mario LANGUAGE=fr flash
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
none separate
Info : clock speed 1800 kHz
Info : STLINK V2J29S7 (API v2) VID:PID 0483:3748
Info : Target voltage: 3.117383
Info : [stm32h7x.cpu0] Cortex-M7 r1p1 processor detected
Info : [stm32h7x.cpu0] target has 8 breakpoints, 4 watchpoints
Info : starting gdb server for stm32h7x.cpu0 on 3333
Info : Listening on port 3333 for gdb connections
[stm32h7x.cpu0] halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x08018170 msp: 0x20011330
Info : Device: STM32H7Ax/7Bx
Info : flash size probed value 128k
Info : STM32H7 flash has dual banks
Info : Bank (0) size is 256 kb, base address is 0x08000000
Initializing Octo-SPI interface
Info : Device: STM32H7Ax/7Bx
Info : flash size probed value 128k
Info : STM32H7 flash has dual banks
Info : Bank (1) size is 256 kb, base address is 0x08100000
** Programming Started **
Info : device has to be switched to 4-byte addresses
Info : 4-byte address parameter table
Info : valid SFDP detected
Info : flash1 'sfdp' id = 0x3a25c2 size = 65536 KiB
Error: FSIZE in DCR(1) doesn't match actual capacity.
Warn : Adding extra erase range, 0x9023a31c .. 0x9023ffff
Error: Sector erase command not accepted by flash1. Status=0x42
Error: Flash sector_erase failed on sector 16
Error: failed erasing sectors 16 to 35
** Programming Failed **
shutdown command invoked

And the exact reference of the chip I use is: MX25U51245GZ4I00
don't hesitate to ask me to test something ;)

@GusseDev
Copy link
Author

I have made some tests on another upgraded 64Mb GnW Mario, with the following command :

make INTFLASH_BANK=2 EXTFLASH_SIZE_MB=63 EXTFLASH_OFFSET=1048576 ADAPTER=stlink GNW_TARGET=mario LANGUAGE=fr flash

and I still get this error :

** Programming Started **
Info : device has to be switched to 4-byte addresses
Info : 4-byte address parameter table
Info : valid SFDP detected
Info : flash1 'sfdp' id = 0x3a25c2 size = 65536 KiB
Error: FSIZE in DCR(1) doesn't match actual capacity.
Warn : Adding extra erase range, 0x9023a31c .. 0x9023ffff
Error: Sector erase command not accepted by flash1. Status=0x42
Error: Flash sector_erase failed on sector 16
Error: failed erasing sectors 16 to 35
** Programming Failed **

Did you think my command is good ?
I have tried to flash a retro go and it's still ok !
Thanks again !

@marian-m12l
Copy link
Owner

I figure you have no issue flashing the original/patched firmware or retro-go?
It's surprising that it would flash ok without offset..

@marian-m12l
Copy link
Owner

maybe try setting the OPENOCD path? You're using the patched openocd?

@GusseDev
Copy link
Author

Yes I use the patch version, I try again with OPENOCD setting
What command do you suggest to flash a 64MB memory?

@marian-m12l
Copy link
Owner

I don't have a flash bigger than 16MB, so I can't try it myself. I think people have successfully flashed 64MB chips. Your flags look alright. Make sure to set LARGE_FLASH=1 to disable verify (which seems to be buggy on large chip) and enable 32-bits addressing.

@marian-m12l
Copy link
Owner

To be a bit more clear, this command sounds good:

make INTFLASH_BANK=2 EXTFLASH_SIZE_MB=63 EXTFLASH_OFFSET=1048576 LARGE_FLASH=1 OPENOCD=/opt/openocd-git/bin/openocd ADAPTER=stlink GNW_TARGET=mario flash

@GusseDev
Copy link
Author

with LARGE_FLASH=1 error is away !
but it still not bootable (on dual boot GAME+LEFT -> black screen).

Here is my command:

make -j12 INTFLASH_BANK=2 EXTFLASH_SIZE_MB=63 EXTFLASH_OFFSET=1048576 ADAPTER=stlink OPENOCD=/opt/openocd-git/bin/openocd GNW_TARGET=mario LANGUAGE=fr LARGE_FLASH=1 flash

and the end message (unable to reset is usual with Stlink if I'm not wrong) :

Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
none separate
Info : clock speed 1800 kHz
Info : STLINK V2J29S7 (API v2) VID:PID 0483:3748
Info : Target voltage: 3.114304
Info : [stm32h7x.cpu0] Cortex-M7 r1p1 processor detected
Info : [stm32h7x.cpu0] target has 8 breakpoints, 4 watchpoints
Error executing event examine-end on target stm32h7x.cpu0:
read_memory: failed to read memory
in procedure 'program'
Info : starting gdb server for stm32h7x.cpu0 on 3333
Info : Listening on port 3333 for gdb connections
Error executing event examine-end on target stm32h7x.cpu0:
embedded:startup.tcl:1187: Error: read_memory: failed to read memory
in procedure 'program' 
in procedure 'ocd_process_reset' 
in procedure 'ocd_process_reset_inner' called at file "embedded:startup.tcl", line 1187
** Unable to reset target **
shutdown command invoked

@marian-m12l
Copy link
Owner

I've never seen this openocd error..
Also I see you're setting LANGUAGE=fr, do you have both US en FR roms? Maybe try without setting the language first?

@GusseDev
Copy link
Author

I make test without language param, and it doesn't run, so I have put LANGUAGE=us

make -j12 INTFLASH_BANK=2 EXTFLASH_SIZE_MB=63 EXTFLASH_OFFSET=1048576 ADAPTER=stlink OPENOCD=/opt/openocd-git/bin/openocd GNW_TARGET=mario LANGUAGE=us LARGE_FLASH=1 flash

and I get:

Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
none separate
Info : clock speed 1800 kHz
Info : STLINK V2J29S7 (API v2) VID:PID 0483:3748
Info : Target voltage: 3.115844
Info : [stm32h7x.cpu0] Cortex-M7 r1p1 processor detected
Info : [stm32h7x.cpu0] target has 8 breakpoints, 4 watchpoints
Error executing event examine-end on target stm32h7x.cpu0:
read_memory: failed to read memory
in procedure 'program'
Info : starting gdb server for stm32h7x.cpu0 on 3333
Info : Listening on port 3333 for gdb connections
Error executing event examine-end on target stm32h7x.cpu0:
embedded:startup.tcl:1187: Error: read_memory: failed to read memory
in procedure 'program'
in procedure 'ocd_process_reset'
in procedure 'ocd_process_reset_inner' called at file "embedded:startup.tcl", line 1187
** Unable to reset target **
shutdown command invoked

@marian-m12l
Copy link
Owner

It doesn't run? What does it do?
Maybe also drop the parallel build for now? Might give a more readable output.

@GusseDev
Copy link
Author

I turn off parallel build, and press reset on Gnw during flash, the process have run without error on terminal:

Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
none separate
Info : clock speed 1800 kHz
Info : STLINK V2J29S7 (API v2) VID:PID 0483:3748
Info : Target voltage: 3.119384
Info : [stm32h7x.cpu0] Cortex-M7 r1p1 processor detected
Info : [stm32h7x.cpu0] target has 8 breakpoints, 4 watchpoints
Info : starting gdb server for stm32h7x.cpu0 on 3333
Info : Listening on port 3333 for gdb connections
[stm32h7x.cpu0] halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x08018170 msp: 0x20011330
Info : Device: STM32H7Ax/7Bx
Info : flash size probed value 128k
Info : STM32H7 flash has dual banks
Info : Bank (0) size is 256 kb, base address is 0x08000000
Initializing Octo-SPI interface
Info : Device: STM32H7Ax/7Bx
Info : flash size probed value 128k
Info : STM32H7 flash has dual banks
Info : Bank (1) size is 256 kb, base address is 0x08100000
make[1]: Leaving directory '/home/gusse/game-and-watch-zelda3'

BUT, on GNW when I try to boot on the second bank (GAME + LEFT) I get a blue screen with the following message :

FATAL EXCEPTION Hardfault
PC=0x08128812 LR=0x0000ef4d
init_mx_issi
Found config: MX25U51245G
Status: 40
JEDEC_ID: C2 25 3A

Unfortunately I have to go for now, I can do additionnal test later, I also make some test with 16Mb memory, I have some under my hand
Thanks again for your time and your awesome job !

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

No branches or pull requests

3 participants