raspberrypi / usbboot

Raspberry Pi USB booting code, moved from tools repository
Apache License 2.0
878 stars 221 forks source link

Remove the need of sudo for make-boot-image #192

Closed ArneSchwerdt closed 8 months ago

ArneSchwerdt commented 8 months ago

I was about to create a recipe for Yocto to create signed boot image using the make-boot-image script. Unfortunately I ran into some issues:

  1. mkfs.fat is being called with an absolute path rather let the shell resolve the location. The problem is that Yocto compiles its own toolchain, so the location of mkfs.fat can vary.
  2. make-boot-image requires sudo. Executing tools with sudo in Yocto recipes is complicated. I found an alternative called mtools that provide a way to modify a fat image without utilizing mount or losetup which requires root permissions.

I tested the modified version of the script on my RPI400 and it worked fine.

timg236 commented 8 months ago

I think this needs to be changed without switching the default to mtools / mcopy. Of course I'm happy for people to fork this code since it's just documentation

ArneSchwerdt commented 8 months ago

I'm not quite sure I understand the reasons. RPI is very popular in the IoT world and is used in industry projects. Therefore automation should be easy. The need for root permissions make it just harder to use it in any toolchain. Also losetup brings trouble in case someone tries to use it in lightweight virtualization like docker which is widely used in CI/CD. Mtools can be found in all Linux package manager repos(apt, apk, pacman, yum, nix, portage, brew) I checked and is even preinstalled in Ubuntu. Could you explain your concerns?

timg236 commented 8 months ago

No objection to adding an option to using mtools but I'm not dropping the current implementation. I would suggest giving the user the option to use mtools

ArneSchwerdt commented 8 months ago

Adding an option would mean to uglify the script with too many if statements in my opinion. As you already said it is now fork/documented. For my specific cause, I simply make use of yoctos patch mechanism to apply the changes which seems to me a much more elegant solution. Thanks for your feedback.