U-Boot New Board Definition Question (Based on am335x_evm)


For the TL;DR out there, here is the short version:

Where is the CONFIG_TARGET_AM335X_EVM=y being set when compiling the am335x_evm_defconfig? Git history shows that sometime around April this line was removed from the am335x_evm_defconfig file yet when I compile, the .config file in the root directory lists this config as being set.

Compile Commands From eewiki
make ARCH=arm CROSS_COMPILE=${CC} distclean
make ARCH=arm CROSS_COMPILE=${CC} am335x_evm_defconfig

Full Story:

I have a new chunk of hardware we developed based on the beaglebone black world. We did some changes to the board and to round it all out I would like to make a derivative of the “/board/ti/am335x_evm” for our board. I can give specific files and changes I made if needed but the jist is I copied the TI am335x_evm board and all associated files (include, configs, common, etc), renamed all to my board name, changed Kconfigs to add reference to my new board, and changed any file references in the sources to point to my new board (/board/me/myboard).

At this point I have essentially cloned the TI files under my own name but have not modified any sources. I attempted to compile U-Boot under my new board name but it appears that the source being compiled is still the /board/ti/am335x_evm/.

Compile commands:
make ARCH=arm CROSS_COMPILE=${CC} distclean
make ARCH=arm CROSS_COMPILE=${CC} myboard_defconfig

When I open up the .config file in the root folder I see that CONFIG_SYS_BOARD=“am335x” and not “myboard”, VENDOR is “ti” and not “me”, all of which are changed in the Kconfig file in my /board/my/myboard directory.

After some digging it appears that CONFIG_TARGET_AM335X_EVM is set when I would expect CONFIG_TARGET_MYBOARD would be set. Looking in /configs/am335x_evm_defconfig I do not see any CONFIG_TARGET_xxxxxxxxx lines. A text search for this line in the source turned up nothing that jumped out at me.

Where is the CONFIG_TARGET_AM335X_EVM being set? Git history shows that sometime around April this line was removed from the am335x_evm_defconfig file but I am not able to determine what has taken up defining this when compiling. Since I copied all the TI files, something recognizes myboard as am335x_evm and sets the CONFIG_TARGET_AM335x_EVM.

I did try adding a CONFIG_TARGET_MYBOARD=y to /configs/myboad_defconfig and build using that config and I get what I expected (CONFIG_SYS_BOARD=“myboard” in the .config) but why do I have to do this when the TI board does not?

Any insight greatly appreciated,


Hi Ty,

Yeah, nothing defines that CONFIG directly. It’s only if you select it in your config.

voodoo@hades:/opt/github/u-boot$ grep -R "TARGET_AM335X_EVM" ./*
./arch/arm/mach-omap2/am33xx/Kconfig:config TARGET_AM335X_EVM
./board/ti/am335x/Kconfig:if TARGET_AM335X_EVM
./env/fat.c:# if !defined(CONFIG_TARGET_AM335X_EVM) || defined(CONFIG_SPL_OS_BOOT)

I’d run

make ARCH=arm CROSS_COMPILE=${CC} menuconfig

and then compared menuconfig’s .config output with your custom defconfig



Firstly thank you Robert the excellent eewiki page,

I ran some experiments on U-Boot v2017.09 (with patches from eewiki) and I believe what is going on is this:

  • The AM335X_EVM_DEFCONFIG does not contain a TARGET config however it does define AM33XX

  • Kmake in its travels looks in the Kconfig file in /arch/arm/mach-omap2/am33xx/ and finds a section to process if AM33XX is set

  • While processing that section it encounters a “choice” for board selection, since none of the options is selected in the AM335X_EVM_DEFCONFIG (and by extension the .config) it must default to picking the first option in the list which is coincidentally AM335X_EVM

So if you define “CONFIG_AM33XX=y” but do not define any “CONFIG_TARGET_”, you will get the first CONFIG_TARGET Kmake encounters.

Thoughts and Consequences:
Assuming the above is correct and since the Kconfig board entries are generally kept in alphabetical order, as soon as a new board is added that would find itself preceding AM335X_EVM in the list (APPLE_BOARD for example) then I believe the builds for the AM335X_EVM_DEFCONFIG could fail silently. What I mean here is that the images could build with no compilation errors but when you intent to build AM335X_EVM_DEFCOFNIG you instead get the board that is at the top of the Kconfig list. Unless you inspect the .config or /include/config.h I do not believe the user would notice.
I can not say for certain if this is a potential problem because I can not find out why the CONFIG_TARGET line was removed from the AM335X_EVM_DEFCONFIG in the first place but I am sure there was a reason.

Running make menuconfig and saving the config avoids this problem because the user is responsible to choose the proper board in the menus.