This repository has been archived by the owner. It is now read-only.

[mozilla-flame] Append `dtb` file to `boot.img` (qcdt) #323

Closed
ollieparanoid opened this Issue Aug 2, 2017 · 8 comments

Comments

Projects
None yet
3 participants
@ollieparanoid
Member

ollieparanoid commented Aug 2, 2017

From what @yuvadm told us in the channel, the flame comes with its own version of fastboot/mkbootimg, which appends the dtb file at the end of the boot.img (and not at the end of the kernel, as it is with all other Android devices). The kernel is part of the boot.img file though.

I'm not sure what the best way would be to handle this right now (suggestions welcome!) - @yuvadm, could you point us to the source code of these mozilla specific forks?

@yuvadm

This comment has been minimized.

Show comment
Hide comment
@yuvadm

yuvadm Aug 2, 2017

Member

@ollieparanoid Thanks for opening an issue on this topic. Also CC'ing @z3ntu here as well since he provided some initial patches.

Essentially we need to pick a mkbootimg that supports the --dt flag which is able to append the device tree files to the boot.img. This is needed not only for the Flame but also for another device I believe @z3ntu is working on porting.

There are several different patched mkbootimg floating around, I'll paste a few that I ran into here, and then we can decide on the merits of each one:

(tbh I'm not exactly sure which version is used by B2G, but I guess it doesn't really matter, we need something that works for many devices)

Once we figure this out, we need to conditionally add the --dt flag to mkbootimg. An initial breaking patch looks like this:

--- a/aports/postmarketos-mkinitfs/mkinitfs.sh
+++ b/aports/postmarketos-mkinitfs/mkinitfs.sh
@@ -171,6 +171,7 @@ create_bootimg()
                --ramdisk_offset "${deviceinfo_flash_offset_ramdisk}" \
                --tags_offset "${deviceinfo_flash_offset_tags}" \
                --pagesize "${deviceinfo_flash_pagesize}" \
+               --dt "${kernelfile/initramfs-/dt.img-}" \
                -o "${outfile/initramfs-/boot.img-}"
 }
Member

yuvadm commented Aug 2, 2017

@ollieparanoid Thanks for opening an issue on this topic. Also CC'ing @z3ntu here as well since he provided some initial patches.

Essentially we need to pick a mkbootimg that supports the --dt flag which is able to append the device tree files to the boot.img. This is needed not only for the Flame but also for another device I believe @z3ntu is working on porting.

There are several different patched mkbootimg floating around, I'll paste a few that I ran into here, and then we can decide on the merits of each one:

(tbh I'm not exactly sure which version is used by B2G, but I guess it doesn't really matter, we need something that works for many devices)

Once we figure this out, we need to conditionally add the --dt flag to mkbootimg. An initial breaking patch looks like this:

--- a/aports/postmarketos-mkinitfs/mkinitfs.sh
+++ b/aports/postmarketos-mkinitfs/mkinitfs.sh
@@ -171,6 +171,7 @@ create_bootimg()
                --ramdisk_offset "${deviceinfo_flash_offset_ramdisk}" \
                --tags_offset "${deviceinfo_flash_offset_tags}" \
                --pagesize "${deviceinfo_flash_pagesize}" \
+               --dt "${kernelfile/initramfs-/dt.img-}" \
                -o "${outfile/initramfs-/boot.img-}"
 }
@z3ntu

This comment has been minimized.

Show comment
Hide comment
@z3ntu

z3ntu Aug 2, 2017

Member

I have a version of the last patch on my laptop which is non-breaking but I'm on my phone atm

Member

z3ntu commented Aug 2, 2017

I have a version of the last patch on my laptop which is non-breaking but I'm on my phone atm

@z3ntu

This comment has been minimized.

Show comment
Hide comment
@z3ntu

z3ntu Aug 2, 2017

Member

Also the method used is called qcdt and I would use the lineage source of the tools if available. @M1cha pushed the important changes from efidroid to Lineage

Member

z3ntu commented Aug 2, 2017

Also the method used is called qcdt and I would use the lineage source of the tools if available. @M1cha pushed the important changes from efidroid to Lineage

@yuvadm

This comment has been minimized.

Show comment
Hide comment
@yuvadm

yuvadm Aug 2, 2017

Member

@z3ntu good to know! Would love to get the updated version whenever you have a chance to post it. Also curious if this worked for you. I'm still running into problems with the flame dt.img.

Member

yuvadm commented Aug 2, 2017

@z3ntu good to know! Would love to get the updated version whenever you have a chance to post it. Also curious if this worked for you. I'm still running into problems with the flame dt.img.

@ollieparanoid ollieparanoid changed the title from [mozilla-flame] Append `dtb` file to `boot.img` to [mozilla-flame] Append `dtb` file to `boot.img` (qcdt) Aug 2, 2017

@ollieparanoid

This comment has been minimized.

Show comment
Hide comment
@ollieparanoid

ollieparanoid Aug 3, 2017

Member

Alright, then I suggest to integrate it the following way:

  • Replace the mkbootimg we have packaged with the version from LineageOS
  • Modify linux-mozilla-flame to save the dtb file in /usr/share/dtb
  • Specify the dtb file name in the deviceinfo
  • Add a new option: deviceinfo_bootimg_qcdt="true"
  • Modify mkinitfs.sh to use the --dt flag, when that option is enabled
  • Test if everything works
  • Make a PR
  • Document the new deviceinfo option in the deviceinfo reference
Member

ollieparanoid commented Aug 3, 2017

Alright, then I suggest to integrate it the following way:

  • Replace the mkbootimg we have packaged with the version from LineageOS
  • Modify linux-mozilla-flame to save the dtb file in /usr/share/dtb
  • Specify the dtb file name in the deviceinfo
  • Add a new option: deviceinfo_bootimg_qcdt="true"
  • Modify mkinitfs.sh to use the --dt flag, when that option is enabled
  • Test if everything works
  • Make a PR
  • Document the new deviceinfo option in the deviceinfo reference
@z3ntu

This comment has been minimized.

Show comment
Hide comment
@z3ntu

z3ntu Aug 3, 2017

Member

@yuvadm I only got pmOS to boot with a kernel not built via the alpine build process (but normal Android mka zImage)

Member

z3ntu commented Aug 3, 2017

@yuvadm I only got pmOS to boot with a kernel not built via the alpine build process (but normal Android mka zImage)

@z3ntu

This comment has been minimized.

Show comment
Hide comment
@z3ntu

z3ntu Aug 3, 2017

Member

A crude version of that patch is z3ntu@6b5a9de but it isn't in the format that @ollieparanoid proposed. I don't really have time this week but next week I should be able to do the things listed (except someone else does them earlier)

Member

z3ntu commented Aug 3, 2017

A crude version of that patch is z3ntu@6b5a9de but it isn't in the format that @ollieparanoid proposed. I don't really have time this week but next week I should be able to do the things listed (except someone else does them earlier)

@ollieparanoid

This comment has been minimized.

Show comment
Hide comment
@ollieparanoid

ollieparanoid Aug 12, 2017

Member

Support for this feature has been merged in #356, which also shows how to use it.
I have extended the deviceinfo reference and added a new sub-article for deviceinfo_bootimg_qcdt (which has not much content yet, but it's a start).

The only thing I would like to see improved in hindsight (you know, after I reviewed the PR and merged it :p) is saving the dt.img file as dt.img-$FLAVOR, so we could have multiple kernels installed in parallel. But we can leave that for another PR if this becomes an issue.

Thanks for working on this feature, this is a great enhancement!

Member

ollieparanoid commented Aug 12, 2017

Support for this feature has been merged in #356, which also shows how to use it.
I have extended the deviceinfo reference and added a new sub-article for deviceinfo_bootimg_qcdt (which has not much content yet, but it's a start).

The only thing I would like to see improved in hindsight (you know, after I reviewed the PR and merged it :p) is saving the dt.img file as dt.img-$FLAVOR, so we could have multiple kernels installed in parallel. But we can leave that for another PR if this becomes an issue.

Thanks for working on this feature, this is a great enhancement!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.