Difference between revisions of "TinyCtrl Initial Setup of Linux Board"
Line 117: | Line 117: | ||
/dev/root / auto defaults,sync 1 1 | /dev/root / auto defaults,sync 1 1 | ||
hit <code>ESC</code> and then <code>:wq!</code> | hit <code>ESC</code> and then <code>:wq!</code> | ||
+ | sync | ||
+ | reboot | ||
==Set date and time== | ==Set date and time== |
Revision as of 10:39, 6 September 2018
Linux Install
Note that any board ordered from Commonplace Robotics will definitely have been set up like this already. This may serve as a recovery procedure, should the system not boot at all after some sort of cataclysmic event.
This document assumes that you sort of know what you're doing. Warning! This procedure may well break your board.
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 (note that neither of these components are normally supplied with a DCi robot).
Boot Linux (instructions here for ubuntu 16.04 and 18.04) and open a terminal.
Download SD card image to your desktop PC
The single board computer 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 your 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 bootloader, kernel and root FS into flash
This section is copied modified from various different Phytec manuals.
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.
- Look at the minicom terminal.
- Switch on the Phytec board
- When it's asking whether to boot or not, hit return. That will drop you to a command prompt "bootloader$".
- Mount
mkdir /boot mmc0.probe=1 mount /dev/mmc0.0 /boot
- Type:
bootloader$ barebox_update -t MLO.nand /boot/MLO
Update the third stage bootloader with the barebox_update command.
- Type:
bootloader$ barebox_update -t nand /boot/barebox.bin
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
Again, you have to be quick and interrupt the boot by hitting return in the minicom terminal once the boot countdown starts to drop to the "bootloader" prompt. Otherwise you will boot from the SD card and the following commands won't work.
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 the SD card 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, use:
bootloader$ cp -v /boot/phytec-headless-image-phyboard-wega-am335x-1.ubifs /dev/nand0.root.ubi.root
Change the boot configuration of your board to NAND boot if necessary (type exit
) With the boards that we normally get, this step is not necessary
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 prepared as described above, 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
Set ubifs to sync mode
vi /etc/fstab
hit i
modify first mount point to:
/dev/root / auto defaults,sync 1 1
hit ESC
and then :wq!
sync reboot
Set date and time
date --set "2018-09-05 10:51:30" hwclock -w -u
Copy TinyCtrl/ into /home/root/
scp -r TinyCtrl root@192.168.3.11:/home/root/ ssh root@192.168.3.11 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.