import SAMBA 3.2
|
import SAMBA.Connection.Serial 3.2
|
import SAMBA.Device.SAMA5D4 3.2
|
|
SerialConnection {
|
|
device: SAMA5D4Xplained {
|
config {
|
nandflash {
|
header: 0xc1e04e07
|
}
|
}
|
}
|
|
function initNand() {
|
/* Placeholder: Nothing to do */
|
}
|
|
function getEraseSize(size) {
|
/* get smallest erase block size supported by applet */
|
var eraseSize
|
for (var i = 0; i <= 32; i++) {
|
eraseSize = 1 << i
|
if ((applet.eraseSupport & eraseSize) !== 0)
|
break;
|
}
|
eraseSize *= applet.pageSize
|
|
/* round up file size to erase block size */
|
return (size + eraseSize - 1) & ~(eraseSize - 1)
|
}
|
|
function eraseWrite(offset, filename, bootfile) {
|
/* get file size */
|
var file = File.open(filename, false)
|
var size = file.size()
|
file.close()
|
|
applet.erase(offset, getEraseSize(size))
|
applet.write(offset, filename, bootfile)
|
}
|
|
onConnectionOpened: {
|
var bootstrapFileName = "images/bootstrap-sama5d4.bin"
|
var ubootFileName = "images/u-boot-sama5d4.bin"
|
var linuxFileNmae = "images/linuxrom-sama5d4.itb"
|
var rootfsFileNmae = "images/rootfs-sama5d4.ubi"
|
|
print("-I- === Initilize low level (system clocks) ===")
|
initializeApplet("lowlevel")
|
|
print("-I- === Initialize extram ===")
|
initializeApplet("extram")
|
|
print("-I- === Initialize nandflash access ===")
|
initializeApplet("nandflash")
|
|
print("-I- === Erase nandflash access ===")
|
//applet.erase(0, 0x100000)
|
applet.erase()
|
|
print("-I- === Load AT91Bootstrap ===")
|
eraseWrite(0x000000, bootstrapFileName, true)
|
|
print("-I- === Load u-boot ===")
|
eraseWrite(0x040000, ubootFileName)
|
|
print("-I- === Load linux kernel image ===")
|
applet.write(0x100000, linuxFileNmae)
|
|
print("-I- === Load UBI rootfs image ===")
|
applet.write(0x800000, rootfsFileNmae)
|
|
print("-I- === Done. ===")
|
}
|
}
|