MityCAMAC

From DaqWiki
Revision as of 13:42, 19 January 2015 by Olchansk (talk | contribs)
Jump to navigation Jump to search

CriticalLink MityARM

Links

Useful links

minicom settings

    +-----------------------------------------------------------------------+
    | A -    Serial Device      : /dev/ttyUSB0                              |
    | B - Lockfile Location     : /var/lock                                 |
    | C -   Callin Program      :                                           |
    | D -  Callout Program      :                                           |
    | E -    Bps/Par/Bits       : 115200 8N1                                |
    | F - Hardware Flow Control : No                                        |
    | G - Software Flow Control : No                                        |
    |                                                                       |
    |    Change which setting?                                              |
    +-----------------------------------------------------------------------+

 +--------------------[Modem and dialing parameter setup]---------------------+
 |                                                                            |
 | A - Init string .........                                                  |
 | B - Reset string ........                                                  |
 | C - Dialing prefix #1.... ATDT                                             |
 | D - Dialing suffix #1.... ^M                                               |
 | E - Dialing prefix #2.... ATDP                                             |
 | F - Dialing suffix #2.... ^M                                               |
 | G - Dialing prefix #3.... ATX1DT                                           |
 | H - Dialing suffix #3.... ;X4D^M                                           |
 | I - Connect string ...... CONNECT                                          |
 | J - No connect strings .. NO CARRIER            BUSY                       |
 |                           NO DIALTONE           VOICE                      |
 | K - Hang-up string ...... ~~+++~~ATH^M                                     |
 | L - Dial cancel string .. ^M                                               |
 |                                                                            |
 | M - Dial time ........... 45      Q - Auto bps detect ..... No             |
 | N - Delay before redial . 2       R - Modem has DCD line .. Yes            |
 | O - Number of tries ..... 10      S - Status line shows ... DTE speed      |
 | P - DTR drop time (0=no). 1       T - Multi-line untag .... No             |
 |                                                                            |
 | Change which setting?       (Return or Esc to exit)                        |
 +----------------------------------------------------------------------------+

BOOTCONFIG

BOOTCONFIG settings:

  • CL eval board:
    • BOOTCONFIG[0..11] are SYSBOOT[0..11]
    • boot from SD: all open, [3] closed
    • boot from on-SoM NAND: all open, close [2], [3], [8], [9], [10], [11] (6 jumpers)
  • CAMAC board:
    • top-to-bottom: B0..4,G0..5,R0 correspond to LCD_DATA[0..11] are SYSBOOT[0..11]
    • boot from SD: all open, B3 closed
    • boot from on-SoM NAND: all open, close B2, B3, G3, G4, G5, R0 (6 jumpers)

NOTES:

  • boot from EMAC1 requires PHY connection to RGMII1, CLeval and CAMAC boards connected PHY to RGMII2.

SYSBOOT modes: http://ladd00.triumf.ca/~olchansk/MityARM/Docs/spruh73g.pdf table 26-7

SYSBOOT[4..0]
00000 - reserved
00001 - UART0
00010 - UART0
00011 - UART0
00100 - UART0
00101 - UART0
00110 - EMAC1, SYSBOOT[7..6]: 00=MII, 01=RMII, 10=reserved, 11=RGMII
00111 - EMAC1
01000 - EMAC1
01001 - EMAC1
01010 - EMAC1
01011 - USB0
01100 - USB0
01101 - USB0
01110 - reserved
01111 - fast external boot
10000 - XIP
10001 - XIP
10010 - NAND
10011 - NAND
10100 - NAND
10101 - NAND-I2C
10110 - SPI0
10111 - MMC0 <---- default (boot from SD flash) - other bits - don't care
11000 - SPI0
11001 - SPI0
11010 - XIP
11011 - XIP
11100 - MMC1
11101 - reserved
11110 - reserved
11111 - fast external boot

GPMC interface

0x8 = CS0 0x9 = CS1 0xa = CS2 0xb = CS3

./gpmc 0x0a000000 0x12ff5678

CAMAC interface

General information:

  • CAMAC interface responds to GPMC CS3
  • the host CPU should always issue 32-bit read and write cycles on even addresses (last 2 bits of address set to 0)
  • address bits 15..12 address the FPGA GPMC registers (4 bits, 16 registers)
  • remaining address bits are used for encoding CAMAC operations
  • all GPMC registers are 32-bit wide

Firmware update

  • test the activer serial flash programmer interface
$ ./srunner_gpmc -id -16 /dev/null
================================================================
SRunner Version 1.2-GPMC-0xABCD-KO3 (POF, JIC support)
Altera Corporation 
Configuration Devices: EPCS1, EPCS4, EPCS16, EPCS64 and EPCS128
================================================================

Operation: Identify EPCS Device
bb_open!
Info: Found GPMC 0xABCD FlashProgrammer interface.

Info: Silicon ID - 0x14 
Info: Serial Configuration Device - EPCS16

Operation Completed!!!

  • write pof file to flash memory
$ ./srunner_gpmc -program -16 CAMAC_Crat_Controller.pof

================================================================

Operation: Programming EPCS
Info: Programming file: "CAMAC_Crat_Controller.pof" opened.
Info: File size: 2097359 bytes.
Skipping POF file header: start of data at 154, file size 2097359, remain 2097205, modulo 1024 = 53
Final file size 2097152
bb_open!
Info: Found GPMC 0xABCD FlashProgrammer interface.

Info: Silicon ID - 0x14 
Info: Serial Configuration Device - EPCS16
Info: Erasing...
....................Info: Erase Done
Info: Start programming process.

Info: Programming 8192 pages...
Info: Programming successful
bb_close!

Operation Completed!!!
  • reboot the FPGA
lxdaq30:LINUX$ ./camac --reboot
CAMAC firmware: 0x14120407
rebooting FPGA...
CAMAC firmware: 0x14120711
lxdaq30:LINUX$ 

Register 1 - command

Write-only 32 bit register:

command 1: CMD_reset: 0x
command 2: CMD_reconfigure
command 3: CMD_TestMode
command 4: CMD_Zero
command 5: CMD_Clear
command 6: CMD_Inhibit
command 7: CMD_WriteLED: 0xXXXX0007 -> write 0xXXXX to the LED bus

Register 2 - test read/write register

32-bit read/write register for testing GPMC bus communications

Register 3 - FPGA flash programmer

active-serial flash programmer interface (see srunner, srunner_vme and srunner_gpmc).

Register 4 and 5 - CAMAC command, write data and read data

A write cycle to the GPMC bus carries 16 bits of address and 32 bits of data:

Address 16 bits (Quartus cmd_A[15..0])
----
15..12 - GPMC register address 
--
11 - not used
10 - not used
9 - not used
8..4 - CAMAC N[4..0]
--
3 - CAMAC F[4]
2 - CAMAC_start - set this bit to 1 to trigger a CAMAC operation. Value 0 is for testing the communications without running the CAMAC sequencer.
1 - not accessible
0 - not accessible
----

Data 32 bits: (Quartus cmd_D[31..0])
----
31..28 - CAMAC F[3..0]. (CAMAC F[4] is cmd_A[3])
27..24 - CAMAC A[3..0]
--
23..0 - CAMAC write lines W[24..1]
----

To verify correct data transmission on the GPMC bus and correct latching of the data in the CAMAC part of the FPGA, the 32 bits of data can be read back through register 4 and the 16 bits of address can be read through the low 16 bits of register 5. Reading from these registers is not necessary for operating CAMAC cycles.

Register 6 - CAMAC status and read data

Read-only 32 bit register:

31 - not used
30 - not used
29 - not used
28 - BUSY_OUT
--
27 - BUSY
26 - set to 1 when CAMAC cycle is finished and new data is ready
25 - CMD_ACCPT
24 - RESPONSE
--
23..0 - CAMAC read data[24..1]

Register 7 - CAMAC LAM and interface status

Read-only 32-bit register:

31 - EXT_BUSY
30 - EXT_INHIBIT
29 - EXT_GRANT_IN
28 - EXT_GRANT_OUT
--
27 - ACL
26 - RI
25 - not used
24 - not used
--
23..0 - CAMAC LAM from slots 24..1

LEDs

                       ----
gpmc            0x0008 |OO| 0x0040
busy            0x0010 |OO| 0x0080
inhibit         0x0020 |OO| 0x0100
-----------------------------------------------------

Software commands

./gpmc 0x0b000000 # read firmware revision
./gpmc 0x0b001000 2 # reconfigure the fpga
./srunner_gpmc -id -64 /dev/null # use the flash programmer to read the flash chip identity
./srunner_gpmc -program -16 ../QUARTUS/output_files/CAMAC_Crat_Controller.pof # write POF file into the flash (remember to do an FPGA reconfigure to reboot into the new firmware)
./gpmc 0x0b001000 0x01f80007 # write to the LEDs
./gpmc 0x0b0040ac 0x00123456 # run some camac cycle
./gpmc 0x0b001000 0x80000003 # enable test mode
./gpmc 0x0b004174 0x00123456 # read from slot 23 - "manual input register"
./gpmc 0x0b00416c 0x00000000 # write to slot 22 - dataway display
./gpmc 0x0b00416c 0x00ffffff # write to slot 22 - dataway display
./gpmc 0x0b006000 # read CAMAC read data and status
./gpmc 0x0a00012c # reconfigure FPGA thorugh the CS2 line

pinmux through debugfs

  • mount debugfs:
    • echo "none /sys/kernel/debug debugfs defaults 0 0" >> /etc/fstab
    • mount -a
    • ls -l /sys/kernel/debug/omap_mux/
  • show pinmux state:
    • cat /sys/kernel/debug/omap_mux/board/core | grep GPMC
  • enable GPMC pins:
echo 30 >> /sys/kernel/debug/omap_mux/gpmc_ad8     ### AD pin
echo 30 >> /sys/kernel/debug/omap_mux/gpmc_ad9     ### AD pin
echo 30 >> /sys/kernel/debug/omap_mux/gpmc_ad10     ### AD pin
echo 30 >> /sys/kernel/debug/omap_mux/gpmc_ad11     ### AD pin
echo 30 >> /sys/kernel/debug/omap_mux/gpmc_ad12     ### AD pin
echo 30 >> /sys/kernel/debug/omap_mux/gpmc_ad13     ### AD pin
echo 30 >> /sys/kernel/debug/omap_mux/gpmc_ad14     ### AD pin
echo 30 >> /sys/kernel/debug/omap_mux/gpmc_ad15     ### AD pin

echo 8 >> /sys/kernel/debug/omap_mux/gpmc_csn1     ### CS pin
echo 8 >> /sys/kernel/debug/omap_mux/gpmc_csn2     ### CS pin
echo 8 >> /sys/kernel/debug/omap_mux/gpmc_csn3     ### CS pin

echo 8 >> /sys/kernel/debug/omap_mux/gpmc_ben1     ### output pin
echo 30 >> /sys/kernel/debug/omap_mux/gpmc_clk     ### CLK has to be configured as in "input" pin

Work with the Fedora images

  • xz -d < Fedora-Minimal-armhfp-19-1-sda.raw.xz > Fedora-Minimal-armhfp-19-1-sda.raw
  • fdisk -lu Fedora-Minimal-armhfp-19-1-sda.raw ### show the partition table:
[root@ladd00 Fedora]# fdisk -lu Fedora-Minimal-armhfp-19-1-sda.raw
You must set cylinders.
You can do this from the extra functions menu.

Disk Fedora-Minimal-armhfp-19-1-sda.raw: 0 MB, 0 bytes
255 heads, 63 sectors/track, 0 cylinders, total 0 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0007895f

                             Device Boot      Start         End      Blocks   Id  System
Fedora-Minimal-armhfp-19-1-sda.raw1            1953     1001953      500000+  83  Linux
Partition 1 does not end on cylinder boundary.
Fedora-Minimal-armhfp-19-1-sda.raw2         1001954     2001953      500000   83  Linux
Partition 2 does not end on cylinder boundary.
Fedora-Minimal-armhfp-19-1-sda.raw3         2001954    14697265     6347656   83  Linux
Partition 3 does not end on cylinder boundary.
  • mount -r -o loop,offset=1025000448 Fedora-Minimal-armhfp-19-1-sda.raw /mnt/tmp ### the offset value is the partition "Start" value multiplied by 512.

NAND boot configuration

#yum install mtd-utils # get nandwrite and flash_erase
#cd /media/mmcblk0p1/
#mount /dev/mmcblk0p1 /mnt/tmp
#cd /mnt/tmp
# the MicroSD card labeled "F20" has the correct MLO and uboot in ~root:
cd ~root
flash_erase /dev/mtd1 0 0
nandwrite -p /dev/mtd1 MLO
flash_erase /dev/mtd2 0 0
nandwrite -p /dev/mtd2 MLO
flash_erase /dev/mtd3 0 0
nandwrite -p /dev/mtd3 MLO
flash_erase /dev/mtd4 0 0
nandwrite -p /dev/mtd4 MLO
flash_erase /dev/mtd5 0 0
nandwrite -p /dev/mtd5 u-boot.img
  • setup boot jumpers to boot from NAND flash:
BOOTCONFIG [0..11]
::[:][:]::::[:][:][:][:]
  • (to boot from MMC/SD flash)
BOOTCONFIG [0..11]
:::[:]::::::::
  • power off
  • connect serial console
  • power on
  • on serial console: press <space> to get into the uboot shell
  • (notice how u-boot complains about loading default environememt)
  • on serial console, type these commands:
setenv bootcmd_orig \'${bootcmd}\'
setenv bootcmd 'run net_boot'
setenv rootpath
saveenv
U-Boot# setenv bootcmd_orig \'${bootcmd}\'
U-Boot# setenv bootcmd 'run net_boot'
U-Boot# setenv rootpath
U-Boot# saveenv
Saving Environment to NAND...
Erasing NAND...
Erasing at 0x300000 -- 100% complete.
Writing to NAND... OK
U-Boot# 
  • cycle power
  • again, press space to get into the uboto shell
  • (notice how the complaints about default environement are gone)
  • run net_boot
  • (on dhcp server, observe how we get an IP address and try to load the linux kernel)
  • on the dhcp server, add this to dhcpd.conf:
group {
	option routers 142.90.100.18;
	option subnet-mask 255.255.224.0;
	option domain-name "triumf.ca";
	option domain-name-servers 142.90.100.19, 142.90.100.68;
	default-lease-time infinite;
	max-lease-time infinite;

	filename "mityarm/uImage";
        next-server ladd00;
	option root-path "142.90.111.60:/data0/root/%s,v3,tcp,hard";

	host lxdaq30-eth0 { fixed-address lxdaq30; option host-name "lxdaq30.triumf.ca"; hardware ethernet D4:94:A1:83:61:50; } # mityarm
        host lxdaq30-eth1 { fixed-address lxdaq30; option host-name "lxdaq30.triumf.ca"; hardware ethernet D4:94:A1:83:61:51; } # mityarm
}
  • on the dhcp server, put uImage from the MityArm SD flash card into /var/lib/tftpboot/mityarm
  • on the dhcp server, "server dhcpd restart", "tail -100f /var/log/messages"
  • on the MityArm serial console, reset, press <space> to get the u-boot prompt, say "run net_boot"
  • on the dhcp server, observe we get an IP address, we tftp load "uImage", try to mount the root filesystem
  • on the MityArm serial console, observe we get an IP address, tftp load the kernel, start the kernel, try to mount the root filesystem.
  • root filesystem should be at /data0/root/lxdaq30.triumf.ca created by "rsync -av" of the SDflash root filesystem.

Build U-Boot

instructions: http://support.criticallink.com/redmine/projects/armc8-platforms/wiki/Das_U-Boot_Port

git clone git://support.criticallink.com/home/git/u-boot-mityarm-335x.git
cd u-boot-mityarm-335x
#git pull
#git checkout release_20140214
git checkout u-boot-2013.10
make ARCH=arm CROSS_COMPILE=/ladd/data0/olchansk/MityARM/TI/ti-sdk-am335x-evm-05.05.00.00/linux-devkit/bin/arm-arago-linux-gnueabi- mityarm335x_4kpage_config
make ARCH=arm CROSS_COMPILE=/ladd/data0/olchansk/MityARM/TI/ti-sdk-am335x-evm-05.05.00.00/linux-devkit/bin/arm-arago-linux-gnueabi- mityarm335x_4kpage

This creates:

ladd00:u-boot-mityarm-335x$ ls -l MLO u-boot* tools/mkimage
-rw-r--r-- 1 olchansk users   38643 Dec  5 16:39 MLO
-rwxr-xr-x 1 olchansk users   70320 Dec  5 16:38 tools/mkimage
-rwxr-xr-x 1 olchansk users 1769651 Dec  5 16:39 u-boot
-rw-r--r-- 1 olchansk users  373252 Dec  5 16:39 u-boot.bin
-rw-r--r-- 1 olchansk users  373316 Dec  5 16:39 u-boot.img
-rw-r--r-- 1 olchansk users     846 Dec  5 16:39 u-boot.lds
-rw-r--r-- 1 olchansk users  107524 Dec  5 16:39 u-boot.map
-rw-r--r-- 1 olchansk users 1119828 Dec  5 16:39 u-boot.srec
ladd00:u-boot-mityarm-335x$ 

The files MLO and u-boot.img are used to boot the linux kernel.

The executable file tools/mkimage is used to build the linux kernel.

Build fw_printenv:

 1082  rm tools/env/fw_printenv 
 1083  make env HOSTCC=/ladd/data0/olchansk/MityARM/TI/ti-sdk-am335x-evm-05.05.00.00/linux-devkit/bin/arm-arago-linux-gnueabi-gcc

Build linux kernel

instructions: http://support.criticallink.com/redmine/projects/armc8-platforms/wiki/Linux_Kernel

git clone git://support.criticallink.com/home/git/linux-mityarm-335x.git
cd linux-mityarm-335x
git checkout mityarm-linux-v3.2
cp ../am335x-pm-firmware.bin ./firmware/
make ARCH=arm CROSS_COMPILE=arm-arago-linux-gnueabi- mityarm-335x-devkit_defconfig
make ARCH=arm CROSS_COMPILE=arm-arago-linux-gnueabi- menuconfig
make ARCH=arm CROSS_COMPILE=/ladd/data0/olchansk/MityARM/TI/ti-sdk-am335x-evm-05.05.00.00/linux-devkit/bin/arm-arago-linux-gnueabi- uImage
make ARCH=arm CROSS_COMPILE=/ladd/data0/olchansk/MityARM/TI/ti-sdk-am335x-evm-05.05.00.00/linux-devkit/bin/arm-arago-linux-gnueabi- modules
make ARCH=arm CROSS_COMPILE=/ladd/data0/olchansk/MityARM/TI/ti-sdk-am335x-evm-05.05.00.00/linux-devkit/bin/arm-arago-linux-gnueabi- INSTALL_MOD_PATH=../rootfs modules_install

To build the kernel for the CAMAC board: (there are no kernel modules to build or install)

git checkout triumf/camac
make ARCH=arm CROSS_COMPILE=/ladd/data0/olchansk/MityARM/TI/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/i686-arago-linux/usr/bin/arm-linux-gnueabihf- uImage -j6
cp arch/arm/boot/uImage /var/lib/tftpboot/mityarm/uImage

If the above complains about missing "mkimage", do this:

cp -pv ../u-boot-mityarm-335x/tools/mkimage /ladd/data0/olchansk/MityARM/TI/ti-sdk-am335x-evm-05.05.00.00/linux-devkit/bin/arm-arago-linux-gnueabi-mkimage
cp -pv ../u-boot-mityarm-335x/tools/mkimage /ladd/data0/olchansk/MityARM/TI/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/i686-arago-linux/usr/bin/arm-linux-gnueabihf-mkimage

List of on-board hardware

Create initramfs

cd .../rootfs
find . | cpio -o -H newc | gzip > ../rootfs.cpio.gz
  • in linux kernel menuconfig set initramfs to .../rootfs.cpio.gz
  • make sure there is a "/init" in the initramfs - that's what is executed first

Access U-Boot environement from Linux

  • create /etc/fw_env.config
# MTD device name       Device offset   Env. size       Flash sector size
/dev/mtd6 0 0x20000 0x40000
  • run: /ladd/data0/olchansk/MityARM/Fedora/Fedora-Minimal-armhfp-19-1-part3/usr/bin/fw_printenv
  • get fw_printenv for Fedora20: yum install uboot-tools

Note: ENV_SIZE comes from uboot include/configs/mityarm335x.h where it is defined as

/* Always 128 KiB env size */
#define CONFIG_ENV_SIZE  (128 << 10)

Fedora 20 setup

  • disable unwanted services
systemctl disable cups.path 
systemctl disable systemd-ask-password-plymouth.path
systemctl disable systemd-ask-password-wall.path
systemctl disable auditd.service
systemctl disable firewalld.service
systemctl disable lvm2-lvmetad.service
systemctl disable lvm2-monitor.service
systemctl disable ModemManager.service
systemctl disable rngd.service
systemctl disable cups.socket
systemctl disable lvm2-lvmetad.socket 
systemctl disable dm-event.socket
systemctl disable iscsid.socket
systemctl disable iscsiuio.socket
systemctl disable pcscd.socket
systemctl disable cryptsetup.target
systemctl disable NetworkManager
  • enable /etc/rc.local
touch /etc/rc.d/rc.local
chmod a+rx /etc/rc.d/rc.local
ln -s rc.d/rc.local /etc/rc.local

Network boot configuration

  • add this to dhcpd.conf:
# 
# group for network booting MityARM machines 
# 
 
group { 
        option routers 142.90.100.18; 
        option subnet-mask 255.255.224.0; 
        option domain-name "triumf.ca"; 
        option domain-name-servers 142.90.100.19, 142.90.100.68; 
        default-lease-time infinite; 
        max-lease-time infinite; 
 
        filename "mityarm/uImage-KO7"; 
        next-server ladd00; 
        option root-path "142.90.111.60:/data0/root/%s,v3,tcp,hard"; 
 
        host lxdaq30-512MB-linux { fixed-address lxdaq30; option host-name "lxdaq30.triumf.ca"; hardware ethernet 78:c5:e5:be:6b:6f; } # mityarm 
        host lxdaq30-512MB-uboot { fixed-address lxdaq30; option host-name "lxdaq30.triumf.ca"; hardware ethernet 78:c5:e5:be:6b:70; } # mityarm 
}
  • note how there are 2 entries for each mityarm module: one for uboot and one for linux - they seem to use different MAC addresses (different by 1)
  • populate /var/lib/tftpboot/mityarm:
mkdir -p /var/lib/tftpboot/mityarm
cd /var/lib/tftpboot/mityarm
wget http://daqshare.triumf.ca/~olchansk/MityARM/uImage-KO7
  • populate the NFS-Root filesystem:
cd /nfsroot
wget http://daqshare.triumf.ca/~olchansk/MityARM/lxdaq30.triumf.ca-fedora20-20140811a.tgz
untar
rename to lxdaq30.triumf.ca (to match "%s" in DHCP root-path)
export to lxdaq30.triumf.ca with options (rw,async,no_root_squash)
add your ssh key to .../root/.ssh/authorized_keys
  • try to boot, look for DHCP messages (get the IP address), TFTP messages (loads uImage), NFS images (mounts the root filesystem)
  • try to ping, try to ssh


End

AAA