Difference between revisions of "TinyCtrl Initial Setup of Linux Board"
m (Added note about RPi) |
|||
(5 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
=Linux Install= | =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.''' | '''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 guide is only for older robot controls that use a Phytec-based embedded control. Read the following guide to restore a newer Raspberry Pi-based control: [[Factory Reset]]''' | ||
''This document assumes that you sort of know what you're doing. Warning! This procedure may well break your board.'' | ''This document assumes that you sort of know what you're doing. Warning! This procedure may well break your board.'' | ||
Line 93: | Line 95: | ||
<code>reset</code> your board. | <code>reset</code> your board. | ||
+ | '''If you get stuck in a reboot loop at this point, double, triple and quadruple check the supply voltage arriving at the Phytec Board! It needs to be >4.95V and <5.2V (not between 4.8V and 5.2V as the manufacturer states).''' | ||
=Post Install= | =Post Install= | ||
''' Note that any Board that ordered from Commonplace Robotics will definitely have been set up like this already.''' | ''' Note that any Board that ordered from Commonplace Robotics will definitely have been set up like this already.''' | ||
Line 110: | Line 113: | ||
**The desktop computer needs to be set to a static IP like <code>192.168.3.1</code>. | **The desktop computer needs to be set to a static IP like <code>192.168.3.1</code>. | ||
**The Phytec Linux board has IP <code>192.168.3.11</code> by default.) | **The Phytec Linux board has IP <code>192.168.3.11</code> by default.) | ||
− | * Use [https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html Putty] to connect to the embedded computer (links to the Putty binaries: [https://the.earth.li/~sgtatham/putty/latest/w64/putty.exe 64bit Putty] and [https://the.earth.li/~sgtatham/putty/latest/w32/putty.exe 32bit Putty]). The username is <code>root</code>. There is no password. | + | * Use [https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html Putty] to connect to the embedded computer via ssh (links to the Putty binaries: [https://the.earth.li/~sgtatham/putty/latest/w64/putty.exe 64bit Putty] and [https://the.earth.li/~sgtatham/putty/latest/w32/putty.exe 32bit Putty]). The username is <code>root</code>. There is no password. |
==Set ubifs to sync mode== | ==Set ubifs to sync mode== | ||
+ | The NAND memory file system used by the embedded linux contains a bug. This bug leads to loss of files. To fix this problem the fstab file has to be adapted. This can be done when connected with the embedded system via e.g. putty. | ||
+ | |||
+ | Connect, login and type: | ||
+ | |||
vi /etc/fstab | vi /etc/fstab | ||
− | hit <code>i</code> | + | to open the vi editor with the file /etc/fstab |
− | modify first mount point to: | + | |
+ | hit <code>i</code> to get into edit mode and | ||
+ | modify the first mount point to: | ||
/dev/root / auto defaults,sync 1 1 | /dev/root / auto defaults,sync 1 1 | ||
− | hit <code>ESC</code> and then <code>:wq!</code> | + | To save and close the editor hit <code>ESC</code> and then <code>:wq!</code> |
+ | |||
+ | Then make sure the file system is synced and reboot the linux system. | ||
sync | sync | ||
reboot | reboot | ||
Line 175: | Line 186: | ||
==Load Amp Config== | ==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 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]]. A USB to CAN adapter is required: ([[CAN_Protocol#CAN_Hardware_.2F_Drivers|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. | 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. | ||
+ | =Boot Stress-Test= | ||
+ | This test is not carried out on boards that leave Commonplace Robotics. It is for internal use: | ||
+ | |||
+ | ==Service== | ||
+ | /etc/systemd/system/stresstest.service | ||
+ | <syntaxhighlight lang=bash> | ||
+ | # This is part of systemd. | ||
+ | |||
+ | [Unit] | ||
+ | Description=stresstest | ||
+ | DefaultDependencies=no | ||
+ | |||
+ | |||
+ | [Service] | ||
+ | Type=oneshot | ||
+ | RemainAfterExit=no | ||
+ | ExecStart=/home/root/stresstest.sh | ||
+ | StandardOutput=syslog | ||
+ | |||
+ | [Install] | ||
+ | WantedBy=sysinit.target | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | systemctl enable stresstest.service | ||
+ | |||
+ | ===Stresstest.sh=== | ||
+ | /home/root/stresstest.sh: | ||
+ | <syntaxhighlight lang=bash> | ||
+ | #!/bin/bash | ||
+ | sleep 5 | ||
+ | date +%s >> /home/root/stresstest.txt | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | At boot the current epoch time is stored in /home/root/stresstest.txt | ||
[[Category:TinyCtrl]][[Category:Downloads]] | [[Category:TinyCtrl]][[Category:Downloads]] |
Latest revision as of 11:57, 8 January 2024
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 guide is only for older robot controls that use a Phytec-based embedded control. Read the following guide to restore a newer Raspberry Pi-based control: Factory Reset
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.
If you get stuck in a reboot loop at this point, double, triple and quadruple check the supply voltage arriving at the Phytec Board! It needs to be >4.95V and <5.2V (not between 4.8V and 5.2V as the manufacturer states).
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
- Use Putty to connect to the embedded computer via ssh (links to the Putty binaries: 64bit Putty and 32bit Putty). The username is
root
. There is no password.
Set ubifs to sync mode
The NAND memory file system used by the embedded linux contains a bug. This bug leads to loss of files. To fix this problem the fstab file has to be adapted. This can be done when connected with the embedded system via e.g. putty.
Connect, login and type:
vi /etc/fstab
to open the vi editor with the file /etc/fstab
hit i
to get into edit mode and
modify the first mount point to:
/dev/root / auto defaults,sync 1 1
To save and close the editor hit ESC
and then :wq!
Then make sure the file system is synced and reboot the linux system.
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. 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.
Boot Stress-Test
This test is not carried out on boards that leave Commonplace Robotics. It is for internal use:
Service
/etc/systemd/system/stresstest.service
# This is part of systemd.
[Unit]
Description=stresstest
DefaultDependencies=no
[Service]
Type=oneshot
RemainAfterExit=no
ExecStart=/home/root/stresstest.sh
StandardOutput=syslog
[Install]
WantedBy=sysinit.target
systemctl enable stresstest.service
Stresstest.sh
/home/root/stresstest.sh:
#!/bin/bash
sleep 5
date +%s >> /home/root/stresstest.txt
At boot the current epoch time is stored in /home/root/stresstest.txt