pxa: add support for palmtreo680 board
v6 cover pxa: add support for palmtreo680 board
These two patches add support for the Palm Treo 680 phone. The second patch provides a userspace utility that is needed to program u-boot to the docg4 nand flash in the manner required by the phone's IPL.
Marek, I thought that these patches were in your tree when you issued the PR a few weeks ago, but I must have been mistaken. Sorry.
I would have labeled these patches RESEND, but since I submitted v5 I learned that README files now go into the board/ directory, so I made that change and called it v6. Each patch contains its full changelog.
Thanks!
Mike Dunn (2):
pxa: add support for palmtreo680 board
pxa: palmtreo680 flash programming utility
CREDITS | 4 + MAINTAINERS | 3 + board/palmtreo680/Makefile | 34 +++ board/palmtreo680/README | 581 ++++++++++++++++++++++++++++++++++++++ board/palmtreo680/palmtreo680.c | 148 ++++++++++ boards.cfg | 1 + include/configs/palmtreo680.h | 286 +++++++++++++++++++ tools/palmtreo680/flash_u-boot.c | 177 ++++++++++++ 8 files changed, 1234 insertions(+), 0 deletions(-) create mode 100644 board/palmtreo680/Makefile create mode 100644 board/palmtreo680/README create mode 100644 board/palmtreo680/palmtreo680.c create mode 100644 include/configs/palmtreo680.h create mode 100644 tools/palmtreo680/flash_u-boot.c
Signature · 1 line
1.7.8.6
PATCH v6 1/2 pxa: add support for palmtreo680 board
This patch adds support for the Palm Treo 680 smartphone. A quick overview of u-boot implementation on the treo 680...
The treo 680 has a Diskonchip G4 nand flash chip. This device has a 2k region that maps to the system bus at the reset vector in a NOR-like fashion so that it can be used as the boot device. The phone is shipped with this 2k region configured as write-protected (can't be modified) and programmed with an initial program loader (IPL). At power-up, this IPL loads the contents of two flash blocks to SDRAM and jumps to it. The capacity of the two blocks is not large enough to hold all of u-boot, so a u-boot SPL is used. To conserve flash space, these two blocks and the necessary number of subsequent blocks are programmed with a concatenated spl + u-boot image. That way, the IPL will also load a portion of u-boot proper, and when the spl runs, it relocates the portion of u-boot that the IPL has already loaded, and then resumes loading the remaining part of u-boot before jumping to it.
The default_environment is used (CONFIG_ENV_IS_NOWHERE) because I didn't think that having a writable environment was worth the cost of a flash block, although adding it would be straightforward. I abuse the CONFIG_EXTRA_ENV_SETTINGS option to specify the usbtty for the console (CONFIG_SYS_CONSOLE_IS_IN_ENV).
Support for the LCD is included, but currently it is only useful for displaying the u-boot splash screen. But if u-boot is built without the usbtty console, it does display the auto-boot progress nicely.
---
Changelog:
v6: mv doc/README.palmtreo680 board/palmtreo680/README
v5: do not use a custom linker script for spl build
v4:
- use CONFIG_MACH_TYPE instead of MACH_TYPE_TREO680 to initialize bi_arch_number
- use offset from CONFIG_SYS_DRAM_BASE to initialize bi_boot_params, instead of hard-coding an absolute address
- use shift operator to set one bit when initializing gpio register
- remove memcpy() definition from spl build; use CONFIG_SPL_LIBGENERIC_SUPPORT to properly build and link with u-boot's memcpy()
- config file cleanup: remove erroneous comments, unneeded numerical definitions
- edited README.palmtreo680 a bit
v3: flash_u-boot utility split into separate patch
v2:
- tabs removed in #defines in palmtreo680.h
- utility for programming u-boot to flash moved to tools/palmtreo680
CREDITS | 4 + MAINTAINERS | 3 + board/palmtreo680/Makefile | 34 +++ board/palmtreo680/README | 581 +++++++++++++++++++++++++++++++++++++++ board/palmtreo680/palmtreo680.c | 148 ++++++++++ boards.cfg | 1 + include/configs/palmtreo680.h | 286 +++++++++++++++++++ 7 files changed, 1057 insertions(+), 0 deletions(-) create mode 100644 board/palmtreo680/Makefile create mode 100644 board/palmtreo680/README create mode 100644 board/palmtreo680/palmtreo680.c create mode 100644 include/configs/palmtreo680.h
CREDITS +4 -0
@@ -124,6 +124,10 @@ N: James F. Dougherty E: jfd at GigabitNetworks.COM D: Port to the MOUSSE board +N: Mike Dunn +E: mikedunn at newsguy.com +D: Palmtreo680 board, docg4 nand flash driver + N: Dave Ellis E: DGE at sixnetio.com D: EEPROM Speedup, SXNI855T port
MAINTAINERS +3 -0
@@ -651,6 +651,9 @@ Wolfgang Denk <[email protected]> imx27lite i.MX27 qong i.MX31 +Mike Dunn <[email protected]> + palmtreo680 pxa270 + Kristoffer Ericson <[email protected]> jornada SA1110
board/palmtreo680/Makefile new file +34 -0
@@ -0,0 +1,34 @@ +# +# Palm Treo680 Support +# +# Copyright (C) 2013 Mike Dunn <[email protected]> +# +# This file is released under the terms of GPL v2 and any later version. +# See the file COPYING in the root directory of the source tree for details. + +include $(TOPDIR)/config.mk + +LIB = $(obj)lib$(BOARD).o + +COBJS := palmtreo680.o + +SRCS := $(COBJS:.o=.c) +OBJS := $(addprefix $(obj),$(COBJS)) + +$(LIB): $(obj).depend $(OBJS) + $(call cmd_link_o_target, $(OBJS)) + +clean: + rm -f $(OBJS) + +distclean: clean + rm -f $(LIB) core *.bak $(obj).depend + +######################################################################### + +# defines $(obj).depend target +include $(SRCTREE)/rules.mk + +sinclude $(obj).depend + +#########################################################################
board/palmtreo680/README new file +581 -0
581 lines not on this page · raw message
board/palmtreo680/palmtreo680.c new file +148 -0
148 lines not on this page · raw message
boards.cfg +1 -0
@@ -352,6 +352,7 @@ lp8x4x arm pxa lp8x4x icpdas lubbock arm pxa palmld arm pxa palmtc arm pxa +palmtreo680 arm pxa polaris arm pxa trizepsiv - - trizepsiv:POLARIS pxa255_idp arm pxa trizepsiv arm pxa
include/configs/palmtreo680.h new file +286 -0
286 lines not on this page · raw message
Signature · 1 line
1.7.8.6
PATCH v6 2/2 pxa: palmtreo680 flash programming utility
In reply to Mike DunnThis adds a userspace linux utility that writes the u-boot image to an mtd partition on the docg4 nand flash.
A special utility is required to do this because u-boot is partially loaded by an initial program loader (IPL) that is permanently programmed to the boot region of the flash. This IPL expects the image to be written in a unique format. The characteristics of this format can be summarized as follows:
- Flash blocks to be loaded must have a magic number in the oob bytes of the first page of the block.
- Each page must be written redundantly in the subsequent page.
- The integrated flash controller's "reliable mode" is used, requiring that alternate 2k regions (4 pages) are skipped when writing.
For these reasons, a u-boot image can not be written using nandwrite from mtd-utils.
---
Changelog:
v6: no change
v5: on error, return a sensible errno.h code v4:
- use return instead of exit
- use calloc() instead of malloc()
- remove call to read() from within while loop test
v3: new patch; split off from patch 7 in v2 of patchset
tools/palmtreo680/flash_u-boot.c | 177 ++++++++++++++++++++++++++++++++++++++ 1 files changed, 177 insertions(+), 0 deletions(-) create mode 100644 tools/palmtreo680/flash_u-boot.c
tools/palmtreo680/flash_u-boot.c new file +177 -0
@@ -0,0 +1,177 @@ +/* +* Copyright (C) 2013 Mike Dunn <[email protected]> +* +* This file is released under the terms of GPL v2 and any later version. +* See the file COPYING in the root directory of the source tree for details. +* +* +* This is a userspace Linux utility that, when run on the Treo 680, will +* program u-boot to flash. The docg4 driver *must* be loaded with the +* reliable_mode and ignore_badblocks parameters enabled: +* +* modprobe docg4 ignore_badblocks=1 reliable_mode=1 +* +* This utility writes the concatenated spl + u-boot image to the start of the +* mtd device in the format expected by the IPL/SPL. The image file and mtd +* device node are passed to the utility as arguments. The blocks must have +* been erased beforehand. +* +* When you compile this, note that it links to libmtd from mtd-utils, so ensure +* that your include and lib paths include this. +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <string.h> +#include <sys/types.h> +#include <unistd.h> +#include <errno.h> +#include <mtd/mtd-user.h> +#include "libmtd.h" + +#define RELIABLE_BLOCKSIZE 0x10000/* block capacity in reliable mode */ +#define STANDARD_BLOCKSIZE 0x40000/* block capacity in normal mode */ +#define PAGESIZE 512 +#define PAGES_PER_BLOCK 512 +#define OOBSIZE 7/* available to user (16 total) */ + +uint8_t ff_oob[OOBSIZE ] = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff }; + +/* this is the magic number the IPL looks for (ASCII "BIPO") */ +uint8_t page0_oob[OOBSIZE ] = {'B' ,'I' ,'P' ,'O' ,0xff ,0xff ,0xff }; + +int main (int argc,char *const argv[]) +{ +int devfd, datafd, num_blocks, block; +off_t file_size; +libmtd_t mtd_desc; +struct mtd_dev_info devinfo; +uint8_t *blockbuf; +char response[8 ]; + +if (argc !=3 ) { +printf ("usage: %s <image file> <mtd dev node>\n" , argv[0 ]); +return -EINVAL ; + } + + mtd_desc =libmtd_open (); +if (mtd_desc ==NULL ) { +int errsv = errno; +fprintf (stderr,"can't initialize libmtd\n" ); +return -errsv; + } + +/* open the spl image file and mtd device */ + datafd =open (argv[1 ],O_RDONLY ); +if (datafd ==-1 ) { +int errsv = errno; +perror (argv[1 ]); +return -errsv; + } + devfd =open (argv[2 ],O_WRONLY ); +if (devfd ==-1 ) { +int errsv = errno; +perror (argv[2 ]); +return -errsv; + } +if (mtd_get_dev_info (mtd_desc, argv[2 ], &devinfo) <0 ) { +int errsv = errno; +perror (argv[2 ]); +return -errsv; + } + +/* determine the number of blocks needed by the image */ + file_size =lseek (datafd,0 ,SEEK_END ); +if (file_size == (off_t)-1 ) { +int errsv = errno; +perror ("lseek" ); +return -errsv; + } + num_blocks = (file_size +RELIABLE_BLOCKSIZE -1 ) /RELIABLE_BLOCKSIZE ; + file_size =lseek (datafd,0 ,SEEK_SET ); +if (file_size == (off_t)-1 ) { +int errsv = errno; +perror ("lseek" ); +return -errsv; + } +printf ("The mtd partition contains %d blocks\n" , devinfo.eb_cnt); +printf ("U-boot will occupy %d blocks\n" , num_blocks); +if (num_blocks > devinfo.eb_cnt) { +fprintf (stderr,"Insufficient blocks on partition\n" ); +return -EINVAL ; + } + +printf ("IMPORTANT: These blocks must be in an erased state!\n" ); +printf ("Do you want to proceed?\n" ); +scanf ("%s" , response); +if ((response[0 ] !='y' ) && (response[0 ] !='Y' )) { +printf ("Exiting\n" ); +close (devfd); +close (datafd); +return 0 ; + } + + blockbuf =calloc (RELIABLE_BLOCKSIZE ,1 ); +if (blockbuf ==NULL ) { +int errsv = errno; +perror ("calloc" ); +return -errsv; + } + +for (block =0 ; block < num_blocks; block++) { +int ofs, page; +uint8_t *pagebuf = blockbuf, *buf = blockbuf; +uint8_t *oobbuf = page0_oob;/* magic num in oob of 1st page */ +size_t len =RELIABLE_BLOCKSIZE ; +int ret; + +/* read data for one block from file */ +while (len) { +ssize_t read_ret =read (datafd, buf, len); +if (read_ret ==-1 ) { +int errsv = errno; +if (errno ==EINTR ) +continue ; +perror ("read" ); +return -errsv; + }else if (read_ret ==0 ) { +break ;/* EOF */ + } + len -= read_ret; + buf += read_ret; + } + +printf ("Block %d: writing\r" , block +1 ); +fflush (stdout); + +for (page =0 , ofs =0 ; + page <PAGES_PER_BLOCK ; + page++, ofs +=PAGESIZE ) { +if (page &0x04 )/* Odd-numbered 2k page */ +continue ;/* skipped in reliable mode */ + + ret =mtd_write (mtd_desc, &devinfo, devfd, block, ofs, + pagebuf,PAGESIZE , oobbuf,OOBSIZE , +MTD_OPS_PLACE_OOB ); +if (ret) { +fprintf (stderr, +"\nmtd_write returned %d on block %d, ofs %x\n" , + ret, block +1 , ofs); +return -EIO ; + } + oobbuf = ff_oob;/* oob for subsequent pages */ + +if (page &0x01 )/* odd-numbered subpage */ + pagebuf +=PAGESIZE ; + } + } + +printf ("\nDone\n" ); + +close (devfd); +close (datafd); +free (blockbuf); +return 0 ; +}
Signature · 1 line
1.7.8.6
v6 cover pxa: add support for palmtreo680 board
In reply to Mike DunnDear Mike Dunn,
Quoted 10 lines
These two patches add support for the Palm Treo 680 phone. The second patch provides a userspace utility that is needed to program u-boot to the docg4 nand flash in the manner required by the phone's IPL.
Marek, I thought that these patches were in your tree when you issued the PR a few weeks ago, but I must have been mistaken. Sorry.
I would have labeled these patches RESEND, but since I submitted v5 I learned that README files now go into the board/ directory, so I made that change and called it v6. Each patch contains its full changelog.
Sorry, it must have gone lost. I applied them and will push them shortly.
Best regards,
Marek Vasut