# Swiss Army kNife Command line environment to build/flash and debug roku firmware. ## Install Source .profile.roku.dev in your .bashrc. ### Install web server Some of commands rely on a web server accessible by device. Install an Nginex server, and make sure that your working directory is available through it. Currently, the script expects that all files are accessable under http:///roku/ This can be changed from .profile.roku.dev ``` export ROKU_WEB_DIR="$HOME/roku" export ROKU_WEB_PREFIX="roku" ``` My Nginx configuration is: ``` server { listen 80 default_server; listen [::]:80 default_server; root /var/www/html; # Add index.php to the list if you are using PHP index index.html index.htm index.nginx-debian.html; server_name _; location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ =404; } location /roku/ { alias /home/vahagn/roku/; index index.html index.htm; autoindex on; types { text/plain cc; text/plain cpp; text/plain h; text/plain mk; text/plain md; text/plain *; } } } ``` ## Usage When a new console opened, setup the device that you want to work with. For that run: `roku device ` e.g. ``` mknik:17:41:54 ~/roku/san@master$ roku device 192.168.0.194 device: 192.168.0.194 platform: lockhart ``` This will set environment variables for the device ( e.g. `ROKU_DEV_TARGET` ) And now you could use the commands below. If this is the first time you are using the device (after factory reset) or you have updated SAN, then you need to run `roku san update`. (Assuming you have web server installed and san is accessible from http:///roku/san). This copies san to /nvram/san and configures the device e.g. turns off fastboot, disables failsafe and etc. ## Commands | | | |--|--| | roku telnet | to telnet to device | | roku telnet 8080 |- to telnet to 8080 port of the device | | roku reboot | reboot device | | roku flash | flash acramfs from http:///roku/main | | roku log | logs through ethernet | | roku audcap | capture audio from audio mixer of device | | roku build | build firmware | | roku gdb attach | run gdb server on the device | | roku gdb | attach to gdb server from workstation | | roku .... | etc | ## The name Initially only 'san' was crafted and was used directly from the device. One would need to get a shell on the device, source it and then use it on the device. It had to be tiny auxilary script to perform repeating tasks, hence the name Swiss Army Knife. Later I have realised that I could manipulate the device directly from my command line. All I need is to save it's IP address somewhere. That's how the rest was born. ## Cheats ### Setup debug mode. ``` rokusetup dev on saveenv reset ``` ### Setup network from uBoot. ``` usb start rokusetup net auto rokusetup tftpserver rokusetup coreserver saveenv reset ``` ``` env set ipaddr 192.168.0.62 env set serverip 192.168.0.64 env set gatewayip 192.168.0.1 env set netmask 255.255.252.0 saveenv usb start ping 192.168.0.64 ``` ``` usb start tftpboot acramfs.marlin.bin ``` ``` usb start rokuflash tftp acramfs.marlin.bin ```