soc/intel/cannonlake: Enable CNVi based on devicetree
[coreboot.git] / Documentation / lessons / lesson2.md
blobc9c9484478d125f332c2196ba94258c49ba3b80b
1 # coreboot Lesson 2: Submitting a patch to coreboot.org
3 ## Part 1: Setting up an account at coreboot.org
5 If you already have an account, skip to Part 2.
7 Otherwise, go to <https://review.coreboot.org> in your preferred web browser.
8 Select **Register** in the upper right corner.
10 Select the appropriate sign-in. For example, if you have a Google account,
11 select **Google OAuth2** (gerrit-oauth-provider plugin)".**Note:** Your
12 username for the account will be the username of the account you used to
13 sign-in with. (ex. your Google username).
15 ## Part 2a: Set up RSA Private/Public Key
17 If you prefer to use an HTTP password instead, skip to Part 2b.
19 For the most up-to-date instructions on how to set up SSH keys with Gerrit go to
20 <https://gerrit-documentation.storage.googleapis.com/Documentation/2.14.2/user-upload.html#configure_ssh)>
21 and follow the instructions there. Then, skip to Part 3.
23 Additionally, that section of the Web site provides explanation on starting
24 an ssh-agent, which may be particularly helpful for those who anticipate
25 frequently uploading changes.
27 If you instead prefer to have review.coreboot.org specific instructions,
28 follow the steps below. Note that this particular section may have the
29 most up-to-date instructions.
31 If you do not have an RSA key set up on your account already (as is the case
32 with a newly created account), follow the instructions below; otherwise,
33 doing so could overwrite an existing key.
35 In the upper right corner, select your name and click on **Settings**.
36 Select **SSH Public Keys** on the left-hand side.
38 In a terminal, run "ssh-keygen" and confirm the default path ".ssh/id_rsa".
40 Make a passphrase -- remember this phrase. It will be needed whenever you use
41 this RSA Public Key. **Note:** You might want to use a short password, or
42 forego the password altogether as you will be using it very often.
44 Open "id_rsa.pub", copy all contents and paste into the textbox under
45 "Add SSH Public Key" in the https://review.coreboot.org webpage.
47 ## Part 2b: Setting up an HTTP Password
49 Alternatively, instead of using SSH keys, you can use an HTTP password. To do so,
50 after you select your name and click on **Settings** on the left-hand side, rather
51 than selecting **SSH Public Keys**, select **HTTP Password**.
53 Click **Generate Password**. This should fill the "Password" box with a password. Copy
54 the password, and add the following to your $HOME/.netrc file:
56         machine review.coreboot.org login YourUserNameHere password YourPasswordHere
58 where YourUserNameHere is your username, and YourPasswordHere is the password you
59 just generated.
61 ## Part 3: Clone coreboot and configure it for submitting patches
63 On Gerrit, click on the **Browse** tab in the upper left corner and select
64 **Repositories**.  From the listing, select the "coreboot" repo.  You may have
65 to click the next page arrow at the bottom a few times to find it.
67 If you are using SSH keys, select **ssh** from the tabs under "Project
68 coreboot" and run the "clone with commit-msg hook" command that's provided.
69 This should prompt you for your id_rsa passphrase, if you previously set one.
71 If you are using HTTP, instead, select **http** from the tabs under "Project coreboot"
72 and run the command that appears
74 Now is a good time to configure your global git identity, if you haven't
75 already.
77         git config --global user.name "Your Name"
78         git config --global user.email "Your Email"
80 Finally, enter the local git repository and set up repository specific hooks
81 and other configurations.
83         cd coreboot
84         make gitconfig
86 ## Part 4: Submit a commit
88 An easy first commit to make is fixing existing checkpatch errors and warnings
89 in the source files. To see errors that are already present, build the files in
90 the repository by running 'make lint' in the coreboot directory. Alternatively,
91 if you want to run 'make lint' on a specific directory, run:
93         for file in $(git ls-files | grep src/amd/quadcore); do \
94         util/lint/checkpatch.pl --file $file --terse; done
96 where <filepath> is the filepath of the directory (ex. src/cpu/amd/car).
98 Any changes made to files under the src directory are made locally,
99 and can be submitted for review.
101 Once you finish making your desired changes, use the command line to stage
102 and submit your changes. An alternative and potentially easier way to stage
103 and submit commits is to use git cola, a graphical user interface for git. For
104 instructions on how to do so, skip to Part 4b.
106 ## Part 4a: Using the command line to stage and submit a commit
108 To use the command line to stage a commit, run
110         git add <filename>
112 where `filename` is the name of your file.
114 To commit the change, run
116         git commit -s
118 **Note:** The -s adds a signed-off-by line by the committer. Your commit should be
119 signed off with your name and email (i.e. **Your Name** **<Your Email>**, based on
120 what you set with git config earlier).
122 Running git commit first checks for any errors and warnings using lint. If
123 there are any, you must go back and fix them before submitting your commit.
124 You can do so by making the necessary changes, and then staging your commit again.
126 When there are no errors or warnings, your default text editor will open.
127 This is where you will write your commit message.
129 The first line of your commit message is your commit summary. This is a brief
130 one-line description of what you changed in the files using the template
131 below:
133 <filepath>: Short description
134 *ex. cpu/amd/pi/00630F01: Fix checkpatch warnings and errors*
135 **Note:** It is good practice to use present tense in your descriptions
136 and do not punctuate your summary.
138 Then hit Enter. The next paragraph should be a more in-depth explanation of the
139 changes you've made to the files. Again, it is good practice to use present
140 tense.
141 *ex.  Fix space prohibited between function name and open parenthesis,
142 line over 80 characters, unnecessary braces for single statement blocks,
143 space required before open brace errors and warnings.*
145 When you have finished writing your commit message, save and exit the text
146 editor. You have finished committing your change. If, after submitting your
147 commit, you wish to make changes to it, running "git commit --amend" allows
148 you to take back your commit and amend it.
150 When you are done with your commit, run 'git push' to push your commit to
151 coreboot.org. **Note:** To submit as a draft, use
152 'git push origin HEAD:refs/drafts/master' Submitting as a draft means that
153 your commit will be on coreboot.org, but is only visible to those you add
154 as reviewers.
156 This has been a quick primer on how to submit a change to Gerrit for review
157 using git.  You may wish to review the [Gerrit code review workflow
158 documentation](https://gerrit-review.googlesource.com/Documentation/intro-user.html#code-review),
159 especially if you plan to work on multiple changes at the same time.
161 ## Part 4b: Using git cola to stage and submit a commit
163 If git cola is not installed on your machine, see
164 https://git-cola.github.io/downloads.html for download instructions.
166 After making some edits to src files, rather than run "git add," run
167 'git cola' from the command line. You should see all of the files
168 edited under "Modified".
170 In the textbox labeled "Commit summary" provide a brief one-line
171 description of what you changed in the files according to the template
172 below:
174 <filepath>: Short description
175 *ex. cpu/amd/pi/00630F01: Fix checkpatch warnings and errors*
176 **Note:** It is good practice to use present tense in your descriptions
177 and do not punctuate your short description.
179 In the larger text box labeled 'Extended description...' provide a more
180 in-depth explanation of the changes you've made to the files. Again, it
181 is good practice to use present tense.
182 *ex.  Fix space prohibited between function name and open parenthesis,
183 line over 80 characters, unnecessary braces for single statement blocks,
184 space required before open brace errors and warnings.*
186 Then press Enter two times to move the cursor to below your description.
187 To the left of the text boxes, there is an icon with an downward arrow.
188 Press the arrow and select "Sign Off." Make sure that you are signing off
189 with your name and email (i.e. **Your Name** **<Your Email>**, based on what
190 you set with git config earlier).
192 Now, review each of your changes and mark either individual changes or
193 an entire file as Ready to Commit by marking it as 'Staged'. To do
194 this, select one file from the 'Modified' list. If you only want to
195 submit particular changes from each file, then highlight the red and
196 green lines for your changes, right click and select 'Stage Selected
197 Lines'. Alternatively, if an entire file is ready to be committed, just
198 double click on the file under 'Modified' and it will be marked as
199 Staged.
201 Once the descriptions are done and all the edits you would like to
202 commit have been staged, press 'Commit' on the right of the text
203 boxes.
205 If the commit fails due to persisting errors, a text box will appear
206 showing the errors. You can correct these errors within 'git cola' by
207 right-clicking on the file in which the error occurred and selecting
208 'Launch Diff Tool'. Make necessary corrections, close the Diff Tool and
209 'Stage' the corrected file again. It might be necessary to refresh
210 'git cola' in order for the file to be shown under 'Modified' again.
211 Note: Be sure to add any other changes that haven't already been
212 explained in the extended description.
214 When ready, select 'Commit' again. Once all errors have been satisfied
215 and the commit succeeds, move to the command line and run 'git push'.
216 **Note:** To submit as a draft, use 'git push origin HEAD:refs/drafts/master'
217 Submitting as a draft means that your commit will be on coreboot.org, but is
218 only visible to those you add as reviewers.
220 ## Part 5: Getting your commit reviewed
222 Your commits can now be seen on review.coreboot.org if you select “Your”
223 and click on “Changes” and can be reviewed by others. Your code will
224 first be reviewed by build bot (Jenkins), which will either give you a warning
225 or verify a successful build; if so, your commit will receive a +1. Other
226 users may also give your commit +1.  For a commit to be merged, it needs
227 to receive a +2.**Note:** A +1 and a +1 does not make a +2. Only certain users
228 can give a +2.
230 ## Part 6 (optional): bash-git-prompt
232 To help make it easier to understand the state of the git repository
233 without running 'git status' or 'git log', there is a way to make the
234 command line show the status of the repository at every point. This
235 is through bash-git-prompt.
237 Instructions for installing this are found at:
238 https://github.com/magicmonty/bash-git-prompt
239 **Note:** Feel free to search for different versions of git prompt,
240 as this one is specific to bash.
242 Alternatively, follow the instructions below:
243 Run the following two commands in the command line:
245     cd
246     git clone https://github.com/magicmonty/bash-git-prompt.git .bash-git-prompt --depth=1
248 **Note:** cd will change your directory to your home directory, so the
249 git clone command will be run there.
251 Finally, open the ~/.bashrc file and append the following two lines:
253     GIT_PROMPT_ONLY_IN_REPO=1
254     source ~/.bash-git-prompt/gitprompt.sh
256 Now, whenever you are in a git repository, it will continuously display
257 its state.
259 There also are additional configurations that you can change depending on your
260 preferences. If you wish to do so, look at the "All configs for .bashrc" section
261 on https://github.com/magicmonty/bash-git-prompt. Listed in that section are
262 various lines that you can copy, uncomment and add to your .bashrc file to
263 change the configurations. Example configurations include avoid fetching remote
264 status, and supporting versions of Git older than 1.7.10.
266 ## Appendix: Miscellaneous Advice
268 ### Updating a commit after running git push:
270 Suppose you would like to update a commit that has already been pushed to the
271 remote repository. If the commit you wish to update is the most recent
272 commit you have made, after making your desired changes, stage the files
273 (either using git add or in git cola), and amend the commit. To do so,
274 if you are using the command line, run "git commit --amend." If you are
275 using git cola, click on the gear icon located on the upper left side under
276 **Commit** and select **Amend Last Commit** in the drop down menu. Then, stage
277 the files you have changed, commit the changes, and run git push to push the
278 changes to the remote repository. Your change should be reflected in Gerrit as
279 a new patch set.
281 If, however, the commit you wish to update is not the most recent commit you
282 have made, you will first need to checkout that commit. To do so, find the
283 URL of the commit on <https://review.coreboot.org> and go to that page; if
284 the commit is one that you previously pushed, it can be found by selecting
285 **My** and then **Changes** in the upper left corner. To checkout this commit,
286 in the upper right corner, click on **Download**, and copy the command listed
287 next to checkout by clicking **Copy to clipboard**. Then, run the copied
288 command in your coreboot repository. Now, the last commit should be the most
289 recent commit to that patch; to update it, make your desired changes, stage
290 the files, then amend and push the commit using the instructions in the above
291 paragraph.