Skip to content

Instantly share code, notes, and snippets.

@lisovy
Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lisovy/9455f0710599713e5028 to your computer and use it in GitHub Desktop.
Save lisovy/9455f0710599713e5028 to your computer and use it in GitHub Desktop.
http://www.embest-tech.com/shop/star/marsboard.html
U-boot
======
git clone git://git.denx.de/u-boot.git
cd u-boot
# Build U-boot
mkdir _build
make O=_build marsboard_defconfig
cd _build
CROSS_COMPILE=arm-linux-gnueabihf- make -j8
# Will be downloaded later to the device via TFTP
cp u-boot.imx /srv/tftp/
# Switch the SoC into the serial-load mode (SW1: D0: OFF, D1: ON)
# imx-usb-loader is distributed as part of the Barebox bootloader
barebox/_build$ sudo ./scripts/imx/imx-usb-loader -vvv -c ../../u-boot/_build/u-boot.imx
=> dhcp
*** ERROR: `ethaddr' not set
# Check fuses for proper MAC address (doc/README.imx6)
=> fuse read 4 2
Reading bank 4:
Word 0x00000002: 00000000
=> fuse read 4 3
Reading bank 4:
Word 0x00000003: 00000000
# Set your own MAC address, request IP address
=> setenv ethaddr "00:11:22:33:44:55"
=> setenv autoload no
=> dhcp
# Fetch new U-boot in DCD format
=> setenv serverip 192.168.0.10
=> tftpboot ${loadaddr} u-boot.imx
Using FEC device
TFTP from server 192.168.0.10; our IP address is 192.168.0.23
Filename 'u-boot.imx'.
Load address: 0x12000000
Loading: #################################################################
#######
5.9 MiB/s
done
Bytes transferred = 367616 (59c00 hex)
# Erase the SPI NOR FLash
=> sf erase 0 0x200000
SF: 2097152 bytes @ 0x0 Erased: OK
# Flash the new bootloader to the SPI NOR flash
# Why the 0x400 offset? See "Table 8-28. Image Vector Table
# Offset and Initial Load Region Size" in IMX6DQRM.pdf
=> sf write ${loadaddr} 0x400 ${filesize};
SF: 367616 bytes @ 0x400 Written: OK
# Check out the SPI NOR content
=> sf read ${loadaddr} 0x400 32
SF: 50 bytes @ 0x400 Read: OK
=> md ${loadaddr}
12000000: 402000d1 27800720 00000000 2780042c .. @ ..'....,..'
# Correct DCD header -- Tag = 0xD1, Len = 0x0020, Ver = 0x40
# Power cycle the board; Do not run "reset"
Control GPIO (user LEDs) through raw memory access in U-boot
============================================================
# See the following sections of IMX6DQRM.pdf to get more info on
# register values used in this examples:
# * Table 4-1 (page 264 and 268) -- Alternative functions of PINs
# * 36.4.30 and 36.4.45 -- PINMUX configuration (select ALT5 for GPIO)
# * 28.5 -- GPIO Memory Map/Register Definition
# EIM_D28 PINMUX, ALT5 (GPIO3_IO28)
md.l 0x020E00C4 1
mw.l 0x020E00C4 0x5 1
# GPIO3_IO28 direction OUT
mw.l 0x020A4004 0x10000000 1
md.l 0x020A4004 1
# GPIO3_IO28 output value
mw.l 0x020A4000 0x10000000 1
mw.l 0x020A4000 0x00000000 1
# EIM_A25 Pinmux, ALT5 (GPIO5_IO02)
md.l 0x020E0088 1
mw.l 0x020E0088 0x5 1
# GPIO5_02 direction OUT
mw.l 0x020ac004 0x4 1
# GPIO5_02 output value
mw.l 0x020ac000 0x4 1
mw.l 0x020ac000 0x0 1
# Automate application loading in U-boot
setenv ethaddr "00:11:22:33:44:55"
setenv autoload no
dhcp
setenv serverip 192.168.0.10
tftpboot ${loadaddr} gpio.bin
go ${loadaddr}
setenv loadprog "setenv ethaddr "00:11:22:33:44:55"; setenv autoload no; dhcp; setenv serverip 192.168.0.10; tftpboot ${loadaddr} gpio.bin; go ${loadaddr}"
setenv bootcmd "run loadprog"
saveenv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment