Development Guidelines

The wiki is being retired!

Documentation is now handled by the same processes we use for code: Add something to the Documentation/ directory in the coreboot repo, and it will be rendered to https://doc.coreboot.org/. Contributions welcome!

Development Environment

Required Toolchain

The easiest way to get a working toolchain is to run make crossgcc in the toplevel directory of a coreboot checkout. Distributions usually modify their compilers in ways incompatible with coreboot. If in doubt, use our toolchain.

The toolchain consists of:

Coding Guidelines

General Guidelines

Variable types

Whenever possible, please use a variable type which is explicit about the size of data it can hold. For example, use uint32_t or u32 instead of unsigned long when referencing a 32-bit wide register.

short int names vs stdint names

There is currently no hard rule on whether one should use short int types (u32), or stdint types (uint32_t). Whichever type you elect to use, please use common sense and stay consistent.

Assembly Language

To keep the code consistent across the different supported platforms, AT&T syntax is to be used through-out the project. We are working actively on replacing the existing Intel syntax code with AT&T syntax. No new Intel syntax code is allowed into the project.

It is highly encouraged to not use inline assembly, but instead to encapsulate and isolate the use of assembly language to pure assembly files.

Comments

References

If you are referencing a data sheet or other documentation in the code, please add the name or document number in addition to the URL. Vendors just love to rearrange their websites (and some remove documentation on their old products altogether)! If we have the name/number (or even just the filename of the PDF) at least there's a chance to google for it again (either on the vendor's site or on some archive).

Coding Style

indent -npro -kr -i8 -ts8 -sob -l80 -ss -ncs *.[ch]
Do not trust 'indent' blindly, though. It sometimes gets things wrong. Manual corrections may be required.

The 80 character limit

Lines larger than 80 columns should be broken down into readable pieces. This includes not only source files, but also Makefiles, Kconfig files, and any file meant to be edited by a human. We recommend setting your editor to show the 80th character limit. This limit is not a relic from long forgotten times, but a very practical and efficient way to organize code and increase productivity. Several files can be edited on the same monitor, without the need to side-scroll. Side-scrolling source files is inefficient, time-consuming, and uncomfortable. On average, 95% of source lines are shorter than 80 characters, so limiting the line length is this manner is not only _not_ an impediment, it also gets you to think on how to best organize the code.

Documentation Guidelines

General Guidelines and Tips

Automatic documentation

/**
 * Sample comment.
 */
or
/** Sample comment. */
@param — input parameters of a function
@return — return value of a function

Full example:

/**
 * Calculate the length of a string.
 *
 * @param str The input string.
 * @return The length of the string, not including the final NUL character.
 */
static inline size_t strlen(const char *str)
{
        /* ... */
}

Testing

Every commit will be processed by the autobuild and autotest system available at http://qa.coreboot.org/. In addition please run autobuild yourself before submitting patches.

autobuild

Autobuild can be found at coreboot/util/abuild.

Please run abuild before you commit.

Autobuild is also running on every check-in to the repository. The results of this build are also available at http://qa.coreboot.org/.

autotest

We can also run automatic tests on boards, if we find contributors willing to have a board automatically managed by our QA system. This requires a permanent connection to the net, a host system and some special circuitry. If interested, please contact us using the mailing list.

How to contribute

Creating Patches

Sign-off Procedure

We employ a similar sign-off procedure for coreboot as the Linux kernel developers do. Please add a note such as

Signed-off-by: Random J Developer <random@developer.example.org>

to your email/patch if you agree with the following Developer's Certificate of Origin 1.1.

Patches without a Signed-off-by cannot be pushed to gerrit!

You have to use your real name in the Signed-off-by line and in any copyright notices you add. Patches without an associated real name cannot be committed!

Developer's Certificate of Origin 1.1:

By making a contribution to this project, I certify that:
(a) The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file; or
(b) The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file; or
(c) The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it; and
(d) In the case of each of (a), (b), or (c), I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the open source license indicated in the file.

Note: The Developer's Certificate of Origin 1.1 is licensed under the terms of the Creative Commons Attribution-ShareAlike 2.5 License.

Reviews

Bug-Tracker

Issues can be documented at https://ticket.coreboot.org/.

License Issues

Common License Header

Please quote the shortened GPL license header text in every file, as shown below. It should contain:

Copyright (C) 2006 John Doe <john@example.com>
Copyright (C) 2004-2006 Company, Inc.

Complete example for *.c and *.h files:

/*
 * This file is part of the coreboot project.
 *
 * Copyright (C) 2003-2005 Jane Doe <jane@example.com>
 * Copyright (C) 2006 Company, Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; version 2 of the License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

Complete example for Makefiles, config files, Python files, shell scripts etc.:

##
## This file is part of the coreboot project.
##
## Copyright (C) 2003-2005 Jane Doe <jane@example.com>
## Copyright (C) 2006 Company, Inc.
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; version 2 of the License.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
##