You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.adoc
+48-46Lines changed: 48 additions & 46 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -392,10 +392,9 @@ This is a good option if you are on a Linux host, but the native setup failed du
392
392
For example, to do a <<qemu-buildroot-setup>> inside Docker, run:
393
393
394
394
....
395
-
sudo apt-get install docker && \
395
+
sudo apt-get install docker
396
396
./run-docker create && \
397
-
./run-docker start && \
398
-
./run-docker sh ./build --download-dependencies && \
397
+
./run-docker sh -- ./build --download-dependencies
399
398
./run-docker sh
400
399
....
401
400
@@ -405,50 +404,63 @@ You are now left inside a shell in the Docker! From there, just run as usual:
405
404
./run
406
405
....
407
406
407
+
The host git top level directory is mounted inside the guest with a link:https://stackoverflow.com/questions/23439126/how-to-mount-a-host-directory-in-a-docker-container[Docker volume], which means for example that you can use your host's GUI text editor directly on the files. Just don't forget that if you nuke that directory on the guest, then it gets nuked on the host as well!
408
+
408
409
Command breakdown:
409
410
410
-
* `./run-docker create`: create the container.
411
+
* `./run-docker create`: create the image and container.
411
412
+
412
413
Needed only the very first time you use Docker, or if you run `./run-docker DESTROY` to restart for scratch, or save some disk space.
413
414
+
414
-
The container name is `lkmc` and shows up in the list of all containers:
415
+
The image and container name is `lkmc`. The container shows under:
415
416
+
416
417
....
417
418
docker ps -a
418
419
....
419
-
* `./run-docker start`: start the container as daemon on the background.
420
420
+
421
-
Needed only after reboot, or if you run `./run-docker stop` to save CPU or memory resources.
421
+
and the image shows under:
422
422
+
423
-
The container can now be seen on the list of running containers:
423
+
....
424
+
docker images
425
+
....
426
+
* `./run-docker sh`: open a shell on the container.
427
+
+
428
+
If it has not been started previously, start it. This can also be done explicitly with:
424
429
+
425
430
....
426
-
docker ps
431
+
./run-docker start
427
432
....
428
-
* `./run-docker sh`: open a shell on a previously started Docker daemon.
429
433
+
430
434
Quit the shell as usual with `Ctrl-D`
431
435
+
432
-
Can be called multiple times from different host terminals to open multiple shells.
433
-
434
-
The host git top level directory is mounted inside the guest with a link:https://stackoverflow.com/questions/23439126/how-to-mount-a-host-directory-in-a-docker-container[Docker volume], which means for example that you can use your host's GUI text editor directly on the files. Just don't forget that if you nuke that directory on the guest, then it gets nuked on the host as well!
436
+
This can be called multiple times from different host terminals to open multiple shells.
437
+
* `./run-docker stop`: stop the container.
438
+
+
439
+
This might save a bit of CPU and RAM once you stop working on this project, but it should not be a lot.
440
+
* `./run-docker DESTROY`: delete the container and image.
441
+
+
442
+
This doesn't really clean the build, since we mount the guest's working directory on the host git top-level, so you basically just got rid of the `apt-get` installs.
443
+
+
444
+
To actually delete the Docker build, run on host:
445
+
+
446
+
....
447
+
# sudo rm -rf out.docker
448
+
....
435
449
436
-
In order to use functionality such as <<gdb>> from inside Docker, you need a second shell inside the container. You can either do that from another shell with:
450
+
To use <<gdb>> from inside Docker, you need a second shell inside the container. You can either do that from another shell with:
437
451
438
452
....
439
453
./run-docker sh
440
454
....
441
455
442
456
or even better, by starting a <<tmux>> session inside the container. We install `tmux` by default in the container.
443
457
444
-
You can start a second shell and run a command in it at the same time with:
458
+
You can also start a second shell and run a command in it at the same time with:
445
459
446
460
....
447
-
./run-docker sh ./run-gdb start_kernel
461
+
./run-docker sh -- ./run-gdb start_kernel
448
462
....
449
463
450
-
Docker stops if and only if you quit the initial shell, you can quit this one without consequences.
you don't really destroy the build, since we mount the guest's working directory on the host git top-level, so you basically just get rid of the `apt-get` installs.
472
-
473
-
To actually delete the Docker build, run:
474
-
475
-
....
476
-
# sudo rm -rf out.docker
477
-
....
477
+
TODO make files created inside Docker be owned by the current user in host instead of `root`:
478
478
479
-
TODO make files created inside Docker be owned by the current user in host instead of `root`: https://stackoverflow.com/questions/23544282/what-is-the-best-way-to-manage-permissions-for-docker-shared-volumes
You are now left inside QEMU running the tiny baremetal system link:baremetal/interactive/prompt.c[], which uses the UART to:
@@ -749,41 +751,41 @@ vim baremetal/interactive/prompt.c
749
751
and run:
750
752
751
753
....
752
-
./build-baremetal --arch arm
754
+
./build-baremetal --arch aarch64
753
755
....
754
756
755
757
`./build qemu-baremetal` had called link:build-baremetal[] for us previously, in addition to its requirements. `./build-baremetal` uses crosstool-NG, and so it must be preceded by link:build-crosstool-ng[], which `./build qemu-baremetal` also calls.
756
758
757
759
Every `.c` file inside link:baremetal/[] and `.S` file inside `baremetal/arch/<arch>/` generates a separate baremetal image. You can run a different image with commands such as:
758
760
759
761
....
760
-
./run --arch arm --baremetal exit
761
-
./run --arch arm --baremetal arch/arm/add
762
+
./run --arch aarch64 --baremetal exit
763
+
./run --arch aarch64 --baremetal arch/aarch64/add
762
764
....
763
765
764
766
which will run respectively:
765
767
766
768
* link:baremetal/exit.c[]
767
-
* link:baremetal/arch/arm/add.S[]
769
+
* link:baremetal/arch/aarch64/add.S[]
768
770
769
771
Alternatively, for the sake of tab completion, we also accept relative paths inside `baremetal/`:
770
772
771
773
....
772
-
./run --arch arm --baremetal baremetal/exit.c
773
-
./run --arch arm --baremetal baremetal/arch/arm/add.S
0 commit comments