PacktPublishing / Mastering-Embedded-Linux-Programming-Third-Edition

Mastering Embedded Linux Programming Third Edition, published by Packt
MIT License
532 stars 151 forks source link

BBB kernel build fail in chapter 4 #65

Closed zximeng closed 11 months ago

zximeng commented 11 months ago

Had a problem with building Linux kernel 5.4.50 or 5.4.254. always having problems with ahci.h macros.

linux/drivers/ata/libahci.c: In function 'ahci_led_store': linux/include/linux/compiler_types.h:357:45: error: call to '__compiletime_assert_302' declared with attribute error: BUILD_BUG_ON failed: sizeof(_s) > sizeof(long) 357 | _compiletime_assert(condition, msg, compiletimeassert, COUNTER__)

After finding the solutions online, I found it was a known problem and already solved in newer versions of kernels when I checked. So to be able to successfully build the kernel, you need to either change the bits shifts to BIT() as instructed or just use a newer kernel.

The solution to the problem is documented here: https://lore.kernel.org/lkml/20221203105425.180641-1-arnd@kernel.org/

One note is that you need to change SATA_MOBILE_LPM_POLICY to AHCI_HFLAG_IS_MOBILE.

And its also discussed in detail here:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107405

Also what is not mentioned in the book is that when you build, a prompt would ask you the strategy of heap memory zeroing. I don't think it matters a lot and I just choose zeroing when allocating. It's just a tradeoff between performance and security. Maybe the author can give more insight or advice on this.

fvasquez commented 10 months ago

@zximeng I agree with you that heap memory zeroing or not is just a tradeoff between security and performance. I think it's worth mentioning this in the next edition of the book.