Skip to content

Building and Running ARC Linux for HSDK

Yuriy Kolerov edited this page Aug 1, 2023 · 1 revision

This article provides basic information on how to get Linux up and running on the ARC HS Development Kit (HSDK) platform.

Preparing ARC HS Development Kit

The ARC HSDK development system is based on a custom designed Synopsys ARC SoC containing the ARC HS38x4 (quad core) processor. Please refer to board's documentation for detailed information about how to setup the board for initial operation:

In short, preparation of HSDK board consists of following steps:

  1. Insert a prepared micro-SD card in the micro-SD card slot of the HSDK board (read further about how to prepare a micro-SD card).
  2. DIP-switch BIM should be in 1:off, 2:on state while both BMC and BCS should be in 1:on, 2:on state.
  3. Connect HSDK board to host PC using micro-USB <-> USB cable and insert a power adapter.

The image below shows a correct board setup:

Connecting to a Serial Port Terminal

Connecting HSDK to the host computer allows you using a serial port terminal for interacting with the board. You can use any software to connect to the serial port terminal:

  • On Windows you can use HyperTerminal or Putty.
  • On Linux you can use minicom, gtkterm, cutecom, etc.

For any of them, you need to configure parameters to interact with the serial port this way:

  • baud-rate 115200
  • 8 data bits
  • 1 stop Bit
  • No HW/SW flow control

An Example for minicom

For minicom use this command:

$ minicom -8 -b 115200 -D /dev/ttyUSB0 -s

Then choose Serial port setup, press F to disable Hardware Flow Control, press Enter key and then choose Exit to close the configuration menu.

After resetting HSDK you will see this output of the bootloader:

********************************
**       Synopsys, Inc.       **
**   ARC HS Development Kit   **
********************************
** IC revision: Rev 2.0
** Bootloader verbosity: Normal
** Starting HS Core 1
** HS Core running @ 500 MHz
fptr = 8** HS Core fetching application from SPI flash
** HS Core starting application
<debug_uart> 

U-Boot 2020.01 (Apr 26 2020 - 22:30:20 +0300)

CPU:   ARC HS v4.0 at 500 MHz
Model: snps,hsdk-4xd
Board: Synopsys ARC HS4x/HS4xD Development Kit
DRAM:  1 GiB
Relocation Offset is: 3ef8a000
MMC:   mmc0@f000a000: 0
Loading Environment from FAT... MMC: no card present
In:    serial0@f0005000
Out:   serial0@f0005000
Err:   serial0@f0005000
Clock values are saved to environment
Net:   
Warning: ethernet@f0008000 (eth0) using random MAC address - c2:26:b0:99:98:4a
eth0: ethernet@f0008000
hsdk-4xd# 

Preparing Buildroot for Building Linux Images

Users which are not familiar with Buildroot should read this article first: How to build filesystem and kernel images for ARC cores with Buildroot. It covers Buildroot usage in more details.

Download Buildroot from upstream Buildroot project:

$ wget https://buildroot.org/downloads/buildroot-2023.02.1.tar.gz
$ tar -xvf buildroot-2023.02.1.tar.gz
$ cd buildroot-2023.02.1

Building the Linux Kernel and Booting Using U-Boot

Building the Linux kernel

ℹ️ You can find the latest prebuilt image for SD card on a release page for HSDK. Consider building it yourself, since the prebuilt images are quite old.

Configure Buildroot to use a default configuration for ARC HSDK and start building:

$ make snps_archs38_hsdk_defconfig
$ make

Building takes some time but usually less than an hour on modern machines. Note that build will produce following files in output/images/ folder:

  • sdcard.img - binary image to be deployed on a micro-SD card, containing everything required to boot into user shell
  • rootfs.cpio, rootfs.tar - these 2 files contain minimalistic rootfs, for example "rootfs.cpio" could be re-used when manually building Linux kernel for ARC boards.
  • u-boot.bin - this is a binary image of U-Boot bootloader, it is meant to be programmed in the ARC HSDK SPI flash and then autostart on power-on.
  • uImage - this is Linux kernel prepared for loading by U-Boot bootloader. When u-boot.bin is programmed in HSDK' SPI flash and autostarts on power-on it will attempt to find uImage on the first partition of the SD-card.

Then you can write sdcard.img to micro-SD card:

  • On Linux hosts, use dd command as follows: sudo dd if=sdcard.img of=/dev/mmcblk0 bs=1M. Ensure that the SD card is not mounted, otherwise the result is undefined.
  • On Windows hosts, use Win32 Disk Imager utility.

Building the Linux Kernel and Booting Using a Debugger

Building the Linux kernel

If you want to use a debugger for loading and running your Linux kernel then you need to modify the default configuration first. Configure Buildroot to use a default configuration for ARC HSDK and go to the configuration menu:

$ make snps_archs38_hsdk_defconfig
$ make menuconfig

Choose this option (corresponds to BR2_LINUX_KERNEL_UIMAGE=n and BR2_LINUX_KERNEL_VMLINUX=y):

Kernel -> Kernel binary format -> vmlinux

Completely delete content for this option (BR2_ROOTFS_POST_IMAGE_SCRIPT=""):

System configuration -> Custom scripts to run after creating filesystem images

Then build the Linux kernel:

$ make

Loading Using MDB and Ashling Opella-XD JTAG probe

Make sure that JTAG-probe is attached to the board. Then use these commands for MetaWare Debugger:

mdb -pset=1 -psetname=core0 -DLL=opxdarc.so -prop=jtag_frequency=12MHz -prop=jtag_optimise=1 -memxfersize=0x8000 output/images/vmlinux
mdb -pset=2 -psetname=core1 -DLL=opxdarc.so -prop=jtag_frequency=12MHz -prop=jtag_optimise=1 -prop=download=2 output/images/vmlinux
mdb -multifiles=core0,core1 -run -cl

Loading Using MDB and Digilent HS1/HS2 probe

Make sure that USB cable is attached to the board and Digilent Adept runtime and utilitied are isntalled. Then use these commands for MetaWare Debugger:

mdb -pset=1 -psetname=core0 -digilent output/images/vmlinux
mdb -pset=2 -psetname=core1 -digilent -prop=download=2 output/images/vmlinux
mdb -pset=3 -psetname=core2 -digilent -prop=download=2 output/images/vmlinux
mdb -pset=4 -psetname=core3 -digilent -prop=download=2 output/images/vmlinux
mdb -multifiles=core0,core1,core2,core3 -OK

Loading Using OpenOCD and Digilent HS1/HS2 probe

It's possible to use OpenOCD and Digilent HS1/HS2 probe for loading and debugging the Linux kernel on HSDK. You can find detailed instructions in AXS SDP and OpenOCD article (the same procedures are applicable for HSDK). There is a short guide for HSDK below.

If you've downloaded IDE bundle for Linux then you can run OpenOCD this way (replace <ide> by a path to the directory of IDE bundle):

$ <ide>/bin/openocd -s <ide>/share/openocd/scripts -f board/snps_hsdk.cfg

If you've built and installed OpenOCD manually then you can run OpenOCD this way:

openocd -f board/snps_hsdk.cfg

Then GDB servers for all 4 cores are started: 3333 — for 4th core, 3336 — for 1st core. You can debug Linux in a single core mode by connecting to the 1st core (which is on 3336 port):

$ arc-elf32-gdb output/images/vmlinux
(gdb) target remote :3336
Remote debugging using :3336
0xbff8a400 in ?? ()
(gdb) load
Loading section .vector, size 0x2000 lma 0x90000000
Loading section .init.ramfs, size 0x370d7c lma 0x90002000
Loading section .init.data, size 0x59c4 lma 0x90372d80
...
Start address 0x9037e000, load size 12871904
Transfer rate: 354 KB/sec, 15019 bytes/write.
(gdb) c

To run debug cores it’s necessary to run GDB for each core separately (cores 2-4 must be initialized first):

# Load and run core #2
$ arc-elf32-gdb -ex "target remote :3335" -ex "load" -ex "c" output/images/vmlinux

# Load and run core #3
$ arc-elf32-gdb -ex "target remote :3334" -ex "load" -ex "c" output/images/vmlinux

# Load and run core #4
$ arc-elf32-gdb -ex "target remote :3333" -ex "load" -ex "c" output/images/vmlinux

# Load and run core #1 (main one)
$ arc-elf32-gdb -ex "target remote :3336" -ex "load" -ex "c" output/images/vmlinux

Working with Linux After Loading the Kernel

The following log messages should appear in the console after loading and running the kernel:

Linux version 4.19.9 (didin@ru20arcgnu1) (gcc version 8.2.1 20180814 (Buildroot 2018.11-rc1-04991-gb17b76d030)) #3 SMP PREEMPT Wed Apr 24 16:26:10 MSK 2019
Memory @ 80000000 [1536M] 
OF: fdt: Machine model: snps,hsdk
earlycon: uart8250 at MMIO32 0xf0005000 (options '115200n8')
bootconsole [uart8250] enabled
Failed to get possible-cpus from dtb, pretending all 4 cpus exist
archs-intc      : 2 priority levels (default 1) FIRQ (not used)

IDENTITY        : ARCVER [0x52] ARCNUM [0x0] CHIPID [ 0x0]
processor [0]   : ARC HS38 R2.1 (ARCv2 ISA) 
Timers          : Timer0 Timer1 RTC [UP 64-bit] GFRC [SMP 64-bit] 
ISA Extn        : atomic ll64 unalign (not used)
                : mpy[opt 9] div_rem norm barrel-shift swap minmax swape
BPU             : full match, cache:2048, Predict Table:16384
MMU [v4]        : 8k PAGE, 2M Super Page (not used) JTLB 1024 (256x4), uDTLB 8, uITLB 4, PAE40 (not used) 
I-Cache         : 64K, 4way/set, 64B Line, VIPT aliasing
D-Cache         : 64K, 2way/set, 64B Line, PIPT
SLC             : 512K, 128B Line
Peripherals     : 0xf0000000, IO-Coherency (per-device) 
Vector Table    : 0x90000000
FPU             : SP DP 
DEBUG           : ActionPoint smaRT RTT 
OS ABI [v4]     : 64-bit data any register aligned
Extn [SMP]      : ARConnect (v2): 4 cores with IPI IDU DEBUG GFRC
percpu: Embedded 8 pages/cpu @(ptrval) s35968 r8192 d21376 u65536
Built 1 zonelists, mobility grouping on.  Total pages: 195744
Kernel command line: earlycon=uart8250,mmio32,0xf0005000,115200n8 console=ttyS0,115200n8 print-fatal-signals=1 root=/dev/mmcblk0p2 rootwait
Dentry cache hash table entries: 262144 (order: 7, 1048576 bytes)
Inode-cache hash table entries: 131072 (order: 6, 524288 bytes)
Memory: 1554656K/1572864K available (5592K kernel code, 448K rwdata, 1472K rodata, 224K init, 301K bss, 18208K reserved, 0K cma-reserved)

**********************************************************
**   NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE   **
**                                                      **
** trace_printk() being used. Allocating extra memory.  **
**                                                      **
** This means that this is a DEBUG kernel and it is     **
** unsafe for production use.                           **
**                                                      **
** If you see this message and you are not debugging    **
** the kernel, report this immediately to your vendor!  **
**                                                      **
**   NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE   **
**********************************************************
rcu: Preemptible hierarchical RCU implementation.
        Tasks RCU enabled.
NR_IRQS: 512
MCIP: IDU supports 64 common irqs
clocksource: ARConnect GFRC: mask: 0xffffffffffffffff max_cycles: 0x1cd42e4dffb, max_idle_ns: 881590591483 ns
Console: colour dummy device 80x25
Calibrating delay loop... 996.14 BogoMIPS (lpj=4980736)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 4096 (order: 1, 16384 bytes)
Mountpoint-cache hash table entries: 4096 (order: 1, 16384 bytes)
rcu: Hierarchical SRCU implementation.
smp: Bringing up secondary CPUs ...
Idle Task [1] (ptrval)
Trying to bring up CPU1 ...
archs-intc      : 2 priority levels (default 1) FIRQ (not used)

IDENTITY        : ARCVER [0x52] ARCNUM [0x1] CHIPID [ 0x0]
processor [1]   : ARC HS38 R2.1 (ARCv2 ISA) 
Timers          : Timer0 Timer1 RTC [UP 64-bit] 
ISA Extn        : atomic ll64 unalign (not used)
                : mpy[opt 9] div_rem norm barrel-shift swap minmax swape
BPU             : full match, cache:2048, Predict Table:16384
MMU [v4]        : 8k PAGE, 2M Super Page (not used) JTLB 1024 (256x4), uDTLB 8, uITLB 4, PAE40 (not used) 
I-Cache         : 64K, 4way/set, 64B Line, VIPT aliasing
D-Cache         : 64K, 2way/set, 64B Line, PIPT
SLC             : 512K, 128B Line
Peripherals     : 0xf0000000, IO-Coherency (per-device) 
Vector Table    : 0x90000000
FPU             : SP DP 
DEBUG           : ActionPoint smaRT RTT 
Extn [CCM]      : DCCM @ 80000000, 256 KB / ICCM: @ 70000000, 256 KB
OS ABI [v4]     : 64-bit data any register aligned
Extn [SMP]      : ARConnect (v2): 4 cores with IPI IDU DEBUG GFRC
## CPU1 LIVE ##: Executing Code...
Idle Task [2] (ptrval)
Trying to bring up CPU2 ...
archs-intc      : 2 priority levels (default 1) FIRQ (not used)

IDENTITY        : ARCVER [0x52] ARCNUM [0x2] CHIPID [ 0x0]
processor [2]   : ARC HS38 R2.1 (ARCv2 ISA) 
Timers          : Timer0 Timer1 RTC [UP 64-bit] 
ISA Extn        : atomic ll64 unalign (not used)
                : mpy[opt 9] div_rem norm barrel-shift swap minmax swape
BPU             : full match, cache:2048, Predict Table:16384
MMU [v4]        : 8k PAGE, 2M Super Page (not used) JTLB 1024 (256x4), uDTLB 8, uITLB 4, PAE40 (not used) 
I-Cache         : 64K, 4way/set, 64B Line, VIPT aliasing
D-Cache         : 64K, 2way/set, 64B Line, PIPT
SLC             : 512K, 128B Line
Peripherals     : 0xf0000000, IO-Coherency (per-device) 
Vector Table    : 0x90000000
FPU             : SP DP 
DEBUG           : ActionPoint smaRT RTT 
OS ABI [v4]     : 64-bit data any register aligned
Extn [SMP]      : ARConnect (v2): 4 cores with IPI IDU DEBUG GFRC
## CPU2 LIVE ##: Executing Code...
Idle Task [3] (ptrval)
Trying to bring up CPU3 ...
archs-intc      : 2 priority levels (default 1) FIRQ (not used)

IDENTITY        : ARCVER [0x52] ARCNUM [0x3] CHIPID [ 0x0]
processor [3]   : ARC HS38 R2.1 (ARCv2 ISA) 
Timers          : Timer0 Timer1 RTC [UP 64-bit] 
ISA Extn        : atomic ll64 unalign (not used)
                : mpy[opt 9] div_rem norm barrel-shift swap minmax swape
BPU             : full match, cache:2048, Predict Table:16384
MMU [v4]        : 8k PAGE, 2M Super Page (not used) JTLB 1024 (256x4), uDTLB 8, uITLB 4, PAE40 (not used) 
I-Cache         : 64K, 4way/set, 64B Line, VIPT aliasing
D-Cache         : 64K, 2way/set, 64B Line, PIPT
SLC             : 512K, 128B Line
Peripherals     : 0xf0000000, IO-Coherency (per-device) 
Vector Table    : 0x90000000
FPU             : SP DP 
DEBUG           : ActionPoint smaRT RTT 
Extn [CCM]      : DCCM @ 80000000, 256 KB / ICCM: @ 70000000, 256 KB
OS ABI [v4]     : 64-bit data any register aligned
Extn [SMP]      : ARConnect (v2): 4 cores with IPI IDU DEBUG GFRC
## CPU3 LIVE ##: Executing Code...
smp: Brought up 1 node, 4 CPUs
devtmpfs: initialized
random: get_random_u32 called from bucket_table_alloc+0x64/0x188 with crng_init=0
clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
futex hash table entries: 1024 (order: 4, 131072 bytes)
NET: Registered protocol family 16
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
media: Linux media interface: v0.10
videodev: Linux video capture interface: v2.00
pps_core: LinuxPPS API ver. 1 registered
pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <[email protected]>
PTP clock support registered
clocksource: Switched to clocksource ARConnect GFRC
NET: Registered protocol family 2
tcp_listen_portaddr_hash hash table entries: 1024 (order: 0, 12288 bytes)
TCP established hash table entries: 16384 (order: 3, 65536 bytes)
TCP bind hash table entries: 16384 (order: 4, 131072 bytes)
TCP: Hash tables configured (established 16384 bind 16384)
UDP hash table entries: 1024 (order: 2, 32768 bytes)
UDP-Lite hash table entries: 1024 (order: 2, 32768 bytes)
NET: Registered protocol family 1
RPC: Registered named UNIX socket transport module.
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
arc-pct pct: use dma_noncoherent_ops cache ops
ARC perf        : 8 counters (48 bits), 113 conditions
workingset: timestamp_bits=30 max_order=18 bucket_order=0
Block layer SCSI generic (bsg) driver version 0.4 loaded (major 251)
io scheduler noop registered
io scheduler deadline registered
io scheduler cfq registered (default)
io scheduler mq-deadline registered
io scheduler kyber registered
hsdk-reset f00008a0.reset-controller: use dma_noncoherent_ops cache ops
Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
dw-apb-uart f0005000.serial: use dma_noncoherent_ops cache ops
console [ttyS0] disabled
f0005000.serial: ttyS0 at MMIO 0xf0005000 (irq = 6, base_baud = 2083125) is a 16550A
console [ttyS0] enabled
console [ttyS0] enabled
bootconsole [uart8250] disabled
bootconsole [uart8250] disabled
usbcore: registered new interface driver udl
etnaviv-gpu f0090000.gpu: use dma_noncoherent_ops cache ops
 (null): use dma_noncoherent_ops cache ops
etnaviv etnaviv: bound f0090000.gpu (ops 0x905e03d4)
etnaviv-gpu f0090000.gpu: model: GC880, revision: 5124
[drm] Initialized etnaviv 1.2.0 20151214 for etnaviv on minor 0
libphy: Fixed MDIO Bus: probed
stmmaceth f0008000.ethernet: use dma_direct_ops cache ops
stmmaceth f0008000.ethernet: PTP uses main clock
random: fast init done
stmmaceth f0008000.ethernet: User ID: 0x10, Synopsys ID: 0x37
stmmaceth f0008000.ethernet:    DWMAC1000
stmmaceth f0008000.ethernet: DMA HW capability register supported
stmmaceth f0008000.ethernet: RX Checksum Offload Engine supported
stmmaceth f0008000.ethernet: COE Type 2
stmmaceth f0008000.ethernet: TX Checksum insertion supported
stmmaceth f0008000.ethernet: Normal descriptors
stmmaceth f0008000.ethernet: Ring mode enabled
stmmaceth f0008000.ethernet: Enable RX Mitigation via HW Watchdog Timer
libphy: stmmac: probed
ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
ehci-platform: EHCI generic platform driver
ehci-platform f0040000.ehci: use dma_direct_ops cache ops
ehci-platform f0040000.ehci: EHCI Host Controller
ehci-platform f0040000.ehci: new USB bus registered, assigned bus number 1
ehci-platform f0040000.ehci: irq 15, io mem 0xf0040000
ehci-platform f0040000.ehci: USB 2.0 started, EHCI 1.00
usb usb1: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 4.19
usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
usb usb1: Product: EHCI Host Controller
usb usb1: Manufacturer: Linux 4.19.9 ehci_hcd
usb usb1: SerialNumber: f0040000.ehci
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 1 port detected
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
ohci-platform: OHCI generic platform driver
ohci-platform f0060000.ohci: use dma_direct_ops cache ops
ohci-platform f0060000.ohci: Generic Platform OHCI controller
ohci-platform f0060000.ohci: new USB bus registered, assigned bus number 2
ohci-platform f0060000.ohci: irq 15, io mem 0xf0060000
usb usb2: New USB device found, idVendor=1d6b, idProduct=0001, bcdDevice= 4.19
usb usb2: New USB device strings: Mfr=3, Product=2, SerialNumber=1
usb usb2: Product: Generic Platform OHCI controller
usb usb2: Manufacturer: Linux 4.19.9 ohci_hcd
usb usb2: SerialNumber: f0060000.ohci
hub 2-0:1.0: USB hub found
hub 2-0:1.0: 1 port detected
usbcore: registered new interface driver usb-storage
sdhci: Secure Digital Host Controller Interface driver
sdhci: Copyright(c) Pierre Ossman
Synopsys Designware Multimedia Card Interface Driver
dw_mmc f000a000.mmc: use dma_direct_ops cache ops
dw_mmc f000a000.mmc: IDMAC supports 32-bit address mode.
dw_mmc f000a000.mmc: Using internal DMA controller.
dw_mmc f000a000.mmc: Version ID is 290a
dw_mmc f000a000.mmc: DW MMC controller at irq 12,32 bit host data width,16 deep fifo
mmc_host mmc0: Bus speed (slot 0) = 50000000Hz (slot req 400000Hz, actual 396825HZ div = 63)
sdhci-pltfm: SDHCI platform and OF driver helper
hidraw: raw HID events driver (C) Jiri Kosina
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
most_core: init()
usbcore: registered new interface driver hdm_usb
NET: Registered protocol family 10
Segment Routing with IPv6
sit: IPv6, IPv4 and MPLS over IPv4 tunneling driver
NET: Registered protocol family 17
ttyS0 - failed to request DMA
Waiting for root device /dev/mmcblk0p2...
mmc_host mmc0: Bus speed (slot 0) = 50000000Hz (slot req 25000000Hz, actual 25000000HZ div = 1)
mmc0: new SDHC card at address 59b4
blk_queue_max_segment_size: set to minimum 8192
mmcblk0: mmc0:59b4 USDU1 7.51 GiB 
 mmcblk0: p1 p2
usb 1-1: new high-speed USB device number 2 using ehci-platform
EXT4-fs (mmcblk0p2): recovery complete
EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
VFS: Mounted root (ext4 filesystem) on device 179:2.
devtmpfs: mounted
Freeing unused kernel memory: 224K
This architecture does not have kernel memory protection.
Run /sbin/init as init process
usb 1-1: New USB device found, idVendor=0424, idProduct=2422, bcdDevice= 0.a0
usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
hub 1-1:1.0: USB hub found
hub 1-1:1.0: 2 ports detected
EXT4-fs (mmcblk0p2): re-mounted. Opts: (null)
Starting logging: OK
Populating /dev using udev: udevd[100]: starting version 3.2.5
random: udevd: uninitialized urandom read (16 bytes read)
random: udevd: uninitialized urandom read (16 bytes read)
random: udevd: uninitialized urandom read (16 bytes read)
udevd[102]: starting eudev-3.2.5
done
Initializing random number generator... done.
Starting system message bus: dbus[129]: Unknown username "pulse" in message bus configuration file
done
Starting network: stmmaceth f0008000.ethernet eth0: device MAC address 56:46:65:60:1b:08
Micrel KSZ9031 Gigabit PHY stmmac-0:00: attached PHY driver [Micrel KSZ9031 Gigabit PHY] (mii_bus:phy_addr=stmmac-0:00, irq=POLL)
stmmaceth f0008000.ethernet eth0: No Safety Features support found
stmmaceth f0008000.ethernet eth0: PTP not supported by HW
IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
udhcpc: started, v1.29.3
udhcpc: sending discover
udhcpc: sending discover
random: crng init done
random: 5 urandom warning(s) missed due to ratelimiting
udhcpc: sending discover
udhcpc: no lease, failing
FAIL
Starting mpd: OK

Welcome to the HSDK Platform
hsdk login:

Enter login root and press Enter.

Note if you see following in bootlog:

udhcpc (v1.23.2) started
Sending discover...
Sending discover...
Sending discover...
No lease, failing

And also later:

stmmaceth e0018000.ethernet eth0: Link is Up - 100Mbps/Full - flow control rx/tx

That means Ethernet PHY became alive a bit too late. And that means it's required to execute DHCP discovery once again from console:

udhcpc

Now you may run whatever programs were built from your Buildroot selections. For the default only busybox is built and installed.

# ls /dev
bus                 tty1                tty43
console             tty10               tty44
cpu_dma_latency     tty11               tty45
full                tty12               tty46
gpiochip0           tty13               tty47
gpiochip1           tty14               tty48
gpiochip2           tty15               tty49
gpiochip3           tty16               tty5
gpiochip4           tty17               tty50
gpiochip5           tty18               tty51
gpiochip6           tty19               tty52
i2c-0               tty2                tty53
i2c-1               tty20               tty54
input               tty21               tty55
kmsg                tty22               tty56
log                 tty23               tty57
loop-control        tty24               tty58
loop0               tty25               tty59
loop1               tty26               tty6
loop2               tty27               tty60
loop3               tty28               tty61
loop4               tty29               tty62
loop5               tty3                tty63
loop6               tty30               tty7
loop7               tty31               tty8
mem                 tty32               tty9
memory_bandwidth    tty33               ttyS0
network_latency     tty34               ttyS1
network_throughput  tty35               ttyS2
null                tty36               ttyS3
psaux               tty37               urandom
ptmx                tty38               vcs
pts                 tty39               vcs1
random              tty4                vcsa
shm                 tty40               vcsa1
tty                 tty41               zero
tty0                tty42

Execution of Linux image on the target board with U-Boot

It's possible to use U-Boot bootloader for loading and starting Linux image on HSDK board. U-Boot itself could be whether pre-programmed in on-board SPI flash and start automatically on power-on or user may load it via JTAG similarly to how kernel image was loaded above. Linux image file executed by U-Boot is stored in "output/images" directory and has a name uImage. Put that file in the root of FAT32-formatted SD-card or in shared folder on TFTP server.

Building U-Boot for HSDK board

First of all U-Boot sources are fetch using next commands:

wget ftp://ftp.denx.de/pub/u-boot/u-boot-2019.04.tar.bz2
tar -xf u-boot-2019.04.tar.bz2
cd u-boot-2019.04/

To build U-Boot binaries arc-toolchain is required. You can use toolchain built by Buildroot, in this case add path <path_to_buildroot>/output/host/bin to $PATH environment variable. It is also possible to use prebuilt toolchain which is available here arc-toolchain. In this unpack downloaded archive in some place and add path <path_to_archive>/arc_gnu_2018.09_prebuilt_uclibc_le_archs_linux_install/bin/ to $PATH environment variable.

Configure U-Boot before building:

export CROSS_COMPILE=arc-linux-
make hsdk_defconfig

Now depending on use-case 2 different commands should be used.

  • for programming in on-board SPI flash: make
  • for loading U-Boot with debugger via JTAG: make mdbtrick

Loading U-Boot with debugger via JTAG

Ashling Opella-XD

 mdb -DLL=opxdarc.so -prop=jtag_frequency=12MHz -prop=jtag_optimise=1 -nooptions -OK -memxfersize=0x8000 u-boot

Digilent

mdb -digilent -prop=dig_speed=10000000 u-boot

Preparing U-Boot for automatic load of Linux kernel

Once U-Boot is loaded on the HSDK board it could be used for loading Linux kernel image from different media manually and automatically.

On execution of U-Boot you'll see this in serial console:

U-Boot 2019.4 (May 5 2019 - 18:43:19 +0300)

CPU:   ARC HS38 v2.1c
Model: snps,hsdk
DRAM:  1 GiB
Relocation Offset is: 3ef7f000
MMC:   Synopsys Mobile storage: 0
Loading Environment from FAT... OK
In:    serial0@f0005000
Out:   serial0@f0005000
Err:   serial0@f0005000
Clock values are saved to environment
Net:   
Warning: ethernet@f0008000 (eth0) using random MAC address - 96:f3:fa:6c:19:d9
eth0: ethernet@f0008000
Hit any key to stop autoboot:  0 
hsdk#

Press any key to stop count-down and make sure U-Boot doesn't go to execute automatic boot sequence.

U-Boot is controlled with its specific set of commands. List of available commands could be obtained with ? or help command like that:

hsdk# ?
?       - alias for 'help'
base    - print or set address offset
bdinfo  - print Board Info structure
boot    - boot default, i.e., run 'bootcmd'
bootd   - boot default, i.e., run 'bootcmd'
bootelf - Boot from an ELF image in memory
bootm   - boot application image from memory
bootp   - boot image via network using BOOTP/TFTP protocol
bootvx  - Boot vxWorks from an ELF image
cmp     - memory compare
coninfo - print console devices and information
cp      - memory copy
crc32   - checksum calculation
dhcp    - boot image via network using DHCP/TFTP protocol
dm      - Driver model low level access
echo    - echo args to console
editenv - edit environment variable
eeprom  - EEPROM sub-system
env     - environment handling commands
fatinfo - print information about filesystem
fatload - load binary file from a dos filesystem
fatls   - list files in a directory (default /)
fatsize - determine a file's size
fdt     - flattened device tree utility commands
go      - start application at address 'addr'
help    - print command description/usage
iminfo  - print header information for application image
imxtract- extract a part of a multi-image
itest   - return true/false on integer compare
loadb   - load binary file over serial line (kermit mode)
loads   - load S-Record file over serial line
loadx   - load binary file over serial line (xmodem mode)
loady   - load binary file over serial line (ymodem mode)
loop    - infinite loop on address range
md      - memory display
mm      - memory modify (auto-incrementing address)
mmc     - MMC sub system
mmcinfo - display MMC info
mw      - memory write (fill)
nand    - NAND sub-system
nboot   - boot from NAND device
nfs     - boot image via network using NFS protocol
nm      - memory modify (constant address)
ping    - send ICMP ECHO_REQUEST to network host
printenv- print environment variables
reset   - Perform RESET of the CPU
run     - run commands in an environment variable
saveenv - save environment variables to persistent storage
setenv  - set environment variables
sleep   - delay execution for some time
source  - run script from memory
tftpboot- boot image via network using TFTP protocol
usb     - USB sub-system
usbboot - boot from USB device
version - print monitor, compiler and linker version

It's also possible to create scripts - sequences of commands to be executed one by one. And a script with special name bootcmd is automatically executed after boot delay gets expired.

And so we may tune that script for our purposes.

  • To load Linux image from SD-card: setenv bootcmd fatload mmc 0\; bootm
  • To load Linux image from TFTP server: setenv bootcmd dhcp\; bootm

When all preparations are done it's good to save modifications of U-Boot environment with saveenv command.

And with boot command or with restart of U-Boot (whether with reset button if U-Boot is pre-programmed in SPI flash or with reload of U-Boot elf with MDB) you'll be able to load and start Linux kernel.

Clone this wiki locally