|
From: <bob...@us...> - 2007-07-07 04:08:43
|
Revision: 1110
http://svn.sourceforge.net/hackndev/?rev=1110&view=rev
Author: bobofdoom
Date: 2007-07-06 21:08:39 -0700 (Fri, 06 Jul 2007)
Log Message:
-----------
TOOLS: Initial revision of a quick and dirty bootloader for the palmld's "sandal" serial recovery console.
Added Paths:
-----------
linux4palm/tools/serial-loader/
linux4palm/tools/serial-loader/Makefile
linux4palm/tools/serial-loader/README
linux4palm/tools/serial-loader/bin2sandal.py
linux4palm/tools/serial-loader/ql.py
linux4palm/tools/serial-loader/quickload.S
linux4palm/tools/serial-loader/quickload.lds
Added: linux4palm/tools/serial-loader/Makefile
===================================================================
--- linux4palm/tools/serial-loader/Makefile (rev 0)
+++ linux4palm/tools/serial-loader/Makefile 2007-07-07 04:08:39 UTC (rev 1110)
@@ -0,0 +1,21 @@
+CROSS_COMPILE?=arm-softfloat-linux-gnueabi-
+CC=${CROSS_COMPILE}gcc
+OBJCOPY=${CROSS_COMPILE}objcopy
+LDFLAGS=-nostdlib -Wall -pipe -Tquickload.lds -g -O2
+CFLAGS=-g -O2
+
+SRCS=quickload.S #quickload.c
+
+all: quickload.sandal
+
+quickload.sandal: quickload.bin
+ ./bin2sandal.py quickload.bin quickload.sandal
+
+quickload.bin: quickload.elf
+ ${OBJCOPY} -O binary quickload.elf quickload.bin
+
+quickload.elf: ${SRCS} quickload.lds
+ ${CC} $(LDFLAGS) ${SRCS} -o quickload.elf
+
+clean:
+ rm -f quickload.bin quickload.elf quickload.sandal *.s
Added: linux4palm/tools/serial-loader/README
===================================================================
--- linux4palm/tools/serial-loader/README (rev 0)
+++ linux4palm/tools/serial-loader/README 2007-07-07 04:08:39 UTC (rev 1110)
@@ -0,0 +1,55 @@
+--------------------
+Serial Loading Tools
+--------------------
+
+This collection of tools enables you to boot Linux on a palmld PDA via the
+'Sandal' recovery console on the serial port. They may also be useful for other
+devices.
+
+Usage
+-----
+
+Connect PDA to PC's serial port. You'll need to convert between the PDA's TTL
+level serial port and your PCs RS232. Alternatively you can get a something
+like a Nokia DKU-5 data cable which does TTL serial -> USB conversion.
+
+Open the serial port using something like minicom at a baud rate of 115200 with
+both software and hardware flow control disabled.
+
+Reset the PDA while holding down the hotsync button. The LCD should remain off
+indicating the recovery console has been entered. On the PC you should see the
+Sandal prompt. Check to make sure the link is working by typing a command such
+as "w 0".
+
+Compile the 'quickload' bootloader by typing 'make'. Upload the bootloader to
+the PDA using a command like:
+
+ ./bin2sandal.py -d quickload.bin > /dev/ttyUSB0
+
+In minicom you should see a bunch memory write commands hopefully ending in
+quickload's prompt "Q?" .
+
+Upload your kernel image using ql.py:
+
+ ./ql.py < zImage > /dev/ttyUSB0
+
+This may take a while, ql.py will print the progress percentage and you should
+see the bootloader replying with lots of dots in minicom. When the upload is
+complete ql.py will exit and the bootloader will print 'G' and then attempt to
+jump to the image.
+
+
+Kernel Note
+-----------
+
+Quickload doesn't support passing a kernel command line at the moment so you'll
+want to compile one into kernel itself. Normally you'll want to at least
+specify the RAM size of the device and put the console on the serial port like
+this:
+
+ mem=32M console=ttyS0,115200
+
+
+----
+Alex Osborne
+<alex at-sign hackndev dot com>
Added: linux4palm/tools/serial-loader/bin2sandal.py
===================================================================
--- linux4palm/tools/serial-loader/bin2sandal.py (rev 0)
+++ linux4palm/tools/serial-loader/bin2sandal.py 2007-07-07 04:08:39 UTC (rev 1110)
@@ -0,0 +1,57 @@
+#!/usr/bin/env python
+#
+# This script takes an executable binary image (such as a zImage) and spits out
+# a bunch of commands for the "Sandal" recovery console on the LD which loads
+# the image into RAM and then executes it.
+#
+# eg. ./bin2sandal -d quickload.bin > /dev/ttyUSB0
+#
+# The -d option introduces a short delay to prevent the Sandal console from being
+# overwhelmed.
+#
+# Author: Alex Osborne <alex at-sign hackndev dot com>
+# Created: Jul 2007
+
+LOAD_ADDR=0xa0000000
+
+import sys
+import struct
+import time
+
+if len(sys.argv) > 1 and sys.argv[1] in ['-h', '--help']:
+ print 'Usage: %s [-d] [input binary file] [output sandal commands file]' % sys.argv[0]
+ sys.exit(1)
+
+inf = sys.stdin
+outf = sys.stdout
+delay = False
+
+if len(sys.argv) > 1 and sys.argv[1] == '-d':
+ delay = True
+ sys.argv.pop(1)
+
+if len(sys.argv) > 1:
+ inf = file(sys.argv[1], 'rb')
+
+if len(sys.argv) > 2:
+ outf = file(sys.argv[2], 'wb')
+
+address = LOAD_ADDR
+
+while 1:
+ data = inf.read(4)
+ if not data: break
+
+ data += '\0' * (4 - len(data)) # pad with zeros to make full dword
+
+ value, = struct.unpack('<I', data)
+
+ outf.write('w 0x%x=0x%x\r\n' % (address, value))
+
+ address += 4
+
+ if delay:
+ outf.flush()
+ time.sleep(0.02)
+
+outf.write('x 0x%x\r\n' % LOAD_ADDR)
Property changes on: linux4palm/tools/serial-loader/bin2sandal.py
___________________________________________________________________
Name: svn:executable
+ *
Added: linux4palm/tools/serial-loader/ql.py
===================================================================
--- linux4palm/tools/serial-loader/ql.py (rev 0)
+++ linux4palm/tools/serial-loader/ql.py 2007-07-07 04:08:39 UTC (rev 1110)
@@ -0,0 +1,36 @@
+#!/usr/bin/env python
+#
+# Quick and dirty script for sending an image to the 'quickload' serial
+# bootloader.
+#
+# eg. ./ql.py < zImage > /dev/ttyUSB0
+#
+# Author: Alex Osborne <alex at-sign hackndev dot com>
+# Created: July 2007
+
+import sys
+import struct
+import time
+
+image = sys.stdin.read()
+
+# anything before a 'G' will be echoed by bootloader
+sys.stdout.write('ql.py: uploading image...\r\n')
+
+# notify bootloader to begin listening
+sys.stdout.write('G')
+
+# output the size of the image
+sys.stdout.write(struct.pack('<I', len(image)))
+
+# write out image
+i = 0
+for c in image:
+ sys.stdout.write(c)
+ sys.stdout.flush()
+
+ # print progress percentage
+ i += 1
+ if (i % 1000) == 0:
+ sys.stderr.write('%f\n' % (i / float(len(image)) * 100))
+ sys.stderr.flush()
Property changes on: linux4palm/tools/serial-loader/ql.py
___________________________________________________________________
Name: svn:executable
+ *
Added: linux4palm/tools/serial-loader/quickload.S
===================================================================
--- linux4palm/tools/serial-loader/quickload.S (rev 0)
+++ linux4palm/tools/serial-loader/quickload.S 2007-07-07 04:08:39 UTC (rev 1110)
@@ -0,0 +1,138 @@
+@ quickload.S - primitive serial bootloader for pxa devices
+@
+@ This bootloader enables you to load and execute a kernel image via the serial
+@ port using a very simple transfer protocol. The bootloader expects the system
+@ to have the MMU disabled.
+@
+@ Protocol:
+@
+@ Upon starting the bootloader will output the prompt 'Q?'. It will then read
+@ echo characters until it encounters a 'G' character. This echo mode is to
+@ allow reliability testing of the link and to soak up any stray characters that
+@ may have been received. Upon receiving 'G' the bootloader will read a DWORD
+@ which it treats as the length of the kernel image. It will then read that
+@ many bytes loading them into RAM starting at 0xA0008000. It prints a '.'
+@ character every 256 or so bytes. After the image loading is complete it
+@ prints 'D' and jumps to the start of the image.
+@
+@ Author: Alex Osborne <alex at-sign hackndev dot com>
+@ Created: July 2007
+@
+
+.text
+.globl _start
+_start:
+ b _copier
+
+@ magic number for tools to recognize us (currently unused)
+ .word 0xb007104d
+
+@ here we store how many bytes will be uploaded
+data_length:
+ .word 0x0
+
+_copier:
+@ figure out where we are loaded
+ mov r7, pc
+ sub r7, #(_copier-_start+8)
+
+@ r5 := FFUART base
+ mov r5, #0x40000000
+ orr r5, #0x00100000
+
+@ show our ready prompt "Q?"
+ mov r0, #'Q'
+ bl ffuart_putc
+ mov r0, #'?'
+ bl ffuart_putc
+
+@ echo until we get a 'G' indicating start of transmission
+wait_ready:
+ bl ffuart_getc
+ bl ffuart_putc
+ cmp r0, #'G'
+ bne wait_ready
+
+@ read in the length of the image
+ mov r0, #0
+ str r0, [r7, #8]
+
+ bl ffuart_getc
+ strb r0, [r7, #8]
+ bl ffuart_getc
+ strb r0, [r7, #8 + 1]
+ bl ffuart_getc
+ strb r0, [r7, #8 + 2]
+ bl ffuart_getc
+ strb r0, [r7, #8 + 3]
+
+
+@ start loading in the image
+ mov r1, #0xa0000000
+ orr r1, #0x00008000
+ ldr r2, [r7, #8] @ remaining bytes
+
+_loop:
+ @ if no remaining bytes, goto done
+ cmp r2, #0
+ beq done
+
+ @ decrement remaining bytes
+ sub r2, #1
+
+ @ print '.' every now and then
+ and r0, r2, #0xff
+ cmp r0, #0
+ mov r0, #'.'
+ bleq ffuart_putc
+
+ @ get a character
+ bl ffuart_getc
+
+ @ store it in RAM
+ strb r0, [r1]
+
+ @ increment our storage location
+ add r1, #1
+
+
+ b _loop
+
+done:
+ mov r0, #'D'
+ bl ffuart_putc
+
+ @ setup the kernel parameters
+ mov r0, #0
+ mov r1, #0x340 @ mach id
+ orr r1, #0x003 @ 0x343 = palmld
+ mov r2, #0 @ atag base
+
+ @ jump to the kernel image
+ mov r3, #0xa0000000
+ orr r3, #0x00008000
+ mov pc, r3
+
+ffuart_putc:
+@ wait for LSR to show we're ready to transmit
+ ldr r6, [r5, #0x14] @ get LSR
+ and r6, #0x32 @ is TDRQ set?
+ cmp r6, #0
+ beq ffuart_putc
+
+ str r0, [r5] @ put character into THR
+
+ mov pc, lr
+
+ffuart_getc:
+@ wait for LSR to show we're ready to receive
+ ldr r6, [r5, #0x14] @ get LSR
+ and r6, #1 @ is DR set?
+ cmp r6, #0
+ beq ffuart_getc
+
+ ldr r0, [r5] @ get character from RBR
+
+ mov pc, lr
+
+
Added: linux4palm/tools/serial-loader/quickload.lds
===================================================================
--- linux4palm/tools/serial-loader/quickload.lds (rev 0)
+++ linux4palm/tools/serial-loader/quickload.lds 2007-07-07 04:08:39 UTC (rev 1110)
@@ -0,0 +1,14 @@
+SECTIONS
+{
+ /* This is the location that bootmenu will be copied to.
+ Set it to a safe place that will not squash any PalmOS
+ data.
+ */
+ . = 0xa0100000;
+
+ .text : { *(.text) }
+ .data : { *(.data) }
+ .bss : { *(.bss) }
+ _end = .;
+ _length = _end - _start;
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|