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

Compiling bootloader from source issues #28794

Open
davidkhan opened this issue Dec 1, 2024 · 1 comment
Open

Compiling bootloader from source issues #28794

davidkhan opened this issue Dec 1, 2024 · 1 comment

Comments

@davidkhan
Copy link

davidkhan commented Dec 1, 2024

Hello , this is first time i am posting and not sure the right place.

I have flight controller boards
MicoAir743 ardupilot/libraries/AP_HAL_ChibiOS/hwdef/MicoAir743/hwdef.dat at master · ArduPilot/ardupilot · GitHub

MicoAir405v2 ardupilot/libraries/AP_HAL_ChibiOS/hwdef/MicoAir405v2/hwdef.dat at master · ArduPilot/ardupilot · GitHub

Pixhawk6C MINI ardupilot/libraries/AP_HAL_ChibiOS/hwdef/Pixhawk6C/hwdef.dat at master · ArduPilot/ardupilot · GitHub

I was trying to build bootloader on my MacOS machine , all compile ok and even .bin sizes are same. I use STM32CubeProgrammer , full erase and upload , but doesn't work.
Doesn’t work i mean , no led flashing , no hardware discovery on my windows and MAC.
Though it could be build system , I tried on my linux ubuntu 24 machine and upload , but still the same.

I tried to build bootloaders for all board and tested and none of the board work.
I have attached 2 bootloaders , one is my build and other one is original.
***** Please note all original bootloaders under ardupilot/Tools/bootloaders at master · ArduPilot/ardupilot · GitHub are working fine. and i tried from latest sources and older as well*******

Any idea what it could be and have anybody same issues?

Regards,
David

BOOTLOADER.zip

@rossiangela
Copy link

I see several important differences between your build and the official bootloader:

Size Difference:

  • Your build: 19,681 bytes
  • Official build: 19,571 bytes
  • Difference of 110 bytes

Content Differences:

18,473 bytes differ between the two files
First difference appears very early at offset 9
This suggests fundamental differences in the compiled code

Early Differences:
The differences start in what appears to be the vector table or early initialization code, this could indicate differences in:

  • Compiler settings
  • Linker configuration
    Memory layout
  • Build flags

Based on my analysis, here are some potential issues to check:

Build Environment:

  • Ensure you're using the exact same compiler version as the official builds
  • Check that all build flags match the official configuration
  • Verify the optimization levels (-O0, -O2, etc.)

Toolchain Setup:

  • Confirm you're using the correct ARM toolchain
  • Verify the compiler prefix (e.g., arm-none-eabi-)
  • Check if any environment variables might be affecting the build

Hardware Definitions:

  • Double-check the board-specific hwdef.dat files
  • Verify all pin configurations match
  • Ensure memory layout definitions are correct

Could you share:

  • The exact build commands you're using?
  • Your compiler version (arm-none-eabi-gcc --version)?
  • The content of your wscript or build configuration?

MY ANALYSIS

`// Read both bootloader files
const myBuild = await window.fs.readFile('AP_Bootloader_mybuild_linux.bin');
const official = await window.fs.readFile('MicoAir405v2_AP_Bootloader.bin');

// Compare file sizes
console.log('My build size:', myBuild.length, 'bytes');
console.log('Official size:', official.length, 'bytes');

// Look for major differences by comparing chunks
let differences = 0;
let firstDiffPos = -1;

for (let i = 0; i < myBuild.length && i < official.length; i++) {
    if (myBuild[i] !== official[i]) {
        differences++;
        if (firstDiffPos === -1) firstDiffPos = i;
    }
}

console.log('Number of different bytes:', differences);
console.log('First difference at position:', firstDiffPos);

// Look at the context around first difference
if (firstDiffPos !== -1) {
    const start = Math.max(0, firstDiffPos - 8);
    const end = Math.min(myBuild.length, firstDiffPos + 8);
    
    console.log('\nContext around first difference:');
    console.log('My build:', Array.from(myBuild.slice(start, end)).map(b => b.toString(16).padStart(2, '0')).join(' '));
    console.log('Official:', Array.from(official.slice(start, end)).map(b => b.toString(16).padStart(2, '0')).join(' '));
}`

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