Add build files

This commit is contained in:
Michal Moskal 2017-07-25 12:15:59 +01:00
parent 763a5c7436
commit 11bcf77402
7 changed files with 85 additions and 0 deletions

View File

@ -3,3 +3,4 @@ IndentWidth: 4
UseTab: Never
ColumnLimit: 100
AllowShortFunctionsOnASingleLine: Inline
SortIncludes: false

1
.gitignore vendored
View File

@ -30,3 +30,4 @@ videos/**
.piolibdeps
lib/
.vscode/
bin

12
brick/Makefile Normal file
View File

@ -0,0 +1,12 @@
all: mod uf2
mod:
$(MAKE) -C .. MOD=d_usbdev M=`pwd`/kernel ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi-
@mkdir -p bin
cp kernel/*.ko bin/
uf2:
$(MAKE) -C uf2daemon
@mkdir -p bin
cp uf2daemon/server bin/uf2daemon

34
brick/README.md Normal file
View File

@ -0,0 +1,34 @@
# Support code to run on EV3 brick
## Kernel module
Kernel module is based on LEGO's `d_usbdev` module, with the addition of slightly modified `g_mass_storage`
module from the Linux kernel. The module and supporting sources are licensed under GPLv2 (since
they are derived from GPLv2 code).
### Modifications
* the `d_usbdev` uses the composite framework to register an additional mass storage function in addtion
to the pre-existing custom USB HID function
* the `g_mass_storage` module has the following changes:
* a bug fixed, where page-misaligned writes would hang
* additional `/sys/.../lun0/active` entry is added, which allows for signaling drive eject to the host
### Kernel modifications
The kernel itself has modified FIFO queue sizes. The LEGO kernel uses `1024` for `ep1in` and `ep1out`,
and then `64` for `ep2` and `ep3`. Note that this is non-standard modification done with a kernel patch,
that I didn't manage to find. The MSD requires `512` for `ep2` and `ep3`. I have binary edited the kernel
to do so.
Note that there's 4k of FIFO memory in the hardware. If you set the queue sizes with a sum of more than
4k, the kernel will hang, and you will not know why.
## UF2 Daemon
The [UF2](https://github.com/Microsoft/uf2) daemon is based on
[UF2 ATSAMD21](https://github.com/Microsoft/uf2-samd21) bootloader code. It exposes a virtual
FAT16 file system over Linux Network Block Device interface (`/dev/nbd0` to be precise).
This device is then exposed via the `g_mass_storage` module to the host computer.
The Daemon is licensed under MIT.

22
brick/ins Executable file
View File

@ -0,0 +1,22 @@
#!/bin/sh
set -ex
cd /mnt/ramdisk/prjs/ko
insmod ./nbd.ko
sleep 1
./nbd-serv &
sleep 1
insmod ./d_usbdev.ko file=/dev/nbd0 HostStr=EV3 SerialStr=0016535543af
L=/sys/devices/platform/musb_hdrc/gadget/lun0
echo $L
echo -n "ent: "
read LINE
#echo > $L/file
echo 3 > $L/reset
killall nbd-serv
sleep 1
./nbd-serv &
sleep 1
#echo /dev/nbd0 > $L/file
#sleep 1
echo 4 > $L/reset

7
brick/mk Executable file
View File

@ -0,0 +1,7 @@
#!/bin/sh
set -xe
scp -qr * vm:linux/pxt/
ssh vm "cd linux/pxt; make $1"
mkdir -p bin
scp vm:linux/pxt/bin/* bin/

8
brick/send Executable file
View File

@ -0,0 +1,8 @@
#!/bin/sh
./mk
ev3duder up bin/d_usbdev.ko ../prjs/ko/d_usbdev.ko
ev3duder up bin/nbd.ko ../prjs/ko/nbd.ko
ev3duder up bin/nbd-serv ../prjs/ko/nbd-serv
ev3duder up ins ../prjs/ko/ins