[U-Boot] Question about board-specific Makefile actions

James Chargin jimccrown at gmail.com
Thu Mar 12 19:35:50 CET 2015


I could still use some help with this from someone who really knows how 
the make system works.

Tom and Simon provided hints that were helpful, as I note below.

On 03/09/2015 08:34 AM, James Chargin wrote:
> So, is no one willing to offer a hint?
>
> Thanks,
> Jim
>
> On 03/03/2015 01:39 PM, James Chargin wrote:
>> I have a custom board in a git workspace for U-Boot 2014.07. I've copied
>> most of this from the .../board/ti/beagle. My board directory Makefile
>> looks like
>>
>> 8<---
>> obj-y := board.o
>> 8<---
>>
>> I'd like to add a few files to this directory that are processed during
>> "make all" and have any newly derived files deleted during "make clean".
>>
>> I've experimented with various Makefile contents but I can't get the new
>> files processed or any newly derived files deleted. U-Boot's makefile
>> system is quite large for my experience level and it seems I don't have
>> enough understanding.
>>
>> A new file might contain some hush commands that are to be executed from
>> the U-Boot command line. I'd like to use "source" to process these
>> commands. The "source" command requires that its argument be an image (I
>> get this into memory via TFTP), so I'd like "make all" to transform the
>> text file containing the hush commands into the image file. I'd also
>> like "make clean" to delete the derived image file.
>>
>> So, if my hush commands are in a text file called test.txt, I'd like
>> "make all" to apply mkimage so that a test.img is generated. I'd also
>> like "make clean" to delete test.img.
>>
>> I tried various changes to my Makefile, but the most likely seeming
>> changes are
>>
>> 8<---
>> IMG  = test.img
>>
>> obj-y    := board.o
>>
>> board.o : $(IMG)
>>
>> %.img : %.txt
>>      $(srctree)/tools/mkimage -T script -n $* -C none -d $< $@
>>
>> CLEAN_FILES += $(IMG)
>> CLEAN_DIRS  += .
>> 8<---
>>
>> This doesn't work, nor has any other approach I've taken. mkimage is
>> never run for "make all" and test.img doesn't get deleted if I create a
>> fake one and run "make clean"
>>
>> Could someone offer a solution, either directly, or by pointing at an
>> existing board that does something similar?

On 03/09/2015 08:54 AM, Tom Rini wrote:
>
> Off the top of my head, try throwing test.img into obj-y ?
>

Adding text.img to obj-y did cause the .img file to get generated, but 
it also added text.img to the list of files supplied to ld, causing the 
final u-boot link to fail


On 03/09/2015 11:49 AM, Simon Glass wrote:

> Also you may want to add a command like cmd_img_txt (see Makefile.lib
> for examples). Did you need to add anything to ALL-y?

Your mention of Makefile.lib prompted my to look there for other targets 
I might use. I discovered extra-y and adding

extra-y := test.img

to my board's Makefile caused the correct operations.

As you suggest, I added cmd_my_mkimage, which while not actually needed, 
is a very nice way to have a non-verbose progress report in the make output.

> Another option is to put this outside the U-Boot build system, and
> just run mkimage later.

I really want these steps to be part of the normal board make. Requiring 
a separate manual build step will inevitably result in that separate 
step being forgotten (most probably by me).


Is there any documentation you could point me at that might explain the 
way these Makefiles interact? I know most of this was derived from 
somewhere else (Linux kernel?) as part of the move to KConfig. But I 
have no experience with the kernel build system and following make's 
debug output is difficult, at best. Some overview of how makes are done 
would be quite helpful to me and maybe to other non-U-Boot-developers.


Remaining problems:

1) I can't figure out how to clean my newly created derived .img file. 
I've tried each of the following four lines (one at a time), but none worked
CLEAN_FILES += board/aja/helo/helo_setupdeveloper.img
CLEAN_FILES += test.img
CLEAN_FILES := test.img
clean-files += test.img
clean-files := test.img


2) More generally, I'd like to be able to add some arbitrary make steps 
that are peculiar to my boards Makefile, but I can't figure this out 
either, so far.

I've tried adding my_all to extra-y and then adding steps for my_all, 
similar to the following.

8<---
extra-y := test.img my_all

.PHONY my_all
my_all : test1.txt
	# some arbitrary commands to be executed if test1.txt isn't present
	cp -f test.txt test1.txt
8<---

In this case, make reports an error

make[1]: *** No rule to make target `board/my_board/my_all', needed by 
`__build'.  Stop.
make: *** [board/my_board] Error 2

Any help would be appreciated.

Thanks,
Jim


More information about the U-Boot mailing list