summaryrefslogtreecommitdiff
path: root/nuttx/configs/ea3131/tools/lpchdr.h
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2010-01-16 02:12:48 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2010-01-16 02:12:48 +0000
commitb7cd2ccf64a21dc25dfa2974182d4ebb3c6272f2 (patch)
tree1efde010f5c460561ed4a577b23c555783bf8960 /nuttx/configs/ea3131/tools/lpchdr.h
parent3d4c7fcadd7f3d1beabc6f5a1705ab2bb1b97f12 (diff)
downloadpx4-nuttx-b7cd2ccf64a21dc25dfa2974182d4ebb3c6272f2.tar.gz
px4-nuttx-b7cd2ccf64a21dc25dfa2974182d4ebb3c6272f2.tar.bz2
px4-nuttx-b7cd2ccf64a21dc25dfa2974182d4ebb3c6272f2.zip
Add CRC32 to lib/; add tool to make lpc313x bootloader images
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2506 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/configs/ea3131/tools/lpchdr.h')
-rwxr-xr-xnuttx/configs/ea3131/tools/lpchdr.h105
1 files changed, 105 insertions, 0 deletions
diff --git a/nuttx/configs/ea3131/tools/lpchdr.h b/nuttx/configs/ea3131/tools/lpchdr.h
new file mode 100755
index 000000000..036dc8728
--- /dev/null
+++ b/nuttx/configs/ea3131/tools/lpchdr.h
@@ -0,0 +1,105 @@
+/************************************************************************************
+ * configs/ea3131/tools/lpchdr.h
+ *
+ * Copyright (C) 2010 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ************************************************************************************/
+
+#ifndef __CONFIGS_EA3131_TOOLS_BINFMT_H
+#define __CONFIGS_EA3131_TOOLS_BINFMT_H
+
+/************************************************************************************
+ * Included Files
+ ************************************************************************************/
+
+#include <stdint.h>
+
+/************************************************************************************
+ * Definitions
+ ************************************************************************************/
+
+/************************************************************************************
+ * Public Types
+ ************************************************************************************/
+
+struct lpc313x_header_s
+{
+ /* OFFS DESCRIPTION */
+ uint32_t vector; /* 0x00 Valid ARM instruction. Usually this will be
+ * a branch instruction to entry point of the
+ * image. */
+ uint32_t magic; /* 0x04 This field is used by boot ROM to detect a
+ * valid image header. This field should always
+ * be set to 0x41676d69. */
+ uint32_t execution_crc32; /* 0x08 CRC32 value of execution part of the image. If
+ * the ‘image_type’ is set to ‘0xA’, this field
+ * is ignored by boot ROM. */
+ uint32_t Reserved0[4]; /* 0x0c-0x18: Should be zero. */
+ uint32_t imageType; /* 0x1c Specifies whether CRC check should be done
+ * on the image or not:
+ * 0xA – No CRC check required.
+ * 0xB – Do CRC32 check on both header and
+ * execution part of the image. */
+ uint32_t imageLength; /* 0x20 Total image length including header rounded
+ * up to the nearest 512 byte boundary. In C
+ * language the field can be computed as:
+ * imageLength = (Actual length + 511) & ~0x1FF; */
+ uint32_t releaseID; /* 0x24 Release or version number of the image. Note,
+ * this field is not used by boot ROM but is
+ * provided to track the image versions. */
+ uint32_t buildTime; /* 0x28 Time (expressed in EPOC time format) at which
+ * image is built. Note, this field is not used
+ * by boot ROM but is provided to track the image
+ * versions. */
+ uint32_t sbzBootParameter; /* 0x2c hould be zero. */
+ uint32_t cust_reserved[15]; /* 0x30-0x68: Reserved for customer use (60 bytes) */
+ uint32_t header_crc32; /* 0x6c CRC32 value of the header (bytes 0x00 to 0x6C
+ * of the image). If the ‘image_type’ is set
+ * to ‘0xA’, this field is ignored by boot ROM. */
+ uint32_t Reserved1[4]; /* 0x70-0x7c: Should be zero. */
+ /* 0x80 Start of program code (128Kb max). The final
+ * image has to be padded to the nearest 512
+ * byte boundary */
+};
+
+/************************************************************************************
+ * Public data
+ ************************************************************************************/
+
+/************************************************************************************
+ * Public Functions
+ ************************************************************************************/
+
+extern uint32_t crc32part(const uint8_t *src, size_t len, uint32_t crc32val);
+extern uint32_t crc32(const uint8_t *src, size_t len);
+
+#endif /* __CONFIGS_EA3131_TOOLS_BINFMT_H */
+