TinyCtrl Initial Setup of Linux Board
Linux Install
Starting from a board with just a bootloader on it, use the daughterboard PEB-EVAL-01 to connect via a FTDI Serial to USB adapter. Boot Linux (instructions here for ubuntu 16.04) and open a terminal
Download SD card image to your desktop PC
The board is a PB-00802-0101C. The mainline kernel image is therefore: phyboard-wega-am335x-1 according to https://www.phytec.de/software/board-support-packages/yocto-buildsystem/bsp-seite/?bsp=BSP-Yocto-AM335x-PD17.2.2
wget ftp://ftp.phytec.de/pub/Software/Linux/BSP-Yocto-AM335x/BSP-Yocto-AM335x-PD17.2.2/images/phyboard-wega-am335x-1/phytec-headless-image-phyboard-wega-am335x-1.sdcard
Insert a microSD card min 500MB in size.
fdisk -l
Find the correct device.
umount /dev/mmcblk0p1 dd if=phytec-headless-image-phyboard-wega-am335x-1.sdcard of=/dev/mmcblk0 conv=sync bs=1M
Insert SD card into Phytec board.
Install minicom on your desktop PC
sudo apt update sudo apt install minicom
Configure minicom on zour desktop PC
Plug in your USB to Serial adapter and check the device name allocated to it using dmesg
.
sudo minicom -s
- Go to "Serial Port Setup".
- Disable flow control, set to 115200, 8N1.
- Set serial device to whatever the name is that you have found in dmesg. For me it is /dev/ttyUSB0.
- go back and "save setup as dfl"
- "exit" the setup menu, but don't exit mincom.
Writing the kernel and root FS into flash
To update the second stage bootloader MLO, you may use the barebox_update command. This provides a handler which automatically erases and flashes copies of the MLO image into the first four blocks of the NAND Flash. This makes the system more robust against ECC issues. If one block is corrupted, the ROM loader does use the next block.
- Type:
bootloader$ barebox_update -t MLO.nand /boot/MLO
On startup, the TFTP server is automatically mounted to /mnt/tftp. So copying an image from TFTP to flash can be done in one step. Do not get confused when doing an ls on the /mnt/tftp folder. The TFTP protocol does not support anything like ls so the folder will appear to be empty.
The barebox as third stage bootloader can also be updated with a barebox_update command. But it is only stored once in the flash.
- Type:
bootloader$ barebox_update -t nand /boot/barebox.bin
We recommend also erasing the environment of the old barebox. Otherwise, the new barebox would use the old environment.
- First erase the old environment with:
bootloader$ erase /dev/nand0.bareboxenv.bb
After erasing the environment, you have to reset your board. Otherwise, the barebox still uses the old environment.
- Reset your board in order to get the new barebox running type:
bootloader$ reset
Mount your SD card again
mkdir /boot mmc0.probe=1 mount /dev/mmc0.0 /boot
Create UBI volumes for Linux kernel, oftree and root filesystem in NAND:
bootloader$ ubiformat /dev/nand0.root bootloader$ ubiattach /dev/nand0.root bootloader$ ubimkvol -t static /dev/nand0.root.ubi kernel 8M bootloader$ ubimkvol -t static /dev/nand0.root.ubi oftree 1M bootloader$ ubimkvol -t dynamic /dev/nand0.root.ubi root 0
Now get the Linux kernel and oftree from your TFTP server and store it in the NAND Flash with:
bootloader$ ubiupdatevol /dev/nand0.root.ubi.kernel /boot/linuximage bootloader$ ubiupdatevol /dev/nand0.root.ubi.oftree /boot/oftree
For flashing Linux’s root filesystem to NAND, please use:
bootloader$ cp -v /boot/root.ubifs /dev/nand0.root.ubi.root
Change the boot configuration of your board to NAND boot if necessary, and reset your board.
Post Install
Note that any Board that ordered from Commonplace Robotics will definitely have been set up like this already. However this document may provide some insight about what is happening behind the scenes:
This is what we do to a virgin Phytec board when integrating it into a DCi robot.
This document assumes that you know what you're doing and that you are familiar with linux console environments.
This procedure applies to DCi robots and Linux Embedded Control Electronics shipped after April 2018
Download
Download the full, zipped folder structure: TinyCtrl_Full
Connect to the Phytec Linux Board
- Connect both computers, i.e. the embedded linux computer and the Windows PC, with an ethernet cable. Use the right LAN port on the embedded Linux Board.
- The desktop computer needs to be set to a static IP like
192.168.3.1
. - The Phytec Linux board has IP
192.168.3.11
by default.)
- The desktop computer needs to be set to a static IP like
Copy TinyCtrl/ into /home/root/
scp TinyCtrl_Full.zip root@192.168.3.11:/home/root/ ssh root@192.168.3.11 unzip TinyCtrl_Full.zip rm TinyCtrl_Full.zip cd TinyCtrl chmod +x TinyCtrl chmod +x startBatch.sh cd
Install TinyCtrl Service
vi /etc/systemd/system/autostart_tinyctrl.service
hit i
paste this:
# This is part of systemd.
[Unit]
Description=TinyCtrl autostart
DefaultDependencies=no
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/home/root/TinyCtrl/startBatch.sh
StandardOutput=syslog
[Install]
WantedBy=sysinit.target
Hit ESC
Save and close.
:wq!
Enable the service
systemctl enable autostart_tinyctrl.service
Start the service
systemctl start autostart_tinyctrl.service
At this point the green LEDs of the stepper motor boards and the DIO board(s) should start blinking, which indicates that TinyCtrl is communicating with the boards via the internal CAN bus connection between the Phytec Linux board and the robot control electronics.
Reboot:
reboot
After the reboot TinyCtrl should start automatically, which can be observed by looking at the same green blinking green LEDs.
Load Amp Config
The firmware configuration for the stepper motor controllers needs to be uploaded to the boards and the zero position offsets need to be set. I usually do this over the CAN bus directly as described here Define the zero position offsets. The parameter file to be used is: igus_5DOF_SV_AE_AmpParameter.dat
. A USB to CAN adapter is required: (CAN Hardware).
Do not forget to unplug the CAN adapter from USB of the desktop PC after loading the Amp config, otherwise CPRog will show module dead as it is trying to connect via the CAN adapter first.