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

UF2 files with address gaps are not flashed correctly #762

Closed
timokroeger opened this issue Mar 22, 2022 · 7 comments
Closed

UF2 files with address gaps are not flashed correctly #762

timokroeger opened this issue Mar 22, 2022 · 7 comments
Labels
documentation Improvements or additions to documentation elf2uf2
Milestone

Comments

@timokroeger
Copy link

The rp2040 bootrom uses the uf2 block number to determine when to erase a flash page:
https://github.com/raspberrypi/pico-bootrom/blob/c09c7f08550e8a36fc38dc74f8873b9576de99eb/bootrom/virtual_disk.c#L205

When there is a gap in target addresses between two uf2 blocks this logic does not work out.
As a workaround align all uf2 blocks to page erase boundary, so that the bootrom always removes the correct flash page.

@timokroeger
Copy link
Author

From the datasheet Section 2.8.4.2. UF2 Format Details:
"Note that flash is erased a 4K sector at a time, so writing to only a subset of a 4K flash sector will leave the rest of that
flash sector undefined. Beyond that there is no requirement that a binary be contiguous."

I guess this also needs an update.

@kilograham kilograham added documentation Improvements or additions to documentation elf2uf2 labels Mar 28, 2022
@kilograham kilograham added this to the 1.3.1 milestone Apr 4, 2022
@kilograham
Copy link
Contributor

can you please attach a UF2 with some holes? I want to test a slight fix change

@timokroeger
Copy link
Author

timokroeger commented May 3, 2022

Sure: holes.zip

The hole comes from RO data with huge alignment:

const uint8_t some_data[128] __attribute__((aligned(32 * 1024)));

@kilograham
Copy link
Contributor

ha i should have said holey ELF...
also, what compiler/version are you using? I've never seen GCC leave an actual hole.

@timokroeger
Copy link
Author

elf_with_holes.zip

I‘m using a recent version of GCC on windows:

> arm-none-eabi-gcc -v
Using built-in specs.
COLLECT_GCC=C:\Coding\gcc-arm-none-eabi-10.3-2021.10\bin\arm-none-eabi-gcc.exe
COLLECT_LTO_WRAPPER=c:/coding/gcc-arm-none-eabi-10.3-2021.10/bin/../lib/gcc/arm-none-eabi/10.3.1/lto-wrapper.exe
Target: arm-none-eabi
Configured with: /mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-338_20211018_1634516203/src/gcc/configure --build=x86_64-linux-gnu --host=i686-w64-mingw32 --target=arm-none-eabi --prefix=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-338_20211018_1634516203/install-mingw --libexecdir=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-338_20211018_1634516203/install-mingw/lib --infodir=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-338_20211018_1634516203/install-mingw/share/doc/gcc-arm-none-eabi/info --mandir=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-338_20211018_1634516203/install-mingw/share/doc/gcc-arm-none-eabi/man --htmldir=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-338_20211018_1634516203/install-mingw/share/doc/gcc-arm-none-eabi/html --pdfdir=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-338_20211018_1634516203/install-mingw/share/doc/gcc-arm-none-eabi/pdf --enable-languages=c,c++ --enable-mingw-wildcard --disable-decimal-float --disable-libffi --disable-libgomp --disable-libmudflap --disable-libquadmath --disable-libssp --disable-libstdcxx-pch --disable-nls --disable-shared --disable-threads --disable-tls --with-gnu-as --with-gnu-ld --with-headers=yes --with-newlib --with-python-dir=share/gcc-arm-none-eabi --with-sysroot=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-338_20211018_1634516203/install-mingw/arm-none-eabi --with-libiconv-prefix=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-338_20211018_1634516203/build-mingw/host-libs/usr --with-gmp=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-338_20211018_1634516203/build-mingw/host-libs/usr --with-mpfr=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-338_20211018_1634516203/build-mingw/host-libs/usr --with-mpc=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-338_20211018_1634516203/build-mingw/host-libs/usr --with-isl=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-338_20211018_1634516203/build-mingw/host-libs/usr --with-libelf=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-338_20211018_1634516203/build-mingw/host-libs/usr --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --with-pkgversion='GNU Arm Embedded Toolchain 10.3-2021.10' --with-multilib-list=rmprofile,aprofile
Thread model: single
Supported LTO compression algorithms: zlib
gcc version 10.3.1 20210824 (release) (GNU Arm Embedded Toolchain 10.3-2021.10)

@kilograham
Copy link
Contributor

fixed by #800

@kilograham
Copy link
Contributor

merged into develop

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

No branches or pull requests

2 participants