[U-Boot] Help defining an address in the environment

John, Michael Michael.John at Crown.com
Wed Feb 1 21:34:45 UTC 2017


Hello,

I'm trying to define an address value in the U-Boot environment and my issue
is the macro needs expended and arithmetic done before stringification.
I'm finding this to be difficult to define using just the preprocessor.
Below is the code showing what I'm trying to do.

Some other headers define a base address and some offsets:

============ CODE =============
#define IIM_BASE_ADDR 0x63F98000 /* define in different header */
#define IIM_BANK_AREA_1_OFFSET 0x00000C00 /* define in different header */

#define IIM_MAC_OCTET_1 (IIM_BASE_ADDR + IIM_BANK_AREA_1_OFFSET + 0x24) /*
IIM, bank 1, row 9 */

#define xstr(s) str(s)
#define str(s) #s

.....

#define CONFIG_EXTRA_ENV_SETTINGS \
    "octet_addr=" xstr(IIM_MAC_OCTET_1) "\0" \

============CODE END ==========

What I want is for the 'octet_addr' variable to equal '0x63F98C24', so I
could use it with 'itest' to do a check, but what I get is 'octet_addr'
equals '(IIM_BASE_ADDR + IIM_BANK_AREA_1_OFFSET + 0x24)'. I'm not seeing a
way to do what I want with just macros and the preprocessor. Is there a way
I could define some environment variable from inside a function?

Thanks for any help.

-Michael


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4892 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170201/499bbeb9/attachment.bin>


More information about the U-Boot mailing list