[coreboot] Re: How can I set up a userspace test for coreboot code in 2023?

2023-04-04 Thread Julius Werner
We actually have a real unit test framework for coreboot now, so you
should be using that rather than trying to set up something
standalone. Hopefully that will make it easier to get things to
compile correctly as well. Check out the guide at
Documentation/tutorial/part3.md and the existing tests under tests/.

On Sun, Apr 2, 2023 at 8:36 AM Nico Huber  wrote:
>
> Hi Keith,
>
> On 02.04.23 15:33, Keith Hui wrote:
> > Here is the command line I figured would work, gathered with "make -n":
> >
> > gcc -Isrc -Isrc/include -Isrc/commonlib/include
> > -Isrc/commonlib/bsd/include -Ibuild -I3rdparty/vboot/firmware/include
> > -include src/include/kconfig.h -include src/include/rules.h -include
> > src/commonlib/bsd/include/commonlib/bsd/compiler.h -I3rdparty
> > -D__BUILD_DIR__=\"build\" -Isrc/arch/x86/include -D__ARCH_x86_32__
> > -Isrc/device/oprom/include -nostdinc -pipe -g -std=gnu11 -nostdlib
> > -Wall -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wwrite-strings
> > -Wredundant-decls -Wno-trigraphs -Wimplicit-fallthrough -Wshadow
> > -Wdate-time -Wtype-limits -Wvla -Wold-style-definition -Wdangling-else
> > -Wmissing-include-dirs -fno-common -ffreestanding -fno-builtin
> > -fomit-frame-pointer -fstrict-aliasing -ffunction-sections
> > -fdata-sections -fno-pie -Wno-packed-not-aligned -fconserve-stack
> > -Wnull-dereference -Wreturn-type -Wlogical-op -Wduplicated-cond
> > -Wno-unused-but-set-variable -Werror -Os -Wno-address-of-packed-member
> >  -m32  -fuse-ld=bfd -fno-stack-protector -Wl,--build-id=none
> > -fno-delete-null-pointer-checks -Wlogical-op -march=i686 -mno-mmx
> > --param asan-globals=0 -D__RAMSTAGE__ -include build/config.h
> > src/northbridge/intel/i440bx/raminit.c
> > src/northbridge/intel/i440bx/raminittest.c -o raminittest2023
> >
> > The C test code is attached.
>
> I'm seeing two errors, smbus_read_byte() not being declared and
>  missing.
>
> For the former, you should build with -D__ROMSTAGE__ (not R*A*MSTAGE).
>
> For the latter, I guess it might be better to compile `raminit.c` with
> the coreboot include paths and your `raminittest.c` with your host
> headers, i.e. *without* `-nostdinc` and coreboot paths. If that actually
> works depends a lot on details; it would be best to compile everything
> with the host's standard headers and only use those coreboot headers
> that are coreboot specific. However, both kinds of headers are mixed
> in coreboot's directory structure and some headers in coreboot that have
> standard names are actually not standard :-/
>
> With separate compilation, I get to
>
>   fatal error: standalonetest.h: No such file or directory
>
> ;)
>
> Cheers,
> Nico
>
> ___
> coreboot mailing list -- coreboot@coreboot.org
> To unsubscribe send an email to coreboot-le...@coreboot.org
___
coreboot mailing list -- coreboot@coreboot.org
To unsubscribe send an email to coreboot-le...@coreboot.org


[coreboot] Re: How can I set up a userspace test for coreboot code in 2023?

2023-04-02 Thread Nico Huber
Hi Keith,

On 02.04.23 15:33, Keith Hui wrote:
> Here is the command line I figured would work, gathered with "make -n":
>
> gcc -Isrc -Isrc/include -Isrc/commonlib/include
> -Isrc/commonlib/bsd/include -Ibuild -I3rdparty/vboot/firmware/include
> -include src/include/kconfig.h -include src/include/rules.h -include
> src/commonlib/bsd/include/commonlib/bsd/compiler.h -I3rdparty
> -D__BUILD_DIR__=\"build\" -Isrc/arch/x86/include -D__ARCH_x86_32__
> -Isrc/device/oprom/include -nostdinc -pipe -g -std=gnu11 -nostdlib
> -Wall -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wwrite-strings
> -Wredundant-decls -Wno-trigraphs -Wimplicit-fallthrough -Wshadow
> -Wdate-time -Wtype-limits -Wvla -Wold-style-definition -Wdangling-else
> -Wmissing-include-dirs -fno-common -ffreestanding -fno-builtin
> -fomit-frame-pointer -fstrict-aliasing -ffunction-sections
> -fdata-sections -fno-pie -Wno-packed-not-aligned -fconserve-stack
> -Wnull-dereference -Wreturn-type -Wlogical-op -Wduplicated-cond
> -Wno-unused-but-set-variable -Werror -Os -Wno-address-of-packed-member
>  -m32  -fuse-ld=bfd -fno-stack-protector -Wl,--build-id=none
> -fno-delete-null-pointer-checks -Wlogical-op -march=i686 -mno-mmx
> --param asan-globals=0 -D__RAMSTAGE__ -include build/config.h
> src/northbridge/intel/i440bx/raminit.c
> src/northbridge/intel/i440bx/raminittest.c -o raminittest2023
>
> The C test code is attached.

I'm seeing two errors, smbus_read_byte() not being declared and
 missing.

For the former, you should build with -D__ROMSTAGE__ (not R*A*MSTAGE).

For the latter, I guess it might be better to compile `raminit.c` with
the coreboot include paths and your `raminittest.c` with your host
headers, i.e. *without* `-nostdinc` and coreboot paths. If that actually
works depends a lot on details; it would be best to compile everything
with the host's standard headers and only use those coreboot headers
that are coreboot specific. However, both kinds of headers are mixed
in coreboot's directory structure and some headers in coreboot that have
standard names are actually not standard :-/

With separate compilation, I get to

  fatal error: standalonetest.h: No such file or directory

;)

Cheers,
Nico

___
coreboot mailing list -- coreboot@coreboot.org
To unsubscribe send an email to coreboot-le...@coreboot.org