Skip to content

Commit

Permalink
Introduce macOS (partial) and Windows support (#125)
Browse files Browse the repository at this point in the history
* add debug defconfig, remove symlink

* Update README.md

* eol gitattr

* add note about nanomq

* misc nrc params fixes, nero debug update
  • Loading branch information
jr1221 authored Mar 28, 2024
1 parent d6b9572 commit 49e0d2d
Show file tree
Hide file tree
Showing 13 changed files with 92 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1 @@
*.sh text eol=lf
* text=auto eol=lf
34 changes: 25 additions & 9 deletions odysseus/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,34 @@ All defconfigs come with (in addition to busybox and util_linux utilities):
- iperf3, iw, iputils, and other network configuration utilities

## Quick start
Download and install to PATH git and docker.
Download and install to PATH git and docker. Docker desktop is recommended for macOS and Windows.
```
git clone https://github.com/Northeastern-Electric-Racing/Siren.git
git submodule update --init --recursive
cd ./odysseus
```
At this point, copy the file `SECRETS.env-example` to `SECRETS.env`, if you want to use non-default passwords edit this file.

Once that is done, run:
For linux (current support includes all build defconfigs):
```
docker compose run --rm --build odysseus # Future launches can omit `--build` for time savings and space savings, but it should be used if the Dockerfile or docker_out_of_tree.sh files change.
```

For mac and windows: (current support includes all _debug defconfigs, on x86_64 host normal defconfigs can work (experimental)):
```
docker compose -f "compose-compat.yml" run --rm --build odysseus # Future launches can omit `--build` for time savings and space savings, but it should be used if the Dockerfile or docker_out_of_tree.sh files change.
```



Now you are in the docker container. To build cd into the defconfig directory (either ap, or tpu), then run the make command alias:
```
cd ./<defconfig>
make-current
```
You can view the `output.log` for more info. Now, to deploy just flash the image in `images/

**Note: If failure occurs on mac or windows very early in the process, run `make nanomq-source` and try again before reporting the error.**
You can view the `output.log` for more info.

### More on docker configuration
The container has a directory structure as so:
Expand All @@ -54,13 +64,16 @@ The container has a directory structure as so:
- `./odysseus_tree`: The odyssues external tree, bound to the same directory in the git repository on your local machine!
- `./shared_data`: The download and ccache cache for buildroot, should be persisted as long as space is available, there is usually no reason to enter this. A persistent docker volume with the name `odysseus_shared_data`.
- `./outputs/*`:
- **The output folders for odysseus. `cd` into the one named for what defconfig you would like to build, and run the `make` configuration and build commands as described below. It is recommended to save space to run `make clean` in defconfig directories rather than removing this volume all together. This is bound to the `./odysseus/outputs` directory in the repository. *Remember to use `make savedefconfig` when you are done as changes are overriden when you re-open the docker image!*
- **The output folders for odysseus. `cd` into the one named for what defconfig you would like to build, and run the `make` configuration and build commands as described below. It is recommended to save space to run `make clean` in defconfig directories rather than removing this volume all together. For Linux hosts, this is bound to the `./odysseus/outputs` directory in the repository. For Windows users, this is a docker volume. *Remember to use `make savedefconfig` when you are done as changes are overriden when you re-open the docker image!*

### Extra docker tips
All paths relative to Siren root.

#### Note for Windows/macOS users
The outputs are stored in a docker volume on these platforms to ensure rsync compatability. Therefore fetching the files requires first running the image, then use `docker cp` to get them to the userspace. Alternatively, docker desktop has a file explorer for docker volumes that may come in handy.

#### Writing the sd card
The image is present in `./odysseus/outputs/<defconfig name>/images/sdcard.img`.
The image is present in `./odysseus/outputs/<defconfig name>/images/sdcard.img`. One can flash this with tools like the Raspberry Pi OS Imager.

#### Pulling source files for scp, etc.
The target binaries are located in `./odysseus/outputs/<defconfig name>/target`.
Expand All @@ -71,6 +84,10 @@ The target binaries are located in `./odysseus/outputs/<defconfig name>/target`.
**IMPORTANT**: this WILL wipe all shared cache (don't do this unless you need the space):
`docker volume rm odysseus_shared_data`

This will wipe all outputs, not the cache so just requires a full rebuild to recover from. On compose-compat images only:
`docker volume rm odysseus_outputs`


#### Open another tty
`docker ps`
Find the container ID of odysseus-odysseus then run:
Expand All @@ -83,9 +100,8 @@ docker exec <container_id> -d -w /home/odysseus/outputs/<defconfig> make-current
```
Be careful with this.

Notes about docker:
- Build time may be slower due to docker isolations (not dramatic, about 5-15%)
- Since odysseus only supports amd64 hosts for non-debug defconfigs, full releases cannot be built on mac
Docker limitations:
- Build time may be slower due to docker isolations (not dramatic, about 5%)
- Launch time is longer
- Space is used up by rebuilds, prune often or omit `--build`

Expand Down
27 changes: 27 additions & 0 deletions odysseus/compose-compat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
version: "3.8"
services:
odysseus:
build: .
command: /bin/bash
privileged: true
tty: true
# for fakeroot failure
ulimits:
nofile:
soft: 1024
hard: 1048576
volumes:
- ./odysseus_tree:/home/odysseus/build/odysseus_tree
- shared_data:/home/odysseus/shared_data
- outputs:/home/odysseus/outputs
environment:
- BR2_DL_DIR=/home/odysseus/shared_data/dl
- BR2_CCACHE_DIR=/home/odysseus/shared_data/ccache
volumes:
# required for mac as no hard linking:(
outputs:
labels:
com.northeastern_electric_racing.description: "Buildroot outputs, including disk images"
shared_data:
labels:
com.northeastern_electric_racing.description: "Shared output between buildroot runs"
3 changes: 1 addition & 2 deletions odysseus/odysseus_tree/configs/raspberrypi3_64_ap_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_EUDEV=y
BR2_TARGET_GENERIC_ROOT_PASSWD="$(ODY_AP_ROOT_PASSWORD)"
# BR2_TARGET_GENERIC_GETTY is not set
BR2_ROOTFS_OVERLAY="$(BR2_EXTERNAL_ODY_TREE_PATH)/overlays/rootfs_overlay_common $(BR2_EXTERNAL_ODY_TREE_PATH)/overlays/rootfs_overlay_nrc_common $(BR2_EXTERNAL_ODY_TREE_PATH)/overlays/rootfs_overlay_ap"
BR2_ROOTFS_PRE_BUILD_SCRIPT="$(BR2_EXTERNAL_ODY_TREE_PATH)/pre-make-ap.sh"
BR2_ROOTFS_POST_BUILD_SCRIPT="$(BR2_EXTERNAL_ODY_TREE_PATH)/post-build-os-release.sh board/raspberrypi3-64/post-build.sh"
BR2_ROOTFS_POST_BUILD_SCRIPT="$(BR2_EXTERNAL_ODY_TREE_PATH)/post-build-ap.sh $(BR2_EXTERNAL_ODY_TREE_PATH)/post-build-os-release.sh board/raspberrypi3-64/post-build.sh"
BR2_ROOTFS_POST_IMAGE_SCRIPT="board/raspberrypi3-64/post-image.sh"
BR2_ROOTFS_POST_SCRIPT_ARGS="AP"
BR2_LINUX_KERNEL=y
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
BR2_aarch64=y
BR2_cortex_a72=y
BR2_ARM_FPU_VFPV4=y
BR2_TOOLCHAIN_BUILDROOT_CXX=y
BR2_CCACHE=y
BR2_GLOBAL_PATCH_DIR="$(BR2_EXTERNAL_ODY_TREE_PATH)/patches"
BR2_PER_PACKAGE_DIRECTORIES=y
BR2_PACKAGE_DEJAVU=y
# BR2_PACKAGE_DEJAVU_SANS is not set
# BR2_PACKAGE_DEJAVU_SERIF is not set
# BR2_PACKAGE_DEJAVU_SANS_CONDENSED is not set
# BR2_PACKAGE_DEJAVU_SERIF_CONDENSED is not set
BR2_PACKAGE_KMSCUBE=y
BR2_PACKAGE_MESA3D=y
BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_V3D=y
BR2_PACKAGE_MESA3D_OPENGL_ES=y
BR2_PACKAGE_NERO2=y
BR2_PACKAGE_NERQT6=y
BR2_PACKAGE_NERQT6BASE_EGLFS=y
BR2_PACKAGE_NERQT6BASE_DEFAULT_QPA="eglfs"
BR2_PACKAGE_NERQT6BASE_JPEG=y
BR2_PACKAGE_NERQT6BASE_PNG=y
BR2_PACKAGE_NERQT6BASE_WIDGETS=y
BR2_PACKAGE_NERQT6BASE_NETWORK=y
BR2_PACKAGE_NERQT6BASE_SYSLOG=y
BR2_PACKAGE_NERQT6CORE5COMPAT=y
BR2_PACKAGE_NERQT6SVG=y
BR2_PACKAGE_NERQT6DECLARATIVE=y
BR2_PACKAGE_NERQT6DECLARATIVE_QUICK=y
BR2_PACKAGE_NERQT6MQTT=y
BR2_PACKAGE_NERQT6GRPC=y
3 changes: 1 addition & 2 deletions odysseus/odysseus_tree/configs/raspberrypi4_64_tpu_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ BR2_TARGET_GENERIC_ROOT_PASSWD="$(ODY_TPU_ROOT_PASSWORD)"
BR2_TARGET_TZ_INFO=y
BR2_TARGET_LOCALTIME="America/New_York"
BR2_ROOTFS_OVERLAY="$(BR2_EXTERNAL_ODY_TREE_PATH)/overlays/rootfs_overlay_common $(BR2_EXTERNAL_ODY_TREE_PATH)/overlays/rootfs_overlay_nrc_common $(BR2_EXTERNAL_ODY_TREE_PATH)/overlays/rootfs_overlay_tpu"
BR2_ROOTFS_PRE_BUILD_SCRIPT="$(BR2_EXTERNAL_ODY_TREE_PATH)/pre-make-sta.sh"
BR2_ROOTFS_POST_BUILD_SCRIPT="$(BR2_EXTERNAL_ODY_TREE_PATH)/post-build-os-release.sh board/raspberrypi4-64/post-build.sh"
BR2_ROOTFS_POST_BUILD_SCRIPT="$(BR2_EXTERNAL_ODY_TREE_PATH)/post-build-sta.sh $(BR2_EXTERNAL_ODY_TREE_PATH)/post-build-os-release.sh board/raspberrypi4-64/post-build.sh"
BR2_ROOTFS_POST_IMAGE_SCRIPT="board/raspberrypi4-64/post-image.sh"
BR2_ROOTFS_POST_SCRIPT_ARGS="TPU"
BR2_LINUX_KERNEL=y
Expand Down

This file was deleted.

This file was deleted.

3 changes: 3 additions & 0 deletions odysseus/odysseus_tree/post-build-ap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

python3 "$BR2_EXTERNAL_ODY_TREE_PATH"/overlays/rootfs_overlay_nrc_common/usr/bin/build_nrc_params.py 1 "$BR2_EXTERNAL_ODY_TREE_PATH"/overlays/rootfs_overlay_ap/etc/nrc_opts_ap.ini "$TARGET_DIR"/etc/modprobe.d/nrc.conf
3 changes: 3 additions & 0 deletions odysseus/odysseus_tree/post-build-sta.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

python3 "$BR2_EXTERNAL_ODY_TREE_PATH"/overlays/rootfs_overlay_nrc_common/usr/bin/build_nrc_params.py 0 "$BR2_EXTERNAL_ODY_TREE_PATH"/overlays/rootfs_overlay_tpu/etc/nrc_opts_sta.ini "$TARGET_DIR"/etc/modprobe.d/nrc.conf
3 changes: 0 additions & 3 deletions odysseus/odysseus_tree/pre-make-ap.sh

This file was deleted.

3 changes: 0 additions & 3 deletions odysseus/odysseus_tree/pre-make-sta.sh

This file was deleted.

1 change: 0 additions & 1 deletion odysseus/odysseus_tree/utils/build_nrc_params.py

This file was deleted.

0 comments on commit 49e0d2d

Please sign in to comment.